OpenCoverage

ct_prn.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/ct/ct_prn.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2 * Copyright 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#ifdef OPENSSL_NO_CT-
11# error "CT is disabled"-
12#endif-
13-
14#include <openssl/asn1.h>-
15#include <openssl/bio.h>-
16-
17#include "ct_locl.h"-
18-
19static void SCT_signature_algorithms_print(const SCT *sct, BIO *out)-
20{-
21 int nid = SCT_get_signature_nid(sct);-
22-
23 if (nid == NID_undef)
nid == 0Description
TRUEnever evaluated
FALSEevaluated 2338 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2338
24 BIO_printf(out, "%02X%02X", sct->hash_alg, sct->sig_alg);
never executed: BIO_printf(out, "%02X%02X", sct->hash_alg, sct->sig_alg);
0
25 else-
26 BIO_printf(out, "%s", OBJ_nid2ln(nid));
executed 2338 times by 1 test: BIO_printf(out, "%s", OBJ_nid2ln(nid));
Executed by:
  • libcrypto.so.1.1
2338
27}-
28-
29static void timestamp_print(uint64_t timestamp, BIO *out)-
30{-
31 ASN1_GENERALIZEDTIME *gen = ASN1_GENERALIZEDTIME_new();-
32 char genstr[20];-
33-
34 if (gen == NULL)
gen == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 2338 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-2338
35 return;
never executed: return;
0
36 ASN1_GENERALIZEDTIME_adj(gen, (time_t)0,-
37 (int)(timestamp / 86400000),-
38 (timestamp % 86400000) / 1000);-
39 /*-
40 * Note GeneralizedTime from ASN1_GENERALIZETIME_adj is always 15-
41 * characters long with a final Z. Update it with fractional seconds.-
42 */-
43 BIO_snprintf(genstr, sizeof(genstr), "%.14s.%03dZ",-
44 ASN1_STRING_get0_data(gen), (unsigned int)(timestamp % 1000));-
45 if (ASN1_GENERALIZEDTIME_set_string(gen, genstr))
ASN1_GENERALIZ...g(gen, genstr)Description
TRUEevaluated 1804 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 534 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
534-1804
46 ASN1_GENERALIZEDTIME_print(out, gen);
executed 1804 times by 1 test: ASN1_GENERALIZEDTIME_print(out, gen);
Executed by:
  • libcrypto.so.1.1
1804
47 ASN1_GENERALIZEDTIME_free(gen);-
48}
executed 2338 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
2338
49-
50const char *SCT_validation_status_string(const SCT *sct)-
51{-
52-
53 switch (SCT_get_validation_status(sct)) {-
54 case SCT_VALIDATION_STATUS_NOT_SET:
executed 2 times by 1 test: case SCT_VALIDATION_STATUS_NOT_SET:
Executed by:
  • libcrypto.so.1.1
2
55 return "not set";
executed 2 times by 1 test: return "not set";
Executed by:
  • libcrypto.so.1.1
2
56 case SCT_VALIDATION_STATUS_UNKNOWN_VERSION:
never executed: case SCT_VALIDATION_STATUS_UNKNOWN_VERSION:
0
57 return "unknown version";
never executed: return "unknown version";
0
58 case SCT_VALIDATION_STATUS_UNKNOWN_LOG:
never executed: case SCT_VALIDATION_STATUS_UNKNOWN_LOG:
0
59 return "unknown log";
never executed: return "unknown log";
0
60 case SCT_VALIDATION_STATUS_UNVERIFIED:
never executed: case SCT_VALIDATION_STATUS_UNVERIFIED:
0
61 return "unverified";
never executed: return "unverified";
0
62 case SCT_VALIDATION_STATUS_INVALID:
never executed: case SCT_VALIDATION_STATUS_INVALID:
0
63 return "invalid";
never executed: return "invalid";
0
64 case SCT_VALIDATION_STATUS_VALID:
never executed: case SCT_VALIDATION_STATUS_VALID:
0
65 return "valid";
never executed: return "valid";
0
66 }-
67 return "unknown status";
never executed: return "unknown status";
0
68}-
69-
70void SCT_print(const SCT *sct, BIO *out, int indent,-
71 const CTLOG_STORE *log_store)-
72{-
73 const CTLOG *log = NULL;-
74-
75 if (log_store != NULL) {
log_store != ((void *)0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 10671 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2-10671
76 log = CTLOG_STORE_get0_log_by_id(log_store, sct->log_id,-
77 sct->log_id_len);-
78 }
executed 2 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
2
79-
80 BIO_printf(out, "%*sSigned Certificate Timestamp:", indent, "");-
81 BIO_printf(out, "\n%*sVersion : ", indent + 4, "");-
82-
83 if (sct->version != SCT_VERSION_V1) {
sct->version != SCT_VERSION_V1Description
TRUEevaluated 8335 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2338 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2338-8335
84 BIO_printf(out, "unknown\n%*s", indent + 16, "");-
85 BIO_hex_string(out, indent + 16, 16, sct->sct, sct->sct_len);-
86 return;
executed 8335 times by 1 test: return;
Executed by:
  • libcrypto.so.1.1
8335
87 }-
88-
89 BIO_printf(out, "v1 (0x0)");-
90-
91 if (log != NULL) {
log != ((void *)0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2336 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2-2336
92 BIO_printf(out, "\n%*sLog : %s", indent + 4, "",-
93 CTLOG_get0_name(log));-
94 }
executed 2 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
2
95-
96 BIO_printf(out, "\n%*sLog ID : ", indent + 4, "");-
97 BIO_hex_string(out, indent + 16, 16, sct->log_id, sct->log_id_len);-
98-
99 BIO_printf(out, "\n%*sTimestamp : ", indent + 4, "");-
100 timestamp_print(sct->timestamp, out);-
101-
102 BIO_printf(out, "\n%*sExtensions: ", indent + 4, "");-
103 if (sct->ext_len == 0)
sct->ext_len == 0Description
TRUEevaluated 2220 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 118 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
118-2220
104 BIO_printf(out, "none");
executed 2220 times by 1 test: BIO_printf(out, "none");
Executed by:
  • libcrypto.so.1.1
2220
105 else-
106 BIO_hex_string(out, indent + 16, 16, sct->ext, sct->ext_len);
executed 118 times by 1 test: BIO_hex_string(out, indent + 16, 16, sct->ext, sct->ext_len);
Executed by:
  • libcrypto.so.1.1
118
107-
108 BIO_printf(out, "\n%*sSignature : ", indent + 4, "");-
109 SCT_signature_algorithms_print(sct, out);-
110 BIO_printf(out, "\n%*s ", indent + 4, "");-
111 BIO_hex_string(out, indent + 16, 16, sct->sig, sct->sig_len);-
112}
executed 2338 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
2338
113-
114void SCT_LIST_print(const STACK_OF(SCT) *sct_list, BIO *out, int indent,-
115 const char *separator, const CTLOG_STORE *log_store)-
116{-
117 int sct_count = sk_SCT_num(sct_list);-
118 int i;-
119-
120 for (i = 0; i < sct_count; ++i) {
i < sct_countDescription
TRUEevaluated 10671 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2731 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2731-10671
121 SCT *sct = sk_SCT_value(sct_list, i);-
122-
123 SCT_print(sct, out, indent, log_store);-
124 if (i < sk_SCT_num(sct_list) - 1)
i < sk_SCT_num(sct_list) - 1Description
TRUEevaluated 8405 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
FALSEevaluated 2266 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
2266-8405
125 BIO_printf(out, "%s", separator);
executed 8405 times by 1 test: BIO_printf(out, "%s", separator);
Executed by:
  • libcrypto.so.1.1
8405
126 }
executed 10671 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
10671
127}
executed 2731 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
2731
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2