| 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 | | - |
| 57 | | - |
| 58 | | - |
| 59 | #include <limits.h> | - |
| 60 | #include <stdio.h> | - |
| 61 | #include <string.h> | - |
| 62 | | - |
| 63 | #include <openssl/opensslconf.h> | - |
| 64 | | - |
| 65 | #include <openssl/asn1t.h> | - |
| 66 | #include <openssl/bn.h> | - |
| 67 | #include <openssl/err.h> | - |
| 68 | #include <openssl/evp.h> | - |
| 69 | #include <openssl/rsa.h> | - |
| 70 | #include <openssl/x509.h> | - |
| 71 | | - |
| 72 | | - |
| 73 | #include "evp_locl.h" | - |
| 74 | #include "rsa_locl.h" | - |
| 75 | | - |
| 76 | | - |
| 77 | | - |
| 78 | typedef struct { | - |
| 79 | | - |
| 80 | int nbits; | - |
| 81 | BIGNUM *pub_exp; | - |
| 82 | | - |
| 83 | int gentmp[2]; | - |
| 84 | | - |
| 85 | int pad_mode; | - |
| 86 | | - |
| 87 | const EVP_MD *md; | - |
| 88 | | - |
| 89 | const EVP_MD *mgf1md; | - |
| 90 | | - |
| 91 | int saltlen; | - |
| 92 | | - |
| 93 | unsigned char *tbuf; | - |
| 94 | } RSA_PKEY_CTX; | - |
| 95 | | - |
| 96 | static int | - |
| 97 | pkey_rsa_init(EVP_PKEY_CTX *ctx) | - |
| 98 | { | - |
| 99 | RSA_PKEY_CTX *rctx; | - |
| 100 | | - |
| 101 | rctx = malloc(sizeof(RSA_PKEY_CTX)); | - |
| 102 | if (!rctx)| TRUE | never evaluated | | FALSE | evaluated 226 times by 5 testsEvaluated by:- libcrypto.so.44.0.1
- pkcs7test
- servertest
- ssltest
- tlstest
|
| 0-226 |
| 103 | return 0; never executed: return 0; | 0 |
| 104 | rctx->nbits = 2048; | - |
| 105 | rctx->pub_exp = NULL; | - |
| 106 | rctx->pad_mode = RSA_PKCS1_PADDING; | - |
| 107 | rctx->md = NULL; | - |
| 108 | rctx->mgf1md = NULL; | - |
| 109 | rctx->tbuf = NULL; | - |
| 110 | | - |
| 111 | rctx->saltlen = -2; | - |
| 112 | | - |
| 113 | ctx->data = rctx; | - |
| 114 | ctx->keygen_info = rctx->gentmp; | - |
| 115 | ctx->keygen_info_count = 2; | - |
| 116 | | - |
| 117 | return 1;executed 226 times by 5 tests: return 1;Executed by:- libcrypto.so.44.0.1
- pkcs7test
- servertest
- ssltest
- tlstest
| 226 |
| 118 | } | - |
| 119 | | - |
| 120 | static int | - |
| 121 | pkey_rsa_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src) | - |
| 122 | { | - |
| 123 | RSA_PKEY_CTX *dctx, *sctx; | - |
| 124 | | - |
| 125 | if (!pkey_rsa_init(dst))| TRUE | never evaluated | | FALSE | evaluated 75 times by 4 testsEvaluated by:- libcrypto.so.44.0.1
- pkcs7test
- ssltest
- tlstest
|
| 0-75 |
| 126 | return 0; never executed: return 0; | 0 |
| 127 | sctx = src->data; | - |
| 128 | dctx = dst->data; | - |
| 129 | dctx->nbits = sctx->nbits; | - |
| 130 | if (sctx->pub_exp) {| TRUE | never evaluated | | FALSE | evaluated 75 times by 4 testsEvaluated by:- libcrypto.so.44.0.1
- pkcs7test
- ssltest
- tlstest
|
| 0-75 |
| 131 | dctx->pub_exp = BN_dup(sctx->pub_exp); | - |
| 132 | if (!dctx->pub_exp)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 133 | return 0; never executed: return 0; | 0 |
| 134 | } never executed: end of block | 0 |
| 135 | dctx->pad_mode = sctx->pad_mode; | - |
| 136 | dctx->md = sctx->md; | - |
| 137 | return 1;executed 75 times by 4 tests: return 1;Executed by:- libcrypto.so.44.0.1
- pkcs7test
- ssltest
- tlstest
| 75 |
| 138 | } | - |
| 139 | | - |
| 140 | static int | - |
| 141 | setup_tbuf(RSA_PKEY_CTX *ctx, EVP_PKEY_CTX *pk) | - |
| 142 | { | - |
| 143 | if (ctx->tbuf)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 144 | return 1; never executed: return 1; | 0 |
| 145 | ctx->tbuf = malloc(EVP_PKEY_size(pk->pkey)); | - |
| 146 | if (!ctx->tbuf)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 147 | return 0; never executed: return 0; | 0 |
| 148 | return 1; never executed: return 1; | 0 |
| 149 | } | - |
| 150 | | - |
| 151 | static void | - |
| 152 | pkey_rsa_cleanup(EVP_PKEY_CTX *ctx) | - |
| 153 | { | - |
| 154 | RSA_PKEY_CTX *rctx = ctx->data; | - |
| 155 | | - |
| 156 | if (rctx) {| TRUE | evaluated 226 times by 5 testsEvaluated by:- libcrypto.so.44.0.1
- pkcs7test
- servertest
- ssltest
- tlstest
| | FALSE | never evaluated |
| 0-226 |
| 157 | BN_free(rctx->pub_exp); | - |
| 158 | free(rctx->tbuf); | - |
| 159 | free(rctx); | - |
| 160 | }executed 226 times by 5 tests: end of blockExecuted by:- libcrypto.so.44.0.1
- pkcs7test
- servertest
- ssltest
- tlstest
| 226 |
| 161 | }executed 226 times by 5 tests: end of blockExecuted by:- libcrypto.so.44.0.1
- pkcs7test
- servertest
- ssltest
- tlstest
| 226 |
| 162 | | - |
| 163 | static int | - |
| 164 | pkey_rsa_sign(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, | - |
| 165 | const unsigned char *tbs, size_t tbslen) | - |
| 166 | { | - |
| 167 | int ret; | - |
| 168 | RSA_PKEY_CTX *rctx = ctx->data; | - |
| 169 | RSA *rsa = ctx->pkey->pkey.rsa; | - |
| 170 | | - |
| 171 | if (rctx->md) {| TRUE | evaluated 36 times by 5 testsEvaluated by:- libcrypto.so.44.0.1
- pkcs7test
- servertest
- ssltest
- tlstest
| | FALSE | never evaluated |
| 0-36 |
| 172 | if (tbslen != (size_t)EVP_MD_size(rctx->md)) {| TRUE | never evaluated | | FALSE | evaluated 36 times by 5 testsEvaluated by:- libcrypto.so.44.0.1
- pkcs7test
- servertest
- ssltest
- tlstest
|
| 0-36 |
| 173 | RSAerror(RSA_R_INVALID_DIGEST_LENGTH); | - |
| 174 | return -1; never executed: return -1; | 0 |
| 175 | } | - |
| 176 | | - |
| 177 | if (rctx->pad_mode == RSA_X931_PADDING) {| TRUE | never evaluated | | FALSE | evaluated 36 times by 5 testsEvaluated by:- libcrypto.so.44.0.1
- pkcs7test
- servertest
- ssltest
- tlstest
|
| 0-36 |
| 178 | if (!setup_tbuf(rctx, ctx))| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 179 | return -1; never executed: return -1; | 0 |
| 180 | memcpy(rctx->tbuf, tbs, tbslen); | - |
| 181 | rctx->tbuf[tbslen] = | - |
| 182 | RSA_X931_hash_id(EVP_MD_type(rctx->md)); | - |
| 183 | ret = RSA_private_encrypt(tbslen + 1, rctx->tbuf, sig, | - |
| 184 | rsa, RSA_X931_PADDING); | - |
| 185 | } else if (rctx->pad_mode == RSA_PKCS1_PADDING) { never executed: end of block | TRUE | evaluated 36 times by 5 testsEvaluated by:- libcrypto.so.44.0.1
- pkcs7test
- servertest
- ssltest
- tlstest
| | FALSE | never evaluated |
| 0-36 |
| 186 | unsigned int sltmp; | - |
| 187 | | - |
| 188 | ret = RSA_sign(EVP_MD_type(rctx->md), tbs, tbslen, sig, | - |
| 189 | &sltmp, rsa); | - |
| 190 | if (ret <= 0)| TRUE | never evaluated | | FALSE | evaluated 36 times by 5 testsEvaluated by:- libcrypto.so.44.0.1
- pkcs7test
- servertest
- ssltest
- tlstest
|
| 0-36 |
| 191 | return ret; never executed: return ret; | 0 |
| 192 | ret = sltmp; | - |
| 193 | } else if (rctx->pad_mode == RSA_PKCS1_PSS_PADDING) {executed 36 times by 5 tests: end of blockExecuted by:- libcrypto.so.44.0.1
- pkcs7test
- servertest
- ssltest
- tlstest
| TRUE | never evaluated | | FALSE | never evaluated |
| 0-36 |
| 194 | if (!setup_tbuf(rctx, ctx))| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 195 | return -1; never executed: return -1; | 0 |
| 196 | if (!RSA_padding_add_PKCS1_PSS_mgf1(rsa, rctx->tbuf,| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 197 | tbs, rctx->md, rctx->mgf1md, rctx->saltlen))| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 198 | return -1; never executed: return -1; | 0 |
| 199 | ret = RSA_private_encrypt(RSA_size(rsa), rctx->tbuf, | - |
| 200 | sig, rsa, RSA_NO_PADDING); | - |
| 201 | } else never executed: end of block | 0 |
| 202 | return -1; never executed: return -1; | 0 |
| 203 | } else | - |
| 204 | ret = RSA_private_encrypt(tbslen, tbs, sig, ctx->pkey->pkey.rsa, never executed: ret = RSA_private_encrypt(tbslen, tbs, sig, ctx->pkey->pkey.rsa, rctx->pad_mode); | 0 |
| 205 | rctx->pad_mode); never executed: ret = RSA_private_encrypt(tbslen, tbs, sig, ctx->pkey->pkey.rsa, rctx->pad_mode); | 0 |
| 206 | if (ret < 0)| TRUE | never evaluated | | FALSE | evaluated 36 times by 5 testsEvaluated by:- libcrypto.so.44.0.1
- pkcs7test
- servertest
- ssltest
- tlstest
|
| 0-36 |
| 207 | return ret; never executed: return ret; | 0 |
| 208 | *siglen = ret; | - |
| 209 | return 1;executed 36 times by 5 tests: return 1;Executed by:- libcrypto.so.44.0.1
- pkcs7test
- servertest
- ssltest
- tlstest
| 36 |
| 210 | } | - |
| 211 | | - |
| 212 | static int | - |
| 213 | pkey_rsa_verifyrecover(EVP_PKEY_CTX *ctx, unsigned char *rout, size_t *routlen, | - |
| 214 | const unsigned char *sig, size_t siglen) | - |
| 215 | { | - |
| 216 | int ret; | - |
| 217 | RSA_PKEY_CTX *rctx = ctx->data; | - |
| 218 | | - |
| 219 | if (rctx->md) {| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 220 | if (rctx->pad_mode == RSA_X931_PADDING) {| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 221 | if (!setup_tbuf(rctx, ctx))| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 222 | return -1; never executed: return -1; | 0 |
| 223 | ret = RSA_public_decrypt(siglen, sig, rctx->tbuf, | - |
| 224 | ctx->pkey->pkey.rsa, RSA_X931_PADDING); | - |
| 225 | if (ret < 1)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 226 | return 0; never executed: return 0; | 0 |
| 227 | ret--; | - |
| 228 | if (rctx->tbuf[ret] !=| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 229 | RSA_X931_hash_id(EVP_MD_type(rctx->md))) {| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 230 | RSAerror(RSA_R_ALGORITHM_MISMATCH); | - |
| 231 | return 0; never executed: return 0; | 0 |
| 232 | } | - |
| 233 | if (ret != EVP_MD_size(rctx->md)) {| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 234 | RSAerror(RSA_R_INVALID_DIGEST_LENGTH); | - |
| 235 | return 0; never executed: return 0; | 0 |
| 236 | } | - |
| 237 | if (rout)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 238 | memcpy(rout, rctx->tbuf, ret); never executed: memcpy(rout, rctx->tbuf, ret); | 0 |
| 239 | } else if (rctx->pad_mode == RSA_PKCS1_PADDING) { never executed: end of block | TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 240 | size_t sltmp; | - |
| 241 | | - |
| 242 | ret = int_rsa_verify(EVP_MD_type(rctx->md), NULL, 0, | - |
| 243 | rout, &sltmp, sig, siglen, ctx->pkey->pkey.rsa); | - |
| 244 | if (ret <= 0)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 245 | return 0; never executed: return 0; | 0 |
| 246 | ret = sltmp; | - |
| 247 | } else never executed: end of block | 0 |
| 248 | return -1; never executed: return -1; | 0 |
| 249 | } else | - |
| 250 | ret = RSA_public_decrypt(siglen, sig, rout, ctx->pkey->pkey.rsa, never executed: ret = RSA_public_decrypt(siglen, sig, rout, ctx->pkey->pkey.rsa, rctx->pad_mode); | 0 |
| 251 | rctx->pad_mode); never executed: ret = RSA_public_decrypt(siglen, sig, rout, ctx->pkey->pkey.rsa, rctx->pad_mode); | 0 |
| 252 | if (ret < 0)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 253 | return ret; never executed: return ret; | 0 |
| 254 | *routlen = ret; | - |
| 255 | return 1; never executed: return 1; | 0 |
| 256 | } | - |
| 257 | | - |
| 258 | static int | - |
| 259 | pkey_rsa_verify(EVP_PKEY_CTX *ctx, const unsigned char *sig, size_t siglen, | - |
| 260 | const unsigned char *tbs, size_t tbslen) | - |
| 261 | { | - |
| 262 | RSA_PKEY_CTX *rctx = ctx->data; | - |
| 263 | RSA *rsa = ctx->pkey->pkey.rsa; | - |
| 264 | size_t rslen; | - |
| 265 | | - |
| 266 | if (rctx->md) {| TRUE | evaluated 106 times by 3 tests | | FALSE | never evaluated |
| 0-106 |
| 267 | if (rctx->pad_mode == RSA_PKCS1_PADDING)| TRUE | evaluated 106 times by 3 tests | | FALSE | never evaluated |
| 0-106 |
| 268 | return RSA_verify(EVP_MD_type(rctx->md), tbs, tbslen,executed 106 times by 3 tests: return RSA_verify(EVP_MD_type(rctx->md), tbs, tbslen, sig, siglen, rsa); | 106 |
| 269 | sig, siglen, rsa);executed 106 times by 3 tests: return RSA_verify(EVP_MD_type(rctx->md), tbs, tbslen, sig, siglen, rsa); | 106 |
| 270 | if (rctx->pad_mode == RSA_X931_PADDING) {| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 271 | if (pkey_rsa_verifyrecover(ctx, NULL, &rslen, sig,| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 272 | siglen) <= 0)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 273 | return 0; never executed: return 0; | 0 |
| 274 | } else if (rctx->pad_mode == RSA_PKCS1_PSS_PADDING) { never executed: end of block | TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 275 | int ret; | - |
| 276 | | - |
| 277 | if (!setup_tbuf(rctx, ctx))| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 278 | return -1; never executed: return -1; | 0 |
| 279 | ret = RSA_public_decrypt(siglen, sig, rctx->tbuf, | - |
| 280 | rsa, RSA_NO_PADDING); | - |
| 281 | if (ret <= 0)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 282 | return 0; never executed: return 0; | 0 |
| 283 | ret = RSA_verify_PKCS1_PSS_mgf1(rsa, tbs, rctx->md, | - |
| 284 | rctx->mgf1md, rctx->tbuf, rctx->saltlen); | - |
| 285 | if (ret <= 0)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 286 | return 0; never executed: return 0; | 0 |
| 287 | return 1; never executed: return 1; | 0 |
| 288 | } else | - |
| 289 | return -1; never executed: return -1; | 0 |
| 290 | } else { | - |
| 291 | if (!setup_tbuf(rctx, ctx))| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 292 | return -1; never executed: return -1; | 0 |
| 293 | rslen = RSA_public_decrypt(siglen, sig, rctx->tbuf, rsa, | - |
| 294 | rctx->pad_mode); | - |
| 295 | if (rslen == 0)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 296 | return 0; never executed: return 0; | 0 |
| 297 | } never executed: end of block | 0 |
| 298 | | - |
| 299 | if (rslen != tbslen || timingsafe_bcmp(tbs, rctx->tbuf, rslen))| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 300 | return 0; never executed: return 0; | 0 |
| 301 | | - |
| 302 | return 1; never executed: return 1; | 0 |
| 303 | } | - |
| 304 | | - |
| 305 | static int | - |
| 306 | pkey_rsa_encrypt(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, | - |
| 307 | const unsigned char *in, size_t inlen) | - |
| 308 | { | - |
| 309 | int ret; | - |
| 310 | RSA_PKEY_CTX *rctx = ctx->data; | - |
| 311 | | - |
| 312 | ret = RSA_public_encrypt(inlen, in, out, ctx->pkey->pkey.rsa, | - |
| 313 | rctx->pad_mode); | - |
| 314 | if (ret < 0)| TRUE | never evaluated | | FALSE | evaluated 1 time by 1 test |
| 0-1 |
| 315 | return ret; never executed: return ret; | 0 |
| 316 | *outlen = ret; | - |
| 317 | return 1;executed 1 time by 1 test: return 1; | 1 |
| 318 | } | - |
| 319 | | - |
| 320 | static int | - |
| 321 | pkey_rsa_decrypt(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, | - |
| 322 | const unsigned char *in, size_t inlen) | - |
| 323 | { | - |
| 324 | int ret; | - |
| 325 | RSA_PKEY_CTX *rctx = ctx->data; | - |
| 326 | | - |
| 327 | ret = RSA_private_decrypt(inlen, in, out, ctx->pkey->pkey.rsa, | - |
| 328 | rctx->pad_mode); | - |
| 329 | if (ret < 0)| TRUE | never evaluated | | FALSE | evaluated 1 time by 1 test |
| 0-1 |
| 330 | return ret; never executed: return ret; | 0 |
| 331 | *outlen = ret; | - |
| 332 | return 1;executed 1 time by 1 test: return 1; | 1 |
| 333 | } | - |
| 334 | | - |
| 335 | static int | - |
| 336 | check_padding_md(const EVP_MD *md, int padding) | - |
| 337 | { | - |
| 338 | if (!md)| TRUE | never evaluated | | FALSE | evaluated 149 times by 5 testsEvaluated by:- libcrypto.so.44.0.1
- pkcs7test
- servertest
- ssltest
- tlstest
|
| 0-149 |
| 339 | return 1; never executed: return 1; | 0 |
| 340 | | - |
| 341 | if (padding == RSA_NO_PADDING) {| TRUE | never evaluated | | FALSE | evaluated 149 times by 5 testsEvaluated by:- libcrypto.so.44.0.1
- pkcs7test
- servertest
- ssltest
- tlstest
|
| 0-149 |
| 342 | RSAerror(RSA_R_INVALID_PADDING_MODE); | - |
| 343 | return 0; never executed: return 0; | 0 |
| 344 | } | - |
| 345 | | - |
| 346 | if (padding == RSA_X931_PADDING) {| TRUE | never evaluated | | FALSE | evaluated 149 times by 5 testsEvaluated by:- libcrypto.so.44.0.1
- pkcs7test
- servertest
- ssltest
- tlstest
|
| 0-149 |
| 347 | if (RSA_X931_hash_id(EVP_MD_type(md)) == -1) {| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 348 | RSAerror(RSA_R_INVALID_X931_DIGEST); | - |
| 349 | return 0; never executed: return 0; | 0 |
| 350 | } | - |
| 351 | return 1; never executed: return 1; | 0 |
| 352 | } | - |
| 353 | | - |
| 354 | return 1;executed 149 times by 5 tests: return 1;Executed by:- libcrypto.so.44.0.1
- pkcs7test
- servertest
- ssltest
- tlstest
| 149 |
| 355 | } | - |
| 356 | | - |
| 357 | static int | - |
| 358 | pkey_rsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) | - |
| 359 | { | - |
| 360 | RSA_PKEY_CTX *rctx = ctx->data; | - |
| 361 | | - |
| 362 | switch (type) { | - |
| 363 | case EVP_PKEY_CTRL_RSA_PADDING: never executed: case (0x1000 + 1): | 0 |
| 364 | if (p1 >= RSA_PKCS1_PADDING && p1 <= RSA_PKCS1_PSS_PADDING) {| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 365 | if (!check_padding_md(rctx->md, p1))| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 366 | return 0; never executed: return 0; | 0 |
| 367 | if (p1 == RSA_PKCS1_PSS_PADDING) {| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 368 | if (!(ctx->operation &| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 369 | (EVP_PKEY_OP_SIGN | EVP_PKEY_OP_VERIFY)))| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 370 | goto bad_pad; never executed: goto bad_pad; | 0 |
| 371 | if (!rctx->md)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 372 | rctx->md = EVP_sha1(); never executed: rctx->md = EVP_sha1(); | 0 |
| 373 | } never executed: end of block | 0 |
| 374 | if (p1 == RSA_PKCS1_OAEP_PADDING) {| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 375 | if (!(ctx->operation & EVP_PKEY_OP_TYPE_CRYPT))| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 376 | goto bad_pad; never executed: goto bad_pad; | 0 |
| 377 | if (!rctx->md)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 378 | rctx->md = EVP_sha1(); never executed: rctx->md = EVP_sha1(); | 0 |
| 379 | } never executed: end of block | 0 |
| 380 | rctx->pad_mode = p1; | - |
| 381 | return 1; never executed: return 1; | 0 |
| 382 | } | - |
| 383 | bad_pad: code before this statement never executed: bad_pad: | 0 |
| 384 | RSAerror(RSA_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE); | - |
| 385 | return -2; never executed: return -2; | 0 |
| 386 | | - |
| 387 | case EVP_PKEY_CTRL_GET_RSA_PADDING:executed 1 time by 1 test: case (0x1000 + 6): | 1 |
| 388 | *(int *)p2 = rctx->pad_mode; | - |
| 389 | return 1;executed 1 time by 1 test: return 1; | 1 |
| 390 | | - |
| 391 | case EVP_PKEY_CTRL_RSA_PSS_SALTLEN: never executed: case (0x1000 + 2): | 0 |
| 392 | case EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN: never executed: case (0x1000 + 7): | 0 |
| 393 | if (rctx->pad_mode != RSA_PKCS1_PSS_PADDING) {| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 394 | RSAerror(RSA_R_INVALID_PSS_SALTLEN); | - |
| 395 | return -2; never executed: return -2; | 0 |
| 396 | } | - |
| 397 | if (type == EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 398 | *(int *)p2 = rctx->saltlen; never executed: *(int *)p2 = rctx->saltlen; | 0 |
| 399 | else { | - |
| 400 | if (p1 < -2)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 401 | return -2; never executed: return -2; | 0 |
| 402 | rctx->saltlen = p1; | - |
| 403 | } never executed: end of block | 0 |
| 404 | return 1; never executed: return 1; | 0 |
| 405 | | - |
| 406 | case EVP_PKEY_CTRL_RSA_KEYGEN_BITS: never executed: case (0x1000 + 3): | 0 |
| 407 | if (p1 < 256) {| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 408 | RSAerror(RSA_R_INVALID_KEYBITS); | - |
| 409 | return -2; never executed: return -2; | 0 |
| 410 | } | - |
| 411 | rctx->nbits = p1; | - |
| 412 | return 1; never executed: return 1; | 0 |
| 413 | | - |
| 414 | case EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP: never executed: case (0x1000 + 4): | 0 |
| 415 | if (!p2)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 416 | return -2; never executed: return -2; | 0 |
| 417 | rctx->pub_exp = p2; | - |
| 418 | return 1; never executed: return 1; | 0 |
| 419 | | - |
| 420 | case EVP_PKEY_CTRL_MD:executed 149 times by 5 tests: case 1:Executed by:- libcrypto.so.44.0.1
- pkcs7test
- servertest
- ssltest
- tlstest
| 149 |
| 421 | if (!check_padding_md(p2, rctx->pad_mode))| TRUE | never evaluated | | FALSE | evaluated 149 times by 5 testsEvaluated by:- libcrypto.so.44.0.1
- pkcs7test
- servertest
- ssltest
- tlstest
|
| 0-149 |
| 422 | return 0; never executed: return 0; | 0 |
| 423 | rctx->md = p2; | - |
| 424 | return 1;executed 149 times by 5 tests: return 1;Executed by:- libcrypto.so.44.0.1
- pkcs7test
- servertest
- ssltest
- tlstest
| 149 |
| 425 | | - |
| 426 | case EVP_PKEY_CTRL_RSA_MGF1_MD: never executed: case (0x1000 + 5): | 0 |
| 427 | case EVP_PKEY_CTRL_GET_RSA_MGF1_MD: never executed: case (0x1000 + 8): | 0 |
| 428 | if (rctx->pad_mode != RSA_PKCS1_PSS_PADDING) {| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 429 | RSAerror(RSA_R_INVALID_MGF1_MD); | - |
| 430 | return -2; never executed: return -2; | 0 |
| 431 | } | - |
| 432 | if (type == EVP_PKEY_CTRL_GET_RSA_MGF1_MD) {| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 433 | if (rctx->mgf1md)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 434 | *(const EVP_MD **)p2 = rctx->mgf1md; never executed: *(const EVP_MD **)p2 = rctx->mgf1md; | 0 |
| 435 | else | - |
| 436 | *(const EVP_MD **)p2 = rctx->md; never executed: *(const EVP_MD **)p2 = rctx->md; | 0 |
| 437 | } else | - |
| 438 | rctx->mgf1md = p2; never executed: rctx->mgf1md = p2; | 0 |
| 439 | return 1; never executed: return 1; | 0 |
| 440 | | - |
| 441 | case EVP_PKEY_CTRL_DIGESTINIT:executed 75 times by 4 tests: case 7:Executed by:- libcrypto.so.44.0.1
- pkcs7test
- ssltest
- tlstest
| 75 |
| 442 | case EVP_PKEY_CTRL_PKCS7_ENCRYPT:executed 1 time by 1 test: case 3: | 1 |
| 443 | case EVP_PKEY_CTRL_PKCS7_DECRYPT:executed 1 time by 1 test: case 4: | 1 |
| 444 | case EVP_PKEY_CTRL_PKCS7_SIGN:executed 4 times by 1 test: case 5: | 4 |
| 445 | return 1;executed 81 times by 4 tests: return 1;Executed by:- libcrypto.so.44.0.1
- pkcs7test
- ssltest
- tlstest
| 81 |
| 446 | case EVP_PKEY_CTRL_PEER_KEY: never executed: case 2: | 0 |
| 447 | RSAerror(RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE); | - |
| 448 | return -2; never executed: return -2; | 0 |
| 449 | | - |
| 450 | default: never executed: default: | 0 |
| 451 | return -2; never executed: return -2; | 0 |
| 452 | } | - |
| 453 | } | - |
| 454 | | - |
| 455 | static int | - |
| 456 | pkey_rsa_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value) | - |
| 457 | { | - |
| 458 | long lval; | - |
| 459 | char *ep; | - |
| 460 | | - |
| 461 | if (!value) {| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 462 | RSAerror(RSA_R_VALUE_MISSING); | - |
| 463 | return 0; never executed: return 0; | 0 |
| 464 | } | - |
| 465 | if (!strcmp(type, "rsa_padding_mode")) { never executed: __result = (((const unsigned char *) (const char *) ( type ))[3] - __s2[3]); never executed: end of block never executed: end of block never executed: __result = (((const unsigned char *) (const char *) ( "rsa_padding_mode" ))[3] - __s2[3]); never executed: end of block never executed: end of block | TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 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 |
| 466 | int pm; | - |
| 467 | if (!strcmp(value, "pkcs1")) never executed: __result = (((const unsigned char *) (const char *) ( value ))[3] - __s2[3]); never executed: end of block never executed: end of block never executed: __result = (((const unsigned char *) (const char *) ( "pkcs1" ))[3] - __s2[3]); never executed: end of block never executed: end of block | TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 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 |
| 468 | pm = RSA_PKCS1_PADDING; never executed: pm = 1; | 0 |
| 469 | else if (!strcmp(value, "none")) never executed: __result = (((const unsigned char *) (const char *) ( value ))[3] - __s2[3]); never executed: end of block never executed: end of block never executed: __result = (((const unsigned char *) (const char *) ( "none" ))[3] - __s2[3]); never executed: end of block never executed: end of block | TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 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 |
| 470 | pm = RSA_NO_PADDING; never executed: pm = 3; | 0 |
| 471 | else if (!strcmp(value, "oeap")) never executed: __result = (((const unsigned char *) (const char *) ( value ))[3] - __s2[3]); never executed: end of block never executed: end of block never executed: __result = (((const unsigned char *) (const char *) ( "oeap" ))[3] - __s2[3]); never executed: end of block never executed: end of block | TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 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 |
| 472 | pm = RSA_PKCS1_OAEP_PADDING; never executed: pm = 4; | 0 |
| 473 | else if (!strcmp(value, "oaep")) never executed: __result = (((const unsigned char *) (const char *) ( value ))[3] - __s2[3]); never executed: end of block never executed: end of block never executed: __result = (((const unsigned char *) (const char *) ( "oaep" ))[3] - __s2[3]); never executed: end of block never executed: end of block | TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 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 |
| 474 | pm = RSA_PKCS1_OAEP_PADDING; never executed: pm = 4; | 0 |
| 475 | else if (!strcmp(value, "x931")) never executed: __result = (((const unsigned char *) (const char *) ( value ))[3] - __s2[3]); never executed: end of block never executed: end of block never executed: __result = (((const unsigned char *) (const char *) ( "x931" ))[3] - __s2[3]); never executed: end of block never executed: end of block | TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 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 |
| 476 | pm = RSA_X931_PADDING; never executed: pm = 5; | 0 |
| 477 | else if (!strcmp(value, "pss")) never executed: __result = (((const unsigned char *) (const char *) ( value ))[3] - __s2[3]); never executed: end of block never executed: end of block never executed: __result = (((const unsigned char *) (const char *) ( "pss" ))[3] - __s2[3]); never executed: end of block never executed: end of block | TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 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 |
| 478 | pm = RSA_PKCS1_PSS_PADDING; never executed: pm = 6; | 0 |
| 479 | else { | - |
| 480 | RSAerror(RSA_R_UNKNOWN_PADDING_TYPE); | - |
| 481 | return -2; never executed: return -2; | 0 |
| 482 | } | - |
| 483 | return EVP_PKEY_CTX_set_rsa_padding(ctx, pm); never executed: return EVP_PKEY_CTX_ctrl(ctx, 6, -1, (0x1000 + 1), pm, ((void *)0) ); | 0 |
| 484 | } | - |
| 485 | | - |
| 486 | if (!strcmp(type, "rsa_pss_saltlen")) { never executed: __result = (((const unsigned char *) (const char *) ( type ))[3] - __s2[3]); never executed: end of block never executed: end of block never executed: __result = (((const unsigned char *) (const char *) ( "rsa_pss_saltlen" ))[3] - __s2[3]); never executed: end of block never executed: end of block | TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 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 |
| 487 | int saltlen; | - |
| 488 | | - |
| 489 | errno = 0; | - |
| 490 | lval = strtol(value, &ep, 10); | - |
| 491 | if (value[0] == '\0' || *ep != '\0')| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 492 | goto not_a_number; never executed: goto not_a_number; | 0 |
| 493 | if ((errno == ERANGE &&| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 494 | (lval == LONG_MAX || lval == LONG_MIN)) ||| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 495 | (lval > INT_MAX || lval < INT_MIN))| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 496 | goto out_of_range; never executed: goto out_of_range; | 0 |
| 497 | saltlen = lval; | - |
| 498 | return EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx, saltlen); never executed: return EVP_PKEY_CTX_ctrl(ctx, 6, ((1<<3)|(1<<4)), (0x1000 + 2), saltlen, ((void *)0) ); | 0 |
| 499 | } | - |
| 500 | | - |
| 501 | if (!strcmp(type, "rsa_keygen_bits")) { never executed: __result = (((const unsigned char *) (const char *) ( type ))[3] - __s2[3]); never executed: end of block never executed: end of block never executed: __result = (((const unsigned char *) (const char *) ( "rsa_keygen_bits" ))[3] - __s2[3]); never executed: end of block never executed: end of block | TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 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 |
| 502 | int nbits; | - |
| 503 | | - |
| 504 | errno = 0; | - |
| 505 | lval = strtol(value, &ep, 10); | - |
| 506 | if (value[0] == '\0' || *ep != '\0')| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 507 | goto not_a_number; never executed: goto not_a_number; | 0 |
| 508 | if ((errno == ERANGE &&| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 509 | (lval == LONG_MAX || lval == LONG_MIN)) ||| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 510 | (lval > INT_MAX || lval < INT_MIN))| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 511 | goto out_of_range; never executed: goto out_of_range; | 0 |
| 512 | nbits = lval; | - |
| 513 | return EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, nbits); never executed: return EVP_PKEY_CTX_ctrl(ctx, 6, (1<<2), (0x1000 + 3), nbits, ((void *)0) ); | 0 |
| 514 | } | - |
| 515 | | - |
| 516 | if (!strcmp(type, "rsa_keygen_pubexp")) { never executed: __result = (((const unsigned char *) (const char *) ( type ))[3] - __s2[3]); never executed: end of block never executed: end of block never executed: __result = (((const unsigned char *) (const char *) ( "rsa_keygen_pubexp" ))[3] - __s2[3]); never executed: end of block never executed: end of block | TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 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 |
| 517 | int ret; | - |
| 518 | BIGNUM *pubexp = NULL; | - |
| 519 | | - |
| 520 | if (!BN_asc2bn(&pubexp, value))| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 521 | return 0; never executed: return 0; | 0 |
| 522 | ret = EVP_PKEY_CTX_set_rsa_keygen_pubexp(ctx, pubexp); | - |
| 523 | if (ret <= 0)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 524 | BN_free(pubexp); never executed: BN_free(pubexp); | 0 |
| 525 | return ret; never executed: return ret; | 0 |
| 526 | } | - |
| 527 | | - |
| 528 | not_a_number: code before this statement never executed: not_a_number: | 0 |
| 529 | out_of_range: | - |
| 530 | return -2; never executed: return -2; | 0 |
| 531 | } | - |
| 532 | | - |
| 533 | static int | - |
| 534 | pkey_rsa_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey) | - |
| 535 | { | - |
| 536 | RSA *rsa = NULL; | - |
| 537 | RSA_PKEY_CTX *rctx = ctx->data; | - |
| 538 | BN_GENCB *pcb, cb; | - |
| 539 | int ret; | - |
| 540 | | - |
| 541 | if (!rctx->pub_exp) {| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 542 | rctx->pub_exp = BN_new(); | - |
| 543 | if (!rctx->pub_exp || !BN_set_word(rctx->pub_exp, RSA_F4))| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 544 | return 0; never executed: return 0; | 0 |
| 545 | } never executed: end of block | 0 |
| 546 | rsa = RSA_new(); | - |
| 547 | if (!rsa)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 548 | return 0; never executed: return 0; | 0 |
| 549 | if (ctx->pkey_gencb) {| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 550 | pcb = &cb; | - |
| 551 | evp_pkey_set_cb_translate(pcb, ctx); | - |
| 552 | } else never executed: end of block | 0 |
| 553 | pcb = NULL; never executed: pcb = ((void *)0) ; | 0 |
| 554 | ret = RSA_generate_key_ex(rsa, rctx->nbits, rctx->pub_exp, pcb); | - |
| 555 | if (ret > 0)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 556 | EVP_PKEY_assign_RSA(pkey, rsa); never executed: EVP_PKEY_assign((pkey),6, (char *)(rsa)); | 0 |
| 557 | else | - |
| 558 | RSA_free(rsa); never executed: RSA_free(rsa); | 0 |
| 559 | return ret; never executed: return ret; | 0 |
| 560 | } | - |
| 561 | | - |
| 562 | const EVP_PKEY_METHOD rsa_pkey_meth = { | - |
| 563 | .pkey_id = EVP_PKEY_RSA, | - |
| 564 | .flags = EVP_PKEY_FLAG_AUTOARGLEN, | - |
| 565 | | - |
| 566 | .init = pkey_rsa_init, | - |
| 567 | .copy = pkey_rsa_copy, | - |
| 568 | .cleanup = pkey_rsa_cleanup, | - |
| 569 | | - |
| 570 | .keygen = pkey_rsa_keygen, | - |
| 571 | | - |
| 572 | .sign = pkey_rsa_sign, | - |
| 573 | | - |
| 574 | .verify = pkey_rsa_verify, | - |
| 575 | | - |
| 576 | .verify_recover = pkey_rsa_verifyrecover, | - |
| 577 | | - |
| 578 | .encrypt = pkey_rsa_encrypt, | - |
| 579 | | - |
| 580 | .decrypt = pkey_rsa_decrypt, | - |
| 581 | | - |
| 582 | .ctrl = pkey_rsa_ctrl, | - |
| 583 | .ctrl_str = pkey_rsa_ctrl_str | - |
| 584 | }; | - |
| | |