static TS_RESP *create_response(CONF *conf, const char *section, char *engine, char *queryfile, char *passin, char *inkey, const EVP_MD *md, char *signer, char *chain, const char *policy) { int ret = 0; TS_RESP *response = NULL; BIO *query_bio = NULL; TS_RESP_CTX *resp_ctx = NULL; if ((query_bio = BIO_new_file(queryfile, "rb")) == NULL) goto end; if ((section = TS_CONF_get_tsa_section(conf, section)) == NULL) goto end; if ((resp_ctx = TS_RESP_CTX_new()) == NULL) goto end; if (!TS_CONF_set_serial(conf, section, serial_cb, resp_ctx)) goto end; # ifndef OPENSSL_NO_ENGINE if (!TS_CONF_set_crypto_device(conf, section, engine)) goto end; # endif if (!TS_CONF_set_signer_cert(conf, section, signer, resp_ctx)) goto end; if (!TS_CONF_set_certs(conf, section, chain, resp_ctx)) goto end; if (!TS_CONF_set_signer_key(conf, section, inkey, passin, resp_ctx)) goto end; if (md) { if (!TS_RESP_CTX_set_signer_digest(resp_ctx, md)) goto end; } else if (!TS_CONF_set_signer_digest(conf, section, NULL, resp_ctx)) { goto end; } if (!TS_CONF_set_def_policy(conf, section, policy, resp_ctx)) goto end; if (!TS_CONF_set_policies(conf, section, resp_ctx)) goto end; if (!TS_CONF_set_digests(conf, section, resp_ctx)) goto end; if (!TS_CONF_set_accuracy(conf, section, resp_ctx)) goto end; if (!TS_CONF_set_clock_precision_digits(conf, section, resp_ctx)) goto end; if (!TS_CONF_set_ordering(conf, section, resp_ctx)) goto end; if (!TS_CONF_set_tsa_name(conf, section, resp_ctx)) goto end; if (!TS_CONF_set_ess_cert_id_chain(conf, section, resp_ctx)) goto end; if ((response = TS_RESP_create_response(resp_ctx, query_bio)) == NULL) goto end; ret = 1; end: if (!ret) { TS_RESP_free(response); response = NULL; } TS_RESP_CTX_free(resp_ctx); BIO_free_all(query_bio); return response; }
static TS_RESP * create_response(CONF * conf, const char *section, char *engine, char *queryfile, char *passin, char *inkey, char *signer, char *chain, const char *policy) { int ret = 0; TS_RESP *response = NULL; BIO *query_bio = NULL; TS_RESP_CTX *resp_ctx = NULL; if (!(query_bio = BIO_new_file(queryfile, "rb"))) goto end; /* Getting TSA configuration section. */ if (!(section = TS_CONF_get_tsa_section(conf, section))) goto end; /* Setting up response generation context. */ if (!(resp_ctx = TS_RESP_CTX_new())) goto end; /* Setting serial number provider callback. */ if (!TS_CONF_set_serial(conf, section, serial_cb, resp_ctx)) goto end; #ifndef OPENSSL_NO_ENGINE /* Setting default OpenSSL engine. */ if (!TS_CONF_set_crypto_device(conf, section, engine)) goto end; #endif /* Setting TSA signer certificate. */ if (!TS_CONF_set_signer_cert(conf, section, signer, resp_ctx)) goto end; /* Setting TSA signer certificate chain. */ if (!TS_CONF_set_certs(conf, section, chain, resp_ctx)) goto end; /* Setting TSA signer private key. */ if (!TS_CONF_set_signer_key(conf, section, inkey, passin, resp_ctx)) goto end; /* Setting default policy OID. */ if (!TS_CONF_set_def_policy(conf, section, policy, resp_ctx)) goto end; /* Setting acceptable policy OIDs. */ if (!TS_CONF_set_policies(conf, section, resp_ctx)) goto end; /* Setting the acceptable one-way hash algorithms. */ if (!TS_CONF_set_digests(conf, section, resp_ctx)) goto end; /* Setting guaranteed time stamp accuracy. */ if (!TS_CONF_set_accuracy(conf, section, resp_ctx)) goto end; /* Setting the precision of the time. */ if (!TS_CONF_set_clock_precision_digits(conf, section, resp_ctx)) goto end; /* Setting the ordering flaf if requested. */ if (!TS_CONF_set_ordering(conf, section, resp_ctx)) goto end; /* Setting the TSA name required flag if requested. */ if (!TS_CONF_set_tsa_name(conf, section, resp_ctx)) goto end; /* Setting the ESS cert id chain flag if requested. */ if (!TS_CONF_set_ess_cert_id_chain(conf, section, resp_ctx)) goto end; /* Creating the response. */ if (!(response = TS_RESP_create_response(resp_ctx, query_bio))) goto end; ret = 1; end: if (!ret) { TS_RESP_free(response); response = NULL; } TS_RESP_CTX_free(resp_ctx); BIO_free_all(query_bio); return response; }