Change PSA Cipher macro safety to use block length

Although checking if the key was symmetric was correct, its easier to
read if we just check the block length is not zero before we use it in a
division.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
Paul Elliott 2021-07-08 16:50:01 +01:00
parent a02003babe
commit c22950c9d0

View File

@ -992,8 +992,7 @@
*/ */
#define PSA_CIPHER_ENCRYPT_OUTPUT_SIZE(key_type, alg, input_length) \ #define PSA_CIPHER_ENCRYPT_OUTPUT_SIZE(key_type, alg, input_length) \
(alg == PSA_ALG_CBC_PKCS7 ? \ (alg == PSA_ALG_CBC_PKCS7 ? \
(((key_type) & PSA_KEY_TYPE_CATEGORY_MASK) \ (PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type) != 0 ? \
== PSA_KEY_TYPE_CATEGORY_SYMMETRIC ? \
PSA_ROUND_UP_TO_MULTIPLE(PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type), \ PSA_ROUND_UP_TO_MULTIPLE(PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type), \
(input_length) + 1) + \ (input_length) + 1) + \
PSA_CIPHER_IV_LENGTH((key_type), (alg)) : 0) : \ PSA_CIPHER_IV_LENGTH((key_type), (alg)) : 0) : \