#include <limits.h>
#include <stdio.h>
Go to the source code of this file.
Data Structures | |
union | C_block |
Defines | |
#define | _PASSWORD_EFMT1 '_' |
#define | MUST_ALIGN |
#define | LONG_IS_32_BITS |
#define | STATIC static |
#define | TO_SIX_BIT(rslt, src) |
#define | ZERO(d, d0, d1) d0 = 0, d1 = 0 |
#define | LOAD(d, d0, d1, bl) d0 = (bl).b32.i0, d1 = (bl).b32.i1 |
#define | LOADREG(d, d0, d1, s, s0, s1) d0 = s0, d1 = s1 |
#define | OR(d, d0, d1, bl) d0 |= (bl).b32.i0, d1 |= (bl).b32.i1 |
#define | STORE(s, s0, s1, bl) (bl).b32.i0 = s0, (bl).b32.i1 = s1 |
#define | DCL_BLOCK(d, d0, d1) long d0, d1 |
#define | LGCHUNKBITS 2 |
#define | CHUNKBITS (1<<LGCHUNKBITS) |
#define | PERM6464(d, d0, d1, cpp, p) { C_block tblk; permute(cpp,&tblk,p,8); LOAD (d,d0,d1,tblk); } |
#define | PERM3264(d, d0, d1, cpp, p) { C_block tblk; permute(cpp,&tblk,p,4); LOAD (d,d0,d1,tblk); } |
#define | KS_SIZE 16 |
#define | SALT salt |
#define | SPTAB(t, i) (*(long *)((unsigned char *)t + i*(sizeof(long)/4))) |
#define | DOXOR(x, y, i) k=B.b[i]; x^=SPTAB(SPE[0][i],k); y^=SPTAB(SPE[1][i],k); |
#define | CRUNCH(p0, p1, q0, q1) |
Functions | |
int | des_setkey () |
int | des_cipher () |
STATIC void | init_des () |
STATIC void | init_perm () |
STATIC void | permute () |
STATIC void | permute (unsigned char *cp, C_block *out, C_block *p, int chars_in) |
char * | crypt (const char *key, const char *setting) |
int | des_setkey (const char *key) |
int | des_cipher (char *in, char *out, long salt, int num_iter) const |
STATIC void | init_perm (perm, p, int chars_in, int chars_out) |
int | setkey (const char *key) |
int | encrypt (char *block, int flag) |
Variables | |
static unsigned char | IP [] |
static unsigned char | ExpandTr [] |
static unsigned char | PC1 [] |
static unsigned char | Rotates [] |
static unsigned char | PC2 [] |
static unsigned char | S [8][64] |
static unsigned char | P32Tr [] |
static unsigned char | CIFP [] |
static unsigned char | itoa64 [] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" |
static unsigned char | a64toi [128] |
static C_block | PC1ROT [64/CHUNKBITS][1<< CHUNKBITS] |
static C_block | PC2ROT [2][64/CHUNKBITS][1<< CHUNKBITS] |
static C_block | IE3264 [32/CHUNKBITS][1<< CHUNKBITS] |
static long | SPE [2][8][64] |
static C_block | CF6464 [64/CHUNKBITS][1<< CHUNKBITS] |
static C_block | constdatablock |
static char | cryptresult [1+4+4+11+1] |
static C_block | KS [KS_SIZE] |
#define CRUNCH | ( | p0, | ||
p1, | ||||
q0, | ||||
q1 | ||||
) |
k = (q0 ^ q1) & SALT; \ B.b32.i0 = k ^ q0 ^ kp->b32.i0; \ B.b32.i1 = k ^ q1 ^ kp->b32.i1; \ kp = (C_block *)((char *)kp+ks_inc); \ \ DOXOR(p0, p1, 0); \ DOXOR(p0, p1, 1); \ DOXOR(p0, p1, 2); \ DOXOR(p0, p1, 3); \ DOXOR(p0, p1, 4); \ DOXOR(p0, p1, 5); \ DOXOR(p0, p1, 6); \ DOXOR(p0, p1, 7);
Referenced by des_cipher().
#define DCL_BLOCK | ( | d, | ||
d0, | ||||
d1 | ||||
) | long d0, d1 |
Definition at line 275 of file crypt.c.
Referenced by des_setkey(), and permute().
#define KS_SIZE 16 |
Definition at line 595 of file crypt.c.
Referenced by des_cipher().
#define LOAD | ( | d, | ||
d0, | ||||
d1, | ||||
bl | ||||
) | d0 = (bl).b32.i0, d1 = (bl).b32.i1 |
Definition at line 271 of file crypt.c.
Referenced by des_cipher().
#define LOADREG | ( | d, | ||
d0, | ||||
d1, | ||||
s, | ||||
s0, | ||||
s1 | ||||
) | d0 = s0, d1 = s1 |
Definition at line 272 of file crypt.c.
Referenced by des_cipher().
#define OR | ( | d, | ||
d0, | ||||
d1, | ||||
bl | ||||
) | d0 |= (bl).b32.i0, d1 |= (bl).b32.i1 |
#define PERM3264 | ( | d, | ||
d0, | ||||
d1, | ||||
cpp, | ||||
p | ||||
) | { C_block tblk; permute(cpp,&tblk,p,4); LOAD (d,d0,d1,tblk); } |
Definition at line 301 of file crypt.c.
Referenced by des_cipher().
#define PERM6464 | ( | d, | ||
d0, | ||||
d1, | ||||
cpp, | ||||
p | ||||
) | { C_block tblk; permute(cpp,&tblk,p,8); LOAD (d,d0,d1,tblk); } |
Definition at line 299 of file crypt.c.
Referenced by des_cipher(), and des_setkey().
#define SALT salt |
#define SPTAB | ( | t, | ||
i | ||||
) | (*(long *)((unsigned char *)t + i*(sizeof(long)/4))) |
#define STORE | ( | s, | ||
s0, | ||||
s1, | ||||
bl | ||||
) | (bl).b32.i0 = s0, (bl).b32.i1 = s1 |
Definition at line 274 of file crypt.c.
Referenced by des_cipher(), des_setkey(), and permute().
#define TO_SIX_BIT | ( | rslt, | ||
src | ||||
) |
{ \ C_block cvt; \ cvt.b[0] = (unsigned char)src; src >>= 6; \ cvt.b[1] = (unsigned char)src; src >>= 6; \ cvt.b[2] = (unsigned char)src; src >>= 6; \ cvt.b[3] = (unsigned char)src; \ rslt = (cvt.b32.i0 & 0x3f3f3f3fL) << 2; \ }
Definition at line 258 of file crypt.c.
Referenced by des_cipher(), and init_des().
#define ZERO | ( | d, | ||
d0, | ||||
d1 | ||||
) | d0 = 0, d1 = 0 |
char* crypt | ( | const char * | key, | |
const char * | setting | |||
) |
Definition at line 499 of file crypt.c.
References _PASSWORD_EFMT1, a64toi, C_block::b, cryptresult, des_cipher(), des_setkey(), itoa64, and NULL.
Referenced by rb_str_crypt().
int des_cipher | ( | char * | in, | |
char * | out, | |||
long | salt, | |||
int | num_iter | |||
) | const |
int des_setkey | ( | const char * | key | ) |
int encrypt | ( | char * | block, | |
int | flag | |||
) |
Definition at line 947 of file crypt.c.
References C_block::b, and des_cipher().
STATIC void init_des | ( | ) |
STATIC void init_perm | ( | ) |
Referenced by init_des().
STATIC void init_perm | ( | perm | , | |
p | , | |||
int | chars_in, | |||
int | chars_out | |||
) |
STATIC void permute | ( | ) |
int setkey | ( | const char * | key | ) |
Definition at line 926 of file crypt.c.
References C_block::b, and des_setkey().
unsigned char a64toi[128] [static] |
Definition at line 470 of file crypt.c.
Referenced by crypt(), and init_des().
unsigned char CIFP[] [static] |
{ 1, 2, 3, 4, 17, 18, 19, 20, 5, 6, 7, 8, 21, 22, 23, 24, 9, 10, 11, 12, 25, 26, 27, 28, 13, 14, 15, 16, 29, 30, 31, 32, 33, 34, 35, 36, 49, 50, 51, 52, 37, 38, 39, 40, 53, 54, 55, 56, 41, 42, 43, 44, 57, 58, 59, 60, 45, 46, 47, 48, 61, 62, 63, 64, }
Definition at line 451 of file crypt.c.
Referenced by init_des().
C_block constdatablock [static] |
char cryptresult[1+4+4+11+1] [static] |
unsigned char ExpandTr[] [static] |
{ 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 341 of file crypt.c.
Referenced by init_des().
unsigned char IP[] [static] |
{ 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 328 of file crypt.c.
Referenced by init_des().
unsigned char itoa64[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" [static] |
Definition at line 463 of file crypt.c.
Referenced by crypt(), and init_des().
unsigned char P32Tr[] [static] |
{ 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 440 of file crypt.c.
Referenced by init_des().
unsigned char PC1[] [static] |
{ 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 352 of file crypt.c.
Referenced by init_des().
unsigned char PC2[] [static] |
{ 9, 18, 14, 17, 11, 24, 1, 5, 22, 25, 3, 28, 15, 6, 21, 10, 35, 38, 23, 19, 12, 4, 26, 8, 43, 54, 16, 7, 27, 20, 13, 2, 0, 0, 41, 52, 31, 37, 47, 55, 0, 0, 30, 40, 51, 45, 33, 48, 0, 0, 44, 49, 39, 56, 34, 53, 0, 0, 46, 42, 50, 36, 29, 32, }
Definition at line 369 of file crypt.c.
Referenced by init_des().
unsigned char Rotates[] [static] |
{ 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1, }
Definition at line 364 of file crypt.c.
Referenced by des_setkey(), and init_des().
unsigned char S[8][64] [static] |
Definition at line 381 of file crypt.c.
Referenced by init_des(), and ruby_dtoa().
long SPE[2][8][64] [static] |
Definition at line 482 of file crypt.c.
Referenced by init_des().