mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2025-12-21 21:36:21 +01:00
chacha20: fix bug in starts() and add test for it
Previously the streaming API would fail when encrypting multiple messages with the same key.
This commit is contained in:
parent
7296771194
commit
55c0d096b7
2 changed files with 42 additions and 1 deletions
|
|
@ -243,6 +243,12 @@ int mbedtls_chacha20_starts( mbedtls_chacha20_context* ctx,
|
|||
ctx->initial_state[14] = BYTES_TO_U32_LE( nonce, 4 );
|
||||
ctx->initial_state[15] = BYTES_TO_U32_LE( nonce, 8 );
|
||||
|
||||
mbedtls_zeroize( ctx->working_state, sizeof( ctx->working_state ) );
|
||||
mbedtls_zeroize( ctx->keystream8, sizeof( ctx->keystream8 ) );
|
||||
|
||||
/* Initially, there's no keystream bytes available */
|
||||
ctx->keystream_bytes_used = CHACHA20_BLOCK_SIZE_BYTES;
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue