summaryrefslogtreecommitdiffstats
path: root/sys/opencrypto
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2006-04-10 18:24:59 +0000
committerpjd <pjd@FreeBSD.org>2006-04-10 18:24:59 +0000
commitd84c042d263d6eee5435c0cfb536f2e81f811e6f (patch)
tree597a399137d8691f9cc13b4bcce0849a6bbf7fbd /sys/opencrypto
parent65ac7dfb9ec5e393d5b5ba687f2c900e3d92de0b (diff)
downloadFreeBSD-src-d84c042d263d6eee5435c0cfb536f2e81f811e6f.zip
FreeBSD-src-d84c042d263d6eee5435c0cfb536f2e81f811e6f.tar.gz
- Simplify the code by using arc4rand(9) instead of arc4random(9) in a loop.
- Correct a comment. MFC after: 2 weeks
Diffstat (limited to 'sys/opencrypto')
-rw-r--r--sys/opencrypto/cryptosoft.c25
1 files changed, 3 insertions, 22 deletions
diff --git a/sys/opencrypto/cryptosoft.c b/sys/opencrypto/cryptosoft.c
index 9cd2250..e41f0ce 100644
--- a/sys/opencrypto/cryptosoft.c
+++ b/sys/opencrypto/cryptosoft.c
@@ -111,27 +111,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
+ arc4rand(iv, blks, 0);
/* Do we need to write the IV */
if (!(crd->crd_flags & CRD_F_IV_PRESENT)) {
@@ -431,7 +412,7 @@ swcr_encdec(struct cryptodesc *crd, struct swcr_data *sw, caddr_t buf,
}
}
- return 0; /* Done with mbuf encryption/decryption */
+ return 0; /* Done with iov encryption/decryption */
}
/* Unreachable */
OpenPOWER on IntegriCloud