| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/evp/e_rc2.c |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /* | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | * Copyright 1995-2016 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 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | #ifndef OPENSSL_NO_RC2 | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # include <openssl/evp.h> | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # include <openssl/objects.h> | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # include "internal/evp_int.h" | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # include <openssl/rc2.h> | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | static int rc2_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | const unsigned char *iv, int enc); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | static int rc2_meth_to_magic(EVP_CIPHER_CTX *ctx); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | static int rc2_magic_to_meth(int i); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | static int rc2_set_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | static int rc2_get_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | static int rc2_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | typedef struct { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | int key_bits; /* effective key bits */ | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | RC2_KEY ks; /* key schedule */ | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } EVP_RC2_KEY; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | # define data(ctx) EVP_C_DATA(EVP_RC2_KEY,ctx) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | IMPLEMENT_BLOCK_CIPHER(rc2, ks, RC2, EVP_RC2_KEY, NID_rc2, never executed: end of blockexecuted 531 times by 1 test: RC2_cbc_encrypt(in, out, (long)inl, &((EVP_RC2_KEY *)EVP_CIPHER_CTX_get_cipher_data(ctx))->ks, EVP_CIPHER_CTX_iv_noconst(ctx), EVP_CIPHER_CTX_encrypting(ctx));Executed by:
executed 531 times by 1 test: return 1;Executed by:
never executed: chunk >>= 3;executed 70 times by 1 test: chunk = inl;Executed by:
executed 70 times by 1 test: chunk = inl;Executed by:
executed 70 times by 1 test: end of blockExecuted by:
executed 70 times by 1 test: return 1;Executed by:
never executed: return 1;executed 1572 times by 1 test: RC2_ecb_encrypt(in + i, out + i, &((EVP_RC2_KEY *)EVP_CIPHER_CTX_get_cipher_data(ctx))->ks, EVP_CIPHER_CTX_encrypting(ctx));Executed by:
executed 129 times by 1 test: return 1;Executed by:
never executed: end of blockexecuted 70 times by 1 test: end of blockExecuted by:
executed 70 times by 1 test: return 1;Executed by:
executed 3920 times by 1 test: return &rc2_cbc;Executed by:
executed 1962 times by 1 test: return &rc2_cfb64;Executed by:
executed 1962 times by 1 test: return &rc2_ofb;Executed by:
executed 1962 times by 1 test: return &rc2_ecb;Executed by:
| 0-3920 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 8, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | RC2_KEY_LENGTH, 8, 64, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | rc2_init_key, NULL, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | rc2_set_asn1_type_and_iv, rc2_get_asn1_type_and_iv, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | rc2_ctrl) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | # define RC2_40_MAGIC 0xa0 | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | # define RC2_64_MAGIC 0x78 | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | # define RC2_128_MAGIC 0x3a | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | static const EVP_CIPHER r2_64_cbc_cipher = { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | NID_rc2_64_cbc, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 8, 8 /* 64 bit */ , 8, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | rc2_init_key, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | rc2_cbc_cipher, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | NULL, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | sizeof(EVP_RC2_KEY), | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | rc2_set_asn1_type_and_iv, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | rc2_get_asn1_type_and_iv, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | rc2_ctrl, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | NULL | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | }; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | static const EVP_CIPHER r2_40_cbc_cipher = { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | NID_rc2_40_cbc, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 8, 5 /* 40 bit */ , 8, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH | EVP_CIPH_CTRL_INIT, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | rc2_init_key, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | rc2_cbc_cipher, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | NULL, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | sizeof(EVP_RC2_KEY), | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | rc2_set_asn1_type_and_iv, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | rc2_get_asn1_type_and_iv, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | rc2_ctrl, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | NULL | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | }; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | const EVP_CIPHER *EVP_rc2_64_cbc(void) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | return &r2_64_cbc_cipher; executed 1962 times by 1 test: return &r2_64_cbc_cipher;Executed by:
| 1962 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | const EVP_CIPHER *EVP_rc2_40_cbc(void) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | return &r2_40_cbc_cipher; executed 3920 times by 1 test: return &r2_40_cbc_cipher;Executed by:
| 3920 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | static int rc2_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | const unsigned char *iv, int enc) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | RC2_set_key(&data(ctx)->ks, EVP_CIPHER_CTX_key_length(ctx), | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | key, data(ctx)->key_bits); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | return 1; executed 52 times by 1 test: return 1;Executed by:
| 52 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | static int rc2_meth_to_magic(EVP_CIPHER_CTX *e) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | int i; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | EVP_CIPHER_CTX_ctrl(e, EVP_CTRL_GET_RC2_KEY_BITS, 0, &i); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | if (i == 128)
| 0-2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | return RC2_128_MAGIC; executed 2 times by 1 test: return 0x3a;Executed by:
| 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | else if (i == 64)
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | return RC2_64_MAGIC; never executed: return 0x78; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | else if (i == 40)
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | return RC2_40_MAGIC; never executed: return 0xa0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | else | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | static int rc2_magic_to_meth(int i) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | if (i == RC2_128_MAGIC)
| 0-2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | return 128; executed 2 times by 1 test: return 128;Executed by:
| 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | else if (i == RC2_64_MAGIC)
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | return 64; never executed: return 64; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | else if (i == RC2_40_MAGIC)
| 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | return 40; never executed: return 40; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | else { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | EVPerr(EVP_F_RC2_MAGIC_TO_METH, EVP_R_UNSUPPORTED_KEY_SIZE); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | static int rc2_get_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | long num = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | int i = 0; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | int key_bits; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | unsigned int l; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | unsigned char iv[EVP_MAX_IV_LENGTH]; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | if (type != NULL) {
| 0-2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | l = EVP_CIPHER_CTX_iv_length(c); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | OPENSSL_assert(l <= sizeof(iv)); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | i = ASN1_TYPE_get_int_octetstring(type, &num, iv, l); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | if (i != (int)l)
| 0-2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | key_bits = rc2_magic_to_meth((int)num); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | if (!key_bits)
| 0-2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | if (i > 0 && !EVP_CipherInit_ex(c, NULL, NULL, NULL, iv, -1))
| 0-2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | EVP_CIPHER_CTX_ctrl(c, EVP_CTRL_SET_RC2_KEY_BITS, key_bits, NULL); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | if (EVP_CIPHER_CTX_set_key_length(c, key_bits / 8) <= 0)
| 0-2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | return i; executed 2 times by 1 test: return i;Executed by:
| 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | static int rc2_set_asn1_type_and_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | long num; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | int i = 0, j; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | if (type != NULL) {
| 0-2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | num = rc2_meth_to_magic(c); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | j = EVP_CIPHER_CTX_iv_length(c); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | i = ASN1_TYPE_set_int_octetstring(type, num, | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | (unsigned char *)EVP_CIPHER_CTX_original_iv(c), | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | j); | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | return i; executed 2 times by 1 test: return i;Executed by:
| 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | static int rc2_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr) | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | switch (type) { | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | case EVP_CTRL_INIT: executed 52 times by 1 test: case 0x0:Executed by:
| 52 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | data(c)->key_bits = EVP_CIPHER_CTX_key_length(c) * 8; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | return 1; executed 52 times by 1 test: return 1;Executed by:
| 52 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | case EVP_CTRL_GET_RC2_KEY_BITS: executed 2 times by 1 test: case 0x2:Executed by:
| 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | *(int *)ptr = data(c)->key_bits; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | return 1; executed 2 times by 1 test: return 1;Executed by:
| 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | case EVP_CTRL_SET_RC2_KEY_BITS: executed 2 times by 1 test: case 0x3:Executed by:
| 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | if (arg > 0) {
| 0-2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | data(c)->key_bits = arg; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | return 1; executed 2 times by 1 test: return 1;Executed by:
| 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | # ifdef PBE_PRF_TEST | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | case EVP_CTRL_PBE_PRF_NID: | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | *(int *)ptr = NID_hmacWithMD5; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | return 1; | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | # endif | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | default: never executed: default: | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | - | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | #endif | - | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Source code | Switch to Preprocessed file |