OpenCoverage

gostr341194.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/gost/gostr341194.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8static void-
9swap_bytes(unsigned char *w, unsigned char *k)-
10{-
11 int i, j;-
12-
13 for (i = 0; i < 4
i < 4Description
TRUEevaluated 102512 times by 3 tests
Evaluated by:
  • evptest
  • gost2814789t
  • tls_prf
FALSEevaluated 25628 times by 3 tests
Evaluated by:
  • evptest
  • gost2814789t
  • tls_prf
; i++)
25628-102512
14 for (j = 0; j < 8
j < 8Description
TRUEevaluated 820096 times by 3 tests
Evaluated by:
  • evptest
  • gost2814789t
  • tls_prf
FALSEevaluated 102512 times by 3 tests
Evaluated by:
  • evptest
  • gost2814789t
  • tls_prf
; j++)
102512-820096
15 k[i + 4 * j] = w[8 * i + j];
executed 820096 times by 3 tests: k[i + 4 * j] = w[8 * i + j];
Executed by:
  • evptest
  • gost2814789t
  • tls_prf
820096
16}
executed 25628 times by 3 tests: end of block
Executed by:
  • evptest
  • gost2814789t
  • tls_prf
25628
17-
18-
19static void-
20circle_xor8(const unsigned char *w, unsigned char *k)-
21{-
22 unsigned char buf[8];-
23 int i;-
24-
25 memcpy(buf, w, 8);-
26 memmove(k, w + 8, 24);-
27 for (i = 0; i < 8
i < 8Description
TRUEevaluated 461304 times by 3 tests
Evaluated by:
  • evptest
  • gost2814789t
  • tls_prf
FALSEevaluated 57663 times by 3 tests
Evaluated by:
  • evptest
  • gost2814789t
  • tls_prf
; i++)
57663-461304
28 k[i + 24] = buf[i] ^ k[i];
executed 461304 times by 3 tests: k[i + 24] = buf[i] ^ k[i];
Executed by:
  • evptest
  • gost2814789t
  • tls_prf
461304
29}
executed 57663 times by 3 tests: end of block
Executed by:
  • evptest
  • gost2814789t
  • tls_prf
57663
30-
31-
32static void-
33transform_3(unsigned char *data)-
34{-
35 unsigned short int acc;-
36-
37 acc = (data[0] ^ data[2] ^ data[4] ^ data[6] ^ data[24] ^ data[30]) |-
38 ((data[1] ^ data[3] ^ data[5] ^ data[7] ^ data[25] ^ data[31]) << 8);-
39 memmove(data, data + 2, 30);-
40 data[30] = acc & 0xff;-
41 data[31] = acc >> 8;-
42}
executed 474118 times by 3 tests: end of block
Executed by:
  • evptest
  • gost2814789t
  • tls_prf
474118
43-
44-
45static int-
46add_blocks(int n, unsigned char *left, const unsigned char *right)-
47{-
48 int i;-
49 int carry = 0;-
50 int sum;-
51-
52 for (i = 0; i < n
i < nDescription
TRUEevaluated 121568 times by 2 tests
Evaluated by:
  • gost2814789t
  • tls_prf
FALSEevaluated 3799 times by 2 tests
Evaluated by:
  • gost2814789t
  • tls_prf
; i++) {
3799-121568
53 sum = (int)left[i] + (int)right[i] + carry;-
54 left[i] = sum & 0xff;-
55 carry = sum >> 8;-
56 }
executed 121568 times by 2 tests: end of block
Executed by:
  • gost2814789t
  • tls_prf
121568
57 return
executed 3799 times by 2 tests: return carry;
Executed by:
  • gost2814789t
  • tls_prf
carry;
executed 3799 times by 2 tests: return carry;
Executed by:
  • gost2814789t
  • tls_prf
3799
58}-
59-
60-
61static void-
62xor_blocks(unsigned char *result, const unsigned char *a,-
63 const unsigned char *b, size_t len)-
64{-
65 size_t i;-
66-
67 for (i = 0; i < len
i < lenDescription
TRUEevaluated 1230144 times by 3 tests
Evaluated by:
  • evptest
  • gost2814789t
  • tls_prf
FALSEevaluated 38442 times by 3 tests
Evaluated by:
  • evptest
  • gost2814789t
  • tls_prf
; i++)
38442-1230144
68 result[i] = a[i] ^ b[i];
executed 1230144 times by 3 tests: result[i] = a[i] ^ b[i];
Executed by:
  • evptest
  • gost2814789t
  • tls_prf
1230144
69}
executed 38442 times by 3 tests: end of block
Executed by:
  • evptest
  • gost2814789t
  • tls_prf
38442
70-
71-
72-
73-
74-
75static int-
76hash_step(GOSTR341194_CTX *c, unsigned char *H, const unsigned char *M)-
77{-
78 unsigned char U[32], W[32], V[32], S[32], Key[32];-
79 int i;-
80-
81-
82 xor_blocks(W, H, M, 32);-
83 swap_bytes(W, Key);-
84-
85 Gost2814789_set_key(&c->cipher, Key, 256);-
86 Gost2814789_encrypt(H, S, &c->cipher);-
87-
88-
89 circle_xor8(H, U);-
90 circle_xor8(M, V);-
91 circle_xor8(V, V);-
92 xor_blocks(W, U, V, 32);-
93 swap_bytes(W, Key);-
94-
95 Gost2814789_set_key(&c->cipher, Key, 256);-
96 Gost2814789_encrypt(H+8, S+8, &c->cipher);-
97-
98-
99 circle_xor8(U, U);-
100 U[31] = ~U[31];-
101 U[29] = ~U[29];-
102 U[28] = ~U[28];-
103 U[24] = ~U[24];-
104 U[23] = ~U[23];-
105 U[20] = ~U[20];-
106 U[18] = ~U[18];-
107 U[17] = ~U[17];-
108 U[14] = ~U[14];-
109 U[12] = ~U[12];-
110 U[10] = ~U[10];-
111 U[8] = ~U[8];-
112 U[7] = ~U[7];-
113 U[5] = ~U[5];-
114 U[3] = ~U[3];-
115 U[1] = ~U[1];-
116 circle_xor8(V, V);-
117 circle_xor8(V, V);-
118 xor_blocks(W, U, V, 32);-
119 swap_bytes(W, Key);-
120-
121 Gost2814789_set_key(&c->cipher, Key, 256);-
122 Gost2814789_encrypt(H+16, S+16, &c->cipher);-
123-
124-
125 circle_xor8(U, U);-
126 circle_xor8(V, V);-
127 circle_xor8(V, V);-
128 xor_blocks(W, U, V, 32);-
129 swap_bytes(W, Key);-
130-
131 Gost2814789_set_key(&c->cipher, Key, 256);-
132 Gost2814789_encrypt(H+24, S+24, &c->cipher);-
133-
134 for (i = 0; i < 12
i < 12Description
TRUEevaluated 76884 times by 3 tests
Evaluated by:
  • evptest
  • gost2814789t
  • tls_prf
FALSEevaluated 6407 times by 3 tests
Evaluated by:
  • evptest
  • gost2814789t
  • tls_prf
; i++)
6407-76884
135 transform_3(S);
executed 76884 times by 3 tests: transform_3(S);
Executed by:
  • evptest
  • gost2814789t
  • tls_prf
76884
136 xor_blocks(S, S, M, 32);-
137 transform_3(S);-
138 xor_blocks(S, S, H, 32);-
139 for (i = 0; i < 61
i < 61Description
TRUEevaluated 390827 times by 3 tests
Evaluated by:
  • evptest
  • gost2814789t
  • tls_prf
FALSEevaluated 6407 times by 3 tests
Evaluated by:
  • evptest
  • gost2814789t
  • tls_prf
; i++)
6407-390827
140 transform_3(S);
executed 390827 times by 3 tests: transform_3(S);
Executed by:
  • evptest
  • gost2814789t
  • tls_prf
390827
141 memcpy(H, S, 32);-
142 return
executed 6407 times by 3 tests: return 1;
Executed by:
  • evptest
  • gost2814789t
  • tls_prf
1;
executed 6407 times by 3 tests: return 1;
Executed by:
  • evptest
  • gost2814789t
  • tls_prf
6407
143}-
144-
145int-
146GOSTR341194_Init(GOSTR341194_CTX *c, int nid)-
147{-
148 memset(c, 0, sizeof(*c));-
149 return
executed 1304 times by 3 tests: return Gost2814789_set_sbox(&c->cipher, nid);
Executed by:
  • evptest
  • gost2814789t
  • tls_prf
Gost2814789_set_sbox(&c->cipher, nid);
executed 1304 times by 3 tests: return Gost2814789_set_sbox(&c->cipher, nid);
Executed by:
  • evptest
  • gost2814789t
  • tls_prf
1304
150}-
151-
152static void-
153GOSTR341194_block_data_order(GOSTR341194_CTX *ctx, const unsigned char *p,-
154 size_t num)-
155{-
156 int i;-
157-
158 for (i = 0; i < num
i < numDescription
TRUEevaluated 3328 times by 1 test
Evaluated by:
  • tls_prf
FALSEevaluated 3328 times by 1 test
Evaluated by:
  • tls_prf
; i++) {
3328
159 hash_step(ctx, ctx->H, p);-
160 add_blocks(32, ctx->S, p);-
161 p += 32;-
162 }
executed 3328 times by 1 test: end of block
Executed by:
  • tls_prf
3328
163}
executed 3328 times by 1 test: end of block
Executed by:
  • tls_prf
3328
164-
165int-
166GOSTR341194_Final(unsigned char *md, GOSTR341194_CTX * c)-
167{-
168 unsigned char *p = (unsigned char *)c->data;-
169 unsigned char T[32];-
170-
171 if (c->num > 0
c->num > 0Description
TRUEevaluated 471 times by 2 tests
Evaluated by:
  • gost2814789t
  • tls_prf
FALSEevaluated 833 times by 2 tests
Evaluated by:
  • evptest
  • tls_prf
) {
471-833
172 memset(p + c->num, 0, 32 - c->num);-
173 hash_step(c, c->H, p);-
174 add_blocks(32, c->S, p);-
175 }
executed 471 times by 2 tests: end of block
Executed by:
  • gost2814789t
  • tls_prf
471
176-
177 p = T;-
178 (*((unsigned int *)(p))=(c->Nl), (p)+=4);-
179 (*((unsigned int *)(p))=(c->Nh), (p)+=4);-
180 memset(p, 0, 32 - 8);-
181 hash_step(c, c->H, T);-
182 hash_step(c, c->H, c->S);-
183-
184 memcpy(md, c->H, 32);-
185-
186 return
executed 1304 times by 3 tests: return 1;
Executed by:
  • evptest
  • gost2814789t
  • tls_prf
1;
executed 1304 times by 3 tests: return 1;
Executed by:
  • evptest
  • gost2814789t
  • tls_prf
1304
187}-
188-
189unsigned char *-
190GOSTR341194(const unsigned char *d, size_t n, unsigned char *md, int nid)-
191{-
192 GOSTR341194_CTX c;-
193 static unsigned char m[32];-
194-
195 if (md ==
md == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
196 ((void *)0)
md == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
197 )-
198 md = m;
never executed: md = m;
0
199 if (!GOSTR341194_Init(&c, nid)
!GOSTR341194_Init(&c, nid)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
200 return
never executed: return 0;
0;
never executed: return 0;
0
201 GOSTR341194_Update(&c, d, n);-
202 GOSTR341194_Final(md, &c);-
203 explicit_bzero(&c, sizeof(c));-
204 return
never executed: return (md);
(md);
never executed: return (md);
0
205}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2