diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2005-05-02 22:19:11 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2005-05-02 22:19:11 +0000 |
commit | 198b569554874615d602a75824759271c7b33af5 (patch) | |
tree | 4e26ddb0b57ed37fec538f42cf308e31488583db /sys/crypto/cryptosoft.c | |
parent | 1f53865c5ff6829311873d4aded0ca2a45272ead (diff) |
simplify by using arc4random_bytes(), ok djm, hshoexer
Diffstat (limited to 'sys/crypto/cryptosoft.c')
-rw-r--r-- | sys/crypto/cryptosoft.c | 25 |
1 files changed, 3 insertions, 22 deletions
diff --git a/sys/crypto/cryptosoft.c b/sys/crypto/cryptosoft.c index dfb2329ccc6..1b582f99879 100644 --- a/sys/crypto/cryptosoft.c +++ b/sys/crypto/cryptosoft.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cryptosoft.c,v 1.42 2004/12/20 20:31:18 hshoexer Exp $ */ +/* $OpenBSD: cryptosoft.c,v 1.43 2005/05/02 22:19:10 markus Exp $ */ /* * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu) @@ -104,27 +104,8 @@ swcr_encdec(struct cryptodesc *crd, struct swcr_data *sw, caddr_t buf, /* IV explicitly provided ? */ if (crd->crd_flags & CRD_F_IV_EXPLICIT) bcopy(crd->crd_iv, iv, blks); - else { - /* Get random IV */ - for (i = 0; - i + sizeof (u_int32_t) < EALG_MAX_BLOCK_LEN; - i += sizeof (u_int32_t)) { - u_int32_t temp = arc4random(); - - bcopy(&temp, iv + i, sizeof(u_int32_t)); - } - /* - * What if the block size is not a multiple - * of sizeof (u_int32_t), which is the size of - * what arc4random() returns ? - */ - if (EALG_MAX_BLOCK_LEN % sizeof (u_int32_t) != 0) { - u_int32_t temp = arc4random(); - - bcopy (&temp, iv + i, - EALG_MAX_BLOCK_LEN - i); - } - } + else + arc4random_bytes(iv, blks); /* Do we need to write the IV */ if (!(crd->crd_flags & CRD_F_IV_PRESENT)) { |