| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/bn/bn_intern.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | signed char *bn_compute_wNAF(const BIGNUM *scalar, int w, size_t *ret_len) | - | ||||||||||||||||||||||||
| 2 | { | - | ||||||||||||||||||||||||
| 3 | int window_val; | - | ||||||||||||||||||||||||
| 4 | signed char *r = | - | ||||||||||||||||||||||||
| 5 | ((void *)0) | - | ||||||||||||||||||||||||
| 6 | ; | - | ||||||||||||||||||||||||
| 7 | int sign = 1; | - | ||||||||||||||||||||||||
| 8 | int bit, next_bit, mask; | - | ||||||||||||||||||||||||
| 9 | size_t len = 0, j; | - | ||||||||||||||||||||||||
| 10 | - | |||||||||||||||||||||||||
| 11 | if (BN_is_zero(scalar)
| 4-2205 | ||||||||||||||||||||||||
| 12 | r = CRYPTO_malloc(1, __FILE__, 31); | - | ||||||||||||||||||||||||
| 13 | if (r ==
| 0-4 | ||||||||||||||||||||||||
| 14 | ((void *)0)
| 0-4 | ||||||||||||||||||||||||
| 15 | ) { | - | ||||||||||||||||||||||||
| 16 | ERR_put_error(3,(142),((1|64)),__FILE__,33); | - | ||||||||||||||||||||||||
| 17 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 18 | } | - | ||||||||||||||||||||||||
| 19 | r[0] = 0; | - | ||||||||||||||||||||||||
| 20 | *ret_len = 1; | - | ||||||||||||||||||||||||
| 21 | return executed 4 times by 1 test: r;return r;Executed by:
executed 4 times by 1 test: return r;Executed by:
| 4 | ||||||||||||||||||||||||
| 22 | } | - | ||||||||||||||||||||||||
| 23 | - | |||||||||||||||||||||||||
| 24 | if (w <= 0
| 0-2205 | ||||||||||||||||||||||||
| 25 | - | |||||||||||||||||||||||||
| 26 | ERR_put_error(3,(142),((4|64)),__FILE__,43); | - | ||||||||||||||||||||||||
| 27 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 28 | } | - | ||||||||||||||||||||||||
| 29 | bit = 1 << w; | - | ||||||||||||||||||||||||
| 30 | next_bit = bit << 1; | - | ||||||||||||||||||||||||
| 31 | mask = next_bit - 1; | - | ||||||||||||||||||||||||
| 32 | - | |||||||||||||||||||||||||
| 33 | if (BN_is_negative(scalar)
| 586-1619 | ||||||||||||||||||||||||
| 34 | sign = -1; | - | ||||||||||||||||||||||||
| 35 | } executed 586 times by 1 test: end of blockExecuted by:
| 586 | ||||||||||||||||||||||||
| 36 | - | |||||||||||||||||||||||||
| 37 | if (scalar->d ==
| 0-2205 | ||||||||||||||||||||||||
| 38 | ((void *)0)
| 0-2205 | ||||||||||||||||||||||||
| 39 | || scalar->top == 0
| 0-2205 | ||||||||||||||||||||||||
| 40 | ERR_put_error(3,(142),((4|64)),__FILE__,55); | - | ||||||||||||||||||||||||
| 41 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 42 | } | - | ||||||||||||||||||||||||
| 43 | - | |||||||||||||||||||||||||
| 44 | len = BN_num_bits(scalar); | - | ||||||||||||||||||||||||
| 45 | r = CRYPTO_malloc(len + 1, __FILE__, 60); | - | ||||||||||||||||||||||||
| 46 | - | |||||||||||||||||||||||||
| 47 | - | |||||||||||||||||||||||||
| 48 | - | |||||||||||||||||||||||||
| 49 | - | |||||||||||||||||||||||||
| 50 | if (r ==
| 0-2205 | ||||||||||||||||||||||||
| 51 | ((void *)0)
| 0-2205 | ||||||||||||||||||||||||
| 52 | ) { | - | ||||||||||||||||||||||||
| 53 | ERR_put_error(3,(142),((1|64)),__FILE__,66); | - | ||||||||||||||||||||||||
| 54 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 55 | } | - | ||||||||||||||||||||||||
| 56 | window_val = scalar->d[0] & mask; | - | ||||||||||||||||||||||||
| 57 | j = 0; | - | ||||||||||||||||||||||||
| 58 | while ((
| 2205-519118 | ||||||||||||||||||||||||
| 59 | - | |||||||||||||||||||||||||
| 60 | - | |||||||||||||||||||||||||
| 61 | int digit = 0; | - | ||||||||||||||||||||||||
| 62 | - | |||||||||||||||||||||||||
| 63 | - | |||||||||||||||||||||||||
| 64 | - | |||||||||||||||||||||||||
| 65 | if (window_val & 1
| 89410-520811 | ||||||||||||||||||||||||
| 66 | - | |||||||||||||||||||||||||
| 67 | - | |||||||||||||||||||||||||
| 68 | if (window_val & bit
| 43088-46322 | ||||||||||||||||||||||||
| 69 | digit = window_val - next_bit; | - | ||||||||||||||||||||||||
| 70 | - | |||||||||||||||||||||||||
| 71 | - | |||||||||||||||||||||||||
| 72 | if (j + w + 1 >= len
| 184-42904 | ||||||||||||||||||||||||
| 73 | - | |||||||||||||||||||||||||
| 74 | - | |||||||||||||||||||||||||
| 75 | - | |||||||||||||||||||||||||
| 76 | - | |||||||||||||||||||||||||
| 77 | - | |||||||||||||||||||||||||
| 78 | - | |||||||||||||||||||||||||
| 79 | - | |||||||||||||||||||||||||
| 80 | digit = window_val & (mask >> 1); | - | ||||||||||||||||||||||||
| 81 | } executed 184 times by 1 test: end of blockExecuted by:
| 184 | ||||||||||||||||||||||||
| 82 | - | |||||||||||||||||||||||||
| 83 | } executed 43088 times by 2 tests: else {end of blockExecuted by:
| 43088 | ||||||||||||||||||||||||
| 84 | digit = window_val; | - | ||||||||||||||||||||||||
| 85 | } executed 46322 times by 2 tests: end of blockExecuted by:
| 46322 | ||||||||||||||||||||||||
| 86 | - | |||||||||||||||||||||||||
| 87 | if (digit <= -bit
| 0-89410 | ||||||||||||||||||||||||
| 88 | ERR_put_error(3,(142),((4|64)),__FILE__,101); | - | ||||||||||||||||||||||||
| 89 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 90 | } | - | ||||||||||||||||||||||||
| 91 | - | |||||||||||||||||||||||||
| 92 | window_val -= digit; | - | ||||||||||||||||||||||||
| 93 | - | |||||||||||||||||||||||||
| 94 | - | |||||||||||||||||||||||||
| 95 | - | |||||||||||||||||||||||||
| 96 | - | |||||||||||||||||||||||||
| 97 | - | |||||||||||||||||||||||||
| 98 | if (window_val != 0
| 184-46322 | ||||||||||||||||||||||||
| 99 | && window_val != bit
| 0-184 | ||||||||||||||||||||||||
| 100 | ERR_put_error(3,(142),((4|64)),__FILE__,113); | - | ||||||||||||||||||||||||
| 101 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 102 | } | - | ||||||||||||||||||||||||
| 103 | } executed 89410 times by 2 tests: end of blockExecuted by:
| 89410 | ||||||||||||||||||||||||
| 104 | - | |||||||||||||||||||||||||
| 105 | r[j++] = sign * digit; | - | ||||||||||||||||||||||||
| 106 | - | |||||||||||||||||||||||||
| 107 | window_val >>= 1; | - | ||||||||||||||||||||||||
| 108 | window_val += bit * BN_is_bit_set(scalar, j + w); | - | ||||||||||||||||||||||||
| 109 | - | |||||||||||||||||||||||||
| 110 | if (window_val > next_bit
| 0-610221 | ||||||||||||||||||||||||
| 111 | ERR_put_error(3,(142),((4|64)),__FILE__,124); | - | ||||||||||||||||||||||||
| 112 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 113 | } | - | ||||||||||||||||||||||||
| 114 | } executed 610221 times by 2 tests: end of blockExecuted by:
| 610221 | ||||||||||||||||||||||||
| 115 | - | |||||||||||||||||||||||||
| 116 | if (j > len + 1
| 0-2205 | ||||||||||||||||||||||||
| 117 | ERR_put_error(3,(142),((4|64)),__FILE__,130); | - | ||||||||||||||||||||||||
| 118 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||||||||||||||
| 119 | } | - | ||||||||||||||||||||||||
| 120 | *ret_len = j; | - | ||||||||||||||||||||||||
| 121 | return executed 2205 times by 2 tests: r;return r;Executed by:
executed 2205 times by 2 tests: return r;Executed by:
| 2205 | ||||||||||||||||||||||||
| 122 | - | |||||||||||||||||||||||||
| 123 | err: | - | ||||||||||||||||||||||||
| 124 | CRYPTO_free(r, __FILE__, 137); | - | ||||||||||||||||||||||||
| 125 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 126 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 127 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||||||||
| 128 | } | - | ||||||||||||||||||||||||
| 129 | - | |||||||||||||||||||||||||
| 130 | int bn_get_top(const BIGNUM *a) | - | ||||||||||||||||||||||||
| 131 | { | - | ||||||||||||||||||||||||
| 132 | return executed 17493 times by 2 tests: a->top;return a->top;Executed by:
executed 17493 times by 2 tests: return a->top;Executed by:
| 17493 | ||||||||||||||||||||||||
| 133 | } | - | ||||||||||||||||||||||||
| 134 | - | |||||||||||||||||||||||||
| 135 | int bn_get_dmax(const BIGNUM *a) | - | ||||||||||||||||||||||||
| 136 | { | - | ||||||||||||||||||||||||
| 137 | return never executed: a->dmax;return a->dmax;never executed: return a->dmax; | 0 | ||||||||||||||||||||||||
| 138 | } | - | ||||||||||||||||||||||||
| 139 | - | |||||||||||||||||||||||||
| 140 | void bn_set_all_zero(BIGNUM *a) | - | ||||||||||||||||||||||||
| 141 | { | - | ||||||||||||||||||||||||
| 142 | int i; | - | ||||||||||||||||||||||||
| 143 | - | |||||||||||||||||||||||||
| 144 | for (i = a->top; i < a->dmax
| 38978-47286 | ||||||||||||||||||||||||
| 145 | a->d[i] = 0; executed 47286 times by 1 test: a->d[i] = 0;Executed by:
| 47286 | ||||||||||||||||||||||||
| 146 | } executed 38978 times by 1 test: end of blockExecuted by:
| 38978 | ||||||||||||||||||||||||
| 147 | - | |||||||||||||||||||||||||
| 148 | int bn_copy_words(unsigned long *out, const BIGNUM *in, int size) | - | ||||||||||||||||||||||||
| 149 | { | - | ||||||||||||||||||||||||
| 150 | if (in->top > size
| 0-43574 | ||||||||||||||||||||||||
| 151 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 152 | - | |||||||||||||||||||||||||
| 153 | memset(out, 0, sizeof(*out) * size); | - | ||||||||||||||||||||||||
| 154 | if (in->d !=
| 2-43572 | ||||||||||||||||||||||||
| 155 | ((void *)0)
| 2-43572 | ||||||||||||||||||||||||
| 156 | ) | - | ||||||||||||||||||||||||
| 157 | memcpy(out, in->d, sizeof(*out) * in->top); executed 43572 times by 1 test: memcpy(out, in->d, sizeof(*out) * in->top);Executed by:
| 43572 | ||||||||||||||||||||||||
| 158 | return executed 43574 times by 1 test: 1;return 1;Executed by:
executed 43574 times by 1 test: return 1;Executed by:
| 43574 | ||||||||||||||||||||||||
| 159 | } | - | ||||||||||||||||||||||||
| 160 | - | |||||||||||||||||||||||||
| 161 | unsigned long *bn_get_words(const BIGNUM *a) | - | ||||||||||||||||||||||||
| 162 | { | - | ||||||||||||||||||||||||
| 163 | return executed 29449 times by 1 test: a->d;return a->d;Executed by:
executed 29449 times by 1 test: return a->d;Executed by:
| 29449 | ||||||||||||||||||||||||
| 164 | } | - | ||||||||||||||||||||||||
| 165 | - | |||||||||||||||||||||||||
| 166 | void bn_set_static_words(BIGNUM *a, const unsigned long *words, int size) | - | ||||||||||||||||||||||||
| 167 | { | - | ||||||||||||||||||||||||
| 168 | - | |||||||||||||||||||||||||
| 169 | - | |||||||||||||||||||||||||
| 170 | - | |||||||||||||||||||||||||
| 171 | - | |||||||||||||||||||||||||
| 172 | a->d = (unsigned long *)words; | - | ||||||||||||||||||||||||
| 173 | a->dmax = a->top = size; | - | ||||||||||||||||||||||||
| 174 | a->neg = 0; | - | ||||||||||||||||||||||||
| 175 | a->flags |= 0x02; | - | ||||||||||||||||||||||||
| 176 | bn_correct_top(a); | - | ||||||||||||||||||||||||
| 177 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 178 | - | |||||||||||||||||||||||||
| 179 | int bn_set_words(BIGNUM *a, const unsigned long *words, int num_words) | - | ||||||||||||||||||||||||
| 180 | { | - | ||||||||||||||||||||||||
| 181 | if (bn_wexpand(a, num_words) ==
| 0-31069 | ||||||||||||||||||||||||
| 182 | ((void *)0)
| 0-31069 | ||||||||||||||||||||||||
| 183 | ) { | - | ||||||||||||||||||||||||
| 184 | ERR_put_error(3,(144),((1|64)),__FILE__,191); | - | ||||||||||||||||||||||||
| 185 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 186 | } | - | ||||||||||||||||||||||||
| 187 | - | |||||||||||||||||||||||||
| 188 | memcpy(a->d, words, sizeof(unsigned long) * num_words); | - | ||||||||||||||||||||||||
| 189 | a->top = num_words; | - | ||||||||||||||||||||||||
| 190 | bn_correct_top(a); | - | ||||||||||||||||||||||||
| 191 | return executed 31069 times by 1 test: 1;return 1;Executed by:
executed 31069 times by 1 test: return 1;Executed by:
| 31069 | ||||||||||||||||||||||||
| 192 | } | - | ||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |