| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/rsa/rsa_crpt.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | int RSA_bits(const RSA *r) | - | ||||||||||||
| 3 | { | - | ||||||||||||
| 4 | return executed 20 times by 1 test: BN_num_bits(r->n);return BN_num_bits(r->n);Executed by:
executed 20 times by 1 test: return BN_num_bits(r->n);Executed by:
| 20 | ||||||||||||
| 5 | } | - | ||||||||||||
| 6 | - | |||||||||||||
| 7 | int RSA_size(const RSA *r) | - | ||||||||||||
| 8 | { | - | ||||||||||||
| 9 | return executed 15070 times by 1 test: ((BN_num_bits(r->n)+7)/8);return ((BN_num_bits(r->n)+7)/8);Executed by:
executed 15070 times by 1 test: return ((BN_num_bits(r->n)+7)/8);Executed by:
| 15070 | ||||||||||||
| 10 | } | - | ||||||||||||
| 11 | - | |||||||||||||
| 12 | int RSA_public_encrypt(int flen, const unsigned char *from, unsigned char *to, | - | ||||||||||||
| 13 | RSA *rsa, int padding) | - | ||||||||||||
| 14 | { | - | ||||||||||||
| 15 | return executed 499 times by 1 test: rsa->meth->rsa_pub_enc(flen, from, to, rsa, padding);return rsa->meth->rsa_pub_enc(flen, from, to, rsa, padding);Executed by:
executed 499 times by 1 test: return rsa->meth->rsa_pub_enc(flen, from, to, rsa, padding);Executed by:
| 499 | ||||||||||||
| 16 | } | - | ||||||||||||
| 17 | - | |||||||||||||
| 18 | int RSA_private_encrypt(int flen, const unsigned char *from, | - | ||||||||||||
| 19 | unsigned char *to, RSA *rsa, int padding) | - | ||||||||||||
| 20 | { | - | ||||||||||||
| 21 | return executed 1651 times by 1 test: rsa->meth->rsa_priv_enc(flen, from, to, rsa, padding);return rsa->meth->rsa_priv_enc(flen, from, to, rsa, padding);Executed by:
executed 1651 times by 1 test: return rsa->meth->rsa_priv_enc(flen, from, to, rsa, padding);Executed by:
| 1651 | ||||||||||||
| 22 | } | - | ||||||||||||
| 23 | - | |||||||||||||
| 24 | int RSA_private_decrypt(int flen, const unsigned char *from, | - | ||||||||||||
| 25 | unsigned char *to, RSA *rsa, int padding) | - | ||||||||||||
| 26 | { | - | ||||||||||||
| 27 | return executed 735 times by 1 test: rsa->meth->rsa_priv_dec(flen, from, to, rsa, padding);return rsa->meth->rsa_priv_dec(flen, from, to, rsa, padding);Executed by:
executed 735 times by 1 test: return rsa->meth->rsa_priv_dec(flen, from, to, rsa, padding);Executed by:
| 735 | ||||||||||||
| 28 | } | - | ||||||||||||
| 29 | - | |||||||||||||
| 30 | int RSA_public_decrypt(int flen, const unsigned char *from, unsigned char *to, | - | ||||||||||||
| 31 | RSA *rsa, int padding) | - | ||||||||||||
| 32 | { | - | ||||||||||||
| 33 | return executed 2776 times by 1 test: rsa->meth->rsa_pub_dec(flen, from, to, rsa, padding);return rsa->meth->rsa_pub_dec(flen, from, to, rsa, padding);Executed by:
executed 2776 times by 1 test: return rsa->meth->rsa_pub_dec(flen, from, to, rsa, padding);Executed by:
| 2776 | ||||||||||||
| 34 | } | - | ||||||||||||
| 35 | - | |||||||||||||
| 36 | int RSA_flags(const RSA *r) | - | ||||||||||||
| 37 | { | - | ||||||||||||
| 38 | return executed 3942 times by 1 test: r == return r == ((void *)0) ? 0 : r->meth->flags;Executed by:
executed 3942 times by 1 test: return r == ((void *)0) ? 0 : r->meth->flags;Executed by:
| 0-3942 | ||||||||||||
| 39 | ((void *)0)
executed 3942 times by 1 test: return r == ((void *)0) ? 0 : r->meth->flags;Executed by:
| 0-3942 | ||||||||||||
| 40 | ? 0 : r->meth->flags; executed 3942 times by 1 test: return r == ((void *)0) ? 0 : r->meth->flags;Executed by:
| 3942 | ||||||||||||
| 41 | } | - | ||||||||||||
| 42 | - | |||||||||||||
| 43 | void RSA_blinding_off(RSA *rsa) | - | ||||||||||||
| 44 | { | - | ||||||||||||
| 45 | BN_BLINDING_free(rsa->blinding); | - | ||||||||||||
| 46 | rsa->blinding = | - | ||||||||||||
| 47 | ((void *)0) | - | ||||||||||||
| 48 | ; | - | ||||||||||||
| 49 | rsa->flags &= ~0x0008; | - | ||||||||||||
| 50 | rsa->flags |= 0x0080; | - | ||||||||||||
| 51 | } never executed: end of block | 0 | ||||||||||||
| 52 | - | |||||||||||||
| 53 | int RSA_blinding_on(RSA *rsa, BN_CTX *ctx) | - | ||||||||||||
| 54 | { | - | ||||||||||||
| 55 | int ret = 0; | - | ||||||||||||
| 56 | - | |||||||||||||
| 57 | if (rsa->blinding !=
| 0 | ||||||||||||
| 58 | ((void *)0)
| 0 | ||||||||||||
| 59 | ) | - | ||||||||||||
| 60 | RSA_blinding_off(rsa); never executed: RSA_blinding_off(rsa); | 0 | ||||||||||||
| 61 | - | |||||||||||||
| 62 | rsa->blinding = RSA_setup_blinding(rsa, ctx); | - | ||||||||||||
| 63 | if (rsa->blinding ==
| 0 | ||||||||||||
| 64 | ((void *)0)
| 0 | ||||||||||||
| 65 | ) | - | ||||||||||||
| 66 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||
| 67 | - | |||||||||||||
| 68 | rsa->flags |= 0x0008; | - | ||||||||||||
| 69 | rsa->flags &= ~0x0080; | - | ||||||||||||
| 70 | ret = 1; | - | ||||||||||||
| 71 | err: code before this statement never executed: err: | 0 | ||||||||||||
| 72 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||
| 73 | } | - | ||||||||||||
| 74 | - | |||||||||||||
| 75 | static BIGNUM *rsa_get_public_exp(const BIGNUM *d, const BIGNUM *p, | - | ||||||||||||
| 76 | const BIGNUM *q, BN_CTX *ctx) | - | ||||||||||||
| 77 | { | - | ||||||||||||
| 78 | BIGNUM *ret = | - | ||||||||||||
| 79 | ((void *)0) | - | ||||||||||||
| 80 | , *r0, *r1, *r2; | - | ||||||||||||
| 81 | - | |||||||||||||
| 82 | if (d ==
| 0 | ||||||||||||
| 83 | ((void *)0)
| 0 | ||||||||||||
| 84 | || p ==
| 0 | ||||||||||||
| 85 | ((void *)0)
| 0 | ||||||||||||
| 86 | || q ==
| 0 | ||||||||||||
| 87 | ((void *)0)
| 0 | ||||||||||||
| 88 | ) | - | ||||||||||||
| 89 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||
| 90 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||
| 91 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||
| 92 | - | |||||||||||||
| 93 | BN_CTX_start(ctx); | - | ||||||||||||
| 94 | r0 = BN_CTX_get(ctx); | - | ||||||||||||
| 95 | r1 = BN_CTX_get(ctx); | - | ||||||||||||
| 96 | r2 = BN_CTX_get(ctx); | - | ||||||||||||
| 97 | if (r2 ==
| 0 | ||||||||||||
| 98 | ((void *)0)
| 0 | ||||||||||||
| 99 | ) | - | ||||||||||||
| 100 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||
| 101 | - | |||||||||||||
| 102 | if (!BN_sub(r1, p, BN_value_one())
| 0 | ||||||||||||
| 103 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||
| 104 | if (!BN_sub(r2, q, BN_value_one())
| 0 | ||||||||||||
| 105 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||
| 106 | if (!BN_mul(r0, r1, r2, ctx)
| 0 | ||||||||||||
| 107 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||
| 108 | - | |||||||||||||
| 109 | ret = BN_mod_inverse( | - | ||||||||||||
| 110 | ((void *)0) | - | ||||||||||||
| 111 | , d, r0, ctx); | - | ||||||||||||
| 112 | err: code before this statement never executed: err: | 0 | ||||||||||||
| 113 | BN_CTX_end(ctx); | - | ||||||||||||
| 114 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||
| 115 | } | - | ||||||||||||
| 116 | - | |||||||||||||
| 117 | BN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *in_ctx) | - | ||||||||||||
| 118 | { | - | ||||||||||||
| 119 | BIGNUM *e; | - | ||||||||||||
| 120 | BN_CTX *ctx; | - | ||||||||||||
| 121 | BN_BLINDING *ret = | - | ||||||||||||
| 122 | ((void *)0) | - | ||||||||||||
| 123 | ; | - | ||||||||||||
| 124 | - | |||||||||||||
| 125 | if (in_ctx ==
| 0-1733 | ||||||||||||
| 126 | ((void *)0)
| 0-1733 | ||||||||||||
| 127 | ) { | - | ||||||||||||
| 128 | if ((
| 0 | ||||||||||||
| 129 | ((void *)0)
| 0 | ||||||||||||
| 130 | ) | - | ||||||||||||
| 131 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||
| 132 | } never executed: else {end of block | 0 | ||||||||||||
| 133 | ctx = in_ctx; | - | ||||||||||||
| 134 | } executed 1733 times by 1 test: end of blockExecuted by:
| 1733 | ||||||||||||
| 135 | - | |||||||||||||
| 136 | BN_CTX_start(ctx); | - | ||||||||||||
| 137 | e = BN_CTX_get(ctx); | - | ||||||||||||
| 138 | if (e ==
| 0-1733 | ||||||||||||
| 139 | ((void *)0)
| 0-1733 | ||||||||||||
| 140 | ) { | - | ||||||||||||
| 141 | ERR_put_error(4,(136),((1|64)),__FILE__,126); | - | ||||||||||||
| 142 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||
| 143 | } | - | ||||||||||||
| 144 | - | |||||||||||||
| 145 | if (rsa->e ==
| 0-1733 | ||||||||||||
| 146 | ((void *)0)
| 0-1733 | ||||||||||||
| 147 | ) { | - | ||||||||||||
| 148 | e = rsa_get_public_exp(rsa->d, rsa->p, rsa->q, ctx); | - | ||||||||||||
| 149 | if (e ==
| 0 | ||||||||||||
| 150 | ((void *)0)
| 0 | ||||||||||||
| 151 | ) { | - | ||||||||||||
| 152 | ERR_put_error(4,(136),(140),__FILE__,133); | - | ||||||||||||
| 153 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||
| 154 | } | - | ||||||||||||
| 155 | } never executed: else {end of block | 0 | ||||||||||||
| 156 | e = rsa->e; | - | ||||||||||||
| 157 | } executed 1733 times by 1 test: end of blockExecuted by:
| 1733 | ||||||||||||
| 158 | - | |||||||||||||
| 159 | { | - | ||||||||||||
| 160 | BIGNUM *n = BN_new(); | - | ||||||||||||
| 161 | - | |||||||||||||
| 162 | if (n ==
| 0-1733 | ||||||||||||
| 163 | ((void *)0)
| 0-1733 | ||||||||||||
| 164 | ) { | - | ||||||||||||
| 165 | ERR_put_error(4,(136),((1|64)),__FILE__,144); | - | ||||||||||||
| 166 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||
| 167 | } | - | ||||||||||||
| 168 | BN_with_flags(n, rsa->n, 0x04); | - | ||||||||||||
| 169 | - | |||||||||||||
| 170 | ret = BN_BLINDING_create_param( | - | ||||||||||||
| 171 | ((void *)0) | - | ||||||||||||
| 172 | , e, n, ctx, rsa->meth->bn_mod_exp, | - | ||||||||||||
| 173 | rsa->_method_mod_n); | - | ||||||||||||
| 174 | - | |||||||||||||
| 175 | BN_free(n); | - | ||||||||||||
| 176 | } | - | ||||||||||||
| 177 | if (ret ==
| 0-1733 | ||||||||||||
| 178 | ((void *)0)
| 0-1733 | ||||||||||||
| 179 | ) { | - | ||||||||||||
| 180 | ERR_put_error(4,(136),(3),__FILE__,155); | - | ||||||||||||
| 181 | goto never executed: err;goto err;never executed: goto err; | 0 | ||||||||||||
| 182 | } | - | ||||||||||||
| 183 | - | |||||||||||||
| 184 | BN_BLINDING_set_current_thread(ret); | - | ||||||||||||
| 185 | - | |||||||||||||
| 186 | err: code before this statement executed 1733 times by 1 test: err:Executed by:
| 1733 | ||||||||||||
| 187 | BN_CTX_end(ctx); | - | ||||||||||||
| 188 | if (ctx != in_ctx
| 0-1733 | ||||||||||||
| 189 | BN_CTX_free(ctx); never executed: BN_CTX_free(ctx); | 0 | ||||||||||||
| 190 | if (e != rsa->e
| 0-1733 | ||||||||||||
| 191 | BN_free(e); never executed: BN_free(e); | 0 | ||||||||||||
| 192 | - | |||||||||||||
| 193 | return executed 1733 times by 1 test: ret;return ret;Executed by:
executed 1733 times by 1 test: return ret;Executed by:
| 1733 | ||||||||||||
| 194 | } | - | ||||||||||||
| Switch to Source code | Preprocessed file |