Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2016-07-12Revert "Move C++ helpers into |bssl| namespace."Adam Langley
This reverts commit 09feb0f3d95a2bc58ce0faaf14256d3bd30f52a4. (In order to make WebRTC happy this also needs to be reverted.)
2016-07-12Revert scoped_types.h change.Adam Langley
This reverts commits: 8d79ed67407e433d80ebc8d3aa080e8ce16e6eb7 19fdcb523402ed13ab798cf811fb0119e3e7b104 8d79ed67407e433d80ebc8d3aa080e8ce16e6eb7 Because WebRTC (at least) includes our headers in an extern "C" block, which precludes having any C++ in them. Change-Id: Ia849f43795a40034cbd45b22ea680b51aab28b2d
2016-07-12Remove scoped_types.h.Adam Langley
This change scatters the contents of the two scoped_types.h files into the headers for each of the areas of the code. The types are now in the |bssl| namespace. Change-Id: I802b8de68fba4786b6a0ac1bacd11d81d5842423 Reviewed-on: https://boringssl-review.googlesource.com/8731 Reviewed-by: Adam Langley <agl@google.com>
2016-07-12Move C++ helpers into |bssl| namespace.Adam Langley
We currently have the situation where the |tool| and |bssl_shim| code includes scoped_types.h from crypto/test and ssl/test. That's weird and shouldn't happen. Also, our C++ consumers might quite like to have access to the scoped types. Thus this change moves some of the template code to base.h and puts it all in a |bssl| namespace to prepare for scattering these types into their respective headers. In order that all the existing test code be able to access these types, it's all moved into the same namespace. Change-Id: I3207e29474dc5fcc344ace43119df26dae04eabb Reviewed-on: https://boringssl-review.googlesource.com/8730 Reviewed-by: David Benjamin <davidben@google.com>
2016-06-27Add CBB_add_u32.David Benjamin
It was missing. Writing NewSessionTicket will need it. Change-Id: I39de237894f2e8356bd6861da2b8a4d805dcd2d6 Reviewed-on: https://boringssl-review.googlesource.com/8439 Reviewed-by: Adam Langley <agl@google.com>
2016-06-08Make tls_open_record always in-place.David Benjamin
The business with ssl_record_prefix_len is rather a hassle. Instead, have tls_open_record always decrypt in-place and give back a CBS to where the body is. This way the caller doesn't need to do an extra check all to avoid creating an invalid pointer and underflow in subtraction. Change-Id: I4e12b25a760870d8f8a503673ab00a2d774fc9ee Reviewed-on: https://boringssl-review.googlesource.com/8173 Reviewed-by: Steven Valdez <svaldez@google.com> Reviewed-by: David Benjamin <davidben@google.com>
2016-04-28Merge documentation from chromium's net/der into cbs.cNick Harper
Change-Id: Icfd959a168e3fce423b10dd0dcb1312ec03f0623 Reviewed-on: https://boringssl-review.googlesource.com/7800 Reviewed-by: David Benjamin <davidben@google.com>
2016-03-23Add CBS_ASN1_UTF8STRING define.Matt Mueller
Change-Id: I34384feb46c15c4f443f506d724ad500a4cf0f36 Reviewed-on: https://boringssl-review.googlesource.com/7525 Reviewed-by: David Benjamin <davidben@google.com>
2016-02-16Add a convenience function for i2d compatibility wrappers.David Benjamin
An i2d compatibility function is rather long, so add CBB_finish_i2d for part of it. It takes a CBB as input so only a 'marshal' function is needed, rather than a 'to_bytes' one. Also replace the *inp d2i update pattern with a slightly shorter one. Change-Id: Ibb41059c9532f6a8ce33460890cc1afe26adc97c Reviewed-on: https://boringssl-review.googlesource.com/6868 Reviewed-by: Adam Langley <agl@google.com>
2016-02-16Parse BER for PKCS#12 more accurately.David Benjamin
CBS_asn1_ber_to_der currently uses heuristics because implicitly-tagged constructed strings in BER are ambiguous with implicitly-tagged sequences. It's not possible to convert BER to DER without knowing the schema. Fortunately, implicitly tagged strings don't appear often so instead split the job up: CBS_asn1_ber_to_der fixes indefinite-length elements and constructed strings it can see. Implicitly-tagged strings it leaves uncoverted, but they will only nest one level down (because BER kindly allows one to nest constructed strings arbitrarily!). CBS_get_asn1_implicit_string then performs the final concatenation at parse time. This isn't much more complex and lets us parse BER more accurately and also reject a number of mis-encoded values (e.g. constructed INTEGERs are not a thing) we'd previously let through. The downside is the post-conversion parsing code must be aware of this limitation of CBS_asn1_ber_to_der. Fortunately, there's only one implicitly-tagged string in our PKCS#12 code. (In the category of things that really really don't matter, but I had spare cycles and the old BER converter is weird.) Change-Id: Iebdd13b08559fa158b308ef83a5bb07bfdf80ae8 Reviewed-on: https://boringssl-review.googlesource.com/7052 Reviewed-by: Adam Langley <agl@google.com>
2016-02-04Fix theoretical memory leak on malloc error in CBS_asn1_ber_to_der.David Benjamin
On failure, CBB_finish doesn't call CBB_cleanup. Also chain more of the ||s together now that CBB_cleanup after failed CBB_init is legal. (I don't think this is actually reachable because the CBB is guaranteed to be flushed by this point.) Change-Id: Ib16a0a185f15e13675ac2550c5e8e0926ceb7957 Reviewed-on: https://boringssl-review.googlesource.com/7051 Reviewed-by: Adam Langley <agl@google.com>
2015-12-22Rewrite ssl3_send_server_key_exchange to use CBB.David Benjamin
There is some messiness around saving and restoring the CBB, but this is still significantly clearer. Note that the BUF_MEM_grow line is gone in favor of a fixed CBB like the other functions ported thus far. This line was never necessary as init_buf is initialized to 16k and none of our key exchanges get that large. (The largest one can get is DHE_RSA. Even so, it'd take a roughly 30k-bit DH group with a 30k-bit RSA key.) Having such limits and tight assumptions on init_buf's initial size is poor (but on par for the old code which usually just blindly assumed the message would not get too large) and the size of the certificate chain is much less obviously bounded, so those BUF_MEM_grows can't easily go. My current plan is convert everything but those which legitimately need BUF_MEM_grow to CBB, then atomically convert the rest, remove init_buf, and switch everything to non-fixed CBBs. This will hopefully also simplify async resumption. In the meantime, having a story for resumption means the future atomic change is smaller and, more importantly, relieves some complexity budget in the ServerKeyExchange code for adding Curve25519. Change-Id: I1de6af9856caaed353453d92a502ba461a938fbd Reviewed-on: https://boringssl-review.googlesource.com/6770 Reviewed-by: Adam Langley <agl@google.com>
2015-12-22Add CBB_reserve and CBB_did_write.David Benjamin
These will be needed when we start writing variable-length things to a CBB. Change-Id: Ie7b9b140f5f875b43adedc8203ce9d3f4068dfea Reviewed-on: https://boringssl-review.googlesource.com/6764 Reviewed-by: Adam Langley <agl@google.com>
2015-12-17Make CBB_len relative to its argument.David Benjamin
Rather than the length of the top-level CBB, which is kind of odd when ASN.1 length prefixes are not yet determined, return the number of bytes written to the CBB so far. This can be computed without increasing the size of CBB at all. Have offset and pending_*. This means functions which take in a CBB as argument will not be sensitive to whether the CBB is a top-level or child CBB. The extensions logic had to be careful to only ever compare differences of lengths, which was awkward. The reversal will also allow for the following pattern in the future, once CBB_add_space is split into, say, CBB_reserve and CBB_did_write and we add a CBB_data: uint8_t *signature; size_t signature_len = 0; if (!CBB_add_asn1(out, &cert, CBB_ASN1_SEQUENCE) || /* Emit the TBSCertificate. */ !CBB_add_asn1(&cert, &tbs_cert, CBS_ASN1_SEQUENCE) || !CBB_add_tbs_cert_stuff(&tbs_cert, stuff) || !CBB_flush(&cert) || /* Feed it into md_ctx. */ !EVP_DigestSignInit(&md_ctx, NULL, EVP_sha256(), NULL, pkey) || !EVP_DigestSignUpdate(&md_ctx, CBB_data(&cert), CBB_len(&cert)) || /* Emit the signature algorithm. */ !CBB_add_asn1(&cert, &sig_alg, CBS_ASN1_SEQUENCE) || !CBB_add_sigalg_stuff(&sig_alg, other_stuff) || /* Emit the signature. */ !EVP_DigestSignFinal(&md_ctx, NULL, &signature_len) || !CBB_reserve(&cert, &signature, signature_len) || !EVP_DigestSignFinal(&md_ctx, signature, &signature_len) || !CBB_did_write(&cert, signature_len)) { goto err; } (Were TBSCertificate not the first field, we'd still have to sample CBB_len(&cert), but at least that's reasonable straight-forward. The alternative would be if CBB_data and CBB_len somehow worked on recently-invalidated CBBs, but that would go wrong once the invalidated CBB's parent flushed and possibly shifts everything.) And similar for signing ServerKeyExchange. Change-Id: I7761e492ae472d7632875b5666b6088970261b14 Reviewed-on: https://boringssl-review.googlesource.com/6681 Reviewed-by: Adam Langley <agl@google.com>
2015-11-17Use UINT64_C instead of OPENSSL_U64.David Benjamin
stdint.h already has macros for this. The spec says that, in C++, __STDC_CONSTANT_MACROS is needed, so define it for bytestring_test.cc. Chromium seems to use these macros without trouble, so I'm assuming we can rely on them. Change-Id: I56d178689b44d22c6379911bbb93d3b01dd832a3 Reviewed-on: https://boringssl-review.googlesource.com/6510 Reviewed-by: Adam Langley <agl@google.com>
2015-11-17Drop CBB allocation failure test.Adam Langley
To no great surprise, ASAN didn't like this test and I suspect that Chromium, with its crashing allocator, won't like it either. Oh well. Change-Id: I235dbb965dbba186f8f37d7df45f8eac9addc7eb Reviewed-on: https://boringssl-review.googlesource.com/6496 Reviewed-by: Adam Langley <agl@google.com>
2015-11-17Have |CBB_init| zero the |CBB| before any possible failures.Adam Langley
People expect to do: CBB foo; if (!CBB_init(&foo, 100) || … …) { CBB_cleanup(&foo); return 0; } However, currently, if the allocation of |initial_capacity| fails in |CBB_init| then |CBB_cleanup| will operate on uninitialised values. This change makes the above pattern safe. Change-Id: I3e002fda8f0a3ac18650b504e7e84a842d4165ca Reviewed-on: https://boringssl-review.googlesource.com/6495 Reviewed-by: David Benjamin <davidben@chromium.org> Reviewed-by: Adam Langley <agl@google.com>
2015-11-12Remove stl_compat.h.David Benjamin
Chromium's toolchains may now assume C++11 library support, so we may freely use C++11 features. (Chromium's still in the process of deciding what to allow, but we use Google's style guide directly, toolchain limitations aside.) Change-Id: I1c7feb92b7f5f51d9091a4c686649fb574ac138d Reviewed-on: https://boringssl-review.googlesource.com/6465 Reviewed-by: Adam Langley <agl@google.com>
2015-11-04Correct the spelling of "primitive".Matt Braithwaite
Spotted by Matt Smart. Change-Id: Id9c61ba6a293ddc52b2e2c93c427860765848c6d Reviewed-on: https://boringssl-review.googlesource.com/6430 Reviewed-by: Adam Langley <agl@google.com>
2015-10-26Add a run_tests target to run all tests.David Benjamin
It's very annoying having to remember the right incant every time I want to switch around between my build, build-release, build-asan, etc., output directories. Unfortunately, this target is pretty unfriendly without CMake 3.2+ (and Ninja 1.5+). This combination gives a USES_TERMINAL flag to add_custom_target which uses Ninja's "console" pool, otherwise the output buffering gets in the way. Ubuntu LTS is still on an older CMake, so do a version check in the meantime. CMake also has its own test mechanism (CTest), but this doesn't use it. It seems to prefer knowing what all the tests are and then tries to do its own output management and parallelizing and such. We already have our own runners. all_tests.go could actually be converted tidily, but generate_build_files.py also needs to read it, and runner.go has very specific needs. Naming the target ninja -C build test would be nice, but CTest squats that name and CMake grumps when you use a reserved name, so I've gone with run_tests. Change-Id: Ibd20ebd50febe1b4e91bb19921f3bbbd9fbcf66c Reviewed-on: https://boringssl-review.googlesource.com/6270 Reviewed-by: Adam Langley <alangley@gmail.com>
2015-10-20Convert ssl3_send_client_hello to CBB.David Benjamin
Start converting the ones we can right now. Some of the messier ones resize init_buf rather than assume the initial size is sufficient, so those will probably wait until init_buf is gone and the handshake's undergone some more invasive surgery. The async ones will also require some thought. But some can be incrementally converted now. BUG=468889 Change-Id: I0bc22e4dca37d9d671a488c42eba864c51933638 Reviewed-on: https://boringssl-review.googlesource.com/6190 Reviewed-by: Adam Langley <alangley@gmail.com>
2015-09-29Clarify that only top-level CBBs get CBB_cleanup.David Benjamin
Also add an assert to that effect. Change-Id: I1bd0571e3889f1cba968fd99041121ac42ee9e89 Reviewed-on: https://boringssl-review.googlesource.com/5990 Reviewed-by: Adam Langley <agl@google.com>
2015-09-03Allow out_present to be NULL in CBS_get_optional_asn1Paul Lietar
This is useful to skip an optional element, and mirrors the behaviour of CBS_get_optional_asn1_octet_string. Change-Id: Icb538c5e99a1d4e46412cae3c438184a94fab339 Reviewed-on: https://boringssl-review.googlesource.com/5800 Reviewed-by: Adam Langley <agl@google.com>
2015-08-29Factor out the buffering and low-level record code.David Benjamin
This begins decoupling the transport from the SSL state machine. The buffering logic is hidden behind an opaque API. Fields like ssl->packet and ssl->packet_length are gone. ssl3_get_record and dtls1_get_record now call low-level tls_open_record and dtls_open_record functions that unpack a single record independent of who owns the buffer. Both may be called in-place. This removes ssl->rstate which was redundant with the buffer length. Future work will push the buffer up the stack until it is above the handshake. Then we can expose SSL_open and SSL_seal APIs which act like *_open_record but return a slightly larger enum due to other events being possible. Likewise the handshake state machine will be detached from its buffer. The existing SSL_read, SSL_write, etc., APIs will be implemented on top of SSL_open, etc., combined with ssl_read_buffer_* and ssl_write_buffer_*. (Which is why ssl_read_buffer_extend still tries to abstract between TLS's and DTLS's fairly different needs.) The new buffering logic does not support read-ahead (removed previously) since it lacks a memmove on ssl_read_buffer_discard for TLS, but this could be added if desired. The old buffering logic wasn't quite right anyway; it tried to avoid the memmove in some cases and could get stuck too far into the buffer and not accept records. (The only time the memmove is optional is in DTLS or if enough of the record header is available to know that the entire next record would fit in the buffer.) The new logic also now actually decrypts the ciphertext in-place again, rather than almost in-place when there's an explicit nonce/IV. (That accidentally switched in https://boringssl-review.googlesource.com/#/c/4792/; see 3d59e04bce96474099ba76786a2337e99ae14505.) BUG=468889 Change-Id: I403c1626253c46897f47c7ae93aeab1064b767b2 Reviewed-on: https://boringssl-review.googlesource.com/5715 Reviewed-by: Adam Langley <agl@google.com>
2015-08-26Move arm_arch.h and fix up lots of include paths.Adam Langley
arm_arch.h is included from ARM asm files, but lives in crypto/, not openssl/include/. Since the asm files are often built from a different location than their position in the source tree, relative include paths are unlikely to work so, rather than having crypto/ be a de-facto, second global include path, this change moves arm_arch.h to include/openssl/. It also removes entries from many include paths because they should be needed as relative includes are always based on the locations of the source file. Change-Id: I638ff43d641ca043a4fc06c0d901b11c6ff73542 Reviewed-on: https://boringssl-review.googlesource.com/5746 Reviewed-by: Adam Langley <agl@google.com>
2015-07-09Make CBB_len return a length, not remaining.David Benjamin
It switched from CBB_remaining to CBB_len partway through review, but the semantics are still CBB_remaining. Using CBB_len allows the len_before/len_after logic to continue working even if, in the future, handshake messages are built on a non-fixed CBB. Change-Id: Id466bb341a14dbbafcdb26e4c940a04181f2787d Reviewed-on: https://boringssl-review.googlesource.com/5371 Reviewed-by: Adam Langley <agl@google.com>
2015-07-01Add CBB_zero to set a CBB to the zero state.David Benjamin
One tedious thing about using CBB is that you can't safely CBB_cleanup until CBB_init is successful, which breaks the general 'goto err' style of cleanup. This makes it possible: CBB_zero ~ EVP_MD_CTX_init CBB_init ~ EVP_DigestInit CBB_cleanup ~ EVP_MD_CTX_cleanup Change-Id: I085ecc4405715368886dc4de02285a47e7fc4c52 Reviewed-on: https://boringssl-review.googlesource.com/5267 Reviewed-by: Adam Langley <agl@google.com>
2015-07-01Fix crypto/bytestring test for too long lengths.David Benjamin
kData5 was meant to test lengths that are too long, but the input gets rejected earlier for not using short-form encoding. Switch it to testing a badly encoded element of length 128, the shortest element that uses long-form encoding. Change-Id: I35f4df89bfa7a681698eda569c525b5871288487 Reviewed-on: https://boringssl-review.googlesource.com/5264 Reviewed-by: Adam Langley <agl@google.com>
2015-07-01Add infrastructure for better extension handling.Adam Langley
Rather than four massive functions that handle every extension, organise the code by extension with four smaller functions for each. Change-Id: I876b31dacb05aca9884ed3ae7c48462e6ffe3b49 Reviewed-on: https://boringssl-review.googlesource.com/5142 Reviewed-by: Adam Langley <agl@google.com>
2015-06-06Export |CBS_get_any_ber_asn1_element|.Adam Langley
We have need of it internally. Change-Id: I564af468728b22245e8eab384ea7018b7e88cc86 Reviewed-on: https://boringssl-review.googlesource.com/5022 Reviewed-by: Matt Braithwaite <mab@google.com> Reviewed-by: Adam Langley <agl@google.com>
2015-06-04Make CBS_get_any_asn1_element accept only DER.Adam Langley
This change makes |CBS_get_any_asn1_element| only handle DER elements. Another function, |CBS_get_any_ber_asn1_element| is exposed internally for the cases where we need to process BER data. Change-Id: I544141a1a3d7913986352a8fd9a6d00b9f282652 Reviewed-on: https://boringssl-review.googlesource.com/4994 Reviewed-by: Adam Langley <agl@google.com>
2015-06-04bytestring: Test out_header_len != NULL before writing.Adam Langley
The documentation for |CBS_get_any_asn1_element| says that |out_header_len| may be NULL, but in the case of an indefinite-length element it would be written unconditionally. Thanks to Doug Hogan for noticing this. Change-Id: I17609b3465df73d42dd9efd75e783159aa99a59b Reviewed-on: https://boringssl-review.googlesource.com/4993 Reviewed-by: Adam Langley <agl@google.com>
2015-05-21Fix some malloc test crashs.David Benjamin
This isn't exhaustive. There are still failures in some tests which probably ought to get C++'d first. Change-Id: Iac58df9d98cdfd94603d54374a531b2559df64c3 Reviewed-on: https://boringssl-review.googlesource.com/4795 Reviewed-by: Adam Langley <agl@google.com>
2015-05-21Add malloc test support to unit tests.David Benjamin
Currently far from passing and I haven't even tried with a leak checker yet. Also bn_test is slow. Change-Id: I4fe2783aa5f7897839ca846062ae7e4a367d2469 Reviewed-on: https://boringssl-review.googlesource.com/4794 Reviewed-by: Adam Langley <agl@google.com>
2015-05-05Remove unnecessary NULL checks, part 1.David Benjamin
First batch of the alphabet. Change-Id: If4e60f4fbb69e04eb4b70aa1b2240e329251bfa5 Reviewed-on: https://boringssl-review.googlesource.com/4514 Reviewed-by: Adam Langley <agl@google.com>
2015-04-06Check for leading zeros in CBS_get_asn1_uint64.David Benjamin
The encoding of an INTEGER should not have leading zeros, except to pad for the sign bit. Change-Id: I80d22818cf1d2ca9d27e215620392e1725372aa5 Reviewed-on: https://boringssl-review.googlesource.com/4218 Reviewed-by: Adam Langley <agl@google.com>
2015-04-01Convert bytestring_test to C++.David Benjamin
Change-Id: Id3e6183da3ae328b562ec5413151256cf6071ffc Reviewed-on: https://boringssl-review.googlesource.com/4140 Reviewed-by: Adam Langley <agl@google.com>
2015-02-11Add in missing curly braces part 1.David Benjamin
Everything before crypto/ec. Change-Id: Icbfab8e4ffe5cc56bf465eb57d3fdad3959a085c Reviewed-on: https://boringssl-review.googlesource.com/3401 Reviewed-by: Adam Langley <agl@google.com>
2015-02-03Don't accept tag number 31 (long form identifier octets) in CBB_add_asn1.Doug Hogan
Tag number 31 is a long form tag that requires multiple octets. It cannot be handled by adding a single uint8. Changed CBB_add_asn1() to return 0 when it is passed in the extension for tag 31. Change-Id: Ia33936d4f174d1a7176eb11da0b5c7370efb9416
2015-02-03Move free from cbb_init() to only CBB_init().Doug Hogan
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. In the current code, ssl3_get_v2_client_hello() may free s->init_buf->data via CBB_init_fixed(). It can also be freed via SSL_free(s) since ssl3_get_v2_client_hello() doesn't set it to NULL and CBB_init_fixed() can't set the caller's pointer to NULL. Change-Id: Ia05a67ae25af7eb4fb04f08f20d50d912b41e38b
2015-02-02Remove string.h from base.h.Adam Langley
Including string.h in base.h causes any file that includes a BoringSSL header to include string.h. Generally this wouldn't be a problem, although string.h might slow down the compile if it wasn't otherwise needed. However, it also causes problems for ipsec-tools in Android because OpenSSL didn't have this behaviour. This change removes string.h from base.h and, instead, adds it to each .c file that requires it. Change-Id: I5968e50b0e230fd3adf9b72dd2836e6f52d6fb37 Reviewed-on: https://boringssl-review.googlesource.com/3200 Reviewed-by: David Benjamin <davidben@chromium.org> Reviewed-by: Adam Langley <agl@google.com>
2015-01-29Change CMakeLists.txt to two-space indent.Adam Langley
find -name CMakeLists.txt -type f | xargs sed -e 's/\t/ /g' -i Change-Id: I01636b1849c00ba918f48828252492d99b0403ac
2014-12-10Remove variable shadowing.Adam Langley
Bruce Dawson pointed out that the shadowing of |ret| in |s3_srvr.c| looked dodgy. It was actually deliberate (we don't want to reset the default value of the function's |ret| variable with a successful return from the callback) but it does look dodgy. This change adds -Wshadow to ban variable shadowing and fixes all current instances. Change-Id: I1268f88b9f26245c7d16d6ead5bb9014ea471c01 Reviewed-on: https://boringssl-review.googlesource.com/2520 Reviewed-by: Adam Langley <agl@google.com>
2014-10-25Fix "integer constant is too large for 'long' type" errors.Piotr Sikora
Change-Id: I018cdc805e19284b057a57d04c9665f0a35ccc3b Signed-off-by: Piotr Sikora <piotr@cloudflare.com> Reviewed-on: https://boringssl-review.googlesource.com/2040 Reviewed-by: Adam Langley <agl@google.com>
2014-10-25Extended master secret support.Adam Langley
This change implements support for the extended master secret. See https://tools.ietf.org/html/draft-ietf-tls-session-hash-01 https://secure-resumption.com/ Change-Id: Ifc7327763149ab0894b4f1d48cdc35e0f1093b93 Reviewed-on: https://boringssl-review.googlesource.com/1930 Reviewed-by: David Benjamin <davidben@chromium.org> Reviewed-by: Adam Langley <agl@google.com>
2014-10-24Reimplement d2i_SSL_SESSION with CBS.David Benjamin
Do away with all those unreadable macros. Also fix many many memory leaks in the SSL_SESSION reuse case. Add a number of helper functions in CBS to help with parsing optional fields. Change-Id: I2ce8fd0d5b060a1b56e7f99f7780997fabc5ce41 Reviewed-on: https://boringssl-review.googlesource.com/1998 Reviewed-by: Adam Langley <agl@google.com>
2014-10-24The empty contents are not a valid ASN.1 INTEGER.David Benjamin
Zero is encoded as a single zero octet. Per X.690, 8.3.1: The encoding of an integer value shall be primitive. The contents octets shall consist of one or more octets. Change-Id: If4304a2be5117b71446a3a62a2b8a6124f85a202 Reviewed-on: https://boringssl-review.googlesource.com/2010 Reviewed-by: Adam Langley <agl@google.com>
2014-10-24Add CBB_add_asn1_uint64.David Benjamin
Companion to CBS_get_asn1_uint64. Also add tests for both the parsing and the serializing. Change-Id: Ic5e9a0089c88b300f874712d0e9964cb35a8c40b Reviewed-on: https://boringssl-review.googlesource.com/1999 Reviewed-by: Adam Langley <agl@google.com>
2014-10-20Add CBS_peek_asn1_tag.David Benjamin
Intended to make parsing ASN.1 structures with OPTIONAL elements easier. (Just attempting to parse the next tag doesn't distinguish between a malformed CBS which has now been partially advanced and an optional tag mismatch.) Change-Id: Idceb3dfd6ec028e87e1bc5aaddcec177b0c32150 Reviewed-on: https://boringssl-review.googlesource.com/1995 Reviewed-by: Adam Langley <agl@google.com>
2014-09-12Add a CRYPTO_library_init and static-initializer-less build option.David Benjamin
Chromium does not like static initializers, and the CPU logic uses one to initialize CPU bits. However, the crypto library lacks an explicit initialization function, which could complicate (no compile-time errors) porting existing code which uses crypto/, but not ssl/. Add an explicit CRYPTO_library_init function, but make it a no-op by default. It only does anything (and is required) if building with BORINGSSL_NO_STATIC_INITIALIZER. Change-Id: I6933bdc3447fb382b1f87c788e5b8142d6f3fe39 Reviewed-on: https://boringssl-review.googlesource.com/1770 Reviewed-by: Adam Langley <agl@google.com>