OpenCoverage

ct_policy.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/ct/ct_policy.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
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 */-
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#include <time.h>-
17-
18#include "ct_locl.h"-
19-
20/*-
21 * Number of seconds in the future that an SCT timestamp can be, by default,-
22 * without being considered invalid. This is added to time() when setting a-
23 * default value for CT_POLICY_EVAL_CTX.epoch_time_in_ms.-
24 * It can be overridden by calling CT_POLICY_EVAL_CTX_set_time().-
25 */-
26static const time_t SCT_CLOCK_DRIFT_TOLERANCE = 300;-
27-
28CT_POLICY_EVAL_CTX *CT_POLICY_EVAL_CTX_new(void)-
29{-
30 CT_POLICY_EVAL_CTX *ctx = OPENSSL_zalloc(sizeof(CT_POLICY_EVAL_CTX));-
31-
32 if (ctx == NULL) {
ctx == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 15 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-15
33 CTerr(CT_F_CT_POLICY_EVAL_CTX_NEW, ERR_R_MALLOC_FAILURE);-
34 return NULL;
never executed: return ((void *)0) ;
0
35 }-
36-
37 /* time(NULL) shouldn't ever fail, so don't bother checking for -1. */-
38 ctx->epoch_time_in_ms = (uint64_t)(time(NULL) + SCT_CLOCK_DRIFT_TOLERANCE) *-
39 1000;-
40-
41 return ctx;
executed 15 times by 1 test: return ctx;
Executed by:
  • libcrypto.so.1.1
15
42}-
43-
44void CT_POLICY_EVAL_CTX_free(CT_POLICY_EVAL_CTX *ctx)-
45{-
46 if (ctx == NULL)
ctx == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 15 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-15
47 return;
never executed: return;
0
48 X509_free(ctx->cert);-
49 X509_free(ctx->issuer);-
50 OPENSSL_free(ctx);-
51}
executed 15 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
15
52-
53int CT_POLICY_EVAL_CTX_set1_cert(CT_POLICY_EVAL_CTX *ctx, X509 *cert)-
54{-
55 if (!X509_up_ref(cert))
!X509_up_ref(cert)Description
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-12
56 return 0;
never executed: return 0;
0
57 ctx->cert = cert;-
58 return 1;
executed 12 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
12
59}-
60-
61int CT_POLICY_EVAL_CTX_set1_issuer(CT_POLICY_EVAL_CTX *ctx, X509 *issuer)-
62{-
63 if (!X509_up_ref(issuer))
!X509_up_ref(issuer)Description
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • libcrypto.so.1.1
0-12
64 return 0;
never executed: return 0;
0
65 ctx->issuer = issuer;-
66 return 1;
executed 12 times by 1 test: return 1;
Executed by:
  • libcrypto.so.1.1
12
67}-
68-
69void CT_POLICY_EVAL_CTX_set_shared_CTLOG_STORE(CT_POLICY_EVAL_CTX *ctx,-
70 CTLOG_STORE *log_store)-
71{-
72 ctx->log_store = log_store;-
73}
executed 14 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
14
74-
75void CT_POLICY_EVAL_CTX_set_time(CT_POLICY_EVAL_CTX *ctx, uint64_t time_in_ms)-
76{-
77 ctx->epoch_time_in_ms = time_in_ms;-
78}
executed 14 times by 1 test: end of block
Executed by:
  • libcrypto.so.1.1
14
79-
80X509* CT_POLICY_EVAL_CTX_get0_cert(const CT_POLICY_EVAL_CTX *ctx)-
81{-
82 return ctx->cert;
never executed: return ctx->cert;
0
83}-
84-
85X509* CT_POLICY_EVAL_CTX_get0_issuer(const CT_POLICY_EVAL_CTX *ctx)-
86{-
87 return ctx->issuer;
never executed: return ctx->issuer;
0
88}-
89-
90const CTLOG_STORE *CT_POLICY_EVAL_CTX_get0_log_store(const CT_POLICY_EVAL_CTX *ctx)-
91{-
92 return ctx->log_store;
never executed: return ctx->log_store;
0
93}-
94-
95uint64_t CT_POLICY_EVAL_CTX_get_time(const CT_POLICY_EVAL_CTX *ctx)-
96{-
97 return ctx->epoch_time_in_ms;
executed 1 time by 1 test: return ctx->epoch_time_in_ms;
Executed by:
  • libcrypto.so.1.1
1
98}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2