| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/evp/evp_lib.c |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | /* | - | ||||||
| 2 | * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. | - | ||||||
| 3 | * | - | ||||||
| 4 | * Licensed under the OpenSSL license (the "License"). You may not use | - | ||||||
| 5 | * this file except in compliance with the License. You can obtain a copy | - | ||||||
| 6 | * in the file LICENSE in the source distribution or at | - | ||||||
| 7 | * https://www.openssl.org/source/license.html | - | ||||||
| 8 | */ | - | ||||||
| 9 | - | |||||||
| 10 | #include <stdio.h> | - | ||||||
| 11 | #include "internal/cryptlib.h" | - | ||||||
| 12 | #include <openssl/evp.h> | - | ||||||
| 13 | #include <openssl/objects.h> | - | ||||||
| 14 | #include "internal/evp_int.h" | - | ||||||
| 15 | #include "evp_locl.h" | - | ||||||
| 16 | - | |||||||
| 17 | int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type) | - | ||||||
| 18 | { | - | ||||||
| 19 | int ret; | - | ||||||
| 20 | - | |||||||
| 21 | if (c->cipher->set_asn1_parameters != NULL)
| 2-33 | ||||||
| 22 | ret = c->cipher->set_asn1_parameters(c, type); executed 2 times by 1 test: ret = c->cipher->set_asn1_parameters(c, type);Executed by:
| 2 | ||||||
| 23 | else if (c->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1) {
| 0-33 | ||||||
| 24 | switch (EVP_CIPHER_CTX_mode(c)) { | - | ||||||
| 25 | case EVP_CIPH_WRAP_MODE: executed 7 times by 1 test: case 0x10002:Executed by:
| 7 | ||||||
| 26 | if (EVP_CIPHER_CTX_nid(c) == NID_id_smime_alg_CMS3DESwrap)
| 3-4 | ||||||
| 27 | ASN1_TYPE_set(type, V_ASN1_NULL, NULL); executed 4 times by 1 test: ASN1_TYPE_set(type, 5, ((void *)0) );Executed by:
| 4 | ||||||
| 28 | ret = 1; | - | ||||||
| 29 | break; executed 7 times by 1 test: break;Executed by:
| 7 | ||||||
| 30 | - | |||||||
| 31 | case EVP_CIPH_GCM_MODE: never executed: case 0x6: | 0 | ||||||
| 32 | case EVP_CIPH_CCM_MODE: never executed: case 0x7: | 0 | ||||||
| 33 | case EVP_CIPH_XTS_MODE: never executed: case 0x10001: | 0 | ||||||
| 34 | case EVP_CIPH_OCB_MODE: never executed: case 0x10003: | 0 | ||||||
| 35 | ret = -2; | - | ||||||
| 36 | break; never executed: break; | 0 | ||||||
| 37 | - | |||||||
| 38 | default: executed 26 times by 1 test: default:Executed by:
| 26 | ||||||
| 39 | ret = EVP_CIPHER_set_asn1_iv(c, type); | - | ||||||
| 40 | } executed 26 times by 1 test: end of blockExecuted by:
| 26 | ||||||
| 41 | } else | - | ||||||
| 42 | ret = -1; never executed: ret = -1; | 0 | ||||||
| 43 | if (ret <= 0)
| 0-35 | ||||||
| 44 | EVPerr(EVP_F_EVP_CIPHER_PARAM_TO_ASN1, ret == -2 ? never executed: ERR_put_error(6,(205),(ret == -2 ? 228 : 122),__FILE__,46) ; | 0 | ||||||
| 45 | ASN1_R_UNSUPPORTED_CIPHER : never executed: ERR_put_error(6,(205),(ret == -2 ? 228 : 122),__FILE__,46) ; | 0 | ||||||
| 46 | EVP_R_CIPHER_PARAMETER_ERROR); never executed: ERR_put_error(6,(205),(ret == -2 ? 228 : 122),__FILE__,46) ; | 0 | ||||||
| 47 | if (ret < -1)
| 0-35 | ||||||
| 48 | ret = -1; never executed: ret = -1; | 0 | ||||||
| 49 | return ret; executed 35 times by 1 test: return ret;Executed by:
| 35 | ||||||
| 50 | } | - | ||||||
| 51 | - | |||||||
| 52 | int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type) | - | ||||||
| 53 | { | - | ||||||
| 54 | int ret; | - | ||||||
| 55 | - | |||||||
| 56 | if (c->cipher->get_asn1_parameters != NULL)
| 2-32 | ||||||
| 57 | ret = c->cipher->get_asn1_parameters(c, type); executed 2 times by 1 test: ret = c->cipher->get_asn1_parameters(c, type);Executed by:
| 2 | ||||||
| 58 | else if (c->cipher->flags & EVP_CIPH_FLAG_DEFAULT_ASN1) {
| 0-32 | ||||||
| 59 | switch (EVP_CIPHER_CTX_mode(c)) { | - | ||||||
| 60 | - | |||||||
| 61 | case EVP_CIPH_WRAP_MODE: executed 6 times by 1 test: case 0x10002:Executed by:
| 6 | ||||||
| 62 | ret = 1; | - | ||||||
| 63 | break; executed 6 times by 1 test: break;Executed by:
| 6 | ||||||
| 64 | - | |||||||
| 65 | case EVP_CIPH_GCM_MODE: never executed: case 0x6: | 0 | ||||||
| 66 | case EVP_CIPH_CCM_MODE: never executed: case 0x7: | 0 | ||||||
| 67 | case EVP_CIPH_XTS_MODE: never executed: case 0x10001: | 0 | ||||||
| 68 | case EVP_CIPH_OCB_MODE: never executed: case 0x10003: | 0 | ||||||
| 69 | ret = -2; | - | ||||||
| 70 | break; never executed: break; | 0 | ||||||
| 71 | - | |||||||
| 72 | default: executed 26 times by 1 test: default:Executed by:
| 26 | ||||||
| 73 | ret = EVP_CIPHER_get_asn1_iv(c, type); | - | ||||||
| 74 | break; executed 26 times by 1 test: break;Executed by:
| 26 | ||||||
| 75 | } | - | ||||||
| 76 | } else | - | ||||||
| 77 | ret = -1; never executed: ret = -1; | 0 | ||||||
| 78 | if (ret <= 0)
| 0-34 | ||||||
| 79 | EVPerr(EVP_F_EVP_CIPHER_ASN1_TO_PARAM, ret == -2 ? never executed: ERR_put_error(6,(204),(ret == -2 ? 107 : 122),__FILE__,81) ; | 0 | ||||||
| 80 | EVP_R_UNSUPPORTED_CIPHER : never executed: ERR_put_error(6,(204),(ret == -2 ? 107 : 122),__FILE__,81) ; | 0 | ||||||
| 81 | EVP_R_CIPHER_PARAMETER_ERROR); never executed: ERR_put_error(6,(204),(ret == -2 ? 107 : 122),__FILE__,81) ; | 0 | ||||||
| 82 | if (ret < -1)
| 0-34 | ||||||
| 83 | ret = -1; never executed: ret = -1; | 0 | ||||||
| 84 | return ret; executed 34 times by 1 test: return ret;Executed by:
| 34 | ||||||
| 85 | } | - | ||||||
| 86 | - | |||||||
| 87 | int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type) | - | ||||||
| 88 | { | - | ||||||
| 89 | int i = 0; | - | ||||||
| 90 | unsigned int l; | - | ||||||
| 91 | - | |||||||
| 92 | if (type != NULL) {
| 0-26 | ||||||
| 93 | l = EVP_CIPHER_CTX_iv_length(c); | - | ||||||
| 94 | OPENSSL_assert(l <= sizeof(c->iv)); | - | ||||||
| 95 | i = ASN1_TYPE_get_octetstring(type, c->oiv, l); | - | ||||||
| 96 | if (i != (int)l)
| 0-26 | ||||||
| 97 | return -1; never executed: return -1; | 0 | ||||||
| 98 | else if (i > 0)
| 0-26 | ||||||
| 99 | memcpy(c->iv, c->oiv, l); executed 26 times by 1 test: memcpy(c->iv, c->oiv, l);Executed by:
| 26 | ||||||
| 100 | } executed 26 times by 1 test: end of blockExecuted by:
| 26 | ||||||
| 101 | return i; executed 26 times by 1 test: return i;Executed by:
| 26 | ||||||
| 102 | } | - | ||||||
| 103 | - | |||||||
| 104 | int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type) | - | ||||||
| 105 | { | - | ||||||
| 106 | int i = 0; | - | ||||||
| 107 | unsigned int j; | - | ||||||
| 108 | - | |||||||
| 109 | if (type != NULL) {
| 0-26 | ||||||
| 110 | j = EVP_CIPHER_CTX_iv_length(c); | - | ||||||
| 111 | OPENSSL_assert(j <= sizeof(c->iv)); | - | ||||||
| 112 | i = ASN1_TYPE_set_octetstring(type, c->oiv, j); | - | ||||||
| 113 | } executed 26 times by 1 test: end of blockExecuted by:
| 26 | ||||||
| 114 | return i; executed 26 times by 1 test: return i;Executed by:
| 26 | ||||||
| 115 | } | - | ||||||
| 116 | - | |||||||
| 117 | /* Convert the various cipher NIDs and dummies to a proper OID NID */ | - | ||||||
| 118 | int EVP_CIPHER_type(const EVP_CIPHER *ctx) | - | ||||||
| 119 | { | - | ||||||
| 120 | int nid; | - | ||||||
| 121 | ASN1_OBJECT *otmp; | - | ||||||
| 122 | nid = EVP_CIPHER_nid(ctx); | - | ||||||
| 123 | - | |||||||
| 124 | switch (nid) { | - | ||||||
| 125 | - | |||||||
| 126 | case NID_rc2_cbc: executed 2 times by 1 test: case 37:Executed by:
| 2 | ||||||
| 127 | case NID_rc2_64_cbc: never executed: case 166: | 0 | ||||||
| 128 | case NID_rc2_40_cbc: never executed: case 98: | 0 | ||||||
| 129 | - | |||||||
| 130 | return NID_rc2_cbc; executed 2 times by 1 test: return 37;Executed by:
| 2 | ||||||
| 131 | - | |||||||
| 132 | case NID_rc4: never executed: case 5: | 0 | ||||||
| 133 | case NID_rc4_40: never executed: case 97: | 0 | ||||||
| 134 | - | |||||||
| 135 | return NID_rc4; never executed: return 5; | 0 | ||||||
| 136 | - | |||||||
| 137 | case NID_aes_128_cfb128: never executed: case 421: | 0 | ||||||
| 138 | case NID_aes_128_cfb8: never executed: case 653: | 0 | ||||||
| 139 | case NID_aes_128_cfb1: never executed: case 650: | 0 | ||||||
| 140 | - | |||||||
| 141 | return NID_aes_128_cfb128; never executed: return 421; | 0 | ||||||
| 142 | - | |||||||
| 143 | case NID_aes_192_cfb128: never executed: case 425: | 0 | ||||||
| 144 | case NID_aes_192_cfb8: never executed: case 654: | 0 | ||||||
| 145 | case NID_aes_192_cfb1: never executed: case 651: | 0 | ||||||
| 146 | - | |||||||
| 147 | return NID_aes_192_cfb128; never executed: return 425; | 0 | ||||||
| 148 | - | |||||||
| 149 | case NID_aes_256_cfb128: never executed: case 429: | 0 | ||||||
| 150 | case NID_aes_256_cfb8: never executed: case 655: | 0 | ||||||
| 151 | case NID_aes_256_cfb1: never executed: case 652: | 0 | ||||||
| 152 | - | |||||||
| 153 | return NID_aes_256_cfb128; never executed: return 429; | 0 | ||||||
| 154 | - | |||||||
| 155 | case NID_des_cfb64: never executed: case 30: | 0 | ||||||
| 156 | case NID_des_cfb8: never executed: case 657: | 0 | ||||||
| 157 | case NID_des_cfb1: never executed: case 656: | 0 | ||||||
| 158 | - | |||||||
| 159 | return NID_des_cfb64; never executed: return 30; | 0 | ||||||
| 160 | - | |||||||
| 161 | case NID_des_ede3_cfb64: never executed: case 61: | 0 | ||||||
| 162 | case NID_des_ede3_cfb8: never executed: case 659: | 0 | ||||||
| 163 | case NID_des_ede3_cfb1: never executed: case 658: | 0 | ||||||
| 164 | - | |||||||
| 165 | return NID_des_cfb64; never executed: return 30; | 0 | ||||||
| 166 | - | |||||||
| 167 | default: executed 45 times by 1 test: default:Executed by:
| 45 | ||||||
| 168 | /* Check it has an OID and it is valid */ | - | ||||||
| 169 | otmp = OBJ_nid2obj(nid); | - | ||||||
| 170 | if (OBJ_get0_data(otmp) == NULL)
| 0-45 | ||||||
| 171 | nid = NID_undef; never executed: nid = 0; | 0 | ||||||
| 172 | ASN1_OBJECT_free(otmp); | - | ||||||
| 173 | return nid; executed 45 times by 1 test: return nid;Executed by:
| 45 | ||||||
| 174 | } | - | ||||||
| 175 | } | - | ||||||
| 176 | - | |||||||
| 177 | int EVP_CIPHER_block_size(const EVP_CIPHER *e) | - | ||||||
| 178 | { | - | ||||||
| 179 | return e->block_size; executed 18082 times by 1 test: return e->block_size;Executed by:
| 18082 | ||||||
| 180 | } | - | ||||||
| 181 | - | |||||||
| 182 | int EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx) | - | ||||||
| 183 | { | - | ||||||
| 184 | return ctx->cipher->block_size; executed 28804263 times by 2 tests: return ctx->cipher->block_size;Executed by:
| 28804263 | ||||||
| 185 | } | - | ||||||
| 186 | - | |||||||
| 187 | int EVP_CIPHER_impl_ctx_size(const EVP_CIPHER *e) | - | ||||||
| 188 | { | - | ||||||
| 189 | return e->ctx_size; executed 256 times by 1 test: return e->ctx_size;Executed by:
| 256 | ||||||
| 190 | } | - | ||||||
| 191 | - | |||||||
| 192 | int EVP_Cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, | - | ||||||
| 193 | const unsigned char *in, unsigned int inl) | - | ||||||
| 194 | { | - | ||||||
| 195 | return ctx->cipher->do_cipher(ctx, out, in, inl); executed 17755 times by 1 test: return ctx->cipher->do_cipher(ctx, out, in, inl);Executed by:
| 17755 | ||||||
| 196 | } | - | ||||||
| 197 | - | |||||||
| 198 | const EVP_CIPHER *EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx) | - | ||||||
| 199 | { | - | ||||||
| 200 | return ctx->cipher; executed 12820273 times by 2 tests: return ctx->cipher;Executed by:
| 12820273 | ||||||
| 201 | } | - | ||||||
| 202 | - | |||||||
| 203 | int EVP_CIPHER_CTX_encrypting(const EVP_CIPHER_CTX *ctx) | - | ||||||
| 204 | { | - | ||||||
| 205 | return ctx->encrypt; executed 158312 times by 1 test: return ctx->encrypt;Executed by:
| 158312 | ||||||
| 206 | } | - | ||||||
| 207 | - | |||||||
| 208 | unsigned long EVP_CIPHER_flags(const EVP_CIPHER *cipher) | - | ||||||
| 209 | { | - | ||||||
| 210 | return cipher->flags; executed 12940989 times by 2 tests: return cipher->flags;Executed by:
| 12940989 | ||||||
| 211 | } | - | ||||||
| 212 | - | |||||||
| 213 | void *EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx) | - | ||||||
| 214 | { | - | ||||||
| 215 | return ctx->app_data; never executed: return ctx->app_data; | 0 | ||||||
| 216 | } | - | ||||||
| 217 | - | |||||||
| 218 | void EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data) | - | ||||||
| 219 | { | - | ||||||
| 220 | ctx->app_data = data; | - | ||||||
| 221 | } never executed: end of block | 0 | ||||||
| 222 | - | |||||||
| 223 | void *EVP_CIPHER_CTX_get_cipher_data(const EVP_CIPHER_CTX *ctx) | - | ||||||
| 224 | { | - | ||||||
| 225 | return ctx->cipher_data; executed 31265188 times by 2 tests: return ctx->cipher_data;Executed by:
| 31265188 | ||||||
| 226 | } | - | ||||||
| 227 | - | |||||||
| 228 | void *EVP_CIPHER_CTX_set_cipher_data(EVP_CIPHER_CTX *ctx, void *cipher_data) | - | ||||||
| 229 | { | - | ||||||
| 230 | void *old_cipher_data; | - | ||||||
| 231 | - | |||||||
| 232 | old_cipher_data = ctx->cipher_data; | - | ||||||
| 233 | ctx->cipher_data = cipher_data; | - | ||||||
| 234 | - | |||||||
| 235 | return old_cipher_data; never executed: return old_cipher_data; | 0 | ||||||
| 236 | } | - | ||||||
| 237 | - | |||||||
| 238 | int EVP_CIPHER_iv_length(const EVP_CIPHER *cipher) | - | ||||||
| 239 | { | - | ||||||
| 240 | return cipher->iv_len; executed 18408 times by 1 test: return cipher->iv_len;Executed by:
| 18408 | ||||||
| 241 | } | - | ||||||
| 242 | - | |||||||
| 243 | int EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx) | - | ||||||
| 244 | { | - | ||||||
| 245 | return ctx->cipher->iv_len; executed 120663 times by 1 test: return ctx->cipher->iv_len;Executed by:
| 120663 | ||||||
| 246 | } | - | ||||||
| 247 | - | |||||||
| 248 | const unsigned char *EVP_CIPHER_CTX_original_iv(const EVP_CIPHER_CTX *ctx) | - | ||||||
| 249 | { | - | ||||||
| 250 | return ctx->oiv; executed 2 times by 1 test: return ctx->oiv;Executed by:
| 2 | ||||||
| 251 | } | - | ||||||
| 252 | - | |||||||
| 253 | const unsigned char *EVP_CIPHER_CTX_iv(const EVP_CIPHER_CTX *ctx) | - | ||||||
| 254 | { | - | ||||||
| 255 | return ctx->iv; executed 9 times by 1 test: return ctx->iv;Executed by:
| 9 | ||||||
| 256 | } | - | ||||||
| 257 | - | |||||||
| 258 | unsigned char *EVP_CIPHER_CTX_iv_noconst(EVP_CIPHER_CTX *ctx) | - | ||||||
| 259 | { | - | ||||||
| 260 | return ctx->iv; executed 187233 times by 1 test: return ctx->iv;Executed by:
| 187233 | ||||||
| 261 | } | - | ||||||
| 262 | - | |||||||
| 263 | unsigned char *EVP_CIPHER_CTX_buf_noconst(EVP_CIPHER_CTX *ctx) | - | ||||||
| 264 | { | - | ||||||
| 265 | return ctx->buf; executed 24043 times by 1 test: return ctx->buf;Executed by:
| 24043 | ||||||
| 266 | } | - | ||||||
| 267 | - | |||||||
| 268 | int EVP_CIPHER_CTX_num(const EVP_CIPHER_CTX *ctx) | - | ||||||
| 269 | { | - | ||||||
| 270 | return ctx->num; executed 61168 times by 1 test: return ctx->num;Executed by:
| 61168 | ||||||
| 271 | } | - | ||||||
| 272 | - | |||||||
| 273 | void EVP_CIPHER_CTX_set_num(EVP_CIPHER_CTX *ctx, int num) | - | ||||||
| 274 | { | - | ||||||
| 275 | ctx->num = num; | - | ||||||
| 276 | } executed 61168 times by 1 test: end of blockExecuted by:
| 61168 | ||||||
| 277 | - | |||||||
| 278 | int EVP_CIPHER_key_length(const EVP_CIPHER *cipher) | - | ||||||
| 279 | { | - | ||||||
| 280 | return cipher->key_len; executed 14443 times by 1 test: return cipher->key_len;Executed by:
| 14443 | ||||||
| 281 | } | - | ||||||
| 282 | - | |||||||
| 283 | int EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx) | - | ||||||
| 284 | { | - | ||||||
| 285 | return ctx->key_len; executed 3186973 times by 2 tests: return ctx->key_len;Executed by:
| 3186973 | ||||||
| 286 | } | - | ||||||
| 287 | - | |||||||
| 288 | int EVP_CIPHER_nid(const EVP_CIPHER *cipher) | - | ||||||
| 289 | { | - | ||||||
| 290 | return cipher->nid; executed 47 times by 1 test: return cipher->nid;Executed by:
| 47 | ||||||
| 291 | } | - | ||||||
| 292 | - | |||||||
| 293 | int EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx) | - | ||||||
| 294 | { | - | ||||||
| 295 | return ctx->cipher->nid; executed 13 times by 1 test: return ctx->cipher->nid;Executed by:
| 13 | ||||||
| 296 | } | - | ||||||
| 297 | - | |||||||
| 298 | int EVP_MD_block_size(const EVP_MD *md) | - | ||||||
| 299 | { | - | ||||||
| 300 | return md->block_size; executed 160570 times by 1 test: return md->block_size;Executed by:
| 160570 | ||||||
| 301 | } | - | ||||||
| 302 | - | |||||||
| 303 | int EVP_MD_type(const EVP_MD *md) | - | ||||||
| 304 | { | - | ||||||
| 305 | return md->type; executed 28459 times by 1 test: return md->type;Executed by:
| 28459 | ||||||
| 306 | } | - | ||||||
| 307 | - | |||||||
| 308 | int EVP_MD_pkey_type(const EVP_MD *md) | - | ||||||
| 309 | { | - | ||||||
| 310 | return md->pkey_type; never executed: return md->pkey_type; | 0 | ||||||
| 311 | } | - | ||||||
| 312 | - | |||||||
| 313 | int EVP_MD_size(const EVP_MD *md) | - | ||||||
| 314 | { | - | ||||||
| 315 | if (!md) {
| 0-426109 | ||||||
| 316 | EVPerr(EVP_F_EVP_MD_SIZE, EVP_R_MESSAGE_DIGEST_IS_NULL); | - | ||||||
| 317 | return -1; never executed: return -1; | 0 | ||||||
| 318 | } | - | ||||||
| 319 | return md->md_size; executed 426109 times by 2 tests: return md->md_size;Executed by:
| 426109 | ||||||
| 320 | } | - | ||||||
| 321 | - | |||||||
| 322 | unsigned long EVP_MD_flags(const EVP_MD *md) | - | ||||||
| 323 | { | - | ||||||
| 324 | return md->flags; executed 119 times by 1 test: return md->flags;Executed by:
| 119 | ||||||
| 325 | } | - | ||||||
| 326 | - | |||||||
| 327 | EVP_MD *EVP_MD_meth_new(int md_type, int pkey_type) | - | ||||||
| 328 | { | - | ||||||
| 329 | EVP_MD *md = OPENSSL_zalloc(sizeof(*md)); | - | ||||||
| 330 | - | |||||||
| 331 | if (md != NULL) {
| 0-1835 | ||||||
| 332 | md->type = md_type; | - | ||||||
| 333 | md->pkey_type = pkey_type; | - | ||||||
| 334 | } executed 1835 times by 1 test: end of blockExecuted by:
| 1835 | ||||||
| 335 | return md; executed 1835 times by 1 test: return md;Executed by:
| 1835 | ||||||
| 336 | } | - | ||||||
| 337 | EVP_MD *EVP_MD_meth_dup(const EVP_MD *md) | - | ||||||
| 338 | { | - | ||||||
| 339 | EVP_MD *to = EVP_MD_meth_new(md->type, md->pkey_type); | - | ||||||
| 340 | - | |||||||
| 341 | if (to != NULL)
| 0 | ||||||
| 342 | memcpy(to, md, sizeof(*to)); never executed: memcpy(to, md, sizeof(*to)); | 0 | ||||||
| 343 | return to; never executed: return to; | 0 | ||||||
| 344 | } | - | ||||||
| 345 | void EVP_MD_meth_free(EVP_MD *md) | - | ||||||
| 346 | { | - | ||||||
| 347 | OPENSSL_free(md); | - | ||||||
| 348 | } executed 1835 times by 1 test: end of blockExecuted by:
| 1835 | ||||||
| 349 | int EVP_MD_meth_set_input_blocksize(EVP_MD *md, int blocksize) | - | ||||||
| 350 | { | - | ||||||
| 351 | md->block_size = blocksize; | - | ||||||
| 352 | return 1; executed 1835 times by 1 test: return 1;Executed by:
| 1835 | ||||||
| 353 | } | - | ||||||
| 354 | int EVP_MD_meth_set_result_size(EVP_MD *md, int resultsize) | - | ||||||
| 355 | { | - | ||||||
| 356 | md->md_size = resultsize; | - | ||||||
| 357 | return 1; executed 1835 times by 1 test: return 1;Executed by:
| 1835 | ||||||
| 358 | } | - | ||||||
| 359 | int EVP_MD_meth_set_app_datasize(EVP_MD *md, int datasize) | - | ||||||
| 360 | { | - | ||||||
| 361 | md->ctx_size = datasize; | - | ||||||
| 362 | return 1; executed 1835 times by 1 test: return 1;Executed by:
| 1835 | ||||||
| 363 | } | - | ||||||
| 364 | int EVP_MD_meth_set_flags(EVP_MD *md, unsigned long flags) | - | ||||||
| 365 | { | - | ||||||
| 366 | md->flags = flags; | - | ||||||
| 367 | return 1; executed 1835 times by 1 test: return 1;Executed by:
| 1835 | ||||||
| 368 | } | - | ||||||
| 369 | int EVP_MD_meth_set_init(EVP_MD *md, int (*init)(EVP_MD_CTX *ctx)) | - | ||||||
| 370 | { | - | ||||||
| 371 | md->init = init; | - | ||||||
| 372 | return 1; executed 1835 times by 1 test: return 1;Executed by:
| 1835 | ||||||
| 373 | } | - | ||||||
| 374 | int EVP_MD_meth_set_update(EVP_MD *md, int (*update)(EVP_MD_CTX *ctx, | - | ||||||
| 375 | const void *data, | - | ||||||
| 376 | size_t count)) | - | ||||||
| 377 | { | - | ||||||
| 378 | md->update = update; | - | ||||||
| 379 | return 1; executed 1835 times by 1 test: return 1;Executed by:
| 1835 | ||||||
| 380 | } | - | ||||||
| 381 | int EVP_MD_meth_set_final(EVP_MD *md, int (*final)(EVP_MD_CTX *ctx, | - | ||||||
| 382 | unsigned char *md)) | - | ||||||
| 383 | { | - | ||||||
| 384 | md->final = final; | - | ||||||
| 385 | return 1; executed 1835 times by 1 test: return 1;Executed by:
| 1835 | ||||||
| 386 | } | - | ||||||
| 387 | int EVP_MD_meth_set_copy(EVP_MD *md, int (*copy)(EVP_MD_CTX *to, | - | ||||||
| 388 | const EVP_MD_CTX *from)) | - | ||||||
| 389 | { | - | ||||||
| 390 | md->copy = copy; | - | ||||||
| 391 | return 1; never executed: return 1; | 0 | ||||||
| 392 | } | - | ||||||
| 393 | int EVP_MD_meth_set_cleanup(EVP_MD *md, int (*cleanup)(EVP_MD_CTX *ctx)) | - | ||||||
| 394 | { | - | ||||||
| 395 | md->cleanup = cleanup; | - | ||||||
| 396 | return 1; never executed: return 1; | 0 | ||||||
| 397 | } | - | ||||||
| 398 | int EVP_MD_meth_set_ctrl(EVP_MD *md, int (*ctrl)(EVP_MD_CTX *ctx, int cmd, | - | ||||||
| 399 | int p1, void *p2)) | - | ||||||
| 400 | { | - | ||||||
| 401 | md->md_ctrl = ctrl; | - | ||||||
| 402 | return 1; never executed: return 1; | 0 | ||||||
| 403 | } | - | ||||||
| 404 | - | |||||||
| 405 | int EVP_MD_meth_get_input_blocksize(const EVP_MD *md) | - | ||||||
| 406 | { | - | ||||||
| 407 | return md->block_size; never executed: return md->block_size; | 0 | ||||||
| 408 | } | - | ||||||
| 409 | int EVP_MD_meth_get_result_size(const EVP_MD *md) | - | ||||||
| 410 | { | - | ||||||
| 411 | return md->md_size; never executed: return md->md_size; | 0 | ||||||
| 412 | } | - | ||||||
| 413 | int EVP_MD_meth_get_app_datasize(const EVP_MD *md) | - | ||||||
| 414 | { | - | ||||||
| 415 | return md->ctx_size; never executed: return md->ctx_size; | 0 | ||||||
| 416 | } | - | ||||||
| 417 | unsigned long EVP_MD_meth_get_flags(const EVP_MD *md) | - | ||||||
| 418 | { | - | ||||||
| 419 | return md->flags; never executed: return md->flags; | 0 | ||||||
| 420 | } | - | ||||||
| 421 | int (*EVP_MD_meth_get_init(const EVP_MD *md))(EVP_MD_CTX *ctx) | - | ||||||
| 422 | { | - | ||||||
| 423 | return md->init; never executed: return md->init; | 0 | ||||||
| 424 | } | - | ||||||
| 425 | int (*EVP_MD_meth_get_update(const EVP_MD *md))(EVP_MD_CTX *ctx, | - | ||||||
| 426 | const void *data, | - | ||||||
| 427 | size_t count) | - | ||||||
| 428 | { | - | ||||||
| 429 | return md->update; never executed: return md->update; | 0 | ||||||
| 430 | } | - | ||||||
| 431 | int (*EVP_MD_meth_get_final(const EVP_MD *md))(EVP_MD_CTX *ctx, | - | ||||||
| 432 | unsigned char *md) | - | ||||||
| 433 | { | - | ||||||
| 434 | return md->final; never executed: return md->final; | 0 | ||||||
| 435 | } | - | ||||||
| 436 | int (*EVP_MD_meth_get_copy(const EVP_MD *md))(EVP_MD_CTX *to, | - | ||||||
| 437 | const EVP_MD_CTX *from) | - | ||||||
| 438 | { | - | ||||||
| 439 | return md->copy; never executed: return md->copy; | 0 | ||||||
| 440 | } | - | ||||||
| 441 | int (*EVP_MD_meth_get_cleanup(const EVP_MD *md))(EVP_MD_CTX *ctx) | - | ||||||
| 442 | { | - | ||||||
| 443 | return md->cleanup; never executed: return md->cleanup; | 0 | ||||||
| 444 | } | - | ||||||
| 445 | int (*EVP_MD_meth_get_ctrl(const EVP_MD *md))(EVP_MD_CTX *ctx, int cmd, | - | ||||||
| 446 | int p1, void *p2) | - | ||||||
| 447 | { | - | ||||||
| 448 | return md->md_ctrl; never executed: return md->md_ctrl; | 0 | ||||||
| 449 | } | - | ||||||
| 450 | - | |||||||
| 451 | const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx) | - | ||||||
| 452 | { | - | ||||||
| 453 | if (!ctx)
| 79614-171354 | ||||||
| 454 | return NULL; executed 79614 times by 1 test: return ((void *)0) ;Executed by:
| 79614 | ||||||
| 455 | return ctx->digest; executed 171354 times by 1 test: return ctx->digest;Executed by:
| 171354 | ||||||
| 456 | } | - | ||||||
| 457 | - | |||||||
| 458 | EVP_PKEY_CTX *EVP_MD_CTX_pkey_ctx(const EVP_MD_CTX *ctx) | - | ||||||
| 459 | { | - | ||||||
| 460 | return ctx->pctx; executed 106253 times by 1 test: return ctx->pctx;Executed by:
| 106253 | ||||||
| 461 | } | - | ||||||
| 462 | - | |||||||
| 463 | void EVP_MD_CTX_set_pkey_ctx(EVP_MD_CTX *ctx, EVP_PKEY_CTX *pctx) | - | ||||||
| 464 | { | - | ||||||
| 465 | /* | - | ||||||
| 466 | * it's reasonable to set NULL pctx (a.k.a clear the ctx->pctx), so | - | ||||||
| 467 | * we have to deal with the cleanup job here. | - | ||||||
| 468 | */ | - | ||||||
| 469 | if (!EVP_MD_CTX_test_flags(ctx, EVP_MD_CTX_FLAG_KEEP_PKEY_CTX))
| 0-3 | ||||||
| 470 | EVP_PKEY_CTX_free(ctx->pctx); executed 3 times by 1 test: EVP_PKEY_CTX_free(ctx->pctx);Executed by:
| 3 | ||||||
| 471 | - | |||||||
| 472 | ctx->pctx = pctx; | - | ||||||
| 473 | - | |||||||
| 474 | if (pctx != NULL) {
| 0-3 | ||||||
| 475 | /* make sure pctx is not freed when destroying EVP_MD_CTX */ | - | ||||||
| 476 | EVP_MD_CTX_set_flags(ctx, EVP_MD_CTX_FLAG_KEEP_PKEY_CTX); | - | ||||||
| 477 | } else { executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||
| 478 | EVP_MD_CTX_clear_flags(ctx, EVP_MD_CTX_FLAG_KEEP_PKEY_CTX); | - | ||||||
| 479 | } never executed: end of block | 0 | ||||||
| 480 | } | - | ||||||
| 481 | - | |||||||
| 482 | void *EVP_MD_CTX_md_data(const EVP_MD_CTX *ctx) | - | ||||||
| 483 | { | - | ||||||
| 484 | return ctx->md_data; executed 4002432 times by 2 tests: return ctx->md_data;Executed by:
| 4002432 | ||||||
| 485 | } | - | ||||||
| 486 | - | |||||||
| 487 | int (*EVP_MD_CTX_update_fn(EVP_MD_CTX *ctx))(EVP_MD_CTX *ctx, | - | ||||||
| 488 | const void *data, size_t count) | - | ||||||
| 489 | { | - | ||||||
| 490 | return ctx->update; never executed: return ctx->update; | 0 | ||||||
| 491 | } | - | ||||||
| 492 | - | |||||||
| 493 | void EVP_MD_CTX_set_update_fn(EVP_MD_CTX *ctx, | - | ||||||
| 494 | int (*update) (EVP_MD_CTX *ctx, | - | ||||||
| 495 | const void *data, size_t count)) | - | ||||||
| 496 | { | - | ||||||
| 497 | ctx->update = update; | - | ||||||
| 498 | } executed 19278 times by 1 test: end of blockExecuted by:
| 19278 | ||||||
| 499 | - | |||||||
| 500 | void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags) | - | ||||||
| 501 | { | - | ||||||
| 502 | ctx->flags |= flags; | - | ||||||
| 503 | } executed 494387 times by 1 test: end of blockExecuted by:
| 494387 | ||||||
| 504 | - | |||||||
| 505 | void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags) | - | ||||||
| 506 | { | - | ||||||
| 507 | ctx->flags &= ~flags; | - | ||||||
| 508 | } executed 1712324 times by 3 tests: end of blockExecuted by:
| 1712324 | ||||||
| 509 | - | |||||||
| 510 | int EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx, int flags) | - | ||||||
| 511 | { | - | ||||||
| 512 | return (ctx->flags & flags); executed 3624465 times by 3 tests: return (ctx->flags & flags);Executed by:
| 3624465 | ||||||
| 513 | } | - | ||||||
| 514 | - | |||||||
| 515 | void EVP_CIPHER_CTX_set_flags(EVP_CIPHER_CTX *ctx, int flags) | - | ||||||
| 516 | { | - | ||||||
| 517 | ctx->flags |= flags; | - | ||||||
| 518 | } executed 8361 times by 1 test: end of blockExecuted by:
| 8361 | ||||||
| 519 | - | |||||||
| 520 | void EVP_CIPHER_CTX_clear_flags(EVP_CIPHER_CTX *ctx, int flags) | - | ||||||
| 521 | { | - | ||||||
| 522 | ctx->flags &= ~flags; | - | ||||||
| 523 | } never executed: end of block | 0 | ||||||
| 524 | - | |||||||
| 525 | int EVP_CIPHER_CTX_test_flags(const EVP_CIPHER_CTX *ctx, int flags) | - | ||||||
| 526 | { | - | ||||||
| 527 | return (ctx->flags & flags); executed 28481639 times by 2 tests: return (ctx->flags & flags);Executed by:
| 28481639 | ||||||
| 528 | } | - | ||||||
| Source code | Switch to Preprocessed file |