From 121258e054a7a48285d885ad3a892dec2795d05f Mon Sep 17 00:00:00 2001 From: "John M. Schanck" Date: Tue, 15 Sep 2020 12:50:49 -0400 Subject: [PATCH] sphincs: satisfy test_boolean --- crypto_sign/sphincs-sha256-128f-robust/avx2/sha256avx.c | 4 +++- crypto_sign/sphincs-sha256-128f-simple/avx2/sha256avx.c | 4 +++- crypto_sign/sphincs-sha256-128s-robust/avx2/sha256avx.c | 4 +++- crypto_sign/sphincs-sha256-128s-simple/avx2/sha256avx.c | 4 +++- crypto_sign/sphincs-sha256-192f-robust/avx2/sha256avx.c | 4 +++- crypto_sign/sphincs-sha256-192f-simple/avx2/sha256avx.c | 4 +++- crypto_sign/sphincs-sha256-192s-robust/avx2/sha256avx.c | 4 +++- crypto_sign/sphincs-sha256-192s-simple/avx2/sha256avx.c | 4 +++- crypto_sign/sphincs-sha256-256f-robust/avx2/sha256avx.c | 4 +++- crypto_sign/sphincs-sha256-256f-simple/avx2/sha256avx.c | 4 +++- crypto_sign/sphincs-sha256-256s-robust/avx2/sha256avx.c | 4 +++- crypto_sign/sphincs-sha256-256s-simple/avx2/sha256avx.c | 4 +++- 12 files changed, 36 insertions(+), 12 deletions(-) diff --git a/crypto_sign/sphincs-sha256-128f-robust/avx2/sha256avx.c b/crypto_sign/sphincs-sha256-128f-robust/avx2/sha256avx.c index 9c1fd6c5..9fb6aa53 100644 --- a/crypto_sign/sphincs-sha256-128f-robust/avx2/sha256avx.c +++ b/crypto_sign/sphincs-sha256-128f-robust/avx2/sha256avx.c @@ -63,9 +63,11 @@ void PQCLEAN_SPHINCSSHA256128FROBUST_AVX2_sha256_update8x(sha256ctxx8 *ctx, const unsigned char *d7, unsigned long long len) { unsigned long long i = 0; + unsigned long long bytes_to_copy; while (i < len) { - unsigned long long bytes_to_copy = (len - i) > 64 ? 64 : (len - i); + bytes_to_copy = len - i; + if (bytes_to_copy > 64) bytes_to_copy = 64; memcpy(&ctx->msgblocks[64 * 0], d0 + i, bytes_to_copy); memcpy(&ctx->msgblocks[64 * 1], d1 + i, bytes_to_copy); memcpy(&ctx->msgblocks[64 * 2], d2 + i, bytes_to_copy); diff --git a/crypto_sign/sphincs-sha256-128f-simple/avx2/sha256avx.c b/crypto_sign/sphincs-sha256-128f-simple/avx2/sha256avx.c index 1e34b5f2..d8af492c 100644 --- a/crypto_sign/sphincs-sha256-128f-simple/avx2/sha256avx.c +++ b/crypto_sign/sphincs-sha256-128f-simple/avx2/sha256avx.c @@ -63,9 +63,11 @@ void PQCLEAN_SPHINCSSHA256128FSIMPLE_AVX2_sha256_update8x(sha256ctxx8 *ctx, const unsigned char *d7, unsigned long long len) { unsigned long long i = 0; + unsigned long long bytes_to_copy; while (i < len) { - unsigned long long bytes_to_copy = (len - i) > 64 ? 64 : (len - i); + bytes_to_copy = len - i; + if (bytes_to_copy > 64) bytes_to_copy = 64; memcpy(&ctx->msgblocks[64 * 0], d0 + i, bytes_to_copy); memcpy(&ctx->msgblocks[64 * 1], d1 + i, bytes_to_copy); memcpy(&ctx->msgblocks[64 * 2], d2 + i, bytes_to_copy); diff --git a/crypto_sign/sphincs-sha256-128s-robust/avx2/sha256avx.c b/crypto_sign/sphincs-sha256-128s-robust/avx2/sha256avx.c index 4d43b57a..31a22283 100644 --- a/crypto_sign/sphincs-sha256-128s-robust/avx2/sha256avx.c +++ b/crypto_sign/sphincs-sha256-128s-robust/avx2/sha256avx.c @@ -63,9 +63,11 @@ void PQCLEAN_SPHINCSSHA256128SROBUST_AVX2_sha256_update8x(sha256ctxx8 *ctx, const unsigned char *d7, unsigned long long len) { unsigned long long i = 0; + unsigned long long bytes_to_copy; while (i < len) { - unsigned long long bytes_to_copy = (len - i) > 64 ? 64 : (len - i); + bytes_to_copy = len - i; + if (bytes_to_copy > 64) bytes_to_copy = 64; memcpy(&ctx->msgblocks[64 * 0], d0 + i, bytes_to_copy); memcpy(&ctx->msgblocks[64 * 1], d1 + i, bytes_to_copy); memcpy(&ctx->msgblocks[64 * 2], d2 + i, bytes_to_copy); diff --git a/crypto_sign/sphincs-sha256-128s-simple/avx2/sha256avx.c b/crypto_sign/sphincs-sha256-128s-simple/avx2/sha256avx.c index 7fe73516..1f1500c7 100644 --- a/crypto_sign/sphincs-sha256-128s-simple/avx2/sha256avx.c +++ b/crypto_sign/sphincs-sha256-128s-simple/avx2/sha256avx.c @@ -63,9 +63,11 @@ void PQCLEAN_SPHINCSSHA256128SSIMPLE_AVX2_sha256_update8x(sha256ctxx8 *ctx, const unsigned char *d7, unsigned long long len) { unsigned long long i = 0; + unsigned long long bytes_to_copy; while (i < len) { - unsigned long long bytes_to_copy = (len - i) > 64 ? 64 : (len - i); + bytes_to_copy = len - i; + if (bytes_to_copy > 64) bytes_to_copy = 64; memcpy(&ctx->msgblocks[64 * 0], d0 + i, bytes_to_copy); memcpy(&ctx->msgblocks[64 * 1], d1 + i, bytes_to_copy); memcpy(&ctx->msgblocks[64 * 2], d2 + i, bytes_to_copy); diff --git a/crypto_sign/sphincs-sha256-192f-robust/avx2/sha256avx.c b/crypto_sign/sphincs-sha256-192f-robust/avx2/sha256avx.c index 76fc9014..50e42a56 100644 --- a/crypto_sign/sphincs-sha256-192f-robust/avx2/sha256avx.c +++ b/crypto_sign/sphincs-sha256-192f-robust/avx2/sha256avx.c @@ -63,9 +63,11 @@ void PQCLEAN_SPHINCSSHA256192FROBUST_AVX2_sha256_update8x(sha256ctxx8 *ctx, const unsigned char *d7, unsigned long long len) { unsigned long long i = 0; + unsigned long long bytes_to_copy; while (i < len) { - unsigned long long bytes_to_copy = (len - i) > 64 ? 64 : (len - i); + bytes_to_copy = len - i; + if (bytes_to_copy > 64) bytes_to_copy = 64; memcpy(&ctx->msgblocks[64 * 0], d0 + i, bytes_to_copy); memcpy(&ctx->msgblocks[64 * 1], d1 + i, bytes_to_copy); memcpy(&ctx->msgblocks[64 * 2], d2 + i, bytes_to_copy); diff --git a/crypto_sign/sphincs-sha256-192f-simple/avx2/sha256avx.c b/crypto_sign/sphincs-sha256-192f-simple/avx2/sha256avx.c index aedfd893..97e8f442 100644 --- a/crypto_sign/sphincs-sha256-192f-simple/avx2/sha256avx.c +++ b/crypto_sign/sphincs-sha256-192f-simple/avx2/sha256avx.c @@ -63,9 +63,11 @@ void PQCLEAN_SPHINCSSHA256192FSIMPLE_AVX2_sha256_update8x(sha256ctxx8 *ctx, const unsigned char *d7, unsigned long long len) { unsigned long long i = 0; + unsigned long long bytes_to_copy; while (i < len) { - unsigned long long bytes_to_copy = (len - i) > 64 ? 64 : (len - i); + bytes_to_copy = len - i; + if (bytes_to_copy > 64) bytes_to_copy = 64; memcpy(&ctx->msgblocks[64 * 0], d0 + i, bytes_to_copy); memcpy(&ctx->msgblocks[64 * 1], d1 + i, bytes_to_copy); memcpy(&ctx->msgblocks[64 * 2], d2 + i, bytes_to_copy); diff --git a/crypto_sign/sphincs-sha256-192s-robust/avx2/sha256avx.c b/crypto_sign/sphincs-sha256-192s-robust/avx2/sha256avx.c index a4807e94..2235dc7b 100644 --- a/crypto_sign/sphincs-sha256-192s-robust/avx2/sha256avx.c +++ b/crypto_sign/sphincs-sha256-192s-robust/avx2/sha256avx.c @@ -63,9 +63,11 @@ void PQCLEAN_SPHINCSSHA256192SROBUST_AVX2_sha256_update8x(sha256ctxx8 *ctx, const unsigned char *d7, unsigned long long len) { unsigned long long i = 0; + unsigned long long bytes_to_copy; while (i < len) { - unsigned long long bytes_to_copy = (len - i) > 64 ? 64 : (len - i); + bytes_to_copy = len - i; + if (bytes_to_copy > 64) bytes_to_copy = 64; memcpy(&ctx->msgblocks[64 * 0], d0 + i, bytes_to_copy); memcpy(&ctx->msgblocks[64 * 1], d1 + i, bytes_to_copy); memcpy(&ctx->msgblocks[64 * 2], d2 + i, bytes_to_copy); diff --git a/crypto_sign/sphincs-sha256-192s-simple/avx2/sha256avx.c b/crypto_sign/sphincs-sha256-192s-simple/avx2/sha256avx.c index 201346dc..237e8aeb 100644 --- a/crypto_sign/sphincs-sha256-192s-simple/avx2/sha256avx.c +++ b/crypto_sign/sphincs-sha256-192s-simple/avx2/sha256avx.c @@ -63,9 +63,11 @@ void PQCLEAN_SPHINCSSHA256192SSIMPLE_AVX2_sha256_update8x(sha256ctxx8 *ctx, const unsigned char *d7, unsigned long long len) { unsigned long long i = 0; + unsigned long long bytes_to_copy; while (i < len) { - unsigned long long bytes_to_copy = (len - i) > 64 ? 64 : (len - i); + bytes_to_copy = len - i; + if (bytes_to_copy > 64) bytes_to_copy = 64; memcpy(&ctx->msgblocks[64 * 0], d0 + i, bytes_to_copy); memcpy(&ctx->msgblocks[64 * 1], d1 + i, bytes_to_copy); memcpy(&ctx->msgblocks[64 * 2], d2 + i, bytes_to_copy); diff --git a/crypto_sign/sphincs-sha256-256f-robust/avx2/sha256avx.c b/crypto_sign/sphincs-sha256-256f-robust/avx2/sha256avx.c index df93c559..13aad2d8 100644 --- a/crypto_sign/sphincs-sha256-256f-robust/avx2/sha256avx.c +++ b/crypto_sign/sphincs-sha256-256f-robust/avx2/sha256avx.c @@ -63,9 +63,11 @@ void PQCLEAN_SPHINCSSHA256256FROBUST_AVX2_sha256_update8x(sha256ctxx8 *ctx, const unsigned char *d7, unsigned long long len) { unsigned long long i = 0; + unsigned long long bytes_to_copy; while (i < len) { - unsigned long long bytes_to_copy = (len - i) > 64 ? 64 : (len - i); + bytes_to_copy = len - i; + if (bytes_to_copy > 64) bytes_to_copy = 64; memcpy(&ctx->msgblocks[64 * 0], d0 + i, bytes_to_copy); memcpy(&ctx->msgblocks[64 * 1], d1 + i, bytes_to_copy); memcpy(&ctx->msgblocks[64 * 2], d2 + i, bytes_to_copy); diff --git a/crypto_sign/sphincs-sha256-256f-simple/avx2/sha256avx.c b/crypto_sign/sphincs-sha256-256f-simple/avx2/sha256avx.c index da2ad9a4..ef988608 100644 --- a/crypto_sign/sphincs-sha256-256f-simple/avx2/sha256avx.c +++ b/crypto_sign/sphincs-sha256-256f-simple/avx2/sha256avx.c @@ -63,9 +63,11 @@ void PQCLEAN_SPHINCSSHA256256FSIMPLE_AVX2_sha256_update8x(sha256ctxx8 *ctx, const unsigned char *d7, unsigned long long len) { unsigned long long i = 0; + unsigned long long bytes_to_copy; while (i < len) { - unsigned long long bytes_to_copy = (len - i) > 64 ? 64 : (len - i); + bytes_to_copy = len - i; + if (bytes_to_copy > 64) bytes_to_copy = 64; memcpy(&ctx->msgblocks[64 * 0], d0 + i, bytes_to_copy); memcpy(&ctx->msgblocks[64 * 1], d1 + i, bytes_to_copy); memcpy(&ctx->msgblocks[64 * 2], d2 + i, bytes_to_copy); diff --git a/crypto_sign/sphincs-sha256-256s-robust/avx2/sha256avx.c b/crypto_sign/sphincs-sha256-256s-robust/avx2/sha256avx.c index c02ce1e1..fbdce7e8 100644 --- a/crypto_sign/sphincs-sha256-256s-robust/avx2/sha256avx.c +++ b/crypto_sign/sphincs-sha256-256s-robust/avx2/sha256avx.c @@ -63,9 +63,11 @@ void PQCLEAN_SPHINCSSHA256256SROBUST_AVX2_sha256_update8x(sha256ctxx8 *ctx, const unsigned char *d7, unsigned long long len) { unsigned long long i = 0; + unsigned long long bytes_to_copy; while (i < len) { - unsigned long long bytes_to_copy = (len - i) > 64 ? 64 : (len - i); + bytes_to_copy = len - i; + if (bytes_to_copy > 64) bytes_to_copy = 64; memcpy(&ctx->msgblocks[64 * 0], d0 + i, bytes_to_copy); memcpy(&ctx->msgblocks[64 * 1], d1 + i, bytes_to_copy); memcpy(&ctx->msgblocks[64 * 2], d2 + i, bytes_to_copy); diff --git a/crypto_sign/sphincs-sha256-256s-simple/avx2/sha256avx.c b/crypto_sign/sphincs-sha256-256s-simple/avx2/sha256avx.c index 7f0972bc..73eb3471 100644 --- a/crypto_sign/sphincs-sha256-256s-simple/avx2/sha256avx.c +++ b/crypto_sign/sphincs-sha256-256s-simple/avx2/sha256avx.c @@ -63,9 +63,11 @@ void PQCLEAN_SPHINCSSHA256256SSIMPLE_AVX2_sha256_update8x(sha256ctxx8 *ctx, const unsigned char *d7, unsigned long long len) { unsigned long long i = 0; + unsigned long long bytes_to_copy; while (i < len) { - unsigned long long bytes_to_copy = (len - i) > 64 ? 64 : (len - i); + bytes_to_copy = len - i; + if (bytes_to_copy > 64) bytes_to_copy = 64; memcpy(&ctx->msgblocks[64 * 0], d0 + i, bytes_to_copy); memcpy(&ctx->msgblocks[64 * 1], d1 + i, bytes_to_copy); memcpy(&ctx->msgblocks[64 * 2], d2 + i, bytes_to_copy);