From 821916bc98fce9ea19574e9d60665c429b976313 Mon Sep 17 00:00:00 2001 From: Joost Rijneveld Date: Wed, 24 Apr 2019 12:52:02 +0200 Subject: [PATCH] Prevent VLA in Haraka --- .../sphincs-haraka-128f-robust/clean/haraka.c | 28 +++++++++---------- .../sphincs-haraka-128f-simple/clean/haraka.c | 28 +++++++++---------- .../sphincs-haraka-128s-robust/clean/haraka.c | 28 +++++++++---------- .../sphincs-haraka-128s-simple/clean/haraka.c | 28 +++++++++---------- .../sphincs-haraka-192f-robust/clean/haraka.c | 28 +++++++++---------- .../sphincs-haraka-192f-simple/clean/haraka.c | 28 +++++++++---------- .../sphincs-haraka-192s-robust/clean/haraka.c | 28 +++++++++---------- .../sphincs-haraka-192s-simple/clean/haraka.c | 28 +++++++++---------- .../sphincs-haraka-256f-robust/clean/haraka.c | 28 +++++++++---------- .../sphincs-haraka-256f-simple/clean/haraka.c | 28 +++++++++---------- .../sphincs-haraka-256s-robust/clean/haraka.c | 28 +++++++++---------- .../sphincs-haraka-256s-simple/clean/haraka.c | 28 +++++++++---------- 12 files changed, 168 insertions(+), 168 deletions(-) diff --git a/crypto_sign/sphincs-haraka-128f-robust/clean/haraka.c b/crypto_sign/sphincs-haraka-128f-robust/clean/haraka.c index 7fdea02d..4387402c 100644 --- a/crypto_sign/sphincs-haraka-128f-robust/clean/haraka.c +++ b/crypto_sign/sphincs-haraka-128f-robust/clean/haraka.c @@ -688,41 +688,41 @@ void PQCLEAN_SPHINCSHARAKA128FROBUST_CLEAN_tweak_constants( } } -static void haraka_S_absorb(unsigned char *s, unsigned int r, +static void haraka_S_absorb(unsigned char *s, const unsigned char *m, unsigned long long mlen, unsigned char p) { unsigned long long i; - unsigned char t[r]; + unsigned char t[HARAKAS_RATE]; - while (mlen >= r) { + while (mlen >= HARAKAS_RATE) { /* XOR block to state */ - for (i = 0; i < r; ++i) { + for (i = 0; i < HARAKAS_RATE; ++i) { s[i] ^= m[i]; } PQCLEAN_SPHINCSHARAKA128FROBUST_CLEAN_haraka512_perm(s, s); - mlen -= r; - m += r; + mlen -= HARAKAS_RATE; + m += HARAKAS_RATE; } - for (i = 0; i < r; ++i) { + for (i = 0; i < HARAKAS_RATE; ++i) { t[i] = 0; } for (i = 0; i < mlen; ++i) { t[i] = m[i]; } t[i] = p; - t[r - 1] |= 128; - for (i = 0; i < r; ++i) { + t[HARAKAS_RATE - 1] |= 128; + for (i = 0; i < HARAKAS_RATE; ++i) { s[i] ^= t[i]; } } static void haraka_S_squeezeblocks(unsigned char *h, unsigned long long nblocks, - unsigned char *s, unsigned int r) { + unsigned char *s) { while (nblocks > 0) { PQCLEAN_SPHINCSHARAKA128FROBUST_CLEAN_haraka512_perm(s, s); memcpy(h, s, HARAKAS_RATE); - h += r; + h += HARAKAS_RATE; nblocks--; } } @@ -801,13 +801,13 @@ void PQCLEAN_SPHINCSHARAKA128FROBUST_CLEAN_haraka_S(unsigned char *out, unsigned for (i = 0; i < 64; i++) { s[i] = 0; } - haraka_S_absorb(s, 32, in, inlen, 0x1F); + haraka_S_absorb(s, in, inlen, 0x1F); - haraka_S_squeezeblocks(out, outlen / 32, s, 32); + haraka_S_squeezeblocks(out, outlen / 32, s); out += (outlen / 32) * 32; if (outlen % 32) { - haraka_S_squeezeblocks(d, 1, s, 32); + haraka_S_squeezeblocks(d, 1, s); for (i = 0; i < outlen % 32; i++) { out[i] = d[i]; } diff --git a/crypto_sign/sphincs-haraka-128f-simple/clean/haraka.c b/crypto_sign/sphincs-haraka-128f-simple/clean/haraka.c index 8b6c6ae2..0ce00c98 100644 --- a/crypto_sign/sphincs-haraka-128f-simple/clean/haraka.c +++ b/crypto_sign/sphincs-haraka-128f-simple/clean/haraka.c @@ -688,41 +688,41 @@ void PQCLEAN_SPHINCSHARAKA128FSIMPLE_CLEAN_tweak_constants( } } -static void haraka_S_absorb(unsigned char *s, unsigned int r, +static void haraka_S_absorb(unsigned char *s, const unsigned char *m, unsigned long long mlen, unsigned char p) { unsigned long long i; - unsigned char t[r]; + unsigned char t[HARAKAS_RATE]; - while (mlen >= r) { + while (mlen >= HARAKAS_RATE) { /* XOR block to state */ - for (i = 0; i < r; ++i) { + for (i = 0; i < HARAKAS_RATE; ++i) { s[i] ^= m[i]; } PQCLEAN_SPHINCSHARAKA128FSIMPLE_CLEAN_haraka512_perm(s, s); - mlen -= r; - m += r; + mlen -= HARAKAS_RATE; + m += HARAKAS_RATE; } - for (i = 0; i < r; ++i) { + for (i = 0; i < HARAKAS_RATE; ++i) { t[i] = 0; } for (i = 0; i < mlen; ++i) { t[i] = m[i]; } t[i] = p; - t[r - 1] |= 128; - for (i = 0; i < r; ++i) { + t[HARAKAS_RATE - 1] |= 128; + for (i = 0; i < HARAKAS_RATE; ++i) { s[i] ^= t[i]; } } static void haraka_S_squeezeblocks(unsigned char *h, unsigned long long nblocks, - unsigned char *s, unsigned int r) { + unsigned char *s) { while (nblocks > 0) { PQCLEAN_SPHINCSHARAKA128FSIMPLE_CLEAN_haraka512_perm(s, s); memcpy(h, s, HARAKAS_RATE); - h += r; + h += HARAKAS_RATE; nblocks--; } } @@ -801,13 +801,13 @@ void PQCLEAN_SPHINCSHARAKA128FSIMPLE_CLEAN_haraka_S(unsigned char *out, unsigned for (i = 0; i < 64; i++) { s[i] = 0; } - haraka_S_absorb(s, 32, in, inlen, 0x1F); + haraka_S_absorb(s, in, inlen, 0x1F); - haraka_S_squeezeblocks(out, outlen / 32, s, 32); + haraka_S_squeezeblocks(out, outlen / 32, s); out += (outlen / 32) * 32; if (outlen % 32) { - haraka_S_squeezeblocks(d, 1, s, 32); + haraka_S_squeezeblocks(d, 1, s); for (i = 0; i < outlen % 32; i++) { out[i] = d[i]; } diff --git a/crypto_sign/sphincs-haraka-128s-robust/clean/haraka.c b/crypto_sign/sphincs-haraka-128s-robust/clean/haraka.c index f064802c..72ac40ef 100644 --- a/crypto_sign/sphincs-haraka-128s-robust/clean/haraka.c +++ b/crypto_sign/sphincs-haraka-128s-robust/clean/haraka.c @@ -688,41 +688,41 @@ void PQCLEAN_SPHINCSHARAKA128SROBUST_CLEAN_tweak_constants( } } -static void haraka_S_absorb(unsigned char *s, unsigned int r, +static void haraka_S_absorb(unsigned char *s, const unsigned char *m, unsigned long long mlen, unsigned char p) { unsigned long long i; - unsigned char t[r]; + unsigned char t[HARAKAS_RATE]; - while (mlen >= r) { + while (mlen >= HARAKAS_RATE) { /* XOR block to state */ - for (i = 0; i < r; ++i) { + for (i = 0; i < HARAKAS_RATE; ++i) { s[i] ^= m[i]; } PQCLEAN_SPHINCSHARAKA128SROBUST_CLEAN_haraka512_perm(s, s); - mlen -= r; - m += r; + mlen -= HARAKAS_RATE; + m += HARAKAS_RATE; } - for (i = 0; i < r; ++i) { + for (i = 0; i < HARAKAS_RATE; ++i) { t[i] = 0; } for (i = 0; i < mlen; ++i) { t[i] = m[i]; } t[i] = p; - t[r - 1] |= 128; - for (i = 0; i < r; ++i) { + t[HARAKAS_RATE - 1] |= 128; + for (i = 0; i < HARAKAS_RATE; ++i) { s[i] ^= t[i]; } } static void haraka_S_squeezeblocks(unsigned char *h, unsigned long long nblocks, - unsigned char *s, unsigned int r) { + unsigned char *s) { while (nblocks > 0) { PQCLEAN_SPHINCSHARAKA128SROBUST_CLEAN_haraka512_perm(s, s); memcpy(h, s, HARAKAS_RATE); - h += r; + h += HARAKAS_RATE; nblocks--; } } @@ -801,13 +801,13 @@ void PQCLEAN_SPHINCSHARAKA128SROBUST_CLEAN_haraka_S(unsigned char *out, unsigned for (i = 0; i < 64; i++) { s[i] = 0; } - haraka_S_absorb(s, 32, in, inlen, 0x1F); + haraka_S_absorb(s, in, inlen, 0x1F); - haraka_S_squeezeblocks(out, outlen / 32, s, 32); + haraka_S_squeezeblocks(out, outlen / 32, s); out += (outlen / 32) * 32; if (outlen % 32) { - haraka_S_squeezeblocks(d, 1, s, 32); + haraka_S_squeezeblocks(d, 1, s); for (i = 0; i < outlen % 32; i++) { out[i] = d[i]; } diff --git a/crypto_sign/sphincs-haraka-128s-simple/clean/haraka.c b/crypto_sign/sphincs-haraka-128s-simple/clean/haraka.c index d7d77f2a..908cd36d 100644 --- a/crypto_sign/sphincs-haraka-128s-simple/clean/haraka.c +++ b/crypto_sign/sphincs-haraka-128s-simple/clean/haraka.c @@ -688,41 +688,41 @@ void PQCLEAN_SPHINCSHARAKA128SSIMPLE_CLEAN_tweak_constants( } } -static void haraka_S_absorb(unsigned char *s, unsigned int r, +static void haraka_S_absorb(unsigned char *s, const unsigned char *m, unsigned long long mlen, unsigned char p) { unsigned long long i; - unsigned char t[r]; + unsigned char t[HARAKAS_RATE]; - while (mlen >= r) { + while (mlen >= HARAKAS_RATE) { /* XOR block to state */ - for (i = 0; i < r; ++i) { + for (i = 0; i < HARAKAS_RATE; ++i) { s[i] ^= m[i]; } PQCLEAN_SPHINCSHARAKA128SSIMPLE_CLEAN_haraka512_perm(s, s); - mlen -= r; - m += r; + mlen -= HARAKAS_RATE; + m += HARAKAS_RATE; } - for (i = 0; i < r; ++i) { + for (i = 0; i < HARAKAS_RATE; ++i) { t[i] = 0; } for (i = 0; i < mlen; ++i) { t[i] = m[i]; } t[i] = p; - t[r - 1] |= 128; - for (i = 0; i < r; ++i) { + t[HARAKAS_RATE - 1] |= 128; + for (i = 0; i < HARAKAS_RATE; ++i) { s[i] ^= t[i]; } } static void haraka_S_squeezeblocks(unsigned char *h, unsigned long long nblocks, - unsigned char *s, unsigned int r) { + unsigned char *s) { while (nblocks > 0) { PQCLEAN_SPHINCSHARAKA128SSIMPLE_CLEAN_haraka512_perm(s, s); memcpy(h, s, HARAKAS_RATE); - h += r; + h += HARAKAS_RATE; nblocks--; } } @@ -801,13 +801,13 @@ void PQCLEAN_SPHINCSHARAKA128SSIMPLE_CLEAN_haraka_S(unsigned char *out, unsigned for (i = 0; i < 64; i++) { s[i] = 0; } - haraka_S_absorb(s, 32, in, inlen, 0x1F); + haraka_S_absorb(s, in, inlen, 0x1F); - haraka_S_squeezeblocks(out, outlen / 32, s, 32); + haraka_S_squeezeblocks(out, outlen / 32, s); out += (outlen / 32) * 32; if (outlen % 32) { - haraka_S_squeezeblocks(d, 1, s, 32); + haraka_S_squeezeblocks(d, 1, s); for (i = 0; i < outlen % 32; i++) { out[i] = d[i]; } diff --git a/crypto_sign/sphincs-haraka-192f-robust/clean/haraka.c b/crypto_sign/sphincs-haraka-192f-robust/clean/haraka.c index 5817af8a..25e3bbe0 100644 --- a/crypto_sign/sphincs-haraka-192f-robust/clean/haraka.c +++ b/crypto_sign/sphincs-haraka-192f-robust/clean/haraka.c @@ -688,41 +688,41 @@ void PQCLEAN_SPHINCSHARAKA192FROBUST_CLEAN_tweak_constants( } } -static void haraka_S_absorb(unsigned char *s, unsigned int r, +static void haraka_S_absorb(unsigned char *s, const unsigned char *m, unsigned long long mlen, unsigned char p) { unsigned long long i; - unsigned char t[r]; + unsigned char t[HARAKAS_RATE]; - while (mlen >= r) { + while (mlen >= HARAKAS_RATE) { /* XOR block to state */ - for (i = 0; i < r; ++i) { + for (i = 0; i < HARAKAS_RATE; ++i) { s[i] ^= m[i]; } PQCLEAN_SPHINCSHARAKA192FROBUST_CLEAN_haraka512_perm(s, s); - mlen -= r; - m += r; + mlen -= HARAKAS_RATE; + m += HARAKAS_RATE; } - for (i = 0; i < r; ++i) { + for (i = 0; i < HARAKAS_RATE; ++i) { t[i] = 0; } for (i = 0; i < mlen; ++i) { t[i] = m[i]; } t[i] = p; - t[r - 1] |= 128; - for (i = 0; i < r; ++i) { + t[HARAKAS_RATE - 1] |= 128; + for (i = 0; i < HARAKAS_RATE; ++i) { s[i] ^= t[i]; } } static void haraka_S_squeezeblocks(unsigned char *h, unsigned long long nblocks, - unsigned char *s, unsigned int r) { + unsigned char *s) { while (nblocks > 0) { PQCLEAN_SPHINCSHARAKA192FROBUST_CLEAN_haraka512_perm(s, s); memcpy(h, s, HARAKAS_RATE); - h += r; + h += HARAKAS_RATE; nblocks--; } } @@ -801,13 +801,13 @@ void PQCLEAN_SPHINCSHARAKA192FROBUST_CLEAN_haraka_S(unsigned char *out, unsigned for (i = 0; i < 64; i++) { s[i] = 0; } - haraka_S_absorb(s, 32, in, inlen, 0x1F); + haraka_S_absorb(s, in, inlen, 0x1F); - haraka_S_squeezeblocks(out, outlen / 32, s, 32); + haraka_S_squeezeblocks(out, outlen / 32, s); out += (outlen / 32) * 32; if (outlen % 32) { - haraka_S_squeezeblocks(d, 1, s, 32); + haraka_S_squeezeblocks(d, 1, s); for (i = 0; i < outlen % 32; i++) { out[i] = d[i]; } diff --git a/crypto_sign/sphincs-haraka-192f-simple/clean/haraka.c b/crypto_sign/sphincs-haraka-192f-simple/clean/haraka.c index 630e07aa..c792f83e 100644 --- a/crypto_sign/sphincs-haraka-192f-simple/clean/haraka.c +++ b/crypto_sign/sphincs-haraka-192f-simple/clean/haraka.c @@ -688,41 +688,41 @@ void PQCLEAN_SPHINCSHARAKA192FSIMPLE_CLEAN_tweak_constants( } } -static void haraka_S_absorb(unsigned char *s, unsigned int r, +static void haraka_S_absorb(unsigned char *s, const unsigned char *m, unsigned long long mlen, unsigned char p) { unsigned long long i; - unsigned char t[r]; + unsigned char t[HARAKAS_RATE]; - while (mlen >= r) { + while (mlen >= HARAKAS_RATE) { /* XOR block to state */ - for (i = 0; i < r; ++i) { + for (i = 0; i < HARAKAS_RATE; ++i) { s[i] ^= m[i]; } PQCLEAN_SPHINCSHARAKA192FSIMPLE_CLEAN_haraka512_perm(s, s); - mlen -= r; - m += r; + mlen -= HARAKAS_RATE; + m += HARAKAS_RATE; } - for (i = 0; i < r; ++i) { + for (i = 0; i < HARAKAS_RATE; ++i) { t[i] = 0; } for (i = 0; i < mlen; ++i) { t[i] = m[i]; } t[i] = p; - t[r - 1] |= 128; - for (i = 0; i < r; ++i) { + t[HARAKAS_RATE - 1] |= 128; + for (i = 0; i < HARAKAS_RATE; ++i) { s[i] ^= t[i]; } } static void haraka_S_squeezeblocks(unsigned char *h, unsigned long long nblocks, - unsigned char *s, unsigned int r) { + unsigned char *s) { while (nblocks > 0) { PQCLEAN_SPHINCSHARAKA192FSIMPLE_CLEAN_haraka512_perm(s, s); memcpy(h, s, HARAKAS_RATE); - h += r; + h += HARAKAS_RATE; nblocks--; } } @@ -801,13 +801,13 @@ void PQCLEAN_SPHINCSHARAKA192FSIMPLE_CLEAN_haraka_S(unsigned char *out, unsigned for (i = 0; i < 64; i++) { s[i] = 0; } - haraka_S_absorb(s, 32, in, inlen, 0x1F); + haraka_S_absorb(s, in, inlen, 0x1F); - haraka_S_squeezeblocks(out, outlen / 32, s, 32); + haraka_S_squeezeblocks(out, outlen / 32, s); out += (outlen / 32) * 32; if (outlen % 32) { - haraka_S_squeezeblocks(d, 1, s, 32); + haraka_S_squeezeblocks(d, 1, s); for (i = 0; i < outlen % 32; i++) { out[i] = d[i]; } diff --git a/crypto_sign/sphincs-haraka-192s-robust/clean/haraka.c b/crypto_sign/sphincs-haraka-192s-robust/clean/haraka.c index c292b979..cd6045a8 100644 --- a/crypto_sign/sphincs-haraka-192s-robust/clean/haraka.c +++ b/crypto_sign/sphincs-haraka-192s-robust/clean/haraka.c @@ -688,41 +688,41 @@ void PQCLEAN_SPHINCSHARAKA192SROBUST_CLEAN_tweak_constants( } } -static void haraka_S_absorb(unsigned char *s, unsigned int r, +static void haraka_S_absorb(unsigned char *s, const unsigned char *m, unsigned long long mlen, unsigned char p) { unsigned long long i; - unsigned char t[r]; + unsigned char t[HARAKAS_RATE]; - while (mlen >= r) { + while (mlen >= HARAKAS_RATE) { /* XOR block to state */ - for (i = 0; i < r; ++i) { + for (i = 0; i < HARAKAS_RATE; ++i) { s[i] ^= m[i]; } PQCLEAN_SPHINCSHARAKA192SROBUST_CLEAN_haraka512_perm(s, s); - mlen -= r; - m += r; + mlen -= HARAKAS_RATE; + m += HARAKAS_RATE; } - for (i = 0; i < r; ++i) { + for (i = 0; i < HARAKAS_RATE; ++i) { t[i] = 0; } for (i = 0; i < mlen; ++i) { t[i] = m[i]; } t[i] = p; - t[r - 1] |= 128; - for (i = 0; i < r; ++i) { + t[HARAKAS_RATE - 1] |= 128; + for (i = 0; i < HARAKAS_RATE; ++i) { s[i] ^= t[i]; } } static void haraka_S_squeezeblocks(unsigned char *h, unsigned long long nblocks, - unsigned char *s, unsigned int r) { + unsigned char *s) { while (nblocks > 0) { PQCLEAN_SPHINCSHARAKA192SROBUST_CLEAN_haraka512_perm(s, s); memcpy(h, s, HARAKAS_RATE); - h += r; + h += HARAKAS_RATE; nblocks--; } } @@ -801,13 +801,13 @@ void PQCLEAN_SPHINCSHARAKA192SROBUST_CLEAN_haraka_S(unsigned char *out, unsigned for (i = 0; i < 64; i++) { s[i] = 0; } - haraka_S_absorb(s, 32, in, inlen, 0x1F); + haraka_S_absorb(s, in, inlen, 0x1F); - haraka_S_squeezeblocks(out, outlen / 32, s, 32); + haraka_S_squeezeblocks(out, outlen / 32, s); out += (outlen / 32) * 32; if (outlen % 32) { - haraka_S_squeezeblocks(d, 1, s, 32); + haraka_S_squeezeblocks(d, 1, s); for (i = 0; i < outlen % 32; i++) { out[i] = d[i]; } diff --git a/crypto_sign/sphincs-haraka-192s-simple/clean/haraka.c b/crypto_sign/sphincs-haraka-192s-simple/clean/haraka.c index 4e668053..22febc91 100644 --- a/crypto_sign/sphincs-haraka-192s-simple/clean/haraka.c +++ b/crypto_sign/sphincs-haraka-192s-simple/clean/haraka.c @@ -688,41 +688,41 @@ void PQCLEAN_SPHINCSHARAKA192SSIMPLE_CLEAN_tweak_constants( } } -static void haraka_S_absorb(unsigned char *s, unsigned int r, +static void haraka_S_absorb(unsigned char *s, const unsigned char *m, unsigned long long mlen, unsigned char p) { unsigned long long i; - unsigned char t[r]; + unsigned char t[HARAKAS_RATE]; - while (mlen >= r) { + while (mlen >= HARAKAS_RATE) { /* XOR block to state */ - for (i = 0; i < r; ++i) { + for (i = 0; i < HARAKAS_RATE; ++i) { s[i] ^= m[i]; } PQCLEAN_SPHINCSHARAKA192SSIMPLE_CLEAN_haraka512_perm(s, s); - mlen -= r; - m += r; + mlen -= HARAKAS_RATE; + m += HARAKAS_RATE; } - for (i = 0; i < r; ++i) { + for (i = 0; i < HARAKAS_RATE; ++i) { t[i] = 0; } for (i = 0; i < mlen; ++i) { t[i] = m[i]; } t[i] = p; - t[r - 1] |= 128; - for (i = 0; i < r; ++i) { + t[HARAKAS_RATE - 1] |= 128; + for (i = 0; i < HARAKAS_RATE; ++i) { s[i] ^= t[i]; } } static void haraka_S_squeezeblocks(unsigned char *h, unsigned long long nblocks, - unsigned char *s, unsigned int r) { + unsigned char *s) { while (nblocks > 0) { PQCLEAN_SPHINCSHARAKA192SSIMPLE_CLEAN_haraka512_perm(s, s); memcpy(h, s, HARAKAS_RATE); - h += r; + h += HARAKAS_RATE; nblocks--; } } @@ -801,13 +801,13 @@ void PQCLEAN_SPHINCSHARAKA192SSIMPLE_CLEAN_haraka_S(unsigned char *out, unsigned for (i = 0; i < 64; i++) { s[i] = 0; } - haraka_S_absorb(s, 32, in, inlen, 0x1F); + haraka_S_absorb(s, in, inlen, 0x1F); - haraka_S_squeezeblocks(out, outlen / 32, s, 32); + haraka_S_squeezeblocks(out, outlen / 32, s); out += (outlen / 32) * 32; if (outlen % 32) { - haraka_S_squeezeblocks(d, 1, s, 32); + haraka_S_squeezeblocks(d, 1, s); for (i = 0; i < outlen % 32; i++) { out[i] = d[i]; } diff --git a/crypto_sign/sphincs-haraka-256f-robust/clean/haraka.c b/crypto_sign/sphincs-haraka-256f-robust/clean/haraka.c index d1c8f662..242feed1 100644 --- a/crypto_sign/sphincs-haraka-256f-robust/clean/haraka.c +++ b/crypto_sign/sphincs-haraka-256f-robust/clean/haraka.c @@ -688,41 +688,41 @@ void PQCLEAN_SPHINCSHARAKA256FROBUST_CLEAN_tweak_constants( } } -static void haraka_S_absorb(unsigned char *s, unsigned int r, +static void haraka_S_absorb(unsigned char *s, const unsigned char *m, unsigned long long mlen, unsigned char p) { unsigned long long i; - unsigned char t[r]; + unsigned char t[HARAKAS_RATE]; - while (mlen >= r) { + while (mlen >= HARAKAS_RATE) { /* XOR block to state */ - for (i = 0; i < r; ++i) { + for (i = 0; i < HARAKAS_RATE; ++i) { s[i] ^= m[i]; } PQCLEAN_SPHINCSHARAKA256FROBUST_CLEAN_haraka512_perm(s, s); - mlen -= r; - m += r; + mlen -= HARAKAS_RATE; + m += HARAKAS_RATE; } - for (i = 0; i < r; ++i) { + for (i = 0; i < HARAKAS_RATE; ++i) { t[i] = 0; } for (i = 0; i < mlen; ++i) { t[i] = m[i]; } t[i] = p; - t[r - 1] |= 128; - for (i = 0; i < r; ++i) { + t[HARAKAS_RATE - 1] |= 128; + for (i = 0; i < HARAKAS_RATE; ++i) { s[i] ^= t[i]; } } static void haraka_S_squeezeblocks(unsigned char *h, unsigned long long nblocks, - unsigned char *s, unsigned int r) { + unsigned char *s) { while (nblocks > 0) { PQCLEAN_SPHINCSHARAKA256FROBUST_CLEAN_haraka512_perm(s, s); memcpy(h, s, HARAKAS_RATE); - h += r; + h += HARAKAS_RATE; nblocks--; } } @@ -801,13 +801,13 @@ void PQCLEAN_SPHINCSHARAKA256FROBUST_CLEAN_haraka_S(unsigned char *out, unsigned for (i = 0; i < 64; i++) { s[i] = 0; } - haraka_S_absorb(s, 32, in, inlen, 0x1F); + haraka_S_absorb(s, in, inlen, 0x1F); - haraka_S_squeezeblocks(out, outlen / 32, s, 32); + haraka_S_squeezeblocks(out, outlen / 32, s); out += (outlen / 32) * 32; if (outlen % 32) { - haraka_S_squeezeblocks(d, 1, s, 32); + haraka_S_squeezeblocks(d, 1, s); for (i = 0; i < outlen % 32; i++) { out[i] = d[i]; } diff --git a/crypto_sign/sphincs-haraka-256f-simple/clean/haraka.c b/crypto_sign/sphincs-haraka-256f-simple/clean/haraka.c index 233780e4..3b85173c 100644 --- a/crypto_sign/sphincs-haraka-256f-simple/clean/haraka.c +++ b/crypto_sign/sphincs-haraka-256f-simple/clean/haraka.c @@ -688,41 +688,41 @@ void PQCLEAN_SPHINCSHARAKA256FSIMPLE_CLEAN_tweak_constants( } } -static void haraka_S_absorb(unsigned char *s, unsigned int r, +static void haraka_S_absorb(unsigned char *s, const unsigned char *m, unsigned long long mlen, unsigned char p) { unsigned long long i; - unsigned char t[r]; + unsigned char t[HARAKAS_RATE]; - while (mlen >= r) { + while (mlen >= HARAKAS_RATE) { /* XOR block to state */ - for (i = 0; i < r; ++i) { + for (i = 0; i < HARAKAS_RATE; ++i) { s[i] ^= m[i]; } PQCLEAN_SPHINCSHARAKA256FSIMPLE_CLEAN_haraka512_perm(s, s); - mlen -= r; - m += r; + mlen -= HARAKAS_RATE; + m += HARAKAS_RATE; } - for (i = 0; i < r; ++i) { + for (i = 0; i < HARAKAS_RATE; ++i) { t[i] = 0; } for (i = 0; i < mlen; ++i) { t[i] = m[i]; } t[i] = p; - t[r - 1] |= 128; - for (i = 0; i < r; ++i) { + t[HARAKAS_RATE - 1] |= 128; + for (i = 0; i < HARAKAS_RATE; ++i) { s[i] ^= t[i]; } } static void haraka_S_squeezeblocks(unsigned char *h, unsigned long long nblocks, - unsigned char *s, unsigned int r) { + unsigned char *s) { while (nblocks > 0) { PQCLEAN_SPHINCSHARAKA256FSIMPLE_CLEAN_haraka512_perm(s, s); memcpy(h, s, HARAKAS_RATE); - h += r; + h += HARAKAS_RATE; nblocks--; } } @@ -801,13 +801,13 @@ void PQCLEAN_SPHINCSHARAKA256FSIMPLE_CLEAN_haraka_S(unsigned char *out, unsigned for (i = 0; i < 64; i++) { s[i] = 0; } - haraka_S_absorb(s, 32, in, inlen, 0x1F); + haraka_S_absorb(s, in, inlen, 0x1F); - haraka_S_squeezeblocks(out, outlen / 32, s, 32); + haraka_S_squeezeblocks(out, outlen / 32, s); out += (outlen / 32) * 32; if (outlen % 32) { - haraka_S_squeezeblocks(d, 1, s, 32); + haraka_S_squeezeblocks(d, 1, s); for (i = 0; i < outlen % 32; i++) { out[i] = d[i]; } diff --git a/crypto_sign/sphincs-haraka-256s-robust/clean/haraka.c b/crypto_sign/sphincs-haraka-256s-robust/clean/haraka.c index 420226ad..9eddddd3 100644 --- a/crypto_sign/sphincs-haraka-256s-robust/clean/haraka.c +++ b/crypto_sign/sphincs-haraka-256s-robust/clean/haraka.c @@ -688,41 +688,41 @@ void PQCLEAN_SPHINCSHARAKA256SROBUST_CLEAN_tweak_constants( } } -static void haraka_S_absorb(unsigned char *s, unsigned int r, +static void haraka_S_absorb(unsigned char *s, const unsigned char *m, unsigned long long mlen, unsigned char p) { unsigned long long i; - unsigned char t[r]; + unsigned char t[HARAKAS_RATE]; - while (mlen >= r) { + while (mlen >= HARAKAS_RATE) { /* XOR block to state */ - for (i = 0; i < r; ++i) { + for (i = 0; i < HARAKAS_RATE; ++i) { s[i] ^= m[i]; } PQCLEAN_SPHINCSHARAKA256SROBUST_CLEAN_haraka512_perm(s, s); - mlen -= r; - m += r; + mlen -= HARAKAS_RATE; + m += HARAKAS_RATE; } - for (i = 0; i < r; ++i) { + for (i = 0; i < HARAKAS_RATE; ++i) { t[i] = 0; } for (i = 0; i < mlen; ++i) { t[i] = m[i]; } t[i] = p; - t[r - 1] |= 128; - for (i = 0; i < r; ++i) { + t[HARAKAS_RATE - 1] |= 128; + for (i = 0; i < HARAKAS_RATE; ++i) { s[i] ^= t[i]; } } static void haraka_S_squeezeblocks(unsigned char *h, unsigned long long nblocks, - unsigned char *s, unsigned int r) { + unsigned char *s) { while (nblocks > 0) { PQCLEAN_SPHINCSHARAKA256SROBUST_CLEAN_haraka512_perm(s, s); memcpy(h, s, HARAKAS_RATE); - h += r; + h += HARAKAS_RATE; nblocks--; } } @@ -801,13 +801,13 @@ void PQCLEAN_SPHINCSHARAKA256SROBUST_CLEAN_haraka_S(unsigned char *out, unsigned for (i = 0; i < 64; i++) { s[i] = 0; } - haraka_S_absorb(s, 32, in, inlen, 0x1F); + haraka_S_absorb(s, in, inlen, 0x1F); - haraka_S_squeezeblocks(out, outlen / 32, s, 32); + haraka_S_squeezeblocks(out, outlen / 32, s); out += (outlen / 32) * 32; if (outlen % 32) { - haraka_S_squeezeblocks(d, 1, s, 32); + haraka_S_squeezeblocks(d, 1, s); for (i = 0; i < outlen % 32; i++) { out[i] = d[i]; } diff --git a/crypto_sign/sphincs-haraka-256s-simple/clean/haraka.c b/crypto_sign/sphincs-haraka-256s-simple/clean/haraka.c index e248d7d8..4c535f23 100644 --- a/crypto_sign/sphincs-haraka-256s-simple/clean/haraka.c +++ b/crypto_sign/sphincs-haraka-256s-simple/clean/haraka.c @@ -688,41 +688,41 @@ void PQCLEAN_SPHINCSHARAKA256SSIMPLE_CLEAN_tweak_constants( } } -static void haraka_S_absorb(unsigned char *s, unsigned int r, +static void haraka_S_absorb(unsigned char *s, const unsigned char *m, unsigned long long mlen, unsigned char p) { unsigned long long i; - unsigned char t[r]; + unsigned char t[HARAKAS_RATE]; - while (mlen >= r) { + while (mlen >= HARAKAS_RATE) { /* XOR block to state */ - for (i = 0; i < r; ++i) { + for (i = 0; i < HARAKAS_RATE; ++i) { s[i] ^= m[i]; } PQCLEAN_SPHINCSHARAKA256SSIMPLE_CLEAN_haraka512_perm(s, s); - mlen -= r; - m += r; + mlen -= HARAKAS_RATE; + m += HARAKAS_RATE; } - for (i = 0; i < r; ++i) { + for (i = 0; i < HARAKAS_RATE; ++i) { t[i] = 0; } for (i = 0; i < mlen; ++i) { t[i] = m[i]; } t[i] = p; - t[r - 1] |= 128; - for (i = 0; i < r; ++i) { + t[HARAKAS_RATE - 1] |= 128; + for (i = 0; i < HARAKAS_RATE; ++i) { s[i] ^= t[i]; } } static void haraka_S_squeezeblocks(unsigned char *h, unsigned long long nblocks, - unsigned char *s, unsigned int r) { + unsigned char *s) { while (nblocks > 0) { PQCLEAN_SPHINCSHARAKA256SSIMPLE_CLEAN_haraka512_perm(s, s); memcpy(h, s, HARAKAS_RATE); - h += r; + h += HARAKAS_RATE; nblocks--; } } @@ -801,13 +801,13 @@ void PQCLEAN_SPHINCSHARAKA256SSIMPLE_CLEAN_haraka_S(unsigned char *out, unsigned for (i = 0; i < 64; i++) { s[i] = 0; } - haraka_S_absorb(s, 32, in, inlen, 0x1F); + haraka_S_absorb(s, in, inlen, 0x1F); - haraka_S_squeezeblocks(out, outlen / 32, s, 32); + haraka_S_squeezeblocks(out, outlen / 32, s); out += (outlen / 32) * 32; if (outlen % 32) { - haraka_S_squeezeblocks(d, 1, s, 32); + haraka_S_squeezeblocks(d, 1, s); for (i = 0; i < outlen % 32; i++) { out[i] = d[i]; }