diff options
author | jsing <> | 2014-04-21 16:32:06 +0000 |
---|---|---|
committer | jsing <> | 2014-04-21 16:32:06 +0000 |
commit | dbe50a7f3c84521e4543ad2e5292244bd0b81414 (patch) | |
tree | be04a70e8733f1afb3ae549ad26c1c50ec666f15 /src/lib/libcrypto/ts/ts_lib.c | |
parent | 4e74c38c506a70910cb7f88175f2f718983bbdc6 (diff) | |
download | openbsd-dbe50a7f3c84521e4543ad2e5292244bd0b81414.tar.gz openbsd-dbe50a7f3c84521e4543ad2e5292244bd0b81414.tar.bz2 openbsd-dbe50a7f3c84521e4543ad2e5292244bd0b81414.zip |
KNF.
Diffstat (limited to 'src/lib/libcrypto/ts/ts_lib.c')
-rw-r--r-- | src/lib/libcrypto/ts/ts_lib.c | 59 |
1 files changed, 31 insertions, 28 deletions
diff --git a/src/lib/libcrypto/ts/ts_lib.c b/src/lib/libcrypto/ts/ts_lib.c index a8de801e28..81a5f23cd5 100644 --- a/src/lib/libcrypto/ts/ts_lib.c +++ b/src/lib/libcrypto/ts/ts_lib.c | |||
@@ -10,7 +10,7 @@ | |||
10 | * are met: | 10 | * are met: |
11 | * | 11 | * |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * | 14 | * |
15 | * 2. Redistributions in binary form must reproduce the above copyright | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in | 16 | * notice, this list of conditions and the following disclaimer in |
@@ -67,27 +67,28 @@ | |||
67 | 67 | ||
68 | /* Function definitions. */ | 68 | /* Function definitions. */ |
69 | 69 | ||
70 | int TS_ASN1_INTEGER_print_bio(BIO *bio, const ASN1_INTEGER *num) | 70 | int |
71 | { | 71 | TS_ASN1_INTEGER_print_bio(BIO *bio, const ASN1_INTEGER *num) |
72 | { | ||
72 | BIGNUM num_bn; | 73 | BIGNUM num_bn; |
73 | int result = 0; | 74 | int result = 0; |
74 | char *hex; | 75 | char *hex; |
75 | 76 | ||
76 | BN_init(&num_bn); | 77 | BN_init(&num_bn); |
77 | ASN1_INTEGER_to_BN(num, &num_bn); | 78 | ASN1_INTEGER_to_BN(num, &num_bn); |
78 | if ((hex = BN_bn2hex(&num_bn))) | 79 | if ((hex = BN_bn2hex(&num_bn))) { |
79 | { | ||
80 | result = BIO_write(bio, "0x", 2) > 0; | 80 | result = BIO_write(bio, "0x", 2) > 0; |
81 | result = result && BIO_write(bio, hex, strlen(hex)) > 0; | 81 | result = result && BIO_write(bio, hex, strlen(hex)) > 0; |
82 | free(hex); | 82 | free(hex); |
83 | } | 83 | } |
84 | BN_free(&num_bn); | 84 | BN_free(&num_bn); |
85 | 85 | ||
86 | return result; | 86 | return result; |
87 | } | 87 | } |
88 | 88 | ||
89 | int TS_OBJ_print_bio(BIO *bio, const ASN1_OBJECT *obj) | 89 | int |
90 | { | 90 | TS_OBJ_print_bio(BIO *bio, const ASN1_OBJECT *obj) |
91 | { | ||
91 | char obj_txt[128]; | 92 | char obj_txt[128]; |
92 | 93 | ||
93 | int len = OBJ_obj2txt(obj_txt, sizeof(obj_txt), obj, 0); | 94 | int len = OBJ_obj2txt(obj_txt, sizeof(obj_txt), obj, 0); |
@@ -95,51 +96,53 @@ int TS_OBJ_print_bio(BIO *bio, const ASN1_OBJECT *obj) | |||
95 | BIO_write(bio, "\n", 1); | 96 | BIO_write(bio, "\n", 1); |
96 | 97 | ||
97 | return 1; | 98 | return 1; |
98 | } | 99 | } |
99 | 100 | ||
100 | int TS_ext_print_bio(BIO *bio, const STACK_OF(X509_EXTENSION) *extensions) | 101 | int |
101 | { | 102 | TS_ext_print_bio(BIO *bio, const STACK_OF(X509_EXTENSION) *extensions) |
103 | { | ||
102 | int i, critical, n; | 104 | int i, critical, n; |
103 | X509_EXTENSION *ex; | 105 | X509_EXTENSION *ex; |
104 | ASN1_OBJECT *obj; | 106 | ASN1_OBJECT *obj; |
105 | 107 | ||
106 | BIO_printf(bio, "Extensions:\n"); | 108 | BIO_printf(bio, "Extensions:\n"); |
107 | n = X509v3_get_ext_count(extensions); | 109 | n = X509v3_get_ext_count(extensions); |
108 | for (i = 0; i < n; i++) | 110 | for (i = 0; i < n; i++) { |
109 | { | ||
110 | ex = X509v3_get_ext(extensions, i); | 111 | ex = X509v3_get_ext(extensions, i); |
111 | obj = X509_EXTENSION_get_object(ex); | 112 | obj = X509_EXTENSION_get_object(ex); |
112 | i2a_ASN1_OBJECT(bio, obj); | 113 | i2a_ASN1_OBJECT(bio, obj); |
113 | critical = X509_EXTENSION_get_critical(ex); | 114 | critical = X509_EXTENSION_get_critical(ex); |
114 | BIO_printf(bio, ": %s\n", critical ? "critical" : ""); | 115 | BIO_printf(bio, ": %s\n", critical ? "critical" : ""); |
115 | if (!X509V3_EXT_print(bio, ex, 0, 4)) | 116 | if (!X509V3_EXT_print(bio, ex, 0, 4)) { |
116 | { | ||
117 | BIO_printf(bio, "%4s", ""); | 117 | BIO_printf(bio, "%4s", ""); |
118 | M_ASN1_OCTET_STRING_print(bio, ex->value); | 118 | M_ASN1_OCTET_STRING_print(bio, ex->value); |
119 | } | ||
120 | BIO_write(bio, "\n", 1); | ||
121 | } | 119 | } |
120 | BIO_write(bio, "\n", 1); | ||
121 | } | ||
122 | 122 | ||
123 | return 1; | 123 | return 1; |
124 | } | 124 | } |
125 | 125 | ||
126 | int TS_X509_ALGOR_print_bio(BIO *bio, const X509_ALGOR *alg) | 126 | int |
127 | { | 127 | TS_X509_ALGOR_print_bio(BIO *bio, const X509_ALGOR *alg) |
128 | { | ||
128 | int i = OBJ_obj2nid(alg->algorithm); | 129 | int i = OBJ_obj2nid(alg->algorithm); |
130 | |||
129 | return BIO_printf(bio, "Hash Algorithm: %s\n", | 131 | return BIO_printf(bio, "Hash Algorithm: %s\n", |
130 | (i == NID_undef) ? "UNKNOWN" : OBJ_nid2ln(i)); | 132 | (i == NID_undef) ? "UNKNOWN" : OBJ_nid2ln(i)); |
131 | } | 133 | } |
132 | 134 | ||
133 | int TS_MSG_IMPRINT_print_bio(BIO *bio, TS_MSG_IMPRINT *a) | 135 | int |
134 | { | 136 | TS_MSG_IMPRINT_print_bio(BIO *bio, TS_MSG_IMPRINT *a) |
137 | { | ||
135 | const ASN1_OCTET_STRING *msg; | 138 | const ASN1_OCTET_STRING *msg; |
136 | 139 | ||
137 | TS_X509_ALGOR_print_bio(bio, TS_MSG_IMPRINT_get_algo(a)); | 140 | TS_X509_ALGOR_print_bio(bio, TS_MSG_IMPRINT_get_algo(a)); |
138 | 141 | ||
139 | BIO_printf(bio, "Message data:\n"); | 142 | BIO_printf(bio, "Message data:\n"); |
140 | msg = TS_MSG_IMPRINT_get_msg(a); | 143 | msg = TS_MSG_IMPRINT_get_msg(a); |
141 | BIO_dump_indent(bio, (const char *)M_ASN1_STRING_data(msg), | 144 | BIO_dump_indent(bio, (const char *)M_ASN1_STRING_data(msg), |
142 | M_ASN1_STRING_length(msg), 4); | 145 | M_ASN1_STRING_length(msg), 4); |
143 | 146 | ||
144 | return 1; | 147 | return 1; |
145 | } | 148 | } |