More tests

This commit is contained in:
Frank Denis
2017-07-24 15:16:22 +02:00
parent 67a7df73b1
commit f92c82537b
5 changed files with 42 additions and 9 deletions
+2
View File
@@ -64,6 +64,8 @@ main(void)
assert(ret == -1);
memset(m, 0, sizeof m);
ret = crypto_box_beforenm(k, small_order_p, bobsk);
assert(ret == -1);
ret = crypto_box_beforenm(k, alicepk, bobsk);
assert(ret == 0);
if (crypto_box_open_afternm(m, c, 163, nonce, k) == 0) {
+11 -1
View File
@@ -5,12 +5,22 @@
#include <signal.h>
static void
sigabrt_handler_5(int sig)
sigabrt_handler_6(int sig)
{
(void) sig;
exit(0);
}
static void
sigabrt_handler_5(int sig)
{
(void) sig;
signal(SIGABRT, sigabrt_handler_6);
assert(crypto_aead_xchacha20poly1305_ietf_encrypt(NULL, NULL, NULL, UINT64_MAX,
NULL, 0, NULL, NULL, NULL) == -1);
exit(1);
}
static void
sigabrt_handler_4(int sig)
{
+17
View File
@@ -164,6 +164,11 @@ tv_stream_xchacha20(void)
hex = (char *) sodium_malloc(192 * 2 + 1);
sodium_bin2hex(hex, 192 * 2 + 1, out, 192);
printf("%s\n", hex);
memset(key, 0, crypto_stream_xchacha20_KEYBYTES);
crypto_stream_xchacha20_keygen(key);
assert(sodium_is_zero(key, crypto_stream_xchacha20_KEYBYTES) == 0);
sodium_free(hex);
sodium_free(out);
sodium_free(out2);
@@ -234,6 +239,12 @@ tv_secretbox_xchacha20poly1305(void)
assert(memcmp(out, out2,
crypto_secretbox_xchacha20poly1305_MACBYTES + m_len) == 0);
n = randombytes_uniform(crypto_secretbox_xchacha20poly1305_MACBYTES + m_len);
assert(crypto_secretbox_xchacha20poly1305_open_easy
(out2, out2, crypto_secretbox_xchacha20poly1305_MACBYTES - 1,
nonce, key) == -1);
assert(crypto_secretbox_xchacha20poly1305_open_easy
(out2, out2, 0,
nonce, key) == -1);
out2[n]++;
assert(crypto_secretbox_xchacha20poly1305_open_easy
(out2, out2, crypto_secretbox_xchacha20poly1305_MACBYTES + m_len,
@@ -326,6 +337,12 @@ tv_box_xchacha20poly1305(void)
(out, m, SIZE_MAX, nonce, pc) == -1);
assert(crypto_box_curve25519xchacha20poly1305_easy_afternm
(out, m, m_len, nonce, pc) == 0);
assert(crypto_box_curve25519xchacha20poly1305_open_easy_afternm
(m2, out, crypto_box_curve25519xchacha20poly1305_MACBYTES - 1,
nonce, pc) == -1);
assert(crypto_box_curve25519xchacha20poly1305_open_easy_afternm
(m2, out, 0,
nonce, pc) == -1);
assert(crypto_box_curve25519xchacha20poly1305_open_easy_afternm
(m2, out, crypto_box_curve25519xchacha20poly1305_MACBYTES + m_len,
nonce, pc) == 0);