mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-22 16:51:08 +00:00
psa_constant_names: support truncated MAC and AEAD
This commit is contained in:
parent
0deaf3d8d7
commit
498c2a1ff5
|
@ -51,7 +51,24 @@ static int psa_snprint_algorithm(char *buffer, size_t buffer_size,
|
||||||
psa_algorithm_t alg)
|
psa_algorithm_t alg)
|
||||||
{
|
{
|
||||||
size_t required_size = 0;
|
size_t required_size = 0;
|
||||||
switch (alg) {
|
psa_algorithm_t core_alg = alg;
|
||||||
|
unsigned long length_modifier = 0;
|
||||||
|
if (PSA_ALG_IS_MAC(alg)) {
|
||||||
|
core_alg = PSA_ALG_TRUNCATED_MAC(alg, 0);
|
||||||
|
if (core_alg != alg) {
|
||||||
|
append(&buffer, buffer_size, &required_size,
|
||||||
|
"PSA_ALG_TRUNCATED_MAC(", 22);
|
||||||
|
length_modifier = PSA_MAC_TRUNCATED_LENGTH(alg);
|
||||||
|
}
|
||||||
|
} else if (PSA_ALG_IS_AEAD(alg)) {
|
||||||
|
core_alg = PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH(alg);
|
||||||
|
if (core_alg != alg) {
|
||||||
|
append(&buffer, buffer_size, &required_size,
|
||||||
|
"PSA_ALG_AEAD_WITH_TAG_LENGTH(", 29);
|
||||||
|
length_modifier = PSA_AEAD_TAG_LENGTH(alg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch (core_alg) {
|
||||||
%(algorithm_cases)s
|
%(algorithm_cases)s
|
||||||
default:
|
default:
|
||||||
%(algorithm_code)s{
|
%(algorithm_code)s{
|
||||||
|
@ -60,6 +77,12 @@ static int psa_snprint_algorithm(char *buffer, size_t buffer_size,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (core_alg != alg) {
|
||||||
|
append(&buffer, buffer_size, &required_size, ", ", 2);
|
||||||
|
append_integer(&buffer, buffer_size, &required_size,
|
||||||
|
"%%lu", length_modifier);
|
||||||
|
append(&buffer, buffer_size, &required_size, ")", 1);
|
||||||
|
}
|
||||||
buffer[0] = 0;
|
buffer[0] = 0;
|
||||||
return required_size;
|
return required_size;
|
||||||
}
|
}
|
||||||
|
@ -99,10 +122,10 @@ key_type_from_curve_template = '''if (%(tester)s(type)) {
|
||||||
PSA_KEY_TYPE_GET_CURVE(type));
|
PSA_KEY_TYPE_GET_CURVE(type));
|
||||||
} else '''
|
} else '''
|
||||||
|
|
||||||
algorithm_from_hash_template = '''if (%(tester)s(alg)) {
|
algorithm_from_hash_template = '''if (%(tester)s(core_alg)) {
|
||||||
append_with_hash(&buffer, buffer_size, &required_size,
|
append_with_hash(&buffer, buffer_size, &required_size,
|
||||||
"%(builder)s", %(builder_length)s,
|
"%(builder)s", %(builder_length)s,
|
||||||
PSA_ALG_GET_HASH(alg));
|
PSA_ALG_GET_HASH(core_alg));
|
||||||
} else '''
|
} else '''
|
||||||
|
|
||||||
bit_test_template = '''\
|
bit_test_template = '''\
|
||||||
|
|
Loading…
Reference in a new issue