*/
-#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
+ * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
* @(#)crypt_util.c 2.31 02/08/92
*
* Support routines
*
*/
-#include "includes.h"
#ifndef long32
* 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';
}
* by fcrypt users.
*/
-static void ufc_init_des()
+static void ufc_init_des(void)
{ int comes_from_bit;
int bit, sg;
ufc_long j;
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);
}
}
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;
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++;
*/
#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--;) {
#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--;) {
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();
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_
* 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];
* 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;
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];
#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;
#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;
#else
- int ufc_dummy_procedure(void)
-{return 0;}
+ int ufc_dummy_procedure(void);
+ int ufc_dummy_procedure(void) {return 0;}
#endif