Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/poly1305/poly1305.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | size_t Poly1305_ctx_size(void) | - | ||||||||||||
4 | { | - | ||||||||||||
5 | return executed 13290 times by 1 test: sizeof(struct poly1305_context);return sizeof(struct poly1305_context); Executed by:
executed 13290 times by 1 test: return sizeof(struct poly1305_context); Executed by:
| 13290 | ||||||||||||
6 | } | - | ||||||||||||
7 | - | |||||||||||||
8 | - | |||||||||||||
9 | static unsigned int U8TOU32(const unsigned char *p) | - | ||||||||||||
10 | { | - | ||||||||||||
11 | return executed 60844 times by 2 tests: (((unsigned int)(p[0] & 0xff)) |return (((unsigned int)(p[0] & 0xff)) | ((unsigned int)(p[1] & 0xff) << 8) | ((unsigned int)(p[2] & 0xff) << 16) | ((unsigned int)(p[3] & 0xff) << 24)); Executed by:
executed 60844 times by 2 tests: return (((unsigned int)(p[0] & 0xff)) | ((unsigned int)(p[1] & 0xff) << 8) | ((unsigned int)(p[2] & 0xff) << 16) | ((unsigned int)(p[3] & 0xff) << 24)); Executed by:
| 60844 | ||||||||||||
12 | ((unsigned int)(p[1] & 0xff) << 8) | executed 60844 times by 2 tests: return (((unsigned int)(p[0] & 0xff)) | ((unsigned int)(p[1] & 0xff) << 8) | ((unsigned int)(p[2] & 0xff) << 16) | ((unsigned int)(p[3] & 0xff) << 24)); Executed by:
| 60844 | ||||||||||||
13 | ((unsigned int)(p[2] & 0xff) << 16) | executed 60844 times by 2 tests: return (((unsigned int)(p[0] & 0xff)) | ((unsigned int)(p[1] & 0xff) << 8) | ((unsigned int)(p[2] & 0xff) << 16) | ((unsigned int)(p[3] & 0xff) << 24)); Executed by:
| 60844 | ||||||||||||
14 | ((unsigned int)(p[3] & 0xff) << 24)); executed 60844 times by 2 tests: return (((unsigned int)(p[0] & 0xff)) | ((unsigned int)(p[1] & 0xff) << 8) | ((unsigned int)(p[2] & 0xff) << 16) | ((unsigned int)(p[3] & 0xff) << 24)); Executed by:
| 60844 | ||||||||||||
15 | } | - | ||||||||||||
16 | int poly1305_init(void *ctx, const unsigned char key[16], void *func); | - | ||||||||||||
17 | void poly1305_blocks(void *ctx, const unsigned char *inp, size_t len, | - | ||||||||||||
18 | unsigned int padbit); | - | ||||||||||||
19 | void poly1305_emit(void *ctx, unsigned char mac[16], | - | ||||||||||||
20 | const unsigned int nonce[4]); | - | ||||||||||||
21 | - | |||||||||||||
22 | - | |||||||||||||
23 | void Poly1305_Init(POLY1305 *ctx, const unsigned char key[32]) | - | ||||||||||||
24 | { | - | ||||||||||||
25 | ctx->nonce[0] = U8TOU32(&key[16]); | - | ||||||||||||
26 | ctx->nonce[1] = U8TOU32(&key[20]); | - | ||||||||||||
27 | ctx->nonce[2] = U8TOU32(&key[24]); | - | ||||||||||||
28 | ctx->nonce[3] = U8TOU32(&key[28]); | - | ||||||||||||
29 | if (!poly1305_init(ctx->opaque, key, &ctx->func)
| 0-15211 | ||||||||||||
30 | ctx->func.blocks = poly1305_blocks; | - | ||||||||||||
31 | ctx->func.emit = poly1305_emit; | - | ||||||||||||
32 | } never executed: end of block | 0 | ||||||||||||
33 | - | |||||||||||||
34 | - | |||||||||||||
35 | ctx->num = 0; | - | ||||||||||||
36 | - | |||||||||||||
37 | } executed 15211 times by 2 tests: end of block Executed by:
| 15211 | ||||||||||||
38 | void Poly1305_Update(POLY1305 *ctx, const unsigned char *inp, size_t len) | - | ||||||||||||
39 | { | - | ||||||||||||
40 | - | |||||||||||||
41 | - | |||||||||||||
42 | - | |||||||||||||
43 | - | |||||||||||||
44 | - | |||||||||||||
45 | - | |||||||||||||
46 | - | |||||||||||||
47 | poly1305_blocks_f poly1305_blocks_p = ctx->func.blocks; | - | ||||||||||||
48 | - | |||||||||||||
49 | size_t rem, num; | - | ||||||||||||
50 | - | |||||||||||||
51 | if ((
| 24990-43508 | ||||||||||||
52 | rem = 16 - num; | - | ||||||||||||
53 | if (len >= rem
| 144-24846 | ||||||||||||
54 | memcpy(ctx->data + num, inp, rem); | - | ||||||||||||
55 | (*poly1305_blocks_p)(ctx->opaque, ctx->data, 16, 1); | - | ||||||||||||
56 | inp += rem; | - | ||||||||||||
57 | len -= rem; | - | ||||||||||||
58 | } executed 24846 times by 2 tests: else {end of block Executed by:
| 24846 | ||||||||||||
59 | - | |||||||||||||
60 | memcpy(ctx->data + num, inp, len); | - | ||||||||||||
61 | ctx->num = num + len; | - | ||||||||||||
62 | return; executed 144 times by 1 test: return; Executed by:
| 144 | ||||||||||||
63 | } | - | ||||||||||||
64 | } | - | ||||||||||||
65 | - | |||||||||||||
66 | rem = len % 16; | - | ||||||||||||
67 | len -= rem; | - | ||||||||||||
68 | - | |||||||||||||
69 | if (len >= 16
| 33991-34363 | ||||||||||||
70 | (*poly1305_blocks_p)(ctx->opaque, inp, len, 1); | - | ||||||||||||
71 | inp += len; | - | ||||||||||||
72 | } executed 34363 times by 2 tests: end of block Executed by:
| 34363 | ||||||||||||
73 | - | |||||||||||||
74 | if (rem
| 24965-43389 | ||||||||||||
75 | memcpy(ctx->data, inp, rem); executed 24965 times by 2 tests: memcpy(ctx->data, inp, rem); Executed by:
| 24965 | ||||||||||||
76 | - | |||||||||||||
77 | ctx->num = rem; | - | ||||||||||||
78 | } executed 68354 times by 2 tests: end of block Executed by:
| 68354 | ||||||||||||
79 | - | |||||||||||||
80 | void Poly1305_Final(POLY1305 *ctx, unsigned char mac[16]) | - | ||||||||||||
81 | { | - | ||||||||||||
82 | - | |||||||||||||
83 | poly1305_blocks_f poly1305_blocks_p = ctx->func.blocks; | - | ||||||||||||
84 | poly1305_emit_f poly1305_emit_p = ctx->func.emit; | - | ||||||||||||
85 | - | |||||||||||||
86 | size_t num; | - | ||||||||||||
87 | - | |||||||||||||
88 | if ((
| 119-15092 | ||||||||||||
89 | ctx->data[num++] = 1; | - | ||||||||||||
90 | while (num < 16
| 119-780 | ||||||||||||
91 | ctx->data[num++] = 0; executed 780 times by 2 tests: ctx->data[num++] = 0; Executed by:
| 780 | ||||||||||||
92 | (*poly1305_blocks_p)(ctx->opaque, ctx->data, 16, 0); | - | ||||||||||||
93 | } executed 119 times by 2 tests: end of block Executed by:
| 119 | ||||||||||||
94 | - | |||||||||||||
95 | (*poly1305_emit_p)(ctx->opaque, mac, ctx->nonce); | - | ||||||||||||
96 | - | |||||||||||||
97 | - | |||||||||||||
98 | OPENSSL_cleanse(ctx, sizeof(*ctx)); | - | ||||||||||||
99 | } executed 15211 times by 2 tests: end of block Executed by:
| 15211 | ||||||||||||
Switch to Source code | Preprocessed file |