diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-08-06 18:31:18 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-08-06 19:25:29 +0200 |
commit | 5856479cdaf7e87f2bc46881246607ec3b887dae (patch) | |
tree | bfff84bd6d34cfefa014681629b55a5081d0ed54 /src/selftest/poly1305.h | |
parent | compat: better atomic acquire/release backport (diff) | |
download | wireguard-monolithic-historical-5856479cdaf7e87f2bc46881246607ec3b887dae.tar.xz wireguard-monolithic-historical-5856479cdaf7e87f2bc46881246607ec3b887dae.zip |
crypto: move simd context to specific type
Suggested-by: Andy Lutomirski <luto@kernel.org>
Diffstat (limited to '')
-rw-r--r-- | src/selftest/poly1305.h | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/src/selftest/poly1305.h b/src/selftest/poly1305.h index d1b7227..0ff2301 100644 --- a/src/selftest/poly1305.h +++ b/src/selftest/poly1305.h @@ -6,8 +6,6 @@ #ifdef DEBUG -#include "../crypto/simd.h" - struct poly1305_testdata { size_t size; const u8 data[1024]; @@ -1489,7 +1487,7 @@ static const struct poly1305_testvec poly1305_testvecs[] = { bool __init poly1305_selftest(void) { - bool have_simd = simd_get(); + simd_context_t simd_context = simd_get(); bool success = true; size_t i; @@ -1509,9 +1507,9 @@ bool __init poly1305_selftest(void) memset(out, 0, sizeof(out)); memset(&poly1305, 0, sizeof(poly1305)); - poly1305_init(&poly1305, key, have_simd); - poly1305_update(&poly1305, in, inlen, have_simd); - poly1305_finish(&poly1305, out, have_simd); + poly1305_init(&poly1305, key, simd_context); + poly1305_update(&poly1305, in, inlen, simd_context); + poly1305_finish(&poly1305, out, simd_context); if (memcmp(out, expected, expectedlen)) { pr_info("poly1305 self-test %zu: FAIL\n", i + 1); success = false; @@ -1520,10 +1518,10 @@ bool __init poly1305_selftest(void) if (inlen > 16) { memset(out, 0, sizeof(out)); memset(&poly1305, 0, sizeof(poly1305)); - poly1305_init(&poly1305, key, have_simd); - poly1305_update(&poly1305, in, 1, have_simd); - poly1305_update(&poly1305, in + 1, inlen - 1, have_simd); - poly1305_finish(&poly1305, out, have_simd); + poly1305_init(&poly1305, key, simd_context); + poly1305_update(&poly1305, in, 1, simd_context); + poly1305_update(&poly1305, in + 1, inlen - 1, simd_context); + poly1305_finish(&poly1305, out, simd_context); if (memcmp(out, expected, expectedlen)) { pr_info("poly1305 self-test %zu/1+(N-1): FAIL\n", i + 1); success = false; @@ -1535,10 +1533,10 @@ bool __init poly1305_selftest(void) memset(out, 0, sizeof(out)); memset(&poly1305, 0, sizeof(poly1305)); - poly1305_init(&poly1305, key, have_simd); - poly1305_update(&poly1305, in, half, have_simd); - poly1305_update(&poly1305, in + half, inlen - half, have_simd); - poly1305_finish(&poly1305, out, have_simd); + poly1305_init(&poly1305, key, simd_context); + poly1305_update(&poly1305, in, half, simd_context); + poly1305_update(&poly1305, in + half, inlen - half, simd_context); + poly1305_finish(&poly1305, out, simd_context); if (memcmp(out, expected, expectedlen)) { pr_info("poly1305 self-test %zu/2: FAIL\n", i + 1); success = false; @@ -1547,10 +1545,10 @@ bool __init poly1305_selftest(void) for (half = 16; half < inlen; half += 16) { memset(out, 0, sizeof(out)); memset(&poly1305, 0, sizeof(poly1305)); - poly1305_init(&poly1305, key, have_simd); - poly1305_update(&poly1305, in, half, have_simd); - poly1305_update(&poly1305, in + half, inlen - half, have_simd); - poly1305_finish(&poly1305, out, have_simd); + poly1305_init(&poly1305, key, simd_context); + poly1305_update(&poly1305, in, half, simd_context); + poly1305_update(&poly1305, in + half, inlen - half, simd_context); + poly1305_finish(&poly1305, out, simd_context); if (memcmp(out, expected, expectedlen)) { pr_info("poly1305 self-test %zu/%zu+%zu: FAIL\n", i + 1, half, inlen - half); success = false; @@ -1558,7 +1556,7 @@ bool __init poly1305_selftest(void) } } } - simd_put(have_simd); + simd_put(simd_context); if (success) pr_info("poly1305 self-tests: pass\n"); |