summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/objects/obj_dat.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* Send the function codes from the error functions to the bit bucket,beck2017-01-291-9/+9
| | | | | | as was done earlier in libssl. Thanks inoguchi@ for noticing libssl had more reacharounds into this. ok jsing@ inoguchi@
* Expand DECLARE_OBJ_BSEARCH_CMP_FN and IMPLEMENT_OBJ_BSEARCH_CMP_FN macros.jsing2017-01-211-7/+55
| | | | No change to generated assembly excluding line numbers.
* OBJ_obj2txt() should return the total amount of space requiredinoguchi2016-12-221-5/+1
| | | | | reported by @rhenium on GitHub ok jsing@
* remove unused OPENSSL_NO_OBJECT casebcook2016-07-171-14/+1
| | | | ok tedu@
* better fix for overrun reported by Qualys Security.tedu2015-10-141-4/+1
| | | | | | buf is at all times kept nul terminated, so there is no need to enforce this again upon exit. (no need to move buf around after we exahust space.) ok beck miod
* Bail out early if we have no buf_lenbeck2015-10-141-1/+5
| | | | ok miod@
* fix a memory leak reported by Qualys Security.tedu2015-10-141-3/+4
| | | | | | move the bndec variable in tighter since it's not used elsewhere in the loop, then always free it after use. ok bcook miod
* Ensure we don't write a 0 byte past end of the buffer in the error case.beck2015-10-141-3/+3
| | | | ok bcook@ deraadt@
* Fix CVE-2014-3508, pretty printing and OID validation:guenther2014-08-081-2/+7
| | | | | | | | | | | - make sure the output buffer is always NUL terminated if buf_len was initially greater than zero. - reject OIDs that are too long, too short, or not in proper base-127 Based on https://git.openssl.org/gitweb/?p=openssl.git;a=commit;h=0042fb5fd1c9d257d713b15a1f45da05cf5c1c87 ok bcook@
* Only import cryptlib.h in the four source files that actually need it.jsing2014-07-111-4/+4
| | | | | | | | Remove the openssl public includes from cryptlib.h and add a small number of includes into the source files that actually need them. While here, also sort/group/tidy the includes. ok beck@ miod@
* Explicitly include <openssl/opensslconf.h> in every file that referencesjsing2014-07-101-1/+3
| | | | | | | | | an OPENSSL_NO_* define. This avoids relying on something else pulling it in for us, plus it fixes several cases where the #ifndef OPENSSL_NO_XYZ is never going to do anything, since OPENSSL_NO_XYZ will never defined, due to the fact that opensslconf.h has not been included. This also includes some miscellaneous sorting/tidying of headers.
* Stop including standard headers via cryptlib.h - pull in the headers thatjsing2014-07-101-2/+4
| | | | | | are needed in the source files that actually require them. ok beck@ miod@
* tags as requested by miod and teduderaadt2014-06-121-1/+1
|
* malloc() result does not need a cast.deraadt2014-06-071-6/+6
| | | | ok miod
* Clean up some of the nightmare of string and pointer arithmatic inbeck2014-06-011-52/+36
| | | | | | | | | | | | | this nasty function. This gets rid of the nasty tmp variables used to hold temporary strings and the DECIMAL_SIZE hack. it gets rid of the rather pointless null checks for buf (since the original code dereferences it before checking). It also gets rid of the insane possibility this could return -1 when stuff is using the return values to compute lengths All the failure cases now return 0 and an empty string like the first error case in the original code. ok miod@ tedu@
* more: no need for null check before freederaadt2014-05-301-6/+3
| | | | ok tedu guenther
* Restore beck's rev 1.21: snprintf() was reviewedguenther2014-04-201-1/+1
|
* KNF.jsing2014-04-191-429/+429
|
* We'll interpret a (void) cast on snprintf() to mean it's been verified thatguenther2014-04-191-1/+1
| | | | | | truncation is either desirable, not an issue, or is detected and handled later ok deraadt@
* use intrinsic strlcpy and strlcat everywhere so we only have one set ofbeck2014-04-191-3/+3
| | | | | | funcitons to check for incorrect use. keep BUF_strlcpy and BUF_strlcat for API comptibility only. ok tedu@
* Shrink a local buffer to the size it really needs to be; this is the onlymiod2014-04-181-1/+1
| | | | | | discrepancy found while checking proper {HEX,DECIMAL}_SIZE macro usage, which is confusing enough. tweaks and ok jca@, ok guenther@
* Change library to use intrinsic memory allocation functions instead ofbeck2014-04-171-13/+13
| | | | | | | | OPENSSL_foo wrappers. This changes: OPENSSL_malloc->malloc OPENSSL_free->free OPENSSL_relloc->realloc OPENSSL_freeFunc->free
* Send the rotIBM stream cipher (ebcdic) to Valhalla to party for eternitybeck2014-04-151-16/+0
| | | | | with the bearded ones... some API's that nobody should be using will dissapear with this commit.
* Part 1 of eliminating BIO_snprintf(). This fixes mechanical conversionsbeck2014-04-151-1/+1
| | | | | where the return value is ignored changing to (void) snprintf. ok deraadt@
* Remove some stuff that isn't needed.beck2014-04-131-1/+1
| | | | ok miod@ deraadt@
* resolve conflicts, fix local changesdjm2010-10-011-78/+102
|
* resolve conflictsdjm2008-09-061-68/+186
|
* resolve conflictsdjm2005-04-291-5/+7
|
* merge 0.9.7dmarkus2004-04-081-2/+2
|
* merge 0.9.7b with local changes; crank majors for libssl/libcryptomarkus2003-05-121-4/+3
|
* Trivial sprintf() -> snprintf() changes. ok deraadt@ho2003-04-051-2/+2
|
* merge with openssl-0.9.7-stable-SNAP-20020911,markus2002-09-141-1/+1
| | | | | new minor for libcrypto (_X509_REQ_print_ex) tested by miod@, pb@
* apply patches from OpenSSL Security Advisory [30 July 2002],markus2002-07-301-1/+1
| | | | http://marc.theaimsgroup.com/?l=openssl-dev&m=102802395104110&w=2
* Merge OpenSSL 0.9.7-stable-20020605,beck2002-06-071-1/+1
| | | | correctly autogenerate obj_mac.h
* OpenSSL 0.9.7 stable 2002 05 08 mergebeck2002-05-151-18/+28
|
* openssl-engine-0.9.6 mergebeck2000-12-151-28/+36
|