diff options
Diffstat (limited to 'src/lib/libcrypto/ct/ct_prn.c')
-rw-r--r-- | src/lib/libcrypto/ct/ct_prn.c | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/src/lib/libcrypto/ct/ct_prn.c b/src/lib/libcrypto/ct/ct_prn.c index 3cd9b8e838..3b1be71394 100644 --- a/src/lib/libcrypto/ct/ct_prn.c +++ b/src/lib/libcrypto/ct/ct_prn.c | |||
@@ -16,6 +16,36 @@ | |||
16 | 16 | ||
17 | #include "ct_local.h" | 17 | #include "ct_local.h" |
18 | 18 | ||
19 | /* | ||
20 | * XXX public api in OpenSSL 1.1.0 but this is the only thing that uses it. | ||
21 | * so I am stuffing it here for the moment. | ||
22 | */ | ||
23 | static int | ||
24 | BIO_hex_string(BIO *out, int indent, int width, unsigned char *data, | ||
25 | int datalen) | ||
26 | { | ||
27 | int i, j = 0; | ||
28 | |||
29 | if (datalen < 1) | ||
30 | return 1; | ||
31 | |||
32 | for (i = 0; i < datalen - 1; i++) { | ||
33 | if (i && !j) | ||
34 | BIO_printf(out, "%*s", indent, ""); | ||
35 | |||
36 | BIO_printf(out, "%02X:", data[i]); | ||
37 | |||
38 | j = (j + 1) % width; | ||
39 | if (!j) | ||
40 | BIO_printf(out, "\n"); | ||
41 | } | ||
42 | |||
43 | if (i && !j) | ||
44 | BIO_printf(out, "%*s", indent, ""); | ||
45 | BIO_printf(out, "%02X", data[datalen - 1]); | ||
46 | return 1; | ||
47 | } | ||
48 | |||
19 | static void | 49 | static void |
20 | SCT_signature_algorithms_print(const SCT *sct, BIO *out) | 50 | SCT_signature_algorithms_print(const SCT *sct, BIO *out) |
21 | { | 51 | { |
@@ -35,13 +65,13 @@ timestamp_print(uint64_t timestamp, BIO *out) | |||
35 | 65 | ||
36 | if (gen == NULL) | 66 | if (gen == NULL) |
37 | return; | 67 | return; |
38 | ASN1_GENERALIZEDTIME_adj(gen, (time_t)0,(int)(timestamp / 86400000), | 68 | ASN1_GENERALIZEDTIME_adj(gen, (time_t)0, (int)(timestamp / 86400000), |
39 | (timestamp % 86400000) / 1000); | 69 | (timestamp % 86400000) / 1000); |
40 | /* | 70 | /* |
41 | * Note GeneralizedTime from ASN1_GENERALIZETIME_adj is always 15 | 71 | * Note GeneralizedTime from ASN1_GENERALIZETIME_adj is always 15 |
42 | * characters long with a final Z. Update it with fractional seconds. | 72 | * characters long with a final Z. Update it with fractional seconds. |
43 | */ | 73 | */ |
44 | BIO_snprintf(genstr, sizeof(genstr), "%.14s.%03dZ", | 74 | snprintf(genstr, sizeof(genstr), "%.14s.%03dZ", |
45 | ASN1_STRING_get0_data(gen), (unsigned int)(timestamp % 1000)); | 75 | ASN1_STRING_get0_data(gen), (unsigned int)(timestamp % 1000)); |
46 | if (ASN1_GENERALIZEDTIME_set_string(gen, genstr)) | 76 | if (ASN1_GENERALIZEDTIME_set_string(gen, genstr)) |
47 | ASN1_GENERALIZEDTIME_print(out, gen); | 77 | ASN1_GENERALIZEDTIME_print(out, gen); |
@@ -63,7 +93,7 @@ SCT_validation_status_string(const SCT *sct) | |||
63 | case SCT_VALIDATION_STATUS_INVALID: | 93 | case SCT_VALIDATION_STATUS_INVALID: |
64 | return "invalid"; | 94 | return "invalid"; |
65 | case SCT_VALIDATION_STATUS_VALID: | 95 | case SCT_VALIDATION_STATUS_VALID: |
66 | return "valid"; | 96 | return "valid"; |
67 | } | 97 | } |
68 | return "unknown status"; | 98 | return "unknown status"; |
69 | } | 99 | } |