diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-09-25 23:01:32 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-09-25 23:26:35 +0200 |
commit | 38c18b1364f7afa358b1a96464c0a4d6f737c78f (patch) | |
tree | 4048844deb9625c25f874e56ad336e9d0642d0df /src/crypto/zinc/selftest | |
parent | b161ec0f59cb93132fe6289f2b19a2fb7f893595 (diff) |
crypto: rename DEBUG to SELFTEST
Also we make selftest errors of type err, so that they're obvious in
dmesg.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/crypto/zinc/selftest')
-rw-r--r-- | src/crypto/zinc/selftest/blake2s.h | 6 | ||||
-rw-r--r-- | src/crypto/zinc/selftest/chacha20.h | 45 | ||||
-rw-r--r-- | src/crypto/zinc/selftest/chacha20poly1305.h | 28 | ||||
-rw-r--r-- | src/crypto/zinc/selftest/curve25519.h | 8 | ||||
-rw-r--r-- | src/crypto/zinc/selftest/poly1305.h | 12 |
5 files changed, 49 insertions, 50 deletions
diff --git a/src/crypto/zinc/selftest/blake2s.h b/src/crypto/zinc/selftest/blake2s.h index b15cc56..e6f8b2a 100644 --- a/src/crypto/zinc/selftest/blake2s.h +++ b/src/crypto/zinc/selftest/blake2s.h @@ -3,7 +3,7 @@ * Copyright (C) 2015-2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. */ -#ifdef DEBUG +#ifdef CONFIG_ZINC_SELFTEST 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, @@ -2075,7 +2075,7 @@ static bool __init blake2s_selftest(void) for (i = 0; i < ARRAY_SIZE(blake2s_keyed_testvecs); ++i) { 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); + pr_err("blake2s keyed self-test %zu: FAIL\n", i + 1); success = false; } } @@ -2083,7 +2083,7 @@ static bool __init blake2s_selftest(void) for (i = 0; i < ARRAY_SIZE(blake2s_testvecs); ++i) { 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); + pr_err("blake2s unkeyed self-test %zu: FAIL\n", i + i); success = false; } } diff --git a/src/crypto/zinc/selftest/chacha20.h b/src/crypto/zinc/selftest/chacha20.h index 397a4b9..16add65 100644 --- a/src/crypto/zinc/selftest/chacha20.h +++ b/src/crypto/zinc/selftest/chacha20.h @@ -3,8 +3,7 @@ * Copyright (C) 2015-2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. */ -#ifdef DEBUG - +#ifdef CONFIG_ZINC_SELFTEST struct chacha20_testvec { const u8 *input, *output, *key; u64 nonce; @@ -2529,7 +2528,7 @@ static bool __init chacha20_selftest(void) offset_input = kmalloc(MAXIMUM_TEST_BUFFER_LEN + 1, GFP_KERNEL); computed_output = kmalloc(MAXIMUM_TEST_BUFFER_LEN + 1, GFP_KERNEL); if (!computed_output || !offset_input) { - pr_info("chacha20 self-test malloc: FAIL\n"); + pr_err("chacha20 self-test malloc: FAIL\n"); success = false; goto out; } @@ -2545,14 +2544,14 @@ static bool __init chacha20_selftest(void) chacha20_testvecs[i].ilen, &simd_context); if (memcmp(computed_output, chacha20_testvecs[i].output, chacha20_testvecs[i].ilen)) { - pr_info("chacha20 self-test %zu: FAIL\n", i + 1); + pr_err("chacha20 self-test %zu: FAIL\n", i + 1); success = false; } for (k = chacha20_testvecs[i].ilen; k < MAXIMUM_TEST_BUFFER_LEN + 1; ++k) { if (computed_output[k]) { - pr_info("chacha20 self-test %zu (zero check): FAIL\n", - i + 1); + pr_err("chacha20 self-test %zu (zero check): FAIL\n", + i + 1); success = false; } } @@ -2569,20 +2568,20 @@ static bool __init chacha20_selftest(void) chacha20_testvecs[i].ilen, &simd_context); if (memcmp(computed_output + 1, chacha20_testvecs[i].output, chacha20_testvecs[i].ilen)) { - pr_info("chacha20 self-test %zu (unaligned): FAIL\n", - i + 1); + pr_err("chacha20 self-test %zu (unaligned): FAIL\n", + i + 1); success = false; } if (computed_output[0]) { - pr_info("chacha20 self-test %zu (unaligned, zero check): FAIL\n", - i + 1); + pr_err("chacha20 self-test %zu (unaligned, zero check): FAIL\n", + i + 1); success = false; } for (k = chacha20_testvecs[i].ilen + 1; k < MAXIMUM_TEST_BUFFER_LEN + 1; ++k) { if (computed_output[k]) { - pr_info("chacha20 self-test %zu (unaligned, zero check): FAIL\n", - i + 1); + pr_err("chacha20 self-test %zu (unaligned, zero check): FAIL\n", + i + 1); success = false; } } @@ -2602,15 +2601,15 @@ static bool __init chacha20_selftest(void) &simd_context); if (memcmp(computed_output, chacha20_testvecs[i].output, chacha20_testvecs[i].ilen)) { - pr_info("chacha20 self-test %zu (chunked): FAIL\n", - i + 1); + pr_err("chacha20 self-test %zu (chunked): FAIL\n", + i + 1); success = false; } for (k = chacha20_testvecs[i].ilen; k < MAXIMUM_TEST_BUFFER_LEN + 1; ++k) { if (computed_output[k]) { - pr_info("chacha20 self-test %zu (chunked, zero check): FAIL\n", - i + 1); + pr_err("chacha20 self-test %zu (chunked, zero check): FAIL\n", + i + 1); success = false; } } @@ -2632,22 +2631,22 @@ next_test: if (memcmp(computed_output + j, chacha20_testvecs[i].output, chacha20_testvecs[i].ilen)) { - pr_info("chacha20 self-test %zu (unaligned, slide %zu): FAIL\n", - i + 1, j); + pr_err("chacha20 self-test %zu (unaligned, slide %zu): FAIL\n", + i + 1, j); success = false; } for (k = j; k < j; ++k) { if (computed_output[k]) { - pr_info("chacha20 self-test %zu (unaligned, slide %zu, zero check): FAIL\n", - i + 1, j); + pr_err("chacha20 self-test %zu (unaligned, slide %zu, zero check): FAIL\n", + i + 1, j); success = false; } } for (k = chacha20_testvecs[i].ilen + j; k < MAXIMUM_TEST_BUFFER_LEN + 1; ++k) { if (computed_output[k]) { - pr_info("chacha20 self-test %zu (unaligned, slide %zu, zero check): FAIL\n", - i + 1, j); + pr_err("chacha20 self-test %zu (unaligned, slide %zu, zero check): FAIL\n", + i + 1, j); success = false; } } @@ -2660,7 +2659,7 @@ next_test: cpu_to_le32_array(derived_key, ARRAY_SIZE(derived_key)); if (memcmp(derived_key, hchacha20_testvecs[i].output, CHACHA20_KEY_SIZE)) { - pr_info("hchacha20 self-test %zu: FAIL\n", i + 1); + pr_err("hchacha20 self-test %zu: FAIL\n", i + 1); success = false; } } diff --git a/src/crypto/zinc/selftest/chacha20poly1305.h b/src/crypto/zinc/selftest/chacha20poly1305.h index 0510a8e..9f42252 100644 --- a/src/crypto/zinc/selftest/chacha20poly1305.h +++ b/src/crypto/zinc/selftest/chacha20poly1305.h @@ -3,7 +3,7 @@ * Copyright (C) 2015-2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. */ -#ifdef DEBUG +#ifdef CONFIG_ZINC_SELFTEST struct chacha20poly1305_testvec { const u8 *input, *output, *assoc, *nonce, *key; size_t ilen, alen, nlen; @@ -8889,7 +8889,7 @@ static bool __init chacha20poly1305_selftest(void) heap_src = kmalloc(MAXIMUM_TEST_BUFFER_LEN, GFP_KERNEL); computed_output = kmalloc(MAXIMUM_TEST_BUFFER_LEN, GFP_KERNEL); if (!heap_src || !computed_output) { - pr_info("chacha20poly1305 self-test malloc: FAIL\n"); + pr_err("chacha20poly1305 self-test malloc: FAIL\n"); success = false; goto out; } @@ -8908,8 +8908,8 @@ static bool __init chacha20poly1305_selftest(void) chacha20poly1305_enc_vectors[i].output, chacha20poly1305_enc_vectors[i].ilen + POLY1305_MAC_SIZE)) { - pr_info("chacha20poly1305 encryption self-test %zu: FAIL\n", - i + 1); + pr_err("chacha20poly1305 encryption self-test %zu: FAIL\n", + i + 1); success = false; } } @@ -8936,8 +8936,8 @@ static bool __init chacha20poly1305_selftest(void) chacha20poly1305_enc_vectors[i].output, chacha20poly1305_enc_vectors[i].ilen + POLY1305_MAC_SIZE)) { - pr_info("chacha20poly1305 sg encryption self-test %zu: FAIL\n", - i + 1); + pr_err("chacha20poly1305 sg encryption self-test %zu: FAIL\n", + i + 1); success = false; } } @@ -8957,8 +8957,8 @@ static bool __init chacha20poly1305_selftest(void) chacha20poly1305_dec_vectors[i].output, chacha20poly1305_dec_vectors[i].ilen - POLY1305_MAC_SIZE))) { - pr_info("chacha20poly1305 decryption self-test %zu: FAIL\n", - i + 1); + pr_err("chacha20poly1305 decryption self-test %zu: FAIL\n", + i + 1); success = false; } } @@ -8983,8 +8983,8 @@ static bool __init chacha20poly1305_selftest(void) memcmp(computed_output, chacha20poly1305_dec_vectors[i].output, chacha20poly1305_dec_vectors[i].ilen - POLY1305_MAC_SIZE))) { - pr_info("chacha20poly1305 sg decryption self-test %zu: FAIL\n", - i + 1); + pr_err("chacha20poly1305 sg decryption self-test %zu: FAIL\n", + i + 1); success = false; } } @@ -9002,8 +9002,8 @@ static bool __init chacha20poly1305_selftest(void) xchacha20poly1305_enc_vectors[i].output, xchacha20poly1305_enc_vectors[i].ilen + POLY1305_MAC_SIZE)) { - pr_info("xchacha20poly1305 encryption self-test %zu: FAIL\n", - i + 1); + pr_err("xchacha20poly1305 encryption self-test %zu: FAIL\n", + i + 1); success = false; } } @@ -9022,8 +9022,8 @@ static bool __init chacha20poly1305_selftest(void) xchacha20poly1305_dec_vectors[i].output, xchacha20poly1305_dec_vectors[i].ilen - POLY1305_MAC_SIZE))) { - pr_info("xchacha20poly1305 decryption self-test %zu: FAIL\n", - i + 1); + pr_err("xchacha20poly1305 decryption self-test %zu: FAIL\n", + i + 1); success = false; } } diff --git a/src/crypto/zinc/selftest/curve25519.h b/src/crypto/zinc/selftest/curve25519.h index f529b7b..8ea9f92 100644 --- a/src/crypto/zinc/selftest/curve25519.h +++ b/src/crypto/zinc/selftest/curve25519.h @@ -3,7 +3,7 @@ * Copyright (C) 2015-2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. */ -#ifdef DEBUG +#ifdef CONFIG_ZINC_SELFTEST struct curve25519_test_vector { u8 private[CURVE25519_KEY_SIZE]; u8 public[CURVE25519_KEY_SIZE]; @@ -1293,7 +1293,7 @@ static bool __init curve25519_selftest(void) if (ret != curve25519_test_vectors[i].valid || memcmp(out, curve25519_test_vectors[i].result, CURVE25519_KEY_SIZE)) { - pr_info("curve25519 self-test %zu: FAIL\n", i + 1); + pr_err("curve25519 self-test %zu: FAIL\n", i + 1); success = false; } } @@ -1303,8 +1303,8 @@ static bool __init curve25519_selftest(void) ret = curve25519_generate_public(out, in); 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); + pr_err("curve25519 basepoint self-test %zu: FAIL: input - 0x", + i + 1); for (j = CURVE25519_KEY_SIZE; j-- > 0;) printk(KERN_CONT "%02x", in[j]); printk(KERN_CONT "\n"); diff --git a/src/crypto/zinc/selftest/poly1305.h b/src/crypto/zinc/selftest/poly1305.h index e806ab2..9c12feb 100644 --- a/src/crypto/zinc/selftest/poly1305.h +++ b/src/crypto/zinc/selftest/poly1305.h @@ -3,7 +3,7 @@ * Copyright (C) 2015-2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. */ -#ifdef DEBUG +#ifdef CONFIG_ZINC_SELFTEST struct poly1305_testvec { const u8 *input, *output, *key; size_t ilen; @@ -1057,7 +1057,7 @@ static bool __init poly1305_selftest(void) poly1305_final(&poly1305, out, &simd_context); if (memcmp(out, poly1305_testvecs[i].output, POLY1305_MAC_SIZE)) { - pr_info("poly1305 self-test %zu: FAIL\n", i + 1); + pr_err("poly1305 self-test %zu: FAIL\n", i + 1); success = false; } simd_relax(&simd_context); @@ -1078,8 +1078,8 @@ static bool __init poly1305_selftest(void) poly1305_final(&poly1305, out, &simd_context); if (memcmp(out, poly1305_testvecs[i].output, POLY1305_MAC_SIZE)) { - pr_info("poly1305 self-test %zu (split %zu): FAIL\n", - i + 1, j); + pr_err("poly1305 self-test %zu (split %zu): FAIL\n", + i + 1, j); success = false; } @@ -1095,8 +1095,8 @@ static bool __init poly1305_selftest(void) poly1305_final(&poly1305, out, &simd_context); if (memcmp(out, poly1305_testvecs[i].output, POLY1305_MAC_SIZE)) { - pr_info("poly1305 self-test %zu (split %zu, mixed simd): FAIL\n", - i + 1, j); + pr_err("poly1305 self-test %zu (split %zu, mixed simd): FAIL\n", + i + 1, j); success = false; } simd_relax(&simd_context); |