Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/sys/crypto/blowfish pullup 1.1 -> 1.2 (for all files) -...



details:   https://anonhg.NetBSD.org/src/rev/5d6dbca6aa3e
branches:  netbsd-1-5
changeset: 489319:5d6dbca6aa3e
user:      itojun <itojun%NetBSD.org@localhost>
date:      Thu Aug 31 07:50:37 2000 +0000

description:
pullup 1.1 -> 1.2 (for all files) - approved by releng-1-5

without the fix, blowfish encryption function panics the kernel, on LP64 arch.

>make the code friendly with LP64 machines.
>- use u_int32_t for 32bit quantity unsigned integer type.
>- s/unsigned long/BF_LONG/ (BF_LONG = u_int32_t) where appropriate.
>- prototype cleanup - due to *BSD code sharing, we still are using __P().
>part of PR 10918.  sync with kame.

diffstat:

 sys/crypto/blowfish/bf_cbc.c   |   5 ++-
 sys/crypto/blowfish/bf_cbc_m.c |   5 ++-
 sys/crypto/blowfish/bf_enc.c   |   5 ++-
 sys/crypto/blowfish/bf_locl.h  |  62 +++++++++++++++++++++++------------------
 sys/crypto/blowfish/blowfish.h |  51 ++++++++++------------------------
 5 files changed, 58 insertions(+), 70 deletions(-)

diffs (236 lines):

diff -r 6741b88c9d8b -r 5d6dbca6aa3e sys/crypto/blowfish/bf_cbc.c
--- a/sys/crypto/blowfish/bf_cbc.c      Wed Aug 30 20:49:38 2000 +0000
+++ b/sys/crypto/blowfish/bf_cbc.c      Thu Aug 31 07:50:37 2000 +0000
@@ -1,5 +1,5 @@
-/*     $NetBSD: bf_cbc.c,v 1.1.1.1 2000/06/14 19:45:33 thorpej Exp $   */
-/*     $KAME: bf_cbc.c,v 1.3 2000/03/27 04:36:25 sumikawa Exp $        */
+/*     $NetBSD: bf_cbc.c,v 1.1.1.1.2.1 2000/08/31 07:50:37 itojun Exp $        */
+/*     $KAME: bf_cbc.c,v 1.4 2000/08/31 05:41:02 itojun Exp $  */
 
 /* crypto/bf/bf_cbc.c */
 /* Copyright (C) 1995-1997 Eric Young (eay%mincom.oz.au@localhost)
@@ -59,6 +59,7 @@
  * [including the GNU Public Licence.]
  */
 
+#include <sys/types.h>
 #include <crypto/blowfish/blowfish.h>
 #include <crypto/blowfish/bf_locl.h>
 
diff -r 6741b88c9d8b -r 5d6dbca6aa3e sys/crypto/blowfish/bf_cbc_m.c
--- a/sys/crypto/blowfish/bf_cbc_m.c    Wed Aug 30 20:49:38 2000 +0000
+++ b/sys/crypto/blowfish/bf_cbc_m.c    Thu Aug 31 07:50:37 2000 +0000
@@ -1,5 +1,5 @@
-/*     $NetBSD: bf_cbc_m.c,v 1.1.1.1 2000/06/14 19:45:33 thorpej Exp $ */
-/*     $KAME: bf_cbc_m.c,v 1.4 2000/06/14 10:41:16 itojun Exp $        */
+/*     $NetBSD: bf_cbc_m.c,v 1.1.1.1.2.1 2000/08/31 07:50:37 itojun Exp $      */
+/*     $KAME: bf_cbc_m.c,v 1.5 2000/08/31 05:41:03 itojun Exp $        */
 
 /*
  * heavily modified to accept mbuf, by Jun-ichiro itojun Itoh
@@ -63,6 +63,7 @@
  * [including the GNU Public Licence.]
  */
 
+#include <sys/types.h>
 #include <sys/param.h>
 #include <sys/malloc.h>
 #include <sys/mbuf.h>
diff -r 6741b88c9d8b -r 5d6dbca6aa3e sys/crypto/blowfish/bf_enc.c
--- a/sys/crypto/blowfish/bf_enc.c      Wed Aug 30 20:49:38 2000 +0000
+++ b/sys/crypto/blowfish/bf_enc.c      Thu Aug 31 07:50:37 2000 +0000
@@ -1,5 +1,5 @@
-/*     $NetBSD: bf_enc.c,v 1.1.1.1 2000/06/14 19:45:33 thorpej Exp $   */
-/*     $KAME: bf_enc.c,v 1.3 2000/03/27 04:36:26 sumikawa Exp $        */
+/*     $NetBSD: bf_enc.c,v 1.1.1.1.2.1 2000/08/31 07:50:37 itojun Exp $        */
+/*     $KAME: bf_enc.c,v 1.4 2000/08/31 05:41:03 itojun Exp $  */
 
 /* crypto/bf/bf_enc.c */
 /* Copyright (C) 1995-1997 Eric Young (eay%mincom.oz.au@localhost)
@@ -59,6 +59,7 @@
  * [including the GNU Public Licence.]
  */
 
+#include <sys/types.h>
 #include <crypto/blowfish/blowfish.h>
 #include <crypto/blowfish/bf_locl.h>
 
diff -r 6741b88c9d8b -r 5d6dbca6aa3e sys/crypto/blowfish/bf_locl.h
--- a/sys/crypto/blowfish/bf_locl.h     Wed Aug 30 20:49:38 2000 +0000
+++ b/sys/crypto/blowfish/bf_locl.h     Thu Aug 31 07:50:37 2000 +0000
@@ -1,5 +1,5 @@
-/*     $NetBSD: bf_locl.h,v 1.1.1.1 2000/06/14 19:45:33 thorpej Exp $  */
-/*     $KAME: bf_locl.h,v 1.3 2000/03/27 04:36:26 sumikawa Exp $       */
+/*     $NetBSD: bf_locl.h,v 1.1.1.1.2.1 2000/08/31 07:50:37 itojun Exp $       */
+/*     $KAME: bf_locl.h,v 1.5 2000/08/31 06:03:48 itojun Exp $ */
 
 /* crypto/bf/bf_local.h */
 /* Copyright (C) 1995-1997 Eric Young (eay%mincom.oz.au@localhost)
@@ -67,10 +67,10 @@
  */
 
 #undef c2l
-#define c2l(c,l)       (l =((unsigned long)(*((c)++)))    , \
-                        l|=((unsigned long)(*((c)++)))<< 8L, \
-                        l|=((unsigned long)(*((c)++)))<<16L, \
-                        l|=((unsigned long)(*((c)++)))<<24L)
+#define c2l(c,l)       (l =((BF_LONG)(*((c)++)))    , \
+                        l|=((BF_LONG)(*((c)++)))<< 8L, \
+                        l|=((BF_LONG)(*((c)++)))<<16L, \
+                        l|=((BF_LONG)(*((c)++)))<<24L)
 
 /* NOTE - c is not incremented as per c2l */
 #undef c2ln
@@ -78,14 +78,14 @@
                        c+=n; \
                        l1=l2=0; \
                        switch (n) { \
-                       case 8: l2 =((unsigned long)(*(--(c))))<<24L; \
-                       case 7: l2|=((unsigned long)(*(--(c))))<<16L; \
-                       case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \
-                       case 5: l2|=((unsigned long)(*(--(c))));     \
-                       case 4: l1 =((unsigned long)(*(--(c))))<<24L; \
-                       case 3: l1|=((unsigned long)(*(--(c))))<<16L; \
-                       case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \
-                       case 1: l1|=((unsigned long)(*(--(c))));     \
+                       case 8: l2 =((BF_LONG)(*(--(c))))<<24L; \
+                       case 7: l2|=((BF_LONG)(*(--(c))))<<16L; \
+                       case 6: l2|=((BF_LONG)(*(--(c))))<< 8L; \
+                       case 5: l2|=((BF_LONG)(*(--(c))));     \
+                       case 4: l1 =((BF_LONG)(*(--(c))))<<24L; \
+                       case 3: l1|=((BF_LONG)(*(--(c))))<<16L; \
+                       case 2: l1|=((BF_LONG)(*(--(c))))<< 8L; \
+                       case 1: l1|=((BF_LONG)(*(--(c))));     \
                                } \
                        }
 
@@ -116,14 +116,14 @@
                        c+=n; \
                        l1=l2=0; \
                        switch (n) { \
-                       case 8: l2 =((unsigned long)(*(--(c))))    ; \
-                       case 7: l2|=((unsigned long)(*(--(c))))<< 8; \
-                       case 6: l2|=((unsigned long)(*(--(c))))<<16; \
-                       case 5: l2|=((unsigned long)(*(--(c))))<<24; \
-                       case 4: l1 =((unsigned long)(*(--(c))))    ; \
-                       case 3: l1|=((unsigned long)(*(--(c))))<< 8; \
-                       case 2: l1|=((unsigned long)(*(--(c))))<<16; \
-                       case 1: l1|=((unsigned long)(*(--(c))))<<24; \
+                       case 8: l2 =((BF_LONG)(*(--(c))))    ; \
+                       case 7: l2|=((BF_LONG)(*(--(c))))<< 8; \
+                       case 6: l2|=((BF_LONG)(*(--(c))))<<16; \
+                       case 5: l2|=((BF_LONG)(*(--(c))))<<24; \
+                       case 4: l1 =((BF_LONG)(*(--(c))))    ; \
+                       case 3: l1|=((BF_LONG)(*(--(c))))<< 8; \
+                       case 2: l1|=((BF_LONG)(*(--(c))))<<16; \
+                       case 1: l1|=((BF_LONG)(*(--(c))))<<24; \
                                } \
                        }
 
@@ -143,10 +143,10 @@
                        }
 
 #undef n2l
-#define n2l(c,l)        (l =((unsigned long)(*((c)++)))<<24L, \
-                         l|=((unsigned long)(*((c)++)))<<16L, \
-                         l|=((unsigned long)(*((c)++)))<< 8L, \
-                         l|=((unsigned long)(*((c)++))))
+#define n2l(c,l)        (l =((BF_LONG)(*((c)++)))<<24L, \
+                         l|=((BF_LONG)(*((c)++)))<<16L, \
+                         l|=((BF_LONG)(*((c)++)))<< 8L, \
+                         l|=((BF_LONG)(*((c)++))))
 
 #undef l2n
 #define l2n(l,c)        (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
@@ -161,8 +161,14 @@
  * BF_PTR for sparc and MIPS/SGI
  * use nothing for Alpha and HP.
  */
-#if !defined(BF_PTR) && !defined(BF_PTR2)
-#undef BF_PTR
+#undef BF_PTR
+#undef BF_PTR2
+#ifdef __i386__
+#define        BF_PTR2
+#else
+#ifdef __mips__
+#define        BF_PTR
+#endif
 #endif
 
 #define BF_M   0x3fc
diff -r 6741b88c9d8b -r 5d6dbca6aa3e sys/crypto/blowfish/blowfish.h
--- a/sys/crypto/blowfish/blowfish.h    Wed Aug 30 20:49:38 2000 +0000
+++ b/sys/crypto/blowfish/blowfish.h    Thu Aug 31 07:50:37 2000 +0000
@@ -1,5 +1,5 @@
-/*     $NetBSD: blowfish.h,v 1.1.1.1 2000/06/14 19:45:34 thorpej Exp $ */
-/*     $KAME: blowfish.h,v 1.4 2000/06/14 10:41:16 itojun Exp $        */
+/*     $NetBSD: blowfish.h,v 1.1.1.1.2.1 2000/08/31 07:50:37 itojun Exp $      */
+/*     $KAME: blowfish.h,v 1.7 2000/08/31 06:21:55 itojun Exp $        */
 
 /* crypto/bf/blowfish.h */
 /* Copyright (C) 1995-1997 Eric Young (eay%mincom.oz.au@localhost)
@@ -69,11 +69,8 @@
 #define BF_ENCRYPT     1
 #define BF_DECRYPT     0
 
-/* If you make this 'unsigned int' the pointer variants will work on
- * the Alpha, otherwise they will not.  Strangly using the '8 byte'
- * BF_LONG and the default 'non-pointer' inner loop is the best configuration
- * for the Alpha */
-#define BF_LONG unsigned long
+/* must be 32bit quantity */
+#define BF_LONG u_int32_t
 
 #define BF_ROUNDS      16
 #define BF_BLOCK       8
@@ -84,38 +81,20 @@
        BF_LONG S[4*256];
        } BF_KEY;
 
-#ifndef NOPROTO
-
-void BF_set_key(BF_KEY *key, int len, unsigned char *data);
-void BF_ecb_encrypt(unsigned char *in,unsigned char *out,BF_KEY *key,
-       int encrypt);
-void BF_encrypt(BF_LONG *data,BF_KEY *key,int encrypt);
-void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length,
-       BF_KEY *ks, unsigned char *iv, int encrypt);
-void BF_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
-       BF_KEY *schedule, unsigned char *ivec, int *num, int encrypt);
-void BF_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
-       BF_KEY *schedule, unsigned char *ivec, int *num);
-char *BF_options(void);
+void BF_set_key __P((BF_KEY *, int, unsigned char *));
+void BF_ecb_encrypt __P((unsigned char *, unsigned char *, BF_KEY *, int));
+void BF_encrypt __P((BF_LONG *, BF_KEY *, int));
+void BF_cbc_encrypt __P((unsigned char *, unsigned char *, long,
+       BF_KEY *, unsigned char *, int));
+void BF_cfb64_encrypt __P((unsigned char *, unsigned char *, long,
+       BF_KEY *, unsigned char *, int *, int));
+void BF_ofb64_encrypt __P((unsigned char *, unsigned char *, long,
+       BF_KEY *, unsigned char *, int *));
+char *BF_options __P((void));
 
 /* added by itojun */
 struct mbuf;
-int BF_cbc_encrypt_m(struct mbuf *, int, int, BF_KEY *, unsigned char *, int);
-
-#else
-
-void BF_set_key();
-void BF_ecb_encrypt();
-void BF_encrypt();
-void BF_cbc_encrypt();
-void BF_cfb64_encrypt();
-void BF_ofb64_encrypt();
-char *BF_options();
-
-/* added by itojun */
-void BF_cbc_encrypt_m();
-
-#endif
+int BF_cbc_encrypt_m __P((struct mbuf *, int, int, BF_KEY *, unsigned char *, int));
 
 #ifdef  __cplusplus
 }



Home | Main Index | Thread Index | Old Index