3099 Commits

Author SHA1 Message Date
Brian Smith
61b234ef94 Add GCC 4.6 to Travis CI matrix.
GCC 4.6 is the default compiler on Ubuntu 12.04 LTS and other LTS
distros so it isn't a complete waste of time to support it. Luckily, it
is easy to do so.
2016-01-31 20:04:13 -10:00
Brian Smith
e191da43ff Remove C++11isms not supported by GCC 4.6. 2016-01-31 19:30:55 -10:00
Brian Smith
5d77c02b5f Use __extension__ instead of pragmas to avoid pedantic warnings.
GCC 4.6 doesn't support `#pragma GCC diagnostic ignored "-Wpedantic"`
and `__extension` is a better workaround anyway.
2016-01-31 19:30:55 -10:00
Brian Smith
a8d8d48bb0 Work around the lack of <stdalign.h> in GCC 4.6. 2016-01-31 19:30:54 -10:00
Brian Smith
4e8ebc3a69 Use -std=c1x and -std=c++0x to be compatible with GCC 4.6.
Later versions of GCC and Clang treat these as being equivalent to
`-std=c11` and `-std=c++11`, respectively. GCC 4.6 doesn't understand
the latter form, unfortunately.
2016-01-31 19:30:54 -10:00
Brian Smith
6d521815c8 Build with -pedantic-errors. 2016-01-31 19:30:53 -10:00
Brian Smith
9e3bdaa096 Add throw() to functions in malloc.cc to avoid -pedantic errors. 2016-01-31 19:30:53 -10:00
Brian Smith
2b319449f4 Remove data <-> function pointer casts in thread_test.c.
Avoid undefined behavior by avoiding data <-> function pointer casts.
Moves the code base a step closer to enabling |-Wpedantic|.
2016-01-31 19:30:52 -10:00
Brian Smith
c87120d5fd Add comment about linker selection hack in travis.sh. 2016-01-31 19:30:52 -10:00
Brian Smith
2c9a84c637 Drop i686-apple-darwin support.
It doesn't make sense to support this configuration given that nobody
has 32-bit Macs any more.
2016-01-31 19:30:13 -10:00
Brian Smith
cc774e257d Adjust i64/u64 alignment test workaround.
GCC reports either 4 or 8 for `alignof(uint64_t)` depending on the
version, so adjust the test so that they all work by being liberal with
whichever value the C compiler uses.
2016-01-31 14:12:21 -10:00
Brian Smith
8d7378dee1 Use $CC_X instead of cc as the linker on Travis CI. 2016-01-30 23:02:35 -10:00
Brian Smith
1ac1375e10 Install i686 version of rust-std on Travis for i686 builds.
This is based on the the script named "test" from
https://github.com/carllerche/travis-rust-matrix commit
de565ce5afe1a4cb1e6311f9c08b5ebeda3e7eb1.
2016-01-30 17:29:53 -10:00
Brian Smith
542b03b5d3 Tempoarily disable doctests to fix cross-compilation. 2016-01-30 17:29:52 -10:00
Brian Smith
6119830d5f Fix ring::c tests for 64-bit integer alignment.
Rust's core::mem::align_of<i64> and core::mem::align_of<u64> are 4
for i686-apple-darwin and i686-unknown-linux-gnu, but the C compiler
returns 8 for them. And, surprisingly, neither of them is 100% wrong.
2016-01-30 17:29:51 -10:00
Brian Smith
cf94f69d5e Remove P-224 & P-521 curves. Fix cross-compilation.
`#[cfg(target_pointer_width)]` in a build script is the host pointer
width, not the end-target pointer width, because during the build of
the build script, the target is the host. Due to this confusion, the
calculation of the constants for P-224 was wrong when the
`sizeof(BN_ULONG)` on the host did not match `sizeof(BN_ULONG)`. To
solve this, limit the curves we support to P-256 and P-384, where
`sizeof(BN_ULONG)` doesn't affect the calculations.
2016-01-30 17:29:51 -10:00
Brian Smith
5ffa2435b5 Fix ABI mismatch in ring::c size/alignment tests.
These tests worked fine (somehow) in 64-bit builds and on Windows but
they didn't work on 32-bit Linux or 32-bit Mac OS X builds due to the
`ring_X_align` and `ring_X_size` functions having the wrong return type
in the C code.
2016-01-30 17:19:04 -10:00
Brian Smith
866f2b6c18 Restore wrongly-removed brace in crypto/aes/asm/aesni-x86.pl.
Commit 663ab65689cd48495e4b985d4bf45b413939ec74 accidentally removed
this.
2016-01-30 17:18:49 -10:00
David Benjamin
72f7e21087 Stop allowing SHA-224 in TLS 1.2.
Take the mappings for MD5 and SHA-224 values out of the code altogether. This
aligns with the current TLS 1.3 draft.

For MD5, this is a no-op. It is not currently possible to configure accepted
signature algorithms, MD5 wasn't in the hardcoded list, and we already had a
test ensuring we enforced our preferences correctly. MD5 also wasn't in the
default list of hashes our keys could sign and no one overrides it with a
different hash.

For SHA-224, this is not quite a no-op. The hardcoded accepted signature
algorithms list included SHA-224, so this will break servers relying on that.
However, Chrome's metrics have zero data points of servers picking SHA-224 and
no other major browser includes it. Thus that should be safe.

SHA-224 was also in the default list of hashes we are willing to sign. For
client certificates, Chromium's abstractions already did not allow signing
SHA-224, so this is a no-op there. For servers, this will break any clients
which only accept SHA-224. But no major browsers do this and I am not aware of
any client implementation which does such ridiculous thing.

(SHA-1's still in there. Getting rid of that one is going to take more effort.)

Change-Id: I6a765fdeea9e19348e409d58a0eac770b318e599
Reviewed-on: https://boringssl-review.googlesource.com/7020
Reviewed-by: Adam Langley <agl@google.com>
2016-01-29 21:30:00 +00:00
Brian Smith
5fa8f5bc9a Fix |-Werror=old-style-declaration| violations in poly1305_vec.c.
The |inline| must appear before the type.

Change-Id: Iecebbcc50024a846d7804228a858acfc33d68efd
Reviewed-on: https://boringssl-review.googlesource.com/7010
Reviewed-by: David Benjamin <davidben@google.com>
2016-01-28 23:58:45 +00:00
David Benjamin
2cdf398773 Remove pkey_base_id.
This is never accessed.

Change-Id: I4cade5e907ad4c03e9de7634b53ef965f7240087
Reviewed-on: https://boringssl-review.googlesource.com/6864
Reviewed-by: Adam Langley <agl@google.com>
2016-01-28 15:55:24 +00:00
Brian Smith
aae3738861 Actually build/test 32-bit configurations in Travis CI.
$TARGET_X was being ignored by mk/travis.sh, and the target strings
were wrong.
2016-01-27 23:22:57 -10:00
Brian Smith
1d12309195 Take BoringSSL 647cd02: Fix 32-bit build. 2016-01-27 23:22:45 -10:00
Brian Smith
9f5d5b351e Fix |-Werror=old-style-declaration| violations in poly1305_vec.c.
The |inline| must appear before the type.
2016-01-27 23:12:41 -10:00
Brian Smith
2c0624e821 Ignore BoringSSL 8f2d4e3 and b04c905.
This is code that has already been removed in *ring*.
2016-01-27 21:57:53 -10:00
Brian Smith
5cba2ec298 Take BoringSSL 87c7640: Use |inline| in crypto/poly1305/poly1305_vec.c. 2016-01-27 21:57:24 -10:00
Brian Smith
4bd46a8221 Merge BoringSSL 24e4288: Define int128_t and uint128_t in one place. 2016-01-27 21:57:06 -10:00
Brian Smith
ac79b8be4e Take BoringSSL f547007: Use |alignas| more in crypto/chacha/chacha_vec.c. 2016-01-27 21:55:42 -10:00
Brian Smith
9c2be3985c Merge BoringSSL 9333d6d: Fix data <-> function pointer casts in thread_win.c. 2016-01-27 21:55:20 -10:00
Brian Smith
82d88fb640 Take BoringSSL f5f4be8: Fix pointer-to-non-volatile cast in thread_win.c. 2016-01-27 21:54:56 -10:00
Brian Smith
6452e530f0 Ignore BoringSSL 54a8d7c.
This code has already been removed in *ring*.
2016-01-27 21:54:31 -10:00
Brian Smith
608bc710ee Ignore BoringSSL 75a64c0..91b2501.
These changes are all either modifying code that has already been
removed in *ring*, or adding compatibility functionality that *ring*
doesn't need.
2016-01-27 21:53:11 -10:00
Brian Smith
bccbeb28d7 Merge BoringSSL 7cae9f5: Use |alignas| for alignment.
This is the BoringSSL version of *ring*'s
f111a76b8db2ab2ebf698d709933aa877591b3cd. The only difference is that
one statement is above a comment instead of below it.
2016-01-27 21:51:07 -10:00
Brian Smith
bbfe2e7d6b Take BoringSSL 34749f4: Remove unnecessary assignment of |e| in |rsa_setup_blinding|. 2016-01-27 21:45:07 -10:00
Brian Smith
44a4d83a71 Ignore BoringSSL 95219fe..232127d.
These are all changes to code that has been removed in *ring*.
2016-01-27 21:44:29 -10:00
Brian Smith
e80080ed73 No-op merge of BoringSSL d3a4e28.
This is the BoringSSL version of *ring*'s
4e7d5e348364cf31e08c525971f9bdb1f14cde7f.
crypto/modes/ctr.c has already been remoed in *ring*, and that was
the only difference.
2016-01-27 21:41:45 -10:00
Brian Smith
dbae642b1e Ignore BoringSSL 0687bdf..a646258.
These are all changes to code that has been removed in *ring*. *ring*'s
build system already enables -Wformat=2.
2016-01-27 21:40:32 -10:00
Brian Smith
c296c26d65 Ignore BoringSSL 6288218..6c22f54.
These are all changes to code that has been removed in *ring*.
2016-01-27 21:39:28 -10:00
Brian Smith
4d464719de Take BoringSSL b8ba65a: Fix arm perlasm trailing newline. 2016-01-27 21:34:45 -10:00
Brian Smith
27d2a958e4 Ignore BoringSSL 0b553eb: Remove a trailing ^M (DOS newline).
This code has been moved/removed in *ring*.
2016-01-27 21:34:12 -10:00
Brian Smith
a5573d0b32 Ignore BoringSSL ef1b009..b9e4fa5.
These are all changes to libssl, which has already been removed in
*ring*.
2016-01-27 21:33:32 -10:00
Brian Smith
1e8da5b799 Take BoringSSL dd1f6f4: Rename the curve25519 precomputed tables. 2016-01-27 21:31:21 -10:00
Brian Smith
18b883cd21 Ignore BoringSSL e021a24.
util/generate_build_files.py was removed in *ring*.
2016-01-27 19:17:22 -10:00
Brian Smith
1eb4fbe21b Merge BoringSSL 625475f: Fix bits vs. bytes confusion in RSA encryption. 2016-01-27 19:14:40 -10:00
David Benjamin
415564fe2c Update draft-irtf-cfrg-curves-11 references to RFC 7748.
Change-Id: I6148df93a1748754ee6be9e2b98cc8afd38746cb
Reviewed-on: https://boringssl-review.googlesource.com/6960
Reviewed-by: Adam Langley <alangley@gmail.com>
2016-01-28 00:53:26 +00:00
David Benjamin
4f6acaf0da Use more C++11 features.
Finally, we can stick ScopedFOO in containers.

Change-Id: I3ed166575822af9f182e8be8f4db723e1f08ea31
Reviewed-on: https://boringssl-review.googlesource.com/6553
Reviewed-by: Adam Langley <alangley@gmail.com>
2016-01-28 00:52:37 +00:00
David Benjamin
c3774c1187 Fix some indentation.
Change-Id: I3507be754b489a99a04c0dea888cb1f3652e68c3
Reviewed-on: https://boringssl-review.googlesource.com/6854
Reviewed-by: Adam Langley <alangley@gmail.com>
2016-01-28 00:51:45 +00:00
David Benjamin
0a2c9938a5 Don't allow the specifiedCurve form of ECParameters in SPKIs.
Although RFC 3279 allows both, per RFC 5912, keys must use a named curve
rather than spelling out the curve parameters. Although we do not allow
arbitrary curves, we do have to (pretty hackishly) recognize built-in
curves in ECPrivateKeys.

It seems the cause of this was that OpenSSL, unless you set asn1_flag on
the EC_GROUP, likes to encode keys by spelling out the parameters. This
is in violation of RFC 5915, though probably not in violation of one of
the other redundant ECC specifications. For more fun, it appears
asn1_flag defaults to *off* in the API and *on* in the command-line
tools.

I think the original cause was these defaults meant the pre-BoringSSL
Android/OpenSSL Chromium port wrote out Channel ID keys in this format.
By now this should no longer by an issue, but it'll warrant a bit more
investigation to be sure we can drop it.

For now, keep this logic out of SPKIs by not calling d2i_ECParameters.
d2i_ECParameters is a fairly pointless function when only named curves
are allowed. In testing other implementations, none of Firefox, Safari,
or IE11/Win will parse such certificates (i.e. the error is fatal and
unbypassable). Likewise, because Mac and Windows' underlying libraries
reject this, Chrome on Mac and Windows already rejects such things. Thus
this change should be compatible.

The following is the certificate and key I constructed to test with:

-----BEGIN CERTIFICATE-----
MIICwjCCAmqgAwIBAgIJANlMBNpJfb/rMAkGByqGSM49BAEwRTELMAkGA1UEBhMC
QVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0IFdpZGdp
dHMgUHR5IEx0ZDAeFw0xNDA0MjMyMzIxNTdaFw0xNDA1MjMyMzIxNTdaMEUxCzAJ
BgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5l
dCBXaWRnaXRzIFB0eSBMdGQwggFLMIIBAwYHKoZIzj0CATCB9wIBATAsBgcqhkjO
PQEBAiEA/////wAAAAEAAAAAAAAAAAAAAAD///////////////8wWwQg/////wAA
AAEAAAAAAAAAAAAAAAD///////////////wEIFrGNdiqOpPns+u9VXaYhrxlHQaw
zFOw9jvOPD4n0mBLAxUAxJ02CIbnBJNqZnjhE50mt4GffpAEQQRrF9Hy4SxCR/i8
5uVjpEDydwN9gS3rM6D0oTlF2JjClk/jQuL+Gn+bjufrSnwPnhYrzjNXazFezsu2
QGg3v1H1AiEA/////wAAAAD//////////7zm+q2nF56E87nKwvxjJVECAQEDQgAE
5itp4r9ln5e+Lx4NlIpM1Zdrt6keDUb73ampHp3culoB59aXqAoY+cPEox5W4nyD
SNsWGhz1HX7xlC1Lz3IiwaNQME4wHQYDVR0OBBYEFKuE0qyrlfCCThZ4B1VXX+Qm
jYLRMB8GA1UdIwQYMBaAFKuE0qyrlfCCThZ4B1VXX+QmjYLRMAwGA1UdEwQFMAMB
Af8wCQYHKoZIzj0EAQNHADBEAiBATB6aVJxDD6YAxEM4vf6Sbg2Ty334ldXpkNwc
TF+SngIgZ/f59kgDLf6YA04iLw1fUv5Wf1nLYJWwgrRFON5+zvw=
-----END CERTIFICATE-----
-----BEGIN EC PARAMETERS-----
MIH3AgEBMCwGByqGSM49AQECIQD/////AAAAAQAAAAAAAAAAAAAAAP//////////
/////zBbBCD/////AAAAAQAAAAAAAAAAAAAAAP///////////////AQgWsY12Ko6
k+ez671VdpiGvGUdBrDMU7D2O848PifSYEsDFQDEnTYIhucEk2pmeOETnSa3gZ9+
kARBBGsX0fLhLEJH+Lzm5WOkQPJ3A32BLeszoPShOUXYmMKWT+NC4v4af5uO5+tK
fA+eFivOM1drMV7Oy7ZAaDe/UfUCIQD/////AAAAAP//////////vOb6racXnoTz
ucrC/GMlUQIBAQ==
-----END EC PARAMETERS-----
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIAcPCHJ61KBKnN1ZyU2JaHcItW/JXTB3DujRyc4Ki7RqoAoGCCqGSM49
AwEHoUQDQgAE5itp4r9ln5e+Lx4NlIpM1Zdrt6keDUb73ampHp3culoB59aXqAoY
+cPEox5W4nyDSNsWGhz1HX7xlC1Lz3IiwQ==
-----END EC PRIVATE KEY-----

BUG=522228

Change-Id: I3723411a633dc07c4640027de07500293f8f7913
Reviewed-on: https://boringssl-review.googlesource.com/6853
Reviewed-by: Adam Langley <alangley@gmail.com>
2016-01-28 00:51:14 +00:00
David Benjamin
f6094e05ef Don't allow EVP_PKEY_RSA2.
OpenSSL accepts both OID 2.5.8.1.1 and OID 1.2.840.113549.1.1.1 for RSA
public keys. The latter comes from RFC 3279 and is widely implemented.
The former comes from the ITU-T version of X.509. Interestingly,
2.5.8.1.1 actually has a parameter, which OpenSSL ignores:

  rsa ALGORITHM ::= {
     KeySize
     IDENTIFIED BY id-ea-rsa
  }
  KeySize ::= INTEGER

Remove support for 2.5.8.1.1 completely. In tests with a self-signed
certificate and code inspection:

- IE11 on Win8 does not accept the certificate in a TLS handshake at
  all. Such a certificate is fatal and unbypassable. However Microsoft's
  libraries do seem to parse it, so Chrome on Windows allows one to
  click through the error. I'm guessing either the X.509 stack accepts
  it while the TLS stack doesn't recognize it as RSA or the X.509 stack
  is able to lightly parse it but not actually understand the key. (The
  system certificate UI didn't display it as an RSA key, so probably the
  latter?)

- Apple's certificate library on 10.11.2 does not parse the certificate
  at all. Both Safari and Chrome on Mac treat it as a fatal and
  unbypassable error.

- mozilla::pkix, from code inspection, does not accept such
  certificates. However, Firefox does allow clicking through the error.
  This is likely a consequence of mozilla::pkix and NSS having different
  ASN.1 stacks. I did not test this, but I expect this means Chrome on
  Linux also accepts it.

Given IE and Safari's results, it should be safe to simply remove this.
Firefox's data point is weak (perhaps someone is relying on being able
to click-through a self-signed 2.5.8.1.1 certificate), but it does
further ensure no valid certificate could be doing this.

The following is the 2.5.8.1.1 certificate I constructed to test with.
The private key is key.pem from ssl/test/runner:

-----BEGIN CERTIFICATE-----
MIICVTCCAb6gAwIBAgIJAPuwTC6rEJsMMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV
BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX
aWRnaXRzIFB0eSBMdGQwHhcNMTQwNDIzMjA1MDQwWhcNMTcwNDIyMjA1MDQwWjBF
MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50
ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIGcMAoGBFUIAQECAgQAA4GNADCBiQKBgQDY
K8imMuRi/03z0K1Zi0WnvfFHvwlYeyK9Na6XJYaUoIDAtB92kWdGMdAQhLciHnAj
kXLI6W15OoV3gA/ElRZ1xUpxTMhjP6PyY5wqT5r6y8FxbiiFKKAnHmUcrgfVW28t
Q+0rkLGMryRtrukXOgXBv7gcrmU7G1jC2a7WqmeI8QIDAQABo1AwTjAdBgNVHQ4E
FgQUi3XVrMsIvg4fZbf6Vr5sp3Xaha8wHwYDVR0jBBgwFoAUi3XVrMsIvg4fZbf6
Vr5sp3Xaha8wDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQAIZuUICtYv
w3cbpCGX6HNCtyI0guOfbytcdwzRkQaCsYNSDrTxrSSWxHwqg3Dl/RlvS+T3Yaua
Xkioadstwt7GDP6MwpIpdbjchh0XZd3kjdJWqXSvihUDpRePNjNS2LmJW8GWfB3c
F6UVyNK+wcApRY+goREIhyYupAHUexR7FQ==
-----END CERTIFICATE-----

BUG=522228

Change-Id: I031d03c0f53a16cbc749c4a5d8be6efca50dc863
Reviewed-on: https://boringssl-review.googlesource.com/6852
Reviewed-by: Adam Langley <alangley@gmail.com>
2016-01-28 00:43:37 +00:00
David Benjamin
c612e61e1d Fix minor stylistic problem.
Normally this would be pretty scary:
  if (...) {
  } if (...) {
  }
But it's an early return anyway.

Change-Id: I0a8965b5e294d3aaa803be47f4006ea0311c431d
Reviewed-on: https://boringssl-review.googlesource.com/6851
Reviewed-by: Adam Langley <alangley@gmail.com>
2016-01-28 00:35:35 +00:00