commit cebf0790e77c1919e20e62c27c75a2d8d5e90182
parent 242b89ecafc7f9ea4a954c5f5cfe0db91bce57d1
Author: Drew DeVault <sir@cmpwn.com>
Date: Tue, 24 May 2022 14:37:02 +0200
crypto::curve25519: zero clamped scalar
Signed-off-by: Drew DeVault <sir@cmpwn.com>
Diffstat:
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/crypto/curve25519/curve25519.ha b/crypto/curve25519/curve25519.ha
@@ -1,5 +1,6 @@
// License: MPL-2.0
// (c) 2021 Thomas Bracht Laumann Jespersen <t@laumann.xyz>
+use bytes;
// Implements the curve25519 elliptic curve
@@ -59,6 +60,7 @@ export fn scalarmult(
point: const *[POINTSZ]u8
) void = {
let clamped: [SCALARSZ]u8 = *scalar;
+ defer bytes::zero(clamped);
clamp(&clamped);
let x = unpack25519(point);
diff --git a/scripts/gen-stdlib b/scripts/gen-stdlib
@@ -461,7 +461,7 @@ crypto_curve25519() {
if [ $testing -eq 0 ]
then
gen_srcs crypto::curve25519 curve25519.ha
- gen_ssa crypto::curve25519
+ gen_ssa crypto::curve25519 bytes
else
gen_srcs crypto::curve25519 curve25519.ha +test.ha
gen_ssa crypto::curve25519 bytes fmt io encoding::hex crypto::random
diff --git a/stdlib.mk b/stdlib.mk
@@ -964,7 +964,7 @@ $(HARECACHE)/crypto/sha512/crypto_sha512-any.ssa: $(stdlib_crypto_sha512_any_src
stdlib_crypto_curve25519_any_srcs = \
$(STDLIB)/crypto/curve25519/curve25519.ha
-$(HARECACHE)/crypto/curve25519/crypto_curve25519-any.ssa: $(stdlib_crypto_curve25519_any_srcs) $(stdlib_rt)
+$(HARECACHE)/crypto/curve25519/crypto_curve25519-any.ssa: $(stdlib_crypto_curve25519_any_srcs) $(stdlib_rt) $(stdlib_bytes_$(PLATFORM))
@printf 'HAREC \t$@\n'
@mkdir -p $(HARECACHE)/crypto/curve25519
@HARECACHE=$(HARECACHE) $(HAREC) $(HAREFLAGS) -o $@ -Ncrypto::curve25519 \