Added "ctmulq" implementation of Poly1305 (using 64->128 multiplications when available).

This commit is contained in:
Thomas Pornin 2017-03-18 16:46:00 +01:00
parent 2f88a67304
commit 5db2d48b12
10 changed files with 588 additions and 17 deletions

View file

@ -4190,24 +4190,12 @@ test_Poly1305_inner(const char *name, br_poly1305_run ipoly,
memcpy(data, plain, len);
ipoly(key, nonce, data, len,
aad, aad_len, tmp, br_chacha20_ct_run, 1);
if (memcmp(data, cipher, len) != 0) {
fprintf(stderr, "ChaCha20+Poly1305 KAT failed (1)\n");
exit(EXIT_FAILURE);
}
if (memcmp(tmp, tag, 16) != 0) {
fprintf(stderr, "ChaCha20+Poly1305 KAT failed (2)\n");
exit(EXIT_FAILURE);
}
check_equals("ChaCha20+Poly1305 KAT (1)", data, cipher, len);
check_equals("ChaCha20+Poly1305 KAT (2)", tmp, tag, 16);
ipoly(key, nonce, data, len,
aad, aad_len, tmp, br_chacha20_ct_run, 0);
if (memcmp(data, plain, len) != 0) {
fprintf(stderr, "ChaCha20+Poly1305 KAT failed (3)\n");
exit(EXIT_FAILURE);
}
if (memcmp(tmp, tag, 16) != 0) {
fprintf(stderr, "ChaCha20+Poly1305 KAT failed (4)\n");
exit(EXIT_FAILURE);
}
check_equals("ChaCha20+Poly1305 KAT (3)", data, plain, len);
check_equals("ChaCha20+Poly1305 KAT (4)", tmp, tag, 16);
printf(".");
fflush(stdout);
@ -4273,6 +4261,20 @@ test_Poly1305_i15(void)
&br_poly1305_ctmul_run);
}
static void
test_Poly1305_ctmulq(void)
{
br_poly1305_run bp;
bp = br_poly1305_ctmulq_get();
if (bp == 0) {
printf("Test Poly1305_ctmulq: UNAVAILABLE\n");
} else {
test_Poly1305_inner("Poly1305_ctmulq", bp,
&br_poly1305_ctmul_run);
}
}
/*
* A 1024-bit RSA key, generated with OpenSSL.
*/
@ -5670,6 +5672,7 @@ static const struct {
STU(ChaCha20_ct),
STU(Poly1305_ctmul),
STU(Poly1305_ctmul32),
STU(Poly1305_ctmulq),
STU(Poly1305_i15),
STU(RSA_i15),
STU(RSA_i31),

View file

@ -416,6 +416,19 @@ test_speed_poly1305_ctmul32(void)
&br_poly1305_ctmul32_run);
}
static void
test_speed_poly1305_ctmulq(void)
{
br_poly1305_run bp;
bp = br_poly1305_ctmulq_get();
if (bp == 0) {
printf("%-30s UNAVAILABLE\n", "Poly1305 (ctmulq)");
} else {
test_speed_poly1305_inner("Poly1305 (ctmulq)", bp);
}
}
static void
test_speed_poly1305_i15(void)
{
@ -1260,6 +1273,7 @@ static const struct {
STU(poly1305_ctmul),
STU(poly1305_ctmul32),
STU(poly1305_ctmulq),
STU(poly1305_i15),
STU(rsa_i15),