OpenCoverage

f_generic.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/ec/curve448/f_generic.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2static const gf MODULUS = {-
3 {{((0xffffffffffffff) & ((1 << 28) - 1)), ((0xffffffffffffff) >> 28), ((0xffffffffffffff) & ((1 << 28) - 1)), ((0xffffffffffffff) >> 28), ((0xffffffffffffff) & ((1 << 28) - 1)), ((0xffffffffffffff) >> 28), ((0xffffffffffffff) & ((1 << 28) - 1)), ((0xffffffffffffff) >> 28), ((0xfffffffffffffe) & ((1 << 28) - 1)), ((0xfffffffffffffe) >> 28), ((0xffffffffffffff) & ((1 << 28) - 1)), ((0xffffffffffffff) >> 28), ((0xffffffffffffff) & ((1 << 28) - 1)), ((0xffffffffffffff) >> 28), ((0xffffffffffffff) & ((1 << 28) - 1)), ((0xffffffffffffff) >> 28)}}-
4-
5-
6};-
7-
8-
9void gf_serialize(uint8_t serial[56], const gf x, int with_hibit)-
10{-
11 unsigned int j = 0, fill = 0;-
12 dword_t buffer = 0;-
13 int i;-
14 gf red;-
15-
16 gf_copy(red, x);-
17 gf_strong_reduce(red);-
18 if (!with_hibit
!with_hibitDescription
TRUEnever evaluated
FALSEevaluated 1136 times by 2 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
)
0-1136
19 -
20 ((
never executed: ((void) (0)) ;
void) (0))
never executed: ((void) (0)) ;
0
21 ;
never executed: ((void) (0)) ;
0
22-
23 for (i = 0; i < (with_hibit ? 56 : 56)
i < (with_hibit ? 56 : 56)Description
TRUEevaluated 63616 times by 2 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
FALSEevaluated 1136 times by 2 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
; i++) {
1136-63616
24 if (fill < 8
fill < 8Description
TRUEevaluated 18176 times by 2 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
FALSEevaluated 45440 times by 2 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
&& j < (64/sizeof(word_t))
j < (64/sizeof(word_t))Description
TRUEevaluated 18176 times by 2 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
FALSEnever evaluated
) {
0-45440
25 buffer |= ((dword_t) red->limb[(j)]) << fill;-
26 fill += 28;-
27 j++;-
28 }
executed 18176 times by 2 tests: end of block
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
18176
29 serial[i] = (uint8_t)buffer;-
30 fill -= 8;-
31 buffer >>= 8;-
32 }
executed 63616 times by 2 tests: end of block
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
63616
33}
executed 1136 times by 2 tests: end of block
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
1136
34-
35-
36mask_t gf_hibit(const gf x)-
37{-
38 gf y;-
39-
40 gf_add(y, x, x);-
41 gf_strong_reduce(y);-
42 return
never executed: return 0 - (y->limb[0] & 1);
0 - (y->limb[0] & 1);
never executed: return 0 - (y->limb[0] & 1);
0
43}-
44-
45-
46mask_t gf_lobit(const gf x)-
47{-
48 gf y;-
49-
50 gf_copy(y, x);-
51 gf_strong_reduce(y);-
52 return
executed 81 times by 2 tests: return 0 - (y->limb[0] & 1);
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
0 - (y->limb[0] & 1);
executed 81 times by 2 tests: return 0 - (y->limb[0] & 1);
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
81
53}-
54-
55-
56mask_t gf_deserialize(gf x, const uint8_t serial[56], int with_hibit,-
57 uint8_t hi_nmask)-
58{-
59 unsigned int j = 0, fill = 0;-
60 dword_t buffer = 0;-
61 dsword_t scarry = 0;-
62 const unsigned nbytes = with_hibit
with_hibitDescription
TRUEevaluated 1032 times by 2 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
FALSEnever evaluated
? 56 : 56;
0-1032
63 unsigned int i;-
64 mask_t succ;-
65-
66 for (i = 0; i < (64/sizeof(word_t))
i < (64/sizeof(word_t))Description
TRUEevaluated 16512 times by 2 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
FALSEevaluated 1032 times by 2 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
; i++) {
1032-16512
67 while (fill < 28
fill < 28Description
TRUEevaluated 57792 times by 2 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
FALSEevaluated 16512 times by 2 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
&& j < nbytes
j < nbytesDescription
TRUEevaluated 57792 times by 2 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
FALSEnever evaluated
) {
0-57792
68 uint8_t sj;-
69-
70 sj = serial[j];-
71 if (j == nbytes - 1
j == nbytes - 1Description
TRUEevaluated 1032 times by 2 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
FALSEevaluated 56760 times by 2 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
)
1032-56760
72 sj &= ~hi_nmask;
executed 1032 times by 2 tests: sj &= ~hi_nmask;
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
1032
73 buffer |= ((dword_t) sj) << fill;-
74 fill += 8;-
75 j++;-
76 }
executed 57792 times by 2 tests: end of block
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
57792
77 x->limb[(i)] = (word_t)-
78 ((
(i < (64/sizeof(word_t)) - 1)Description
TRUEevaluated 15480 times by 2 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
FALSEevaluated 1032 times by 2 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
i < (64/sizeof(word_t)) - 1)
(i < (64/sizeof(word_t)) - 1)Description
TRUEevaluated 15480 times by 2 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
FALSEevaluated 1032 times by 2 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
? buffer & (((1)<<28)-1) : buffer);
1032-15480
79 fill -= 28;-
80 buffer >>= 28;-
81 scarry =-
82 (scarry + x->limb[(i)] --
83 MODULUS->limb[(i)]) >> (8 * sizeof(word_t));-
84 }
executed 16512 times by 2 tests: end of block
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
16512
85 succ = with_hibit
with_hibitDescription
TRUEevaluated 1032 times by 2 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
FALSEnever evaluated
? 0 - (mask_t) 1 : ~gf_hibit(x);
0-1032
86 return
executed 1032 times by 2 tests: return succ & constant_time_is_zero_32((word_t)buffer) & ~constant_time_is_zero_32((word_t)scarry);
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
succ & constant_time_is_zero_32((word_t)buffer) & ~constant_time_is_zero_32((word_t)scarry);
executed 1032 times by 2 tests: return succ & constant_time_is_zero_32((word_t)buffer) & ~constant_time_is_zero_32((word_t)scarry);
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
1032
87}-
88-
89-
90void gf_strong_reduce(gf a)-
91{-
92 dsword_t scarry;-
93 word_t scarry_0;-
94 dword_t carry = 0;-
95 unsigned int i;-
96-
97-
98 gf_weak_reduce(a);-
99-
100-
101-
102-
103 scarry = 0;-
104 for (i = 0; i < (64/sizeof(word_t))
i < (64/sizeof(word_t))Description
TRUEevaluated 54304 times by 2 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
FALSEevaluated 3394 times by 2 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
; i++) {
3394-54304
105 scarry = scarry + a->limb[(i)] - MODULUS->limb[(i)];-
106 a->limb[(i)] = scarry & (((1)<<28)-1);-
107 scarry >>= 28;-
108 }
executed 54304 times by 2 tests: end of block
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
54304
109-
110-
111-
112-
113-
114-
115 -
116 ((void) (0))-
117 ;-
118-
119 scarry_0 = (word_t)scarry;-
120-
121-
122 for (i = 0; i < (64/sizeof(word_t))
i < (64/sizeof(word_t))Description
TRUEevaluated 54304 times by 2 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
FALSEevaluated 3394 times by 2 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
; i++) {
3394-54304
123 carry =-
124 carry + a->limb[(i)] +-
125 (scarry_0 & MODULUS->limb[(i)]);-
126 a->limb[(i)] = carry & (((1)<<28)-1);-
127 carry >>= 28;-
128 }
executed 54304 times by 2 tests: end of block
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
54304
129-
130 -
131 ((void) (0))-
132 ;-
133}
executed 3394 times by 2 tests: end of block
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
3394
134-
135-
136void gf_sub(gf d, const gf a, const gf b)-
137{-
138 gf_sub_RAW(d, a, b);-
139 gf_bias(d, 2);-
140 gf_weak_reduce(d);-
141}
executed 13765 times by 2 tests: end of block
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
13765
142-
143-
144void gf_add(gf d, const gf a, const gf b)-
145{-
146 gf_add_RAW(d, a, b);-
147 gf_weak_reduce(d);-
148}
executed 536 times by 2 tests: end of block
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
536
149-
150-
151mask_t gf_eq(const gf a, const gf b)-
152{-
153 gf c;-
154 mask_t ret = 0;-
155 unsigned int i;-
156-
157 gf_sub(c, a, b);-
158 gf_strong_reduce(c);-
159-
160 for (i = 0; i < (64/sizeof(word_t))
i < (64/sizeof(word_t))Description
TRUEevaluated 34832 times by 2 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
FALSEevaluated 2177 times by 2 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
; i++)
2177-34832
161 ret |= c->limb[(i)];
executed 34832 times by 2 tests: ret |= c->limb[(i)];
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
34832
162-
163 return
executed 2177 times by 2 tests: return constant_time_is_zero_32(ret);
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
constant_time_is_zero_32(ret);
executed 2177 times by 2 tests: return constant_time_is_zero_32(ret);
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
2177
164}-
165-
166mask_t gf_isr(gf a, const gf x)-
167{-
168 gf L0, L1, L2;-
169-
170 gf_sqr(L1, x);-
171 gf_mul(L2, x, L1);-
172 gf_sqr(L1, L2);-
173 gf_mul(L2, x, L1);-
174 gf_sqrn(L1, L2, 3);-
175 gf_mul(L0, L2, L1);-
176 gf_sqrn(L1, L0, 3);-
177 gf_mul(L0, L2, L1);-
178 gf_sqrn(L2, L0, 9);-
179 gf_mul(L1, L0, L2);-
180 gf_sqr(L0, L1);-
181 gf_mul(L2, x, L0);-
182 gf_sqrn(L0, L2, 18);-
183 gf_mul(L2, L1, L0);-
184 gf_sqrn(L0, L2, 37);-
185 gf_mul(L1, L2, L0);-
186 gf_sqrn(L0, L1, 37);-
187 gf_mul(L1, L2, L0);-
188 gf_sqrn(L0, L1, 111);-
189 gf_mul(L2, L1, L0);-
190 gf_sqr(L0, L2);-
191 gf_mul(L1, x, L0);-
192 gf_sqrn(L0, L1, 223);-
193 gf_mul(L1, L2, L0);-
194 gf_sqr(L2, L1);-
195 gf_mul(L0, L2, x);-
196 gf_copy(a, L1);-
197 return
executed 1154 times by 2 tests: return gf_eq(L0, ONE);
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
gf_eq(L0, ONE);
executed 1154 times by 2 tests: return gf_eq(L0, ONE);
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
1154
198}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2