OpenCoverage

bio_md.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/evp/bio_md.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7static int md_write(BIO *h, char const *buf, int num);-
8static int md_read(BIO *h, char *buf, int size);-
9static int md_gets(BIO *h, char *str, int size);-
10static long md_ctrl(BIO *h, int cmd, long arg1, void *arg2);-
11static int md_new(BIO *h);-
12static int md_free(BIO *data);-
13static long md_callback_ctrl(BIO *h, int cmd, BIO_info_cb *fp);-
14-
15static const BIO_METHOD methods_md = {-
16 ( 8|0x0200),-
17 "message digest",-
18-
19 bwrite_conv,-
20 md_write,-
21-
22 bread_conv,-
23 md_read,-
24 -
25 ((void *)0)-
26 ,-
27 md_gets,-
28 md_ctrl,-
29 md_new,-
30 md_free,-
31 md_callback_ctrl,-
32};-
33-
34const BIO_METHOD *BIO_f_md(void)-
35{-
36 return
executed 88 times by 1 test: return &methods_md;
Executed by:
  • libcrypto.so.1.1
&methods_md;
executed 88 times by 1 test: return &methods_md;
Executed by:
  • libcrypto.so.1.1
88
37}-
38-
39static int md_new(BIO *bi)-
40{-
41 EVP_MD_CTX *ctx;-
42-
43 ctx = EVP_MD_CTX_new();-
44 if (ctx ==
ctx == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 88 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-88
45 ((void *)0)
ctx == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 88 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-88
46 )-
47 return
never executed: return 0;
0;
never executed: return 0;
0
48-
49 BIO_set_init(bi, 1);-
50 BIO_set_data(bi, ctx);-
51-
52 return
executed 88 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 88 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
88
53}-
54-
55static int md_free(BIO *a)-
56{-
57 if (a ==
a == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 88 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-88
58 ((void *)0)
a == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 88 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-88
59 )-
60 return
never executed: return 0;
0;
never executed: return 0;
0
61 EVP_MD_CTX_free(BIO_get_data(a));-
62 BIO_set_data(a, -
63 ((void *)0)-
64 );-
65 BIO_set_init(a, 0);-
66-
67 return
executed 88 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
1;
executed 88 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
88
68}-
69-
70static int md_read(BIO *b, char *out, int outl)-
71{-
72 int ret = 0;-
73 EVP_MD_CTX *ctx;-
74 BIO *next;-
75-
76 if (out ==
out == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 76 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-76
77 ((void *)0)
out == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 76 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-76
78 )-
79 return
never executed: return 0;
0;
never executed: return 0;
0
80-
81 ctx = BIO_get_data(b);-
82 next = BIO_next(b);-
83-
84 if ((
(ctx == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 76 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
ctx ==
(ctx == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 76 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-76
85 ((void *)0)
(ctx == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 76 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-76
86 )
(ctx == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 76 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
|| (
(next == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 76 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
next ==
(next == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 76 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-76
87 ((void *)0)
(next == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 76 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-76
88 )
(next == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 76 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-76
89 return
never executed: return 0;
0;
never executed: return 0;
0
90-
91 ret = BIO_read(next, out, outl);-
92 if (BIO_get_init(b)
BIO_get_init(b)Description
TRUEevaluated 76 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
) {
0-76
93 if (ret > 0
ret > 0Description
TRUEevaluated 38 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 38 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
38
94 if (EVP_DigestUpdate(ctx, (unsigned char *)out,
EVP_DigestUpda... int)ret) <= 0Description
TRUEnever evaluated
FALSEevaluated 38 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-38
95 (unsigned int)ret) <= 0
EVP_DigestUpda... int)ret) <= 0Description
TRUEnever evaluated
FALSEevaluated 38 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-38
96 return
never executed: return -1;
-1;
never executed: return -1;
0
97 }
executed 38 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
38
98 }
executed 76 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
76
99 BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08));-
100 BIO_copy_next_retry(b);-
101 return
executed 76 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
ret;
executed 76 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
76
102}-
103-
104static int md_write(BIO *b, const char *in, int inl)-
105{-
106 int ret = 0;-
107 EVP_MD_CTX *ctx;-
108 BIO *next;-
109-
110 if ((
(in == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 50 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
in ==
(in == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 50 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-50
111 ((void *)0)
(in == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 50 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-50
112 )
(in == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 50 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
|| (
(inl <= 0)Description
TRUEnever evaluated
FALSEevaluated 50 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
inl <= 0)
(inl <= 0)Description
TRUEnever evaluated
FALSEevaluated 50 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
)
0-50
113 return
never executed: return 0;
0;
never executed: return 0;
0
114-
115 ctx = BIO_get_data(b);-
116 next = BIO_next(b);-
117 if ((
(ctx != ((void *)0) )Description
TRUEevaluated 50 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
ctx !=
(ctx != ((void *)0) )Description
TRUEevaluated 50 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-50
118 ((void *)0)
(ctx != ((void *)0) )Description
TRUEevaluated 50 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-50
119 )
(ctx != ((void *)0) )Description
TRUEevaluated 50 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
&& (
(next != ((void *)0) )Description
TRUEevaluated 50 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
next !=
(next != ((void *)0) )Description
TRUEevaluated 50 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-50
120 ((void *)0)
(next != ((void *)0) )Description
TRUEevaluated 50 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-50
121 )
(next != ((void *)0) )Description
TRUEevaluated 50 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
)
0-50
122 ret = BIO_write(next, in, inl);
executed 50 times by 1 test: ret = BIO_write(next, in, inl);
Executed by:
  • libcrypto.so.1.1
50
123-
124 if (BIO_get_init(b)
BIO_get_init(b)Description
TRUEevaluated 50 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
) {
0-50
125 if (ret > 0
ret > 0Description
TRUEevaluated 50 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
) {
0-50
126 if (!EVP_DigestUpdate(ctx, (const unsigned char *)in,
!EVP_DigestUpd...igned int)ret)Description
TRUEnever evaluated
FALSEevaluated 50 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-50
127 (unsigned int)ret)
!EVP_DigestUpd...igned int)ret)Description
TRUEnever evaluated
FALSEevaluated 50 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
) {
0-50
128 BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08));-
129 return
never executed: return 0;
0;
never executed: return 0;
0
130 }-
131 }
executed 50 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
50
132 }
executed 50 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
50
133 if (next !=
next != ((void *)0)Description
TRUEevaluated 50 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-50
134 ((void *)0)
next != ((void *)0)Description
TRUEevaluated 50 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
0-50
135 ) {-
136 BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08));-
137 BIO_copy_next_retry(b);-
138 }
executed 50 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
50
139 return
executed 50 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
ret;
executed 50 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
50
140}-
141-
142static long md_ctrl(BIO *b, int cmd, long num, void *ptr)-
143{-
144 EVP_MD_CTX *ctx, *dctx, **pctx;-
145 const EVP_MD **ppmd;-
146 EVP_MD *md;-
147 long ret = 1;-
148 BIO *dbio, *next;-
149-
150-
151 ctx = BIO_get_data(b);-
152 next = BIO_next(b);-
153-
154 switch (cmd) {-
155 case
executed 5 times by 1 test: case 1:
Executed by:
  • libcrypto.so.1.1
1:
executed 5 times by 1 test: case 1:
Executed by:
  • libcrypto.so.1.1
5
156 if (BIO_get_init(b)
BIO_get_init(b)Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
)
0-5
157 ret = EVP_DigestInit_ex(ctx, ctx->digest,
executed 5 times by 1 test: ret = EVP_DigestInit_ex(ctx, ctx->digest, ((void *)0) );
Executed by:
  • libcrypto.so.1.1
5
158 ((void *)0)
executed 5 times by 1 test: ret = EVP_DigestInit_ex(ctx, ctx->digest, ((void *)0) );
Executed by:
  • libcrypto.so.1.1
5
159 );
executed 5 times by 1 test: ret = EVP_DigestInit_ex(ctx, ctx->digest, ((void *)0) );
Executed by:
  • libcrypto.so.1.1
5
160 else-
161 ret = 0;
never executed: ret = 0;
0
162 if (ret > 0
ret > 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
)
0-5
163 ret = BIO_ctrl(next, cmd, num, ptr);
executed 5 times by 1 test: ret = BIO_ctrl(next, cmd, num, ptr);
Executed by:
  • libcrypto.so.1.1
5
164 break;
executed 5 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
5
165 case
never executed: case 112:
112:
never executed: case 112:
0
166 if (BIO_get_init(b)
BIO_get_init(b)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
167 ppmd = ptr;-
168 *ppmd = ctx->digest;-
169 }
never executed: end of block
else
0
170 ret = 0;
never executed: ret = 0;
0
171 break;
never executed: break;
0
172 case
executed 180 times by 1 test: case 120:
Executed by:
  • libcrypto.so.1.1
120:
executed 180 times by 1 test: case 120:
Executed by:
  • libcrypto.so.1.1
180
173 pctx = ptr;-
174 *pctx = ctx;-
175 BIO_set_init(b, 1);-
176 break;
executed 180 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
180
177 case
never executed: case 148:
148:
never executed: case 148:
0
178 if (BIO_get_init(b)
BIO_get_init(b)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
179 BIO_set_data(b, ptr);
never executed: BIO_set_data(b, ptr);
0
180 else-
181 ret = 0;
never executed: ret = 0;
0
182 break;
never executed: break;
0
183 case
never executed: case 101:
101:
never executed: case 101:
0
184 BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08));-
185 ret = BIO_ctrl(next, cmd, num, ptr);-
186 BIO_copy_next_retry(b);-
187 break;
never executed: break;
0
188-
189 case
executed 83 times by 1 test: case 111:
Executed by:
  • libcrypto.so.1.1
111:
executed 83 times by 1 test: case 111:
Executed by:
  • libcrypto.so.1.1
83
190 md = ptr;-
191 ret = EVP_DigestInit_ex(ctx, md, -
192 ((void *)0)-
193 );-
194 if (ret > 0
ret > 0Description
TRUEevaluated 83 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEnever evaluated
)
0-83
195 BIO_set_init(b, 1);
executed 83 times by 1 test: BIO_set_init(b, 1);
Executed by:
  • libcrypto.so.1.1
83
196 break;
executed 83 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
83
197 case
never executed: case 12:
12:
never executed: case 12:
0
198 dbio = ptr;-
199 dctx = BIO_get_data(dbio);-
200 if (!EVP_MD_CTX_copy_ex(dctx, ctx)
!EVP_MD_CTX_copy_ex(dctx, ctx)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
201 return
never executed: return 0;
0;
never executed: return 0;
0
202 BIO_set_init(b, 1);-
203 break;
never executed: break;
0
204 default
executed 308 times by 1 test: default:
Executed by:
  • libcrypto.so.1.1
:
executed 308 times by 1 test: default:
Executed by:
  • libcrypto.so.1.1
308
205 ret = BIO_ctrl(next, cmd, num, ptr);-
206 break;
executed 308 times by 1 test: break;
Executed by:
  • libcrypto.so.1.1
308
207 }-
208 return
executed 576 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
ret;
executed 576 times by 1 test: return ret;
Executed by:
  • libcrypto.so.1.1
576
209}-
210-
211static long md_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp)-
212{-
213 long ret = 1;-
214 BIO *next;-
215-
216 next = BIO_next(b);-
217-
218 if (next ==
next == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
219 ((void *)0)
next == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
220 )-
221 return
never executed: return 0;
0;
never executed: return 0;
0
222-
223 switch (cmd) {-
224 default
never executed: default:
:
never executed: default:
0
225 ret = BIO_callback_ctrl(next, cmd, fp);-
226 break;
never executed: break;
0
227 }-
228 return
never executed: return ret;
ret;
never executed: return ret;
0
229}-
230-
231static int md_gets(BIO *bp, char *buf, int size)-
232{-
233 EVP_MD_CTX *ctx;-
234 unsigned int ret;-
235-
236 ctx = BIO_get_data(bp);-
237-
238 if (size < ctx->digest->md_size
size < ctx->digest->md_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
239 return
never executed: return 0;
0;
never executed: return 0;
0
240-
241 if (EVP_DigestFinal_ex(ctx, (unsigned char *)buf, &ret) <= 0
EVP_DigestFina...uf, &ret) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
242 return
never executed: return -1;
-1;
never executed: return -1;
0
243-
244 return
never executed: return (int)ret;
(int)ret;
never executed: return (int)ret;
0
245}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2