OpenCoverage

pmeth_fn.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/evp/pmeth_fn.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright 2006-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 <stdlib.h>-
12#include "internal/cryptlib.h"-
13#include <openssl/objects.h>-
14#include <openssl/evp.h>-
15#include "internal/evp_int.h"-
16-
17#define M_check_autoarg(ctx, arg, arglen, err) \-
18 if (ctx->pmeth->flags & EVP_PKEY_FLAG_AUTOARGLEN) { \-
19 size_t pksize = (size_t)EVP_PKEY_size(ctx->pkey); \-
20 \-
21 if (pksize == 0) { \-
22 EVPerr(err, EVP_R_INVALID_KEY); /*ckerr_ignore*/ \-
23 return 0; \-
24 } \-
25 if (!arg) { \-
26 *arglen = pksize; \-
27 return 1; \-
28 } \-
29 if (*arglen < pksize) { \-
30 EVPerr(err, EVP_R_BUFFER_TOO_SMALL); /*ckerr_ignore*/ \-
31 return 0; \-
32 } \-
33 }-
34-
35int EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx)-
36{-
37 int ret;-
38 if (!ctx || !ctx->pmeth || !ctx->pmeth->sign) {
!ctxDescription
TRUEnever evaluated
FALSEevaluated 2018 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!ctx->pmethDescription
TRUEnever evaluated
FALSEevaluated 2018 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!ctx->pmeth->signDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2016 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2018
39 EVPerr(EVP_F_EVP_PKEY_SIGN_INIT,-
40 EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);-
41 return -2;
executed 2 times by 1 test: return -2;
Executed by:
  • libcrypto.so.1.1
2
42 }-
43 ctx->operation = EVP_PKEY_OP_SIGN;-
44 if (!ctx->pmeth->sign_init)
!ctx->pmeth->sign_initDescription
TRUEevaluated 2013 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
3-2013
45 return 1;
executed 2013 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
2013
46 ret = ctx->pmeth->sign_init(ctx);-
47 if (ret <= 0)
ret <= 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3
48 ctx->operation = EVP_PKEY_OP_UNDEFINED;
never executed: ctx->operation = 0;
0
49 return ret;
executed 3 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
3
50}-
51-
52int EVP_PKEY_sign(EVP_PKEY_CTX *ctx,-
53 unsigned char *sig, size_t *siglen,-
54 const unsigned char *tbs, size_t tbslen)-
55{-
56 if (!ctx || !ctx->pmeth || !ctx->pmeth->sign) {
!ctxDescription
TRUEnever evaluated
FALSEevaluated 2105 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!ctx->pmethDescription
TRUEnever evaluated
FALSEevaluated 2105 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!ctx->pmeth->signDescription
TRUEnever evaluated
FALSEevaluated 2105 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2105
57 EVPerr(EVP_F_EVP_PKEY_SIGN,-
58 EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);-
59 return -2;
never executed: return -2;
0
60 }-
61 if (ctx->operation != EVP_PKEY_OP_SIGN) {
ctx->operation != (1<<3)Description
TRUEnever evaluated
FALSEevaluated 2105 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2105
62 EVPerr(EVP_F_EVP_PKEY_SIGN, EVP_R_OPERATON_NOT_INITIALIZED);-
63 return -1;
never executed: return -1;
0
64 }-
65 M_check_autoarg(ctx, sig, siglen, EVP_F_EVP_PKEY_SIGN)
never executed: return 0;
executed 88 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
never executed: return 0;
executed 1718 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
ctx->pmeth->flags & 2Description
TRUEevaluated 1806 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 299 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
pksize == 0Description
TRUEnever evaluated
FALSEevaluated 1806 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!sigDescription
TRUEevaluated 88 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 1718 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
*siglen < pksizeDescription
TRUEnever evaluated
FALSEevaluated 1718 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1806
66 return ctx->pmeth->sign(ctx, sig, siglen, tbs, tbslen);
executed 2017 times by 1 test: return ctx->pmeth->sign(ctx, sig, siglen, tbs, tbslen);
Executed by:
  • libcrypto.so.1.1
2017
67}-
68-
69int EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx)-
70{-
71 int ret;-
72 if (!ctx || !ctx->pmeth || !ctx->pmeth->verify) {
!ctxDescription
TRUEnever evaluated
FALSEevaluated 3331 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!ctx->pmethDescription
TRUEnever evaluated
FALSEevaluated 3331 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!ctx->pmeth->verifyDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3329 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3331
73 EVPerr(EVP_F_EVP_PKEY_VERIFY_INIT,-
74 EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);-
75 return -2;
executed 2 times by 1 test: return -2;
Executed by:
  • libcrypto.so.1.1
2
76 }-
77 ctx->operation = EVP_PKEY_OP_VERIFY;-
78 if (!ctx->pmeth->verify_init)
!ctx->pmeth->verify_initDescription
TRUEevaluated 3313 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 16 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
16-3313
79 return 1;
executed 3313 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
3313
80 ret = ctx->pmeth->verify_init(ctx);-
81 if (ret <= 0)
ret <= 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 14 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2-14
82 ctx->operation = EVP_PKEY_OP_UNDEFINED;
executed 2 times by 1 test: ctx->operation = 0;
Executed by:
  • libcrypto.so.1.1
2
83 return ret;
executed 16 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
16
84}-
85-
86int EVP_PKEY_verify(EVP_PKEY_CTX *ctx,-
87 const unsigned char *sig, size_t siglen,-
88 const unsigned char *tbs, size_t tbslen)-
89{-
90 if (!ctx || !ctx->pmeth || !ctx->pmeth->verify) {
!ctxDescription
TRUEnever evaluated
FALSEevaluated 3327 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!ctx->pmethDescription
TRUEnever evaluated
FALSEevaluated 3327 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!ctx->pmeth->verifyDescription
TRUEnever evaluated
FALSEevaluated 3327 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3327
91 EVPerr(EVP_F_EVP_PKEY_VERIFY,-
92 EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);-
93 return -2;
never executed: return -2;
0
94 }-
95 if (ctx->operation != EVP_PKEY_OP_VERIFY) {
ctx->operation != (1<<4)Description
TRUEnever evaluated
FALSEevaluated 3327 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-3327
96 EVPerr(EVP_F_EVP_PKEY_VERIFY, EVP_R_OPERATON_NOT_INITIALIZED);-
97 return -1;
never executed: return -1;
0
98 }-
99 return ctx->pmeth->verify(ctx, sig, siglen, tbs, tbslen);
executed 3327 times by 1 test: return ctx->pmeth->verify(ctx, sig, siglen, tbs, tbslen);
Executed by:
  • libcrypto.so.1.1
3327
100}-
101-
102int EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx)-
103{-
104 int ret;-
105 if (!ctx || !ctx->pmeth || !ctx->pmeth->verify_recover) {
!ctxDescription
TRUEnever evaluated
FALSEevaluated 11 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!ctx->pmethDescription
TRUEnever evaluated
FALSEevaluated 11 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!ctx->pmeth->verify_recoverDescription
TRUEnever evaluated
FALSEevaluated 11 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-11
106 EVPerr(EVP_F_EVP_PKEY_VERIFY_RECOVER_INIT,-
107 EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);-
108 return -2;
never executed: return -2;
0
109 }-
110 ctx->operation = EVP_PKEY_OP_VERIFYRECOVER;-
111 if (!ctx->pmeth->verify_recover_init)
!ctx->pmeth->v...y_recover_initDescription
TRUEevaluated 11 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-11
112 return 1;
executed 11 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
11
113 ret = ctx->pmeth->verify_recover_init(ctx);-
114 if (ret <= 0)
ret <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
115 ctx->operation = EVP_PKEY_OP_UNDEFINED;
never executed: ctx->operation = 0;
0
116 return ret;
never executed: return ret;
0
117}-
118-
119int EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx,-
120 unsigned char *rout, size_t *routlen,-
121 const unsigned char *sig, size_t siglen)-
122{-
123 if (!ctx || !ctx->pmeth || !ctx->pmeth->verify_recover) {
!ctxDescription
TRUEnever evaluated
FALSEevaluated 22 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!ctx->pmethDescription
TRUEnever evaluated
FALSEevaluated 22 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!ctx->pmeth->verify_recoverDescription
TRUEnever evaluated
FALSEevaluated 22 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-22
124 EVPerr(EVP_F_EVP_PKEY_VERIFY_RECOVER,-
125 EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);-
126 return -2;
never executed: return -2;
0
127 }-
128 if (ctx->operation != EVP_PKEY_OP_VERIFYRECOVER) {
ctx->operation != (1<<5)Description
TRUEnever evaluated
FALSEevaluated 22 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-22
129 EVPerr(EVP_F_EVP_PKEY_VERIFY_RECOVER, EVP_R_OPERATON_NOT_INITIALIZED);-
130 return -1;
never executed: return -1;
0
131 }-
132 M_check_autoarg(ctx, rout, routlen, EVP_F_EVP_PKEY_VERIFY_RECOVER)
never executed: return 0;
executed 11 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
never executed: return 0;
executed 11 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
ctx->pmeth->flags & 2Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
pksize == 0Description
TRUEnever evaluated
FALSEevaluated 22 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!routDescription
TRUEevaluated 11 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 11 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
*routlen < pksizeDescription
TRUEnever evaluated
FALSEevaluated 11 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-22
133 return ctx->pmeth->verify_recover(ctx, rout, routlen, sig, siglen);
executed 11 times by 1 test: return ctx->pmeth->verify_recover(ctx, rout, routlen, sig, siglen);
Executed by:
  • libcrypto.so.1.1
11
134}-
135-
136int EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx)-
137{-
138 int ret;-
139 if (!ctx || !ctx->pmeth || !ctx->pmeth->encrypt) {
!ctxDescription
TRUEnever evaluated
FALSEevaluated 493 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!ctx->pmethDescription
TRUEnever evaluated
FALSEevaluated 493 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!ctx->pmeth->encryptDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 492 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-493
140 EVPerr(EVP_F_EVP_PKEY_ENCRYPT_INIT,-
141 EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);-
142 return -2;
executed 1 time by 1 test: return -2;
Executed by:
  • libcrypto.so.1.1
1
143 }-
144 ctx->operation = EVP_PKEY_OP_ENCRYPT;-
145 if (!ctx->pmeth->encrypt_init)
!ctx->pmeth->encrypt_initDescription
TRUEevaluated 492 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-492
146 return 1;
executed 492 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
492
147 ret = ctx->pmeth->encrypt_init(ctx);-
148 if (ret <= 0)
ret <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
149 ctx->operation = EVP_PKEY_OP_UNDEFINED;
never executed: ctx->operation = 0;
0
150 return ret;
never executed: return ret;
0
151}-
152-
153int EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx,-
154 unsigned char *out, size_t *outlen,-
155 const unsigned char *in, size_t inlen)-
156{-
157 if (!ctx || !ctx->pmeth || !ctx->pmeth->encrypt) {
!ctxDescription
TRUEnever evaluated
FALSEevaluated 978 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!ctx->pmethDescription
TRUEnever evaluated
FALSEevaluated 978 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!ctx->pmeth->encryptDescription
TRUEnever evaluated
FALSEevaluated 978 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-978
158 EVPerr(EVP_F_EVP_PKEY_ENCRYPT,-
159 EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);-
160 return -2;
never executed: return -2;
0
161 }-
162 if (ctx->operation != EVP_PKEY_OP_ENCRYPT) {
ctx->operation != (1<<8)Description
TRUEnever evaluated
FALSEevaluated 978 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-978
163 EVPerr(EVP_F_EVP_PKEY_ENCRYPT, EVP_R_OPERATON_NOT_INITIALIZED);-
164 return -1;
never executed: return -1;
0
165 }-
166 M_check_autoarg(ctx, out, outlen, EVP_F_EVP_PKEY_ENCRYPT)
executed 1 time by 1 test: return 0;
Executed by:
  • libcrypto.so.1.1
executed 486 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
never executed: return 0;
executed 488 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
ctx->pmeth->flags & 2Description
TRUEevaluated 975 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
pksize == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 974 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!outDescription
TRUEevaluated 486 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 488 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
*outlen < pksizeDescription
TRUEnever evaluated
FALSEevaluated 488 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-975
167 return ctx->pmeth->encrypt(ctx, out, outlen, in, inlen);
executed 491 times by 1 test: return ctx->pmeth->encrypt(ctx, out, outlen, in, inlen);
Executed by:
  • libcrypto.so.1.1
491
168}-
169-
170int EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx)-
171{-
172 int ret;-
173 if (!ctx || !ctx->pmeth || !ctx->pmeth->decrypt) {
!ctxDescription
TRUEnever evaluated
FALSEevaluated 92 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!ctx->pmethDescription
TRUEnever evaluated
FALSEevaluated 92 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!ctx->pmeth->decryptDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 91 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-92
174 EVPerr(EVP_F_EVP_PKEY_DECRYPT_INIT,-
175 EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);-
176 return -2;
executed 1 time by 1 test: return -2;
Executed by:
  • libcrypto.so.1.1
1
177 }-
178 ctx->operation = EVP_PKEY_OP_DECRYPT;-
179 if (!ctx->pmeth->decrypt_init)
!ctx->pmeth->decrypt_initDescription
TRUEevaluated 91 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-91
180 return 1;
executed 91 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
91
181 ret = ctx->pmeth->decrypt_init(ctx);-
182 if (ret <= 0)
ret <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
183 ctx->operation = EVP_PKEY_OP_UNDEFINED;
never executed: ctx->operation = 0;
0
184 return ret;
never executed: return ret;
0
185}-
186-
187int EVP_PKEY_decrypt(EVP_PKEY_CTX *ctx,-
188 unsigned char *out, size_t *outlen,-
189 const unsigned char *in, size_t inlen)-
190{-
191 if (!ctx || !ctx->pmeth || !ctx->pmeth->decrypt) {
!ctxDescription
TRUEnever evaluated
FALSEevaluated 181 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!ctx->pmethDescription
TRUEnever evaluated
FALSEevaluated 181 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!ctx->pmeth->decryptDescription
TRUEnever evaluated
FALSEevaluated 181 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-181
192 EVPerr(EVP_F_EVP_PKEY_DECRYPT,-
193 EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);-
194 return -2;
never executed: return -2;
0
195 }-
196 if (ctx->operation != EVP_PKEY_OP_DECRYPT) {
ctx->operation != (1<<9)Description
TRUEnever evaluated
FALSEevaluated 181 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-181
197 EVPerr(EVP_F_EVP_PKEY_DECRYPT, EVP_R_OPERATON_NOT_INITIALIZED);-
198 return -1;
never executed: return -1;
0
199 }-
200 M_check_autoarg(ctx, out, outlen, EVP_F_EVP_PKEY_DECRYPT)
never executed: return 0;
executed 89 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
never executed: return 0;
executed 89 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
ctx->pmeth->flags & 2Description
TRUEevaluated 178 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
pksize == 0Description
TRUEnever evaluated
FALSEevaluated 178 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!outDescription
TRUEevaluated 89 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 89 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
*outlen < pksizeDescription
TRUEnever evaluated
FALSEevaluated 89 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-178
201 return ctx->pmeth->decrypt(ctx, out, outlen, in, inlen);
executed 92 times by 1 test: return ctx->pmeth->decrypt(ctx, out, outlen, in, inlen);
Executed by:
  • libcrypto.so.1.1
92
202}-
203-
204int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx)-
205{-
206 int ret;-
207 if (!ctx || !ctx->pmeth || !ctx->pmeth->derive) {
!ctxDescription
TRUEnever evaluated
FALSEevaluated 46538 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!ctx->pmethDescription
TRUEnever evaluated
FALSEevaluated 46538 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!ctx->pmeth->deriveDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 46537 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-46538
208 EVPerr(EVP_F_EVP_PKEY_DERIVE_INIT,-
209 EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);-
210 return -2;
executed 1 time by 1 test: return -2;
Executed by:
  • libcrypto.so.1.1
1
211 }-
212 ctx->operation = EVP_PKEY_OP_DERIVE;-
213 if (!ctx->pmeth->derive_init)
!ctx->pmeth->derive_initDescription
TRUEevaluated 46537 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-46537
214 return 1;
executed 46537 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
46537
215 ret = ctx->pmeth->derive_init(ctx);-
216 if (ret <= 0)
ret <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
217 ctx->operation = EVP_PKEY_OP_UNDEFINED;
never executed: ctx->operation = 0;
0
218 return ret;
never executed: return ret;
0
219}-
220-
221int EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer)-
222{-
223 int ret;-
224 if (!ctx || !ctx->pmeth
!ctxDescription
TRUEnever evaluated
FALSEevaluated 4367 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!ctx->pmethDescription
TRUEnever evaluated
FALSEevaluated 4367 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4367
225 || !(ctx->pmeth->derive || ctx->pmeth->encrypt || ctx->pmeth->decrypt)
ctx->pmeth->deriveDescription
TRUEevaluated 4367 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
ctx->pmeth->encryptDescription
TRUEnever evaluated
FALSEnever evaluated
ctx->pmeth->decryptDescription
TRUEnever evaluated
FALSEnever evaluated
0-4367
226 || !ctx->pmeth->ctrl) {
!ctx->pmeth->ctrlDescription
TRUEnever evaluated
FALSEevaluated 4367 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4367
227 EVPerr(EVP_F_EVP_PKEY_DERIVE_SET_PEER,-
228 EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);-
229 return -2;
never executed: return -2;
0
230 }-
231 if (ctx->operation != EVP_PKEY_OP_DERIVE
ctx->operation != (1<<10)Description
TRUEnever evaluated
FALSEevaluated 4367 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4367
232 && ctx->operation != EVP_PKEY_OP_ENCRYPT
ctx->operation != (1<<8)Description
TRUEnever evaluated
FALSEnever evaluated
0
233 && ctx->operation != EVP_PKEY_OP_DECRYPT) {
ctx->operation != (1<<9)Description
TRUEnever evaluated
FALSEnever evaluated
0
234 EVPerr(EVP_F_EVP_PKEY_DERIVE_SET_PEER,-
235 EVP_R_OPERATON_NOT_INITIALIZED);-
236 return -1;
never executed: return -1;
0
237 }-
238-
239 ret = ctx->pmeth->ctrl(ctx, EVP_PKEY_CTRL_PEER_KEY, 0, peer);-
240-
241 if (ret <= 0)
ret <= 0Description
TRUEnever evaluated
FALSEevaluated 4367 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4367
242 return ret;
never executed: return ret;
0
243-
244 if (ret == 2)
ret == 2Description
TRUEnever evaluated
FALSEevaluated 4367 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4367
245 return 1;
never executed: return 1;
0
246-
247 if (!ctx->pkey) {
!ctx->pkeyDescription
TRUEnever evaluated
FALSEevaluated 4367 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4367
248 EVPerr(EVP_F_EVP_PKEY_DERIVE_SET_PEER, EVP_R_NO_KEY_SET);-
249 return -1;
never executed: return -1;
0
250 }-
251-
252 if (ctx->pkey->type != peer->type) {
ctx->pkey->type != peer->typeDescription
TRUEnever evaluated
FALSEevaluated 4367 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4367
253 EVPerr(EVP_F_EVP_PKEY_DERIVE_SET_PEER, EVP_R_DIFFERENT_KEY_TYPES);-
254 return -1;
never executed: return -1;
0
255 }-
256-
257 /*-
258 * For clarity. The error is if parameters in peer are-
259 * present (!missing) but don't match. EVP_PKEY_cmp_parameters may return-
260 * 1 (match), 0 (don't match) and -2 (comparison is not defined). -1-
261 * (different key types) is impossible here because it is checked earlier.-
262 * -2 is OK for us here, as well as 1, so we can check for 0 only.-
263 */-
264 if (!EVP_PKEY_missing_parameters(peer) &&
!EVP_PKEY_miss...rameters(peer)Description
TRUEevaluated 4367 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-4367
265 !EVP_PKEY_cmp_parameters(ctx->pkey, peer)) {
!EVP_PKEY_cmp_...x->pkey, peer)Description
TRUEnever evaluated
FALSEevaluated 4367 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4367
266 EVPerr(EVP_F_EVP_PKEY_DERIVE_SET_PEER, EVP_R_DIFFERENT_PARAMETERS);-
267 return -1;
never executed: return -1;
0
268 }-
269-
270 EVP_PKEY_free(ctx->peerkey);-
271 ctx->peerkey = peer;-
272-
273 ret = ctx->pmeth->ctrl(ctx, EVP_PKEY_CTRL_PEER_KEY, 1, peer);-
274-
275 if (ret <= 0) {
ret <= 0Description
TRUEnever evaluated
FALSEevaluated 4367 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-4367
276 ctx->peerkey = NULL;-
277 return ret;
never executed: return ret;
0
278 }-
279-
280 EVP_PKEY_up_ref(peer);-
281 return 1;
executed 4367 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
4367
282}-
283-
284int EVP_PKEY_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *pkeylen)-
285{-
286 if (!ctx || !ctx->pmeth || !ctx->pmeth->derive) {
!ctxDescription
TRUEnever evaluated
FALSEevaluated 50891 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!ctx->pmethDescription
TRUEnever evaluated
FALSEevaluated 50891 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!ctx->pmeth->deriveDescription
TRUEnever evaluated
FALSEevaluated 50891 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-50891
287 EVPerr(EVP_F_EVP_PKEY_DERIVE,-
288 EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);-
289 return -2;
never executed: return -2;
0
290 }-
291 if (ctx->operation != EVP_PKEY_OP_DERIVE) {
ctx->operation != (1<<10)Description
TRUEnever evaluated
FALSEevaluated 50891 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-50891
292 EVPerr(EVP_F_EVP_PKEY_DERIVE, EVP_R_OPERATON_NOT_INITIALIZED);-
293 return -1;
never executed: return -1;
0
294 }-
295 M_check_autoarg(ctx, key, pkeylen, EVP_F_EVP_PKEY_DERIVE)
never executed: return 0;
never executed: return 1;
never executed: return 0;
never executed: end of block
ctx->pmeth->flags & 2Description
TRUEnever evaluated
FALSEevaluated 50891 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
pksize == 0Description
TRUEnever evaluated
FALSEnever evaluated
!keyDescription
TRUEnever evaluated
FALSEnever evaluated
*pkeylen < pksizeDescription
TRUEnever evaluated
FALSEnever evaluated
0-50891
296 return ctx->pmeth->derive(ctx, key, pkeylen);
executed 50891 times by 1 test: return ctx->pmeth->derive(ctx, key, pkeylen);
Executed by:
  • libcrypto.so.1.1
50891
297}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2