summaryrefslogtreecommitdiffhomepage
path: root/src/crypto/zinc/selftest
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-09-24 22:02:13 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-09-25 03:01:21 +0200
commit6b7d734ee75319cc421c57f47d295ed911033947 (patch)
tree8176c3bd3b3e4e9c0157b256d11749530dbfd5e9 /src/crypto/zinc/selftest
parent3106f71185676be1b95a814e9015525dd17ab19c (diff)
crypto: make constant naming scheme consistent
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/crypto/zinc/selftest')
-rw-r--r--src/crypto/zinc/selftest/blake2s.h18
-rw-r--r--src/crypto/zinc/selftest/chacha20poly1305.h4
-rw-r--r--src/crypto/zinc/selftest/curve25519.h20
3 files changed, 21 insertions, 21 deletions
diff --git a/src/crypto/zinc/selftest/blake2s.h b/src/crypto/zinc/selftest/blake2s.h
index dea18f4..b15cc56 100644
--- a/src/crypto/zinc/selftest/blake2s.h
+++ b/src/crypto/zinc/selftest/blake2s.h
@@ -4,7 +4,7 @@
*/
#ifdef DEBUG
-static const u8 blake2s_testvecs[][BLAKE2S_OUTBYTES] __initconst = {
+static const u8 blake2s_testvecs[][BLAKE2S_HASH_SIZE] __initconst = {
{ 0x69, 0x21, 0x7a, 0x30, 0x79, 0x90, 0x80, 0x94,
0xe1, 0x11, 0x21, 0xd0, 0x42, 0x35, 0x4a, 0x7c,
0x1f, 0x55, 0xb6, 0x48, 0x2c, 0xa1, 0xa5, 0x1e,
@@ -1031,7 +1031,7 @@ static const u8 blake2s_testvecs[][BLAKE2S_OUTBYTES] __initconst = {
0x86, 0xaa, 0x99, 0x4a, 0xcb, 0x38, 0xfe, 0x2d }
};
-static const u8 blake2s_keyed_testvecs[][BLAKE2S_OUTBYTES] __initconst = {
+static const u8 blake2s_keyed_testvecs[][BLAKE2S_HASH_SIZE] __initconst = {
{ 0x48, 0xa8, 0x99, 0x7d, 0xa4, 0x07, 0x87, 0x6b,
0x3d, 0x79, 0xc0, 0xd9, 0x23, 0x25, 0xad, 0x3b,
0x89, 0xcb, 0xb7, 0x54, 0xd8, 0x6a, 0xb7, 0x1a,
@@ -2060,29 +2060,29 @@ static const u8 blake2s_keyed_testvecs[][BLAKE2S_OUTBYTES] __initconst = {
static bool __init blake2s_selftest(void)
{
- u8 key[BLAKE2S_KEYBYTES];
+ u8 key[BLAKE2S_KEY_SIZE];
u8 buf[ARRAY_SIZE(blake2s_testvecs)];
- u8 hash[BLAKE2S_OUTBYTES];
+ u8 hash[BLAKE2S_HASH_SIZE];
size_t i;
bool success = true;
- for (i = 0; i < BLAKE2S_KEYBYTES; ++i)
+ for (i = 0; i < BLAKE2S_KEY_SIZE; ++i)
key[i] = (u8)i;
for (i = 0; i < ARRAY_SIZE(blake2s_testvecs); ++i)
buf[i] = (u8)i;
for (i = 0; i < ARRAY_SIZE(blake2s_keyed_testvecs); ++i) {
- blake2s(hash, buf, key, BLAKE2S_OUTBYTES, i, BLAKE2S_KEYBYTES);
- if (memcmp(hash, blake2s_keyed_testvecs[i], BLAKE2S_OUTBYTES)) {
+ blake2s(hash, buf, key, BLAKE2S_HASH_SIZE, i, BLAKE2S_KEY_SIZE);
+ if (memcmp(hash, blake2s_keyed_testvecs[i], BLAKE2S_HASH_SIZE)) {
pr_info("blake2s keyed self-test %zu: FAIL\n", i + 1);
success = false;
}
}
for (i = 0; i < ARRAY_SIZE(blake2s_testvecs); ++i) {
- blake2s(hash, buf, NULL, BLAKE2S_OUTBYTES, i, 0);
- if (memcmp(hash, blake2s_testvecs[i], BLAKE2S_OUTBYTES)) {
+ blake2s(hash, buf, NULL, BLAKE2S_HASH_SIZE, i, 0);
+ if (memcmp(hash, blake2s_testvecs[i], BLAKE2S_HASH_SIZE)) {
pr_info("blake2s unkeyed self-test %zu: FAIL\n", i + i);
success = false;
}
diff --git a/src/crypto/zinc/selftest/chacha20poly1305.h b/src/crypto/zinc/selftest/chacha20poly1305.h
index 2a75dfa..0510a8e 100644
--- a/src/crypto/zinc/selftest/chacha20poly1305.h
+++ b/src/crypto/zinc/selftest/chacha20poly1305.h
@@ -8817,7 +8817,7 @@ chacha20poly1305_selftest_encrypt_bignonce(u8 *dst, const u8 *src,
const size_t src_len, const u8 *ad,
const size_t ad_len,
const u8 nonce[12],
- const u8 key[CHACHA20POLY1305_KEYLEN])
+ const u8 key[CHACHA20POLY1305_KEY_SIZE])
{
simd_context_t simd_context;
struct poly1305_ctx poly1305_state;
@@ -8856,7 +8856,7 @@ static void __init
chacha20poly1305_selftest_encrypt(u8 *dst, const u8 *src, const size_t src_len,
const u8 *ad, const size_t ad_len,
const u8 *nonce, const size_t nonce_len,
- const u8 key[CHACHA20POLY1305_KEYLEN])
+ const u8 key[CHACHA20POLY1305_KEY_SIZE])
{
if (nonce_len == 8)
chacha20poly1305_encrypt(dst, src, src_len, ad, ad_len,
diff --git a/src/crypto/zinc/selftest/curve25519.h b/src/crypto/zinc/selftest/curve25519.h
index 5d3f268..8c11d80 100644
--- a/src/crypto/zinc/selftest/curve25519.h
+++ b/src/crypto/zinc/selftest/curve25519.h
@@ -5,9 +5,9 @@
#ifdef DEBUG
struct curve25519_test_vector {
- u8 private[CURVE25519_POINT_SIZE];
- u8 public[CURVE25519_POINT_SIZE];
- u8 result[CURVE25519_POINT_SIZE];
+ u8 private[CURVE25519_KEY_SIZE];
+ u8 public[CURVE25519_KEY_SIZE];
+ u8 result[CURVE25519_KEY_SIZE];
bool valid;
};
static const struct curve25519_test_vector curve25519_test_vectors[] __initconst = {
@@ -1283,16 +1283,16 @@ static bool __init curve25519_selftest(void)
{
bool success = true, ret, ret2;
size_t i = 0, j;
- u8 in[CURVE25519_POINT_SIZE];
- u8 out[CURVE25519_POINT_SIZE], out2[CURVE25519_POINT_SIZE];
+ u8 in[CURVE25519_KEY_SIZE];
+ u8 out[CURVE25519_KEY_SIZE], out2[CURVE25519_KEY_SIZE];
for (i = 0; i < ARRAY_SIZE(curve25519_test_vectors); ++i) {
- memset(out, 0, CURVE25519_POINT_SIZE);
+ memset(out, 0, CURVE25519_KEY_SIZE);
ret = curve25519(out, curve25519_test_vectors[i].private,
curve25519_test_vectors[i].public);
if (ret != curve25519_test_vectors[i].valid ||
memcmp(out, curve25519_test_vectors[i].result,
- CURVE25519_POINT_SIZE)) {
+ CURVE25519_KEY_SIZE)) {
pr_info("curve25519 self-test %zu: FAIL\n", i + 1);
success = false;
break;
@@ -1302,11 +1302,11 @@ static bool __init curve25519_selftest(void)
for (i = 0; i < 5; ++i) {
get_random_bytes(in, sizeof(in));
ret = curve25519_generate_public(out, in);
- ret2 = curve25519(out2, in, (u8[CURVE25519_POINT_SIZE]){ 9 });
- if (ret != ret2 || memcmp(out, out2, CURVE25519_POINT_SIZE)) {
+ ret2 = curve25519(out2, in, (u8[CURVE25519_KEY_SIZE]){ 9 });
+ if (ret != ret2 || memcmp(out, out2, CURVE25519_KEY_SIZE)) {
pr_info("curve25519 basepoint self-test %zu: FAIL: input - 0x",
i + 1);
- for (j = CURVE25519_POINT_SIZE; j-- > 0;)
+ for (j = CURVE25519_KEY_SIZE; j-- > 0;)
printk(KERN_CONT "%02x", in[j]);
printk(KERN_CONT "\n");
success = false;