Improve documentation of PSA_AEAD_xxx_OUTPUT_SIZE

This commit is contained in:
Gilles Peskine 2018-06-08 11:36:37 +02:00 committed by itayzafrir
parent 3158564f08
commit 212e4d8f7c

View file

@ -1074,22 +1074,24 @@ psa_status_t psa_cipher_abort(psa_cipher_operation_t *operation);
*/ */
/** AEAD Encrypted data size /** The maximum size of the output of psa_aead_encrypt(), in bytes.
* *
* This macro calculates the encrypted data size according to given algorithm * If the size of the ciphertext buffer is at least this large, it is
* and plaintext_length. * guaranteed that psa_aead_encrypt() will not fail due to an
* insufficient buffer size. Depending on the algorithm, the actual size of
* the ciphertext may be smaller.
* *
* * \param alg An AEAD algorithm
* \param alg The AEAD algorithm to compute
* (\c PSA_ALG_XXX value such that * (\c PSA_ALG_XXX value such that
* #PSA_ALG_IS_AEAD(alg) is true). * #PSA_ALG_IS_AEAD(alg) is true).
* \param plaintext_length Size of \p plaintext in bytes. * \param plaintext_length Size of the plaintext in bytes.
* *
* \return If the algorithm is PSA_ALG_GCM the encrypted data size is * \return The AEAD ciphertext size for the specified
* plaintext_length plus 16-bytes for tag. * algorithm.
* If the algorithm is PSA_ALG_CCM the encrypted data size is * If the AEAD algorithm is not recognized, return 0.
* plaintext_length plus 16-bytes for tag. * An implementation may return either 0 or a
* Otherwise return zero. * correct size for an AEAD algorithm that it
* recognizes, but does not support.
*/ */
#define PSA_AEAD_ENCRYPT_OUTPUT_SIZE(alg, plaintext_length) \ #define PSA_AEAD_ENCRYPT_OUTPUT_SIZE(alg, plaintext_length) \
((alg) == PSA_ALG_GCM ? (plaintext_length) + 16 : \ ((alg) == PSA_ALG_GCM ? (plaintext_length) + 16 : \
@ -1149,22 +1151,24 @@ psa_status_t psa_aead_encrypt( psa_key_slot_t key,
size_t ciphertext_size, size_t ciphertext_size,
size_t *ciphertext_length ); size_t *ciphertext_length );
/** AEAD Decrypted data size /** The maximum size of the output of psa_aead_decrypt(), in bytes.
* *
* This macro calculates the decrypted data size according to given algorithm * If the size of the plaintext buffer is at least this large, it is
* and ciphertext_length. * guaranteed that psa_aead_decrypt() will not fail due to an
* insufficient buffer size. Depending on the algorithm, the actual size of
* the plaintext may be smaller.
* *
* * \param alg An AEAD algorithm
* \param alg The AEAD algorithm to compute
* (\c PSA_ALG_XXX value such that * (\c PSA_ALG_XXX value such that
* #PSA_ALG_IS_AEAD(alg) is true). * #PSA_ALG_IS_AEAD(alg) is true).
* \param ciphertext_length Size of \p ciphertext in bytes. * \param ciphertext_length Size of the plaintext in bytes.
* *
* \return If the algorithm is PSA_ALG_GCM the decrypted data size is * \return The AEAD ciphertext size for the specified
* ciphertext_length minus 16-bytes for tag. * algorithm.
* If the algorithm is PSA_ALG_CCM the decrypted data size is * If the AEAD algorithm is not recognized, return 0.
* ciphertext_length minus 16-bytes for tag. * An implementation may return either 0 or a
* Otherwise return zero. * correct size for an AEAD algorithm that it
* recognizes, but does not support.
*/ */
#define PSA_AEAD_DECRYPT_OUTPUT_SIZE(alg, ciphertext_length) \ #define PSA_AEAD_DECRYPT_OUTPUT_SIZE(alg, ciphertext_length) \
((alg) == PSA_ALG_GCM ? (ciphertext_length) - 16 : \ ((alg) == PSA_ALG_GCM ? (ciphertext_length) - 16 : \