| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/bn/bn_add.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) | - | ||||||||||||||||||
| 4 | { | - | ||||||||||||||||||
| 5 | int ret, r_neg, cmp_res; | - | ||||||||||||||||||
| 6 | - | |||||||||||||||||||
| 7 | ; | - | ||||||||||||||||||
| 8 | ; | - | ||||||||||||||||||
| 9 | - | |||||||||||||||||||
| 10 | if (a->neg == b->neg
| 2356233-2479515 | ||||||||||||||||||
| 11 | r_neg = a->neg; | - | ||||||||||||||||||
| 12 | ret = BN_uadd(r, a, b); | - | ||||||||||||||||||
| 13 | } executed 2479515 times by 2 tests: else {end of blockExecuted by:
| 2479515 | ||||||||||||||||||
| 14 | cmp_res = BN_ucmp(a, b); | - | ||||||||||||||||||
| 15 | if (cmp_res > 0
| 217-2356016 | ||||||||||||||||||
| 16 | r_neg = a->neg; | - | ||||||||||||||||||
| 17 | ret = BN_usub(r, a, b); | - | ||||||||||||||||||
| 18 | } executed 217 times by 1 test: else if (cmp_res < 0end of blockExecuted by:
| 4-2356012 | ||||||||||||||||||
| 19 | r_neg = b->neg; | - | ||||||||||||||||||
| 20 | ret = BN_usub(r, b, a); | - | ||||||||||||||||||
| 21 | } executed 2356012 times by 2 tests: else {end of blockExecuted by:
| 2356012 | ||||||||||||||||||
| 22 | r_neg = 0; | - | ||||||||||||||||||
| 23 | (BN_set_word((r),0)); | - | ||||||||||||||||||
| 24 | ret = 1; | - | ||||||||||||||||||
| 25 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||
| 26 | } | - | ||||||||||||||||||
| 27 | - | |||||||||||||||||||
| 28 | r->neg = r_neg; | - | ||||||||||||||||||
| 29 | ; | - | ||||||||||||||||||
| 30 | return executed 4835748 times by 2 tests: ret;return ret;Executed by:
executed 4835748 times by 2 tests: return ret;Executed by:
| 4835748 | ||||||||||||||||||
| 31 | } | - | ||||||||||||||||||
| 32 | - | |||||||||||||||||||
| 33 | - | |||||||||||||||||||
| 34 | int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) | - | ||||||||||||||||||
| 35 | { | - | ||||||||||||||||||
| 36 | int ret, r_neg, cmp_res; | - | ||||||||||||||||||
| 37 | - | |||||||||||||||||||
| 38 | ; | - | ||||||||||||||||||
| 39 | ; | - | ||||||||||||||||||
| 40 | - | |||||||||||||||||||
| 41 | if (a->neg != b->neg
| 413-6458150 | ||||||||||||||||||
| 42 | r_neg = a->neg; | - | ||||||||||||||||||
| 43 | ret = BN_uadd(r, a, b); | - | ||||||||||||||||||
| 44 | } executed 413 times by 1 test: else {end of blockExecuted by:
| 413 | ||||||||||||||||||
| 45 | cmp_res = BN_ucmp(a, b); | - | ||||||||||||||||||
| 46 | if (cmp_res > 0
| 2361250-4096900 | ||||||||||||||||||
| 47 | r_neg = a->neg; | - | ||||||||||||||||||
| 48 | ret = BN_usub(r, a, b); | - | ||||||||||||||||||
| 49 | } executed 4096900 times by 2 tests: else if (cmp_res < 0end of blockExecuted by:
| 5902-4096900 | ||||||||||||||||||
| 50 | r_neg = !b->neg; | - | ||||||||||||||||||
| 51 | ret = BN_usub(r, b, a); | - | ||||||||||||||||||
| 52 | } executed 2355348 times by 2 tests: else {end of blockExecuted by:
| 2355348 | ||||||||||||||||||
| 53 | r_neg = 0; | - | ||||||||||||||||||
| 54 | (BN_set_word((r),0)); | - | ||||||||||||||||||
| 55 | ret = 1; | - | ||||||||||||||||||
| 56 | } executed 5902 times by 1 test: end of blockExecuted by:
| 5902 | ||||||||||||||||||
| 57 | } | - | ||||||||||||||||||
| 58 | - | |||||||||||||||||||
| 59 | r->neg = r_neg; | - | ||||||||||||||||||
| 60 | ; | - | ||||||||||||||||||
| 61 | return executed 6458563 times by 2 tests: ret;return ret;Executed by:
executed 6458563 times by 2 tests: return ret;Executed by:
| 6458563 | ||||||||||||||||||
| 62 | } | - | ||||||||||||||||||
| 63 | - | |||||||||||||||||||
| 64 | - | |||||||||||||||||||
| 65 | int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) | - | ||||||||||||||||||
| 66 | { | - | ||||||||||||||||||
| 67 | int max, min, dif; | - | ||||||||||||||||||
| 68 | const unsigned long *ap, *bp; | - | ||||||||||||||||||
| 69 | unsigned long *rp, carry, t1, t2; | - | ||||||||||||||||||
| 70 | - | |||||||||||||||||||
| 71 | ; | - | ||||||||||||||||||
| 72 | ; | - | ||||||||||||||||||
| 73 | - | |||||||||||||||||||
| 74 | if (a->top < b->top
| 150607-10317130 | ||||||||||||||||||
| 75 | const BIGNUM *tmp; | - | ||||||||||||||||||
| 76 | - | |||||||||||||||||||
| 77 | tmp = a; | - | ||||||||||||||||||
| 78 | a = b; | - | ||||||||||||||||||
| 79 | b = tmp; | - | ||||||||||||||||||
| 80 | } executed 150607 times by 2 tests: end of blockExecuted by:
| 150607 | ||||||||||||||||||
| 81 | max = a->top; | - | ||||||||||||||||||
| 82 | min = b->top; | - | ||||||||||||||||||
| 83 | dif = max - min; | - | ||||||||||||||||||
| 84 | - | |||||||||||||||||||
| 85 | if (bn_wexpand(r, max + 1) ==
| 0-10467737 | ||||||||||||||||||
| 86 | ((void *)0)
| 0-10467737 | ||||||||||||||||||
| 87 | ) | - | ||||||||||||||||||
| 88 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 89 | - | |||||||||||||||||||
| 90 | r->top = max; | - | ||||||||||||||||||
| 91 | - | |||||||||||||||||||
| 92 | ap = a->d; | - | ||||||||||||||||||
| 93 | bp = b->d; | - | ||||||||||||||||||
| 94 | rp = r->d; | - | ||||||||||||||||||
| 95 | - | |||||||||||||||||||
| 96 | carry = bn_add_words(rp, ap, bp, min); | - | ||||||||||||||||||
| 97 | rp += min; | - | ||||||||||||||||||
| 98 | ap += min; | - | ||||||||||||||||||
| 99 | - | |||||||||||||||||||
| 100 | while (dif
| 1667428-10467737 | ||||||||||||||||||
| 101 | dif--; | - | ||||||||||||||||||
| 102 | t1 = *(ap++); | - | ||||||||||||||||||
| 103 | t2 = (t1 + carry) & (0xffffffffffffffffL); | - | ||||||||||||||||||
| 104 | *(rp++) = t2; | - | ||||||||||||||||||
| 105 | carry &= (t2 == 0); | - | ||||||||||||||||||
| 106 | } executed 1667428 times by 2 tests: end of blockExecuted by:
| 1667428 | ||||||||||||||||||
| 107 | *rp = carry; | - | ||||||||||||||||||
| 108 | r->top += carry; | - | ||||||||||||||||||
| 109 | - | |||||||||||||||||||
| 110 | r->neg = 0; | - | ||||||||||||||||||
| 111 | ; | - | ||||||||||||||||||
| 112 | return executed 10467737 times by 2 tests: 1;return 1;Executed by:
executed 10467737 times by 2 tests: return 1;Executed by:
| 10467737 | ||||||||||||||||||
| 113 | } | - | ||||||||||||||||||
| 114 | - | |||||||||||||||||||
| 115 | - | |||||||||||||||||||
| 116 | int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) | - | ||||||||||||||||||
| 117 | { | - | ||||||||||||||||||
| 118 | int max, min, dif; | - | ||||||||||||||||||
| 119 | unsigned long t1, t2, borrow, *rp; | - | ||||||||||||||||||
| 120 | const unsigned long *ap, *bp; | - | ||||||||||||||||||
| 121 | - | |||||||||||||||||||
| 122 | ; | - | ||||||||||||||||||
| 123 | ; | - | ||||||||||||||||||
| 124 | - | |||||||||||||||||||
| 125 | max = a->top; | - | ||||||||||||||||||
| 126 | min = b->top; | - | ||||||||||||||||||
| 127 | dif = max - min; | - | ||||||||||||||||||
| 128 | - | |||||||||||||||||||
| 129 | if (dif < 0
| 0-13895182 | ||||||||||||||||||
| 130 | ERR_put_error(3,(115),(100),__FILE__,139); | - | ||||||||||||||||||
| 131 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 132 | } | - | ||||||||||||||||||
| 133 | - | |||||||||||||||||||
| 134 | if (bn_wexpand(r, max) ==
| 0-13895182 | ||||||||||||||||||
| 135 | ((void *)0)
| 0-13895182 | ||||||||||||||||||
| 136 | ) | - | ||||||||||||||||||
| 137 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 138 | - | |||||||||||||||||||
| 139 | ap = a->d; | - | ||||||||||||||||||
| 140 | bp = b->d; | - | ||||||||||||||||||
| 141 | rp = r->d; | - | ||||||||||||||||||
| 142 | - | |||||||||||||||||||
| 143 | borrow = bn_sub_words(rp, ap, bp, min); | - | ||||||||||||||||||
| 144 | ap += min; | - | ||||||||||||||||||
| 145 | rp += min; | - | ||||||||||||||||||
| 146 | - | |||||||||||||||||||
| 147 | while (dif
| 1173206-13895182 | ||||||||||||||||||
| 148 | dif--; | - | ||||||||||||||||||
| 149 | t1 = *(ap++); | - | ||||||||||||||||||
| 150 | t2 = (t1 - borrow) & (0xffffffffffffffffL); | - | ||||||||||||||||||
| 151 | *(rp++) = t2; | - | ||||||||||||||||||
| 152 | borrow &= (t1 == 0); | - | ||||||||||||||||||
| 153 | } executed 1173206 times by 2 tests: end of blockExecuted by:
| 1173206 | ||||||||||||||||||
| 154 | - | |||||||||||||||||||
| 155 | while (max
| 70161-16205684 | ||||||||||||||||||
| 156 | max--; executed 2380663 times by 2 tests: max--;Executed by:
| 2380663 | ||||||||||||||||||
| 157 | - | |||||||||||||||||||
| 158 | r->top = max; | - | ||||||||||||||||||
| 159 | r->neg = 0; | - | ||||||||||||||||||
| 160 | ; | - | ||||||||||||||||||
| 161 | - | |||||||||||||||||||
| 162 | return executed 13895182 times by 2 tests: 1;return 1;Executed by:
executed 13895182 times by 2 tests: return 1;Executed by:
| 13895182 | ||||||||||||||||||
| 163 | } | - | ||||||||||||||||||
| Switch to Source code | Preprocessed file |