OpenCoverage

t_x509.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/asn1/t_x509.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/* $OpenBSD: t_x509.c,v 1.31 2018/05/18 18:23:24 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/buffer.h>-
65#include <openssl/err.h>-
66#include <openssl/objects.h>-
67#include <openssl/x509.h>-
68#include <openssl/x509v3.h>-
69-
70#ifndef OPENSSL_NO_DSA-
71#include <openssl/dsa.h>-
72#endif-
73#ifndef OPENSSL_NO_EC-
74#include <openssl/ec.h>-
75#endif-
76#ifndef OPENSSL_NO_RSA-
77#include <openssl/rsa.h>-
78#endif-
79-
80#include "asn1_locl.h"-
81-
82int-
83X509_print_fp(FILE *fp, X509 *x)-
84{-
85 return X509_print_ex_fp(fp, x, XN_FLAG_COMPAT, X509_FLAG_COMPAT);
never executed: return X509_print_ex_fp(fp, x, 0, 0);
0
86}-
87-
88int-
89X509_print_ex_fp(FILE *fp, X509 *x, unsigned long nmflag, unsigned long cflag)-
90{-
91 BIO *b;-
92 int ret;-
93-
94 if ((b = BIO_new(BIO_s_file())) == NULL) {
(b = BIO_new(B...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
95 X509error(ERR_R_BUF_LIB);-
96 return (0);
never executed: return (0);
0
97 }-
98 BIO_set_fp(b, fp, BIO_NOCLOSE);-
99 ret = X509_print_ex(b, x, nmflag, cflag);-
100 BIO_free(b);-
101 return (ret);
never executed: return (ret);
0
102}-
103-
104int-
105X509_print(BIO *bp, X509 *x)-
106{-
107 return X509_print_ex(bp, x, XN_FLAG_COMPAT, X509_FLAG_COMPAT);
never executed: return X509_print_ex(bp, x, 0, 0);
0
108}-
109-
110int-
111X509_print_ex(BIO *bp, X509 *x, unsigned long nmflags, unsigned long cflag)-
112{-
113 long l;-
114 int ret = 0, i;-
115 char *m = NULL, mlch = ' ';-
116 int nmindent = 0;-
117 X509_CINF *ci;-
118 ASN1_INTEGER *bs;-
119 EVP_PKEY *pkey = NULL;-
120 const char *neg;-
121-
122 if ((nmflags & XN_FLAG_SEP_MASK) == XN_FLAG_SEP_MULTILINE) {
(nmflags & (0x...) == (4 << 16)Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
123 mlch = '\n';-
124 nmindent = 12;-
125 }
never executed: end of block
0
126-
127 if (nmflags == X509_FLAG_COMPAT)
nmflags == 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
0-3
128 nmindent = 16;
executed 3 times by 1 test: nmindent = 16;
Executed by:
  • libcrypto.so.44.0.1
3
129-
130 ci = x->cert_info;-
131 if (!(cflag & X509_FLAG_NO_HEADER)) {
!(cflag & 1L)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
0-3
132 if (BIO_write(bp, "Certificate:\n", 13) <= 0)
BIO_write(bp, ...:\n", 13) <= 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
133 goto err;
never executed: goto err;
0
134 if (BIO_write(bp, " Data:\n", 10) <= 0)
BIO_write(bp, ...:\n", 10) <= 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
135 goto err;
never executed: goto err;
0
136 }
executed 3 times by 1 test: end of block
Executed by:
  • libcrypto.so.44.0.1
3
137 if (!(cflag & X509_FLAG_NO_VERSION)) {
!(cflag & (1L << 1))Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
0-3
138 l = X509_get_version(x);-
139 if (BIO_printf(bp, "%8sVersion: %lu (0x%lx)\n",
BIO_printf(bp,...l + 1, l) <= 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
140 "", l + 1, l) <= 0)
BIO_printf(bp,...l + 1, l) <= 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
141 goto err;
never executed: goto err;
0
142 }
executed 3 times by 1 test: end of block
Executed by:
  • libcrypto.so.44.0.1
3
143 if (!(cflag & X509_FLAG_NO_SERIAL)) {
!(cflag & (1L << 2))Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
0-3
144 if (BIO_write(bp, " Serial Number:", 22) <= 0)
BIO_write(bp, ...er:", 22) <= 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
145 goto err;
never executed: goto err;
0
146-
147 bs = X509_get_serialNumber(x);-
148 if (bs->length <= (int)sizeof(long)) {
bs->length <= ...t)sizeof(long)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
0-3
149 l = ASN1_INTEGER_get(bs);-
150 if (bs->type == V_ASN1_NEG_INTEGER) {
bs->type == (2 | 0x100)Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
151 l = -l;-
152 neg = "-";-
153 } else
never executed: end of block
0
154 neg = "";
executed 3 times by 1 test: neg = "";
Executed by:
  • libcrypto.so.44.0.1
3
155 if (BIO_printf(bp, " %s%lu (%s0x%lx)\n",
BIO_printf(bp,..., neg, l) <= 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
156 neg, l, neg, l) <= 0)
BIO_printf(bp,..., neg, l) <= 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
157 goto err;
never executed: goto err;
0
158 } else {
executed 3 times by 1 test: end of block
Executed by:
  • libcrypto.so.44.0.1
3
159 neg = (bs->type == V_ASN1_NEG_INTEGER) ?
(bs->type == (2 | 0x100))Description
TRUEnever evaluated
FALSEnever evaluated
0
160 " (Negative)" : "";-
161 if (BIO_printf(bp, "\n%12s%s", "", neg) <= 0)
BIO_printf(bp,... "", neg) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
162 goto err;
never executed: goto err;
0
163 for (i = 0; i < bs->length; i++) {
i < bs->lengthDescription
TRUEnever evaluated
FALSEnever evaluated
0
164 if (BIO_printf(bp, "%02x%c", bs->data[i],
BIO_printf(bp,...' : ':')) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
165 ((i + 1 == bs->length) ? '\n' : ':')) <= 0)
BIO_printf(bp,...' : ':')) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
166 goto err;
never executed: goto err;
0
167 }
never executed: end of block
0
168 }
never executed: end of block
0
169-
170 }-
171-
172 if (!(cflag & X509_FLAG_NO_SIGNAME)) {
!(cflag & (1L << 3))Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
0-3
173 if (X509_signature_print(bp, x->sig_alg, NULL) <= 0)
X509_signature...id *)0) ) <= 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
174 goto err;
never executed: goto err;
0
175 }
executed 3 times by 1 test: end of block
Executed by:
  • libcrypto.so.44.0.1
3
176-
177 if (!(cflag & X509_FLAG_NO_ISSUER)) {
!(cflag & (1L << 4))Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
0-3
178 if (BIO_printf(bp, " Issuer:%c", mlch) <= 0)
BIO_printf(bp,...c", mlch) <= 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
179 goto err;
never executed: goto err;
0
180 if (X509_NAME_print_ex(bp, X509_get_issuer_name(x),
X509_NAME_prin..., nmflags) < 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
181 nmindent, nmflags) < 0)
X509_NAME_prin..., nmflags) < 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
182 goto err;
never executed: goto err;
0
183 if (BIO_write(bp, "\n", 1) <= 0)
BIO_write(bp, "\n", 1) <= 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
184 goto err;
never executed: goto err;
0
185 }
executed 3 times by 1 test: end of block
Executed by:
  • libcrypto.so.44.0.1
3
186 if (!(cflag & X509_FLAG_NO_VALIDITY)) {
!(cflag & (1L << 5))Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
0-3
187 if (BIO_write(bp, " Validity\n", 17) <= 0)
BIO_write(bp, ...y\n", 17) <= 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
188 goto err;
never executed: goto err;
0
189 if (BIO_write(bp, " Not Before: ", 24) <= 0)
BIO_write(bp, ...e: ", 24) <= 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
190 goto err;
never executed: goto err;
0
191 if (!ASN1_TIME_print(bp, X509_get_notBefore(x)))
!ASN1_TIME_pri..._notBefore(x))Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
192 goto err;
never executed: goto err;
0
193 if (BIO_write(bp, "\n Not After : ", 25) <= 0)
BIO_write(bp, ... : ", 25) <= 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
194 goto err;
never executed: goto err;
0
195 if (!ASN1_TIME_print(bp, X509_get_notAfter(x)))
!ASN1_TIME_pri...m_notAfter(x))Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
196 goto err;
never executed: goto err;
0
197 if (BIO_write(bp, "\n", 1) <= 0)
BIO_write(bp, "\n", 1) <= 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
198 goto err;
never executed: goto err;
0
199 }
executed 3 times by 1 test: end of block
Executed by:
  • libcrypto.so.44.0.1
3
200 if (!(cflag & X509_FLAG_NO_SUBJECT)) {
!(cflag & (1L << 6))Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
0-3
201 if (BIO_printf(bp, " Subject:%c", mlch) <= 0)
BIO_printf(bp,...c", mlch) <= 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
202 goto err;
never executed: goto err;
0
203 if (X509_NAME_print_ex(bp, X509_get_subject_name(x),
X509_NAME_prin..., nmflags) < 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
204 nmindent, nmflags) < 0)
X509_NAME_prin..., nmflags) < 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
205 goto err;
never executed: goto err;
0
206 if (BIO_write(bp, "\n", 1) <= 0)
BIO_write(bp, "\n", 1) <= 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
207 goto err;
never executed: goto err;
0
208 }
executed 3 times by 1 test: end of block
Executed by:
  • libcrypto.so.44.0.1
3
209 if (!(cflag & X509_FLAG_NO_PUBKEY)) {
!(cflag & (1L << 7))Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
0-3
210 if (BIO_write(bp, " Subject Public Key Info:\n",
BIO_write(bp, ...:\n", 33) <= 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
211 33) <= 0)
BIO_write(bp, ...:\n", 33) <= 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
212 goto err;
never executed: goto err;
0
213 if (BIO_printf(bp, "%12sPublic Key Algorithm: ", "") <= 0)
BIO_printf(bp,...m: ", "") <= 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
214 goto err;
never executed: goto err;
0
215 if (i2a_ASN1_OBJECT(bp, ci->key->algor->algorithm) <= 0)
i2a_ASN1_OBJEC...lgorithm) <= 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
216 goto err;
never executed: goto err;
0
217 if (BIO_puts(bp, "\n") <= 0)
BIO_puts(bp, "\n") <= 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
218 goto err;
never executed: goto err;
0
219-
220 pkey = X509_get_pubkey(x);-
221 if (pkey == NULL) {
pkey == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
222 BIO_printf(bp, "%12sUnable to load Public Key\n", "");-
223 ERR_print_errors(bp);-
224 } else {
never executed: end of block
0
225 EVP_PKEY_print_public(bp, pkey, 16, NULL);-
226 EVP_PKEY_free(pkey);-
227 }
executed 3 times by 1 test: end of block
Executed by:
  • libcrypto.so.44.0.1
3
228 }-
229-
230 if (!(cflag & X509_FLAG_NO_EXTENSIONS))
!(cflag & (1L << 8))Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
0-3
231 X509V3_extensions_print(bp, "X509v3 extensions",
executed 3 times by 1 test: X509V3_extensions_print(bp, "X509v3 extensions", ci->extensions, cflag, 8);
Executed by:
  • libcrypto.so.44.0.1
3
232 ci->extensions, cflag, 8);
executed 3 times by 1 test: X509V3_extensions_print(bp, "X509v3 extensions", ci->extensions, cflag, 8);
Executed by:
  • libcrypto.so.44.0.1
3
233-
234 if (!(cflag & X509_FLAG_NO_SIGDUMP)) {
!(cflag & (1L << 9))Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
0-3
235 if (X509_signature_print(bp, x->sig_alg, x->signature) <= 0)
X509_signature...ignature) <= 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
236 goto err;
never executed: goto err;
0
237 }
executed 3 times by 1 test: end of block
Executed by:
  • libcrypto.so.44.0.1
3
238 if (!(cflag & X509_FLAG_NO_AUX)) {
!(cflag & (1L << 10))Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
0-3
239 if (!X509_CERT_AUX_print(bp, x->aux, 0))
!X509_CERT_AUX...bp, x->aux, 0)Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-3
240 goto err;
never executed: goto err;
0
241 }
executed 3 times by 1 test: end of block
Executed by:
  • libcrypto.so.44.0.1
3
242 ret = 1;-
243-
244err:
code before this statement executed 3 times by 1 test: err:
Executed by:
  • libcrypto.so.44.0.1
3
245 free(m);-
246 return (ret);
executed 3 times by 1 test: return (ret);
Executed by:
  • libcrypto.so.44.0.1
3
247}-
248-
249int-
250X509_ocspid_print(BIO *bp, X509 *x)-
251{-
252 unsigned char *der = NULL;-
253 unsigned char *dertmp;-
254 int derlen;-
255 int i;-
256 unsigned char SHA1md[SHA_DIGEST_LENGTH];-
257-
258 /* display the hash of the subject as it would appear-
259 in OCSP requests */-
260 if (BIO_printf(bp, " Subject OCSP hash: ") <= 0)
BIO_printf(bp,... hash: ") <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
261 goto err;
never executed: goto err;
0
262 derlen = i2d_X509_NAME(x->cert_info->subject, NULL);-
263 if ((der = dertmp = malloc(derlen)) == NULL)
(der = dertmp ...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
264 goto err;
never executed: goto err;
0
265 i2d_X509_NAME(x->cert_info->subject, &dertmp);-
266-
267 if (!EVP_Digest(der, derlen, SHA1md, NULL, EVP_sha1(), NULL))
!EVP_Digest(de... ((void *)0) )Description
TRUEnever evaluated
FALSEnever evaluated
0
268 goto err;
never executed: goto err;
0
269 for (i = 0; i < SHA_DIGEST_LENGTH; i++) {
i < 20Description
TRUEnever evaluated
FALSEnever evaluated
0
270 if (BIO_printf(bp, "%02X", SHA1md[i]) <= 0)
BIO_printf(bp,...HA1md[i]) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
271 goto err;
never executed: goto err;
0
272 }
never executed: end of block
0
273 free (der);-
274 der = NULL;-
275-
276 /* display the hash of the public key as it would appear-
277 in OCSP requests */-
278 if (BIO_printf(bp, "\n Public key OCSP hash: ") <= 0)
BIO_printf(bp,... hash: ") <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
279 goto err;
never executed: goto err;
0
280-
281 if (!EVP_Digest(x->cert_info->key->public_key->data,
!EVP_Digest(x-... ((void *)0) )Description
TRUEnever evaluated
FALSEnever evaluated
0
282 x->cert_info->key->public_key->length,
!EVP_Digest(x-... ((void *)0) )Description
TRUEnever evaluated
FALSEnever evaluated
0
283 SHA1md, NULL, EVP_sha1(), NULL))
!EVP_Digest(x-... ((void *)0) )Description
TRUEnever evaluated
FALSEnever evaluated
0
284 goto err;
never executed: goto err;
0
285 for (i = 0; i < SHA_DIGEST_LENGTH; i++) {
i < 20Description
TRUEnever evaluated
FALSEnever evaluated
0
286 if (BIO_printf(bp, "%02X", SHA1md[i]) <= 0)
BIO_printf(bp,...HA1md[i]) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
287 goto err;
never executed: goto err;
0
288 }
never executed: end of block
0
289 BIO_printf(bp, "\n");-
290-
291 return (1);
never executed: return (1);
0
292-
293err:-
294 free(der);-
295 return (0);
never executed: return (0);
0
296}-
297-
298int-
299X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent)-
300{-
301 const unsigned char *s;-
302 int i, n;-
303-
304 n = sig->length;-
305 s = sig->data;-
306 for (i = 0; i < n; i++) {
i < nDescription
TRUEevaluated 512 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
2-512
307 if ((i % 18) == 0) {
(i % 18) == 0Description
TRUEevaluated 30 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEevaluated 482 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
30-482
308 if (BIO_write(bp, "\n", 1) <= 0)
BIO_write(bp, "\n", 1) <= 0Description
TRUEnever evaluated
FALSEevaluated 30 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-30
309 return 0;
never executed: return 0;
0
310 if (BIO_indent(bp, indent, indent) <= 0)
BIO_indent(bp,..., indent) <= 0Description
TRUEnever evaluated
FALSEevaluated 30 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-30
311 return 0;
never executed: return 0;
0
312 }
executed 30 times by 1 test: end of block
Executed by:
  • libcrypto.so.44.0.1
30
313 if (BIO_printf(bp, "%02x%s", s[i],
BIO_printf(bp,..."" : ":") <= 0Description
TRUEnever evaluated
FALSEevaluated 512 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-512
314 ((i + 1) == n) ? "" : ":") <= 0)
BIO_printf(bp,..."" : ":") <= 0Description
TRUEnever evaluated
FALSEevaluated 512 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-512
315 return 0;
never executed: return 0;
0
316 }
executed 512 times by 1 test: end of block
Executed by:
  • libcrypto.so.44.0.1
512
317 if (BIO_write(bp, "\n", 1) != 1)
BIO_write(bp, "\n", 1) != 1Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-2
318 return 0;
never executed: return 0;
0
319-
320 return 1;
executed 2 times by 1 test: return 1;
Executed by:
  • libcrypto.so.44.0.1
2
321}-
322-
323int-
324X509_signature_print(BIO *bp, const X509_ALGOR *sigalg, const ASN1_STRING *sig)-
325{-
326 int sig_nid;-
327 if (BIO_puts(bp, " Signature Algorithm: ") <= 0)
BIO_puts(bp, "...rithm: ") <= 0Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-6
328 return 0;
never executed: return 0;
0
329 if (i2a_ASN1_OBJECT(bp, sigalg->algorithm) <= 0)
i2a_ASN1_OBJEC...lgorithm) <= 0Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-6
330 return 0;
never executed: return 0;
0
331-
332 sig_nid = OBJ_obj2nid(sigalg->algorithm);-
333 if (sig_nid != NID_undef) {
sig_nid != 0Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
0-6
334 int pkey_nid, dig_nid;-
335 const EVP_PKEY_ASN1_METHOD *ameth;-
336 if (OBJ_find_sigid_algs(sig_nid, &dig_nid, &pkey_nid)) {
OBJ_find_sigid...id, &pkey_nid)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
0-6
337 ameth = EVP_PKEY_asn1_find(NULL, pkey_nid);-
338 if (ameth && ameth->sig_print)
amethDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
ameth->sig_printDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
0-6
339 return ameth->sig_print(bp, sigalg, sig, 9, 0);
executed 6 times by 1 test: return ameth->sig_print(bp, sigalg, sig, 9, 0);
Executed by:
  • libcrypto.so.44.0.1
6
340 }
never executed: end of block
0
341 }
never executed: end of block
0
342 if (sig)
sigDescription
TRUEnever evaluated
FALSEnever evaluated
0
343 return X509_signature_dump(bp, sig, 9);
never executed: return X509_signature_dump(bp, sig, 9);
0
344 else if (BIO_puts(bp, "\n") <= 0)
BIO_puts(bp, "\n") <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
345 return 0;
never executed: return 0;
0
346 return 1;
never executed: return 1;
0
347}-
348-
349int-
350ASN1_STRING_print(BIO *bp, const ASN1_STRING *v)-
351{-
352 int i, n;-
353 char buf[80];-
354 const char *p;-
355-
356 if (v == NULL)
v == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
357 return (0);
never executed: return (0);
0
358 n = 0;-
359 p = (const char *)v->data;-
360 for (i = 0; i < v->length; i++) {
i < v->lengthDescription
TRUEnever evaluated
FALSEnever evaluated
0
361 if ((p[i] > '~') || ((p[i] < ' ') &&
(p[i] > '~')Description
TRUEnever evaluated
FALSEnever evaluated
(p[i] < ' ')Description
TRUEnever evaluated
FALSEnever evaluated
0
362 (p[i] != '\n') && (p[i] != '\r')))
(p[i] != '\n')Description
TRUEnever evaluated
FALSEnever evaluated
(p[i] != '\r')Description
TRUEnever evaluated
FALSEnever evaluated
0
363 buf[n] = '.';
never executed: buf[n] = '.';
0
364 else-
365 buf[n] = p[i];
never executed: buf[n] = p[i];
0
366 n++;-
367 if (n >= 80) {
n >= 80Description
TRUEnever evaluated
FALSEnever evaluated
0
368 if (BIO_write(bp, buf, n) <= 0)
BIO_write(bp, buf, n) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
369 return (0);
never executed: return (0);
0
370 n = 0;-
371 }
never executed: end of block
0
372 }
never executed: end of block
0
373 if (n > 0)
n > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
374 if (BIO_write(bp, buf, n) <= 0)
BIO_write(bp, buf, n) <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
375 return (0);
never executed: return (0);
0
376 return (1);
never executed: return (1);
0
377}-
378-
379int-
380ASN1_TIME_print(BIO *bp, const ASN1_TIME *tm)-
381{-
382 if (tm->type == V_ASN1_UTCTIME)
tm->type == 23Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
0-6
383 return ASN1_UTCTIME_print(bp, tm);
executed 6 times by 1 test: return ASN1_UTCTIME_print(bp, tm);
Executed by:
  • libcrypto.so.44.0.1
6
384 if (tm->type == V_ASN1_GENERALIZEDTIME)
tm->type == 24Description
TRUEnever evaluated
FALSEnever evaluated
0
385 return ASN1_GENERALIZEDTIME_print(bp, tm);
never executed: return ASN1_GENERALIZEDTIME_print(bp, tm);
0
386 BIO_write(bp, "Bad time value", 14);-
387 return (0);
never executed: return (0);
0
388}-
389-
390static const char *mon[12] = {-
391 "Jan", "Feb", "Mar", "Apr", "May", "Jun",-
392 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"-
393};-
394-
395int-
396ASN1_GENERALIZEDTIME_print(BIO *bp, const ASN1_GENERALIZEDTIME *tm)-
397{-
398 char *v;-
399 int gmt = 0;-
400 int i;-
401 int y = 0, M = 0, d = 0, h = 0, m = 0, s = 0;-
402 char *f = "";-
403 int f_len = 0;-
404-
405 i = tm->length;-
406 v = (char *)tm->data;-
407-
408 if (i < 12)
i < 12Description
TRUEnever evaluated
FALSEnever evaluated
0
409 goto err;
never executed: goto err;
0
410 if (v[i-1] == 'Z')
v[i-1] == 'Z'Description
TRUEnever evaluated
FALSEnever evaluated
0
411 gmt = 1;
never executed: gmt = 1;
0
412 for (i = 0; i < 12; i++)
i < 12Description
TRUEnever evaluated
FALSEnever evaluated
0
413 if ((v[i] > '9') || (v[i] < '0'))
(v[i] > '9')Description
TRUEnever evaluated
FALSEnever evaluated
(v[i] < '0')Description
TRUEnever evaluated
FALSEnever evaluated
0
414 goto err;
never executed: goto err;
0
415 y = (v[0] - '0') * 1000 + (v[1] - '0') * 100 +-
416 (v[2] - '0') * 10 + (v[3] - '0');-
417 M = (v[4] - '0') * 10 + (v[5] - '0');-
418 if ((M > 12) || (M < 1))
(M > 12)Description
TRUEnever evaluated
FALSEnever evaluated
(M < 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
419 goto err;
never executed: goto err;
0
420 d = (v[6] - '0') * 10 + (v[7] - '0');-
421 h = (v[8] - '0') * 10 + (v[9] - '0');-
422 m = (v[10] - '0') * 10 + (v[11] - '0');-
423 if (tm->length >= 14 &&
tm->length >= 14Description
TRUEnever evaluated
FALSEnever evaluated
0
424 (v[12] >= '0') && (v[12] <= '9') &&
(v[12] >= '0')Description
TRUEnever evaluated
FALSEnever evaluated
(v[12] <= '9')Description
TRUEnever evaluated
FALSEnever evaluated
0
425 (v[13] >= '0') && (v[13] <= '9')) {
(v[13] >= '0')Description
TRUEnever evaluated
FALSEnever evaluated
(v[13] <= '9')Description
TRUEnever evaluated
FALSEnever evaluated
0
426 s = (v[12] - '0') * 10 + (v[13] - '0');-
427 /* Check for fractions of seconds. */-
428 if (tm->length >= 15 && v[14] == '.') {
tm->length >= 15Description
TRUEnever evaluated
FALSEnever evaluated
v[14] == '.'Description
TRUEnever evaluated
FALSEnever evaluated
0
429 int l = tm->length;-
430 f = &v[14]; /* The decimal point. */-
431 f_len = 1;-
432 while (14 + f_len < l && f[f_len] >= '0' &&
14 + f_len < lDescription
TRUEnever evaluated
FALSEnever evaluated
f[f_len] >= '0'Description
TRUEnever evaluated
FALSEnever evaluated
0
433 f[f_len] <= '9')
f[f_len] <= '9'Description
TRUEnever evaluated
FALSEnever evaluated
0
434 ++f_len;
never executed: ++f_len;
0
435 }
never executed: end of block
0
436 }
never executed: end of block
0
437-
438 if (BIO_printf(bp, "%s %2d %02d:%02d:%02d%.*s %d%s",
BIO_printf(bp,...MT" : "") <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
439 mon[M - 1], d, h, m, s, f_len, f, y, (gmt) ? " GMT" : "") <= 0)
BIO_printf(bp,...MT" : "") <= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
440 return (0);
never executed: return (0);
0
441 else-
442 return (1);
never executed: return (1);
0
443-
444err:-
445 BIO_write(bp, "Bad time value", 14);-
446 return (0);
never executed: return (0);
0
447}-
448-
449int-
450ASN1_UTCTIME_print(BIO *bp, const ASN1_UTCTIME *tm)-
451{-
452 const char *v;-
453 int gmt = 0;-
454 int i;-
455 int y = 0, M = 0, d = 0, h = 0, m = 0, s = 0;-
456-
457 i = tm->length;-
458 v = (const char *)tm->data;-
459-
460 if (i < 10)
i < 10Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-6
461 goto err;
never executed: goto err;
0
462 if (v[i-1] == 'Z')
v[i-1] == 'Z'Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
0-6
463 gmt = 1;
executed 6 times by 1 test: gmt = 1;
Executed by:
  • libcrypto.so.44.0.1
6
464 for (i = 0; i < 10; i++)
i < 10Description
TRUEevaluated 60 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
6-60
465 if ((v[i] > '9') || (v[i] < '0'))
(v[i] > '9')Description
TRUEnever evaluated
FALSEevaluated 60 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
(v[i] < '0')Description
TRUEnever evaluated
FALSEevaluated 60 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-60
466 goto err;
never executed: goto err;
0
467 y = (v[0] - '0') * 10 + (v[1] - '0');-
468 if (y < 50)
y < 50Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
0-6
469 y += 100;
executed 6 times by 1 test: y += 100;
Executed by:
  • libcrypto.so.44.0.1
6
470 M = (v[2] - '0') * 10 + (v[3] - '0');-
471 if ((M > 12) || (M < 1))
(M > 12)Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
(M < 1)Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-6
472 goto err;
never executed: goto err;
0
473 d = (v[4] - '0') * 10 + (v[5] - '0');-
474 h = (v[6] - '0') * 10 + (v[7] - '0');-
475 m = (v[8] - '0') * 10 + (v[9] - '0');-
476 if (tm->length >=12 &&
tm->length >=12Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
0-6
477 (v[10] >= '0') && (v[10] <= '9') &&
(v[10] >= '0')Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
(v[10] <= '9')Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
0-6
478 (v[11] >= '0') && (v[11] <= '9'))
(v[11] >= '0')Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
(v[11] <= '9')Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
0-6
479 s = (v[10] - '0') * 10 + (v[11] - '0');
executed 6 times by 1 test: s = (v[10] - '0') * 10 + (v[11] - '0');
Executed by:
  • libcrypto.so.44.0.1
6
480-
481 if (BIO_printf(bp, "%s %2d %02d:%02d:%02d %d%s",
BIO_printf(bp,...MT" : "") <= 0Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-6
482 mon[M - 1], d, h, m, s, y + 1900, (gmt) ? " GMT" : "") <= 0)
BIO_printf(bp,...MT" : "") <= 0Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-6
483 return (0);
never executed: return (0);
0
484 else-
485 return (1);
executed 6 times by 1 test: return (1);
Executed by:
  • libcrypto.so.44.0.1
6
486-
487err:-
488 BIO_write(bp, "Bad time value", 14);-
489 return (0);
never executed: return (0);
0
490}-
491-
492int-
493X509_NAME_print(BIO *bp, const X509_NAME *name, int obase)-
494{-
495 char *s, *c, *b;-
496 int ret = 0, l, i;-
497-
498 l = 80 - 2 - obase;-
499-
500 b = X509_NAME_oneline(name, NULL, 0);-
501 if (b == NULL)
b == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-6
502 return 0;
never executed: return 0;
0
503 if (*b == '\0') {
*b == '\0'Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-6
504 free(b);-
505 return 1;
never executed: return 1;
0
506 }-
507 s = b + 1; /* skip the first slash */-
508-
509 c = s;-
510 for (;;) {-
511 if (((*s == '/') &&
(*s == '/')Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEevaluated 322 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
18-322
512 ((s[1] >= 'A') && (s[1] <= 'Z') &&
(s[1] >= 'A')Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
(s[1] <= 'Z')Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
0-18
513 ((s[2] == '=') || ((s[2] >= 'A') && (s[2] <= 'Z') &&
(s[2] == '=')Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEevaluated 12 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
(s[2] >= 'A')Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
(s[2] <= 'Z')Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
0-12
514 (s[3] == '='))))) || (*s == '\0')) {
(s[3] == '=')Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
(*s == '\0')Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEevaluated 316 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-316
515 i = s - c;-
516 if (BIO_write(bp, c, i) != i)
BIO_write(bp, c, i) != iDescription
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-24
517 goto err;
never executed: goto err;
0
518 c = s + 1; /* skip following slash */-
519 if (*s != '\0') {
*s != '\0'Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
6-18
520 if (BIO_write(bp, ", ", 2) != 2)
BIO_write(bp, ", ", 2) != 2Description
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
0-18
521 goto err;
never executed: goto err;
0
522 }
executed 18 times by 1 test: end of block
Executed by:
  • libcrypto.so.44.0.1
18
523 l--;-
524 }
executed 24 times by 1 test: end of block
Executed by:
  • libcrypto.so.44.0.1
24
525 if (*s == '\0')
*s == '\0'Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEevaluated 334 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
6-334
526 break;
executed 6 times by 1 test: break;
Executed by:
  • libcrypto.so.44.0.1
6
527 s++;-
528 l--;-
529 }
executed 334 times by 1 test: end of block
Executed by:
  • libcrypto.so.44.0.1
334
530-
531 ret = 1;-
532 if (0) {-
533err:-
534 X509error(ERR_R_BUF_LIB);-
535 }
never executed: end of block
0
536 free(b);-
537 return (ret);
executed 6 times by 1 test: return (ret);
Executed by:
  • libcrypto.so.44.0.1
6
538}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2