9529 Commits

Author SHA1 Message Date
Brian Smith
9e863213d2 Ignore BoringSSL fdb48f9..777a239. 2019-07-02 09:56:37 -10:00
Brian Smith
0d97b47bc8 Add missing GFp_ prefix to GFp_bsaes_ctr32_encrypt_blocks.
The prefix was accidentally removed during a merge.
2019-07-02 09:54:51 -10:00
Brian Smith
0c21917a7f Merge BoringSSL d22578f: Adapt gcm_*_neon to aarch64. 2019-07-01 14:48:16 -10:00
Brian Smith
72c9ae0131 Ignore BoringSSL 4851041. 2019-07-01 14:46:08 -10:00
Brian Smith
bc92e6c313 Merge BoringSSL 885a63f: Patch out the aes_nohw fallback in bsaes_ctr32_encrypt_blocks. 2019-07-01 14:45:18 -10:00
Brian Smith
0097c88d6b Ignore BoringSSL aadcce3. 2019-07-01 14:43:51 -10:00
Brian Smith
d0f95b1a82 Take BoringSSL 35941f2: Make vpaes-armv8.pl compatible with XOM. 2019-07-01 14:39:32 -10:00
Brian Smith
d37abba0a8 Ignore BoringSSL f9c8d30..1d13453. 2019-07-01 14:38:51 -10:00
Brian Smith
91c4f538e0 Ignore BoringSSL b8d7b74. 2019-07-01 14:38:06 -10:00
Brian Smith
f6fe1b0b0b Ignore BoringSSL da8bb84. 2019-07-01 14:37:40 -10:00
Brian Smith
d1e9b5ba3a Take BoringSSL 8d685ec: modes/asm/ghash-armv4.pl: address "infixes are deprecated" warnings. 2019-07-01 14:35:41 -10:00
Brian Smith
a64a9f7377 Merge BoringSSL 55db667: Enable vpaes for aarch64, with CTR optimizations.
This doesn't enable VPAES for AAarch64 in *ring* though.
2019-07-01 14:35:01 -10:00
Brian Smith
8e658d8b89 Take BoringSSL b1b4ff9: Check in vpaes-armv8.pl from OpenSSL unused and unmodified. 2019-07-01 14:33:24 -10:00
Brian Smith
03b9d14d15 Remove array splitting from polyfill::convert.
Lifetime elision infers the wrong bounds. The code could be fixed by using
explicit lifetime annotations, but it's safer to just avoid the issue
altogether. The problem doesn't seem to affect any of the current code; the
problem was only noticed when trying to use the removed code for new uses.
2019-07-01 12:59:11 -10:00
Brian Smith
284619bc44 Use less unsafe in Block. 2019-07-01 12:59:11 -10:00
Brian Smith
a8d87207d9 Use explicit lifetime annotations when transmuting in Block.
The code seems to compile the same before and after this, but this seems
safer than relying on lifetime inference.
2019-07-01 12:58:09 -10:00
Brian Smith
3e814a4d18 Refactor SHA-1 implementation to be like the SHA-2 implementation. 2019-07-01 00:35:26 -10:00
Brian Smith
87728a783e Add Rust SHA-2 implementation. 2019-07-01 00:35:26 -10:00
Brian Smith
928f936c7b Move rsa::bigint to arithmetic/bigint. 2019-06-30 16:57:16 -10:00
Brian Smith
883379f789 Replace {TryFrom_, TryInto_} with now-stable standard versions. 2019-06-30 16:49:52 -10:00
Brian Smith
fd7d91814e Reverse order of limbs in limbs! macros & simplify implementations.
Have the `limbs!` macros accept the limbs least-significant-first to be consistent
with how they are represented in memory. This has the nice side effect of making
them much simpler.
2019-06-25 11:10:31 -10:00
Brian Smith
d041b730ce Do /dev/urandom fallback on Android too. 2019-06-18 11:50:57 -10:00
Brian Smith
ce56ab1be5 Put all Linux-specific ring::rand documentation together. 2019-06-17 19:49:46 -10:00
Brian Smith
3e6972ebb2 rand: Inline urandom implementation into sysrand_or_random. 2019-06-17 19:18:57 -10:00
Brian Smith
41a621cca2 Remove Redox support.
Nobody is using this and there is no CI coverage.
2019-06-17 19:16:14 -10:00
Brian Smith
b1b75a241f Replace GFp_block128_xor with Rust code. 2019-06-14 14:36:59 -10:00
Brian Smith
6960614893 Remove #includes <string.h> in Curve25519. 2019-06-14 13:48:57 -10:00
Brian Smith
0bab61cd23 Remove #include <string.h> in P-256 and P-384 code. 2019-06-14 13:48:57 -10:00
Brian Smith
a804615ed2 Bring back the ring::c internal C types module. 2019-06-14 09:26:38 -10:00
Brian Smith
8237fac8be Fix Android build. 2019-06-13 16:26:50 -10:00
Brian Smith
0382bfd9fd Document Android always uses getrandom(). 2019-06-13 16:26:50 -10:00
Brian Smith
702754d0c6 Remove obsolete comment in ring::rand about /dev/urandom. 2019-06-13 15:32:08 -10:00
Brian Smith
5e8a2f797a Remove dead code. 2019-06-13 15:32:08 -10:00
Brian Smith
680570f823 Temporarily disable armv7-linux-androideabi testing due to CI failures. 2019-06-13 10:26:26 -10:00
Brian Smith
7633902d7c Move ring::rand tests to tests/rand_tests.rs. 2019-06-13 10:01:06 -10:00
Brian Smith
626c64cf9c cargo fmt. 2019-06-13 09:57:15 -10:00
Brian Smith
db1b33584f Remove obsolete comment about importing ToOwned.
Even using Rust 1.35 the `use` is required.
2019-06-13 09:40:25 -10:00
Brian Smith
efb6ede3cc Limit dev_urandom_fallback to Linux. 2019-06-13 09:34:40 -10:00
Joe Richey
7b0f9ad021 Simplify core vs std usage 2019-06-13 08:51:09 -10:00
Brian Smith
fdc558da0f cargo +nightly fix && cargo fmt. 2019-06-13 08:40:58 -10:00
Steven Valdez
777a239175 Hold off flushing NewSessionTicket until write.
In TLS 1.3, if the client doesn't read from the server, the server might hang
from a filled buffer while waiting for the client to read. Instead we avoid
flushing the NewSessionTicket until there is a write from the server.

Update-Note: This delays the flushing of the NewSessionTicket until the first
write. Consumers may need to force an empty write to send the tickets if they
aren't writing any data to the client.

Change-Id: Iec92043567e9a68c0a250533b7745eddeeae2341
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/34948
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-04-23 19:16:23 +00:00
Adam Langley
7540cc2ec0 Predeclare enums in base.h
Including ssl.h is quite a chunk of code and #defines, so we've tried to
limit its spread internally in the interests of code hygine given that
we have a multi-billion-line repo.

However, header files that mention enums from ssl.h currently need to
include ssl.h. For example, your class may have static class member
functions intended to be callbacks, and they need to be class members
because they'll call other private methods.

C cannot predeclare enums, but C++ can if you explicitly type them.
Sadly C doesn't support explicit types. So option one is to move the
enums into base.h. That works, but the enums properly live in ssl.h and
reading the header file is a lot clearer if you don't have to jump
around to see all the pieces.

So option two (this change) is to explicitly type and predelcare the
enums in base.h for C++ only. The worry now is that C and C++ might
disagree about the type of the enums. However, this has already
happened: at least for |ssl_private_key_result_t|, g++ thinks that it's
an |int| (without any explicit type) and gcc thinks that it's an
|unsigned|. At least they're the same length, I guess?

So, to make sure that this doesn't slip any more, this change also adds
|ssl_test_c.c| which tests that C views the enums as having the same
size as an |int|, at least.

Change-Id: I8248583ec997021f8226d5a798609f6afc96dac4
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35664
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-04-22 21:49:12 +00:00
David Benjamin
c67076d653 Require certificates under name constraints use SANs.
The common name fallback does not interact well with name constraints.
Until we remove this fallback, we must resolve this conflict.

Blindly applying name constraints to the common name will reject
"decorative" common names that aren't intended to be hostnames (e.g.
[0]). We need to guess based on format whether the common name is a DNS
name. It is important this same check is applied to *both* name
constraints and name matching, which means the OpenSSL version (see
5bd5dcd49605ca2aa7931599894302a3ac4b0b04,
d02d80b2e80adfdde49f76cf7c7af4e013f45005, and
55a6250f1e7336e8a7d89fb609eb23398715ff6f) is unsuitable as a
compatibility data point.

In theory we could limit this to chains with name constraints, which are
uncommon, but X509_check_host sees only the leaf. We must apply it
uniformly. That means a strict check risks problems with malformed
non-WebPKI setups like [1].

For a first pass, mirror Go's behavior. Like Go, rather than run
SAN-less DNS-like common names through name constraints, we simply
reject all such certificates. Name constraints now exclude all leaf
certificates that can trigger the common name fallback. They are rare
enough that we can hopefully hold them to a higher standard.

Note this does not make misclassified decorative common names any worse,
compared to the checking the name constraint. Such names would not have
matched the constraint anyway.

Update-Note: This can may cause two kinds of errors:

1. Leaf certificates whose chain contains a name constraint and lack
   SANs may be rejected with X509_V_ERR_NAME_CONSTRAINTS_WITHOUT_SANS.

2. Leaf certificates which use the common name fallback and verify
   against an insufficiently DNS-looking hostname may fail with
   X509_V_ERR_HOSTNAME_MISMATCH.

In both cases, the fix is to include the subjectAltName in the
certificate, rather than rely on the common name fallback. (Refining the
heuristic is also an option, but the two failure modes pull it in
opposite directions, so this is tricky.)

[0] https://github.com/golang/go/issues/24151
[1] https://github.com/GoogleCloudPlatform/cloudsql-proxy/issues/194

Change-Id: If25557de428768292a14ba3bdeeffbd74e3a3bf8
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35665
Reviewed-by: Adam Langley <agl@google.com>
2019-04-22 21:32:29 +00:00
David Benjamin
e55c64fdd3 Make X509_verify_cert_error_string thread-safe.
If the error is unknown, we should not return a static buffer. See also
c0a445a9f279d8c4a519b58e52a50112f2341070 from upstream.

Change-Id: I23e1a3b9e29b34ab3dff41b8a58155683bbb9bd2
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35684
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-04-18 18:58:03 +00:00
David Benjamin
d86eb1bbb3 Disable the common name fallback on *any* SAN list.
This aligns with the Go crypto/x509 behavior and reduces the cases when
the SAN to CN fallback occurs. If the certificate is new enough to have
a SAN list, even if it only contains email or IP addresses, it is
reasonable to assume the certificate is new enough that the common name
is not a DNS name.

Update-Note: Our certificate verification is getting slightly stricter.
Change-Id: I9e3466d8dd8a722405c546181a589f797efa43f9
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35647
Reviewed-by: Adam Langley <agl@google.com>
2019-04-18 18:37:36 +00:00
David Benjamin
923feba608 Silently ignore X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT.
This flag is backwards. We want to check the common name less, not more. See if
anything was actually relying on this.

Update-Note: X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT is now ignored.
Change-Id: I8288d57540f8117059e58d72cc173aa4d3077fb6
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35646
Reviewed-by: Adam Langley <agl@google.com>
2019-04-18 18:36:46 +00:00
David Benjamin
c60b42bf7e Add X509_CHECK_FLAG_NEVER_CHECK_SUBJECT.
cryptography.io uses this and it's also the correct behavior. Ideally it would
be default, but start with just adding the flag. See also
dd60efea955e41a6f0926f93ec1503c6f83c4e58 from upstream.

Change-Id: I9e13cdbfd44c904ba5bd69a5a66c68c4b7596867
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35645
Reviewed-by: Adam Langley <agl@google.com>
2019-04-18 18:14:12 +00:00
David Benjamin
9df41ae953 Give ENGINE_free a return value.
This simplifies building against cryptography.io, which expects
ENGINE_free to return something.

Change-Id: Id1590abab7f47dae6b3a9d593fa7b0fe371c9912
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35644
Reviewed-by: Adam Langley <agl@google.com>
2019-04-17 20:57:57 +00:00
Adam Langley
c9827e073f Output a ClientHello during handoff.
This will allow edge servers to pass judgement on the ClientHello before
completing the handoff process. This also means that edge servers will
now enforce ClientHello well-formedness — previously that check didn't
occur until the handshaker tried to parse the handoff submission.

Change-Id: I9804ac0224632b4b4381c1a81f434d188e0b9376
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35584
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-04-15 22:29:15 +00:00
David Benjamin
2e26348e25 Fix and test EVP_PKEY_CTX copying.
The RSA-PSS salt length was not being copied, and copying an Ed25519
EVP_MD_CTX did not work.

This is rather pointless (an EVP_PKEY_CTX is just a bundle of
parameters), and it's unlikely anyone ever will use this. But since
OpenSSL's EVP_PKEY signing API reuses EVP_MD_CTX and EVP_MD_CTX_copy_ex
is plausible in that scenario, we're stuck making EVP_MD_CTX_copy_ex
reachable for EVP_PKEY too. That then implies EVP_PKEY_dup should exist,
and if it exists we should be testing it.

Change-Id: I189435d0c716a83f58e1d8ac4abc2c409ecfea64
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35626
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-04-15 22:22:35 +00:00