Browse files

make sure we have IV that is random enough. memory allocator on

some of platforms give us almost constant number (oops).
  • Loading branch information...
1 parent 80caf67 commit 7071c8bb67c3b5a63aea202f5e4f64d2230cf7b0 itojun committed Aug 27, 2000
Showing with 10 additions and 9 deletions.
  1. +10 −9 kame/sys/netkey/key.c
View
19 kame/sys/netkey/key.c
@@ -1,4 +1,4 @@
-/* $KAME: key.c,v 1.149 2000/08/11 08:58:04 sakane Exp $ */
+/* $KAME: key.c,v 1.150 2000/08/27 17:25:25 itojun Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -2699,6 +2699,7 @@ key_setsaval(sav, m, mhp)
const struct esp_algorithm *algo;
#endif
int error = 0;
+ struct timeval tv;
/* sanity check */
if (m == NULL || mhp == NULL || mhp->msg == NULL)
@@ -2844,7 +2845,14 @@ key_setsaval(sav, m, mhp)
error = ENOBUFS;
goto fail;
}
- /* initialize ? */
+
+ /* initialize */
+ {
+ int i;
+ u_int8_t *p = (u_int8_t *)sav->iv;
+ for (i = 0; i < sav->ivlen; i++)
+ p[i] = key_random() & 0xff;
+ }
break;
#else
break;
@@ -2863,16 +2871,10 @@ key_setsaval(sav, m, mhp)
}
/* reset created */
- {
- struct timeval tv;
microtime(&tv);
sav->created = tv.tv_sec;
- }
/* make lifetime for CURRENT */
- {
- struct timeval tv;
-
KMALLOC(sav->lft_c, struct sadb_lifetime *,
sizeof(struct sadb_lifetime));
if (sav->lft_c == NULL) {
@@ -2892,7 +2894,6 @@ key_setsaval(sav, m, mhp)
sav->lft_c->sadb_lifetime_bytes = 0;
sav->lft_c->sadb_lifetime_addtime = tv.tv_sec;
sav->lft_c->sadb_lifetime_usetime = 0;
- }
/* lifetimes for HARD and SOFT */
{

0 comments on commit 7071c8b

Please sign in to comment.