2016-02-29 17:33:02 +00:00
|
|
|
/*
|
2016-05-17 18:51:26 +00:00
|
|
|
* Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
|
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
|
|
* in the file LICENSE in the source distribution or at
|
|
|
|
* https://www.openssl.org/source/license.html
|
|
|
|
*/
|
2016-02-29 17:33:02 +00:00
|
|
|
|
|
|
|
#ifdef OPENSSL_NO_CT
|
|
|
|
# error "CT is disabled"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <openssl/ct.h>
|
|
|
|
#include <openssl/err.h>
|
|
|
|
|
|
|
|
#include "ct_locl.h"
|
|
|
|
|
|
|
|
CT_POLICY_EVAL_CTX *CT_POLICY_EVAL_CTX_new(void)
|
|
|
|
{
|
|
|
|
CT_POLICY_EVAL_CTX *ctx = OPENSSL_zalloc(sizeof(CT_POLICY_EVAL_CTX));
|
|
|
|
|
|
|
|
if (ctx == NULL) {
|
|
|
|
CTerr(CT_F_CT_POLICY_EVAL_CTX_NEW, ERR_R_MALLOC_FAILURE);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ctx;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CT_POLICY_EVAL_CTX_free(CT_POLICY_EVAL_CTX *ctx)
|
|
|
|
{
|
2016-08-22 21:21:30 +00:00
|
|
|
if (ctx == NULL)
|
|
|
|
return;
|
2016-08-05 13:17:31 +00:00
|
|
|
X509_free(ctx->cert);
|
|
|
|
X509_free(ctx->issuer);
|
2016-02-29 17:33:02 +00:00
|
|
|
OPENSSL_free(ctx);
|
|
|
|
}
|
|
|
|
|
2016-08-15 13:47:02 +00:00
|
|
|
int CT_POLICY_EVAL_CTX_set1_cert(CT_POLICY_EVAL_CTX *ctx, X509 *cert)
|
2016-02-29 17:33:02 +00:00
|
|
|
{
|
2016-08-15 13:47:02 +00:00
|
|
|
if (!X509_up_ref(cert))
|
|
|
|
return 0;
|
|
|
|
ctx->cert = cert;
|
|
|
|
return 1;
|
2016-02-29 17:33:02 +00:00
|
|
|
}
|
|
|
|
|
2016-08-15 13:47:02 +00:00
|
|
|
int CT_POLICY_EVAL_CTX_set1_issuer(CT_POLICY_EVAL_CTX *ctx, X509 *issuer)
|
2016-02-29 17:33:02 +00:00
|
|
|
{
|
2016-08-15 13:47:02 +00:00
|
|
|
if (!X509_up_ref(issuer))
|
|
|
|
return 0;
|
|
|
|
ctx->issuer = issuer;
|
|
|
|
return 1;
|
2016-02-29 17:33:02 +00:00
|
|
|
}
|
|
|
|
|
2016-08-05 13:17:31 +00:00
|
|
|
void CT_POLICY_EVAL_CTX_set_shared_CTLOG_STORE(CT_POLICY_EVAL_CTX *ctx,
|
|
|
|
CTLOG_STORE *log_store)
|
2016-02-29 17:33:02 +00:00
|
|
|
{
|
|
|
|
ctx->log_store = log_store;
|
|
|
|
}
|
|
|
|
|
2016-03-10 23:26:41 +00:00
|
|
|
X509* CT_POLICY_EVAL_CTX_get0_cert(const CT_POLICY_EVAL_CTX *ctx)
|
2016-02-29 17:33:02 +00:00
|
|
|
{
|
|
|
|
return ctx->cert;
|
|
|
|
}
|
|
|
|
|
2016-03-10 23:26:41 +00:00
|
|
|
X509* CT_POLICY_EVAL_CTX_get0_issuer(const CT_POLICY_EVAL_CTX *ctx)
|
2016-02-29 17:33:02 +00:00
|
|
|
{
|
|
|
|
return ctx->issuer;
|
|
|
|
}
|
|
|
|
|
2016-03-10 23:26:41 +00:00
|
|
|
const CTLOG_STORE *CT_POLICY_EVAL_CTX_get0_log_store(const CT_POLICY_EVAL_CTX *ctx)
|
2016-02-29 17:33:02 +00:00
|
|
|
{
|
|
|
|
return ctx->log_store;
|
|
|
|
}
|
|
|
|
|