summaryrefslogtreecommitdiff
path: root/src/lib (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* Rework rsa_priv_decode()tb2023-12-281-14/+17
| | | | | | | Turn the function into single exit and error check EVP_PKEY_assign() for style. ok jsing
* Clean up old_rsa_priv_decode()tb2023-12-281-4/+13
| | | | | | | Again change this function into the single exit idiom, and error check EVP_PKEY_assign(). ok jsing
* Clean up and fix pkey_cmac_keygen()tb2023-12-281-11/+16
| | | | | | | | | | | | | | | A void pointer can be passed without any cast or assigning it to an intermediate variable. That's one of hte puzzling things in old OpenSSL code: there are plenty of unnecessary casts and assignments of void pointers. Make use of this fact and rework the function to be single exit, error check consistently, including the EVP_PKEY_assign() call that can't really fail and free the cmkey on exit. Why coverity didn't flag this one is another mystery. ok jsing
* Replace EVP_KEY_assign_GOST() calls with EVP_PKEY_set_type()tb2023-12-281-3/+7
| | | | | | | | | | Calling EVP_KEY_assign_GOST(pkey, NULL) has the same effect as calling EVP_PKEY_set_type(pkey, EVP_PKEY_GOSTR01). The only difference is that the latter form allows for error checking while the former won't let you do that. Add comments explaining what we're actually doing: freeing and zeroing the pkey->pkey union. ok jsing
* Fix another EVP_PKEY_assign_GOST() calltb2023-12-281-2/+4
| | | | | | | | | Again this can't actually fail, but if it did, things would leak. Call GOST_KEY_free() in the error path. ok jsing CID 471706 (false positive)
* Clean up pkey_gost_mac_keygen()tb2023-12-281-8/+15
| | | | | | | | | | Make this function single exit, check and assign and finally error check EVP_PKEY_assign(). This can't actually fail currently, but if it did, things would leak. Free the key data with freezero. ok jsing CID 471704 (false positive)
* X509_LOOKUP_shutdown() became a noop.tb2023-12-271-2/+1
| | | | | | | That we are still calling this (NB without error check because heritage), made coverity unhappy. CID 471705
* Rename some argument placeholders to be less cryptic,schwarze2023-12-262-55/+58
| | | | | | | | | | | | | | in particular s/inl/in_len/ and s/outl/out_len/ as suggested by tb@. While here, also get rid of the "outm" placeholder that has been around since the file was added to OpenSSL in 2000, replacing it with the usual "out" in the four function prototypes affected; tb@ and myself suspect it was simply a typo followed by copy and paste. Slightly improve variable naming in the examples, too, for clarity and consistency, even though that doesn't turn the examples into good examples. OK tb@
* Close some major gaps in the documentation of EVP_Cipher(3),schwarze2023-12-261-10/+65
| | | | | and describe EVP_CIPHER_CTX_init(3) in a less misleading way. Joint work with and OK tb@.
* 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
* Remove unused X509_LOOKUP_METHODstb2023-12-255-43/+12
| | | | | | | | None of these function pointers were ever set. Now that the structure is opaque they won't ever be, so time for them to hit the bitbucket. Infinite extensibility of the toolkit results in complications, bugs, and dead code. ok jsing
* Avoid out-of-bounds accesses in ASN1_BIT_STRING_{get,set}()tb2023-12-251-14/+26
| | | | | | | | | | | | If a negative n is passed, these functions would underrun the bitstring's data array. So add checks for that and drop spades of unnecessary parens. These functions are quite broken anyway. The setter attempts to zap the unnecessary trailing zero octets, but fails to do so if the bit being cleared isn't already set. Worse is the getter where you can't tell an error (like attempting an out-of-bounds read) from the bit being unset. ok joshua
* 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
* Clarify that the ENGINE argument is ignored; OK tb@.schwarze2023-12-251-11/+10
| | | | | While here, also switch the argument placeholder from *impl to *engine as suggested by tb@.
* 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.
* Prefix get_trusted_issuer() with x509_vfy_tb2023-12-231-4/+3
|
* 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
* Rename check_hosts()tb2023-12-221-3/+3
|
* Replace check_trust() with its x509_vfy_ prefixed wrappertb2023-12-221-11/+4
|
* Replace check_chain_extensions() with its x509_vfy_ wrappertb2023-12-221-8/+2
|
* Replace check_id() with its x509_vfy_check_id() wrappertb2023-12-221-9/+4
|
* Remove a bunch of function pointers from X509_STORE_CTXtb2023-12-222-42/+18
| | | | | | | | | These are only ever set to one particular function which is either local to this file or part of the public API and we never added the public API to set them to something else. Prefix the local functions touched in this commit with x509_vfy_. More cleanup to follow. 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
* Clean up includes in cms_smime.ctb2023-12-221-7/+14
|
* evp_enc: make some flag checks explicittb2023-12-221-4/+4
| | | | ok joshua jsing
* Remove cleanup() and get_crl() from X509_STORE_CTXtb2023-12-222-15/+3
| | | | ok jsing
* Remove unused function pointers from X509_STOREtb2023-12-222-55/+11
| | | | | | | | | The struct underlying the X509_STORE type is opaque ars and nothing uses the accessors that OpenSSL added blindly for these. Therefore we didn't add them in the first place. So this rips out several dozens of lines of dead code. ok beck joshua jsing
* Remove EVP_PKEY_asn1_add{0,_alias}() documentationtb2023-12-214-78/+14
| | | | | | This API was recently neutered and will be removed in the next major bump. Mark it as intentionally undocumented in EVP_PKEY_asn1_new.3 and remove it from all other manuals.
* Mark some API-to-be-removed as intentionally undocumentedtb2023-12-211-2/+6
|
* Remove some superfluous parenthesestb2023-12-211-3/+3
|
* Clean up includes in cms_pwri.ctb2023-12-201-8/+10
|
* Use BIO_indent() for indentation in tasn_prn.ctb2023-12-201-10/+4
| | | | | | | | | | | | | | | Using a loop to print pieces of a static buffer containing 20 spaces to indent things is just silly. Even sillier is making this buffer const without looking what it's actually used for... There is BIO_indent() or BIO_printf() that can handle "%*s". Add a length check to preserve behavior since BIO_indent() succeeds for negattive indent. However, peak silliness must be how BIO_dump_indent_cb() indents things. That's for another day. ok jsing
* 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
|