]>
Commit | Line | Data |
---|---|---|
7d054e5a | 1 | /* |
d2e9e320 RS |
2 | * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. |
3 | * | |
4 | * Licensed under the OpenSSL license (the "License"). You may not use | |
5 | * this file except in compliance with the License. You can obtain a copy | |
6 | * in the file LICENSE in the source distribution or at | |
7 | * https://www.openssl.org/source/license.html | |
8 | */ | |
7d054e5a RP |
9 | |
10 | #ifdef OPENSSL_NO_CT | |
11 | # error "CT is disabled" | |
12 | #endif | |
13 | ||
14 | #include <openssl/ct.h> | |
15 | #include <openssl/err.h> | |
16 | ||
17 | #include "ct_locl.h" | |
18 | ||
19 | CT_POLICY_EVAL_CTX *CT_POLICY_EVAL_CTX_new(void) | |
20 | { | |
21 | CT_POLICY_EVAL_CTX *ctx = OPENSSL_zalloc(sizeof(CT_POLICY_EVAL_CTX)); | |
22 | ||
23 | if (ctx == NULL) { | |
24 | CTerr(CT_F_CT_POLICY_EVAL_CTX_NEW, ERR_R_MALLOC_FAILURE); | |
25 | return NULL; | |
26 | } | |
27 | ||
28 | return ctx; | |
29 | } | |
30 | ||
31 | void CT_POLICY_EVAL_CTX_free(CT_POLICY_EVAL_CTX *ctx) | |
32 | { | |
2b201c5c MC |
33 | if (ctx == NULL) |
34 | return; | |
a1bb7708 RP |
35 | X509_free(ctx->cert); |
36 | X509_free(ctx->issuer); | |
7d054e5a RP |
37 | OPENSSL_free(ctx); |
38 | } | |
39 | ||
11c68cea | 40 | int CT_POLICY_EVAL_CTX_set1_cert(CT_POLICY_EVAL_CTX *ctx, X509 *cert) |
7d054e5a | 41 | { |
11c68cea RP |
42 | if (!X509_up_ref(cert)) |
43 | return 0; | |
44 | ctx->cert = cert; | |
45 | return 1; | |
7d054e5a RP |
46 | } |
47 | ||
11c68cea | 48 | int CT_POLICY_EVAL_CTX_set1_issuer(CT_POLICY_EVAL_CTX *ctx, X509 *issuer) |
7d054e5a | 49 | { |
11c68cea RP |
50 | if (!X509_up_ref(issuer)) |
51 | return 0; | |
52 | ctx->issuer = issuer; | |
53 | return 1; | |
7d054e5a RP |
54 | } |
55 | ||
a1bb7708 RP |
56 | void CT_POLICY_EVAL_CTX_set_shared_CTLOG_STORE(CT_POLICY_EVAL_CTX *ctx, |
57 | CTLOG_STORE *log_store) | |
7d054e5a RP |
58 | { |
59 | ctx->log_store = log_store; | |
60 | } | |
61 | ||
1fa9ffd9 RP |
62 | void CT_POLICY_EVAL_CTX_set_time(CT_POLICY_EVAL_CTX *ctx, uint64_t time_in_ms) |
63 | { | |
64 | ctx->epoch_time_in_ms = time_in_ms; | |
65 | } | |
66 | ||
680ddc99 | 67 | X509* CT_POLICY_EVAL_CTX_get0_cert(const CT_POLICY_EVAL_CTX *ctx) |
7d054e5a RP |
68 | { |
69 | return ctx->cert; | |
70 | } | |
71 | ||
680ddc99 | 72 | X509* CT_POLICY_EVAL_CTX_get0_issuer(const CT_POLICY_EVAL_CTX *ctx) |
7d054e5a RP |
73 | { |
74 | return ctx->issuer; | |
75 | } | |
76 | ||
680ddc99 | 77 | const CTLOG_STORE *CT_POLICY_EVAL_CTX_get0_log_store(const CT_POLICY_EVAL_CTX *ctx) |
7d054e5a RP |
78 | { |
79 | return ctx->log_store; | |
80 | } | |
81 | ||
1fa9ffd9 RP |
82 | uint64_t CT_POLICY_EVAL_CTX_get_time(const CT_POLICY_EVAL_CTX *ctx) |
83 | { | |
84 | return ctx->epoch_time_in_ms; | |
85 | } |