psa_constant_names: fix display for truncated unknown MAC/AEAD algorithm

This commit is contained in:
Gilles Peskine 2018-10-19 11:33:51 +02:00 committed by Darryl Green
parent c68ce9637a
commit 182c2e9836

View file

@ -62,7 +62,10 @@ static int psa_snprint_algorithm(char *buffer, size_t buffer_size,
}
} else if (PSA_ALG_IS_AEAD(alg)) {
core_alg = PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH(alg);
if (core_alg != alg) {
if (core_alg == 0) {
/* For unkonwn AEAD algorithms, there is no "default tag length". */
core_alg = alg;
} else if (core_alg != alg) {
append(&buffer, buffer_size, &required_size,
"PSA_ALG_AEAD_WITH_TAG_LENGTH(", 29);
length_modifier = PSA_AEAD_TAG_LENGTH(alg);
@ -73,7 +76,7 @@ static int psa_snprint_algorithm(char *buffer, size_t buffer_size,
default:
%(algorithm_code)s{
append_integer(&buffer, buffer_size, &required_size,
"0x%%08lx", (unsigned long) alg);
"0x%%08lx", (unsigned long) core_alg);
}
break;
}