OpenCoverage

p_lib.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/evp/p_lib.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/* $OpenBSD: p_lib.c,v 1.24 2018/05/30 15:40:50 tb Exp $ */-
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)-
3 * All rights reserved.-
4 *-
5 * This package is an SSL implementation written-
6 * by Eric Young (eay@cryptsoft.com).-
7 * The implementation was written so as to conform with Netscapes SSL.-
8 *-
9 * This library is free for commercial and non-commercial use as long as-
10 * the following conditions are aheared to. The following conditions-
11 * apply to all code found in this distribution, be it the RC4, RSA,-
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation-
13 * included with this distribution is covered by the same copyright terms-
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).-
15 *-
16 * Copyright remains Eric Young's, and as such any Copyright notices in-
17 * the code are not to be removed.-
18 * If this package is used in a product, Eric Young should be given attribution-
19 * as the author of the parts of the library used.-
20 * This can be in the form of a textual message at program startup or-
21 * in documentation (online or textual) provided with the package.-
22 *-
23 * Redistribution and use in source and binary forms, with or without-
24 * modification, are permitted provided that the following conditions-
25 * are met:-
26 * 1. Redistributions of source code must retain the copyright-
27 * notice, this list of conditions and the following disclaimer.-
28 * 2. Redistributions in binary form must reproduce the above copyright-
29 * notice, this list of conditions and the following disclaimer in the-
30 * documentation and/or other materials provided with the distribution.-
31 * 3. All advertising materials mentioning features or use of this software-
32 * must display the following acknowledgement:-
33 * "This product includes cryptographic software written by-
34 * Eric Young (eay@cryptsoft.com)"-
35 * The word 'cryptographic' can be left out if the rouines from the library-
36 * being used are not cryptographic related :-).-
37 * 4. If you include any Windows specific code (or a derivative thereof) from-
38 * the apps directory (application code) you must include an acknowledgement:-
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"-
40 *-
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND-
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE-
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE-
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE-
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL-
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS-
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)-
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT-
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY-
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF-
51 * SUCH DAMAGE.-
52 *-
53 * The licence and distribution terms for any publically available version or-
54 * derivative of this code cannot be changed. i.e. this code cannot simply be-
55 * copied and put under another distribution licence-
56 * [including the GNU Public Licence.]-
57 */-
58-
59#include <stdio.h>-
60-
61#include <openssl/opensslconf.h>-
62-
63#include <openssl/bn.h>-
64#include <openssl/err.h>-
65#include <openssl/evp.h>-
66#include <openssl/objects.h>-
67#include <openssl/x509.h>-
68-
69#ifndef OPENSSL_NO_DH-
70#include <openssl/dh.h>-
71#endif-
72#ifndef OPENSSL_NO_DSA-
73#include <openssl/dsa.h>-
74#endif-
75#ifndef OPENSSL_NO_RSA-
76#include <openssl/rsa.h>-
77#endif-
78-
79#ifndef OPENSSL_NO_ENGINE-
80#include <openssl/engine.h>-
81#endif-
82-
83#include "asn1_locl.h"-
84-
85static void EVP_PKEY_free_it(EVP_PKEY *x);-
86-
87int-
88EVP_PKEY_bits(const EVP_PKEY *pkey)-
89{-
90 if (pkey && pkey->ameth && pkey->ameth->pkey_bits)
pkeyDescription
TRUEevaluated 3 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • servertest
FALSEnever evaluated
pkey->amethDescription
TRUEevaluated 3 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • servertest
FALSEnever evaluated
pkey->ameth->pkey_bitsDescription
TRUEevaluated 3 times by 2 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • servertest
FALSEnever evaluated
0-3
91 return pkey->ameth->pkey_bits(pkey);
executed 3 times by 2 tests: return pkey->ameth->pkey_bits(pkey);
Executed by:
  • libcrypto.so.44.0.1
  • servertest
3
92 return 0;
never executed: return 0;
0
93}-
94-
95int-
96EVP_PKEY_size(const EVP_PKEY *pkey)-
97{-
98 if (pkey && pkey->ameth && pkey->ameth->pkey_size)
pkeyDescription
TRUEevaluated 232 times by 5 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • pkcs7test
  • servertest
  • ssltest
  • tlstest
FALSEnever evaluated
pkey->amethDescription
TRUEevaluated 232 times by 5 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • pkcs7test
  • servertest
  • ssltest
  • tlstest
FALSEnever evaluated
pkey->ameth->pkey_sizeDescription
TRUEevaluated 232 times by 5 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • pkcs7test
  • servertest
  • ssltest
  • tlstest
FALSEnever evaluated
0-232
99 return pkey->ameth->pkey_size(pkey);
executed 232 times by 5 tests: return pkey->ameth->pkey_size(pkey);
Executed by:
  • libcrypto.so.44.0.1
  • pkcs7test
  • servertest
  • ssltest
  • tlstest
232
100 return 0;
never executed: return 0;
0
101}-
102-
103int-
104EVP_PKEY_save_parameters(EVP_PKEY *pkey, int mode)-
105{-
106#ifndef OPENSSL_NO_DSA-
107 if (pkey->type == EVP_PKEY_DSA) {
pkey->type == 116Description
TRUEnever evaluated
FALSEnever evaluated
0
108 int ret = pkey->save_parameters;-
109-
110 if (mode >= 0)
mode >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
111 pkey->save_parameters = mode;
never executed: pkey->save_parameters = mode;
0
112 return (ret);
never executed: return (ret);
0
113 }-
114#endif-
115#ifndef OPENSSL_NO_EC-
116 if (pkey->type == EVP_PKEY_EC) {
pkey->type == 408Description
TRUEnever evaluated
FALSEnever evaluated
0
117 int ret = pkey->save_parameters;-
118-
119 if (mode >= 0)
mode >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
120 pkey->save_parameters = mode;
never executed: pkey->save_parameters = mode;
0
121 return (ret);
never executed: return (ret);
0
122 }-
123#endif-
124 return (0);
never executed: return (0);
0
125}-
126-
127int-
128EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from)-
129{-
130 if (to->type != from->type) {
to->type != from->typeDescription
TRUEnever evaluated
FALSEevaluated 64 times by 4 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • servertest
  • ssltest
  • tlstest
0-64
131 EVPerror(EVP_R_DIFFERENT_KEY_TYPES);-
132 goto err;
never executed: goto err;
0
133 }-
134-
135 if (EVP_PKEY_missing_parameters(from)) {
EVP_PKEY_missi...rameters(from)Description
TRUEnever evaluated
FALSEevaluated 64 times by 4 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • servertest
  • ssltest
  • tlstest
0-64
136 EVPerror(EVP_R_MISSING_PARAMETERS);-
137 goto err;
never executed: goto err;
0
138 }-
139 if (from->ameth && from->ameth->param_copy)
from->amethDescription
TRUEevaluated 64 times by 4 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • servertest
  • ssltest
  • tlstest
FALSEnever evaluated
from->ameth->param_copyDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEevaluated 63 times by 3 tests
Evaluated by:
  • servertest
  • ssltest
  • tlstest
0-64
140 return from->ameth->param_copy(to, from);
executed 1 time by 1 test: return from->ameth->param_copy(to, from);
Executed by:
  • libcrypto.so.44.0.1
1
141-
142err:
code before this statement executed 63 times by 3 tests: err:
Executed by:
  • servertest
  • ssltest
  • tlstest
63
143 return 0;
executed 63 times by 3 tests: return 0;
Executed by:
  • servertest
  • ssltest
  • tlstest
63
144}-
145-
146int-
147EVP_PKEY_missing_parameters(const EVP_PKEY *pkey)-
148{-
149 if (pkey->ameth && pkey->ameth->param_missing)
pkey->amethDescription
TRUEevaluated 117 times by 4 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • servertest
  • ssltest
  • tlstest
FALSEnever evaluated
pkey->ameth->param_missingDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEevaluated 116 times by 3 tests
Evaluated by:
  • servertest
  • ssltest
  • tlstest
0-117
150 return pkey->ameth->param_missing(pkey);
executed 1 time by 1 test: return pkey->ameth->param_missing(pkey);
Executed by:
  • libcrypto.so.44.0.1
1
151 return 0;
executed 116 times by 3 tests: return 0;
Executed by:
  • servertest
  • ssltest
  • tlstest
116
152}-
153-
154int-
155EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b)-
156{-
157 if (a->type != b->type)
a->type != b->typeDescription
TRUEnever evaluated
FALSEnever evaluated
0
158 return -1;
never executed: return -1;
0
159 if (a->ameth && a->ameth->param_cmp)
a->amethDescription
TRUEnever evaluated
FALSEnever evaluated
a->ameth->param_cmpDescription
TRUEnever evaluated
FALSEnever evaluated
0
160 return a->ameth->param_cmp(a, b);
never executed: return a->ameth->param_cmp(a, b);
0
161 return -2;
never executed: return -2;
0
162}-
163-
164int-
165EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b)-
166{-
167 if (a->type != b->type)
a->type != b->typeDescription
TRUEnever evaluated
FALSEevaluated 70 times by 4 tests
Evaluated by:
  • pkcs7test
  • servertest
  • ssltest
  • tlstest
0-70
168 return -1;
never executed: return -1;
0
169-
170 if (a->ameth) {
a->amethDescription
TRUEevaluated 70 times by 4 tests
Evaluated by:
  • pkcs7test
  • servertest
  • ssltest
  • tlstest
FALSEnever evaluated
0-70
171 int ret;-
172 /* Compare parameters if the algorithm has them */-
173 if (a->ameth->param_cmp) {
a->ameth->param_cmpDescription
TRUEnever evaluated
FALSEevaluated 70 times by 4 tests
Evaluated by:
  • pkcs7test
  • servertest
  • ssltest
  • tlstest
0-70
174 ret = a->ameth->param_cmp(a, b);-
175 if (ret <= 0)
ret <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
176 return ret;
never executed: return ret;
0
177 }
never executed: end of block
0
178-
179 if (a->ameth->pub_cmp)
a->ameth->pub_cmpDescription
TRUEevaluated 70 times by 4 tests
Evaluated by:
  • pkcs7test
  • servertest
  • ssltest
  • tlstest
FALSEnever evaluated
0-70
180 return a->ameth->pub_cmp(a, b);
executed 70 times by 4 tests: return a->ameth->pub_cmp(a, b);
Executed by:
  • pkcs7test
  • servertest
  • ssltest
  • tlstest
70
181 }
never executed: end of block
0
182-
183 return -2;
never executed: return -2;
0
184}-
185-
186EVP_PKEY *-
187EVP_PKEY_new(void)-
188{-
189 EVP_PKEY *ret;-
190-
191 ret = malloc(sizeof(EVP_PKEY));-
192 if (ret == NULL) {
ret == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 2069 times by 8 tests
Evaluated by:
  • dsatest
  • gost2814789t
  • libcrypto.so.44.0.1
  • pkcs7test
  • servertest
  • ssltest
  • tls_prf
  • tlstest
0-2069
193 EVPerror(ERR_R_MALLOC_FAILURE);-
194 return (NULL);
never executed: return ( ((void *)0) );
0
195 }-
196 ret->type = EVP_PKEY_NONE;-
197 ret->save_type = EVP_PKEY_NONE;-
198 ret->references = 1;-
199 ret->ameth = NULL;-
200 ret->engine = NULL;-
201 ret->pkey.ptr = NULL;-
202 ret->attributes = NULL;-
203 ret->save_parameters = 1;-
204 return (ret);
executed 2069 times by 8 tests: return (ret);
Executed by:
  • dsatest
  • gost2814789t
  • libcrypto.so.44.0.1
  • pkcs7test
  • servertest
  • ssltest
  • tls_prf
  • tlstest
2069
205}-
206-
207int-
208EVP_PKEY_up_ref(EVP_PKEY *pkey)-
209{-
210 int refs = CRYPTO_add(&pkey->references, 1, CRYPTO_LOCK_EVP_PKEY);-
211 return ((refs > 1) ? 1 : 0);
never executed: return ((refs > 1) ? 1 : 0);
(refs > 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
212}-
213-
214/* Setup a public key ASN1 method and ENGINE from a NID or a string.-
215 * If pkey is NULL just return 1 or 0 if the algorithm exists.-
216 */-
217-
218static int-
219pkey_set_type(EVP_PKEY *pkey, int type, const char *str, int len)-
220{-
221 const EVP_PKEY_ASN1_METHOD *ameth;-
222 ENGINE *e = NULL;-
223 if (pkey) {
pkeyDescription
TRUEevaluated 2324 times by 8 tests
Evaluated by:
  • dsatest
  • gost2814789t
  • libcrypto.so.44.0.1
  • pkcs7test
  • servertest
  • ssltest
  • tls_prf
  • tlstest
FALSEnever evaluated
0-2324
224 if (pkey->pkey.ptr)
pkey->pkey.ptrDescription
TRUEnever evaluated
FALSEevaluated 2324 times by 8 tests
Evaluated by:
  • dsatest
  • gost2814789t
  • libcrypto.so.44.0.1
  • pkcs7test
  • servertest
  • ssltest
  • tls_prf
  • tlstest
0-2324
225 EVP_PKEY_free_it(pkey);
never executed: EVP_PKEY_free_it(pkey);
0
226 /* If key type matches and a method exists then this-
227 * lookup has succeeded once so just indicate success.-
228 */-
229 if ((type == pkey->save_type) && pkey->ameth)
(type == pkey->save_type)Description
TRUEevaluated 255 times by 5 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • pkcs7test
  • servertest
  • ssltest
  • tlstest
FALSEevaluated 2069 times by 8 tests
Evaluated by:
  • dsatest
  • gost2814789t
  • libcrypto.so.44.0.1
  • pkcs7test
  • servertest
  • ssltest
  • tls_prf
  • tlstest
pkey->amethDescription
TRUEevaluated 254 times by 5 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • pkcs7test
  • servertest
  • ssltest
  • tlstest
FALSEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
1-2069
230 return 1;
executed 254 times by 5 tests: return 1;
Executed by:
  • libcrypto.so.44.0.1
  • pkcs7test
  • servertest
  • ssltest
  • tlstest
254
231#ifndef OPENSSL_NO_ENGINE-
232 ENGINE_finish(pkey->engine);-
233 pkey->engine = NULL;-
234#endif-
235 }
executed 2070 times by 8 tests: end of block
Executed by:
  • dsatest
  • gost2814789t
  • libcrypto.so.44.0.1
  • pkcs7test
  • servertest
  • ssltest
  • tls_prf
  • tlstest
2070
236 if (str)
strDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEevaluated 2069 times by 8 tests
Evaluated by:
  • dsatest
  • gost2814789t
  • libcrypto.so.44.0.1
  • pkcs7test
  • servertest
  • ssltest
  • tls_prf
  • tlstest
1-2069
237 ameth = EVP_PKEY_asn1_find_str(&e, str, len);
executed 1 time by 1 test: ameth = EVP_PKEY_asn1_find_str(&e, str, len);
Executed by:
  • libcrypto.so.44.0.1
1
238 else-
239 ameth = EVP_PKEY_asn1_find(&e, type);
executed 2069 times by 8 tests: ameth = EVP_PKEY_asn1_find(&e, type);
Executed by:
  • dsatest
  • gost2814789t
  • libcrypto.so.44.0.1
  • pkcs7test
  • servertest
  • ssltest
  • tls_prf
  • tlstest
2069
240#ifndef OPENSSL_NO_ENGINE-
241 if (pkey == NULL)
pkey == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 2070 times by 8 tests
Evaluated by:
  • dsatest
  • gost2814789t
  • libcrypto.so.44.0.1
  • pkcs7test
  • servertest
  • ssltest
  • tls_prf
  • tlstest
0-2070
242 ENGINE_finish(e);
never executed: ENGINE_finish(e);
0
243#endif-
244 if (!ameth) {
!amethDescription
TRUEnever evaluated
FALSEevaluated 2070 times by 8 tests
Evaluated by:
  • dsatest
  • gost2814789t
  • libcrypto.so.44.0.1
  • pkcs7test
  • servertest
  • ssltest
  • tls_prf
  • tlstest
0-2070
245 EVPerror(EVP_R_UNSUPPORTED_ALGORITHM);-
246 return 0;
never executed: return 0;
0
247 }-
248 if (pkey) {
pkeyDescription
TRUEevaluated 2070 times by 8 tests
Evaluated by:
  • dsatest
  • gost2814789t
  • libcrypto.so.44.0.1
  • pkcs7test
  • servertest
  • ssltest
  • tls_prf
  • tlstest
FALSEnever evaluated
0-2070
249 pkey->ameth = ameth;-
250 pkey->engine = e;-
251-
252 pkey->type = pkey->ameth->pkey_id;-
253 pkey->save_type = type;-
254 }
executed 2070 times by 8 tests: end of block
Executed by:
  • dsatest
  • gost2814789t
  • libcrypto.so.44.0.1
  • pkcs7test
  • servertest
  • ssltest
  • tls_prf
  • tlstest
2070
255 return 1;
executed 2070 times by 8 tests: return 1;
Executed by:
  • dsatest
  • gost2814789t
  • libcrypto.so.44.0.1
  • pkcs7test
  • servertest
  • ssltest
  • tls_prf
  • tlstest
2070
256}-
257-
258int-
259EVP_PKEY_set_type(EVP_PKEY *pkey, int type)-
260{-
261 return pkey_set_type(pkey, type, NULL, -1);
executed 2323 times by 8 tests: return pkey_set_type(pkey, type, ((void *)0) , -1);
Executed by:
  • dsatest
  • gost2814789t
  • libcrypto.so.44.0.1
  • pkcs7test
  • servertest
  • ssltest
  • tls_prf
  • tlstest
2323
262}-
263-
264int-
265EVP_PKEY_set_type_str(EVP_PKEY *pkey, const char *str, int len)-
266{-
267 return pkey_set_type(pkey, EVP_PKEY_NONE, str, len);
executed 1 time by 1 test: return pkey_set_type(pkey, 0, str, len);
Executed by:
  • libcrypto.so.44.0.1
1
268}-
269-
270int-
271EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key)-
272{-
273 if (!EVP_PKEY_set_type(pkey, type))
!EVP_PKEY_set_type(pkey, type)Description
TRUEnever evaluated
FALSEevaluated 2069 times by 8 tests
Evaluated by:
  • dsatest
  • gost2814789t
  • libcrypto.so.44.0.1
  • pkcs7test
  • servertest
  • ssltest
  • tls_prf
  • tlstest
0-2069
274 return 0;
never executed: return 0;
0
275 pkey->pkey.ptr = key;-
276 return (key != NULL);
executed 2069 times by 8 tests: return (key != ((void *)0) );
Executed by:
  • dsatest
  • gost2814789t
  • libcrypto.so.44.0.1
  • pkcs7test
  • servertest
  • ssltest
  • tls_prf
  • tlstest
2069
277}-
278-
279void *-
280EVP_PKEY_get0(const EVP_PKEY *pkey)-
281{-
282 return pkey->pkey.ptr;
executed 8 times by 1 test: return pkey->pkey.ptr;
Executed by:
  • gost2814789t
8
283}-
284-
285#ifndef OPENSSL_NO_RSA-
286RSA *-
287EVP_PKEY_get0_RSA(EVP_PKEY *pkey)-
288{-
289 if (pkey->type != EVP_PKEY_RSA) {
pkey->type != 6Description
TRUEnever evaluated
FALSEnever evaluated
0
290 EVPerror(EVP_R_EXPECTING_AN_RSA_KEY);-
291 return NULL;
never executed: return ((void *)0) ;
0
292 }-
293 return pkey->pkey.rsa;
never executed: return pkey->pkey.rsa;
0
294}-
295-
296RSA *-
297EVP_PKEY_get1_RSA(EVP_PKEY *pkey)-
298{-
299 if (pkey->type != EVP_PKEY_RSA) {
pkey->type != 6Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tlstest
0-4
300 EVPerror(EVP_R_EXPECTING_AN_RSA_KEY);-
301 return NULL;
never executed: return ((void *)0) ;
0
302 }-
303 RSA_up_ref(pkey->pkey.rsa);-
304 return pkey->pkey.rsa;
executed 4 times by 1 test: return pkey->pkey.rsa;
Executed by:
  • tlstest
4
305}-
306-
307int-
308EVP_PKEY_set1_RSA(EVP_PKEY *pkey, RSA *key)-
309{-
310 int ret = EVP_PKEY_assign_RSA(pkey, key);-
311 if (ret != 0)
ret != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
312 RSA_up_ref(key);
never executed: RSA_up_ref(key);
0
313 return ret;
never executed: return ret;
0
314}-
315#endif-
316-
317#ifndef OPENSSL_NO_DSA-
318DSA *-
319EVP_PKEY_get0_DSA(EVP_PKEY *pkey)-
320{-
321 if (pkey->type != EVP_PKEY_DSA) {
pkey->type != 116Description
TRUEnever evaluated
FALSEnever evaluated
0
322 EVPerror(EVP_R_EXPECTING_A_DSA_KEY);-
323 return NULL;
never executed: return ((void *)0) ;
0
324 }-
325 return pkey->pkey.dsa;
never executed: return pkey->pkey.dsa;
0
326}-
327-
328DSA *-
329EVP_PKEY_get1_DSA(EVP_PKEY *pkey)-
330{-
331 if (pkey->type != EVP_PKEY_DSA) {
pkey->type != 116Description
TRUEnever evaluated
FALSEnever evaluated
0
332 EVPerror(EVP_R_EXPECTING_A_DSA_KEY);-
333 return NULL;
never executed: return ((void *)0) ;
0
334 }-
335 DSA_up_ref(pkey->pkey.dsa);-
336 return pkey->pkey.dsa;
never executed: return pkey->pkey.dsa;
0
337}-
338-
339int-
340EVP_PKEY_set1_DSA(EVP_PKEY *pkey, DSA *key)-
341{-
342 int ret = EVP_PKEY_assign_DSA(pkey, key);-
343 if (ret != 0)
ret != 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • dsatest
FALSEnever evaluated
0-1
344 DSA_up_ref(key);
executed 1 time by 1 test: DSA_up_ref(key);
Executed by:
  • dsatest
1
345 return ret;
executed 1 time by 1 test: return ret;
Executed by:
  • dsatest
1
346}-
347#endif-
348-
349#ifndef OPENSSL_NO_EC-
350EC_KEY *-
351EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey)-
352{-
353 if (pkey->type != EVP_PKEY_EC) {
pkey->type != 408Description
TRUEnever evaluated
FALSEnever evaluated
0
354 EVPerror(EVP_R_EXPECTING_A_EC_KEY);-
355 return NULL;
never executed: return ((void *)0) ;
0
356 }-
357 return pkey->pkey.ec;
never executed: return pkey->pkey.ec;
0
358}-
359-
360EC_KEY *-
361EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey)-
362{-
363 if (pkey->type != EVP_PKEY_EC) {
pkey->type != 408Description
TRUEnever evaluated
FALSEnever evaluated
0
364 EVPerror(EVP_R_EXPECTING_A_EC_KEY);-
365 return NULL;
never executed: return ((void *)0) ;
0
366 }-
367 EC_KEY_up_ref(pkey->pkey.ec);-
368 return pkey->pkey.ec;
never executed: return pkey->pkey.ec;
0
369}-
370-
371int-
372EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, EC_KEY *key)-
373{-
374 int ret = EVP_PKEY_assign_EC_KEY(pkey, key);-
375 if (ret != 0)
ret != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
376 EC_KEY_up_ref(key);
never executed: EC_KEY_up_ref(key);
0
377 return ret;
never executed: return ret;
0
378}-
379#endif-
380-
381-
382#ifndef OPENSSL_NO_DH-
383DH *-
384EVP_PKEY_get0_DH(EVP_PKEY *pkey)-
385{-
386 if (pkey->type != EVP_PKEY_DH) {
pkey->type != 28Description
TRUEnever evaluated
FALSEnever evaluated
0
387 EVPerror(EVP_R_EXPECTING_A_DH_KEY);-
388 return NULL;
never executed: return ((void *)0) ;
0
389 }-
390 return pkey->pkey.dh;
never executed: return pkey->pkey.dh;
0
391}-
392-
393DH *-
394EVP_PKEY_get1_DH(EVP_PKEY *pkey)-
395{-
396 if (pkey->type != EVP_PKEY_DH) {
pkey->type != 28Description
TRUEnever evaluated
FALSEnever evaluated
0
397 EVPerror(EVP_R_EXPECTING_A_DH_KEY);-
398 return NULL;
never executed: return ((void *)0) ;
0
399 }-
400 DH_up_ref(pkey->pkey.dh);-
401 return pkey->pkey.dh;
never executed: return pkey->pkey.dh;
0
402}-
403-
404int-
405EVP_PKEY_set1_DH(EVP_PKEY *pkey, DH *key)-
406{-
407 int ret = EVP_PKEY_assign_DH(pkey, key);-
408 if (ret != 0)
ret != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
409 DH_up_ref(key);
never executed: DH_up_ref(key);
0
410 return ret;
never executed: return ret;
0
411}-
412#endif-
413-
414int-
415EVP_PKEY_type(int type)-
416{-
417 int ret;-
418 const EVP_PKEY_ASN1_METHOD *ameth;-
419 ENGINE *e;-
420 ameth = EVP_PKEY_asn1_find(&e, type);-
421 if (ameth)
amethDescription
TRUEevaluated 73 times by 3 tests
Evaluated by:
  • libcrypto.so.44.0.1
  • ssltest
  • tlstest
FALSEnever evaluated
0-73
422 ret = ameth->pkey_id;
executed 73 times by 3 tests: ret = ameth->pkey_id;
Executed by:
  • libcrypto.so.44.0.1
  • ssltest
  • tlstest
73
423 else-
424 ret = NID_undef;
never executed: ret = 0;
0
425#ifndef OPENSSL_NO_ENGINE-
426 ENGINE_finish(e);-
427#endif-
428 return ret;
executed 73 times by 3 tests: return ret;
Executed by:
  • libcrypto.so.44.0.1
  • ssltest
  • tlstest
73
429}-
430-
431int-
432EVP_PKEY_id(const EVP_PKEY *pkey)-
433{-
434 return pkey->type;
never executed: return pkey->type;
0
435}-
436-
437int-
438EVP_PKEY_base_id(const EVP_PKEY *pkey)-
439{-
440 return EVP_PKEY_type(pkey->type);
executed 1 time by 1 test: return EVP_PKEY_type(pkey->type);
Executed by:
  • libcrypto.so.44.0.1
1
441}-
442-
443void-
444EVP_PKEY_free(EVP_PKEY *x)-
445{-
446 int i;-
447-
448 if (x == NULL)
x == ((void *)0)Description
TRUEevaluated 17151 times by 18 tests
Evaluated by:
  • asn1test
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • freenull
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • pkcs7test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • tls_prf
  • tlsexttest
  • tlstest
  • verifytest
FALSEevaluated 14062 times by 8 tests
Evaluated by:
  • dsatest
  • gost2814789t
  • libcrypto.so.44.0.1
  • pkcs7test
  • servertest
  • ssltest
  • tls_prf
  • tlstest
14062-17151
449 return;
executed 17151 times by 18 tests: return;
Executed by:
  • asn1test
  • cipher_list
  • cipherstest
  • clienttest
  • configtest
  • freenull
  • gost2814789t
  • keypairtest
  • libcrypto.so.44.0.1
  • pkcs7test
  • servertest
  • ssl_versions
  • ssltest
  • tls_ext_alpn
  • tls_prf
  • tlsexttest
  • tlstest
  • verifytest
17151
450-
451 i = CRYPTO_add(&x->references, -1, CRYPTO_LOCK_EVP_PKEY);-
452 if (i > 0)
i > 0Description
TRUEevaluated 11995 times by 7 tests
Evaluated by:
  • gost2814789t
  • libcrypto.so.44.0.1
  • pkcs7test
  • servertest
  • ssltest
  • tls_prf
  • tlstest
FALSEevaluated 2067 times by 7 tests
Evaluated by:
  • dsatest
  • gost2814789t
  • libcrypto.so.44.0.1
  • servertest
  • ssltest
  • tls_prf
  • tlstest
2067-11995
453 return;
executed 11995 times by 7 tests: return;
Executed by:
  • gost2814789t
  • libcrypto.so.44.0.1
  • pkcs7test
  • servertest
  • ssltest
  • tls_prf
  • tlstest
11995
454-
455 EVP_PKEY_free_it(x);-
456 if (x->attributes)
x->attributesDescription
TRUEnever evaluated
FALSEevaluated 2067 times by 7 tests
Evaluated by:
  • dsatest
  • gost2814789t
  • libcrypto.so.44.0.1
  • servertest
  • ssltest
  • tls_prf
  • tlstest
0-2067
457 sk_X509_ATTRIBUTE_pop_free(x->attributes, X509_ATTRIBUTE_free);
never executed: sk_pop_free(((_STACK*) (1 ? (x->attributes) : (struct stack_st_X509_ATTRIBUTE*)0)), ((void (*)(void *)) ((1 ? (X509_ATTRIBUTE_free) : (void (*)(X509_ATTRIBUTE *))0))));
0
458 free(x);-
459}
executed 2067 times by 7 tests: end of block
Executed by:
  • dsatest
  • gost2814789t
  • libcrypto.so.44.0.1
  • servertest
  • ssltest
  • tls_prf
  • tlstest
2067
460-
461static void-
462EVP_PKEY_free_it(EVP_PKEY *x)-
463{-
464 if (x->ameth && x->ameth->pkey_free) {
x->amethDescription
TRUEevaluated 2067 times by 7 tests
Evaluated by:
  • dsatest
  • gost2814789t
  • libcrypto.so.44.0.1
  • servertest
  • ssltest
  • tls_prf
  • tlstest
FALSEnever evaluated
x->ameth->pkey_freeDescription
TRUEevaluated 2067 times by 7 tests
Evaluated by:
  • dsatest
  • gost2814789t
  • libcrypto.so.44.0.1
  • servertest
  • ssltest
  • tls_prf
  • tlstest
FALSEnever evaluated
0-2067
465 x->ameth->pkey_free(x);-
466 x->pkey.ptr = NULL;-
467 }
executed 2067 times by 7 tests: end of block
Executed by:
  • dsatest
  • gost2814789t
  • libcrypto.so.44.0.1
  • servertest
  • ssltest
  • tls_prf
  • tlstest
2067
468#ifndef OPENSSL_NO_ENGINE-
469 ENGINE_finish(x->engine);-
470 x->engine = NULL;-
471#endif-
472}
executed 2067 times by 7 tests: end of block
Executed by:
  • dsatest
  • gost2814789t
  • libcrypto.so.44.0.1
  • servertest
  • ssltest
  • tls_prf
  • tlstest
2067
473-
474static int-
475unsup_alg(BIO *out, const EVP_PKEY *pkey, int indent, const char *kstr)-
476{-
477 BIO_indent(out, indent, 128);-
478 BIO_printf(out, "%s algorithm \"%s\" unsupported\n",-
479 kstr, OBJ_nid2ln(pkey->type));-
480 return 1;
never executed: return 1;
0
481}-
482-
483int-
484EVP_PKEY_print_public(BIO *out, const EVP_PKEY *pkey, int indent,-
485 ASN1_PCTX *pctx)-
486{-
487 if (pkey->ameth && pkey->ameth->pub_print)
pkey->amethDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
pkey->ameth->pub_printDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
0-3
488 return pkey->ameth->pub_print(out, pkey, indent, pctx);
executed 3 times by 1 test: return pkey->ameth->pub_print(out, pkey, indent, pctx);
Executed by:
  • libcrypto.so.44.0.1
3
489-
490 return unsup_alg(out, pkey, indent, "Public Key");
never executed: return unsup_alg(out, pkey, indent, "Public Key");
0
491}-
492-
493int-
494EVP_PKEY_print_private(BIO *out, const EVP_PKEY *pkey, int indent,-
495 ASN1_PCTX *pctx)-
496{-
497 if (pkey->ameth && pkey->ameth->priv_print)
pkey->amethDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • dsatest
FALSEnever evaluated
pkey->ameth->priv_printDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • dsatest
FALSEnever evaluated
0-1
498 return pkey->ameth->priv_print(out, pkey, indent, pctx);
executed 1 time by 1 test: return pkey->ameth->priv_print(out, pkey, indent, pctx);
Executed by:
  • dsatest
1
499-
500 return unsup_alg(out, pkey, indent, "Private Key");
never executed: return unsup_alg(out, pkey, indent, "Private Key");
0
501}-
502-
503int-
504EVP_PKEY_print_params(BIO *out, const EVP_PKEY *pkey, int indent,-
505 ASN1_PCTX *pctx)-
506{-
507 if (pkey->ameth && pkey->ameth->param_print)
pkey->amethDescription
TRUEnever evaluated
FALSEnever evaluated
pkey->ameth->param_printDescription
TRUEnever evaluated
FALSEnever evaluated
0
508 return pkey->ameth->param_print(out, pkey, indent, pctx);
never executed: return pkey->ameth->param_print(out, pkey, indent, pctx);
0
509 return unsup_alg(out, pkey, indent, "Parameters");
never executed: return unsup_alg(out, pkey, indent, "Parameters");
0
510}-
511-
512int-
513EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid)-
514{-
515 if (!pkey->ameth || !pkey->ameth->pkey_ctrl)
!pkey->amethDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • pkcs7test
!pkey->ameth->pkey_ctrlDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • pkcs7test
0-2
516 return -2;
never executed: return -2;
0
517 return pkey->ameth->pkey_ctrl(pkey, ASN1_PKEY_CTRL_DEFAULT_MD_NID,
executed 2 times by 1 test: return pkey->ameth->pkey_ctrl(pkey, 0x3, 0, pnid);
Executed by:
  • pkcs7test
2
518 0, pnid);
executed 2 times by 1 test: return pkey->ameth->pkey_ctrl(pkey, 0x3, 0, pnid);
Executed by:
  • pkcs7test
2
519}-
520-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2