Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/chacha/chacha.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | void | - | ||||||||||||
5 | ChaCha_set_key(ChaCha_ctx *ctx, const unsigned char *key, uint32_t keybits) | - | ||||||||||||
6 | { | - | ||||||||||||
7 | chacha_keysetup((chacha_ctx *)ctx, key, keybits); | - | ||||||||||||
8 | ctx->unused = 0; | - | ||||||||||||
9 | } executed 32 times by 2 tests: end of block Executed by:
| 32 | ||||||||||||
10 | - | |||||||||||||
11 | void | - | ||||||||||||
12 | ChaCha_set_iv(ChaCha_ctx *ctx, const unsigned char *iv, | - | ||||||||||||
13 | const unsigned char *counter) | - | ||||||||||||
14 | { | - | ||||||||||||
15 | chacha_ivsetup((chacha_ctx *)ctx, iv, counter); | - | ||||||||||||
16 | ctx->unused = 0; | - | ||||||||||||
17 | } executed 32 times by 2 tests: end of block Executed by:
| 32 | ||||||||||||
18 | - | |||||||||||||
19 | void | - | ||||||||||||
20 | ChaCha(ChaCha_ctx *ctx, unsigned char *out, const unsigned char *in, size_t len) | - | ||||||||||||
21 | { | - | ||||||||||||
22 | unsigned char *k; | - | ||||||||||||
23 | int i, l; | - | ||||||||||||
24 | - | |||||||||||||
25 | - | |||||||||||||
26 | if (ctx->unused > 0
| 32-552 | ||||||||||||
27 | k = ctx->ks + 64 - ctx->unused; | - | ||||||||||||
28 | l = (
| 0-552 | ||||||||||||
29 | for (i = 0; i < l
| 552-768 | ||||||||||||
30 | *( executed 768 times by 1 test: out++) = *(in++) ^ *(k++);*(out++) = *(in++) ^ *(k++); Executed by:
executed 768 times by 1 test: *(out++) = *(in++) ^ *(k++); Executed by:
| 768 | ||||||||||||
31 | ctx->unused -= l; | - | ||||||||||||
32 | len -= l; | - | ||||||||||||
33 | } executed 552 times by 1 test: end of block Executed by:
| 552 | ||||||||||||
34 | - | |||||||||||||
35 | chacha_encrypt_bytes((chacha_ctx *)ctx, in, out, (uint32_t)len); | - | ||||||||||||
36 | } executed 584 times by 2 tests: end of block Executed by:
| 584 | ||||||||||||
37 | - | |||||||||||||
38 | void | - | ||||||||||||
39 | CRYPTO_chacha_20(unsigned char *out, const unsigned char *in, size_t len, | - | ||||||||||||
40 | const unsigned char key[32], const unsigned char iv[8], uint64_t counter) | - | ||||||||||||
41 | { | - | ||||||||||||
42 | struct chacha_ctx ctx; | - | ||||||||||||
43 | - | |||||||||||||
44 | - | |||||||||||||
45 | - | |||||||||||||
46 | - | |||||||||||||
47 | - | |||||||||||||
48 | - | |||||||||||||
49 | chacha_keysetup(&ctx, key, 256); | - | ||||||||||||
50 | chacha_ivsetup(&ctx, iv, | - | ||||||||||||
51 | ((void *)0) | - | ||||||||||||
52 | ); | - | ||||||||||||
53 | if (counter != 0
| 11-325 | ||||||||||||
54 | ctx.input[12] = (uint32_t)counter; | - | ||||||||||||
55 | ctx.input[13] = (uint32_t)(counter >> 32); | - | ||||||||||||
56 | } executed 325 times by 3 tests: end of block Executed by:
| 325 | ||||||||||||
57 | - | |||||||||||||
58 | chacha_encrypt_bytes(&ctx, in, out, (uint32_t)len); | - | ||||||||||||
59 | } executed 336 times by 4 tests: end of block Executed by:
| 336 | ||||||||||||
Switch to Source code | Preprocessed file |