1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | |
23 | |
24 | |
25 | |
26 | |
27 | |
28 | |
29 | |
30 | |
31 | |
32 | |
33 | |
34 | #if HAVE_CONFIG_H1 |
35 | # include "config.h" |
36 | #endif |
37 | |
38 | #include <assert.h> |
39 | |
40 | #include "ecc-internal.h" |
41 | |
42 | |
43 | void |
44 | ecc_mod_nettle_ecc_mod (const struct ecc_modulo *m, mp_limb_t *rp) |
45 | { |
46 | mp_limb_t hi; |
| 1 | 'hi' declared without an initial value | |
|
47 | mp_size_t mn = m->size; |
48 | mp_size_t bn = m->B_size; |
49 | mp_size_t sn = mn - bn; |
50 | mp_size_t rn = 2*mn; |
51 | mp_size_t i; |
52 | unsigned shift; |
53 | |
54 | assert (sn > 0)((sn > 0) ? (void) (0) : __assert_fail ("sn > 0", "ecc-mod.c" , 54, __PRETTY_FUNCTION__)); |
55 | |
56 | |
57 | |
58 | if (m->B[bn-1] < ((mp_limb_t) 1 << (GMP_NUMB_BITS(64 - 0) - 1))) |
| |
59 | { |
60 | |
61 | |
62 | while (rn > 2 * mn - bn) |
63 | { |
64 | rn -= sn; |
65 | |
66 | for (i = 0; i <= sn; i++) |
67 | rp[rn+i-1] = mpn_addmul_1__gmpn_addmul_1 (rp + rn - mn - 1 + i, m->B, bn, rp[rn+i-1]); |
68 | rp[rn-1] = rp[rn+sn-1] |
69 | + mpn_add_n__gmpn_add_n (rp + rn - sn - 1, rp + rn - sn - 1, rp + rn - 1, sn); |
70 | } |
71 | goto final_limbs; |
72 | } |
73 | else |
74 | { |
75 | while (rn >= 2 * mn - bn) |
| 3 | | Loop condition is false. Execution continues on line 88 | |
|
76 | { |
77 | rn -= sn; |
78 | |
79 | for (i = 0; i < sn; i++) |
80 | rp[rn+i] = mpn_addmul_1__gmpn_addmul_1 (rp + rn - mn + i, m->B, bn, rp[rn+i]); |
81 | |
82 | hi = mpn_add_n__gmpn_add_n (rp + rn - sn, rp + rn - sn, rp + rn, sn); |
83 | hi = cnd_add_n (hi, rp + rn - mn, m->B, mn)__gmpn_cnd_add_n ((hi), (rp + rn - mn), (rp + rn - mn), (m-> B), (mn)); |
84 | assert (hi == 0)((hi == 0) ? (void) (0) : __assert_fail ("hi == 0", "ecc-mod.c" , 84, __PRETTY_FUNCTION__)); |
85 | } |
86 | } |
87 | |
88 | if (rn > mn) |
| |
89 | { |
90 | final_limbs: |
91 | sn = rn - mn; |
92 | |
93 | for (i = 0; i < sn; i++) |
94 | rp[mn+i] = mpn_addmul_1__gmpn_addmul_1 (rp + i, m->B, bn, rp[mn+i]); |
95 | |
96 | hi = mpn_add_n__gmpn_add_n (rp + bn, rp + bn, rp + mn, sn); |
97 | hi = sec_add_1_nettle_sec_add_1 (rp + bn + sn, rp + bn + sn, mn - bn - sn, hi); |
98 | } |
99 | |
100 | shift = m->size * GMP_NUMB_BITS(64 - 0) - m->bit_size; |
101 | if (shift > 0) |
| 5 | | Assuming 'shift' is <= 0 | |
|
| |
102 | { |
103 | |
104 | hi = (hi << shift) | (rp[mn-1] >> (GMP_NUMB_BITS(64 - 0) - shift)); |
105 | rp[mn-1] = (rp[mn-1] & (((mp_limb_t) 1 << (GMP_NUMB_BITS(64 - 0) - shift)) - 1)) |
106 | + mpn_addmul_1__gmpn_addmul_1 (rp, m->B_shifted, mn-1, hi); |
107 | } |
108 | else |
109 | { |
110 | hi = cnd_add_n (hi, rp, m->B_shifted, mn)__gmpn_cnd_add_n ((hi), (rp), (rp), (m->B_shifted), (mn)); |
| 7 | | Within the expansion of the macro 'cnd_add_n':
|
a | Function call argument is an uninitialized value |
|
111 | assert (hi == 0)((hi == 0) ? (void) (0) : __assert_fail ("hi == 0", "ecc-mod.c" , 111, __PRETTY_FUNCTION__)); |
112 | } |
113 | } |