From e4883a404b510bb4125de04104baab71803d1de7 Mon Sep 17 00:00:00 2001 From: Theo Buehler Date: Sat, 26 Oct 2024 10:15:20 +0000 Subject: Add regress coverage for ec_print.c Of course the four stunning beauties in there aren't printing anything. the hex family converts an elliptic curve point's X9.62 encoding into a hex string (which kind of makes sense, you can print that if you want). Much more astounding is EC_POINT_point2bn() where the X9.62 octet string is interpreted as a BIGNUM. Yes, the bignum's hex digits are the point conversion form followed by the affine coordinate(s) of the elliptic curve point, and yes you can choose between compressed, uncompressed, and hybrid encoding, why do you ask? This doesn't really make any sense whatsoever but of course you can also print that if you really want to. Of course the beloved platinum members of the "gotta try every terrible OpenSSL interface" club had to use and expose this. --- regress/lib/libcrypto/ec/ec_asn1_test.c | 891 +++++++++++++++++++++++++++++++- 1 file changed, 889 insertions(+), 2 deletions(-) (limited to 'regress') diff --git a/regress/lib/libcrypto/ec/ec_asn1_test.c b/regress/lib/libcrypto/ec/ec_asn1_test.c index c899c418fda..76dc415a93f 100644 --- a/regress/lib/libcrypto/ec/ec_asn1_test.c +++ b/regress/lib/libcrypto/ec/ec_asn1_test.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_asn1_test.c,v 1.15 2024/10/25 07:31:02 tb Exp $ */ +/* $OpenBSD: ec_asn1_test.c,v 1.16 2024/10/26 10:15:19 tb Exp $ */ /* * Copyright (c) 2017, 2021 Joel Sing * Copyright (c) 2024 Theo Buehler @@ -930,6 +930,9 @@ static const struct ec_private_key { const char *name; size_t der_len; uint8_t der[256]; + const char *hex; + int oct_len; + uint8_t oct[256]; } ec_private_keys[] = { { .name = "secp112r1", @@ -944,6 +947,17 @@ static const struct ec_private_key { 0x7a, 0x3d, 0x49, 0x3a, 0xaa, 0xeb, 0x97, 0xec, 0x19, 0xa3, 0x92, 0x3d, 0xe7, 0xe6, 0x6e, 0x47, }, + .hex = "040FA96ACD146587" + "E42C58861B7A3D49" + "3AAAEB97EC19A392" + "3DE7E66E47", + .oct_len = 29, + .oct = { + 0x04, 0x0f, 0xa9, 0x6a, 0xcd, 0x14, 0x65, 0x87, + 0xe4, 0x2c, 0x58, 0x86, 0x1b, 0x7a, 0x3d, 0x49, + 0x3a, 0xaa, 0xeb, 0x97, 0xec, 0x19, 0xa3, 0x92, + 0x3d, 0xe7, 0xe6, 0x6e, 0x47, + }, }, { .name = "secp112r2", @@ -958,6 +972,17 @@ static const struct ec_private_key { 0xfd, 0x57, 0x7a, 0x8f, 0x38, 0x8b, 0x04, 0xd9, 0xae, 0x3b, 0xcf, 0x10, 0x30, 0x29, 0xdb, 0x59, }, + .hex = "04642D25533F43F2" + "69B2558D7CFD577A" + "8F388B04D9AE3BCF" + "103029DB59", + .oct_len = 29, + .oct = { + 0x04, 0x64, 0x2d, 0x25, 0x53, 0x3f, 0x43, 0xf2, + 0x69, 0xb2, 0x55, 0x8d, 0x7c, 0xfd, 0x57, 0x7a, + 0x8f, 0x38, 0x8b, 0x04, 0xd9, 0xae, 0x3b, 0xcf, + 0x10, 0x30, 0x29, 0xdb, 0x59, + }, }, { .name = "secp128r1", @@ -973,6 +998,19 @@ static const struct ec_private_key { 0x31, 0xaf, 0xd3, 0x85, 0x5e, 0x4d, 0xc0, 0xee, 0x06, 0x4c, 0x26, 0x6d, 0x5e, 0x6d, }, + .hex = "043F88451052C2F6" + "56881B6EEE302164" + "9874DE31AFD3855E" + "4DC0EE064C266D5E" + "6D", + .oct_len = 33, + .oct = { + 0x04, 0x3f, 0x88, 0x45, 0x10, 0x52, 0xc2, 0xf6, + 0x56, 0x88, 0x1b, 0x6e, 0xee, 0x30, 0x21, 0x64, + 0x98, 0x74, 0xde, 0x31, 0xaf, 0xd3, 0x85, 0x5e, + 0x4d, 0xc0, 0xee, 0x06, 0x4c, 0x26, 0x6d, 0x5e, + 0x6d, + }, }, { .name = "secp128r2", @@ -988,6 +1026,19 @@ static const struct ec_private_key { 0x0d, 0x54, 0x61, 0xa0, 0xf3, 0x32, 0xdc, 0xe1, 0x19, 0xbb, 0x6e, 0xcf, 0x3c, 0xe2, }, + .hex = "04D5F51C2F02C039" + "EB6C7B202BCF67E0" + "8A2B830D5461A0F3" + "32DCE119BB6ECF3C" + "E2", + .oct_len = 33, + .oct = { + 0x04, 0xd5, 0xf5, 0x1c, 0x2f, 0x02, 0xc0, 0x39, + 0xeb, 0x6c, 0x7b, 0x20, 0x2b, 0xcf, 0x67, 0xe0, + 0x8a, 0x2b, 0x83, 0x0d, 0x54, 0x61, 0xa0, 0xf3, + 0x32, 0xdc, 0xe1, 0x19, 0xbb, 0x6e, 0xcf, 0x3c, + 0xe2, + }, }, #if CORRECT_PRIV_KEY_PADDING { @@ -1006,6 +1057,21 @@ static const struct ec_private_key { 0x63, 0x8d, 0x7f, 0x17, 0x3e, 0x28, 0x49, 0xcc, 0xcd, 0x6e, 0xb0, }, + .hex = "04FE46EFA6DE9520" + "342E7C65E931EF5B" + "D6B2800A03BAE8C6" + "9C89FF3D6BA5638D" + "7F173E2849CCCD6E" + "B0", + .oct_len = 41, + .oct = { + 0x04, 0xfe, 0x46, 0xef, 0xa6, 0xde, 0x95, 0x20, + 0x34, 0x2e, 0x7c, 0x65, 0xe9, 0x31, 0xef, 0x5b, + 0xd6, 0xb2, 0x80, 0x0a, 0x03, 0xba, 0xe8, 0xc6, + 0x9c, 0x89, 0xff, 0x3d, 0x6b, 0xa5, 0x63, 0x8d, + 0x7f, 0x17, 0x3e, 0x28, 0x49, 0xcc, 0xcd, 0x6e, + 0xb0, + }, }, { .name = "secp160r1", @@ -1023,6 +1089,21 @@ static const struct ec_private_key { 0xcb, 0xae, 0x9e, 0xe0, 0xa2, 0x7e, 0x26, 0x6b, 0xfe, 0xc4, 0xa7, }, + .hex = "04DAF0DA8CAD13E1" + "123B53EF9498A357" + "85BB20C0D8B661AD" + "4479D4BE3E6CCBAE" + "9EE0A27E266BFEC4" + "A7", + .oct_len = 41, + .oct = { + 0x04, 0xda, 0xf0, 0xda, 0x8c, 0xad, 0x13, 0xe1, + 0x12, 0x3b, 0x53, 0xef, 0x94, 0x98, 0xa3, 0x57, + 0x85, 0xbb, 0x20, 0xc0, 0xd8, 0xb6, 0x61, 0xad, + 0x44, 0x79, 0xd4, 0xbe, 0x3e, 0x6c, 0xcb, 0xae, + 0x9e, 0xe0, 0xa2, 0x7e, 0x26, 0x6b, 0xfe, 0xc4, + 0xa7, + }, }, { .name = "secp160r2", @@ -1040,6 +1121,21 @@ static const struct ec_private_key { 0x79, 0x19, 0xdc, 0xb1, 0x03, 0xdc, 0xcb, 0x73, 0x2b, 0x02, 0x63, }, + .hex = "0436CE2ABBEC29DF" + "DA52218B8B4937E3" + "D67FAB662081C730" + "EB00F0AD667C7919" + "DCB103DCCB732B02" + "63", + .oct_len = 41, + .oct = { + 0x04, 0x36, 0xce, 0x2a, 0xbb, 0xec, 0x29, 0xdf, + 0xda, 0x52, 0x21, 0x8b, 0x8b, 0x49, 0x37, 0xe3, + 0xd6, 0x7f, 0xab, 0x66, 0x20, 0x81, 0xc7, 0x30, + 0xeb, 0x00, 0xf0, 0xad, 0x66, 0x7c, 0x79, 0x19, + 0xdc, 0xb1, 0x03, 0xdc, 0xcb, 0x73, 0x2b, 0x02, + 0x63, + }, }, #endif { @@ -1059,6 +1155,23 @@ static const struct ec_private_key { 0x95, 0xed, 0x6f, 0x61, 0x83, 0xc3, 0x06, 0x27, 0x0c, 0x73, 0x6e, 0x73, 0x7c, 0xdc, }, + .hex = "04A87C1E15F01C8A" + "8D7E14DB07D1ACAF" + "2577E539BD595AED" + "6414EFD3F233AB7B" + "D59E2A95ED6F6183" + "C306270C736E737C" + "DC", + .oct_len = 49, + .oct = { + 0x04, 0xa8, 0x7c, 0x1e, 0x15, 0xf0, 0x1c, 0x8a, + 0x8d, 0x7e, 0x14, 0xdb, 0x07, 0xd1, 0xac, 0xaf, + 0x25, 0x77, 0xe5, 0x39, 0xbd, 0x59, 0x5a, 0xed, + 0x64, 0x14, 0xef, 0xd3, 0xf2, 0x33, 0xab, 0x7b, + 0xd5, 0x9e, 0x2a, 0x95, 0xed, 0x6f, 0x61, 0x83, + 0xc3, 0x06, 0x27, 0x0c, 0x73, 0x6e, 0x73, 0x7c, + 0xdc, + }, }, #if CORRECT_PRIV_KEY_PADDING { @@ -1080,6 +1193,25 @@ static const struct ec_private_key { 0x34, 0xef, 0xfb, 0x04, 0xa1, 0x28, 0x7d, 0x51, 0xbe, 0xe7, 0x0b, }, + .hex = "0451C469DF2D497B" + "056C125F9A83517D" + "F34A6CE13AEA4435" + "3E7AA440DFC49018" + "FC2F5D4B1237874D" + "2AF8BD29FB1334EF" + "FB04A1287D51BEE7" + "0B", + .oct_len = 57, + .oct = { + 0x04, 0x51, 0xc4, 0x69, 0xdf, 0x2d, 0x49, 0x7b, + 0x05, 0x6c, 0x12, 0x5f, 0x9a, 0x83, 0x51, 0x7d, + 0xf3, 0x4a, 0x6c, 0xe1, 0x3a, 0xea, 0x44, 0x35, + 0x3e, 0x7a, 0xa4, 0x40, 0xdf, 0xc4, 0x90, 0x18, + 0xfc, 0x2f, 0x5d, 0x4b, 0x12, 0x37, 0x87, 0x4d, + 0x2a, 0xf8, 0xbd, 0x29, 0xfb, 0x13, 0x34, 0xef, + 0xfb, 0x04, 0xa1, 0x28, 0x7d, 0x51, 0xbe, 0xe7, + 0x0b, + }, }, #endif { @@ -1101,6 +1233,25 @@ static const struct ec_private_key { 0xf4, 0x2d, 0x34, 0x25, 0xee, 0x4c, 0xec, 0xfb, 0x4d, 0x0b, }, + .hex = "049484B0CD65EFC5" + "5DC9E49171CBC7F1" + "8E4439C2D307F06C" + "B6EF77C084302CD2" + "F2F0B5B66F0AF443" + "AB5E5DD897BFABF4" + "2D3425EE4CECFB4D" + "0B", + .oct_len = 57, + .oct = { + 0x04, 0x94, 0x84, 0xb0, 0xcd, 0x65, 0xef, 0xc5, + 0x5d, 0xc9, 0xe4, 0x91, 0x71, 0xcb, 0xc7, 0xf1, + 0x8e, 0x44, 0x39, 0xc2, 0xd3, 0x07, 0xf0, 0x6c, + 0xb6, 0xef, 0x77, 0xc0, 0x84, 0x30, 0x2c, 0xd2, + 0xf2, 0xf0, 0xb5, 0xb6, 0x6f, 0x0a, 0xf4, 0x43, + 0xab, 0x5e, 0x5d, 0xd8, 0x97, 0xbf, 0xab, 0xf4, + 0x2d, 0x34, 0x25, 0xee, 0x4c, 0xec, 0xfb, 0x4d, + 0x0b, + }, }, { .name = "secp256k1", @@ -1122,6 +1273,27 @@ static const struct ec_private_key { 0x5e, 0xb5, 0x37, 0x44, 0x40, 0x1c, 0x34, 0x6c, 0xf2, 0xdb, 0x44, 0x71, 0x26, 0xeb, }, + .hex = "049FD2BECCF800E8" + "D0407311B9347668" + "B26B88EAA66437E7" + "06DF9F20B8C37F9F" + "8FBC8065E973CB1D" + "A1FA342366B94789" + "E908925EB5374440" + "1C346CF2DB447126" + "EB", + .oct_len = 65, + .oct = { + 0x04, 0x9f, 0xd2, 0xbe, 0xcc, 0xf8, 0x00, 0xe8, + 0xd0, 0x40, 0x73, 0x11, 0xb9, 0x34, 0x76, 0x68, + 0xb2, 0x6b, 0x88, 0xea, 0xa6, 0x64, 0x37, 0xe7, + 0x06, 0xdf, 0x9f, 0x20, 0xb8, 0xc3, 0x7f, 0x9f, + 0x8f, 0xbc, 0x80, 0x65, 0xe9, 0x73, 0xcb, 0x1d, + 0xa1, 0xfa, 0x34, 0x23, 0x66, 0xb9, 0x47, 0x89, + 0xe9, 0x08, 0x92, 0x5e, 0xb5, 0x37, 0x44, 0x40, + 0x1c, 0x34, 0x6c, 0xf2, 0xdb, 0x44, 0x71, 0x26, + 0xeb, + }, }, { .name = "secp384r1", @@ -1149,6 +1321,35 @@ static const struct ec_private_key { 0xe5, 0xd2, 0xa2, 0x79, 0x47, 0xb0, 0x6e, 0x5f, 0x85, 0x39, 0x94, 0x57, 0xbf, 0x54, 0x76, }, + .hex = "04CE9A3B4B01E6C4" + "5AFA9703C1CE18D5" + "6C47274D6C9ABD47" + "AB200F9983198BCB" + "18D7A3B2E73BD0F1" + "F329B26D38D6CC8E" + "5EF0B2B9BD852CAB" + "4BB69D98A1CEF18A" + "DB92757DF7824C0A" + "C73B526E97C623C9" + "6F3FE5D2A27947B0" + "6E5F85399457BF54" + "76", + .oct_len = 97, + .oct = { + 0x04, 0xce, 0x9a, 0x3b, 0x4b, 0x01, 0xe6, 0xc4, + 0x5a, 0xfa, 0x97, 0x03, 0xc1, 0xce, 0x18, 0xd5, + 0x6c, 0x47, 0x27, 0x4d, 0x6c, 0x9a, 0xbd, 0x47, + 0xab, 0x20, 0x0f, 0x99, 0x83, 0x19, 0x8b, 0xcb, + 0x18, 0xd7, 0xa3, 0xb2, 0xe7, 0x3b, 0xd0, 0xf1, + 0xf3, 0x29, 0xb2, 0x6d, 0x38, 0xd6, 0xcc, 0x8e, + 0x5e, 0xf0, 0xb2, 0xb9, 0xbd, 0x85, 0x2c, 0xab, + 0x4b, 0xb6, 0x9d, 0x98, 0xa1, 0xce, 0xf1, 0x8a, + 0xdb, 0x92, 0x75, 0x7d, 0xf7, 0x82, 0x4c, 0x0a, + 0xc7, 0x3b, 0x52, 0x6e, 0x97, 0xc6, 0x23, 0xc9, + 0x6f, 0x3f, 0xe5, 0xd2, 0xa2, 0x79, 0x47, 0xb0, + 0x6e, 0x5f, 0x85, 0x39, 0x94, 0x57, 0xbf, 0x54, + 0x76, + }, }, { .name = "secp521r1", @@ -1183,6 +1384,43 @@ static const struct ec_private_key { 0x8f, 0x89, 0xb6, 0x39, 0x2c, 0x2c, 0x23, 0x0a, 0xb6, 0x95, 0x9c, 0x6b, 0xce, 0xc4, 0x8e, }, + .hex = "0401D2C37841B186" + "24CA6D805C97CF96" + "F087B425BE379AF3" + "E54A70D1E6369E69" + "CCFB83D6A1626DA8" + "E6CAE70E24E626CD" + "C00D2A01816AD694" + "F290CD2668282C57" + "D3F03700BC5EFAF9" + "36CD0FEB4F82176A" + "A073D248FCFBF054" + "C3232976C7219809" + "298BCE6E6BE39794" + "B230AAF6435C15D7" + "B8DB0692A8368F89" + "B6392C2C230AB695" + "9C6BCEC48E", + .oct_len = 133, + .oct = { + 0x04, 0x01, 0xd2, 0xc3, 0x78, 0x41, 0xb1, 0x86, + 0x24, 0xca, 0x6d, 0x80, 0x5c, 0x97, 0xcf, 0x96, + 0xf0, 0x87, 0xb4, 0x25, 0xbe, 0x37, 0x9a, 0xf3, + 0xe5, 0x4a, 0x70, 0xd1, 0xe6, 0x36, 0x9e, 0x69, + 0xcc, 0xfb, 0x83, 0xd6, 0xa1, 0x62, 0x6d, 0xa8, + 0xe6, 0xca, 0xe7, 0x0e, 0x24, 0xe6, 0x26, 0xcd, + 0xc0, 0x0d, 0x2a, 0x01, 0x81, 0x6a, 0xd6, 0x94, + 0xf2, 0x90, 0xcd, 0x26, 0x68, 0x28, 0x2c, 0x57, + 0xd3, 0xf0, 0x37, 0x00, 0xbc, 0x5e, 0xfa, 0xf9, + 0x36, 0xcd, 0x0f, 0xeb, 0x4f, 0x82, 0x17, 0x6a, + 0xa0, 0x73, 0xd2, 0x48, 0xfc, 0xfb, 0xf0, 0x54, + 0xc3, 0x23, 0x29, 0x76, 0xc7, 0x21, 0x98, 0x09, + 0x29, 0x8b, 0xce, 0x6e, 0x6b, 0xe3, 0x97, 0x94, + 0xb2, 0x30, 0xaa, 0xf6, 0x43, 0x5c, 0x15, 0xd7, + 0xb8, 0xdb, 0x06, 0x92, 0xa8, 0x36, 0x8f, 0x89, + 0xb6, 0x39, 0x2c, 0x2c, 0x23, 0x0a, 0xb6, 0x95, + 0x9c, 0x6b, 0xce, 0xc4, 0x8e, + }, }, { .name = "prime192v1", @@ -1202,6 +1440,23 @@ static const struct ec_private_key { 0x6a, 0xba, 0x4e, 0x52, 0xeb, 0x29, 0x81, 0x87, 0x92, }, + .hex = "046E8A842C8A39EE" + "946BB28A178E965E" + "A20F2EB073435646" + "F102E8A681419374" + "FEE64CF6B95A3918" + "6ABA4E52EB298187" + "92", + .oct_len = 49, + .oct = { + 0x04, 0x6e, 0x8a, 0x84, 0x2c, 0x8a, 0x39, 0xee, + 0x94, 0x6b, 0xb2, 0x8a, 0x17, 0x8e, 0x96, 0x5e, + 0xa2, 0x0f, 0x2e, 0xb0, 0x73, 0x43, 0x56, 0x46, + 0xf1, 0x02, 0xe8, 0xa6, 0x81, 0x41, 0x93, 0x74, + 0xfe, 0xe6, 0x4c, 0xf6, 0xb9, 0x5a, 0x39, 0x18, + 0x6a, 0xba, 0x4e, 0x52, 0xeb, 0x29, 0x81, 0x87, + 0x92, + }, }, { .name = "prime192v2", @@ -1221,6 +1476,23 @@ static const struct ec_private_key { 0x4b, 0xab, 0x5b, 0x66, 0xa7, 0x98, 0xa6, 0x9a, 0xe6, }, + .hex = "04625DFB0E5895D1" + "E713669A0C5CEF2F" + "2F33BB2BA0096E04" + "3E013C605EC3BAFC" + "1CB94D0DB5A99E56" + "4BAB5B66A798A69A" + "E6", + .oct_len = 49, + .oct = { + 0x04, 0x62, 0x5d, 0xfb, 0x0e, 0x58, 0x95, 0xd1, + 0xe7, 0x13, 0x66, 0x9a, 0x0c, 0x5c, 0xef, 0x2f, + 0x2f, 0x33, 0xbb, 0x2b, 0xa0, 0x09, 0x6e, 0x04, + 0x3e, 0x01, 0x3c, 0x60, 0x5e, 0xc3, 0xba, 0xfc, + 0x1c, 0xb9, 0x4d, 0x0d, 0xb5, 0xa9, 0x9e, 0x56, + 0x4b, 0xab, 0x5b, 0x66, 0xa7, 0x98, 0xa6, 0x9a, + 0xe6, + }, }, { .name = "prime192v3", @@ -1240,6 +1512,23 @@ static const struct ec_private_key { 0xc8, 0xd8, 0x3a, 0xc5, 0x7d, 0xfb, 0x9c, 0x78, 0xd3, }, + .hex = "0451389F964E130C" + "E293EEC64410FDFF" + "AED4080F3A7871DC" + "FE6D460EE4E699D1" + "258CB8C0E97C7AD3" + "C8D83AC57DFB9C78" + "D3", + .oct_len = 49, + .oct = { + 0x04, 0x51, 0x38, 0x9f, 0x96, 0x4e, 0x13, 0x0c, + 0xe2, 0x93, 0xee, 0xc6, 0x44, 0x10, 0xfd, 0xff, + 0xae, 0xd4, 0x08, 0x0f, 0x3a, 0x78, 0x71, 0xdc, + 0xfe, 0x6d, 0x46, 0x0e, 0xe4, 0xe6, 0x99, 0xd1, + 0x25, 0x8c, 0xb8, 0xc0, 0xe9, 0x7c, 0x7a, 0xd3, + 0xc8, 0xd8, 0x3a, 0xc5, 0x7d, 0xfb, 0x9c, 0x78, + 0xd3, + }, }, { .name = "prime239v1", @@ -1261,6 +1550,25 @@ static const struct ec_private_key { 0xe3, 0x04, 0xef, 0x5d, 0x65, 0x75, 0x98, 0x7f, 0x2d, 0xd0, 0x68, }, + .hex = "0433C6E58AC18B7C" + "9619C9E1547F819E" + "5962ECC01EE553D5" + "AE6BD3E00907C527" + "81A68D398EFE01C2" + "1DDADE7BDC762717" + "F96FE304EF5D6575" + "987F2DD068", + .oct_len = 61, + .oct = { + 0x04, 0x33, 0xc6, 0xe5, 0x8a, 0xc1, 0x8b, 0x7c, + 0x96, 0x19, 0xc9, 0xe1, 0x54, 0x7f, 0x81, 0x9e, + 0x59, 0x62, 0xec, 0xc0, 0x1e, 0xe5, 0x53, 0xd5, + 0xae, 0x6b, 0xd3, 0xe0, 0x09, 0x07, 0xc5, 0x27, + 0x81, 0xa6, 0x8d, 0x39, 0x8e, 0xfe, 0x01, 0xc2, + 0x1d, 0xda, 0xde, 0x7b, 0xdc, 0x76, 0x27, 0x17, + 0xf9, 0x6f, 0xe3, 0x04, 0xef, 0x5d, 0x65, 0x75, + 0x98, 0x7f, 0x2d, 0xd0, 0x68, + }, }, { .name = "prime239v2", @@ -1282,6 +1590,25 @@ static const struct ec_private_key { 0xe0, 0xcc, 0xdd, 0x45, 0xd8, 0xa6, 0x29, 0x2f, 0xad, 0x6b, 0xf9, }, + .hex = "043C10277BACDF86" + "C94FF839870239AF" + "41BC4B67D85E0496" + "84B56050486A201D" + "2B7E9FAFF88E7EA4" + "CD00ADB1AD226932" + "106CE0CCDD45D8A6" + "292FAD6BF9", + .oct_len = 61, + .oct = { + 0x04, 0x3c, 0x10, 0x27, 0x7b, 0xac, 0xdf, 0x86, + 0xc9, 0x4f, 0xf8, 0x39, 0x87, 0x02, 0x39, 0xaf, + 0x41, 0xbc, 0x4b, 0x67, 0xd8, 0x5e, 0x04, 0x96, + 0x84, 0xb5, 0x60, 0x50, 0x48, 0x6a, 0x20, 0x1d, + 0x2b, 0x7e, 0x9f, 0xaf, 0xf8, 0x8e, 0x7e, 0xa4, + 0xcd, 0x00, 0xad, 0xb1, 0xad, 0x22, 0x69, 0x32, + 0x10, 0x6c, 0xe0, 0xcc, 0xdd, 0x45, 0xd8, 0xa6, + 0x29, 0x2f, 0xad, 0x6b, 0xf9, + }, }, { .name = "prime239v3", @@ -1303,6 +1630,25 @@ static const struct ec_private_key { 0x26, 0x81, 0x2a, 0x91, 0x14, 0x0f, 0xc7, 0x31, 0x13, 0x78, 0x16, }, + .hex = "0437BA077FD9465A" + "3303317738EFEECC" + "3DE1AA57E38DB7CD" + "E301F4D675497261" + "4CBFC01F8B5F989B" + "A7E56AB7FE63DBB0" + "40CB26812A91140F" + "C731137816", + .oct_len = 61, + .oct = { + 0x04, 0x37, 0xba, 0x07, 0x7f, 0xd9, 0x46, 0x5a, + 0x33, 0x03, 0x31, 0x77, 0x38, 0xef, 0xee, 0xcc, + 0x3d, 0xe1, 0xaa, 0x57, 0xe3, 0x8d, 0xb7, 0xcd, + 0xe3, 0x01, 0xf4, 0xd6, 0x75, 0x49, 0x72, 0x61, + 0x4c, 0xbf, 0xc0, 0x1f, 0x8b, 0x5f, 0x98, 0x9b, + 0xa7, 0xe5, 0x6a, 0xb7, 0xfe, 0x63, 0xdb, 0xb0, + 0x40, 0xcb, 0x26, 0x81, 0x2a, 0x91, 0x14, 0x0f, + 0xc7, 0x31, 0x13, 0x78, 0x16, + }, }, { .name = "prime256v1", @@ -1325,6 +1671,27 @@ static const struct ec_private_key { 0x0b, 0xa6, 0xdd, 0x16, 0xc5, 0x8d, 0x5a, 0xcf, 0xe3, }, + .hex = "04968AC3661EF7CF" + "F6CC4E73AEE264C4" + "565F2DFEDEAC92BE" + "104037CE24123019" + "0866CF90C93703D1" + "D58DAA182ABCED82" + "32C9434B987FDCB1" + "0BA6DD16C58D5ACF" + "E3", + .oct_len = 65, + .oct = { + 0x04, 0x96, 0x8a, 0xc3, 0x66, 0x1e, 0xf7, 0xcf, + 0xf6, 0xcc, 0x4e, 0x73, 0xae, 0xe2, 0x64, 0xc4, + 0x56, 0x5f, 0x2d, 0xfe, 0xde, 0xac, 0x92, 0xbe, + 0x10, 0x40, 0x37, 0xce, 0x24, 0x12, 0x30, 0x19, + 0x08, 0x66, 0xcf, 0x90, 0xc9, 0x37, 0x03, 0xd1, + 0xd5, 0x8d, 0xaa, 0x18, 0x2a, 0xbc, 0xed, 0x82, + 0x32, 0xc9, 0x43, 0x4b, 0x98, 0x7f, 0xdc, 0xb1, + 0x0b, 0xa6, 0xdd, 0x16, 0xc5, 0x8d, 0x5a, 0xcf, + 0xe3, + }, }, { .name = "wap-wsg-idm-ecid-wtls6", @@ -1339,6 +1706,17 @@ static const struct ec_private_key { 0x43, 0x15, 0x6e, 0x27, 0x8a, 0x4f, 0x28, 0x11, 0xb8, 0xf6, 0x80, 0xfe, 0x7a, 0xb1, 0xa2, 0x74, }, + .hex = "04563F72F1B5EE7A" + "4C5976D49743156E" + "278A4F2811B8F680" + "FE7AB1A274", + .oct_len = 29, + .oct = { + 0x04, 0x56, 0x3f, 0x72, 0xf1, 0xb5, 0xee, 0x7a, + 0x4c, 0x59, 0x76, 0xd4, 0x97, 0x43, 0x15, 0x6e, + 0x27, 0x8a, 0x4f, 0x28, 0x11, 0xb8, 0xf6, 0x80, + 0xfe, 0x7a, 0xb1, 0xa2, 0x74, + }, }, #if CORRECT_PRIV_KEY_PADDING { @@ -1357,6 +1735,21 @@ static const struct ec_private_key { 0x92, 0x2e, 0x9a, 0xa9, 0x73, 0x2b, 0xc3, 0x06, 0x0e, 0x4e, 0x69, }, + .hex = "04AF842D08CBE2F2" + "A3AC20B0995C38D7" + "5ECEB90B2E38DDCF" + "137F5AFAAC1D922E" + "9AA9732BC3060E4E" + "69", + .oct_len = 41, + .oct = { + 0x04, 0xaf, 0x84, 0x2d, 0x08, 0xcb, 0xe2, 0xf2, + 0xa3, 0xac, 0x20, 0xb0, 0x99, 0x5c, 0x38, 0xd7, + 0x5e, 0xce, 0xb9, 0x0b, 0x2e, 0x38, 0xdd, 0xcf, + 0x13, 0x7f, 0x5a, 0xfa, 0xac, 0x1d, 0x92, 0x2e, + 0x9a, 0xa9, 0x73, 0x2b, 0xc3, 0x06, 0x0e, 0x4e, + 0x69, + }, }, { .name = "wap-wsg-idm-ecid-wtls8", @@ -1372,6 +1765,17 @@ static const struct ec_private_key { 0x52, 0x3c, 0x6a, 0x6a, 0x2f, 0x69, 0x1a, 0x06, 0x56, }, + .hex = "0448814BAE65F8DA" + "022C66C60B1DA698" + "4225F231523C6A6A" + "2F691A0656", + .oct_len = 29, + .oct = { + 0x04, 0x48, 0x81, 0x4b, 0xae, 0x65, 0xf8, 0xda, + 0x02, 0x2c, 0x66, 0xc6, 0x0b, 0x1d, 0xa6, 0x98, + 0x42, 0x25, 0xf2, 0x31, 0x52, 0x3c, 0x6a, 0x6a, + 0x2f, 0x69, 0x1a, 0x06, 0x56, + }, }, { .name = "wap-wsg-idm-ecid-wtls9", @@ -1389,6 +1793,21 @@ static const struct ec_private_key { 0xfa, 0x7e, 0xdc, 0x50, 0xc4, 0xac, 0xea, 0x84, 0x2f, 0xba, 0x3c, }, + .hex = "04AAFCE4FEF89148" + "F1CC4944353D4971" + "44DC74735B5F014B" + "AB8B5C84EC2BFA7E" + "DC50C4ACEA842FBA" + "3C", + .oct_len = 41, + .oct = { + 0x04, 0xaa, 0xfc, 0xe4, 0xfe, 0xf8, 0x91, 0x48, + 0xf1, 0xcc, 0x49, 0x44, 0x35, 0x3d, 0x49, 0x71, + 0x44, 0xdc, 0x74, 0x73, 0x5b, 0x5f, 0x01, 0x4b, + 0xab, 0x8b, 0x5c, 0x84, 0xec, 0x2b, 0xfa, 0x7e, + 0xdc, 0x50, 0xc4, 0xac, 0xea, 0x84, 0x2f, 0xba, + 0x3c, + }, }, #endif { @@ -1410,6 +1829,25 @@ static const struct ec_private_key { 0x00, 0xaf, 0xdc, 0x4a, 0xe7, 0xc6, 0x61, 0x44, 0x50, 0xc6, }, + .hex = "0447D66327E1AD30" + "ACBAAB86D663B5D9" + "C59C243AD96A7A5D" + "2B45718D7ED23275" + "65C43725C71FEB33" + "F76829168296D900" + "AFDC4AE7C6614450" + "C6", + .oct_len = 57, + .oct = { + 0x04, 0x47, 0xd6, 0x63, 0x27, 0xe1, 0xad, 0x30, + 0xac, 0xba, 0xab, 0x86, 0xd6, 0x63, 0xb5, 0xd9, + 0xc5, 0x9c, 0x24, 0x3a, 0xd9, 0x6a, 0x7a, 0x5d, + 0x2b, 0x45, 0x71, 0x8d, 0x7e, 0xd2, 0x32, 0x75, + 0x65, 0xc4, 0x37, 0x25, 0xc7, 0x1f, 0xeb, 0x33, + 0xf7, 0x68, 0x29, 0x16, 0x82, 0x96, 0xd9, 0x00, + 0xaf, 0xdc, 0x4a, 0xe7, 0xc6, 0x61, 0x44, 0x50, + 0xc6, + }, }, { .name = "brainpoolP160r1", @@ -1427,6 +1865,21 @@ static const struct ec_private_key { 0xa2, 0xcc, 0xc4, 0xd0, 0x1d, 0xd6, 0xe6, 0xcf, 0x11, 0x6e, 0x59, 0x12, 0xbb, 0x14, }, + .hex = "044C15498194F56E" + "808EC865EA48FA29" + "C259F136D68DA4C5" + "E07DE5A2CCC4D01D" + "D6E6CF116E5912BB" + "14", + .oct_len = 41, + .oct = { + 0x04, 0x4c, 0x15, 0x49, 0x81, 0x94, 0xf5, 0x6e, + 0x80, 0x8e, 0xc8, 0x65, 0xea, 0x48, 0xfa, 0x29, + 0xc2, 0x59, 0xf1, 0x36, 0xd6, 0x8d, 0xa4, 0xc5, + 0xe0, 0x7d, 0xe5, 0xa2, 0xcc, 0xc4, 0xd0, 0x1d, + 0xd6, 0xe6, 0xcf, 0x11, 0x6e, 0x59, 0x12, 0xbb, + 0x14, + }, }, { .name = "brainpoolP160t1", @@ -1444,6 +1897,21 @@ static const struct ec_private_key { 0xcf, 0x8f, 0x31, 0xb1, 0x69, 0x99, 0xc6, 0x11, 0x80, 0x0d, 0x40, 0x25, 0xf0, 0x90, }, + .hex = "04964B2C8AED9B18" + "30C11CBC16567BC0" + "3A6C52F871DF5420" + "96E3E9CF8F31B169" + "99C611800D4025F0" + "90", + .oct_len = 41, + .oct = { + 0x04, 0x96, 0x4b, 0x2c, 0x8a, 0xed, 0x9b, 0x18, + 0x30, 0xc1, 0x1c, 0xbc, 0x16, 0x56, 0x7b, 0xc0, + 0x3a, 0x6c, 0x52, 0xf8, 0x71, 0xdf, 0x54, 0x20, + 0x96, 0xe3, 0xe9, 0xcf, 0x8f, 0x31, 0xb1, 0x69, + 0x99, 0xc6, 0x11, 0x80, 0x0d, 0x40, 0x25, 0xf0, + 0x90, + }, }, { .name = "brainpoolP192r1", @@ -1463,6 +1931,23 @@ static const struct ec_private_key { 0x3c, 0xf1, 0x96, 0x94, 0x1f, 0x9c, 0x04, 0x2a, 0x43, 0x27, }, + .hex = "0471609C629876C9" + "149175C6C81632C2" + "294764A359A745DB" + "D75195BAA433466E" + "4F86ED1EEAF6F13C" + "F196941F9C042A43" + "27", + .oct_len = 49, + .oct = { + 0x04, 0x71, 0x60, 0x9c, 0x62, 0x98, 0x76, 0xc9, + 0x14, 0x91, 0x75, 0xc6, 0xc8, 0x16, 0x32, 0xc2, + 0x29, 0x47, 0x64, 0xa3, 0x59, 0xa7, 0x45, 0xdb, + 0xd7, 0x51, 0x95, 0xba, 0xa4, 0x33, 0x46, 0x6e, + 0x4f, 0x86, 0xed, 0x1e, 0xea, 0xf6, 0xf1, 0x3c, + 0xf1, 0x96, 0x94, 0x1f, 0x9c, 0x04, 0x2a, 0x43, + 0x27, + }, }, { .name = "brainpoolP192t1", @@ -1482,6 +1967,23 @@ static const struct ec_private_key { 0x6d, 0x1b, 0x15, 0xd7, 0x4b, 0x79, 0xc1, 0xb5, 0x28, 0xc7, }, + .hex = "048D2B0CEEEA4B63" + "AF6336B23A554085" + "3395C11D37D3FC5C" + "258A0AC5EC7FE07F" + "085EDF89E6EE216D" + "1B15D74B79C1B528" + "C7", + .oct_len = 49, + .oct = { + 0x04, 0x8d, 0x2b, 0x0c, 0xee, 0xea, 0x4b, 0x63, + 0xaf, 0x63, 0x36, 0xb2, 0x3a, 0x55, 0x40, 0x85, + 0x33, 0x95, 0xc1, 0x1d, 0x37, 0xd3, 0xfc, 0x5c, + 0x25, 0x8a, 0x0a, 0xc5, 0xec, 0x7f, 0xe0, 0x7f, + 0x08, 0x5e, 0xdf, 0x89, 0xe6, 0xee, 0x21, 0x6d, + 0x1b, 0x15, 0xd7, 0x4b, 0x79, 0xc1, 0xb5, 0x28, + 0xc7, + }, }, { .name = "brainpoolP224r1", @@ -1502,6 +2004,25 @@ static const struct ec_private_key { 0x71, 0x50, 0x6b, 0xed, 0xe3, 0xc5, 0xd4, 0xe9, 0x1b, 0x59, 0x92, 0xa4, 0xa8, 0x81, }, + .hex = "04308820B3472E40" + "1E68AEE10058A24B" + "B9ACF75DC1EEF5FB" + "DD34AEBE3C93DDC2" + "D83A9A726541ACCC" + "256ACF71506BEDE3" + "C5D4E91B5992A4A8" + "81", + .oct_len = 57, + .oct = { + 0x04, 0x30, 0x88, 0x20, 0xb3, 0x47, 0x2e, 0x40, + 0x1e, 0x68, 0xae, 0xe1, 0x00, 0x58, 0xa2, 0x4b, + 0xb9, 0xac, 0xf7, 0x5d, 0xc1, 0xee, 0xf5, 0xfb, + 0xdd, 0x34, 0xae, 0xbe, 0x3c, 0x93, 0xdd, 0xc2, + 0xd8, 0x3a, 0x9a, 0x72, 0x65, 0x41, 0xac, 0xcc, + 0x25, 0x6a, 0xcf, 0x71, 0x50, 0x6b, 0xed, 0xe3, + 0xc5, 0xd4, 0xe9, 0x1b, 0x59, 0x92, 0xa4, 0xa8, + 0x81, + }, }, { .name = "brainpoolP224t1", @@ -1522,6 +2043,25 @@ static const struct ec_private_key { 0x59, 0xb2, 0xfd, 0xe7, 0xdf, 0x41, 0xff, 0x4f, 0x36, 0xe9, 0x56, 0xe9, 0x07, 0xc2, }, + .hex = "040BBF95EA8BA824" + "94685469D955A536" + "34F14A45F99F667B" + "5DC98B0A7A5DEF25" + "9AA386E1981B5BE3" + "E355A059B2FDE7DF" + "41FF4F36E956E907" + "C2", + .oct_len = 57, + .oct = { + 0x04, 0x0b, 0xbf, 0x95, 0xea, 0x8b, 0xa8, 0x24, + 0x94, 0x68, 0x54, 0x69, 0xd9, 0x55, 0xa5, 0x36, + 0x34, 0xf1, 0x4a, 0x45, 0xf9, 0x9f, 0x66, 0x7b, + 0x5d, 0xc9, 0x8b, 0x0a, 0x7a, 0x5d, 0xef, 0x25, + 0x9a, 0xa3, 0x86, 0xe1, 0x98, 0x1b, 0x5b, 0xe3, + 0xe3, 0x55, 0xa0, 0x59, 0xb2, 0xfd, 0xe7, 0xdf, + 0x41, 0xff, 0x4f, 0x36, 0xe9, 0x56, 0xe9, 0x07, + 0xc2, + }, }, { .name = "brainpoolP256r1", @@ -1544,6 +2084,27 @@ static const struct ec_private_key { 0xcf, 0xe3, 0x38, 0xa0, 0xb7, 0x95, 0x85, 0x26, 0xf5, 0xb2, }, + .hex = "0408D777F510A983" + "D9DFFD40E442CED8" + "3B9BEFE64D4ECA2D" + "EAE669FED3A93F30" + "FA7EA7149D3777C5" + "CC1E32F6CE17911B" + "EBA38FCE7055C1CF" + "E338A0B7958526F5" + "B2", + .oct_len = 65, + .oct = { + 0x04, 0x08, 0xd7, 0x77, 0xf5, 0x10, 0xa9, 0x83, + 0xd9, 0xdf, 0xfd, 0x40, 0xe4, 0x42, 0xce, 0xd8, + 0x3b, 0x9b, 0xef, 0xe6, 0x4d, 0x4e, 0xca, 0x2d, + 0xea, 0xe6, 0x69, 0xfe, 0xd3, 0xa9, 0x3f, 0x30, + 0xfa, 0x7e, 0xa7, 0x14, 0x9d, 0x37, 0x77, 0xc5, + 0xcc, 0x1e, 0x32, 0xf6, 0xce, 0x17, 0x91, 0x1b, + 0xeb, 0xa3, 0x8f, 0xce, 0x70, 0x55, 0xc1, 0xcf, + 0xe3, 0x38, 0xa0, 0xb7, 0x95, 0x85, 0x26, 0xf5, + 0xb2, + }, }, { .name = "brainpoolP256t1", @@ -1566,6 +2127,27 @@ static const struct ec_private_key { 0xbd, 0x1e, 0x53, 0x8d, 0x26, 0x96, 0xab, 0x44, 0x6b, 0x84, }, + .hex = "047B1D55290B0A0D" + "027A1D7253C184B9" + "9000B945E5A5D4EE" + "D69A1DB03A91A895" + "565832CBF32895A6" + "8246E60A3300D10C" + "61AC1EA0B0AD3ABD" + "1E538D2696AB446B" + "84", + .oct_len = 65, + .oct = { + 0x04, 0x7b, 0x1d, 0x55, 0x29, 0x0b, 0x0a, 0x0d, + 0x02, 0x7a, 0x1d, 0x72, 0x53, 0xc1, 0x84, 0xb9, + 0x90, 0x00, 0xb9, 0x45, 0xe5, 0xa5, 0xd4, 0xee, + 0xd6, 0x9a, 0x1d, 0xb0, 0x3a, 0x91, 0xa8, 0x95, + 0x56, 0x58, 0x32, 0xcb, 0xf3, 0x28, 0x95, 0xa6, + 0x82, 0x46, 0xe6, 0x0a, 0x33, 0x00, 0xd1, 0x0c, + 0x61, 0xac, 0x1e, 0xa0, 0xb0, 0xad, 0x3a, 0xbd, + 0x1e, 0x53, 0x8d, 0x26, 0x96, 0xab, 0x44, 0x6b, + 0x84, + }, }, { .name = "brainpoolP320r1", @@ -1591,6 +2173,31 @@ static const struct ec_private_key { 0x54, 0xcc, 0x11, 0x2a, 0x84, 0xc6, 0x79, 0x10, 0x7b, 0x20, 0x26, }, + .hex = "04A33785E2F25FA1" + "71A675FEA1EA6635" + "7A53712483CDC95D" + "3F43C4976DCC0CED" + "9A51517D1ED0EAD2" + "8C36B09362EB26DA" + "E1EFC71AFA0CEA84" + "7AF1502CEEF1B3CC" + "B7A0985DDEC254CC" + "112A84C679107B20" + "26", + .oct_len = 81, + .oct = { + 0x04, 0xa3, 0x37, 0x85, 0xe2, 0xf2, 0x5f, 0xa1, + 0x71, 0xa6, 0x75, 0xfe, 0xa1, 0xea, 0x66, 0x35, + 0x7a, 0x53, 0x71, 0x24, 0x83, 0xcd, 0xc9, 0x5d, + 0x3f, 0x43, 0xc4, 0x97, 0x6d, 0xcc, 0x0c, 0xed, + 0x9a, 0x51, 0x51, 0x7d, 0x1e, 0xd0, 0xea, 0xd2, + 0x8c, 0x36, 0xb0, 0x93, 0x62, 0xeb, 0x26, 0xda, + 0xe1, 0xef, 0xc7, 0x1a, 0xfa, 0x0c, 0xea, 0x84, + 0x7a, 0xf1, 0x50, 0x2c, 0xee, 0xf1, 0xb3, 0xcc, + 0xb7, 0xa0, 0x98, 0x5d, 0xde, 0xc2, 0x54, 0xcc, + 0x11, 0x2a, 0x84, 0xc6, 0x79, 0x10, 0x7b, 0x20, + 0x26, + }, }, { .name = "brainpoolP320t1", @@ -1616,6 +2223,31 @@ static const struct ec_private_key { 0x03, 0xbe, 0xa5, 0x05, 0x88, 0x16, 0x47, 0x9f, 0xe5, 0x3b, 0xb8, }, + .hex = "043D8C4CBB303FA0" + "846143502370E370" + "B64D89C895A009AE" + "FC559C2FEF16C072" + "3C3E07A1BBD88AFA" + "AF9FAF077C154D75" + "6BF525655BC47859" + "22E5925CC28FDC97" + "5982C50D247003BE" + "A5058816479FE53B" + "B8", + .oct_len = 81, + .oct = { + 0x04, 0x3d, 0x8c, 0x4c, 0xbb, 0x30, 0x3f, 0xa0, + 0x84, 0x61, 0x43, 0x50, 0x23, 0x70, 0xe3, 0x70, + 0xb6, 0x4d, 0x89, 0xc8, 0x95, 0xa0, 0x09, 0xae, + 0xfc, 0x55, 0x9c, 0x2f, 0xef, 0x16, 0xc0, 0x72, + 0x3c, 0x3e, 0x07, 0xa1, 0xbb, 0xd8, 0x8a, 0xfa, + 0xaf, 0x9f, 0xaf, 0x07, 0x7c, 0x15, 0x4d, 0x75, + 0x6b, 0xf5, 0x25, 0x65, 0x5b, 0xc4, 0x78, 0x59, + 0x22, 0xe5, 0x92, 0x5c, 0xc2, 0x8f, 0xdc, 0x97, + 0x59, 0x82, 0xc5, 0x0d, 0x24, 0x70, 0x03, 0xbe, + 0xa5, 0x05, 0x88, 0x16, 0x47, 0x9f, 0xe5, 0x3b, + 0xb8, + }, }, { .name = "brainpoolP384r1", @@ -1644,6 +2276,35 @@ static const struct ec_private_key { 0x92, 0x00, 0xaf, 0x3d, 0xe8, 0x5a, 0x7d, 0x7b, 0x63, 0xc2, 0xde, }, + .hex = "044F79E0E7F95733" + "F99D6A5C006EB8BC" + "E64F701D73025C87" + "A188EAE3575C1A27" + "40CFCC6F7E6DFD96" + "0BAAC50292106D7E" + "D517DAAB529BCD87" + "08642A6103C9FE97" + "79F05C8472505395" + "567A97CE36132378" + "3182360745AD9200" + "AF3DE85A7D7B63C2" + "DE", + .oct_len = 97, + .oct = { + 0x04, 0x4f, 0x79, 0xe0, 0xe7, 0xf9, 0x57, 0x33, + 0xf9, 0x9d, 0x6a, 0x5c, 0x00, 0x6e, 0xb8, 0xbc, + 0xe6, 0x4f, 0x70, 0x1d, 0x73, 0x02, 0x5c, 0x87, + 0xa1, 0x88, 0xea, 0xe3, 0x57, 0x5c, 0x1a, 0x27, + 0x40, 0xcf, 0xcc, 0x6f, 0x7e, 0x6d, 0xfd, 0x96, + 0x0b, 0xaa, 0xc5, 0x02, 0x92, 0x10, 0x6d, 0x7e, + 0xd5, 0x17, 0xda, 0xab, 0x52, 0x9b, 0xcd, 0x87, + 0x08, 0x64, 0x2a, 0x61, 0x03, 0xc9, 0xfe, 0x97, + 0x79, 0xf0, 0x5c, 0x84, 0x72, 0x50, 0x53, 0x95, + 0x56, 0x7a, 0x97, 0xce, 0x36, 0x13, 0x23, 0x78, + 0x31, 0x82, 0x36, 0x07, 0x45, 0xad, 0x92, 0x00, + 0xaf, 0x3d, 0xe8, 0x5a, 0x7d, 0x7b, 0x63, 0xc2, + 0xde, + }, }, { .name = "brainpoolP384t1", @@ -1672,6 +2333,35 @@ static const struct ec_private_key { 0x88, 0x76, 0x72, 0x9a, 0xb4, 0xea, 0xc0, 0x48, 0x01, 0x5d, 0x8e, }, + .hex = "0485DB574B71B165" + "9351837CB324076B" + "7B5733733AA61486" + "83A88881F290DF93" + "4F6741EFCB3514AD" + "4C670BDB86035E6D" + "5E7E4B0F739E7350" + "8629097C38FCBEAF" + "599C69DFB460143E" + "B21A728657CB6B42" + "20677FBCA8578876" + "729AB4EAC048015D" + "8E", + .oct_len = 97, + .oct = { + 0x04, 0x85, 0xdb, 0x57, 0x4b, 0x71, 0xb1, 0x65, + 0x93, 0x51, 0x83, 0x7c, 0xb3, 0x24, 0x07, 0x6b, + 0x7b, 0x57, 0x33, 0x73, 0x3a, 0xa6, 0x14, 0x86, + 0x83, 0xa8, 0x88, 0x81, 0xf2, 0x90, 0xdf, 0x93, + 0x4f, 0x67, 0x41, 0xef, 0xcb, 0x35, 0x14, 0xad, + 0x4c, 0x67, 0x0b, 0xdb, 0x86, 0x03, 0x5e, 0x6d, + 0x5e, 0x7e, 0x4b, 0x0f, 0x73, 0x9e, 0x73, 0x50, + 0x86, 0x29, 0x09, 0x7c, 0x38, 0xfc, 0xbe, 0xaf, + 0x59, 0x9c, 0x69, 0xdf, 0xb4, 0x60, 0x14, 0x3e, + 0xb2, 0x1a, 0x72, 0x86, 0x57, 0xcb, 0x6b, 0x42, + 0x20, 0x67, 0x7f, 0xbc, 0xa8, 0x57, 0x88, 0x76, + 0x72, 0x9a, 0xb4, 0xea, 0xc0, 0x48, 0x01, 0x5d, + 0x8e, + }, }, { .name = "brainpoolP512r1", @@ -1706,6 +2396,43 @@ static const struct ec_private_key { 0x68, 0xe7, 0x19, 0xc1, 0x7d, 0xb6, 0x9d, 0xb9, 0xc6, 0xc2, 0x1b, 0x48, 0x7f, }, + .hex = "041E99EA54B61A4F" + "4425F4F8BE337CD1" + "6235F5D18E9FAEA8" + "8F6D61272D2AB196" + "486DB263059FECA1" + "CD6545C8CDF1A4BA" + "20B7E4C7923C1F16" + "F45B75E42A2E4472" + "6563C3785450CB50" + "E0BEE76F2ADC247B" + "F84BA8E21B27002D" + "E899DC5FA443A8F7" + "B155EAD702090897" + "5F211E16A0D827E4" + "5E3AA55168E719C1" + "7DB69DB9C6C21B48" + "7F", + .oct_len = 129, + .oct = { + 0x04, 0x1e, 0x99, 0xea, 0x54, 0xb6, 0x1a, 0x4f, + 0x44, 0x25, 0xf4, 0xf8, 0xbe, 0x33, 0x7c, 0xd1, + 0x62, 0x35, 0xf5, 0xd1, 0x8e, 0x9f, 0xae, 0xa8, + 0x8f, 0x6d, 0x61, 0x27, 0x2d, 0x2a, 0xb1, 0x96, + 0x48, 0x6d, 0xb2, 0x63, 0x05, 0x9f, 0xec, 0xa1, + 0xcd, 0x65, 0x45, 0xc8, 0xcd, 0xf1, 0xa4, 0xba, + 0x20, 0xb7, 0xe4, 0xc7, 0x92, 0x3c, 0x1f, 0x16, + 0xf4, 0x5b, 0x75, 0xe4, 0x2a, 0x2e, 0x44, 0x72, + 0x65, 0x63, 0xc3, 0x78, 0x54, 0x50, 0xcb, 0x50, + 0xe0, 0xbe, 0xe7, 0x6f, 0x2a, 0xdc, 0x24, 0x7b, + 0xf8, 0x4b, 0xa8, 0xe2, 0x1b, 0x27, 0x00, 0x2d, + 0xe8, 0x99, 0xdc, 0x5f, 0xa4, 0x43, 0xa8, 0xf7, + 0xb1, 0x55, 0xea, 0xd7, 0x02, 0x09, 0x08, 0x97, + 0x5f, 0x21, 0x1e, 0x16, 0xa0, 0xd8, 0x27, 0xe4, + 0x5e, 0x3a, 0xa5, 0x51, 0x68, 0xe7, 0x19, 0xc1, + 0x7d, 0xb6, 0x9d, 0xb9, 0xc6, 0xc2, 0x1b, 0x48, + 0x7f, + }, }, { .name = "brainpoolP512t1", @@ -1740,6 +2467,43 @@ static const struct ec_private_key { 0x68, 0x0f, 0x3f, 0x34, 0xee, 0x90, 0x4e, 0xab, 0x80, 0x7c, 0x41, 0xd7, 0x8f, }, + .hex = "045B2B478361EA80" + "148506E703BD2404" + "475D334EDE0C9209" + "5477530E333073C0" + "C06AF2B5B5D4D302" + "2F20E288B2074A9F" + "90BFBAB53DC45B65" + "76B5E5A17D633957" + "AA1D1F9952435D0B" + "58A6511E6F7B9E2F" + "455A2D6FAA2BFCE1" + "9F78117080F8FE51" + "4512BF79D8AF0559" + "1401819C125C8D4D" + "EDC74461680F3F34" + "EE904EAB807C41D7" + "8F", + .oct_len = 129, + .oct = { + 0x04, 0x5b, 0x2b, 0x47, 0x83, 0x61, 0xea, 0x80, + 0x14, 0x85, 0x06, 0xe7, 0x03, 0xbd, 0x24, 0x04, + 0x47, 0x5d, 0x33, 0x4e, 0xde, 0x0c, 0x92, 0x09, + 0x54, 0x77, 0x53, 0x0e, 0x33, 0x30, 0x73, 0xc0, + 0xc0, 0x6a, 0xf2, 0xb5, 0xb5, 0xd4, 0xd3, 0x02, + 0x2f, 0x20, 0xe2, 0x88, 0xb2, 0x07, 0x4a, 0x9f, + 0x90, 0xbf, 0xba, 0xb5, 0x3d, 0xc4, 0x5b, 0x65, + 0x76, 0xb5, 0xe5, 0xa1, 0x7d, 0x63, 0x39, 0x57, + 0xaa, 0x1d, 0x1f, 0x99, 0x52, 0x43, 0x5d, 0x0b, + 0x58, 0xa6, 0x51, 0x1e, 0x6f, 0x7b, 0x9e, 0x2f, + 0x45, 0x5a, 0x2d, 0x6f, 0xaa, 0x2b, 0xfc, 0xe1, + 0x9f, 0x78, 0x11, 0x70, 0x80, 0xf8, 0xfe, 0x51, + 0x45, 0x12, 0xbf, 0x79, 0xd8, 0xaf, 0x05, 0x59, + 0x14, 0x01, 0x81, 0x9c, 0x12, 0x5c, 0x8d, 0x4d, + 0xed, 0xc7, 0x44, 0x61, 0x68, 0x0f, 0x3f, 0x34, + 0xee, 0x90, 0x4e, 0xab, 0x80, 0x7c, 0x41, 0xd7, + 0x8f, + }, }, { .name = "FRP256v1", @@ -1762,6 +2526,27 @@ static const struct ec_private_key { 0xa7, 0xe0, 0x31, 0x1c, 0x4d, 0x1c, 0xa8, 0x2a, 0x51, 0x11, 0x24, }, + .hex = "0417C7AE1BE4C6D6" + "3ACF6B7E43299FDC" + "C2A3905362426EA3" + "A4CAD3F65353D4A6" + "1FA8031F6DD47577" + "23F792A47C5A4CC7" + "C6965462949BA7E0" + "311C4D1CA82A5111" + "24", + .oct_len = 65, + .oct = { + 0x04, 0x17, 0xc7, 0xae, 0x1b, 0xe4, 0xc6, 0xd6, + 0x3a, 0xcf, 0x6b, 0x7e, 0x43, 0x29, 0x9f, 0xdc, + 0xc2, 0xa3, 0x90, 0x53, 0x62, 0x42, 0x6e, 0xa3, + 0xa4, 0xca, 0xd3, 0xf6, 0x53, 0x53, 0xd4, 0xa6, + 0x1f, 0xa8, 0x03, 0x1f, 0x6d, 0xd4, 0x75, 0x77, + 0x23, 0xf7, 0x92, 0xa4, 0x7c, 0x5a, 0x4c, 0xc7, + 0xc6, 0x96, 0x54, 0x62, 0x94, 0x9b, 0xa7, 0xe0, + 0x31, 0x1c, 0x4d, 0x1c, 0xa8, 0x2a, 0x51, 0x11, + 0x24, + }, }, }; @@ -1771,10 +2556,15 @@ static int ec_group_check_private_key(const struct ec_private_key *key) { EC_KEY *ec_key = NULL, *ec_pub_key = NULL; + const EC_GROUP *group; + const EC_POINT *ec_public_point; + EC_POINT *point = NULL; + BIGNUM *hex_bn = NULL, *point_bn = NULL; const unsigned char *p; unsigned int flags; unsigned char *der = NULL, *ostr = NULL; - int der_len = 0, ostr_len = 0; + char *hex = NULL; + int der_len = 0, hex_len = 0, ostr_len = 0; uint8_t form; int rv; int failed = 1; @@ -1790,6 +2580,11 @@ ec_group_check_private_key(const struct ec_private_key *key) flags, key->name); goto err; } + if ((form = EC_KEY_get_conv_form(ec_key)) != POINT_CONVERSION_UNCOMPRESSED) { + fprintf(stderr, "FAIL: got conversion form %02x, want %02x\n", + form, POINT_CONVERSION_UNCOMPRESSED); + goto err; + } ERR_clear_error(); if (!EC_KEY_check_key(ec_key)) { @@ -1810,6 +2605,92 @@ ec_group_check_private_key(const struct ec_private_key *key) freezero(der, der_len); der = NULL; + /* + * Check the outputs of EC_POINT_point2hex() and i2o_ECPublicKey(). + */ + + if ((group = EC_KEY_get0_group(ec_key)) == NULL) { + fprintf(stderr, "FAIL: EC_KEY_get0_group() for %s\n", key->name); + goto err; + } + if ((ec_public_point = EC_KEY_get0_public_key(ec_key)) == NULL) { + fprintf(stderr, "FAIL: EC_KEY_get0_public_key() for %s\n", key->name); + goto err; + } + + if ((hex = EC_POINT_point2hex(group, ec_public_point, + POINT_CONVERSION_UNCOMPRESSED, NULL)) == NULL) { + fprintf(stderr, "FAIL: EC_POINT_point2hex() for %s\n", key->name); + goto err; + } + + if ((hex_len = strlen(hex)) != 2 * key->oct_len) { + fprintf(stderr, "FAIL: hex_len: %d, oct_len %d for %s\n", + hex_len, key->oct_len, key->name); + goto err; + } + + freezero(ostr, ostr_len); + ostr = NULL; + if ((ostr_len = i2o_ECPublicKey(ec_key, &ostr)) <= 0) { + fprintf(stderr, "FAIL: i2o_ECPublicKey for %s\n", key->name); + goto err; + } + + if (compare_data(key->name, ostr, ostr_len, key->oct, key->oct_len) == -1) { + fprintf(stderr, "FAIL: i2o_ECPublicKey comparison for %s\n", + key->name); + goto err; + } + + /* + * Now compare the octet string placed into a bignum with what we got + * from point2hex (what a wonderful idea). + */ + + if ((point_bn = BN_new()) == NULL) + err(1, "BN_new()"); + if ((EC_POINT_point2bn(group, ec_public_point, + POINT_CONVERSION_UNCOMPRESSED, point_bn, NULL)) == NULL) { + fprintf(stderr, "FAIL: EC_POINT_point2bn() for %s\n", key->name); + goto err; + } + + if ((BN_hex2bn(&hex_bn, hex)) != hex_len) { + fprintf(stderr, "FAIL: BN_hex2bn() for %s\n", key->name); + goto err; + } + + if (BN_cmp(hex_bn, point_bn) != 0) { + fprintf(stderr, "FAIL: mismatch between " + "hex point and curve point for %s\n", key->name); + goto err; + } + + /* + * And translate back to a point on the curve. + */ + + EC_POINT_free(point); + point = NULL; + if ((point = EC_POINT_hex2point(group, hex, NULL, NULL)) == NULL) { + fprintf(stderr, "FAIL: EC_POINT_hex2point() failed for %s\n", + key->name); + goto err; + } + + if ((rv = EC_POINT_cmp(group, ec_public_point, point, NULL)) != 0) { + fprintf(stderr, "FAIL: EC_POINT_cmp() returned %d for %s\n", + rv, key->name); + goto err; + } + + free(hex); + hex = NULL; + + freezero(ostr, ostr_len); + ostr = NULL; + /* * Round trip the public key through i2o and o2i in compressed form. */ @@ -1911,6 +2792,12 @@ ec_group_check_private_key(const struct ec_private_key *key) freezero(der, der_len); freezero(ostr, ostr_len); + free(hex); + + BN_free(hex_bn); + BN_free(point_bn); + + EC_POINT_free(point); return failed; } -- cgit v1.2.3