Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor-Misic committed Mar 27, 2024
1 parent 484cd45 commit b5f75d3
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Src/crypto/chacha20.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ quarterround(uint32_t* a, uint32_t* b, uint32_t* c, uint32_t* d) {
*b = BitManipulation_rotl32(*b ^ *c, 7);
}

static void
static bool
chacha20_block(const byte_t key[CHACHA20_KEY_SIZE], const uint32_t counter, const byte_t nonce[CHACHA20_NONCE_SIZE],
byte_t out[KEY_STREAM_SIZE]) {

Expand Down Expand Up @@ -153,9 +153,9 @@ chacha20(const byte_t* plaintext,

uint32_t blocks = plaintext_len / BLOCK_SIZE;
uint32_t remaining_bytes = plaintext_len % BLOCK_SIZE;
static byte_t key_stream[KEY_STREAM_SIZE] = ARRAY_64_ZERO_VALUES;

for (uint32_t j = 0; j < blocks; ++j) {
byte_t key_stream[KEY_STREAM_SIZE] = ARRAY_64_ZERO_VALUES;
chacha20_block(key, j + inc, nonce, key_stream);

for (uint8_t i = 0; i < BLOCK_SIZE; ++i) {
Expand All @@ -164,7 +164,6 @@ chacha20(const byte_t* plaintext,
}

if (0U != remaining_bytes) {
byte_t key_stream[KEY_STREAM_SIZE] = ARRAY_64_ZERO_VALUES;
chacha20_block(key, blocks + inc, nonce, key_stream);

for (uint32_t i = 0; i < remaining_bytes; ++i) {
Expand Down

0 comments on commit b5f75d3

Please sign in to comment.