diff options
Diffstat (limited to 'src/lib/libcrypto/ts/ts_rsp_print.c')
| -rw-r--r-- | src/lib/libcrypto/ts/ts_rsp_print.c | 140 |
1 files changed, 77 insertions, 63 deletions
diff --git a/src/lib/libcrypto/ts/ts_rsp_print.c b/src/lib/libcrypto/ts/ts_rsp_print.c index 21062517ba..248674f4e5 100644 --- a/src/lib/libcrypto/ts/ts_rsp_print.c +++ b/src/lib/libcrypto/ts/ts_rsp_print.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 |
| @@ -63,22 +63,22 @@ | |||
| 63 | #include <openssl/x509v3.h> | 63 | #include <openssl/x509v3.h> |
| 64 | #include "ts.h" | 64 | #include "ts.h" |
| 65 | 65 | ||
| 66 | struct status_map_st | 66 | struct status_map_st { |
| 67 | { | ||
| 68 | int bit; | 67 | int bit; |
| 69 | const char *text; | 68 | const char *text; |
| 70 | }; | 69 | }; |
| 71 | 70 | ||
| 72 | /* Local function declarations. */ | 71 | /* Local function declarations. */ |
| 73 | 72 | ||
| 74 | static int TS_status_map_print(BIO *bio, struct status_map_st *a, | 73 | static int TS_status_map_print(BIO *bio, struct status_map_st *a, |
| 75 | ASN1_BIT_STRING *v); | 74 | ASN1_BIT_STRING *v); |
| 76 | static int TS_ACCURACY_print_bio(BIO *bio, const TS_ACCURACY *accuracy); | 75 | static int TS_ACCURACY_print_bio(BIO *bio, const TS_ACCURACY *accuracy); |
| 77 | 76 | ||
| 78 | /* Function definitions. */ | 77 | /* Function definitions. */ |
| 79 | 78 | ||
| 80 | int TS_RESP_print_bio(BIO *bio, TS_RESP *a) | 79 | int |
| 81 | { | 80 | TS_RESP_print_bio(BIO *bio, TS_RESP *a) |
| 81 | { | ||
| 82 | TS_TST_INFO *tst_info; | 82 | TS_TST_INFO *tst_info; |
| 83 | 83 | ||
| 84 | BIO_printf(bio, "Status info:\n"); | 84 | BIO_printf(bio, "Status info:\n"); |
| @@ -90,98 +90,111 @@ int TS_RESP_print_bio(BIO *bio, TS_RESP *a) | |||
| 90 | TS_TST_INFO_print_bio(bio, TS_RESP_get_tst_info(a)); | 90 | TS_TST_INFO_print_bio(bio, TS_RESP_get_tst_info(a)); |
| 91 | else | 91 | else |
| 92 | BIO_printf(bio, "Not included.\n"); | 92 | BIO_printf(bio, "Not included.\n"); |
| 93 | 93 | ||
| 94 | return 1; | 94 | return 1; |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | int TS_STATUS_INFO_print_bio(BIO *bio, TS_STATUS_INFO *a) | 97 | int |
| 98 | { | 98 | TS_STATUS_INFO_print_bio(BIO *bio, TS_STATUS_INFO *a) |
| 99 | static const char *status_map[] = | 99 | { |
| 100 | { | 100 | static const char *status_map[] = { |
| 101 | "Granted.", | 101 | "Granted.", |
| 102 | "Granted with modifications.", | 102 | "Granted with modifications.", |
| 103 | "Rejected.", | 103 | "Rejected.", |
| 104 | "Waiting.", | 104 | "Waiting.", |
| 105 | "Revocation warning.", | 105 | "Revocation warning.", |
| 106 | "Revoked." | 106 | "Revoked." |
| 107 | }; | 107 | }; |
| 108 | static struct status_map_st failure_map[] = | 108 | static struct status_map_st failure_map[] = { |
| 109 | { | ||
| 110 | TS_INFO_BAD_ALG, | ||
| 111 | "unrecognized or unsupported algorithm identifier" | ||
| 112 | }, | ||
| 113 | { | ||
| 114 | TS_INFO_BAD_REQUEST, | ||
| 115 | "transaction not permitted or supported" | ||
| 116 | }, | ||
| 109 | { | 117 | { |
| 110 | { TS_INFO_BAD_ALG, | 118 | TS_INFO_BAD_DATA_FORMAT, |
| 111 | "unrecognized or unsupported algorithm identifier" }, | 119 | "the data submitted has the wrong format" |
| 112 | { TS_INFO_BAD_REQUEST, | 120 | }, |
| 113 | "transaction not permitted or supported" }, | 121 | { |
| 114 | { TS_INFO_BAD_DATA_FORMAT, | 122 | TS_INFO_TIME_NOT_AVAILABLE, |
| 115 | "the data submitted has the wrong format" }, | 123 | "the TSA's time source is not available" |
| 116 | { TS_INFO_TIME_NOT_AVAILABLE, | 124 | }, |
| 117 | "the TSA's time source is not available" }, | 125 | { |
| 118 | { TS_INFO_UNACCEPTED_POLICY, | 126 | TS_INFO_UNACCEPTED_POLICY, |
| 119 | "the requested TSA policy is not supported by the TSA" }, | 127 | "the requested TSA policy is not supported by the TSA" |
| 120 | { TS_INFO_UNACCEPTED_EXTENSION, | 128 | }, |
| 121 | "the requested extension is not supported by the TSA" }, | 129 | { |
| 122 | { TS_INFO_ADD_INFO_NOT_AVAILABLE, | 130 | TS_INFO_UNACCEPTED_EXTENSION, |
| 123 | "the additional information requested could not be understood " | 131 | "the requested extension is not supported by the TSA" |
| 124 | "or is not available" }, | 132 | }, |
| 125 | { TS_INFO_SYSTEM_FAILURE, | 133 | { |
| 126 | "the request cannot be handled due to system failure" }, | 134 | TS_INFO_ADD_INFO_NOT_AVAILABLE, |
| 135 | "the additional information requested could not be understood " | ||
| 136 | "or is not available" | ||
| 137 | }, | ||
| 138 | { | ||
| 139 | TS_INFO_SYSTEM_FAILURE, | ||
| 140 | "the request cannot be handled due to system failure" | ||
| 141 | }, | ||
| 127 | { -1, NULL } | 142 | { -1, NULL } |
| 128 | }; | 143 | }; |
| 129 | long status; | 144 | long status; |
| 130 | int i, lines = 0; | 145 | int i, lines = 0; |
| 131 | 146 | ||
| 132 | /* Printing status code. */ | 147 | /* Printing status code. */ |
| 133 | BIO_printf(bio, "Status: "); | 148 | BIO_printf(bio, "Status: "); |
| 134 | status = ASN1_INTEGER_get(a->status); | 149 | status = ASN1_INTEGER_get(a->status); |
| 135 | if (0 <= status && status < (long)(sizeof(status_map)/sizeof(status_map[0]))) | 150 | if (0 <= status && |
| 151 | status < (long)(sizeof(status_map) / sizeof(status_map[0]))) | ||
| 136 | BIO_printf(bio, "%s\n", status_map[status]); | 152 | BIO_printf(bio, "%s\n", status_map[status]); |
| 137 | else | 153 | else |
| 138 | BIO_printf(bio, "out of bounds\n"); | 154 | BIO_printf(bio, "out of bounds\n"); |
| 139 | 155 | ||
| 140 | /* Printing status description. */ | 156 | /* Printing status description. */ |
| 141 | BIO_printf(bio, "Status description: "); | 157 | BIO_printf(bio, "Status description: "); |
| 142 | for (i = 0; i < sk_ASN1_UTF8STRING_num(a->text); ++i) | 158 | for (i = 0; i < sk_ASN1_UTF8STRING_num(a->text); ++i) { |
| 143 | { | ||
| 144 | if (i > 0) | 159 | if (i > 0) |
| 145 | BIO_puts(bio, "\t"); | 160 | BIO_puts(bio, "\t"); |
| 146 | ASN1_STRING_print_ex(bio, sk_ASN1_UTF8STRING_value(a->text, i), | 161 | ASN1_STRING_print_ex(bio, sk_ASN1_UTF8STRING_value(a->text, i), |
| 147 | 0); | 162 | 0); |
| 148 | BIO_puts(bio, "\n"); | 163 | BIO_puts(bio, "\n"); |
| 149 | } | 164 | } |
| 150 | if (i == 0) | 165 | if (i == 0) |
| 151 | BIO_printf(bio, "unspecified\n"); | 166 | BIO_printf(bio, "unspecified\n"); |
| 152 | 167 | ||
| 153 | /* Printing failure information. */ | 168 | /* Printing failure information. */ |
| 154 | BIO_printf(bio, "Failure info: "); | 169 | BIO_printf(bio, "Failure info: "); |
| 155 | if (a->failure_info != NULL) | 170 | if (a->failure_info != NULL) |
| 156 | lines = TS_status_map_print(bio, failure_map, | 171 | lines = TS_status_map_print(bio, failure_map, a->failure_info); |
| 157 | a->failure_info); | ||
| 158 | if (lines == 0) | 172 | if (lines == 0) |
| 159 | BIO_printf(bio, "unspecified"); | 173 | BIO_printf(bio, "unspecified"); |
| 160 | BIO_printf(bio, "\n"); | 174 | BIO_printf(bio, "\n"); |
| 161 | 175 | ||
| 162 | return 1; | 176 | return 1; |
| 163 | } | 177 | } |
| 164 | 178 | ||
| 165 | static int TS_status_map_print(BIO *bio, struct status_map_st *a, | 179 | static int |
| 166 | ASN1_BIT_STRING *v) | 180 | TS_status_map_print(BIO *bio, struct status_map_st *a, ASN1_BIT_STRING *v) |
| 167 | { | 181 | { |
| 168 | int lines = 0; | 182 | int lines = 0; |
| 169 | 183 | ||
| 170 | for (; a->bit >= 0; ++a) | 184 | for (; a->bit >= 0; ++a) { |
| 171 | { | 185 | if (ASN1_BIT_STRING_get_bit(v, a->bit)) { |
| 172 | if (ASN1_BIT_STRING_get_bit(v, a->bit)) | ||
| 173 | { | ||
| 174 | if (++lines > 1) | 186 | if (++lines > 1) |
| 175 | BIO_printf(bio, ", "); | 187 | BIO_printf(bio, ", "); |
| 176 | BIO_printf(bio, "%s", a->text); | 188 | BIO_printf(bio, "%s", a->text); |
| 177 | } | ||
| 178 | } | 189 | } |
| 190 | } | ||
| 179 | 191 | ||
| 180 | return lines; | 192 | return lines; |
| 181 | } | 193 | } |
| 182 | 194 | ||
| 183 | int TS_TST_INFO_print_bio(BIO *bio, TS_TST_INFO *a) | 195 | int |
| 184 | { | 196 | TS_TST_INFO_print_bio(BIO *bio, TS_TST_INFO *a) |
| 197 | { | ||
| 185 | int v; | 198 | int v; |
| 186 | ASN1_OBJECT *policy_id; | 199 | ASN1_OBJECT *policy_id; |
| 187 | const ASN1_INTEGER *serial; | 200 | const ASN1_INTEGER *serial; |
| @@ -190,7 +203,8 @@ int TS_TST_INFO_print_bio(BIO *bio, TS_TST_INFO *a) | |||
| 190 | const ASN1_INTEGER *nonce; | 203 | const ASN1_INTEGER *nonce; |
| 191 | GENERAL_NAME *tsa_name; | 204 | GENERAL_NAME *tsa_name; |
| 192 | 205 | ||
| 193 | if (a == NULL) return 0; | 206 | if (a == NULL) |
| 207 | return 0; | ||
| 194 | 208 | ||
| 195 | /* Print version. */ | 209 | /* Print version. */ |
| 196 | v = TS_TST_INFO_get_version(a); | 210 | v = TS_TST_INFO_get_version(a); |
| @@ -229,8 +243,8 @@ int TS_TST_INFO_print_bio(BIO *bio, TS_TST_INFO *a) | |||
| 229 | BIO_write(bio, "\n", 1); | 243 | BIO_write(bio, "\n", 1); |
| 230 | 244 | ||
| 231 | /* Print ordering. */ | 245 | /* Print ordering. */ |
| 232 | BIO_printf(bio, "Ordering: %s\n", | 246 | BIO_printf(bio, "Ordering: %s\n", |
| 233 | TS_TST_INFO_get_ordering(a) ? "yes" : "no"); | 247 | TS_TST_INFO_get_ordering(a) ? "yes" : "no"); |
| 234 | 248 | ||
| 235 | /* Print nonce. */ | 249 | /* Print nonce. */ |
| 236 | BIO_printf(bio, "Nonce: "); | 250 | BIO_printf(bio, "Nonce: "); |
| @@ -246,23 +260,23 @@ int TS_TST_INFO_print_bio(BIO *bio, TS_TST_INFO *a) | |||
| 246 | tsa_name = TS_TST_INFO_get_tsa(a); | 260 | tsa_name = TS_TST_INFO_get_tsa(a); |
| 247 | if (tsa_name == NULL) | 261 | if (tsa_name == NULL) |
| 248 | BIO_printf(bio, "unspecified"); | 262 | BIO_printf(bio, "unspecified"); |
| 249 | else | 263 | else { |
| 250 | { | ||
| 251 | STACK_OF(CONF_VALUE) *nval; | 264 | STACK_OF(CONF_VALUE) *nval; |
| 252 | if ((nval = i2v_GENERAL_NAME(NULL, tsa_name, NULL))) | 265 | if ((nval = i2v_GENERAL_NAME(NULL, tsa_name, NULL))) |
| 253 | X509V3_EXT_val_prn(bio, nval, 0, 0); | 266 | X509V3_EXT_val_prn(bio, nval, 0, 0); |
| 254 | sk_CONF_VALUE_pop_free(nval, X509V3_conf_free); | 267 | sk_CONF_VALUE_pop_free(nval, X509V3_conf_free); |
| 255 | } | 268 | } |
| 256 | BIO_write(bio, "\n", 1); | 269 | BIO_write(bio, "\n", 1); |
| 257 | 270 | ||
| 258 | /* Print extensions. */ | 271 | /* Print extensions. */ |
| 259 | TS_ext_print_bio(bio, TS_TST_INFO_get_exts(a)); | 272 | TS_ext_print_bio(bio, TS_TST_INFO_get_exts(a)); |
| 260 | 273 | ||
| 261 | return 1; | 274 | return 1; |
| 262 | } | 275 | } |
| 263 | 276 | ||
| 264 | static int TS_ACCURACY_print_bio(BIO *bio, const TS_ACCURACY *accuracy) | 277 | static int |
| 265 | { | 278 | TS_ACCURACY_print_bio(BIO *bio, const TS_ACCURACY *accuracy) |
| 279 | { | ||
| 266 | const ASN1_INTEGER *seconds = TS_ACCURACY_get_seconds(accuracy); | 280 | const ASN1_INTEGER *seconds = TS_ACCURACY_get_seconds(accuracy); |
| 267 | const ASN1_INTEGER *millis = TS_ACCURACY_get_millis(accuracy); | 281 | const ASN1_INTEGER *millis = TS_ACCURACY_get_millis(accuracy); |
| 268 | const ASN1_INTEGER *micros = TS_ACCURACY_get_micros(accuracy); | 282 | const ASN1_INTEGER *micros = TS_ACCURACY_get_micros(accuracy); |
| @@ -284,4 +298,4 @@ static int TS_ACCURACY_print_bio(BIO *bio, const TS_ACCURACY *accuracy) | |||
| 284 | BIO_printf(bio, " micros"); | 298 | BIO_printf(bio, " micros"); |
| 285 | 299 | ||
| 286 | return 1; | 300 | return 1; |
| 287 | } | 301 | } |
