generate_test_keys: generate also look-up table in script

Remove static declaration of look-up table from test_suite_pk
and generate it automatically with Python.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
This commit is contained in:
Valerio Setti 2024-04-16 10:54:23 +02:00
parent 7031a4ebd8
commit 9aa4fa9572
3 changed files with 285 additions and 284 deletions

View File

@ -32,13 +32,6 @@ def c_byte_array_literal_content(array_name: str, key_data: bytes) -> Iterator[s
def convert_der_to_c(array_name: str, key_data: bytes) -> str:
return ''.join(c_byte_array_literal_content(array_name, key_data))
EC_NAME_CONVERSION = {
'PSA_ECC_FAMILY_SECP_K1': ['secp', 'k1'],
'PSA_ECC_FAMILY_SECP_R1': ['secp', 'r1'],
'PSA_ECC_FAMILY_BRAINPOOL_P_R1': ['bp', 'r1'],
'PSA_ECC_FAMILY_MONTGOMERY': ['curve', ''],
}
def get_key_type(key: str) -> str:
if re.match('PSA_KEY_TYPE_RSA_.*', key):
return "rsa"
@ -54,11 +47,49 @@ def get_ec_key_family(key: str) -> str:
raise Exception("Unable to get EC family from {}".format(key))
return match.group(1)
def get_key_role(key_type: str) -> str:
if re.match('PSA_KEY_TYPE_.*_KEY_PAIR', key_type):
return "priv"
else:
return "pub"
# Legacy EC group ID do not support all the key types that PSA does, so the
# following dictionaries are used for:
# - getting prefix/suffix for legacy curve names
# - understand if the curve is supported in legacy symbols (MBEDTLS_ECP_DP_...)
EC_NAME_CONVERSION = {
'PSA_ECC_FAMILY_SECP_K1': {
192: ['secp', 'k1'],
224: ['secp', 'k1'],
256: ['secp', 'k1']
},
'PSA_ECC_FAMILY_SECP_R1': {
192: ['secp', 'r1'],
224: ['secp', 'r1'],
256: ['secp', 'r1'],
384: ['secp', 'r1'],
521: ['secp', 'r1']
},
'PSA_ECC_FAMILY_BRAINPOOL_P_R1': {
256: ['bp', 'r1'],
384: ['bp', 'r1'],
512: ['bp', 'r1']
},
'PSA_ECC_FAMILY_MONTGOMERY': {
255: ['curve', '19'],
448: ['curve', '']
}
}
def get_ec_curve_name(priv_key: str, bits: int) -> str:
ec_family = get_ec_key_family(priv_key)
try:
prefix = EC_NAME_CONVERSION[ec_family][bits][0]
suffix = EC_NAME_CONVERSION[ec_family][bits][1]
except: # pylint: disable=bare-except
return ""
return prefix + str(bits) + suffix
def get_look_up_table_entry(key_type: str, curve_or_keybits: str,
priv_array_name: str, pub_array_name: str) -> Iterator[str]:
yield "\n {{ {}, ".format("1" if key_type == "ec" else "0")
yield "{},\n".format(curve_or_keybits)
yield " {0}, sizeof({0}),\n".format(priv_array_name)
yield " {0}, sizeof({0}) }},".format(pub_array_name)
def main() -> None:
# Remove output file if already existing.
@ -73,33 +104,60 @@ def main() -> None:
" *********************************************************************************/\n"
)
for key in ASYMMETRIC_KEY_DATA:
key_type = get_key_type(key)
look_up_table = ""
# Get a list of private keys only in order to get a single item for every
# (key type, key bits) pair. We know that ASYMMETRIC_KEY_DATA
# contains also the public counterpart.
priv_keys = [key for key in ASYMMETRIC_KEY_DATA if re.match(r'.*_KEY_PAIR', key)]
for priv_key in priv_keys:
key_type = get_key_type(priv_key)
# Ignore keys which are not EC or RSA
if key_type == "unknown":
continue
# Ignore undesired EC keys
if key_type == "ec":
ec_family = get_ec_key_family(key)
if not ec_family in EC_NAME_CONVERSION:
continue
role = get_key_role(key)
for bits in ASYMMETRIC_KEY_DATA[key]:
pub_key = re.sub('_KEY_PAIR', '_PUBLIC_KEY', priv_key)
for bits in ASYMMETRIC_KEY_DATA[priv_key]:
if key_type == "ec":
curve = get_ec_curve_name(priv_key, bits)
# Ignore EC curves unsupported in legacy symbols
if curve == "":
continue
# Create output array name
if key_type == "rsa":
array_name = "_".join(["test", key_type, str(bits), role])
array_name_base = "_".join(["test", key_type, str(bits)])
else:
prefix = EC_NAME_CONVERSION[ec_family][0]
suffix = EC_NAME_CONVERSION[ec_family][1]
curve = "".join([prefix, str(bits), suffix])
array_name = "_".join(["test", key_type, curve, role])
array_name_base = "_".join(["test", key_type, curve])
array_name_priv = array_name_base + "_priv"
array_name_pub = array_name_base + "_pub"
# Convert bytearray to C array
c_array = convert_der_to_c(array_name, ASYMMETRIC_KEY_DATA[key][bits])
c_array_priv = convert_der_to_c(array_name_priv, ASYMMETRIC_KEY_DATA[priv_key][bits])
c_array_pub = convert_der_to_c(array_name_pub, ASYMMETRIC_KEY_DATA[pub_key][bits])
# Write the C array to the output file
output_file.write("\n")
output_file.write(c_array)
output_file.write("\n")
output_file.write(''.join(["\n", c_array_priv, "\n", c_array_pub, "\n"]))
# Update the lookup table
if key_type == "ec":
curve_or_keybits = "MBEDTLS_ECP_DP_" + curve.upper()
else:
curve_or_keybits = str(bits)
look_up_table = look_up_table + \
''.join(get_look_up_table_entry(key_type, curve_or_keybits,
array_name_priv, array_name_pub))
# Write the lookup table: the struct containing pointers to all the arrays we created above.
output_file.write("""
struct predefined_key_element {
int is_ec; // 1 for EC keys; 0 for RSA
int curve_or_keybits;
const unsigned char *priv_key;
size_t priv_key_len;
const unsigned char *pub_key;
size_t pub_key_len;
};
struct predefined_key_element predefined_keys[] = {""")
output_file.write("{}\n}};\n".format(look_up_table))
if __name__ == '__main__':
main()

View File

@ -7,17 +7,6 @@ const unsigned char test_ec_secp192k1_priv[] = {
0x29, 0x7a, 0xc1, 0x72, 0x2c, 0xca, 0xc7, 0x58, 0x9e, 0xcb, 0x24, 0x0d, 0xc7, 0x19, 0x84, 0x25,
0x38, 0xca, 0x97, 0x4b, 0xeb, 0x79, 0xf2, 0x28,
};
const unsigned char test_ec_secp225k1_priv[] = {
0x00, 0x24, 0x12, 0x2b, 0xf0, 0x20, 0xfa, 0x11, 0x3f, 0x6c, 0x0a, 0xc9, 0x78, 0xdf, 0xbd, 0x41,
0xf7, 0x49, 0x25, 0x7a, 0x94, 0x68, 0xfe, 0xbd, 0xbe, 0x0d, 0xc9, 0xf7, 0xe8,
};
const unsigned char test_ec_secp256k1_priv[] = {
0x7f, 0xa0, 0x6f, 0xa0, 0x2d, 0x0e, 0x91, 0x1b, 0x9a, 0x47, 0xfd, 0xc1, 0x7d, 0x2d, 0x96, 0x2c,
0xa0, 0x1e, 0x2f, 0x31, 0xd6, 0x0c, 0x62, 0x12, 0xd0, 0xed, 0x7e, 0x3b, 0xba, 0x23, 0xa7, 0xb9,
};
const unsigned char test_ec_secp192k1_pub[] = {
0x04, 0x26, 0xb7, 0xbb, 0x38, 0xda, 0x64, 0x9a, 0xc2, 0x13, 0x8f, 0xc0, 0x50, 0xc6, 0x54, 0x8b,
0x32, 0x55, 0x3d, 0xab, 0x68, 0xaf, 0xeb, 0xc3, 0x61, 0x05, 0xd3, 0x25, 0xb7, 0x55, 0x38, 0xc1,
@ -25,13 +14,10 @@ const unsigned char test_ec_secp192k1_pub[] = {
0xf5,
};
const unsigned char test_ec_secp225k1_pub[] = {
0x04, 0x2c, 0xc7, 0x33, 0x5f, 0x4b, 0x76, 0x04, 0x2b, 0xed, 0x44, 0xef, 0x45, 0x95, 0x9a, 0x62,
0xaa, 0x21, 0x5f, 0x7a, 0x5f, 0xf0, 0xc8, 0x11, 0x1b, 0x8c, 0x44, 0xed, 0x65, 0x4e, 0xe7, 0x1c,
0x19, 0x18, 0x32, 0x6a, 0xd4, 0x85, 0xb2, 0xd5, 0x99, 0xfe, 0x2a, 0x6e, 0xab, 0x09, 0x6e, 0xe2,
0x6d, 0x97, 0x73, 0x34, 0xd2, 0xba, 0xc6, 0xd6, 0x1d,
const unsigned char test_ec_secp256k1_priv[] = {
0x7f, 0xa0, 0x6f, 0xa0, 0x2d, 0x0e, 0x91, 0x1b, 0x9a, 0x47, 0xfd, 0xc1, 0x7d, 0x2d, 0x96, 0x2c,
0xa0, 0x1e, 0x2f, 0x31, 0xd6, 0x0c, 0x62, 0x12, 0xd0, 0xed, 0x7e, 0x3b, 0xba, 0x23, 0xa7, 0xb9,
};
const unsigned char test_ec_secp256k1_pub[] = {
0x04, 0x5c, 0x39, 0x15, 0x45, 0x79, 0xef, 0xd6, 0x67, 0xad, 0xc7, 0x3a, 0x81, 0x01, 0x5a, 0x79,
0x7d, 0x2c, 0x86, 0x82, 0xcd, 0xfb, 0xd3, 0xc3, 0x55, 0x3c, 0x4a, 0x18, 0x5d, 0x48, 0x1c, 0xdc,
@ -44,31 +30,6 @@ const unsigned char test_ec_secp192r1_priv[] = {
0xd8, 0x3b, 0x57, 0xa5, 0x9c, 0x51, 0x35, 0x8d, 0x9c, 0x8b, 0xbb, 0x89, 0x8a, 0xff, 0x50, 0x7f,
0x44, 0xdd, 0x14, 0xcf, 0x16, 0x91, 0x71, 0x90,
};
const unsigned char test_ec_secp224r1_priv[] = {
0x87, 0x2f, 0x20, 0x3b, 0x3a, 0xd3, 0x5b, 0x7f, 0x2e, 0xcc, 0x80, 0x3c, 0x3a, 0x0e, 0x1e, 0x0b,
0x1e, 0xd6, 0x1c, 0xc1, 0xaf, 0xe7, 0x1b, 0x18, 0x9c, 0xd4, 0xc9, 0x95,
};
const unsigned char test_ec_secp256r1_priv[] = {
0x49, 0xc9, 0xa8, 0xc1, 0x8c, 0x4b, 0x88, 0x56, 0x38, 0xc4, 0x31, 0xcf, 0x1d, 0xf1, 0xc9, 0x94,
0x13, 0x16, 0x09, 0xb5, 0x80, 0xd4, 0xfd, 0x43, 0xa0, 0xca, 0xb1, 0x7d, 0xb2, 0xf1, 0x3e, 0xee,
};
const unsigned char test_ec_secp384r1_priv[] = {
0x3f, 0x5d, 0x8d, 0x9b, 0xe2, 0x80, 0xb5, 0x69, 0x6c, 0xc5, 0xcc, 0x9f, 0x94, 0xcf, 0x8a, 0xf7,
0xe6, 0xb6, 0x1d, 0xd6, 0x59, 0x2b, 0x2a, 0xb2, 0xb3, 0xa4, 0xc6, 0x07, 0x45, 0x04, 0x17, 0xec,
0x32, 0x7d, 0xcd, 0xca, 0xed, 0x7c, 0x10, 0x05, 0x3d, 0x71, 0x9a, 0x05, 0x74, 0xf0, 0xa7, 0x6a,
};
const unsigned char test_ec_secp521r1_priv[] = {
0x01, 0xb1, 0xb6, 0xad, 0x07, 0xbb, 0x79, 0xe7, 0x32, 0x0d, 0xa5, 0x98, 0x60, 0xea, 0x28, 0xe0,
0x55, 0x28, 0x4f, 0x60, 0x58, 0xf2, 0x79, 0xde, 0x66, 0x6e, 0x06, 0xd4, 0x35, 0xd2, 0xaf, 0x7b,
0xda, 0x28, 0xd9, 0x9f, 0xa4, 0x7b, 0x7d, 0xd0, 0x96, 0x3e, 0x16, 0xb0, 0x07, 0x30, 0x78, 0xee,
0x8b, 0x8a, 0x38, 0xd9, 0x66, 0xa5, 0x82, 0xf4, 0x6d, 0x19, 0xff, 0x95, 0xdf, 0x3a, 0xd9, 0x68,
0x5a, 0xae,
};
const unsigned char test_ec_secp192r1_pub[] = {
0x04, 0xe3, 0x5f, 0xcb, 0xee, 0x11, 0xce, 0xc3, 0x15, 0x4f, 0x80, 0xa1, 0xa6, 0x1d, 0xf7, 0xd7,
0x61, 0x2d, 0xe4, 0xf2, 0xfd, 0x70, 0xc5, 0x60, 0x8d, 0x0e, 0xe3, 0xa4, 0xa1, 0xa5, 0x71, 0x94,
@ -76,6 +37,10 @@ const unsigned char test_ec_secp192r1_pub[] = {
0x4c,
};
const unsigned char test_ec_secp224r1_priv[] = {
0x87, 0x2f, 0x20, 0x3b, 0x3a, 0xd3, 0x5b, 0x7f, 0x2e, 0xcc, 0x80, 0x3c, 0x3a, 0x0e, 0x1e, 0x0b,
0x1e, 0xd6, 0x1c, 0xc1, 0xaf, 0xe7, 0x1b, 0x18, 0x9c, 0xd4, 0xc9, 0x95,
};
const unsigned char test_ec_secp224r1_pub[] = {
0x04, 0x6f, 0x00, 0xea, 0xda, 0xa9, 0x49, 0xfe, 0xe3, 0xe9, 0xe1, 0xc7, 0xfa, 0x12, 0x47, 0xee,
0xce, 0xc8, 0x6a, 0x0d, 0xce, 0x46, 0x41, 0x8b, 0x9b, 0xd3, 0x11, 0x7b, 0x98, 0x1d, 0x4b, 0xd0,
@ -83,6 +48,10 @@ const unsigned char test_ec_secp224r1_pub[] = {
0x39, 0x4a, 0xc2, 0x9e, 0x81, 0x80, 0x4b, 0xf1, 0x60,
};
const unsigned char test_ec_secp256r1_priv[] = {
0x49, 0xc9, 0xa8, 0xc1, 0x8c, 0x4b, 0x88, 0x56, 0x38, 0xc4, 0x31, 0xcf, 0x1d, 0xf1, 0xc9, 0x94,
0x13, 0x16, 0x09, 0xb5, 0x80, 0xd4, 0xfd, 0x43, 0xa0, 0xca, 0xb1, 0x7d, 0xb2, 0xf1, 0x3e, 0xee,
};
const unsigned char test_ec_secp256r1_pub[] = {
0x04, 0x77, 0x72, 0x65, 0x6f, 0x81, 0x4b, 0x39, 0x92, 0x79, 0xd5, 0xe1, 0xf1, 0x78, 0x1f, 0xac,
0x6f, 0x09, 0x9a, 0x3c, 0x5c, 0xa1, 0xb0, 0xe3, 0x53, 0x51, 0x83, 0x4b, 0x08, 0xb6, 0x5e, 0x0b,
@ -91,6 +60,11 @@ const unsigned char test_ec_secp256r1_pub[] = {
0x45,
};
const unsigned char test_ec_secp384r1_priv[] = {
0x3f, 0x5d, 0x8d, 0x9b, 0xe2, 0x80, 0xb5, 0x69, 0x6c, 0xc5, 0xcc, 0x9f, 0x94, 0xcf, 0x8a, 0xf7,
0xe6, 0xb6, 0x1d, 0xd6, 0x59, 0x2b, 0x2a, 0xb2, 0xb3, 0xa4, 0xc6, 0x07, 0x45, 0x04, 0x17, 0xec,
0x32, 0x7d, 0xcd, 0xca, 0xed, 0x7c, 0x10, 0x05, 0x3d, 0x71, 0x9a, 0x05, 0x74, 0xf0, 0xa7, 0x6a,
};
const unsigned char test_ec_secp384r1_pub[] = {
0x04, 0xd9, 0xc6, 0x62, 0xb5, 0x0b, 0xa2, 0x9c, 0xa4, 0x79, 0x90, 0x45, 0x0e, 0x04, 0x3a, 0xea,
0xf4, 0xf0, 0xc6, 0x9b, 0x15, 0x67, 0x6d, 0x11, 0x2f, 0x62, 0x2a, 0x71, 0xc9, 0x30, 0x59, 0xaf,
@ -101,6 +75,13 @@ const unsigned char test_ec_secp384r1_pub[] = {
0x47,
};
const unsigned char test_ec_secp521r1_priv[] = {
0x01, 0xb1, 0xb6, 0xad, 0x07, 0xbb, 0x79, 0xe7, 0x32, 0x0d, 0xa5, 0x98, 0x60, 0xea, 0x28, 0xe0,
0x55, 0x28, 0x4f, 0x60, 0x58, 0xf2, 0x79, 0xde, 0x66, 0x6e, 0x06, 0xd4, 0x35, 0xd2, 0xaf, 0x7b,
0xda, 0x28, 0xd9, 0x9f, 0xa4, 0x7b, 0x7d, 0xd0, 0x96, 0x3e, 0x16, 0xb0, 0x07, 0x30, 0x78, 0xee,
0x8b, 0x8a, 0x38, 0xd9, 0x66, 0xa5, 0x82, 0xf4, 0x6d, 0x19, 0xff, 0x95, 0xdf, 0x3a, 0xd9, 0x68,
0x5a, 0xae,
};
const unsigned char test_ec_secp521r1_pub[] = {
0x04, 0x00, 0x1d, 0xe1, 0x42, 0xd5, 0x4f, 0x69, 0xeb, 0x03, 0x8e, 0xe4, 0xb7, 0xaf, 0x9d, 0x3c,
0xa0, 0x77, 0x36, 0xfd, 0x9c, 0xf7, 0x19, 0xeb, 0x35, 0x4d, 0x69, 0x87, 0x9e, 0xe7, 0xf3, 0xc1,
@ -113,65 +94,10 @@ const unsigned char test_ec_secp521r1_pub[] = {
0x2c, 0x4c, 0x2f, 0x6a, 0xc1,
};
const unsigned char test_ec_bp160r1_priv[] = {
0x69, 0x50, 0x2c, 0x4f, 0xda, 0xf4, 0x8d, 0x4f, 0xa6, 0x17, 0xbd, 0xd2, 0x44, 0x98, 0xb0, 0x40,
0x6d, 0x0e, 0xea, 0xac,
};
const unsigned char test_ec_bp192r1_priv[] = {
0x16, 0x88, 0xa2, 0xc5, 0xfb, 0xf4, 0xa3, 0xc8, 0x51, 0xd7, 0x6a, 0x98, 0xc3, 0xec, 0x88, 0xf4,
0x45, 0xa9, 0x79, 0x96, 0x28, 0x3d, 0xb5, 0x9f,
};
const unsigned char test_ec_bp224r1_priv[] = {
0xa6, 0x98, 0x35, 0xda, 0xfe, 0xb5, 0xda, 0x5a, 0xb8, 0x9c, 0x59, 0x86, 0x0d, 0xdd, 0xeb, 0xcf,
0xd8, 0x0b, 0x52, 0x9a, 0x99, 0xf5, 0x9b, 0x88, 0x08, 0x82, 0x92, 0x3c,
};
const unsigned char test_ec_bp256r1_priv[] = {
0x21, 0x61, 0xd6, 0xf2, 0xdb, 0x76, 0x52, 0x6f, 0xa6, 0x2c, 0x16, 0xf3, 0x56, 0xa8, 0x0f, 0x01,
0xf3, 0x2f, 0x77, 0x67, 0x84, 0xb3, 0x6a, 0xa9, 0x97, 0x99, 0xa8, 0xb7, 0x66, 0x20, 0x80, 0xff,
};
const unsigned char test_ec_bp320r1_priv[] = {
0x61, 0xb8, 0xda, 0xa7, 0xa6, 0xe5, 0xaa, 0x9f, 0xcc, 0xf1, 0xef, 0x50, 0x42, 0x20, 0xb2, 0xe5,
0xa5, 0xb8, 0xc6, 0xdc, 0x74, 0x75, 0xd1, 0x6d, 0x31, 0x72, 0xd7, 0xdb, 0x0b, 0x27, 0x78, 0x41,
0x4e, 0x4f, 0x6e, 0x8f, 0xa2, 0x03, 0x2e, 0xad,
};
const unsigned char test_ec_bp384r1_priv[] = {
0x3d, 0xd9, 0x2e, 0x75, 0x0d, 0x90, 0xd7, 0xd3, 0x9f, 0xc1, 0x88, 0x5c, 0xd8, 0xad, 0x12, 0xea,
0x94, 0x41, 0xf2, 0x2b, 0x93, 0x34, 0xb4, 0xd9, 0x65, 0x20, 0x2a, 0xdb, 0x14, 0x48, 0xce, 0x24,
0xc5, 0x80, 0x8a, 0x85, 0xdd, 0x9a, 0xfc, 0x22, 0x9a, 0xf0, 0xa3, 0x12, 0x4f, 0x75, 0x5b, 0xcb,
};
const unsigned char test_ec_bp512r1_priv[] = {
0x37, 0x2c, 0x97, 0x78, 0xf6, 0x9f, 0x72, 0x6c, 0xbc, 0xa3, 0xf4, 0xa2, 0x68, 0xf1, 0x6b, 0x4d,
0x61, 0x7d, 0x10, 0x28, 0x0d, 0x79, 0xa6, 0xa0, 0x29, 0xcd, 0x51, 0x87, 0x9f, 0xe1, 0x01, 0x29,
0x34, 0xdf, 0xe5, 0x39, 0x54, 0x55, 0x33, 0x7d, 0xf6, 0x90, 0x6d, 0xc7, 0xd6, 0xd2, 0xee, 0xa4,
0xdb, 0xb2, 0x06, 0x5c, 0x02, 0x28, 0xf7, 0x3b, 0x3e, 0xd7, 0x16, 0x48, 0x0e, 0x7d, 0x71, 0xd2,
};
const unsigned char test_ec_bp160r1_pub[] = {
0x04, 0xd4, 0xb9, 0x18, 0x68, 0x16, 0x35, 0x8e, 0x2f, 0x9c, 0x59, 0xcf, 0x70, 0x74, 0x8c, 0xb7,
0x06, 0x41, 0xb2, 0x2f, 0xba, 0xb6, 0x54, 0x73, 0xdb, 0x4b, 0x4e, 0x22, 0xa3, 0x61, 0xed, 0x7e,
0x3d, 0xe7, 0xe8, 0xa8, 0xdd, 0xc4, 0x13, 0x0c, 0x5c,
};
const unsigned char test_ec_bp192r1_pub[] = {
0x04, 0x3f, 0xdd, 0x16, 0x8c, 0x17, 0x9f, 0xf5, 0x36, 0x3d, 0xd7, 0x1d, 0xcd, 0x58, 0xde, 0x96,
0x17, 0xca, 0xad, 0x79, 0x1a, 0xe0, 0xc3, 0x73, 0x28, 0xbe, 0x9c, 0xa0, 0xbf, 0xc7, 0x9c, 0xeb,
0xab, 0xf6, 0xa9, 0x5d, 0x1c, 0x52, 0xdf, 0x5b, 0x5f, 0x3c, 0x8b, 0x1a, 0x24, 0x41, 0xcf, 0x6c,
0x88,
};
const unsigned char test_ec_bp224r1_pub[] = {
0x04, 0x5f, 0xbe, 0xa3, 0x78, 0xfc, 0x85, 0x83, 0xb3, 0x83, 0x7e, 0x3f, 0x21, 0xa4, 0x57, 0xc3,
0x1e, 0xaf, 0x20, 0xa5, 0x4e, 0x18, 0xeb, 0x11, 0xd1, 0x04, 0xb3, 0xad, 0xc4, 0x7f, 0x9d, 0x1c,
0x97, 0xeb, 0x9e, 0xa4, 0xac, 0x21, 0x74, 0x0d, 0x70, 0xd8, 0x85, 0x14, 0xb9, 0x8b, 0xf0, 0xbc,
0x31, 0xad, 0xda, 0xc1, 0xd1, 0x9c, 0x4a, 0xb3, 0xcc,
};
const unsigned char test_ec_bp256r1_pub[] = {
0x04, 0x76, 0x8c, 0x8c, 0xae, 0x4a, 0xbc, 0xa6, 0x30, 0x6d, 0xb0, 0xed, 0x81, 0xb0, 0xc4, 0xa6,
0x21, 0x5c, 0x37, 0x80, 0x66, 0xec, 0x6d, 0x61, 0x6c, 0x14, 0x6e, 0x13, 0xf1, 0xc7, 0xdf, 0x80,
@ -180,15 +106,11 @@ const unsigned char test_ec_bp256r1_pub[] = {
0x1d,
};
const unsigned char test_ec_bp320r1_pub[] = {
0x04, 0x9c, 0xae, 0xd8, 0xfb, 0x47, 0x42, 0x95, 0x6c, 0xc2, 0xad, 0x12, 0xa9, 0xa1, 0xc9, 0x95,
0xe2, 0x17, 0x59, 0xef, 0x26, 0xa0, 0x7b, 0xc2, 0x05, 0x41, 0x36, 0xd3, 0xd2, 0xf2, 0x8b, 0xb3,
0x31, 0xa7, 0x0e, 0x26, 0xc4, 0xc6, 0x87, 0x27, 0x5a, 0xb1, 0xf4, 0x34, 0xbe, 0x78, 0x71, 0xe1,
0x15, 0xd2, 0x35, 0x0c, 0x0c, 0x5f, 0x61, 0xd4, 0xd0, 0x6d, 0x2b, 0xcd, 0xb6, 0x7f, 0x5c, 0xb6,
0x3f, 0xdb, 0x79, 0x4e, 0x59, 0x47, 0xc8, 0x7d, 0xc6, 0x84, 0x9a, 0x58, 0x69, 0x4e, 0x37, 0xe6,
0xcd,
const unsigned char test_ec_bp384r1_priv[] = {
0x3d, 0xd9, 0x2e, 0x75, 0x0d, 0x90, 0xd7, 0xd3, 0x9f, 0xc1, 0x88, 0x5c, 0xd8, 0xad, 0x12, 0xea,
0x94, 0x41, 0xf2, 0x2b, 0x93, 0x34, 0xb4, 0xd9, 0x65, 0x20, 0x2a, 0xdb, 0x14, 0x48, 0xce, 0x24,
0xc5, 0x80, 0x8a, 0x85, 0xdd, 0x9a, 0xfc, 0x22, 0x9a, 0xf0, 0xa3, 0x12, 0x4f, 0x75, 0x5b, 0xcb,
};
const unsigned char test_ec_bp384r1_pub[] = {
0x04, 0x71, 0x9f, 0x9d, 0x09, 0x3a, 0x62, 0x7e, 0x0d, 0x35, 0x03, 0x85, 0xc6, 0x61, 0xce, 0xbf,
0x00, 0xc6, 0x19, 0x23, 0x56, 0x6f, 0xe9, 0x00, 0x6a, 0x31, 0x07, 0xaf, 0x1d, 0x87, 0x1b, 0xc6,
@ -199,6 +121,12 @@ const unsigned char test_ec_bp384r1_pub[] = {
0x6a,
};
const unsigned char test_ec_bp512r1_priv[] = {
0x37, 0x2c, 0x97, 0x78, 0xf6, 0x9f, 0x72, 0x6c, 0xbc, 0xa3, 0xf4, 0xa2, 0x68, 0xf1, 0x6b, 0x4d,
0x61, 0x7d, 0x10, 0x28, 0x0d, 0x79, 0xa6, 0xa0, 0x29, 0xcd, 0x51, 0x87, 0x9f, 0xe1, 0x01, 0x29,
0x34, 0xdf, 0xe5, 0x39, 0x54, 0x55, 0x33, 0x7d, 0xf6, 0x90, 0x6d, 0xc7, 0xd6, 0xd2, 0xee, 0xa4,
0xdb, 0xb2, 0x06, 0x5c, 0x02, 0x28, 0xf7, 0x3b, 0x3e, 0xd7, 0x16, 0x48, 0x0e, 0x7d, 0x71, 0xd2,
};
const unsigned char test_ec_bp512r1_pub[] = {
0x04, 0x38, 0xb7, 0xec, 0x92, 0xb6, 0x1c, 0x5c, 0x6c, 0x7f, 0xbc, 0x28, 0xa4, 0xec, 0x75, 0x9d,
0x48, 0xfc, 0xd4, 0xe2, 0xe3, 0x74, 0xde, 0xfd, 0x5c, 0x49, 0x68, 0xa5, 0x4d, 0xbe, 0xf7, 0x51,
@ -211,10 +139,14 @@ const unsigned char test_ec_bp512r1_pub[] = {
0x1a,
};
const unsigned char test_ec_curve255_priv[] = {
const unsigned char test_ec_curve25519_priv[] = {
0x70, 0x07, 0x6d, 0x0a, 0x73, 0x18, 0xa5, 0x7d, 0x3c, 0x16, 0xc1, 0x72, 0x51, 0xb2, 0x66, 0x45,
0xdf, 0x4c, 0x2f, 0x87, 0xeb, 0xc0, 0x99, 0x2a, 0xb1, 0x77, 0xfb, 0xa5, 0x1d, 0xb9, 0x2c, 0x6a,
};
const unsigned char test_ec_curve25519_pub[] = {
0x85, 0x20, 0xf0, 0x09, 0x89, 0x30, 0xa7, 0x54, 0x74, 0x8b, 0x7d, 0xdc, 0xb4, 0x3e, 0xf7, 0x5a,
0x0d, 0xbf, 0x3a, 0x0d, 0x26, 0x38, 0x1a, 0xf4, 0xeb, 0xa4, 0xa9, 0x8e, 0xaa, 0x9b, 0x4e, 0x6a,
};
const unsigned char test_ec_curve448_priv[] = {
0xe4, 0xe4, 0x9f, 0x52, 0x68, 0x6f, 0x9e, 0xe3, 0xb6, 0x38, 0x52, 0x8f, 0x72, 0x1f, 0x15, 0x96,
@ -222,12 +154,6 @@ const unsigned char test_ec_curve448_priv[] = {
0xeb, 0x1a, 0x28, 0x6d, 0xc7, 0x80, 0x18, 0x09, 0x5c, 0xdf, 0xec, 0x05, 0x0e, 0x80, 0x07, 0xb5,
0xf4, 0x90, 0x89, 0x62, 0xba, 0x20, 0xd6, 0xc1,
};
const unsigned char test_ec_curve255_pub[] = {
0x85, 0x20, 0xf0, 0x09, 0x89, 0x30, 0xa7, 0x54, 0x74, 0x8b, 0x7d, 0xdc, 0xb4, 0x3e, 0xf7, 0x5a,
0x0d, 0xbf, 0x3a, 0x0d, 0x26, 0x38, 0x1a, 0xf4, 0xeb, 0xa4, 0xa9, 0x8e, 0xaa, 0x9b, 0x4e, 0x6a,
};
const unsigned char test_ec_curve448_pub[] = {
0xc0, 0xd3, 0xa5, 0xa2, 0xb4, 0x16, 0xa5, 0x73, 0xdc, 0x99, 0x09, 0xf9, 0x2f, 0x13, 0x4a, 0xc0,
0x13, 0x23, 0xab, 0x8f, 0x8e, 0x36, 0x80, 0x4e, 0x57, 0x85, 0x88, 0xba, 0x2d, 0x09, 0xfe, 0x7c,
@ -276,6 +202,17 @@ const unsigned char test_rsa_1024_priv[] = {
0xba, 0xf2, 0x5b, 0xe5, 0x73, 0x8a, 0xae, 0x59, 0xbb, 0xfe, 0x1c, 0x99, 0x77, 0x81, 0x44, 0x7a,
0x2b, 0x24,
};
const unsigned char test_rsa_1024_pub[] = {
0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xaf, 0x05, 0x7d, 0x39, 0x6e, 0xe8, 0x4f, 0xb7, 0x5f,
0xdb, 0xb5, 0xc2, 0xb1, 0x3c, 0x7f, 0xe5, 0xa6, 0x54, 0xaa, 0x8a, 0xa2, 0x47, 0x0b, 0x54, 0x1e,
0xe1, 0xfe, 0xb0, 0xb1, 0x2d, 0x25, 0xc7, 0x97, 0x11, 0x53, 0x12, 0x49, 0xe1, 0x12, 0x96, 0x28,
0x04, 0x2d, 0xbb, 0xb6, 0xc1, 0x20, 0xd1, 0x44, 0x35, 0x24, 0xef, 0x4c, 0x0e, 0x6e, 0x1d, 0x89,
0x56, 0xee, 0xb2, 0x07, 0x7a, 0xf1, 0x23, 0x49, 0xdd, 0xee, 0xe5, 0x44, 0x83, 0xbc, 0x06, 0xc2,
0xc6, 0x19, 0x48, 0xcd, 0x02, 0xb2, 0x02, 0xe7, 0x96, 0xae, 0xbd, 0x94, 0xd3, 0xa7, 0xcb, 0xf8,
0x59, 0xc2, 0xc1, 0x81, 0x9c, 0x32, 0x4c, 0xb8, 0x2b, 0x9c, 0xd3, 0x4e, 0xde, 0x26, 0x3a, 0x2a,
0xbf, 0xfe, 0x47, 0x33, 0xf0, 0x77, 0x86, 0x9e, 0x86, 0x60, 0xf7, 0xd6, 0x83, 0x4d, 0xa5, 0x3d,
0x69, 0x0e, 0xf7, 0x98, 0x5f, 0x6b, 0xc3, 0x02, 0x03, 0x01, 0x00, 0x01,
};
const unsigned char test_rsa_1026_priv[] = {
0x30, 0x82, 0x02, 0x5e, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81, 0x02, 0xd0, 0x96, 0x61, 0xfc, 0x74,
@ -318,6 +255,17 @@ const unsigned char test_rsa_1026_priv[] = {
0x08, 0x1e, 0x24, 0x0b, 0x6a, 0xe4, 0xe2, 0x71, 0x48, 0x87, 0xdd, 0x78, 0xda, 0xda, 0xeb, 0x0b,
0x92, 0x16,
};
const unsigned char test_rsa_1026_pub[] = {
0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x02, 0xd0, 0x96, 0x61, 0xfc, 0x74, 0x22, 0x4b, 0xa7, 0xbe,
0x79, 0x07, 0xab, 0xef, 0x4f, 0x5e, 0x8b, 0xcc, 0x26, 0x4a, 0x80, 0x2c, 0x97, 0x8f, 0x7e, 0xaa,
0x58, 0x55, 0xad, 0xa0, 0x54, 0x36, 0xd7, 0x5d, 0xb7, 0x68, 0xd2, 0x0f, 0x68, 0x59, 0x5d, 0xbc,
0xc3, 0xd7, 0x25, 0xb1, 0x38, 0xe8, 0x0b, 0x24, 0x7e, 0x44, 0xa4, 0x16, 0x3a, 0x05, 0x42, 0xfa,
0xb6, 0x12, 0xac, 0xbb, 0xde, 0x45, 0xf2, 0xe9, 0x38, 0x94, 0xaa, 0x25, 0x3b, 0xdd, 0xef, 0x6a,
0x7b, 0xec, 0xdc, 0x9c, 0xc2, 0x9a, 0x99, 0xba, 0xcf, 0x48, 0xdc, 0x6e, 0x38, 0xdb, 0x7a, 0x33,
0xe9, 0xac, 0x92, 0x4c, 0x52, 0x0f, 0xc6, 0xbe, 0x7d, 0x6e, 0x56, 0x46, 0xc1, 0xd6, 0x7f, 0xb8,
0xb2, 0xb9, 0x7a, 0xc6, 0x0b, 0xee, 0xcc, 0x3b, 0xb8, 0xe7, 0x5b, 0xed, 0x83, 0x15, 0xaa, 0x3f,
0xe4, 0x6f, 0x74, 0x8a, 0x66, 0xd6, 0xef, 0x02, 0x03, 0x01, 0x00, 0x01,
};
const unsigned char test_rsa_1028_priv[] = {
0x30, 0x82, 0x02, 0x5e, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81, 0x0e, 0x62, 0xa7, 0x6f, 0x0e, 0x0b,
@ -360,6 +308,17 @@ const unsigned char test_rsa_1028_priv[] = {
0x25, 0x03, 0x1b, 0x8d, 0x37, 0x9f, 0x38, 0x9d, 0xe2, 0x77, 0xa9, 0xa0, 0x13, 0x76, 0x51, 0xdf,
0x54, 0x8a,
};
const unsigned char test_rsa_1028_pub[] = {
0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x0e, 0x62, 0xa7, 0x6f, 0x0e, 0x0b, 0x59, 0x68, 0x3a, 0x7e,
0xbf, 0x7c, 0xbf, 0xd3, 0x7b, 0x1d, 0x17, 0x81, 0xd8, 0xf1, 0xb9, 0x00, 0x60, 0x4b, 0x50, 0x7f,
0x0f, 0x04, 0xc7, 0x2a, 0x3d, 0x34, 0x0d, 0x06, 0x7b, 0xcd, 0x53, 0xbe, 0xa3, 0xca, 0xff, 0x4e,
0x4a, 0xe6, 0x94, 0xf0, 0xb6, 0xd8, 0xf5, 0x91, 0xa4, 0x16, 0x7f, 0xbf, 0x7f, 0x37, 0x2a, 0xb5,
0x7e, 0x83, 0xa6, 0x9a, 0x3f, 0x26, 0xf4, 0x47, 0xbc, 0xf5, 0x82, 0xbc, 0x96, 0x21, 0xa3, 0x0a,
0x3b, 0x44, 0xd6, 0xb4, 0x3e, 0x98, 0x6d, 0x1a, 0x86, 0x7b, 0x07, 0x48, 0x9e, 0x4f, 0x9b, 0xfc,
0xad, 0xaa, 0x82, 0xa2, 0x78, 0x2d, 0xc2, 0x72, 0x9a, 0x63, 0x1f, 0xb1, 0xfb, 0x9f, 0xfb, 0x79,
0x4b, 0x4e, 0x53, 0xc7, 0x62, 0x39, 0xe0, 0x4d, 0x4a, 0x8f, 0x80, 0x35, 0x25, 0x88, 0xdb, 0x29,
0x46, 0x2d, 0xde, 0x18, 0x23, 0x7c, 0xf5, 0x02, 0x03, 0x01, 0x00, 0x01,
};
const unsigned char test_rsa_1030_priv[] = {
0x30, 0x82, 0x02, 0x5f, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81, 0x2b, 0x7c, 0xd1, 0x97, 0xf5, 0x79,
@ -402,6 +361,17 @@ const unsigned char test_rsa_1030_priv[] = {
0x32, 0x6a, 0x21, 0x42, 0xfc, 0xa4, 0x54, 0xbb, 0xd3, 0x8d, 0x6d, 0xbc, 0x6c, 0xaa, 0x7a, 0xc3,
0x35, 0xa1, 0x7c,
};
const unsigned char test_rsa_1030_pub[] = {
0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x2b, 0x7c, 0xd1, 0x97, 0xf5, 0x79, 0x6d, 0x1f, 0x8e, 0x57,
0x6b, 0x2b, 0x37, 0x72, 0x3f, 0xd9, 0x21, 0x08, 0x14, 0xef, 0x1c, 0x19, 0x95, 0xf9, 0x89, 0x9d,
0x50, 0x05, 0x8f, 0x37, 0x9d, 0x23, 0x9c, 0x66, 0x87, 0x8e, 0x92, 0x2f, 0x34, 0xc6, 0xae, 0x36,
0x72, 0xc8, 0x59, 0x8f, 0xcd, 0x5d, 0x47, 0xb7, 0x64, 0xd2, 0xec, 0x15, 0x6e, 0x13, 0x4d, 0x03,
0xcf, 0x6a, 0x94, 0xd3, 0x8d, 0x2e, 0xa8, 0xbc, 0x76, 0xdb, 0xbc, 0x60, 0xc4, 0xb9, 0x74, 0x21,
0x90, 0x90, 0xea, 0xf2, 0x87, 0x49, 0x7d, 0x7d, 0xcf, 0x7f, 0x11, 0x9c, 0xfa, 0x86, 0x74, 0x96,
0xf7, 0xe9, 0x1c, 0x12, 0xb5, 0xd5, 0x52, 0xe1, 0xd1, 0x46, 0x1a, 0x80, 0xdb, 0xe9, 0xa5, 0x9d,
0xb3, 0xb0, 0x16, 0xc6, 0xc0, 0x14, 0x1c, 0x3b, 0x2a, 0x0e, 0x22, 0x60, 0x89, 0xb8, 0x55, 0xcb,
0x88, 0xef, 0x65, 0x64, 0x08, 0xbd, 0x89, 0x02, 0x03, 0x01, 0x00, 0x01,
};
const unsigned char test_rsa_1536_priv[] = {
0x30, 0x82, 0x03, 0x7b, 0x02, 0x01, 0x00, 0x02, 0x81, 0xc1, 0x00, 0xc8, 0x70, 0xfe, 0xb6, 0xca,
@ -461,6 +431,21 @@ const unsigned char test_rsa_1536_priv[] = {
0x8a, 0xc2, 0x71, 0x0c, 0xb5, 0x87, 0x8b, 0x59, 0x2f, 0xfe, 0xb1, 0xf4, 0xf0, 0xa1, 0x85, 0x3e,
0x4e, 0x8d, 0x1d, 0x05, 0x61, 0xb6, 0xef, 0xcc, 0x83, 0x1a, 0x29, 0x6c, 0xf7, 0xee, 0xaf,
};
const unsigned char test_rsa_1536_pub[] = {
0x30, 0x81, 0xc9, 0x02, 0x81, 0xc1, 0x00, 0xc8, 0x70, 0xfe, 0xb6, 0xca, 0x6b, 0x1d, 0x2b, 0xd9,
0xf2, 0xdd, 0x99, 0xe2, 0x0f, 0x1f, 0xe2, 0xd7, 0xe5, 0x19, 0x2d, 0xe6, 0x62, 0x22, 0x9d, 0xbe,
0x16, 0x2b, 0xd1, 0xba, 0x66, 0x33, 0x6a, 0x71, 0x82, 0x90, 0x3c, 0xa0, 0xb7, 0x27, 0x96, 0xcd,
0x44, 0x1c, 0x83, 0xd2, 0x4b, 0xcd, 0xc3, 0xe9, 0xa2, 0xf5, 0xe4, 0x39, 0x9c, 0x8a, 0x04, 0x3f,
0x1c, 0x3d, 0xdf, 0x04, 0x75, 0x4a, 0x66, 0xd4, 0xcf, 0xe7, 0xb3, 0x67, 0x1a, 0x37, 0xdd, 0x31,
0xa9, 0xb4, 0xc1, 0x3b, 0xfe, 0x06, 0xee, 0x90, 0xf9, 0xd9, 0x4d, 0xda, 0xa0, 0x6d, 0xe6, 0x7a,
0x52, 0xac, 0x86, 0x3e, 0x68, 0xf7, 0x56, 0x73, 0x6c, 0xeb, 0x01, 0x44, 0x05, 0xa6, 0x16, 0x05,
0x79, 0x64, 0x0f, 0x83, 0x1d, 0xdd, 0xcc, 0xc3, 0x4a, 0xd0, 0xb0, 0x50, 0x70, 0xe3, 0xf9, 0x95,
0x4a, 0x58, 0xd1, 0x81, 0x58, 0x13, 0xe1, 0xb8, 0x3b, 0xca, 0xdb, 0xa8, 0x14, 0x78, 0x9c, 0x87,
0xf1, 0xef, 0x2b, 0xa5, 0xd7, 0x38, 0xb7, 0x93, 0xec, 0x45, 0x6a, 0x67, 0x36, 0x0e, 0xea, 0x1b,
0x5f, 0xaf, 0x1c, 0x7c, 0xc7, 0xbf, 0x24, 0xf3, 0xb2, 0xa9, 0xd0, 0xf8, 0x95, 0x8b, 0x10, 0x96,
0xe0, 0xf0, 0xc3, 0x35, 0xf8, 0x88, 0x8d, 0x0c, 0x63, 0xa5, 0x1c, 0x3c, 0x03, 0x37, 0x21, 0x4f,
0xa3, 0xf5, 0xef, 0xdf, 0x6d, 0xcc, 0x35, 0x02, 0x03, 0x01, 0x00, 0x01,
};
const unsigned char test_rsa_2048_priv[] = {
0x30, 0x82, 0x04, 0xa3, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, 0xf7, 0xbb, 0x6b, 0x8e,
@ -539,6 +524,25 @@ const unsigned char test_rsa_2048_priv[] = {
0xbf, 0x08, 0x75, 0x2d, 0x40, 0xa8, 0x41, 0x9d, 0xe7, 0x1b, 0x01, 0xd4, 0x92, 0x7e, 0x27, 0xc1,
0x07, 0x9c, 0xaa, 0xda, 0x05, 0x68, 0xb1,
};
const unsigned char test_rsa_2048_pub[] = {
0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xf7, 0xbb, 0x6b, 0x8e, 0xab, 0x40, 0x49,
0x1c, 0xd6, 0x44, 0x55, 0xec, 0x04, 0xd4, 0xed, 0x8d, 0xb5, 0x05, 0x1a, 0x97, 0x38, 0xfc, 0x7a,
0xf7, 0x3f, 0xf3, 0xb0, 0x97, 0x51, 0x1c, 0xce, 0x40, 0xaa, 0xf7, 0x65, 0x37, 0xb1, 0x35, 0x35,
0x04, 0x42, 0x79, 0x86, 0xb7, 0xb2, 0xb5, 0x3a, 0x96, 0x4a, 0x69, 0x37, 0xb5, 0x58, 0xec, 0x0d,
0x1d, 0xea, 0x27, 0x4a, 0xf2, 0xb8, 0xff, 0xf2, 0xf0, 0x94, 0xc2, 0x43, 0xfa, 0x57, 0x72, 0x66,
0xa7, 0x9d, 0xb0, 0xc2, 0x6f, 0xfe, 0x30, 0x41, 0x6d, 0x23, 0xef, 0x05, 0xdd, 0x5f, 0xec, 0xab,
0x41, 0x3e, 0xbb, 0xb4, 0xf8, 0x52, 0x6a, 0xe7, 0x20, 0xa9, 0x45, 0x84, 0x22, 0x6b, 0x37, 0xd9,
0x2e, 0xf4, 0x63, 0xfc, 0x73, 0x6c, 0xb3, 0x8e, 0x53, 0x0e, 0x74, 0x88, 0xd9, 0x16, 0x2f, 0x57,
0x26, 0x80, 0x7b, 0xc5, 0x43, 0x13, 0x8a, 0x2d, 0x25, 0x8a, 0xdb, 0x4d, 0x68, 0x02, 0x21, 0xc2,
0x53, 0x23, 0x81, 0xcc, 0xfa, 0x81, 0xbc, 0x89, 0xbc, 0x3d, 0x7b, 0x84, 0x03, 0x9c, 0x2d, 0xf4,
0x1c, 0xe3, 0xec, 0x8d, 0xb9, 0x1c, 0x23, 0x80, 0xe7, 0x81, 0xba, 0x3a, 0xa9, 0xe2, 0x3b, 0x74,
0xed, 0x99, 0x73, 0xd4, 0x90, 0x8e, 0xfc, 0xa4, 0x7a, 0xa8, 0xd9, 0xb7, 0xb0, 0xa4, 0x42, 0x32,
0x97, 0xa4, 0x04, 0x42, 0x7c, 0x3f, 0x3c, 0xd6, 0xe0, 0x78, 0x2e, 0x45, 0x53, 0x88, 0x0f, 0x06,
0xba, 0x39, 0xa6, 0x4f, 0x4a, 0x7b, 0x0e, 0xef, 0x92, 0x1a, 0x60, 0x50, 0xa2, 0x07, 0xce, 0xfa,
0xdc, 0xf0, 0x73, 0x94, 0xa3, 0xe1, 0x8e, 0xa9, 0x15, 0xdc, 0x84, 0x97, 0xe7, 0xae, 0x61, 0xfc,
0x31, 0x62, 0xf6, 0x2f, 0x50, 0x65, 0xa6, 0x92, 0xaf, 0x07, 0x72, 0x66, 0xf7, 0x36, 0x0c, 0x20,
0x76, 0xce, 0xbe, 0xaf, 0x14, 0xcb, 0x22, 0xc1, 0xed, 0x02, 0x03, 0x01, 0x00, 0x01,
};
const unsigned char test_rsa_4096_priv[] = {
0x30, 0x82, 0x09, 0x29, 0x02, 0x01, 0x00, 0x02, 0x82, 0x02, 0x01, 0x00, 0xcc, 0x87, 0x25, 0xf6,
@ -689,91 +693,6 @@ const unsigned char test_rsa_4096_priv[] = {
0x2f, 0x20, 0xc0, 0x05, 0xa2, 0x51, 0x9e, 0x3a, 0x87, 0x41, 0x46, 0x49, 0x5d, 0x7a, 0xac, 0xf3,
0x41, 0x6a, 0x42, 0x2e, 0x56, 0x09, 0x86, 0xf2, 0x2f, 0x39, 0x45, 0x6e, 0x7f,
};
const unsigned char test_rsa_1024_pub[] = {
0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xaf, 0x05, 0x7d, 0x39, 0x6e, 0xe8, 0x4f, 0xb7, 0x5f,
0xdb, 0xb5, 0xc2, 0xb1, 0x3c, 0x7f, 0xe5, 0xa6, 0x54, 0xaa, 0x8a, 0xa2, 0x47, 0x0b, 0x54, 0x1e,
0xe1, 0xfe, 0xb0, 0xb1, 0x2d, 0x25, 0xc7, 0x97, 0x11, 0x53, 0x12, 0x49, 0xe1, 0x12, 0x96, 0x28,
0x04, 0x2d, 0xbb, 0xb6, 0xc1, 0x20, 0xd1, 0x44, 0x35, 0x24, 0xef, 0x4c, 0x0e, 0x6e, 0x1d, 0x89,
0x56, 0xee, 0xb2, 0x07, 0x7a, 0xf1, 0x23, 0x49, 0xdd, 0xee, 0xe5, 0x44, 0x83, 0xbc, 0x06, 0xc2,
0xc6, 0x19, 0x48, 0xcd, 0x02, 0xb2, 0x02, 0xe7, 0x96, 0xae, 0xbd, 0x94, 0xd3, 0xa7, 0xcb, 0xf8,
0x59, 0xc2, 0xc1, 0x81, 0x9c, 0x32, 0x4c, 0xb8, 0x2b, 0x9c, 0xd3, 0x4e, 0xde, 0x26, 0x3a, 0x2a,
0xbf, 0xfe, 0x47, 0x33, 0xf0, 0x77, 0x86, 0x9e, 0x86, 0x60, 0xf7, 0xd6, 0x83, 0x4d, 0xa5, 0x3d,
0x69, 0x0e, 0xf7, 0x98, 0x5f, 0x6b, 0xc3, 0x02, 0x03, 0x01, 0x00, 0x01,
};
const unsigned char test_rsa_1026_pub[] = {
0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x02, 0xd0, 0x96, 0x61, 0xfc, 0x74, 0x22, 0x4b, 0xa7, 0xbe,
0x79, 0x07, 0xab, 0xef, 0x4f, 0x5e, 0x8b, 0xcc, 0x26, 0x4a, 0x80, 0x2c, 0x97, 0x8f, 0x7e, 0xaa,
0x58, 0x55, 0xad, 0xa0, 0x54, 0x36, 0xd7, 0x5d, 0xb7, 0x68, 0xd2, 0x0f, 0x68, 0x59, 0x5d, 0xbc,
0xc3, 0xd7, 0x25, 0xb1, 0x38, 0xe8, 0x0b, 0x24, 0x7e, 0x44, 0xa4, 0x16, 0x3a, 0x05, 0x42, 0xfa,
0xb6, 0x12, 0xac, 0xbb, 0xde, 0x45, 0xf2, 0xe9, 0x38, 0x94, 0xaa, 0x25, 0x3b, 0xdd, 0xef, 0x6a,
0x7b, 0xec, 0xdc, 0x9c, 0xc2, 0x9a, 0x99, 0xba, 0xcf, 0x48, 0xdc, 0x6e, 0x38, 0xdb, 0x7a, 0x33,
0xe9, 0xac, 0x92, 0x4c, 0x52, 0x0f, 0xc6, 0xbe, 0x7d, 0x6e, 0x56, 0x46, 0xc1, 0xd6, 0x7f, 0xb8,
0xb2, 0xb9, 0x7a, 0xc6, 0x0b, 0xee, 0xcc, 0x3b, 0xb8, 0xe7, 0x5b, 0xed, 0x83, 0x15, 0xaa, 0x3f,
0xe4, 0x6f, 0x74, 0x8a, 0x66, 0xd6, 0xef, 0x02, 0x03, 0x01, 0x00, 0x01,
};
const unsigned char test_rsa_1028_pub[] = {
0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x0e, 0x62, 0xa7, 0x6f, 0x0e, 0x0b, 0x59, 0x68, 0x3a, 0x7e,
0xbf, 0x7c, 0xbf, 0xd3, 0x7b, 0x1d, 0x17, 0x81, 0xd8, 0xf1, 0xb9, 0x00, 0x60, 0x4b, 0x50, 0x7f,
0x0f, 0x04, 0xc7, 0x2a, 0x3d, 0x34, 0x0d, 0x06, 0x7b, 0xcd, 0x53, 0xbe, 0xa3, 0xca, 0xff, 0x4e,
0x4a, 0xe6, 0x94, 0xf0, 0xb6, 0xd8, 0xf5, 0x91, 0xa4, 0x16, 0x7f, 0xbf, 0x7f, 0x37, 0x2a, 0xb5,
0x7e, 0x83, 0xa6, 0x9a, 0x3f, 0x26, 0xf4, 0x47, 0xbc, 0xf5, 0x82, 0xbc, 0x96, 0x21, 0xa3, 0x0a,
0x3b, 0x44, 0xd6, 0xb4, 0x3e, 0x98, 0x6d, 0x1a, 0x86, 0x7b, 0x07, 0x48, 0x9e, 0x4f, 0x9b, 0xfc,
0xad, 0xaa, 0x82, 0xa2, 0x78, 0x2d, 0xc2, 0x72, 0x9a, 0x63, 0x1f, 0xb1, 0xfb, 0x9f, 0xfb, 0x79,
0x4b, 0x4e, 0x53, 0xc7, 0x62, 0x39, 0xe0, 0x4d, 0x4a, 0x8f, 0x80, 0x35, 0x25, 0x88, 0xdb, 0x29,
0x46, 0x2d, 0xde, 0x18, 0x23, 0x7c, 0xf5, 0x02, 0x03, 0x01, 0x00, 0x01,
};
const unsigned char test_rsa_1030_pub[] = {
0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x2b, 0x7c, 0xd1, 0x97, 0xf5, 0x79, 0x6d, 0x1f, 0x8e, 0x57,
0x6b, 0x2b, 0x37, 0x72, 0x3f, 0xd9, 0x21, 0x08, 0x14, 0xef, 0x1c, 0x19, 0x95, 0xf9, 0x89, 0x9d,
0x50, 0x05, 0x8f, 0x37, 0x9d, 0x23, 0x9c, 0x66, 0x87, 0x8e, 0x92, 0x2f, 0x34, 0xc6, 0xae, 0x36,
0x72, 0xc8, 0x59, 0x8f, 0xcd, 0x5d, 0x47, 0xb7, 0x64, 0xd2, 0xec, 0x15, 0x6e, 0x13, 0x4d, 0x03,
0xcf, 0x6a, 0x94, 0xd3, 0x8d, 0x2e, 0xa8, 0xbc, 0x76, 0xdb, 0xbc, 0x60, 0xc4, 0xb9, 0x74, 0x21,
0x90, 0x90, 0xea, 0xf2, 0x87, 0x49, 0x7d, 0x7d, 0xcf, 0x7f, 0x11, 0x9c, 0xfa, 0x86, 0x74, 0x96,
0xf7, 0xe9, 0x1c, 0x12, 0xb5, 0xd5, 0x52, 0xe1, 0xd1, 0x46, 0x1a, 0x80, 0xdb, 0xe9, 0xa5, 0x9d,
0xb3, 0xb0, 0x16, 0xc6, 0xc0, 0x14, 0x1c, 0x3b, 0x2a, 0x0e, 0x22, 0x60, 0x89, 0xb8, 0x55, 0xcb,
0x88, 0xef, 0x65, 0x64, 0x08, 0xbd, 0x89, 0x02, 0x03, 0x01, 0x00, 0x01,
};
const unsigned char test_rsa_1536_pub[] = {
0x30, 0x81, 0xc9, 0x02, 0x81, 0xc1, 0x00, 0xc8, 0x70, 0xfe, 0xb6, 0xca, 0x6b, 0x1d, 0x2b, 0xd9,
0xf2, 0xdd, 0x99, 0xe2, 0x0f, 0x1f, 0xe2, 0xd7, 0xe5, 0x19, 0x2d, 0xe6, 0x62, 0x22, 0x9d, 0xbe,
0x16, 0x2b, 0xd1, 0xba, 0x66, 0x33, 0x6a, 0x71, 0x82, 0x90, 0x3c, 0xa0, 0xb7, 0x27, 0x96, 0xcd,
0x44, 0x1c, 0x83, 0xd2, 0x4b, 0xcd, 0xc3, 0xe9, 0xa2, 0xf5, 0xe4, 0x39, 0x9c, 0x8a, 0x04, 0x3f,
0x1c, 0x3d, 0xdf, 0x04, 0x75, 0x4a, 0x66, 0xd4, 0xcf, 0xe7, 0xb3, 0x67, 0x1a, 0x37, 0xdd, 0x31,
0xa9, 0xb4, 0xc1, 0x3b, 0xfe, 0x06, 0xee, 0x90, 0xf9, 0xd9, 0x4d, 0xda, 0xa0, 0x6d, 0xe6, 0x7a,
0x52, 0xac, 0x86, 0x3e, 0x68, 0xf7, 0x56, 0x73, 0x6c, 0xeb, 0x01, 0x44, 0x05, 0xa6, 0x16, 0x05,
0x79, 0x64, 0x0f, 0x83, 0x1d, 0xdd, 0xcc, 0xc3, 0x4a, 0xd0, 0xb0, 0x50, 0x70, 0xe3, 0xf9, 0x95,
0x4a, 0x58, 0xd1, 0x81, 0x58, 0x13, 0xe1, 0xb8, 0x3b, 0xca, 0xdb, 0xa8, 0x14, 0x78, 0x9c, 0x87,
0xf1, 0xef, 0x2b, 0xa5, 0xd7, 0x38, 0xb7, 0x93, 0xec, 0x45, 0x6a, 0x67, 0x36, 0x0e, 0xea, 0x1b,
0x5f, 0xaf, 0x1c, 0x7c, 0xc7, 0xbf, 0x24, 0xf3, 0xb2, 0xa9, 0xd0, 0xf8, 0x95, 0x8b, 0x10, 0x96,
0xe0, 0xf0, 0xc3, 0x35, 0xf8, 0x88, 0x8d, 0x0c, 0x63, 0xa5, 0x1c, 0x3c, 0x03, 0x37, 0x21, 0x4f,
0xa3, 0xf5, 0xef, 0xdf, 0x6d, 0xcc, 0x35, 0x02, 0x03, 0x01, 0x00, 0x01,
};
const unsigned char test_rsa_2048_pub[] = {
0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xf7, 0xbb, 0x6b, 0x8e, 0xab, 0x40, 0x49,
0x1c, 0xd6, 0x44, 0x55, 0xec, 0x04, 0xd4, 0xed, 0x8d, 0xb5, 0x05, 0x1a, 0x97, 0x38, 0xfc, 0x7a,
0xf7, 0x3f, 0xf3, 0xb0, 0x97, 0x51, 0x1c, 0xce, 0x40, 0xaa, 0xf7, 0x65, 0x37, 0xb1, 0x35, 0x35,
0x04, 0x42, 0x79, 0x86, 0xb7, 0xb2, 0xb5, 0x3a, 0x96, 0x4a, 0x69, 0x37, 0xb5, 0x58, 0xec, 0x0d,
0x1d, 0xea, 0x27, 0x4a, 0xf2, 0xb8, 0xff, 0xf2, 0xf0, 0x94, 0xc2, 0x43, 0xfa, 0x57, 0x72, 0x66,
0xa7, 0x9d, 0xb0, 0xc2, 0x6f, 0xfe, 0x30, 0x41, 0x6d, 0x23, 0xef, 0x05, 0xdd, 0x5f, 0xec, 0xab,
0x41, 0x3e, 0xbb, 0xb4, 0xf8, 0x52, 0x6a, 0xe7, 0x20, 0xa9, 0x45, 0x84, 0x22, 0x6b, 0x37, 0xd9,
0x2e, 0xf4, 0x63, 0xfc, 0x73, 0x6c, 0xb3, 0x8e, 0x53, 0x0e, 0x74, 0x88, 0xd9, 0x16, 0x2f, 0x57,
0x26, 0x80, 0x7b, 0xc5, 0x43, 0x13, 0x8a, 0x2d, 0x25, 0x8a, 0xdb, 0x4d, 0x68, 0x02, 0x21, 0xc2,
0x53, 0x23, 0x81, 0xcc, 0xfa, 0x81, 0xbc, 0x89, 0xbc, 0x3d, 0x7b, 0x84, 0x03, 0x9c, 0x2d, 0xf4,
0x1c, 0xe3, 0xec, 0x8d, 0xb9, 0x1c, 0x23, 0x80, 0xe7, 0x81, 0xba, 0x3a, 0xa9, 0xe2, 0x3b, 0x74,
0xed, 0x99, 0x73, 0xd4, 0x90, 0x8e, 0xfc, 0xa4, 0x7a, 0xa8, 0xd9, 0xb7, 0xb0, 0xa4, 0x42, 0x32,
0x97, 0xa4, 0x04, 0x42, 0x7c, 0x3f, 0x3c, 0xd6, 0xe0, 0x78, 0x2e, 0x45, 0x53, 0x88, 0x0f, 0x06,
0xba, 0x39, 0xa6, 0x4f, 0x4a, 0x7b, 0x0e, 0xef, 0x92, 0x1a, 0x60, 0x50, 0xa2, 0x07, 0xce, 0xfa,
0xdc, 0xf0, 0x73, 0x94, 0xa3, 0xe1, 0x8e, 0xa9, 0x15, 0xdc, 0x84, 0x97, 0xe7, 0xae, 0x61, 0xfc,
0x31, 0x62, 0xf6, 0x2f, 0x50, 0x65, 0xa6, 0x92, 0xaf, 0x07, 0x72, 0x66, 0xf7, 0x36, 0x0c, 0x20,
0x76, 0xce, 0xbe, 0xaf, 0x14, 0xcb, 0x22, 0xc1, 0xed, 0x02, 0x03, 0x01, 0x00, 0x01,
};
const unsigned char test_rsa_4096_pub[] = {
0x30, 0x82, 0x02, 0x0a, 0x02, 0x82, 0x02, 0x01, 0x00, 0xcc, 0x87, 0x25, 0xf6, 0xb3, 0x8d, 0x5d,
0x01, 0xae, 0xeb, 0x07, 0xd3, 0x6e, 0x03, 0xde, 0x4d, 0x31, 0xa0, 0x26, 0x1c, 0xe7, 0x4f, 0xe1,
@ -809,3 +728,72 @@ const unsigned char test_rsa_4096_pub[] = {
0xf9, 0x34, 0xe2, 0xb4, 0x0f, 0xde, 0xbb, 0xa3, 0xd9, 0x70, 0x1b, 0x76, 0xe1, 0xbe, 0x54, 0x82,
0x74, 0xb2, 0x60, 0x2d, 0x88, 0x85, 0x37, 0x48, 0x2d, 0x02, 0x03, 0x01, 0x00, 0x01,
};
struct predefined_key_element {
int is_ec; // 1 for EC keys; 0 for RSA
int curve_or_keybits;
const unsigned char *priv_key;
size_t priv_key_len;
const unsigned char *pub_key;
size_t pub_key_len;
};
struct predefined_key_element predefined_keys[] = {
{ 1, MBEDTLS_ECP_DP_SECP192K1,
test_ec_secp192k1_priv, sizeof(test_ec_secp192k1_priv),
test_ec_secp192k1_pub, sizeof(test_ec_secp192k1_pub) },
{ 1, MBEDTLS_ECP_DP_SECP256K1,
test_ec_secp256k1_priv, sizeof(test_ec_secp256k1_priv),
test_ec_secp256k1_pub, sizeof(test_ec_secp256k1_pub) },
{ 1, MBEDTLS_ECP_DP_SECP192R1,
test_ec_secp192r1_priv, sizeof(test_ec_secp192r1_priv),
test_ec_secp192r1_pub, sizeof(test_ec_secp192r1_pub) },
{ 1, MBEDTLS_ECP_DP_SECP224R1,
test_ec_secp224r1_priv, sizeof(test_ec_secp224r1_priv),
test_ec_secp224r1_pub, sizeof(test_ec_secp224r1_pub) },
{ 1, MBEDTLS_ECP_DP_SECP256R1,
test_ec_secp256r1_priv, sizeof(test_ec_secp256r1_priv),
test_ec_secp256r1_pub, sizeof(test_ec_secp256r1_pub) },
{ 1, MBEDTLS_ECP_DP_SECP384R1,
test_ec_secp384r1_priv, sizeof(test_ec_secp384r1_priv),
test_ec_secp384r1_pub, sizeof(test_ec_secp384r1_pub) },
{ 1, MBEDTLS_ECP_DP_SECP521R1,
test_ec_secp521r1_priv, sizeof(test_ec_secp521r1_priv),
test_ec_secp521r1_pub, sizeof(test_ec_secp521r1_pub) },
{ 1, MBEDTLS_ECP_DP_BP256R1,
test_ec_bp256r1_priv, sizeof(test_ec_bp256r1_priv),
test_ec_bp256r1_pub, sizeof(test_ec_bp256r1_pub) },
{ 1, MBEDTLS_ECP_DP_BP384R1,
test_ec_bp384r1_priv, sizeof(test_ec_bp384r1_priv),
test_ec_bp384r1_pub, sizeof(test_ec_bp384r1_pub) },
{ 1, MBEDTLS_ECP_DP_BP512R1,
test_ec_bp512r1_priv, sizeof(test_ec_bp512r1_priv),
test_ec_bp512r1_pub, sizeof(test_ec_bp512r1_pub) },
{ 1, MBEDTLS_ECP_DP_CURVE25519,
test_ec_curve25519_priv, sizeof(test_ec_curve25519_priv),
test_ec_curve25519_pub, sizeof(test_ec_curve25519_pub) },
{ 1, MBEDTLS_ECP_DP_CURVE448,
test_ec_curve448_priv, sizeof(test_ec_curve448_priv),
test_ec_curve448_pub, sizeof(test_ec_curve448_pub) },
{ 0, 1024,
test_rsa_1024_priv, sizeof(test_rsa_1024_priv),
test_rsa_1024_pub, sizeof(test_rsa_1024_pub) },
{ 0, 1026,
test_rsa_1026_priv, sizeof(test_rsa_1026_priv),
test_rsa_1026_pub, sizeof(test_rsa_1026_pub) },
{ 0, 1028,
test_rsa_1028_priv, sizeof(test_rsa_1028_priv),
test_rsa_1028_pub, sizeof(test_rsa_1028_pub) },
{ 0, 1030,
test_rsa_1030_priv, sizeof(test_rsa_1030_priv),
test_rsa_1030_pub, sizeof(test_rsa_1030_pub) },
{ 0, 1536,
test_rsa_1536_priv, sizeof(test_rsa_1536_priv),
test_rsa_1536_pub, sizeof(test_rsa_1536_pub) },
{ 0, 2048,
test_rsa_2048_priv, sizeof(test_rsa_2048_priv),
test_rsa_2048_pub, sizeof(test_rsa_2048_pub) },
{ 0, 4096,
test_rsa_4096_priv, sizeof(test_rsa_4096_priv),
test_rsa_4096_pub, sizeof(test_rsa_4096_pub) },
};

View File

@ -185,65 +185,20 @@
#endif
#include <../src/test_keys.h>
struct key_lut_element {
int curve_or_keybits;
const unsigned char *key;
size_t key_len;
const unsigned char *pub_key;
size_t pub_key_len;
};
struct key_lut_element keys_lut[] = {
{ 1024, test_rsa_1024_priv, sizeof(test_rsa_1024_priv),
test_rsa_1024_pub, sizeof(test_rsa_1024_pub) },
{ 1026, test_rsa_1026_priv, sizeof(test_rsa_1026_priv),
test_rsa_1026_pub, sizeof(test_rsa_1026_pub) },
{ 1028, test_rsa_1028_priv, sizeof(test_rsa_1028_priv),
test_rsa_1028_pub, sizeof(test_rsa_1028_pub) },
{ 1030, test_rsa_1030_priv, sizeof(test_rsa_1030_priv),
test_rsa_1030_pub, sizeof(test_rsa_1030_pub) },
{ 2048, test_rsa_2048_priv, sizeof(test_rsa_2048_priv),
test_rsa_2048_pub, sizeof(test_rsa_2048_pub) },
{ 4096, test_rsa_4096_priv, sizeof(test_rsa_4096_priv),
test_rsa_4096_pub, sizeof(test_rsa_4096_pub) },
{ MBEDTLS_ECP_DP_SECP192R1, test_ec_secp192r1_priv, sizeof(test_ec_secp192r1_priv),
test_ec_secp192r1_pub, sizeof(test_ec_secp192r1_pub) },
{ MBEDTLS_ECP_DP_SECP224R1, test_ec_secp224r1_priv, sizeof(test_ec_secp224r1_priv),
test_ec_secp224r1_pub, sizeof(test_ec_secp224r1_pub) },
{ MBEDTLS_ECP_DP_SECP256R1, test_ec_secp256r1_priv, sizeof(test_ec_secp256r1_priv),
test_ec_secp256r1_pub, sizeof(test_ec_secp256r1_pub) },
{ MBEDTLS_ECP_DP_SECP384R1, test_ec_secp384r1_priv, sizeof(test_ec_secp384r1_priv),
test_ec_secp384r1_pub, sizeof(test_ec_secp384r1_pub) },
{ MBEDTLS_ECP_DP_SECP521R1, test_ec_secp521r1_priv, sizeof(test_ec_secp521r1_priv),
test_ec_secp521r1_pub, sizeof(test_ec_secp521r1_pub) },
{ MBEDTLS_ECP_DP_BP256R1, test_ec_bp256r1_priv, sizeof(test_ec_bp256r1_priv),
test_ec_bp256r1_pub, sizeof(test_ec_bp256r1_pub) },
{ MBEDTLS_ECP_DP_BP384R1, test_ec_bp384r1_priv, sizeof(test_ec_bp384r1_priv),
test_ec_bp384r1_pub, sizeof(test_ec_bp384r1_pub) },
{ MBEDTLS_ECP_DP_BP512R1, test_ec_bp512r1_priv, sizeof(test_ec_bp512r1_priv),
test_ec_bp512r1_pub, sizeof(test_ec_bp512r1_pub) },
{ MBEDTLS_ECP_DP_CURVE25519, test_ec_curve255_priv, sizeof(test_ec_curve255_priv),
test_ec_curve255_pub, sizeof(test_ec_curve255_pub) },
{ MBEDTLS_ECP_DP_SECP192K1, test_ec_secp192k1_priv, sizeof(test_ec_secp192k1_priv),
test_ec_secp192k1_pub, sizeof(test_ec_secp192k1_pub) },
{ MBEDTLS_ECP_DP_SECP256K1, test_ec_secp256k1_priv, sizeof(test_ec_secp256k1_priv),
test_ec_secp256k1_pub, sizeof(test_ec_secp256k1_pub) },
{ MBEDTLS_ECP_DP_CURVE448, test_ec_curve448_priv, sizeof(test_ec_curve448_priv),
test_ec_curve448_pub, sizeof(test_ec_curve448_pub) },
};
static int get_predefined_key_data(int curve_or_keybits,
static int get_predefined_key_data(int is_ec, int curve_or_keybits,
const unsigned char **key, size_t *key_len,
const unsigned char **pub_key, size_t *pub_key_len)
{
size_t i;
for (i = 0; i < ARRAY_LENGTH(keys_lut); i++) {
if (curve_or_keybits == keys_lut[i].curve_or_keybits) {
*key = keys_lut[i].key;
*key_len = keys_lut[i].key_len;
for (i = 0; i < ARRAY_LENGTH(predefined_keys); i++) {
if ((is_ec == predefined_keys[i].is_ec) &&
(curve_or_keybits == predefined_keys[i].curve_or_keybits)) {
*key = predefined_keys[i].priv_key;
*key_len = predefined_keys[i].priv_key_len;
if (pub_key != NULL) {
*pub_key = keys_lut[i].pub_key;
*pub_key_len = keys_lut[i].pub_key_len;
*pub_key = predefined_keys[i].pub_key;
*pub_key_len = predefined_keys[i].pub_key_len;
}
return 0;
}
@ -301,12 +256,12 @@ static int pk_genkey(mbedtls_pk_context *pk, mbedtls_pk_type_t pk_type, int curv
int ret = MBEDTLS_ERR_PK_BAD_INPUT_DATA;
if (pk_type == MBEDTLS_PK_RSA) {
TEST_EQUAL(get_predefined_key_data(curve_or_keybits, &key_data, &key_data_len,
TEST_EQUAL(get_predefined_key_data(0, curve_or_keybits, &key_data, &key_data_len,
NULL, 0), 0);
TEST_EQUAL(mbedtls_pk_parse_key(pk, key_data, key_data_len, NULL, 0,
mbedtls_test_rnd_std_rand, NULL), 0);
} else {
TEST_EQUAL(get_predefined_key_data(curve_or_keybits, &key_data, &key_data_len,
TEST_EQUAL(get_predefined_key_data(1, curve_or_keybits, &key_data, &key_data_len,
&pub_key_data, &pub_key_data_len), 0);
TEST_EQUAL(mbedtls_pk_setup(pk, mbedtls_pk_info_from_type(pk_type)), 0);
#if defined(MBEDTLS_PK_USE_PSA_EC_DATA)
@ -368,12 +323,12 @@ psa_status_t pk_psa_genkey(psa_key_type_t type, size_t bits,
size_t key_data_size = 0;
if (PSA_KEY_TYPE_IS_RSA(type)) {
TEST_EQUAL(get_predefined_key_data(bits, &key_data, &key_data_size, NULL, 0), 0);
TEST_EQUAL(get_predefined_key_data(0, bits, &key_data, &key_data_size, NULL, 0), 0);
} else {
#if defined(PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY)
mbedtls_ecp_group_id grp_id;
grp_id = mbedtls_ecc_group_from_psa(PSA_KEY_TYPE_ECC_GET_FAMILY(type), bits);
TEST_EQUAL(get_predefined_key_data(grp_id, &key_data, &key_data_size, NULL, 0), 0);
TEST_EQUAL(get_predefined_key_data(1, grp_id, &key_data, &key_data_size, NULL, 0), 0);
#else /* PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY */
TEST_FAIL("EC keys are not supported");
#endif /* PSA_WANT_KEY_TYPE_ECC_PUBLIC_KEY */