Commit Graph

866 Commits

Author SHA1 Message Date
Adam Langley
4a0f0c4910 Change CMakeLists.txt to two-space indent.
find -name CMakeLists.txt -type f | xargs sed -e 's/\t/  /g' -i

Change-Id: I01636b1849c00ba918f48828252492d99b0403ac
2015-01-28 16:37:10 -08:00
Brian Smith
2e38008558 Define _HAS_EXCEPTIONS=0 to avoid MSVC C4530 warning.
Avoid "warning C4530: C++ exception handler used, but unwind semantics
are not enabled. Specify /EHsc" when compiling MSVC's <xlocale> by
disabling the exception code in MSVC's STL using _HAS_EXCEPTIONS=0.

Change-Id: I75aeb445d58cc9fb44467a6044386ae6b519cca8
Reviewed-on: https://boringssl-review.googlesource.com/3111
Reviewed-by: Adam Langley <agl@google.com>
2015-01-29 00:35:19 +00:00
Eric Roman
bcc4fa87af Add unit-tests for PBKDF2.
BUG=http://crbug.com/449409

Change-Id: I0f7de3ef0e43588d55955e92ba16ebb02a97d099
Reviewed-on: https://boringssl-review.googlesource.com/3080
Reviewed-by: Adam Langley <agl@google.com>
2015-01-28 20:48:17 +00:00
David Benjamin
507c1eec51 Honor the standard BUILD_SHARED_LIBS cmake variable.
The variable switches the default type for add_library from STATIC to SHARED.
We can condition additional stuff on that for convenience. (tabtest still
doesn't build.)

BoringSSL as any kind of stable system shared library is still very much
unsupported, but this is probably handy for making sure we don't forget all
those pesky OPENSSL_EXPORTs.

Change-Id: I66ab80bcddbf3724e03e85384141fdf4f4acbc2e
Reviewed-on: https://boringssl-review.googlesource.com/3092
Reviewed-by: Adam Langley <agl@google.com>
2015-01-28 20:40:10 +00:00
David Benjamin
f4600adb0e Add missing OPENSSL_EXPORTs.
Forgot to export those when adding them.

Change-Id: I206f488eb38e5ff55b8c212911aced0cf28b7664
Reviewed-on: https://boringssl-review.googlesource.com/3090
Reviewed-by: Adam Langley <agl@google.com>
2015-01-28 20:38:33 +00:00
David Benjamin
f058dae8fc Revert "Add a test for CONF_parse_list."
This reverts commit cd5c892a87. We'd rather get
rid of crypto/conf altogether, and these tests will require that we
OPENSSL_EXPORT conf.h's functions.

Change-Id: I271511ba321201e60de94e5c79c4b565ce31728f
Reviewed-on: https://boringssl-review.googlesource.com/3120
Reviewed-by: Adam Langley <agl@google.com>
2015-01-28 20:38:24 +00:00
Brian Smith
dc94b54708 Clean up use of Windows Platform SDK headers.
Define WIN32_LEAN_AND_MEAN before including Windows Platform SDK
headers to preempt naming conflicts and to make the build faster. Avoid
including those headers in BoringSSL headers. Document that Platform
SDK 8.1 or later is required on Windows.

Change-Id: I907ada21dc722527ea37e839c71c5157455a7003
Reviewed-on: https://boringssl-review.googlesource.com/3100
Reviewed-by: Adam Langley <agl@google.com>
2015-01-28 20:36:49 +00:00
Brian Smith
33970e6ce0 Enable bssl client/s_client and server/s_server on Windows.
Change-Id: Iea9bd25176724b56ebb21bded6925f5d30176548
Reviewed-on: https://boringssl-review.googlesource.com/3071
Reviewed-by: Adam Langley <agl@google.com>
2015-01-28 20:24:09 +00:00
David Benjamin
9a9a193388 Build with -fvisibility=hidden.
This matches the Chromium build, in both static and components builds. (Also
happens to sort out an undocumented requirement of the standalone shared
library build.)

Change-Id: Ib47fc4c2143115fe6faf9b83079576075efd72bb
Reviewed-on: https://boringssl-review.googlesource.com/3091
Reviewed-by: Adam Langley <agl@google.com>
2015-01-28 20:09:20 +00:00
Brian Smith
afdaeee7ed Enable bssl (md5sum, sha256sum, etc.) on Windows.
We deal with the difference between binary and text modes on Windows by
doing all I/O in binary mode (including, in particular,
stdin/stdout/stderr) and by treating text mode as equivalent to binary
mode (i.e. we use Unix line ending semantics).

Change-Id: I76a46d8d02cd7efe1931c8272d8f2c311aef3acb
Reviewed-on: https://boringssl-review.googlesource.com/3070
Reviewed-by: Adam Langley <agl@google.com>
2015-01-28 20:07:39 +00:00
Eric Roman
2fe7f2d0d9 Initialize HMAC keys to zero.
In an attempt to assign a zero-length HMAC key, consumers might
incorrectly call:

   HMAC_Init_ex(key=NULL, key_len=0)

This does not work as expected since |key==NULL| has special semantics.
This bug may consequently result in uninitialized memory being used for
the HMAC key data.

This workaround doesn't fix all the problems associated with this
pattern, however by defaulting to a zero key the results are more
predictable than before.

BUG=http://crbug.com/449409

Change-Id: I777276d57c61f1c0cce80b18e28a9b063784733f
Reviewed-on: https://boringssl-review.googlesource.com/3040
Reviewed-by: Adam Langley <agl@google.com>
2015-01-28 01:27:25 +00:00
Brian Smith
1d75c8be73 Improve compatibility with CMake 3.0 and later
CMake 3.0 changed the identifier for Apple-supplied Clang to
AppleClang.

CMake 3.1 changed the behavior of variable expansion in quoted
strings and complains with warning CMP0054 twice without these
changes.

BUG=crbug.com/451610

Change-Id: I0f1514ec302cf5f1b5cfc2c5a1c71c9e20d5e855
Reviewed-on: https://boringssl-review.googlesource.com/3011
Reviewed-by: Adam Langley <agl@google.com>
2015-01-28 01:13:46 +00:00
Brian Smith
ed30c0d6cf Improve the documentation in BUILDING
The initial instructions given don't work on Windows for a variety of
reasons. Document the prerequisite tools and the limitations on
Windows.

BUG=crbug.com/451610

Change-Id: Ib5eaf00ed9b91c02b4d0e9987f8f3b4eb73266d3
Reviewed-on: https://boringssl-review.googlesource.com/3010
Reviewed-by: Adam Langley <agl@google.com>
2015-01-28 01:13:15 +00:00
David Benjamin
b7f3144a20 Add a style guide.
I hear all the cool projects have those.

Change-Id: I0fb82ddb3f7c1768523311637099baf26c574c75
Reviewed-on: https://boringssl-review.googlesource.com/3062
Reviewed-by: Adam Langley <agl@google.com>
2015-01-28 01:12:05 +00:00
David Benjamin
69ad27fdd8 Run x86 perlasm on UNIX with -fPIC.
This matches the Chromium build.

Change-Id: I6ebd01c6ecb67c79577f98cf468dc204721595ef
Reviewed-on: https://boringssl-review.googlesource.com/3063
Reviewed-by: Adam Langley <agl@google.com>
2015-01-27 19:32:17 +00:00
David Benjamin
36eb7d5fbc Fix buffer size in aead_test.c.
out2 wasn't sized to account for stateful AEAD open requiring a seal overhead's
worth of scratch space. Also, pass in sizeof(out2) rather than a computed
ciphertext length, so the max_out check would have actually caught this.

Change-Id: Ibe689424f6c8ad550b3a45266699892076e7ba5e
Reviewed-on: https://boringssl-review.googlesource.com/3060
Reviewed-by: Adam Langley <agl@google.com>
2015-01-27 01:38:57 +00:00
David Benjamin
53cbd6c8a0 Fix unused variable warning in OPENSSL_NO_ASM build.
Te4 is used in in crypto/aes/aes.c. It's used upstream in an alternate
implementation of AES_set_encrypt_key not included in our version.

Change-Id: I5704dbc714bdb05ef515cbf2aff5e43c3b62c5b2
Reviewed-on: https://boringssl-review.googlesource.com/3061
Reviewed-by: Adam Langley <agl@google.com>
2015-01-27 01:34:54 +00:00
Adam Langley
bed8f7307e Fix build after mistake addressing comments in cca4d599.
My screwup—I didn't rebuild before submitting :(

Change-Id: If3e1a5cc5bdf6cacb94bc23896619796b22bd9d2
2015-01-26 16:34:37 -08:00
Adam Langley
cca4d5991f Add digest sum handling to the tool.
Android might want to replace the system *sum (i.e. md5sum, sha256sum
etc) binaries with a symlink to the BoringSSL tool binary.

This change also allows the tool to figure out what to do based on
argv[0] if it matches one of the known commands.

Change-Id: Ia4fc3cff45ce2ae623dae6786eea5d7ad127d44b
Reviewed-on: https://boringssl-review.googlesource.com/2940
Reviewed-by: Adam Langley <agl@google.com>
2015-01-26 21:27:18 +00:00
David Benjamin
cd5c892a87 Add a test for CONF_parse_list.
Change-Id: I7af0753cac07756a75d03a4820a16f3f8b18d7ba
Reviewed-on: https://boringssl-review.googlesource.com/3026
Reviewed-by: Adam Langley <agl@google.com>
2015-01-26 21:24:50 +00:00
Adam Langley
fd4eb60497 Remove duplication of common DH parameters.
Previously, the data for the common DH parameters was given twice: once
with 64-bit limbs and again with 32-bit limbs. A simple macro can
eliminate this duplication.

Change-Id: I15af008a769616f8146845cc8dd0e6526aa142ba
Reviewed-on: https://boringssl-review.googlesource.com/2950
Reviewed-by: David Benjamin <davidben@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2015-01-26 20:26:51 +00:00
Adam Langley
b4a494cc32 Reformat SSL/TLS headers.
Change-Id: Id9d848a6bb13a414d7c199674ff980c5011f92cf
Reviewed-on: https://boringssl-review.googlesource.com/3000
Reviewed-by: Adam Langley <agl@google.com>
2015-01-26 20:23:09 +00:00
David Benjamin
347f025d75 Remove unused modexp512-x86_64.pl.
See upstream's c436e05bdc7f49985a750df64122c960240b3ae1.

Change-Id: I7cbe5315a769450e4630dd4e8f465cdfd45c2e08
Reviewed-on: https://boringssl-review.googlesource.com/3025
Reviewed-by: Adam Langley <agl@google.com>
2015-01-26 18:45:45 +00:00
David Benjamin
6ae7f072e3 Only send sigalgs extension in 1.2-capable ClientHellos.
BUG=https://code.google.com/p/webrtc/issues/detail?id=4223

Change-Id: I88eb036fdc6da17bc6a5179df02f35486abe9add
Reviewed-on: https://boringssl-review.googlesource.com/3030
Reviewed-by: Adam Langley <agl@google.com>
2015-01-26 18:45:04 +00:00
David Benjamin
4189bd943c Test application data and Finished reordering.
This is fatal for TLS but buffered in DTLS. The buffering isn't strictly
necessary (it would be just as valid to drop the record on the floor), but so
long as we want this behavior it should have a test.

Change-Id: I5846bb2fe80d78e25b6dfad51bcfcff2dc427c3f
Reviewed-on: https://boringssl-review.googlesource.com/3029
Reviewed-by: Adam Langley <agl@google.com>
2015-01-26 18:43:02 +00:00
David Benjamin
78e6978ab9 Disable NPN and Channel ID in DTLS.
They're not in the duplicated handshake state machines anyway. But we still
shouldn't negotiate them. d1_pkt.c assumes Finished is the only post-CCS
handshake message. An unexpected handshake message in the current epoch may
either be a retransmit/out-of-order message from the previous handshake, or a
message from the next handshake (also potentially out-of-order). In the former
case, we shouldn't spin up another handshake state machine instance.

(This assumption is required due to a protocol bug. DTLS resets sequence
numbers after a handshake, so it is necessary to categorize handshake fragments
by pre-CCS and post-CCS to distinguish between retransmit and renego.)

Change-Id: Ib3c1c7085c729e36a40f7ff14494733156924a24
Reviewed-on: https://boringssl-review.googlesource.com/3028
Reviewed-by: Adam Langley <agl@google.com>
2015-01-26 18:41:10 +00:00
David Benjamin
33e799fe19 Don't allow CCS just before CertificateVerify in DTLS.
This is the DTLS-side equivalent of 6553b379e2.

Change-Id: I5eb7f9d6d5030e375baa1406b00e3166d276dc84
Reviewed-on: https://boringssl-review.googlesource.com/3027
Reviewed-by: Adam Langley <agl@google.com>
2015-01-26 18:41:08 +00:00
David Benjamin
c898ce752f Add generated documentation to .gitignore
Change-Id: I5175ba1b316e381949c820211769fbd636fe645e
Reviewed-on: https://boringssl-review.googlesource.com/3024
Reviewed-by: Adam Langley <agl@google.com>
2015-01-26 18:37:55 +00:00
David Benjamin
2a0e72f08a Fix segfault with empty fields as last in the config.
(Imported from upstream's 2747d73c1466c487daf64a1234b6fe2e8a62ac75.)

Also fix up some stylistic issues in conf.c and clarify empty case in
documentation.

Change-Id: Ibacabfab2339d7566d51db4b3ac4579aec0d1fbf
Reviewed-on: https://boringssl-review.googlesource.com/3023
Reviewed-by: Adam Langley <agl@google.com>
2015-01-26 18:37:47 +00:00
David Benjamin
df1cda345f Use inner algorithm when printing certificate.
(Imported from upstream's 004efdbb41f731d36bf12d251909aaa08704a756.)

The outer algorithm is already printed at the bottom of the function. This
allows any tools which print the X509 this way to determine if there is a
mismatch. This is also the point where the TBSCertificate is printed, not the
Certificate. See upstream's RT #3665.

Change-Id: I89baa4e4b626abf8813545a90eaa4409489ad893
Reviewed-on: https://boringssl-review.googlesource.com/3022
Reviewed-by: Adam Langley <agl@google.com>
2015-01-26 18:37:23 +00:00
David Benjamin
e3b24674ef sha256-armv4.pl: fix typo.
(Imported from upstream's 52cab5635603c1a7a00bc6f92401c84ec8920298.)

Change-Id: I97b89c03e1a05063100f94b87e06afb2028371ff
Reviewed-on: https://boringssl-review.googlesource.com/3021
Reviewed-by: Adam Langley <agl@google.com>
2015-01-26 18:37:01 +00:00
David Benjamin
8604eda634 Add Broadwell performance results.
(Imported from upstream's b3d7294976c58e0e05d0ee44a0e7c9c3b8515e05.)

May as well avoid diverging.

Change-Id: I3edec4fe15b492dd3bfb3146a8944acc6575f861
Reviewed-on: https://boringssl-review.googlesource.com/3020
Reviewed-by: Adam Langley <agl@google.com>
2015-01-26 18:35:35 +00:00
Adam Langley
c5cc15b4f5 Don't expect bsaes functions on ARMv6.
The bsaes-armv7.S asm has an #if __ARM_ARCH__>=7 around its contents,
i.e. it's not just switched at runtime – it only compiles for >= ARMv7.

I mistakenly regressed e_aes.c in 3e652657 to always expected bsaes
functions to exist on ARM. This change fixes that.

Change-Id: Ifd9111438508909a0627b25aee3e2f11e62e3ee8
2015-01-23 11:04:46 -08:00
David Benjamin
5fa3eba03d Clear the error queue when dropping a bad DTLS packet.
This regressed in e95d20dcb8. EVP_AEAD will push
errors on the error queue (unlike the EVP_CIPHER codepath which checked
everything internally to ssl/ and didn't bother pushing anything). This meant
that a dropped packet would leave junk in the error queue.

Later, when SSL_read returns <= 0 (EOF or EWOULDBLOCK), the non-empty error
queue check in SSL_get_error kicks in and SSL_read looks to have failed.

BUG=https://code.google.com/p/webrtc/issues/detail?id=4214

Change-Id: I1e5e41c77a3e5b71e9eb0c72294abf0da677f840
Reviewed-on: https://boringssl-review.googlesource.com/2982
Reviewed-by: Adam Langley <agl@google.com>
2015-01-22 22:06:40 +00:00
David Benjamin
9a38e924aa Return SSL_ERROR_SYSCALL on unclean EOF.
This regressed in fcf25833bc. 0 return code on
unclean shutdown means the underlying BIO returned EOF, didn't push any error
code, but we haven't seen close_notify yet. The intent seems to be that you go
check errno or some BIO-specific equivalent if you care about close_notify.

Make sure test code routes all SSL_read return codes through SSL_get_error
since that's supposed to work in all cases.

(Note that rv == 0 can still give SSL_ERROR_SSL if the error queue is not
empty.)

Change-Id: I45bf9614573f876d93419ce169a4e0d9ceea9052
Reviewed-on: https://boringssl-review.googlesource.com/2981
Reviewed-by: Adam Langley <agl@google.com>
2015-01-22 22:01:35 +00:00
David Benjamin
1e52ecac4d Normalize tls1_enc return values.
The distinction between publicly and non-publicly invalid is barely acted upon
and slightly silly now that the CBC padding check has been folded into
EVP_AEAD.

Change-Id: Idce4b9b8d29d624e3c95243a147265d071612127
Reviewed-on: https://boringssl-review.googlesource.com/2980
Reviewed-by: Adam Langley <agl@google.com>
2015-01-22 22:00:01 +00:00
Adam Langley
66850ddec1 Add dummy variables to keep wpa_supplicant happy.
Since we can't update wpa_supplicant nearly as fast as we would like, we
need to try and keep it happy. Unfortunately, the recent switch to
EVP_AEAD breaks it so this dismal change adds some dummy variables that
will allow it to compile.

Change-Id: I03d6b81c30bbebc07af3af0d6cda85a26b461edf
Reviewed-on: https://boringssl-review.googlesource.com/2960
Reviewed-by: Adam Langley <agl@google.com>
2015-01-22 19:27:30 +00:00
David Benjamin
384673ceb7 Fix tool build on Windows.
C++ doesn't allow implicit void* casts.

Change-Id: I50a2ab3fce6a38470b4e8216bd461ba2cd2c2215
Reviewed-on: https://boringssl-review.googlesource.com/2971
Reviewed-by: Adam Langley <agl@google.com>
2015-01-22 19:22:39 +00:00
David Benjamin
cb878e20f3 More documentation fixes.
Missing newlines. I think they got lost in some patch reordering.

Change-Id: Ib1e5833623f4ef613965d32b4e82ba18b6a551e6
Reviewed-on: https://boringssl-review.googlesource.com/2970
Reviewed-by: Adam Langley <agl@google.com>
2015-01-22 19:22:33 +00:00
Adam Langley
07100c6e69 Only use -Wshadow with GCC > 4.6.0.
Prior to 4.6.0, -Wshadow would cause GCC to warn when variables shadowed
global functions. Since libc defines a number of functions with common
names, this is a problem. Also, without this change, we'll keep breaking
on older versions of GCC because we won't be testing with them.

OpenBSD, specifically is reported to have a problem:
https://boringssl-review.googlesource.com/#/c/2900/

(Note the test should really be >= 4.6.0, but CMake doesn't have a
VERSION_GREATEROREQUAL.)

Change-Id: I1aedda01ab629e138c8781e4319bfaaed0b236b0
Reviewed-on: https://boringssl-review.googlesource.com/2952
Reviewed-by: Adam Langley <agl@google.com>
2015-01-21 00:27:26 +00:00
Eric Roman
4dcb05729f Remove support for passing a C-String to PKCS5_PBKDF2_HMAC*().
Before it was possible to pass a NULL-terminated C-string to the PBKDF2
functions, and indicate the parameter was a C-string by passing a length
of -1.

This is not relied on anywhere in the BoringSSL code, and the API contract is
possible to misuse as it is not the common way of doing things.

(A problem would arise when passing in a large unsigned length that
subsequently gets interpreted as -1).

Change-Id: Ifbd31ff76e183fa74e9fa346908daf4bfb8fc3da
Reviewed-on: https://boringssl-review.googlesource.com/2953
Reviewed-by: David Benjamin <davidben@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2015-01-20 23:44:05 +00:00
Emanuele Pucciarelli
25bde4c1f9 Recognize common DH parameter sets.
Recognize the four most commonly offered safe DH parameter sets when
negotiating multiplicative, ephemeral Diffie-Hellman. These values were
found from a scan of the Alexa common sites.

When a known safe prime is used, reduce the private key size
correspondingly.

Change-Id: I655eb7a5c743c0b389698c0471d16db5a0966652
2015-01-16 14:46:59 -08:00
Adam Langley
e49da742cb Include arm_arch.h in e_aes.c.
Not sure why this is working in CMake build, but the Chromium trybots
aren't happy without it.

Change-Id: I810740786c4f3cb9ba786891fdcd6053eea3afcb
2015-01-16 14:06:22 -08:00
Adam Langley
e7624340ee Also test AES-CBC modes in the speed tool.
This change adds the AES-128-CBC-SHA and AES-256-CBC-SHA AEADs to the
speed test. These AEADs need an 11 byte additional data so the test is
extended to be able to provide that.

Change-Id: I9a57c2321a979a68ab0df9faf1bb26b44a3009c4
Reviewed-on: https://boringssl-review.googlesource.com/2922
Reviewed-by: Adam Langley <agl@google.com>
2015-01-16 19:04:44 +00:00
Adam Langley
6a3c288cdf Update SHA-1/256/512 asm for ARM from upstream.
This change syncs these asm files with upstream's 1.0.2 branch. The
important change is that they contain ARMv8 code that allows 32-bit ARM
code to use the hardware support in ARMv8 when running on such a chip.

Change-Id: Id37cb1ff0cbc98a8e328612df7cf60340ca96064
Reviewed-on: https://boringssl-review.googlesource.com/2921
Reviewed-by: David Benjamin <davidben@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2015-01-16 19:00:26 +00:00
Adam Langley
543d00692a Benchmark AEADs with aligned buffers.
This eliminates a source of variability from the benchmarks.

Change-Id: I8ce07bd68e7591f8c5545040b02b96d21609a0e5
Reviewed-on: https://boringssl-review.googlesource.com/2920
Reviewed-by: David Benjamin <davidben@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2015-01-16 19:00:17 +00:00
David Benjamin
7f1d5d5932 Follow-ups from recent patch train.
Comment fixups and a mismerge in aead_test. Also some buffer was larger than
needed.

Change-Id: I0e158089f42801575833684912f9edb206f61007
Reviewed-on: https://boringssl-review.googlesource.com/2870
Reviewed-by: Adam Langley <agl@google.com>
2015-01-16 02:05:45 +00:00
Adam Langley
f0eb169829 Free all error queues on shutdown.
As feared, 2bca0988 did cause some leak checkers to get upset about the
state_hash pointer getting cleared.

This change makes err_shutdown free all the error queues to try and
avoid this. Hopefully this doesn't upset TSAN in turn.

BUG=448296

Change-Id: I827da63c793dcabc73168ece052cdcd3d3cc64e3
Reviewed-on: https://boringssl-review.googlesource.com/2890
Reviewed-by: David Benjamin <davidben@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2015-01-15 22:10:02 +00:00
Adam Langley
d749af7ab1 Use a weak pointer for getauxval.
The Android SDK version against which Chromium builds is too old to
include sys/auxv.h. This change switches the ARM code to use a weak
pointer for getauxval and to hard code the aux value numbers.

It also switches the license on cpu-arm.c because there's no OpenSSL
left in there now.

Change-Id: I440cb9d533a06d8b245b189d8e5148fa33e29412
Reviewed-on: https://boringssl-review.googlesource.com/2880
Reviewed-by: David Benjamin <davidben@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2015-01-15 22:09:53 +00:00
Adam Langley
b1116a4a3b Always write the Poly1305 tag to an aligned buffer.
With GCC 4.9 and -O2 (and only -O2, -O1 and -O3 didn't trigger it), the
Poly1305 code can end up writing to an unaligned address otherwise and
that triggers a bus error on ARM.

Change-Id: Ifbeb7e2066a893d91d6f63c6565bac7d5542ef81
Reviewed-on: https://boringssl-review.googlesource.com/2850
Reviewed-by: Adam Langley <agl@google.com>
2015-01-14 23:38:25 +00:00