summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/objects (follow)
Commit message (Collapse)AuthorAgeFilesLines
* obj_dat: remove parens from returntb2025-02-261-9/+9
|
* obj_dat: don't shift a->length into the sign bittb2025-02-261-2/+2
| | | | | | | For an OID of excessive length >= 2^12, a->length << 20L is undefined, so add a cast to the target type of (unsigned long). From Kenjiro Nakayama
* obj_dat: don't shift ca->type into the sign bittb2025-02-261-2/+2
| | | | | | | | This is undefined for a ca->type of ADDED_LNAME (2) and ADDED_NID (3) when ca->type << 30L results in a shift into the sign bit, so add a cast to the target type of unsigned long. From Kenjiro Nakayama
* Fix underlying pkey of RSA-PSStb2024-08-281-2/+2
| | | | | | | | | | | | | | | | | | | | There are currently very few differences between the rsa_asn1_meth for plain RSA and the rsa_pss_asn1_meth for RSA-PSS apart from the obviously necessary differnces for base_method, pkey_id, pem_str and info (and the fact that RSA has support for legacy private key encoding). This had the lucky side effect that it didn't really matter which ameth one ended up using after OBJ_find_sigid_algs(). With the upcoming support for X509_get_signature_infO() for RSA-PSS, this needs to change as for RSA-PSS we need to decode the PSS parameters for extracting the "security level", whereas for RSA we can just use the hash length. Thus, for RSA-PSS switch pkey_id from the incorrect rsaEncryption to rassaPss. ok jsing PS: OBJ_find_sigid_algs() manual is no longer entirely correct, but this has been the case since we added Ed25519 support to obj_xref.
* Remove lhash_local.h.jsing2024-07-141-2/+1
| | | | | | | | | lhash_local.h was previously needed since conf/conf_api.c and objects/obj_dat.c were fiddling with lhash internals when deleting via a callback. Since we no longer need to do that, inline the structs in lhash.c and remove the header. ok tb@
* Choose fixed NID for TLS1-PRFtb2024-07-091-0/+1
|
* Add NID for TLS1-PRFtb2024-07-091-0/+2
| | | | ok jsing
* libcrypto: constify most error string tablestb2024-06-241-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | These constitute the bulk of the remaining global mutable state in libcrypto. This commit moves most of them into data.rel.ro, leaving out ERR_str_{functs,libraries,reasons} (which require a slightly different approach) and SYS_str_reasons which is populated on startup. The main observation is that if ERR_load_strings() is called with a 0 lib argument, the ERR_STRING_DATA argument is not actually modified. We could use this fact to cast away const on the caller side and be done with it. We can make this cleaner by adding a helper ERR_load_const_strings() which explicitly avoids the assignment to str->error overriding the error code already set in the table. In order for this to work, we need to sprinkle some const in err/err.c. CMS called ERR_load_strings() with non-0 lib argument, but this didn't actually modify the error data since it ored in the value already stored in the table. Annoyingly, we need to cast const away once, namely in the call to lh_insert() in int_err_set_item(). Fixing this would require changing the public API and is going to be tricky since it requires that the LHASH_DOALL_FN_* types adjust. ok jsing
* fix line wrapping in function definitiontb2024-05-081-2/+3
|
* Make LHASH_OF() and STACK_OF() use opaque structstb2024-03-021-1/+2
| | | | | | | | | | | | | This removes internals of these two special snowflakes and will allow further simplifications. Unfortunately, there are some pieces of software that actually use LHASH_OF() (looking at you, pound, Ruby, and openssl(1)), so we get to keep exposing this garbage, at least for now. Expose lh_error() as a symbol to replace a macro reaching into _LHASH. lh_down_load() is no longer available. _LHASH and _STACK are now opaque, LHASH_NODE becomes internal-only. from jsing
* Remove unused OBJ_create_and_add_object()tb2024-03-021-3/+1
| | | | | | This is an alias for OBJ_create(). I haven't dug into its history. ok jsing
* Remove no longer supported OBJ_NAME_TYPEstb2024-03-021-4/+2
| | | | | | | | | OBJ_NAME_TYPE_PKEY_METH and OBJ_NAME_TYPE_COMP_METH were never used as far as I can tell. Unfortunately, PHP and Python still use the weirdly named OBJ_NAME_do_all*() API to list available ciphers and digests, so the MD and CIPHER variants need to remain public. ok jsing
* Make OBJ_add_object() statictb2024-03-022-5/+3
| | | | | | | This is another implementation detail that should never have leaked out of the library. Only OBJ_create() ever used this. ok jsing
* Remove OBJ_bsearch_()tb2024-03-022-31/+2
| | | | | | | | | | | | The only reason this has still been part of the public API was that libssl used it for cipher lookup. This was fixed by replacing the lookup by proper bsearch() -- why OpenSSL felt the need to reinvent ANSI C API badly will forever remain a mystery. The stack code in libcrypto still uses a version of this. This should be rewritten. It will be a bit easier once sk_find_ex() is removed. ok jsing
* Switch name member of OBJ_NAME to const void *tb2024-03-021-2/+2
| | | | | | Because this is the type it should have had from the get go. ok jsing
* Remove unused public OBJ_NAME_* APItb2024-03-021-10/+1
| | | | | | | This functionality has been disabled for a few months. Now it is high time to garbage collect it. ok jsing
* Neuter OBJ_bsearch{_,ex_}()tb2024-02-261-29/+5
| | | | | | | | | Make these functions always fail. A copy of OBJ_bsearch_ex_() is kept in stack.c, where it is still used by internal_find() for sk_find{,_ex}(). sk_find_ex() will be removed in the upcoming bump, and then we can simplify or rewrite what's still needed. ok jsing
* Add id-ct-rpkiSignedPrefixList NIDjob2024-01-291-0/+1
| | | | | | | | References: https://datatracker.ietf.org/doc/draft-ietf-sidrops-rpki-prefixlist/ https://www.iana.org/assignments/smi-numbers/smi-numbers.xhtml#security-smime-1 OK tb@
* Add id-ct-rpkiSignedPrefixList OIDjob2024-01-291-0/+1
| | | | | | | | References: https://datatracker.ietf.org/doc/draft-ietf-sidrops-rpki-prefixlist/ https://www.iana.org/assignments/smi-numbers/smi-numbers.xhtml#security-smime-1 OK tb@
* Teach OBJ_find_sigid_{,by_}algs(3) about ECDSA with SHA-3tb2024-01-271-1/+21
| | | | | | | | This allows signing and verifying ASN.1 "items" using the ECDSA with SHA-3 signature algorithms. With this diff, ECDSA certificates and CMS products using ECDSA with SHA-3 can be generated using the openssl command line tool. ok jsing
* Allocate a fixed NID for the acmeIdentifer OIDtb2024-01-271-0/+1
| | | | ok job jsing
* Add data for the RFC 8737 acmeIdentifiertb2024-01-271-0/+1
| | | | | | | This teaches the object database OID, long and short names for the ACME identifier X.509v3 extension defined in RFC 8737. ok job jsing
* Stop fiddling with hash table internals from lhash doall callers.jsing2024-01-241-2/+2
| | | | | | | | It is now safe to call delete from an lhash doall callback - stop fiddling wit hash table internals from lhash doall callers that previously has to workaround this themselves. ok tb@
* The OBJ_NAME API joins the party in evp_names.ctb2024-01-131-51/+0
| | | | ... and another file without license disappears.
* Remove obj_cleanup_defertb2024-01-131-12/+1
| | | | | With check_defer() gone, this is never set to anything but 0, so the two conditional branches it is still involved in are dead code.
* Garbage collect check_defer()tb2024-01-131-8/+1
| | | | | | | | | | | | | This was a mechanism to ensure that OBJ_cleanup() doesn't remove the ASN1_OBJECT associated with a custom cipher or digest (that was added with EVP_add_{cipher,digest}(), while the latter is still referenced in the OBJ_NAME table. It had the effect that OBJ_cleanup() wasn't actually called ever from OPENSSL_cleanup() (it is only called if you load the OID conf module). Oh, and of course it was once part of the public API. I fixed that two years ago, almost exactly to the day. Still mentioned in OBJ_create.3.
* Remove the guts of the OBJ_NAME APItb2024-01-131-244/+11
| | | | | | | | | | | | | | | | | | | | | With one exception, none of this is used anymore. All of it will be removed in the next major bump. The exception is OBJ_NAME_add(). scurity/xca ran into issues with their cert renewal logic because RSA certs had a way of mapping the signature algorithms to a hash, but a similar mechanism wasn't available for ECDSA certs. So xca uses EVP_add_digest_alias() to have corresponding aliases for ECDSA. This is a macro wrapping OBJ_NAME_add(). xca now has better logic using the more appropriate OBJ_find_sigid_algs() (which wasn't available back then). We will still add the alias entries that xca still adds ourselves to make sure there are no unexpected side effects. They make sense anyway. The diff will hopefully land in a few days. If your life depends on ECDSA cert renewal in xca please hold off on updating to a new snap. ok jsing
* Reimplement {EVP_CIPHER,EVP_MD,OBJ_NAME}_do_all{,_sorted}(3)tb2024-01-131-80/+1
| | | | | | | | | | | | | | | | | | | | | This implements the do_all API by simple loops over the tables of digests and ciphers. Since some ciphers are only available on some platforms, we need to skip them if necessary. We use loops in each of the functions rather the convoluted way of reducing some of the loops to others. Since the tables are sorted, as ensured by regress, both do_all() and do_all_sorted() walk the lists in order. In particular, we no longer need to allocate to be able to sort hash tables by name on the fly in a void function that may end up doing nothing because allocation failed. We still need to do an unchecked OPENSSL_init_crypto() call. But that's what prayer and clean living are there for (as beck put it). The OBJ_NAME API is completely misnamed. It has little to do with objects and a lot to do with EVP. Therefore we implement what will remain from its saner replacement in the evp directory, i.e., evp_names.c. 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
* Move the txt to obj/nid conversions a bit down.tb2023-12-141-42/+42
| | | | No code change
* Dedup OBJ_nid2{obj,sn,ln}()tb2023-12-141-49/+9
| | | | | First get the obj corresponding to nid, then inspect its sn and ln. Shaves off 40 lines of code and will simplify locking.
* Simplify OBJ_nid2obj()tb2023-12-141-23/+26
| | | | | | | This is now yet another identical copy of the same code... Next step will be to dedup. ok jsing
* Simplify OBJ_nid2sn()tb2023-12-141-23/+26
| | | | | | | This is exactly the same as the previous OBJ_nid2ln() change modulo s/ln/sn/g. ok jsing
* Simplify OBJ_nid2ln()tb2023-12-141-23/+26
| | | | | | | | | | | | If nid is in the range of built-in NIDs, return the corresponding long name, unless some genius left a hole. Otherwise perform a yolo check if there are any user-added objects with matching nid in the global hash. This changes behavior in that we now push an OBJ_R_UNKNOWN_NID error onto the stack even if there are no user-added objects. ok jsing
* Simplify OBJ_ln2nid()tb2023-12-131-42/+32
| | | | | | | | | This is s/sn/ln/g of the previous commit and eliminates another OBJ_bsearch_() user, the last one in this file. The bsearch() uses in this file are possibly the only ones that actually make sense since we're searching tables of roughly 1000 entries. ok jsing
* Simplify OBJ_sn2nid()tb2023-12-131-41/+30
| | | | | | | | | | Another OBJ_bsearch_() elimination. OBJ_sn2nid() is very similar to OBJ_obj2nid(). First it tries to retrieve an object identifier with matching "short name" from the global hash of added objects and then searches the table of built-in objects. ok jsing
* Simplify OBJ_obj2nid()tb2023-12-131-39/+28
| | | | | | | | | | | | | | | | | | Continue with OBJ_bsearch_() elimination. OBJ_obj2nid() first checks if the object identifier passed in has a nid and if so, it returns that. Otherwise, it looks into the global hash of added objects (of course without locking) for a match and then returns the nid thereof. As a last attempt, it searches the table of built-in object identifiers. The last two steps can be cleaned up and simplified quite a bit by using C99 initializers, bsearch() and an appropriate comparison function. Then it becomes obvious that bsearch() already returns a pointer to the nid we're looking for, so there is no point in converting that into its corresponding obj and returning the nid thereof. ok jsing
* Remove silly parenthesestb2023-11-271-3/+3
|
* Improve error handling in OBJ_add_object()tb2023-09-051-13/+7
| | | | | | | | | | | | | | | | | There is no need for a helper function to obfuscate lh_ADDED_OBJ_new(). Just call the real thing directly. Adding an object with a NID of NID_undef basically amounts to disabling a built-in OID. It does so in an incoherent fashion and the caller can't easily tell success from failure of the operation. Arguably the result is a corrupted objects table. Let's not allow adding such an object in an attempt at keeping things slightly more coherent. Issue noted and initial diff by schwarze while writing documentation ok schwarze