static int ts_verify_cert(X509_STORE *store, STACK_OF(X509) *untrusted,
                          X509 *signer, STACK_OF(X509) **chain)
{
    X509_STORE_CTX *cert_ctx = NULL;
    int i;
    int ret = 0;
    *chain = NULL;
    cert_ctx = X509_STORE_CTX_new();
    if (cert_ctx == NULL) {
        TSerr(TS_F_TS_VERIFY_CERT, ERR_R_MALLOC_FAILURE);
        goto err;
    }
    if (!X509_STORE_CTX_init(cert_ctx, store, signer, untrusted))
        goto end;
    X509_STORE_CTX_set_purpose(cert_ctx, X509_PURPOSE_TIMESTAMP_SIGN);
    i = X509_verify_cert(cert_ctx);
    if (i <= 0) {
        int j = X509_STORE_CTX_get_error(cert_ctx);
        TSerr(TS_F_TS_VERIFY_CERT, TS_R_CERTIFICATE_VERIFY_ERROR);
        ERR_add_error_data(2, "Verify error:",
                           X509_verify_cert_error_string(j));
        goto err;
    }
    *chain = X509_STORE_CTX_get1_chain(cert_ctx);
    ret = 1;
    goto end;
err:
    ret = 0;
end:
    X509_STORE_CTX_free(cert_ctx);
    return ret;
}
['static int ts_verify_cert(X509_STORE *store, STACK_OF(X509) *untrusted,\n                          X509 *signer, STACK_OF(X509) **chain)\n{\n    X509_STORE_CTX *cert_ctx = NULL;\n    int i;\n    int ret = 0;\n    *chain = NULL;\n    cert_ctx = X509_STORE_CTX_new();\n    if (cert_ctx == NULL) {\n        TSerr(TS_F_TS_VERIFY_CERT, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    if (!X509_STORE_CTX_init(cert_ctx, store, signer, untrusted))\n        goto end;\n    X509_STORE_CTX_set_purpose(cert_ctx, X509_PURPOSE_TIMESTAMP_SIGN);\n    i = X509_verify_cert(cert_ctx);\n    if (i <= 0) {\n        int j = X509_STORE_CTX_get_error(cert_ctx);\n        TSerr(TS_F_TS_VERIFY_CERT, TS_R_CERTIFICATE_VERIFY_ERROR);\n        ERR_add_error_data(2, "Verify error:",\n                           X509_verify_cert_error_string(j));\n        goto err;\n    }\n    *chain = X509_STORE_CTX_get1_chain(cert_ctx);\n    ret = 1;\n    goto end;\nerr:\n    ret = 0;\nend:\n    X509_STORE_CTX_free(cert_ctx);\n    return ret;\n}', 'X509_STORE_CTX *X509_STORE_CTX_new(void)\n{\n    X509_STORE_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));\n    if (ctx == NULL) {\n        X509err(X509_F_X509_STORE_CTX_NEW, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\n    return ctx;\n}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\n    FAILTEST();\n    if (ret != NULL)\n        memset(ret, 0, num);\n    return ret;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\n    if (num == 0)\n        return NULL;\n    FAILTEST();\n    allow_customize = 0;\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);\n        ret = malloc(num);\n        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);\n    } else {\n        ret = malloc(num);\n    }\n#else\n    osslargused(file); osslargused(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}', 'void X509_STORE_CTX_free(X509_STORE_CTX *ctx)\n{\n    if (ctx == NULL)\n        return;\n    X509_STORE_CTX_cleanup(ctx);\n    OPENSSL_free(ctx);\n}', 'void CRYPTO_free(void *str, const char *file, int line)\n{\n    if (free_impl != NULL && free_impl != &CRYPTO_free) {\n        free_impl(str, file, line);\n        return;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_free(str, 0, file, line);\n        free(str);\n        CRYPTO_mem_debug_free(str, 1, file, line);\n    } else {\n        free(str);\n    }\n#else\n    free(str);\n#endif\n}']