mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-26 23:15:41 +01:00
Code readability improvements
Signed-off-by: Steven Cooreman <steven.cooreman@silabs.com>
This commit is contained in:
parent
a1d8322f74
commit
947bb0b06f
@ -154,34 +154,25 @@ static int psa_snprint_algorithm(char *buffer, size_t buffer_size,
|
|||||||
append(&buffer, buffer_size, &required_size,
|
append(&buffer, buffer_size, &required_size,
|
||||||
"PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(", 33);
|
"PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(", 33);
|
||||||
length_modifier = PSA_MAC_TRUNCATED_LENGTH(alg);
|
length_modifier = PSA_MAC_TRUNCATED_LENGTH(alg);
|
||||||
} else {
|
} else if (core_alg != alg) {
|
||||||
if (core_alg != alg) {
|
|
||||||
append(&buffer, buffer_size, &required_size,
|
append(&buffer, buffer_size, &required_size,
|
||||||
"PSA_ALG_TRUNCATED_MAC(", 22);
|
"PSA_ALG_TRUNCATED_MAC(", 22);
|
||||||
length_modifier = PSA_MAC_TRUNCATED_LENGTH(alg);
|
length_modifier = PSA_MAC_TRUNCATED_LENGTH(alg);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else if (PSA_ALG_IS_AEAD(alg)) {
|
} else if (PSA_ALG_IS_AEAD(alg)) {
|
||||||
core_alg = PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG(alg);
|
core_alg = PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG(alg);
|
||||||
if (alg & PSA_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG) {
|
|
||||||
if (core_alg == 0) {
|
if (core_alg == 0) {
|
||||||
/* For unknown AEAD algorithms, there is no "default tag length". */
|
/* For unknown AEAD algorithms, there is no "default tag length". */
|
||||||
core_alg = alg;
|
core_alg = alg;
|
||||||
} else {
|
} else if (alg & PSA_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG) {
|
||||||
append(&buffer, buffer_size, &required_size,
|
append(&buffer, buffer_size, &required_size,
|
||||||
"PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(", 43);
|
"PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(", 43);
|
||||||
length_modifier = PSA_AEAD_TAG_LENGTH(alg);
|
length_modifier = PSA_AEAD_TAG_LENGTH(alg);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (core_alg == 0) {
|
|
||||||
/* For unknown AEAD algorithms, there is no "default tag length". */
|
|
||||||
core_alg = alg;
|
|
||||||
} else if (core_alg != alg) {
|
} else if (core_alg != alg) {
|
||||||
append(&buffer, buffer_size, &required_size,
|
append(&buffer, buffer_size, &required_size,
|
||||||
"PSA_ALG_AEAD_WITH_SHORTENED_TAG(", 32);
|
"PSA_ALG_AEAD_WITH_SHORTENED_TAG(", 32);
|
||||||
length_modifier = PSA_AEAD_TAG_LENGTH(alg);
|
length_modifier = PSA_AEAD_TAG_LENGTH(alg);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else if (PSA_ALG_IS_KEY_AGREEMENT(alg) &&
|
} else if (PSA_ALG_IS_KEY_AGREEMENT(alg) &&
|
||||||
!PSA_ALG_IS_RAW_KEY_AGREEMENT(alg)) {
|
!PSA_ALG_IS_RAW_KEY_AGREEMENT(alg)) {
|
||||||
core_alg = PSA_ALG_KEY_AGREEMENT_GET_KDF(alg);
|
core_alg = PSA_ALG_KEY_AGREEMENT_GET_KDF(alg);
|
||||||
|
@ -104,34 +104,25 @@ static int psa_snprint_algorithm(char *buffer, size_t buffer_size,
|
|||||||
append(&buffer, buffer_size, &required_size,
|
append(&buffer, buffer_size, &required_size,
|
||||||
"PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(", 33);
|
"PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(", 33);
|
||||||
length_modifier = PSA_MAC_TRUNCATED_LENGTH(alg);
|
length_modifier = PSA_MAC_TRUNCATED_LENGTH(alg);
|
||||||
} else {
|
} else if (core_alg != alg) {
|
||||||
if (core_alg != alg) {
|
|
||||||
append(&buffer, buffer_size, &required_size,
|
append(&buffer, buffer_size, &required_size,
|
||||||
"PSA_ALG_TRUNCATED_MAC(", 22);
|
"PSA_ALG_TRUNCATED_MAC(", 22);
|
||||||
length_modifier = PSA_MAC_TRUNCATED_LENGTH(alg);
|
length_modifier = PSA_MAC_TRUNCATED_LENGTH(alg);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else if (PSA_ALG_IS_AEAD(alg)) {
|
} else if (PSA_ALG_IS_AEAD(alg)) {
|
||||||
core_alg = PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG(alg);
|
core_alg = PSA_ALG_AEAD_WITH_DEFAULT_LENGTH_TAG(alg);
|
||||||
if (alg & PSA_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG) {
|
|
||||||
if (core_alg == 0) {
|
if (core_alg == 0) {
|
||||||
/* For unknown AEAD algorithms, there is no "default tag length". */
|
/* For unknown AEAD algorithms, there is no "default tag length". */
|
||||||
core_alg = alg;
|
core_alg = alg;
|
||||||
} else {
|
} else if (alg & PSA_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG) {
|
||||||
append(&buffer, buffer_size, &required_size,
|
append(&buffer, buffer_size, &required_size,
|
||||||
"PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(", 43);
|
"PSA_ALG_AEAD_WITH_AT_LEAST_THIS_LENGTH_TAG(", 43);
|
||||||
length_modifier = PSA_AEAD_TAG_LENGTH(alg);
|
length_modifier = PSA_AEAD_TAG_LENGTH(alg);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (core_alg == 0) {
|
|
||||||
/* For unknown AEAD algorithms, there is no "default tag length". */
|
|
||||||
core_alg = alg;
|
|
||||||
} else if (core_alg != alg) {
|
} else if (core_alg != alg) {
|
||||||
append(&buffer, buffer_size, &required_size,
|
append(&buffer, buffer_size, &required_size,
|
||||||
"PSA_ALG_AEAD_WITH_SHORTENED_TAG(", 32);
|
"PSA_ALG_AEAD_WITH_SHORTENED_TAG(", 32);
|
||||||
length_modifier = PSA_AEAD_TAG_LENGTH(alg);
|
length_modifier = PSA_AEAD_TAG_LENGTH(alg);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else if (PSA_ALG_IS_KEY_AGREEMENT(alg) &&
|
} else if (PSA_ALG_IS_KEY_AGREEMENT(alg) &&
|
||||||
!PSA_ALG_IS_RAW_KEY_AGREEMENT(alg)) {
|
!PSA_ALG_IS_RAW_KEY_AGREEMENT(alg)) {
|
||||||
core_alg = PSA_ALG_KEY_AGREEMENT_GET_KDF(alg);
|
core_alg = PSA_ALG_KEY_AGREEMENT_GET_KDF(alg);
|
||||||
|
Loading…
Reference in New Issue
Block a user