mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-24 20:41:05 +00:00
Fix divide by zero if macro used with wrong key
If PSA_CIPHER_ENCRYPT_OUTPUT_SIZE was called on a non symmetric key, then a divide by zero could happen, as PSA_CIPHER_BLOCK_LENGTH will return 0 for such a key, and PSA_ROUND_UP_TO_MULTIPLE will divide by the block length. Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
parent
008cd0c4d8
commit
7fe62cc88b
|
@ -998,9 +998,11 @@
|
|||
*/
|
||||
#define PSA_CIPHER_ENCRYPT_OUTPUT_SIZE(key_type, alg, input_length) \
|
||||
(alg == PSA_ALG_CBC_PKCS7 ? \
|
||||
(((key_type) & PSA_KEY_TYPE_CATEGORY_MASK) \
|
||||
== PSA_KEY_TYPE_CATEGORY_SYMMETRIC ? \
|
||||
PSA_ROUND_UP_TO_MULTIPLE(PSA_BLOCK_CIPHER_BLOCK_LENGTH(key_type), \
|
||||
(input_length) + 1) + \
|
||||
PSA_CIPHER_IV_LENGTH((key_type), (alg)) : \
|
||||
PSA_CIPHER_IV_LENGTH((key_type), (alg)) : 0) : \
|
||||
(PSA_ALG_IS_CIPHER(alg) ? \
|
||||
(input_length) + PSA_CIPHER_IV_LENGTH((key_type), (alg)) : \
|
||||
0))
|
||||
|
|
Loading…
Reference in a new issue