OpenCoverage

digest.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/evp/digest.c
Source codeSwitch to Preprocessed file
LineSourceCount
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/objects.h>-
13#include <openssl/evp.h>-
14#include <openssl/engine.h>-
15#include "internal/evp_int.h"-
16#include "evp_locl.h"-
17-
18/* This call frees resources associated with the context */-
19int EVP_MD_CTX_reset(EVP_MD_CTX *ctx)-
20{-
21 if (ctx == NULL)
ctx == ((void *)0)Description
TRUEevaluated 783053 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2564792 times by 3 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
783053-2564792
22 return 1;
executed 783053 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
783053
23-
24 /*-
25 * Don't assume ctx->md_data was cleaned in EVP_Digest_Final, because-
26 * sometimes only copies of the context are ever finalised.-
27 */-
28 if (ctx->digest && ctx->digest->cleanup
ctx->digestDescription
TRUEevaluated 1218625 times by 3 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 1346167 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
ctx->digest->cleanupDescription
TRUEnever evaluated
FALSEevaluated 1218625 times by 3 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
0-1346167
29 && !EVP_MD_CTX_test_flags(ctx, EVP_MD_CTX_FLAG_CLEANED))
!EVP_MD_CTX_te...s(ctx, 0x0002)Description
TRUEnever evaluated
FALSEnever evaluated
0
30 ctx->digest->cleanup(ctx);
never executed: ctx->digest->cleanup(ctx);
0
31 if (ctx->digest && ctx->digest->ctx_size && ctx->md_data
ctx->digestDescription
TRUEevaluated 1218625 times by 3 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 1346167 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
ctx->digest->ctx_sizeDescription
TRUEevaluated 1218625 times by 3 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEnever evaluated
ctx->md_dataDescription
TRUEevaluated 1040427 times by 3 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 178198 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1346167
32 && !EVP_MD_CTX_test_flags(ctx, EVP_MD_CTX_FLAG_REUSE)) {
!EVP_MD_CTX_te...s(ctx, 0x0004)Description
TRUEevaluated 733840 times by 3 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 306587 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
306587-733840
33 OPENSSL_clear_free(ctx->md_data, ctx->digest->ctx_size);-
34 }
executed 733840 times by 3 tests: end of block
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
733840
35 /*-
36 * pctx should be freed by the user of EVP_MD_CTX-
37 * if EVP_MD_CTX_FLAG_KEEP_PKEY_CTX is set-
38 */-
39 if (!EVP_MD_CTX_test_flags(ctx, EVP_MD_CTX_FLAG_KEEP_PKEY_CTX))
!EVP_MD_CTX_te...s(ctx, 0x0400)Description
TRUEevaluated 2564789 times by 3 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
3-2564789
40 EVP_PKEY_CTX_free(ctx->pctx);
executed 2564789 times by 3 tests: EVP_PKEY_CTX_free(ctx->pctx);
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
2564789
41#ifndef OPENSSL_NO_ENGINE-
42 ENGINE_finish(ctx->engine);-
43#endif-
44 OPENSSL_cleanse(ctx, sizeof(*ctx));-
45-
46 return 1;
executed 2564792 times by 3 tests: return 1;
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
2564792
47}-
48-
49EVP_MD_CTX *EVP_MD_CTX_new(void)-
50{-
51 return OPENSSL_zalloc(sizeof(EVP_MD_CTX));
executed 882945 times by 3 tests: return CRYPTO_zalloc(sizeof(EVP_MD_CTX), __FILE__, 51);
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
882945
52}-
53-
54void EVP_MD_CTX_free(EVP_MD_CTX *ctx)-
55{-
56 EVP_MD_CTX_reset(ctx);-
57 OPENSSL_free(ctx);-
58}
executed 1018217 times by 3 tests: end of block
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
1018217
59-
60int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type)-
61{-
62 EVP_MD_CTX_reset(ctx);-
63 return EVP_DigestInit_ex(ctx, type, NULL);
executed 18 times by 2 tests: return EVP_DigestInit_ex(ctx, type, ((void *)0) );
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
18
64}-
65-
66int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl)-
67{-
68 EVP_MD_CTX_clear_flags(ctx, EVP_MD_CTX_FLAG_CLEANED);-
69#ifndef OPENSSL_NO_ENGINE-
70 /*-
71 * Whether it's nice or not, "Inits" can be used on "Final"'d contexts so-
72 * this context may already have an ENGINE! Try to avoid releasing the-
73 * previous handle, re-querying for an ENGINE, and having a-
74 * reinitialisation, when it may all be unnecessary.-
75 */-
76 if (ctx->engine && ctx->digest &&
ctx->engineDescription
TRUEevaluated 730 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 689700 times by 3 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
ctx->digestDescription
TRUEevaluated 730 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-689700
77 (type == NULL || (type->type == ctx->digest->type)))
type == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 730 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(type->type ==...>digest->type)Description
TRUEevaluated 730 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-730
78 goto skip_to_init;
executed 730 times by 1 test: goto skip_to_init;
Executed by:
  • libcrypto.so.1.1
730
79 if (type) {
typeDescription
TRUEevaluated 689700 times by 3 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEnever evaluated
0-689700
80 /*-
81 * Ensure an ENGINE left lying around from last time is cleared (the-
82 * previous check attempted to avoid this if the same ENGINE and-
83 * EVP_MD could be used).-
84 */-
85 ENGINE_finish(ctx->engine);-
86 if (impl != NULL) {
impl != ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 689700 times by 3 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
0-689700
87 if (!ENGINE_init(impl)) {
!ENGINE_init(impl)Description
TRUEnever evaluated
FALSEnever evaluated
0
88 EVPerr(EVP_F_EVP_DIGESTINIT_EX, EVP_R_INITIALIZATION_ERROR);-
89 return 0;
never executed: return 0;
0
90 }-
91 } else {
never executed: end of block
0
92 /* Ask if an ENGINE is reserved for this job */-
93 impl = ENGINE_get_digest_engine(type->type);-
94 }
executed 689700 times by 3 tests: end of block
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
689700
95 if (impl != NULL) {
impl != ((void *)0)Description
TRUEevaluated 10747 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 678953 times by 3 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
10747-678953
96 /* There's an ENGINE for this job ... (apparently) */-
97 const EVP_MD *d = ENGINE_get_digest(impl, type->type);-
98-
99 if (d == NULL) {
d == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 10747 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-10747
100 EVPerr(EVP_F_EVP_DIGESTINIT_EX, EVP_R_INITIALIZATION_ERROR);-
101 ENGINE_finish(impl);-
102 return 0;
never executed: return 0;
0
103 }-
104 /* We'll use the ENGINE's private digest definition */-
105 type = d;-
106 /*-
107 * Store the ENGINE functional reference so we know 'type' came-
108 * from an ENGINE and we need to release it when done.-
109 */-
110 ctx->engine = impl;-
111 } else
executed 10747 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
10747
112 ctx->engine = NULL;
executed 678953 times by 3 tests: ctx->engine = ((void *)0) ;
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
678953
113 } else {-
114 if (!ctx->digest) {
!ctx->digestDescription
TRUEnever evaluated
FALSEnever evaluated
0
115 EVPerr(EVP_F_EVP_DIGESTINIT_EX, EVP_R_NO_DIGEST_SET);-
116 return 0;
never executed: return 0;
0
117 }-
118 type = ctx->digest;-
119 }
never executed: end of block
0
120#endif-
121 if (ctx->digest != type) {
ctx->digest != typeDescription
TRUEevaluated 196733 times by 3 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 492967 times by 2 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
196733-492967
122 if (ctx->digest && ctx->digest->ctx_size) {
ctx->digestDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 196731 times by 3 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
ctx->digest->ctx_sizeDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-196731
123 OPENSSL_clear_free(ctx->md_data, ctx->digest->ctx_size);-
124 ctx->md_data = NULL;-
125 }
executed 2 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
2
126 ctx->digest = type;-
127 if (!(ctx->flags & EVP_MD_CTX_FLAG_NO_INIT) && type->ctx_size) {
!(ctx->flags & 0x0100)Description
TRUEevaluated 177835 times by 3 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEevaluated 18898 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
type->ctx_sizeDescription
TRUEevaluated 177835 times by 3 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
FALSEnever evaluated
0-177835
128 ctx->update = type->update;-
129 ctx->md_data = OPENSSL_zalloc(type->ctx_size);-
130 if (ctx->md_data == NULL) {
ctx->md_data == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 177835 times by 3 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
0-177835
131 EVPerr(EVP_F_EVP_DIGESTINIT_EX, ERR_R_MALLOC_FAILURE);-
132 return 0;
never executed: return 0;
0
133 }-
134 }
executed 177835 times by 3 tests: end of block
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
177835
135 }
executed 196733 times by 3 tests: end of block
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
196733
136#ifndef OPENSSL_NO_ENGINE-
137 skip_to_init:
code before this statement executed 689700 times by 3 tests: skip_to_init:
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
689700
138#endif-
139 if (ctx->pctx) {
ctx->pctxDescription
TRUEevaluated 24374 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 666056 times by 3 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
24374-666056
140 int r;-
141 r = EVP_PKEY_CTX_ctrl(ctx->pctx, -1, EVP_PKEY_OP_TYPE_SIG,-
142 EVP_PKEY_CTRL_DIGESTINIT, 0, ctx);-
143 if (r <= 0 && (r != -2))
r <= 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 24371 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(r != -2)Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-24371
144 return 0;
never executed: return 0;
0
145 }
executed 24374 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
24374
146 if (ctx->flags & EVP_MD_CTX_FLAG_NO_INIT)
ctx->flags & 0x0100Description
TRUEevaluated 19206 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 671224 times by 3 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
19206-671224
147 return 1;
executed 19206 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
19206
148 return ctx->digest->init(ctx);
executed 671224 times by 3 tests: return ctx->digest->init(ctx);
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
671224
149}-
150-
151int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *data, size_t count)-
152{-
153 return ctx->update(ctx, data, count);
executed 2536966 times by 3 tests: return ctx->update(ctx, data, count);
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
  • sm2_internal_test
2536966
154}-
155-
156/* The caller can assume that this removes any secret data from the context */-
157int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size)-
158{-
159 int ret;-
160 ret = EVP_DigestFinal_ex(ctx, md, size);-
161 EVP_MD_CTX_reset(ctx);-
162 return ret;
executed 374 times by 2 tests: return ret;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
374
163}-
164-
165/* The caller can assume that this removes any secret data from the context */-
166int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *size)-
167{-
168 int ret;-
169-
170 OPENSSL_assert(ctx->digest->md_size <= EVP_MAX_MD_SIZE);-
171 ret = ctx->digest->final(ctx, md);-
172 if (size != NULL)
size != ((void *)0)Description
TRUEevaluated 259342 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 642946 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
259342-642946
173 *size = ctx->digest->md_size;
executed 259342 times by 1 test: *size = ctx->digest->md_size;
Executed by:
  • libcrypto.so.1.1
259342
174 if (ctx->digest->cleanup) {
ctx->digest->cleanupDescription
TRUEnever evaluated
FALSEevaluated 902288 times by 2 tests
Evaluated by:
  • libcrypto.so.1.1
  • sm2_internal_test
0-902288
175 ctx->digest->cleanup(ctx);-
176 EVP_MD_CTX_set_flags(ctx, EVP_MD_CTX_FLAG_CLEANED);-
177 }
never executed: end of block
0
178 OPENSSL_cleanse(ctx->md_data, ctx->digest->ctx_size);-
179 return ret;
executed 902288 times by 2 tests: return ret;
Executed by:
  • libcrypto.so.1.1
  • sm2_internal_test
902288
180}-
181-
182int EVP_DigestFinalXOF(EVP_MD_CTX *ctx, unsigned char *md, size_t size)-
183{-
184 int ret = 0;-
185-
186 if (ctx->digest->flags & EVP_MD_FLAG_XOF
ctx->digest->flags & 0x0002Description
TRUEevaluated 136 times by 2 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
FALSEnever evaluated
0-136
187 && size <= INT_MAX
size <= 0x7fffffffDescription
TRUEevaluated 136 times by 2 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
FALSEnever evaluated
0-136
188 && ctx->digest->md_ctrl(ctx, EVP_MD_CTRL_XOF_LEN, (int)size, NULL)) {
ctx->digest->m... ((void *)0) )Description
TRUEevaluated 136 times by 2 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
FALSEnever evaluated
0-136
189 ret = ctx->digest->final(ctx, md);-
190-
191 if (ctx->digest->cleanup != NULL) {
ctx->digest->c...!= ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 136 times by 2 tests
Evaluated by:
  • curve448_internal_test
  • libcrypto.so.1.1
0-136
192 ctx->digest->cleanup(ctx);-
193 EVP_MD_CTX_set_flags(ctx, EVP_MD_CTX_FLAG_CLEANED);-
194 }
never executed: end of block
0
195 OPENSSL_cleanse(ctx->md_data, ctx->digest->ctx_size);-
196 } else {
executed 136 times by 2 tests: end of block
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
136
197 EVPerr(EVP_F_EVP_DIGESTFINALXOF, EVP_R_NOT_XOF_OR_INVALID_LENGTH);-
198 }
never executed: end of block
0
199-
200 return ret;
executed 136 times by 2 tests: return ret;
Executed by:
  • curve448_internal_test
  • libcrypto.so.1.1
136
201}-
202-
203int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in)-
204{-
205 EVP_MD_CTX_reset(out);-
206 return EVP_MD_CTX_copy_ex(out, in);
executed 11621 times by 1 test: return EVP_MD_CTX_copy_ex(out, in);
Executed by:
  • libcrypto.so.1.1
11621
207}-
208-
209int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in)-
210{-
211 unsigned char *tmp_buf;-
212 if ((in == NULL) || (in->digest == NULL)) {
(in == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 1021894 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
(in->digest == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 1021894 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1021894
213 EVPerr(EVP_F_EVP_MD_CTX_COPY_EX, EVP_R_INPUT_NOT_INITIALIZED);-
214 return 0;
never executed: return 0;
0
215 }-
216#ifndef OPENSSL_NO_ENGINE-
217 /* Make sure it's safe to copy a digest context using an ENGINE */-
218 if (in->engine && !ENGINE_init(in->engine)) {
in->engineDescription
TRUEevaluated 39211 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 982683 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
!ENGINE_init(in->engine)Description
TRUEnever evaluated
FALSEevaluated 39211 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-982683
219 EVPerr(EVP_F_EVP_MD_CTX_COPY_EX, ERR_R_ENGINE_LIB);-
220 return 0;
never executed: return 0;
0
221 }-
222#endif-
223-
224 if (out->digest == in->digest) {
out->digest == in->digestDescription
TRUEevaluated 353623 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 668271 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
353623-668271
225 tmp_buf = out->md_data;-
226 EVP_MD_CTX_set_flags(out, EVP_MD_CTX_FLAG_REUSE);-
227 } else
executed 353623 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
353623
228 tmp_buf = NULL;
executed 668271 times by 1 test: tmp_buf = ((void *)0) ;
Executed by:
  • libcrypto.so.1.1
668271
229 EVP_MD_CTX_reset(out);-
230 memcpy(out, in, sizeof(*out));-
231-
232 /* copied EVP_MD_CTX should free the copied EVP_PKEY_CTX */-
233 EVP_MD_CTX_clear_flags(out, EVP_MD_CTX_FLAG_KEEP_PKEY_CTX);-
234-
235 /* Null these variables, since they are getting fixed up-
236 * properly below. Anything else may cause a memleak and/or-
237 * double free if any of the memory allocations below fail-
238 */-
239 out->md_data = NULL;-
240 out->pctx = NULL;-
241-
242 if (in->md_data && out->digest->ctx_size) {
in->md_dataDescription
TRUEevaluated 862594 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 159300 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
out->digest->ctx_sizeDescription
TRUEevaluated 862594 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-862594
243 if (tmp_buf)
tmp_bufDescription
TRUEevaluated 306587 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 556007 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
306587-556007
244 out->md_data = tmp_buf;
executed 306587 times by 1 test: out->md_data = tmp_buf;
Executed by:
  • libcrypto.so.1.1
306587
245 else {-
246 out->md_data = OPENSSL_malloc(out->digest->ctx_size);-
247 if (out->md_data == NULL) {
out->md_data == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 556007 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-556007
248 EVPerr(EVP_F_EVP_MD_CTX_COPY_EX, ERR_R_MALLOC_FAILURE);-
249 return 0;
never executed: return 0;
0
250 }-
251 }
executed 556007 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
556007
252 memcpy(out->md_data, in->md_data, out->digest->ctx_size);-
253 }
executed 862594 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
862594
254-
255 out->update = in->update;-
256-
257 if (in->pctx) {
in->pctxDescription
TRUEevaluated 164769 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 857125 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
164769-857125
258 out->pctx = EVP_PKEY_CTX_dup(in->pctx);-
259 if (!out->pctx) {
!out->pctxDescription
TRUEnever evaluated
FALSEevaluated 164769 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-164769
260 EVP_MD_CTX_reset(out);-
261 return 0;
never executed: return 0;
0
262 }-
263 }
executed 164769 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
164769
264-
265 if (out->digest->copy)
out->digest->copyDescription
TRUEnever evaluated
FALSEevaluated 1021894 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-1021894
266 return out->digest->copy(out, in);
never executed: return out->digest->copy(out, in);
0
267-
268 return 1;
executed 1021894 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1021894
269}-
270-
271int EVP_Digest(const void *data, size_t count,-
272 unsigned char *md, unsigned int *size, const EVP_MD *type,-
273 ENGINE *impl)-
274{-
275 EVP_MD_CTX *ctx = EVP_MD_CTX_new();-
276 int ret;-
277-
278 if (ctx == NULL)
ctx == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 50360 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-50360
279 return 0;
never executed: return 0;
0
280 EVP_MD_CTX_set_flags(ctx, EVP_MD_CTX_FLAG_ONESHOT);-
281 ret = EVP_DigestInit_ex(ctx, type, impl)
EVP_DigestInit...x, type, impl)Description
TRUEevaluated 50360 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-50360
282 && EVP_DigestUpdate(ctx, data, count)
EVP_DigestUpda..., data, count)Description
TRUEevaluated 50360 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-50360
283 && EVP_DigestFinal_ex(ctx, md, size);
EVP_DigestFina...ctx, md, size)Description
TRUEevaluated 50360 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-50360
284 EVP_MD_CTX_free(ctx);-
285-
286 return ret;
executed 50360 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
50360
287}-
288-
289int EVP_MD_CTX_ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void *p2)-
290{-
291 if (ctx->digest && ctx->digest->md_ctrl) {
ctx->digestDescription
TRUEnever evaluated
FALSEnever evaluated
ctx->digest->md_ctrlDescription
TRUEnever evaluated
FALSEnever evaluated
0
292 int ret = ctx->digest->md_ctrl(ctx, cmd, p1, p2);-
293 if (ret <= 0)
ret <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
294 return 0;
never executed: return 0;
0
295 return 1;
never executed: return 1;
0
296 }-
297 return 0;
never executed: return 0;
0
298}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2