6486 Commits

Author SHA1 Message Date
David Benjamin
1a7456ac15 No-op CL to trigger some builds.
Make sure the recent changes to the builders all work.

Change-Id: I0eca1b7732da29a14325673deeb031c8863b45b8
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45724
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2021-02-19 19:48:13 +00:00
David Benjamin
48d80bb6cf Use CIPD Go packages.
These are ultimately just the upstream tarballs, but it's one less
ad-hoc script to maintain.

Change-Id: Ia93a7a9d4944d482e4e4137587998790e8e59294
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45784
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2021-02-19 19:31:14 +00:00
David Benjamin
814465f01d Update CMake on the bots and switch to CIPD where available.
Newer versions of CMake have some fix for default libraries on
Windows/ARM64. (Not sure exactly what version, but the latest CMake does
seem to work.)

While trying to update the others, it turns out my workstation no longer
makes CMake builds compatible with the builders. It's also tedious that
updating CMake requires making builds myself. Fortunately, Chrome infra
is maintains some packages of third-party software in CIPD.

However, they don't make Windows CMake builds (filed
https://crbug.com/1180257 to request them), and they're stuck on 3.13.x
(blocked on https://crbug.com/1176531).

So, this CL switches to CIPD for Mac/Linux, with the latest version they
have available. It sticks with the old method (uploading copies of
upstream's packages) for Windows and grabs the latest version. When both
of the bugs above are fixed, hopefully things will be more uniform.

Change-Id: I710091fc60594165738a893b2be73cdcef54dfe2
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45764
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2021-02-19 18:48:04 +00:00
David Benjamin
e5d41a57e6 Future-proof vs_toolchain.py for VS2019.
In trying to figure out an ARM64 builder issue, I tried VS2019. That
didn't fix the ARM64 issue, but it did reveal that I ported over some of
the logic from Chromium wrong. For "new-style" paths, the toolchain
directory should be toolchain_data['path'], not the parent directory of
win_sdk.

(The latest VS2019 package in Chromium puts win_sdk a few directories
down from the toolchain root.)

This CL should be a no-op for now because all our current toolchains use
Chromium's "old-style" win_sdk-relative paths.

Change-Id: I8ad7784abb479d1ede3995a44433e57448e8debf
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45744
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2021-02-19 16:24:54 +00:00
Adam Langley
be9a86f459 Revert "Revert "Disable check that X.509 extensions implies v3.""
This reverts commit 4251d0d3f66a182e1b1ff22e9d0085613a1253ec, except
that the reland dates have been updated to not be in the past.

Change-Id: I7812c0e36d87ed1e049ec0a7d92a23efec881a81
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45704
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2021-02-18 18:32:41 +00:00
David Benjamin
bbd1742f61 Update Clang and Go on the bots.
I've left libc++ and Android tools for now. libc++ is running into
https://crbug.com/1166707. I'm not sure what's wrong with the Android
tools. (CMAKE_LINKER isn't defined for some reason, but it's defined on
my machine.)

We'll also want to update the builders before the NDK anyway. The new
NDK now defaults to ANDROID_ARM_NEON=TRUE.

Change-Id: I1c0fbc3e26368c04d31464477a51e04209aec7ba
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45544
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2021-02-17 23:04:21 +00:00
David Benjamin
f6bd54efbc Check for OBJ_nid2obj failures in X509_ATTRIBUTE_create.
While I'm here, rewrite it a bit to align more with our preferred style.
(No assignments in conditions, no need for NULL checks on free
functions.)

See also 64a1b940d2b640e5edf0feae90e81bbb6b4941e7 from upstream.

Change-Id: I99a122343541e89d5950888de2c708cfa3ec45e2
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45686
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2021-02-17 02:01:57 +00:00
David Benjamin
e7c0c9734f Don't overflow the output length in EVP_CipherUpdate calls.
CVE-2021-23840

(Imported from upstream's 6a51b9e1d0cf0bf8515f7201b68fb0a3482b3dc1.)

This differs slightly from upstream's version:

- EVP_R_OUTPUT_WOULD_OVERFLOW didn't seem necessary when ERR_R_OVERFLOW
  already exists. (Also since we use CIPHER_R_*, it wouldn't have helped
  with compatibility anyway. Though there's probably something to be
  said for us folding CIPHER_R_* back into EVP_R_*.)

- For simplicity, just check in_len + bl at the top, rather than trying
  to predict the exact number of bytes written.

Update-Note: Passing extremely large input lengths into EVP_CipherUpdate
will now fail. Use EVP_AEAD instead, which is size_t-based and has more
explicit output bounds.

Change-Id: I31835c89dcdecb6b112828f57deb798dc7187db5
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45685
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2021-02-16 20:50:26 +00:00
David Benjamin
ca2162d719 Remove X509_issuer_and_serial_hash.
Update-Note: No one uses this function. It had a NULL dereference in
some error cases. See CVE-2021-23841.

Change-Id: Ie1cc97615ac8b674147715d7d62e62faf218ae65
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45684
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2021-02-16 18:22:32 +00:00
Justin Paupore
238a25831e Fix Bazel build breakage.
This fixes an issue in a99308f that caused Bazel builds to break during
the analysis phase.

Change-Id: Ib26e70a52730f04905c2b2f137674f297488ec4f
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45665
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2021-02-13 04:22:30 +00:00
David Benjamin
85bda4b244 Specify VS toolchain by command-line argument.
This lets the builders pass it in via gclient_vars. Once this lands,
I'll make the builders fill it in, at which point we can remove the
magic 'env' value and the logic in the recipe.

Change-Id: Idfc4db3e4cdecf62eacbb2925fd545e1a76b2c79
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45624
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2021-02-13 01:43:23 +00:00
Justin Paupore
a99308fa91 Update Android Bazel build support in BUILD.toplevel.
Newer versions of Bazel use a different setting for the crosstool_top
flag, depending on the NDK toolchain in use. This change detects these
crosstools and builds them using Android flags.

Fixes: 180083900
Change-Id: I937d18e53d72b2911e1c472adbce65282d31885d
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45564
Commit-Queue: Justin Paupore <jpaupore@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2021-02-12 23:24:22 +00:00
David Benjamin
c02c19e0d8 Honor SSL_TLSEXT_ERR_ALERT_FATAL in the ALPN callback.
This aligns with OpenSSL's behavior. RFC7301 says servers should return
no_application_protocol if the client supported ALPN but no common
protocol was found. We currently interpret all values as
SSL_TLSEXT_ERR_NOACK. Instead, implement both modes and give guidance on
whne to use each. (NOACK is still useful because the callback may be
shared across multiple configurations, some of which don't support ALPN
at all. Those would want to return NOACK to ignore the list.)

To match upstream, I've also switched SSL_R_MISSING_ALPN, added for
QUIC, to SSL_R_NO_APPLICATION_PROTOCOL.

Update-Note: Callers that return SSL_TLSEXT_ERR_ALERT_FATAL from the
ALPN callback will change behavior. The old behavior may be restored by
returning SSL_TLSEXT_ERR_NOACK, though see the documentation for new
recommendations on return values.

Change-Id: Ib7917b5f8a098571bed764c79aa7a4ce0f728297
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45504
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2021-02-11 23:36:22 +00:00
Adam Langley
3b7029a549 acvp: detect header element in JSON.
Sometimes JSON vector files contain a header element that must be
duplicated into the output and sometimes they don't. Auto-detect this by
looking for a “url” field in the first element.

Change-Id: I76046adb8ea64fe5ac9bae9d6583546504723918
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45524
Reviewed-by: David Benjamin <davidben@google.com>
2021-02-11 16:45:32 +00:00
David Benjamin
ce9b002ebd Align the ARM capability functions.
This is largely some cleanup so the three features follow the same
patterns and is hopefully cleaner (no more separate static and
non-static paths). The practical impact is probably nil. (Linux-based
ARM builds with crypto extensions as a baseline, if any exist, save
binary size.)

Change-Id: I2214b1a54e2074024b8eeb51799a08b94646cbf3
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45485
Reviewed-by: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2021-02-10 17:34:17 +00:00
David Benjamin
f9bd455c85 Skip runtime NEON checks if __ARM_NEON is defined.
When a feature is enabled statically in the build config, the compiler
defines __ARM_NEON and also considers itself free to emit NEON code.
In this case, there is no need to check for NEON support at runtime
since the binary will not work without NEON anyway. Moving the check to
compile time lets us drop unused code.

Chrome has required NEON on Android for nearly five years now. However,
historically there was a bad CPU which broke on some NEON code, but not
others. See https://crbug.com/341598 and https://crbug.com/606629. We
worked around that CPU by parsing /proc/cpuinfo and intentionally
dropping the optimization. This is not a stable situation, however, as
we're hoping the compiler is not good enough at emitting NEON to trigger
this bug.

Since then, the number of affected devices has dropped, and Chrome has
raised the minimum Android requirement to L. The Net.HasBrokenNEON
metric from Chrome is now well in the noise.

This CL stops short of removing the workaround altogether because some
consumers of Cronet are unsure whether they needed this workaround.
Those consumers also build without __ARM_NEON, so gating on that works
out. We'll decide what to do with it pending metrics from them.

Update-Note: Builds with __ARM_NEON (-mfpu=neon) will now drop about
30KiB of dead code, but no longer work (if they even did before) on a
particular buggy CPU. Builds without __ARM_NEON are not affected.

Change-Id: Id8f7bccfb75afe0a1594572ea20c51d275b0a256
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45484
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2021-02-09 23:25:27 +00:00
Adam Langley
fc23300164 acvp: don't include CMAC-AES in regcap dump.
CMAC-AES isn't inside our FIPS module, it's only included in
modulewrapper in order to test acvptool. Mark it with a special tag to
avoid it appearing when dumping regcap JSON because NIST paperwork is
such that it's better not to ACVP test such code.

Change-Id: I0c6d3a38bce9bf5766b889677eb3f7de94262c24
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45465
Reviewed-by: David Benjamin <davidben@google.com>
2021-02-09 22:57:26 +00:00
Adam Langley
4d3e540cc0 acvp: fix CMAC verify
This is only used for testing acvptool but, yea, |memcmp| doesn't return
a bool 😳

This wasn't noticed because "ver" mode was missing from the registration
and thus from the test vectors.

Change-Id: I181c9b66aea4032543d39ebcc8728a01e0f34f55
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45464
Commit-Queue: Adam Langley <alangley@gmail.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2021-02-09 22:22:14 +00:00
Adam Langley
a2278d4d2c Include bn/internal.h for non-bcm.c builds.
Change-Id: Ica2248a0c7f90b3cc13dfea79c95277313c4eb58
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45424
Reviewed-by: Adam Langley <agl@google.com>
2021-02-05 03:59:30 +00:00
Adam Langley
48cbd69dee Add various function calls to test_fips.
test_fips probably needs to exercise everything that we have self-tests
for.

(The following change will eliminate the duplication of the code to
create the FFDH group. For reasons, that can't be done in this change.)

Change-Id: Ia72064db77381e7cf396a34b4723b2607f26f00b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45404
Reviewed-by: Adam Langley <alangley@gmail.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2021-02-04 17:40:21 +00:00
David Benjamin
bb43a45d6d Add missing include to self_check.c.
This fixes the build for folks not using bcm.c.

Change-Id: I47935d8af7cb5a12ff2918ee2a8774182681d930
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45384
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2021-02-02 21:34:40 +00:00
Adam Langley
4251d0d3f6 Revert "Disable check that X.509 extensions implies v3."
This reverts commit 5850a016b212407708a963f4f94e4217ae18dd0e.

Bug: 375
Change-Id: Ife8184ded5b09f175924bfc29ac113d3186e60ed
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45344
Reviewed-by: David Benjamin <davidben@google.com>
2021-01-29 22:56:19 +00:00
David Benjamin
c5e4538e3b Fix TLS13SessionID-TLS13 test.
The check was happening in code that only ran at TLS 1.2, so we weren't
testing anything. Additionally check the resumption case. While we do
handle it correctly, we only manage it due to the weird OpenSSL quirk
we've carried over from TLS 1.2 tickets where we synthesize a session ID
for TLS 1.3 tickets. (Is that still needed?)

That's subtle enough to warrant a test, and some other implementations
reuse our test suite, so it's worth the coverage there.

Change-Id: I83cc355bd853097ec6edcd2cc40b06b19e3b00e5
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45324
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2021-01-29 19:20:59 +00:00
David Benjamin
ae2bb64173 Use ID instead of Id in Go.
A linter was complaining about some instance, so just fix the lot of it.

Change-Id: I7e23cbada6e42da887d740b84a05de9f104a86ab
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45284
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2021-01-28 17:44:43 +00:00
Adam Langley
4a196ccf9a acvp: move CMAC verification into the module wrapper.
CMAC is not inside our FIPS module and we have ACVP support for it just
for testing (other modules need to validate CMAC). This change makes the
CMAC verify test an explicit action for the module wrapper so that a
verification function exposed by a FIPS module can be tested.

Change-Id: I3943bde175f2c1d62881002b4e12d7bca68a9018
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45264
Reviewed-by: David Benjamin <davidben@google.com>
2021-01-28 17:42:38 +00:00
David Benjamin
ab5edbe7fc Benchmark BORINGSSL_self_test in FIPS mode.
Probably worth benchmarking this, given it slows down every process
startup.

Change-Id: I603c79a445203f87e26fa23d9afc4450688f2929
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45245
Reviewed-by: Adam Langley <agl@google.com>
2021-01-27 22:53:04 +00:00
David Benjamin
1c919724d3 Support MOVLPS and MOVHPS in delocate.
GCC 10.2.1 seems to be emitting code like this:

    movq    gcm_gmult_clmul@GOTPCREL(%rip), %xmm0
    movhps  gcm_ghash_clmul@GOTPCREL(%rip), %xmm0
    movaps  %xmm0, (%rsp)

This is assembling a pair of function pointers in %xmm0 and writing the
two out together. I've not observed the compiler output movlps, but
supporting movhps and movlps are about as tricky. The main complication
is that these instructions preserve the unwritten half of the
destination, and they do not support register sources, only memory.

This CL supports them by loading in a general-purpose register as we
usually do, pushing the register on the stack, and then running the
instruction on (%rsp). Some alternatives I considered:

- Save/restore a temporary XMM register and then use MOVHLPS and
  MOVLHPS. This would work but require another saveRegister-like
  wrapper.

- Take advantage of loadFromGOT ending in a memory mov and swap out
  the final instruction. This would be more efficient, but we downgrade
  GOT-based accesses to local symbols to a plain LEA. The compiler will
  only do this when we write a pair of function pointers in a row, so
  trying to optimize the non-local symbols seems not worth the trouble.
  (Really the compiler should not be emitting GOT-relative loads at all,
  but the compiler doesn't know these symbols will be private and in the
  same module, so it has a habit of pessimally using GOT-based loads.)

This option seemed the simplest.

Change-Id: I8c4915a6a0d72aa4c5f4d581081b99b3a6ab64c2
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45244
Reviewed-by: Adam Langley <agl@google.com>
2021-01-27 22:51:57 +00:00
Adam Langley
5cf02188fe Add FFDH FIPS self-test.
This invovles a |2048|^|225| modexp, which is far from ideal, but is now
required in FIPS mode.

Change-Id: Id7384b4ba92aa74e971231bc44fa0f10434d18e2
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45085
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2021-01-27 22:48:11 +00:00
Adam Langley
d09962d5c3 acvp: update to newer FFDH test.
Revision 1.0 is this test is reportedly no longer acceptable and we have
to use the “SSC” version now. The documentation for this test doesn't
mention that a “z” field is possible, but that's what the test vectors
from the demo server contain and, after guessing at the correct response
format, this makes the NIST server happy.

Change-Id: Ic63d9e19998dc015733d847cd0330a3af1d5e7e6
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45224
Reviewed-by: David Benjamin <davidben@google.com>
2021-01-27 15:31:39 +00:00
Adam Langley
e133345dba Add basic BLAKE2b-256 support.
Our use-case for this does not require optimisation at the current time,
so a clean C implementation is fine.

Change-Id: I8f29572c33e8dbcc37961c099c71c14aafc8d0a3
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45164
Reviewed-by: David Benjamin <davidben@google.com>
2021-01-26 19:59:29 +00:00
Adam Langley
16c42cc796 acvp: check that the payloadLen of cipher tests is correct.
NIST currently seems to have a bug where they don't respect the regcap
for AES-CTR and return fractional-byte tests when not allowed.
Previously we didn't notice that the specified payload length didn't
match the actual value.

Change-Id: I0e48d5246f7250e6047d983cd016b0de290d0f70
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45205
Reviewed-by: David Benjamin <davidben@google.com>
2021-01-26 18:59:21 +00:00
Adam Langley
1fa6b7ffd9 acvp: update test expectations in light of 8dcdcb39a7
(Forgot to git add these files to that change.)

Change-Id: I8303bbbf7e0089b3e992f4be7e645fe989a7ddb6
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45204
Reviewed-by: David Benjamin <davidben@google.com>
2021-01-26 18:58:42 +00:00
Adam Langley
b0d71a2908 Support cross-compiling AArch64 FIPS to Android.
In order to support cross-compiling:
  1) inject-hash needs to know to use SHA-256 for the hash function
     on Android. Since that's a good idea on Aarch64 in general
     (due to common hardware support), do it for all Aarch64.
  2) We need to use the compiler to run the preprocessor, not plain
     cpp, because the compiler will get the built-in #defines right.

Change-Id: Ie00d46e9e6d489fcb9e3f3e5e625aa289c7e0d73
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45044
Reviewed-by: David Benjamin <davidben@google.com>
2021-01-25 20:31:17 +00:00
Adam Langley
8dcdcb39a7 acvp: drop 3DES fields from output when unused.
Change-Id: Ibc7f1b70deca0e1541c3f32271e57fc0320e6a05
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45185
Reviewed-by: David Benjamin <davidben@google.com>
2021-01-22 13:32:33 +00:00
Adam Langley
0f0e2bce6d acvp: don't advertise SHA-1 RSA signature generation.
The NIST production server doesn't like this.

Change-Id: I22ce31e822107f176eb97f7632ea2777c6ab4a44
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45184
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2021-01-22 01:20:48 +00:00
Dan McArdle
39093c1bfb Fix comments that refer to old draft of HPKE.
Bug: 275
Change-Id: I4879459fceade79a0d646cb394f42af55e12236d
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45144
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2021-01-21 20:39:18 +00:00
David Benjamin
c47bfce062 Define TLSEXT_TYPE_quic_transport_parameters to the old code point for now.
QUICHE currently does not know to call
SSL_set_quic_use_legacy_codepoint, picking up the current default of the
legacy code point. It then assumes that the
TLSEXT_TYPE_quic_transport_parameters constant may be used to extract
transport parameters, so after
https://boringssl-review.googlesource.com/c/boringssl/+/44704, it
breaks.

To smooth over the transition, we now define three constants:
TLSEXT_TYPE_quic_transport_parameters_legacy,
TLSEXT_TYPE_quic_transport_parameters_standard, and the old constant.
The old constant will match whatever the default is (for now, legacy) so
the default is self-consistent. Then plan is then:

1. BoringSSL switches to the state in this CL: the default code point
   and constant are the legacy one, but there are APIs to specify the
   code point. This will not affect QUICHE, which only uses the
   defaults.

2. QUICHE calls SSL_set_quic_use_legacy_codepoint and uses the
   corresponding _legacy or _standard constant. It should *not* use the
   unsuffixed constant at this point.

3. BoringSSL switches the default setting and the constant to the
   standard code point. This will not affect QUICHE, which explicitly
   configures the code point it wants.

4. Optional: BoringSSL won't switch the default back to legacy, so
   QUICHE can switch _standard to unsuffixed and BoringSSL
   can remove the _standard alias (but not the function) early.

5. When QUICHE no longer needs both code points, it unwinds the
   SSL_set_quic_use_legacy_codepoint code and switches back to the
   unsuffixed constant.

6. BoringSSL removes all this scaffolding now that it's no longer
   needed.

Update-Note: This this fixes a compatibility issue with
https://boringssl-review.googlesource.com/c/boringssl/+/44704.

Change-Id: I9f75845aba58ba93e9665cd6f05bcd080eb5f139
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45124
Reviewed-by: David Schinazi <dschinazi@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2021-01-20 22:57:32 +00:00
Adam Langley
2d691ca60d Make BN_clear_free a wrapper around BN_free.
We clear all heap memory on free now, thus the difference between these
functions is quite small. There are some differences though:

Firstly, BN_clear_free will attempt to zero out static limb data.  But
static data is probably read-only and thus trying to zero it will crash.

Secondly it will try to zero out the BIGNUM structure itself. But either
it's on the heap, and will be zeroed anyway, or else it's on the stack,
and we don't try and clear the stack in general because the compiler is
duplicating bits of it at will anyway.

Change-Id: I8a07385a102cfd308b555432942225c25eb7c12d
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45084
Reviewed-by: David Benjamin <davidben@google.com>
2021-01-20 19:18:27 +00:00
Adam Langley
c5e2cf3c07 delocate: support Aarch64
Add Aarch64 support to delocate. Since it's a modern ISA, it's actually
not too bad once I understood the behaviour of the assembler.

Change-Id: I105fede43b5196b7ff7bdbf1ee71c6cfa2fc1aab
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/44848
Reviewed-by: David Benjamin <davidben@google.com>
2021-01-20 17:18:30 +00:00
David Benjamin
c1e156ae16 Add DH_compute_key_padded.
OpenSSL has a fixed-width version of DH_compute_key nowadays. Searching
around callers of DH_compute_key, many of them go back and re-pad the
secret anyway. Uses of DH should migrate to modern primitives but, in
the meantime, DH_compute_key_padded seems worthwhile for OpenSSL
compatibility and giving fixed-width users a function to avoid the
timing leak.

Bump BORINGSSL_API_VERSION since one of the uses is in wpa_supplicant
and they like to compile against a wide range of Android revisions.

Update-Note: No compatibility impact, but callers that use
DH_compute_key and then fix up the removed leading zeros can switch to
this function. Then they should migrate to something else.

Change-Id: Icf8b2ace3972fa174a0f08ece39710f7599f96f2
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45004
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2021-01-19 23:23:20 +00:00
David Benjamin
a9319d9b0f Fix client 0-RTT handling with ALPS.
When offering 0-RTT, the client should check that all carried-over
values are consistent with its preferences. This ensures that parameter
negotiation happens independently of 0-RTT. The ALPS version of this
check was a tad too aggressive: a session without ALPS should be treated
as always compatible.

I'll follow this with a fix to the draft spec to clarify this.

Change-Id: Ia3c2a60449c555d1d91c4e528215f8e551a90a9f
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45104
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2021-01-19 23:17:12 +00:00
Adam Langley
2f2d27eb5c acvp: add XTS support.
Since we don't have XTS in the FIPS module, this change uses
testmodulewrapper for testing.

Change-Id: I82117472ea4288d017983fe9cc11d4ba808a972a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45064
Reviewed-by: David Benjamin <davidben@google.com>
2021-01-19 22:32:08 +00:00
Yuchen Dai
595cdc29d6 doc: fix SSL_set0_rbio
Change-Id: I8559f1af23a2254ad5fe62c7169d71bd6c957384
Signed-off-by: Yuchen Dai <silentdai@gmail.com>
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/45024
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2021-01-15 20:27:30 +00:00
David Schinazi
3d8b8c3df2 Add support for the new QUIC TLS extension codepoint
IETF QUIC draft 33 is replacing the TLS extension
codepoint for QUIC transport parameters from 0xffa5
to 57. To support multiple versions of Chrome, we
need to support both codepoints in BoringSSL. This
CL adds support for the new codepoint in a way that
can be enabled on individual connections.

Note that when BoringSSL is not in QUIC mode, it
will error if it sees the new codepoint as a server
but it will ignore the legacy codepoint as that could
be a different private usage of that codepoint.

Change-Id: I314f8f0b169cedd96eeccc42b44153e97044388c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/44704
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2021-01-14 21:22:33 +00:00
Adam Langley
f8f35c9555 delocate: preprocess perlasm output on Aarch64
Aarch64 perlasm outputs need to be run via the C preprocessor before
being parsed by delocate.

Change-Id: Ie420388e0e1707cb064d696ee8f87728cab9a36e
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/44847
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2021-01-13 23:44:43 +00:00
David Benjamin
c3ee9c8040 Replace MockQUICTransport tags with record types.
They align exactly with TLS record types, so just use the existing
constants.

Change-Id: I693e7c740458cf73061e6b573eeb466d0fce93cc
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/44990
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2021-01-13 19:27:02 +00:00
David Benjamin
e606f79c5b Run extension tests at all protocols.
Change-Id: Ied0ef856de3a1ae2c65b10645fbce614726f4e20
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/44989
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2021-01-13 18:48:52 +00:00
David Benjamin
47d1274fd2 Make QUIC tests work with early data.
This changes the format of the mock QUIC transport to include an
explicit encryption level, matching real QUIC a bit better. In
particular, we need that extra data to properly skip rejected early data
on the shim side. (On the runner, we manage it by synchronizing with the
TLS stack. Still, the levels make it a bit more accurate.)

Testing sending and receiving of actual early data is not very relevant
in QUIC since application I/O is external, but this allows us to more
easily run the same tests in TLS and QUIC.

Along the way, improve error-reporting in mock_quick_transport.cc so
it's easier to diagnose record-level mismatches.

Change-Id: I96175a4023134b03d61dac089f8e7ff4eb627933
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/44988
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2021-01-13 18:47:12 +00:00
David Benjamin
7a55c80271 Make QUIC work with -async tests.
This originally didn't work because we installed an async BIO, while
QUIC uses the BIO to mock out a QUIC transport. Our QUIC IO callbacks
don't have a meaningful notion of sync vs async, so no-op this portion
of the -async flag.

The immediate motivation is I'd like to make addExtensionTests run over
all protocols, and having the async tests fail is inconvenient. However,
async tests in QUIC is still meaningful anyway to support various
callbacks, so I've removed the workaround in the state machine coverage
tests. (Though most of those async tests are redundant as they're
concerned with IO, not callbacks.) Along the way, the various handshake
record controls are irrelevant to QUIC, so this actually results in a
net decrease in redundant tests.

Change-Id: I67c1ee48cb2d85b47ae3328fecfac86a24aa2ed1
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/44987
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2021-01-13 18:37:22 +00:00
David Benjamin
71ed9d7538 Fix ALPS state machine in QUIC servers.
The state machine around EndOfEarlyData is a bit messy, which caused a
problem introducing the new message in QUIC. We keep waffling on whether
that state junction should no-op the EndOfEarlyData state or skip it.
Since skipping it caused us to miss this spot, let's try no-op-ing it.

As a test, so this CL is easier to cherry-pick, I've just duplicated the
basic server test. Better, however, would be to run all the extensions
tests under QUIC. (In particular, this is missing 0-RTT coverage.) But
this is a large diff and requires improving the mock QUIC transport,
etc., in runner. That work is done in follow-up CLs, which replace this
duplicated test.

Change-Id: I25b6feabdc6e5393ba7f486651986a90e3721667
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/44985
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2021-01-13 18:35:42 +00:00