| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/bn/bn_shift.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | int BN_lshift1(BIGNUM *r, const BIGNUM *a) | - | ||||||||||||
| 3 | { | - | ||||||||||||
| 4 | register unsigned long *ap, *rp, t, c; | - | ||||||||||||
| 5 | int i; | - | ||||||||||||
| 6 | - | |||||||||||||
| 7 | ; | - | ||||||||||||
| 8 | ; | - | ||||||||||||
| 9 | - | |||||||||||||
| 10 | if (r != a
| 515226-1968061 | ||||||||||||
| 11 | r->neg = a->neg; | - | ||||||||||||
| 12 | if (bn_wexpand(r, a->top + 1) ==
| 0-515226 | ||||||||||||
| 13 | ((void *)0)
| 0-515226 | ||||||||||||
| 14 | ) | - | ||||||||||||
| 15 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 16 | r->top = a->top; | - | ||||||||||||
| 17 | } executed 515226 times by 2 tests: else {end of blockExecuted by:
| 515226 | ||||||||||||
| 18 | if (bn_wexpand(r, a->top + 1) ==
| 0-1968061 | ||||||||||||
| 19 | ((void *)0)
| 0-1968061 | ||||||||||||
| 20 | ) | - | ||||||||||||
| 21 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 22 | } executed 1968061 times by 2 tests: end of blockExecuted by:
| 1968061 | ||||||||||||
| 23 | ap = a->d; | - | ||||||||||||
| 24 | rp = r->d; | - | ||||||||||||
| 25 | c = 0; | - | ||||||||||||
| 26 | for (i = 0; i < a->top
| 2483287-14493324 | ||||||||||||
| 27 | t = *(ap++); | - | ||||||||||||
| 28 | *(rp++) = ((t << 1) | c) & (0xffffffffffffffffL); | - | ||||||||||||
| 29 | c = (
| 6873524-7619800 | ||||||||||||
| 30 | } executed 14493324 times by 2 tests: end of blockExecuted by:
| 14493324 | ||||||||||||
| 31 | if (c
| 795961-1687326 | ||||||||||||
| 32 | *rp = 1; | - | ||||||||||||
| 33 | r->top++; | - | ||||||||||||
| 34 | } executed 795961 times by 2 tests: end of blockExecuted by:
| 795961 | ||||||||||||
| 35 | ; | - | ||||||||||||
| 36 | return executed 2483287 times by 2 tests: 1;return 1;Executed by:
executed 2483287 times by 2 tests: return 1;Executed by:
| 2483287 | ||||||||||||
| 37 | } | - | ||||||||||||
| 38 | - | |||||||||||||
| 39 | int BN_rshift1(BIGNUM *r, const BIGNUM *a) | - | ||||||||||||
| 40 | { | - | ||||||||||||
| 41 | unsigned long *ap, *rp, t, c; | - | ||||||||||||
| 42 | int i, j; | - | ||||||||||||
| 43 | - | |||||||||||||
| 44 | ; | - | ||||||||||||
| 45 | ; | - | ||||||||||||
| 46 | - | |||||||||||||
| 47 | if (BN_is_zero(a)
| 27-5356044 | ||||||||||||
| 48 | (BN_set_word((r),0)); | - | ||||||||||||
| 49 | return executed 27 times by 1 test: 1;return 1;Executed by:
executed 27 times by 1 test: return 1;Executed by:
| 27 | ||||||||||||
| 50 | } | - | ||||||||||||
| 51 | i = a->top; | - | ||||||||||||
| 52 | ap = a->d; | - | ||||||||||||
| 53 | j = i - (ap[i - 1] == 1); | - | ||||||||||||
| 54 | if (a != r
| 56338-5299706 | ||||||||||||
| 55 | if (bn_wexpand(r, j) ==
| 0-56338 | ||||||||||||
| 56 | ((void *)0)
| 0-56338 | ||||||||||||
| 57 | ) | - | ||||||||||||
| 58 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 59 | r->neg = a->neg; | - | ||||||||||||
| 60 | } executed 56338 times by 2 tests: end of blockExecuted by:
| 56338 | ||||||||||||
| 61 | rp = r->d; | - | ||||||||||||
| 62 | t = ap[--i]; | - | ||||||||||||
| 63 | c = (
| 2119695-3236349 | ||||||||||||
| 64 | if (t >>= 1
| 1839120-3516924 | ||||||||||||
| 65 | rp[i] = t; executed 3516924 times by 2 tests: rp[i] = t;Executed by:
| 3516924 | ||||||||||||
| 66 | while (i > 0
| 5356044-10396202 | ||||||||||||
| 67 | t = ap[--i]; | - | ||||||||||||
| 68 | rp[i] = ((t >> 1) & (0xffffffffffffffffL)) | c; | - | ||||||||||||
| 69 | c = (
| 2358710-8037492 | ||||||||||||
| 70 | } executed 10396202 times by 2 tests: end of blockExecuted by:
| 10396202 | ||||||||||||
| 71 | r->top = j; | - | ||||||||||||
| 72 | if (!r->top
| 7-5356037 | ||||||||||||
| 73 | r->neg = 0; executed 7 times by 1 test: r->neg = 0;Executed by:
| 7 | ||||||||||||
| 74 | ; | - | ||||||||||||
| 75 | return executed 5356044 times by 2 tests: 1;return 1;Executed by:
executed 5356044 times by 2 tests: return 1;Executed by:
| 5356044 | ||||||||||||
| 76 | } | - | ||||||||||||
| 77 | - | |||||||||||||
| 78 | int BN_lshift(BIGNUM *r, const BIGNUM *a, int n) | - | ||||||||||||
| 79 | { | - | ||||||||||||
| 80 | int i, nw, lb, rb; | - | ||||||||||||
| 81 | unsigned long *t, *f; | - | ||||||||||||
| 82 | unsigned long l; | - | ||||||||||||
| 83 | - | |||||||||||||
| 84 | ; | - | ||||||||||||
| 85 | ; | - | ||||||||||||
| 86 | - | |||||||||||||
| 87 | if (n < 0
| 0-14793446 | ||||||||||||
| 88 | ERR_put_error(3,(145),(119),__FILE__,93); | - | ||||||||||||
| 89 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 90 | } | - | ||||||||||||
| 91 | - | |||||||||||||
| 92 | nw = n / (8 * 8); | - | ||||||||||||
| 93 | if (bn_wexpand(r, a->top + nw + 1) ==
| 0-14793446 | ||||||||||||
| 94 | ((void *)0)
| 0-14793446 | ||||||||||||
| 95 | ) | - | ||||||||||||
| 96 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 97 | r->neg = a->neg; | - | ||||||||||||
| 98 | lb = n % (8 * 8); | - | ||||||||||||
| 99 | rb = (8 * 8) - lb; | - | ||||||||||||
| 100 | f = a->d; | - | ||||||||||||
| 101 | t = r->d; | - | ||||||||||||
| 102 | t[a->top + nw] = 0; | - | ||||||||||||
| 103 | if (lb == 0
| 653604-14139842 | ||||||||||||
| 104 | for (i = a->top - 1; i >= 0
| 653604-5503450 | ||||||||||||
| 105 | t[nw + i] = f[i]; executed 5503450 times by 2 tests: t[nw + i] = f[i];Executed by:
| 5503450 | ||||||||||||
| 106 | else | - | ||||||||||||
| 107 | for (i = a->top - 1; i >= 0
| 14139842-122548139 | ||||||||||||
| 108 | l = f[i]; | - | ||||||||||||
| 109 | t[nw + i + 1] |= (l >> rb) & (0xffffffffffffffffL); | - | ||||||||||||
| 110 | t[nw + i] = (l << lb) & (0xffffffffffffffffL); | - | ||||||||||||
| 111 | } executed 122548139 times by 2 tests: end of blockExecuted by:
| 122548139 | ||||||||||||
| 112 | memset(t, 0, sizeof(*t) * nw); | - | ||||||||||||
| 113 | r->top = a->top + nw + 1; | - | ||||||||||||
| 114 | bn_correct_top(r); | - | ||||||||||||
| 115 | ; | - | ||||||||||||
| 116 | return executed 14793446 times by 2 tests: 1;return 1;Executed by:
executed 14793446 times by 2 tests: return 1;Executed by:
| 14793446 | ||||||||||||
| 117 | } | - | ||||||||||||
| 118 | - | |||||||||||||
| 119 | int BN_rshift(BIGNUM *r, const BIGNUM *a, int n) | - | ||||||||||||
| 120 | { | - | ||||||||||||
| 121 | int i, j, nw, lb, rb; | - | ||||||||||||
| 122 | unsigned long *t, *f; | - | ||||||||||||
| 123 | unsigned long l, tmp; | - | ||||||||||||
| 124 | - | |||||||||||||
| 125 | ; | - | ||||||||||||
| 126 | ; | - | ||||||||||||
| 127 | - | |||||||||||||
| 128 | if (n < 0
| 0-11958314 | ||||||||||||
| 129 | ERR_put_error(3,(146),(119),__FILE__,132); | - | ||||||||||||
| 130 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 131 | } | - | ||||||||||||
| 132 | - | |||||||||||||
| 133 | nw = n / (8 * 8); | - | ||||||||||||
| 134 | rb = n % (8 * 8); | - | ||||||||||||
| 135 | lb = (8 * 8) - rb; | - | ||||||||||||
| 136 | if (nw >= a->top
| 0-11924943 | ||||||||||||
| 137 | (BN_set_word((r),0)); | - | ||||||||||||
| 138 | return executed 33371 times by 1 test: 1;return 1;Executed by:
executed 33371 times by 1 test: return 1;Executed by:
| 33371 | ||||||||||||
| 139 | } | - | ||||||||||||
| 140 | i = (BN_num_bits(a) - n + ((8 * 8) - 1)) / (8 * 8); | - | ||||||||||||
| 141 | if (r != a
| 4840297-7084646 | ||||||||||||
| 142 | if (bn_wexpand(r, i) ==
| 0-7084646 | ||||||||||||
| 143 | ((void *)0)
| 0-7084646 | ||||||||||||
| 144 | ) | - | ||||||||||||
| 145 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 146 | r->neg = a->neg; | - | ||||||||||||
| 147 | } executed 7084646 times by 2 tests: else {end of blockExecuted by:
| 7084646 | ||||||||||||
| 148 | if (n == 0
| 70216-4770081 | ||||||||||||
| 149 | return executed 70216 times by 1 test: 1;return 1;Executed by:
executed 70216 times by 1 test: return 1;Executed by:
| 70216 | ||||||||||||
| 150 | } executed 4770081 times by 2 tests: end of blockExecuted by:
| 4770081 | ||||||||||||
| 151 | - | |||||||||||||
| 152 | f = &(a->d[nw]); | - | ||||||||||||
| 153 | t = r->d; | - | ||||||||||||
| 154 | j = a->top - nw; | - | ||||||||||||
| 155 | r->top = i; | - | ||||||||||||
| 156 | - | |||||||||||||
| 157 | if (rb == 0
| 340750-11513977 | ||||||||||||
| 158 | for (i = j; i != 0
| 340750-3128235 | ||||||||||||
| 159 | *( executed 3128235 times by 2 tests: t++) = *(f++);*(t++) = *(f++);Executed by:
executed 3128235 times by 2 tests: *(t++) = *(f++);Executed by:
| 3128235 | ||||||||||||
| 160 | } executed 340750 times by 2 tests: else {end of blockExecuted by:
| 340750 | ||||||||||||
| 161 | l = *(f++); | - | ||||||||||||
| 162 | for (i = j - 1; i != 0
| 11513977-48326049 | ||||||||||||
| 163 | tmp = (l >> rb) & (0xffffffffffffffffL); | - | ||||||||||||
| 164 | l = *(f++); | - | ||||||||||||
| 165 | *(t++) = (tmp | (l << lb)) & (0xffffffffffffffffL); | - | ||||||||||||
| 166 | } executed 48326049 times by 2 tests: end of blockExecuted by:
| 48326049 | ||||||||||||
| 167 | if ((
| 169035-11344942 | ||||||||||||
| 168 | *( executed 11344942 times by 2 tests: t) = l;*(t) = l;Executed by:
executed 11344942 times by 2 tests: *(t) = l;Executed by:
| 11344942 | ||||||||||||
| 169 | } executed 11513977 times by 2 tests: end of blockExecuted by:
| 11513977 | ||||||||||||
| 170 | if (!r->top
| 464-11854263 | ||||||||||||
| 171 | r->neg = 0; executed 464 times by 1 test: r->neg = 0;Executed by:
| 464 | ||||||||||||
| 172 | ; | - | ||||||||||||
| 173 | return executed 11854727 times by 2 tests: 1;return 1;Executed by:
executed 11854727 times by 2 tests: return 1;Executed by:
| 11854727 | ||||||||||||
| 174 | } | - | ||||||||||||
| Switch to Source code | Preprocessed file |