mux/src/crypt/crypt_util.cpp File Reference

#include <string.h>
#include "patchlevel.h"
#include "ufc-crypt.h"
#include "crypt.h"
#include "crypt-private.h"

Include dependency graph for crypt_util.cpp:

Go to the source code of this file.

Defines

#define STATIC   static
#define ascii_to_bin(c)   ((c)>='a'?(c-59):(c)>='A'?((c)-53):(c)-'.')
#define bin_to_ascii(c)   (char)((c)>=38?((c)-38+'a'):(c)>=12?((c)-12+'A'):(c)+'.')
#define s_lookup(i, s)   sbox[(i)][(((s)>>4) & 0x2)|((s) & 0x1)][((s)>>1) & 0xf];
#define LONGG   long32*

Functions

STATIC void shuffle_sb (long32 *k, ufc_long saltbits)
void __init_des_r (struct crypt_data *__data)
void __init_des ()
void _ufc_setup_salt_r (const char *s, struct crypt_data *__data)
void _ufc_mk_keytab_r (char *key, struct crypt_data *__data)
void _ufc_dofinalperm_r (ufc_long *res, struct crypt_data *__data)
void _ufc_output_conversion_r (ufc_long v1, ufc_long v2, const char *salt, struct crypt_data *__data)
void __encrypt_r (char *__block, int __edflag, struct crypt_data *__data)
void encrypt (char *__block, int __edflag)
void __setkey_r (const char *__key, struct crypt_data *__data)
void setkey (const char *__key)

Variables

static const char patchlevel_str [] = PATCHLEVEL
static const int pc1 [56]
static const int rots [16]
static const int pc2 [48]
static const int esel [48]
static const int perm32 [32]
static const int sbox [8][4][16]
static const int initial_perm [64]
static const int final_perm [64]
static const ufc_long BITMASK [24]
static const unsigned char bytemask [8]
static const ufc_long longmask [32]
static ufc_long do_pc1 [8][2][128]
static ufc_long do_pc2 [8][128]
static ufc_long eperm32tab [4][256][2]
static ufc_long efp [16][64][2]
crypt_data _ufc_foobar


Define Documentation

#define ascii_to_bin (  )     ((c)>='a'?(c-59):(c)>='A'?((c)-53):(c)-'.')

Definition at line 185 of file crypt_util.cpp.

Referenced by _ufc_setup_salt_r().

#define bin_to_ascii (  )     (char)((c)>=38?((c)-38+'a'):(c)>=12?((c)-12+'A'):(c)+'.')

Definition at line 186 of file crypt_util.cpp.

Referenced by _ufc_output_conversion_r().

#define LONGG   long32*

Referenced by _ufc_setup_salt_r().

#define s_lookup ( i,
 )     sbox[(i)][(((s)>>4) & 0x2)|((s) & 0x1)][((s)>>1) & 0xf];

Definition at line 304 of file crypt_util.cpp.

Referenced by __init_des_r().

#define STATIC   static

Definition at line 33 of file crypt_util.cpp.


Function Documentation

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 __init_des ( void   ) 

Definition at line 510 of file crypt_util.cpp.

References __init_des_r(), and _ufc_foobar.

00511 {
00512   __init_des_r(&_ufc_foobar);
00513 }

void __init_des_r ( struct crypt_data __data  ) 

Definition at line 312 of file crypt_util.cpp.

References BITMASK, bytemask, do_pc1, do_pc2, efp, eperm32tab, esel, final_perm, crypt_data::initialized, longmask, pc1, pc2, perm32, s_lookup, crypt_data::sb0, crypt_data::sb1, crypt_data::sb2, and crypt_data::sb3.

Referenced by __init_des(), and _ufc_setup_salt_r().

00313 {
00314   int comes_from_bit;
00315   int bit, sg;
00316   ufc_long j;
00317   ufc_long mask1, mask2;
00318   int e_inverse[64];
00319   static volatile int small_tables_initialized = 0;
00320 
00321 #ifdef _UFC_32_
00322   long32 *sb[4];
00323   sb[0] = (long32*)__data->sb0; sb[1] = (long32*)__data->sb1;
00324   sb[2] = (long32*)__data->sb2; sb[3] = (long32*)__data->sb3;
00325 #endif
00326 #ifdef _UFC_64_
00327   long64 *sb[4];
00328   sb[0] = (long64*)__data->sb0; sb[1] = (long64*)__data->sb1;
00329   sb[2] = (long64*)__data->sb2; sb[3] = (long64*)__data->sb3;
00330 #endif
00331 
00332   if(small_tables_initialized == 0) {
00333 #ifdef __GNU_LIBRARY__
00334     __libc_lock_lock (_ufc_tables_lock);
00335     if(small_tables_initialized)
00336       goto small_tables_done;
00337 #endif
00338 
00339     /*
00340      * Create the do_pc1 table used
00341      * to affect pc1 permutation
00342      * when generating keys
00343      */
00344     memset(do_pc1, 0, sizeof(do_pc1));
00345     for(bit = 0; bit < 56; bit++) {
00346       comes_from_bit  = pc1[bit] - 1;
00347       mask1 = bytemask[comes_from_bit % 8 + 1];
00348       mask2 = longmask[bit % 28 + 4];
00349       for(j = 0; j < 128; j++) {
00350     if(j & mask1)
00351       do_pc1[comes_from_bit / 8][bit / 28][j] |= mask2;
00352       }
00353     }
00354 
00355     /*
00356      * Create the do_pc2 table used
00357      * to affect pc2 permutation when
00358      * generating keys
00359      */
00360     memset(do_pc2, 0, sizeof(do_pc2));
00361     for(bit = 0; bit < 48; bit++) {
00362       comes_from_bit  = pc2[bit] - 1;
00363       mask1 = bytemask[comes_from_bit % 7 + 1];
00364       mask2 = BITMASK[bit % 24];
00365       for(j = 0; j < 128; j++) {
00366     if(j & mask1)
00367       do_pc2[comes_from_bit / 7][j] |= mask2;
00368       }
00369     }
00370 
00371     /*
00372      * Now generate the table used to do combined
00373      * 32 bit permutation and e expansion
00374      *
00375      * We use it because we have to permute 16384 32 bit
00376      * longs into 48 bit in order to initialize sb.
00377      *
00378      * Looping 48 rounds per permutation becomes
00379      * just too slow...
00380      *
00381      */
00382 
00383     memset(eperm32tab, 0, sizeof(eperm32tab));
00384     for(bit = 0; bit < 48; bit++) {
00385       ufc_long mask1,comes_from;
00386       comes_from = perm32[esel[bit]-1]-1;
00387       mask1      = bytemask[comes_from % 8];
00388       for(j = 256; j--;) {
00389     if(j & mask1)
00390       eperm32tab[comes_from / 8][j][bit / 24] |= BITMASK[bit % 24];
00391       }
00392     }
00393 
00394     /*
00395      * Create an inverse matrix for esel telling
00396      * where to plug out bits if undoing it
00397      */
00398     for(bit=48; bit--;) {
00399       e_inverse[esel[bit] - 1     ] = bit;
00400       e_inverse[esel[bit] - 1 + 32] = bit + 48;
00401     }
00402 
00403     /*
00404      * create efp: the matrix used to
00405      * undo the E expansion and effect final permutation
00406      */
00407     memset(efp, 0, sizeof efp);
00408     for(bit = 0; bit < 64; bit++) {
00409       int o_bit, o_long;
00410       ufc_long word_value, mask1, mask2;
00411       int comes_from_f_bit, comes_from_e_bit;
00412       int comes_from_word, bit_within_word;
00413 
00414       /* See where bit i belongs in the two 32 bit long's */
00415       o_long = bit / 32; /* 0..1  */
00416       o_bit  = bit % 32; /* 0..31 */
00417 
00418       /*
00419        * And find a bit in the e permutated value setting this bit.
00420        *
00421        * Note: the e selection may have selected the same bit several
00422        * times. By the initialization of e_inverse, we only look
00423        * for one specific instance.
00424        */
00425       comes_from_f_bit = final_perm[bit] - 1;         /* 0..63 */
00426       comes_from_e_bit = e_inverse[comes_from_f_bit]; /* 0..95 */
00427       comes_from_word  = comes_from_e_bit / 6;        /* 0..15 */
00428       bit_within_word  = comes_from_e_bit % 6;        /* 0..5  */
00429 
00430       mask1 = longmask[bit_within_word + 26];
00431       mask2 = longmask[o_bit];
00432 
00433       for(word_value = 64; word_value--;) {
00434     if(word_value & mask1)
00435       efp[comes_from_word][word_value][o_long] |= mask2;
00436       }
00437     }
00438     small_tables_initialized = 1;
00439 #ifdef __GNU_LIBRARY__
00440 small_tables_done:
00441     __libc_lock_unlock(_ufc_tables_lock);
00442 #endif
00443   }
00444 
00445   /*
00446    * Create the sb tables:
00447    *
00448    * For each 12 bit segment of an 48 bit intermediate
00449    * result, the sb table precomputes the two 4 bit
00450    * values of the sbox lookups done with the two 6
00451    * bit halves, shifts them to their proper place,
00452    * sends them through perm32 and finally E expands
00453    * them so that they are ready for the next
00454    * DES round.
00455    *
00456    */
00457 
00458   memset(__data->sb0, 0, sizeof(__data->sb0));
00459   memset(__data->sb1, 0, sizeof(__data->sb1));
00460   memset(__data->sb2, 0, sizeof(__data->sb2));
00461   memset(__data->sb3, 0, sizeof(__data->sb3));
00462 
00463   for(sg = 0; sg < 4; sg++) {
00464     int j1, j2;
00465     int s1, s2;
00466 
00467     for(j1 = 0; j1 < 64; j1++) {
00468       s1 = s_lookup(2 * sg, j1);
00469       for(j2 = 0; j2 < 64; j2++) {
00470     ufc_long to_permute, inx;
00471 
00472     s2         = s_lookup(2 * sg + 1, j2);
00473     to_permute = (((ufc_long)s1 << 4)  |
00474               (ufc_long)s2) << (24 - 8 * (ufc_long)sg);
00475 
00476 #ifdef _UFC_32_
00477     inx = ((j1 << 6)  | j2) << 1;
00478     sb[sg][inx  ]  = eperm32tab[0][(to_permute >> 24) & 0xff][0];
00479     sb[sg][inx+1]  = eperm32tab[0][(to_permute >> 24) & 0xff][1];
00480     sb[sg][inx  ] |= eperm32tab[1][(to_permute >> 16) & 0xff][0];
00481     sb[sg][inx+1] |= eperm32tab[1][(to_permute >> 16) & 0xff][1];
00482     sb[sg][inx  ] |= eperm32tab[2][(to_permute >>  8) & 0xff][0];
00483     sb[sg][inx+1] |= eperm32tab[2][(to_permute >>  8) & 0xff][1];
00484     sb[sg][inx  ] |= eperm32tab[3][(to_permute)       & 0xff][0];
00485     sb[sg][inx+1] |= eperm32tab[3][(to_permute)       & 0xff][1];
00486 #endif
00487 #ifdef _UFC_64_
00488     inx = ((j1 << 6)  | j2);
00489     sb[sg][inx]  =
00490       ((long64)eperm32tab[0][(to_permute >> 24) & 0xff][0] << 32) |
00491        (long64)eperm32tab[0][(to_permute >> 24) & 0xff][1];
00492     sb[sg][inx] |=
00493       ((long64)eperm32tab[1][(to_permute >> 16) & 0xff][0] << 32) |
00494        (long64)eperm32tab[1][(to_permute >> 16) & 0xff][1];
00495     sb[sg][inx] |=
00496       ((long64)eperm32tab[2][(to_permute >>  8) & 0xff][0] << 32) |
00497        (long64)eperm32tab[2][(to_permute >>  8) & 0xff][1];
00498     sb[sg][inx] |=
00499       ((long64)eperm32tab[3][(to_permute)       & 0xff][0] << 32) |
00500        (long64)eperm32tab[3][(to_permute)       & 0xff][1];
00501 #endif
00502       }
00503     }
00504   }
00505 
00506   __data->initialized++;
00507 }

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 }

void _ufc_dofinalperm_r ( ufc_long res,
struct crypt_data __data 
)

Definition at line 659 of file crypt_util.cpp.

References crypt_data::current_saltbits, and efp.

00660 {
00661   ufc_long v1, v2, x;
00662   ufc_long l1,l2,r1,r2;
00663 
00664   l1 = res[0]; l2 = res[1];
00665   r1 = res[2]; r2 = res[3];
00666 
00667   x = (l1 ^ l2) & __data->current_saltbits; l1 ^= x; l2 ^= x;
00668   x = (r1 ^ r2) & __data->current_saltbits; r1 ^= x; r2 ^= x;
00669 
00670   v1=v2=0; l1 >>= 3; l2 >>= 3; r1 >>= 3; r2 >>= 3;
00671 
00672   v1 |= efp[15][ r2         & 0x3f][0]; v2 |= efp[15][ r2 & 0x3f][1];
00673   v1 |= efp[14][(r2 >>= 6)  & 0x3f][0]; v2 |= efp[14][ r2 & 0x3f][1];
00674   v1 |= efp[13][(r2 >>= 10) & 0x3f][0]; v2 |= efp[13][ r2 & 0x3f][1];
00675   v1 |= efp[12][(r2 >>= 6)  & 0x3f][0]; v2 |= efp[12][ r2 & 0x3f][1];
00676 
00677   v1 |= efp[11][ r1         & 0x3f][0]; v2 |= efp[11][ r1 & 0x3f][1];
00678   v1 |= efp[10][(r1 >>= 6)  & 0x3f][0]; v2 |= efp[10][ r1 & 0x3f][1];
00679   v1 |= efp[ 9][(r1 >>= 10) & 0x3f][0]; v2 |= efp[ 9][ r1 & 0x3f][1];
00680   v1 |= efp[ 8][(r1 >>= 6)  & 0x3f][0]; v2 |= efp[ 8][ r1 & 0x3f][1];
00681 
00682   v1 |= efp[ 7][ l2         & 0x3f][0]; v2 |= efp[ 7][ l2 & 0x3f][1];
00683   v1 |= efp[ 6][(l2 >>= 6)  & 0x3f][0]; v2 |= efp[ 6][ l2 & 0x3f][1];
00684   v1 |= efp[ 5][(l2 >>= 10) & 0x3f][0]; v2 |= efp[ 5][ l2 & 0x3f][1];
00685   v1 |= efp[ 4][(l2 >>= 6)  & 0x3f][0]; v2 |= efp[ 4][ l2 & 0x3f][1];
00686 
00687   v1 |= efp[ 3][ l1         & 0x3f][0]; v2 |= efp[ 3][ l1 & 0x3f][1];
00688   v1 |= efp[ 2][(l1 >>= 6)  & 0x3f][0]; v2 |= efp[ 2][ l1 & 0x3f][1];
00689   v1 |= efp[ 1][(l1 >>= 10) & 0x3f][0]; v2 |= efp[ 1][ l1 & 0x3f][1];
00690   v1 |= efp[ 0][(l1 >>= 6)  & 0x3f][0]; v2 |= efp[ 0][ l1 & 0x3f][1];
00691 
00692   res[0] = v1; res[1] = v2;
00693 }

void _ufc_mk_keytab_r ( char *  key,
struct crypt_data __data 
)

Definition at line 601 of file crypt_util.cpp.

References crypt_data::direction, do_pc1, do_pc2, crypt_data::keysched, and rots.

00602 {
00603   ufc_long v1, v2, *k1;
00604   int i;
00605 #ifdef _UFC_32_
00606   long32 v, *k2;
00607   k2 = (long32*)__data->keysched;
00608 #endif
00609 #ifdef _UFC_64_
00610   long64 v, *k2;
00611   k2 = (long64*)__data->keysched;
00612 #endif
00613 
00614   v1 = v2 = 0; k1 = &do_pc1[0][0][0];
00615   for(i = 8; i--;) {
00616     v1 |= k1[*key   & 0x7f]; k1 += 128;
00617     v2 |= k1[*key++ & 0x7f]; k1 += 128;
00618   }
00619 
00620   for(i = 0; i < 16; i++) {
00621     k1 = &do_pc2[0][0];
00622 
00623     v1 = (v1 << rots[i]) | (v1 >> (28 - rots[i]));
00624     v  = k1[(v1 >> 21) & 0x7f]; k1 += 128;
00625     v |= k1[(v1 >> 14) & 0x7f]; k1 += 128;
00626     v |= k1[(v1 >>  7) & 0x7f]; k1 += 128;
00627     v |= k1[(v1      ) & 0x7f]; k1 += 128;
00628 
00629 #ifdef _UFC_32_
00630     *k2++ = (v | 0x00008000);
00631     v = 0;
00632 #endif
00633 #ifdef _UFC_64_
00634     v = (v << 32);
00635 #endif
00636 
00637     v2 = (v2 << rots[i]) | (v2 >> (28 - rots[i]));
00638     v |= k1[(v2 >> 21) & 0x7f]; k1 += 128;
00639     v |= k1[(v2 >> 14) & 0x7f]; k1 += 128;
00640     v |= k1[(v2 >>  7) & 0x7f]; k1 += 128;
00641     v |= k1[(v2      ) & 0x7f];
00642 
00643 #ifdef _UFC_32_
00644     *k2++ = (v | 0x00008000);
00645 #endif
00646 #ifdef _UFC_64_
00647     *k2++ = v | 0x0000800000008000l;
00648 #endif
00649   }
00650 
00651   __data->direction = 0;
00652 }

void _ufc_output_conversion_r ( ufc_long  v1,
ufc_long  v2,
const char *  salt,
struct crypt_data __data 
)

Definition at line 701 of file crypt_util.cpp.

References bin_to_ascii, and crypt_data::crypt_3_buf.

00702 {
00703   int i, s, shf;
00704 
00705   __data->crypt_3_buf[0] = salt[0];
00706   __data->crypt_3_buf[1] = salt[1] ? salt[1] : salt[0];
00707 
00708   for(i = 0; i < 5; i++) {
00709     shf = (26 - 6 * i); /* to cope with MSC compiler bug */
00710     __data->crypt_3_buf[i + 2] = bin_to_ascii((v1 >> shf) & 0x3f);
00711   }
00712 
00713   s  = (v2 & 0xf) << 2;
00714   v2 = (v2 >> 2) | ((v1 & 0x3) << 30);
00715 
00716   for(i = 5; i < 10; i++) {
00717     shf = (56 - 6 * i);
00718     __data->crypt_3_buf[i + 2] = bin_to_ascii((v2 >> shf) & 0x3f);
00719   }
00720 
00721   __data->crypt_3_buf[12] = bin_to_ascii(s);
00722   __data->crypt_3_buf[13] = 0;
00723 }

void _ufc_setup_salt_r ( const char *  s,
struct crypt_data __data 
)

Definition at line 555 of file crypt_util.cpp.

References __init_des_r(), ascii_to_bin, BITMASK, crypt_data::current_salt, crypt_data::current_saltbits, crypt_data::initialized, LONGG, crypt_data::sb0, crypt_data::sb1, crypt_data::sb2, crypt_data::sb3, and shuffle_sb().

00556 {
00557   ufc_long i, j, saltbits;
00558 
00559   if(__data->initialized == 0)
00560     __init_des_r(__data);
00561 
00562   if(s[0] == __data->current_salt[0] && s[1] == __data->current_salt[1])
00563     return;
00564   __data->current_salt[0] = s[0]; __data->current_salt[1] = s[1];
00565 
00566   /*
00567    * This is the only crypt change to DES:
00568    * entries are swapped in the expansion table
00569    * according to the bits set in the salt.
00570    */
00571   saltbits = 0;
00572   for(i = 0; i < 2; i++) {
00573     long c=ascii_to_bin(s[i]);
00574     for(j = 0; j < 6; j++) {
00575       if((c >> j) & 0x1)
00576     saltbits |= BITMASK[6 * i + j];
00577     }
00578   }
00579 
00580   /*
00581    * Permute the sb table values
00582    * to reflect the changed e
00583    * selection table
00584    */
00585 #ifdef _UFC_32_
00586 #define LONGG long32*
00587 #endif
00588 #ifdef _UFC_64_
00589 #define LONGG long64*
00590 #endif
00591 
00592   shuffle_sb((LONGG)__data->sb0, __data->current_saltbits ^ saltbits);
00593   shuffle_sb((LONGG)__data->sb1, __data->current_saltbits ^ saltbits);
00594   shuffle_sb((LONGG)__data->sb2, __data->current_saltbits ^ saltbits);
00595   shuffle_sb((LONGG)__data->sb3, __data->current_saltbits ^ saltbits);
00596 
00597   __data->current_saltbits = saltbits;
00598 }

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 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 }

STATIC void shuffle_sb ( long32 k,
ufc_long  saltbits 
)

Definition at line 522 of file crypt_util.cpp.

Referenced by _ufc_setup_salt_r().

00523 {
00524   ufc_long j;
00525   long32 x;
00526   for(j=4096; j--;) {
00527     x = (k[0] ^ k[1]) & (long32)saltbits;
00528     *k++ ^= x;
00529     *k++ ^= x;
00530   }
00531 }


Variable Documentation

struct crypt_data _ufc_foobar

Definition at line 259 of file crypt_util.cpp.

Referenced by __init_des(), crypt(), encrypt(), and setkey().

const ufc_long BITMASK[24] [static]

Initial value:

 {
  0x40000000, 0x20000000, 0x10000000, 0x08000000, 0x04000000, 0x02000000,
  0x01000000, 0x00800000, 0x00400000, 0x00200000, 0x00100000, 0x00080000,
  0x00004000, 0x00002000, 0x00001000, 0x00000800, 0x00000400, 0x00000200,
  0x00000100, 0x00000080, 0x00000040, 0x00000020, 0x00000010, 0x00000008
}

Definition at line 188 of file crypt_util.cpp.

Referenced by __encrypt_r(), __init_des_r(), and _ufc_setup_salt_r().

const unsigned char bytemask[8] [static]

Initial value:

 {
  0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01
}

Definition at line 195 of file crypt_util.cpp.

Referenced by __init_des_r().

ufc_long do_pc1[8][2][128] [static]

Definition at line 220 of file crypt_util.cpp.

Referenced by __init_des_r(), and _ufc_mk_keytab_r().

ufc_long do_pc2[8][128] [static]

Definition at line 233 of file crypt_util.cpp.

Referenced by __init_des_r(), and _ufc_mk_keytab_r().

ufc_long efp[16][64][2] [static]

Definition at line 253 of file crypt_util.cpp.

Referenced by __init_des_r(), and _ufc_dofinalperm_r().

ufc_long eperm32tab[4][256][2] [static]

Definition at line 244 of file crypt_util.cpp.

Referenced by __init_des_r().

const int esel[48] [static]

Initial value:

 {
  32,  1,  2,  3,  4,  5,  4,  5,  6,  7,  8,  9,
   8,  9, 10, 11, 12, 13, 12, 13, 14, 15, 16, 17,
  16, 17, 18, 19, 20, 21, 20, 21, 22, 23, 24, 25,
  24, 25, 26, 27, 28, 29, 28, 29, 30, 31, 32,  1
}

Definition at line 94 of file crypt_util.cpp.

Referenced by __encrypt_r(), and __init_des_r().

const int final_perm[64] [static]

Initial value:

 {
  40,  8, 48, 16, 56, 24, 64, 32, 39,  7, 47, 15, 55, 23, 63, 31,
  38,  6, 46, 14, 54, 22, 62, 30, 37,  5, 45, 13, 53, 21, 61, 29,
  36,  4, 44, 12, 52, 20, 60, 28, 35,  3, 43, 11, 51, 19, 59, 27,
  34,  2, 42, 10, 50, 18, 58, 26, 33,  1, 41,  9, 49, 17, 57, 25
}

Definition at line 178 of file crypt_util.cpp.

Referenced by __init_des_r().

const int initial_perm[64] [static]

Initial value:

 {
  58, 50, 42, 34, 26, 18, 10,  2, 60, 52, 44, 36, 28, 20, 12, 4,
  62, 54, 46, 38, 30, 22, 14,  6, 64, 56, 48, 40, 32, 24, 16, 8,
  57, 49, 41, 33, 25, 17,  9,  1, 59, 51, 43, 35, 27, 19, 11, 3,
  61, 53, 45, 37, 29, 21, 13,  5, 63, 55, 47, 39, 31, 23, 15, 7
}

Definition at line 167 of file crypt_util.cpp.

Referenced by __encrypt_r().

const ufc_long longmask[32] [static]

Initial value:

 {
  0x80000000, 0x40000000, 0x20000000, 0x10000000,
  0x08000000, 0x04000000, 0x02000000, 0x01000000,
  0x00800000, 0x00400000, 0x00200000, 0x00100000,
  0x00080000, 0x00040000, 0x00020000, 0x00010000,
  0x00008000, 0x00004000, 0x00002000, 0x00001000,
  0x00000800, 0x00000400, 0x00000200, 0x00000100,
  0x00000080, 0x00000040, 0x00000020, 0x00000010,
  0x00000008, 0x00000004, 0x00000002, 0x00000001
}

Definition at line 199 of file crypt_util.cpp.

Referenced by __encrypt_r(), and __init_des_r().

const char patchlevel_str[] = PATCHLEVEL [static]

Definition at line 58 of file crypt_util.cpp.

const int pc1[56] [static]

Initial value:

 {
  57, 49, 41, 33, 25, 17,  9,  1, 58, 50, 42, 34, 26, 18,
  10,  2, 59, 51, 43, 35, 27, 19, 11,  3, 60, 52, 44, 36,
  63, 55, 47, 39, 31, 23, 15,  7, 62, 54, 46, 38, 30, 22,
  14,  6, 61, 53, 45, 37, 29, 21, 13,  5, 28, 20, 12,  4
}

Definition at line 64 of file crypt_util.cpp.

Referenced by __init_des_r().

const int pc2[48] [static]

Initial value:

 {
  14, 17, 11, 24,  1,  5,  3, 28, 15,  6, 21, 10,
  23, 19, 12,  4, 26,  8, 16,  7, 27, 20, 13,  2,
  41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48,
  44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32
}

Definition at line 83 of file crypt_util.cpp.

Referenced by __init_des_r().

const int perm32[32] [static]

Initial value:

 {
  16,  7, 20, 21, 29, 12, 28, 17,  1, 15, 23, 26,  5, 18, 31, 10,
  2,   8, 24, 14, 32, 27,  3,  9, 19, 13, 30,  6, 22, 11,  4, 25
}

Definition at line 105 of file crypt_util.cpp.

Referenced by __init_des_r().

const int rots[16] [static]

Initial value:

 {
  1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1
}

Definition at line 75 of file crypt_util.cpp.

Referenced by _ufc_mk_keytab_r().

const int sbox[8][4][16] [static]

Definition at line 113 of file crypt_util.cpp.


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