summaryrefslogtreecommitdiffstats
path: root/test/evp_extra_test.c
AgeCommit message (Collapse)Author
2022-08-18Add testcases for EVP_PKEY_get1_encoded_public_keyTomas Mraz
Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18902) (cherry picked from commit 3a1596f4e3d710c163279a20e6b844d371886e73)
2022-06-28Add a test for an all 0 RSA keyMatt Caswell
Testing a key with all values set to 0. Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Shane Lontis <shane.lontis@oracle.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18651) (cherry picked from commit 995eccb611431a4857cac3283e2442c01109d428)
2022-06-02Fix the checks of EVP_PKEY_CTX_set/get_* functionsPeiwei Hu
Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18399) (cherry picked from commit 2cba2e160d5b028e4a777e8038744a8bc4280629)
2022-06-02Fix the checks of EVP_PKEY_CTX_get/set_rsa_pss_saltlenPeiwei Hu
Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18399) (cherry picked from commit 7263a7fc3d0c0c17616c2e5309e0fd52ed654ecc)
2022-06-02Fix the erroneous checks of EVP_PKEY_CTX_set_group_namePeiwei Hu
Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18399) (cherry picked from commit 56876ae952b96b4a83266f6b2ec1393f599015d6)
2022-05-24Fix check of EVP_CIPHER_CTX_ctrlPeiwei Hu
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18368) (cherry picked from commit d649c51a5388912277dffb56d921eb720db54be1)
2022-05-23Test the default key length of the Blowfish ciphersTomas Mraz
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18362) (cherry picked from commit 091e60c42c5d2a194936da7f4de3ce82527b27a3)
2022-04-21str[n]casecmp => OPENSSL_strncasecmpDmitry Belyavskiy
Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18103)
2022-04-11Add test for resetting SM2 dist IDTomas Mraz
Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18052) (cherry picked from commit 707d4e06eba71fb8a8b2faa77a2072511189544d)
2022-03-15Update copyright yearMatt Caswell
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2022-01-10Add a test for a custom digest created via EVP_MD_meth_new()Matt Caswell
We check that the init and cleanup functions for the custom method are called as expected. Based on an original reproducer by Dmitry Belyavsky from issue #17149. Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> (Merged from https://github.com/openssl/openssl/pull/17255) (cherry picked from commit fbbe7202eba9fba243c18513f4f0316dafb3496d)
2021-12-13test/evp_extra_test.c: Add EVP_PKEY comparisons in test_EC_priv_pub()Richard Levitte
Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16765) (cherry picked from commit edc8566f475d63278d5f85cd25f324cf2fe9aaf9)
2021-12-13test/evp_extra_test.c: Refactor test_fromdata()Richard Levitte
test_fromdata() turns out to be a bit inflexible, so we split it into two functions, make_key_fromdata() and test_selection(), and adjust test_EVP_PKEY_ffc_priv_pub() and test_EC_priv_pub() accordingly. This allows us to check the resulting keys further, not only to check that the bits we expect are there, but also that the bits that we expect not to be there to actually not be there! Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16765) (cherry picked from commit 5fbe15fd3b7c90a0cfb9f00be16225d8ed18b0dd)
2021-11-27Fix EVP_PKEY_CTX_get_rsa_pss_saltlen() not returning a valueTom Cosgrove
When an integer value was specified, it was not being passed back via the orig_p2 weirdness. Regression test included. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17136) (cherry picked from commit 6f87463b62f9b2849510d74ff0fd6a62955ea947)
2021-11-22Fix EVP_PKEY_decrypt return checkPeiwei Hu
Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17028) (cherry picked from commit 0650ac437b529274aca094c516a5a0127bbaf48c)
2021-11-16EVP_PKEY_keygen_init: fix return checkPeiwei Hu
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17031) (cherry picked from commit bf4ceeded1497c79e72fba4f9ff15febae58108d)
2021-11-16EVP_PKEY_paramgen_init: fix return checkPeiwei Hu
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17030) (cherry picked from commit 6e0b05f3008a3f22105fd2bed9314b0bfa381f93)
2021-11-16EVP_DigestVerifyFinal: fix test function and invocationPeiwei Hu
Signed-off-by: Peiwei Hu <jlu.hpw@foxmail.com> Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17029) (cherry picked from commit e2e5e72d5aec4d8d633cc5e9930f762da7973ab6)
2021-11-16Add a test for creating ECX private keys that are too shortMatt Caswell
We expect attempting to create such short keys to fail Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17041) (cherry picked from commit 8c08c8b37cab0eb66ca74fc65a40af3ccec77c00)
2021-11-15Add null digest implementation to the default providerTomas Mraz
This is necessary to keep compatibility with 1.1.1. Fixes #16660 Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17016) (cherry picked from commit bef9b48e5071cdd2b41a4f486d1bcb5e14b2a5c3)
2021-11-12evp_extra_test: Add SIPHASH MAC digestsign test with reinitializationTomas Mraz
Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16964) (cherry picked from commit 8cbfc4f67b4e97d423ab4784dbbb54d454c6342a)
2021-11-12test: Add testing of reinitialization via EVP_DigestSignInit()Tomas Mraz
Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16964) (cherry picked from commit 816f72d08834ee35ba2615f624b4a29f2717d1c7)
2021-11-12do_sigver_init: Allow reinitialization of an existing operation.Tomas Mraz
Fixes #16936 Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16964) (cherry picked from commit ae6b68b761b9c5f30897747487ea943ccfab53ba)
2021-10-27Test that a key is usable after an EVP_PKEY_fromdata callMatt Caswell
Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16911) (cherry picked from commit fd19fc4c2726b08282b8db15f9bace2f04712498)
2021-10-25X509_PUBKEY_dup: Do not just up-ref the EVP_PKEYTomas Mraz
We try EVP_PKEY_dup() and if it fails we re-decode it using the legacy method as provided keys should be duplicable. Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16648) (cherry picked from commit 7e35458b511f042d9a37d49227b01096c444e575)
2021-10-25Fix no-cmacMatt Caswell
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16894) (cherry picked from commit ef2fb64f9dfde1965cb0b8a5f8765c4f467c1604)
2021-10-22Fix test_CMAC_keygenMatt Caswell
Make sure we correctly pass through the size of the buffer to EVP_DigestSignFinal Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16789) (cherry picked from commit cff7d58eb4c8e0ef43e2fd0b12bc067bd3540e2c)
2021-10-22Test short buffersMatt Caswell
Test that calling EVP_DigestSign(), EVP_DigestSignFinal(), EVP_PKEY_sign(), EVP_PKEY_get_raw_private_key(), or EVP_PKEY_get_raw_public_key() with a short output buffer results in a failure. Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16789) (cherry picked from commit 15ff7d7c2569a1aceaf6e85b61aee62422628fc9)
2021-10-19Add tests for ENGINE problemsMatt Caswell
Add some tests which would have caught the issues fixed in the previous 3 commits related to engine handling. Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16846) (cherry picked from commit 0299094c52ddb66f9a22cfff4e7d70c139112832)
2021-08-26EVP_DigestSign/VerifyFinal: Duplicate the pctx to allow multiple callsTomas Mraz
The legacy implementation duplicates the pctx before creating/verifying the signature unless EVP_MD_CTX_FLAG_FINALISE is set. We have to do the same with provided implementations. Fixes #16321 Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16422)
2021-08-16Test EVP Cipher updating the context's IVIngo Franzki
Ensure that an EVP_CipherUpdate operation updates the context's IV for AES CBC, CFB, OFB, and CTR. An application can get the updated IV via EVP_CIPHER_CTX_iv(). The s390x implementation of the CFB and OFB ciphers in e_aes.c did not update the IV in the context, but only within its s390x specific context data. Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com> Reviewed-by: Patrick Steuer <patrick.steuer@de.ibm.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16291)
2021-08-16Multiple fixes for getting pub key from legacy DH PKEYTomas Mraz
There were multiple issues with getting OSSL_PKEY_PARAM_PUB_KEY from a legacy EVP_PKEY DH and DHX keys. Fixes #16247 Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16253)
2021-07-28Add a test case for EVP_MD_meth_dup() and EVP_CIPHER_meth_dup()Matt Caswell
Check that EVP_MD_meth_free() and EVP_CIPHER_meth_free() does actually free the data. Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16159)
2021-07-27Mark the EVP_PKEY_METHOD arg as const on some EVP_PKEY_meth_get_*() funcsMatt Caswell
Most EVP_PKEY_meth_get_*() functions mark the EVP_PKEY_METHOD argument as const. But 3 did not. We fix those to be consistent. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16128)
2021-07-22Add a test for custom EVP_PKEY_METHODsMatt Caswell
Adds a test for using custom EVP_PKEY_METHODs without an ENGINE. As part of this we also test having a custom EVP_PKEY_METHOD that wraps a built-in EVP_PKEY_METHOD. We do this for both legacy and provided keys. Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16118)
2021-06-15test/evp_extra_test.c: Peek at the error instead of getting it.Richard Levitte
If there is an error report, we want to get it printed too. Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15604)
2021-06-08EVP_PKEY_new_raw_private_key: Allow zero length keysTomas Mraz
Allocate at least one byte to distinguish a zero length key from an unset key. Fixes #15632 Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15643)
2021-06-08Test EVP_CipherInit sequences and resetsJuergen Christ
Various EVP_CipherInit sequences including partial inits and initializations with different "enc" flags caused problems on s390x. Similarly, cipher reinitialization and especially GCM reinitialization with different tag length led to wrong results. Add some unit tests to cover these rather exotic use cases. Signed-off-by: Juergen Christ <jchrist@linux.ibm.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15521)
2021-06-05Fix evp_extra_test to use libctx in an X509_PUBKEYMatt Caswell
Reviewed-by: Shane Lontis <shane.lontis@oracle.com> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15591)
2021-06-01Rename all getters to use get/get0 in nameTomas Mraz
For functions that exist in 1.1.1 provide a simple aliases via #define. Fixes #15236 Functions with OSSL_DECODER_, OSSL_ENCODER_, OSSL_STORE_LOADER_, EVP_KEYEXCH_, EVP_KEM_, EVP_ASYM_CIPHER_, EVP_SIGNATURE_, EVP_KEYMGMT_, EVP_RAND_, EVP_MAC_, EVP_KDF_, EVP_PKEY_, EVP_MD_, and EVP_CIPHER_ prefixes are renamed. Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15405)
2021-05-18seal: make EVP_SealInit() library context awarePauli
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/15300)
2021-05-09Mark pop/clear error stack in der2key_decode_p8Daniel Bevenius
This commit sets the error mark before calling d2i_X509_SIG and clear it if that function call is successful. The motivation for this is that if d2i_X509_SIG returns NULL then the else clause will be entered and d2i_PKCS8_PRIV_KEY_INFO will be called. If d2i_X509_SIG raised any errors those error will be on the error stack when d2i_PKCS8_PRIV_KEY_INFO gets called, and even if it returns successfully those errors will still be on the error stack. We ran into this issue when upgrading Node.js to 3.0.0-alpha15. More details can be found in the ref links below. Refs: https://github.com/nodejs/node/issues/38373 Refs: https://github.com/danbev/learning-libcrypto/blob/master/notes/wrong-tag-issue2.md Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Ben Kaduk <kaduk@mit.edu> (Merged from https://github.com/openssl/openssl/pull/15067)
2021-05-06evp_extra_test: Avoid potential double free of paramsTomas Mraz
Fixes #14916 Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15135)
2021-04-27Deprecate EVP_PKEY_cmp() and EVP_PKEY_cmp_parameters().Shane Lontis
The replacement functions EVP_PKEY_eq() and EVP_PKEY_parameters_eq() already exist. Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com> (Merged from https://github.com/openssl/openssl/pull/14997)
2021-04-23Runchecker: fix no-ec2m build which was trying to validate the e2cm curvesPauli
The evp_extra_test program was trying to validate these curves when they were not build. Fixes #14959 Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14977)
2021-04-23Trivial shortcuts for EVP_PKEY_eq()Tomas Mraz
Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14942)
2021-04-21test: fix double free problems.Pauli
In function test_EVP_PKEY_ffc_priv_pub, params is freed via OSSL_PARAM_free() at line 577. If the condition at line 581 is true, the execution will goto err, and params will be freed again at line 630. The same problem also happens at line 593 and line 609, which causes two double free bugs. Bugs reported by @Yunlongs Fixes 14916 Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14921)
2021-04-19Add test for the IV handling of DES based ciphersTomas Mraz
Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/14882)
2021-04-18TEST: Use OSSL_MAX_NAME_SIZE instead of arbitrary number of mdnameRichard Levitte
Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14498)
2021-04-18TEST: Modify how the retrieved digest name for SM2 digestsign is checkedRichard Levitte
Because of aliases, retrieved names won't always match one specific string. A safer way to check is to fetch the digest from the retrieved name and check it's the expected one with the help of EVP_MD_is_a(). Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14498)