1
1
mirror of https://github.com/henrydcase/pqc.git synced 2024-11-22 23:48:58 +00:00

fixup! Add Dilithium's AVX2 implementations

This commit is contained in:
Thom Wiggers 2019-12-09 09:59:28 +01:00 committed by Kris Kwiatkowski
parent 377d0cbf1a
commit 6cd265f5b9
6 changed files with 9 additions and 13 deletions

View File

@ -296,11 +296,10 @@ static unsigned int rej_uniform(uint32_t *a,
void PQCLEAN_DILITHIUM2_CLEAN_poly_uniform(poly *a, void PQCLEAN_DILITHIUM2_CLEAN_poly_uniform(poly *a,
const uint8_t seed[SEEDBYTES], const uint8_t seed[SEEDBYTES],
uint16_t nonce) { uint16_t nonce) {
unsigned int i, ctr; size_t ctr, off;
size_t buflen = POLY_UNIFORM_BUFLEN; size_t buflen = POLY_UNIFORM_BUFLEN;
uint8_t buf[POLY_UNIFORM_BUFLEN + 2]; uint8_t buf[POLY_UNIFORM_BUFLEN + 2];
stream128_state state; stream128_state state;
size_t off;
stream128_init(&state, seed, nonce); stream128_init(&state, seed, nonce);
stream128_squeezeblocks(buf, POLY_UNIFORM_NBLOCKS, &state); stream128_squeezeblocks(buf, POLY_UNIFORM_NBLOCKS, &state);
@ -309,7 +308,7 @@ void PQCLEAN_DILITHIUM2_CLEAN_poly_uniform(poly *a,
while (ctr < N) { while (ctr < N) {
off = buflen % 3; off = buflen % 3;
for (i = 0; i < off; ++i) { for (size_t i = 0; i < off; ++i) {
buf[i] = buf[buflen - off + i]; buf[i] = buf[buflen - off + i];
} }

View File

@ -296,11 +296,10 @@ static unsigned int rej_uniform(uint32_t *a,
void PQCLEAN_DILITHIUM3_CLEAN_poly_uniform(poly *a, void PQCLEAN_DILITHIUM3_CLEAN_poly_uniform(poly *a,
const uint8_t seed[SEEDBYTES], const uint8_t seed[SEEDBYTES],
uint16_t nonce) { uint16_t nonce) {
unsigned int i, ctr; size_t ctr, off;
size_t buflen = POLY_UNIFORM_BUFLEN; size_t buflen = POLY_UNIFORM_BUFLEN;
uint8_t buf[POLY_UNIFORM_BUFLEN + 2]; uint8_t buf[POLY_UNIFORM_BUFLEN + 2];
stream128_state state; stream128_state state;
size_t off;
stream128_init(&state, seed, nonce); stream128_init(&state, seed, nonce);
stream128_squeezeblocks(buf, POLY_UNIFORM_NBLOCKS, &state); stream128_squeezeblocks(buf, POLY_UNIFORM_NBLOCKS, &state);
@ -309,7 +308,7 @@ void PQCLEAN_DILITHIUM3_CLEAN_poly_uniform(poly *a,
while (ctr < N) { while (ctr < N) {
off = buflen % 3; off = buflen % 3;
for (i = 0; i < off; ++i) { for (size_t i = 0; i < off; ++i) {
buf[i] = buf[buflen - off + i]; buf[i] = buf[buflen - off + i];
} }

View File

@ -296,11 +296,10 @@ static unsigned int rej_uniform(uint32_t *a,
void PQCLEAN_DILITHIUM4_CLEAN_poly_uniform(poly *a, void PQCLEAN_DILITHIUM4_CLEAN_poly_uniform(poly *a,
const uint8_t seed[SEEDBYTES], const uint8_t seed[SEEDBYTES],
uint16_t nonce) { uint16_t nonce) {
unsigned int i, ctr; size_t ctr, off;
size_t buflen = POLY_UNIFORM_BUFLEN; size_t buflen = POLY_UNIFORM_BUFLEN;
uint8_t buf[POLY_UNIFORM_BUFLEN + 2]; uint8_t buf[POLY_UNIFORM_BUFLEN + 2];
stream128_state state; stream128_state state;
size_t off;
stream128_init(&state, seed, nonce); stream128_init(&state, seed, nonce);
stream128_squeezeblocks(buf, POLY_UNIFORM_NBLOCKS, &state); stream128_squeezeblocks(buf, POLY_UNIFORM_NBLOCKS, &state);
@ -309,7 +308,7 @@ void PQCLEAN_DILITHIUM4_CLEAN_poly_uniform(poly *a,
while (ctr < N) { while (ctr < N) {
off = buflen % 3; off = buflen % 3;
for (i = 0; i < off; ++i) { for (size_t i = 0; i < off; ++i) {
buf[i] = buf[buflen - off + i]; buf[i] = buf[buflen - off + i];
} }

View File

@ -41,7 +41,7 @@ consistency_checks:
- stream.h - stream.h
- symmetric.h - symmetric.h
- source: - source:
scheme: dilithium2 scheme: dilithium3
implementation: avx2 implementation: avx2
files: files:
- api.h - api.h

View File

@ -40,7 +40,7 @@ consistency_checks:
- stream.h - stream.h
- symmetric.h - symmetric.h
- source: - source:
scheme: dilithium2 scheme: dilithium4
implementation: avx2 implementation: avx2
files: files:
- api.h - api.h
@ -51,4 +51,3 @@ consistency_checks:
- stream.c - stream.c
- stream.h - stream.h
- symmetric.h - symmetric.h

View File

@ -26,7 +26,7 @@ def valgrind_supports_exit_early():
@pytest.mark.parametrize( @pytest.mark.parametrize(
'implementation,test_dir,impl_path, init, destr', 'implementation,test_dir,impl_path, init, destr',
[(impl, *helpers.isolate_test_files(impl.path(), 'test_functest_')) [(impl, *helpers.isolate_test_files(impl.path(), 'test_valgrind_'))
for impl in pqclean.Scheme.all_supported_implementations()], for impl in pqclean.Scheme.all_supported_implementations()],
ids=[str(impl) for impl in pqclean.Scheme.all_supported_implementations()], ids=[str(impl) for impl in pqclean.Scheme.all_supported_implementations()],
) )