diff --git a/include/psa/crypto.h b/include/psa/crypto.h index c45fccd4b..8e20013a2 100755 --- a/include/psa/crypto.h +++ b/include/psa/crypto.h @@ -1073,7 +1073,24 @@ psa_status_t psa_cipher_abort(psa_cipher_operation_t *operation); * @{ */ -// This macro calculates the encryption output size according to given algorithm + +/** AEAD Encrypted data size + * + * This macro calculates the encrypted data size according to given algorithm + * and plaintext_length. + * + * + * \param alg The AEAD algorithm to compute + * (\c PSA_ALG_XXX value such that + * #PSA_ALG_IS_AEAD(alg) is true). + * \param plaintext_length Size of \p plaintext in bytes. + * + * \return If the algorithm is PSA_ALG_GCM the encrypted data size is + * plaintext_length plus 16-bytes for tag. + * If the algorithm is PSA_ALG_CCM the encrypted data size is + * plaintext_length plus 16-bytes for tag. + * Otherwise return zero. + */ #define PSA_AEAD_ENCRYPT_OUTPUT_SIZE(alg, plaintext_length) \ ((alg) == PSA_ALG_GCM ? (plaintext_length) + 16 : \ (alg) == PSA_ALG_CCM ? (plaintext_length) + 16 : \ @@ -1132,7 +1149,23 @@ psa_status_t psa_aead_encrypt( psa_key_slot_t key, size_t ciphertext_size, size_t *ciphertext_length ); -// This macro calculates the decryption output size according to given algorithm +/** AEAD Decrypted data size + * + * This macro calculates the decrypted data size according to given algorithm + * and ciphertext_length. + * + * + * \param alg The AEAD algorithm to compute + * (\c PSA_ALG_XXX value such that + * #PSA_ALG_IS_AEAD(alg) is true). + * \param ciphertext_length Size of \p ciphertext in bytes. + * + * \return If the algorithm is PSA_ALG_GCM the decrypted data size is + * ciphertext_length minus 16-bytes for tag. + * If the algorithm is PSA_ALG_CCM the decrypted data size is + * ciphertext_length minus 16-bytes for tag. + * Otherwise return zero. + */ #define PSA_AEAD_DECRYPT_OUTPUT_SIZE(alg, ciphertext_length) \ ((alg) == PSA_ALG_GCM ? (ciphertext_length) - 16 : \ (alg) == PSA_ALG_CCM ? (ciphertext_length) - 16 : \