3119 Commits
Author SHA1 Message Date
David Benjamin 92ae3b9b6e Update citations from RFC 3447 to RFC 8017
Change-Id: Ie3ab169e5bde403382eb0edbe9e774aba2a23692
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/81659
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2025-08-28 12:24:07 -07:00
David Benjamin 815fec1839 Replace OPENSSL_ARRAY_SIZE with std::size
In the STL, <iterator> has a std::size for arrays. Some of these could
also just be ranged for loops. One static_assert could not use
std::size(out->whatever) because out was not a compile-time value, but
std::extent_v<decltype(out->whatever)> works instead.

Change-Id: I28007c79f5583e09167b81a34a447e205ee6dd9b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/81658
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2025-08-28 12:22:59 -07:00
David Benjamin b0e18ff06e Switch libssl to the new SPKI parsing APIs
Bug: 42290364
Change-Id: I91bc1950e5759c5267131fc0bc301104aeca7d7b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/81654
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2025-08-28 10:12:43 -07:00
David Benjamin 7091d0949c Add an ERR_equals function
Checking for an error on the error queue is very tedious. You have to
check both library and reason code separately, which often means you
need to save the error code to a local variable.

Make an ERR_equals function. I've gone ahead and just made it public API
because even within BoringSSL, it seems to come up everywhere.

Change-Id: Ia963c9ae743ac5c6939846f8f64bbc98b495ce0b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/81627
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
2025-08-25 16:00:23 -07:00
David Benjamin 908bdb84c5 Test async BIO_flush and fix a corner case
We were simulating non-blocking writes, but not non-blocking flush.
Model it as consuming one byte in AsyncBio.

In doing so, fix an obscure corner case in DTLS: If flushing after ACK
blocked, the next try would write a new ACK to the transport. There's no
real harm in this (we're running over UDP), but our tests intentionally
check for exactly the right number of writes and this was easy to fix.

This completely doesn't matter as a non-blocking writes on UDP-like
sockets are not really a thing, much less buffered non-blocking writes
on them. I don't even concretely know of anyone relying on BIO_flush in
TCP-like BIOs anymore in libssl. But since we try to support it, we
should test that we get it right.

Fixed: 381906252
Change-Id: I5296fcb01ca409d3026ca1150d6bdeaccc868014
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/81348
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Lily Chen <chlily@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2025-08-19 11:13:18 -07:00
David Benjamin cd033d7e12 runner: Remove need for an AllCurves value
Among other things, this shortcut meant that every curve test explicitly
configures every other curve, but only the curve under test needs to be
configured.

Change-Id: If21dcd997c78c6a02dab30aa16259c60ea7f479b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/81347
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Lily Chen <chlily@google.com>
Commit-Queue: Lily Chen <chlily@google.com>
2025-08-18 13:00:05 -07:00
David Benjamin a352ae6bae Unexport the Kyber implementation
Kyber was the prestandard version of ML-KEM. Callers should be using
ML-KEM now. For now, keep the implementation behind an internal header
for libssl, but we expect to remove that soon too.

Update-Note: <openssl/experimental/kyber.h> is gone. Use
<openssl/mlkem.h> instead.

Bug: 438787615
Change-Id: I02919e5d627dcbe863e70e433c79e360a556d462
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/81287
Reviewed-by: Lily Chen <chlily@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2025-08-18 09:23:13 -07:00
Lily Chen d89a16e005 Implement MLKEM1024 for TLS
This adds the codepoint for ML-KEM-1024 from draft-ietf-tls-mlkem-04.

Change-Id: I897e50c6de7f00feaf0a9f8727d934fd0f8796cb
Bug: b:437414532
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/81187
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Lily Chen <chlily@google.com>
2025-08-12 11:40:59 -07:00
David Benjamin ad395cbf35 Fix some more IWYU issues
Change-Id: Icdb1f71bff0f6f3ce55cbe126958b21076d8691c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/80407
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2025-07-10 14:00:51 -07:00
Adam Langley e21d41adeb Add sha2.h
Historically, sha.h included both SHA-1 and SHA-2 functions. But SHA-1
functions mostly shouldn't be used now, and it's useful to be able to
audit at the level of header names in some contexts.

Therefore move SHA-2 things into a new sha2.h. In order not to break
everything, sha.h now includes sha2.h so no changes are needed in
existing callers.

Change-Id: I68d5e991f58a1c74ca377ba017caaff356acc870
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/80327
Commit-Queue: David Benjamin <davidben@google.com>
Auto-Submit: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2025-07-09 12:17:15 -07:00
David Benjamin 6aefe37a96 Test that libssl rejects id-RSASSA-PSS certificates
We should never mix them up with a context that expects
id-rsaEncryption. Right now it fails because we can't parse the
certificate. Later it will fail at a slightly different point.

Bug: 384818542
Change-Id: I64dc99a0099f6423ffa2686bede369b14b7544b9
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/80268
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2025-07-07 14:38:15 -07:00
David Benjamin 193edd58a5 runner: write a new test certificate library
This is a test certificate library that is slightly more convenient to
build certificate chains. More importantly, it reimplements the
crypto/x509 serializer with x/crypto/cryptobyte.

This is a fair amount of work, but means we can add new key types that
Go does not support, notably RSA-PSS keys. This is to ensure that later
work to add RSA-PSS keys to libcrypto (but *not* libssl) will not
regress libssl. (All this work to test that we *don't* support something
in libssl.)

Bug: 384818542
Change-Id: I54cd264cf9e774fc38d8f8780becb61f886466a3
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/80267
Reviewed-by: Adam Langley <agl@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2025-07-07 14:38:08 -07:00
David Benjamin 791b390017 Add EVP_PKEY_get_ec_curve_nid and EVP_PKEY_get_ec_point_conv_form
EVP_PKEY_get_ec_point_conv_form comes from OpenSSL 3.x.
EVP_PKEY_get_ec_curve_nid is new because OpenSSL 3.x instead has a
string-based API.

Still a ways to go, but let's start making EVP_PKEYs more useful, so
folks don't have to dip into a parallel universe of "low-level" APIs
as much.

Bug: 42290405
Change-Id: Ide3fad08194d833a3f011116fcfb0365540e4fad
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/80009
Commit-Queue: Adam Langley <agl@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2025-06-30 15:51:02 -07:00
David Benjamin 535cc39191 runner: Remove Leaf field from Credential
This field is unused and already wasn't filled in with
garbageCertificate. Removing it also makes it more obvious that runner
does not actually care if it can parse its own certificate.

Change-Id: I788a6f6fe8784579d03c1c4023728b5ca77c3f88
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/79911
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
2025-06-24 14:36:49 -07:00
David Benjamin aef63864e8 runner: silence some confusing errors when tests fail
When runner fails a test at the first connection, but the shim tries to
make a second connection before it is killed, the dispatcher doesn't
recognize the shim ID and we get a confusing message:

> Error dispatching connection: shim ID 55 not found

Fix this by remembering closed shim IDs and silently rejecting them.

Change-Id: Ic8afdd853da2ab3c9ef6d7102a5a0a7d52f905df
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/79808
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2025-06-20 10:19:53 -07:00
David Benjamin e2766abdee Test server_name acknowledgement
We have APIs to control whether we do or don't send it, and logic to
(per RFC 6066) not send it on resumption. Test all of these.

Go folks requested this as part of
https://github.com/golang/go/issues/74282, but it makes sense to test
for BoringSSL too.

Change-Id: Iaf8df4bcff87c75d63c9cbf536b0b97888731525
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/79807
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2025-06-20 10:09:20 -07:00
David Benjamin 4d937ae3df Add constants for special PSS salt length values
Align with OpenSSL for the names of the constants. -1 and -2 are too
confusing.

Change-Id: Ibd82361e81fe58f4a1006fc9f4c605c59b66ab12
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/79727
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
2025-06-17 09:25:21 -07:00
David Benjamin 60d933e9d6 Add a stub implementation of SSL_CTX_get_security_level
This function is not meaningful in BoringSSL. OpenSSL has an arbitrary
mapping from algorithms to "security levels" and offers an API to filter
TLS configuration by those levels. In OpenSSL, this function does not
return how secure |ctx| is, just what security level the caller
previously configured. As BoringSSL does not implement this API, we
return zero to report that the security levels mechanism is not used.

It is bizarre to implement a function getter without the corresponding
setter, but Python apparently wants this.

Change-Id: I0b40c9bbb2504a7a8ded28db33ece4b8535c1e7c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/79687
Commit-Queue: Adam Langley <agl@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2025-06-05 10:33:20 -07:00
David Benjamin 035e720641 Don't pass parent or ad to CRYPTO_EX_free
We used to pass the parent object to callbacks, but this isn't safe. The
object is in the middle of being destroyed, so the object's
invariants won't hold. We can't remove the parameters, but pass in NULL
instead.

This also has the side effect of making it possible to manage
CRYPTO_EX_DATA lifetime in its destructor, because we won't need to find
some handle back to the parent object. It also means that defensively
clearing fields in BIO destroy callbacks, while harmless, is more
obviously unnecessary.

Update-Note: CRYPTO_EX_free is no longer passed the parent object. We do
not expect any callers to be impacted. Callers that were impacted
probably had some object lifetime bug already.

Fixed: 412707574
Change-Id: Idda889898a9eca3b59e3200ba1d5b4f2e62f2d37
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/79607
Reviewed-by: Adam Langley <agl@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2025-06-02 13:27:41 -07:00
David Benjamin f84e4e8c6a Remove unused bputs hook
Bug: 412269080
Change-Id: Iab4951efc53005d9aa5e02067da65561bcffcf1c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/79568
Reviewed-by: Adam Langley <agl@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2025-05-27 13:00:47 -07:00
David Benjamin 8edfd1b30c Make BIO and BIO_METHOD opaque
This does not switch our internal BIOs to the public APIs yet. The
tricky aspects are:

- We need a CRYPTO_once to fill in the BIO_METHOD, which is a little
  tedious without __cxa_guard_acquire.

- bio->num is not exposed. External BIOs are expected to just make their
  BIO_get_data structure more involved.

Update-Note: Callers should switch to public APIs.

Bug: 412269080
Change-Id: I09a2f61c653cf7a48412d9088e437b2bbbea3bb2
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/79567
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2025-05-27 13:00:42 -07:00
David Benjamin 1cca127557 Remove P-224 from TLS
P-224 is too small to meet our security requirements. It seems that
nothing is using this anymore, so remove it to avoid folks accidentally
turning it on when they don't mean to.

Update-Note: Attempting to configure P-224 in TLS will now fail. This
does not impact P-224 as a general cryptographic primitive. Note that
this was off by default, so unless your project was explicitly enabling
this, this will not impact you.

Change-Id: I7b931ef0f37e3fac87848a37c5173892442e4f4f
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/79427
Reviewed-by: Adam Langley <agl@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2025-05-19 13:54:53 -07:00
David Benjamin 45cab558a8 Send only usable trust anchor IDs in EncryptedExtensions
CL originally by Bob Beck.

We did not filter this list to things that would be usable in the
handshake. This allows the client to not bother retrying with a
credential that wouldn't be usable anyway.

Fixed: 402692373
Change-Id: I78850ada5014bfd18235cfe5463fa2973da91a30
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/79188
Reviewed-by: Adam Langley <agl@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2025-05-08 20:20:22 -07:00
David Benjamin 52ef94f532 Clean up ssl_file.cc
- Use scopers

- BIO_new + BIO_read_filename can be replaced with BIO_new_file (note
  BIO_read_filename is "rb", not "r", on Windows)

- SSL_CTX_use_certificate_chain_file is more straightforward if we use
  SSL_CTX_add1_chain_cert. add0 doesn't even save a refcount bump
  because we internally transform it into a CRYPTO_BUFFER anyway.

Bug: 394340436
Change-Id: I586214b6547d5d85e589242eb218d296223778c9
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/79010
Commit-Queue: David Benjamin <davidben@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2025-05-02 10:01:24 -07:00
David Benjamin 35e07a80d8 Remove some dead code from SSL_CTX_use_certificate_chain_file
SSL_CTX_use_certificate_chain_file has some extra logic where, if
SSL_CTX_use_certificate succeeds but leaves an error in the error queue,
it fails anyway.

The comment claims it's because, on cert/key mismatch, it succeeds and
leaves an error. When the function was added in upstream's
b3ca645f479b1f0bcfa1d1a65c955e8b7ff33de6, this appears to have been
true.

However, years later upstream's 6049399bafac74bd809ffac2108e8d5d284cd720
added an ERR_clear_error and made SSL_CTX_use_certificate behave more
consistently. Now the behavior is that installing a certificate silently
clears any pre-existing mismatched keys, so this case no longer exists.
The recently-added tests also demonstrate this behavior.

Change-Id: I4c7de44046f10bc653f8f1fd86aff0d6956b2b1a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/79009
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2025-05-02 10:01:22 -07:00
David Benjamin bc70ca75b1 Write some tests for ssl_file.cc
Mostly SSL_CTX_use_certificate_chain_file as that has some non-trivial
logic (and some seemingly dead code).

Change-Id: Id1196f18bca71c1be64178ec65eaef4ac1694925
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/79008
Auto-Submit: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2025-05-02 10:01:21 -07:00
David Benjamin 99ee682d5c Add various missing includes
Silence some clang-tidy warnings.

Change-Id: I194660d9f2b5282be073b82ec42bc70e835fce24
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/78988
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2025-05-01 11:06:57 -07:00
David Benjamin 6296407710 Move most of libssl's C++ utilities to libcrypto
This doesn't actually use them yet, but puts them in place so we can.

Bug: 394340436
Change-Id: Ia0550577aa021722943e9539aa25d221dc34467a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/78888
Commit-Queue: David Benjamin <davidben@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2025-04-28 15:33:36 -07:00
Chris Vest cccf8525db Use max_cert_list for TLSv1.3 NewSessionTicket
Certificate chains are transfered to the respective peer during the TLS
handshake in the ServerHello, and sometimes the ClientHello, messages.
These certificate chains can be of arbitrary size due to the number of
intermediary issuers, and due to the extensions within the certificates.

To avoid resource exhaustion, BoringSSL limits the size of handshake
messages, and rejects handshakes beyond a certain size.
By default, the max message size is 16 KiB, but it can be increased with
the SSL_CTX_set_cert_max_list setting.

This setting allows handshakes to complete with large certificate
chains. However, a new problem surfaces for TLSv1.3 sessions.
In TLSv1.3, session tickets (for supporting session resumption) are sent
after the handshake in NewSessionTicket messages. BoringSSL currently
encode the entire peer certificate chain (and some other things) in the
session ticket, which means the size of the certificate chains
influence the size of the corresponding NewSessionTicket.

To avoid breaking the TLS session on oversized NewSessionTicket
messages, a BoringSSL server will refuse to send any NewSessionTicket
that looks like it will be larger than 16 KiB. Unfortunately, this
accounting is inaccurate and does not take the entire NewSessionTicket
message into account. Thus, certificate chains that are a few hundred
bytes smaller than 16 KiB can be accepted by a handshake when the
max_cert_list setting has been increased, and by the NewSessionTicket
size accounting, but then later fail on the client with an
EXCESSIVE_MESSAGE_SIZE error, because ssl_max_handshake_message_len()
returns the default 16 KiB, in turn because the handshake has finished
and that causes it to ignore the configured max_cert_list.

This patch fixes this problem by making TLSv1.3 clients keep using the
max_cert_list setting post-handshake, when it is greater than the
default 16 KiB.

Change-Id: I17d689906a12079add4ad48b679508bc09a79f7c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/78647
Reviewed-by: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2025-04-23 16:09:52 -07:00
David Benjamin e369919445 Make bssl_shim and fuzzer BIOs use the public APIs
Converting libcrypto's is actually kind of hairy because we need to
either use CRYPTO_once or make sure downstream callers have
__cxa_guard_acquire. (Also bio->num is not part of public API.) But
let's at least demonstrate better hygiene for these few.

Bug: 412269080
Change-Id: I6a7e1fa063e4857b9f584413443dd7f5f8ae7d00
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/78848
Reviewed-by: Adam Langley <agl@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2025-04-22 14:24:00 -07:00
David Benjamin 3718975696 Make LHASH a completely internal type
The one remaining external reference was in an unused parameter where it
was impossible to obtain a non-null value. Remove the last of that
machinery from the public API. This leaves us free to completely rework
LHASH_OF(T) internally, including making it a template that understands
whether it owns its values.

(If we end up needing to revert it, we can still make the real
LHASH_OF(T) into a template. It just won't be called LHASH_OF(T)
anymore.)

Update-Note: Calling code which references LHASH_OF(T) will no longer
compile. We have had no public APIs that allow a caller to usefully
construct an LHASH_OF(T) for some time, so this only ever came up in odd
cases around bindings APIs.

Change-Id: I5a44310b04d8f8f3599f0f356b64786e62db5fbf
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/78787
Reviewed-by: Adam Langley <agl@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2025-04-22 12:29:02 -07:00
David Benjamin 690261bafd Align bio_info_cb with upstream OpenSSL
A few things got lost in translation here:

OpenSSL has two (well, three with BIO_set_callback_ex) BIO callback
signatures: BIO_callback_fn and BIO_info_cb. BIO_info_cb was formerly
known as bio_info_cb.

    typedef long (*BIO_callback_fn)(BIO *b, int oper, const char *argp, int argi,
                                    long argl, long ret);
    typedef int BIO_info_cb(BIO *, int, int);

Note that BIO_info_cb is a typedef for the function type, not the
pointer type.

BIO_callback_fn is used with BIO_set_callback, which is some callback
that hooks into every BIO operation, using BIO_CB_* constants.

BIO_info_cb* is used in two places. First, it is the type-erased
function pointer type for BIO_callback_ctrl, a separate control type for
BIO_CTRL_* that needs to pass in function pointers. Second, it is the
actual function pointer type for BIO_set_info_callback, which is the
only thing that uses BIO_callback_ctrl.

In the initial fork, we somehow got bio_info_cb defined as
BIO_callback_fn and passed into BIO_set_callback.
https://boringssl-review.googlesource.com/c/boringssl/+/19184 removed
BIO_set_callback, but forgot to remove the now outdated documentation
for bio_info_cb and the unusable BIO_CB_* constants.

This CL does the following:

1. Finish removing the remants of BIO_set_callback.

2. Introduce BIO_info_cb, OpenSSL's new preferred name for bio_info_cb,
   and make it match OpenSSL.

3. Redefine bio_info_cb as a deprecated alias for BIO_info_cb.

4. Update all the callback_ctrl implementations to reflect the new
   types (function pointer vs function). Although since function
   arguments decay to function pointer arguments, it's actually moot.

5. Make the connect BIO's callback type match upstream OpenSSL and
   BIO_info_cb and non-const.

This whole machinery is kinda pointless and we should probably unwind it
all, but this CL just fixes it for now.

Change-Id: I1972c62c638b96f45189d733067aa59602d9b18f
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/78830
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2025-04-22 12:20:59 -07:00
David Benjamin 27ac00d283 Add missing asserts to SSL_get_(min|max)_proto_version
It's a caller error to call those after the handshake config has been
shed. (We have an analogous pattern of asserts in other cases.)

Change-Id: Ifea0cb043a4f17e8e627d7fca81f90b8899c6587
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/78827
Auto-Submit: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2025-04-22 09:16:54 -07:00
David Benjamin 217e99d014 Add CBB_add_asn1_element convenience function
This is common enough that we probably should have one available. Saves
declaring a variable, calling flush, etc.

Change-Id: Ib21627e9e4caea01c729ad0dbb6266fdd30bb533
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/78788
Commit-Queue: Adam Langley <agl@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2025-04-21 10:09:16 -07:00
David Benjamin 2301836071 Tidy TLS 1.2 cipher selection.
This fixes a size_t truncation, but also we can simplify the
equi-preference group logic slightly.

Bug: 516
Change-Id: I64d6b7b1f22c69236d5802135f2bb5c5ec50f29d
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/61427
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
2025-04-15 11:38:37 -07:00
David Benjamin 1c8c0d928e Use std::sort instead of qsort in libssl
At least in libssl, we've been able to use std::sort without problems.
std::sort has a much, much better API than qsort.

Change-Id: Ife6f134364b653084633bc369ab48fd920db36f8
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/78048
Commit-Queue: David Benjamin <davidben@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
2025-04-02 11:52:45 -07:00
Victor Tan c86127e656 Change to use ALPS new codepoint as default
Change-Id: Id8f0fd89bd64c5cc79c18d70ceedf959f4bd33ce
Bug: 396645354
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/78187
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2025-04-01 09:36:04 -07:00
David Benjamin f6bf5e2cc1 Add APIs to access DTLS record layer state
DTLS record layer state is more complex and, with DTLS 1.3, we could not
make the simplifying assumptions that we did in DTLS 1.2. Expose enough
information so that, at idle points, we can extract state. See
go/dtls13-handover (internal) for details.

This requires maintaining some extra state on each epoch. We could
recover most of it if we did a better job not allocating unused fields
in DTLS by reworking the transport-specific portions.

Update-Note: Callers that need DTLS record layer state should migrate to
the new APIs. For now, the old APIs continue to work for DTLS 1.2, but
once caller have migrated, we'll make them TLS-only.

Bug: 42290608
Change-Id: Id3f7185e9715b9ee0e5e68108fd44d9484abd569
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/77967
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2025-03-25 10:50:32 -07:00
David Benjamin 02f0d8776e draft-kwiatkowski-tls-ecdhe-mlkem-01 is now draft-ietf-tls-ecdhe-mlkem-00
Bug: 40910498
Change-Id: Ia9adb945b6a2df32d263d306b3b2e45c84bfcf6e
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/77947
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
2025-03-24 13:30:42 -07:00
David Benjamin 126de11fc1 Remove MSVC warning suppressions around Windows system headers
These seem to no longer be needed? Over time we have gotten a bit more
measured about enabling all of MSVC's warnings (MSVC is just not
designed to be used with -Wall), so I'm guessing that's what changed.

Change-Id: If71850136fb83841a423b63bdf65c2d546ba0223
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/77887
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
Commit-Queue: Bob Beck <bbe@google.com>
2025-03-20 21:40:35 -07:00
David Benjamin 7c25e7308c Fix fuzzer build on Windows
https://ci.chromium.org/ui/p/chromium/builders/try/win-libfuzzer-asan-rel/2118578/overview

Change-Id: Id195253592610d849a3c4218295a62c320574ed4
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/77867
Reviewed-by: Bob Beck <bbe@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
2025-03-20 05:25:29 -07:00
David Benjamin 56383dabf4 Simplfy fuzzer build
Instead of having a pair of bespoke build definitions use the standard
FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION toggle. We actually originated
the idea of a fuzzing-specific build toggle, and then libFuzzer
standardized a toggle when we talked to them about what we were doing.

The problem is our fuzzer mode toggle substantially changed the TLS
stack behavior, such that downstream code would likely go haywire. So we
couldn't easily fold into the standard one, and all of BoringSSL's
downstream fuzzer builds were messy.

Instead, make a few changes:

1. Switch BORINGSSL_UNSAFE_DETERMINISTIC_MODE to
   FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION. That flag is not expected
   to cause downstream issues as it just makes the PRNG deterministic.

2. Replace BORINGSSL_UNSAFE_FUZZER_MODE with a runtime toggle that is
   only available when building with
   FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION.

3. Instead of the no_fuzzer_mode fuzzers being special corpora for the
   client and server fuzzers, they're now just separate fuzzerrs and
   follow the usual naming conventions between fuzzers and their
   corpora.

Update-Note: Downstream fuzzer builds can now be simplified. If the
fuzzing infrastructure already builds with
FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION, the separate boringssl_fuzz
(or whatever) target can be removed.

Bug: 42290128
Change-Id: Ia1e479777f366908951e15067c96c9767c229f0a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/77749
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
2025-03-20 03:41:54 -07:00
David Benjamin 51e517b22c Don't override the clock in BORINGSSL_UNSAFE_DETERMINISTIC_MODE
Instead, do it in a callback in the fuzzer itself. This removes a part
of BORINGSSL_UNSAFE_DETERMINISTIC_MODE that is probably a little tricky
to use automatically as FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION.

Bug: 42290128
Change-Id: Ie3a62e25b099b4cb4ca1c16581beb04fc9d9930e
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/77748
Commit-Queue: David Benjamin <davidben@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
2025-03-19 23:58:30 -07:00
David Benjamin 1536de883c Const-correct SSL_export_keying_material
Change-Id: I1c41985dc3997d46f102d3f2f3cc1c9784045377
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/77188
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
2025-03-11 14:38:26 -07:00
David Benjamin 899b557b0c Implement draft-ietf-tls-cross-sni-resumption
Although we only need a subset of draft-ietf-tls-tlsflags, go ahead and
implement helper functions good enough for response flags to get some
experience with the extension.

Change-Id: Iba1581686c9d1883439cfd6445e98801f8fad098
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/77128
Reviewed-by: Bob Beck <bbe@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2025-03-10 19:37:16 -07:00
David Benjamin 9ddcda5d26 runner: Test export keying material across all protocols
Notably DTLS, which flips the HKDF-Expand-Label function around.

Change-Id: I9bb02e17a8fd61358ff148bbdede73af934fea0a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/77147
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2025-03-10 12:19:20 -07:00
David Benjamin 5d4b8d99a1 runner: Restore error output in the "unexpected failure" case
We accidentally lost this in
https://boringssl-review.googlesource.com/c/boringssl/+/75507

Change-Id: Ib22a68e43fd78f007e79c338127f10b575c4de7e
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/77127
Auto-Submit: David Benjamin <davidben@google.com>
Commit-Queue: Bob Beck <bbe@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
2025-03-06 15:11:09 -08:00
David Benjamin cbc61792ca Split runner.go into a bunch of different files
Now runner.go contains only the test runner, while the various test
suites are moved into their own files, named foo_tests.go. (foo_test.go
would be treated as a Go test.)

I broadly just split by the addFooTests functions, but in a few cases I
grouped them together.

Now we no longer have a single 24,000 line file with all the tests. That
was getting unwieldy.

Change-Id: I76f372f60f5f0de5f1ba0913317918a4053372a3
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/77107
Reviewed-by: Bob Beck <bbe@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Commit-Queue: Bob Beck <bbe@google.com>
2025-03-06 14:27:40 -08:00
Neal Patel f1ebcda138 runner: add one-to-many error mapping for canonical error checking in BoGo tests
Associated Issue: https://github.com/golang/go/issues/71066

Change-Id: I6d8e35f03249bd0b612e54e6c00452f50f4cb4bf
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/75507
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2025-03-06 09:02:57 -08:00
Bob Beck 7e529d2b39 Add Trust Anchors extension
Bug: 398275713
Change-Id: I9d15693ae88440817585b2d1d5a62244529f45b7
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/73087
Commit-Queue: Bob Beck <bbe@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2025-03-04 12:50:43 -08:00