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

some of platforms give us almost constant number (oops).

Obtained from:	KAME
This commit is contained in:
ume 2000-08-28 08:24:46 +00:00
parent 7e2fa230c7
commit b00485b521

View File

@ -2664,6 +2664,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)
@ -2812,7 +2813,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;
@ -2834,9 +2842,6 @@ key_setsaval(sav, m, mhp)
sav->tick = 0;
/* make lifetime for CURRENT */
{
struct timeval tv;
KMALLOC(sav->lft_c, struct sadb_lifetime *,
sizeof(struct sadb_lifetime));
if (sav->lft_c == NULL) {
@ -2856,7 +2861,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 */
{