Module Name:    src
Committed By:   riastradh
Date:           Fri May 13 09:49:44 UTC 2022

Modified Files:
        src/sys/arch/arm/rockchip: rk_v1crypto.c

Log Message:
rkv1crypto(4): Fix units in RNG repeated-output health test.

This code was intended to check whether the two 4-word halves of an
8-word, 32-byte, 256-bit sample were repeated.

Instead, it accidentally checked whether the first 4 _bytes_ of the
two halves were repeated.

The effect was a false alarm rate of 1/2^32, instead of a false alarm
rate of 1/2^128, with no change on the true alarm rate in the event
of an RNG wedged producing all-zero or all-one bits.  1/2^128 is an
acceptable false alarm rate; 1/2^32, not so much.

(The false alarm right might be higher if the samples are not
perfectly uniformly distributed, which they most likey aren't,
although the documentation doesn't give any details other than
suggesting it's a ring oscillator under the hood, which provides
entropy from jitter induced by thermal noise.  This driver records
half a bit of entropy per bit of sample to be reasonably
conservative.)


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/rockchip/rk_v1crypto.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/rockchip/rk_v1crypto.c
diff -u src/sys/arch/arm/rockchip/rk_v1crypto.c:1.9 src/sys/arch/arm/rockchip/rk_v1crypto.c:1.10
--- src/sys/arch/arm/rockchip/rk_v1crypto.c:1.9	Fri Apr  8 23:14:21 2022
+++ src/sys/arch/arm/rockchip/rk_v1crypto.c	Fri May 13 09:49:44 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: rk_v1crypto.c,v 1.9 2022/04/08 23:14:21 riastradh Exp $	*/
+/*	$NetBSD: rk_v1crypto.c,v 1.10 2022/05/13 09:49:44 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: rk_v1crypto.c,v 1.9 2022/04/08 23:14:21 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: rk_v1crypto.c,v 1.10 2022/05/13 09:49:44 riastradh Exp $");
 
 #include <sys/types.h>
 
@@ -268,7 +268,7 @@ rk_v1crypto_rng_get(size_t nbytes, void 
 			device_printf(self, "timed out\n");
 			break;
 		}
-		if (consttime_memequal(buf, buf + n/2, n/2)) {
+		if (consttime_memequal(buf, buf + n/2, sizeof(buf[0]) * n/2)) {
 			device_printf(self, "failed repeated output test\n");
 			break;
 		}

Reply via email to