Commit Graph

304 Commits

Author SHA1 Message Date
Piotr Sikora
1d8adf18d2 Fix CPU architecture detection on BSDs.
CMake calls "uname" in order to detect the CPU architecture,
so $(CMAKE_SYSTEM_PROCESSOR) varies from platform to platform.

This changes adds support for "i386" and "amd64" values, which
are used by BSDs for the x86 family of CPUs.

Change-Id: I532ce787a9ac06220c92a6d8c78ad5a55d8c40bf
Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
Reviewed-on: https://boringssl-review.googlesource.com/1360
Reviewed-by: Adam Langley <agl@google.com>
2014-07-31 18:54:51 +00:00
Adam Langley
ad1907fe73 Use asm directives to protect OPENSSL_cleanse.
Compilers have a bad habit of removing "superfluous" memset calls that
are trying to zero memory. For example, when memset()ing a buffer and
then free()ing it, the compiler might decide that the memset is
unobservable and thus can be removed.

Previously we tried to stop this by a) implementing memset in assembly
on x86 and b) putting the function in its own file for other platforms.

This change removes those tricks in favour of using asm directives to
scare the compiler away. As best as our compiler folks can tell, this is
sufficient and will continue to be so.

Change-Id: I40e0a62c3043038bafd8c63a91814a75a3c59269
Reviewed-on: https://boringssl-review.googlesource.com/1339
Reviewed-by: David Benjamin <davidben@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2014-07-31 18:49:22 +00:00
Adam Langley
22bb031c43 Don't mark AES_set_{en|de}crypt_key arg as const.
Windows complains when the declaration of a function doesn't match the
definition. In this case, the |bits| argument (not a pointer, just an
unsigned) was marked as const in the definition only.

Normally const isn't used for non-pointer arguments so I've removed it
in this case to make Windows compile.

https://code.google.com/p/chromium/issues/detail?id=398960

Change-Id: If7386cf61f9dfbf6b32bfada1a49d5742fe94396
Reviewed-on: https://boringssl-review.googlesource.com/1338
Reviewed-by: Adam Langley <agl@google.com>
2014-07-30 18:19:02 +00:00
Adam Langley
a3d21e2101 Fix copy in AES-KW.
The AES-KW code from 93a3dcd572 would
write 8 bytes past the end of the out buffer.

https://code.google.com/p/chromium/issues/detail?id=398699

Change-Id: I6e1a2884790f69cdbefb59ed60d71459b7327b89
2014-07-29 19:44:50 -07:00
David Benjamin
44dbcc0804 Remove SSL_get_client_certificate_types.
Chromium is no longer using it.

Change-Id: If56340627d2024ff3fb8561405dd0cfc6f4787cb
Reviewed-on: https://boringssl-review.googlesource.com/1346
Reviewed-by: Adam Langley <agl@google.com>
2014-07-30 00:44:16 +00:00
David Benjamin
7bbeead507 A bunch of dead assignments.
Caught by clang scan-build.

Change-Id: I4f10c879dc137d4a14a7a395764d28e5caa033ff
Reviewed-on: https://boringssl-review.googlesource.com/1342
Reviewed-by: Adam Langley <agl@google.com>
2014-07-30 00:44:03 +00:00
David Benjamin
072c953f40 Convert some malloc + memcpys into BUF_memdup.
Slightly tidier.

Change-Id: Ib3cb4dc262c88087bd56b446a6f7a05d1e57ade6
Reviewed-on: https://boringssl-review.googlesource.com/1345
Reviewed-by: Adam Langley <agl@google.com>
2014-07-30 00:42:40 +00:00
David Benjamin
9a37359008 Don't malloc(0) on empty extensions list.
Caught by clang scan-build.

Change-Id: I29092d659f1ac21c6a74b925f6abc0283e7652fc
Reviewed-on: https://boringssl-review.googlesource.com/1344
Reviewed-by: Adam Langley <agl@google.com>
2014-07-30 00:35:38 +00:00
David Benjamin
61b66ffcc2 Fix error-handling bugs.
Caught by clang scan-build.

Change-Id: I133d0338fe38172d687c02099d909366a59ee95b
Reviewed-on: https://boringssl-review.googlesource.com/1343
Reviewed-by: Adam Langley <agl@google.com>
2014-07-30 00:34:55 +00:00
David Benjamin
59b3a728dc Fix some DTLS alerts.
Caught by clang scan-build.

Change-Id: Ib17368557d3e8b2edac91e0441e64c21a5eb1318
Reviewed-on: https://boringssl-review.googlesource.com/1341
Reviewed-by: Adam Langley <agl@google.com>
2014-07-30 00:34:23 +00:00
David Benjamin
b70da6a246 Fix mis-sized allocation in x509_vpm.c
Caught by clang scan-build. (The allocation was larger than it should have
been.)

Change-Id: Ideb800118f65aaba1ee85b7611c8a705671025a8
Reviewed-on: https://boringssl-review.googlesource.com/1340
Reviewed-by: Adam Langley <agl@google.com>
2014-07-30 00:33:49 +00:00
Adam Langley
5129e2d695 Align EVP return values with BoringSSL convention.
Where possible, functions should return one for success and zero for
error. The use of additional negative values to indicate an error is,
itself, error prone.

This change fixes many EVP functions to remove the possibility of
negative return values. Existing code that is testing for <= 0 will
continue to function, although there is the possibility that some code
was differentiating between negative values (error) and zero (invalid
signature) for the verify functions and will now show the wrong error
message.

Change-Id: I982512596bb18a82df65861394dbd7487783bd3d
Reviewed-on: https://boringssl-review.googlesource.com/1333
Reviewed-by: Adam Langley <agl@google.com>
2014-07-29 21:47:51 +00:00
Adam Langley
d82d79dffe "EC_POINT_invert" was checking "dbl" function pointer instead of "invert".
PR#2569

(Imported from upstream's 4ccc2c19e299741c8e0a8678a13f40e032709e9c)

Change-Id: Id6f5181ea99401145d7b3c4074b292cae8a1c660
2014-07-28 17:05:14 -07:00
Adam Langley
482b4f189f Fix DTLS certificate requesting code.
Use same logic when determining when to expect a client certificate for
both TLS and DTLS.

PR#3452

(Imported from upstream's 666a597ffb9bcf3ba2d49e711fcca28df91eff9d)

Change-Id: Ia267255a32c0b3b9a7da1c53f13ef6f620ff5ec1
2014-07-28 17:05:14 -07:00
Adam Langley
4b5979b3fa x86_64 assembly pack: improve masm support.
(Imported from upstream's 371feee876dd8b58531cb6e50fe79262db8e4ed7)

Change-Id: Id3b5ece6b5e5f0565060d5e598ea265d64dac9df
2014-07-28 17:05:13 -07:00
Adam Langley
c82087b31f Prevent infinite loop loading config files.
PR#2985

(Imported from upstream's 2cb761c1f4e0155743f4414932b5cff167389cf4)

Change-Id: I3e4f3c0c558dd2e1cc5ed2df1651834018627342
2014-07-28 17:05:13 -07:00
Adam Langley
887b1c3d49 Don't limit message sizes in ssl3_get_cert_verify.
PR#319 (reoponed version).

(Imported from upstream's 8358302d47c8b6e0680d91ffee11302331f17a69)

Change-Id: I222c454620ab445d4906ee2c2b6a9ad80e56018e
2014-07-28 17:05:13 -07:00
Adam Langley
43dca4d8bb fix x86_64-specific crash with one-word modulus.
PR: #3397

(Imported from upstream's 47b9e06cfd3a4fa89a690309e5839ed57e93f0f8)

Change-Id: I92d46a3132233c179f4b708d506bfb7212c26a33
2014-07-28 17:05:13 -07:00
Adam Langley
e3142a788c Make disabling last cipher work.
(Imported from upstream's 8f243ab6c173096943ca079648d240eba1e46dd3)

Change-Id: I929e481842c489aa28f28cf066b4556160a23efe
2014-07-28 17:05:13 -07:00
Adam Langley
e532f823d6 ASN1 sanity check.
Primitive encodings shouldn't use indefinite length constructed form.

PR#2438 (partial).

(Imported from upstream's 9223a31eb72dc46085ce97736c119c541973511e)

Change-Id: I832d0bcda491c03c799b7b70184a1a3ec16b1592
2014-07-28 17:05:13 -07:00
Adam Langley
d33cbb583e sha512-x86_64.pl: fix linking problem under Windows.
(Imported from upstream's daa96141d31dbe6a6fadc6afc7cf9d1284d9bdd8)

Change-Id: Ibc55db0909585c6472b92af519ffbe717b79c90c
2014-07-28 17:05:13 -07:00
Adam Langley
7578f3f0de Make EVP_CIPHER_CTX_copy work in GCM mode.
PR#3272

(Imported from upstream's 14183e50e75f54c44df6be69670180860ac19550 and
802fdcda1ebc4241a8e02af0046ba2f5264f71f6)

Change-Id: Ied6183d938e320f953a18f6616890d88b74def3f
2014-07-28 17:05:13 -07:00
Adam Langley
3e14885558 Fix memory leak.
PR#2531

(Imported from upstream's 15de0f609c859883347357aaf6cc685c797358bd)

Change-Id: I4ee3a5ce22ee047a8eaa2c74f26971109a23680c
2014-07-28 17:05:13 -07:00
Adam Langley
46cfb0e4ee Remove redundant check.
PR#3174

(Imported from upstream's ec77f276e14f4b835cdd42fa175d74dcda532663)

Change-Id: I7e33d67c201bdd088520d060cc8e4e9713223e69
2014-07-28 17:05:13 -07:00
Adam Langley
2811da2eca x86_64 assembly pack: allow clang to compile AVX code.
(Imported from upstream's 912f08dd5ed4f68fb275f3b2db828349fcffba14,
52f856526c46ee80ef4c8c37844f084423a3eff7 and
377551b9c4e12aa7846f4d80cf3604f2e396c964)

Change-Id: Ic2bf93371f6d246818729810e7a45b3f0021845a
2014-07-28 17:05:13 -07:00
Adam Langley
b351d83875 bn/asm/rsaz-avx2.pl: fix occasional failures.
(Imported from upstream's 1067663d852435b1adff32ec01e9b8e54d2b5896)

Change-Id: I39e2a24176306f4170449145d3dee2c2edbf6dfe
2014-07-28 17:05:12 -07:00
Adam Langley
9036c26612 Tolerate critical AKID in CRLs.
PR#3014

(Imported from upstream's 22228d2d407763d234a2463f694df77dca8158fc)

Change-Id: I23ee7dd6b295c3141fe3f5897673dd932831a4f6
2014-07-28 17:05:12 -07:00
Adam Langley
29b6292841 Fix OID encoding for one component.
OIDs with one component don't have an encoding.

PR#2556 (Bug#1)

(Imported from upstream's ff4cfc4c588c41d5e8d2d530231bc36cbc525add and
65e4dca40cb15f3acc878e26d734ec93bd367dca)

Change-Id: I55b54f23e891abc2c1e0b2976531fba1f16070bb
2014-07-28 17:05:12 -07:00
Adam Langley
7893c008e6 Memory leak and NULL dereference fixes.
PR#3403

(Imported from upstream's e42c208235a86beee16ff0d0e6ca4e164a57d21a)

Change-Id: Ibcdd8c95604f661055bfb1e91b15fd3686a04c0d
2014-07-28 17:05:12 -07:00
Adam Langley
ac71c09529 Make sure BN_sqr can never return a negative value.
PR#3410

(Imported from upstream's b7a4f98b152e5b9a56da1501e73053d83a9799b6)

Change-Id: I382c12f205d9adbd418574f7938a1d55a07128e4
2014-07-28 17:05:12 -07:00
Adam Langley
25ba90e34a move check for AD*X to rsaz-avx2.pl.
This ensures high performance is situations when assembler supports
AVX2, but not AD*X.

(Imported from upstream's 82a9dafe32e1e39b5adff18f9061e43d8df3d3c5)

Change-Id: Ie67f49a1c5467807139b6a8a0d4e62162d8a974f
2014-07-28 17:05:12 -07:00
Adam Langley
05b7377065 Add RSA_check_key function.
This is function that is available in OpenSSL too. Here it only returns
zero or one and doesn't do expensive primality checks on p and q.

https://code.google.com/p/chromium/issues/detail?id=396250

Change-Id: I7a173da26e06440dbb595fb717e3a620edf23576
Reviewed-on: https://boringssl-review.googlesource.com/1334
Reviewed-by: Adam Langley <agl@google.com>
2014-07-28 21:36:57 +00:00
Adam Langley
93a3dcd572 Add AES Key Wrap mode.
This is needed in order to support Web Crypto.

https://code.google.com/p/chromium/issues/detail?id=396407

Change-Id: I900d8cad2716c2e3341eeae153659502326c9173
Reviewed-on: https://boringssl-review.googlesource.com/1335
Reviewed-by: Adam Langley <agl@google.com>
2014-07-28 21:32:39 +00:00
David Benjamin
7e3305eebd Fix False Start without session tickets.
One of the state transitions wasn't rewritten to CR_CHANGE. Add a test to
exercise this codepath. Also SSL_cutthrough_complete references the state.

Change-Id: Ib2f7ac5ac3f0348864efa93cf13cfd87454572f0
Reviewed-on: https://boringssl-review.googlesource.com/1337
Reviewed-by: Adam Langley <agl@google.com>
2014-07-28 20:31:56 +00:00
Piotr Sikora
c3e431762a Add OpenSSL-compatible alias for ERR_FLAG_STRING flag.
A lot of applications use ERR_TXT_STRING flag in order to determine
whether the error string is printable or not.

Change-Id: Ic79cdb55d43fdfac48da5de5e18c0c9c03c8f747
Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
Reviewed-on: https://boringssl-review.googlesource.com/1192
Reviewed-by: Adam Langley <agl@google.com>
2014-07-28 19:00:28 +00:00
Piotr Sikora
987b8f1e71 Add <opensslfeatures.h> to ease migration from OpenSSL.
The <opensslfeatures.h> header provides #defines which are normally
declared by OpenSSL when features are disabled.

This way applications are able to detect which features were removed
from BoringSSL and use it as drop-in replacement for OpenSSL.

Inspired by LibreSSL, which provides similar header.

Change-Id: If4352743fd938267e2640fb09ca851464b9240b9
Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
Reviewed-on: https://boringssl-review.googlesource.com/1191
Reviewed-by: Adam Langley <agl@google.com>
2014-07-28 18:51:33 +00:00
Piotr Sikora
108300573f Hook ssl_stat.c into build.
Change-Id: I049b2ed1b83e38375ddb658abf588a8e3355acb8
Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
Reviewed-on: https://boringssl-review.googlesource.com/1190
Reviewed-by: Adam Langley <agl@google.com>
2014-07-28 18:50:46 +00:00
David Benjamin
0eb5a2df4a Fix tls1_get_curvelist default curves list size.
The length is the number of elements now, not the size in bytes. Caught by
ASan.

Change-Id: I4c5ccee61711e8d2e272b9bacd292dbff04b5133
Reviewed-on: https://boringssl-review.googlesource.com/1336
Reviewed-by: Adam Langley <agl@google.com>
2014-07-26 02:56:37 +00:00
David Benjamin
0aa0767340 Improve constant-time padding check in RSA key exchange.
Although the PKCS#1 padding check is internally constant-time, it is not
constant time at the crypto/ ssl/ API boundary. Expose a constant-time
RSA_message_index_PKCS1_type_2 function and integrate it into the
timing-sensitive portion of the RSA key exchange logic.

Change-Id: I6fa64ddc9d65564d05529d9b2985da7650d058c3
Reviewed-on: https://boringssl-review.googlesource.com/1301
Reviewed-by: Adam Langley <agl@google.com>
2014-07-25 20:25:15 +00:00
David Benjamin
86271ee9f8 Change CCS_OK to EXPECT_CCS.
Now that the flag is set accurately, use it to enforce that the handshake and
CCS synchronization. If EXPECT_CCS is set, enforce that:

(a) No handshake records may be received before ChangeCipherSpec.

(b) There is no pending handshake data at the point EXPECT_CCS is set.

Change-Id: I04b228fe6a7a771cf6600b7d38aa762b2d553f08
Reviewed-on: https://boringssl-review.googlesource.com/1299
Reviewed-by: Adam Langley <agl@google.com>
2014-07-25 17:58:58 +00:00
David Benjamin
cb5abad717 Consolidate CCS_OK paths in s3_clnt.c.
Introduce a CR_CHANGE state just before entering CR_FINISHED_A. This replaces
the CCS_OK in the CR_FINISHED_A/CR_FINISHED_B case which otherwise would get
applied after partial reads of Finished. The other CCS_OK settings are
redundant with this one.

The copy in tls_secret_session_cb codepath is made unnecessary with
9eaeef81fa.

The copy in the normal session resumption case is unnecessary with
6444287806. Before that commit, OpenSSL would
potentially read Finished a state early. Now that we are strict (and get the
book-keeping correct) for expecting the NewSessionTicket message it too is
redundant.

Of particular note is the one after ssl3_send_finished. That was added in
response to upstream's PR#3400. I've reproduced the bug and concluded it was
actually a bug around expecting a NewSessionTicket message. That has been fixed
properly in 6444287806 by resetting
tlsext_expect_ticket on renegotiations.

Change-Id: I6a928386994fcd5efff26a5f0efb12b65bf7f299
Reviewed-on: https://boringssl-review.googlesource.com/1298
Reviewed-by: Adam Langley <agl@google.com>
2014-07-25 17:49:12 +00:00
David Benjamin
84ec49e914 Consolidate CCS_OK codepaths in s3_srvr.c.
Rename SSL3_ST_SR_POST_CLIENT_CERT to SSL3_ST_SR_CHANGE and have this be the
point at which CCS_OK is set. The copy before ssl3_get_finished is redundant as
we never transition to SR_FINISHED directly.

Change-Id: I3eefeb821e7ae53d52dacc587fdc59de9ea9a667
Reviewed-on: https://boringssl-review.googlesource.com/1297
Reviewed-by: Adam Langley <agl@google.com>
2014-07-25 17:44:40 +00:00
Adam Langley
794bf6e0ce Fix OAEP with non-SHA hash functions.
Due to merging our patched 1.0.1 code with the 1.0.2 code, some parts of
upstream's 25f93585a70fb05bb9f911884ab95e560f662a5d didn't make it into
the code.

https://code.google.com/p/chromium/issues/detail?id=397333

Change-Id: Iceb13e63a7ac91474fd39e7faad11fa52c56185d
Reviewed-on: https://boringssl-review.googlesource.com/1310
Reviewed-by: David Benjamin <davidben@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2014-07-25 00:43:21 +00:00
David Benjamin
77a942b7fe Don't use the RSA key exchange with a signing-only key.
This removes the last case where the server generates an RSA key for the
ServerKeyExchange. Remove the code for this. Client support to accept them
still remains.

Leave the APIs for now, but they don't do anything anymore.

Change-Id: I84439e034cc575719f5bc9b3e501165e12b62107
Reviewed-on: https://boringssl-review.googlesource.com/1286
Reviewed-by: Adam Langley <agl@google.com>
2014-07-24 21:35:40 +00:00
David Benjamin
cd9969434c Pass parameters to tls1_process_sigalgs as a CBS.
Slightly cleaner; it means we can use CBS_stow.

Change-Id: I074aa2d73a79648013dea025ee531beeea2af4a2
Reviewed-on: https://boringssl-review.googlesource.com/1287
Reviewed-by: Adam Langley <agl@google.com>
2014-07-24 21:18:38 +00:00
David Benjamin
060d9d2c56 Remove support code for export cipher suites.
Now the only case where temporary RSA keys are used on the server end is
non-signing keys.

Change-Id: I55f6c206e798dd28548c386fdffd555ccc395477
Reviewed-on: https://boringssl-review.googlesource.com/1285
Reviewed-by: Adam Langley <agl@google.com>
2014-07-24 21:14:08 +00:00
David Benjamin
5ffeb7c22f Remove two more quirks.
SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG and
SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG. Neither of them have code that's even
enabled.

Change-Id: I866aabe1aa37e8ee145aaeaecaff6704c3ad21bc
Reviewed-on: https://boringssl-review.googlesource.com/1284
Reviewed-by: Adam Langley <agl@google.com>
2014-07-24 21:12:04 +00:00
David Benjamin
b9cc33a4d6 Remove SSL_OP_EPHEMERAL_RSA quirk.
Also fix a place where fixes for the condition for sending ServerKeyExchange in
s3_srvr.c were never propogated to d1_srvr.c. Tidy up that logic to use
ssl_cipher_requires_server_key_exchange and simplify the PSK check.

Change-Id: Ie36d378f733e59a8df405bc869f2346af59bd574
Reviewed-on: https://boringssl-review.googlesource.com/1283
Reviewed-by: Adam Langley <agl@google.com>
2014-07-24 21:11:50 +00:00
David Benjamin
ff175b4a46 unifdef OPENSSL_NO_PSK.
Get those out of the way.

Change-Id: I4cc8c34cf637379ad734c43623f76ae72f22014e
Reviewed-on: https://boringssl-review.googlesource.com/1282
Reviewed-by: Adam Langley <agl@google.com>
2014-07-24 21:11:05 +00:00
David Benjamin
019c3cc64a Remove last remnants of GOST support.
This removes support code for a "stream_mac" mode only used by GOST. Also get
rid of this

   /* I should fix this up TLS TLS TLS TLS TLS XXXXXXXX */

comment next to it. It's not actually related to GOST (dates to OpenSSL initial
commit), but isn't especially helpful at this point.

Change-Id: Ib13c6e27e16e0d1fb59ed0142ddf913b9abc20b7
Reviewed-on: https://boringssl-review.googlesource.com/1281
Reviewed-by: Adam Langley <agl@google.com>
2014-07-24 21:10:53 +00:00