mux/src/crypt/crypt.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  crypt_data

Defines

#define _CRYPT_H   1

Functions

char * crypt (const char *__key, const char *__salt)
void setkey (const char *__key)
void encrypt (char *__block, int __edflag)
char * __crypt_r (const char *__key, const char *__salt, struct crypt_data *__data)
char * crypt_r (const char *__key, const char *__salt, struct crypt_data *__data)
void __setkey_r (const char *__key, struct crypt_data *__data)
void setkey_r (const char *__key, struct crypt_data *__data)
void __encrypt_r (char *__block, int __edflag, struct crypt_data *__data)
void encrypt_r (char *__block, int __edflag, struct crypt_data *__data)


Define Documentation

#define _CRYPT_H   1

Definition at line 26 of file crypt.h.


Function Documentation

char* __crypt_r ( const char *  __key,
const char *  __salt,
struct crypt_data __data 
)

void __encrypt_r ( char *  __block,
int  __edflag,
struct crypt_data __data 
)

Definition at line 733 of file crypt_util.cpp.

References _ufc_dofinalperm_r(), _ufc_doit_r(), _ufc_setup_salt_r(), BITMASK, crypt_data::direction, esel, initial_perm, crypt_data::keysched, and longmask.

Referenced by encrypt().

00734 {
00735   ufc_long l1, l2, r1, r2, res[4];
00736   int i;
00737 #ifdef _UFC_32_
00738   long32 *kt;
00739   kt = (long32*)__data->keysched;
00740 #endif
00741 #ifdef _UFC_64_
00742   long64 *kt;
00743   kt = (long64*)__data->keysched;
00744 #endif
00745 
00746   /*
00747    * Undo any salt changes to E expansion
00748    */
00749   _ufc_setup_salt_r("..", __data);
00750 
00751   /*
00752    * Reverse key table if
00753    * changing operation (encrypt/decrypt)
00754    */
00755   if((__edflag == 0) != (__data->direction == 0)) {
00756     for(i = 0; i < 8; i++) {
00757 #ifdef _UFC_32_
00758       long32 x;
00759       x = kt[2 * (15-i)];
00760       kt[2 * (15-i)] = kt[2 * i];
00761       kt[2 * i] = x;
00762 
00763       x = kt[2 * (15-i) + 1];
00764       kt[2 * (15-i) + 1] = kt[2 * i + 1];
00765       kt[2 * i + 1] = x;
00766 #endif
00767 #ifdef _UFC_64_
00768       long64 x;
00769       x = kt[15-i];
00770       kt[15-i] = kt[i];
00771       kt[i] = x;
00772 #endif
00773       }
00774     __data->direction = __edflag;
00775   }
00776 
00777   /*
00778    * Do initial permutation + E expansion
00779    */
00780   i = 0;
00781   for(l1 = 0; i < 24; i++) {
00782     if(__block[initial_perm[esel[i]-1]-1])
00783       l1 |= BITMASK[i];
00784   }
00785   for(l2 = 0; i < 48; i++) {
00786     if(__block[initial_perm[esel[i]-1]-1])
00787       l2 |= BITMASK[i-24];
00788   }
00789 
00790   i = 0;
00791   for(r1 = 0; i < 24; i++) {
00792     if(__block[initial_perm[esel[i]-1+32]-1])
00793       r1 |= BITMASK[i];
00794   }
00795   for(r2 = 0; i < 48; i++) {
00796     if(__block[initial_perm[esel[i]-1+32]-1])
00797       r2 |= BITMASK[i-24];
00798   }
00799 
00800   /*
00801    * Do DES inner loops + final conversion
00802    */
00803   res[0] = l1; res[1] = l2;
00804   res[2] = r1; res[3] = r2;
00805   _ufc_doit_r((ufc_long)1, __data, &res[0]);
00806 
00807   /*
00808    * Do final permutations
00809    */
00810   _ufc_dofinalperm_r(res, __data);
00811 
00812   /*
00813    * And convert to bit array
00814    */
00815   l1 = res[0]; r1 = res[1];
00816   for(i = 0; i < 32; i++) {
00817     *__block++ = (l1 & longmask[i]) != 0;
00818   }
00819   for(i = 0; i < 32; i++) {
00820     *__block++ = (r1 & longmask[i]) != 0;
00821   }
00822 }

void __setkey_r ( const char *  __key,
struct crypt_data __data 
)

Definition at line 837 of file crypt_util.cpp.

References _ufc_mk_keytab_r(), and _ufc_setup_salt_r().

Referenced by setkey().

00838 {
00839   int i,j;
00840   unsigned char c;
00841   unsigned char ktab[8];
00842 
00843   _ufc_setup_salt_r("..", __data); /* be sure we're initialized */
00844 
00845   for(i = 0; i < 8; i++) {
00846     for(j = 0, c = 0; j < 8; j++)
00847       c = c << 1 | *__key++;
00848     ktab[i] = c >> 1;
00849   }
00850   _ufc_mk_keytab_r((char *)ktab, __data);
00851 }

char* crypt ( const char *  __key,
const char *  __salt 
)

Definition at line 118 of file crypt-entry.cpp.

00119 {
00120 #ifdef _LIBC
00121   /* Try to find out whether we have to use MD5 encryption replacement.  */
00122   if (strncmp (md5_salt_prefix, salt, sizeof (md5_salt_prefix) - 1) == 0)
00123     return __md5_crypt (key, salt);
00124 #endif
00125 
00126   return crypt_r (key, salt, &_ufc_foobar);
00127 }

char* crypt_r ( const char *  __key,
const char *  __salt,
struct crypt_data __data 
)

Definition at line 74 of file crypt-entry.cpp.

References __md5_crypt_r(), _ufc_dofinalperm_r(), _ufc_doit_r(), _ufc_mk_keytab_r(), _ufc_output_conversion_r(), _ufc_setup_salt_r(), and md5_salt_prefix.

Referenced by crypt().

00075 {
00076   ufc_long res[4];
00077   char ktab[9];
00078   ufc_long xx = 25; /* to cope with GCC long long compiler bugs */
00079 
00080 #ifdef _LIBC
00081   /* Try to find out whether we have to use MD5 encryption replacement.  */
00082   if (strncmp (md5_salt_prefix, salt, sizeof (md5_salt_prefix) - 1) == 0)
00083     return __md5_crypt_r (key, salt, (char *) data,
00084               sizeof (struct crypt_data));
00085 #endif
00086 
00087   /*
00088    * Hack DES tables according to salt
00089    */
00090   _ufc_setup_salt_r (salt, data);
00091 
00092   /*
00093    * Setup key schedule
00094    */
00095   memset(ktab, 0, sizeof(ktab));
00096   strncpy (ktab, key, 8);
00097   _ufc_mk_keytab_r (ktab, data);
00098 
00099   /*
00100    * Go for the 25 DES encryptions
00101    */
00102   memset(res, 0, sizeof (res));
00103   _ufc_doit_r (xx,  data, &res[0]);
00104 
00105   /*
00106    * Do final permutations
00107    */
00108   _ufc_dofinalperm_r (res, data);
00109 
00110   /*
00111    * And convert back to 6 bit ASCII
00112    */
00113   _ufc_output_conversion_r (res[0], res[1], salt, data);
00114   return data->crypt_3_buf;
00115 }

void encrypt ( char *  __block,
int  __edflag 
)

Definition at line 825 of file crypt_util.cpp.

References __encrypt_r(), and _ufc_foobar.

00826 {
00827   __encrypt_r(__block, __edflag, &_ufc_foobar);
00828 }

void encrypt_r ( char *  __block,
int  __edflag,
struct crypt_data __data 
)

void setkey ( const char *  __key  ) 

Definition at line 853 of file crypt_util.cpp.

References __setkey_r(), and _ufc_foobar.

00854 {
00855   __setkey_r(__key, &_ufc_foobar);
00856 }

void setkey_r ( const char *  __key,
struct crypt_data __data 
)


Generated on Mon May 28 04:40:14 2007 for MUX by  doxygen 1.4.7