aboutsummaryrefslogtreecommitdiff
path: root/sntrup761.c
diff options
context:
space:
mode:
Diffstat (limited to 'sntrup761.c')
-rw-r--r--sntrup761.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/sntrup761.c b/sntrup761.c
index 123d01381c61..a731e560f6f8 100644
--- a/sntrup761.c
+++ b/sntrup761.c
@@ -1,5 +1,4 @@
-
-/* $OpenBSD: sntrup761.c,v 1.8 2024/09/16 05:37:05 djm Exp $ */
+/* $OpenBSD: sntrup761.c,v 1.9 2026/01/20 22:56:11 dtucker Exp $ */
/*
* Public Domain, Authors:
@@ -1961,27 +1960,20 @@ static void Hash_prefix(unsigned char *out, int b, const unsigned char *in, int
for (i = 0; i < 32; ++i) out[i] = h[i];
}
-static uint32_t urandom32(void) {
- unsigned char c[4];
- uint32_t result = 0;
- int i;
- randombytes(c, 4);
- for (i = 0; i < 4; ++i) result += ((uint32_t)c[i]) << (8 * i);
- return result;
-}
static void Short_random(small *out) {
uint32_t L[p];
- int i;
- for (i = 0; i < p; ++i) L[i] = urandom32();
+ randombytes(L, sizeof(L));
Short_fromlist(out, L);
+ explicit_bzero(L, sizeof(L));
}
-
static void Small_random(small *out) {
int i;
- for (i = 0; i < p; ++i) out[i] = (((urandom32() & 0x3fffffff) * 3) >> 30) - 1;
+ uint32_t L[p];
+ randombytes(L, sizeof(L));
+ for (i = 0; i < p; ++i) out[i] = (((L[i] & 0x3fffffff) * 3) >> 30) - 1;
+ explicit_bzero(L, sizeof(L));
}
-
static void KeyGen(Fq *h, small *f, small *ginv) {
small g[p];
Fq finv[p];