summaryrefslogtreecommitdiff
path: root/src (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Remove a changelog from 1991tb2023-12-201-8/+1
|
* DES_random_key() sets the keytb2023-12-203-71/+15
| | | | | There's no need to have 60 lines of license for 4 lines of actual code. Move DES_random_key() to set_key.c.
* Remove commented-out codetb2023-12-201-8/+1
|
* A small cleanup of malloc_bytes(), getting rid of a goto and a tinyotto2023-12-191-29/+27
| | | | bit of optimization; ok tb@ asou@
* cmac: use block_size rather than bltb2023-12-181-35/+36
| | | | This is purely mechanical apart from a single line wrap.
* 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
* c2sp: replace openssl 3.0 with 3.2 supporttb2023-12-171-2/+2
|
* ASN1_STRING_TABLE_get.3: grammar: have -> hastb2023-12-161-2/+2
|
* 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
|
* Annotate incorrect value for ub_email_addresstb2023-12-162-3/+8
| | | | | | | | | | | | | | | | | The ub_email_address upper bound, 128, returned for NID_pkcs9_emailAddress, doesn't match the PKCS#9 specification where it is 255. This was adjusted in RFC 5280: The ASN.1 modules in Appendix A are unchanged from RFC 3280, except that ub-emailaddress-length was changed from 128 to 255 in order to align with PKCS #9 [RFC2985]. Nobody seems to have noticed so far, so leave it at an XXX and a BUGS entry for now. It also clearly has the wrong name. Another mystery is why the RFCs suffix some upper bounds with length, but not others. Also, OpenSSL chose to be inconsistent with that, because inconsistency is one of the few things this library is really good at.
* Neuter the ASN1_STRING_TABLE modification APItb2023-12-161-133/+16
| | | | | | | | This is complete nonsense that nothing's ever used except for a test by schwarze. It will be removed in the next major bump. What remains could be moved to a simple lookup table in security/xca... ok jsing
* Remove call to ASN1_STRING_TABLE_cleanup()tb2023-12-161-2/+1
| | | | | | | | In a few minutes, the string table will no longer have anything to clean up and ASN1_STRING_TABLE_cleanup() will push an error on the stack. So remove this pointless call in the still too complicated OPENSSL_cleanup(). ok jsing
* asn1.h: mark a type and a bunch of macros for removaltb2023-12-161-2/+3
| | | | ok jsing
* Rename ASN1_STRING_TABLE_add manual to _gettb2023-12-162-3/+3
|
* Remove ASN1_STRING_TABLE_{add,cleanup}() documentationtb2023-12-161-71/+14
| | | | | | | | | | | The unused ASN1_STRING_TABLE extensibility API will be removed in the next major bump and the table itself will become immutable. Lightly adjust the remaining text. In particular, update the RFC reference, stop talking about defaults when nothing can be changed anymore, do not mention useless flags that you will no longer be able to set and move the description of the only remaining flag after the description of ASN1_STRING_TABLE_get(). The file will be renamed in a second step.
* 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 the string_table testtb2023-12-152-130/+1
| | | | | | | | If it wasn't for security/xca, all of the ASN1_STRING_TABLE API would hit the attic before long. API design by a trained professional... The table can at least be made immutable, which in turn makes this test entirely pointless.
* Remove strings.h againtb2023-12-151-2/+1
| | | | The portable compat shim doesn't provide it.
* 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
* Disallow ciphers with EVP_CIPH_FLAG_CUSTOM_CIPHER in CMACtb2023-12-151-1/+8
| | | | | | | | | | | | | | | | These are usually AEAD ciphers, for which CMAC makes little sense (if you need a MAC and all you have is an AEAD, you don't need CMAC, you can just use a zero length cipher text). Also, since the CMAC implementation only allows 64 and 128 bit block sizes, the AEADs would error out later anyway. The only family of ciphers this effectively excludes is AES key wrap, for which CMAC makes little sense. One notable side effect of doing this is that the EVP_Cipher() return value checks in the CMAC code magically become correct. EVP. What's not to love about it. 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.
* Clean up includestb2023-12-151-6/+4
|
* Neuter EVP_PKEY_asn1_add{0,_alias}()tb2023-12-151-42/+10
| | | | | | | | | Nothing uses these, so they will be removed in the next bump. For now make them always fail and remove the unprotected global state backing them. This makes EVP_PKEY_asn1_get{0,_count}() completely trivial and will allow some further cleanup in later steps. ok jsing
* Hoist OBJ_sn2nid() over OBJ_ln2nid()tb2023-12-151-17/+17
| | | | | In all other places, the short name comes before the long name, so fix the only exception.
* Coverity rightly points out that an unsigned int is always >= 0tb2023-12-151-4/+4
|
* OBJ_create: sorry Omar, aobj is a better name than optb2023-12-141-5/+5
| | | | Done.
* OBJ_create: use a nid variable to avoid nested function calltb2023-12-141-3/+4
|
* OBJ_create: malloc() -> calloc()tb2023-12-141-2/+2
|
* OBJ_create: test and assign as usualtb2023-12-141-7/+7
|
* OBJ_create: initialize buf and turn function into single exittb2023-12-141-4/+5
|
* OBJ_create: rename ok to ret and make it last declarationtb2023-12-141-4/+4
|
* OBJ_create(): rename i to lentb2023-12-141-8/+8
|
* OBJ_create(): remove pointless parenthesestb2023-12-141-4/+4
|
* OBJ_create(): remove useless casttb2023-12-141-2/+2
|
* OPENSSL_assert() that the passed nid is within rangetb2023-12-141-1/+7
| | | | discussed with deraadt and jsing
* Bump OPENSSL_showfatal() from LOG_INFO to LOG_CONStb2023-12-141-2/+2
| | | | | | This way people can actually notice that an OPENSSL_assert() triggered. discussed with deraadt and jsing