]> arthur.barton.de Git - netatalk.git/commitdiff
Prefix functions in crypt.[ch] with atalk_. Removed all direct invocations
authorsrittau <srittau>
Wed, 11 Jun 2003 07:14:09 +0000 (07:14 +0000)
committersrittau <srittau>
Wed, 11 Jun 2003 07:14:09 +0000 (07:14 +0000)
of SSL functions from uams_randnum.c.

etc/uams/crypt.c
etc/uams/crypt.h
etc/uams/uams_randnum.c

index aa7b9e4087a9fcb199236a34a8fb071eb561e99a..3d1015162afbb51ceb2a9dd0bde6bbf18f6f40b5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: crypt.c,v 1.1 2003-06-11 06:29:30 srittau Exp $
+ * $Id: crypt.c,v 1.2 2003-06-11 07:14:09 srittau Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * Copyright (c) 1999 Adrian Sun (asun@u.washington.edu)
@@ -19,7 +19,7 @@
 #include "crypt.h"
 
 /* Cannot perform in-place operation. dstlen must be at least srclen*2. */
-void hexify(u_int8_t *dst, size_t dstlen, const u_int8_t *src, size_t srclen)
+void atalk_hexify(u_int8_t *dst, size_t dstlen, const u_int8_t *src, size_t srclen)
 {
        static const unsigned char hextable[] = "0123456789ABCDEF";
 
@@ -35,7 +35,7 @@ void hexify(u_int8_t *dst, size_t dstlen, const u_int8_t *src, size_t srclen)
 
 /* Can perform in-place operation. dstlen must be at least srclen/2. */
 #define unhex(x)  (isdigit(x) ? (x) - '0' : toupper(x) + 10 - 'A')
-void unhexify(u_int8_t *dst, size_t dstlen, const u_int8_t *src, size_t srclen)
+void atalk_unhexify(u_int8_t *dst, size_t dstlen, const u_int8_t *src, size_t srclen)
 {
        assert(srclen % 2 == 0);
        assert(dstlen >= srclen / 2);
@@ -46,7 +46,7 @@ void unhexify(u_int8_t *dst, size_t dstlen, const u_int8_t *src, size_t srclen)
        memset(dst, 0, dstlen);
 }
 
-int encrypt_start(CryptHandle *handle, u_int8_t *key)
+int atalk_encrypt_start(CryptHandle *handle, u_int8_t *key)
 {
        DES_key_schedule *sched = malloc(sizeof(DES_key_schedule));
        DES_set_key_unchecked((DES_cblock *) key, sched);
@@ -56,7 +56,7 @@ int encrypt_start(CryptHandle *handle, u_int8_t *key)
        return AFP_OK;
 }
 
-int encrypt_do(CryptHandle handle, u_int8_t *dst, u_int8_t *src)
+int atalk_encrypt_do(CryptHandle handle, u_int8_t *dst, u_int8_t *src)
 {
        DES_ecb_encrypt((DES_cblock *) src, (DES_cblock *) dst,
                        (DES_key_schedule *) handle, DES_ENCRYPT);
@@ -64,13 +64,13 @@ int encrypt_do(CryptHandle handle, u_int8_t *dst, u_int8_t *src)
        return AFP_OK;
 }
 
-void encrypt_end(CryptHandle handle)
+void atalk_encrypt_end(CryptHandle handle)
 {
        memset(handle, 0, sizeof(DES_key_schedule));
        free(handle);
 }
 
-int encrypt(u_int8_t *key, u_int8_t *dst, u_int8_t *src)
+int atalk_encrypt(u_int8_t *key, u_int8_t *dst, u_int8_t *src)
 {
        DES_key_schedule sched;
 
@@ -83,7 +83,7 @@ int encrypt(u_int8_t *key, u_int8_t *dst, u_int8_t *src)
        return AFP_OK;
 }
 
-int decrypt(u_int8_t *key, u_int8_t *dst, u_int8_t *src)
+int atalk_decrypt(u_int8_t *key, u_int8_t *dst, u_int8_t *src)
 {
        DES_key_schedule sched;
 
index 1ded494d1e03abdb07c493f76eacee89ea14d124..7906c23b33f4de650d9b2aab9cbc53ff5b1dcdf2 100644 (file)
@@ -2,7 +2,7 @@
 #define __UAMS_CRYPT_H
 
 /*
- * $Id: crypt.h,v 1.1 2003-06-11 06:29:30 srittau Exp $
+ * $Id: crypt.h,v 1.2 2003-06-11 07:14:12 srittau Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * Copyright (c) 1999 Adrian Sun (asun@u.washington.edu)
 
 typedef void *CryptHandle;
 
-void hexify(u_int8_t *dst, size_t dstlen, const u_int8_t *src, size_t srclen);
-void unhexify(u_int8_t *dst, size_t dstlen, const u_int8_t *src, size_t srclen);
+void atalk_hexify(u_int8_t *dst, size_t dstlen, const u_int8_t *src, size_t srclen);
+void atalk_unhexify(u_int8_t *dst, size_t dstlen, const u_int8_t *src, size_t srclen);
 
-int encrypt_start(CryptHandle *handle, u_int8_t *key);
-int encrypt_do(CryptHandle handle, u_int8_t *dst, u_int8_t *src);
-void encrypt_end(CryptHandle handle);
+int atalk_encrypt_start(CryptHandle *handle, u_int8_t *key);
+int atalk_encrypt_do(CryptHandle handle, u_int8_t *dst, u_int8_t *src);
+void atalk_encrypt_end(CryptHandle handle);
 
-int encrypt(u_int8_t *key, u_int8_t *dst, u_int8_t *src);
-int decrypt(u_int8_t *key, u_int8_t *dst, u_int8_t *src);
+int atalk_encrypt(u_int8_t *key, u_int8_t *dst, u_int8_t *src);
+int atalk_decrypt(u_int8_t *key, u_int8_t *dst, u_int8_t *src);
 
 #endif /* __UAMS_CRYPT_H */
index eee3459d75f5f97d0156a42b978aa710d00b0ad6..8caf9ceceb6accead8e1cff981aea373b470530c 100644 (file)
@@ -1,5 +1,5 @@
 /* 
- * $Id: uams_randnum.c,v 1.13 2003-06-11 06:29:30 srittau Exp $
+ * $Id: uams_randnum.c,v 1.14 2003-06-11 07:14:12 srittau Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * Copyright (c) 1999 Adrian Sun (asun@u.washington.edu) 
@@ -62,7 +62,6 @@ char *strchr (), *strrchr ();
 #define PASSWDLEN 8
 
 static C_Block         seskey;
-static Key_schedule    seskeysched;
 static struct passwd   *randpwd;
 static u_int8_t         randbuf[8];
 
@@ -189,7 +188,7 @@ static int afppasswd(const struct passwd *pwd,
 
 afppasswd_found:
   if (!set)
-    unhexify(p, sizeof(key), p, sizeof(key));
+    atalk_unhexify(p, sizeof(key), p, sizeof(key));
 
   if (keyfd > -1) {
       size_t len;
@@ -199,14 +198,14 @@ afppasswd_found:
 
       /* convert to binary key */
       len = strlen((char *) key);
-      unhexify(key, len, key, len);
+      atalk_unhexify(key, len, key, len);
 
       if (set) {
        /* NOTE: this takes advantage of the fact that passwd doesn't
         *       get used after this call if it's being set. */
-       err = encrypt(key, passwd, passwd);
+       err = atalk_encrypt(key, passwd, passwd);
       } else {
-       err = decrypt(key, p, p);
+       err = atalk_decrypt(key, p, p);
       }
       memset(key, 0, sizeof(key));
 
@@ -219,7 +218,7 @@ afppasswd_found:
     int fd = fileno(fp);
 
     /* convert to hex password */
-    hexify(key, sizeof(key), passwd, DES_KEY_SZ);
+    atalk_hexify(key, sizeof(key), passwd, DES_KEY_SZ);
     memcpy(p, key, sizeof(key));
 
     /* get exclusive access to the user's password entry. we don't
@@ -368,7 +367,7 @@ static int randnum_logincont(void *obj, struct passwd **uam_pwd,
 
   ibuf += sizeof(sessid);
 
-  err = encrypt(seskey, randbuf, randbuf);
+  err = atalk_encrypt(seskey, randbuf, randbuf);
   memset(seskey, 0, sizeof(seskey));
   if (err)
     return err;
@@ -413,21 +412,20 @@ static int rand2num_logincont(void *obj, struct passwd **uam_pwd,
     seskey[i] <<= 1;
 
   /* encrypt randbuf */
-  err = encrypt_start(&crypt_handle, seskey);
-  encrypt_do(crypt_handle, randbuf, randbuf);
+  err = atalk_encrypt_start(&crypt_handle, seskey);
+  atalk_encrypt_do(crypt_handle, randbuf, randbuf);
 
   /* test against client's reply */
   if (memcmp(randbuf, ibuf, sizeof(randbuf))) { /* != */
     memset(randbuf, 0, sizeof(randbuf));
-    memset(&seskeysched, 0, sizeof(seskeysched));
     return AFPERR_NOTAUTH;
   }
   ibuf += sizeof(randbuf);
   memset(randbuf, 0, sizeof(randbuf));
 
   /* encrypt client's challenge and send back */
-  encrypt_do(crypt_handle, rbuf, ibuf);
-  encrypt_end(crypt_handle);
+  atalk_encrypt_do(crypt_handle, rbuf, ibuf);
+  atalk_encrypt_end(crypt_handle);
   memset(seskey, 0, sizeof(seskey));
 
   *rbuflen = sizeof(randbuf);
@@ -462,15 +460,17 @@ static int randnum_changepw(void *obj, const char *username,
       return err;
 
     /* use old passwd to decrypt new passwd */
-    key_sched((C_Block *) seskey, seskeysched);
     ibuf += PASSWDLEN; /* new passwd */
     ibuf[PASSWDLEN] = '\0';
-    ecb_encrypt( (C_Block *) ibuf, (C_Block *) ibuf, seskeysched, DES_DECRYPT);
+    err = atalk_decrypt(seskey, ibuf, ibuf);
+    if (err)
+      return err;
 
     /* now use new passwd to decrypt old passwd */
-    key_sched((C_Block *) ibuf, seskeysched);
     ibuf -= PASSWDLEN; /* old passwd */
-    ecb_encrypt((C_Block *) ibuf, (C_Block *) ibuf, seskeysched, DES_DECRYPT);
+    err = atalk_decrypt(ibuf, ibuf, ibuf);
+    if (err)
+      return err;
     if (memcmp(seskey, ibuf, sizeof(seskey))) 
        err = AFPERR_NOTAUTH;
     else if (memcmp(seskey, ibuf + PASSWDLEN, sizeof(seskey)) == 0)
@@ -484,7 +484,6 @@ static int randnum_changepw(void *obj, const char *username,
       err = randpass(pwd, passwdfile, ibuf + PASSWDLEN, sizeof(seskey), 1);
 
     /* zero out some fields */
-    memset(&seskeysched, 0, sizeof(seskeysched));
     memset(seskey, 0, sizeof(seskey));
     memset(ibuf, 0, sizeof(seskey)); /* old passwd */
     memset(ibuf + PASSWDLEN, 0, sizeof(seskey)); /* new passwd */