diff options
author | Shane Lontis <shane.lontis@oracle.com> | 2021-03-29 13:38:00 +1000 |
---|---|---|
committer | Shane Lontis <shane.lontis@oracle.com> | 2021-04-01 09:07:08 +1000 |
commit | e454a3934c287aede194cac49c8934f04bf6a04f (patch) | |
tree | c43916f0a50c5e2d1a9aa1caa00539c0629f1175 /include | |
parent | 9e6f30e683fd0f243cf15d2bac2cdef2bcbbac12 (diff) |
Add a range check (from SP800-56Ar3) to DH key derivation.
Fixes #14401
Note that this moves the public key check out of DH compute_key() since
key validation does not belong inside this primitive..
The check has been moved to the EVP_PKEY_derive_set_peer() function so that
it generally applies to all exchange operations.. Use EVP_PKEY_derive_set_peer_ex()
to disable this behaviour.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14717)
Diffstat (limited to 'include')
-rw-r--r-- | include/crypto/dh.h | 1 | ||||
-rw-r--r-- | include/crypto/dherr.h | 2 | ||||
-rw-r--r-- | include/openssl/dherr.h | 1 | ||||
-rw-r--r-- | include/openssl/evp.h | 2 |
4 files changed, 5 insertions, 1 deletions
diff --git a/include/crypto/dh.h b/include/crypto/dh.h index b16ac8f42f..ab6115d986 100644 --- a/include/crypto/dh.h +++ b/include/crypto/dh.h @@ -38,6 +38,7 @@ int ossl_dh_params_todata(DH *dh, OSSL_PARAM_BLD *bld, OSSL_PARAM params[]); int ossl_dh_key_todata(DH *dh, OSSL_PARAM_BLD *bld, OSSL_PARAM params[]); DH *ossl_dh_key_from_pkcs8(const PKCS8_PRIV_KEY_INFO *p8inf, OSSL_LIB_CTX *libctx, const char *propq); +int ossl_dh_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh); int ossl_dh_check_pub_key_partial(const DH *dh, const BIGNUM *pub_key, int *ret); int ossl_dh_check_priv_key(const DH *dh, const BIGNUM *priv_key, int *ret); diff --git a/include/crypto/dherr.h b/include/crypto/dherr.h index eb587f19ae..351d7da01b 100644 --- a/include/crypto/dherr.h +++ b/include/crypto/dherr.h @@ -1,6 +1,6 @@ /* * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2020-2021 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 diff --git a/include/openssl/dherr.h b/include/openssl/dherr.h index 237de52522..5d2a762a96 100644 --- a/include/openssl/dherr.h +++ b/include/openssl/dherr.h @@ -39,6 +39,7 @@ # define DH_R_INVALID_PARAMETER_NAME 110 # define DH_R_INVALID_PARAMETER_NID 114 # define DH_R_INVALID_PUBKEY 102 +# define DH_R_INVALID_SECRET 128 # define DH_R_KDF_PARAMETER_ERROR 112 # define DH_R_KEYS_NOT_SET 108 # define DH_R_MISSING_PUBKEY 125 diff --git a/include/openssl/evp.h b/include/openssl/evp.h index 26a97008ba..4268f1020d 100644 --- a/include/openssl/evp.h +++ b/include/openssl/evp.h @@ -1825,6 +1825,8 @@ int EVP_PKEY_decrypt(EVP_PKEY_CTX *ctx, int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx); int EVP_PKEY_derive_init_ex(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[]); +int EVP_PKEY_derive_set_peer_ex(EVP_PKEY_CTX *ctx, EVP_PKEY *peer, + int validate_peer); int EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer); int EVP_PKEY_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen); |