10803 Commits

Author SHA1 Message Date
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
Brian Smith
cdd1955d9c
Merge pull request #1179 from briansmith/b/merge-boringssl-integrated-chacha-x86_64
Use integrated ChaCha20-Poly1305 assembly from BoringSSL
2021-01-27 14:45:23 -08:00
Brian Smith
a822206929 Remove currently-unused test vectors for AES-GCM-SIV.
We'll add them back when we add the actual AES-GCM-SIV code.
2021-01-27 12:23:45 -08: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
Brian Smith
af3fa46f29 ChaCha20-Poly1305: Clarify alignment of the output tag in the integrated x86-64 code. 2021-01-26 15:37:56 -08:00
Brian Smith
a0017634b2 Merge branch 'main' into b/merge-boringssl-integrated-chacha-x86_64 2021-01-26 14:29:23 -08:00
Brian Smith
45e2ed5cf7 ChaCha20-Poly1305: Remove has_sse41.
It isn't significantly simpler to use than the direct use of `cpu`.
2021-01-26 14:28:12 -08: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
Brian Smith
5e38e04857 ChaCha20-Poly1305: Revert unneeded changes to BoringSSL assembly code.
`chacha20_poly1305_constants` is unused but if we want to remove it, we should
remove it upstream too (first).
2021-01-26 10:16:14 -08:00
Brian Smith
47437a3d57 ChaCha20-Poly1305: Combine unsafe blocks in integrated version. 2021-01-26 10:15:26 -08:00
Brian Smith
1ebb1e93b6 ChaCha20-Poly1305: Elide lifetimes in integrated version. 2021-01-26 10:15:26 -08:00
Brian Smith
45b034905d ChaCha20-Poly1305: Define integrated assembly types more like BoringSSL.
Define the input data structures for the integrated assembly almost exactly
like BoringSSL does, except for the caveat mentioned in the comments.

Similarly, define the output type as a structure containing a byte array, like
BoringSSL, again with the caveats mentioned in the comments.

Abstract the union types into a single parameterized type.
2021-01-26 10:15:26 -08:00
Brian Smith
8d5b0f2059 ChaCha20-Poly1305: Rearrange the unwrapping of the key.
Unwrap the ChaCha20 key earlier so we can use stronger types in the code that calls into
the integrated assembly. Either way we do the unwrapping in two places, but this way we
do it earlier.
2021-01-26 10:15:26 -08:00
Brian Smith
cce0b6afdb Endian: Allow ArrayEncoding to be implemented for larger arrays.
The original version avoided `unsafe` but doesn't work for older
versions of Rust that we're still trying to support. Switch to the
`unsafe` implementation that works everywhere.
2021-01-26 10:15:26 -08:00
Brian Smith
da1a5ec473 Limit visibility of function that exposes a ChaCha20 key's value.
In the future we may exposes the `chacha` module publicly and then it
would be wrong for the `Key` type to implement `as_ref()` as that would
then expose the key material outside the module.
2021-01-26 10:15:26 -08:00
Vlad Krasnov
34424d829d Enable the integrated assembly x86-64 ChaCha20-Poly1305 implementation from BoringSSL 2021-01-26 10:12:14 -08:00
Brian Smith
f3a2c36c57 Endian: Allow ArrayEncoding to be implemented for larger arrays.
The original version avoided `unsafe` but doesn't work for older
versions of Rust that we're still trying to support. Switch to the
`unsafe` implementation that works everywhere.
2021-01-26 10:05:58 -08: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
David Benjamin
f4a88296fc runner: Allow tokbind without RI/EMS in TLS 1.3.
There was a QUIC-specific ALPS bug, so I'm thinking we should loop
addExtensionTests at all protocols. To do so, we need to fix this bug in
the test expectation.

Change-Id: Ic05a4cb2ea32e7145441a0273cd65966c41534ec
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/44986
Reviewed-by: Adam Langley <agl@google.com>
2021-01-13 18:34:35 +00:00
David Benjamin
41676bfd86 Test that ALPS can be deferred to the ALPN callback.
This wasn't the cause of the bug, but I noticed we never tested it, so
fill that in.

Change-Id: Ib38bc08309e69f43c1995ba2a387643c0a7bae99
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/44984
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2021-01-13 16:22:32 +00:00
Dan McArdle
c295935a9b Send ECH acceptance signal from backend server.
This CL implements the backend server behavior described in Section 7.2
of draft-ietf-tls-esni-09.

Bug: 275
Change-Id: I2e162673ce564db0cb75fc9b71ef11ed15037f4b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/43924
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2021-01-12 20:41:51 +00:00
Adam Langley
5d54832f1a delocate: handle Aarch64 assembly in parser.
Aarch64 assembly is quite different from x86-64 or POWER. But the system
of directives is the same so there's quite a lot of utility from being
able to use the same delocate framework.

Unfortunately, with peg, there's no obvious way to be able to parse
instructions differently without breaking the parsing into two stages.
Thus the parser is extended here to support all three ISAs. This seems
to work ok without breaking either of the other two.

Change-Id: Iced0f651e556e6ffae3eb35f2edfc0bf84167967
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/44846
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2021-01-11 19:03:16 +00:00
Anthony Roberts
afd5dba756 Add ASM optimizations for Windows on Arm
Windows on Arm (WoA) builds are currently using the C implementations
of the various functions within BoringSSL. This patch enables feature
detection for the Neon and hardware crypto optimizations, and updates
the perl script to generate AArch64 .S files for WoA.

Note these files use GNU assembler syntax (specifically tested with
Clang assembler), not armasm.

Change-Id: Id8841f4db0498ec16215095a4e6bd60d427cd54b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/43304
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2021-01-09 01:18:19 +00:00
David Benjamin
571c3e78bf Use gai_strerrorA on Windows.
gai_strerror is one of the Windows functions which behaves differently
whether UNICODE is defined. See
https://docs.microsoft.com/en-us/windows/win32/intl/conventions-for-function-prototypes

Call gai_strerrorA so that we behave consistently in both modes. This
fixes the build failure in
https://chromium-review.googlesource.com/c/chromium/src/+/2613519.

It also fixes a type error in the connect BIO (built but not used in
Chromium), which wasn't noticed because ERR_add_error_data is a variadic
function and untyped. (The type error won't go out of bounds because
we're interpreting a NUL-terminated WCHAR* as a NUL-terminated char*.
The string will be misinterpreted, but it still will be terminated
either at the NUL WCHAR or, more likely, the upper zero byte of the
first Latin-1 character in the string.)

The ERR_add_error_data call raises the question of which of our char*
strings are UTF-8 and which are the POSIX locale / Windows code page
(when those are not also UTF-8). This CL doesn't address this and only
fixes the character width error. Realistically, calling code tosses
char* to printf so often that non-UTF-8 locales are probably a lost
cause. (Although right now we do not transform any OS error strings, so
tossing them to printf works fine. The outputs of functions like
ASN1_STRING_to_UTF8, not so much.)

Change-Id: Ie789730658829bde90022605ade2c86b8a65c3de
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/44964
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2021-01-08 17:06:29 +00:00
Brian Smith
628acbeff5 Document all features in docs.rs. 2021-01-07 15:00:13 -08:00
Daniel McArdle
13da180506 Optimize suffix building in FileTest::ReadNext().
Updating HPKE to draft-irtf-cfrg-hpke-07 added a number of tests to
crypto/hpke/hpke_test_vectors.txt. The time to run HPKE crypto tests
increased from 0.09 to 0.56 seconds (averaged over 6 runs). The runtime
for the whole crypto_test suite increased from 86.44 to 88.19 (measured
once).

Profiling revealed an excessive amount of CPU time (~50% for HPKE tests)
spent on std::map lookups in ReadNext(). I found a slow loop that
computes the suffix for a repeated attribute by hammering a std::map
with incremental guesses.

This CL adds a std::map<std::string, size_t> for counting repeated
attributes, eliminating the need for the loop. This reduces the runtime
for HPKE tests from 0.56 to 0.12 seconds (averaged over 6 runs). For the
whole crypto_test suite, runtime is reduced from 88.19 to 86.71
seconds (measured once).

Change-Id: Ie87f4a7f3edc95d434226d2959dcf09974f0656f
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/44905
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2021-01-07 22:59:08 +00:00
Adam Langley
5dd18d017d A handful more compatibility functions.
Change-Id: I814f55742910c519e9b64aca1b15a4d754adc541
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/44944
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2021-01-07 22:41:58 +00:00