summaryrefslogtreecommitdiffhomepage
path: root/src/crypto/zinc/selftest/chacha20poly1305.h
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-09-20 19:26:43 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-09-23 17:05:10 +0200
commit27d9a33a0e117558a42f6642f753e52388be45ad (patch)
tree8e3a57f826f0b1d2809679b6d78ce34befbfd91a /src/crypto/zinc/selftest/chacha20poly1305.h
parent1e4a1352ce4d4e6bc883e3e520e62d1d00c9f909 (diff)
chacha20: add chunked selftest and test sliding alignments and hchacha20
This ensures we're properly updating state[12] and that we're handling all unaligned acceses (in the jump tables for MIPS). Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/crypto/zinc/selftest/chacha20poly1305.h')
-rw-r--r--src/crypto/zinc/selftest/chacha20poly1305.h65
1 files changed, 1 insertions, 64 deletions
diff --git a/src/crypto/zinc/selftest/chacha20poly1305.h b/src/crypto/zinc/selftest/chacha20poly1305.h
index 100344a..5133231 100644
--- a/src/crypto/zinc/selftest/chacha20poly1305.h
+++ b/src/crypto/zinc/selftest/chacha20poly1305.h
@@ -11,74 +11,11 @@ struct chacha20poly1305_testvec {
};
/* The first of these are the ChaCha20-Poly1305 AEAD test vectors from RFC7539
- * 2.8.2. After they are generated by the below python program. And the final
+ * 2.8.2. After they are generated by reference implementations. And the final
* marked ones are taken from wycheproof, but we only do these for the encrypt
* side, because mostly we're stressing the primitives rather than the actual
* chapoly construction. This also requires adding a 96-bit nonce construction,
* just for the purpose of the tests.
- *
- * #!/usr/bin/env python3
- *
- * from cryptography.hazmat.primitives.ciphers.aead import ChaCha20Poly1305
- * import os
- *
- * def encode_blob(blob):
- * a = ""
- * for i in blob:
- * a += "\\x" + hex(i)[2:]
- * return a
- *
- * enc = [ ]
- * dec = [ ]
- *
- * def make_vector(plen, adlen):
- * key = os.urandom(32)
- * nonce = os.urandom(8)
- * p = os.urandom(plen)
- * ad = os.urandom(adlen)
- * c = ChaCha20Poly1305(key).encrypt(nonce=bytes(4) + nonce, data=p, associated_data=ad)
- *
- * out = "{\n"
- * out += "\t.key\t= \"" + encode_blob(key) + "\",\n"
- * out += "\t.nonce\t= \"" + encode_blob(nonce) + "\",\n"
- * out += "\t.assoc\t= \"" + encode_blob(ad) + "\",\n"
- * out += "\t.alen\t= " + str(len(ad)) + ",\n"
- * out += "\t.input\t= \"" + encode_blob(p) + "\",\n"
- * out += "\t.ilen\t= " + str(len(p)) + ",\n"
- * out += "\t.output\t= \"" + encode_blob(c) + "\"\n"
- * out += "}"
- * enc.append(out)
- *
- *
- * out = "{\n"
- * out += "\t.key\t= \"" + encode_blob(key) + "\",\n"
- * out += "\t.nonce\t= \"" + encode_blob(nonce) + "\",\n"
- * out += "\t.assoc\t= \"" + encode_blob(ad) + "\",\n"
- * out += "\t.alen\t= " + str(len(ad)) + ",\n"
- * out += "\t.input\t= \"" + encode_blob(c) + "\",\n"
- * out += "\t.ilen\t= " + str(len(c)) + ",\n"
- * out += "\t.output\t= \"" + encode_blob(p) + "\"\n"
- * out += "}"
- * dec.append(out)
- *
- *
- * make_vector(0, 0)
- * make_vector(0, 8)
- * make_vector(1, 8)
- * make_vector(1, 0)
- * make_vector(129, 7)
- * make_vector(256, 0)
- * make_vector(512, 0)
- * make_vector(513, 9)
- * make_vector(1024, 16)
- * make_vector(1933, 7)
- * make_vector(2011, 63)
- *
- * print("======== encryption vectors ========")
- * print(", ".join(enc))
- *
- * print("\n\n\n======== decryption vectors ========")
- * print(", ".join(dec))
*/
static const u8 enc_input001[] __initconst = {