mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
crypt.c: protoize
* missing/crypt.c: protoize function definitions and make always-zero functions void. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f4b4a19eb2
commit
4cec7e8e35
1 changed files with 30 additions and 54 deletions
|
@ -108,16 +108,13 @@ static char sccsid[] = "@(#)crypt.c 8.1 (Berkeley) 6/4/93";
|
|||
#define LARGEDATA
|
||||
#endif
|
||||
|
||||
int des_setkey(), des_cipher();
|
||||
void des_setkey(const char *key);
|
||||
void des_cipher(const char *in, char *out, long salt, int num_iter);
|
||||
|
||||
/* compile with "-DSTATIC=int" when profiling */
|
||||
#ifndef STATIC
|
||||
#define STATIC static
|
||||
#endif
|
||||
STATIC void init_des(), init_perm(), permute();
|
||||
#ifdef DEBUG
|
||||
STATIC void prtab();
|
||||
#endif
|
||||
|
||||
/* ==================================== */
|
||||
|
||||
|
@ -303,11 +300,7 @@ typedef union {
|
|||
{ C_block tblk; permute((cpp),&tblk,(p),4); LOAD ((d),(d0),(d1),tblk); }
|
||||
|
||||
STATIC void
|
||||
permute(cp, out, p, chars_in)
|
||||
unsigned char *cp;
|
||||
C_block *out;
|
||||
register C_block *p;
|
||||
int chars_in;
|
||||
permute(unsigned char *cp, C_block *out, register C_block *p, int chars_in)
|
||||
{
|
||||
register DCL_BLOCK(D,D0,D1);
|
||||
register C_block *tp;
|
||||
|
@ -323,6 +316,12 @@ permute(cp, out, p, chars_in)
|
|||
}
|
||||
#endif /* LARGEDATA */
|
||||
|
||||
STATIC void init_des(void);
|
||||
STATIC void init_perm(C_block perm[64/CHUNKBITS][1<<CHUNKBITS], unsigned char p[64], int chars_in, int chars_out);
|
||||
|
||||
#ifdef DEBUG
|
||||
STATIC void prtab(const char *s, const unsigned char *t, int num_rows);
|
||||
#endif
|
||||
|
||||
/* ===== (mostly) Standard DES Tables ==================== */
|
||||
|
||||
|
@ -497,9 +496,7 @@ static char cryptresult[1+4+4+11+1]; /* encrypted result */
|
|||
* followed by an encryption produced by the "key" and "setting".
|
||||
*/
|
||||
char *
|
||||
crypt(key, setting)
|
||||
register const char *key;
|
||||
register const char *setting;
|
||||
crypt(const char *key, const char *setting)
|
||||
{
|
||||
register char *encp;
|
||||
register long i;
|
||||
|
@ -513,8 +510,7 @@ crypt(key, setting)
|
|||
key++;
|
||||
keyblock.b[i] = t;
|
||||
}
|
||||
if (des_setkey((char *)keyblock.b)) /* also initializes "a64toi" */
|
||||
return (NULL);
|
||||
des_setkey((char *)keyblock.b); /* also initializes "a64toi" */
|
||||
|
||||
encp = &cryptresult[0];
|
||||
switch (*setting) {
|
||||
|
@ -523,16 +519,14 @@ crypt(key, setting)
|
|||
* Involve the rest of the password 8 characters at a time.
|
||||
*/
|
||||
while (*key) {
|
||||
if (des_cipher((char *)&keyblock,
|
||||
(char *)&keyblock, 0L, 1))
|
||||
return (NULL);
|
||||
des_cipher((char *)&keyblock,
|
||||
(char *)&keyblock, 0L, 1);
|
||||
for (i = 0; i < 8; i++) {
|
||||
if ((t = 2*(unsigned char)(*key)) != 0)
|
||||
key++;
|
||||
keyblock.b[i] ^= t;
|
||||
}
|
||||
if (des_setkey((char *)keyblock.b))
|
||||
return (NULL);
|
||||
des_setkey((char *)keyblock.b);
|
||||
}
|
||||
|
||||
*encp++ = *setting++;
|
||||
|
@ -562,9 +556,8 @@ crypt(key, setting)
|
|||
salt = (salt<<6) | a64toi[t];
|
||||
}
|
||||
encp += salt_size;
|
||||
if (des_cipher((char *)&constdatablock, (char *)&rsltblock,
|
||||
salt, num_iter))
|
||||
return (NULL);
|
||||
des_cipher((char *)&constdatablock, (char *)&rsltblock,
|
||||
salt, num_iter);
|
||||
|
||||
/*
|
||||
* Encode the 64 cipher bits as 11 ascii characters.
|
||||
|
@ -599,9 +592,8 @@ static C_block KS[KS_SIZE];
|
|||
/*
|
||||
* Set up the key schedule from the key.
|
||||
*/
|
||||
int
|
||||
des_setkey(key)
|
||||
register const char *key;
|
||||
void
|
||||
des_setkey(const char *key)
|
||||
{
|
||||
register DCL_BLOCK(K, K0, K1);
|
||||
register C_block *ptabp;
|
||||
|
@ -623,7 +615,6 @@ des_setkey(key)
|
|||
PERM6464(K,K0,K1,(unsigned char *)key,ptabp);
|
||||
STORE(K&~0x03030303L, K0&~0x03030303L, K1, *(C_block *)key);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -634,12 +625,8 @@ des_setkey(key)
|
|||
* NOTE: the performance of this routine is critically dependent on your
|
||||
* compiler and machine architecture.
|
||||
*/
|
||||
int
|
||||
des_cipher(in, out, salt, num_iter)
|
||||
const char *in;
|
||||
char *out;
|
||||
long salt;
|
||||
int num_iter;
|
||||
void
|
||||
des_cipher(const char *in, char *out, long salt, int num_iter)
|
||||
{
|
||||
/* variables that we want in registers, most important first */
|
||||
#if defined(pdp11)
|
||||
|
@ -747,7 +734,6 @@ des_cipher(in, out, salt, num_iter)
|
|||
#else
|
||||
STORE(L,L0,L1,*(C_block *)out);
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -756,7 +742,7 @@ des_cipher(in, out, salt, num_iter)
|
|||
* done at compile time, if the compiler were capable of that sort of thing.
|
||||
*/
|
||||
STATIC void
|
||||
init_des()
|
||||
init_des(void)
|
||||
{
|
||||
register int i, j;
|
||||
register long k;
|
||||
|
@ -900,10 +886,8 @@ init_des()
|
|||
* "perm" must be all-zeroes on entry to this routine.
|
||||
*/
|
||||
STATIC void
|
||||
init_perm(perm, p, chars_in, chars_out)
|
||||
C_block perm[64/CHUNKBITS][1<<CHUNKBITS];
|
||||
unsigned char p[64];
|
||||
int chars_in, chars_out;
|
||||
init_perm(C_block perm[64/CHUNKBITS][1<<CHUNKBITS],
|
||||
unsigned char p[64], int chars_in, int chars_out)
|
||||
{
|
||||
register int i, j, k, l;
|
||||
|
||||
|
@ -923,9 +907,8 @@ init_perm(perm, p, chars_in, chars_out)
|
|||
/*
|
||||
* "setkey" routine (for backwards compatibility)
|
||||
*/
|
||||
int
|
||||
setkey(key)
|
||||
register const char *key;
|
||||
void
|
||||
setkey(const char *key)
|
||||
{
|
||||
register int i, j, k;
|
||||
C_block keyblock;
|
||||
|
@ -938,16 +921,14 @@ setkey(key)
|
|||
}
|
||||
keyblock.b[i] = k;
|
||||
}
|
||||
return (des_setkey((char *)keyblock.b));
|
||||
des_setkey((char *)keyblock.b);
|
||||
}
|
||||
|
||||
/*
|
||||
* "encrypt" routine (for backwards compatibility)
|
||||
*/
|
||||
int
|
||||
encrypt(block, flag)
|
||||
register char *block;
|
||||
int flag;
|
||||
void
|
||||
encrypt(char *block, int flag)
|
||||
{
|
||||
register int i, j, k;
|
||||
C_block cblock;
|
||||
|
@ -960,8 +941,7 @@ encrypt(block, flag)
|
|||
}
|
||||
cblock.b[i] = k;
|
||||
}
|
||||
if (des_cipher((char *)&cblock, (char *)&cblock, 0L, (flag ? -1: 1)))
|
||||
return (1);
|
||||
des_cipher((char *)&cblock, (char *)&cblock, 0L, (flag ? -1: 1));
|
||||
for (i = 7; i >= 0; i--) {
|
||||
k = cblock.b[i];
|
||||
for (j = 7; j >= 0; j--) {
|
||||
|
@ -969,15 +949,11 @@ encrypt(block, flag)
|
|||
k >>= 1;
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
STATIC void
|
||||
prtab(s, t, num_rows)
|
||||
char *s;
|
||||
unsigned char *t;
|
||||
int num_rows;
|
||||
prtab(const char *s, const unsigned char *t, int num_rows)
|
||||
{
|
||||
register int i, j;
|
||||
|
||||
|
|
Loading…
Reference in a new issue