version 1.18, 2001/03/01 14:37:35 |
version 1.18.2.1, 2004/03/26 22:53:04 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright |
* 2. Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* documentation and/or other materials provided with the distribution. |
* 3. All advertising materials mentioning features or use of this software |
* 3. Neither the name of the University nor the names of its contributors |
* must display the following acknowledgement: |
|
* This product includes software developed by the University of |
|
* California, Berkeley and its contributors. |
|
* 4. Neither the name of the University nor the names of its contributors |
|
* may be used to endorse or promote products derived from this software |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* without specific prior written permission. |
* |
* |
Line 321 permute(cp, out, p, chars_in) |
|
Line 317 permute(cp, out, p, chars_in) |
|
|
|
/* ===== (mostly) Standard DES Tables ==================== */ |
/* ===== (mostly) Standard DES Tables ==================== */ |
|
|
static unsigned char IP[] = { /* initial permutation */ |
static const unsigned char IP[] = { /* initial permutation */ |
58, 50, 42, 34, 26, 18, 10, 2, |
58, 50, 42, 34, 26, 18, 10, 2, |
60, 52, 44, 36, 28, 20, 12, 4, |
60, 52, 44, 36, 28, 20, 12, 4, |
62, 54, 46, 38, 30, 22, 14, 6, |
62, 54, 46, 38, 30, 22, 14, 6, |
Line 334 static unsigned char IP[] = { /* initia |
|
Line 330 static unsigned char IP[] = { /* initia |
|
|
|
/* The final permutation is the inverse of IP - no table is necessary */ |
/* The final permutation is the inverse of IP - no table is necessary */ |
|
|
static unsigned char ExpandTr[] = { /* expansion operation */ |
static const unsigned char ExpandTr[] = { /* expansion operation */ |
32, 1, 2, 3, 4, 5, |
32, 1, 2, 3, 4, 5, |
4, 5, 6, 7, 8, 9, |
4, 5, 6, 7, 8, 9, |
8, 9, 10, 11, 12, 13, |
8, 9, 10, 11, 12, 13, |
Line 345 static unsigned char ExpandTr[] = { /* e |
|
Line 341 static unsigned char ExpandTr[] = { /* e |
|
28, 29, 30, 31, 32, 1, |
28, 29, 30, 31, 32, 1, |
}; |
}; |
|
|
static unsigned char PC1[] = { /* permuted choice table 1 */ |
static const unsigned char PC1[] = { /* permuted choice table 1 */ |
57, 49, 41, 33, 25, 17, 9, |
57, 49, 41, 33, 25, 17, 9, |
1, 58, 50, 42, 34, 26, 18, |
1, 58, 50, 42, 34, 26, 18, |
10, 2, 59, 51, 43, 35, 27, |
10, 2, 59, 51, 43, 35, 27, |
Line 357 static unsigned char PC1[] = { /* permu |
|
Line 353 static unsigned char PC1[] = { /* permu |
|
21, 13, 5, 28, 20, 12, 4, |
21, 13, 5, 28, 20, 12, 4, |
}; |
}; |
|
|
static unsigned char Rotates[] = { /* PC1 rotation schedule */ |
static const unsigned char Rotates[] = {/* PC1 rotation schedule */ |
1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1, |
1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1, |
}; |
}; |
|
|
/* note: each "row" of PC2 is left-padded with bits that make it invertible */ |
/* note: each "row" of PC2 is left-padded with bits that make it invertible */ |
static unsigned char PC2[] = { /* permuted choice table 2 */ |
static const unsigned char PC2[] = { /* permuted choice table 2 */ |
9, 18, 14, 17, 11, 24, 1, 5, |
9, 18, 14, 17, 11, 24, 1, 5, |
22, 25, 3, 28, 15, 6, 21, 10, |
22, 25, 3, 28, 15, 6, 21, 10, |
35, 38, 23, 19, 12, 4, 26, 8, |
35, 38, 23, 19, 12, 4, 26, 8, |
Line 374 static unsigned char PC2[] = { /* permu |
|
Line 370 static unsigned char PC2[] = { /* permu |
|
0, 0, 46, 42, 50, 36, 29, 32, |
0, 0, 46, 42, 50, 36, 29, 32, |
}; |
}; |
|
|
static unsigned char S[8][64] = { /* 48->32 bit substitution tables */ |
static const unsigned char S[8][64] = { /* 48->32 bit substitution tables */ |
/* S[1] */ |
/* S[1] */ |
{ 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7, |
{ 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7, |
0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8, |
0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8, |
Line 417 static unsigned char S[8][64] = { /* 48- |
|
Line 413 static unsigned char S[8][64] = { /* 48- |
|
2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11 } |
2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11 } |
}; |
}; |
|
|
static unsigned char P32Tr[] = { /* 32-bit permutation function */ |
static const unsigned char P32Tr[] = { /* 32-bit permutation function */ |
16, 7, 20, 21, |
16, 7, 20, 21, |
29, 12, 28, 17, |
29, 12, 28, 17, |
1, 15, 23, 26, |
1, 15, 23, 26, |
Line 428 static unsigned char P32Tr[] = { /* 32-b |
|
Line 424 static unsigned char P32Tr[] = { /* 32-b |
|
22, 11, 4, 25, |
22, 11, 4, 25, |
}; |
}; |
|
|
static unsigned char CIFP[] = { /* compressed/interleaved permutation */ |
static const unsigned char CIFP[] = { /* compressed/interleaved permutation */ |
1, 2, 3, 4, 17, 18, 19, 20, |
1, 2, 3, 4, 17, 18, 19, 20, |
5, 6, 7, 8, 21, 22, 23, 24, |
5, 6, 7, 8, 21, 22, 23, 24, |
9, 10, 11, 12, 25, 26, 27, 28, |
9, 10, 11, 12, 25, 26, 27, 28, |
Line 440 static unsigned char CIFP[] = { /* comp |
|
Line 436 static unsigned char CIFP[] = { /* comp |
|
45, 46, 47, 48, 61, 62, 63, 64, |
45, 46, 47, 48, 61, 62, 63, 64, |
}; |
}; |
|
|
static unsigned char itoa64[] = /* 0..63 => ascii-64 */ |
static const unsigned char itoa64[] = /* 0..63 => ascii-64 */ |
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; |
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; |
|
|
|
|
Line 472 static C_block constdatablock; /* encr |
|
Line 468 static C_block constdatablock; /* encr |
|
static char cryptresult[1+4+4+11+1]; /* encrypted result */ |
static char cryptresult[1+4+4+11+1]; /* encrypted result */ |
|
|
extern char *__md5crypt(const char *, const char *); /* XXX */ |
extern char *__md5crypt(const char *, const char *); /* XXX */ |
|
extern char *__bcrypt(const char *, const char *); /* XXX */ |
|
|
|
|
/* |
/* |
* Return a pointer to static data consisting of the "setting" |
* Return a pointer to static data consisting of the "setting" |
Line 492 crypt(key, setting) |
|
Line 490 crypt(key, setting) |
|
/* Non-DES encryption schemes hook in here. */ |
/* Non-DES encryption schemes hook in here. */ |
if (setting[0] == _PASSWORD_NONDES) { |
if (setting[0] == _PASSWORD_NONDES) { |
switch (setting[1]) { |
switch (setting[1]) { |
#ifdef notyet |
|
case '2': |
case '2': |
return (__bcrypt(key, setting)); |
return (__bcrypt(key, setting)); |
#endif |
|
case '1': |
case '1': |
default: |
default: |
return (__md5crypt(key, setting)); |
return (__md5crypt(key, setting)); |