summaryrefslogtreecommitdiff
path: root/src/lib/libssl/bs_cbb.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Ensure that CBB_add_space() always provides zeroed memory.jsing2020-03-131-1/+2
| | | | ok tb@
* Use calloc() rather than malloc() when allocating initial CBB buffer.jsing2020-03-121-4/+3
| | | | | | | | | | CBB uses recallocarray() to expand buffers, however was still using malloc() for the initial buffer, which could result in memory being leaked in incorrect use cases. While here also use calloc() to allocate internal structs. ok inoguchi@ tb@
* assert.h is often misused. It should not be used in a librarybeck2019-01-231-3/+3
| | | | ok bcook@ jsing@
* Provide CBB_add_u32(), as needed for an upcoming conversion.jsing2018-08-161-1/+10
| | | | ok tb@
* Add CBB_discard_child(), which allows for a child CBB to be discarded.jsing2017-11-281-1/+15
| | | | Based on BoringSSL.
* Clear the child pointer in CBB_cleanup(), so that we have fewer pointersjsing2017-08-121-1/+2
| | | | | | hanging around to potentially invalid address space. Discussed with beck@ and doug@
* Instead of starting a 'zero-sized' CBB at the size of the first additionjsing2017-05-071-5/+8
| | | | | | | | to the CBB, then doubling, start with an initial size of 64 bytes. Almost all uses will exceed this size and we avoid multiple small recallocarray() calls during the initial usage. ok beck@
* Use freezero(3) in the CBB clean up path, since this could hold sensitivejsing2017-04-141-3/+2
| | | | information (such as master keys).
* Switch CBB to use recallocarray() - this ensures that we do not leakjsing2017-03-101-2/+2
| | | | | | secrets via realloc(). ok inoguchi@
* Make it always safe to call CBB_cleanup() providing that CBB_init() orjsing2015-09-011-2/+8
| | | | | | CBB_init_fixed() have been attempted. ok doug@
* Extend the input types for CBB_add_*() to help catch bugs.doug2015-06-181-8/+20
| | | | | | | | | While the previous types were correct, they can silently accept bad data via truncation or signed conversion. We now take size_t as input for CBB_add_u*() and do a range check. discussed with deraadt@ input + ok jsing@ miod@
* Split up the logic in CBB_flush to separately handle the lengths.doug2015-06-131-21/+32
| | | | | | Also, add comments about assuming short-form. ok miod@, tweak + ok jsing@
* Explain the ASN.1 restriction that requires extra logic for encoding.doug2015-06-131-2/+18
| | | | ok miod@ jsing@
* When initial capacity is 0, always use NULL buffer.doug2015-06-131-7/+8
| | | | | | | malloc(0) is implementation defined and there's no reason to introduce that ambiguity here. Added a few cosmetic changes in sizeof and free. ok miod@ jsing@
* Call CBB_add_space() rather than reimplementing it.doug2015-04-291-2/+2
| | | | ok jsing@
* Rename cbb_buffer_add_u to cbb_add_u and remove redundant code.doug2015-04-291-15/+6
| | | | | | | All of cbb_buffer_add_u's callers first call CBB_flush and send cbb->base. cbb_add_u() now has that common code in one place. ok jsing@
* Added len_len error checking for internal cbb_buffer_add_u().doug2015-04-291-1/+4
| | | | ok jsing@
* Don't allow tag number 31 in CBB_add_asn1().doug2015-02-071-10/+23
| | | | | | | | | Tag 31 is invalid for a short form identifier octet (single byte). KNF a little more. Based on BoringSSL commit 5ba305643f55d37a3e45e8388a36d50c1b2d4ff5 ok miod@
* Only call free in CBB_init().doug2015-02-071-3/+6
| | | | | | | | | | | CBB_init_fixed() should not call free because it can lead to use after free or double free bugs. The caller should be responsible for creating and destroying the buffer. From BoringSSL commit a84f06fc1eee6ea25ce040675fbad72c532afece miod agrees with the reasoning ok jsing@, beck@
* KNF bytestring files.doug2015-02-061-301/+310
| | | | | | | | I checked that this doesn't change anything. Compiled with clang using -Wno-pointer-sign -g0 to reduce the differences. Only difference in the asm is due to assert(0) line number changes in bs_cbs.c and bs_cbb.c. miod is ok with the general process.
* Remove accidental, commented out code.doug2015-02-061-11/+1
| | | | This was to test a patch for upstream.
* Import BoringSSL's crypto bytestring and crypto bytebuilder APIs.doug2015-02-061-0/+387
This is imported with as few changes as possible for the initial commit. I removed OPENSSL_EXPORT, replaced OPENSSL_malloc() etc with malloc() and changed a few header includes. BoringSSL has this as part of their public API. We're leaving it internal to libssl for now. Based on BoringSSL's CBB/CBS API as of commit c5cc15b4f5b1d6e9b9112cb8d30205a638aa2c54. input + ok jsing@, miod@