From 723feffe159b7eacbab7272bc55f429bf726648a Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 31 May 2018 20:08:13 +0200 Subject: [PATCH] Fix some errors in PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE A call to PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE wouldn't even have compiled. Fix some obvious errors. This is still untested. --- include/psa/crypto.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/include/psa/crypto.h b/include/psa/crypto.h index c0b318776..084049430 100755 --- a/include/psa/crypto.h +++ b/include/psa/crypto.h @@ -1368,11 +1368,13 @@ psa_status_t psa_asymmetric_verify(psa_key_slot_t key, (PSA_KEY_TYPE_IS_RSA(key_type) ? \ ((void)alg, PSA_BITS_TO_BYTES(key_bits)) : \ 0) -#define PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE(key_type, key_bits, alg) \ +#define PSA_RSA_MINIMUM_PADDING_SIZE(alg) \ + (PSA_ALG_IS_RSA_OAEP_MGF1(alg) ? \ + 2 * PSA_HASH_FINAL_SIZE(PSA_ALG_RSA_GET_HASH(alg)) + 1 : \ + 11 /*PKCS#1v1.5*/) +#define PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE(key_type, key_bits, alg) \ (PSA_KEY_TYPE_IS_RSA(key_type) ? \ - PSA_BITS_TO_BYTES(key_bits) - ((alg) == PSA_ALG_IS_RSA_OAEP_MGF1 ? \ - 2 * (PSA_ALG_RSA_GET_HASH(alg) + 1) : \ - 11 /*PKCS#1v1.5*/) : \ + PSA_BITS_TO_BYTES(key_bits) - PSA_RSA_MINIMUM_PADDING_SIZE(alg) : \ 0) /**