Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/bn/bn_lib.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | static int bn_limit_bits = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
2 | static int bn_limit_num = 8; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
3 | static int bn_limit_bits_low = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
4 | static int bn_limit_num_low = 8; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
5 | static int bn_limit_bits_high = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
6 | static int bn_limit_num_high = 8; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
7 | static int bn_limit_bits_mont = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
8 | static int bn_limit_num_mont = 8; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
9 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
10 | void BN_set_params(int mult, int high, int low, int mont) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
11 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
12 | if (mult >= 0
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
13 | if (mult > (int)(sizeof(int) * 8) - 1
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
14 | mult = sizeof(int) * 8 - 1; never executed: mult = sizeof(int) * 8 - 1; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
15 | bn_limit_bits = mult; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
16 | bn_limit_num = 1 << mult; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
17 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
18 | if (high >= 0
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
19 | if (high > (int)(sizeof(int) * 8) - 1
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
20 | high = sizeof(int) * 8 - 1; never executed: high = sizeof(int) * 8 - 1; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
21 | bn_limit_bits_high = high; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
22 | bn_limit_num_high = 1 << high; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
23 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
24 | if (low >= 0
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
25 | if (low > (int)(sizeof(int) * 8) - 1
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
26 | low = sizeof(int) * 8 - 1; never executed: low = sizeof(int) * 8 - 1; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
27 | bn_limit_bits_low = low; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
28 | bn_limit_num_low = 1 << low; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
29 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
30 | if (mont >= 0
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
31 | if (mont > (int)(sizeof(int) * 8) - 1
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
32 | mont = sizeof(int) * 8 - 1; never executed: mont = sizeof(int) * 8 - 1; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
33 | bn_limit_bits_mont = mont; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
34 | bn_limit_num_mont = 1 << mont; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
35 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
36 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
37 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
38 | int BN_get_params(int which) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
39 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
40 | if (which == 0
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
41 | return never executed: bn_limit_bits;return bn_limit_bits; never executed: return bn_limit_bits; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
42 | else if (which == 1
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
43 | return never executed: bn_limit_bits_high;return bn_limit_bits_high; never executed: return bn_limit_bits_high; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
44 | else if (which == 2
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
45 | return never executed: bn_limit_bits_low;return bn_limit_bits_low; never executed: return bn_limit_bits_low; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
46 | else if (which == 3
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
47 | return never executed: bn_limit_bits_mont;return bn_limit_bits_mont; never executed: return bn_limit_bits_mont; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
48 | else | - | ||||||||||||||||||||||||||||||||||||||||||||||||
49 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
50 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
51 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
52 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
53 | const BIGNUM *BN_value_one(void) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
54 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
55 | static const unsigned long data_one = 1L; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
56 | static const BIGNUM const_one = | - | ||||||||||||||||||||||||||||||||||||||||||||||||
57 | { (unsigned long *)&data_one, 1, 1, 0, 0x02 }; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
58 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
59 | return executed 167455 times by 2 tests: &const_one;return &const_one; Executed by:
executed 167455 times by 2 tests: return &const_one; Executed by:
| 167455 | ||||||||||||||||||||||||||||||||||||||||||||||||
60 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
61 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
62 | int BN_num_bits_word(unsigned long l) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
63 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
64 | unsigned long x, mask; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
65 | int bits = (l != 0); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
66 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
67 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
68 | x = l >> 32; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
69 | mask = (0 - x) & (0xffffffffffffffffL); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
70 | mask = (0 - (mask >> ((8 * 8) - 1))); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
71 | bits += 32 & mask; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
72 | l ^= (x ^ l) & mask; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
73 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
74 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
75 | x = l >> 16; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
76 | mask = (0 - x) & (0xffffffffffffffffL); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
77 | mask = (0 - (mask >> ((8 * 8) - 1))); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
78 | bits += 16 & mask; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
79 | l ^= (x ^ l) & mask; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
80 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
81 | x = l >> 8; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
82 | mask = (0 - x) & (0xffffffffffffffffL); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
83 | mask = (0 - (mask >> ((8 * 8) - 1))); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
84 | bits += 8 & mask; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
85 | l ^= (x ^ l) & mask; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
86 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
87 | x = l >> 4; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
88 | mask = (0 - x) & (0xffffffffffffffffL); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
89 | mask = (0 - (mask >> ((8 * 8) - 1))); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
90 | bits += 4 & mask; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
91 | l ^= (x ^ l) & mask; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
92 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
93 | x = l >> 2; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
94 | mask = (0 - x) & (0xffffffffffffffffL); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
95 | mask = (0 - (mask >> ((8 * 8) - 1))); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
96 | bits += 2 & mask; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
97 | l ^= (x ^ l) & mask; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
98 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
99 | x = l >> 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
100 | mask = (0 - x) & (0xffffffffffffffffL); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
101 | mask = (0 - (mask >> ((8 * 8) - 1))); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
102 | bits += 1 & mask; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
103 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
104 | return executed 27251278 times by 2 tests: bits;return bits; Executed by:
executed 27251278 times by 2 tests: return bits; Executed by:
| 27251278 | ||||||||||||||||||||||||||||||||||||||||||||||||
105 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
106 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
107 | int BN_num_bits(const BIGNUM *a) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
108 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
109 | int i = a->top - 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
110 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
111 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
112 | if (BN_is_zero(a)
| 11962-23356888 | ||||||||||||||||||||||||||||||||||||||||||||||||
113 | return executed 11962 times by 1 test: 0;return 0; Executed by:
executed 11962 times by 1 test: return 0; Executed by:
| 11962 | ||||||||||||||||||||||||||||||||||||||||||||||||
114 | return executed 23356888 times by 2 tests: ((i * (8 * 8)) + BN_num_bits_word(a->d[i]));return ((i * (8 * 8)) + BN_num_bits_word(a->d[i])); Executed by:
executed 23356888 times by 2 tests: return ((i * (8 * 8)) + BN_num_bits_word(a->d[i])); Executed by:
| 23356888 | ||||||||||||||||||||||||||||||||||||||||||||||||
115 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
116 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
117 | static void bn_free_d(BIGNUM *a) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
118 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
119 | if (BN_get_flags(a, 0x08)
| 74763-4855179 | ||||||||||||||||||||||||||||||||||||||||||||||||
120 | CRYPTO_secure_free(a->d, __FILE__, 148); executed 74763 times by 2 tests: CRYPTO_secure_free(a->d, __FILE__, 148); Executed by:
| 74763 | ||||||||||||||||||||||||||||||||||||||||||||||||
121 | else | - | ||||||||||||||||||||||||||||||||||||||||||||||||
122 | CRYPTO_free(a->d, __FILE__, 150); executed 4855179 times by 2 tests: CRYPTO_free(a->d, __FILE__, 150); Executed by:
| 4855179 | ||||||||||||||||||||||||||||||||||||||||||||||||
123 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
124 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
125 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
126 | void BN_clear_free(BIGNUM *a) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
127 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
128 | if (a ==
| 346187-1926437 | ||||||||||||||||||||||||||||||||||||||||||||||||
129 | ((void *)0)
| 346187-1926437 | ||||||||||||||||||||||||||||||||||||||||||||||||
130 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
131 | return; executed 346187 times by 2 tests: return; Executed by:
| 346187 | ||||||||||||||||||||||||||||||||||||||||||||||||
132 | if (a->d !=
| 162605-1763832 | ||||||||||||||||||||||||||||||||||||||||||||||||
133 | ((void *)0)
| 162605-1763832 | ||||||||||||||||||||||||||||||||||||||||||||||||
134 | && !BN_get_flags(a, 0x02)
| 2-1763830 | ||||||||||||||||||||||||||||||||||||||||||||||||
135 | OPENSSL_cleanse(a->d, a->dmax * sizeof(a->d[0])); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
136 | bn_free_d(a); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
137 | } executed 1763830 times by 2 tests: end of block Executed by:
| 1763830 | ||||||||||||||||||||||||||||||||||||||||||||||||
138 | if (BN_get_flags(a, 0x01)
| 198408-1728029 | ||||||||||||||||||||||||||||||||||||||||||||||||
139 | OPENSSL_cleanse(a, sizeof(*a)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
140 | CRYPTO_free(a, __FILE__, 164); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
141 | } executed 198408 times by 2 tests: end of block Executed by:
| 198408 | ||||||||||||||||||||||||||||||||||||||||||||||||
142 | } executed 1926437 times by 2 tests: end of block Executed by:
| 1926437 | ||||||||||||||||||||||||||||||||||||||||||||||||
143 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
144 | void BN_free(BIGNUM *a) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
145 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
146 | if (a ==
| 325716-1181122 | ||||||||||||||||||||||||||||||||||||||||||||||||
147 | ((void *)0)
| 325716-1181122 | ||||||||||||||||||||||||||||||||||||||||||||||||
148 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
149 | return; executed 325716 times by 2 tests: return; Executed by:
| 325716 | ||||||||||||||||||||||||||||||||||||||||||||||||
150 | if (!BN_get_flags(a, 0x02)
| 4455-1176667 | ||||||||||||||||||||||||||||||||||||||||||||||||
151 | bn_free_d(a); executed 1176667 times by 2 tests: bn_free_d(a); Executed by:
| 1176667 | ||||||||||||||||||||||||||||||||||||||||||||||||
152 | if (a->flags & 0x01
| 1156-1179966 | ||||||||||||||||||||||||||||||||||||||||||||||||
153 | CRYPTO_free(a, __FILE__, 175); executed 1179966 times by 2 tests: CRYPTO_free(a, __FILE__, 175); Executed by:
| 1179966 | ||||||||||||||||||||||||||||||||||||||||||||||||
154 | } executed 1181122 times by 2 tests: end of block Executed by:
| 1181122 | ||||||||||||||||||||||||||||||||||||||||||||||||
155 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
156 | void bn_init(BIGNUM *a) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
157 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
158 | static BIGNUM nilbn; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
159 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
160 | *a = nilbn; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
161 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
162 | } executed 5213480 times by 2 tests: end of block Executed by:
| 5213480 | ||||||||||||||||||||||||||||||||||||||||||||||||
163 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
164 | BIGNUM *BN_new(void) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
165 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
166 | BIGNUM *ret; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
167 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
168 | if ((
| 0-1378374 | ||||||||||||||||||||||||||||||||||||||||||||||||
169 | ((void *)0)
| 0-1378374 | ||||||||||||||||||||||||||||||||||||||||||||||||
170 | ) { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
171 | ERR_put_error(3,(113),((1|64)),__FILE__,191); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
172 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
173 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
174 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
175 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
176 | ret->flags = 0x01; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
177 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
178 | return executed 1378374 times by 2 tests: ret;return ret; Executed by:
executed 1378374 times by 2 tests: return ret; Executed by:
| 1378374 | ||||||||||||||||||||||||||||||||||||||||||||||||
179 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
180 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
181 | BIGNUM *BN_secure_new(void) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
182 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
183 | BIGNUM *ret = BN_new(); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
184 | if (ret !=
| 0-75262 | ||||||||||||||||||||||||||||||||||||||||||||||||
185 | ((void *)0)
| 0-75262 | ||||||||||||||||||||||||||||||||||||||||||||||||
186 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
187 | ret->flags |= 0x08; executed 75262 times by 1 test: ret->flags |= 0x08; Executed by:
| 75262 | ||||||||||||||||||||||||||||||||||||||||||||||||
188 | return executed 75262 times by 1 test: ret;return ret; Executed by:
executed 75262 times by 1 test: return ret; Executed by:
| 75262 | ||||||||||||||||||||||||||||||||||||||||||||||||
189 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
190 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
191 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
192 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
193 | static unsigned long *bn_expand_internal(const BIGNUM *b, int words) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
194 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
195 | unsigned long *a = | - | ||||||||||||||||||||||||||||||||||||||||||||||||
196 | ((void *)0) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
197 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
198 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
199 | if (words > (0x7fffffff / (4 * (8 * 8)))
| 3-4889508 | ||||||||||||||||||||||||||||||||||||||||||||||||
200 | ERR_put_error(3,(120),(114),__FILE__,214); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
201 | return executed 3 times by 1 test: return ((void *)0) ; Executed by:
executed 3 times by 1 test: return ((void *)0) ; Executed by:
| 3 | ||||||||||||||||||||||||||||||||||||||||||||||||
202 | ((void *)0) executed 3 times by 1 test: return ((void *)0) ; Executed by:
| 3 | ||||||||||||||||||||||||||||||||||||||||||||||||
203 | ; executed 3 times by 1 test: return ((void *)0) ; Executed by:
| 3 | ||||||||||||||||||||||||||||||||||||||||||||||||
204 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
205 | if (BN_get_flags(b, 0x02)
| 0-4889508 | ||||||||||||||||||||||||||||||||||||||||||||||||
206 | ERR_put_error(3,(120),(105),__FILE__,218); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
207 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
208 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
209 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
210 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
211 | if (BN_get_flags(b, 0x08)
| 74760-4814748 | ||||||||||||||||||||||||||||||||||||||||||||||||
212 | a = CRYPTO_secure_zalloc(words * sizeof(*a), __FILE__, 222); executed 74760 times by 2 tests: a = CRYPTO_secure_zalloc(words * sizeof(*a), __FILE__, 222); Executed by:
| 74760 | ||||||||||||||||||||||||||||||||||||||||||||||||
213 | else | - | ||||||||||||||||||||||||||||||||||||||||||||||||
214 | a = CRYPTO_zalloc(words * sizeof(*a), __FILE__, 224); executed 4814748 times by 2 tests: a = CRYPTO_zalloc(words * sizeof(*a), __FILE__, 224); Executed by:
| 4814748 | ||||||||||||||||||||||||||||||||||||||||||||||||
215 | if (a ==
| 0-4889508 | ||||||||||||||||||||||||||||||||||||||||||||||||
216 | ((void *)0)
| 0-4889508 | ||||||||||||||||||||||||||||||||||||||||||||||||
217 | ) { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
218 | ERR_put_error(3,(120),((1|64)),__FILE__,226); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
219 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
220 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
221 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
222 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
223 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
224 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
225 | ((void) (0)) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
226 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
227 | if (b->top > 0
| 430883-4458625 | ||||||||||||||||||||||||||||||||||||||||||||||||
228 | memcpy(a, b->d, sizeof(*a) * b->top); executed 430883 times by 2 tests: memcpy(a, b->d, sizeof(*a) * b->top); Executed by:
| 430883 | ||||||||||||||||||||||||||||||||||||||||||||||||
229 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
230 | return executed 4889508 times by 2 tests: a;return a; Executed by:
executed 4889508 times by 2 tests: return a; Executed by:
| 4889508 | ||||||||||||||||||||||||||||||||||||||||||||||||
231 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
232 | BIGNUM *bn_expand2(BIGNUM *b, int words) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
233 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
234 | if (words > b->dmax
| 0-4889511 | ||||||||||||||||||||||||||||||||||||||||||||||||
235 | unsigned long *a = bn_expand_internal(b, words); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
236 | if (!a
| 3-4889508 | ||||||||||||||||||||||||||||||||||||||||||||||||
237 | return executed 3 times by 1 test: return ((void *)0) ; Executed by:
executed 3 times by 1 test: return ((void *)0) ; Executed by:
| 3 | ||||||||||||||||||||||||||||||||||||||||||||||||
238 | ((void *)0) executed 3 times by 1 test: return ((void *)0) ; Executed by:
| 3 | ||||||||||||||||||||||||||||||||||||||||||||||||
239 | ; executed 3 times by 1 test: return ((void *)0) ; Executed by:
| 3 | ||||||||||||||||||||||||||||||||||||||||||||||||
240 | if (b->d
| 1989445-2900063 | ||||||||||||||||||||||||||||||||||||||||||||||||
241 | OPENSSL_cleanse(b->d, b->dmax * sizeof(b->d[0])); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
242 | bn_free_d(b); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
243 | } executed 1989445 times by 2 tests: end of block Executed by:
| 1989445 | ||||||||||||||||||||||||||||||||||||||||||||||||
244 | b->d = a; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
245 | b->dmax = words; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
246 | } executed 4889508 times by 2 tests: end of block Executed by:
| 4889508 | ||||||||||||||||||||||||||||||||||||||||||||||||
247 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
248 | return executed 4889508 times by 2 tests: b;return b; Executed by:
executed 4889508 times by 2 tests: return b; Executed by:
| 4889508 | ||||||||||||||||||||||||||||||||||||||||||||||||
249 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
250 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
251 | BIGNUM *BN_dup(const BIGNUM *a) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
252 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
253 | BIGNUM *t; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
254 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
255 | if (a ==
| 0-46612 | ||||||||||||||||||||||||||||||||||||||||||||||||
256 | ((void *)0)
| 0-46612 | ||||||||||||||||||||||||||||||||||||||||||||||||
257 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
258 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
259 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
260 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
261 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
262 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
263 | t = BN_get_flags(a, 0x08)
| 1-46611 | ||||||||||||||||||||||||||||||||||||||||||||||||
264 | if (t ==
| 0-46612 | ||||||||||||||||||||||||||||||||||||||||||||||||
265 | ((void *)0)
| 0-46612 | ||||||||||||||||||||||||||||||||||||||||||||||||
266 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
267 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
268 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
269 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
270 | if (!BN_copy(t, a)
| 0-46612 | ||||||||||||||||||||||||||||||||||||||||||||||||
271 | BN_free(t); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
272 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
273 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
274 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
275 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
276 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
277 | return executed 46612 times by 2 tests: t;return t; Executed by:
executed 46612 times by 2 tests: return t; Executed by:
| 46612 | ||||||||||||||||||||||||||||||||||||||||||||||||
278 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
279 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
280 | BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
281 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
282 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
283 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
284 | if (a == b
| 1712-3248124 | ||||||||||||||||||||||||||||||||||||||||||||||||
285 | return executed 1712 times by 1 test: a;return a; Executed by:
executed 1712 times by 1 test: return a; Executed by:
| 1712 | ||||||||||||||||||||||||||||||||||||||||||||||||
286 | if (bn_wexpand(a, b->top) ==
| 0-3248124 | ||||||||||||||||||||||||||||||||||||||||||||||||
287 | ((void *)0)
| 0-3248124 | ||||||||||||||||||||||||||||||||||||||||||||||||
288 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
289 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
290 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
291 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
292 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
293 | if (b->top > 0
| 79989-3168135 | ||||||||||||||||||||||||||||||||||||||||||||||||
294 | memcpy(a->d, b->d, sizeof(b->d[0]) * b->top); executed 3168135 times by 2 tests: memcpy(a->d, b->d, sizeof(b->d[0]) * b->top); Executed by:
| 3168135 | ||||||||||||||||||||||||||||||||||||||||||||||||
295 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
296 | a->neg = b->neg; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
297 | a->top = b->top; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
298 | a->flags |= b->flags & 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
299 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
300 | return executed 3248124 times by 2 tests: a;return a; Executed by:
executed 3248124 times by 2 tests: return a; Executed by:
| 3248124 | ||||||||||||||||||||||||||||||||||||||||||||||||
301 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
302 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
303 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
304 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
305 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
306 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
307 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
308 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
309 | void BN_swap(BIGNUM *a, BIGNUM *b) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
310 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
311 | int flags_old_a, flags_old_b; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
312 | unsigned long *tmp_d; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
313 | int tmp_top, tmp_dmax, tmp_neg; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
314 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
315 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
316 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
317 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
318 | flags_old_a = a->flags; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
319 | flags_old_b = b->flags; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
320 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
321 | tmp_d = a->d; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
322 | tmp_top = a->top; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
323 | tmp_dmax = a->dmax; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
324 | tmp_neg = a->neg; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
325 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
326 | a->d = b->d; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
327 | a->top = b->top; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
328 | a->dmax = b->dmax; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
329 | a->neg = b->neg; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
330 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
331 | b->d = tmp_d; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
332 | b->top = tmp_top; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
333 | b->dmax = tmp_dmax; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
334 | b->neg = tmp_neg; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
335 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
336 | a->flags = ((flags_old_a) & (0x01)) | ((flags_old_b) & (0x02 | 0x04 | 0x08 | 0)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
337 | b->flags = ((flags_old_b) & (0x01)) | ((flags_old_a) & (0x02 | 0x04 | 0x08 | 0)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
338 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
339 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
340 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||||||||||||||||||||||||||||||||||||||
341 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
342 | void BN_clear(BIGNUM *a) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
343 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
344 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
345 | if (a->d !=
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
346 | ((void *)0)
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
347 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
348 | OPENSSL_cleanse(a->d, sizeof(*a->d) * a->dmax); never executed: OPENSSL_cleanse(a->d, sizeof(*a->d) * a->dmax); | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
349 | a->neg = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
350 | a->top = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
351 | a->flags &= ~0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
352 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
353 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
354 | unsigned long BN_get_word(const BIGNUM *a) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
355 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
356 | if (a->top > 1
| 582-879 | ||||||||||||||||||||||||||||||||||||||||||||||||
357 | return executed 582 times by 1 test: (0xffffffffffffffffL);return (0xffffffffffffffffL); Executed by:
executed 582 times by 1 test: return (0xffffffffffffffffL); Executed by:
| 582 | ||||||||||||||||||||||||||||||||||||||||||||||||
358 | else if (a->top == 1
| 3-876 | ||||||||||||||||||||||||||||||||||||||||||||||||
359 | return executed 876 times by 1 test: a->d[0];return a->d[0]; Executed by:
executed 876 times by 1 test: return a->d[0]; Executed by:
| 876 | ||||||||||||||||||||||||||||||||||||||||||||||||
360 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
361 | return executed 3 times by 1 test: 0;return 0; Executed by:
executed 3 times by 1 test: return 0; Executed by:
| 3 | ||||||||||||||||||||||||||||||||||||||||||||||||
362 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
363 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
364 | int BN_set_word(BIGNUM *a, unsigned long w) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
365 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
366 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
367 | if (bn_expand(a, (int)sizeof(unsigned long) * 8) ==
| 0-97681932 | ||||||||||||||||||||||||||||||||||||||||||||||||
368 | ((void *)0)
| 0-97681932 | ||||||||||||||||||||||||||||||||||||||||||||||||
369 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
370 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
371 | a->neg = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
372 | a->d[0] = w; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
373 | a->top = (w
| 174034-97507898 | ||||||||||||||||||||||||||||||||||||||||||||||||
374 | a->flags &= ~0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
375 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
376 | return executed 97681932 times by 2 tests: 1;return 1; Executed by:
executed 97681932 times by 2 tests: return 1; Executed by:
| 97681932 | ||||||||||||||||||||||||||||||||||||||||||||||||
377 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
378 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
379 | BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
380 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
381 | unsigned int i, m; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
382 | unsigned int n; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
383 | unsigned long l; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
384 | BIGNUM *bn = | - | ||||||||||||||||||||||||||||||||||||||||||||||||
385 | ((void *)0) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
386 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
387 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
388 | if (ret ==
| 228973-323799 | ||||||||||||||||||||||||||||||||||||||||||||||||
389 | ((void *)0)
| 228973-323799 | ||||||||||||||||||||||||||||||||||||||||||||||||
390 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
391 | ret = bn = BN_new(); executed 228973 times by 2 tests: ret = bn = BN_new(); Executed by:
| 228973 | ||||||||||||||||||||||||||||||||||||||||||||||||
392 | if (ret ==
| 0-552772 | ||||||||||||||||||||||||||||||||||||||||||||||||
393 | ((void *)0)
| 0-552772 | ||||||||||||||||||||||||||||||||||||||||||||||||
394 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
395 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
396 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
397 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
398 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
399 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
400 | for ( ; len > 0
| 11110-1060628 | ||||||||||||||||||||||||||||||||||||||||||||||||
401 | continue; executed 518966 times by 2 tests: continue; Executed by:
| 518966 | ||||||||||||||||||||||||||||||||||||||||||||||||
402 | n = len; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
403 | if (n == 0
| 11107-541665 | ||||||||||||||||||||||||||||||||||||||||||||||||
404 | ret->top = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
405 | return executed 11107 times by 1 test: ret;return ret; Executed by:
executed 11107 times by 1 test: return ret; Executed by:
| 11107 | ||||||||||||||||||||||||||||||||||||||||||||||||
406 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
407 | i = ((n - 1) / 8) + 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
408 | m = ((n - 1) % (8)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
409 | if (bn_wexpand(ret, (int)i) ==
| 3-541662 | ||||||||||||||||||||||||||||||||||||||||||||||||
410 | ((void *)0)
| 3-541662 | ||||||||||||||||||||||||||||||||||||||||||||||||
411 | ) { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
412 | BN_free(bn); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
413 | return executed 3 times by 1 test: return ((void *)0) ; Executed by:
executed 3 times by 1 test: return ((void *)0) ; Executed by:
| 3 | ||||||||||||||||||||||||||||||||||||||||||||||||
414 | ((void *)0) executed 3 times by 1 test: return ((void *)0) ; Executed by:
| 3 | ||||||||||||||||||||||||||||||||||||||||||||||||
415 | ; executed 3 times by 1 test: return ((void *)0) ; Executed by:
| 3 | ||||||||||||||||||||||||||||||||||||||||||||||||
416 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
417 | ret->top = i; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
418 | ret->neg = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
419 | l = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
420 | while (n--
| 541662-28215531 | ||||||||||||||||||||||||||||||||||||||||||||||||
421 | l = (l << 8L) | *(s++); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
422 | if (m-- == 0
| 3668371-24547160 | ||||||||||||||||||||||||||||||||||||||||||||||||
423 | ret->d[--i] = l; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
424 | l = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
425 | m = 8 - 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
426 | } executed 3668371 times by 2 tests: end of block Executed by:
| 3668371 | ||||||||||||||||||||||||||||||||||||||||||||||||
427 | } executed 28215531 times by 2 tests: end of block Executed by:
| 28215531 | ||||||||||||||||||||||||||||||||||||||||||||||||
428 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
429 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
430 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
431 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
432 | bn_correct_top(ret); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
433 | return executed 541662 times by 2 tests: ret;return ret; Executed by:
executed 541662 times by 2 tests: return ret; Executed by:
| 541662 | ||||||||||||||||||||||||||||||||||||||||||||||||
434 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
435 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
436 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
437 | static int bn2binpad(const BIGNUM *a, unsigned char *to, int tolen) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
438 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
439 | int n; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
440 | size_t i, lasti, j, atop, mask; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
441 | unsigned long l; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
442 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
443 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
444 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
445 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
446 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
447 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
448 | n = ((BN_num_bits(a)+7)/8); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
449 | if (tolen == -1
| 6501-60919 | ||||||||||||||||||||||||||||||||||||||||||||||||
450 | tolen = n; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
451 | } executed 60919 times by 2 tests: else if (tolen < nend of block Executed by:
| 78-60919 | ||||||||||||||||||||||||||||||||||||||||||||||||
452 | BIGNUM temp = *a; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
453 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
454 | bn_correct_top(&temp); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
455 | n = ((BN_num_bits(&temp)+7)/8); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
456 | if (tolen < n
| 0-78 | ||||||||||||||||||||||||||||||||||||||||||||||||
457 | return executed 78 times by 1 test: -1;return -1; Executed by:
executed 78 times by 1 test: return -1; Executed by:
| 78 | ||||||||||||||||||||||||||||||||||||||||||||||||
458 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
459 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
460 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
461 | atop = a->dmax * 8; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
462 | if (atop == 0
| 807-66535 | ||||||||||||||||||||||||||||||||||||||||||||||||
463 | OPENSSL_cleanse(to, tolen); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
464 | return executed 807 times by 1 test: tolen;return tolen; Executed by:
executed 807 times by 1 test: return tolen; Executed by:
| 807 | ||||||||||||||||||||||||||||||||||||||||||||||||
465 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
466 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
467 | lasti = atop - 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
468 | atop = a->top * 8; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
469 | for (i = 0, j = 0, to += tolen; j < (size_t)tolen
| 66535-3658384 | ||||||||||||||||||||||||||||||||||||||||||||||||
470 | l = a->d[i / 8]; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
471 | mask = 0 - ((j - atop) >> (8 * sizeof(i) - 1)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
472 | *--to = (unsigned char)(l >> (8 * (i % 8)) & mask); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
473 | i += (i - lasti) >> (8 * sizeof(i) - 1); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
474 | } executed 3658384 times by 2 tests: end of block Executed by:
| 3658384 | ||||||||||||||||||||||||||||||||||||||||||||||||
475 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
476 | return executed 66535 times by 2 tests: tolen;return tolen; Executed by:
executed 66535 times by 2 tests: return tolen; Executed by:
| 66535 | ||||||||||||||||||||||||||||||||||||||||||||||||
477 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
478 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
479 | int BN_bn2binpad(const BIGNUM *a, unsigned char *to, int tolen) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
480 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
481 | if (tolen < 0
| 0-6501 | ||||||||||||||||||||||||||||||||||||||||||||||||
482 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
483 | return executed 6501 times by 2 tests: bn2binpad(a, to, tolen);return bn2binpad(a, to, tolen); Executed by:
executed 6501 times by 2 tests: return bn2binpad(a, to, tolen); Executed by:
| 6501 | ||||||||||||||||||||||||||||||||||||||||||||||||
484 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
485 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
486 | int BN_bn2bin(const BIGNUM *a, unsigned char *to) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
487 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
488 | return executed 60919 times by 2 tests: bn2binpad(a, to, -1);return bn2binpad(a, to, -1); Executed by:
executed 60919 times by 2 tests: return bn2binpad(a, to, -1); Executed by:
| 60919 | ||||||||||||||||||||||||||||||||||||||||||||||||
489 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
490 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
491 | BIGNUM *BN_lebin2bn(const unsigned char *s, int len, BIGNUM *ret) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
492 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
493 | unsigned int i, m; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
494 | unsigned int n; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
495 | unsigned long l; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
496 | BIGNUM *bn = | - | ||||||||||||||||||||||||||||||||||||||||||||||||
497 | ((void *)0) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
498 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
499 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
500 | if (ret ==
| 0-15 | ||||||||||||||||||||||||||||||||||||||||||||||||
501 | ((void *)0)
| 0-15 | ||||||||||||||||||||||||||||||||||||||||||||||||
502 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
503 | ret = bn = BN_new(); executed 15 times by 1 test: ret = bn = BN_new(); Executed by:
| 15 | ||||||||||||||||||||||||||||||||||||||||||||||||
504 | if (ret ==
| 0-15 | ||||||||||||||||||||||||||||||||||||||||||||||||
505 | ((void *)0)
| 0-15 | ||||||||||||||||||||||||||||||||||||||||||||||||
506 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
507 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
508 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
509 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
510 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
511 | s += len; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
512 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
513 | for ( ; len > 0
| 0-15 | ||||||||||||||||||||||||||||||||||||||||||||||||
514 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
515 | n = len; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
516 | if (n == 0
| 0-15 | ||||||||||||||||||||||||||||||||||||||||||||||||
517 | ret->top = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
518 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
519 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
520 | i = ((n - 1) / 8) + 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
521 | m = ((n - 1) % (8)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
522 | if (bn_wexpand(ret, (int)i) ==
| 0-15 | ||||||||||||||||||||||||||||||||||||||||||||||||
523 | ((void *)0)
| 0-15 | ||||||||||||||||||||||||||||||||||||||||||||||||
524 | ) { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
525 | BN_free(bn); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
526 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
527 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
528 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
529 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
530 | ret->top = i; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
531 | ret->neg = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
532 | l = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
533 | while (n--
| 15-1404 | ||||||||||||||||||||||||||||||||||||||||||||||||
534 | s--; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
535 | l = (l << 8L) | *s; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
536 | if (m-- == 0
| 177-1227 | ||||||||||||||||||||||||||||||||||||||||||||||||
537 | ret->d[--i] = l; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
538 | l = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
539 | m = 8 - 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
540 | } executed 177 times by 1 test: end of block Executed by:
| 177 | ||||||||||||||||||||||||||||||||||||||||||||||||
541 | } executed 1404 times by 1 test: end of block Executed by:
| 1404 | ||||||||||||||||||||||||||||||||||||||||||||||||
542 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
543 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
544 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
545 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
546 | bn_correct_top(ret); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
547 | return executed 15 times by 1 test: ret;return ret; Executed by:
executed 15 times by 1 test: return ret; Executed by:
| 15 | ||||||||||||||||||||||||||||||||||||||||||||||||
548 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
549 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
550 | int BN_bn2lebinpad(const BIGNUM *a, unsigned char *to, int tolen) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
551 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
552 | int i; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
553 | unsigned long l; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
554 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
555 | i = ((BN_num_bits(a)+7)/8); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
556 | if (tolen < i
| 0-24 | ||||||||||||||||||||||||||||||||||||||||||||||||
557 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
558 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
559 | if (tolen > i
| 4-20 | ||||||||||||||||||||||||||||||||||||||||||||||||
560 | memset(to + i, 0, tolen - i); executed 4 times by 1 test: memset(to + i, 0, tolen - i); Executed by:
| 4 | ||||||||||||||||||||||||||||||||||||||||||||||||
561 | to += i; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
562 | while (i--
| 24-1884 | ||||||||||||||||||||||||||||||||||||||||||||||||
563 | l = a->d[i / 8]; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
564 | to--; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
565 | *to = (unsigned char)(l >> (8 * (i % 8))) & 0xff; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
566 | } executed 1884 times by 1 test: end of block Executed by:
| 1884 | ||||||||||||||||||||||||||||||||||||||||||||||||
567 | return executed 24 times by 1 test: tolen;return tolen; Executed by:
executed 24 times by 1 test: return tolen; Executed by:
| 24 | ||||||||||||||||||||||||||||||||||||||||||||||||
568 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
569 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
570 | int BN_ucmp(const BIGNUM *a, const BIGNUM *b) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
571 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
572 | int i; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
573 | unsigned long t1, t2, *ap, *bp; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
574 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
575 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
576 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
577 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
578 | i = a->top - b->top; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
579 | if (i != 0
| 5553445-17957942 | ||||||||||||||||||||||||||||||||||||||||||||||||
580 | return executed 5553445 times by 2 tests: i;return i; Executed by:
executed 5553445 times by 2 tests: return i; Executed by:
| 5553445 | ||||||||||||||||||||||||||||||||||||||||||||||||
581 | ap = a->d; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
582 | bp = b->d; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
583 | for (i = a->top - 1; i >= 0
| 277374-18873871 | ||||||||||||||||||||||||||||||||||||||||||||||||
584 | t1 = ap[i]; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
585 | t2 = bp[i]; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
586 | if (t1 != t2
| 1193303-17680568 | ||||||||||||||||||||||||||||||||||||||||||||||||
587 | return executed 17680568 times by 2 tests: ((return ((t1 > t2) ? 1 : -1); Executed by:
executed 17680568 times by 2 tests: return ((t1 > t2) ? 1 : -1); Executed by:
| 5030131-17680568 | ||||||||||||||||||||||||||||||||||||||||||||||||
588 | } executed 1193303 times by 2 tests: end of block Executed by:
| 1193303 | ||||||||||||||||||||||||||||||||||||||||||||||||
589 | return executed 277374 times by 2 tests: 0;return 0; Executed by:
executed 277374 times by 2 tests: return 0; Executed by:
| 277374 | ||||||||||||||||||||||||||||||||||||||||||||||||
590 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
591 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
592 | int BN_cmp(const BIGNUM *a, const BIGNUM *b) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
593 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
594 | int i; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
595 | int gt, lt; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
596 | unsigned long t1, t2; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
597 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
598 | if ((
| 3-3486604 | ||||||||||||||||||||||||||||||||||||||||||||||||
599 | ((void *)0)
| 3-3486604 | ||||||||||||||||||||||||||||||||||||||||||||||||
600 | )
| 3-3486604 | ||||||||||||||||||||||||||||||||||||||||||||||||
601 | ((void *)0)
| 3-3486601 | ||||||||||||||||||||||||||||||||||||||||||||||||
602 | )
| 3-3486601 | ||||||||||||||||||||||||||||||||||||||||||||||||
603 | if (a !=
| 3 | ||||||||||||||||||||||||||||||||||||||||||||||||
604 | ((void *)0)
| 3 | ||||||||||||||||||||||||||||||||||||||||||||||||
605 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
606 | return executed 3 times by 1 test: -1;return -1; Executed by:
executed 3 times by 1 test: return -1; Executed by:
| 3 | ||||||||||||||||||||||||||||||||||||||||||||||||
607 | else if (b !=
| 1-2 | ||||||||||||||||||||||||||||||||||||||||||||||||
608 | ((void *)0)
| 1-2 | ||||||||||||||||||||||||||||||||||||||||||||||||
609 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
610 | return executed 1 time by 1 test: 1;return 1; Executed by:
executed 1 time by 1 test: return 1; Executed by:
| 1 | ||||||||||||||||||||||||||||||||||||||||||||||||
611 | else | - | ||||||||||||||||||||||||||||||||||||||||||||||||
612 | return executed 2 times by 1 test: 0;return 0; Executed by:
executed 2 times by 1 test: return 0; Executed by:
| 2 | ||||||||||||||||||||||||||||||||||||||||||||||||
613 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
614 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
615 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
616 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
617 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
618 | if (a->neg != b->neg
| 14-3486587 | ||||||||||||||||||||||||||||||||||||||||||||||||
619 | if (a->neg
| 4-10 | ||||||||||||||||||||||||||||||||||||||||||||||||
620 | return executed 4 times by 1 test: -1;return -1; Executed by:
executed 4 times by 1 test: return -1; Executed by:
| 4 | ||||||||||||||||||||||||||||||||||||||||||||||||
621 | else | - | ||||||||||||||||||||||||||||||||||||||||||||||||
622 | return executed 10 times by 1 test: 1;return 1; Executed by:
executed 10 times by 1 test: return 1; Executed by:
| 10 | ||||||||||||||||||||||||||||||||||||||||||||||||
623 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
624 | if (a->neg == 0
| 3351-3483236 | ||||||||||||||||||||||||||||||||||||||||||||||||
625 | gt = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
626 | lt = -1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
627 | } executed 3483236 times by 2 tests: else {end of block Executed by:
| 3483236 | ||||||||||||||||||||||||||||||||||||||||||||||||
628 | gt = -1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
629 | lt = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
630 | } executed 3351 times by 1 test: end of block Executed by:
| 3351 | ||||||||||||||||||||||||||||||||||||||||||||||||
631 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
632 | if (a->top > b->top
| 816003-2670584 | ||||||||||||||||||||||||||||||||||||||||||||||||
633 | return executed 816003 times by 2 tests: gt;return gt; Executed by:
executed 816003 times by 2 tests: return gt; Executed by:
| 816003 | ||||||||||||||||||||||||||||||||||||||||||||||||
634 | if (a->top < b->top
| 44279-2626305 | ||||||||||||||||||||||||||||||||||||||||||||||||
635 | return executed 44279 times by 1 test: lt;return lt; Executed by:
executed 44279 times by 1 test: return lt; Executed by:
| 44279 | ||||||||||||||||||||||||||||||||||||||||||||||||
636 | for (i = a->top - 1; i >= 0
| 122509-3358288 | ||||||||||||||||||||||||||||||||||||||||||||||||
637 | t1 = a->d[i]; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
638 | t2 = b->d[i]; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
639 | if (t1 > t2
| 909111-2449177 | ||||||||||||||||||||||||||||||||||||||||||||||||
640 | return executed 909111 times by 2 tests: gt;return gt; Executed by:
executed 909111 times by 2 tests: return gt; Executed by:
| 909111 | ||||||||||||||||||||||||||||||||||||||||||||||||
641 | if (t1 < t2
| 854492-1594685 | ||||||||||||||||||||||||||||||||||||||||||||||||
642 | return executed 1594685 times by 2 tests: lt;return lt; Executed by:
executed 1594685 times by 2 tests: return lt; Executed by:
| 1594685 | ||||||||||||||||||||||||||||||||||||||||||||||||
643 | } executed 854492 times by 2 tests: end of block Executed by:
| 854492 | ||||||||||||||||||||||||||||||||||||||||||||||||
644 | return executed 122509 times by 2 tests: 0;return 0; Executed by:
executed 122509 times by 2 tests: return 0; Executed by:
| 122509 | ||||||||||||||||||||||||||||||||||||||||||||||||
645 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
646 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
647 | int BN_set_bit(BIGNUM *a, int n) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
648 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
649 | int i, j, k; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
650 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
651 | if (n < 0
| 0-170758 | ||||||||||||||||||||||||||||||||||||||||||||||||
652 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
653 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
654 | i = n / (8 * 8); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
655 | j = n % (8 * 8); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
656 | if (a->top <= i
| 620-170138 | ||||||||||||||||||||||||||||||||||||||||||||||||
657 | if (bn_wexpand(a, i + 1) ==
| 0-170138 | ||||||||||||||||||||||||||||||||||||||||||||||||
658 | ((void *)0)
| 0-170138 | ||||||||||||||||||||||||||||||||||||||||||||||||
659 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
660 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
661 | for (k = a->top; k < i + 1
| 170138-1585657 | ||||||||||||||||||||||||||||||||||||||||||||||||
662 | a->d[k] = 0; executed 1585657 times by 2 tests: a->d[k] = 0; Executed by:
| 1585657 | ||||||||||||||||||||||||||||||||||||||||||||||||
663 | a->top = i + 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
664 | a->flags &= ~0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
665 | } executed 170138 times by 2 tests: end of block Executed by:
| 170138 | ||||||||||||||||||||||||||||||||||||||||||||||||
666 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
667 | a->d[i] |= (((unsigned long)1) << j); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
668 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
669 | return executed 170758 times by 2 tests: 1;return 1; Executed by:
executed 170758 times by 2 tests: return 1; Executed by:
| 170758 | ||||||||||||||||||||||||||||||||||||||||||||||||
670 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
671 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
672 | int BN_clear_bit(BIGNUM *a, int n) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
673 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
674 | int i, j; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
675 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
676 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
677 | if (n < 0
| 0-2 | ||||||||||||||||||||||||||||||||||||||||||||||||
678 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
679 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
680 | i = n / (8 * 8); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
681 | j = n % (8 * 8); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
682 | if (a->top <= i
| 0-2 | ||||||||||||||||||||||||||||||||||||||||||||||||
683 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
684 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
685 | a->d[i] &= (~(((unsigned long)1) << j)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
686 | bn_correct_top(a); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
687 | return executed 2 times by 1 test: 1;return 1; Executed by:
executed 2 times by 1 test: return 1; Executed by:
| 2 | ||||||||||||||||||||||||||||||||||||||||||||||||
688 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
689 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
690 | int BN_is_bit_set(const BIGNUM *a, int n) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
691 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
692 | int i, j; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
693 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
694 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
695 | if (n < 0
| 627-20344838 | ||||||||||||||||||||||||||||||||||||||||||||||||
696 | return executed 627 times by 1 test: 0;return 0; Executed by:
executed 627 times by 1 test: return 0; Executed by:
| 627 | ||||||||||||||||||||||||||||||||||||||||||||||||
697 | i = n / (8 * 8); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
698 | j = n % (8 * 8); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
699 | if (a->top <= i
| 3521-20341317 | ||||||||||||||||||||||||||||||||||||||||||||||||
700 | return executed 3521 times by 2 tests: 0;return 0; Executed by:
executed 3521 times by 2 tests: return 0; Executed by:
| 3521 | ||||||||||||||||||||||||||||||||||||||||||||||||
701 | return executed 20341317 times by 2 tests: (int)(((a->d[i]) >> j) & ((unsigned long)1));return (int)(((a->d[i]) >> j) & ((unsigned long)1)); Executed by:
executed 20341317 times by 2 tests: return (int)(((a->d[i]) >> j) & ((unsigned long)1)); Executed by:
| 20341317 | ||||||||||||||||||||||||||||||||||||||||||||||||
702 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
703 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
704 | int BN_mask_bits(BIGNUM *a, int n) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
705 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
706 | int b, w; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
707 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
708 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
709 | if (n < 0
| 0-106 | ||||||||||||||||||||||||||||||||||||||||||||||||
710 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
711 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
712 | w = n / (8 * 8); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
713 | b = n % (8 * 8); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
714 | if (w >= a->top
| 0-106 | ||||||||||||||||||||||||||||||||||||||||||||||||
715 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
716 | if (b == 0
| 0-106 | ||||||||||||||||||||||||||||||||||||||||||||||||
717 | a->top = w; never executed: a->top = w; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
718 | else { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
719 | a->top = w + 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
720 | a->d[w] &= ~((0xffffffffffffffffL) << b); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
721 | } executed 106 times by 1 test: end of block Executed by:
| 106 | ||||||||||||||||||||||||||||||||||||||||||||||||
722 | bn_correct_top(a); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
723 | return executed 106 times by 1 test: 1;return 1; Executed by:
executed 106 times by 1 test: return 1; Executed by:
| 106 | ||||||||||||||||||||||||||||||||||||||||||||||||
724 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
725 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
726 | void BN_set_negative(BIGNUM *a, int b) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
727 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
728 | if (b
| 44-273582 | ||||||||||||||||||||||||||||||||||||||||||||||||
729 | a->neg = 1; executed 4233 times by 1 test: a->neg = 1; Executed by:
| 4233 | ||||||||||||||||||||||||||||||||||||||||||||||||
730 | else | - | ||||||||||||||||||||||||||||||||||||||||||||||||
731 | a->neg = 0; executed 273626 times by 2 tests: a->neg = 0; Executed by:
| 273626 | ||||||||||||||||||||||||||||||||||||||||||||||||
732 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
733 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
734 | int bn_cmp_words(const unsigned long *a, const unsigned long *b, int n) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
735 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
736 | int i; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
737 | unsigned long aa, bb; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
738 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
739 | aa = a[n - 1]; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
740 | bb = b[n - 1]; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
741 | if (aa != bb
| 104887-591616 | ||||||||||||||||||||||||||||||||||||||||||||||||
742 | return executed 591616 times by 1 test: ((return ((aa > bb) ? 1 : -1); Executed by:
executed 591616 times by 1 test: return ((aa > bb) ? 1 : -1); Executed by:
| 278925-591616 | ||||||||||||||||||||||||||||||||||||||||||||||||
743 | for (i = n - 2; i >= 0
| 45640-759648 | ||||||||||||||||||||||||||||||||||||||||||||||||
744 | aa = a[i]; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
745 | bb = b[i]; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
746 | if (aa != bb
| 59247-700401 | ||||||||||||||||||||||||||||||||||||||||||||||||
747 | return executed 59247 times by 1 test: ((return ((aa > bb) ? 1 : -1); Executed by:
executed 59247 times by 1 test: return ((aa > bb) ? 1 : -1); Executed by:
| 23228-59247 | ||||||||||||||||||||||||||||||||||||||||||||||||
748 | } executed 700401 times by 1 test: end of block Executed by:
| 700401 | ||||||||||||||||||||||||||||||||||||||||||||||||
749 | return executed 45640 times by 1 test: 0;return 0; Executed by:
executed 45640 times by 1 test: return 0; Executed by:
| 45640 | ||||||||||||||||||||||||||||||||||||||||||||||||
750 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
751 | int bn_cmp_part_words(const unsigned long *a, const unsigned long *b, int cl, int dl) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
752 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
753 | int n, i; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
754 | n = cl - 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
755 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
756 | if (dl < 0
| 40010-677866 | ||||||||||||||||||||||||||||||||||||||||||||||||
757 | for (i = dl; i < 0
| 3985-66274 | ||||||||||||||||||||||||||||||||||||||||||||||||
758 | if (b[n - i] != 0
| 30249-36025 | ||||||||||||||||||||||||||||||||||||||||||||||||
759 | return executed 36025 times by 1 test: -1;return -1; Executed by:
executed 36025 times by 1 test: return -1; Executed by:
| 36025 | ||||||||||||||||||||||||||||||||||||||||||||||||
760 | } executed 30249 times by 1 test: end of block Executed by:
| 30249 | ||||||||||||||||||||||||||||||||||||||||||||||||
761 | } executed 3985 times by 1 test: end of block Executed by:
| 3985 | ||||||||||||||||||||||||||||||||||||||||||||||||
762 | if (dl > 0
| 38964-642887 | ||||||||||||||||||||||||||||||||||||||||||||||||
763 | for (i = dl; i > 0
| 8644-145592 | ||||||||||||||||||||||||||||||||||||||||||||||||
764 | if (a[n + i] != 0
| 30320-115272 | ||||||||||||||||||||||||||||||||||||||||||||||||
765 | return executed 30320 times by 1 test: 1;return 1; Executed by:
executed 30320 times by 1 test: return 1; Executed by:
| 30320 | ||||||||||||||||||||||||||||||||||||||||||||||||
766 | } executed 115272 times by 1 test: end of block Executed by:
| 115272 | ||||||||||||||||||||||||||||||||||||||||||||||||
767 | } executed 8644 times by 1 test: end of block Executed by:
| 8644 | ||||||||||||||||||||||||||||||||||||||||||||||||
768 | return executed 651531 times by 1 test: bn_cmp_words(a, b, cl);return bn_cmp_words(a, b, cl); Executed by:
executed 651531 times by 1 test: return bn_cmp_words(a, b, cl); Executed by:
| 651531 | ||||||||||||||||||||||||||||||||||||||||||||||||
769 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
770 | void BN_consttime_swap(unsigned long condition, BIGNUM *a, BIGNUM *b, int nwords) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
771 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
772 | unsigned long t; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
773 | int i; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
774 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
775 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
776 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
777 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
778 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
779 | ((void) (0)) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
780 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
781 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
782 | ((void) (0)) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
783 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
784 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
785 | ((void) (0)) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
786 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
787 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
788 | condition = ((condition - 1) >> ((8 * 8) - 1)) - 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
789 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
790 | t = (a->top ^ b->top) & condition; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
791 | a->top ^= t; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
792 | b->top ^= t; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
793 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
794 | t = (a->neg ^ b->neg) & condition; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
795 | a->neg ^= t; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
796 | b->neg ^= t; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
797 | t = ((a->flags ^ b->flags) & 0x04) & condition; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
798 | a->flags ^= t; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
799 | b->flags ^= t; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
800 | switch (nwords) { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
801 | default executed 8 times by 1 test: :default: Executed by:
executed 8 times by 1 test: default: Executed by:
| 8 | ||||||||||||||||||||||||||||||||||||||||||||||||
802 | for (i = 10; i < nwords
| 8-38 | ||||||||||||||||||||||||||||||||||||||||||||||||
803 | do { t = (a->d[i] ^ b->d[i]) & condition; a->d[i] ^= t; b->d[i] ^= t; } executed 38 times by 1 test: while (0);end of block Executed by:
| 38 | ||||||||||||||||||||||||||||||||||||||||||||||||
804 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
805 | case executed 651 times by 1 test: 10:case 10: Executed by:
executed 651 times by 1 test: case 10: Executed by:
code before this statement executed 8 times by 1 test: case 10: Executed by:
| 8-651 | ||||||||||||||||||||||||||||||||||||||||||||||||
806 | do { t = (a->d[9] ^ b->d[9]) & condition; a->d[9] ^= t; b->d[9] ^= t; } while (0); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
807 | case executed 1045899 times by 1 test: 9:case 9: Executed by:
executed 1045899 times by 1 test: case 9: Executed by:
code before this statement executed 659 times by 1 test: case 9: Executed by:
| 659-1045899 | ||||||||||||||||||||||||||||||||||||||||||||||||
808 | do { t = (a->d[8] ^ b->d[8]) & condition; a->d[8] ^= t; b->d[8] ^= t; } while (0); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
809 | case executed 115648 times by 1 test: 8:case 8: Executed by:
executed 115648 times by 1 test: case 8: Executed by:
code before this statement executed 1046558 times by 1 test: case 8: Executed by:
| 115648-1046558 | ||||||||||||||||||||||||||||||||||||||||||||||||
810 | do { t = (a->d[7] ^ b->d[7]) & condition; a->d[7] ^= t; b->d[7] ^= t; } while (0); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
811 | case executed 277790 times by 1 test: 7:case 7: Executed by:
executed 277790 times by 1 test: case 7: Executed by:
code before this statement executed 1162206 times by 1 test: case 7: Executed by:
| 277790-1162206 | ||||||||||||||||||||||||||||||||||||||||||||||||
812 | do { t = (a->d[6] ^ b->d[6]) & condition; a->d[6] ^= t; b->d[6] ^= t; } while (0); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
813 | case executed 451358 times by 1 test: 6:case 6: Executed by:
executed 451358 times by 1 test: case 6: Executed by:
code before this statement executed 1439996 times by 1 test: case 6: Executed by:
| 451358-1439996 | ||||||||||||||||||||||||||||||||||||||||||||||||
814 | do { t = (a->d[5] ^ b->d[5]) & condition; a->d[5] ^= t; b->d[5] ^= t; } while (0); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
815 | case executed 279640 times by 2 tests: 5:case 5: Executed by:
executed 279640 times by 2 tests: case 5: Executed by:
code before this statement executed 1891354 times by 1 test: case 5: Executed by:
| 279640-1891354 | ||||||||||||||||||||||||||||||||||||||||||||||||
816 | do { t = (a->d[4] ^ b->d[4]) & condition; a->d[4] ^= t; b->d[4] ^= t; } while (0); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
817 | case executed 738108 times by 2 tests: 4:case 4: Executed by:
executed 738108 times by 2 tests: case 4: Executed by:
code before this statement executed 2170994 times by 2 tests: case 4: Executed by:
| 738108-2170994 | ||||||||||||||||||||||||||||||||||||||||||||||||
818 | do { t = (a->d[3] ^ b->d[3]) & condition; a->d[3] ^= t; b->d[3] ^= t; } while (0); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
819 | case executed 595031 times by 1 test: 3:case 3: Executed by:
executed 595031 times by 1 test: case 3: Executed by:
code before this statement executed 2909102 times by 2 tests: case 3: Executed by:
| 595031-2909102 | ||||||||||||||||||||||||||||||||||||||||||||||||
820 | do { t = (a->d[2] ^ b->d[2]) & condition; a->d[2] ^= t; b->d[2] ^= t; } while (0); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
821 | case executed 93368 times by 1 test: 2:case 2: Executed by:
executed 93368 times by 1 test: case 2: Executed by:
code before this statement executed 3504133 times by 2 tests: case 2: Executed by:
| 93368-3504133 | ||||||||||||||||||||||||||||||||||||||||||||||||
822 | do { t = (a->d[1] ^ b->d[1]) & condition; a->d[1] ^= t; b->d[1] ^= t; } while (0); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
823 | case executed 3597501 times by 2 tests: 1:case 1: Executed by:
executed 3597501 times by 2 tests: case 1: Executed by:
code before this statement executed 3597501 times by 2 tests: case 1: Executed by:
| 3597501 | ||||||||||||||||||||||||||||||||||||||||||||||||
824 | do { t = (a->d[0] ^ b->d[0]) & condition; a->d[0] ^= t; b->d[0] ^= t; } while (0); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
825 | } executed 3597501 times by 2 tests: end of block Executed by:
| 3597501 | ||||||||||||||||||||||||||||||||||||||||||||||||
826 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
827 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
828 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
829 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
830 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
831 | int BN_security_bits(int L, int N) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
832 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
833 | int secbits, bits; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
834 | if (L >= 15360
| 0-11236 | ||||||||||||||||||||||||||||||||||||||||||||||||
835 | secbits = 256; never executed: secbits = 256; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
836 | else if (L >= 7680
| 0-11236 | ||||||||||||||||||||||||||||||||||||||||||||||||
837 | secbits = 192; never executed: secbits = 192; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
838 | else if (L >= 3072
| 8-11228 | ||||||||||||||||||||||||||||||||||||||||||||||||
839 | secbits = 128; executed 8 times by 1 test: secbits = 128; Executed by:
| 8 | ||||||||||||||||||||||||||||||||||||||||||||||||
840 | else if (L >= 2048
| 2463-8765 | ||||||||||||||||||||||||||||||||||||||||||||||||
841 | secbits = 112; executed 8765 times by 1 test: secbits = 112; Executed by:
| 8765 | ||||||||||||||||||||||||||||||||||||||||||||||||
842 | else if (L >= 1024
| 7-2456 | ||||||||||||||||||||||||||||||||||||||||||||||||
843 | secbits = 80; executed 2456 times by 1 test: secbits = 80; Executed by:
| 2456 | ||||||||||||||||||||||||||||||||||||||||||||||||
844 | else | - | ||||||||||||||||||||||||||||||||||||||||||||||||
845 | return executed 7 times by 1 test: 0;return 0; Executed by:
executed 7 times by 1 test: return 0; Executed by:
| 7 | ||||||||||||||||||||||||||||||||||||||||||||||||
846 | if (N == -1
| 2042-9187 | ||||||||||||||||||||||||||||||||||||||||||||||||
847 | return executed 9187 times by 1 test: secbits;return secbits; Executed by:
executed 9187 times by 1 test: return secbits; Executed by:
| 9187 | ||||||||||||||||||||||||||||||||||||||||||||||||
848 | bits = N / 2; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
849 | if (bits < 80
| 0-2042 | ||||||||||||||||||||||||||||||||||||||||||||||||
850 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
851 | return executed 2042 times by 1 test: bits >= secbitsreturn bits >= secbits ? secbits : bits; Executed by:
executed 2042 times by 1 test: return bits >= secbits ? secbits : bits; Executed by:
| 0-2042 | ||||||||||||||||||||||||||||||||||||||||||||||||
852 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
853 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
854 | void BN_zero_ex(BIGNUM *a) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
855 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
856 | a->neg = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
857 | a->top = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
858 | a->flags &= ~0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
859 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
860 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
861 | int BN_abs_is_word(const BIGNUM *a, const unsigned long w) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
862 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
863 | return executed 3905302 times by 2 tests: ((return ((a->top == 1) && (a->d[0] == w)) || ((w == 0) && (a->top == 0)); Executed by:
executed 3905302 times by 2 tests: return ((a->top == 1) && (a->d[0] == w)) || ((w == 0) && (a->top == 0)); Executed by:
| 1-3905302 | ||||||||||||||||||||||||||||||||||||||||||||||||
864 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
865 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
866 | int BN_is_zero(const BIGNUM *a) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
867 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
868 | return executed 52453965 times by 2 tests: a->top == 0;return a->top == 0; Executed by:
executed 52453965 times by 2 tests: return a->top == 0; Executed by:
| 52453965 | ||||||||||||||||||||||||||||||||||||||||||||||||
869 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
870 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
871 | int BN_is_one(const BIGNUM *a) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
872 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
873 | return executed 3786971 times by 2 tests: BN_abs_is_word(a, 1)return BN_abs_is_word(a, 1) && !a->neg; Executed by:
executed 3786971 times by 2 tests: return BN_abs_is_word(a, 1) && !a->neg; Executed by:
| 0-3786971 | ||||||||||||||||||||||||||||||||||||||||||||||||
874 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
875 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
876 | int BN_is_word(const BIGNUM *a, const unsigned long w) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
877 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
878 | return executed 30470 times by 1 test: BN_abs_is_word(a, w)return BN_abs_is_word(a, w) && (!w || !a->neg); Executed by:
executed 30470 times by 1 test: return BN_abs_is_word(a, w) && (!w || !a->neg); Executed by:
| 1-30470 | ||||||||||||||||||||||||||||||||||||||||||||||||
879 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
880 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
881 | int BN_is_odd(const BIGNUM *a) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
882 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
883 | return executed 5599741 times by 2 tests: (return (a->top > 0) && (a->d[0] & 1); Executed by:
executed 5599741 times by 2 tests: return (a->top > 0) && (a->d[0] & 1); Executed by:
| 439-5599741 | ||||||||||||||||||||||||||||||||||||||||||||||||
884 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
885 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
886 | int BN_is_negative(const BIGNUM *a) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
887 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
888 | return executed 44625 times by 2 tests: (a->neg != 0);return (a->neg != 0); Executed by:
executed 44625 times by 2 tests: return (a->neg != 0); Executed by:
| 44625 | ||||||||||||||||||||||||||||||||||||||||||||||||
889 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
890 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
891 | int BN_to_montgomery(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont, | - | ||||||||||||||||||||||||||||||||||||||||||||||||
892 | BN_CTX *ctx) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
893 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
894 | return executed 180462 times by 2 tests: BN_mod_mul_montgomery(r, a, &(mont->RR), mont, ctx);return BN_mod_mul_montgomery(r, a, &(mont->RR), mont, ctx); Executed by:
executed 180462 times by 2 tests: return BN_mod_mul_montgomery(r, a, &(mont->RR), mont, ctx); Executed by:
| 180462 | ||||||||||||||||||||||||||||||||||||||||||||||||
895 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
896 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
897 | void BN_with_flags(BIGNUM *dest, const BIGNUM *b, int flags) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
898 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
899 | dest->d = b->d; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
900 | dest->top = b->top; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
901 | dest->dmax = b->dmax; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
902 | dest->neg = b->neg; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
903 | dest->flags = ((dest->flags & 0x01) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
904 | | (b->flags & ~0x01) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
905 | | 0x02 | flags); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
906 | } executed 2427751 times by 1 test: end of block Executed by:
| 2427751 | ||||||||||||||||||||||||||||||||||||||||||||||||
907 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
908 | BN_GENCB *BN_GENCB_new(void) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
909 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
910 | BN_GENCB *ret; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
911 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
912 | if ((
| 0-23 | ||||||||||||||||||||||||||||||||||||||||||||||||
913 | ((void *)0)
| 0-23 | ||||||||||||||||||||||||||||||||||||||||||||||||
914 | ) { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
915 | ERR_put_error(3,(143),((1|64)),__FILE__,913); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
916 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
917 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
918 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
919 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
920 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
921 | return executed 23 times by 1 test: ret;return ret; Executed by:
executed 23 times by 1 test: return ret; Executed by:
| 23 | ||||||||||||||||||||||||||||||||||||||||||||||||
922 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
923 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
924 | void BN_GENCB_free(BN_GENCB *cb) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
925 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
926 | if (cb ==
| 1-23 | ||||||||||||||||||||||||||||||||||||||||||||||||
927 | ((void *)0)
| 1-23 | ||||||||||||||||||||||||||||||||||||||||||||||||
928 | ) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
929 | return; executed 1 time by 1 test: return; Executed by:
| 1 | ||||||||||||||||||||||||||||||||||||||||||||||||
930 | CRYPTO_free(cb, __FILE__, 924); | - | ||||||||||||||||||||||||||||||||||||||||||||||||
931 | } executed 23 times by 1 test: end of block Executed by:
| 23 | ||||||||||||||||||||||||||||||||||||||||||||||||
932 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
933 | void BN_set_flags(BIGNUM *b, int n) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
934 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
935 | b->flags |= n; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
936 | } executed 71162 times by 2 tests: end of block Executed by:
| 71162 | ||||||||||||||||||||||||||||||||||||||||||||||||
937 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
938 | int BN_get_flags(const BIGNUM *b, int n) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
939 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
940 | return executed 31803222 times by 2 tests: b->flags & n;return b->flags & n; Executed by:
executed 31803222 times by 2 tests: return b->flags & n; Executed by:
| 31803222 | ||||||||||||||||||||||||||||||||||||||||||||||||
941 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
942 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
943 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
944 | void BN_GENCB_set_old(BN_GENCB *gencb, void (*callback) (int, int, void *), | - | ||||||||||||||||||||||||||||||||||||||||||||||||
945 | void *cb_arg) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
946 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
947 | BN_GENCB *tmp_gencb = gencb; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
948 | tmp_gencb->ver = 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
949 | tmp_gencb->arg = cb_arg; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
950 | tmp_gencb->cb.cb_1 = callback; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
951 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
952 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
953 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
954 | void BN_GENCB_set(BN_GENCB *gencb, int (*callback) (int, int, BN_GENCB *), | - | ||||||||||||||||||||||||||||||||||||||||||||||||
955 | void *cb_arg) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
956 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
957 | BN_GENCB *tmp_gencb = gencb; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
958 | tmp_gencb->ver = 2; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
959 | tmp_gencb->arg = cb_arg; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
960 | tmp_gencb->cb.cb_2 = callback; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
961 | } executed 23 times by 1 test: end of block Executed by:
| 23 | ||||||||||||||||||||||||||||||||||||||||||||||||
962 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
963 | void *BN_GENCB_get_arg(BN_GENCB *cb) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
964 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
965 | return executed 5332 times by 1 test: cb->arg;return cb->arg; Executed by:
executed 5332 times by 1 test: return cb->arg; Executed by:
| 5332 | ||||||||||||||||||||||||||||||||||||||||||||||||
966 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
967 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
968 | BIGNUM *bn_wexpand(BIGNUM *a, int words) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
969 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
970 | return executed 244086374 times by 2 tests: (return (words <= a->dmax) ? a : bn_expand2(a, words); Executed by:
executed 244086374 times by 2 tests: return (words <= a->dmax) ? a : bn_expand2(a, words); Executed by:
| 3485680-244086374 | ||||||||||||||||||||||||||||||||||||||||||||||||
971 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||
972 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
973 | void bn_correct_top(BIGNUM *a) | - | ||||||||||||||||||||||||||||||||||||||||||||||||
974 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||
975 | unsigned long *ftl; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
976 | int tmp_top = a->top; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
977 | - | |||||||||||||||||||||||||||||||||||||||||||||||||
978 | if (tmp_top > 0
| 218082-195880464 | ||||||||||||||||||||||||||||||||||||||||||||||||
979 | for (ftl = &(a->d[tmp_top]); tmp_top > 0
| 459604-634226577 | ||||||||||||||||||||||||||||||||||||||||||||||||
980 | ftl--; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
981 | if (*
| 195420860-438805717 | ||||||||||||||||||||||||||||||||||||||||||||||||
982 | break; executed 195420860 times by 2 tests: break; Executed by:
| 195420860 | ||||||||||||||||||||||||||||||||||||||||||||||||
983 | } executed 438805717 times by 2 tests: end of block Executed by:
| 438805717 | ||||||||||||||||||||||||||||||||||||||||||||||||
984 | a->top = tmp_top; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
985 | } executed 195880464 times by 2 tests: end of block Executed by:
| 195880464 | ||||||||||||||||||||||||||||||||||||||||||||||||
986 | if (a->top == 0
| 677686-195420860 | ||||||||||||||||||||||||||||||||||||||||||||||||
987 | a->neg = 0; executed 677686 times by 2 tests: a->neg = 0; Executed by:
| 677686 | ||||||||||||||||||||||||||||||||||||||||||||||||
988 | a->flags &= ~0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
989 | ; | - | ||||||||||||||||||||||||||||||||||||||||||||||||
990 | } executed 196098546 times by 2 tests: end of block Executed by:
| 196098546 | ||||||||||||||||||||||||||||||||||||||||||||||||
Switch to Source code | Preprocessed file |