Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/opencrypto swcrypto(4): Simplify iv generation logic wit...
details: https://anonhg.NetBSD.org/src/rev/d808f88934f7
branches: trunk
changeset: 972979:d808f88934f7
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Jun 14 23:23:55 2020 +0000
description:
swcrypto(4): Simplify iv generation logic with cprng_fast.
diffstat:
sys/opencrypto/cryptosoft.c | 24 +++---------------------
1 files changed, 3 insertions(+), 21 deletions(-)
diffs (45 lines):
diff -r da13abb82528 -r d808f88934f7 sys/opencrypto/cryptosoft.c
--- a/sys/opencrypto/cryptosoft.c Sun Jun 14 23:23:12 2020 +0000
+++ b/sys/opencrypto/cryptosoft.c Sun Jun 14 23:23:55 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cryptosoft.c,v 1.54 2019/10/12 00:49:30 christos Exp $ */
+/* $NetBSD: cryptosoft.c,v 1.55 2020/06/14 23:23:55 riastradh Exp $ */
/* $FreeBSD: src/sys/opencrypto/cryptosoft.c,v 1.2.2.1 2002/11/21 23:34:23 sam Exp $ */
/* $OpenBSD: cryptosoft.c,v 1.35 2002/04/26 08:43:50 deraadt Exp $ */
@@ -24,7 +24,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cryptosoft.c,v 1.54 2019/10/12 00:49:30 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cryptosoft.c,v 1.55 2020/06/14 23:23:55 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -112,25 +112,7 @@
} else if (exf->reinit) {
exf->reinit(sw->sw_kschedule, 0, iv);
} 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 = cprng_fast32();
-
- memcpy(iv + i, &temp, 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 = cprng_fast32();
-
- bcopy (&temp, iv + i,
- EALG_MAX_BLOCK_LEN - i);
- }
+ cprng_fast(iv, EALG_MAX_BLOCK_LEN);
}
/* Do we need to write the IV */
Home |
Main Index |
Thread Index |
Old Index