10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
53864Sraf * Common Development and Distribution License (the "License").
63864Sraf * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
211219Sraf
223864Sraf /*
23*6812Sraf * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
243864Sraf * Use is subject to license terms.
253864Sraf */
263864Sraf
270Sstevel@tonic-gate /* Copyright (c) 1988 AT&T */
280Sstevel@tonic-gate /* All Rights Reserved */
290Sstevel@tonic-gate
300Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
310Sstevel@tonic-gate
32*6812Sraf #pragma weak _des_crypt = des_crypt
33*6812Sraf #pragma weak _des_encrypt = des_encrypt
34*6812Sraf #pragma weak _des_setkey = des_setkey
350Sstevel@tonic-gate
360Sstevel@tonic-gate #include <sys/types.h>
370Sstevel@tonic-gate #include <crypt.h>
380Sstevel@tonic-gate #include "des_soft.h"
390Sstevel@tonic-gate
400Sstevel@tonic-gate #include <stdlib.h>
410Sstevel@tonic-gate #include <thread.h>
423864Sraf #include <pthread.h>
430Sstevel@tonic-gate #include <sys/types.h>
440Sstevel@tonic-gate
450Sstevel@tonic-gate /* EXPORT DELETE START */
460Sstevel@tonic-gate /*
470Sstevel@tonic-gate * This program implements the
480Sstevel@tonic-gate * Proposed Federal Information Processing
490Sstevel@tonic-gate * Data Encryption Standard.
500Sstevel@tonic-gate * See Federal Register, March 17, 1975 (40FR12134)
510Sstevel@tonic-gate */
520Sstevel@tonic-gate
530Sstevel@tonic-gate /*
540Sstevel@tonic-gate * Initial permutation,
550Sstevel@tonic-gate */
560Sstevel@tonic-gate static char IP[] = {
570Sstevel@tonic-gate 58, 50, 42, 34, 26, 18, 10, 2,
580Sstevel@tonic-gate 60, 52, 44, 36, 28, 20, 12, 4,
590Sstevel@tonic-gate 62, 54, 46, 38, 30, 22, 14, 6,
600Sstevel@tonic-gate 64, 56, 48, 40, 32, 24, 16, 8,
610Sstevel@tonic-gate 57, 49, 41, 33, 25, 17, 9, 1,
620Sstevel@tonic-gate 59, 51, 43, 35, 27, 19, 11, 3,
630Sstevel@tonic-gate 61, 53, 45, 37, 29, 21, 13, 5,
640Sstevel@tonic-gate 63, 55, 47, 39, 31, 23, 15, 7,
650Sstevel@tonic-gate };
660Sstevel@tonic-gate
670Sstevel@tonic-gate /*
680Sstevel@tonic-gate * Final permutation, FP = IP^(-1)
690Sstevel@tonic-gate */
700Sstevel@tonic-gate static char FP[] = {
710Sstevel@tonic-gate 40, 8, 48, 16, 56, 24, 64, 32,
720Sstevel@tonic-gate 39, 7, 47, 15, 55, 23, 63, 31,
730Sstevel@tonic-gate 38, 6, 46, 14, 54, 22, 62, 30,
740Sstevel@tonic-gate 37, 5, 45, 13, 53, 21, 61, 29,
750Sstevel@tonic-gate 36, 4, 44, 12, 52, 20, 60, 28,
760Sstevel@tonic-gate 35, 3, 43, 11, 51, 19, 59, 27,
770Sstevel@tonic-gate 34, 2, 42, 10, 50, 18, 58, 26,
780Sstevel@tonic-gate 33, 1, 41, 9, 49, 17, 57, 25,
790Sstevel@tonic-gate };
800Sstevel@tonic-gate
810Sstevel@tonic-gate /*
820Sstevel@tonic-gate * Permuted-choice 1 from the key bits
830Sstevel@tonic-gate * to yield C and D.
840Sstevel@tonic-gate * Note that bits 8, 16... are left out:
850Sstevel@tonic-gate * They are intended for a parity check.
860Sstevel@tonic-gate */
870Sstevel@tonic-gate static char PC1_C[] = {
880Sstevel@tonic-gate 57, 49, 41, 33, 25, 17, 9,
890Sstevel@tonic-gate 1, 58, 50, 42, 34, 26, 18,
900Sstevel@tonic-gate 10, 2, 59, 51, 43, 35, 27,
910Sstevel@tonic-gate 19, 11, 3, 60, 52, 44, 36,
920Sstevel@tonic-gate };
930Sstevel@tonic-gate
940Sstevel@tonic-gate static char PC1_D[] = {
950Sstevel@tonic-gate 63, 55, 47, 39, 31, 23, 15,
960Sstevel@tonic-gate 7, 62, 54, 46, 38, 30, 22,
970Sstevel@tonic-gate 14, 6, 61, 53, 45, 37, 29,
980Sstevel@tonic-gate 21, 13, 5, 28, 20, 12, 4,
990Sstevel@tonic-gate };
1000Sstevel@tonic-gate
1010Sstevel@tonic-gate /*
1020Sstevel@tonic-gate * Sequence of shifts used for the key schedule.
1030Sstevel@tonic-gate */
1040Sstevel@tonic-gate static char shifts[] = {1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1, };
1050Sstevel@tonic-gate
1060Sstevel@tonic-gate /*
1070Sstevel@tonic-gate * Permuted-choice 2, to pick out the bits from
1080Sstevel@tonic-gate * the CD array that generate the key schedule.
1090Sstevel@tonic-gate */
1100Sstevel@tonic-gate static char PC2_C[] = {
1110Sstevel@tonic-gate 14, 17, 11, 24, 1, 5,
1120Sstevel@tonic-gate 3, 28, 15, 6, 21, 10,
1130Sstevel@tonic-gate 23, 19, 12, 4, 26, 8,
1140Sstevel@tonic-gate 16, 7, 27, 20, 13, 2,
1150Sstevel@tonic-gate };
1160Sstevel@tonic-gate
1170Sstevel@tonic-gate static char PC2_D[] = {
1180Sstevel@tonic-gate 41, 52, 31, 37, 47, 55,
1190Sstevel@tonic-gate 30, 40, 51, 45, 33, 48,
1200Sstevel@tonic-gate 44, 49, 39, 56, 34, 53,
1210Sstevel@tonic-gate 46, 42, 50, 36, 29, 32,
1220Sstevel@tonic-gate };
1230Sstevel@tonic-gate
1240Sstevel@tonic-gate /*
1250Sstevel@tonic-gate * The C and D arrays used to calculate the key schedule.
1260Sstevel@tonic-gate */
1270Sstevel@tonic-gate
1280Sstevel@tonic-gate static char C[28];
1290Sstevel@tonic-gate static char D[28];
1300Sstevel@tonic-gate /*
1310Sstevel@tonic-gate * The key schedule.
1320Sstevel@tonic-gate * Generated from the key.
1330Sstevel@tonic-gate */
1340Sstevel@tonic-gate static char KS[16][48];
1350Sstevel@tonic-gate
1360Sstevel@tonic-gate /*
1370Sstevel@tonic-gate * The E bit-selection table.
1380Sstevel@tonic-gate */
1390Sstevel@tonic-gate static char E[48];
1400Sstevel@tonic-gate static char e2[] = {
1410Sstevel@tonic-gate 32, 1, 2, 3, 4, 5,
1420Sstevel@tonic-gate 4, 5, 6, 7, 8, 9,
1430Sstevel@tonic-gate 8, 9, 10, 11, 12, 13,
1440Sstevel@tonic-gate 12, 13, 14, 15, 16, 17,
1450Sstevel@tonic-gate 16, 17, 18, 19, 20, 21,
1460Sstevel@tonic-gate 20, 21, 22, 23, 24, 25,
1470Sstevel@tonic-gate 24, 25, 26, 27, 28, 29,
1480Sstevel@tonic-gate 28, 29, 30, 31, 32, 1,
1490Sstevel@tonic-gate };
1500Sstevel@tonic-gate
1510Sstevel@tonic-gate /*
1520Sstevel@tonic-gate * Set up the key schedule from the key.
1530Sstevel@tonic-gate */
1540Sstevel@tonic-gate
1550Sstevel@tonic-gate static mutex_t lock = DEFAULTMUTEX;
1560Sstevel@tonic-gate
1570Sstevel@tonic-gate /* EXPORT DELETE END */
1580Sstevel@tonic-gate
1590Sstevel@tonic-gate
1600Sstevel@tonic-gate static void
des_setkey_nolock(const char * key)1610Sstevel@tonic-gate des_setkey_nolock(const char *key)
1620Sstevel@tonic-gate {
1630Sstevel@tonic-gate /* EXPORT DELETE START */
1640Sstevel@tonic-gate int i, j, k;
1650Sstevel@tonic-gate char t;
1660Sstevel@tonic-gate
1670Sstevel@tonic-gate /*
1680Sstevel@tonic-gate * First, generate C and D by permuting
1690Sstevel@tonic-gate * the key. The low order bit of each
1700Sstevel@tonic-gate * 8-bit char is not used, so C and D are only 28
1710Sstevel@tonic-gate * bits apiece.
1720Sstevel@tonic-gate */
1730Sstevel@tonic-gate for (i = 0; i < 28; i++) {
1740Sstevel@tonic-gate C[i] = key[PC1_C[i]-1];
1750Sstevel@tonic-gate D[i] = key[PC1_D[i]-1];
1760Sstevel@tonic-gate }
1770Sstevel@tonic-gate /*
1780Sstevel@tonic-gate * To generate Ki, rotate C and D according
1790Sstevel@tonic-gate * to schedule and pick up a permutation
1800Sstevel@tonic-gate * using PC2.
1810Sstevel@tonic-gate */
1820Sstevel@tonic-gate for (i = 0; i < 16; i++) {
1830Sstevel@tonic-gate /*
1840Sstevel@tonic-gate * rotate.
1850Sstevel@tonic-gate */
1860Sstevel@tonic-gate for (k = 0; k < shifts[i]; k++) {
1870Sstevel@tonic-gate t = C[0];
1880Sstevel@tonic-gate for (j = 0; j < 28-1; j++)
1890Sstevel@tonic-gate C[j] = C[j+1];
1900Sstevel@tonic-gate C[27] = (char)t;
1910Sstevel@tonic-gate t = D[0];
1920Sstevel@tonic-gate for (j = 0; j < 28-1; j++)
1930Sstevel@tonic-gate D[j] = D[j+1];
1940Sstevel@tonic-gate D[27] = (char)t;
1950Sstevel@tonic-gate }
1960Sstevel@tonic-gate /*
1970Sstevel@tonic-gate * get Ki. Note C and D are concatenated.
1980Sstevel@tonic-gate */
1990Sstevel@tonic-gate for (j = 0; j < 24; j++) {
2000Sstevel@tonic-gate KS[i][j] = C[PC2_C[j]-1];
2010Sstevel@tonic-gate KS[i][j+24] = D[PC2_D[j]-28-1];
2020Sstevel@tonic-gate }
2030Sstevel@tonic-gate }
2040Sstevel@tonic-gate
2050Sstevel@tonic-gate for (i = 0; i < 48; i++)
2060Sstevel@tonic-gate E[i] = e2[i];
2070Sstevel@tonic-gate /* EXPORT DELETE END */
2080Sstevel@tonic-gate }
2090Sstevel@tonic-gate
2100Sstevel@tonic-gate void
des_setkey(const char * key)2110Sstevel@tonic-gate des_setkey(const char *key)
2120Sstevel@tonic-gate {
2130Sstevel@tonic-gate /* EXPORT DELETE START */
2140Sstevel@tonic-gate (void) mutex_lock(&lock);
2150Sstevel@tonic-gate des_setkey_nolock(key);
2160Sstevel@tonic-gate (void) mutex_unlock(&lock);
2170Sstevel@tonic-gate /* EXPORT DELETE END */
2180Sstevel@tonic-gate }
2190Sstevel@tonic-gate
2200Sstevel@tonic-gate /* EXPORT DELETE START */
2210Sstevel@tonic-gate /*
2220Sstevel@tonic-gate * The 8 selection functions.
2230Sstevel@tonic-gate * For some reason, they give a 0-origin
2240Sstevel@tonic-gate * index, unlike everything else.
2250Sstevel@tonic-gate */
2260Sstevel@tonic-gate static char S[8][64] = {
2270Sstevel@tonic-gate 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7,
2280Sstevel@tonic-gate 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8,
2290Sstevel@tonic-gate 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0,
2300Sstevel@tonic-gate 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13,
2310Sstevel@tonic-gate
2320Sstevel@tonic-gate 15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10,
2330Sstevel@tonic-gate 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5,
2340Sstevel@tonic-gate 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15,
2350Sstevel@tonic-gate 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9,
2360Sstevel@tonic-gate
2370Sstevel@tonic-gate 10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8,
2380Sstevel@tonic-gate 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1,
2390Sstevel@tonic-gate 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7,
2400Sstevel@tonic-gate 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12,
2410Sstevel@tonic-gate
2420Sstevel@tonic-gate 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15,
2430Sstevel@tonic-gate 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9,
2440Sstevel@tonic-gate 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4,
2450Sstevel@tonic-gate 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14,
2460Sstevel@tonic-gate
2470Sstevel@tonic-gate 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9,
2480Sstevel@tonic-gate 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6,
2490Sstevel@tonic-gate 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14,
2500Sstevel@tonic-gate 11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3,
2510Sstevel@tonic-gate
2520Sstevel@tonic-gate 12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11,
2530Sstevel@tonic-gate 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8,
2540Sstevel@tonic-gate 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6,
2550Sstevel@tonic-gate 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13,
2560Sstevel@tonic-gate
2570Sstevel@tonic-gate 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1,
2580Sstevel@tonic-gate 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6,
2590Sstevel@tonic-gate 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2,
2600Sstevel@tonic-gate 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12,
2610Sstevel@tonic-gate
2620Sstevel@tonic-gate 13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7,
2630Sstevel@tonic-gate 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2,
2640Sstevel@tonic-gate 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8,
2650Sstevel@tonic-gate 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11,
2660Sstevel@tonic-gate };
2670Sstevel@tonic-gate
2680Sstevel@tonic-gate /*
2690Sstevel@tonic-gate * P is a permutation on the selected combination
2700Sstevel@tonic-gate * of the current L and key.
2710Sstevel@tonic-gate */
2720Sstevel@tonic-gate static char P[] = {
2730Sstevel@tonic-gate 16, 7, 20, 21,
2740Sstevel@tonic-gate 29, 12, 28, 17,
2750Sstevel@tonic-gate 1, 15, 23, 26,
2760Sstevel@tonic-gate 5, 18, 31, 10,
2770Sstevel@tonic-gate 2, 8, 24, 14,
2780Sstevel@tonic-gate 32, 27, 3, 9,
2790Sstevel@tonic-gate 19, 13, 30, 6,
2800Sstevel@tonic-gate 22, 11, 4, 25,
2810Sstevel@tonic-gate };
2820Sstevel@tonic-gate
2830Sstevel@tonic-gate /*
2840Sstevel@tonic-gate * The current block, divided into 2 halves.
2850Sstevel@tonic-gate */
2860Sstevel@tonic-gate static char L[64];
2870Sstevel@tonic-gate static char tempL[32];
2880Sstevel@tonic-gate static char f[32];
2890Sstevel@tonic-gate
2900Sstevel@tonic-gate /*
2910Sstevel@tonic-gate * The combination of the key and the input, before selection.
2920Sstevel@tonic-gate */
2930Sstevel@tonic-gate static char preS[48];
2940Sstevel@tonic-gate
2950Sstevel@tonic-gate /*
2960Sstevel@tonic-gate * The payoff: encrypt a block.
2970Sstevel@tonic-gate */
2980Sstevel@tonic-gate /* EXPORT DELETE END */
2990Sstevel@tonic-gate
3000Sstevel@tonic-gate static void
des_encrypt_nolock(char * block,int edflag)3010Sstevel@tonic-gate des_encrypt_nolock(char *block, int edflag)
3020Sstevel@tonic-gate {
3030Sstevel@tonic-gate /* EXPORT DELETE START */
3040Sstevel@tonic-gate
3050Sstevel@tonic-gate if (edflag)
306*6812Sraf (void) _des_decrypt1(block, L, IP, &L[32],
3070Sstevel@tonic-gate preS, E, KS, S, f, tempL, P, FP);
3080Sstevel@tonic-gate else
3090Sstevel@tonic-gate (void) des_encrypt1(block, L, IP, &L[32],
3100Sstevel@tonic-gate preS, E, KS, S, f, tempL, P, FP);
3110Sstevel@tonic-gate
3120Sstevel@tonic-gate /* EXPORT DELETE END */
3130Sstevel@tonic-gate }
3140Sstevel@tonic-gate
3150Sstevel@tonic-gate void
des_encrypt(char * block,int edflag)3160Sstevel@tonic-gate des_encrypt(char *block, int edflag)
3170Sstevel@tonic-gate {
3180Sstevel@tonic-gate /* EXPORT DELETE START */
3190Sstevel@tonic-gate (void) mutex_lock(&lock);
3200Sstevel@tonic-gate des_encrypt_nolock(block, edflag);
3210Sstevel@tonic-gate (void) mutex_unlock(&lock);
3220Sstevel@tonic-gate /* EXPORT DELETE END */
3230Sstevel@tonic-gate }
3240Sstevel@tonic-gate
3250Sstevel@tonic-gate
3260Sstevel@tonic-gate
3270Sstevel@tonic-gate #define IOBUF_SIZE 16
3280Sstevel@tonic-gate
3290Sstevel@tonic-gate static char *
_get_iobuf(thread_key_t * keyp,unsigned size)3303864Sraf _get_iobuf(thread_key_t *keyp, unsigned size)
3310Sstevel@tonic-gate {
3323864Sraf char *iobuf;
3330Sstevel@tonic-gate
3343864Sraf if (thr_keycreate_once(keyp, free) != 0)
3353864Sraf return (NULL);
3363864Sraf iobuf = pthread_getspecific(*keyp);
3373864Sraf if (iobuf == NULL) {
3383864Sraf if (thr_setspecific(*keyp, (iobuf = malloc(size))) != 0) {
3390Sstevel@tonic-gate if (iobuf)
3400Sstevel@tonic-gate (void) free(iobuf);
3413864Sraf iobuf = NULL;
3420Sstevel@tonic-gate }
3430Sstevel@tonic-gate }
3440Sstevel@tonic-gate return (iobuf);
3450Sstevel@tonic-gate }
3460Sstevel@tonic-gate
3470Sstevel@tonic-gate char *
des_crypt(const char * pw,const char * salt)3480Sstevel@tonic-gate des_crypt(const char *pw, const char *salt)
3490Sstevel@tonic-gate {
3500Sstevel@tonic-gate /* EXPORT DELETE START */
3510Sstevel@tonic-gate int i, j;
3520Sstevel@tonic-gate char c, temp;
3533864Sraf char block[66];
3543864Sraf static thread_key_t key = THR_ONCE_KEY;
3553864Sraf char *iobuf = _get_iobuf(&key, IOBUF_SIZE);
3560Sstevel@tonic-gate
3570Sstevel@tonic-gate (void) mutex_lock(&lock);
3580Sstevel@tonic-gate for (i = 0; i < 66; i++)
3590Sstevel@tonic-gate block[i] = 0;
3600Sstevel@tonic-gate for (i = 0; (c = *pw) && (i < 64); pw++) {
3610Sstevel@tonic-gate for (j = 0; j < 7; j++, i++)
3620Sstevel@tonic-gate block[i] = (c>>(6-j)) & 01;
3630Sstevel@tonic-gate i++;
3640Sstevel@tonic-gate }
3650Sstevel@tonic-gate
3660Sstevel@tonic-gate des_setkey_nolock(block);
3670Sstevel@tonic-gate
3680Sstevel@tonic-gate for (i = 0; i < 66; i++)
3690Sstevel@tonic-gate block[i] = 0;
3700Sstevel@tonic-gate
3710Sstevel@tonic-gate for (i = 0; i < 2; i++) {
3720Sstevel@tonic-gate c = *salt++;
3730Sstevel@tonic-gate iobuf[i] = (char)c;
3740Sstevel@tonic-gate if (c > 'Z')
3750Sstevel@tonic-gate c -= 6;
3760Sstevel@tonic-gate if (c > '9')
3770Sstevel@tonic-gate c -= 7;
3780Sstevel@tonic-gate c -= '.';
3790Sstevel@tonic-gate for (j = 0; j < 6; j++) {
3800Sstevel@tonic-gate if ((c>>j) & 01) {
3810Sstevel@tonic-gate temp = E[6*i+j];
3820Sstevel@tonic-gate E[6*i+j] = E[6*i+j+24];
3830Sstevel@tonic-gate E[6*i+j+24] = (char)temp;
3840Sstevel@tonic-gate }
3850Sstevel@tonic-gate }
3860Sstevel@tonic-gate }
3870Sstevel@tonic-gate
3880Sstevel@tonic-gate for (i = 0; i < 25; i++)
3890Sstevel@tonic-gate (void) des_encrypt_nolock(block, 0);
3900Sstevel@tonic-gate
3910Sstevel@tonic-gate for (i = 0; i < 11; i++) {
3920Sstevel@tonic-gate c = 0;
3930Sstevel@tonic-gate for (j = 0; j < 6; j++) {
3940Sstevel@tonic-gate c <<= 1;
3950Sstevel@tonic-gate c |= block[6*i+j];
3960Sstevel@tonic-gate }
3970Sstevel@tonic-gate c += '.';
3980Sstevel@tonic-gate if (c > '9')
3990Sstevel@tonic-gate c += 7;
4000Sstevel@tonic-gate if (c > 'Z')
4010Sstevel@tonic-gate c += 6;
4020Sstevel@tonic-gate iobuf[i+2] = (char)c;
4030Sstevel@tonic-gate }
4040Sstevel@tonic-gate iobuf[i+2] = 0;
4050Sstevel@tonic-gate if (iobuf[1] == 0)
4060Sstevel@tonic-gate iobuf[1] = iobuf[0];
4070Sstevel@tonic-gate (void) mutex_unlock(&lock);
4080Sstevel@tonic-gate return (iobuf);
4090Sstevel@tonic-gate #if 0
4100Sstevel@tonic-gate /* EXPORT DELETE END */
4110Sstevel@tonic-gate return (0);
4120Sstevel@tonic-gate /* EXPORT DELETE START */
4130Sstevel@tonic-gate #endif
4140Sstevel@tonic-gate /* EXPORT DELETE END */
4150Sstevel@tonic-gate }
416