summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/objects/obj_dat.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Make OBJ_add_object() statictb2024-03-021-3/+2
| | | | | | | 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-021-18/+1
| | | | | | | | | | | | 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
* 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
* 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@
* 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.
* 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
* Garbage collect two commented abort()tb2023-08-171-3/+1
|
* Make the local ASN1_OBJECTs consttb2023-08-171-2/+2
| | | | ok jsing
* Remove some unnecessary else branchestb2023-08-171-7/+5
|
* Remove some parents from return statementstb2023-08-171-8/+8
|
* Use cmp instead of i for the result of a comparisontb2023-08-171-5/+5
| | | | ok jsing
* Use OBJ_cmp() instead of inlining two variantstb2023-08-171-12/+4
| | | | | | | | | | This also avoids more undefined behavior with memcmp(). ok jsing PS: Unsolicited advice for no one in particular: there is this awesome tool called grep. If someone reports an issue, you might want to use it to find more instances.
* Hide symbols in objectsbeck2023-07-081-1/+18
| | | | ok tb@
* Simplify OBJ_obj2txt()tb2023-05-231-7/+1
| | | | | | | | | | Instead of adding a NUL termination to OBJ_obj2txt(), move the aobj == NULL or aobj->data == NULL checks to i2t_ASN1_OBJECT_internal(). The only other caller, i2t_ASN1_OBJECT(), fails on aobj == NULL and aobj->length == 0, and the latter condition is implied by aobj->data. Cleaner solution for obj_dat.c r1.52 suggested by/ok jsing
* Always NUL terminate buf in OBJ_obj2txt()tb2023-05-231-1/+4
| | | | | | | | | | | OBJ_obj2txt() is often called without error checking and is used for reporting unexpected or malformed objects. As such, we should ensure buf is a string even on failure. This had long been the case before it was lost in a recent rewrite. If obj and obj->data are both non-NULL this is already taken care of by i2t_ASN1_OBJECT_internal(), so many callers were still safe. ok miod
* spelling fixes; from paul tagliamontejmc2022-12-261-3/+3
| | | | | | | i removed the arithmetics -> arithmetic changes, as i felt they were not clearly correct ok tb
* Make internal header file names consistenttb2022-11-261-2/+2
| | | | | | | | | | | | | | | | Libcrypto currently has a mess of *_lcl.h, *_locl.h, and *_local.h names used for internal headers. Move all these headers we inherited from OpenSSL to *_local.h, reserving the name *_internal.h for our own code. Similarly, move dtls_locl.h and ssl_locl.h to dtls_local and ssl_local.h. constant_time_locl.h is moved to constant_time.h since it's special. Adjust all .c files in libcrypto, libssl and regress. The diff is mechanical with the exception of tls13_quic.c, where #include <ssl_locl.h> was fixed manually. discussed with jsing, no objection bcook
* Provide t2i_ASN1_OBJECT_internal() and use it for OBJ_txt2obj()jsing2022-03-191-30/+3
| | | | | | | | | | | The current OBJ_txt2obj() implementation converts the text to ASN.1 object content octets, builds a full DER encoding from it, then feeds the entire thing back through the DER to ASN.1 object conversion. Rather than doing this crazy dance, provide an t2i_ASN1_OBJECT_internal() function that converts the text to ASN.1 object content octets, then creates a new ASN1_OBJECT and attaches the content octets to it. ok inoguchi@ tb@
* Rewrite ASN1_OBJECT content to ascii/text conversion.jsing2022-03-021-76/+5
| | | | | | | | | | Rewrite the ASN1_OBJECT content to ascii/text conversion code using CBB and CBS. Currently there is a strange split with i2t_ASN1_OBJECT() calling OBJ_obj2txt() which implements the conversion, while OBJ_txt2obj() calls back into the misnamed a2d_ASN1_OBJECT() function. Move the conversion code into asn1/a_object.c and have OBJ_txt2obj() call that instead. ok inoguchi@ tb@
* Limit OID text conversion to 64 bits per arc.jsing2022-02-121-55/+16
| | | | | | | | | | | | | | | | The current implementation uses an unsigned long, then switches to BN once the arc exceeds its size. However, the complexity of BN_bn2dec() is quadratic in the length of number being converted. This means that OIDs with excessively large arcs take a lot of computation to convert to text. While the X.660 specification states that arcs are unbounded, in reality they are not overly large numbers - 640K^W64 bits ought to be enough for any arc. Remove BN entirely, switch from unsigned long to uin64_t and fail if an arc exceeds this size. Identified via oss-fuzz timeouts - should fix #41028 and #44372. ok tb@
* Make OBJ_obj2nid() work correctly with NID_undef.jsing2022-02-111-3/+3
| | | | | | | | | | Currently OBJ_obj2nid() with NID_undef returns NID_ccitt - this is due to doing a lookup on an empty value and having NID_undef conflict with an uninitialised NID value. Somewhat based on OpenSSL 0fb99904809. ok tb@
* Prepare to provide OBJ_length() and OBJ_get0_data()tb2022-01-081-1/+22
| | | | | | | | OBJ_length() turns the int obj->length into a size_t, so add an overflow check. While obj->length should never be negative, who knows... ok jsing
* include asn1_locl.h where it will be needed for the bump.tb2022-01-071-1/+3
| | | | discussed with jsing
* Remove assignment of value that is never read.beck2021-09-011-2/+1
| | | | ok tb@
* snprintf/vsnprintf return < 0 on error, rather than -1.deraadt2019-07-031-3/+3
|
* ASN1_OBJECTs should be freed with ASN1_OBJECT_free(3), not with free(3).tb2018-09-081-2/+2
| | | | ok inoguchi, jsing
* indent labelstb2018-09-081-6/+6
|