r23801: The FSF has moved around a lot. This fixes their Mass Ave address.
[bbaumbach/samba-autobuild/.git] / source3 / lib / ufc.c
index ae48a8776d405c642c9b31127a15e87c0b862f48..89329808c98730f60943bca3f3bb963af3f83c43 100644 (file)
 
 */
 
-#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
@@ -281,9 +281,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 +297,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 +348,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 +429,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 +449,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 +466,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 +478,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 +497,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 +537,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 +586,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 +624,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 +646,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 +692,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 +731,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 +765,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