Source-Changes-HG archive

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

[src/trunk]: src/sys fix cast128 with shorter key length. sync with kame



details:   https://anonhg.NetBSD.org/src/rev/a961caadbf07
branches:  trunk
changeset: 518278:a961caadbf07
user:      itojun <itojun%NetBSD.org@localhost>
date:      Tue Nov 27 11:19:36 2001 +0000

description:
fix cast128 with shorter key length.  sync with kame

diffstat:

 sys/crypto/cast128/cast128.c |  21 +++++++++++++++++----
 sys/crypto/cast128/cast128.h |   6 +++---
 sys/netinet6/esp_core.c      |   9 +++++----
 3 files changed, 25 insertions(+), 11 deletions(-)

diffs (94 lines):

diff -r f6d6612f45bb -r a961caadbf07 sys/crypto/cast128/cast128.c
--- a/sys/crypto/cast128/cast128.c      Tue Nov 27 07:30:03 2001 +0000
+++ b/sys/crypto/cast128/cast128.c      Tue Nov 27 11:19:36 2001 +0000
@@ -1,5 +1,5 @@
-/*     $NetBSD: cast128.c,v 1.4 2001/11/13 01:40:09 lukem Exp $        */
-/*     $KAME: cast128.c,v 1.4 2000/11/06 13:58:08 itojun Exp $ */
+/*     $NetBSD: cast128.c,v 1.5 2001/11/27 11:19:37 itojun Exp $       */
+/*     $KAME: cast128.c,v 1.5 2001/11/27 09:47:32 sakane Exp $ */
 
 /*
  * heavily modified by Tomomi Suzuki <suzuki%grelot.elec.ryukoku.ac.jp@localhost>
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cast128.c,v 1.4 2001/11/13 01:40:09 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cast128.c,v 1.5 2001/11/27 11:19:37 itojun Exp $");
 
 #include <sys/param.h>
 #ifdef _KERNEL
@@ -62,9 +62,22 @@
 /*
  * Step 1
  */
-void set_cast128_subkey(u_int32_t *subkey, u_int8_t *key)
+void set_cast128_subkey(u_int32_t *subkey, u_int8_t *key0, int keylen)
 {
        u_int32_t buf[8]; /* for x0x1x2x3, x4x5x6x7 ..., z0z1z2z3, ... */
+       u_int32_t key[16];
+       int i;
+
+       /*
+        * the key has to be initilized.  should it be logged when the key
+        * length is more than 16 bytes ?  anyway, ignore it at this moment.
+        */
+       if (keylen > 16)
+               keylen = 16;
+       for (i = 0; i < keylen; i++)
+               key[i] = key0[i];
+       while (i < 16)
+               key[i++] = 0;
 
        buf[0] = (key[ 0] << 24) | (key[ 1] << 16) | (key[ 2] << 8)
                | key[ 3];
diff -r f6d6612f45bb -r a961caadbf07 sys/crypto/cast128/cast128.h
--- a/sys/crypto/cast128/cast128.h      Tue Nov 27 07:30:03 2001 +0000
+++ b/sys/crypto/cast128/cast128.h      Tue Nov 27 11:19:36 2001 +0000
@@ -1,5 +1,5 @@
-/*     $NetBSD: cast128.h,v 1.3 2000/11/06 14:11:41 itojun Exp $       */
-/*     $KAME: cast128.h,v 1.6 2000/09/18 20:59:20 itojun Exp $ */
+/*     $NetBSD: cast128.h,v 1.4 2001/11/27 11:19:37 itojun Exp $       */
+/*     $KAME: cast128.h,v 1.7 2001/11/27 09:47:32 sakane Exp $ */
 
 /*
  * heavily modified by Tomomi Suzuki <suzuki%grelot.elec.ryukoku.ac.jp@localhost>
@@ -46,7 +46,7 @@
 #define        CAST128_DECRYPT 0
 
 
-extern void set_cast128_subkey __P((u_int32_t *, u_int8_t *));
+extern void set_cast128_subkey __P((u_int32_t *, u_int8_t *, int));
 extern void cast128_encrypt_round16 __P((u_int8_t *, const u_int8_t *,
                                        u_int32_t *));
 extern void cast128_decrypt_round16 __P((u_int8_t *, const u_int8_t *,
diff -r f6d6612f45bb -r a961caadbf07 sys/netinet6/esp_core.c
--- a/sys/netinet6/esp_core.c   Tue Nov 27 07:30:03 2001 +0000
+++ b/sys/netinet6/esp_core.c   Tue Nov 27 11:19:36 2001 +0000
@@ -1,5 +1,5 @@
-/*     $NetBSD: esp_core.c,v 1.18 2001/11/13 00:56:57 lukem Exp $      */
-/*     $KAME: esp_core.c,v 1.52 2001/09/10 04:04:00 itojun Exp $       */
+/*     $NetBSD: esp_core.c,v 1.19 2001/11/27 11:19:36 itojun Exp $     */
+/*     $KAME: esp_core.c,v 1.53 2001/11/27 09:47:30 sakane Exp $       */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: esp_core.c,v 1.18 2001/11/13 00:56:57 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: esp_core.c,v 1.19 2001/11/27 11:19:36 itojun Exp $");
 
 #include "opt_inet.h"
 
@@ -511,7 +511,8 @@
        struct secasvar *sav;
 {
 
-       set_cast128_subkey((u_int32_t *)sav->sched, _KEYBUF(sav->key_enc));
+       set_cast128_subkey((u_int32_t *)sav->sched, _KEYBUF(sav->key_enc),
+               _KEYLEN(sav->key_enc));
        return 0;
 }
 



Home | Main Index | Thread Index | Old Index