Calculate message digest for TSA for CMS_sign prior to CMS_final

0 投票
最新提问 用户: (200 分)

I have code to create CMS signature. It worked well now I need to add trusted timestamping.

BIO *data_output = BIO_new(BIO_s_mem());
const EVP_MD *sign_md = EVP_get_digestbyname(digest_name);

cms = CMS_sign(NULL, NULL, NULL, bio_in, flags);

for (size_t i = 0; i < m_signers.size(); i++) {
    int tflags = flags;

    SignerInfo si = m_signers[i];

    CMS_SignerInfo *signer_info = CMS_add1_signer(cms,
        si.m_x509, si.m_privateKey, sign_md, tflags);
    BOOST_ASSERT(signer_info != NULL);

    for (int c = 0; c < sk_X509_num(si.m_ca); c++) {
        X509* cert = sk_X509_value(si.m_ca, c);
        BOOST_ASSERT(CMS_add0_cert(cms, cert) != 0);

BOOST_ASSERT(CMS_final(cms, bio_in, NULL, flags) != 0);
BOOST_ASSERT(i2d_CMS_bio_stream(data_output, cms, bio_in, flags) != 0);

In order to talk to TSA, I need the digest value but there is no way to get the digest value until CMS_final is called. I could not locate the answer anywhere.

发表于 用户: (2.5k 分)
Email me offlist at noloader, gmail account.

登录 或者 注册 后回答这个问题。

欢迎来到 Security Q&A ,有什么不懂的可以尽管在这里提问,你将会收到社区其他成员的回答。