diff options
Diffstat (limited to 'source3/lib/ufc.c')
-rw-r--r-- | source3/lib/ufc.c | 67 |
1 files changed, 28 insertions, 39 deletions
diff --git a/source3/lib/ufc.c b/source3/lib/ufc.c index 8417285821..ecc04d9e97 100644 --- a/source3/lib/ufc.c +++ b/source3/lib/ufc.c @@ -16,12 +16,14 @@ */ -#ifdef UFC_CRYPT +#include "includes.h" + +#ifndef HAVE_CRYPT /* * UFC-crypt: ultra fast crypt(3) implementation * - * Copyright (C) 1991, 1992, Free Software Foundation, Inc. + * Copyright (C) 1991-1998, Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -42,7 +44,6 @@ * Support routines * */ -#include "includes.h" #ifndef long32 @@ -281,9 +282,7 @@ static ufc_long longmask[32] = { * bzero and some don't have memset. */ -static void clearmem(start, cnt) - char *start; - int cnt; +static void clearmem(char *start, int cnt) { while(cnt--) *start++ = '\0'; } @@ -299,7 +298,7 @@ static int initialized = 0; * by fcrypt users. */ -static void ufc_init_des() +static void ufc_init_des(void) { int comes_from_bit; int bit, sg; ufc_long j; @@ -350,13 +349,13 @@ static void ufc_init_des() clearmem((char*)eperm32tab, sizeof(eperm32tab)); for(bit = 0; bit < 48; bit++) { - ufc_long mask1,comes_from; + ufc_long inner_mask1,comes_from; comes_from = perm32[esel[bit]-1]-1; - mask1 = bytemask[comes_from % 8]; + inner_mask1 = bytemask[comes_from % 8]; for(j = 256; j--;) { - if(j & mask1) + if(j & inner_mask1) eperm32tab[comes_from / 8][j][bit / 24] |= BITMASK(bit % 24); } } @@ -431,7 +430,7 @@ static void ufc_init_des() clearmem((char*)efp, sizeof efp); for(bit = 0; bit < 64; bit++) { int o_bit, o_long; - ufc_long word_value, mask1, mask2; + ufc_long word_value, inner_mask1, inner_mask2; int comes_from_f_bit, comes_from_e_bit; int comes_from_word, bit_within_word; @@ -451,12 +450,12 @@ static void ufc_init_des() comes_from_word = comes_from_e_bit / 6; /* 0..15 */ bit_within_word = comes_from_e_bit % 6; /* 0..5 */ - mask1 = longmask[bit_within_word + 26]; - mask2 = longmask[o_bit]; + inner_mask1 = longmask[bit_within_word + 26]; + inner_mask2 = longmask[o_bit]; for(word_value = 64; word_value--;) { - if(word_value & mask1) - efp[comes_from_word][word_value][o_long] |= mask2; + if(word_value & inner_mask1) + efp[comes_from_word][word_value][o_long] |= inner_mask2; } } initialized++; @@ -468,9 +467,7 @@ static void ufc_init_des() */ #ifdef _UFC_32_ -static void shuffle_sb(k, saltbits) - long32 *k; - ufc_long saltbits; +static void shuffle_sb(long32 *k, ufc_long saltbits) { ufc_long j; long32 x; for(j=4096; j--;) { @@ -482,9 +479,7 @@ static void shuffle_sb(k, saltbits) #endif #ifdef _UFC_64_ -static void shuffle_sb(k, saltbits) - long64 *k; - ufc_long saltbits; +static void shuffle_sb(long64 *k, ufc_long saltbits) { ufc_long j; long64 x; for(j=4096; j--;) { @@ -503,9 +498,9 @@ static unsigned char current_salt[3] = "&&"; /* invalid value */ static ufc_long current_saltbits = 0; static int direction = 0; -static void setup_salt(char *s1) +static void setup_salt(const char *s1) { ufc_long i, j, saltbits; - unsigned char *s2 = (unsigned char *)s1; + const unsigned char *s2 = (const unsigned char *)s1; if(!initialized) ufc_init_des(); @@ -543,8 +538,7 @@ static void setup_salt(char *s1) current_saltbits = saltbits; } -static void ufc_mk_keytab(key) - char *key; +static void ufc_mk_keytab(char *key) { ufc_long v1, v2, *k1; int i; #ifdef _UFC_32_ @@ -593,8 +587,7 @@ static void ufc_mk_keytab(key) * Undo an extra E selection and do final permutations */ -ufc_long *_ufc_dofinalperm(l1, l2, r1, r2) - ufc_long l1,l2,r1,r2; +ufc_long *_ufc_dofinalperm(ufc_long l1, ufc_long l2, ufc_long r1, ufc_long r2) { ufc_long v1, v2, x; static ufc_long ary[2]; @@ -632,9 +625,7 @@ ufc_long *_ufc_dofinalperm(l1, l2, r1, r2) * prefixing with the salt */ -static char *output_conversion(v1, v2, salt) - ufc_long v1, v2; - char *salt; +static char *output_conversion(ufc_long v1, ufc_long v2, const char *salt) { static char outbuf[14]; int i, s; @@ -656,13 +647,13 @@ static char *output_conversion(v1, v2, salt) return outbuf; } -ufc_long *_ufc_doit(); - /* * UNIX crypt function */ + +static ufc_long *_ufc_doit(ufc_long , ufc_long, ufc_long, ufc_long, ufc_long); -char *ufc_crypt(char *key,char *salt) +char *ufc_crypt(const char *key,const char *salt) { ufc_long *s; char ktab[9]; @@ -702,8 +693,7 @@ extern long32 _ufc_sb0[], _ufc_sb1[], _ufc_sb2[], _ufc_sb3[]; #define SBA(sb, v) (*(long32*)((char*)(sb)+(v))) -ufc_long *_ufc_doit(l1, l2, r1, r2, itr) - ufc_long l1, l2, r1, r2, itr; +static ufc_long *_ufc_doit(ufc_long l1, ufc_long l2, ufc_long r1, ufc_long r2, ufc_long itr) { int i; long32 s, *k; @@ -742,8 +732,7 @@ extern long64 _ufc_sb0[], _ufc_sb1[], _ufc_sb2[], _ufc_sb3[]; #define SBA(sb, v) (*(long64*)((char*)(sb)+(v))) -ufc_long *_ufc_doit(l1, l2, r1, r2, itr) - ufc_long l1, l2, r1, r2, itr; +static ufc_long *_ufc_doit(ufc_long l1, ufc_long l2, ufc_long r1, ufc_long r2, ufc_long itr) { int i; long64 l, r, s, *k; @@ -777,6 +766,6 @@ ufc_long *_ufc_doit(l1, l2, r1, r2, itr) #else -int ufc_dummy_procedure(void) -{return 0;} + int ufc_dummy_procedure(void); + int ufc_dummy_procedure(void) {return 0;} #endif |