summaryrefslogtreecommitdiffstats
path: root/crypto
AgeCommit message (Collapse)Author
2021-02-26Fix external symbols related to dh keysShane Lontis
Partial fix for #12964 This adds ossl_ names for the following symbols: dh_new_by_nid_ex, dh_new_ex, dh_generate_ffc_parameters, dh_generate_public_key, dh_get_named_group_uid_from_size, dh_gen_type_id2name, dh_gen_type_name2id, dh_cache_named_group, dh_get0_params, dh_get0_nid, dh_params_fromdata, dh_key_fromdata, dh_params_todata, dh_key_todata, dh_check_pub_key_partial, dh_check_priv_key, dh_check_pairwise, dh_get_method, dh_buf2key, dh_key2buf, dh_KDF_X9_42_asn1, dh_pkey_method, dhx_pkey_method Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14231)
2021-02-26Fix external symbols for bnShane Lontis
Partial fix for #12964 This adds ossl_ names for symbols related to bn_* Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14296)
2021-02-25Fix an integer overflow in o_time.cjwalch
If input offset_sec is sufficiently large (> INT32_MAX * SECS_PER_DAY, which is possible for a long on 64-bit platforms), then the first assignment contains an overflow. I think leaving offset_hms as an int is still safe. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14252)
2021-02-25Don't hold a lock when calling a callback in ossl_namemap_doall_namesMatt Caswell
We don't want to hold a read lock when calling a user supplied callback. That callback could do anything so the risk of a deadlock is high. Instead we collect all the names first inside the read lock, and then subsequently call the user callback outside the read lock. Fixes #14225 Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14250)
2021-02-24Fix string termination and length setting in OSSL_PARAM_BLD_push_utf8_string()Richard Levitte
OSSL_PARAM_BLD_push_utf8_string() was still setting the length in bytes of the UTF8 string to include the terminating NUL byte, while recent changes excludes that byte from the length. It's still made to add a NUL byte at the end of the string no matter what. Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14035)
2021-02-24Fix OSSL_PARAM_allocate_from_text() for OSSL_PARAM_UTF8_STRINGRichard Levitte
OSSL_PARAM_allocate_from_text() was still setting the length in bytes of the UTF8 string to include the terminating NUL byte, while recent changes excludes that byte from the length. Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14035)
2021-02-24Cleanup of some of the EVP_PKEY_CTX_ctrl related TODOsTomas Mraz
Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14290)
2021-02-24Fix missing EOL at the end of the rsa/build.infoTomas Mraz
Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14290)
2021-02-24Remove inclusion of unnecessary header filesTomas Mraz
Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14290)
2021-02-24Use strcasecmp when comparing kdf_typeTomas Mraz
Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14290)
2021-02-25Fix typo in comment in DH_set0_pqg functionDaniel Bevenius
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14288)
2021-02-24Duplicate the file and func error stringsMatt Caswell
Errors raised from a provider that is subsequently unloaded from memory may have references to strings representing the file and function that are no longer present because the provider is no longer in memory. This can cause crashes. To avoid this we duplicate the file and func strings. Fixes #13623 Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14213)
2021-02-24provider: add an unquery function to allow providers to clean up.Pauli
Without this, a provider has no way to know that an application has finished with the array it returned earlier. A non-caching provider requires this information. Fixes #12974 Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/12974)
2021-02-24Deprecated EVP_PKEY_CTX_get0_dh_kdf_ukm() and EVP_PKEY_CTX_get0_ecdh_kdf_ukm()Tomas Mraz
The functions are not needed and require returning octet ptr parameters from providers that would like to support them which complicates provider implementations. Fixes #12985 Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14279)
2021-02-24X509: Refactor X509_PUBKEY processing to include provider side keysRichard Levitte
When a SubjectPublicKeyInfo (SPKI) is decoded into an X509_PUBKEY structure, the corresponding EVP_PKEY is automatically added as well. This used to only support our built-in keytypes, and only in legacy form. This is now refactored by making The ASN1 implementation of the X509_PUBKEY an EXTERN_ASN1, resulting in a more manual implementation of the basic support routines. Specifically, the d2i routine will do what was done in the callback before, and try to interpret the input as an EVP_PKEY, first in legacy form, and then using OSSL_DECODER. Fixes #13893 Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14281)
2021-02-23provider: add option to load a provider without disabling the fallbacks.Pauli
Add an argument to PROVIDER_try_load() that permits a provider to be loaded without changing the fallback status. This is useful when an additional provider needs to be loaded without perturbing any other setup. E.g. adding mock providers as part of unit testing. Reviewed-by: Tim Hudson <tjh@openssl.org> (Merged from https://github.com/openssl/openssl/pull/13652)
2021-02-23rand: allow lock/unlock functions to be absentPauli
Reviewed-by: Tim Hudson <tjh@openssl.org> (Merged from https://github.com/openssl/openssl/pull/13652)
2021-02-23RAND_METHOD deprecation: code changesPauli
Reviewed-by: Tim Hudson <tjh@openssl.org> (Merged from https://github.com/openssl/openssl/pull/13652)
2021-02-23EVP: Adapt the EC_KEY specific EVP_PKEY_CTX setter / getter functionsRichard Levitte
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/13913)
2021-02-23EVP: Make checks in evp_pkey_ctx_store_cached_data() more restrictedRichard Levitte
It would check the keytype and optype before determining if it even supported the ctrl command number. This turned out to be disruptive, so we make it check that it supports the request ctrl command number first. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/13913)
2021-02-23EVP: Adapt the RSA specific EVP_PKEY_CTX setter / getter functionsRichard Levitte
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/13913)
2021-02-23EVP: Adapt the DH specific EVP_PKEY_CTX setter / getter functionsRichard Levitte
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/13913)
2021-02-23EVP: Adapt the EVP_PKEY_CTX ctrl functionsRichard Levitte
legacy_ctrl_to_param() and legacy_ctrl_str_to_param() are now replaced with calls to evp_pkey_ctx_ctrl_to_param() and evp_pkey_ctx_ctrl_str_to_param(). Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/13913)
2021-02-23EVP: Adapt diverse OSSL_PARAM setters and gettersRichard Levitte
EVP_PKEY_get_group_name() now simply calls EVP_PKEY_get_utf8_string_param(). EVP_PKEY_CTX_set_group_name() now simply calls EVP_PKEY_CTX_set_params(). EVP_PKEY_get_bn_param(), EVP_PKEY_get_octet_string_param(), EVP_PKEY_get_utf8_string_param() and EVP_PKEY_get_int_param() can now handle legacy EVP_PKEYs by calling evp_pkey_get_params_to_ctrl(). EVP_PKEY_CTX_get_params() can now handle a legacy backed EVP_PKEY_CTX by calling evp_pkey_ctx_get_params_to_ctrl(). Note: EVP_PKEY_CTX_set_params() doesn't call the translator yet. Should it ever? Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/13913)
2021-02-23EVP: Make evp_pkey_ctx_{set,get}_params_strict() legacy awareRichard Levitte
In the interest of calling these functions on legacy EVP_PKEY contexts, only check the settable / gettable params for provider side keys, leaving to the translated EVP_PKEY_CTX_ctrl() call check the ctrl commands on its own. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/13913)
2021-02-23EVP: Implement data-driven translation between known ctrl and OSSL_PARAMsRichard Levitte
The idea is to make it as transparent as possible to call things like EVP_PKEY_CTX_ctrl() with a provider backed EVP_PKEY_CTX, or things like EVP_PKEY_get_bn_param() with a legacy EVP_PKEY. All these sorts of calls demand that we translate between ctrl commands and OSSL_PARAM keys, and treat the arguments appropriately. This implementation has it being as data driven as possible, thereby centralizing everything into one table of translation data, which supports both directions. Fixes #13528 Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/13913)
2021-02-23EVP: Make evp_pkey_ctx_state() available to all of EVPRichard Levitte
This will help with transitioning diverse functions to be able to use the ctrl<->OSSL_PARAM translators. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/13913)
2021-02-23EVP: Implement EVP_PKEY_CTX_is_a()Richard Levitte
This does what was previously done by looking at pctx->pmeth->pkey_id, but handles both legacy and provider side contexts, and is supposed to become a replacement for the old way. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/13913)
2021-02-23Add back in legacy paths for d2i_PrivateKey/d2i_AutoPrivateKey.Shane Lontis
Fixes #14263 If the new decoder code fails, it now falls back to the old legacy code and tries that also. Tested manually using gost engine master. Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> (Merged from https://github.com/openssl/openssl/pull/14266)
2021-02-22Handle NULL result of ERR_reason_error_string() in some appsDr. David von Oheimb
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/13920)
2021-02-22Add EVP_PKEY_public_check_quick.Shane Lontis
Adding the EVP_PKEY_param_check_quick() reminded me that there are also partial checks for public keys as part of SP800-56A for FFC (DH named safe prime groups) and ECC. The code was mainly already there and just needed to be plumbed into the validate methods. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14206)
2021-02-22Fix external symbols for pkcs7.Shane Lontis
Partial fix for #12964 This adds ossl_ names for symbols related to pkcs7_* Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14241)
2021-02-22Fix external symbols for cms.Shane Lontis
Partial fix for #12964 This adds ossl_ names for symbols related to cms_* and ess_* Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14241)
2021-02-20DECODER: Add better tracing of the chain walking processRichard Levitte
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14233)
2021-02-20DECODER: Use the data structure from the last decoder to select the nextRichard Levitte
Any decoder can now also declare the name of the data structure for the object it decoded in the OSSL_PARAM array they pass back to the decoding process. The decoding process will use that as another criterion to select the next decoder in the chain to consider. Together with declaring the data type, this becomes a means to refine how the decoded data is treated along the chain. Fixes #13539 Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14233)
2021-02-19Correct the return value of BIO_get_ktls_*().John Baldwin
BIO_get_ktls_send() and BIO_get_ktls_recv() are documented as returning either 0 or 1. However, they were actually returning the internal value of the associated BIO flag for the true case instead of 1. Also trim redundant ternary operators. Reviewed-by: Shane Lontis <shane.lontis@oracle.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14023)
2021-02-19CMP: Fix total_timeout behavior; small doc and diagnostic improvementsDr. David von Oheimb
Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14019)
2021-02-19CRYPTO_gcm128_decrypt: fix mac or tag calculationZhang Jinde
The incorrect code is in #ifdef branch that is normally not compiled in. Signed-off-by: Zhang Jinde <zjd5536@163.com> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/12968)
2021-02-19Fix merge problem in d2i_PrivateKey_exShane Lontis
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14243)
2021-02-19Fix DH ASN1 decode so that it detects named groups.Shane Lontis
The dh->nid was not being set if the loaded p,g matched an inbuilt named group for "DH". NOTE: The "DHX" related path already worked since it calls DH_set0_pqg() (which does the name group check). This bug was detected when new tests were added for dh5114 groups, combined with the no-cache tests i.e. loading+import+export set the nid, but just loading did not. Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14207)
2021-02-19Fix d2i_AutoPrivateKey_ex so that is uses the new decoder (and producesShane Lontis
non legacy keys). Fixes #13522 Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/13591)
2021-02-18Pass the object type and data structure from the pem2der decoderMatt Caswell
The pem2der decoder can infer certain information about the endoded der data based on the PEM headers. This information should be passed to the next decoders in the chain to ensure we end up loading the correct type of thing. Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14191)
2021-02-18OSSL_PARAM: Correct the assumptions on the UTF8 string lengthRichard Levitte
When the string "ABCDEFGH" is passed, what's considered its data, this? { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' } or this? { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', '\0' } If it's passed as a pass phrase, should the terminating NUL byte be considered part of the pass phrase, or not? Our treatment of OSSL_PARAMs with the data type OSSL_PARAM_UTF8_STRING set the length of the string to include the terminating NUL byte, which is quite confusing. What should the recipient of such a string believe? Instead of perpetuating this confusion, we change the assumption to set the OSSL_PARAM to the length of the string, not including the terminating NUL byte, thereby giving it the same value as a strlen() call would give. Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14168)
2021-02-18Rename internal X509_add_cert_new() to ossl_x509_add_cert_new()Dr. David von Oheimb
Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14039)
2021-02-18Add internal X509_add_certs_new(), which simplifies mattersDr. David von Oheimb
Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14039)
2021-02-18Update copyright yearMatt Caswell
Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14235)
2021-02-18Fix external symbols in the provider digest implementations.Shane Lontis
Partial fix for #12964 This adds ossl_ names for the following symbols: blake2b512_init,blake2b_final,blake2b_init,blake2b_init_key, blake2b_param_init,blake2b_param_set_digest_length,blake2b_param_set_key_length, blake2b_param_set_personal,blake2b_param_set_salt,blake2b_update, blake2s256_init,blake2s_final,blake2s_init,blake2s_init_key, blake2s_param_init,blake2s_param_set_digest_length,blake2s_param_set_key_length, blake2s_param_set_personal,blake2s_param_set_salt,blake2s_update, digest_default_get_params,digest_default_gettable_params Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14211)
2021-02-18DH: Make DH_bits(), DH_size(), and DH_security_bits() check that there are ↵Sahana Prasad
key parameters Fixes #13569 Signed-off-by: Sahana Prasad <sahana@redhat.com> Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> (Merged from https://github.com/openssl/openssl/pull/13955)
2021-02-18chain_build(): Call verify_cb_cert() if a preliminary error has become finalDr. David von Oheimb
Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14157)
2021-02-18dsa_check: Perform simple parameter check if seed is not availableTomas Mraz
Added primality check on p and q in the ossl_ffc_params_simple_validate(). Checking for p and q sizes in the default provider is made more lenient. Added two testcases for invalid parameters. Fixes #13950 Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/14148)