| Line | Source | Count |
| 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 | | - |
| 35 | | - |
| 36 | | - |
| 37 | | - |
| 38 | | - |
| 39 | | - |
| 40 | | - |
| 41 | | - |
| 42 | | - |
| 43 | | - |
| 44 | | - |
| 45 | | - |
| 46 | | - |
| 47 | | - |
| 48 | | - |
| 49 | | - |
| 50 | | - |
| 51 | | - |
| 52 | | - |
| 53 | | - |
| 54 | | - |
| 55 | | - |
| 56 | #include "bn_lcl.h" | - |
| 57 | | - |
| 58 | | - |
| 59 | #define BN_lsw(n) (((n)->top == 0) ? (BN_ULONG) 0 : (n)->d[0]) | - |
| 60 | | - |
| 61 | | - |
| 62 | int | - |
| 63 | BN_kronecker(const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) | - |
| 64 | { | - |
| 65 | int i; | - |
| 66 | int ret = -2; | - |
| 67 | int err = 0; | - |
| 68 | BIGNUM *A, *B, *tmp; | - |
| 69 | | - |
| 70 | | - |
| 71 | | - |
| 72 | | - |
| 73 | | - |
| 74 | | - |
| 75 | | - |
| 76 | static const int tab[8] = {0, 1, 0, -1, 0, -1, 0, 1}; | - |
| 77 | | - |
| 78 | bn_check_top(a); | - |
| 79 | bn_check_top(b); | - |
| 80 | | - |
| 81 | BN_CTX_start(ctx); | - |
| 82 | if ((A = BN_CTX_get(ctx)) == NULL)| TRUE | never evaluated | | FALSE | evaluated 140 times by 2 tests |
| 0-140 |
| 83 | goto end; never executed: goto end; | 0 |
| 84 | if ((B = BN_CTX_get(ctx)) == NULL)| TRUE | never evaluated | | FALSE | evaluated 140 times by 2 tests |
| 0-140 |
| 85 | goto end; never executed: goto end; | 0 |
| 86 | | - |
| 87 | err = !BN_copy(A, a); | - |
| 88 | if (err)| TRUE | never evaluated | | FALSE | evaluated 140 times by 2 tests |
| 0-140 |
| 89 | goto end; never executed: goto end; | 0 |
| 90 | err = !BN_copy(B, b); | - |
| 91 | if (err)| TRUE | never evaluated | | FALSE | evaluated 140 times by 2 tests |
| 0-140 |
| 92 | goto end; never executed: goto end; | 0 |
| 93 | | - |
| 94 | | - |
| 95 | | - |
| 96 | | - |
| 97 | | - |
| 98 | | - |
| 99 | | - |
| 100 | | - |
| 101 | | - |
| 102 | if (BN_is_zero(B)) {| TRUE | never evaluated | | FALSE | evaluated 140 times by 2 tests |
| 0-140 |
| 103 | ret = BN_abs_is_word(A, 1);| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 104 | goto end; never executed: goto end; | 0 |
| 105 | } | - |
| 106 | | - |
| 107 | | - |
| 108 | | - |
| 109 | if (!BN_is_odd(A) && !BN_is_odd(B)) {| TRUE | evaluated 140 times by 2 tests | | FALSE | never evaluated |
| TRUE | evaluated 69 times by 2 tests | | FALSE | evaluated 71 times by 2 tests |
| TRUE | evaluated 71 times by 2 tests | | FALSE | never evaluated |
| TRUE | evaluated 71 times by 2 tests | | FALSE | never evaluated |
| 0-140 |
| 110 | ret = 0; | - |
| 111 | goto end; never executed: goto end; | 0 |
| 112 | } | - |
| 113 | | - |
| 114 | | - |
| 115 | i = 0; | - |
| 116 | while (!BN_is_bit_set(B, i))| TRUE | never evaluated | | FALSE | evaluated 140 times by 2 tests |
| 0-140 |
| 117 | i++; never executed: i++; | 0 |
| 118 | err = !BN_rshift(B, B, i); | - |
| 119 | if (err)| TRUE | never evaluated | | FALSE | evaluated 140 times by 2 tests |
| 0-140 |
| 120 | goto end; never executed: goto end; | 0 |
| 121 | if (i & 1) {| TRUE | never evaluated | | FALSE | evaluated 140 times by 2 tests |
| 0-140 |
| 122 | | - |
| 123 | | - |
| 124 | | - |
| 125 | | - |
| 126 | ret = tab[BN_lsw(A) & 7]; | - |
| 127 | } else { never executed: end of block | 0 |
| 128 | | - |
| 129 | ret = 1; | - |
| 130 | }executed 140 times by 2 tests: end of block | 140 |
| 131 | | - |
| 132 | if (B->neg) {| TRUE | evaluated 100 times by 1 test | | FALSE | evaluated 40 times by 2 tests |
| 40-100 |
| 133 | B->neg = 0; | - |
| 134 | if (A->neg)| TRUE | evaluated 50 times by 1 test | | FALSE | evaluated 50 times by 1 test |
| 50 |
| 135 | ret = -ret;executed 50 times by 1 test: ret = -ret; | 50 |
| 136 | }executed 100 times by 1 test: end of block | 100 |
| 137 | | - |
| 138 | | - |
| 139 | | - |
| 140 | | - |
| 141 | while (1) { | - |
| 142 | | - |
| 143 | | - |
| 144 | | - |
| 145 | | - |
| 146 | if (BN_is_zero(A)) {| TRUE | evaluated 140 times by 2 tests | | FALSE | evaluated 18638 times by 2 tests |
| 140-18638 |
| 147 | ret = BN_is_one(B) ? ret : 0;| TRUE | evaluated 140 times by 2 tests | | FALSE | never evaluated |
| TRUE | evaluated 140 times by 2 tests | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | evaluated 140 times by 2 tests | | FALSE | never evaluated |
| 0-140 |
| 148 | goto end;executed 140 times by 2 tests: goto end; | 140 |
| 149 | } | - |
| 150 | | - |
| 151 | | - |
| 152 | i = 0; | - |
| 153 | while (!BN_is_bit_set(A, i))| TRUE | evaluated 21111 times by 2 tests | | FALSE | evaluated 18638 times by 2 tests |
| 18638-21111 |
| 154 | i++;executed 21111 times by 2 tests: i++; | 21111 |
| 155 | err = !BN_rshift(A, A, i); | - |
| 156 | if (err)| TRUE | never evaluated | | FALSE | evaluated 18638 times by 2 tests |
| 0-18638 |
| 157 | goto end; never executed: goto end; | 0 |
| 158 | if (i & 1) {| TRUE | evaluated 6769 times by 2 tests | | FALSE | evaluated 11869 times by 2 tests |
| 6769-11869 |
| 159 | | - |
| 160 | | - |
| 161 | ret = ret * tab[BN_lsw(B) & 7]; | - |
| 162 | }executed 6769 times by 2 tests: end of block | 6769 |
| 163 | | - |
| 164 | | - |
| 165 | | - |
| 166 | if ((A->neg ? ~BN_lsw(A) : BN_lsw(A)) & BN_lsw(B) & 2)| TRUE | evaluated 4646 times by 1 test | | FALSE | evaluated 13992 times by 2 tests |
| TRUE | evaluated 50 times by 1 test | | FALSE | evaluated 18588 times by 2 tests |
| TRUE | never evaluated | | FALSE | evaluated 18588 times by 2 tests |
| 0-18588 |
| 167 | ret = -ret;executed 4646 times by 1 test: ret = -ret; | 4646 |
| 168 | | - |
| 169 | | - |
| 170 | err = !BN_nnmod(B, B, A, ctx); | - |
| 171 | if (err)| TRUE | never evaluated | | FALSE | evaluated 18638 times by 2 tests |
| 0-18638 |
| 172 | goto end; never executed: goto end; | 0 |
| 173 | tmp = A; | - |
| 174 | A = B; | - |
| 175 | B = tmp; | - |
| 176 | tmp->neg = 0; | - |
| 177 | }executed 18638 times by 2 tests: end of block | 18638 |
| 178 | | - |
| 179 | end: code before this statement never executed: end: | 0 |
| 180 | BN_CTX_end(ctx); | - |
| 181 | if (err)| TRUE | never evaluated | | FALSE | evaluated 140 times by 2 tests |
| 0-140 |
| 182 | return -2; never executed: return -2; | 0 |
| 183 | else | - |
| 184 | return ret;executed 140 times by 2 tests: return ret; | 140 |
| 185 | } | - |
| | |