Latest update, add TLS 1.3 session time configuration.
This commit is contained in:
@@ -9,6 +9,10 @@
|
||||
|
||||
#include "internal/cryptlib.h"
|
||||
|
||||
#if OPENSSL_API_3
|
||||
NON_EMPTY_TRANSLATION_UNIT
|
||||
#else
|
||||
|
||||
#include <openssl/aes.h>
|
||||
#include "aes_locl.h"
|
||||
|
||||
@@ -34,6 +38,7 @@ typedef struct {
|
||||
|
||||
/* N.B. The IV for this mode is _twice_ the block size */
|
||||
|
||||
/* Use of this function is deprecated. */
|
||||
void AES_ige_encrypt(const unsigned char *in, unsigned char *out,
|
||||
size_t length, const AES_KEY *key,
|
||||
unsigned char *ivec, const int enc)
|
||||
@@ -162,6 +167,14 @@ void AES_ige_encrypt(const unsigned char *in, unsigned char *out,
|
||||
/*
|
||||
* Note that its effectively impossible to do biIGE in anything other
|
||||
* than a single pass, so no provision is made for chaining.
|
||||
*
|
||||
* NB: The implementation of AES_bi_ige_encrypt has a bug. It is supposed to use
|
||||
* 2 AES keys, but in fact only one is ever used. This bug has been present
|
||||
* since this code was first implemented. It is believed to have minimal
|
||||
* security impact in practice and has therefore not been fixed for backwards
|
||||
* compatibility reasons.
|
||||
*
|
||||
* Use of this function is deprecated.
|
||||
*/
|
||||
|
||||
/* N.B. The IV for this mode is _four times_ the block size */
|
||||
@@ -282,3 +295,4 @@ void AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out,
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -683,6 +683,12 @@ int BIO_lookup_ex(const char *host, const char *service, int lookup_type,
|
||||
hints.ai_family = family;
|
||||
hints.ai_socktype = socktype;
|
||||
hints.ai_protocol = protocol;
|
||||
#ifdef AI_ADDRCONFIG
|
||||
#ifdef AF_UNSPEC
|
||||
if (family == AF_UNSPEC)
|
||||
#endif
|
||||
hints.ai_flags |= AI_ADDRCONFIG;
|
||||
#endif
|
||||
|
||||
if (lookup_type == BIO_LOOKUP_SERVER)
|
||||
hints.ai_flags |= AI_PASSIVE;
|
||||
|
||||
+13
-6
@@ -108,7 +108,12 @@ static int sock_read(BIO *b, char *out, int outl)
|
||||
|
||||
if (out != NULL) {
|
||||
clear_socket_error();
|
||||
ret = readsocket(b->num, out, outl);
|
||||
# ifndef OPENSSL_NO_KTLS
|
||||
if (BIO_get_ktls_recv(b))
|
||||
ret = ktls_read_record(b->num, out, outl);
|
||||
else
|
||||
# endif
|
||||
ret = readsocket(b->num, out, outl);
|
||||
BIO_clear_retry_flags(b);
|
||||
if (ret <= 0) {
|
||||
if (BIO_sock_should_retry(ret))
|
||||
@@ -177,20 +182,22 @@ static long sock_ctrl(BIO *b, int cmd, long num, void *ptr)
|
||||
ret = 1;
|
||||
break;
|
||||
# ifndef OPENSSL_NO_KTLS
|
||||
case BIO_CTRL_SET_KTLS_SEND:
|
||||
case BIO_CTRL_SET_KTLS:
|
||||
crypto_info = (struct tls12_crypto_info_aes_gcm_128 *)ptr;
|
||||
ret = ktls_start(b->num, crypto_info, sizeof(*crypto_info), num);
|
||||
if (ret)
|
||||
BIO_set_ktls_flag(b);
|
||||
BIO_set_ktls_flag(b, num);
|
||||
break;
|
||||
case BIO_CTRL_GET_KTLS_SEND:
|
||||
return BIO_should_ktls_flag(b);
|
||||
case BIO_CTRL_SET_KTLS_SEND_CTRL_MSG:
|
||||
return BIO_should_ktls_flag(b, 1);
|
||||
case BIO_CTRL_GET_KTLS_RECV:
|
||||
return BIO_should_ktls_flag(b, 0);
|
||||
case BIO_CTRL_SET_KTLS_TX_SEND_CTRL_MSG:
|
||||
BIO_set_ktls_ctrl_msg_flag(b);
|
||||
b->ptr = (void *)num;
|
||||
ret = 0;
|
||||
break;
|
||||
case BIO_CTRL_CLEAR_KTLS_CTRL_MSG:
|
||||
case BIO_CTRL_CLEAR_KTLS_TX_CTRL_MSG:
|
||||
BIO_clear_ktls_ctrl_msg_flag(b);
|
||||
ret = 0;
|
||||
break;
|
||||
|
||||
+7
-1
@@ -9,7 +9,8 @@ SUBDIRS=objects buffer bio stack lhash rand evp asn1 pem x509 x509v3 conf \
|
||||
|
||||
LIBS=../libcrypto
|
||||
# The Core
|
||||
SOURCE[../libcrypto]=provider_core.c provider_predefined.c core_fetch.c
|
||||
SOURCE[../libcrypto]=provider_core.c provider_predefined.c provider_conf.c \
|
||||
core_fetch.c
|
||||
|
||||
# Central utilities
|
||||
SOURCE[../libcrypto]=\
|
||||
@@ -20,6 +21,11 @@ SOURCE[../libcrypto]=\
|
||||
trace.c provider.c params.c \
|
||||
{- $target{cpuid_asm_src} -} {- $target{uplink_aux_src} -}
|
||||
|
||||
# FIPS module
|
||||
SOURCE[../providers/fips]=\
|
||||
cryptlib.c mem.c mem_clr.c params.c
|
||||
|
||||
|
||||
DEPEND[cversion.o]=buildinf.h
|
||||
GENERATE[buildinf.h]=../util/mkbuildinf.pl "$(CC) $(LIB_CFLAGS) $(CPPFLAGS_Q)" "$(PLATFORM)"
|
||||
DEPEND[buildinf.h]=../configdata.pm
|
||||
|
||||
@@ -356,8 +356,10 @@ OPENSSL_INIT_SETTINGS *OPENSSL_INIT_new(void)
|
||||
{
|
||||
OPENSSL_INIT_SETTINGS *ret = malloc(sizeof(*ret));
|
||||
|
||||
if (ret != NULL)
|
||||
memset(ret, 0, sizeof(*ret));
|
||||
if (ret == NULL)
|
||||
return NULL;
|
||||
|
||||
memset(ret, 0, sizeof(*ret));
|
||||
ret->flags = DEFAULT_CONF_MFLAGS;
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/asn1.h>
|
||||
#include <openssl/engine.h>
|
||||
#include "internal/provider.h"
|
||||
#include "conf_lcl.h"
|
||||
|
||||
/* Load all OpenSSL builtin modules */
|
||||
@@ -28,4 +29,5 @@ void OPENSSL_load_builtin_modules(void)
|
||||
#endif
|
||||
EVP_add_alg_module();
|
||||
conf_add_ssl_module();
|
||||
ossl_provider_add_conf_module();
|
||||
}
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "internal/conf.h"
|
||||
#include "internal/dso.h"
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/trace.h>
|
||||
|
||||
#define DSO_mod_init_name "OPENSSL_init"
|
||||
#define DSO_mod_finish_name "OPENSSL_finish"
|
||||
@@ -92,6 +93,7 @@ int CONF_modules_load(const CONF *cnf, const char *appname,
|
||||
return 1;
|
||||
}
|
||||
|
||||
OSSL_TRACE1(CONF, "Configuration in section %s\n", vsection);
|
||||
values = NCONF_get_section(cnf, vsection);
|
||||
|
||||
if (!values)
|
||||
@@ -100,6 +102,8 @@ int CONF_modules_load(const CONF *cnf, const char *appname,
|
||||
for (i = 0; i < sk_CONF_VALUE_num(values); i++) {
|
||||
vl = sk_CONF_VALUE_value(values, i);
|
||||
ret = module_run(cnf, vl->name, vl->value, flags);
|
||||
OSSL_TRACE3(CONF, "Running module %s (%s) returned %d\n",
|
||||
vl->name, vl->value, ret);
|
||||
if (ret <= 0)
|
||||
if (!(flags & CONF_MFLAGS_IGNORE_ERRORS))
|
||||
return ret;
|
||||
|
||||
+3
-2
@@ -35,8 +35,9 @@ static int ossl_method_construct_this(OSSL_PROVIDER *provider, void *cbdata)
|
||||
const OSSL_ALGORITHM *thismap = map++;
|
||||
void *method = NULL;
|
||||
|
||||
if ((method = data->mcm->construct(thismap->implementation, provider,
|
||||
data->mcm_data)) == NULL)
|
||||
if ((method = data->mcm->construct(thismap->algorithm_name,
|
||||
thismap->implementation, provider,
|
||||
data->mcm_data)) == NULL)
|
||||
continue;
|
||||
|
||||
/*
|
||||
|
||||
@@ -50,8 +50,12 @@ static const ERR_STRING_DATA CRYPTO_str_functs[] = {
|
||||
"OSSL_PROVIDER_add_builtin"},
|
||||
{ERR_PACK(ERR_LIB_CRYPTO, CRYPTO_F_OSSL_PROVIDER_ACTIVATE, 0),
|
||||
"ossl_provider_activate"},
|
||||
{ERR_PACK(ERR_LIB_CRYPTO, CRYPTO_F_OSSL_PROVIDER_ADD_PARAMETER, 0),
|
||||
"ossl_provider_add_parameter"},
|
||||
{ERR_PACK(ERR_LIB_CRYPTO, CRYPTO_F_OSSL_PROVIDER_NEW, 0),
|
||||
"ossl_provider_new"},
|
||||
{ERR_PACK(ERR_LIB_CRYPTO, CRYPTO_F_OSSL_PROVIDER_SET_MODULE_PATH, 0),
|
||||
"ossl_provider_set_module_path"},
|
||||
{ERR_PACK(ERR_LIB_CRYPTO, CRYPTO_F_PKEY_HMAC_INIT, 0), "pkey_hmac_init"},
|
||||
{ERR_PACK(ERR_LIB_CRYPTO, CRYPTO_F_PKEY_POLY1305_INIT, 0),
|
||||
"pkey_poly1305_init"},
|
||||
@@ -59,6 +63,10 @@ static const ERR_STRING_DATA CRYPTO_str_functs[] = {
|
||||
"pkey_siphash_init"},
|
||||
{ERR_PACK(ERR_LIB_CRYPTO, CRYPTO_F_PROVIDER_ACTIVATE, 0),
|
||||
"provider_activate"},
|
||||
{ERR_PACK(ERR_LIB_CRYPTO, CRYPTO_F_PROVIDER_CONF_INIT, 0),
|
||||
"provider_conf_init"},
|
||||
{ERR_PACK(ERR_LIB_CRYPTO, CRYPTO_F_PROVIDER_CONF_LOAD, 0),
|
||||
"provider_conf_load"},
|
||||
{ERR_PACK(ERR_LIB_CRYPTO, CRYPTO_F_PROVIDER_NEW, 0), "provider_new"},
|
||||
{ERR_PACK(ERR_LIB_CRYPTO, CRYPTO_F_PROVIDER_STORE_NEW, 0),
|
||||
"provider_store_new"},
|
||||
@@ -75,6 +83,8 @@ static const ERR_STRING_DATA CRYPTO_str_reasons[] = {
|
||||
"odd number of digits"},
|
||||
{ERR_PACK(ERR_LIB_CRYPTO, 0, CRYPTO_R_PROVIDER_ALREADY_EXISTS),
|
||||
"provider already exists"},
|
||||
{ERR_PACK(ERR_LIB_CRYPTO, 0, CRYPTO_R_PROVIDER_SECTION_ERROR),
|
||||
"provider section error"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "dso_locl.h"
|
||||
|
||||
#if !defined(DSO_VMS) && !defined(DSO_DLCFN) && !defined(DSO_DL) && !defined(DSO_WIN32) && !defined(DSO_DLFCN)
|
||||
#ifdef DSO_NONE
|
||||
|
||||
static DSO_METHOD dso_meth_null = {
|
||||
"NULL shared library method"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2016-2019 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
|
||||
@@ -254,6 +254,7 @@ static void x25519_scalar_mulx(uint8_t out[32], const uint8_t scalar[32],
|
||||
#if defined(X25519_ASM) \
|
||||
|| ( (defined(__SIZEOF_INT128__) && __SIZEOF_INT128__ == 16) \
|
||||
&& !defined(__sparc__) \
|
||||
&& (!defined(__SIZEOF_LONG__) || (__SIZEOF_LONG__ == 8)) \
|
||||
&& !(defined(__ANDROID__) && !defined(__clang__)) )
|
||||
/*
|
||||
* Base 2^51 implementation. It's virtually no different from reference
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2017-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2015 Cryptography Research, Inc.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
@@ -24,7 +24,9 @@
|
||||
*/
|
||||
# ifndef C448_WORD_BITS
|
||||
# if (defined(__SIZEOF_INT128__) && (__SIZEOF_INT128__ == 16)) \
|
||||
&& !defined(__sparc__)
|
||||
&& !defined(__sparc__) \
|
||||
&& (!defined(__SIZEOF_LONG__) || (__SIZEOF_LONG__ == 8))
|
||||
|
||||
# define C448_WORD_BITS 64 /* The number of bits in a word */
|
||||
# else
|
||||
# define C448_WORD_BITS 32 /* The number of bits in a word */
|
||||
|
||||
+16
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2002-2019 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
|
||||
@@ -10,6 +10,16 @@
|
||||
#include "ec_lcl.h"
|
||||
#include <openssl/err.h>
|
||||
|
||||
int EC_GROUP_check_named_curve(const EC_GROUP *group, int nist_only)
|
||||
{
|
||||
int nid;
|
||||
|
||||
nid = ec_curve_nid_from_params(group);
|
||||
if (nid > 0 && nist_only && EC_curve_nid2nist(nid) == NULL)
|
||||
nid = NID_undef;
|
||||
return nid;
|
||||
}
|
||||
|
||||
int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx)
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -17,6 +27,11 @@ int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx)
|
||||
BN_CTX *new_ctx = NULL;
|
||||
EC_POINT *point = NULL;
|
||||
|
||||
if (group == NULL || group->meth == NULL) {
|
||||
ECerr(EC_F_EC_GROUP_CHECK, ERR_R_PASSED_NULL_PARAMETER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Custom curves assumed to be correct */
|
||||
if ((group->meth->flags & EC_FLAGS_CUSTOM_CURVE) != 0)
|
||||
return 1;
|
||||
|
||||
+122
-1
@@ -14,6 +14,7 @@
|
||||
#include <openssl/obj_mac.h>
|
||||
#include <openssl/opensslconf.h>
|
||||
#include "internal/nelem.h"
|
||||
#include "internal/o_str.h"
|
||||
|
||||
typedef struct {
|
||||
int field_type, /* either NID_X9_62_prime_field or
|
||||
@@ -1136,6 +1137,7 @@ static const struct {
|
||||
},
|
||||
{
|
||||
/* no seed */
|
||||
/* p */
|
||||
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||||
@@ -1209,6 +1211,7 @@ static const struct {
|
||||
},
|
||||
{
|
||||
/* no seed */
|
||||
/* p */
|
||||
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||||
@@ -1244,6 +1247,7 @@ static const struct {
|
||||
},
|
||||
{
|
||||
/* no seed */
|
||||
/* p */
|
||||
0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xA1,
|
||||
@@ -1278,7 +1282,7 @@ static const struct {
|
||||
NID_X9_62_characteristic_two_field, 20, 36, 2
|
||||
},
|
||||
{
|
||||
/* no seed */
|
||||
/* seed */
|
||||
0x77, 0xE2, 0xB0, 0x73, 0x70, 0xEB, 0x0F, 0x83, 0x2A, 0x6D, 0xD5, 0xB6,
|
||||
0x2D, 0xFC, 0x88, 0xCD, 0x06, 0xBB, 0x84, 0xBE,
|
||||
/* p */
|
||||
@@ -3197,3 +3201,120 @@ int EC_curve_nist2nid(const char *name)
|
||||
}
|
||||
return NID_undef;
|
||||
}
|
||||
|
||||
#define NUM_BN_FIELDS 6
|
||||
/*
|
||||
* Validates EC domain parameter data for known named curves.
|
||||
* This can be used when a curve is loaded explicitly (without a curve
|
||||
* name) or to validate that domain parameters have not been modified.
|
||||
*
|
||||
* Returns: The nid associated with the found named curve, or NID_undef
|
||||
* if not found. If there was an error it returns -1.
|
||||
*/
|
||||
int ec_curve_nid_from_params(const EC_GROUP *group)
|
||||
{
|
||||
int ret = -1, nid, len, field_type, param_len;
|
||||
size_t i, seed_len;
|
||||
const unsigned char *seed, *params_seed, *params;
|
||||
unsigned char *param_bytes = NULL;
|
||||
const EC_CURVE_DATA *data;
|
||||
const EC_POINT *generator = NULL;
|
||||
const EC_METHOD *meth;
|
||||
const BIGNUM *cofactor = NULL;
|
||||
/* An array of BIGNUMs for (p, a, b, x, y, order) */
|
||||
BIGNUM *bn[NUM_BN_FIELDS] = {NULL, NULL, NULL, NULL, NULL, NULL};
|
||||
BN_CTX *ctx = NULL;
|
||||
|
||||
meth = EC_GROUP_method_of(group);
|
||||
if (meth == NULL)
|
||||
return -1;
|
||||
/* Use the optional named curve nid as a search field */
|
||||
nid = EC_GROUP_get_curve_name(group);
|
||||
field_type = EC_METHOD_get_field_type(meth);
|
||||
seed_len = EC_GROUP_get_seed_len(group);
|
||||
seed = EC_GROUP_get0_seed(group);
|
||||
cofactor = EC_GROUP_get0_cofactor(group);
|
||||
|
||||
ctx = BN_CTX_new();
|
||||
if (ctx == NULL)
|
||||
return -1;
|
||||
BN_CTX_start(ctx);
|
||||
|
||||
/*
|
||||
* The built-in curves contains data fields (p, a, b, x, y, order) that are
|
||||
* all zero-padded to be the same size. The size of the padding is
|
||||
* determined by either the number of bytes in the field modulus (p) or the
|
||||
* EC group order, whichever is larger.
|
||||
*/
|
||||
param_len = BN_num_bytes(group->order);
|
||||
len = BN_num_bytes(group->field);
|
||||
if (len > param_len)
|
||||
param_len = len;
|
||||
|
||||
/* Allocate space to store the padded data for (p, a, b, x, y, order) */
|
||||
param_bytes = OPENSSL_malloc(param_len * NUM_BN_FIELDS);
|
||||
if (param_bytes == NULL)
|
||||
goto end;
|
||||
|
||||
/* Create the bignums */
|
||||
for (i = 0; i < NUM_BN_FIELDS; ++i) {
|
||||
if ((bn[i] = BN_CTX_get(ctx)) == NULL)
|
||||
goto end;
|
||||
}
|
||||
/*
|
||||
* Fill in the bn array with the same values as the internal curves
|
||||
* i.e. the values are p, a, b, x, y, order.
|
||||
*/
|
||||
/* Get p, a & b */
|
||||
if (!(EC_GROUP_get_curve(group, bn[0], bn[1], bn[2], ctx)
|
||||
&& ((generator = EC_GROUP_get0_generator(group)) != NULL)
|
||||
/* Get x & y */
|
||||
&& EC_POINT_get_affine_coordinates(group, generator, bn[3], bn[4], ctx)
|
||||
/* Get order */
|
||||
&& EC_GROUP_get_order(group, bn[5], ctx)))
|
||||
goto end;
|
||||
|
||||
/*
|
||||
* Convert the bignum array to bytes that are joined together to form
|
||||
* a single buffer that contains data for all fields.
|
||||
* (p, a, b, x, y, order) are all zero padded to be the same size.
|
||||
*/
|
||||
for (i = 0; i < NUM_BN_FIELDS; ++i) {
|
||||
if (BN_bn2binpad(bn[i], ¶m_bytes[i*param_len], param_len) <= 0)
|
||||
goto end;
|
||||
}
|
||||
|
||||
for (i = 0; i < curve_list_length; i++) {
|
||||
const ec_list_element curve = curve_list[i];
|
||||
|
||||
data = curve.data;
|
||||
/* Get the raw order byte data */
|
||||
params_seed = (const unsigned char *)(data + 1); /* skip header */
|
||||
params = params_seed + data->seed_len;
|
||||
|
||||
/* Look for unique fields in the fixed curve data */
|
||||
if (data->field_type == field_type
|
||||
&& param_len == data->param_len
|
||||
&& (nid <= 0 || nid == curve.nid)
|
||||
/* check the optional cofactor (ignore if its zero) */
|
||||
&& (BN_is_zero(cofactor)
|
||||
|| BN_is_word(cofactor, (const BN_ULONG)curve.data->cofactor))
|
||||
/* Check the optional seed (ignore if its not set) */
|
||||
&& (data->seed_len == 0 || seed_len == 0
|
||||
|| ((size_t)data->seed_len == seed_len
|
||||
&& OPENSSL_memcmp(params_seed, seed, seed_len) == 0))
|
||||
/* Check that the groups params match the built-in curve params */
|
||||
&& OPENSSL_memcmp(param_bytes, params, param_len * NUM_BN_FIELDS)
|
||||
== 0) {
|
||||
ret = curve.nid;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
/* Gets here if the group was not found */
|
||||
ret = NID_undef;
|
||||
end:
|
||||
OPENSSL_free(param_bytes);
|
||||
BN_CTX_end(ctx);
|
||||
BN_CTX_free(ctx);
|
||||
return ret;
|
||||
}
|
||||
+123
-27
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2002-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
@@ -195,59 +195,90 @@ int ossl_ec_key_gen(EC_KEY *eckey)
|
||||
return eckey->group->meth->keygen(eckey);
|
||||
}
|
||||
|
||||
/*
|
||||
* ECC Key generation.
|
||||
* See SP800-56AR3 5.6.1.2.2 "Key Pair Generation by Testing Candidates"
|
||||
*
|
||||
* Params:
|
||||
* eckey An EC key object that contains domain params. The generated keypair
|
||||
* is stored in this object.
|
||||
* Returns 1 if the keypair was generated or 0 otherwise.
|
||||
*/
|
||||
int ec_key_simple_generate_key(EC_KEY *eckey)
|
||||
{
|
||||
int ok = 0;
|
||||
BN_CTX *ctx = NULL;
|
||||
BIGNUM *priv_key = NULL;
|
||||
const BIGNUM *order = NULL;
|
||||
EC_POINT *pub_key = NULL;
|
||||
|
||||
if ((ctx = BN_CTX_new()) == NULL)
|
||||
goto err;
|
||||
const EC_GROUP *group = eckey->group;
|
||||
|
||||
if (eckey->priv_key == NULL) {
|
||||
priv_key = BN_new();
|
||||
priv_key = BN_secure_new();
|
||||
if (priv_key == NULL)
|
||||
goto err;
|
||||
} else
|
||||
priv_key = eckey->priv_key;
|
||||
|
||||
order = EC_GROUP_get0_order(eckey->group);
|
||||
/*
|
||||
* Steps (1-2): Check domain parameters and security strength.
|
||||
* These steps must be done by the user. This would need to be
|
||||
* stated in the security policy.
|
||||
*/
|
||||
|
||||
order = EC_GROUP_get0_order(group);
|
||||
if (order == NULL)
|
||||
goto err;
|
||||
|
||||
/*
|
||||
* Steps (3-7): priv_key = DRBG_RAND(order_n_bits) (range [1, n-1]).
|
||||
* Although this is slightly different from the standard, it is effectively
|
||||
* equivalent as it gives an unbiased result ranging from 1..n-1. It is also
|
||||
* faster as the standard needs to retry more often. Also doing
|
||||
* 1 + rand[0..n-2] would effect the way that tests feed dummy entropy into
|
||||
* rand so the simpler backward compatible method has been used here.
|
||||
*/
|
||||
do
|
||||
if (!BN_priv_rand_range(priv_key, order))
|
||||
goto err;
|
||||
while (BN_is_zero(priv_key)) ;
|
||||
|
||||
if (eckey->pub_key == NULL) {
|
||||
pub_key = EC_POINT_new(eckey->group);
|
||||
pub_key = EC_POINT_new(group);
|
||||
if (pub_key == NULL)
|
||||
goto err;
|
||||
} else
|
||||
pub_key = eckey->pub_key;
|
||||
|
||||
if (!EC_POINT_mul(eckey->group, pub_key, priv_key, NULL, NULL, ctx))
|
||||
/* Step (8) : pub_key = priv_key * G (where G is a point on the curve) */
|
||||
if (!EC_POINT_mul(group, pub_key, priv_key, NULL, NULL, NULL))
|
||||
goto err;
|
||||
|
||||
eckey->priv_key = priv_key;
|
||||
eckey->pub_key = pub_key;
|
||||
priv_key = NULL;
|
||||
pub_key = NULL;
|
||||
|
||||
ok = 1;
|
||||
|
||||
err:
|
||||
if (eckey->pub_key == NULL)
|
||||
EC_POINT_free(pub_key);
|
||||
if (eckey->priv_key != priv_key)
|
||||
BN_free(priv_key);
|
||||
BN_CTX_free(ctx);
|
||||
err:
|
||||
/* Step (9): If there is an error return an invalid keypair. */
|
||||
if (!ok) {
|
||||
BN_clear(eckey->priv_key);
|
||||
if (eckey->pub_key != NULL)
|
||||
EC_POINT_set_to_infinity(group, eckey->pub_key);
|
||||
}
|
||||
|
||||
EC_POINT_free(pub_key);
|
||||
BN_clear_free(priv_key);
|
||||
return ok;
|
||||
}
|
||||
|
||||
int ec_key_simple_generate_public_key(EC_KEY *eckey)
|
||||
{
|
||||
/*
|
||||
* See SP800-56AR3 5.6.1.2.2: Step (8)
|
||||
* pub_key = priv_key * G (where G is a point on the curve)
|
||||
*/
|
||||
return EC_POINT_mul(eckey->group, eckey->pub_key, eckey->priv_key, NULL,
|
||||
NULL, NULL);
|
||||
}
|
||||
@@ -267,6 +298,58 @@ int EC_KEY_check_key(const EC_KEY *eckey)
|
||||
return eckey->group->meth->keycheck(eckey);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check the range of the EC public key.
|
||||
* See SP800-56A R3 Section 5.6.2.3.3 (Part 2)
|
||||
* i.e.
|
||||
* - If q = odd prime p: Verify that xQ and yQ are integers in the
|
||||
* interval[0, p − 1], OR
|
||||
* - If q = 2m: Verify that xQ and yQ are bit strings of length m bits.
|
||||
* Returns 1 if the public key has a valid range, otherwise it returns 0.
|
||||
*/
|
||||
static int ec_key_public_range_check(BN_CTX *ctx, const EC_KEY *key)
|
||||
{
|
||||
int ret = 0;
|
||||
BIGNUM *x, *y;
|
||||
|
||||
BN_CTX_start(ctx);
|
||||
x = BN_CTX_get(ctx);
|
||||
y = BN_CTX_get(ctx);
|
||||
if (y == NULL)
|
||||
goto err;
|
||||
|
||||
if (!EC_POINT_get_affine_coordinates(key->group, key->pub_key, x, y, ctx))
|
||||
goto err;
|
||||
|
||||
if (EC_METHOD_get_field_type(key->group->meth) == NID_X9_62_prime_field) {
|
||||
if (BN_is_negative(x)
|
||||
|| BN_cmp(x, key->group->field) >= 0
|
||||
|| BN_is_negative(y)
|
||||
|| BN_cmp(y, key->group->field) >= 0) {
|
||||
goto err;
|
||||
}
|
||||
} else {
|
||||
int m = EC_GROUP_get_degree(key->group);
|
||||
if (BN_num_bits(x) > m || BN_num_bits(y) > m) {
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
ret = 1;
|
||||
err:
|
||||
BN_CTX_end(ctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* ECC Key validation as specified in SP800-56A R3.
|
||||
* Section 5.6.2.3.3 ECC Full Public-Key Validation
|
||||
* Section 5.6.2.1.2 Owner Assurance of Private-Key Validity
|
||||
* Section 5.6.2.1.4 Owner Assurance of Pair-wise Consistency
|
||||
* NOTES:
|
||||
* Before calling this method in fips mode, there should be an assurance that
|
||||
* an approved elliptic-curve group is used.
|
||||
* Returns 1 if the key is valid, otherwise it returns 0.
|
||||
*/
|
||||
int ec_key_simple_check_key(const EC_KEY *eckey)
|
||||
{
|
||||
int ok = 0;
|
||||
@@ -279,6 +362,7 @@ int ec_key_simple_check_key(const EC_KEY *eckey)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 5.6.2.3.3 (Step 1): Q != infinity */
|
||||
if (EC_POINT_is_at_infinity(eckey->group, eckey->pub_key)) {
|
||||
ECerr(EC_F_EC_KEY_SIMPLE_CHECK_KEY, EC_R_POINT_AT_INFINITY);
|
||||
goto err;
|
||||
@@ -286,20 +370,28 @@ int ec_key_simple_check_key(const EC_KEY *eckey)
|
||||
|
||||
if ((ctx = BN_CTX_new()) == NULL)
|
||||
goto err;
|
||||
|
||||
if ((point = EC_POINT_new(eckey->group)) == NULL)
|
||||
goto err;
|
||||
|
||||
/* testing whether the pub_key is on the elliptic curve */
|
||||
/* 5.6.2.3.3 (Step 2) Test if the public key is in range */
|
||||
if (!ec_key_public_range_check(ctx, eckey)) {
|
||||
ECerr(EC_F_EC_KEY_SIMPLE_CHECK_KEY, EC_R_COORDINATES_OUT_OF_RANGE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* 5.6.2.3.3 (Step 3) is the pub_key on the elliptic curve */
|
||||
if (EC_POINT_is_on_curve(eckey->group, eckey->pub_key, ctx) <= 0) {
|
||||
ECerr(EC_F_EC_KEY_SIMPLE_CHECK_KEY, EC_R_POINT_IS_NOT_ON_CURVE);
|
||||
goto err;
|
||||
}
|
||||
/* testing whether pub_key * order is the point at infinity */
|
||||
|
||||
order = eckey->group->order;
|
||||
if (BN_is_zero(order)) {
|
||||
ECerr(EC_F_EC_KEY_SIMPLE_CHECK_KEY, EC_R_INVALID_GROUP_ORDER);
|
||||
goto err;
|
||||
}
|
||||
/* 5.6.2.3.3 (Step 4) : pub_key * order is the point at infinity. */
|
||||
if (!EC_POINT_mul(eckey->group, point, NULL, eckey->pub_key, order, ctx)) {
|
||||
ECerr(EC_F_EC_KEY_SIMPLE_CHECK_KEY, ERR_R_EC_LIB);
|
||||
goto err;
|
||||
@@ -308,15 +400,21 @@ int ec_key_simple_check_key(const EC_KEY *eckey)
|
||||
ECerr(EC_F_EC_KEY_SIMPLE_CHECK_KEY, EC_R_WRONG_ORDER);
|
||||
goto err;
|
||||
}
|
||||
/*
|
||||
* in case the priv_key is present : check if generator * priv_key ==
|
||||
* pub_key
|
||||
*/
|
||||
|
||||
if (eckey->priv_key != NULL) {
|
||||
if (BN_cmp(eckey->priv_key, order) >= 0) {
|
||||
/*
|
||||
* 5.6.2.1.2 Owner Assurance of Private-Key Validity
|
||||
* The private key is in the range [1, order-1]
|
||||
*/
|
||||
if (BN_cmp(eckey->priv_key, BN_value_one()) < 0
|
||||
|| BN_cmp(eckey->priv_key, order) >= 0) {
|
||||
ECerr(EC_F_EC_KEY_SIMPLE_CHECK_KEY, EC_R_WRONG_ORDER);
|
||||
goto err;
|
||||
}
|
||||
/*
|
||||
* Section 5.6.2.1.4 Owner Assurance of Pair-wise Consistency (b)
|
||||
* Check if generator * priv_key = pub_key
|
||||
*/
|
||||
if (!EC_POINT_mul(eckey->group, point, eckey->priv_key,
|
||||
NULL, NULL, ctx)) {
|
||||
ECerr(EC_F_EC_KEY_SIMPLE_CHECK_KEY, ERR_R_EC_LIB);
|
||||
@@ -368,12 +466,10 @@ int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x,
|
||||
goto err;
|
||||
|
||||
/*
|
||||
* Check if retrieved coordinates match originals and are less than field
|
||||
* order: if not values are out of range.
|
||||
* Check if retrieved coordinates match originals. The range check is done
|
||||
* inside EC_KEY_check_key().
|
||||
*/
|
||||
if (BN_cmp(x, tx) || BN_cmp(y, ty)
|
||||
|| (BN_cmp(x, key->group->field) >= 0)
|
||||
|| (BN_cmp(y, key->group->field) >= 0)) {
|
||||
if (BN_cmp(x, tx) || BN_cmp(y, ty)) {
|
||||
ECerr(EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES,
|
||||
EC_R_COORDINATES_OUT_OF_RANGE);
|
||||
goto err;
|
||||
|
||||
+6
-7
@@ -309,13 +309,10 @@ struct ec_point_st {
|
||||
static ossl_inline int ec_point_is_compat(const EC_POINT *point,
|
||||
const EC_GROUP *group)
|
||||
{
|
||||
if (group->meth != point->meth
|
||||
|| (group->curve_name != 0
|
||||
&& point->curve_name != 0
|
||||
&& group->curve_name != point->curve_name))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
return group->meth == point->meth
|
||||
&& (group->curve_name == 0
|
||||
|| point->curve_name == 0
|
||||
|| group->curve_name == point->curve_name);
|
||||
}
|
||||
|
||||
NISTP224_PRE_COMP *EC_nistp224_pre_comp_dup(NISTP224_PRE_COMP *);
|
||||
@@ -595,6 +592,8 @@ int ec_key_simple_generate_key(EC_KEY *eckey);
|
||||
int ec_key_simple_generate_public_key(EC_KEY *eckey);
|
||||
int ec_key_simple_check_key(const EC_KEY *eckey);
|
||||
|
||||
int ec_curve_nid_from_params(const EC_GROUP *group);
|
||||
|
||||
/* EC_METHOD definitions */
|
||||
|
||||
struct ec_key_method_st {
|
||||
|
||||
+30
-15
@@ -284,15 +284,17 @@ int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator,
|
||||
if (order != NULL) {
|
||||
if (!BN_copy(group->order, order))
|
||||
return 0;
|
||||
} else
|
||||
} else {
|
||||
BN_zero(group->order);
|
||||
}
|
||||
|
||||
/* The cofactor is an optional field, so it should be able to be NULL. */
|
||||
if (cofactor != NULL) {
|
||||
if (!BN_copy(group->cofactor, cofactor))
|
||||
return 0;
|
||||
} else
|
||||
} else {
|
||||
BN_zero(group->cofactor);
|
||||
|
||||
}
|
||||
/*
|
||||
* Some groups have an order with
|
||||
* factors of two, which makes the Montgomery setup fail.
|
||||
@@ -530,30 +532,43 @@ int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx)
|
||||
!b->meth->group_get_curve(b, b1, b2, b3, ctx))
|
||||
r = 1;
|
||||
|
||||
if (r || BN_cmp(a1, b1) || BN_cmp(a2, b2) || BN_cmp(a3, b3))
|
||||
/* return 1 if the curve parameters are different */
|
||||
if (r || BN_cmp(a1, b1) != 0 || BN_cmp(a2, b2) != 0 || BN_cmp(a3, b3) != 0)
|
||||
r = 1;
|
||||
|
||||
/* XXX EC_POINT_cmp() assumes that the methods are equal */
|
||||
/* return 1 if the generators are different */
|
||||
if (r || EC_POINT_cmp(a, EC_GROUP_get0_generator(a),
|
||||
EC_GROUP_get0_generator(b), ctx))
|
||||
EC_GROUP_get0_generator(b), ctx) != 0)
|
||||
r = 1;
|
||||
|
||||
if (!r) {
|
||||
const BIGNUM *ao, *bo, *ac, *bc;
|
||||
/* compare the order and cofactor */
|
||||
/* compare the orders */
|
||||
ao = EC_GROUP_get0_order(a);
|
||||
bo = EC_GROUP_get0_order(b);
|
||||
if (ao == NULL || bo == NULL) {
|
||||
/* return an error if either order is NULL */
|
||||
r = -1;
|
||||
goto end;
|
||||
}
|
||||
if (BN_cmp(ao, bo) != 0) {
|
||||
/* return 1 if orders are different */
|
||||
r = 1;
|
||||
goto end;
|
||||
}
|
||||
/*
|
||||
* It gets here if the curve parameters and generator matched.
|
||||
* Now check the optional cofactors (if both are present).
|
||||
*/
|
||||
ac = EC_GROUP_get0_cofactor(a);
|
||||
bc = EC_GROUP_get0_cofactor(b);
|
||||
if (ao == NULL || bo == NULL) {
|
||||
BN_CTX_end(ctx);
|
||||
BN_CTX_free(ctx_new);
|
||||
return -1;
|
||||
}
|
||||
if (BN_cmp(ao, bo) || BN_cmp(ac, bc))
|
||||
/* Returns 1 (mismatch) if both cofactors are specified and different */
|
||||
if (!BN_is_zero(ac) && !BN_is_zero(bc) && BN_cmp(ac, bc) != 0)
|
||||
r = 1;
|
||||
/* Returns 0 if the parameters matched */
|
||||
}
|
||||
|
||||
end:
|
||||
BN_CTX_end(ctx);
|
||||
BN_CTX_free(ctx_new);
|
||||
|
||||
@@ -622,8 +637,8 @@ int EC_POINT_copy(EC_POINT *dest, const EC_POINT *src)
|
||||
}
|
||||
if (dest->meth != src->meth
|
||||
|| (dest->curve_name != src->curve_name
|
||||
&& dest->curve_name != 0
|
||||
&& src->curve_name != 0)) {
|
||||
&& dest->curve_name != 0
|
||||
&& src->curve_name != 0)) {
|
||||
ECerr(EC_F_EC_POINT_COPY, EC_R_INCOMPATIBLE_OBJECTS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in,
|
||||
}
|
||||
}
|
||||
|
||||
k = BN_new(); /* this value is later returned in *kinvp */
|
||||
k = BN_secure_new(); /* this value is later returned in *kinvp */
|
||||
r = BN_new(); /* this value is later returned in *rp */
|
||||
X = BN_new();
|
||||
if (k == NULL || r == NULL || X == NULL) {
|
||||
|
||||
@@ -49,7 +49,7 @@ static int int_engine_configure(const char *name, const char *value, const CONF
|
||||
int soft = 0;
|
||||
|
||||
name = skip_dot(name);
|
||||
OSSL_TRACE1(ENGINE_CONF, "Configuring engine %s\n", name);
|
||||
OSSL_TRACE1(CONF, "Configuring engine %s\n", name);
|
||||
/* Value is a section containing ENGINE commands */
|
||||
ecmds = NCONF_get_section(cnf, value);
|
||||
|
||||
@@ -63,7 +63,7 @@ static int int_engine_configure(const char *name, const char *value, const CONF
|
||||
ecmd = sk_CONF_VALUE_value(ecmds, i);
|
||||
ctrlname = skip_dot(ecmd->name);
|
||||
ctrlvalue = ecmd->value;
|
||||
OSSL_TRACE2(ENGINE_CONF, "ENGINE conf: doing ctrl(%s,%s)\n",
|
||||
OSSL_TRACE2(CONF, "ENGINE: doing ctrl(%s,%s)\n",
|
||||
ctrlname, ctrlvalue);
|
||||
|
||||
/* First handle some special pseudo ctrls */
|
||||
@@ -148,7 +148,7 @@ static int int_engine_module_init(CONF_IMODULE *md, const CONF *cnf)
|
||||
STACK_OF(CONF_VALUE) *elist;
|
||||
CONF_VALUE *cval;
|
||||
int i;
|
||||
OSSL_TRACE2(ENGINE_CONF, "Called engine module: name %s, value %s\n",
|
||||
OSSL_TRACE2(CONF, "Called engine module: name %s, value %s\n",
|
||||
CONF_imodule_get_name(md), CONF_imodule_get_value(md));
|
||||
/* Value is a section containing ENGINEs to configure */
|
||||
elist = NCONF_get_section(cnf, CONF_imodule_get_value(md));
|
||||
|
||||
@@ -392,11 +392,15 @@ CRYPTO_F_OPENSSL_SK_DEEP_COPY:127:OPENSSL_sk_deep_copy
|
||||
CRYPTO_F_OPENSSL_SK_DUP:128:OPENSSL_sk_dup
|
||||
CRYPTO_F_OSSL_PROVIDER_ACTIVATE:130:ossl_provider_activate
|
||||
CRYPTO_F_OSSL_PROVIDER_ADD_BUILTIN:132:OSSL_PROVIDER_add_builtin
|
||||
CRYPTO_F_OSSL_PROVIDER_ADD_PARAMETER:139:ossl_provider_add_parameter
|
||||
CRYPTO_F_OSSL_PROVIDER_NEW:131:ossl_provider_new
|
||||
CRYPTO_F_OSSL_PROVIDER_SET_MODULE_PATH:140:ossl_provider_set_module_path
|
||||
CRYPTO_F_PKEY_HMAC_INIT:123:pkey_hmac_init
|
||||
CRYPTO_F_PKEY_POLY1305_INIT:124:pkey_poly1305_init
|
||||
CRYPTO_F_PKEY_SIPHASH_INIT:125:pkey_siphash_init
|
||||
CRYPTO_F_PROVIDER_ACTIVATE:134:provider_activate
|
||||
CRYPTO_F_PROVIDER_CONF_INIT:137:provider_conf_init
|
||||
CRYPTO_F_PROVIDER_CONF_LOAD:138:provider_conf_load
|
||||
CRYPTO_F_PROVIDER_NEW:135:provider_new
|
||||
CRYPTO_F_PROVIDER_STORE_NEW:136:provider_store_new
|
||||
CRYPTO_F_SK_RESERVE:129:sk_reserve
|
||||
@@ -750,12 +754,16 @@ ESS_F_ESS_SIGNING_CERT_NEW_INIT:102:ESS_SIGNING_CERT_new_init
|
||||
ESS_F_ESS_SIGNING_CERT_V2_ADD:105:ESS_SIGNING_CERT_V2_add
|
||||
ESS_F_ESS_SIGNING_CERT_V2_NEW_INIT:103:ESS_SIGNING_CERT_V2_new_init
|
||||
EVP_F_AESNI_INIT_KEY:165:aesni_init_key
|
||||
EVP_F_AESNI_XTS_INIT_KEY:233:aesni_xts_init_key
|
||||
EVP_F_AES_GCM_CTRL:196:aes_gcm_ctrl
|
||||
EVP_F_AES_GCM_TLS_CIPHER:207:aes_gcm_tls_cipher
|
||||
EVP_F_AES_INIT_KEY:133:aes_init_key
|
||||
EVP_F_AES_OCB_CIPHER:169:aes_ocb_cipher
|
||||
EVP_F_AES_T4_INIT_KEY:178:aes_t4_init_key
|
||||
EVP_F_AES_T4_XTS_INIT_KEY:234:aes_t4_xts_init_key
|
||||
EVP_F_AES_WRAP_CIPHER:170:aes_wrap_cipher
|
||||
EVP_F_AES_XTS_CIPHER:229:aes_xts_cipher
|
||||
EVP_F_AES_XTS_INIT_KEY:235:aes_xts_init_key
|
||||
EVP_F_ALG_MODULE_INIT:177:alg_module_init
|
||||
EVP_F_ARIA_CCM_INIT_KEY:175:aria_ccm_init_key
|
||||
EVP_F_ARIA_GCM_CTRL:197:aria_gcm_ctrl
|
||||
@@ -795,6 +803,7 @@ EVP_F_EVP_MAC_CTRL_STR:210:EVP_MAC_ctrl_str
|
||||
EVP_F_EVP_MAC_CTX_COPY:211:EVP_MAC_CTX_copy
|
||||
EVP_F_EVP_MAC_CTX_NEW:213:EVP_MAC_CTX_new
|
||||
EVP_F_EVP_MAC_INIT:212:EVP_MAC_init
|
||||
EVP_F_EVP_MD_BLOCK_SIZE:232:EVP_MD_block_size
|
||||
EVP_F_EVP_MD_CTX_COPY_EX:110:EVP_MD_CTX_copy_ex
|
||||
EVP_F_EVP_MD_SIZE:162:EVP_MD_size
|
||||
EVP_F_EVP_OPENINIT:102:EVP_OpenInit
|
||||
@@ -849,6 +858,7 @@ EVP_F_EVP_PKEY_VERIFY:142:EVP_PKEY_verify
|
||||
EVP_F_EVP_PKEY_VERIFY_INIT:143:EVP_PKEY_verify_init
|
||||
EVP_F_EVP_PKEY_VERIFY_RECOVER:144:EVP_PKEY_verify_recover
|
||||
EVP_F_EVP_PKEY_VERIFY_RECOVER_INIT:145:EVP_PKEY_verify_recover_init
|
||||
EVP_F_EVP_SET_DEFAULT_PROPERTIES:236:EVP_set_default_properties
|
||||
EVP_F_EVP_SIGNFINAL:107:EVP_SignFinal
|
||||
EVP_F_EVP_VERIFYFINAL:108:EVP_VerifyFinal
|
||||
EVP_F_GMAC_CTRL:215:gmac_ctrl
|
||||
@@ -1093,6 +1103,7 @@ PROP_F_PARSE_OCT:105:parse_oct
|
||||
PROP_F_PARSE_STRING:106:parse_string
|
||||
PROP_F_PARSE_UNQUOTED:107:parse_unquoted
|
||||
RAND_F_DRBG_BYTES:101:drbg_bytes
|
||||
RAND_F_DRBG_CTR_INIT:125:drbg_ctr_init
|
||||
RAND_F_DRBG_GET_ENTROPY:105:drbg_get_entropy
|
||||
RAND_F_DRBG_SETUP:117:drbg_setup
|
||||
RAND_F_GET_ENTROPY:106:get_entropy
|
||||
@@ -2159,6 +2170,7 @@ CRYPTO_R_FIPS_MODE_NOT_SUPPORTED:101:fips mode not supported
|
||||
CRYPTO_R_ILLEGAL_HEX_DIGIT:102:illegal hex digit
|
||||
CRYPTO_R_ODD_NUMBER_OF_DIGITS:103:odd number of digits
|
||||
CRYPTO_R_PROVIDER_ALREADY_EXISTS:104:provider already exists
|
||||
CRYPTO_R_PROVIDER_SECTION_ERROR:105:provider section error
|
||||
CT_R_BASE64_DECODE_ERROR:108:base64 decode error
|
||||
CT_R_INVALID_LOG_ID_LENGTH:100:invalid log id length
|
||||
CT_R_LOG_CONF_INVALID:109:log conf invalid
|
||||
@@ -2413,6 +2425,8 @@ EVP_R_UNSUPPORTED_SALT_TYPE:126:unsupported salt type
|
||||
EVP_R_UPDATE_ERROR:189:update error
|
||||
EVP_R_WRAP_MODE_NOT_ALLOWED:170:wrap mode not allowed
|
||||
EVP_R_WRONG_FINAL_BLOCK_LENGTH:109:wrong final block length
|
||||
EVP_R_XTS_DATA_UNIT_IS_TOO_LARGE:191:xts data unit is too large
|
||||
EVP_R_XTS_DUPLICATED_KEYS:192:xts duplicated keys
|
||||
KDF_R_INVALID_DIGEST:100:invalid digest
|
||||
KDF_R_INVALID_MAC_TYPE:116:invalid mac type
|
||||
KDF_R_MISSING_ITERATION_COUNT:109:missing iteration count
|
||||
@@ -2594,6 +2608,8 @@ RAND_R_ADDITIONAL_INPUT_TOO_LONG:102:additional input too long
|
||||
RAND_R_ALREADY_INSTANTIATED:103:already instantiated
|
||||
RAND_R_ARGUMENT_OUT_OF_RANGE:105:argument out of range
|
||||
RAND_R_CANNOT_OPEN_FILE:121:Cannot open file
|
||||
RAND_R_DERIVATION_FUNCTION_MANDATORY_FOR_FIPS:137:\
|
||||
derivation function mandatory for fips
|
||||
RAND_R_DRBG_ALREADY_INITIALIZED:129:drbg already initialized
|
||||
RAND_R_DRBG_NOT_INITIALISED:104:drbg not initialised
|
||||
RAND_R_ENTROPY_INPUT_TOO_LONG:106:entropy input too long
|
||||
|
||||
+18
-1
@@ -83,6 +83,7 @@ void EVP_MD_CTX_free(EVP_MD_CTX *ctx)
|
||||
EVP_MD_meth_free(ctx->fetched_digest);
|
||||
ctx->fetched_digest = NULL;
|
||||
ctx->digest = NULL;
|
||||
ctx->reqdigest = NULL;
|
||||
|
||||
OPENSSL_free(ctx);
|
||||
return;
|
||||
@@ -106,6 +107,9 @@ int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl)
|
||||
|
||||
EVP_MD_CTX_clear_flags(ctx, EVP_MD_CTX_FLAG_CLEANED);
|
||||
|
||||
if (type != NULL)
|
||||
ctx->reqdigest = type;
|
||||
|
||||
/* TODO(3.0): Legacy work around code below. Remove this */
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
/*
|
||||
@@ -141,6 +145,7 @@ int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl)
|
||||
if (type->prov == NULL) {
|
||||
switch(type->type) {
|
||||
case NID_sha256:
|
||||
case NID_md2:
|
||||
break;
|
||||
default:
|
||||
goto legacy;
|
||||
@@ -545,6 +550,11 @@ static void *evp_md_from_dispatch(int mdtype, const OSSL_DISPATCH *fns,
|
||||
break;
|
||||
md->size = OSSL_get_OP_digest_size(fns);
|
||||
break;
|
||||
case OSSL_FUNC_DIGEST_BLOCK_SIZE:
|
||||
if (md->dblock_size != NULL)
|
||||
break;
|
||||
md->dblock_size = OSSL_get_OP_digest_block_size(fns);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((fncnt != 0 && fncnt != 5)
|
||||
@@ -576,10 +586,17 @@ static void evp_md_free(void *md)
|
||||
EVP_MD_meth_free(md);
|
||||
}
|
||||
|
||||
static int evp_md_nid(void *vmd)
|
||||
{
|
||||
EVP_MD *md = vmd;
|
||||
|
||||
return md->type;
|
||||
}
|
||||
|
||||
EVP_MD *EVP_MD_fetch(OPENSSL_CTX *ctx, const char *algorithm,
|
||||
const char *properties)
|
||||
{
|
||||
return evp_generic_fetch(ctx, OSSL_OP_DIGEST, algorithm, properties,
|
||||
evp_md_from_dispatch, evp_md_upref,
|
||||
evp_md_free);
|
||||
evp_md_free, evp_md_nid);
|
||||
}
|
||||
+80
-53
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2001-2019 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
|
||||
@@ -390,22 +390,33 @@ static int aesni_xts_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
return 1;
|
||||
|
||||
if (key) {
|
||||
/* The key is two half length keys in reality */
|
||||
const int bytes = EVP_CIPHER_CTX_key_length(ctx) / 2;
|
||||
const int bits = bytes * 8;
|
||||
|
||||
/*
|
||||
* Verify that the two keys are different.
|
||||
*
|
||||
* This addresses Rogaway's vulnerability.
|
||||
* See comment in aes_xts_init_key() below.
|
||||
*/
|
||||
if (memcmp(key, key + bytes, bytes) == 0) {
|
||||
EVPerr(EVP_F_AESNI_XTS_INIT_KEY, EVP_R_XTS_DUPLICATED_KEYS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* key_len is two AES keys */
|
||||
if (enc) {
|
||||
aesni_set_encrypt_key(key, EVP_CIPHER_CTX_key_length(ctx) * 4,
|
||||
&xctx->ks1.ks);
|
||||
aesni_set_encrypt_key(key, bits, &xctx->ks1.ks);
|
||||
xctx->xts.block1 = (block128_f) aesni_encrypt;
|
||||
xctx->stream = aesni_xts_encrypt;
|
||||
} else {
|
||||
aesni_set_decrypt_key(key, EVP_CIPHER_CTX_key_length(ctx) * 4,
|
||||
&xctx->ks1.ks);
|
||||
aesni_set_decrypt_key(key, bits, &xctx->ks1.ks);
|
||||
xctx->xts.block1 = (block128_f) aesni_decrypt;
|
||||
xctx->stream = aesni_xts_decrypt;
|
||||
}
|
||||
|
||||
aesni_set_encrypt_key(key + EVP_CIPHER_CTX_key_length(ctx) / 2,
|
||||
EVP_CIPHER_CTX_key_length(ctx) * 4,
|
||||
&xctx->ks2.ks);
|
||||
aesni_set_encrypt_key(key + bytes, bits, &xctx->ks2.ks);
|
||||
xctx->xts.block2 = (block128_f) aesni_encrypt;
|
||||
|
||||
xctx->xts.key1 = &xctx->ks1;
|
||||
@@ -796,7 +807,21 @@ static int aes_t4_xts_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
return 1;
|
||||
|
||||
if (key) {
|
||||
int bits = EVP_CIPHER_CTX_key_length(ctx) * 4;
|
||||
/* The key is two half length keys in reality */
|
||||
const int bytes = EVP_CIPHER_CTX_key_length(ctx) / 2;
|
||||
const int bits = bytes * 8;
|
||||
|
||||
/*
|
||||
* Verify that the two keys are different.
|
||||
*
|
||||
* This addresses Rogaway's vulnerability.
|
||||
* See comment in aes_xts_init_key() below.
|
||||
*/
|
||||
if (memcmp(key, key + bytes, bytes) == 0) {
|
||||
EVPerr(EVP_F_AES_T4_XTS_INIT_KEY, EVP_R_XTS_DUPLICATED_KEYS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
xctx->stream = NULL;
|
||||
/* key_len is two AES keys */
|
||||
if (enc) {
|
||||
@@ -813,8 +838,7 @@ static int aes_t4_xts_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
aes_t4_set_decrypt_key(key, EVP_CIPHER_CTX_key_length(ctx) * 4,
|
||||
&xctx->ks1.ks);
|
||||
aes_t4_set_decrypt_key(key, bits, &xctx->ks1.ks);
|
||||
xctx->xts.block1 = (block128_f) aes_t4_decrypt;
|
||||
switch (bits) {
|
||||
case 128:
|
||||
@@ -828,9 +852,7 @@ static int aes_t4_xts_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
}
|
||||
}
|
||||
|
||||
aes_t4_set_encrypt_key(key + EVP_CIPHER_CTX_key_length(ctx) / 2,
|
||||
EVP_CIPHER_CTX_key_length(ctx) * 4,
|
||||
&xctx->ks2.ks);
|
||||
aes_t4_set_encrypt_key(key + bytes, bits, &xctx->ks2.ks);
|
||||
xctx->xts.block2 = (block128_f) aes_t4_encrypt;
|
||||
|
||||
xctx->xts.key1 = &xctx->ks1;
|
||||
@@ -3414,8 +3436,33 @@ static int aes_xts_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
if (!iv && !key)
|
||||
return 1;
|
||||
|
||||
if (key)
|
||||
if (key) {
|
||||
do {
|
||||
/* The key is two half length keys in reality */
|
||||
const int bytes = EVP_CIPHER_CTX_key_length(ctx) / 2;
|
||||
const int bits = bytes * 8;
|
||||
|
||||
/*
|
||||
* Verify that the two keys are different.
|
||||
*
|
||||
* This addresses the vulnerability described in Rogaway's
|
||||
* September 2004 paper:
|
||||
*
|
||||
* "Efficient Instantiations of Tweakable Blockciphers and
|
||||
* Refinements to Modes OCB and PMAC".
|
||||
* (http://web.cs.ucdavis.edu/~rogaway/papers/offsets.pdf)
|
||||
*
|
||||
* FIPS 140-2 IG A.9 XTS-AES Key Generation Requirements states
|
||||
* that:
|
||||
* "The check for Key_1 != Key_2 shall be done at any place
|
||||
* BEFORE using the keys in the XTS-AES algorithm to process
|
||||
* data with them."
|
||||
*/
|
||||
if (memcmp(key, key + bytes, bytes) == 0) {
|
||||
EVPerr(EVP_F_AES_XTS_INIT_KEY, EVP_R_XTS_DUPLICATED_KEYS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef AES_XTS_ASM
|
||||
xctx->stream = enc ? AES_xts_encrypt : AES_xts_decrypt;
|
||||
#else
|
||||
@@ -3425,26 +3472,20 @@ static int aes_xts_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
#ifdef HWAES_CAPABLE
|
||||
if (HWAES_CAPABLE) {
|
||||
if (enc) {
|
||||
HWAES_set_encrypt_key(key,
|
||||
EVP_CIPHER_CTX_key_length(ctx) * 4,
|
||||
&xctx->ks1.ks);
|
||||
HWAES_set_encrypt_key(key, bits, &xctx->ks1.ks);
|
||||
xctx->xts.block1 = (block128_f) HWAES_encrypt;
|
||||
# ifdef HWAES_xts_encrypt
|
||||
xctx->stream = HWAES_xts_encrypt;
|
||||
# endif
|
||||
} else {
|
||||
HWAES_set_decrypt_key(key,
|
||||
EVP_CIPHER_CTX_key_length(ctx) * 4,
|
||||
&xctx->ks1.ks);
|
||||
HWAES_set_decrypt_key(key, bits, &xctx->ks1.ks);
|
||||
xctx->xts.block1 = (block128_f) HWAES_decrypt;
|
||||
# ifdef HWAES_xts_decrypt
|
||||
xctx->stream = HWAES_xts_decrypt;
|
||||
#endif
|
||||
}
|
||||
|
||||
HWAES_set_encrypt_key(key + EVP_CIPHER_CTX_key_length(ctx) / 2,
|
||||
EVP_CIPHER_CTX_key_length(ctx) * 4,
|
||||
&xctx->ks2.ks);
|
||||
HWAES_set_encrypt_key(key + bytes, bits, &xctx->ks2.ks);
|
||||
xctx->xts.block2 = (block128_f) HWAES_encrypt;
|
||||
|
||||
xctx->xts.key1 = &xctx->ks1;
|
||||
@@ -3459,20 +3500,14 @@ static int aes_xts_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
#ifdef VPAES_CAPABLE
|
||||
if (VPAES_CAPABLE) {
|
||||
if (enc) {
|
||||
vpaes_set_encrypt_key(key,
|
||||
EVP_CIPHER_CTX_key_length(ctx) * 4,
|
||||
&xctx->ks1.ks);
|
||||
vpaes_set_encrypt_key(key, bits, &xctx->ks1.ks);
|
||||
xctx->xts.block1 = (block128_f) vpaes_encrypt;
|
||||
} else {
|
||||
vpaes_set_decrypt_key(key,
|
||||
EVP_CIPHER_CTX_key_length(ctx) * 4,
|
||||
&xctx->ks1.ks);
|
||||
vpaes_set_decrypt_key(key, bits, &xctx->ks1.ks);
|
||||
xctx->xts.block1 = (block128_f) vpaes_decrypt;
|
||||
}
|
||||
|
||||
vpaes_set_encrypt_key(key + EVP_CIPHER_CTX_key_length(ctx) / 2,
|
||||
EVP_CIPHER_CTX_key_length(ctx) * 4,
|
||||
&xctx->ks2.ks);
|
||||
vpaes_set_encrypt_key(key + bytes, bits, &xctx->ks2.ks);
|
||||
xctx->xts.block2 = (block128_f) vpaes_encrypt;
|
||||
|
||||
xctx->xts.key1 = &xctx->ks1;
|
||||
@@ -3482,22 +3517,19 @@ static int aes_xts_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
(void)0; /* terminate potentially open 'else' */
|
||||
|
||||
if (enc) {
|
||||
AES_set_encrypt_key(key, EVP_CIPHER_CTX_key_length(ctx) * 4,
|
||||
&xctx->ks1.ks);
|
||||
AES_set_encrypt_key(key, bits, &xctx->ks1.ks);
|
||||
xctx->xts.block1 = (block128_f) AES_encrypt;
|
||||
} else {
|
||||
AES_set_decrypt_key(key, EVP_CIPHER_CTX_key_length(ctx) * 4,
|
||||
&xctx->ks1.ks);
|
||||
AES_set_decrypt_key(key, bits, &xctx->ks1.ks);
|
||||
xctx->xts.block1 = (block128_f) AES_decrypt;
|
||||
}
|
||||
|
||||
AES_set_encrypt_key(key + EVP_CIPHER_CTX_key_length(ctx) / 2,
|
||||
EVP_CIPHER_CTX_key_length(ctx) * 4,
|
||||
&xctx->ks2.ks);
|
||||
AES_set_encrypt_key(key + bytes, bits, &xctx->ks2.ks);
|
||||
xctx->xts.block2 = (block128_f) AES_encrypt;
|
||||
|
||||
xctx->xts.key1 = &xctx->ks1;
|
||||
} while (0);
|
||||
}
|
||||
|
||||
if (iv) {
|
||||
xctx->xts.key2 = &xctx->ks2;
|
||||
@@ -3520,20 +3552,15 @@ static int aes_xts_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* Verify that the two keys are different.
|
||||
*
|
||||
* This addresses the vulnerability described in Rogaway's September 2004
|
||||
* paper (http://web.cs.ucdavis.edu/~rogaway/papers/offsets.pdf):
|
||||
* "Efficient Instantiations of Tweakable Blockciphers and Refinements
|
||||
* to Modes OCB and PMAC".
|
||||
*
|
||||
* FIPS 140-2 IG A.9 XTS-AES Key Generation Requirements states that:
|
||||
* "The check for Key_1 != Key_2 shall be done at any place BEFORE
|
||||
* using the keys in the XTS-AES algorithm to process data with them."
|
||||
*/
|
||||
if (CRYPTO_memcmp(xctx->xts.key1, xctx->xts.key2,
|
||||
EVP_CIPHER_CTX_key_length(ctx) / 2) == 0)
|
||||
* Impose a limit of 2^20 blocks per data unit as specifed by
|
||||
* IEEE Std 1619-2018. The earlier and obsolete IEEE Std 1619-2007
|
||||
* indicated that this was a SHOULD NOT rather than a MUST NOT.
|
||||
* NIST SP 800-38E mandates the same limit.
|
||||
*/
|
||||
if (len > XTS_MAX_BLOCKS_PER_DATA_UNIT * AES_BLOCK_SIZE) {
|
||||
EVPerr(EVP_F_AES_XTS_CIPHER, EVP_R_XTS_DATA_UNIT_IS_TOO_LARGE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (xctx->stream)
|
||||
(*xctx->stream) (in, out, len,
|
||||
|
||||
@@ -671,7 +671,7 @@ static EVP_CIPHER chacha20_poly1305_draft = {
|
||||
NID_chacha20_poly1305_draft,
|
||||
1, /* block_size */
|
||||
CHACHA_KEY_SIZE, /* key_len */
|
||||
0, /* iv_len, none */
|
||||
0, /* iv_len, none */
|
||||
EVP_CIPH_FLAG_AEAD_CIPHER | EVP_CIPH_CUSTOM_IV |
|
||||
EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CTRL_INIT |
|
||||
EVP_CIPH_CUSTOM_COPY | EVP_CIPH_FLAG_CUSTOM_CIPHER,
|
||||
|
||||
+18
-4
@@ -13,9 +13,11 @@
|
||||
#include <openssl/conf.h>
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/x509v3.h>
|
||||
#include <openssl/trace.h>
|
||||
|
||||
/* Algorithm configuration module. */
|
||||
|
||||
/* TODO(3.0): the config module functions should be passed a library context */
|
||||
static int alg_module_init(CONF_IMODULE *md, const CONF *cnf)
|
||||
{
|
||||
int i;
|
||||
@@ -23,6 +25,9 @@ static int alg_module_init(CONF_IMODULE *md, const CONF *cnf)
|
||||
STACK_OF(CONF_VALUE) *sktmp;
|
||||
CONF_VALUE *oval;
|
||||
|
||||
OSSL_TRACE2(CONF, "Loading EVP module: name %s, value %s\n",
|
||||
CONF_imodule_get_name(md), CONF_imodule_get_value(md));
|
||||
|
||||
oid_section = CONF_imodule_get_value(md);
|
||||
if ((sktmp = NCONF_get_section(cnf, oid_section)) == NULL) {
|
||||
EVPerr(EVP_F_ALG_MODULE_INIT, EVP_R_ERROR_LOADING_SECTION);
|
||||
@@ -32,18 +37,26 @@ static int alg_module_init(CONF_IMODULE *md, const CONF *cnf)
|
||||
oval = sk_CONF_VALUE_value(sktmp, i);
|
||||
if (strcmp(oval->name, "fips_mode") == 0) {
|
||||
int m;
|
||||
|
||||
if (!X509V3_get_value_bool(oval, &m)) {
|
||||
EVPerr(EVP_F_ALG_MODULE_INIT, EVP_R_INVALID_FIPS_MODE);
|
||||
return 0;
|
||||
}
|
||||
if (m > 0) {
|
||||
EVPerr(EVP_F_ALG_MODULE_INIT, EVP_R_FIPS_MODE_NOT_SUPPORTED);
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* fips_mode is deprecated and should not be used in new
|
||||
* configurations. Old configurations are likely to ONLY
|
||||
* have this, so we assume that no default properties have
|
||||
* been set before this.
|
||||
*/
|
||||
if (m > 0)
|
||||
EVP_set_default_properties(NULL, "fips=yes");
|
||||
} else if (strcmp(oval->name, "default_properties") == 0) {
|
||||
EVP_set_default_properties(NULL, oval->value);
|
||||
} else {
|
||||
EVPerr(EVP_F_ALG_MODULE_INIT, EVP_R_UNKNOWN_OPTION);
|
||||
ERR_add_error_data(4, "name=", oval->name,
|
||||
", value=", oval->value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -52,5 +65,6 @@ static int alg_module_init(CONF_IMODULE *md, const CONF *cnf)
|
||||
|
||||
void EVP_add_alg_module(void)
|
||||
{
|
||||
OSSL_TRACE(CONF, "Adding config module 'alg_section'\n");
|
||||
CONF_module_add("alg_section", alg_module_init, 0);
|
||||
}
|
||||
+10
-9
@@ -305,6 +305,11 @@ static int evp_EncryptDecryptUpdate(EVP_CIPHER_CTX *ctx,
|
||||
|
||||
bl = ctx->cipher->block_size;
|
||||
|
||||
if (inl <= 0) {
|
||||
*outl = 0;
|
||||
return inl == 0;
|
||||
}
|
||||
|
||||
if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {
|
||||
/* If block size > 1 then the cipher will have to do this check */
|
||||
if (bl == 1 && is_partially_overlapping(out, in, cmpl)) {
|
||||
@@ -320,10 +325,6 @@ static int evp_EncryptDecryptUpdate(EVP_CIPHER_CTX *ctx,
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (inl <= 0) {
|
||||
*outl = 0;
|
||||
return inl == 0;
|
||||
}
|
||||
if (is_partially_overlapping(out + ctx->buf_len, in, cmpl)) {
|
||||
EVPerr(EVP_F_EVP_ENCRYPTDECRYPTUPDATE, EVP_R_PARTIALLY_OVERLAPPING);
|
||||
return 0;
|
||||
@@ -457,6 +458,11 @@ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
|
||||
if (EVP_CIPHER_CTX_test_flags(ctx, EVP_CIPH_FLAG_LENGTH_BITS))
|
||||
cmpl = (cmpl + 7) / 8;
|
||||
|
||||
if (inl <= 0) {
|
||||
*outl = 0;
|
||||
return inl == 0;
|
||||
}
|
||||
|
||||
if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {
|
||||
if (b == 1 && is_partially_overlapping(out, in, cmpl)) {
|
||||
EVPerr(EVP_F_EVP_DECRYPTUPDATE, EVP_R_PARTIALLY_OVERLAPPING);
|
||||
@@ -472,11 +478,6 @@ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (inl <= 0) {
|
||||
*outl = 0;
|
||||
return inl == 0;
|
||||
}
|
||||
|
||||
if (ctx->flags & EVP_CIPH_NO_PADDING)
|
||||
return evp_EncryptDecryptUpdate(ctx, out, outl, in, inl);
|
||||
|
||||
|
||||
@@ -15,12 +15,17 @@
|
||||
|
||||
static const ERR_STRING_DATA EVP_str_functs[] = {
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_AESNI_INIT_KEY, 0), "aesni_init_key"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_AESNI_XTS_INIT_KEY, 0), "aesni_xts_init_key"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_AES_GCM_CTRL, 0), "aes_gcm_ctrl"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_AES_GCM_TLS_CIPHER, 0), "aes_gcm_tls_cipher"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_AES_INIT_KEY, 0), "aes_init_key"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_AES_OCB_CIPHER, 0), "aes_ocb_cipher"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_AES_T4_INIT_KEY, 0), "aes_t4_init_key"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_AES_T4_XTS_INIT_KEY, 0),
|
||||
"aes_t4_xts_init_key"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_AES_WRAP_CIPHER, 0), "aes_wrap_cipher"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_AES_XTS_CIPHER, 0), "aes_xts_cipher"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_AES_XTS_INIT_KEY, 0), "aes_xts_init_key"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_ALG_MODULE_INIT, 0), "alg_module_init"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_ARIA_CCM_INIT_KEY, 0), "aria_ccm_init_key"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_ARIA_GCM_CTRL, 0), "aria_gcm_ctrl"},
|
||||
@@ -70,6 +75,7 @@ static const ERR_STRING_DATA EVP_str_functs[] = {
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_MAC_CTX_COPY, 0), "EVP_MAC_CTX_copy"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_MAC_CTX_NEW, 0), "EVP_MAC_CTX_new"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_MAC_INIT, 0), "EVP_MAC_init"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_MD_BLOCK_SIZE, 0), "EVP_MD_block_size"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_MD_CTX_COPY_EX, 0), "EVP_MD_CTX_copy_ex"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_MD_SIZE, 0), "EVP_MD_size"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_OPENINIT, 0), "EVP_OpenInit"},
|
||||
@@ -150,6 +156,8 @@ static const ERR_STRING_DATA EVP_str_functs[] = {
|
||||
"EVP_PKEY_verify_recover"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_PKEY_VERIFY_RECOVER_INIT, 0),
|
||||
"EVP_PKEY_verify_recover_init"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_SET_DEFAULT_PROPERTIES, 0),
|
||||
"EVP_set_default_properties"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_SIGNFINAL, 0), "EVP_SignFinal"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_EVP_VERIFYFINAL, 0), "EVP_VerifyFinal"},
|
||||
{ERR_PACK(ERR_LIB_EVP, EVP_F_GMAC_CTRL, 0), "gmac_ctrl"},
|
||||
@@ -303,6 +311,10 @@ static const ERR_STRING_DATA EVP_str_reasons[] = {
|
||||
"wrap mode not allowed"},
|
||||
{ERR_PACK(ERR_LIB_EVP, 0, EVP_R_WRONG_FINAL_BLOCK_LENGTH),
|
||||
"wrong final block length"},
|
||||
{ERR_PACK(ERR_LIB_EVP, 0, EVP_R_XTS_DATA_UNIT_IS_TOO_LARGE),
|
||||
"xts data unit is too large"},
|
||||
{ERR_PACK(ERR_LIB_EVP, 0, EVP_R_XTS_DUPLICATED_KEYS),
|
||||
"xts duplicated keys"},
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
|
||||
+29
-11
@@ -62,6 +62,7 @@ struct method_data_st {
|
||||
OSSL_PROVIDER *);
|
||||
int (*refcnt_up_method)(void *method);
|
||||
void (*destruct_method)(void *method);
|
||||
int (*nid_method)(void *method);
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -78,8 +79,7 @@ static void *alloc_tmp_method_store(void)
|
||||
ossl_method_store_free(store);
|
||||
}
|
||||
|
||||
static
|
||||
struct OSSL_METHOD_STORE *get_default_method_store(OPENSSL_CTX *libctx)
|
||||
static OSSL_METHOD_STORE *get_default_method_store(OPENSSL_CTX *libctx)
|
||||
{
|
||||
if (!RUN_ONCE(&default_method_store_init_flag,
|
||||
do_default_method_store_init))
|
||||
@@ -107,29 +107,35 @@ static void *get_method_from_store(OPENSSL_CTX *libctx, void *store,
|
||||
}
|
||||
|
||||
static int put_method_in_store(OPENSSL_CTX *libctx, void *store,
|
||||
const char *propdef, void *method,
|
||||
void *data)
|
||||
const char *propdef,
|
||||
void *method, void *data)
|
||||
{
|
||||
struct method_data_st *methdata = data;
|
||||
int nid = methdata->nid_method(method);
|
||||
|
||||
if (nid == NID_undef)
|
||||
return 0;
|
||||
|
||||
if (store == NULL
|
||||
&& (store = get_default_method_store(libctx)) == NULL)
|
||||
return 0;
|
||||
|
||||
if (methdata->refcnt_up_method(method)
|
||||
&& ossl_method_store_add(store, methdata->nid, propdef, method,
|
||||
&& ossl_method_store_add(store, nid, propdef, method,
|
||||
methdata->destruct_method))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void *construct_method(const OSSL_DISPATCH *fns, OSSL_PROVIDER *prov,
|
||||
static void *construct_method(const char *algorithm_name,
|
||||
const OSSL_DISPATCH *fns, OSSL_PROVIDER *prov,
|
||||
void *data)
|
||||
{
|
||||
struct method_data_st *methdata = data;
|
||||
void *method = NULL;
|
||||
int nid = OBJ_sn2nid(algorithm_name);
|
||||
|
||||
if (methdata->nid == NID_undef) {
|
||||
if (nid == NID_undef) {
|
||||
/* Create a new NID for that name on the fly */
|
||||
ASN1_OBJECT tmpobj;
|
||||
|
||||
@@ -140,13 +146,13 @@ static void *construct_method(const OSSL_DISPATCH *fns, OSSL_PROVIDER *prov,
|
||||
tmpobj.length = 0;
|
||||
tmpobj.data = NULL;
|
||||
|
||||
methdata->nid = OBJ_add_object(&tmpobj);
|
||||
nid = OBJ_add_object(&tmpobj);
|
||||
}
|
||||
|
||||
if (methdata->nid == NID_undef)
|
||||
if (nid == NID_undef)
|
||||
return NULL;
|
||||
|
||||
method = methdata->method_from_dispatch(methdata->nid, fns, prov);
|
||||
method = methdata->method_from_dispatch(nid, fns, prov);
|
||||
if (method == NULL)
|
||||
return NULL;
|
||||
return method;
|
||||
@@ -164,7 +170,8 @@ void *evp_generic_fetch(OPENSSL_CTX *libctx, int operation_id,
|
||||
void *(*new_method)(int nid, const OSSL_DISPATCH *fns,
|
||||
OSSL_PROVIDER *prov),
|
||||
int (*upref_method)(void *),
|
||||
void (*free_method)(void *))
|
||||
void (*free_method)(void *),
|
||||
int (*nid_method)(void *))
|
||||
{
|
||||
int nid = OBJ_sn2nid(algorithm);
|
||||
void *method = NULL;
|
||||
@@ -187,6 +194,7 @@ void *evp_generic_fetch(OPENSSL_CTX *libctx, int operation_id,
|
||||
mcmdata.destruct_method = free_method;
|
||||
mcmdata.refcnt_up_method = upref_method;
|
||||
mcmdata.destruct_method = free_method;
|
||||
mcmdata.nid_method = nid_method;
|
||||
method = ossl_method_construct(libctx, operation_id, algorithm,
|
||||
properties, 0 /* !force_cache */,
|
||||
&mcm, &mcmdata);
|
||||
@@ -195,3 +203,13 @@ void *evp_generic_fetch(OPENSSL_CTX *libctx, int operation_id,
|
||||
|
||||
return method;
|
||||
}
|
||||
|
||||
int EVP_set_default_properties(OPENSSL_CTX *libctx, const char *propq)
|
||||
{
|
||||
OSSL_METHOD_STORE *store = get_default_method_store(libctx);
|
||||
|
||||
if (store != NULL)
|
||||
return ossl_method_store_set_global_properties(store, propq);
|
||||
EVPerr(EVP_F_EVP_SET_DEFAULT_PROPERTIES, ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
+10
-2
@@ -298,6 +298,14 @@ int EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx)
|
||||
|
||||
int EVP_MD_block_size(const EVP_MD *md)
|
||||
{
|
||||
if (md == NULL) {
|
||||
EVPerr(EVP_F_EVP_MD_BLOCK_SIZE, EVP_R_MESSAGE_DIGEST_IS_NULL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (md->prov != NULL && md->dblock_size != NULL)
|
||||
return (int)md->dblock_size();
|
||||
|
||||
return md->block_size;
|
||||
}
|
||||
|
||||
@@ -479,9 +487,9 @@ int (*EVP_MD_meth_get_ctrl(const EVP_MD *md))(EVP_MD_CTX *ctx, int cmd,
|
||||
|
||||
const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx)
|
||||
{
|
||||
if (!ctx)
|
||||
if (ctx == NULL)
|
||||
return NULL;
|
||||
return ctx->digest;
|
||||
return ctx->reqdigest;
|
||||
}
|
||||
|
||||
EVP_PKEY_CTX *EVP_MD_CTX_pkey_ctx(const EVP_MD_CTX *ctx)
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
/* EVP_MD_CTX related stuff */
|
||||
|
||||
struct evp_md_ctx_st {
|
||||
const EVP_MD *reqdigest; /* The original requested digest */
|
||||
const EVP_MD *digest;
|
||||
ENGINE *engine; /* functional reference if 'digest' is
|
||||
* ENGINE-provided */
|
||||
@@ -89,4 +90,5 @@ void *evp_generic_fetch(OPENSSL_CTX *ctx, int operation_id,
|
||||
void *(*new_method)(int nid, const OSSL_DISPATCH *fns,
|
||||
OSSL_PROVIDER *prov),
|
||||
int (*upref_method)(void *),
|
||||
void (*free_method)(void *));
|
||||
void (*free_method)(void *),
|
||||
int (*nid_method)(void *));
|
||||
+1
-1
@@ -40,7 +40,7 @@ int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
|
||||
}
|
||||
|
||||
size = EVP_PKEY_size(priv);
|
||||
key = OPENSSL_malloc(size + 2);
|
||||
key = OPENSSL_malloc(size);
|
||||
if (key == NULL) {
|
||||
/* ERROR */
|
||||
EVPerr(EVP_F_EVP_OPENINIT, ERR_R_MALLOC_FAILURE);
|
||||
|
||||
+7
-2
@@ -235,7 +235,7 @@ int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
|
||||
return 0;
|
||||
}
|
||||
for (i = 0; i < mx; i++) {
|
||||
if (storage[i] && storage[i]->new_func) {
|
||||
if (storage[i] != NULL && storage[i]->new_func != NULL) {
|
||||
ptr = CRYPTO_get_ex_data(ad, i);
|
||||
storage[i]->new_func(obj, ptr, ad, i,
|
||||
storage[i]->argl, storage[i]->argp);
|
||||
@@ -299,7 +299,7 @@ int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
|
||||
|
||||
for (i = 0; i < mx; i++) {
|
||||
ptr = CRYPTO_get_ex_data(from, i);
|
||||
if (storage[i] && storage[i]->dup_func)
|
||||
if (storage[i] != NULL && storage[i]->dup_func != NULL)
|
||||
if (!storage[i]->dup_func(to, from, &ptr, i,
|
||||
storage[i]->argl, storage[i]->argp))
|
||||
goto err;
|
||||
@@ -380,6 +380,8 @@ int CRYPTO_alloc_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad,
|
||||
return 1;
|
||||
|
||||
ip = get_and_lock(class_index);
|
||||
if (ip == NULL)
|
||||
return 0;
|
||||
f = sk_EX_CALLBACK_value(ip->meth, idx);
|
||||
CRYPTO_THREAD_unlock(ex_data_lock);
|
||||
|
||||
@@ -387,6 +389,9 @@ int CRYPTO_alloc_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad,
|
||||
* This should end up calling CRYPTO_set_ex_data(), which allocates
|
||||
* everything necessary to support placing the new data in the right spot.
|
||||
*/
|
||||
if (f->new_func == NULL)
|
||||
return 0;
|
||||
|
||||
f->new_func(obj, curval, ad, idx, f->argl, f->argp);
|
||||
|
||||
return 1;
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
#ifndef HEADER_DSO_CONF_H
|
||||
# define HEADER_DSO_CONF_H
|
||||
{- output_off() if $disabled{dso} -}
|
||||
{- # The DSO code currently always implements all functions so that no
|
||||
# applications will have to worry about that from a compilation point
|
||||
# of view. However, the "method"s may return zero unless that platform
|
||||
@@ -18,6 +17,9 @@
|
||||
# by a define "DSO_<name>" ... we translate the "dso_scheme" config
|
||||
# string entry into using the following logic;
|
||||
my $scheme = uc $target{dso_scheme};
|
||||
if (!$scheme) {
|
||||
$scheme = "NONE";
|
||||
}
|
||||
my @macros = ( "DSO_$scheme" );
|
||||
if ($scheme eq 'DLFCN') {
|
||||
@macros = ( "DSO_DLFCN", "HAVE_DLFCN_H" );
|
||||
@@ -26,5 +28,4 @@
|
||||
}
|
||||
join("\n", map { "# define $_" } @macros); -}
|
||||
# define DSO_EXTENSION "{- platform->dsoext() -}"
|
||||
{- output_on() if $disabled{dso} -}
|
||||
#endif
|
||||
@@ -204,6 +204,7 @@ struct evp_md_st {
|
||||
OSSL_OP_digest_freectx_fn *freectx;
|
||||
OSSL_OP_digest_dupctx_fn *dupctx;
|
||||
OSSL_OP_digest_size_fn *size;
|
||||
OSSL_OP_digest_block_size_fn *dblock_size;
|
||||
|
||||
} /* EVP_MD */ ;
|
||||
|
||||
|
||||
@@ -184,7 +184,7 @@ struct x509_st {
|
||||
CRYPTO_RWLOCK *lock;
|
||||
volatile int ex_cached;
|
||||
# ifndef OPENSSL_NO_SM2
|
||||
ASN1_OCTET_STRING sm2_id;
|
||||
ASN1_OCTET_STRING *sm2_id;
|
||||
# endif
|
||||
} /* X509 */ ;
|
||||
|
||||
|
||||
+5
-7
@@ -160,8 +160,7 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_load_crypto_nodelete)
|
||||
{
|
||||
OSSL_TRACE(INIT, "ossl_init_load_crypto_nodelete()\n");
|
||||
|
||||
#if !defined(OPENSSL_NO_DSO) \
|
||||
&& !defined(OPENSSL_USE_NODELETE) \
|
||||
#if !defined(OPENSSL_USE_NODELETE) \
|
||||
&& !defined(OPENSSL_NO_PINSHARED)
|
||||
# if defined(DSO_WIN32) && !defined(_WIN32_WCE)
|
||||
{
|
||||
@@ -179,7 +178,7 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_load_crypto_nodelete)
|
||||
(ret == TRUE ? "No!" : "Yes."));
|
||||
return (ret == TRUE) ? 1 : 0;
|
||||
}
|
||||
# else
|
||||
# elif !defined(DSO_NONE)
|
||||
/*
|
||||
* Deliberately leak a reference to ourselves. This will force the library
|
||||
* to remain loaded until the atexit() handler is run at process exit.
|
||||
@@ -671,7 +670,7 @@ int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings)
|
||||
ret = RUN_ONCE(&config, ossl_init_config);
|
||||
conf_settings = NULL;
|
||||
CRYPTO_THREAD_unlock(init_lock);
|
||||
if (!ret)
|
||||
if (ret <= 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -733,8 +732,7 @@ int OPENSSL_atexit(void (*handler)(void))
|
||||
{
|
||||
OPENSSL_INIT_STOP *newhand;
|
||||
|
||||
#if !defined(OPENSSL_NO_DSO) \
|
||||
&& !defined(OPENSSL_USE_NODELETE)\
|
||||
#if !defined(OPENSSL_USE_NODELETE)\
|
||||
&& !defined(OPENSSL_NO_PINSHARED)
|
||||
{
|
||||
union {
|
||||
@@ -759,7 +757,7 @@ int OPENSSL_atexit(void (*handler)(void))
|
||||
if (!ret)
|
||||
return 0;
|
||||
}
|
||||
# else
|
||||
# elif !defined(DSO_NONE)
|
||||
/*
|
||||
* Deliberately leak a reference to the handler. This will force the
|
||||
* library/code containing the handler to remain loaded until we run the
|
||||
|
||||
+27
-7
@@ -182,6 +182,8 @@ static int kdf_hkdf_ctrl_str(EVP_KDF_IMPL *impl, const char *type,
|
||||
|
||||
static size_t kdf_hkdf_size(EVP_KDF_IMPL *impl)
|
||||
{
|
||||
int sz;
|
||||
|
||||
if (impl->mode != EVP_KDF_HKDF_MODE_EXTRACT_ONLY)
|
||||
return SIZE_MAX;
|
||||
|
||||
@@ -189,7 +191,11 @@ static size_t kdf_hkdf_size(EVP_KDF_IMPL *impl)
|
||||
KDFerr(KDF_F_KDF_HKDF_SIZE, KDF_R_MISSING_MESSAGE_DIGEST);
|
||||
return 0;
|
||||
}
|
||||
return EVP_MD_size(impl->md);
|
||||
sz = EVP_MD_size(impl->md);
|
||||
if (sz < 0)
|
||||
return 0;
|
||||
|
||||
return sz;
|
||||
}
|
||||
|
||||
static int kdf_hkdf_derive(EVP_KDF_IMPL *impl, unsigned char *key,
|
||||
@@ -241,8 +247,13 @@ static int HKDF(const EVP_MD *evp_md,
|
||||
unsigned char *okm, size_t okm_len)
|
||||
{
|
||||
unsigned char prk[EVP_MAX_MD_SIZE];
|
||||
int ret;
|
||||
size_t prk_len = EVP_MD_size(evp_md);
|
||||
int ret, sz;
|
||||
size_t prk_len;
|
||||
|
||||
sz = EVP_MD_size(evp_md);
|
||||
if (sz < 0)
|
||||
return 0;
|
||||
prk_len = (size_t)sz;
|
||||
|
||||
if (!HKDF_Extract(evp_md, salt, salt_len, key, key_len, prk, prk_len))
|
||||
return 0;
|
||||
@@ -258,7 +269,11 @@ static int HKDF_Extract(const EVP_MD *evp_md,
|
||||
const unsigned char *key, size_t key_len,
|
||||
unsigned char *prk, size_t prk_len)
|
||||
{
|
||||
if (prk_len != (size_t)EVP_MD_size(evp_md)) {
|
||||
int sz = EVP_MD_size(evp_md);
|
||||
|
||||
if (sz < 0)
|
||||
return 0;
|
||||
if (prk_len != (size_t)sz) {
|
||||
KDFerr(KDF_F_HKDF_EXTRACT, KDF_R_WRONG_OUTPUT_BUFFER_SIZE);
|
||||
return 0;
|
||||
}
|
||||
@@ -271,11 +286,16 @@ static int HKDF_Expand(const EVP_MD *evp_md,
|
||||
unsigned char *okm, size_t okm_len)
|
||||
{
|
||||
HMAC_CTX *hmac;
|
||||
int ret = 0;
|
||||
int ret = 0, sz;
|
||||
unsigned int i;
|
||||
unsigned char prev[EVP_MAX_MD_SIZE];
|
||||
size_t done_len = 0, dig_len = EVP_MD_size(evp_md);
|
||||
size_t n = okm_len / dig_len;
|
||||
size_t done_len = 0, dig_len, n;
|
||||
|
||||
sz = EVP_MD_size(evp_md);
|
||||
if (sz <= 0)
|
||||
return 0;
|
||||
dig_len = (size_t)sz;
|
||||
n = okm_len / dig_len;
|
||||
|
||||
if (okm_len % dig_len)
|
||||
n++;
|
||||
|
||||
+6
-6
@@ -14,7 +14,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <openssl/crypto.h>
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE
|
||||
#if !defined(OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE) && !defined(FIPS_MODE)
|
||||
# include <execinfo.h>
|
||||
#endif
|
||||
|
||||
@@ -30,7 +30,7 @@ static void *(*realloc_impl)(void *, size_t, const char *, int)
|
||||
static void (*free_impl)(void *, const char *, int)
|
||||
= CRYPTO_free;
|
||||
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
#if !defined(OPENSSL_NO_CRYPTO_MDEBUG) && !defined(FIPS_MODE)
|
||||
# include "internal/tsan_assist.h"
|
||||
|
||||
static TSAN_QUALIFIER int malloc_count;
|
||||
@@ -94,7 +94,7 @@ void CRYPTO_get_mem_functions(
|
||||
*f = free_impl;
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
#if !defined(OPENSSL_NO_CRYPTO_MDEBUG) && !defined(FIPS_MODE)
|
||||
void CRYPTO_get_alloc_counts(int *mcount, int *rcount, int *fcount)
|
||||
{
|
||||
if (mcount != NULL)
|
||||
@@ -209,7 +209,7 @@ void *CRYPTO_malloc(size_t num, const char *file, int line)
|
||||
*/
|
||||
allow_customize = 0;
|
||||
}
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
#if !defined(OPENSSL_NO_CRYPTO_MDEBUG) && !defined(FIPS_MODE)
|
||||
if (call_malloc_debug) {
|
||||
CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);
|
||||
ret = malloc(num);
|
||||
@@ -250,7 +250,7 @@ void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
#if !defined(OPENSSL_NO_CRYPTO_MDEBUG) && !defined(FIPS_MODE)
|
||||
if (call_malloc_debug) {
|
||||
void *ret;
|
||||
CRYPTO_mem_debug_realloc(str, NULL, num, 0, file, line);
|
||||
@@ -300,7 +300,7 @@ void CRYPTO_free(void *str, const char *file, int line)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
|
||||
#if !defined(OPENSSL_NO_CRYPTO_MDEBUG) && !defined(FIPS_MODE)
|
||||
if (call_malloc_debug) {
|
||||
CRYPTO_mem_debug_free(str, 0, file, line);
|
||||
free(str);
|
||||
|
||||
@@ -133,6 +133,12 @@ struct gcm128_context {
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
* The maximum permitted number of cipher blocks per data unit in XTS mode.
|
||||
* Reference IEEE Std 1619-2018.
|
||||
*/
|
||||
#define XTS_MAX_BLOCKS_PER_DATA_UNIT (1<<20)
|
||||
|
||||
struct xts128_context {
|
||||
void *key1, *key2;
|
||||
block128_f block1, block2;
|
||||
|
||||
+23
-4
@@ -348,6 +348,13 @@ OSSL_PARAM OSSL_PARAM_construct_size_t(const char *key, size_t *buf,
|
||||
return ossl_param_construct(key, OSSL_PARAM_UNSIGNED_INTEGER, buf,
|
||||
sizeof(size_t), rsize); }
|
||||
|
||||
#ifndef FIPS_MODE
|
||||
/*
|
||||
* TODO(3.0): Make this available in FIPS mode.
|
||||
*
|
||||
* Temporarily we don't include these functions in FIPS mode to avoid pulling
|
||||
* in the entire BN sub-library into the module at this point.
|
||||
*/
|
||||
int OSSL_PARAM_get_BN(const OSSL_PARAM *p, BIGNUM **val)
|
||||
{
|
||||
BIGNUM *b;
|
||||
@@ -375,6 +382,10 @@ int OSSL_PARAM_set_BN(const OSSL_PARAM *p, const BIGNUM *val)
|
||||
if (val == NULL || p->data_type != OSSL_PARAM_UNSIGNED_INTEGER)
|
||||
return 0;
|
||||
|
||||
/* For the moment, only positive values are permitted */
|
||||
if (BN_is_negative(val))
|
||||
return 0;
|
||||
|
||||
bytes = (size_t)BN_num_bytes(val);
|
||||
SET_RETURN_SIZE(p, bytes);
|
||||
return p->data_size >= bytes
|
||||
@@ -387,6 +398,7 @@ OSSL_PARAM OSSL_PARAM_construct_BN(const char *key, unsigned char *buf,
|
||||
return ossl_param_construct(key, OSSL_PARAM_UNSIGNED_INTEGER,
|
||||
buf, bsize, rsize);
|
||||
}
|
||||
#endif
|
||||
|
||||
int OSSL_PARAM_get_double(const OSSL_PARAM *p, double *val)
|
||||
{
|
||||
@@ -568,13 +580,20 @@ int OSSL_PARAM_set_octet_ptr(const OSSL_PARAM *p, const void *val,
|
||||
}
|
||||
|
||||
OSSL_PARAM OSSL_PARAM_construct_utf8_ptr(const char *key, char **buf,
|
||||
size_t *rsize)
|
||||
size_t bsize, size_t *rsize)
|
||||
{
|
||||
return ossl_param_construct(key, OSSL_PARAM_UTF8_PTR, buf, 0, rsize);
|
||||
return ossl_param_construct(key, OSSL_PARAM_UTF8_PTR, buf, bsize, rsize);
|
||||
}
|
||||
|
||||
OSSL_PARAM OSSL_PARAM_construct_octet_ptr(const char *key, void **buf,
|
||||
size_t *rsize)
|
||||
size_t bsize, size_t *rsize)
|
||||
{
|
||||
return ossl_param_construct(key, OSSL_PARAM_OCTET_PTR, buf, 0, rsize);
|
||||
return ossl_param_construct(key, OSSL_PARAM_OCTET_PTR, buf, bsize, rsize);
|
||||
}
|
||||
|
||||
OSSL_PARAM OSSL_PARAM_construct_end(void)
|
||||
{
|
||||
OSSL_PARAM end = OSSL_PARAM_END;
|
||||
|
||||
return end;
|
||||
}
|
||||
@@ -31,7 +31,7 @@ int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
|
||||
int i, ret = 0;
|
||||
unsigned int m_len;
|
||||
|
||||
m = OPENSSL_malloc(EVP_PKEY_size(pkey) + 2);
|
||||
m = OPENSSL_malloc(EVP_PKEY_size(pkey));
|
||||
if (m == NULL) {
|
||||
PEMerr(PEM_F_PEM_SIGNFINAL, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
|
||||
@@ -523,6 +523,7 @@ int ossl_property_parse_init(void)
|
||||
{
|
||||
static const char *const predefined_names[] = {
|
||||
"default", /* Being provided by the default built-in provider */
|
||||
"legacy", /* Provided by the legacy provider */
|
||||
"provider", /* Name of provider (default, fips) */
|
||||
"version", /* Version number of this provider */
|
||||
"fips", /* FIPS supporting provider */
|
||||
|
||||
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* Copyright 2019 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 <string.h>
|
||||
#include <openssl/trace.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/conf.h>
|
||||
#include <openssl/safestack.h>
|
||||
#include "internal/provider.h"
|
||||
|
||||
/* PROVIDER config module */
|
||||
|
||||
DEFINE_STACK_OF(OSSL_PROVIDER)
|
||||
static STACK_OF(OSSL_PROVIDER) *activated_providers = NULL;
|
||||
|
||||
static const char *skip_dot(const char *name)
|
||||
{
|
||||
const char *p = strchr(name, '.');
|
||||
|
||||
if (p != NULL)
|
||||
return p + 1;
|
||||
return name;
|
||||
}
|
||||
|
||||
static int provider_conf_params(OSSL_PROVIDER *prov,
|
||||
const char *name, const char *value,
|
||||
const CONF *cnf)
|
||||
{
|
||||
STACK_OF(CONF_VALUE) *sect;
|
||||
int ok = 1;
|
||||
|
||||
sect = NCONF_get_section(cnf, value);
|
||||
if (sect != NULL) {
|
||||
int i;
|
||||
char buffer[512];
|
||||
size_t buffer_len = 0;
|
||||
|
||||
OSSL_TRACE1(CONF, "Provider params: start section %s\n", value);
|
||||
|
||||
if (name != NULL) {
|
||||
OPENSSL_strlcpy(buffer, name, sizeof(buffer));
|
||||
OPENSSL_strlcat(buffer, ".", sizeof(buffer));
|
||||
buffer_len = strlen(buffer);
|
||||
}
|
||||
|
||||
for (i = 0; i < sk_CONF_VALUE_num(sect); i++) {
|
||||
CONF_VALUE *sectconf = sk_CONF_VALUE_value(sect, i);
|
||||
|
||||
if (buffer_len + strlen(sectconf->name) >= sizeof(buffer))
|
||||
return 0;
|
||||
buffer[buffer_len] = '\0';
|
||||
OPENSSL_strlcat(buffer, sectconf->name, sizeof(buffer));
|
||||
if (!provider_conf_params(prov, buffer, sectconf->value, cnf))
|
||||
return 0;
|
||||
}
|
||||
|
||||
OSSL_TRACE1(CONF, "Provider params: finish section %s\n", value);
|
||||
} else {
|
||||
OSSL_TRACE2(CONF, "Provider params: %s = %s\n", name, value);
|
||||
ok = ossl_provider_add_parameter(prov, name, value);
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
static int provider_conf_load(OPENSSL_CTX *libctx, const char *name,
|
||||
const char *value, const CONF *cnf)
|
||||
{
|
||||
int i;
|
||||
STACK_OF(CONF_VALUE) *ecmds;
|
||||
int soft = 0;
|
||||
OSSL_PROVIDER *prov = NULL;
|
||||
const char *path = NULL;
|
||||
long activate = 0;
|
||||
int ok = 0;
|
||||
|
||||
name = skip_dot(name);
|
||||
OSSL_TRACE1(CONF, "Configuring provider %s\n", name);
|
||||
/* Value is a section containing PROVIDER commands */
|
||||
ecmds = NCONF_get_section(cnf, value);
|
||||
|
||||
if (!ecmds) {
|
||||
CRYPTOerr(CRYPTO_F_PROVIDER_CONF_LOAD, CRYPTO_R_PROVIDER_SECTION_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Find the needed data first */
|
||||
for (i = 0; i < sk_CONF_VALUE_num(ecmds); i++) {
|
||||
CONF_VALUE *ecmd = sk_CONF_VALUE_value(ecmds, i);
|
||||
const char *confname = skip_dot(ecmd->name);
|
||||
const char *confvalue = ecmd->value;
|
||||
|
||||
OSSL_TRACE2(CONF, "Provider command: %s = %s\n",
|
||||
confname, confvalue);
|
||||
|
||||
/* First handle some special pseudo confs */
|
||||
|
||||
/* Override provider name to use */
|
||||
if (strcmp(confname, "identity") == 0)
|
||||
name = confvalue;
|
||||
else if (strcmp(confname, "soft_load") == 0)
|
||||
soft = 1;
|
||||
/* Load a dynamic PROVIDER */
|
||||
else if (strcmp(confname, "module") == 0)
|
||||
path = confvalue;
|
||||
else if (strcmp(confname, "activate") == 0)
|
||||
activate = 1;
|
||||
}
|
||||
|
||||
prov = ossl_provider_new(libctx, name, NULL);
|
||||
if (prov == NULL) {
|
||||
if (soft)
|
||||
ERR_clear_error();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (path != NULL)
|
||||
ossl_provider_set_module_path(prov, path);
|
||||
|
||||
ok = provider_conf_params(prov, NULL, value, cnf);
|
||||
|
||||
if (ok && activate) {
|
||||
if (!ossl_provider_activate(prov)) {
|
||||
ok = 0;
|
||||
} else {
|
||||
if (activated_providers == NULL)
|
||||
activated_providers = sk_OSSL_PROVIDER_new_null();
|
||||
sk_OSSL_PROVIDER_push(activated_providers, prov);
|
||||
ok = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(activate && ok))
|
||||
ossl_provider_free(prov);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
static int provider_conf_init(CONF_IMODULE *md, const CONF *cnf)
|
||||
{
|
||||
STACK_OF(CONF_VALUE) *elist;
|
||||
CONF_VALUE *cval;
|
||||
int i;
|
||||
|
||||
OSSL_TRACE1(CONF, "Loading providers module: section %s\n",
|
||||
CONF_imodule_get_value(md));
|
||||
|
||||
/* Value is a section containing PROVIDERs to configure */
|
||||
elist = NCONF_get_section(cnf, CONF_imodule_get_value(md));
|
||||
|
||||
if (!elist) {
|
||||
CRYPTOerr(CRYPTO_F_PROVIDER_CONF_INIT,
|
||||
CRYPTO_R_PROVIDER_SECTION_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < sk_CONF_VALUE_num(elist); i++) {
|
||||
cval = sk_CONF_VALUE_value(elist, i);
|
||||
if (!provider_conf_load(NULL, cval->name, cval->value, cnf))
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static void provider_conf_deinit(CONF_IMODULE *md)
|
||||
{
|
||||
sk_OSSL_PROVIDER_pop_free(activated_providers, ossl_provider_free);
|
||||
activated_providers = NULL;
|
||||
OSSL_TRACE(CONF, "Cleaned up providers\n");
|
||||
}
|
||||
|
||||
void ossl_provider_add_conf_module(void)
|
||||
{
|
||||
OSSL_TRACE(CONF, "Adding config module 'providers'\n");
|
||||
CONF_module_add("providers", provider_conf_init, provider_conf_deinit);
|
||||
}
|
||||
+81
-21
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <openssl/core.h>
|
||||
#include <openssl/core_numbers.h>
|
||||
#include <openssl/params.h>
|
||||
#include <openssl/opensslv.h>
|
||||
#include "internal/cryptlib.h"
|
||||
#include "internal/nelem.h"
|
||||
@@ -25,6 +26,12 @@ static OSSL_PROVIDER *provider_new(const char *name,
|
||||
* =========================
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
char *value;
|
||||
} INFOPAIR;
|
||||
DEFINE_STACK_OF(INFOPAIR)
|
||||
|
||||
struct provider_store_st; /* Forward declaration */
|
||||
|
||||
struct ossl_provider_st {
|
||||
@@ -36,8 +43,10 @@ struct ossl_provider_st {
|
||||
CRYPTO_REF_COUNT refcnt;
|
||||
CRYPTO_RWLOCK *refcnt_lock; /* For the ref counter */
|
||||
char *name;
|
||||
char *path;
|
||||
DSO *module;
|
||||
OSSL_provider_init_fn *init_function;
|
||||
STACK_OF(INFOPAIR) *parameters;
|
||||
struct provider_store_st *store; /* The store this instance belongs to */
|
||||
|
||||
/* Provider side functions */
|
||||
@@ -243,6 +252,13 @@ OSSL_PROVIDER *ossl_provider_new(OPENSSL_CTX *libctx, const char *name,
|
||||
return prov;
|
||||
}
|
||||
|
||||
static void free_infopair(INFOPAIR *pair)
|
||||
{
|
||||
OPENSSL_free(pair->name);
|
||||
OPENSSL_free(pair->value);
|
||||
OPENSSL_free(pair);
|
||||
}
|
||||
|
||||
void ossl_provider_free(OSSL_PROVIDER *prov)
|
||||
{
|
||||
if (prov != NULL) {
|
||||
@@ -270,6 +286,8 @@ void ossl_provider_free(OSSL_PROVIDER *prov)
|
||||
if (ref == 0) {
|
||||
DSO_free(prov->module);
|
||||
OPENSSL_free(prov->name);
|
||||
OPENSSL_free(prov->path);
|
||||
sk_INFOPAIR_pop_free(prov->parameters, free_infopair);
|
||||
#ifndef HAVE_ATOMICS
|
||||
CRYPTO_THREAD_lock_free(prov->refcnt_lock);
|
||||
#endif
|
||||
@@ -278,6 +296,40 @@ void ossl_provider_free(OSSL_PROVIDER *prov)
|
||||
}
|
||||
}
|
||||
|
||||
/* Setters */
|
||||
int ossl_provider_set_module_path(OSSL_PROVIDER *prov, const char *module_path)
|
||||
{
|
||||
OPENSSL_free(prov->path);
|
||||
if (module_path == NULL)
|
||||
return 1;
|
||||
if ((prov->path = OPENSSL_strdup(module_path)) != NULL)
|
||||
return 1;
|
||||
CRYPTOerr(CRYPTO_F_OSSL_PROVIDER_SET_MODULE_PATH, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ossl_provider_add_parameter(OSSL_PROVIDER *prov,
|
||||
const char *name, const char *value)
|
||||
{
|
||||
INFOPAIR *pair = NULL;
|
||||
|
||||
if ((pair = OPENSSL_zalloc(sizeof(*pair))) != NULL
|
||||
&& (prov->parameters != NULL
|
||||
|| (prov->parameters = sk_INFOPAIR_new_null()) != NULL)
|
||||
&& (pair->name = OPENSSL_strdup(name)) != NULL
|
||||
&& (pair->value = OPENSSL_strdup(value)) != NULL
|
||||
&& sk_INFOPAIR_push(prov->parameters, pair) > 0)
|
||||
return 1;
|
||||
|
||||
if (pair != NULL) {
|
||||
OPENSSL_free(pair->name);
|
||||
OPENSSL_free(pair->value);
|
||||
OPENSSL_free(pair);
|
||||
}
|
||||
CRYPTOerr(CRYPTO_F_OSSL_PROVIDER_ADD_PARAMETER, ERR_R_MALLOC_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Provider activation.
|
||||
*
|
||||
@@ -310,8 +362,9 @@ static int provider_activate(OSSL_PROVIDER *prov)
|
||||
*/
|
||||
if (prov->init_function == NULL) {
|
||||
if (prov->module == NULL) {
|
||||
char *platform_module_name = NULL;
|
||||
char *module_path = NULL;
|
||||
char *allocated_path = NULL;
|
||||
const char *module_path = NULL;
|
||||
char *merged_path = NULL;
|
||||
const char *load_dir = ossl_safe_getenv("OPENSSL_MODULES");
|
||||
|
||||
if ((prov->module = DSO_new()) == NULL) {
|
||||
@@ -324,19 +377,22 @@ static int provider_activate(OSSL_PROVIDER *prov)
|
||||
|
||||
DSO_ctrl(prov->module, DSO_CTRL_SET_FLAGS,
|
||||
DSO_FLAG_NAME_TRANSLATION_EXT_ONLY, NULL);
|
||||
if ((platform_module_name =
|
||||
DSO_convert_filename(prov->module, prov->name)) == NULL
|
||||
|| (module_path =
|
||||
DSO_merge(prov->module, platform_module_name,
|
||||
load_dir)) == NULL
|
||||
|| DSO_load(prov->module, module_path, NULL,
|
||||
DSO_FLAG_NAME_TRANSLATION_EXT_ONLY) == NULL) {
|
||||
|
||||
module_path = prov->path;
|
||||
if (module_path == NULL)
|
||||
module_path = allocated_path =
|
||||
DSO_convert_filename(prov->module, prov->name);
|
||||
if (module_path != NULL)
|
||||
merged_path = DSO_merge(prov->module, module_path, load_dir);
|
||||
|
||||
if (merged_path == NULL
|
||||
|| (DSO_load(prov->module, merged_path, NULL, 0)) == NULL) {
|
||||
DSO_free(prov->module);
|
||||
prov->module = NULL;
|
||||
}
|
||||
|
||||
OPENSSL_free(platform_module_name);
|
||||
OPENSSL_free(module_path);
|
||||
OPENSSL_free(merged_path);
|
||||
OPENSSL_free(allocated_path);
|
||||
}
|
||||
|
||||
if (prov->module != NULL)
|
||||
@@ -565,17 +621,21 @@ static const OSSL_ITEM *core_get_param_types(const OSSL_PROVIDER *prov)
|
||||
static int core_get_params(const OSSL_PROVIDER *prov, const OSSL_PARAM params[])
|
||||
{
|
||||
int i;
|
||||
const OSSL_PARAM *p;
|
||||
|
||||
for (i = 0; params[i].key != NULL; i++) {
|
||||
if (strcmp(params[i].key, "openssl-version") == 0) {
|
||||
*(void **)params[i].data = OPENSSL_VERSION_STR;
|
||||
if (params[i].return_size)
|
||||
*params[i].return_size = sizeof(OPENSSL_VERSION_STR);
|
||||
} else if (strcmp(params[i].key, "provider-name") == 0) {
|
||||
*(void **)params[i].data = prov->name;
|
||||
if (params[i].return_size)
|
||||
*params[i].return_size = strlen(prov->name) + 1;
|
||||
}
|
||||
if ((p = OSSL_PARAM_locate(params, "openssl-version")) != NULL)
|
||||
OSSL_PARAM_set_utf8_ptr(p, OPENSSL_VERSION_STR);
|
||||
if ((p = OSSL_PARAM_locate(params, "provider-name")) != NULL)
|
||||
OSSL_PARAM_set_utf8_ptr(p, prov->name);
|
||||
|
||||
if (prov->parameters == NULL)
|
||||
return 1;
|
||||
|
||||
for (i = 0; i < sk_INFOPAIR_num(prov->parameters); i++) {
|
||||
INFOPAIR *pair = sk_INFOPAIR_value(prov->parameters, i);
|
||||
|
||||
if ((p = OSSL_PARAM_locate(params, pair->name)) != NULL)
|
||||
OSSL_PARAM_set_utf8_ptr(p, pair->value);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
@@ -422,6 +422,11 @@ int drbg_ctr_init(RAND_DRBG *drbg)
|
||||
drbg->max_perslen = DRBG_MAX_LENGTH;
|
||||
drbg->max_adinlen = DRBG_MAX_LENGTH;
|
||||
} else {
|
||||
#ifdef FIPS_MODE
|
||||
RANDerr(RAND_F_DRBG_CTR_INIT,
|
||||
RAND_R_DERIVATION_FUNCTION_MANDATORY_FOR_FIPS);
|
||||
return 0;
|
||||
#else
|
||||
drbg->min_entropylen = drbg->seedlen;
|
||||
drbg->max_entropylen = drbg->seedlen;
|
||||
/* Nonce not used */
|
||||
@@ -429,6 +434,7 @@ int drbg_ctr_init(RAND_DRBG *drbg)
|
||||
drbg->max_noncelen = 0;
|
||||
drbg->max_perslen = drbg->seedlen;
|
||||
drbg->max_adinlen = drbg->seedlen;
|
||||
#endif
|
||||
}
|
||||
|
||||
drbg->max_request = 1 << 16;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Generated by util/mkerr.pl DO NOT EDIT
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2019 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,6 +15,7 @@
|
||||
|
||||
static const ERR_STRING_DATA RAND_str_functs[] = {
|
||||
{ERR_PACK(ERR_LIB_RAND, RAND_F_DRBG_BYTES, 0), "drbg_bytes"},
|
||||
{ERR_PACK(ERR_LIB_RAND, RAND_F_DRBG_CTR_INIT, 0), "drbg_ctr_init"},
|
||||
{ERR_PACK(ERR_LIB_RAND, RAND_F_DRBG_GET_ENTROPY, 0), "drbg_get_entropy"},
|
||||
{ERR_PACK(ERR_LIB_RAND, RAND_F_DRBG_SETUP, 0), "drbg_setup"},
|
||||
{ERR_PACK(ERR_LIB_RAND, RAND_F_GET_ENTROPY, 0), "get_entropy"},
|
||||
@@ -60,6 +61,8 @@ static const ERR_STRING_DATA RAND_str_reasons[] = {
|
||||
{ERR_PACK(ERR_LIB_RAND, 0, RAND_R_ARGUMENT_OUT_OF_RANGE),
|
||||
"argument out of range"},
|
||||
{ERR_PACK(ERR_LIB_RAND, 0, RAND_R_CANNOT_OPEN_FILE), "Cannot open file"},
|
||||
{ERR_PACK(ERR_LIB_RAND, 0, RAND_R_DERIVATION_FUNCTION_MANDATORY_FOR_FIPS),
|
||||
"derivation function mandatory for fips"},
|
||||
{ERR_PACK(ERR_LIB_RAND, 0, RAND_R_DRBG_ALREADY_INITIALIZED),
|
||||
"drbg already initialized"},
|
||||
{ERR_PACK(ERR_LIB_RAND, 0, RAND_R_DRBG_NOT_INITIALISED),
|
||||
|
||||
@@ -183,17 +183,6 @@ size_t rand_drbg_get_entropy(RAND_DRBG *drbg,
|
||||
}
|
||||
|
||||
} else {
|
||||
if (prediction_resistance) {
|
||||
/*
|
||||
* We don't have any entropy sources that comply with the NIST
|
||||
* standard to provide prediction resistance (see NIST SP 800-90C,
|
||||
* Section 5.4).
|
||||
*/
|
||||
RANDerr(RAND_F_RAND_DRBG_GET_ENTROPY,
|
||||
RAND_R_PREDICTION_RESISTANCE_NOT_SUPPORTED);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Get entropy by polling system entropy sources. */
|
||||
entropy_available = rand_pool_acquire_entropy(pool);
|
||||
}
|
||||
@@ -203,7 +192,6 @@ size_t rand_drbg_get_entropy(RAND_DRBG *drbg,
|
||||
*pout = rand_pool_detach(pool);
|
||||
}
|
||||
|
||||
err:
|
||||
if (drbg->seed_pool == NULL)
|
||||
rand_pool_free(pool);
|
||||
return ret;
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
# endif
|
||||
|
||||
# include <windows.h>
|
||||
/* On Windows 7 or higher use BCrypt instead of the legacy CryptoAPI */
|
||||
# if defined(_MSC_VER) && defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0601
|
||||
/* On Windows Vista or higher use BCrypt instead of the legacy CryptoAPI */
|
||||
# if defined(_MSC_VER) && defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0600
|
||||
# define USE_BCRYPTGENRANDOM
|
||||
# endif
|
||||
|
||||
|
||||
@@ -583,10 +583,12 @@ static RSA_PSS_PARAMS *rsa_ctx_to_pss(EVP_PKEY_CTX *pkctx)
|
||||
return NULL;
|
||||
if (saltlen == -1) {
|
||||
saltlen = EVP_MD_size(sigmd);
|
||||
} else if (saltlen == -2) {
|
||||
} else if (saltlen == -2 || saltlen == -3) {
|
||||
saltlen = EVP_PKEY_size(pk) - EVP_MD_size(sigmd) - 2;
|
||||
if ((EVP_PKEY_bits(pk) & 0x7) == 1)
|
||||
saltlen--;
|
||||
if (saltlen < 0)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return rsa_pss_params_create(sigmd, mgf1md, saltlen);
|
||||
|
||||
+306
-306
@@ -152,17 +152,17 @@ static int parse_env(struct OPENSSL_s390xcap_st *cap)
|
||||
* Facility detection would fail on real hw (no STFLE).
|
||||
*/
|
||||
static const struct OPENSSL_s390xcap_st z900 = {
|
||||
.stfle = {0ULL, 0ULL, 0ULL, 0ULL},
|
||||
.kimd = {0ULL, 0ULL},
|
||||
.klmd = {0ULL, 0ULL},
|
||||
.km = {0ULL, 0ULL},
|
||||
.kmc = {0ULL, 0ULL},
|
||||
.kmac = {0ULL, 0ULL},
|
||||
.kmctr = {0ULL, 0ULL},
|
||||
.kmo = {0ULL, 0ULL},
|
||||
.kmf = {0ULL, 0ULL},
|
||||
.prno = {0ULL, 0ULL},
|
||||
.kma = {0ULL, 0ULL},
|
||||
/*.stfle = */{0ULL, 0ULL, 0ULL, 0ULL},
|
||||
/*.kimd = */{0ULL, 0ULL},
|
||||
/*.klmd = */{0ULL, 0ULL},
|
||||
/*.km = */{0ULL, 0ULL},
|
||||
/*.kmc = */{0ULL, 0ULL},
|
||||
/*.kmac = */{0ULL, 0ULL},
|
||||
/*.kmctr = */{0ULL, 0ULL},
|
||||
/*.kmo = */{0ULL, 0ULL},
|
||||
/*.kmf = */{0ULL, 0ULL},
|
||||
/*.prno = */{0ULL, 0ULL},
|
||||
/*.kma = */{0ULL, 0ULL},
|
||||
};
|
||||
|
||||
/*-
|
||||
@@ -170,25 +170,25 @@ static int parse_env(struct OPENSSL_s390xcap_st *cap)
|
||||
* Implements MSA. Facility detection would fail on real hw (no STFLE).
|
||||
*/
|
||||
static const struct OPENSSL_s390xcap_st z990 = {
|
||||
.stfle = {S390X_CAPBIT(S390X_MSA),
|
||||
0ULL, 0ULL, 0ULL},
|
||||
.kimd = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_1),
|
||||
0ULL},
|
||||
.klmd = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_1),
|
||||
0ULL},
|
||||
.km = {S390X_CAPBIT(S390X_QUERY),
|
||||
0ULL},
|
||||
.kmc = {S390X_CAPBIT(S390X_QUERY),
|
||||
0ULL},
|
||||
.kmac = {S390X_CAPBIT(S390X_QUERY),
|
||||
0ULL},
|
||||
.kmctr = {0ULL, 0ULL},
|
||||
.kmo = {0ULL, 0ULL},
|
||||
.kmf = {0ULL, 0ULL},
|
||||
.prno = {0ULL, 0ULL},
|
||||
.kma = {0ULL, 0ULL},
|
||||
/*.stfle = */{S390X_CAPBIT(S390X_MSA),
|
||||
0ULL, 0ULL, 0ULL},
|
||||
/*.kimd = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_1),
|
||||
0ULL},
|
||||
/*.klmd = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_1),
|
||||
0ULL},
|
||||
/*.km = */{S390X_CAPBIT(S390X_QUERY),
|
||||
0ULL},
|
||||
/*.kmc = */{S390X_CAPBIT(S390X_QUERY),
|
||||
0ULL},
|
||||
/*.kmac = */{S390X_CAPBIT(S390X_QUERY),
|
||||
0ULL},
|
||||
/*.kmctr = */{0ULL, 0ULL},
|
||||
/*.kmo = */{0ULL, 0ULL},
|
||||
/*.kmf = */{0ULL, 0ULL},
|
||||
/*.prno = */{0ULL, 0ULL},
|
||||
/*.kma = */{0ULL, 0ULL},
|
||||
};
|
||||
|
||||
/*-
|
||||
@@ -196,30 +196,30 @@ static int parse_env(struct OPENSSL_s390xcap_st *cap)
|
||||
* Implements MSA and MSA1.
|
||||
*/
|
||||
static const struct OPENSSL_s390xcap_st z9 = {
|
||||
.stfle = {S390X_CAPBIT(S390X_MSA)
|
||||
| S390X_CAPBIT(S390X_STCKF),
|
||||
0ULL, 0ULL, 0ULL},
|
||||
.kimd = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_1)
|
||||
| S390X_CAPBIT(S390X_SHA_256),
|
||||
0ULL},
|
||||
.klmd = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_1)
|
||||
| S390X_CAPBIT(S390X_SHA_256),
|
||||
0ULL},
|
||||
.km = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128),
|
||||
0ULL},
|
||||
.kmc = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128),
|
||||
0ULL},
|
||||
.kmac = {S390X_CAPBIT(S390X_QUERY),
|
||||
0ULL},
|
||||
.kmctr = {0ULL, 0ULL},
|
||||
.kmo = {0ULL, 0ULL},
|
||||
.kmf = {0ULL, 0ULL},
|
||||
.prno = {0ULL, 0ULL},
|
||||
.kma = {0ULL, 0ULL},
|
||||
/*.stfle = */{S390X_CAPBIT(S390X_MSA)
|
||||
| S390X_CAPBIT(S390X_STCKF),
|
||||
0ULL, 0ULL, 0ULL},
|
||||
/*.kimd = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_1)
|
||||
| S390X_CAPBIT(S390X_SHA_256),
|
||||
0ULL},
|
||||
/*.klmd = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_1)
|
||||
| S390X_CAPBIT(S390X_SHA_256),
|
||||
0ULL},
|
||||
/*.km = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128),
|
||||
0ULL},
|
||||
/*.kmc = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128),
|
||||
0ULL},
|
||||
/*.kmac = */{S390X_CAPBIT(S390X_QUERY),
|
||||
0ULL},
|
||||
/*.kmctr = */{0ULL, 0ULL},
|
||||
/*.kmo = */{0ULL, 0ULL},
|
||||
/*.kmf = */{0ULL, 0ULL},
|
||||
/*.prno = */{0ULL, 0ULL},
|
||||
/*.kma = */{0ULL, 0ULL},
|
||||
};
|
||||
|
||||
/*-
|
||||
@@ -227,36 +227,36 @@ static int parse_env(struct OPENSSL_s390xcap_st *cap)
|
||||
* Implements MSA and MSA1-2.
|
||||
*/
|
||||
static const struct OPENSSL_s390xcap_st z10 = {
|
||||
.stfle = {S390X_CAPBIT(S390X_MSA)
|
||||
| S390X_CAPBIT(S390X_STCKF),
|
||||
0ULL, 0ULL, 0ULL},
|
||||
.kimd = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_1)
|
||||
| S390X_CAPBIT(S390X_SHA_256)
|
||||
| S390X_CAPBIT(S390X_SHA_512),
|
||||
0ULL},
|
||||
.klmd = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_1)
|
||||
| S390X_CAPBIT(S390X_SHA_256)
|
||||
| S390X_CAPBIT(S390X_SHA_512),
|
||||
0ULL},
|
||||
.km = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
.kmc = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
.kmac = {S390X_CAPBIT(S390X_QUERY),
|
||||
0ULL},
|
||||
.kmctr = {0ULL, 0ULL},
|
||||
.kmo = {0ULL, 0ULL},
|
||||
.kmf = {0ULL, 0ULL},
|
||||
.prno = {0ULL, 0ULL},
|
||||
.kma = {0ULL, 0ULL},
|
||||
/*.stfle = */{S390X_CAPBIT(S390X_MSA)
|
||||
| S390X_CAPBIT(S390X_STCKF),
|
||||
0ULL, 0ULL, 0ULL},
|
||||
/*.kimd = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_1)
|
||||
| S390X_CAPBIT(S390X_SHA_256)
|
||||
| S390X_CAPBIT(S390X_SHA_512),
|
||||
0ULL},
|
||||
/*.klmd = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_1)
|
||||
| S390X_CAPBIT(S390X_SHA_256)
|
||||
| S390X_CAPBIT(S390X_SHA_512),
|
||||
0ULL},
|
||||
/*.km = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
/*.kmc = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
/*.kmac = */{S390X_CAPBIT(S390X_QUERY),
|
||||
0ULL},
|
||||
/*.kmctr = */{0ULL, 0ULL},
|
||||
/*.kmo = */{0ULL, 0ULL},
|
||||
/*.kmf = */{0ULL, 0ULL},
|
||||
/*.prno = */{0ULL, 0ULL},
|
||||
/*.kma = */{0ULL, 0ULL},
|
||||
};
|
||||
|
||||
/*-
|
||||
@@ -264,55 +264,55 @@ static int parse_env(struct OPENSSL_s390xcap_st *cap)
|
||||
* Implements MSA and MSA1-4.
|
||||
*/
|
||||
static const struct OPENSSL_s390xcap_st z196 = {
|
||||
.stfle = {S390X_CAPBIT(S390X_MSA)
|
||||
| S390X_CAPBIT(S390X_STCKF),
|
||||
S390X_CAPBIT(S390X_MSA3)
|
||||
| S390X_CAPBIT(S390X_MSA4),
|
||||
0ULL, 0ULL},
|
||||
.kimd = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_1)
|
||||
| S390X_CAPBIT(S390X_SHA_256)
|
||||
| S390X_CAPBIT(S390X_SHA_512),
|
||||
S390X_CAPBIT(S390X_GHASH)},
|
||||
.klmd = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_1)
|
||||
| S390X_CAPBIT(S390X_SHA_256)
|
||||
| S390X_CAPBIT(S390X_SHA_512),
|
||||
0ULL},
|
||||
.km = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256)
|
||||
| S390X_CAPBIT(S390X_XTS_AES_128)
|
||||
| S390X_CAPBIT(S390X_XTS_AES_256),
|
||||
0ULL},
|
||||
.kmc = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
.kmac = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
.kmctr = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
.kmo = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
.kmf = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
.prno = {0ULL, 0ULL},
|
||||
.kma = {0ULL, 0ULL},
|
||||
/*.stfle = */{S390X_CAPBIT(S390X_MSA)
|
||||
| S390X_CAPBIT(S390X_STCKF),
|
||||
S390X_CAPBIT(S390X_MSA3)
|
||||
| S390X_CAPBIT(S390X_MSA4),
|
||||
0ULL, 0ULL},
|
||||
/*.kimd = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_1)
|
||||
| S390X_CAPBIT(S390X_SHA_256)
|
||||
| S390X_CAPBIT(S390X_SHA_512),
|
||||
S390X_CAPBIT(S390X_GHASH)},
|
||||
/*.klmd = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_1)
|
||||
| S390X_CAPBIT(S390X_SHA_256)
|
||||
| S390X_CAPBIT(S390X_SHA_512),
|
||||
0ULL},
|
||||
/*.km = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256)
|
||||
| S390X_CAPBIT(S390X_XTS_AES_128)
|
||||
| S390X_CAPBIT(S390X_XTS_AES_256),
|
||||
0ULL},
|
||||
/*.kmc = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
/*.kmac = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
/*.kmctr = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
/*.kmo = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
/*.kmf = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
/*.prno = */{0ULL, 0ULL},
|
||||
/*.kma = */{0ULL, 0ULL},
|
||||
};
|
||||
|
||||
/*-
|
||||
@@ -320,55 +320,55 @@ static int parse_env(struct OPENSSL_s390xcap_st *cap)
|
||||
* Implements MSA and MSA1-4.
|
||||
*/
|
||||
static const struct OPENSSL_s390xcap_st zEC12 = {
|
||||
.stfle = {S390X_CAPBIT(S390X_MSA)
|
||||
| S390X_CAPBIT(S390X_STCKF),
|
||||
S390X_CAPBIT(S390X_MSA3)
|
||||
| S390X_CAPBIT(S390X_MSA4),
|
||||
0ULL, 0ULL},
|
||||
.kimd = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_1)
|
||||
| S390X_CAPBIT(S390X_SHA_256)
|
||||
| S390X_CAPBIT(S390X_SHA_512),
|
||||
/*.stfle = */{S390X_CAPBIT(S390X_MSA)
|
||||
| S390X_CAPBIT(S390X_STCKF),
|
||||
S390X_CAPBIT(S390X_MSA3)
|
||||
| S390X_CAPBIT(S390X_MSA4),
|
||||
0ULL, 0ULL},
|
||||
/*.kimd = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_1)
|
||||
| S390X_CAPBIT(S390X_SHA_256)
|
||||
| S390X_CAPBIT(S390X_SHA_512),
|
||||
S390X_CAPBIT(S390X_GHASH)},
|
||||
.klmd = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_1)
|
||||
| S390X_CAPBIT(S390X_SHA_256)
|
||||
| S390X_CAPBIT(S390X_SHA_512),
|
||||
0ULL},
|
||||
.km = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256)
|
||||
| S390X_CAPBIT(S390X_XTS_AES_128)
|
||||
| S390X_CAPBIT(S390X_XTS_AES_256),
|
||||
0ULL},
|
||||
.kmc = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
.kmac = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
.kmctr = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
.kmo = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
.kmf = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
.prno = {0ULL, 0ULL},
|
||||
.kma = {0ULL, 0ULL},
|
||||
/*.klmd = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_1)
|
||||
| S390X_CAPBIT(S390X_SHA_256)
|
||||
| S390X_CAPBIT(S390X_SHA_512),
|
||||
0ULL},
|
||||
/*.km = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256)
|
||||
| S390X_CAPBIT(S390X_XTS_AES_128)
|
||||
| S390X_CAPBIT(S390X_XTS_AES_256),
|
||||
0ULL},
|
||||
/*.kmc = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
/*.kmac = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
/*.kmctr = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
/*.kmo = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
/*.kmf = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
/*.prno = */{0ULL, 0ULL},
|
||||
/*.kma = */{0ULL, 0ULL},
|
||||
};
|
||||
|
||||
/*-
|
||||
@@ -376,59 +376,59 @@ static int parse_env(struct OPENSSL_s390xcap_st *cap)
|
||||
* Implements MSA and MSA1-5.
|
||||
*/
|
||||
static const struct OPENSSL_s390xcap_st z13 = {
|
||||
.stfle = {S390X_CAPBIT(S390X_MSA)
|
||||
| S390X_CAPBIT(S390X_STCKF)
|
||||
| S390X_CAPBIT(S390X_MSA5),
|
||||
S390X_CAPBIT(S390X_MSA3)
|
||||
| S390X_CAPBIT(S390X_MSA4),
|
||||
S390X_CAPBIT(S390X_VX),
|
||||
0ULL},
|
||||
.kimd = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_1)
|
||||
| S390X_CAPBIT(S390X_SHA_256)
|
||||
| S390X_CAPBIT(S390X_SHA_512),
|
||||
S390X_CAPBIT(S390X_GHASH)},
|
||||
.klmd = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_1)
|
||||
| S390X_CAPBIT(S390X_SHA_256)
|
||||
| S390X_CAPBIT(S390X_SHA_512),
|
||||
0ULL},
|
||||
.km = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256)
|
||||
| S390X_CAPBIT(S390X_XTS_AES_128)
|
||||
| S390X_CAPBIT(S390X_XTS_AES_256),
|
||||
0ULL},
|
||||
.kmc = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
.kmac = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
.kmctr = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
.kmo = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
.kmf = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
.prno = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_512_DRNG),
|
||||
0ULL},
|
||||
.kma = {0ULL, 0ULL},
|
||||
/*.stfle = */{S390X_CAPBIT(S390X_MSA)
|
||||
| S390X_CAPBIT(S390X_STCKF)
|
||||
| S390X_CAPBIT(S390X_MSA5),
|
||||
S390X_CAPBIT(S390X_MSA3)
|
||||
| S390X_CAPBIT(S390X_MSA4),
|
||||
S390X_CAPBIT(S390X_VX),
|
||||
0ULL},
|
||||
/*.kimd = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_1)
|
||||
| S390X_CAPBIT(S390X_SHA_256)
|
||||
| S390X_CAPBIT(S390X_SHA_512),
|
||||
S390X_CAPBIT(S390X_GHASH)},
|
||||
/*.klmd = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_1)
|
||||
| S390X_CAPBIT(S390X_SHA_256)
|
||||
| S390X_CAPBIT(S390X_SHA_512),
|
||||
0ULL},
|
||||
/*.km = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256)
|
||||
| S390X_CAPBIT(S390X_XTS_AES_128)
|
||||
| S390X_CAPBIT(S390X_XTS_AES_256),
|
||||
0ULL},
|
||||
/*.kmc = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
/*.kmac = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
/*.kmctr = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
/*.kmo = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
/*.kmf = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
/*.prno = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_512_DRNG),
|
||||
0ULL},
|
||||
/*.kma = */{0ULL, 0ULL},
|
||||
};
|
||||
|
||||
/*-
|
||||
@@ -436,78 +436,78 @@ static int parse_env(struct OPENSSL_s390xcap_st *cap)
|
||||
* Implements MSA and MSA1-8.
|
||||
*/
|
||||
static const struct OPENSSL_s390xcap_st z14 = {
|
||||
.stfle = {S390X_CAPBIT(S390X_MSA)
|
||||
| S390X_CAPBIT(S390X_STCKF)
|
||||
| S390X_CAPBIT(S390X_MSA5),
|
||||
S390X_CAPBIT(S390X_MSA3)
|
||||
| S390X_CAPBIT(S390X_MSA4),
|
||||
S390X_CAPBIT(S390X_VX)
|
||||
| S390X_CAPBIT(S390X_VXD)
|
||||
| S390X_CAPBIT(S390X_VXE)
|
||||
| S390X_CAPBIT(S390X_MSA8),
|
||||
0ULL},
|
||||
.kimd = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_1)
|
||||
| S390X_CAPBIT(S390X_SHA_256)
|
||||
| S390X_CAPBIT(S390X_SHA_512)
|
||||
| S390X_CAPBIT(S390X_SHA3_224)
|
||||
| S390X_CAPBIT(S390X_SHA3_256)
|
||||
| S390X_CAPBIT(S390X_SHA3_384)
|
||||
| S390X_CAPBIT(S390X_SHA3_512)
|
||||
| S390X_CAPBIT(S390X_SHAKE_128)
|
||||
| S390X_CAPBIT(S390X_SHAKE_256),
|
||||
S390X_CAPBIT(S390X_GHASH)},
|
||||
.klmd = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_1)
|
||||
| S390X_CAPBIT(S390X_SHA_256)
|
||||
| S390X_CAPBIT(S390X_SHA_512)
|
||||
| S390X_CAPBIT(S390X_SHA3_224)
|
||||
| S390X_CAPBIT(S390X_SHA3_256)
|
||||
| S390X_CAPBIT(S390X_SHA3_384)
|
||||
| S390X_CAPBIT(S390X_SHA3_512)
|
||||
| S390X_CAPBIT(S390X_SHAKE_128)
|
||||
| S390X_CAPBIT(S390X_SHAKE_256),
|
||||
0ULL},
|
||||
.km = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256)
|
||||
| S390X_CAPBIT(S390X_XTS_AES_128)
|
||||
| S390X_CAPBIT(S390X_XTS_AES_256),
|
||||
0ULL},
|
||||
.kmc = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
.kmac = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
.kmctr = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
.kmo = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
.kmf = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
.prno = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_512_DRNG),
|
||||
S390X_CAPBIT(S390X_TRNG)},
|
||||
.kma = {S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
/*.stfle = */{S390X_CAPBIT(S390X_MSA)
|
||||
| S390X_CAPBIT(S390X_STCKF)
|
||||
| S390X_CAPBIT(S390X_MSA5),
|
||||
S390X_CAPBIT(S390X_MSA3)
|
||||
| S390X_CAPBIT(S390X_MSA4),
|
||||
S390X_CAPBIT(S390X_VX)
|
||||
| S390X_CAPBIT(S390X_VXD)
|
||||
| S390X_CAPBIT(S390X_VXE)
|
||||
| S390X_CAPBIT(S390X_MSA8),
|
||||
0ULL},
|
||||
/*.kimd = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_1)
|
||||
| S390X_CAPBIT(S390X_SHA_256)
|
||||
| S390X_CAPBIT(S390X_SHA_512)
|
||||
| S390X_CAPBIT(S390X_SHA3_224)
|
||||
| S390X_CAPBIT(S390X_SHA3_256)
|
||||
| S390X_CAPBIT(S390X_SHA3_384)
|
||||
| S390X_CAPBIT(S390X_SHA3_512)
|
||||
| S390X_CAPBIT(S390X_SHAKE_128)
|
||||
| S390X_CAPBIT(S390X_SHAKE_256),
|
||||
S390X_CAPBIT(S390X_GHASH)},
|
||||
/*.klmd = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_1)
|
||||
| S390X_CAPBIT(S390X_SHA_256)
|
||||
| S390X_CAPBIT(S390X_SHA_512)
|
||||
| S390X_CAPBIT(S390X_SHA3_224)
|
||||
| S390X_CAPBIT(S390X_SHA3_256)
|
||||
| S390X_CAPBIT(S390X_SHA3_384)
|
||||
| S390X_CAPBIT(S390X_SHA3_512)
|
||||
| S390X_CAPBIT(S390X_SHAKE_128)
|
||||
| S390X_CAPBIT(S390X_SHAKE_256),
|
||||
0ULL},
|
||||
/*.km = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256)
|
||||
| S390X_CAPBIT(S390X_XTS_AES_128)
|
||||
| S390X_CAPBIT(S390X_XTS_AES_256),
|
||||
0ULL},
|
||||
/*.kmc = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
/*.kmac = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
/*.kmctr = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
/*.kmo = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
/*.kmf = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
/*.prno = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_SHA_512_DRNG),
|
||||
S390X_CAPBIT(S390X_TRNG)},
|
||||
/*.kma = */{S390X_CAPBIT(S390X_QUERY)
|
||||
| S390X_CAPBIT(S390X_AES_128)
|
||||
| S390X_CAPBIT(S390X_AES_192)
|
||||
| S390X_CAPBIT(S390X_AES_256),
|
||||
0ULL},
|
||||
};
|
||||
|
||||
char *tok_begin, *tok_end, *buff, tok[S390X_STFLE_MAX][LEN + 1];
|
||||
|
||||
@@ -3,6 +3,8 @@ SOURCE[../../libcrypto]=\
|
||||
sha1dgst.c sha1_one.c sha256.c sha512.c {- $target{sha1_asm_src} -} \
|
||||
{- $target{keccak1600_asm_src} -}
|
||||
|
||||
SOURCE[../../providers/fips]= sha256.c
|
||||
|
||||
GENERATE[sha1-586.s]=asm/sha1-586.pl \
|
||||
$(PERLASM_SCHEME) $(LIB_CFLAGS) $(LIB_CPPFLAGS) $(PROCESSOR)
|
||||
DEPEND[sha1-586.s]=../perlasm/x86asm.pl
|
||||
|
||||
+1
-1
@@ -124,7 +124,7 @@ static const struct trace_category_st trace_categories[] = {
|
||||
TRACE_CATEGORY_(INIT),
|
||||
TRACE_CATEGORY_(TLS),
|
||||
TRACE_CATEGORY_(TLS_CIPHER),
|
||||
TRACE_CATEGORY_(ENGINE_CONF),
|
||||
TRACE_CATEGORY_(CONF),
|
||||
TRACE_CATEGORY_(ENGINE_TABLE),
|
||||
TRACE_CATEGORY_(ENGINE_REF_COUNT),
|
||||
TRACE_CATEGORY_(PKCS5V2),
|
||||
|
||||
@@ -297,6 +297,9 @@ int X509_STORE_CTX_get_by_subject(X509_STORE_CTX *vs, X509_LOOKUP_TYPE type,
|
||||
if (ctx == NULL)
|
||||
return 0;
|
||||
|
||||
stmp.type = X509_LU_NONE;
|
||||
stmp.data.ptr = NULL;
|
||||
|
||||
CRYPTO_THREAD_write_lock(ctx->lock);
|
||||
tmp = X509_OBJECT_retrieve_by_subject(ctx->objs, type, name);
|
||||
CRYPTO_THREAD_unlock(ctx->lock);
|
||||
|
||||
+4
-1
@@ -72,7 +72,10 @@ static int x509_verify_sm2(X509 *x, EVP_PKEY *pkey, int mdnid, int pknid)
|
||||
ret = 0;
|
||||
goto err;
|
||||
}
|
||||
if (EVP_PKEY_CTX_set1_id(pctx, x->sm2_id.data, x->sm2_id.length) != 1) {
|
||||
/* NOTE: we tolerate no actual ID, to provide maximum flexibility */
|
||||
if (x->sm2_id != NULL
|
||||
&& EVP_PKEY_CTX_set1_id(pctx, x->sm2_id->data,
|
||||
x->sm2_id->length) != 1) {
|
||||
X509err(X509_F_X509_VERIFY_SM2, ERR_R_EVP_LIB);
|
||||
ret = 0;
|
||||
goto err;
|
||||
|
||||
+10
-3
@@ -72,6 +72,9 @@ static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
#ifndef OPENSSL_NO_RFC3779
|
||||
ret->rfc3779_addr = NULL;
|
||||
ret->rfc3779_asid = NULL;
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SM2
|
||||
ret->sm2_id = NULL;
|
||||
#endif
|
||||
ret->aux = NULL;
|
||||
ret->crldp = NULL;
|
||||
@@ -91,6 +94,9 @@ static int x509_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
#ifndef OPENSSL_NO_RFC3779
|
||||
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
|
||||
break;
|
||||
|
||||
@@ -246,13 +252,14 @@ int X509_get_signature_nid(const X509 *x)
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_SM2
|
||||
void X509_set_sm2_id(X509 *x, ASN1_OCTET_STRING *sm2_id)
|
||||
void X509_set0_sm2_id(X509 *x, ASN1_OCTET_STRING *sm2_id)
|
||||
{
|
||||
x->sm2_id = *sm2_id;
|
||||
ASN1_OCTET_STRING_free(x->sm2_id);
|
||||
x->sm2_id = sm2_id;
|
||||
}
|
||||
|
||||
ASN1_OCTET_STRING *X509_get0_sm2_id(X509 *x)
|
||||
{
|
||||
return &x->sm2_id;
|
||||
return x->sm2_id;
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user