summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/evp (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Less confusing variable names in EVP_PKEY_{de,en}crypt_old()tb2023-12-202-10/+10
| | | | ok jsing
* Improve local variable namestb2023-12-201-29/+29
| | | | | | | Rename the slightly awkward buf_offset into partial_len and rename buf_avail into partial_needed to match. suggested by jsing
* Rename buf_len into partial_len in EVP_CIPHER_CTXtb2023-12-202-11/+11
| | | | suggested by jsing
* Clean up EVP_DecryptFinal_ex()tb2023-12-201-32/+35
| | | | | | | | | | Rework the code to use the usual variable names, return early if we have block size 1 and unindent the remainder of the code for block sizes 8 and 16. Rework the padding check to be less acrobatic and copy the remainder of the plain text into out using memcpy() rather than a for loop. input/ok jsing
* Clean up EVP_EncryptFinal_ex()tb2023-12-201-16/+13
| | | | | | | This switches to the variable names used in other functions, adds a reminder to add a missing length check and uses memset for the padding. ok jsing
* Simplify EVP_DecryptUpdate() a bittb2023-12-201-26/+28
| | | | | | | | | | | | | | | This time the block size is called b and there's some awful length fiddling with fix_len, which until recently also served as store for the return value for do_cipher()... If we land on a block boundary, we keep the last block decrypted and don't count it as part of the output. So in the next call we need to feed it back in. Feeding it back in counts as output written this time around, so instead of remembering that we need to adjust outl, keep a tally of the bytes written. This way we can also do some overflow and underflow checking. ok jsing
* Remove commented out version of EVP_SealUpdate()tb2023-12-201-13/+1
|
* Remove preprocessor mess in EVP_PKEY_{de,en}crypt_old()tb2023-12-202-39/+8
| | | | | | | | This was done the worst possible way. It would be much simpler to invert the logic and use a single #ifdef. jsing prefers keeping the current logic and suggested we ditch the preprocessor mess altogether. ok jsing, claudio agreed with the initial diff
* Clean up EVP_PBE_CipherInit() a littletb2023-12-181-25/+18
| | | | | | | | This is mostly stylistic cleanup, making the control flow a bit more obvious. There's one user-visible change: we no longer go out of our way to provide info about the unknown algorithm. The nid is enough. ok joshua jsing
* EVP_EncryptUpdate(): make block_size and block_mask consttb2023-12-161-3/+3
| | | | suggested by millert
* First cleanup pass over EVP_EncryptUpdate()tb2023-12-161-36/+37
| | | | | | | | | Use more sensible variable names in order to make the logic a bit easier to follow. The variables may be renamed in a later pass. Unindent a block that was squeezed too much to the right and make a few minor stylistic tweaks. ok jsing
* Move EVP_PBE_find() next to the tablestb2023-12-161-46/+46
| | | | | | | There is no point in having EVP_PBE_CipherInit() between the table and the lookup functions (which it notably uses). No code change.
* Remove OBJ_bsearch_() usage from PBEtb2023-12-161-79/+175
| | | | | | | | | Split the table of built-in password based encryption algorithms into two and use a linear scan over the table corresponding to the type specified in EVP_PBE_find()'s type argument. Use better variable names, make the API a bit safer and generally reduce the eye bleed in here. ok jsing
* Using two different spellings of NULL in the same line is an achievementtb2023-12-161-2/+2
|
* Implement and use a do_cipher() wrappertb2023-12-161-59/+63
| | | | | | | | | | | | | | | Instead of using five different idioms for eight callers of the do_cipher() method in EVP_{Decrypt,Encrypt}{Update,Final_ex}(), wrap the API insanity in an evp_cipher() function that calls do_cipher() as appropriate depending on the EVP_CIPH_FLAG_CUSTOM_CIPHER being set or not. This wrapper has the usual OpenSSL calling conventions. There is one complication in EVP_EncryptUpdate() in the case a previous call wrote only a partial buffer. In that case, the evp_cipher() call is made twice and the lengths have to be added. Add overflow checks and only set outl (the number of bytes written) to out on success. ok jsing
* Remove EVP_PBE_cleanup() from EVP_cleanup()tb2023-12-151-2/+1
| | | | | | It's a noop and will be removed in the next major bump. ok jsing
* Move all the neutered PBE API to the bottom of the filetb2023-12-151-17/+17
|
* Remove unprotected global state from EVP_PBEtb2023-12-151-76/+8
| | | | | | | | | | | | | | | | Nobody adds a custom password-based encryption algorithm, be it a PRF or one that can be an outermost AlgorithmIdentifier in CMS or its precursors. This makes the undocumented and unused EVP_PBE_alg_add{,_type}() always fail. They will be removed in the next major bump. Thus, we no longer need to maintain a global stack of PBE algorithms that one thread can happily modify while another one searches it. In subsequent steps we can then remove another rather pointless use of OBJ_bsearch_(). "Let's optimize the lookup in a table with two dozen entries using about as many glorious layers of obfuscating macros." ok jsing
* Fix a return value confusion in chacha20_poly1305_cipher()tb2023-12-151-2/+2
| | | | | | | | | On overlong input, chacha20_poly1305_cipher() would return 0, which in EVP_CipherUpdate() and EVP_CipherFinal() signals success with no data written since EVP_CIPH_FLAG_CUSTOM_CIPHER is set. In order to signal an error, we need to return -1. Obviously. ok jsing
* Document EVP_Cipher() in codetb2023-12-151-1/+13
| | | | | | | | | | | | | | | EVP_Cipher() is an implementation detail of EVP_Cipher{Update,Final}(). Behavior depends on EVP_CIPH_FLAG_CUSTOM_CIPHER being set on ctx->cipher. If the flag is set, do_cipher() operates in update mode if in != NULL and in final mode if in == NULL. It returns the number of bytes written to out (which may be 0) or -1 on error. If the flag is not set, do_cipher() assumes properly aligned data and that padding is handled correctly by the caller. Most do_cipher() methods will silently produce garbage and succeed. Returns 1 on success, 0 on error. ok jsing
* Move EVP_Cipher() from evp_lib.c to evp_enc.ctb2023-12-152-9/+9
| | | | | | | | EVP_Cipher() is a dangerous thin wrapper of the do_cipher() method set on the EVP_CIPHER_CTX's cipher. It implements (part of) the update and final step of the EVP_Cipher* API. Its behavior is nuts and will be documented in a comment in a subsequent commit. schwarze has a manpage diff that will fix the incorrect documentation.
* Remove misuse warnings for EVP_*Final()tb2023-12-031-12/+1
| | | | | | | | | | | | | | They make no sense. These are thin wrappers of EVP_*Final_ex() and behave exactly the same way. The minor behavior difference of Init and Init_ex is likely a historical artefact of this abomination of an API. Deprecation of the Init functions was recently removed from the manpage. The only reason to prefer the _ex versions over the normal versions is ENGINE. This is no longer an argument. The warnings were added in an attempt at adding automatic cleanup. This broke stuff and was therefore backed out. The warnings remained. discussed with schwarze
* Fix some NULL misspellingstb2023-12-021-10/+10
|
* Revert a hunk of r1.23 that makes no sensetb2023-12-021-8/+2
| | | | | | The commit was about checking EVP_CIPHER_CTX_iv_length(), but the function called here is EVP_CIPHER_CTX_key_length(). The result of the computation is still correct, the check and local variable simply make no sense.
* Unify various EVP_*{Update,Final}*() wrapperstb2023-12-011-18/+10
| | | | | | The correct way of wrapping foo() is 'int ret; ret = foo(); return ret;' because 'return foo();' would be too simple... Also unify branching from EVP_Cipher* into EVP_Encrypt* EVP_Decrypt*.
* Ignore ENGINE at the API boundarytb2023-11-297-52/+36
| | | | | | | | This removes the remaining ENGINE members from various internal structs and functions. Any ENGINE passed into a public API is now completely ignored functions returning an ENGINE always return NULL. ok jsing
* Unifdef OPENSSL_NO_ENGINE in libcryptotb2023-11-193-135/+3
| | | | | | | This is mechanical apart from a few manual edits to avoid doubled empty lines. ok jsing
* Unifdef OPENSSL_NO_ENGINE in pmeth_lib.ctb2023-11-191-41/+3
| | | | | | | This includes a manual intervention for the call to EVP_PKEY_meth_find() which ended up in the middle of nowhere. ok jsing
* Forgot to fix one unsigned int vs int confusiontb2023-11-181-3/+3
| | | | CID 468015