diff --git a/tests/libdnssec/sample_keys.h b/tests/libdnssec/sample_keys.h index cd1b529960348e609a35d5fce989f46ce309b309..cd9f18f0a2a9c1c8a0835daa5efc0f3fe8dbfa39 100644 --- a/tests/libdnssec/sample_keys.h +++ b/tests/libdnssec/sample_keys.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2018 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz> +/* Copyright (C) 2021 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -405,3 +405,94 @@ static const key_parameters_t SAMPLE_ED25519_KEY = { 0x45, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a }}, }; + +/* + * Private-key-format: v1.2 + * Algorithm: 16 (ED448) + * PrivateKey: MEcCAQAwBQYDK2VxBDsEOVsk9cLaP+mD8n97xRET5bCqCUDZpPCIkCGrXLJG + * JgXCGlz4mOxH4qva7fIhEXm/62vtdbd55WRXIA== + * + * example.com. 3600 IN DNSKEY 256 3 16 ( + * 3y0sCUZKI+DSyZQTTbgHOFppOzYz01iZQQVUWw9gCb1bLWNqqC/5qq2PL9T + * c6YaK2vHthBtaY0iA ) + * + * example.com. 3600 IN DS 28205 16 2 ( + * 7a27236ccb5193f696cdb4c5fd58af3500634bd836e6defacaac5dd4d76 + * 6dcbe ) + * + * example.com. 3600 IN MX 10 mail.example.com. + * + * example.com. 3600 IN RRSIG MX 16 2 3600 20211108134038 ( + * 20211105115718 28205 example.com. + * uzvY2twOxxSas25N1HNQPRmhVgIaOHrEm6TccvwU + * WeJkecp2Nd0om5+Em1/91cfJWc/ZCFSYBcIAUFVB + * bMKoK0SXbmY5dM6rl0wQRk+Sl8VLyNttLMn5tpFk + * c74nWRGfXebz/HALT5WTdOidgIR8HCcA ) + */ + +static const key_parameters_t SAMPLE_ED448_KEY = { + .name = (uint8_t *)"\x07""example""\x03""com", + .flags = 256, + .protocol = 3, + .algorithm = 16, + .public_key = { .size = 57, .data = (uint8_t []) { + 0xdf, 0x2d, 0x2c, 0x09, 0x46, 0x4a, 0x23, 0xe0, 0xd2, 0xc9, 0x94, 0x13, + 0x4d, 0xb8, 0x07, 0x38, 0x5a, 0x69, 0x3b, 0x36, 0x33, 0xd3, 0x58, 0x99, + 0x41, 0x05, 0x54, 0x5b, 0x0f, 0x60, 0x09, 0xbd, 0x5b, 0x2d, 0x63, 0x6a, + 0xa8, 0x2f, 0xf9, 0xaa, 0xad, 0x8f, 0x2f, 0xd4, 0xdc, 0xe9, 0x86, 0x8a, + 0xda, 0xf1, 0xed, 0x84, 0x1b, 0x5a, 0x63, 0x48, 0x80, + }}, + .rdata = { .size = 61, .data = (uint8_t []) { + 0x01, 0x00, 0x03, 0x10, + 0xdf, 0x2d, 0x2c, 0x09, 0x46, 0x4a, 0x23, 0xe0, 0xd2, 0xc9, 0x94, 0x13, + 0x4d, 0xb8, 0x07, 0x38, 0x5a, 0x69, 0x3b, 0x36, 0x33, 0xd3, 0x58, 0x99, + 0x41, 0x05, 0x54, 0x5b, 0x0f, 0x60, 0x09, 0xbd, 0x5b, 0x2d, 0x63, 0x6a, + 0xa8, 0x2f, 0xf9, 0xaa, 0xad, 0x8f, 0x2f, 0xd4, 0xdc, 0xe9, 0x86, 0x8a, + 0xda, 0xf1, 0xed, 0x84, 0x1b, 0x5a, 0x63, 0x48, 0x80, + }}, + .keytag = 28205, + .key_id = "501a69b2d8ad46c721ffabaa9eaf8e7fa49c1454", + .ds_sha1 = { .size = 24, .data = (uint8_t []) { + 0x6e, 0x2d, 0x10, 0x01, + 0x69, 0xac, 0x45, 0x1c, 0xfa, 0xbb, 0xbb, 0x16, 0x5e, 0xf3, 0x82, 0x08, + 0x1f, 0xd3, 0x7e, 0x7a, 0xb4, 0xd9, 0x13, 0xbf, + }}, + .ds_sha256 = { .size = 36, .data = (uint8_t []) { + 0x6e, 0x2d, 0x10, 0x02, + 0x7a, 0x27, 0x23, 0x6c, 0xcb, 0x51, 0x93, 0xf6, 0x96, 0xcd, 0xb4, 0xc5, + 0xfd, 0x58, 0xaf, 0x35, 0x00, 0x63, 0x4b, 0xd8, 0x36, 0xe6, 0xde, 0xfa, + 0xca, 0xac, 0x5d, 0xd4, 0xd7, 0x66, 0xdc, 0xbe, + }}, + .ds_sha384 = { .size = 52, .data = (uint8_t []) { + 0x6e, 0x2d, 0x10, 0x04, + 0x6e, 0x06, 0x6f, 0xfb, 0xd5, 0xa2, 0x6c, 0xf3, 0x04, 0xa1, 0x2b, 0x76, + 0xf1, 0x83, 0xdb, 0xd3, 0x8b, 0x5e, 0x7c, 0xcb, 0x19, 0x79, 0xff, 0x3f, + 0x46, 0xee, 0xf2, 0x61, 0xf7, 0xa0, 0x48, 0x96, 0xbd, 0xe6, 0x6a, 0xe8, + 0xd0, 0x30, 0x54, 0xc8, 0x3a, 0xa1, 0x2d, 0xb3, 0x77, 0x37, 0xf1, 0xbb, + }}, + .bit_size = 456, + .pem = { .size = 156, .data = (uint8_t []) { + 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x50, + 0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d, + 0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x45, 0x63, 0x43, 0x41, 0x51, 0x41, 0x77, + 0x42, 0x51, 0x59, 0x44, 0x4b, 0x32, 0x56, 0x78, 0x42, 0x44, 0x73, 0x45, + 0x4f, 0x56, 0x73, 0x6b, 0x39, 0x63, 0x4c, 0x61, 0x50, 0x2b, 0x6d, 0x44, + 0x38, 0x6e, 0x39, 0x37, 0x78, 0x52, 0x45, 0x54, 0x35, 0x62, 0x43, 0x71, + 0x43, 0x55, 0x44, 0x5a, 0x70, 0x50, 0x43, 0x49, 0x6b, 0x43, 0x47, 0x72, + 0x58, 0x4c, 0x4a, 0x47, 0x4a, 0x67, 0x58, 0x43, 0x0a, 0x47, 0x6c, 0x7a, + 0x34, 0x6d, 0x4f, 0x78, 0x48, 0x34, 0x71, 0x76, 0x61, 0x37, 0x66, 0x49, + 0x68, 0x45, 0x58, 0x6d, 0x2f, 0x36, 0x32, 0x76, 0x74, 0x64, 0x62, 0x64, + 0x35, 0x35, 0x57, 0x52, 0x58, 0x49, 0x41, 0x3d, 0x3d, 0x0a, 0x2d, 0x2d, + 0x2d, 0x2d, 0x2d, 0x45, 0x4e, 0x44, 0x20, 0x50, 0x52, 0x49, 0x56, 0x41, + 0x54, 0x45, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a + }}, + /* raw private key outside of PEM: + * + * 0x5b, 0x24, 0xf5, 0xc2, 0xda, 0x3f, 0xe9, 0x83, 0xf2, 0x7f, 0x7b, 0xc5, + * 0x11, 0x13, 0xe5, 0xb0, 0xaa, 0x09, 0x40, 0xd9, 0xa4, 0xf0, 0x88, 0x90, + * 0x21, 0xab, 0x5c, 0xb2, 0x46, 0x26, 0x05, 0xc2, 0x1a, 0x5c, 0xf8, 0x98, + * 0xec, 0x47, 0xe2, 0xab, 0xda, 0xed, 0xf2, 0x21, 0x11, 0x79, 0xbf, 0xeb, + * 0x6b, 0xed, 0x75, 0xb7, 0x79, 0xe5, 0x64, 0x57, 0x20, + * + */ +}; diff --git a/tests/libdnssec/test_key.c b/tests/libdnssec/test_key.c index a54f46383f60caf9bb3967614f61ef099910ad8b..cd0aaee0ec67eac238779299a62e45354fe28939 100644 --- a/tests/libdnssec/test_key.c +++ b/tests/libdnssec/test_key.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2018 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz> +/* Copyright (C) 2021 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -194,6 +194,9 @@ int main(void) { "ECDSA", &SAMPLE_ECDSA_KEY }, #ifdef HAVE_ED25519 { "ED25519", &SAMPLE_ED25519_KEY }, +#endif +#ifdef HAVE_ED448 + { "ED448", &SAMPLE_ED448_KEY }, #endif { NULL } }; diff --git a/tests/libdnssec/test_key_algorithm.c b/tests/libdnssec/test_key_algorithm.c index b7d041cc2a9db92f7456e7ae7d8f290044ac1331..6c6210634fff2794991f9df9f9c360f549bc2a8f 100644 --- a/tests/libdnssec/test_key_algorithm.c +++ b/tests/libdnssec/test_key_algorithm.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2018 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz> +/* Copyright (C) 2021 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -62,6 +62,9 @@ static void check_defaults(void) #ifdef HAVE_ED25519 is_int(256, dnssec_algorithm_key_size_default(DNSSEC_KEY_ALGORITHM_ED25519), "ed25519 default"); #endif +#ifdef HAVE_ED448 + is_int(456, dnssec_algorithm_key_size_default(DNSSEC_KEY_ALGORITHM_ED448), "ed448 default"); +#endif } int main(void) @@ -73,6 +76,9 @@ int main(void) ok_range(DNSSEC_KEY_ALGORITHM_ECDSA_P384_SHA384, 384, 384, "ECDSA/SHA384"); #ifdef HAVE_ED25519 ok_range(DNSSEC_KEY_ALGORITHM_ED25519, 256, 256, "ED25519"); +#endif +#ifdef HAVE_ED448 + ok_range(DNSSEC_KEY_ALGORITHM_ED448, 456, 456, "ED448"); #endif null_range(); diff --git a/tests/libdnssec/test_key_ds.c b/tests/libdnssec/test_key_ds.c index 420a4bd8945cf54772fcfb47c2f03e741cfd4853..fbc6327cb151b88d75e7926f6088f7e568e90673 100644 --- a/tests/libdnssec/test_key_ds.c +++ b/tests/libdnssec/test_key_ds.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2018 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz> +/* Copyright (C) 2021 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -104,11 +104,17 @@ int main(int argc, char *argv[]) #ifdef HAVE_ED25519 test_key("ED25519", &SAMPLE_ED25519_KEY); #endif +#ifdef HAVE_ED448 + test_key("ED448", &SAMPLE_ED448_KEY); +#endif test_errors(&SAMPLE_ECDSA_KEY); #ifdef HAVE_ED25519 test_errors(&SAMPLE_ED25519_KEY); #endif +#ifdef HAVE_ED448 + test_errors(&SAMPLE_ED448_KEY); +#endif dnssec_crypto_cleanup(); diff --git a/tests/libdnssec/test_sign.c b/tests/libdnssec/test_sign.c index 57cd0e78ba83e5820c0ccec8aa05c145f37f3ca7..8f57a419b3cb14c45c1f96a6f629dd3b3e6b6f19 100644 --- a/tests/libdnssec/test_sign.c +++ b/tests/libdnssec/test_sign.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2020 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz> +/* Copyright (C) 2021 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -70,6 +70,21 @@ static const dnssec_binary_t signed_ed25519 = { .size = 64, .data = (uint8_t []) }}; #endif +#ifdef HAVE_ED448 +static const dnssec_binary_t signed_ed448 = { .size = 114, .data = (uint8_t []) { + 0x8d, 0x79, 0x27, 0xbd, 0xe2, 0xc4, 0x23, 0xd8, 0x26, 0xc1, 0xd4, 0xab, + 0x6a, 0x0d, 0xdf, 0xe5, 0x5c, 0xf1, 0x8d, 0x3f, 0x1b, 0x13, 0x81, 0x94, + 0xb2, 0x2d, 0xf0, 0x94, 0x58, 0x38, 0x6c, 0xf7, 0xe8, 0xc0, 0x92, 0xab, + 0x33, 0x1f, 0x1c, 0xe8, 0x18, 0x3f, 0xab, 0x24, 0x41, 0x10, 0xf7, 0x04, + 0xf5, 0x81, 0x68, 0x0d, 0x0c, 0x38, 0x8d, 0xd6, 0x80, 0xb4, 0x6b, 0xe8, + 0x65, 0xc1, 0xce, 0x73, 0xc7, 0x54, 0x20, 0x32, 0x21, 0x7c, 0x63, 0x5e, + 0x55, 0xe0, 0xdf, 0x2b, 0xdd, 0xd7, 0xd1, 0x82, 0xe0, 0x41, 0x75, 0xd4, + 0xe9, 0xb9, 0x76, 0xb8, 0xa6, 0xa9, 0x0a, 0x4f, 0x18, 0xe1, 0x62, 0x27, + 0x74, 0x99, 0x01, 0x98, 0x5f, 0xdb, 0xea, 0xdf, 0xab, 0x59, 0x6c, 0x79, + 0xe2, 0xc2, 0x2a, 0x91, 0x29, 0x00 + }}; +#endif + static dnssec_binary_t binary_set_string(char *str) { dnssec_binary_t result = { .data = (uint8_t *)str, .size = strlen(str) }; @@ -177,6 +192,10 @@ int main(void) diag("ED25519 signing"); check_key(&SAMPLE_ED25519_KEY, &input_data, &signed_ed25519, true); #endif +#ifdef HAVE_ED448 + diag("ED448 signing"); + check_key(&SAMPLE_ED448_KEY, &input_data, &signed_ed448, true); +#endif dnssec_crypto_cleanup();