mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-10-31 03:16:37 +08:00
Tidy ChaCha20 counter limit handling
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
This commit is contained in:
parent
7bf0215f8d
commit
dcf3b11749
@ -38,7 +38,8 @@ extern "C" {
|
||||
typedef struct mbedtls_chacha20_context {
|
||||
uint32_t MBEDTLS_PRIVATE(state)[16]; /*! The state (before round operations). */
|
||||
uint8_t MBEDTLS_PRIVATE(keystream8)[64]; /*! Leftover keystream bytes. */
|
||||
size_t MBEDTLS_PRIVATE(keystream_bytes_used); /*! Number of keystream bytes already used. */
|
||||
size_t MBEDTLS_PRIVATE(keystream_bytes_used); /*! Number of keystream bytes already used,
|
||||
* or an internal sentinel value. */
|
||||
}
|
||||
mbedtls_chacha20_context;
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
#define CHACHA20_BLOCK_SIZE_BYTES (4U * 16U)
|
||||
|
||||
#define CHACHA20_MAX_BLOCKS 0xFFFFFFFF
|
||||
#define CHACHA20_MAX_BLOCKS UINT32_MAX
|
||||
|
||||
#define CHACHA20_COUNTER_EXHAUSTED (CHACHA20_BLOCK_SIZE_BYTES + 1U)
|
||||
|
||||
|
||||
@ -96,6 +96,7 @@ void chacha20_input_len_too_long(void)
|
||||
|
||||
/* Consume the rest of the final counter block, then reject more input. */
|
||||
TEST_EQUAL(mbedtls_chacha20_update(&ctx, 63, input, output), 0);
|
||||
TEST_EQUAL(mbedtls_chacha20_update(&ctx, 0, NULL, NULL), 0);
|
||||
TEST_EQUAL(mbedtls_chacha20_update(&ctx, 1, input, output),
|
||||
MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user