]>
git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/ts/ts_lib.c
e18f1f3f7e3ff93b9d83dedfd5b5c3d35da3ff98
2 * Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved.
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
11 #include "internal/cryptlib.h"
12 #include <openssl/objects.h>
13 #include <openssl/bn.h>
14 #include <openssl/x509.h>
15 #include <openssl/x509v3.h>
16 #include <openssl/ts.h>
19 int TS_ASN1_INTEGER_print_bio(BIO
*bio
, const ASN1_INTEGER
*num
)
28 ASN1_INTEGER_to_BN(num
, num_bn
);
29 if ((hex
= BN_bn2hex(num_bn
))) {
30 result
= BIO_write(bio
, "0x", 2) > 0;
31 result
= result
&& BIO_write(bio
, hex
, strlen(hex
)) > 0;
39 int TS_OBJ_print_bio(BIO
*bio
, const ASN1_OBJECT
*obj
)
43 OBJ_obj2txt(obj_txt
, sizeof(obj_txt
), obj
, 0);
44 BIO_printf(bio
, "%s\n", obj_txt
);
49 int TS_ext_print_bio(BIO
*bio
, const STACK_OF(X509_EXTENSION
) *extensions
)
55 BIO_printf(bio
, "Extensions:\n");
56 n
= X509v3_get_ext_count(extensions
);
57 for (i
= 0; i
< n
; i
++) {
58 ex
= X509v3_get_ext(extensions
, i
);
59 obj
= X509_EXTENSION_get_object(ex
);
60 i2a_ASN1_OBJECT(bio
, obj
);
61 critical
= X509_EXTENSION_get_critical(ex
);
62 BIO_printf(bio
, ": %s\n", critical
? "critical" : "");
63 if (!X509V3_EXT_print(bio
, ex
, 0, 4)) {
64 BIO_printf(bio
, "%4s", "");
65 ASN1_STRING_print(bio
, X509_EXTENSION_get_data(ex
));
67 BIO_write(bio
, "\n", 1);
73 int TS_X509_ALGOR_print_bio(BIO
*bio
, const X509_ALGOR
*alg
)
75 int i
= OBJ_obj2nid(alg
->algorithm
);
76 return BIO_printf(bio
, "Hash Algorithm: %s\n",
77 (i
== NID_undef
) ? "UNKNOWN" : OBJ_nid2ln(i
));
80 int TS_MSG_IMPRINT_print_bio(BIO
*bio
, TS_MSG_IMPRINT
*a
)
82 ASN1_OCTET_STRING
*msg
;
84 TS_X509_ALGOR_print_bio(bio
, a
->hash_algo
);
86 BIO_printf(bio
, "Message data:\n");
88 BIO_dump_indent(bio
, (const char *)ASN1_STRING_data(msg
),
89 ASN1_STRING_length(msg
), 4);