75 static int TS_check_status_info(
TS_RESP *response);
80 unsigned char **imprint,
unsigned *imprint_len);
81 static int TS_check_imprints(
X509_ALGOR *algor_a,
82 unsigned char *imprint_a,
unsigned len_a,
93 static const char *TS_status_text[] =
99 "revocationNotification" };
101 #define TS_STATUS_TEXT_SIZE (sizeof(TS_status_text)/sizeof(*TS_status_text))
107 #define TS_STATUS_BUF_SIZE 256
113 } TS_failure_info[] =
123 #define TS_FAILURE_INFO_SIZE (sizeof(TS_failure_info) / \
124 sizeof(*TS_failure_info))
149 int i, j = 0, ret = 0;
167 sinfos = PKCS7_get_signer_info(token);
185 signers = PKCS7_get0_signers(token, certs, 0);
186 if (!signers ||
sk_X509_num(signers) != 1)
goto err;
190 if (!TS_verify_cert(store, certs, signer, &chain))
goto err;
194 if (!TS_check_signing_certs(si, chain))
goto err;
200 while ((i =
BIO_read(p7bio,buf,
sizeof(buf))) > 0);
213 *signer_out = signer;
254 *chain = X509_STORE_CTX_get1_chain(&cert_ctx);
271 cert_ids = ss->cert_ids;
274 if (TS_find_cert(cert_ids, cert) != 0)
goto err;
284 if (TS_find_cert(cert_ids, cert) < 0)
goto err;
299 const unsigned char *
p;
302 if (!attr)
return NULL;
312 if (!cert_ids || !cert)
return -1;
329 if (!is || !TS_issuer_serial_cmp(is, cert->
cert_info))
369 if (!TS_check_status_info(response))
goto err;
372 if (!int_TS_RESP_verify_token(ctx, token, tst_info))
390 ret = int_TS_RESP_verify_token(ctx, token, tst_info);
414 unsigned char *imprint = NULL;
415 unsigned imprint_len = 0;
434 && !TS_check_policy(ctx->
policy, tst_info))
445 && (!TS_compute_imprint(ctx->
data, tst_info,
446 &md_alg, &imprint, &imprint_len)
447 || !TS_check_imprints(md_alg, imprint, imprint_len, tst_info)))
452 && !TS_check_nonces(ctx->
nonce, tst_info))
457 && tsa_name && !TS_check_signer_name(tsa_name, signer))
465 && !TS_check_signer_name(ctx->
tsa_name, signer))
474 X509_ALGOR_free(md_alg);
479 static int TS_check_status_info(
TS_RESP *response)
483 const char *status_text = NULL;
484 char *embedded_status_text = NULL;
488 if (status == 0 || status == 1)
return 1;
492 status_text = TS_status_text[status];
494 status_text =
"unknown code";
498 && !(embedded_status_text = TS_get_status_text(info->text)))
509 TS_failure_info[i].code))
512 strcpy(failure_text,
",");
515 strcat(failure_text, TS_failure_info[i].
text);
519 if (failure_text[0] ==
'\0')
520 strcpy(failure_text,
"unspecified");
525 "status code: ", status_text,
526 ", status text: ", embedded_status_text ?
527 embedded_status_text :
"unspecified",
528 ", failure codes: ", failure_text);
559 if (i > 0) *p++ =
'/';
573 if (
OBJ_cmp(req_oid, resp_oid) != 0)
584 unsigned char **imprint,
unsigned *imprint_len)
590 unsigned char buffer[4096];
619 while ((length =
BIO_read(data, buffer,
sizeof(buffer))) > 0)
629 X509_ALGOR_free(*md_alg);
635 static int TS_check_imprints(
X509_ALGOR *algor_a,
636 unsigned char *imprint_a,
unsigned len_a,
703 while (gen_names != NULL
704 && !(found = TS_find_name(gen_names, tsa_name) >= 0))
708 GENERAL_NAMES_free(gen_names);
712 if (gen_names) GENERAL_NAMES_free(gen_names);
727 return found ? i - 1 : -1;