summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/evp (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* Simplify EVP_CIPHER_{asn1_to_param,parma_to_asn1}()tb2024-01-021-17/+13
| | | | There's no need for a ret variable and else if/else
* Move the EVP_CIPHER API that only exists for CMS/legacy a bit downtb2024-01-021-121/+125
|
* sm4: more NULL misspellingstb2024-01-021-4/+4
|
* Two spellings of key length are enoughtb2024-01-021-6/+7
| | | | | | The API is called EVP_CIPHER_CTX_set_key_length() it has an argument called keylen and, the EVP_CIPHER_CTX's member is called key_len. One of the three is trivial to adjust, so do it.
* Rename the poor outlier EVP_CIPHER *e into *ciphertb2024-01-021-3/+3
|
* Better variable names in EVP_CIPHER_type()tb2024-01-021-7/+8
| | | | | The EVP_CIPHER *ctx (yes) is renamed to cipher, otmp becomes an aobj. Change two !ptr to ptr == NULL checks.
* Consistently use ctx for an EVP_CIPHER_CTXtb2024-01-021-36/+36
| | | | Not c (which is most of the time an EVP_CIPHER) or a (?!).
* Fix bounds check in EVP_PKEY_CTX_get_keygen_info()tb2024-01-011-2/+2
| | | | | | | | | Replace > with >= for the upper array bound to disallow a 4 byte overread. For RSA you can read the padding mode and for DH past the DH_PKEY_CTX. Unfortunately, Ruby thought it important to use this, so we can't kill it easily. ok miod
* Remove EVP_PKEY's save_type membertb2024-01-012-6/+2
| | | | | | | This was only used to avoid an ameth lookup in EVP_PKEY_set_type(), a micro-optimization that was removed in p_lib.c r1.48. ok jsing
* Some Australians don't like voids eithertb2023-12-301-3/+3
|
* Move the EVP_PKEY_asn1_* API that will stay to evp/p_lib.ctb2023-12-292-6/+256
| | | | | | | | Most of these functions are only called from this file internally apart from the pem_str lookups from pem/. In the next major bump we can then remove asn/ameth_lib.c. Also move EVP_PKEY_ASN1_METHOD to evp_local.h. While this is used to dispatch to various ASN.1 decoding routines, it doesn't fit into asn1/ at all.
* Zap some whitespacetb2023-12-291-2/+2
|
* Move the EVP_MD block size accessor downtb2023-12-291-7/+11
| | | | | | This way all the EVP_MD accessors are in the order of the struct fields. Well, arguably the EVP_MD_meth* should come first, but they are scheduled to go meet the dodo.
* Move the EVP_MD_CTX flag accessors up a bittb2023-12-291-19/+19
| | | | This way the accessors are sorted the same way as the struct.
* Hoist EVP_MD_CTX accessors to after EVP_MD_CTX_ctrltb2023-12-291-63/+62
| | | | | | | This way the file has EVP_Digest*, then EVP_MD_CTX new/free/clean, then ctrl then the EVP_MD_CTX accessors, then the EVP_MD accessors and finally the EVP_MD_meth stuff and the order of things starts making a wee bit of sense.
* Move init/reset next to cleanuptb2023-12-291-13/+13
| | | | | | This way new/free aka create/destroy are next to each other. reset/cleanup are the same thing and init will join the club after some other fixing because two APIs that do the exact same thing aren't enough.
* Move the copy/copy_ex stuff down below the new/free/clear messtb2023-12-291-63/+64
|
* Merge the EVP_CIPHER_meth_* API into evp_cipher.ctb2023-12-292-186/+175
|
* Merge the remainder of evp_lib.c into evp_cipher.ctb2023-12-292-365/+298
|
* Move the middle part of evp_lib.c to evp_digest.ctb2023-12-292-205/+205
| | | | | These are ~200 lines of EVP_MD API that separated two parts of the file dedicated to EVP_CIPHER thingies.
* Use more consistent naming for some files in evptb2023-12-293-3/+3
| | | | | | | | | | | | | EVP_Digest{Init,Update,Final}() move from digest.c to evp_digest.c which will become the home of all things related to EVP_MD{,_CTX} handling. EVP_Cipher{Init,Update,Final}() move from evp_enc.c to evp_cipher.c which will become the home of all things related to EVP_CIPHER{,_CTX} handling. EVP_Encode{Init,Update,Final}() move from encode.c to evp_encode.c which already is the home of EVP_ENCODE_CTX_{new,free}(). discussed with jsing
* EVP_CipherInit(): remove cleanup calltb2023-12-261-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | There is a bizarre EVP_CIPHER_CTX_cleanup() call in EVP_CipherInit() leading to a subtle behavior difference with EVP_CipherInit_ex(). The history is that before EVP_CIPHER_CTX was made opaque, a context would often live on the stack (hello, MariaDB) and the EVP_CIPHER_CTX_cleanup() call was in fact an EVP_CIPHER_CTX_init() which just zeroes out the struct. The problem with doing this is that on context reuse there could be data hanging off it, causing leaks. Attempts were made to clean up things in EVP_CipherFinal*(), but that broke applications reaching into the context afterward, so they were removed again. Later on, opacity allowed changing the _init() to a _cleanup() since EVP_CIPHER_CTX could no longer live on the stack, so it would no longer contain garbage. I have to correct myself: it would no longer contain stack garbage. Now: EVP_CipherInit_ex() does some extra dances to preserve the AES key wrap flag, which is cleared unconditionally in EVP_CipherInit(). That's annoying to document and very likely never going to be an issue in the wild: you'd need to do key wrap and then use the same context for use with a cipher that does not allow key wrap for this to make a difference. This way, all our EVP_{Cipher,Decrypt,Encrypt}*_ex() functions are now trivially wrapped by their non-_ex() versions. ok jsing
* EVP_CipherInit_ex() merge two code pathstb2023-12-261-9/+4
| | | | | | | | Clean up the cipher context unconditionally if the cipher is being set. This allows doing the dance to retain the key wrap flag only once and makes it more obvious that allocating the cipher data doesn't leak. suggested by/ok jsing
* Move EVP_PKEY_assign() a bit up and tweak it slightlytb2023-12-251-10/+10
| | | | ok jsing
* Rename a few ret into pkeytb2023-12-251-28/+29
|
* Rework EVP_PKEY_set_type{,_str}()tb2023-12-251-34/+27
| | | | | | | | | | | | | These two functions previously wrapped a pkey_set_type() helper, which was an utter mess because of ENGINE. With the long awaited departure of ENGINE, this function became a lot simpler. A further simplification is obtained by not doing the optimization to avoid an ameth lookup: this requires walking a list of 11 ameths. We should consider bsearch()... With this gone and a saner implementation of EVP_PKEY_free_it(), we can implement these functions with a dozen lines of code each. ok jsing
* Rework EVP_PKEY_free()tb2023-12-251-11/+7
| | | | | | | | Use pkey instead of x, remove the pointless variable i, no need to check for NULL before sk_X509_ATTRIBUTE_pop_free(), switch to freezero() to leave fewer invalid pointers around. ok jsing
* Move EVP_PKEY_free() up next to evp_pkey_free_pkey_ptr()tb2023-12-251-19/+19
| | | | ok jsing
* Fix EVP_PKEY_up_ref() - must have hit ^X somehowtb2023-12-251-2/+2
|
* Rework evp_pkey_free_pkey_ptr()tb2023-12-251-6/+7
| | | | | | Rename the variable from x into pkey, make it NULL safe and unindent. ok jsing
* Rename EVP_PKEY_free_it() into evp_pkey_free_pkey_ptr()tb2023-12-251-4/+4
| | | | ok jsing
* Move the confusingly named EVP_PKEY_free_it() a bit uptb2023-12-251-12/+10
| | | | ok jsing
* Simplify EVP_PKEY_up_ref()tb2023-12-251-3/+2
| | | | | | There is no need for a local variable and a ternary operator here. ok jsing
* Switch EVP_PKEY_new() from malloc() to calloc()tb2023-12-251-8/+6
| | | | ok jsing
* Move EVP_Digest() next to the functions it wrapstb2023-12-241-18/+18
| | | | | | It really makes no sense to have the mess that is EVP_MD_CTX_copy{,_ex}() live between EVP_Digest{Init{,_ex},Update,Final{,_ex}}() and EVP_Digest(), the latter being a relatively simple wrapper of Init_ex/Update/Final_ex.
* Use more consistent order for Init/Update/Finaltb2023-12-231-17/+17
| | | | | | | Consistently implement the _ex() version after the non-extended versions, First Cipher Init/Update/Final, then Encrypt, then Decrypt. This only switches the order of CipherFinal{,_ex} and move the DecryptInit* down, so they are no longer somewhere in the middle of the Encrypt* functions.
* Remove two no longer necessary reminderstb2023-12-221-3/+1
| | | | | I guess I'm getting old. Next time I'll have to add a reminder not to forget to remove the reminder.
* Remove extra whitespace on two linestb2023-12-221-3/+3
|
* Add length checks for partial_lentb2023-12-221-6/+7
| | | | | | | These remove a few more potential out-of-bounds accesses and ensure in particular that the padding is between 1 and block_size (inclusive). ok joshua jsing
* Simplify some logic in EVP_EncryptInit_ex()tb2023-12-221-24/+28
| | | | | | | | | | Pull up the EVP_R_NO_CIPHER_SET check that was hidden somewhere down in the middle of the function. Handle the reuse case outside of the big non-NULL cipher case for now. This looks a bit odd but relies on the invariant that cipher_data is only set if the cipher is set. It will be reworked in a subsequent commit. ok jsing
* evp_enc: make some flag checks explicittb2023-12-221-4/+4
| | | | ok joshua jsing
* Remove some superfluous parenthesestb2023-12-211-3/+3
|
* Rename impl into enginetb2023-12-201-4/+4
|
* Rename inl to in_len throughout the filetb2023-12-201-32/+32
|
* Rename outl into out_len throughout the filetb2023-12-201-32/+32
|
* Tweak a comment a bittb2023-12-201-3/+3
|
* Remove block_mask from EVP_CIPHER_CTXtb2023-12-202-7/+15
| | | | | | | The block mask is only used in EVP_{De,En}cryptUpdate(). There's no need to hang it off the EVP_CIPHER_CTX since it is easy to compute and validate. ok joshua jsing
* Add some sanity checks for EVP_CIPHER_meth_new()tb2023-12-201-1/+8
| | | | | | | Ensure that the nid and key length are non-negative and that the block size is one of the three sizes 1, 8, or 16 supported by the EVP subsystem. ok joshua jsing
* Merge p_open and p_seal into p_legacytb2023-12-203-244/+103
| | | | discussed with jsing
* Fold p_dec.c and p_enc.c into a new p_legacy.ctb2023-12-202-78/+14
| | | | discussed with jsing