2015-09-16 00:13:48 +08:00
|
|
|
/*
|
2021-03-11 21:27:36 +08:00
|
|
|
* Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
|
2015-09-16 00:13:48 +08:00
|
|
|
*
|
2018-12-06 20:34:58 +08:00
|
|
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
2016-05-18 02:51:26 +08:00
|
|
|
* 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
|
2015-09-16 00:13:48 +08:00
|
|
|
*/
|
|
|
|
|
2016-02-26 02:11:16 +08:00
|
|
|
#ifdef OPENSSL_NO_CT
|
|
|
|
# error "CT disabled"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <openssl/ct.h>
|
|
|
|
#include <openssl/err.h>
|
|
|
|
#include <openssl/evp.h>
|
|
|
|
#include <openssl/tls1.h>
|
|
|
|
#include <openssl/x509.h>
|
2015-09-16 00:13:48 +08:00
|
|
|
|
2019-09-28 06:45:40 +08:00
|
|
|
#include "ct_local.h"
|
2015-09-16 00:13:48 +08:00
|
|
|
|
|
|
|
SCT *SCT_new(void)
|
|
|
|
{
|
2016-03-01 04:25:08 +08:00
|
|
|
SCT *sct = OPENSSL_zalloc(sizeof(*sct));
|
2016-02-26 02:11:16 +08:00
|
|
|
|
2015-09-16 00:13:48 +08:00
|
|
|
if (sct == NULL) {
|
2020-11-04 19:23:19 +08:00
|
|
|
ERR_raise(ERR_LIB_CT, ERR_R_MALLOC_FAILURE);
|
2015-09-16 00:13:48 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
2016-02-26 02:11:16 +08:00
|
|
|
|
|
|
|
sct->entry_type = CT_LOG_ENTRY_TYPE_NOT_SET;
|
|
|
|
sct->version = SCT_VERSION_NOT_SET;
|
2015-09-16 00:13:48 +08:00
|
|
|
return sct;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SCT_free(SCT *sct)
|
|
|
|
{
|
2016-02-26 02:11:16 +08:00
|
|
|
if (sct == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
OPENSSL_free(sct->log_id);
|
|
|
|
OPENSSL_free(sct->ext);
|
|
|
|
OPENSSL_free(sct->sig);
|
|
|
|
OPENSSL_free(sct->sct);
|
|
|
|
OPENSSL_free(sct);
|
2015-09-16 00:13:48 +08:00
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:05 +08:00
|
|
|
void SCT_LIST_free(STACK_OF(SCT) *a)
|
|
|
|
{
|
|
|
|
sk_SCT_pop_free(a, SCT_free);
|
|
|
|
}
|
|
|
|
|
2015-09-16 00:13:48 +08:00
|
|
|
int SCT_set_version(SCT *sct, sct_version_t version)
|
|
|
|
{
|
2016-02-26 02:11:16 +08:00
|
|
|
if (version != SCT_VERSION_V1) {
|
2020-11-04 19:23:19 +08:00
|
|
|
ERR_raise(ERR_LIB_CT, CT_R_UNSUPPORTED_VERSION);
|
2015-09-16 00:13:48 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
sct->version = version;
|
2016-03-09 01:35:40 +08:00
|
|
|
sct->validation_status = SCT_VALIDATION_STATUS_NOT_SET;
|
2015-09-16 00:13:48 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2016-02-26 02:11:16 +08:00
|
|
|
int SCT_set_log_entry_type(SCT *sct, ct_log_entry_type_t entry_type)
|
2015-09-16 00:13:48 +08:00
|
|
|
{
|
2016-03-09 01:35:40 +08:00
|
|
|
sct->validation_status = SCT_VALIDATION_STATUS_NOT_SET;
|
|
|
|
|
2016-02-26 02:11:16 +08:00
|
|
|
switch (entry_type) {
|
|
|
|
case CT_LOG_ENTRY_TYPE_X509:
|
|
|
|
case CT_LOG_ENTRY_TYPE_PRECERT:
|
|
|
|
sct->entry_type = entry_type;
|
|
|
|
return 1;
|
2016-08-31 01:31:18 +08:00
|
|
|
case CT_LOG_ENTRY_TYPE_NOT_SET:
|
|
|
|
break;
|
2015-09-16 00:13:48 +08:00
|
|
|
}
|
2020-11-04 19:23:19 +08:00
|
|
|
ERR_raise(ERR_LIB_CT, CT_R_UNSUPPORTED_ENTRY_TYPE);
|
2016-08-31 01:31:18 +08:00
|
|
|
return 0;
|
2015-09-16 00:13:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int SCT_set0_log_id(SCT *sct, unsigned char *log_id, size_t log_id_len)
|
|
|
|
{
|
2016-02-26 02:11:16 +08:00
|
|
|
if (sct->version == SCT_VERSION_V1 && log_id_len != CT_V1_HASHLEN) {
|
2020-11-04 19:23:19 +08:00
|
|
|
ERR_raise(ERR_LIB_CT, CT_R_INVALID_LOG_ID_LENGTH);
|
2015-09-16 00:13:48 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-02-26 02:11:16 +08:00
|
|
|
|
2015-09-16 00:13:48 +08:00
|
|
|
OPENSSL_free(sct->log_id);
|
|
|
|
sct->log_id = log_id;
|
|
|
|
sct->log_id_len = log_id_len;
|
2016-03-09 01:35:40 +08:00
|
|
|
sct->validation_status = SCT_VALIDATION_STATUS_NOT_SET;
|
2015-09-16 00:13:48 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2015-12-05 02:49:14 +08:00
|
|
|
int SCT_set1_log_id(SCT *sct, const unsigned char *log_id, size_t log_id_len)
|
|
|
|
{
|
2016-02-26 02:11:16 +08:00
|
|
|
if (sct->version == SCT_VERSION_V1 && log_id_len != CT_V1_HASHLEN) {
|
2020-11-04 19:23:19 +08:00
|
|
|
ERR_raise(ERR_LIB_CT, CT_R_INVALID_LOG_ID_LENGTH);
|
2015-12-05 02:49:14 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
OPENSSL_free(sct->log_id);
|
2016-02-26 02:11:16 +08:00
|
|
|
sct->log_id = NULL;
|
|
|
|
sct->log_id_len = 0;
|
2016-03-09 01:35:40 +08:00
|
|
|
sct->validation_status = SCT_VALIDATION_STATUS_NOT_SET;
|
2015-12-05 02:49:14 +08:00
|
|
|
|
2016-02-26 02:11:16 +08:00
|
|
|
if (log_id != NULL && log_id_len > 0) {
|
|
|
|
sct->log_id = OPENSSL_memdup(log_id, log_id_len);
|
2015-12-05 02:49:14 +08:00
|
|
|
if (sct->log_id == NULL) {
|
2020-11-04 19:23:19 +08:00
|
|
|
ERR_raise(ERR_LIB_CT, ERR_R_MALLOC_FAILURE);
|
2015-12-05 02:49:14 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-02-26 02:11:16 +08:00
|
|
|
sct->log_id_len = log_id_len;
|
2015-12-05 02:49:14 +08:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-09-16 00:13:48 +08:00
|
|
|
void SCT_set_timestamp(SCT *sct, uint64_t timestamp)
|
|
|
|
{
|
|
|
|
sct->timestamp = timestamp;
|
2016-03-09 01:35:40 +08:00
|
|
|
sct->validation_status = SCT_VALIDATION_STATUS_NOT_SET;
|
2015-09-16 00:13:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int SCT_set_signature_nid(SCT *sct, int nid)
|
|
|
|
{
|
2016-07-29 03:15:52 +08:00
|
|
|
switch (nid) {
|
2015-09-16 00:13:48 +08:00
|
|
|
case NID_sha256WithRSAEncryption:
|
|
|
|
sct->hash_alg = TLSEXT_hash_sha256;
|
|
|
|
sct->sig_alg = TLSEXT_signature_rsa;
|
2016-03-09 01:35:40 +08:00
|
|
|
sct->validation_status = SCT_VALIDATION_STATUS_NOT_SET;
|
2015-09-16 00:13:48 +08:00
|
|
|
return 1;
|
|
|
|
case NID_ecdsa_with_SHA256:
|
|
|
|
sct->hash_alg = TLSEXT_hash_sha256;
|
|
|
|
sct->sig_alg = TLSEXT_signature_ecdsa;
|
2016-03-09 01:35:40 +08:00
|
|
|
sct->validation_status = SCT_VALIDATION_STATUS_NOT_SET;
|
2015-09-16 00:13:48 +08:00
|
|
|
return 1;
|
|
|
|
default:
|
2020-11-04 19:23:19 +08:00
|
|
|
ERR_raise(ERR_LIB_CT, CT_R_UNRECOGNIZED_SIGNATURE_NID);
|
2015-09-16 00:13:48 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SCT_set0_extensions(SCT *sct, unsigned char *ext, size_t ext_len)
|
|
|
|
{
|
|
|
|
OPENSSL_free(sct->ext);
|
|
|
|
sct->ext = ext;
|
|
|
|
sct->ext_len = ext_len;
|
2016-03-09 01:35:40 +08:00
|
|
|
sct->validation_status = SCT_VALIDATION_STATUS_NOT_SET;
|
2015-09-16 00:13:48 +08:00
|
|
|
}
|
|
|
|
|
2015-12-05 02:49:14 +08:00
|
|
|
int SCT_set1_extensions(SCT *sct, const unsigned char *ext, size_t ext_len)
|
|
|
|
{
|
|
|
|
OPENSSL_free(sct->ext);
|
|
|
|
sct->ext = NULL;
|
|
|
|
sct->ext_len = 0;
|
2016-03-09 01:35:40 +08:00
|
|
|
sct->validation_status = SCT_VALIDATION_STATUS_NOT_SET;
|
2015-12-05 02:49:14 +08:00
|
|
|
|
|
|
|
if (ext != NULL && ext_len > 0) {
|
|
|
|
sct->ext = OPENSSL_memdup(ext, ext_len);
|
|
|
|
if (sct->ext == NULL) {
|
2020-11-04 19:23:19 +08:00
|
|
|
ERR_raise(ERR_LIB_CT, ERR_R_MALLOC_FAILURE);
|
2015-12-05 02:49:14 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
sct->ext_len = ext_len;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2015-09-16 00:13:48 +08:00
|
|
|
void SCT_set0_signature(SCT *sct, unsigned char *sig, size_t sig_len)
|
|
|
|
{
|
|
|
|
OPENSSL_free(sct->sig);
|
|
|
|
sct->sig = sig;
|
|
|
|
sct->sig_len = sig_len;
|
2016-03-09 01:35:40 +08:00
|
|
|
sct->validation_status = SCT_VALIDATION_STATUS_NOT_SET;
|
2015-09-16 00:13:48 +08:00
|
|
|
}
|
|
|
|
|
2015-12-05 02:49:14 +08:00
|
|
|
int SCT_set1_signature(SCT *sct, const unsigned char *sig, size_t sig_len)
|
|
|
|
{
|
|
|
|
OPENSSL_free(sct->sig);
|
2016-02-26 02:11:16 +08:00
|
|
|
sct->sig = NULL;
|
|
|
|
sct->sig_len = 0;
|
2016-03-09 01:35:40 +08:00
|
|
|
sct->validation_status = SCT_VALIDATION_STATUS_NOT_SET;
|
2016-02-26 02:11:16 +08:00
|
|
|
|
|
|
|
if (sig != NULL && sig_len > 0) {
|
2015-12-05 02:49:14 +08:00
|
|
|
sct->sig = OPENSSL_memdup(sig, sig_len);
|
|
|
|
if (sct->sig == NULL) {
|
2020-11-04 19:23:19 +08:00
|
|
|
ERR_raise(ERR_LIB_CT, ERR_R_MALLOC_FAILURE);
|
2015-12-05 02:49:14 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2016-02-26 02:11:16 +08:00
|
|
|
sct->sig_len = sig_len;
|
2015-12-05 02:49:14 +08:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2015-09-16 00:13:48 +08:00
|
|
|
sct_version_t SCT_get_version(const SCT *sct)
|
|
|
|
{
|
|
|
|
return sct->version;
|
|
|
|
}
|
|
|
|
|
2016-02-26 02:11:16 +08:00
|
|
|
ct_log_entry_type_t SCT_get_log_entry_type(const SCT *sct)
|
2015-09-16 00:13:48 +08:00
|
|
|
{
|
|
|
|
return sct->entry_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t SCT_get0_log_id(const SCT *sct, unsigned char **log_id)
|
|
|
|
{
|
|
|
|
*log_id = sct->log_id;
|
|
|
|
return sct->log_id_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t SCT_get_timestamp(const SCT *sct)
|
|
|
|
{
|
|
|
|
return sct->timestamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
int SCT_get_signature_nid(const SCT *sct)
|
|
|
|
{
|
2016-02-26 02:11:16 +08:00
|
|
|
if (sct->version == SCT_VERSION_V1) {
|
2015-09-16 00:13:48 +08:00
|
|
|
if (sct->hash_alg == TLSEXT_hash_sha256) {
|
|
|
|
switch (sct->sig_alg) {
|
|
|
|
case TLSEXT_signature_ecdsa:
|
|
|
|
return NID_ecdsa_with_SHA256;
|
|
|
|
case TLSEXT_signature_rsa:
|
|
|
|
return NID_sha256WithRSAEncryption;
|
|
|
|
default:
|
|
|
|
return NID_undef;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NID_undef;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t SCT_get0_extensions(const SCT *sct, unsigned char **ext)
|
|
|
|
{
|
|
|
|
*ext = sct->ext;
|
|
|
|
return sct->ext_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t SCT_get0_signature(const SCT *sct, unsigned char **sig)
|
|
|
|
{
|
|
|
|
*sig = sct->sig;
|
|
|
|
return sct->sig_len;
|
|
|
|
}
|
|
|
|
|
2016-02-26 02:11:16 +08:00
|
|
|
int SCT_is_complete(const SCT *sct)
|
2015-12-05 02:49:14 +08:00
|
|
|
{
|
|
|
|
switch (sct->version) {
|
2016-02-26 02:11:16 +08:00
|
|
|
case SCT_VERSION_NOT_SET:
|
2015-12-05 02:49:14 +08:00
|
|
|
return 0;
|
2016-02-26 02:11:16 +08:00
|
|
|
case SCT_VERSION_V1:
|
|
|
|
return sct->log_id != NULL && SCT_signature_is_complete(sct);
|
2015-12-05 02:49:14 +08:00
|
|
|
default:
|
|
|
|
return sct->sct != NULL; /* Just need cached encoding */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-26 02:11:16 +08:00
|
|
|
int SCT_signature_is_complete(const SCT *sct)
|
|
|
|
{
|
|
|
|
return SCT_get_signature_nid(sct) != NID_undef &&
|
|
|
|
sct->sig != NULL && sct->sig_len > 0;
|
|
|
|
}
|
|
|
|
|
2016-02-25 21:33:48 +08:00
|
|
|
sct_source_t SCT_get_source(const SCT *sct)
|
|
|
|
{
|
|
|
|
return sct->source;
|
|
|
|
}
|
|
|
|
|
|
|
|
int SCT_set_source(SCT *sct, sct_source_t source)
|
|
|
|
{
|
|
|
|
sct->source = source;
|
2016-08-24 01:31:16 +08:00
|
|
|
sct->validation_status = SCT_VALIDATION_STATUS_NOT_SET;
|
2016-02-25 21:33:48 +08:00
|
|
|
switch (source) {
|
|
|
|
case SCT_SOURCE_TLS_EXTENSION:
|
|
|
|
case SCT_SOURCE_OCSP_STAPLED_RESPONSE:
|
|
|
|
return SCT_set_log_entry_type(sct, CT_LOG_ENTRY_TYPE_X509);
|
|
|
|
case SCT_SOURCE_X509V3_EXTENSION:
|
|
|
|
return SCT_set_log_entry_type(sct, CT_LOG_ENTRY_TYPE_PRECERT);
|
2016-08-31 01:31:18 +08:00
|
|
|
case SCT_SOURCE_UNKNOWN:
|
|
|
|
break;
|
2016-02-25 21:33:48 +08:00
|
|
|
}
|
2016-08-31 01:31:18 +08:00
|
|
|
/* if we aren't sure, leave the log entry type alone */
|
|
|
|
return 1;
|
2016-02-25 21:33:48 +08:00
|
|
|
}
|
|
|
|
|
2016-03-01 01:33:02 +08:00
|
|
|
sct_validation_status_t SCT_get_validation_status(const SCT *sct)
|
|
|
|
{
|
|
|
|
return sct->validation_status;
|
|
|
|
}
|
|
|
|
|
|
|
|
int SCT_validate(SCT *sct, const CT_POLICY_EVAL_CTX *ctx)
|
|
|
|
{
|
|
|
|
int is_sct_valid = -1;
|
|
|
|
SCT_CTX *sctx = NULL;
|
|
|
|
X509_PUBKEY *pub = NULL, *log_pkey = NULL;
|
2016-03-11 02:17:23 +08:00
|
|
|
const CTLOG *log;
|
2016-03-01 01:33:02 +08:00
|
|
|
|
2016-04-08 02:17:37 +08:00
|
|
|
/*
|
|
|
|
* With an unrecognized SCT version we don't know what such an SCT means,
|
|
|
|
* let alone validate one. So we return validation failure (0).
|
|
|
|
*/
|
2016-03-11 02:17:23 +08:00
|
|
|
if (sct->version != SCT_VERSION_V1) {
|
2016-03-01 01:33:02 +08:00
|
|
|
sct->validation_status = SCT_VALIDATION_STATUS_UNKNOWN_VERSION;
|
2016-04-08 02:17:37 +08:00
|
|
|
return 0;
|
2016-03-01 01:33:02 +08:00
|
|
|
}
|
|
|
|
|
2016-03-11 02:17:23 +08:00
|
|
|
log = CTLOG_STORE_get0_log_by_id(ctx->log_store,
|
|
|
|
sct->log_id, sct->log_id_len);
|
|
|
|
|
2016-04-08 02:17:37 +08:00
|
|
|
/* Similarly, an SCT from an unknown log also cannot be validated. */
|
2016-03-11 02:17:23 +08:00
|
|
|
if (log == NULL) {
|
2016-03-01 01:33:02 +08:00
|
|
|
sct->validation_status = SCT_VALIDATION_STATUS_UNKNOWN_LOG;
|
2016-04-08 02:17:37 +08:00
|
|
|
return 0;
|
2016-03-01 01:33:02 +08:00
|
|
|
}
|
|
|
|
|
2020-04-03 23:25:18 +08:00
|
|
|
sctx = SCT_CTX_new(ctx->libctx, ctx->propq);
|
2016-03-01 01:33:02 +08:00
|
|
|
if (sctx == NULL)
|
|
|
|
goto err;
|
|
|
|
|
2016-03-11 02:17:23 +08:00
|
|
|
if (X509_PUBKEY_set(&log_pkey, CTLOG_get0_public_key(log)) != 1)
|
2016-03-01 01:33:02 +08:00
|
|
|
goto err;
|
|
|
|
if (SCT_CTX_set1_pubkey(sctx, log_pkey) != 1)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
if (SCT_get_log_entry_type(sct) == CT_LOG_ENTRY_TYPE_PRECERT) {
|
|
|
|
EVP_PKEY *issuer_pkey;
|
|
|
|
|
|
|
|
if (ctx->issuer == NULL) {
|
|
|
|
sct->validation_status = SCT_VALIDATION_STATUS_UNVERIFIED;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
2016-03-07 20:38:49 +08:00
|
|
|
issuer_pkey = X509_get0_pubkey(ctx->issuer);
|
2016-03-01 01:33:02 +08:00
|
|
|
|
|
|
|
if (X509_PUBKEY_set(&pub, issuer_pkey) != 1)
|
|
|
|
goto err;
|
|
|
|
if (SCT_CTX_set1_issuer_pubkey(sctx, pub) != 1)
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2016-09-08 23:02:46 +08:00
|
|
|
SCT_CTX_set_time(sctx, ctx->epoch_time_in_ms);
|
|
|
|
|
2016-04-08 02:17:37 +08:00
|
|
|
/*
|
|
|
|
* XXX: Potential for optimization. This repeats some idempotent heavy
|
|
|
|
* lifting on the certificate for each candidate SCT, and appears to not
|
|
|
|
* use any information in the SCT itself, only the certificate is
|
2021-03-04 11:54:40 +08:00
|
|
|
* processed. So it may make more sense to do this just once, perhaps
|
2016-04-08 02:17:37 +08:00
|
|
|
* associated with the shared (by all SCTs) policy eval ctx.
|
|
|
|
*
|
|
|
|
* XXX: Failure here is global (SCT independent) and represents either an
|
|
|
|
* issue with the certificate (e.g. duplicate extensions) or an out of
|
|
|
|
* memory condition. When the certificate is incompatible with CT, we just
|
|
|
|
* mark the SCTs invalid, rather than report a failure to determine the
|
|
|
|
* validation status. That way, callbacks that want to do "soft" SCT
|
|
|
|
* processing will not abort handshakes with false positive internal
|
|
|
|
* errors. Since the function does not distinguish between certificate
|
|
|
|
* issues (peer's fault) and internal problems (out fault) the safe thing
|
|
|
|
* to do is to report a validation failure and let the callback or
|
|
|
|
* application decide what to do.
|
|
|
|
*/
|
2016-03-01 01:33:02 +08:00
|
|
|
if (SCT_CTX_set1_cert(sctx, ctx->cert, NULL) != 1)
|
2016-04-08 02:17:37 +08:00
|
|
|
sct->validation_status = SCT_VALIDATION_STATUS_UNVERIFIED;
|
|
|
|
else
|
2016-08-23 19:52:43 +08:00
|
|
|
sct->validation_status = SCT_CTX_verify(sctx, sct) == 1 ?
|
2016-03-01 01:33:02 +08:00
|
|
|
SCT_VALIDATION_STATUS_VALID : SCT_VALIDATION_STATUS_INVALID;
|
|
|
|
|
|
|
|
end:
|
|
|
|
is_sct_valid = sct->validation_status == SCT_VALIDATION_STATUS_VALID;
|
|
|
|
err:
|
|
|
|
X509_PUBKEY_free(pub);
|
|
|
|
X509_PUBKEY_free(log_pkey);
|
|
|
|
SCT_CTX_free(sctx);
|
|
|
|
|
|
|
|
return is_sct_valid;
|
|
|
|
}
|
|
|
|
|
|
|
|
int SCT_LIST_validate(const STACK_OF(SCT) *scts, CT_POLICY_EVAL_CTX *ctx)
|
|
|
|
{
|
|
|
|
int are_scts_valid = 1;
|
|
|
|
int sct_count = scts != NULL ? sk_SCT_num(scts) : 0;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < sct_count; ++i) {
|
|
|
|
int is_sct_valid = -1;
|
|
|
|
SCT *sct = sk_SCT_value(scts, i);
|
|
|
|
|
|
|
|
if (sct == NULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
is_sct_valid = SCT_validate(sct, ctx);
|
|
|
|
if (is_sct_valid < 0)
|
|
|
|
return is_sct_valid;
|
|
|
|
are_scts_valid &= is_sct_valid;
|
|
|
|
}
|
|
|
|
|
|
|
|
return are_scts_valid;
|
|
|
|
}
|