.PHONY: all clean
-VEC = chacha20 hchacha20 xchacha20 ietf_chacha20 aead_ietf \
- poly1305 blake2b sha512 hmac_sha512 argon2i \
- edDSA edDSA_pk ed_25519 ed_25519_check \
+VEC = chacha20 hchacha20 xchacha20 ietf_chacha20 aead_ietf \
+ poly1305 blake2b sha512 hmac_sha512 argon2i \
+ edDSA edDSA_pk ed_25519 ed_25519_pk ed_25519_check \
x25519 x25519_pk key_exchange
# monokex_xk1 monokex_x
VEC2 = $(patsubst %, %.all.vec, $(VEC))
edDSA.all.vec : edDSA.vec
edDSA_pk.all.vec : edDSA_pk.vec
ed_25519.all.vec : ed_25519.vec
+ed_25519_pk.all.vec : ed_25519_pk.vec
ed_25519_check.all.vec: vectors/ed_25519_check
key_exchange.all.vec : vectors/key_exchange
monokex_xk1.all.vec : monokex_xk1.vec
}
}
+static void ed_25519_pk(const vector in[], vector *out)
+{
+ crypto_ed25519_public_key(out->buf, in->buf);
+}
+
static void ed_25519_check(const vector in[], vector *out)
{
const vector *public_k = in;
static int p_verify32(){ return p_verify(32, crypto_verify32); }
static int p_verify64(){ return p_verify(64, crypto_verify64); }
+static int p_chacha20_ctr()
+{
+ int status = 0;
+ RANDOM_INPUT(key , 32);
+ RANDOM_INPUT(nonce, 24);
+ RANDOM_INPUT(plain, 128);
+ u8 out_full[128];
+ u8 out1 [64];
+ u8 out2 [64];
+ crypto_chacha20 (out_full, plain , 128, key, nonce);
+ crypto_chacha20_ctr(out1 , plain + 0, 64, key, nonce, 0);
+ crypto_chacha20_ctr(out2 , plain + 64, 64, key, nonce, 1);
+ status |= memcmp(out_full , out1, 64);
+ status |= memcmp(out_full + 64, out2, 64);
+
+ crypto_ietf_chacha20 (out_full, plain , 128, key, nonce);
+ crypto_ietf_chacha20_ctr(out1 , plain + 0, 64, key, nonce, 0);
+ crypto_ietf_chacha20_ctr(out2 , plain + 64, 64, key, nonce, 1);
+ status |= memcmp(out_full , out1, 64);
+ status |= memcmp(out_full + 64, out2, 64);
+
+ crypto_xchacha20 (out_full, plain , 128, key, nonce);
+ crypto_xchacha20_ctr(out1 , plain + 0, 64, key, nonce, 0);
+ crypto_xchacha20_ctr(out2 , plain + 64, 64, key, nonce, 1);
+ status |= memcmp(out_full , out1, 64);
+ status |= memcmp(out_full + 64, out2, 64);
+
+ printf("%s: Chacha20 (ctr)\n", status != 0 ? "FAILED" : "OK");
+ return status;
+}
+
// Tests that Chacha20(nullptr) == Chacha20(all-zeroes)
static int p_chacha20_stream()
{
status |= TEST(edDSA , 3);
status |= TEST(edDSA_pk , 1);
status |= TEST(ed_25519 , 3);
+ status |= TEST(ed_25519_pk , 1);
status |= TEST(ed_25519_check, 3);
status |= test_x25519();
status |= p_verify16();
status |= p_verify32();
status |= p_verify64();
+ status |= p_chacha20_ctr();
status |= p_chacha20_stream();
status |= p_chacha20_same_ptr();
status |= p_hchacha20();