mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-08-22 02:59:54 +00:00
Improve comments and guards
Signed-off-by: Ben Taylor <[email protected]>
This commit is contained in:
@@ -227,6 +227,9 @@ int mbedtls_chachapoly_update_aad(mbedtls_chachapoly_context *ctx,
|
||||
* \return #MBEDTLS_ERR_CHACHAPOLY_BAD_STATE
|
||||
* if the operation has not been started or has been
|
||||
* finished.
|
||||
* \return #MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA
|
||||
* if processing \p len bytes would make the 32-bit block
|
||||
* counter wrap.
|
||||
* \return Another negative error code on other kinds of failure.
|
||||
*/
|
||||
int mbedtls_chachapoly_update(mbedtls_chachapoly_context *ctx,
|
||||
@@ -280,6 +283,9 @@ int mbedtls_chachapoly_finish(mbedtls_chachapoly_context *ctx,
|
||||
* is written. This must not be \c NULL.
|
||||
*
|
||||
* \return \c 0 on success.
|
||||
* \return #MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA
|
||||
* if processing \p length bytes would make the 32-bit block
|
||||
* counter wrap.
|
||||
* \return A negative error code on failure.
|
||||
*/
|
||||
int mbedtls_chachapoly_encrypt_and_tag(mbedtls_chachapoly_context *ctx,
|
||||
@@ -314,6 +320,9 @@ int mbedtls_chachapoly_encrypt_and_tag(mbedtls_chachapoly_context *ctx,
|
||||
* \return \c 0 on success.
|
||||
* \return #MBEDTLS_ERR_CHACHAPOLY_AUTH_FAILED
|
||||
* if the data was not authentic.
|
||||
* \return #MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA
|
||||
* if processing \p length bytes would make the 32-bit block
|
||||
* counter wrap.
|
||||
* \return Another negative error code on other kinds of failure.
|
||||
*/
|
||||
int mbedtls_chachapoly_auth_decrypt(mbedtls_chachapoly_context *ctx,
|
||||
|
||||
@@ -2470,6 +2470,8 @@ psa_status_t psa_aead_set_nonce(psa_aead_operation_t *operation,
|
||||
* psa_aead_set_nonce() or psa_aead_generate_nonce().
|
||||
*
|
||||
* - For #PSA_ALG_CCM, calling this function is required.
|
||||
* - For #PSA_ALG_CHACHA20_POLY1305, the plaintext length must not
|
||||
* exceed `UINT32_MAX * 64` bytes.
|
||||
* - For the other AEAD algorithms defined in this specification, calling
|
||||
* this function is not required.
|
||||
* - For vendor-defined algorithm, refer to the vendor documentation.
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
|
||||
#include "mbedtls/chacha20.h"
|
||||
|
||||
#if !defined(MBEDTLS_CHACHA20_ALT)
|
||||
int mbedtls_chacha20_check_counter_wrap(const mbedtls_chacha20_context *ctx,
|
||||
size_t size);
|
||||
#endif /* !MBEDTLS_CHACHA20_ALT */
|
||||
|
||||
#endif /* MBEDTLS_CHACHA20_INTERNAL_H */
|
||||
|
||||
@@ -167,10 +167,12 @@ int mbedtls_chachapoly_update(mbedtls_chachapoly_context *ctx,
|
||||
return MBEDTLS_ERR_CHACHAPOLY_BAD_STATE;
|
||||
}
|
||||
|
||||
#if !defined(MBEDTLS_CHACHA20_ALT)
|
||||
ret = mbedtls_chacha20_check_counter_wrap(&ctx->chacha20_ctx, len);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
#endif /* !MBEDTLS_CHACHA20_ALT */
|
||||
|
||||
if (ctx->state == CHACHAPOLY_STATE_AAD) {
|
||||
ctx->state = CHACHAPOLY_STATE_CIPHERTEXT;
|
||||
|
||||
Reference in New Issue
Block a user