Update - OpenSSL 1.1.1-pre7-dev
This commit is contained in:
+27
-23
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -48,7 +48,7 @@ static int get_cert_by_subject(X509_LOOKUP *xl, X509_LOOKUP_TYPE type,
|
||||
X509_NAME *name, X509_OBJECT *ret);
|
||||
static X509_LOOKUP_METHOD x509_dir_lookup = {
|
||||
"Load certs from files in a directory",
|
||||
new_dir, /* new */
|
||||
new_dir, /* new_item */
|
||||
free_dir, /* free */
|
||||
NULL, /* init */
|
||||
NULL, /* shutdown */
|
||||
@@ -68,15 +68,13 @@ static int dir_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl,
|
||||
char **retp)
|
||||
{
|
||||
int ret = 0;
|
||||
BY_DIR *ld;
|
||||
char *dir = NULL;
|
||||
|
||||
ld = (BY_DIR *)ctx->method_data;
|
||||
BY_DIR *ld = (BY_DIR *)ctx->method_data;
|
||||
|
||||
switch (cmd) {
|
||||
case X509_L_ADD_DIR:
|
||||
if (argl == X509_FILETYPE_DEFAULT) {
|
||||
dir = (char *)getenv(X509_get_default_cert_dir_env());
|
||||
const char *dir = getenv(X509_get_default_cert_dir_env());
|
||||
|
||||
if (dir)
|
||||
ret = add_cert_dir(ld, dir, X509_FILETYPE_PEM);
|
||||
else
|
||||
@@ -94,23 +92,30 @@ static int dir_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl,
|
||||
|
||||
static int new_dir(X509_LOOKUP *lu)
|
||||
{
|
||||
BY_DIR *a;
|
||||
BY_DIR *a = OPENSSL_malloc(sizeof(*a));
|
||||
|
||||
if ((a = OPENSSL_malloc(sizeof(*a))) == NULL)
|
||||
if (a == NULL) {
|
||||
X509err(X509_F_NEW_DIR, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((a->buffer = BUF_MEM_new()) == NULL) {
|
||||
OPENSSL_free(a);
|
||||
return 0;
|
||||
X509err(X509_F_NEW_DIR, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
a->dirs = NULL;
|
||||
a->lock = CRYPTO_THREAD_lock_new();
|
||||
if (a->lock == NULL) {
|
||||
BUF_MEM_free(a->buffer);
|
||||
OPENSSL_free(a);
|
||||
return 0;
|
||||
X509err(X509_F_NEW_DIR, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
lu->method_data = (char *)a;
|
||||
return 1;
|
||||
|
||||
err:
|
||||
OPENSSL_free(a);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void by_dir_hash_free(BY_DIR_HASH *hash)
|
||||
@@ -137,9 +142,8 @@ static void by_dir_entry_free(BY_DIR_ENTRY *ent)
|
||||
|
||||
static void free_dir(X509_LOOKUP *lu)
|
||||
{
|
||||
BY_DIR *a;
|
||||
BY_DIR *a = (BY_DIR *)lu->method_data;
|
||||
|
||||
a = (BY_DIR *)lu->method_data;
|
||||
sk_BY_DIR_ENTRY_pop_free(a->dirs, by_dir_entry_free);
|
||||
BUF_MEM_free(a->buffer);
|
||||
CRYPTO_THREAD_lock_free(a->lock);
|
||||
@@ -162,6 +166,7 @@ static int add_cert_dir(BY_DIR *ctx, const char *dir, int type)
|
||||
do {
|
||||
if ((*p == LIST_SEPARATOR_CHAR) || (*p == '\0')) {
|
||||
BY_DIR_ENTRY *ent;
|
||||
|
||||
ss = s;
|
||||
s = p + 1;
|
||||
len = p - ss;
|
||||
@@ -182,8 +187,10 @@ static int add_cert_dir(BY_DIR *ctx, const char *dir, int type)
|
||||
}
|
||||
}
|
||||
ent = OPENSSL_malloc(sizeof(*ent));
|
||||
if (ent == NULL)
|
||||
if (ent == NULL) {
|
||||
X509err(X509_F_ADD_CERT_DIR, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
ent->dir_type = type;
|
||||
ent->hashes = sk_BY_DIR_HASH_new(by_dir_hash_cmp);
|
||||
ent->dir = OPENSSL_strndup(ss, len);
|
||||
@@ -193,6 +200,7 @@ static int add_cert_dir(BY_DIR *ctx, const char *dir, int type)
|
||||
}
|
||||
if (!sk_BY_DIR_ENTRY_push(ctx->dirs, ent)) {
|
||||
by_dir_entry_free(ent);
|
||||
X509err(X509_F_ADD_CERT_DIR, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -244,6 +252,7 @@ static int get_cert_by_subject(X509_LOOKUP *xl, X509_LOOKUP_TYPE type,
|
||||
BY_DIR_ENTRY *ent;
|
||||
int idx;
|
||||
BY_DIR_HASH htmp, *hent;
|
||||
|
||||
ent = sk_BY_DIR_ENTRY_value(ctx->dirs, i);
|
||||
j = strlen(ent->dir) + 1 + 8 + 6 + 1 + 1;
|
||||
if (!BUF_MEM_grow(b, j)) {
|
||||
@@ -340,7 +349,7 @@ static int get_cert_by_subject(X509_LOOKUP *xl, X509_LOOKUP_TYPE type,
|
||||
if (idx >= 0)
|
||||
hent = sk_BY_DIR_HASH_value(ent->hashes, idx);
|
||||
}
|
||||
if (!hent) {
|
||||
if (hent == NULL) {
|
||||
hent = OPENSSL_malloc(sizeof(*hent));
|
||||
if (hent == NULL) {
|
||||
CRYPTO_THREAD_unlock(ctx->lock);
|
||||
@@ -353,6 +362,7 @@ static int get_cert_by_subject(X509_LOOKUP *xl, X509_LOOKUP_TYPE type,
|
||||
if (!sk_BY_DIR_HASH_push(ent->hashes, hent)) {
|
||||
CRYPTO_THREAD_unlock(ctx->lock);
|
||||
OPENSSL_free(hent);
|
||||
X509err(X509_F_GET_CERT_BY_SUBJECT, ERR_R_MALLOC_FAILURE);
|
||||
ok = 0;
|
||||
goto finish;
|
||||
}
|
||||
@@ -375,12 +385,6 @@ static int get_cert_by_subject(X509_LOOKUP *xl, X509_LOOKUP_TYPE type,
|
||||
*/
|
||||
ERR_clear_error();
|
||||
|
||||
/*
|
||||
* If we were going to up the reference count, we would need to
|
||||
* do it on a perl 'type' basis
|
||||
*/
|
||||
/*- CRYPTO_add(&tmp->data.x509->references,1,
|
||||
CRYPTO_LOCK_X509);*/
|
||||
goto finish;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -21,7 +21,7 @@ static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc,
|
||||
long argl, char **ret);
|
||||
static X509_LOOKUP_METHOD x509_file_lookup = {
|
||||
"Load file into cache",
|
||||
NULL, /* new */
|
||||
NULL, /* new_item */
|
||||
NULL, /* free */
|
||||
NULL, /* init */
|
||||
NULL, /* shutdown */
|
||||
|
||||
@@ -173,7 +173,7 @@ int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b)
|
||||
|
||||
ret = a->canon_enclen - b->canon_enclen;
|
||||
|
||||
if (ret)
|
||||
if (ret != 0 || a->canon_enclen == 0)
|
||||
return ret;
|
||||
|
||||
return memcmp(a->canon_enc, b->canon_enc, a->canon_enclen);
|
||||
|
||||
+13
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Generated by util/mkerr.pl DO NOT EDIT
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -24,10 +24,13 @@ static const ERR_STRING_DATA X509_str_functs[] = {
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_DIR_CTRL, 0), "dir_ctrl"},
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_GET_CERT_BY_SUBJECT, 0),
|
||||
"get_cert_by_subject"},
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_I2D_X509_AUX, 0), "i2d_X509_AUX"},
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_LOOKUP_CERTS_SK, 0), "lookup_certs_sk"},
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_NETSCAPE_SPKI_B64_DECODE, 0),
|
||||
"NETSCAPE_SPKI_b64_decode"},
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_NETSCAPE_SPKI_B64_ENCODE, 0),
|
||||
"NETSCAPE_SPKI_b64_encode"},
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_NEW_DIR, 0), "new_dir"},
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_X509AT_ADD1_ATTR, 0), "X509at_add1_attr"},
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_X509V3_ADD_EXT, 0), "X509v3_add_ext"},
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_X509_ATTRIBUTE_CREATE_BY_NID, 0),
|
||||
@@ -43,6 +46,8 @@ static const ERR_STRING_DATA X509_str_functs[] = {
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_X509_CHECK_PRIVATE_KEY, 0),
|
||||
"X509_check_private_key"},
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_X509_CRL_DIFF, 0), "X509_CRL_diff"},
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_X509_CRL_METHOD_NEW, 0),
|
||||
"X509_CRL_METHOD_new"},
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_X509_CRL_PRINT_FP, 0), "X509_CRL_print_fp"},
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_X509_EXTENSION_CREATE_BY_NID, 0),
|
||||
"X509_EXTENSION_create_by_NID"},
|
||||
@@ -56,8 +61,10 @@ static const ERR_STRING_DATA X509_str_functs[] = {
|
||||
"X509_load_cert_file"},
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_X509_LOAD_CRL_FILE, 0),
|
||||
"X509_load_crl_file"},
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_X509_LOOKUP_NEW, 0), "X509_LOOKUP_new"},
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_X509_NAME_ADD_ENTRY, 0),
|
||||
"X509_NAME_add_entry"},
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_X509_NAME_CANON, 0), "x509_name_canon"},
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_X509_NAME_ENTRY_CREATE_BY_NID, 0),
|
||||
"X509_NAME_ENTRY_create_by_NID"},
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_X509_NAME_ENTRY_CREATE_BY_TXT, 0),
|
||||
@@ -81,6 +88,8 @@ static const ERR_STRING_DATA X509_str_functs[] = {
|
||||
"X509_STORE_add_cert"},
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_X509_STORE_ADD_CRL, 0),
|
||||
"X509_STORE_add_crl"},
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_X509_STORE_ADD_LOOKUP, 0),
|
||||
"X509_STORE_add_lookup"},
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_X509_STORE_CTX_GET1_ISSUER, 0),
|
||||
"X509_STORE_CTX_get1_issuer"},
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_X509_STORE_CTX_INIT, 0),
|
||||
@@ -89,10 +98,13 @@ static const ERR_STRING_DATA X509_str_functs[] = {
|
||||
"X509_STORE_CTX_new"},
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_X509_STORE_CTX_PURPOSE_INHERIT, 0),
|
||||
"X509_STORE_CTX_purpose_inherit"},
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_X509_STORE_NEW, 0), "X509_STORE_new"},
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_X509_TO_X509_REQ, 0), "X509_to_X509_REQ"},
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_X509_TRUST_ADD, 0), "X509_TRUST_add"},
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_X509_TRUST_SET, 0), "X509_TRUST_set"},
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_X509_VERIFY_CERT, 0), "X509_verify_cert"},
|
||||
{ERR_PACK(ERR_LIB_X509, X509_F_X509_VERIFY_PARAM_NEW, 0),
|
||||
"X509_VERIFY_PARAM_new"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
|
||||
+49
-26
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -17,14 +17,15 @@
|
||||
|
||||
X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method)
|
||||
{
|
||||
X509_LOOKUP *ret;
|
||||
X509_LOOKUP *ret = OPENSSL_zalloc(sizeof(*ret));
|
||||
|
||||
ret = OPENSSL_zalloc(sizeof(*ret));
|
||||
if (ret == NULL)
|
||||
if (ret == NULL) {
|
||||
X509err(X509_F_X509_LOOKUP_NEW, ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret->method = method;
|
||||
if ((method->new_item != NULL) && !method->new_item(ret)) {
|
||||
if (method->new_item != NULL && method->new_item(ret) == 0) {
|
||||
OPENSSL_free(ret);
|
||||
return NULL;
|
||||
}
|
||||
@@ -141,25 +142,36 @@ static int x509_object_cmp(const X509_OBJECT *const *a,
|
||||
|
||||
X509_STORE *X509_STORE_new(void)
|
||||
{
|
||||
X509_STORE *ret;
|
||||
X509_STORE *ret = OPENSSL_zalloc(sizeof(*ret));
|
||||
|
||||
if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL)
|
||||
if (ret == NULL) {
|
||||
X509err(X509_F_X509_STORE_NEW, ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
if ((ret->objs = sk_X509_OBJECT_new(x509_object_cmp)) == NULL)
|
||||
}
|
||||
if ((ret->objs = sk_X509_OBJECT_new(x509_object_cmp)) == NULL) {
|
||||
X509err(X509_F_X509_STORE_NEW, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
ret->cache = 1;
|
||||
if ((ret->get_cert_methods = sk_X509_LOOKUP_new_null()) == NULL)
|
||||
if ((ret->get_cert_methods = sk_X509_LOOKUP_new_null()) == NULL) {
|
||||
X509err(X509_F_X509_STORE_NEW, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if ((ret->param = X509_VERIFY_PARAM_new()) == NULL)
|
||||
if ((ret->param = X509_VERIFY_PARAM_new()) == NULL) {
|
||||
X509err(X509_F_X509_STORE_NEW, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
|
||||
if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_X509_STORE, ret, &ret->ex_data))
|
||||
}
|
||||
if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_X509_STORE, ret, &ret->ex_data)) {
|
||||
X509err(X509_F_X509_STORE_NEW, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret->lock = CRYPTO_THREAD_lock_new();
|
||||
if (ret->lock == NULL)
|
||||
if (ret->lock == NULL) {
|
||||
X509err(X509_F_X509_STORE_NEW, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret->references = 1;
|
||||
return ret;
|
||||
@@ -180,7 +192,6 @@ void X509_STORE_free(X509_STORE *vfy)
|
||||
|
||||
if (vfy == NULL)
|
||||
return;
|
||||
|
||||
CRYPTO_DOWN_REF(&vfy->references, &i, vfy->lock);
|
||||
REF_PRINT_COUNT("X509_STORE", vfy);
|
||||
if (i > 0)
|
||||
@@ -229,17 +240,18 @@ X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m)
|
||||
}
|
||||
/* a new one */
|
||||
lu = X509_LOOKUP_new(m);
|
||||
if (lu == NULL)
|
||||
if (lu == NULL) {
|
||||
X509err(X509_F_X509_STORE_ADD_LOOKUP, ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
else {
|
||||
lu->store_ctx = v;
|
||||
if (sk_X509_LOOKUP_push(v->get_cert_methods, lu))
|
||||
return lu;
|
||||
else {
|
||||
X509_LOOKUP_free(lu);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
lu->store_ctx = v;
|
||||
if (sk_X509_LOOKUP_push(v->get_cert_methods, lu))
|
||||
return lu;
|
||||
/* malloc failed */
|
||||
X509err(X509_F_X509_STORE_ADD_LOOKUP, ERR_R_MALLOC_FAILURE);
|
||||
X509_LOOKUP_free(lu);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
X509_OBJECT *X509_STORE_CTX_get_obj_by_subject(X509_STORE_CTX *vs,
|
||||
@@ -265,6 +277,9 @@ int X509_STORE_CTX_get_by_subject(X509_STORE_CTX *vs, X509_LOOKUP_TYPE type,
|
||||
X509_OBJECT stmp, *tmp;
|
||||
int i, j;
|
||||
|
||||
if (ctx == NULL)
|
||||
return 0;
|
||||
|
||||
CRYPTO_THREAD_write_lock(ctx->lock);
|
||||
tmp = X509_OBJECT_retrieve_by_subject(ctx->objs, type, name);
|
||||
CRYPTO_THREAD_unlock(ctx->lock);
|
||||
@@ -376,7 +391,7 @@ X509_LOOKUP_TYPE X509_OBJECT_get_type(const X509_OBJECT *a)
|
||||
return a->type;
|
||||
}
|
||||
|
||||
X509_OBJECT *X509_OBJECT_new()
|
||||
X509_OBJECT *X509_OBJECT_new(void)
|
||||
{
|
||||
X509_OBJECT *ret = OPENSSL_zalloc(sizeof(*ret));
|
||||
|
||||
@@ -474,6 +489,9 @@ STACK_OF(X509) *X509_STORE_CTX_get1_certs(X509_STORE_CTX *ctx, X509_NAME *nm)
|
||||
X509 *x;
|
||||
X509_OBJECT *obj;
|
||||
|
||||
if (ctx->ctx == NULL)
|
||||
return NULL;
|
||||
|
||||
CRYPTO_THREAD_write_lock(ctx->ctx->lock);
|
||||
idx = x509_object_idx_cnt(ctx->ctx->objs, X509_LU_X509, nm, &cnt);
|
||||
if (idx < 0) {
|
||||
@@ -523,8 +541,10 @@ STACK_OF(X509_CRL) *X509_STORE_CTX_get1_crls(X509_STORE_CTX *ctx, X509_NAME *nm)
|
||||
X509_OBJECT *obj, *xobj = X509_OBJECT_new();
|
||||
|
||||
/* Always do lookup to possibly add new CRLs to cache */
|
||||
if (sk == NULL || xobj == NULL ||
|
||||
!X509_STORE_CTX_get_by_subject(ctx, X509_LU_CRL, nm, xobj)) {
|
||||
if (sk == NULL
|
||||
|| xobj == NULL
|
||||
|| ctx->ctx == NULL
|
||||
|| !X509_STORE_CTX_get_by_subject(ctx, X509_LU_CRL, nm, xobj)) {
|
||||
X509_OBJECT_free(xobj);
|
||||
sk_X509_CRL_free(sk);
|
||||
return NULL;
|
||||
@@ -618,6 +638,9 @@ int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x)
|
||||
}
|
||||
X509_OBJECT_free(obj);
|
||||
|
||||
if (ctx->ctx == NULL)
|
||||
return 0;
|
||||
|
||||
/* Else find index of first cert accepted by 'check_issued' */
|
||||
ret = 0;
|
||||
CRYPTO_THREAD_write_lock(ctx->ctx->lock);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -366,6 +366,7 @@ static STACK_OF(X509) *lookup_certs_sk(X509_STORE_CTX *ctx, X509_NAME *nm)
|
||||
STACK_OF(X509) *sk = NULL;
|
||||
X509 *x;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sk_X509_num(ctx->other_ctx); i++) {
|
||||
x = sk_X509_value(ctx->other_ctx, i);
|
||||
if (X509_NAME_cmp(nm, X509_get_subject_name(x)) == 0) {
|
||||
@@ -373,6 +374,8 @@ static STACK_OF(X509) *lookup_certs_sk(X509_STORE_CTX *ctx, X509_NAME *nm)
|
||||
sk = sk_X509_new_null();
|
||||
if (sk == NULL || sk_X509_push(sk, x) == 0) {
|
||||
sk_X509_pop_free(sk, X509_free);
|
||||
X509err(X509_F_LOOKUP_CERTS_SK, ERR_R_MALLOC_FAILURE);
|
||||
ctx->error = X509_V_ERR_OUT_OF_MEM;
|
||||
return NULL;
|
||||
}
|
||||
X509_up_ref(x);
|
||||
|
||||
+10
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2004-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2004-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -84,13 +84,12 @@ X509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void)
|
||||
X509_VERIFY_PARAM *param;
|
||||
|
||||
param = OPENSSL_zalloc(sizeof(*param));
|
||||
if (param == NULL)
|
||||
if (param == NULL) {
|
||||
X509err(X509_F_X509_VERIFY_PARAM_NEW, ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
param->trust = X509_TRUST_DEFAULT;
|
||||
/*
|
||||
* param->inh_flags = X509_VP_FLAG_DEFAULT;
|
||||
*/
|
||||
param->inh_flags = 0;
|
||||
/* param->inh_flags = X509_VP_FLAG_DEFAULT; */
|
||||
param->depth = -1;
|
||||
param->auth_level = -1; /* -1 means unset, 0 is explicit */
|
||||
return param;
|
||||
@@ -394,6 +393,11 @@ void X509_VERIFY_PARAM_set_hostflags(X509_VERIFY_PARAM *param,
|
||||
param->hostflags = flags;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return param->peername;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -193,7 +193,7 @@ int X509_NAME_add_entry(X509_NAME *name, const X509_NAME_ENTRY *ne, int loc,
|
||||
loc = n;
|
||||
else if (loc < 0)
|
||||
loc = n;
|
||||
|
||||
inc = (set == 0);
|
||||
name->modified = 1;
|
||||
|
||||
if (set == -1) {
|
||||
@@ -202,7 +202,6 @@ int X509_NAME_add_entry(X509_NAME *name, const X509_NAME_ENTRY *ne, int loc,
|
||||
inc = 1;
|
||||
} else {
|
||||
set = sk_X509_NAME_ENTRY_value(sk, loc - 1)->set;
|
||||
inc = 0;
|
||||
}
|
||||
} else { /* if (set >= 0) */
|
||||
|
||||
@@ -213,12 +212,11 @@ int X509_NAME_add_entry(X509_NAME *name, const X509_NAME_ENTRY *ne, int loc,
|
||||
set = 0;
|
||||
} else
|
||||
set = sk_X509_NAME_ENTRY_value(sk, loc)->set;
|
||||
inc = (set == 0) ? 1 : 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* X509_NAME_ENTRY_dup is ASN1 generated code, that can't be easily
|
||||
* const'ified; harmless cast as dup() don't modify its input.
|
||||
* const'ified; harmless cast since dup() don't modify its input.
|
||||
*/
|
||||
if ((new_name = X509_NAME_ENTRY_dup((X509_NAME_ENTRY *)ne)) == NULL)
|
||||
goto err;
|
||||
@@ -230,7 +228,7 @@ int X509_NAME_add_entry(X509_NAME *name, const X509_NAME_ENTRY *ne, int loc,
|
||||
if (inc) {
|
||||
n = sk_X509_NAME_ENTRY_num(sk);
|
||||
for (i = loc + 1; i < n; i++)
|
||||
sk_X509_NAME_ENTRY_value(sk, i - 1)->set += 1;
|
||||
sk_X509_NAME_ENTRY_value(sk, i)->set += 1;
|
||||
}
|
||||
return 1;
|
||||
err:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
+7
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -309,6 +309,7 @@ static int X509_REVOKED_cmp(const X509_REVOKED *const *a,
|
||||
int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev)
|
||||
{
|
||||
X509_CRL_INFO *inf;
|
||||
|
||||
inf = &crl->crl;
|
||||
if (inf->revoked == NULL)
|
||||
inf->revoked = sk_X509_REVOKED_new(X509_REVOKED_cmp);
|
||||
@@ -429,10 +430,12 @@ X509_CRL_METHOD *X509_CRL_METHOD_new(int (*crl_init) (X509_CRL *crl),
|
||||
int (*crl_verify) (X509_CRL *crl,
|
||||
EVP_PKEY *pk))
|
||||
{
|
||||
X509_CRL_METHOD *m;
|
||||
m = OPENSSL_malloc(sizeof(*m));
|
||||
if (m == NULL)
|
||||
X509_CRL_METHOD *m = OPENSSL_malloc(sizeof(*m));
|
||||
|
||||
if (m == NULL) {
|
||||
X509err(X509_F_X509_CRL_METHOD_NEW, ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
m->crl_init = crl_init;
|
||||
m->crl_free = crl_free;
|
||||
m->crl_lookup = crl_lookup;
|
||||
|
||||
+21
-11
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -300,7 +300,7 @@ static int x509_name_ex_print(BIO *out, ASN1_VALUE **pval,
|
||||
static int x509_name_canon(X509_NAME *a)
|
||||
{
|
||||
unsigned char *p;
|
||||
STACK_OF(STACK_OF_X509_NAME_ENTRY) *intname = NULL;
|
||||
STACK_OF(STACK_OF_X509_NAME_ENTRY) *intname;
|
||||
STACK_OF(X509_NAME_ENTRY) *entries = NULL;
|
||||
X509_NAME_ENTRY *entry, *tmpentry = NULL;
|
||||
int i, set = -1, ret = 0, len;
|
||||
@@ -313,44 +313,53 @@ static int x509_name_canon(X509_NAME *a)
|
||||
return 1;
|
||||
}
|
||||
intname = sk_STACK_OF_X509_NAME_ENTRY_new_null();
|
||||
if (!intname)
|
||||
if (intname == NULL) {
|
||||
X509err(X509_F_X509_NAME_CANON, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
for (i = 0; i < sk_X509_NAME_ENTRY_num(a->entries); i++) {
|
||||
entry = sk_X509_NAME_ENTRY_value(a->entries, i);
|
||||
if (entry->set != set) {
|
||||
entries = sk_X509_NAME_ENTRY_new_null();
|
||||
if (!entries)
|
||||
if (entries == NULL)
|
||||
goto err;
|
||||
if (!sk_STACK_OF_X509_NAME_ENTRY_push(intname, entries)) {
|
||||
sk_X509_NAME_ENTRY_free(entries);
|
||||
X509err(X509_F_X509_NAME_CANON, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
set = entry->set;
|
||||
}
|
||||
tmpentry = X509_NAME_ENTRY_new();
|
||||
if (tmpentry == NULL)
|
||||
if (tmpentry == NULL) {
|
||||
X509err(X509_F_X509_NAME_CANON, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
tmpentry->object = OBJ_dup(entry->object);
|
||||
if (tmpentry->object == NULL)
|
||||
if (tmpentry->object == NULL) {
|
||||
X509err(X509_F_X509_NAME_CANON, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
if (!asn1_string_canon(tmpentry->value, entry->value))
|
||||
goto err;
|
||||
if (!sk_X509_NAME_ENTRY_push(entries, tmpentry))
|
||||
if (!sk_X509_NAME_ENTRY_push(entries, tmpentry)) {
|
||||
X509err(X509_F_X509_NAME_CANON, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
tmpentry = NULL;
|
||||
}
|
||||
|
||||
/* Finally generate encoding */
|
||||
|
||||
len = i2d_name_canon(intname, NULL);
|
||||
if (len < 0)
|
||||
goto err;
|
||||
a->canon_enclen = len;
|
||||
|
||||
p = OPENSSL_malloc(a->canon_enclen);
|
||||
|
||||
if (p == NULL)
|
||||
if (p == NULL) {
|
||||
X509err(X509_F_X509_NAME_CANON, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
a->canon_enc = p;
|
||||
|
||||
@@ -359,7 +368,6 @@ static int x509_name_canon(X509_NAME *a)
|
||||
ret = 1;
|
||||
|
||||
err:
|
||||
|
||||
X509_NAME_ENTRY_free(tmpentry);
|
||||
sk_STACK_OF_X509_NAME_ENTRY_pop_free(intname,
|
||||
local_sk_X509_NAME_ENTRY_pop_free);
|
||||
@@ -473,6 +481,8 @@ static int i2d_name_canon(STACK_OF(STACK_OF_X509_NAME_ENTRY) * _intname,
|
||||
|
||||
int X509_NAME_set(X509_NAME **xn, X509_NAME *name)
|
||||
{
|
||||
if (*xn == name)
|
||||
return *xn != NULL;
|
||||
if ((name = X509_NAME_dup(name)) == NULL)
|
||||
return 0;
|
||||
X509_NAME_free(*xn);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -101,7 +101,7 @@ int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey)
|
||||
|
||||
|
||||
static int x509_pubkey_decode(EVP_PKEY **ppkey, X509_PUBKEY *key)
|
||||
{
|
||||
{
|
||||
EVP_PKEY *pkey = EVP_PKEY_new();
|
||||
|
||||
if (pkey == NULL) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -189,8 +189,10 @@ int i2d_X509_AUX(X509 *a, unsigned char **pp)
|
||||
|
||||
/* Allocate requisite combined storage */
|
||||
*pp = tmp = OPENSSL_malloc(length);
|
||||
if (tmp == NULL)
|
||||
return -1; /* Push error onto error stack? */
|
||||
if (tmp == NULL) {
|
||||
X509err(X509_F_I2D_X509_AUX, ERR_R_MALLOC_FAILURE);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Encode, but keep *pp at the originally malloced pointer */
|
||||
length = i2d_x509_aux_internal(a, &tmp);
|
||||
|
||||
Reference in New Issue
Block a user