Latest update.
This commit is contained in:
@@ -12,6 +12,6 @@ SOURCE[../../libcrypto]=\
|
||||
v3_prn.c v3_utl.c v3err.c v3_genn.c v3_alt.c v3_skey.c v3_akey.c \
|
||||
v3_pku.c v3_int.c v3_enum.c v3_sxnet.c v3_cpols.c v3_crld.c v3_purp.c \
|
||||
v3_info.c v3_akeya.c v3_pmaps.c v3_pcons.c v3_ncons.c \
|
||||
v3_pcia.c v3_pci.c \
|
||||
v3_pcia.c v3_pci.c v3_ist.c \
|
||||
pcy_cache.c pcy_node.c pcy_data.c pcy_map.c pcy_tree.c pcy_lib.c \
|
||||
v3_asid.c v3_addr.c v3_tlsf.c v3_admis.c
|
||||
@@ -45,7 +45,7 @@ static int new_dir(X509_LOOKUP *lu);
|
||||
static void free_dir(X509_LOOKUP *lu);
|
||||
static int add_cert_dir(BY_DIR *ctx, const char *dir, int type);
|
||||
static int get_cert_by_subject(X509_LOOKUP *xl, X509_LOOKUP_TYPE type,
|
||||
X509_NAME *name, X509_OBJECT *ret);
|
||||
const X509_NAME *name, X509_OBJECT *ret);
|
||||
static X509_LOOKUP_METHOD x509_dir_lookup = {
|
||||
"Load certs from files in a directory",
|
||||
new_dir, /* new_item */
|
||||
@@ -209,7 +209,7 @@ static int add_cert_dir(BY_DIR *ctx, const char *dir, int type)
|
||||
}
|
||||
|
||||
static int get_cert_by_subject(X509_LOOKUP *xl, X509_LOOKUP_TYPE type,
|
||||
X509_NAME *name, X509_OBJECT *ret)
|
||||
const X509_NAME *name, X509_OBJECT *ret)
|
||||
{
|
||||
BY_DIR *ctx;
|
||||
union {
|
||||
@@ -228,11 +228,11 @@ static int get_cert_by_subject(X509_LOOKUP *xl, X509_LOOKUP_TYPE type,
|
||||
|
||||
stmp.type = type;
|
||||
if (type == X509_LU_X509) {
|
||||
data.st_x509.cert_info.subject = name;
|
||||
data.st_x509.cert_info.subject = (X509_NAME *)name; /* won't modify it */
|
||||
stmp.data.x509 = &data.st_x509;
|
||||
postfix = "";
|
||||
} else if (type == X509_LU_CRL) {
|
||||
data.crl.crl.issuer = name;
|
||||
data.crl.crl.issuer = (X509_NAME *)name; /* won't modify it */
|
||||
stmp.data.crl = &data.crl;
|
||||
postfix = "r";
|
||||
} else {
|
||||
|
||||
@@ -151,9 +151,10 @@ static int by_store(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
|
||||
}
|
||||
|
||||
static int by_store_subject(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
|
||||
X509_NAME *name, X509_OBJECT *ret)
|
||||
const X509_NAME *name, X509_OBJECT *ret)
|
||||
{
|
||||
OSSL_STORE_SEARCH *criterion = OSSL_STORE_SEARCH_by_name(name);
|
||||
OSSL_STORE_SEARCH *criterion =
|
||||
OSSL_STORE_SEARCH_by_name((X509_NAME *)name); /* won't modify it */
|
||||
int ok = by_store(ctx, type, criterion, ret);
|
||||
STACK_OF(X509_OBJECT) *store_objects =
|
||||
X509_STORE_get0_objects(X509_LOOKUP_get_store(ctx));
|
||||
|
||||
@@ -24,3 +24,4 @@ extern const X509V3_EXT_METHOD v3_ct_scts[3];
|
||||
extern const X509V3_EXT_METHOD v3_tls_feature;
|
||||
extern const X509V3_EXT_METHOD v3_ext_admission;
|
||||
extern const X509V3_EXT_METHOD v3_utf8_list[1];
|
||||
extern const X509V3_EXT_METHOD v3_issuer_sign_tool;
|
||||
@@ -69,7 +69,7 @@ int X509_policy_level_node_count(X509_POLICY_LEVEL *level)
|
||||
return n;
|
||||
}
|
||||
|
||||
X509_POLICY_NODE *X509_policy_level_get0_node(X509_POLICY_LEVEL *level, int i)
|
||||
X509_POLICY_NODE *X509_policy_level_get0_node(const X509_POLICY_LEVEL *level, int i)
|
||||
{
|
||||
if (!level)
|
||||
return NULL;
|
||||
|
||||
@@ -69,6 +69,7 @@ static const X509V3_EXT_METHOD *standard_exts[] = {
|
||||
&v3_ct_scts[2],
|
||||
#endif
|
||||
&v3_utf8_list[0],
|
||||
&v3_issuer_sign_tool,
|
||||
&v3_tls_feature,
|
||||
&v3_ext_admission
|
||||
};
|
||||
|
||||
@@ -227,7 +227,7 @@ int X509_ocspid_print(BIO *bp, X509 *x)
|
||||
int i;
|
||||
unsigned char SHA1md[SHA_DIGEST_LENGTH];
|
||||
ASN1_BIT_STRING *keybstr;
|
||||
X509_NAME *subj;
|
||||
const X509_NAME *subj;
|
||||
|
||||
/*
|
||||
* display the hash of the subject as it would appear in OCSP requests
|
||||
@@ -472,7 +472,7 @@ int X509_STORE_CTX_print_verify_cb(int ok, X509_STORE_CTX *ctx)
|
||||
BIO_printf(bio, "certs in trust store:\n");
|
||||
print_store_certs(bio, X509_STORE_CTX_get0_store(ctx));
|
||||
}
|
||||
CMPerr(0, X509_R_CERTIFICATE_VERIFICATION_FAILED);
|
||||
X509err(0, X509_R_CERTIFICATE_VERIFICATION_FAILED);
|
||||
ERR_add_error_mem_bio("\n", bio);
|
||||
BIO_free(bio);
|
||||
}
|
||||
|
||||
@@ -479,7 +479,7 @@ static int i2r_crldp(const X509V3_EXT_METHOD *method, void *pcrldp, BIO *out,
|
||||
return 1;
|
||||
}
|
||||
|
||||
int DIST_POINT_set_dpname(DIST_POINT_NAME *dpn, X509_NAME *iname)
|
||||
int DIST_POINT_set_dpname(DIST_POINT_NAME *dpn, const X509_NAME *iname)
|
||||
{
|
||||
int i;
|
||||
STACK_OF(X509_NAME_ENTRY) *frag;
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (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
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "internal/cryptlib.h"
|
||||
#include <openssl/conf.h>
|
||||
#include <openssl/asn1.h>
|
||||
#include <openssl/asn1t.h>
|
||||
#include <openssl/x509v3.h>
|
||||
#include "ext_dat.h"
|
||||
|
||||
/*
|
||||
* Issuer Sign Tool (1.2.643.100.112) The name of the tool used to signs the subject (ASN1_SEQUENCE)
|
||||
* This extention is required to obtain the status of a qualified certificate at Russian Federation.
|
||||
* RFC-style description is available here: https://tools.ietf.org/html/draft-deremin-rfc4491-bis-04#section-5
|
||||
* Russian Federal Law 63 "Digital Sign" is available here: http://www.consultant.ru/document/cons_doc_LAW_112701/
|
||||
*/
|
||||
|
||||
ASN1_SEQUENCE(ISSUER_SIGN_TOOL) = {
|
||||
ASN1_SIMPLE(ISSUER_SIGN_TOOL, signTool, ASN1_UTF8STRING),
|
||||
ASN1_SIMPLE(ISSUER_SIGN_TOOL, cATool, ASN1_UTF8STRING),
|
||||
ASN1_SIMPLE(ISSUER_SIGN_TOOL, signToolCert, ASN1_UTF8STRING),
|
||||
ASN1_SIMPLE(ISSUER_SIGN_TOOL, cAToolCert, ASN1_UTF8STRING)
|
||||
} ASN1_SEQUENCE_END(ISSUER_SIGN_TOOL)
|
||||
|
||||
IMPLEMENT_ASN1_FUNCTIONS(ISSUER_SIGN_TOOL)
|
||||
|
||||
|
||||
static ISSUER_SIGN_TOOL *v2i_issuer_sign_tool(X509V3_EXT_METHOD *method, X509V3_CTX *ctx,
|
||||
STACK_OF(CONF_VALUE) *nval)
|
||||
{
|
||||
ISSUER_SIGN_TOOL *ist = ISSUER_SIGN_TOOL_new();
|
||||
int i;
|
||||
|
||||
if (ist == NULL) {
|
||||
X509V3err(X509V3_F_V2I_ISSUER_SIGN_TOOL, ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < sk_CONF_VALUE_num(nval); ++i) {
|
||||
CONF_VALUE *cnf = sk_CONF_VALUE_value(nval, i);
|
||||
|
||||
if (cnf == NULL) {
|
||||
continue;
|
||||
}
|
||||
if (strcmp(cnf->name, "signTool") == 0) {
|
||||
ist->signTool = ASN1_UTF8STRING_new();
|
||||
if (ist->signTool == NULL) {
|
||||
X509V3err(X509V3_F_V2I_ISSUER_SIGN_TOOL, ERR_R_MALLOC_FAILURE);
|
||||
ISSUER_SIGN_TOOL_free(ist);
|
||||
return NULL;
|
||||
}
|
||||
ASN1_STRING_set(ist->signTool, cnf->value, strlen(cnf->value));
|
||||
} else if (strcmp(cnf->name, "cATool") == 0) {
|
||||
ist->cATool = ASN1_UTF8STRING_new();
|
||||
if (ist->cATool == NULL) {
|
||||
X509V3err(X509V3_F_V2I_ISSUER_SIGN_TOOL, ERR_R_MALLOC_FAILURE);
|
||||
ISSUER_SIGN_TOOL_free(ist);
|
||||
return NULL;
|
||||
}
|
||||
ASN1_STRING_set(ist->cATool, cnf->value, strlen(cnf->value));
|
||||
} else if (strcmp(cnf->name, "signToolCert") == 0) {
|
||||
ist->signToolCert = ASN1_UTF8STRING_new();
|
||||
if (ist->signToolCert == NULL) {
|
||||
X509V3err(X509V3_F_V2I_ISSUER_SIGN_TOOL, ERR_R_MALLOC_FAILURE);
|
||||
ISSUER_SIGN_TOOL_free(ist);
|
||||
return NULL;
|
||||
}
|
||||
ASN1_STRING_set(ist->signToolCert, cnf->value, strlen(cnf->value));
|
||||
} else if (strcmp(cnf->name, "cAToolCert") == 0) {
|
||||
ist->cAToolCert = ASN1_UTF8STRING_new();
|
||||
if (ist->cAToolCert == NULL) {
|
||||
X509V3err(X509V3_F_V2I_ISSUER_SIGN_TOOL, ERR_R_MALLOC_FAILURE);
|
||||
ISSUER_SIGN_TOOL_free(ist);
|
||||
return NULL;
|
||||
}
|
||||
ASN1_STRING_set(ist->cAToolCert, cnf->value, strlen(cnf->value));
|
||||
} else {
|
||||
X509V3err(X509V3_F_V2I_ISSUER_SIGN_TOOL, ERR_R_PASSED_INVALID_ARGUMENT);
|
||||
ISSUER_SIGN_TOOL_free(ist);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return ist;
|
||||
}
|
||||
|
||||
static int i2r_issuer_sign_tool(X509V3_EXT_METHOD *method,
|
||||
ISSUER_SIGN_TOOL *ist, BIO *out,
|
||||
int indent)
|
||||
{
|
||||
int new_line = 0;
|
||||
|
||||
if (ist == NULL) {
|
||||
X509V3err(X509V3_F_I2R_ISSUER_SIGN_TOOL, ERR_R_PASSED_INVALID_ARGUMENT);
|
||||
return 0;
|
||||
}
|
||||
if (ist->signTool != NULL) {
|
||||
if (new_line == 1) {
|
||||
BIO_write(out, "\n", 1);
|
||||
}
|
||||
BIO_printf(out, "%*ssignTool : ", indent, "");
|
||||
BIO_write(out, ist->signTool->data, ist->signTool->length);
|
||||
new_line = 1;
|
||||
}
|
||||
if (ist->cATool != NULL) {
|
||||
if (new_line == 1) {
|
||||
BIO_write(out, "\n", 1);
|
||||
}
|
||||
BIO_printf(out, "%*scATool : ", indent, "");
|
||||
BIO_write(out, ist->cATool->data, ist->cATool->length);
|
||||
new_line = 1;
|
||||
}
|
||||
if (ist->signToolCert != NULL) {
|
||||
if (new_line == 1) {
|
||||
BIO_write(out, "\n", 1);
|
||||
}
|
||||
BIO_printf(out, "%*ssignToolCert: ", indent, "");
|
||||
BIO_write(out, ist->signToolCert->data, ist->signToolCert->length);
|
||||
new_line = 1;
|
||||
}
|
||||
if (ist->cAToolCert != NULL) {
|
||||
if (new_line == 1) {
|
||||
BIO_write(out, "\n", 1);
|
||||
}
|
||||
BIO_printf(out, "%*scAToolCert : ", indent, "");
|
||||
BIO_write(out, ist->cAToolCert->data, ist->cAToolCert->length);
|
||||
new_line = 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
const X509V3_EXT_METHOD v3_issuer_sign_tool = {
|
||||
NID_issuerSignTool, /* nid */
|
||||
X509V3_EXT_MULTILINE, /* flags */
|
||||
ASN1_ITEM_ref(ISSUER_SIGN_TOOL), /* template */
|
||||
0, 0, 0, 0, /* old functions, ignored */
|
||||
0, /* i2s */
|
||||
0, /* s2i */
|
||||
0, /* i2v */
|
||||
(X509V3_EXT_V2I)v2i_issuer_sign_tool, /* v2i */
|
||||
(X509V3_EXT_I2R)i2r_issuer_sign_tool, /* i2r */
|
||||
0, /* r2i */
|
||||
NULL /* extension-specific data */
|
||||
};
|
||||
@@ -31,7 +31,7 @@ static int print_nc_ipadd(BIO *bp, ASN1_OCTET_STRING *ip);
|
||||
|
||||
static int nc_match(GENERAL_NAME *gen, NAME_CONSTRAINTS *nc);
|
||||
static int nc_match_single(GENERAL_NAME *sub, GENERAL_NAME *gen);
|
||||
static int nc_dn(X509_NAME *sub, X509_NAME *nm);
|
||||
static int nc_dn(const X509_NAME *sub, const X509_NAME *nm);
|
||||
static int nc_dns(ASN1_IA5STRING *sub, ASN1_IA5STRING *dns);
|
||||
static int nc_email(ASN1_IA5STRING *sub, ASN1_IA5STRING *eml);
|
||||
static int nc_uri(ASN1_IA5STRING *uri, ASN1_IA5STRING *base);
|
||||
@@ -400,7 +400,7 @@ static int cn2dnsid(ASN1_STRING *cn, unsigned char **dnsid, size_t *idlen)
|
||||
int NAME_CONSTRAINTS_check_CN(X509 *x, NAME_CONSTRAINTS *nc)
|
||||
{
|
||||
int r, i;
|
||||
X509_NAME *nm = X509_get_subject_name(x);
|
||||
const X509_NAME *nm = X509_get_subject_name(x);
|
||||
ASN1_STRING stmp;
|
||||
GENERAL_NAME gntmp;
|
||||
|
||||
@@ -543,7 +543,7 @@ static int nc_match_single(GENERAL_NAME *gen, GENERAL_NAME *base)
|
||||
* subset of the name.
|
||||
*/
|
||||
|
||||
static int nc_dn(X509_NAME *nm, X509_NAME *base)
|
||||
static int nc_dn(const X509_NAME *nm, const X509_NAME *base)
|
||||
{
|
||||
/* Ensure canonical encodings are up to date. */
|
||||
if (nm->modified && i2d_X509_NAME(nm, NULL) < 0)
|
||||
|
||||
+91
-44
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1999-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -15,8 +15,6 @@
|
||||
#include "crypto/x509.h"
|
||||
#include "internal/tsan_assist.h"
|
||||
|
||||
static void x509v3_cache_extensions(X509 *x);
|
||||
|
||||
static int check_ssl_ca(const X509 *x);
|
||||
static int check_purpose_ssl_client(const X509_PURPOSE *xp, const X509 *x,
|
||||
int ca);
|
||||
@@ -80,7 +78,8 @@ int X509_check_purpose(X509 *x, int id, int ca)
|
||||
int idx;
|
||||
const X509_PURPOSE *pt;
|
||||
|
||||
x509v3_cache_extensions(x);
|
||||
if (!X509v3_cache_extensions(x, NULL, NULL))
|
||||
return -1;
|
||||
|
||||
/* Return if side-effect only call */
|
||||
if (id == -1)
|
||||
@@ -300,10 +299,11 @@ int X509_supported_extension(X509_EXTENSION *ex)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void setup_dp(X509 *x, DIST_POINT *dp)
|
||||
static int setup_dp(X509 *x, DIST_POINT *dp)
|
||||
{
|
||||
X509_NAME *iname = NULL;
|
||||
const X509_NAME *iname = NULL;
|
||||
int i;
|
||||
|
||||
if (dp->reasons) {
|
||||
if (dp->reasons->length > 0)
|
||||
dp->dp_reasons = dp->reasons->data[0];
|
||||
@@ -313,7 +313,7 @@ static void setup_dp(X509 *x, DIST_POINT *dp)
|
||||
} else
|
||||
dp->dp_reasons = CRLDP_ALL_REASONS;
|
||||
if (!dp->distpoint || (dp->distpoint->type != 1))
|
||||
return;
|
||||
return 1;
|
||||
for (i = 0; i < sk_GENERAL_NAME_num(dp->CRLissuer); i++) {
|
||||
GENERAL_NAME *gen = sk_GENERAL_NAME_value(dp->CRLissuer, i);
|
||||
if (gen->type == GEN_DIRNAME) {
|
||||
@@ -324,16 +324,21 @@ static void setup_dp(X509 *x, DIST_POINT *dp)
|
||||
if (!iname)
|
||||
iname = X509_get_issuer_name(x);
|
||||
|
||||
DIST_POINT_set_dpname(dp->distpoint, iname);
|
||||
|
||||
return DIST_POINT_set_dpname(dp->distpoint, iname);
|
||||
}
|
||||
|
||||
static void setup_crldp(X509 *x)
|
||||
static int setup_crldp(X509 *x)
|
||||
{
|
||||
int i;
|
||||
x->crldp = X509_get_ext_d2i(x, NID_crl_distribution_points, NULL, NULL);
|
||||
for (i = 0; i < sk_DIST_POINT_num(x->crldp); i++)
|
||||
setup_dp(x, sk_DIST_POINT_value(x->crldp, i));
|
||||
|
||||
x->crldp = X509_get_ext_d2i(x, NID_crl_distribution_points, &i, NULL);
|
||||
if (x->crldp == NULL && i != -1)
|
||||
return 0;
|
||||
for (i = 0; i < sk_DIST_POINT_num(x->crldp); i++) {
|
||||
if (!setup_dp(x, sk_DIST_POINT_value(x->crldp, i)))
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define V1_ROOT (EXFLAG_V1|EXFLAG_SS)
|
||||
@@ -344,7 +349,7 @@ static void setup_crldp(X509 *x)
|
||||
#define ns_reject(x, usage) \
|
||||
(((x)->ex_flags & EXFLAG_NSCERT) && !((x)->ex_nscert & (usage)))
|
||||
|
||||
static void x509v3_cache_extensions(X509 *x)
|
||||
int X509v3_cache_extensions(X509 *x, OPENSSL_CTX *libctx, const char *propq)
|
||||
{
|
||||
BASIC_CONSTRAINTS *bs;
|
||||
PROXY_CERT_INFO_EXTENSION *pci;
|
||||
@@ -353,41 +358,52 @@ static void x509v3_cache_extensions(X509 *x)
|
||||
EXTENDED_KEY_USAGE *extusage;
|
||||
X509_EXTENSION *ex;
|
||||
int i;
|
||||
EVP_MD *sha1;
|
||||
|
||||
#ifdef tsan_ld_acq
|
||||
/* fast lock-free check, see end of the function for details. */
|
||||
if (tsan_ld_acq((TSAN_QUALIFIER int *)&x->ex_cached))
|
||||
return;
|
||||
return (x->ex_flags & EXFLAG_INVALID) == 0;
|
||||
#endif
|
||||
|
||||
CRYPTO_THREAD_write_lock(x->lock);
|
||||
if (x->ex_flags & EXFLAG_SET) {
|
||||
CRYPTO_THREAD_unlock(x->lock);
|
||||
return;
|
||||
return (x->ex_flags & EXFLAG_INVALID) == 0;
|
||||
}
|
||||
|
||||
X509_digest(x, EVP_sha1(), x->sha1_hash, NULL);
|
||||
sha1 = EVP_MD_fetch(libctx, "SHA1", propq);
|
||||
if (sha1 == NULL || !X509_digest(x, sha1, x->sha1_hash, NULL))
|
||||
x->ex_flags |= EXFLAG_INVALID;
|
||||
EVP_MD_free(sha1);
|
||||
|
||||
/* V1 should mean no extensions ... */
|
||||
if (!X509_get_version(x))
|
||||
x->ex_flags |= EXFLAG_V1;
|
||||
/* Handle basic constraints */
|
||||
if ((bs = X509_get_ext_d2i(x, NID_basic_constraints, NULL, NULL))) {
|
||||
if ((bs = X509_get_ext_d2i(x, NID_basic_constraints, &i, NULL))) {
|
||||
if (bs->ca)
|
||||
x->ex_flags |= EXFLAG_CA;
|
||||
if (bs->pathlen) {
|
||||
if ((bs->pathlen->type == V_ASN1_NEG_INTEGER)
|
||||
|| !bs->ca) {
|
||||
if (bs->pathlen->type == V_ASN1_NEG_INTEGER) {
|
||||
x->ex_flags |= EXFLAG_INVALID;
|
||||
x->ex_pathlen = 0;
|
||||
} else
|
||||
} else {
|
||||
x->ex_pathlen = ASN1_INTEGER_get(bs->pathlen);
|
||||
if (!bs->ca && x->ex_pathlen != 0) {
|
||||
x->ex_flags |= EXFLAG_INVALID;
|
||||
x->ex_pathlen = 0;
|
||||
}
|
||||
}
|
||||
} else
|
||||
x->ex_pathlen = -1;
|
||||
BASIC_CONSTRAINTS_free(bs);
|
||||
x->ex_flags |= EXFLAG_BCONS;
|
||||
} else if (i != -1) {
|
||||
x->ex_flags |= EXFLAG_INVALID;
|
||||
}
|
||||
/* Handle proxy certificates */
|
||||
if ((pci = X509_get_ext_d2i(x, NID_proxyCertInfo, NULL, NULL))) {
|
||||
if ((pci = X509_get_ext_d2i(x, NID_proxyCertInfo, &i, NULL))) {
|
||||
if (x->ex_flags & EXFLAG_CA
|
||||
|| X509_get_ext_by_NID(x, NID_subject_alt_name, -1) >= 0
|
||||
|| X509_get_ext_by_NID(x, NID_issuer_alt_name, -1) >= 0) {
|
||||
@@ -399,9 +415,11 @@ static void x509v3_cache_extensions(X509 *x)
|
||||
x->ex_pcpathlen = -1;
|
||||
PROXY_CERT_INFO_EXTENSION_free(pci);
|
||||
x->ex_flags |= EXFLAG_PROXY;
|
||||
} else if (i != -1) {
|
||||
x->ex_flags |= EXFLAG_INVALID;
|
||||
}
|
||||
/* Handle key usage */
|
||||
if ((usage = X509_get_ext_d2i(x, NID_key_usage, NULL, NULL))) {
|
||||
if ((usage = X509_get_ext_d2i(x, NID_key_usage, &i, NULL))) {
|
||||
if (usage->length > 0) {
|
||||
x->ex_kusage = usage->data[0];
|
||||
if (usage->length > 1)
|
||||
@@ -410,9 +428,11 @@ static void x509v3_cache_extensions(X509 *x)
|
||||
x->ex_kusage = 0;
|
||||
x->ex_flags |= EXFLAG_KUSAGE;
|
||||
ASN1_BIT_STRING_free(usage);
|
||||
} else if (i != -1) {
|
||||
x->ex_flags |= EXFLAG_INVALID;
|
||||
}
|
||||
x->ex_xkusage = 0;
|
||||
if ((extusage = X509_get_ext_d2i(x, NID_ext_key_usage, NULL, NULL))) {
|
||||
if ((extusage = X509_get_ext_d2i(x, NID_ext_key_usage, &i, NULL))) {
|
||||
x->ex_flags |= EXFLAG_XKUSAGE;
|
||||
for (i = 0; i < sk_ASN1_OBJECT_num(extusage); i++) {
|
||||
switch (OBJ_obj2nid(sk_ASN1_OBJECT_value(extusage, i))) {
|
||||
@@ -455,18 +475,26 @@ static void x509v3_cache_extensions(X509 *x)
|
||||
}
|
||||
}
|
||||
sk_ASN1_OBJECT_pop_free(extusage, ASN1_OBJECT_free);
|
||||
} else if (i != -1) {
|
||||
x->ex_flags |= EXFLAG_INVALID;
|
||||
}
|
||||
|
||||
if ((ns = X509_get_ext_d2i(x, NID_netscape_cert_type, NULL, NULL))) {
|
||||
if ((ns = X509_get_ext_d2i(x, NID_netscape_cert_type, &i, NULL))) {
|
||||
if (ns->length > 0)
|
||||
x->ex_nscert = ns->data[0];
|
||||
else
|
||||
x->ex_nscert = 0;
|
||||
x->ex_flags |= EXFLAG_NSCERT;
|
||||
ASN1_BIT_STRING_free(ns);
|
||||
} else if (i != -1) {
|
||||
x->ex_flags |= EXFLAG_INVALID;
|
||||
}
|
||||
x->skid = X509_get_ext_d2i(x, NID_subject_key_identifier, NULL, NULL);
|
||||
x->akid = X509_get_ext_d2i(x, NID_authority_key_identifier, NULL, NULL);
|
||||
x->skid = X509_get_ext_d2i(x, NID_subject_key_identifier, &i, NULL);
|
||||
if (x->skid == NULL && i != -1)
|
||||
x->ex_flags |= EXFLAG_INVALID;
|
||||
x->akid = X509_get_ext_d2i(x, NID_authority_key_identifier, &i, NULL);
|
||||
if (x->akid == NULL && i != -1)
|
||||
x->ex_flags |= EXFLAG_INVALID;
|
||||
/* Does subject name match issuer ? */
|
||||
if (!X509_NAME_cmp(X509_get_subject_name(x), X509_get_issuer_name(x))) {
|
||||
x->ex_flags |= EXFLAG_SI;
|
||||
@@ -475,16 +503,22 @@ static void x509v3_cache_extensions(X509 *x)
|
||||
!ku_reject(x, KU_KEY_CERT_SIGN))
|
||||
x->ex_flags |= EXFLAG_SS;
|
||||
}
|
||||
x->altname = X509_get_ext_d2i(x, NID_subject_alt_name, NULL, NULL);
|
||||
x->nc = X509_get_ext_d2i(x, NID_name_constraints, &i, NULL);
|
||||
if (!x->nc && (i != -1))
|
||||
x->altname = X509_get_ext_d2i(x, NID_subject_alt_name, &i, NULL);
|
||||
if (x->altname == NULL && i != -1)
|
||||
x->ex_flags |= EXFLAG_INVALID;
|
||||
x->nc = X509_get_ext_d2i(x, NID_name_constraints, &i, NULL);
|
||||
if (x->nc == NULL && i != -1)
|
||||
x->ex_flags |= EXFLAG_INVALID;
|
||||
if (!setup_crldp(x))
|
||||
x->ex_flags |= EXFLAG_INVALID;
|
||||
setup_crldp(x);
|
||||
|
||||
#ifndef OPENSSL_NO_RFC3779
|
||||
x->rfc3779_addr = X509_get_ext_d2i(x, NID_sbgp_ipAddrBlock, NULL, NULL);
|
||||
x->rfc3779_asid = X509_get_ext_d2i(x, NID_sbgp_autonomousSysNum,
|
||||
NULL, NULL);
|
||||
x->rfc3779_addr = X509_get_ext_d2i(x, NID_sbgp_ipAddrBlock, &i, NULL);
|
||||
if (x->rfc3779_addr == NULL && i != -1)
|
||||
x->ex_flags |= EXFLAG_INVALID;
|
||||
x->rfc3779_asid = X509_get_ext_d2i(x, NID_sbgp_autonomousSysNum, &i, NULL);
|
||||
if (x->rfc3779_asid == NULL && i != -1)
|
||||
x->ex_flags |= EXFLAG_INVALID;
|
||||
#endif
|
||||
for (i = 0; i < X509_get_ext_count(x); i++) {
|
||||
ex = X509_get_ext(x, i);
|
||||
@@ -509,6 +543,8 @@ static void x509v3_cache_extensions(X509 *x)
|
||||
*/
|
||||
#endif
|
||||
CRYPTO_THREAD_unlock(x->lock);
|
||||
|
||||
return (x->ex_flags & EXFLAG_INVALID) == 0;
|
||||
}
|
||||
|
||||
/*-
|
||||
@@ -516,9 +552,11 @@ static void x509v3_cache_extensions(X509 *x)
|
||||
* return codes:
|
||||
* 0 not a CA
|
||||
* 1 is a CA
|
||||
* 2 basicConstraints absent so "maybe" a CA
|
||||
* 2 Only possible in older versions of openSSL when basicConstraints are absent
|
||||
* new versions will not return this value. May be a CA
|
||||
* 3 basicConstraints absent but self signed V1.
|
||||
* 4 basicConstraints absent but keyUsage present and keyCertSign asserted.
|
||||
* 5 Netscape specific CA Flags present
|
||||
*/
|
||||
|
||||
static int check_ca(const X509 *x)
|
||||
@@ -561,7 +599,9 @@ void X509_set_proxy_pathlen(X509 *x, long l)
|
||||
|
||||
int X509_check_ca(X509 *x)
|
||||
{
|
||||
x509v3_cache_extensions(x);
|
||||
/* Note 0 normally means "not a CA" - but in this case means error. */
|
||||
if (!X509v3_cache_extensions(x, NULL, NULL))
|
||||
return 0;
|
||||
|
||||
return check_ca(x);
|
||||
}
|
||||
@@ -777,8 +817,9 @@ int X509_check_issued(X509 *issuer, X509 *subject)
|
||||
X509_get_issuer_name(subject)))
|
||||
return X509_V_ERR_SUBJECT_ISSUER_MISMATCH;
|
||||
|
||||
x509v3_cache_extensions(issuer);
|
||||
x509v3_cache_extensions(subject);
|
||||
if (!X509v3_cache_extensions(issuer, NULL, NULL)
|
||||
|| !X509v3_cache_extensions(subject, NULL, NULL))
|
||||
return X509_V_ERR_UNSPECIFIED;
|
||||
|
||||
if (subject->akid) {
|
||||
int ret = X509_check_akid(issuer, subject->akid);
|
||||
@@ -861,7 +902,8 @@ uint32_t X509_get_extension_flags(X509 *x)
|
||||
uint32_t X509_get_key_usage(X509 *x)
|
||||
{
|
||||
/* Call for side-effect of computing hash and caching extensions */
|
||||
X509_check_purpose(x, -1, -1);
|
||||
if (X509_check_purpose(x, -1, -1) != 1)
|
||||
return 0;
|
||||
if (x->ex_flags & EXFLAG_KUSAGE)
|
||||
return x->ex_kusage;
|
||||
return UINT32_MAX;
|
||||
@@ -870,7 +912,8 @@ uint32_t X509_get_key_usage(X509 *x)
|
||||
uint32_t X509_get_extended_key_usage(X509 *x)
|
||||
{
|
||||
/* Call for side-effect of computing hash and caching extensions */
|
||||
X509_check_purpose(x, -1, -1);
|
||||
if (X509_check_purpose(x, -1, -1) != 1)
|
||||
return 0;
|
||||
if (x->ex_flags & EXFLAG_XKUSAGE)
|
||||
return x->ex_xkusage;
|
||||
return UINT32_MAX;
|
||||
@@ -879,28 +922,32 @@ uint32_t X509_get_extended_key_usage(X509 *x)
|
||||
const ASN1_OCTET_STRING *X509_get0_subject_key_id(X509 *x)
|
||||
{
|
||||
/* Call for side-effect of computing hash and caching extensions */
|
||||
X509_check_purpose(x, -1, -1);
|
||||
if (X509_check_purpose(x, -1, -1) != 1)
|
||||
return NULL;
|
||||
return x->skid;
|
||||
}
|
||||
|
||||
const ASN1_OCTET_STRING *X509_get0_authority_key_id(X509 *x)
|
||||
{
|
||||
/* Call for side-effect of computing hash and caching extensions */
|
||||
X509_check_purpose(x, -1, -1);
|
||||
if (X509_check_purpose(x, -1, -1) != 1)
|
||||
return NULL;
|
||||
return (x->akid != NULL ? x->akid->keyid : NULL);
|
||||
}
|
||||
|
||||
const GENERAL_NAMES *X509_get0_authority_issuer(X509 *x)
|
||||
{
|
||||
/* Call for side-effect of computing hash and caching extensions */
|
||||
X509_check_purpose(x, -1, -1);
|
||||
if (X509_check_purpose(x, -1, -1) != 1)
|
||||
return NULL;
|
||||
return (x->akid != NULL ? x->akid->issuer : NULL);
|
||||
}
|
||||
|
||||
const ASN1_INTEGER *X509_get0_authority_serial(X509 *x)
|
||||
{
|
||||
/* Call for side-effect of computing hash and caching extensions */
|
||||
X509_check_purpose(x, -1, -1);
|
||||
if (X509_check_purpose(x, -1, -1) != 1)
|
||||
return NULL;
|
||||
return (x->akid != NULL ? x->akid->serial : NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
static char *strip_spaces(char *name);
|
||||
static int sk_strcmp(const char *const *a, const char *const *b);
|
||||
static STACK_OF(OPENSSL_STRING) *get_email(X509_NAME *name,
|
||||
static STACK_OF(OPENSSL_STRING) *get_email(const X509_NAME *name,
|
||||
GENERAL_NAMES *gens);
|
||||
static void str_free(OPENSSL_STRING str);
|
||||
static int append_ia5(STACK_OF(OPENSSL_STRING) **sk, const ASN1_IA5STRING *email);
|
||||
@@ -463,7 +463,7 @@ STACK_OF(OPENSSL_STRING) *X509_REQ_get1_email(X509_REQ *x)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static STACK_OF(OPENSSL_STRING) *get_email(X509_NAME *name,
|
||||
static STACK_OF(OPENSSL_STRING) *get_email(const X509_NAME *name,
|
||||
GENERAL_NAMES *gens)
|
||||
{
|
||||
STACK_OF(OPENSSL_STRING) *ret = NULL;
|
||||
@@ -819,7 +819,7 @@ static int do_x509_check(X509 *x, const char *chk, size_t chklen,
|
||||
unsigned int flags, int check_type, char **peername)
|
||||
{
|
||||
GENERAL_NAMES *gens = NULL;
|
||||
X509_NAME *name = NULL;
|
||||
const X509_NAME *name = NULL;
|
||||
int i;
|
||||
int cnid = NID_undef;
|
||||
int alt_type;
|
||||
|
||||
+12
-9
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -135,9 +135,12 @@ unsigned long X509_subject_name_hash_old(X509 *x)
|
||||
int X509_cmp(const X509 *a, const X509 *b)
|
||||
{
|
||||
int rv;
|
||||
|
||||
/* ensure hash is valid */
|
||||
X509_check_purpose((X509 *)a, -1, 0);
|
||||
X509_check_purpose((X509 *)b, -1, 0);
|
||||
if (X509_check_purpose((X509 *)a, -1, 0) != 1)
|
||||
return -2;
|
||||
if (X509_check_purpose((X509 *)b, -1, 0) != 1)
|
||||
return -2;
|
||||
|
||||
rv = memcmp(a->sha1_hash, b->sha1_hash, SHA_DIGEST_LENGTH);
|
||||
if (rv)
|
||||
@@ -181,7 +184,7 @@ int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b)
|
||||
|
||||
}
|
||||
|
||||
unsigned long X509_NAME_hash(X509_NAME *x)
|
||||
unsigned long X509_NAME_hash(const X509_NAME *x)
|
||||
{
|
||||
unsigned long ret = 0;
|
||||
unsigned char md[SHA_DIGEST_LENGTH];
|
||||
@@ -204,7 +207,7 @@ unsigned long X509_NAME_hash(X509_NAME *x)
|
||||
* this is reasonably efficient.
|
||||
*/
|
||||
|
||||
unsigned long X509_NAME_hash_old(X509_NAME *x)
|
||||
unsigned long X509_NAME_hash_old(const X509_NAME *x)
|
||||
{
|
||||
EVP_MD *md5 = EVP_MD_fetch(NULL, OSSL_DIGEST_NAME_MD5, "-fips");
|
||||
EVP_MD_CTX *md_ctx = EVP_MD_CTX_new();
|
||||
@@ -232,8 +235,8 @@ unsigned long X509_NAME_hash_old(X509_NAME *x)
|
||||
#endif
|
||||
|
||||
/* Search a stack of X509 for a match */
|
||||
X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk, X509_NAME *name,
|
||||
ASN1_INTEGER *serial)
|
||||
X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk, const X509_NAME *name,
|
||||
const ASN1_INTEGER *serial)
|
||||
{
|
||||
int i;
|
||||
X509 x, *x509 = NULL;
|
||||
@@ -242,7 +245,7 @@ X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk, X509_NAME *name,
|
||||
return NULL;
|
||||
|
||||
x.cert_info.serialNumber = *serial;
|
||||
x.cert_info.issuer = name;
|
||||
x.cert_info.issuer = (X509_NAME *)name; /* won't modify it */
|
||||
|
||||
for (i = 0; i < sk_X509_num(sk); i++) {
|
||||
x509 = sk_X509_value(sk, i);
|
||||
@@ -252,7 +255,7 @@ X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk, X509_NAME *name,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
X509 *X509_find_by_subject(STACK_OF(X509) *sk, X509_NAME *name)
|
||||
X509 *X509_find_by_subject(STACK_OF(X509) *sk, const X509_NAME *name)
|
||||
{
|
||||
X509 *x509;
|
||||
int i;
|
||||
|
||||
@@ -64,7 +64,7 @@ struct x509_crl_method_st {
|
||||
int (*crl_init) (X509_CRL *crl);
|
||||
int (*crl_free) (X509_CRL *crl);
|
||||
int (*crl_lookup) (X509_CRL *crl, X509_REVOKED **ret,
|
||||
ASN1_INTEGER *ser, X509_NAME *issuer);
|
||||
const ASN1_INTEGER *ser, const X509_NAME *issuer);
|
||||
int (*crl_verify) (X509_CRL *crl, EVP_PKEY *pk);
|
||||
};
|
||||
|
||||
@@ -77,9 +77,10 @@ struct x509_lookup_method_st {
|
||||
int (*ctrl) (X509_LOOKUP *ctx, int cmd, const char *argc, long argl,
|
||||
char **ret);
|
||||
int (*get_by_subject) (X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
|
||||
X509_NAME *name, X509_OBJECT *ret);
|
||||
const X509_NAME *name, X509_OBJECT *ret);
|
||||
int (*get_by_issuer_serial) (X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
|
||||
X509_NAME *name, ASN1_INTEGER *serial,
|
||||
const X509_NAME *name,
|
||||
const ASN1_INTEGER *serial,
|
||||
X509_OBJECT *ret);
|
||||
int (*get_by_fingerprint) (X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
|
||||
const unsigned char *bytes, int len,
|
||||
@@ -128,8 +129,11 @@ struct x509_store_st {
|
||||
int (*cert_crl) (X509_STORE_CTX *ctx, X509_CRL *crl, X509 *x);
|
||||
/* Check policy status of the chain */
|
||||
int (*check_policy) (X509_STORE_CTX *ctx);
|
||||
STACK_OF(X509) *(*lookup_certs) (X509_STORE_CTX *ctx, X509_NAME *nm);
|
||||
STACK_OF(X509_CRL) *(*lookup_crls) (X509_STORE_CTX *ctx, X509_NAME *nm);
|
||||
STACK_OF(X509) *(*lookup_certs) (X509_STORE_CTX *ctx,
|
||||
const X509_NAME *nm);
|
||||
/* cannot constify 'ctx' param due to lookup_certs_sk() in x509_vfy.c */
|
||||
STACK_OF(X509_CRL) *(*lookup_crls) (const X509_STORE_CTX *ctx,
|
||||
const X509_NAME *nm);
|
||||
int (*cleanup) (X509_STORE_CTX *ctx);
|
||||
CRYPTO_EX_DATA ex_data;
|
||||
CRYPTO_REF_COUNT references;
|
||||
|
||||
+36
-31
@@ -83,7 +83,7 @@ int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, long argl,
|
||||
}
|
||||
|
||||
int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
|
||||
X509_NAME *name, X509_OBJECT *ret)
|
||||
const X509_NAME *name, X509_OBJECT *ret)
|
||||
{
|
||||
if ((ctx->method == NULL) || (ctx->method->get_by_subject == NULL))
|
||||
return 0;
|
||||
@@ -93,7 +93,8 @@ int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
|
||||
}
|
||||
|
||||
int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
|
||||
X509_NAME *name, ASN1_INTEGER *serial,
|
||||
const X509_NAME *name,
|
||||
const ASN1_INTEGER *serial,
|
||||
X509_OBJECT *ret)
|
||||
{
|
||||
if ((ctx->method == NULL) || (ctx->method->get_by_issuer_serial == NULL))
|
||||
@@ -273,7 +274,7 @@ X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m)
|
||||
|
||||
X509_OBJECT *X509_STORE_CTX_get_obj_by_subject(X509_STORE_CTX *vs,
|
||||
X509_LOOKUP_TYPE type,
|
||||
X509_NAME *name)
|
||||
const X509_NAME *name)
|
||||
{
|
||||
X509_OBJECT *ret = X509_OBJECT_new();
|
||||
|
||||
@@ -286,8 +287,9 @@ X509_OBJECT *X509_STORE_CTX_get_obj_by_subject(X509_STORE_CTX *vs,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int X509_STORE_CTX_get_by_subject(X509_STORE_CTX *vs, X509_LOOKUP_TYPE type,
|
||||
X509_NAME *name, X509_OBJECT *ret)
|
||||
int X509_STORE_CTX_get_by_subject(const X509_STORE_CTX *vs,
|
||||
X509_LOOKUP_TYPE type,
|
||||
const X509_NAME *name, X509_OBJECT *ret)
|
||||
{
|
||||
X509_STORE *store = vs->store;
|
||||
X509_LOOKUP *lu;
|
||||
@@ -403,7 +405,7 @@ X509 *X509_OBJECT_get0_X509(const X509_OBJECT *a)
|
||||
return a->data.x509;
|
||||
}
|
||||
|
||||
X509_CRL *X509_OBJECT_get0_X509_CRL(X509_OBJECT *a)
|
||||
X509_CRL *X509_OBJECT_get0_X509_CRL(const X509_OBJECT *a)
|
||||
{
|
||||
if (a == NULL || a->type != X509_LU_CRL)
|
||||
return NULL;
|
||||
@@ -472,7 +474,7 @@ void X509_OBJECT_free(X509_OBJECT *a)
|
||||
}
|
||||
|
||||
static int x509_object_idx_cnt(STACK_OF(X509_OBJECT) *h, X509_LOOKUP_TYPE type,
|
||||
X509_NAME *name, int *pnmatch)
|
||||
const X509_NAME *name, int *pnmatch)
|
||||
{
|
||||
X509_OBJECT stmp;
|
||||
X509 x509_s;
|
||||
@@ -483,11 +485,11 @@ static int x509_object_idx_cnt(STACK_OF(X509_OBJECT) *h, X509_LOOKUP_TYPE type,
|
||||
switch (type) {
|
||||
case X509_LU_X509:
|
||||
stmp.data.x509 = &x509_s;
|
||||
x509_s.cert_info.subject = name;
|
||||
x509_s.cert_info.subject = (X509_NAME *)name; /* won't modify it */
|
||||
break;
|
||||
case X509_LU_CRL:
|
||||
stmp.data.crl = &crl_s;
|
||||
crl_s.crl.issuer = name;
|
||||
crl_s.crl.issuer = (X509_NAME *)name; /* won't modify it */
|
||||
break;
|
||||
case X509_LU_NONE:
|
||||
/* abort(); */
|
||||
@@ -511,14 +513,14 @@ static int x509_object_idx_cnt(STACK_OF(X509_OBJECT) *h, X509_LOOKUP_TYPE type,
|
||||
}
|
||||
|
||||
int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, X509_LOOKUP_TYPE type,
|
||||
X509_NAME *name)
|
||||
const X509_NAME *name)
|
||||
{
|
||||
return x509_object_idx_cnt(h, type, name, NULL);
|
||||
}
|
||||
|
||||
X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,
|
||||
X509_LOOKUP_TYPE type,
|
||||
X509_NAME *name)
|
||||
const X509_NAME *name)
|
||||
{
|
||||
int idx;
|
||||
idx = X509_OBJECT_idx_by_subject(h, type, name);
|
||||
@@ -527,11 +529,12 @@ X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,
|
||||
return sk_X509_OBJECT_value(h, idx);
|
||||
}
|
||||
|
||||
STACK_OF(X509_OBJECT) *X509_STORE_get0_objects(X509_STORE *v)
|
||||
STACK_OF(X509_OBJECT) *X509_STORE_get0_objects(const X509_STORE *v)
|
||||
{
|
||||
return v->objs;
|
||||
}
|
||||
|
||||
/* TODO param type could be constified as change to lock is intermittent */
|
||||
STACK_OF(X509) *X509_STORE_get1_all_certs(X509_STORE *store)
|
||||
{
|
||||
STACK_OF(X509) *sk;
|
||||
@@ -567,7 +570,8 @@ STACK_OF(X509) *X509_STORE_get1_all_certs(X509_STORE *store)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
STACK_OF(X509) *X509_STORE_CTX_get1_certs(X509_STORE_CTX *ctx, X509_NAME *nm)
|
||||
STACK_OF(X509) *X509_STORE_CTX_get1_certs(X509_STORE_CTX *ctx,
|
||||
const X509_NAME *nm)
|
||||
{
|
||||
int i, idx, cnt;
|
||||
STACK_OF(X509) *sk = NULL;
|
||||
@@ -624,7 +628,8 @@ STACK_OF(X509) *X509_STORE_CTX_get1_certs(X509_STORE_CTX *ctx, X509_NAME *nm)
|
||||
return sk;
|
||||
}
|
||||
|
||||
STACK_OF(X509_CRL) *X509_STORE_CTX_get1_crls(X509_STORE_CTX *ctx, X509_NAME *nm)
|
||||
STACK_OF(X509_CRL) *X509_STORE_CTX_get1_crls(const X509_STORE_CTX *ctx,
|
||||
const X509_NAME *nm)
|
||||
{
|
||||
int i, idx, cnt;
|
||||
STACK_OF(X509_CRL) *sk = sk_X509_CRL_new_null();
|
||||
@@ -711,7 +716,7 @@ X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h,
|
||||
*/
|
||||
int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x)
|
||||
{
|
||||
X509_NAME *xn;
|
||||
const X509_NAME *xn;
|
||||
X509_OBJECT *obj = X509_OBJECT_new(), *pobj = NULL;
|
||||
X509_STORE *store = ctx->store;
|
||||
int i, ok, idx, ret;
|
||||
@@ -800,12 +805,12 @@ int X509_STORE_set_trust(X509_STORE *ctx, int trust)
|
||||
return X509_VERIFY_PARAM_set_trust(ctx->param, trust);
|
||||
}
|
||||
|
||||
int X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *param)
|
||||
int X509_STORE_set1_param(X509_STORE *ctx, const X509_VERIFY_PARAM *param)
|
||||
{
|
||||
return X509_VERIFY_PARAM_set1(ctx->param, param);
|
||||
}
|
||||
|
||||
X509_VERIFY_PARAM *X509_STORE_get0_param(X509_STORE *ctx)
|
||||
X509_VERIFY_PARAM *X509_STORE_get0_param(const X509_STORE *ctx)
|
||||
{
|
||||
return ctx->param;
|
||||
}
|
||||
@@ -815,7 +820,7 @@ void X509_STORE_set_verify(X509_STORE *ctx, X509_STORE_CTX_verify_fn verify)
|
||||
ctx->verify = verify;
|
||||
}
|
||||
|
||||
X509_STORE_CTX_verify_fn X509_STORE_get_verify(X509_STORE *ctx)
|
||||
X509_STORE_CTX_verify_fn X509_STORE_get_verify(const X509_STORE *ctx)
|
||||
{
|
||||
return ctx->verify;
|
||||
}
|
||||
@@ -826,7 +831,7 @@ void X509_STORE_set_verify_cb(X509_STORE *ctx,
|
||||
ctx->verify_cb = verify_cb;
|
||||
}
|
||||
|
||||
X509_STORE_CTX_verify_cb X509_STORE_get_verify_cb(X509_STORE *ctx)
|
||||
X509_STORE_CTX_verify_cb X509_STORE_get_verify_cb(const X509_STORE *ctx)
|
||||
{
|
||||
return ctx->verify_cb;
|
||||
}
|
||||
@@ -837,7 +842,7 @@ void X509_STORE_set_get_issuer(X509_STORE *ctx,
|
||||
ctx->get_issuer = get_issuer;
|
||||
}
|
||||
|
||||
X509_STORE_CTX_get_issuer_fn X509_STORE_get_get_issuer(X509_STORE *ctx)
|
||||
X509_STORE_CTX_get_issuer_fn X509_STORE_get_get_issuer(const X509_STORE *ctx)
|
||||
{
|
||||
return ctx->get_issuer;
|
||||
}
|
||||
@@ -848,7 +853,7 @@ void X509_STORE_set_check_issued(X509_STORE *ctx,
|
||||
ctx->check_issued = check_issued;
|
||||
}
|
||||
|
||||
X509_STORE_CTX_check_issued_fn X509_STORE_get_check_issued(X509_STORE *ctx)
|
||||
X509_STORE_CTX_check_issued_fn X509_STORE_get_check_issued(const X509_STORE *ctx)
|
||||
{
|
||||
return ctx->check_issued;
|
||||
}
|
||||
@@ -859,7 +864,7 @@ void X509_STORE_set_check_revocation(X509_STORE *ctx,
|
||||
ctx->check_revocation = check_revocation;
|
||||
}
|
||||
|
||||
X509_STORE_CTX_check_revocation_fn X509_STORE_get_check_revocation(X509_STORE *ctx)
|
||||
X509_STORE_CTX_check_revocation_fn X509_STORE_get_check_revocation(const X509_STORE *ctx)
|
||||
{
|
||||
return ctx->check_revocation;
|
||||
}
|
||||
@@ -870,7 +875,7 @@ void X509_STORE_set_get_crl(X509_STORE *ctx,
|
||||
ctx->get_crl = get_crl;
|
||||
}
|
||||
|
||||
X509_STORE_CTX_get_crl_fn X509_STORE_get_get_crl(X509_STORE *ctx)
|
||||
X509_STORE_CTX_get_crl_fn X509_STORE_get_get_crl(const X509_STORE *ctx)
|
||||
{
|
||||
return ctx->get_crl;
|
||||
}
|
||||
@@ -881,7 +886,7 @@ void X509_STORE_set_check_crl(X509_STORE *ctx,
|
||||
ctx->check_crl = check_crl;
|
||||
}
|
||||
|
||||
X509_STORE_CTX_check_crl_fn X509_STORE_get_check_crl(X509_STORE *ctx)
|
||||
X509_STORE_CTX_check_crl_fn X509_STORE_get_check_crl(const X509_STORE *ctx)
|
||||
{
|
||||
return ctx->check_crl;
|
||||
}
|
||||
@@ -892,7 +897,7 @@ void X509_STORE_set_cert_crl(X509_STORE *ctx,
|
||||
ctx->cert_crl = cert_crl;
|
||||
}
|
||||
|
||||
X509_STORE_CTX_cert_crl_fn X509_STORE_get_cert_crl(X509_STORE *ctx)
|
||||
X509_STORE_CTX_cert_crl_fn X509_STORE_get_cert_crl(const X509_STORE *ctx)
|
||||
{
|
||||
return ctx->cert_crl;
|
||||
}
|
||||
@@ -903,7 +908,7 @@ void X509_STORE_set_check_policy(X509_STORE *ctx,
|
||||
ctx->check_policy = check_policy;
|
||||
}
|
||||
|
||||
X509_STORE_CTX_check_policy_fn X509_STORE_get_check_policy(X509_STORE *ctx)
|
||||
X509_STORE_CTX_check_policy_fn X509_STORE_get_check_policy(const X509_STORE *ctx)
|
||||
{
|
||||
return ctx->check_policy;
|
||||
}
|
||||
@@ -914,7 +919,7 @@ void X509_STORE_set_lookup_certs(X509_STORE *ctx,
|
||||
ctx->lookup_certs = lookup_certs;
|
||||
}
|
||||
|
||||
X509_STORE_CTX_lookup_certs_fn X509_STORE_get_lookup_certs(X509_STORE *ctx)
|
||||
X509_STORE_CTX_lookup_certs_fn X509_STORE_get_lookup_certs(const X509_STORE *ctx)
|
||||
{
|
||||
return ctx->lookup_certs;
|
||||
}
|
||||
@@ -925,7 +930,7 @@ void X509_STORE_set_lookup_crls(X509_STORE *ctx,
|
||||
ctx->lookup_crls = lookup_crls;
|
||||
}
|
||||
|
||||
X509_STORE_CTX_lookup_crls_fn X509_STORE_get_lookup_crls(X509_STORE *ctx)
|
||||
X509_STORE_CTX_lookup_crls_fn X509_STORE_get_lookup_crls(const X509_STORE *ctx)
|
||||
{
|
||||
return ctx->lookup_crls;
|
||||
}
|
||||
@@ -936,7 +941,7 @@ void X509_STORE_set_cleanup(X509_STORE *ctx,
|
||||
ctx->cleanup = ctx_cleanup;
|
||||
}
|
||||
|
||||
X509_STORE_CTX_cleanup_fn X509_STORE_get_cleanup(X509_STORE *ctx)
|
||||
X509_STORE_CTX_cleanup_fn X509_STORE_get_cleanup(const X509_STORE *ctx)
|
||||
{
|
||||
return ctx->cleanup;
|
||||
}
|
||||
@@ -946,12 +951,12 @@ int X509_STORE_set_ex_data(X509_STORE *ctx, int idx, void *data)
|
||||
return CRYPTO_set_ex_data(&ctx->ex_data, idx, data);
|
||||
}
|
||||
|
||||
void *X509_STORE_get_ex_data(X509_STORE *ctx, int idx)
|
||||
void *X509_STORE_get_ex_data(const X509_STORE *ctx, int idx)
|
||||
{
|
||||
return CRYPTO_get_ex_data(&ctx->ex_data, idx);
|
||||
}
|
||||
|
||||
X509_STORE *X509_STORE_CTX_get0_store(X509_STORE_CTX *ctx)
|
||||
X509_STORE *X509_STORE_CTX_get0_store(const X509_STORE_CTX *ctx)
|
||||
{
|
||||
return ctx->store;
|
||||
}
|
||||
@@ -21,7 +21,7 @@ X509 *X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey)
|
||||
{
|
||||
X509 *ret = NULL;
|
||||
X509_CINF *xi = NULL;
|
||||
X509_NAME *xn;
|
||||
const X509_NAME *xn;
|
||||
EVP_PKEY *pubkey = NULL;
|
||||
|
||||
if ((ret = X509_new()) == NULL) {
|
||||
|
||||
@@ -47,14 +47,14 @@ int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int X509_set_issuer_name(X509 *x, X509_NAME *name)
|
||||
int X509_set_issuer_name(X509 *x, const X509_NAME *name)
|
||||
{
|
||||
if (x == NULL)
|
||||
return 0;
|
||||
return X509_NAME_set(&x->cert_info.issuer, name);
|
||||
}
|
||||
|
||||
int X509_set_subject_name(X509 *x, X509_NAME *name)
|
||||
int X509_set_subject_name(X509 *x, const X509_NAME *name)
|
||||
{
|
||||
if (x == NULL)
|
||||
return 0;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1999-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -240,8 +240,9 @@ static int trust_1oid(X509_TRUST *trust, X509 *x, int flags)
|
||||
static int trust_compat(X509_TRUST *trust, X509 *x, int flags)
|
||||
{
|
||||
/* Call for side-effect of computing hash and caching extensions */
|
||||
X509_check_purpose(x, -1, 0);
|
||||
if ((flags & X509_TRUST_NO_SS_COMPAT) == 0 && x->ex_flags & EXFLAG_SS)
|
||||
if (X509_check_purpose(x, -1, 0) != 1)
|
||||
return X509_TRUST_UNTRUSTED;
|
||||
if ((flags & X509_TRUST_NO_SS_COMPAT) == 0 && (x->ex_flags & EXFLAG_SS))
|
||||
return X509_TRUST_TRUSTED;
|
||||
else
|
||||
return X509_TRUST_UNTRUSTED;
|
||||
|
||||
+108
-48
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -104,15 +104,12 @@ static int null_callback(int ok, X509_STORE_CTX *e)
|
||||
return ok;
|
||||
}
|
||||
|
||||
/* Return 1 is a certificate is self signed */
|
||||
static int cert_self_signed(X509 *x)
|
||||
/* Return 1 is a certificate is self signed, 0 if not, or -1 on error */
|
||||
static int cert_self_signed(X509_STORE_CTX *ctx, X509 *x)
|
||||
{
|
||||
/*
|
||||
* FIXME: x509v3_cache_extensions() needs to detect more failures and not
|
||||
* set EXFLAG_SET when that happens. Especially, if the failures are
|
||||
* parse errors, rather than memory pressure!
|
||||
*/
|
||||
X509_check_purpose(x, -1, 0);
|
||||
if (!X509v3_cache_extensions(x, ctx->libctx, ctx->propq))
|
||||
return -1;
|
||||
|
||||
if (x->ex_flags & EXFLAG_SS)
|
||||
return 1;
|
||||
else
|
||||
@@ -328,14 +325,26 @@ static X509 *find_issuer(X509_STORE_CTX *ctx, STACK_OF(X509) *sk, X509 *x)
|
||||
static int check_issued(X509_STORE_CTX *ctx, X509 *x, X509 *issuer)
|
||||
{
|
||||
int ret;
|
||||
if (x == issuer)
|
||||
return cert_self_signed(x);
|
||||
int ss;
|
||||
|
||||
if (x == issuer) {
|
||||
ss = cert_self_signed(ctx, x);
|
||||
if (ss < 0)
|
||||
return 0;
|
||||
return ss;
|
||||
}
|
||||
|
||||
ret = X509_check_issued(issuer, x);
|
||||
if (ret == X509_V_OK) {
|
||||
int i;
|
||||
X509 *ch;
|
||||
|
||||
ss = cert_self_signed(ctx, x);
|
||||
if (ss < 0)
|
||||
return 0;
|
||||
|
||||
/* Special case: single self signed certificate */
|
||||
if (cert_self_signed(x) && sk_X509_num(ctx->chain) == 1)
|
||||
if (ss > 0 && sk_X509_num(ctx->chain) == 1)
|
||||
return 1;
|
||||
for (i = 0; i < sk_X509_num(ctx->chain); i++) {
|
||||
ch = sk_X509_value(ctx->chain, i);
|
||||
@@ -361,7 +370,8 @@ static int get_issuer_sk(X509 **issuer, X509_STORE_CTX *ctx, X509 *x)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static STACK_OF(X509) *lookup_certs_sk(X509_STORE_CTX *ctx, X509_NAME *nm)
|
||||
static STACK_OF(X509) *lookup_certs_sk(X509_STORE_CTX *ctx,
|
||||
const X509_NAME *nm)
|
||||
{
|
||||
STACK_OF(X509) *sk = NULL;
|
||||
X509 *x;
|
||||
@@ -512,6 +522,12 @@ static int check_chain_extensions(X509_STORE_CTX *ctx)
|
||||
ret = 1;
|
||||
break;
|
||||
}
|
||||
if ((x->ex_flags & EXFLAG_CA) == 0
|
||||
&& x->ex_pathlen != -1
|
||||
&& (ctx->param->flags & X509_V_FLAG_X509_STRICT)) {
|
||||
ctx->error = X509_V_ERR_INVALID_EXTENSION;
|
||||
ret = 0;
|
||||
}
|
||||
if (ret == 0 && !verify_cb_cert(ctx, x, i, X509_V_OK))
|
||||
return 0;
|
||||
/* check_purpose() makes the callback as needed */
|
||||
@@ -1212,7 +1228,7 @@ static void crl_akid_check(X509_STORE_CTX *ctx, X509_CRL *crl,
|
||||
X509 **pissuer, int *pcrl_score)
|
||||
{
|
||||
X509 *crl_issuer = NULL;
|
||||
X509_NAME *cnm = X509_CRL_get_issuer(crl);
|
||||
const X509_NAME *cnm = X509_CRL_get_issuer(crl);
|
||||
int cidx = ctx->error_depth;
|
||||
int i;
|
||||
|
||||
@@ -1388,7 +1404,7 @@ static int idp_check_dp(DIST_POINT_NAME *a, DIST_POINT_NAME *b)
|
||||
static int crldp_check_crlissuer(DIST_POINT *dp, X509_CRL *crl, int crl_score)
|
||||
{
|
||||
int i;
|
||||
X509_NAME *nm = X509_CRL_get_issuer(crl);
|
||||
const X509_NAME *nm = X509_CRL_get_issuer(crl);
|
||||
/* If no CRLissuer return is successful iff don't need a match */
|
||||
if (!dp->CRLissuer)
|
||||
return ! !(crl_score & CRL_SCORE_ISSUER_NAME);
|
||||
@@ -1447,7 +1463,7 @@ static int get_crl_delta(X509_STORE_CTX *ctx,
|
||||
unsigned int reasons;
|
||||
X509_CRL *crl = NULL, *dcrl = NULL;
|
||||
STACK_OF(X509_CRL) *skcrl;
|
||||
X509_NAME *nm = X509_get_issuer_name(x);
|
||||
const X509_NAME *nm = X509_get_issuer_name(x);
|
||||
|
||||
reasons = ctx->current_reasons;
|
||||
ok = get_crl_sk(ctx, &crl, &dcrl,
|
||||
@@ -2052,12 +2068,12 @@ int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx, int idx, void *data)
|
||||
return CRYPTO_set_ex_data(&ctx->ex_data, idx, data);
|
||||
}
|
||||
|
||||
void *X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx, int idx)
|
||||
void *X509_STORE_CTX_get_ex_data(const X509_STORE_CTX *ctx, int idx)
|
||||
{
|
||||
return CRYPTO_get_ex_data(&ctx->ex_data, idx);
|
||||
}
|
||||
|
||||
int X509_STORE_CTX_get_error(X509_STORE_CTX *ctx)
|
||||
int X509_STORE_CTX_get_error(const X509_STORE_CTX *ctx)
|
||||
{
|
||||
return ctx->error;
|
||||
}
|
||||
@@ -2067,7 +2083,7 @@ void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx, int err)
|
||||
ctx->error = err;
|
||||
}
|
||||
|
||||
int X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx)
|
||||
int X509_STORE_CTX_get_error_depth(const X509_STORE_CTX *ctx)
|
||||
{
|
||||
return ctx->error_depth;
|
||||
}
|
||||
@@ -2077,7 +2093,7 @@ void X509_STORE_CTX_set_error_depth(X509_STORE_CTX *ctx, int depth)
|
||||
ctx->error_depth = depth;
|
||||
}
|
||||
|
||||
X509 *X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx)
|
||||
X509 *X509_STORE_CTX_get_current_cert(const X509_STORE_CTX *ctx)
|
||||
{
|
||||
return ctx->current_cert;
|
||||
}
|
||||
@@ -2087,29 +2103,29 @@ void X509_STORE_CTX_set_current_cert(X509_STORE_CTX *ctx, X509 *x)
|
||||
ctx->current_cert = x;
|
||||
}
|
||||
|
||||
STACK_OF(X509) *X509_STORE_CTX_get0_chain(X509_STORE_CTX *ctx)
|
||||
STACK_OF(X509) *X509_STORE_CTX_get0_chain(const X509_STORE_CTX *ctx)
|
||||
{
|
||||
return ctx->chain;
|
||||
}
|
||||
|
||||
STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx)
|
||||
STACK_OF(X509) *X509_STORE_CTX_get1_chain(const X509_STORE_CTX *ctx)
|
||||
{
|
||||
if (!ctx->chain)
|
||||
return NULL;
|
||||
return X509_chain_up_ref(ctx->chain);
|
||||
}
|
||||
|
||||
X509 *X509_STORE_CTX_get0_current_issuer(X509_STORE_CTX *ctx)
|
||||
X509 *X509_STORE_CTX_get0_current_issuer(const X509_STORE_CTX *ctx)
|
||||
{
|
||||
return ctx->current_issuer;
|
||||
}
|
||||
|
||||
X509_CRL *X509_STORE_CTX_get0_current_crl(X509_STORE_CTX *ctx)
|
||||
X509_CRL *X509_STORE_CTX_get0_current_crl(const X509_STORE_CTX *ctx)
|
||||
{
|
||||
return ctx->current_crl;
|
||||
}
|
||||
|
||||
X509_STORE_CTX *X509_STORE_CTX_get0_parent_ctx(X509_STORE_CTX *ctx)
|
||||
X509_STORE_CTX *X509_STORE_CTX_get0_parent_ctx(const X509_STORE_CTX *ctx)
|
||||
{
|
||||
return ctx->parent;
|
||||
}
|
||||
@@ -2205,23 +2221,45 @@ int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose,
|
||||
return 1;
|
||||
}
|
||||
|
||||
X509_STORE_CTX *X509_STORE_CTX_new(void)
|
||||
X509_STORE_CTX *X509_STORE_CTX_new_with_libctx(OPENSSL_CTX *libctx,
|
||||
const char *propq)
|
||||
{
|
||||
X509_STORE_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
|
||||
|
||||
if (ctx == NULL) {
|
||||
X509err(X509_F_X509_STORE_CTX_NEW, ERR_R_MALLOC_FAILURE);
|
||||
X509err(0, ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ctx->libctx = libctx;
|
||||
if (propq != NULL) {
|
||||
ctx->propq = OPENSSL_strdup(propq);
|
||||
if (ctx->propq == NULL) {
|
||||
OPENSSL_free(ctx);
|
||||
X509err(0, ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
X509_STORE_CTX *X509_STORE_CTX_new(void)
|
||||
{
|
||||
return X509_STORE_CTX_new_with_libctx(NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
void X509_STORE_CTX_free(X509_STORE_CTX *ctx)
|
||||
{
|
||||
if (ctx == NULL)
|
||||
return;
|
||||
|
||||
X509_STORE_CTX_cleanup(ctx);
|
||||
|
||||
/* libctx and propq survive X509_STORE_CTX_cleanup() */
|
||||
OPENSSL_free(ctx->propq);
|
||||
|
||||
OPENSSL_free(ctx);
|
||||
}
|
||||
|
||||
@@ -2416,12 +2454,12 @@ void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags,
|
||||
X509_VERIFY_PARAM_set_time(ctx->param, t);
|
||||
}
|
||||
|
||||
X509 *X509_STORE_CTX_get0_cert(X509_STORE_CTX *ctx)
|
||||
X509 *X509_STORE_CTX_get0_cert(const X509_STORE_CTX *ctx)
|
||||
{
|
||||
return ctx->cert;
|
||||
}
|
||||
|
||||
STACK_OF(X509) *X509_STORE_CTX_get0_untrusted(X509_STORE_CTX *ctx)
|
||||
STACK_OF(X509) *X509_STORE_CTX_get0_untrusted(const X509_STORE_CTX *ctx)
|
||||
{
|
||||
return ctx->untrusted;
|
||||
}
|
||||
@@ -2443,7 +2481,7 @@ void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx,
|
||||
ctx->verify_cb = verify_cb;
|
||||
}
|
||||
|
||||
X509_STORE_CTX_verify_cb X509_STORE_CTX_get_verify_cb(X509_STORE_CTX *ctx)
|
||||
X509_STORE_CTX_verify_cb X509_STORE_CTX_get_verify_cb(const X509_STORE_CTX *ctx)
|
||||
{
|
||||
return ctx->verify_cb;
|
||||
}
|
||||
@@ -2454,72 +2492,77 @@ void X509_STORE_CTX_set_verify(X509_STORE_CTX *ctx,
|
||||
ctx->verify = verify;
|
||||
}
|
||||
|
||||
X509_STORE_CTX_verify_fn X509_STORE_CTX_get_verify(X509_STORE_CTX *ctx)
|
||||
X509_STORE_CTX_verify_fn X509_STORE_CTX_get_verify(const X509_STORE_CTX *ctx)
|
||||
{
|
||||
return ctx->verify;
|
||||
}
|
||||
|
||||
X509_STORE_CTX_get_issuer_fn X509_STORE_CTX_get_get_issuer(X509_STORE_CTX *ctx)
|
||||
X509_STORE_CTX_get_issuer_fn X509_STORE_CTX_get_get_issuer(const X509_STORE_CTX *ctx)
|
||||
{
|
||||
return ctx->get_issuer;
|
||||
}
|
||||
|
||||
X509_STORE_CTX_check_issued_fn X509_STORE_CTX_get_check_issued(X509_STORE_CTX *ctx)
|
||||
X509_STORE_CTX_check_issued_fn
|
||||
X509_STORE_CTX_get_check_issued(const X509_STORE_CTX *ctx)
|
||||
{
|
||||
return ctx->check_issued;
|
||||
}
|
||||
|
||||
X509_STORE_CTX_check_revocation_fn X509_STORE_CTX_get_check_revocation(X509_STORE_CTX *ctx)
|
||||
X509_STORE_CTX_check_revocation_fn
|
||||
X509_STORE_CTX_get_check_revocation(const X509_STORE_CTX *ctx)
|
||||
{
|
||||
return ctx->check_revocation;
|
||||
}
|
||||
|
||||
X509_STORE_CTX_get_crl_fn X509_STORE_CTX_get_get_crl(X509_STORE_CTX *ctx)
|
||||
X509_STORE_CTX_get_crl_fn X509_STORE_CTX_get_get_crl(const X509_STORE_CTX *ctx)
|
||||
{
|
||||
return ctx->get_crl;
|
||||
}
|
||||
|
||||
X509_STORE_CTX_check_crl_fn X509_STORE_CTX_get_check_crl(X509_STORE_CTX *ctx)
|
||||
X509_STORE_CTX_check_crl_fn X509_STORE_CTX_get_check_crl(const X509_STORE_CTX *ctx)
|
||||
{
|
||||
return ctx->check_crl;
|
||||
}
|
||||
|
||||
X509_STORE_CTX_cert_crl_fn X509_STORE_CTX_get_cert_crl(X509_STORE_CTX *ctx)
|
||||
X509_STORE_CTX_cert_crl_fn X509_STORE_CTX_get_cert_crl(const X509_STORE_CTX *ctx)
|
||||
{
|
||||
return ctx->cert_crl;
|
||||
}
|
||||
|
||||
X509_STORE_CTX_check_policy_fn X509_STORE_CTX_get_check_policy(X509_STORE_CTX *ctx)
|
||||
X509_STORE_CTX_check_policy_fn
|
||||
X509_STORE_CTX_get_check_policy(const X509_STORE_CTX *ctx)
|
||||
{
|
||||
return ctx->check_policy;
|
||||
}
|
||||
|
||||
X509_STORE_CTX_lookup_certs_fn X509_STORE_CTX_get_lookup_certs(X509_STORE_CTX *ctx)
|
||||
X509_STORE_CTX_lookup_certs_fn
|
||||
X509_STORE_CTX_get_lookup_certs(const X509_STORE_CTX *ctx)
|
||||
{
|
||||
return ctx->lookup_certs;
|
||||
}
|
||||
|
||||
X509_STORE_CTX_lookup_crls_fn X509_STORE_CTX_get_lookup_crls(X509_STORE_CTX *ctx)
|
||||
X509_STORE_CTX_lookup_crls_fn
|
||||
X509_STORE_CTX_get_lookup_crls(const X509_STORE_CTX *ctx)
|
||||
{
|
||||
return ctx->lookup_crls;
|
||||
}
|
||||
|
||||
X509_STORE_CTX_cleanup_fn X509_STORE_CTX_get_cleanup(X509_STORE_CTX *ctx)
|
||||
X509_STORE_CTX_cleanup_fn X509_STORE_CTX_get_cleanup(const X509_STORE_CTX *ctx)
|
||||
{
|
||||
return ctx->cleanup;
|
||||
}
|
||||
|
||||
X509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(X509_STORE_CTX *ctx)
|
||||
X509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(const X509_STORE_CTX *ctx)
|
||||
{
|
||||
return ctx->tree;
|
||||
}
|
||||
|
||||
int X509_STORE_CTX_get_explicit_policy(X509_STORE_CTX *ctx)
|
||||
int X509_STORE_CTX_get_explicit_policy(const X509_STORE_CTX *ctx)
|
||||
{
|
||||
return ctx->explicit_policy;
|
||||
}
|
||||
|
||||
int X509_STORE_CTX_get_num_untrusted(X509_STORE_CTX *ctx)
|
||||
int X509_STORE_CTX_get_num_untrusted(const X509_STORE_CTX *ctx)
|
||||
{
|
||||
return ctx->num_untrusted;
|
||||
}
|
||||
@@ -2534,7 +2577,7 @@ int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name)
|
||||
return X509_VERIFY_PARAM_inherit(ctx->param, param);
|
||||
}
|
||||
|
||||
X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx)
|
||||
X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(const X509_STORE_CTX *ctx)
|
||||
{
|
||||
return ctx->param;
|
||||
}
|
||||
@@ -2890,7 +2933,7 @@ static int build_chain(X509_STORE_CTX *ctx)
|
||||
SSL_DANE *dane = ctx->dane;
|
||||
int num = sk_X509_num(ctx->chain);
|
||||
X509 *cert = sk_X509_value(ctx->chain, num - 1);
|
||||
int ss = cert_self_signed(cert);
|
||||
int ss;
|
||||
STACK_OF(X509) *sktmp = NULL;
|
||||
unsigned int search;
|
||||
int may_trusted = 0;
|
||||
@@ -2908,6 +2951,13 @@ static int build_chain(X509_STORE_CTX *ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
ss = cert_self_signed(ctx, cert);
|
||||
if (ss < 0) {
|
||||
X509err(X509_F_BUILD_CHAIN, ERR_R_INTERNAL_ERROR);
|
||||
ctx->error = X509_V_ERR_UNSPECIFIED;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define S_DOUNTRUSTED (1 << 0) /* Search untrusted chain */
|
||||
#define S_DOTRUSTED (1 << 1) /* Search trusted store */
|
||||
#define S_DOALTERNATE (1 << 2) /* Retry with pruned alternate chain */
|
||||
@@ -3080,7 +3130,12 @@ static int build_chain(X509_STORE_CTX *ctx)
|
||||
search = 0;
|
||||
continue;
|
||||
}
|
||||
ss = cert_self_signed(x);
|
||||
ss = cert_self_signed(ctx, x);
|
||||
if (ss < 0) {
|
||||
X509err(X509_F_BUILD_CHAIN, ERR_R_INTERNAL_ERROR);
|
||||
ctx->error = X509_V_ERR_UNSPECIFIED;
|
||||
return 0;
|
||||
}
|
||||
} else if (num == ctx->num_untrusted) {
|
||||
/*
|
||||
* We have a self-signed certificate that has the same
|
||||
@@ -3192,7 +3247,12 @@ static int build_chain(X509_STORE_CTX *ctx)
|
||||
|
||||
X509_up_ref(x = xtmp);
|
||||
++ctx->num_untrusted;
|
||||
ss = cert_self_signed(xtmp);
|
||||
ss = cert_self_signed(ctx, xtmp);
|
||||
if (ss < 0) {
|
||||
X509err(X509_F_BUILD_CHAIN, ERR_R_INTERNAL_ERROR);
|
||||
ctx->error = X509_V_ERR_UNSPECIFIED;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for DANE-TA trust of the topmost untrusted certificate.
|
||||
|
||||
@@ -398,7 +398,7 @@ unsigned int X509_VERIFY_PARAM_get_hostflags(const X509_VERIFY_PARAM *param)
|
||||
return param->hostflags;
|
||||
}
|
||||
|
||||
char *X509_VERIFY_PARAM_get0_peername(X509_VERIFY_PARAM *param)
|
||||
char *X509_VERIFY_PARAM_get0_peername(const X509_VERIFY_PARAM *param)
|
||||
{
|
||||
return param->peername;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ int X509_CRL_set_version(X509_CRL *x, long version)
|
||||
return ASN1_INTEGER_set(x->crl.version, version);
|
||||
}
|
||||
|
||||
int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name)
|
||||
int X509_CRL_set_issuer_name(X509_CRL *x, const X509_NAME *name)
|
||||
{
|
||||
if (x == NULL)
|
||||
return 0;
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
#include <openssl/x509.h>
|
||||
#include "crypto/x509.h"
|
||||
|
||||
int X509_NAME_get_text_by_NID(X509_NAME *name, int nid, char *buf, int len)
|
||||
int X509_NAME_get_text_by_NID(const X509_NAME *name, int nid,
|
||||
char *buf, int len)
|
||||
{
|
||||
ASN1_OBJECT *obj;
|
||||
|
||||
@@ -26,7 +27,7 @@ int X509_NAME_get_text_by_NID(X509_NAME *name, int nid, char *buf, int len)
|
||||
return X509_NAME_get_text_by_OBJ(name, obj, buf, len);
|
||||
}
|
||||
|
||||
int X509_NAME_get_text_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj,
|
||||
int X509_NAME_get_text_by_OBJ(const X509_NAME *name, const ASN1_OBJECT *obj,
|
||||
char *buf, int len)
|
||||
{
|
||||
int i;
|
||||
@@ -53,7 +54,7 @@ int X509_NAME_entry_count(const X509_NAME *name)
|
||||
return sk_X509_NAME_ENTRY_num(name->entries);
|
||||
}
|
||||
|
||||
int X509_NAME_get_index_by_NID(X509_NAME *name, int nid, int lastpos)
|
||||
int X509_NAME_get_index_by_NID(const X509_NAME *name, int nid, int lastpos)
|
||||
{
|
||||
ASN1_OBJECT *obj;
|
||||
|
||||
@@ -64,7 +65,8 @@ int X509_NAME_get_index_by_NID(X509_NAME *name, int nid, int lastpos)
|
||||
}
|
||||
|
||||
/* NOTE: you should be passing -1, not 0 as lastpos */
|
||||
int X509_NAME_get_index_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, int lastpos)
|
||||
int X509_NAME_get_index_by_OBJ(const X509_NAME *name, const ASN1_OBJECT *obj,
|
||||
int lastpos)
|
||||
{
|
||||
int n;
|
||||
X509_NAME_ENTRY *ne;
|
||||
@@ -216,11 +218,7 @@ int X509_NAME_add_entry(X509_NAME *name, const X509_NAME_ENTRY *ne, int loc,
|
||||
set = sk_X509_NAME_ENTRY_value(sk, loc)->set;
|
||||
}
|
||||
|
||||
/*
|
||||
* X509_NAME_ENTRY_dup is ASN1 generated code, that can't be easily
|
||||
* const'ified; harmless cast since dup() don't modify its input.
|
||||
*/
|
||||
if ((new_name = X509_NAME_ENTRY_dup((X509_NAME_ENTRY *)ne)) == NULL)
|
||||
if ((new_name = X509_NAME_ENTRY_dup(ne)) == NULL)
|
||||
goto err;
|
||||
new_name->set = set;
|
||||
if (!sk_X509_NAME_ENTRY_insert(sk, new_name, loc)) {
|
||||
|
||||
@@ -23,7 +23,7 @@ int X509_REQ_set_version(X509_REQ *x, long version)
|
||||
return ASN1_INTEGER_set(x->req_info.version, version);
|
||||
}
|
||||
|
||||
int X509_REQ_set_subject_name(X509_REQ *x, X509_NAME *name)
|
||||
int X509_REQ_set_subject_name(X509_REQ *x, const X509_NAME *name)
|
||||
{
|
||||
if (x == NULL)
|
||||
return 0;
|
||||
|
||||
+37
-12
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -71,10 +71,7 @@ int X509_verify(X509 *a, EVP_PKEY *r)
|
||||
if (X509_ALGOR_cmp(&a->sig_alg, &a->cert_info.signature))
|
||||
return 0;
|
||||
|
||||
#ifndef OPENSSL_NO_SM2
|
||||
id = a->sm2_id;
|
||||
#endif
|
||||
|
||||
id = a->distinguishing_id;
|
||||
if ((ctx = make_id_ctx(r, id)) != NULL) {
|
||||
rv = ASN1_item_verify_ctx(ASN1_ITEM_rptr(X509_CINF), &a->sig_alg,
|
||||
&a->signature, &a->cert_info, ctx);
|
||||
@@ -89,10 +86,7 @@ int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r)
|
||||
EVP_MD_CTX *ctx = NULL;
|
||||
ASN1_OCTET_STRING *id = NULL;
|
||||
|
||||
#ifndef OPENSSL_NO_SM2
|
||||
id = a->sm2_id;
|
||||
#endif
|
||||
|
||||
id = a->distinguishing_id;
|
||||
if ((ctx = make_id_ctx(r, id)) != NULL) {
|
||||
rv = ASN1_item_verify_ctx(ASN1_ITEM_rptr(X509_REQ_INFO), &a->sig_alg,
|
||||
a->signature, &a->req_info, ctx);
|
||||
@@ -127,7 +121,7 @@ int X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx)
|
||||
static ASN1_VALUE *simple_get_asn1(const char *url, BIO *bio, BIO *rbio,
|
||||
int timeout, const ASN1_ITEM *it)
|
||||
{
|
||||
return OSSL_HTTP_get_asn1(url, NULL, NULL /* no proxy and port */, bio,
|
||||
return OSSL_HTTP_get_asn1(url, NULL, NULL /* no proxy used */, bio,
|
||||
rbio, NULL /* no callback for SSL/TLS */, NULL,
|
||||
NULL /* headers */, 1024 /* maxline */,
|
||||
0 /* max_resp_len */, timeout,
|
||||
@@ -439,7 +433,8 @@ int X509_pubkey_digest(const X509 *data, const EVP_MD *type,
|
||||
int X509_digest(const X509 *data, const EVP_MD *type, unsigned char *md,
|
||||
unsigned int *len)
|
||||
{
|
||||
if (type == EVP_sha1() && (data->ex_flags & EXFLAG_SET) != 0) {
|
||||
if (type == EVP_sha1() && (data->ex_flags & EXFLAG_SET) != 0
|
||||
&& (data->ex_flags & EXFLAG_INVALID) == 0) {
|
||||
/* Asking for SHA1 and we already computed it. */
|
||||
if (len != NULL)
|
||||
*len = sizeof(data->sha1_hash);
|
||||
@@ -450,10 +445,40 @@ int X509_digest(const X509 *data, const EVP_MD *type, unsigned char *md,
|
||||
(ASN1_ITEM_rptr(X509), type, (char *)data, md, len));
|
||||
}
|
||||
|
||||
/* calculate cert digest using the same hash algorithm as in its signature */
|
||||
ASN1_OCTET_STRING *X509_digest_sig(const X509 *cert)
|
||||
{
|
||||
unsigned int len;
|
||||
unsigned char hash[EVP_MAX_MD_SIZE];
|
||||
int md_NID;
|
||||
const EVP_MD *md = NULL;
|
||||
ASN1_OCTET_STRING *new = NULL;
|
||||
|
||||
if (cert == NULL) {
|
||||
X509err(0, ERR_R_PASSED_NULL_PARAMETER);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!OBJ_find_sigid_algs(X509_get_signature_nid(cert), &md_NID, NULL)
|
||||
|| (md = EVP_get_digestbynid(md_NID)) == NULL) {
|
||||
CMPerr(0, X509_R_UNSUPPORTED_ALGORITHM);
|
||||
return NULL;
|
||||
}
|
||||
if (!X509_digest(cert, md, hash, &len)
|
||||
|| (new = ASN1_OCTET_STRING_new()) == NULL)
|
||||
return NULL;
|
||||
if (!(ASN1_OCTET_STRING_set(new, hash, len))) {
|
||||
ASN1_OCTET_STRING_free(new);
|
||||
return NULL;
|
||||
}
|
||||
return new;
|
||||
}
|
||||
|
||||
int X509_CRL_digest(const X509_CRL *data, const EVP_MD *type,
|
||||
unsigned char *md, unsigned int *len)
|
||||
{
|
||||
if (type == EVP_sha1() && (data->flags & EXFLAG_SET) != 0) {
|
||||
if (type == EVP_sha1() && (data->flags & EXFLAG_SET) != 0
|
||||
&& (data->flags & EXFLAG_INVALID) == 0) {
|
||||
/* Asking for SHA1; always computed in CRL d2i. */
|
||||
if (len != NULL)
|
||||
*len = sizeof(data->sha1_hash);
|
||||
|
||||
+33
-20
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
static int X509_REVOKED_cmp(const X509_REVOKED *const *a,
|
||||
const X509_REVOKED *const *b);
|
||||
static void setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp);
|
||||
static int setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp);
|
||||
|
||||
ASN1_SEQUENCE(X509_REVOKED) = {
|
||||
ASN1_EMBED(X509_REVOKED,serialNumber, ASN1_INTEGER),
|
||||
@@ -27,8 +27,8 @@ ASN1_SEQUENCE(X509_REVOKED) = {
|
||||
|
||||
static int def_crl_verify(X509_CRL *crl, EVP_PKEY *r);
|
||||
static int def_crl_lookup(X509_CRL *crl,
|
||||
X509_REVOKED **ret, ASN1_INTEGER *serial,
|
||||
X509_NAME *issuer);
|
||||
X509_REVOKED **ret, const ASN1_INTEGER *serial,
|
||||
const X509_NAME *issuer);
|
||||
|
||||
static X509_CRL_METHOD int_crl_meth = {
|
||||
0,
|
||||
@@ -155,7 +155,7 @@ static int crl_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
X509_CRL *crl = (X509_CRL *)*pval;
|
||||
STACK_OF(X509_EXTENSION) *exts;
|
||||
X509_EXTENSION *ext;
|
||||
int idx;
|
||||
int idx, i;
|
||||
|
||||
switch (operation) {
|
||||
case ASN1_OP_D2I_PRE:
|
||||
@@ -184,23 +184,35 @@ static int crl_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
break;
|
||||
|
||||
case ASN1_OP_D2I_POST:
|
||||
X509_CRL_digest(crl, EVP_sha1(), crl->sha1_hash, NULL);
|
||||
if (!X509_CRL_digest(crl, EVP_sha1(), crl->sha1_hash, NULL))
|
||||
crl->flags |= EXFLAG_INVALID;
|
||||
crl->idp = X509_CRL_get_ext_d2i(crl,
|
||||
NID_issuing_distribution_point, NULL,
|
||||
NID_issuing_distribution_point, &i,
|
||||
NULL);
|
||||
if (crl->idp)
|
||||
setup_idp(crl, crl->idp);
|
||||
if (crl->idp != NULL) {
|
||||
if (!setup_idp(crl, crl->idp))
|
||||
crl->flags |= EXFLAG_INVALID;
|
||||
}
|
||||
else if (i != -1) {
|
||||
crl->flags |= EXFLAG_INVALID;
|
||||
}
|
||||
|
||||
crl->akid = X509_CRL_get_ext_d2i(crl,
|
||||
NID_authority_key_identifier, NULL,
|
||||
NID_authority_key_identifier, &i,
|
||||
NULL);
|
||||
if (crl->akid == NULL && i != -1)
|
||||
crl->flags |= EXFLAG_INVALID;
|
||||
|
||||
crl->crl_number = X509_CRL_get_ext_d2i(crl,
|
||||
NID_crl_number, NULL, NULL);
|
||||
NID_crl_number, &i, NULL);
|
||||
if (crl->crl_number == NULL && i != -1)
|
||||
crl->flags |= EXFLAG_INVALID;
|
||||
|
||||
crl->base_crl_number = X509_CRL_get_ext_d2i(crl,
|
||||
NID_delta_crl, NULL,
|
||||
NID_delta_crl, &i,
|
||||
NULL);
|
||||
if (crl->base_crl_number == NULL && i != -1)
|
||||
crl->flags |= EXFLAG_INVALID;
|
||||
/* Delta CRLs must have CRL number */
|
||||
if (crl->base_crl_number && !crl->crl_number)
|
||||
crl->flags |= EXFLAG_INVALID;
|
||||
@@ -259,9 +271,10 @@ static int crl_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
|
||||
/* Convert IDP into a more convenient form */
|
||||
|
||||
static void setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp)
|
||||
static int setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp)
|
||||
{
|
||||
int idp_only = 0;
|
||||
|
||||
/* Set various flags according to IDP */
|
||||
crl->idp_flags |= IDP_PRESENT;
|
||||
if (idp->onlyuser > 0) {
|
||||
@@ -292,7 +305,7 @@ static void setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp)
|
||||
crl->idp_reasons &= CRLDP_ALL_REASONS;
|
||||
}
|
||||
|
||||
DIST_POINT_set_dpname(idp->distpoint, X509_CRL_get_issuer(crl));
|
||||
return DIST_POINT_set_dpname(idp->distpoint, X509_CRL_get_issuer(crl));
|
||||
}
|
||||
|
||||
ASN1_SEQUENCE_ref(X509_CRL, crl_cb) = {
|
||||
@@ -341,7 +354,7 @@ int X509_CRL_verify(X509_CRL *crl, EVP_PKEY *r)
|
||||
}
|
||||
|
||||
int X509_CRL_get0_by_serial(X509_CRL *crl,
|
||||
X509_REVOKED **ret, ASN1_INTEGER *serial)
|
||||
X509_REVOKED **ret, const ASN1_INTEGER *serial)
|
||||
{
|
||||
if (crl->meth->crl_lookup)
|
||||
return crl->meth->crl_lookup(crl, ret, serial, NULL);
|
||||
@@ -363,7 +376,7 @@ static int def_crl_verify(X509_CRL *crl, EVP_PKEY *r)
|
||||
&crl->sig_alg, &crl->signature, &crl->crl, r));
|
||||
}
|
||||
|
||||
static int crl_revoked_issuer_match(X509_CRL *crl, X509_NAME *nm,
|
||||
static int crl_revoked_issuer_match(X509_CRL *crl, const X509_NAME *nm,
|
||||
X509_REVOKED *rev)
|
||||
{
|
||||
int i;
|
||||
@@ -391,8 +404,8 @@ static int crl_revoked_issuer_match(X509_CRL *crl, X509_NAME *nm,
|
||||
}
|
||||
|
||||
static int def_crl_lookup(X509_CRL *crl,
|
||||
X509_REVOKED **ret, ASN1_INTEGER *serial,
|
||||
X509_NAME *issuer)
|
||||
X509_REVOKED **ret, const ASN1_INTEGER *serial,
|
||||
const X509_NAME *issuer)
|
||||
{
|
||||
X509_REVOKED rtmp, *rev;
|
||||
int idx, num;
|
||||
@@ -441,8 +454,8 @@ X509_CRL_METHOD *X509_CRL_METHOD_new(int (*crl_init) (X509_CRL *crl),
|
||||
int (*crl_free) (X509_CRL *crl),
|
||||
int (*crl_lookup) (X509_CRL *crl,
|
||||
X509_REVOKED **ret,
|
||||
ASN1_INTEGER *ser,
|
||||
X509_NAME *issuer),
|
||||
const ASN1_INTEGER *ser,
|
||||
const X509_NAME *issuer),
|
||||
int (*crl_verify) (X509_CRL *crl,
|
||||
EVP_PKEY *pk))
|
||||
{
|
||||
|
||||
@@ -542,7 +542,7 @@ int X509_NAME_print(BIO *bp, const X509_NAME *name, int obase)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int X509_NAME_get0_der(X509_NAME *nm, const unsigned char **pder,
|
||||
int X509_NAME_get0_der(const X509_NAME *nm, const unsigned char **pder,
|
||||
size_t *pderlen)
|
||||
{
|
||||
/* Make sure encoding is valid */
|
||||
|
||||
+8
-10
@@ -53,14 +53,14 @@ static int req_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
|
||||
switch (operation) {
|
||||
case ASN1_OP_D2I_PRE:
|
||||
ASN1_OCTET_STRING_free(ret->sm2_id);
|
||||
ASN1_OCTET_STRING_free(ret->distinguishing_id);
|
||||
/* fall thru */
|
||||
case ASN1_OP_NEW_POST:
|
||||
ret->sm2_id = NULL;
|
||||
ret->distinguishing_id = NULL;
|
||||
break;
|
||||
|
||||
case ASN1_OP_FREE_POST:
|
||||
ASN1_OCTET_STRING_free(ret->sm2_id);
|
||||
ASN1_OCTET_STRING_free(ret->distinguishing_id);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
@@ -90,15 +90,13 @@ IMPLEMENT_ASN1_FUNCTIONS(X509_REQ)
|
||||
|
||||
IMPLEMENT_ASN1_DUP_FUNCTION(X509_REQ)
|
||||
|
||||
#ifndef OPENSSL_NO_SM2
|
||||
void X509_REQ_set0_sm2_id(X509_REQ *x, ASN1_OCTET_STRING *sm2_id)
|
||||
void X509_REQ_set0_distinguishing_id(X509_REQ *x, ASN1_OCTET_STRING *d_id)
|
||||
{
|
||||
ASN1_OCTET_STRING_free(x->sm2_id);
|
||||
x->sm2_id = sm2_id;
|
||||
ASN1_OCTET_STRING_free(x->distinguishing_id);
|
||||
x->distinguishing_id = d_id;
|
||||
}
|
||||
|
||||
ASN1_OCTET_STRING *X509_REQ_get0_sm2_id(X509_REQ *x)
|
||||
ASN1_OCTET_STRING *X509_REQ_get0_distinguishing_id(X509_REQ *x)
|
||||
{
|
||||
return x->sm2_id;
|
||||
return x->distinguishing_id;
|
||||
}
|
||||
#endif
|
||||
+9
-17
@@ -53,9 +53,7 @@ static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
sk_IPAddressFamily_pop_free(ret->rfc3779_addr, IPAddressFamily_free);
|
||||
ASIdentifiers_free(ret->rfc3779_asid);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SM2
|
||||
ASN1_OCTET_STRING_free(ret->sm2_id);
|
||||
#endif
|
||||
ASN1_OCTET_STRING_free(ret->distinguishing_id);
|
||||
|
||||
/* fall thru */
|
||||
|
||||
@@ -76,9 +74,7 @@ static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
ret->rfc3779_addr = NULL;
|
||||
ret->rfc3779_asid = NULL;
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SM2
|
||||
ret->sm2_id = NULL;
|
||||
#endif
|
||||
ret->distinguishing_id = NULL;
|
||||
ret->aux = NULL;
|
||||
ret->crldp = NULL;
|
||||
if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_X509, ret, &ret->ex_data))
|
||||
@@ -98,9 +94,7 @@ static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
sk_IPAddressFamily_pop_free(ret->rfc3779_addr, IPAddressFamily_free);
|
||||
ASIdentifiers_free(ret->rfc3779_asid);
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SM2
|
||||
ASN1_OCTET_STRING_free(ret->sm2_id);
|
||||
#endif
|
||||
ASN1_OCTET_STRING_free(ret->distinguishing_id);
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -123,7 +117,7 @@ int X509_set_ex_data(X509 *r, int idx, void *arg)
|
||||
return CRYPTO_set_ex_data(&r->ex_data, idx, arg);
|
||||
}
|
||||
|
||||
void *X509_get_ex_data(X509 *r, int idx)
|
||||
void *X509_get_ex_data(const X509 *r, int idx)
|
||||
{
|
||||
return CRYPTO_get_ex_data(&r->ex_data, idx);
|
||||
}
|
||||
@@ -254,15 +248,13 @@ int X509_get_signature_nid(const X509 *x)
|
||||
return OBJ_obj2nid(x->sig_alg.algorithm);
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_SM2
|
||||
void X509_set0_sm2_id(X509 *x, ASN1_OCTET_STRING *sm2_id)
|
||||
void X509_set0_distinguishing_id(X509 *x, ASN1_OCTET_STRING *d_id)
|
||||
{
|
||||
ASN1_OCTET_STRING_free(x->sm2_id);
|
||||
x->sm2_id = sm2_id;
|
||||
ASN1_OCTET_STRING_free(x->distinguishing_id);
|
||||
x->distinguishing_id = d_id;
|
||||
}
|
||||
|
||||
ASN1_OCTET_STRING *X509_get0_sm2_id(X509 *x)
|
||||
ASN1_OCTET_STRING *X509_get0_distinguishing_id(X509 *x)
|
||||
{
|
||||
return x->sm2_id;
|
||||
return x->distinguishing_id;
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user