summaryrefslogtreecommitdiff
path: root/lib/libcrypto/dh
AgeCommit message (Collapse)Author
2022-06-27Prepare to provide EVP_PKEY_security_bits()Theo Buehler
This also provides a pkey_security_bits member to the PKEY ASN.1 methods and a corresponding setter EVP_PKEY_asn1_set_security_bits(). ok beck jsing
2022-06-27Prepare to provide DH_security_bits()Theo Buehler
ok beck jsing
2022-01-20Add check for BIO_indent return valueKinichiro Inoguchi
CID 24812 ok jsing@ millert@ tb@
2022-01-14Make structs in dh.h opaqueTheo Buehler
This moves the struct internals for DH and DH_METHOD to dh_local.h. ok inoguchi jsing
2022-01-14Unifdef LIBRESSL_OPAQUE_* and LIBRESSL_NEXT_APITheo Buehler
This marks the start of major surgery in libcrypto. Do not attempt to build the tree for a while (~50 commits).
2022-01-10Prepare to provide EVP_PKEY_{public,param}_checkTheo Buehler
This implements checking of a public key and of key generation parameters for DH and EC keys. With the same logic and setters and const quirks as for EVP_PKEY_check(). There are a couple of quirks: For DH no default EVP_PKEY_check() is implemented, instead EVP_PKEY_param_check() calls DH_check_ex() even though DH_param_check_ex() was added for this purpose. EVP_PKEY_public_check() for EC curves also checks the private key if present. ok inoguchi jsing
2022-01-10Provide DH_check*_ex and many error codesTheo Buehler
DH_check{,_pub_key}_ex() wrap their non-ex versions to translate the flags argument of the original functions into OpenSSL errors. For this almost a dozen new error codes need to be added. DH_params_check{,_ex}() is a new version of DH_check that only performs a cheap subset of the checks. They are needed to implement EVP_PKEY_{public,param}_check() (observe the consistent naming) although the actual implementation of EVP_PKEY_param_check() chose to use DH_check_ex(). As far as I can tell, the only raison d'être of the _ex functions and error codes is to spew them to stderr in a couple of openssl(1) commands. This couldn't have been solved differently... These functions will not be exposed publicly. ok inoguchi jsing
2022-01-10zap trailing whitespaceTheo Buehler
2022-01-07Add an essentially empty dh_local.h and include it in the files whereTheo Buehler
it will be needed in the upcoming bump. discussed with jsing
2022-01-07zap trailing whitespaceTheo Buehler
2022-01-05Prepare to provide DH_get_length()Theo Buehler
Will be needed by openssl(1) dhparam. ok inoguchi jsing
2022-01-05Prepare to provide DH_get0_{p,q,g,{priv,pub}_key}()Theo Buehler
These are accessors that allow getting one specific DH member. They are less error prone than the current getters DH_get0_{pqg,key}(). They are used by many ports and will also be used in base for this reason. Who can remember whether the pub_key or the priv_key goes first in DH_get0_key()? ok inoguchi jsing
2021-12-12Include evp_locl.h where it will be needed once most structs fromTheo Buehler
evp.h will be moved to evp_locl.h in an upcoming bump. ok inoguchi
2021-12-05Simplify DH_check_params a bit.Theo Buehler
It makes no sense to allocate an entire BN_CTX if we only use it to get a single BIGNUM, from which we subtract 1 to compare it to g. We can just use a plain BIGNUM and delete a bunch of lines. ok inoguchi jsing
2021-12-04Add #include "bn_lcl.h" to the files that will soon need it.Theo Buehler
ok inoguchi jsing
2021-11-29Clean up DH_check_pub_key() and ensure that y^q (mod p) == 1.Theo Buehler
This aligns our behavior with OpenSSL 1.1.1 which includes a mitigation for small subgroup attacks. This did not affect LibreSSL since we do not support X9.42 style parameter files or RFC 5114. The meat of this commit is from Matt Caswell, OpenSSL b128abc3 ok inoguchi jsing
2021-11-29Increase number of iterations in Miller-Rabin checks for DH.Theo Buehler
BN_prime_checks is only to be used for random input. Here, the input isn't random, so increase the number of checks. According to https://eprint.iacr.org/2019/032, 64 rounds is suitable. From Jake Massimo, OpenSSL 1.1.1, af6ce3b4 ok inoguchi jsing
2021-11-29Synchronize DH_check() mostly with OpenSSL 1.1.1 with someTheo Buehler
simplifications and readability tweaks. This ensures in particular that dh->q is suitable if present. Based on work by Stephen Henson and Bernd Edlinger in OpenSSL. Issues with the current implementation found via regression tests in py-cryptography. ok inoguchi jsing
2021-11-29Provide a version of DH_check_params() for internal use.Theo Buehler
Based on the version in OpenSSL 1.1.1l with minor tweaks. ok inoguchi jsing
2021-11-29Provide a number of flags for DH_check and DH_check_pubkeyTheo Buehler
that will be used in subsequent commits. ok inoguchi jsing
2021-11-23In DH_set0_pqg() also set dh->length if q is set to match what OpenSSL do.Theo Buehler
ok inoguchi jsing
2020-01-04Avoid leak in error path of dh_priv_decodeKinichiro Inoguchi
ok jsing@ tb@
2019-01-20Fix BN_is_prime_* calls in libcrypto, the API returns -1 on error.Theo Buehler
From BoringSSL's commit 53409ee3d7595ed37da472bc73b010cd2c8a5ffd by David Benjamin. ok djm, jsing
2018-11-12Missing initialization for pub_key. CID 184303.Theo Buehler
ok bcook
2018-11-09Initialize priv_key and pub_key on first use instead of at the top.Theo Buehler
While there, eliminate a flag that was only used once. ok beck jsing mestre
2018-11-06unrevert the use of bn_rand_interval().Theo Buehler
ok beck jsing
2018-11-06revert use of bn_rand_interval due to failures with ECDHE and TLSTheo Buehler
2018-11-05Make use of bn_rand_interval() where appropriate.Theo Buehler
ok beck jsing
2018-11-05Eliminate a few "} else" branches, a few unneeded NULL checks beforeTheo Buehler
freeing and indent nearby labels. ok beck jsing
2018-11-05Remove two unnecessary BN_FLG_CONSTTIME dances: BN_mod_exp_ct() alreadyTheo Buehler
takes care of this internally. ok beck jsing
2018-08-24Add consts to EVP_PKEY_asn1_set_private()Theo Buehler
Requires adding a const to the priv_decode() member of EVP_PKEY_ASN1_METHOD and adjusting all *_priv_decode() functions. All this is already documented this way. tested in a bulk build by sthen ok jsing
2018-08-24After removing support for broken PKCS#8 formats (it was high time),Theo Buehler
we can add const to PKCS8_pkey_get0(). In order for this to work, we need to sprinkle a few consts here and there. tested in a bulk by sthen ok jsing
2018-06-12zap stray tabStuart Henderson
2018-06-12Reject excessively large primes in DH key generation. Problem reportedStuart Henderson
by Guido Vranken to OpenSSL (https://github.com/openssl/openssl/pull/6457) and based on his diff. suggestions from tb@, ok tb@ jsing@ "During key agreement in a TLS handshake using a DH(E) based ciphersuite a malicious server can send a very large prime value to the client. This will cause the client to spend an unreasonably long period of time generating a key for this prime resulting in a hang until the client has finished. This could be exploited in a Denial Of Service attack."
2018-05-02Remove incorrect NULL checks in DH_set0_key().Theo Buehler
Reported by Ondřej Surý, LibreSSL-portable issue #92. ok inoguchi, jsing
2018-05-01Convert a handful of X509_*() functions to take const as in OpenSSL.Theo Buehler
tested in a bulk by sthen ok jsing
2018-04-14make ENGINE_finish() succeed on NULL and simplify callers as inTheo Buehler
OpenSSL commit 7c96dbcdab9 by Rich Salz. This cleans up the caller side quite a bit and reduces the number of lines enclosed in #ifndef OPENSSL_NO_ENGINE. codesearch.debian.net shows that almost nothing checks the return value of ENGINE_finish(). While there, replace a few nearby 'if (!ptr)' with 'if (ptr == NULL)'. ok jsing, tested by & ok inoguchi
2018-02-22Provide DH_get0_engine().Joel Sing
2018-02-20Fix bogus check. Spotted by brynet, thanks.Theo Buehler
2018-02-20Provide DH_set_length()Theo Buehler
ok jsing
2018-02-20Provide DH_bits()Theo Buehler
ok jsing
2018-02-20Provide DH_{clear,set,test}_flags().Theo Buehler
ok jsing
2018-02-18Provide {DH,DSA}_set0_key(). Requested by sthen.Theo Buehler
ok jsing
2018-02-18Provide DH_set0_pqg.Theo Buehler
ok jsing
2018-02-17Provide further parts of the OpenSSL 1.1 API: {DH,DSA}_get0_{key,pqg}(),Theo Buehler
EVP_PKEY_get0_{DH,DSA,RSA}(), RSA_{g,s}et0_key(). ok jsing
2017-01-29Send the function codes from the error functions to the bit bucket,Bob Beck
as was done earlier in libssl. Thanks inoguchi@ for noticing libssl had more reacharounds into this. ok jsing@ inoguchi@
2017-01-21Make explicit _ct and _nonct versions of bn_mod_exp funcitons thatBob Beck
matter for constant time, and make the public interface only used external to the library. This moves us to a model where the important things are constant time versions unless you ask for them not to be, rather than the opposite. I'll continue with this method by method. Add regress tests for same. ok jsing@
2016-12-30Expand ASN1_ITEM_rptr macro - no change in generated assembly.Joel Sing
2016-11-04Kill a bunch of OLD_ASN1 usage by replacing ASN1_{d2i,i2d}_* withJoel Sing
ASN1_item_{d2i,i2d}_* equivalents. ok guenther@ miod@
2016-07-07call BN_init on temporaries to avoid use-before-set warningsBrent Cook
ok beck@