MCPcopy Create free account
hub / github.com/bailey27/cppcryptfs / aes256_ctr

Function aes256_ctr

libcppcryptfs/crypt/aes-siv/aes256-ctr.cpp:19–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17}
18
19void aes256_ctr(AES *ctx, uint8_t *input, const size_t input_len, const uint8_t *iv)
20{
21 uint8_t nonce[16], buf[16];
22 memcpy(nonce, iv, sizeof(nonce));
23
24 size_t count = 0;
25 while (count + 16 <= input_len)
26 {
27 memcpy(buf, nonce, sizeof(nonce));
28 ctx->encrypt(buf, buf);
29 aes256_xor(&input[count], buf, sizeof(buf));
30
31 aes256_ctr_increment_nonce(nonce);
32 count += 16;
33 }
34
35 size_t rem = input_len - count;
36 if (rem > 0)
37 {
38 ctx->encrypt(nonce, nonce);
39 aes256_xor(&input[count], nonce, rem);
40 }
41}

Callers 2

aes256_encrypt_sivFunction · 0.85
aes256_decrypt_sivFunction · 0.85

Calls 3

aes256_xorFunction · 0.85
encryptMethod · 0.80

Tested by

no test coverage detected