Compare commits

..

1707 Commits

Author SHA1 Message Date
Adam Langley 0cd846f24f delocation: large memory model support.
Large memory models on x86-64 allow the code/data of a shared object /
executable to be larger than 2GiB. This is typically impossible because
x86-64 code frequently uses int32 offsets from RIP.

Consider the following program:

    int getpid();

    int main() {
        return getpid();
    }

This is turned into the following assembly under a large memory model:

.L0$pb:
	leaq	.L0$pb(%rip), %rax
	movabsq	$_GLOBAL_OFFSET_TABLE_-.L0$pb, %rcx
	addq	%rax, %rcx
	movabsq	$getpid@GOT, %rdx
	xorl	%eax, %eax
	jmpq	*(%rcx,%rdx)            # TAILCALL

And, with relocations:

   0:	48 8d 05 f9 ff ff ff 	lea    -0x7(%rip),%rax        # 0 <main>
   7:	48 b9 00 00 00 00 00 	movabs $0x0,%rcx
   e:	00 00 00
			9: R_X86_64_GOTPC64	_GLOBAL_OFFSET_TABLE_+0x9
  11:	48 01 c1             	add    %rax,%rcx
  14:	48 ba 00 00 00 00 00 	movabs $0x0,%rdx
  1b:	00 00 00
			16: R_X86_64_GOT64	getpid
  1e:	31 c0                	xor    %eax,%eax
  20:	ff 24 11             	jmpq   *(%rcx,%rdx,1)

We can see that, in the large memory model, function calls involve
loading the address of _GLOBAL_OFFSET_TABLE_ (using `movabs`, which
takes a 64-bit immediate) and then indexing into it. Both cause
relocations.

If we link the binary and disassemble we get:

0000000000001120 <main>:
    1120:	48 8d 05 f9 ff ff ff 	lea    -0x7(%rip),%rax        # 1120 <main>
    1127:	48 b9 e0 2e 00 00 00 	movabs $0x2ee0,%rcx
    112e:	00 00 00
    1131:	48 01 c1             	add    %rax,%rcx
    1134:	48 ba d8 ff ff ff ff 	movabs $0xffffffffffffffd8,%rdx
    113b:	ff ff ff
    113e:	31 c0                	xor    %eax,%eax
    1140:	ff 24 11             	jmpq   *(%rcx,%rdx,1)

Thus the _GLOBAL_OFFSET_TABLE_ symbol is at 0x1120+0x2ee0 = 0x4000.
That's the address of the .got.plt section. But the offset “into” the
table is -0x40, putting it at 0x3fd8, in .got:

Idx Name          Size      VMA               LMA               File off  Algn
 18 .got          00000030  0000000000003fd0  0000000000003fd0  00002fd0  2**3
 19 .got.plt      00000018  0000000000004000  0000000000004000  00003000  2**3

And, indeed, there's a dynamic relocation to setup that address:

OFFSET           TYPE              VALUE
0000000000003fd8 R_X86_64_GLOB_DAT  getpid@GLIBC_2.2.5

Accessing data or BSS works the same: the address of the variable is
stored relative to _GLOBAL_OFFSET_TABLE_.

This is a bit of a pain because we want to delocate the module into a
single .text segment so that it moves through linking unaltered. If we
took the obvious path and built our own offset table then it would need
to contain absolute addresses, but they are only available at runtime
and .text segments aren't supposed to be run-time patched. (That's why
.rela.dyn is a separate segment.) If we use a different segment then
we have the same problem as with the original offset table: the offset
to the segment is unknown when compiling the module.

Trying to pattern match this two-step lookup to do extensive rewriting
seems fragile: I'm sure the compilers will move things around and
interleave other work in time, if they don't already.

So, in order to handle movabs trying to load _GLOBAL_OFFSET_TABLE_ we
define a symbol in the same segment, but outside of the hashed region of
the module, that contains the offset from that position to
_GLOBAL_OFFSET_TABLE_:

.boringssl_got_delta:
    .quad _GLOBAL_OFFSET_TABLE_-.boringssl_got_delta

Then a movabs of $_GLOBAL_OFFSET_TABLE_-.Lfoo turns into:

movq .boringssl_got_delta(%rip), %destreg
addq $.boringssl_got_delta-.Lfoo, %destreg

This works because it's calculating
_GLOBAL_OFFSET_TABLE_ - got_delta + (got_delta - .Lfoo)

When that value is added to .Lfoo, as the original code will do, the
correct address results. Also it doesn't need an extra register because
we know that 32-bit offsets are sufficient for offsets within the
module.

As for the offsets within the offset table, we have to load them from
locations outside of the hashed part of the module to get the
relocations out of the way. Again, no extra registers are needed.

Change-Id: I87b19a2f8886bd9f7ac538fd55754e526bcf3097
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/42324
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2020-08-10 23:46:33 +00:00
Nick Harper 74161f485b Enforce presence of ALPN when QUIC is in use.
Update-Note: If an SSL_QUIC_METHOD is set, connections will now fail if
ALPN is not negotiated. This new behavior can be detected by checking
if the value of BORINGSSL_API_VERSION is greater than 10.

Bug: 294
Change-Id: I42fb80aa09268e77cec4a51e49cdad79bd72fa58
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/42304
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-07-30 16:41:06 +00:00
David Benjamin 7d3a24d9db Fix the naming of alert error codes.
Reason codes 1000+N correspond to receiving an alert N from the peer,
rather than observing the corresponding error condition locally. This
has generally been a source of confusion for folks.

They were originally named like SSL_R_TLSV1_ALERT_DECRYPTION_FAILED, but
OpenSSL introduced a few without the "ALERT" token in
739a543ea863682f157e9aa0ee382367eb3d187c.

We then inadvertently carried the mistake over in
SSL_R_TLSV1_UNKNOWN_PSK_IDENTITY and SSL_R_TLSV1_CERTIFICATE_REQUIRED.
Fix all these to include the "ALERT" for consistency and make it
slightly less confusing. (Although perhaps it should have been
RECEIVED_ALERT or so.) Add compatibility #defines for the original
OpenSSL ones and SSL_R_TLSV1_CERTIFICATE_REQUIRED. The latter can be
removed when downstream code is fixed. The OpenSSL ones we'll probably
just leave around.

Update-Note: The renamed alerts will log slightly different strings, but
the constants used by external code are still there.

Bug: 366
Change-Id: I30c299c4ad4b2bed695bd71d0831fbe6755975a7
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/42384
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-07-29 21:19:25 +00:00
David Benjamin 70fee17204 Use golang.org/x/crypto in runner.
The CI should be set up to retain the Go module and build caches, so
we'll avoid downloading it multiple times. This avoids having to
replicate some code.

Update-Note: The tests now have a golang.org/x/crypto dependency. This
should be fetched transparently with Go modules. Monorepos with
different import path conventions may need to rewrite these imports.

Change-Id: If5ba52e051f180536d72109c2e690bbd13d58e7c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/42044
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-07-29 19:27:59 +00:00
Nick Harper 281a8f5ea3 Disable ClientHello padding for QUIC.
Bug: 327
Change-Id: I415deee8e6b2dc4cd5bdfb5e329d889dd3a5baa7
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/42364
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-07-28 18:16:41 +00:00
David Benjamin db129f3f3f Add X509_SIG_get0 and X509_SIG_getm.
Change-Id: I1bef3ea54f871003f7e4a076c5cfb0dbb7f89f73
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/42344
Reviewed-by: Adam Langley <agl@google.com>
2020-07-28 15:36:02 +00:00
Daniel McArdle 8b601c88fb Implement HPKE.
draft-ietf-tls-esni-07 uses HPKE for encryption.

Bug: 275
Change-Id: I4af39be4df534f8c1c991c4df82d38c6adcf2574
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41304
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-07-27 20:08:35 +00:00
Nick Harper cac93924ab Disallow TLS 1.3 compatibility mode in QUIC.
Bug: 335
Change-Id: I3caa780284d4a3e646414d1fd85cc2528ebeceff
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41264
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-07-27 18:51:35 +00:00
David Benjamin 54858b63c1 Switch clang-format IncludeBlocks to Preserve.
clang-format now reorders includes. It used to simply sort within
blocks, but later it added a "regroup" option. The regroup option is a
bit aggressive and does not take into account our project headers being
referenced in <system/header.h> style. (It also won't be able to
recognize the header corresponding to the source file, but perhaps we
should drop that rule.)

For now, just revert it to Preserve.

Change-Id: Ief82b5c3f91c16a8def14f91ef6bf6cde502bb79
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/42265
Reviewed-by: Adam Langley <agl@google.com>
2020-07-23 21:55:26 +00:00
David Benjamin d054e1bc61 Fix unterminated clang-format off.
We should probably ponder what to do about clang-format. That we
disagree on chains of && is a little annoying, but peppering the code
with clang-format off seems problematic.

Change-Id: I0547e4e41817e8c0b585d5fabe759ef25ed00cf7
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/42264
Reviewed-by: Adam Langley <agl@google.com>
2020-07-23 20:52:15 +00:00
Daniel McArdle 1a63507c41 Add line number to doc.go error messages.
Change-Id: I00f35648a6d354abdc908314fef48b3fa573d825
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/42224
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-07-20 17:33:03 +00:00
Adam Langley f0558c359c Kick the bots.
This should make them update and generate JSON outputs due to
8c0a6ebfc2.

Change-Id: I7e2fa7ace2ed0216fee6b553c4cf7e16a7d7457d
2020-07-16 14:14:15 -07:00
David Benjamin 8c0a6ebfc2 Add a JSON output to generate_build_files.py.
gRPC are currently importing generate_build_files.py, injecting a
custom printer, and running into problems with the symlinks they set up
to make this work, as well as needing to delete duplicate generated
files.
https://github.com/grpc/grpc/blob/53a5ad34c0b5fca2cc9fd9ec4b354ff79c12948b/src/boringssl/gen_build_yaml.py#L130
https://boringssl-review.googlesource.com/c/boringssl/+/42164

Rather than layer on more hacks, add a JSON output to
generate_build_files.py. This outputs a sources.json file that folks
with especially custom builds can consume. (Looks like gRPC converts to
some home-grown YAML format which I imagine is further processed by some
other generator?) We can then add it to master-with-bazel's output.

Change-Id: I82b4ea0647386ca6c76a977f057b9962f40d41c8
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/42204
Reviewed-by: Adam Langley <agl@google.com>
2020-07-16 19:32:10 +00:00
Adam Langley 83b74c6a7a Add details of 20190808 FIPS certification.
Change-Id: I4d17e1e6f24b623ee39a844def8f265eb5e6c6cc
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/42144
Commit-Queue: Adam Langley <alangley@gmail.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-07-13 16:59:37 +00:00
David Benjamin 8f88b27d6a Link to ws2_32 more consistently.
This fixes a couple issues:

- Which libraries to use should be based on WIN32, not MSVC.

- Windows libraries can be specified by #pragma comment lines in the
  source or by build dependencies. We specified #pragma lines in
  source, but also have build dependencies in crypto_test, etc. The
  latter was missing bssl.

  The comment line should be sufficient, but being explicit is useful,
  so fill in the missing one. This should help building with MINGW,
  which is missing support for the usual Windows pragma.

Change-Id: Ide9328c7dd306738ebbb0792e47da96948fe12f4
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/42105
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-07-09 23:43:52 +00:00
David Benjamin de196121b0 Allow explicitly-encoded X.509v1 versions for now.
Sadly, we need to roll this one back for now, at least until we've
cleared all the test failures it causes. This retains the other checks
in https://boringssl-review.googlesource.com/c/boringssl/+/41746. We're
only rolling back enforcement of the DEFAULT v1 encoding.

Bug: 348, 364
Change-Id: I6a290311f5a5714ff4d5add3ae35ec4550398b32
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/42104
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-07-09 16:28:02 +00:00
David Benjamin eda849d2e6 Opaquify PKCS8_PRIV_KEY_INFO.
This is partially imported from upstream's
54dbf42398e23349b59f258a3dd60387bbc5ba13 which does something similar.

In doing so, remove the pkcs8->broken field, which is a remnant of some
parsing hacks we long since removed (PKCS8_set_broken). The immediate
motivation is, if this sticks, this would make it easier to detach
i2d_PKCS8_PRIV_KEY_INFO and d2i_PKCS8_PRIV_KEY_INFO from the old ASN.1
code.

Update-Note: Direct accesses of PKCS8_PRIV_KEY_INFO now need to use the
accessors. Code search suggests no one uses the fields. Even the
accessors are virtually unused (the one thing which uses it doesn't need
it).

Bug: chromium:1102458
Change-Id: I57054de3fe412079f7387dc99291250e873b1471
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/42006
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-07-08 16:09:11 +00:00
David Benjamin 5d7c2f8b1d Implement i2d_PUBKEY and friends without crypto/asn1.
Code which targets OpenSSL won't use EVP_parse_public_key. X509_PUBKEY
is fairly deeply tied to the old ASN.1 stack, but there's no reason for
i2d_PUBKEY and friends to be. Move them to crypto/evp and reimplement as
wrappers over our functions.

Bug: chromium:1102458
Change-Id: Ic11766acdac797602e4abe1253b0efe33faef298
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/42005
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-07-08 15:48:18 +00:00
Steven Valdez d0637e901d Remove TRUST_TOKEN_experiment_v0.
Update-Note: This gets rid of TRUST_TOKEN_experiment_v0. Existing callers
should be updated to call TRUST_TOKEN_experiment_v1.

Change-Id: I8ec9b808cbd35546425690d1548db671ff033e14
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41524
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
2020-07-07 16:26:59 +00:00
David Benjamin b9fbf4069e Clarify in-place rules for low-level AES mode functions.
Change-Id: I9dde27f4a6b492d5a3f49041c8cdcac642c58335
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/42004
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-07-06 18:20:21 +00:00
Adam Langley fb0c05cac2 acvp: add CMAC-AES support.
Change by Dan Janni.

Change-Id: I3f059e7b1a822c6f97128ca92a693499a3f7fa8f
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41984
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-07-02 20:51:31 +00:00
Adam Langley c655065273 acvp: add SP800-108 KDF support.
Based on a change from Dan Janni.

Change-Id: Ibe00e61cb43819ecad7c1376f8c013aca3667037
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41964
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-07-02 20:29:41 +00:00
David Benjamin 25638f06e3 Remove x509->name.
Every X509 object, when parsed, would pretty-print the subject and stash
the result in x509->name. This field was removed in upstream OpenSSL and
all uses I found have now been fixed. Remove this to reduce unnecessary
work in the X.509 parser.

Update-Note: instead of x509->name, use X509_NAME_oneline and
X509_get_subject_name.

Change-Id: I1d1e69bed7429d59125a8bdea5cbba391cd1028c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41904
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2020-07-02 20:19:01 +00:00
Adam Langley 939d426f6b Maybe build for AArch64 Windows.
Microsoft lists[1] this define to indicate AArch64, support for which is
requested on https://github.com/grpc/grpc/issues/23310.

More might well be needed, especially if the assembly code is to work,
but maybe this'll work for gRPC.

[1] https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=vs-2019

Change-Id: Id66d1c8ab7ab161f73c993dd4901e2252198bda8
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41945
Reviewed-by: Adam Langley <alangley@gmail.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2020-07-02 20:06:21 +00:00
Adam Langley e2abade424 sha1-x86_64: fix CFI.
This issue only arises when SHAEXT is enabled, which it isn't (yet).
Will upstream too.

Change-Id: I92de51789d58ba1784b88eb872b1f9eca8eb78d8
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41944
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-06-30 16:48:54 +00:00
Brian Smith 5d74463301 Use |crypto_word_t| and |size_t| more consistently in ECC scalar recoding.
Use |crypto_word_t| as the type for secret values in scalar recoding.
Use |size_t| as the type of array indexes in scalar recoding. Use
explicit casts where a larger type is (losslessly) truncated to a
smaller type. With this change, |uint64_t| is no longer used in the
p256.c when building in 32-bit mode, |unsigned| is not used in any of
the affected modules, and |uint8_t| and |char| are no longer used for
secret values in the ECC recoding.

When given the choice of doing non-array-indexing arithmetic (e.g. shifts)
on |size_t| values or |crypto_word_t| values, prefer doing it on
|crypto_word_t| values. More generally, try to use |size_t| only for
sizes and array indexes.

This is part of a bigger project to minimize the use of types other than
|crypto_word_t| for secret values. This is also part of a larger project
make the ECC code more consistent.

Avoid changing the loop indexing in the P-256 scalar multiplication from
|int| to |size_t|. The P-224 code does use |size_t| but it is less clear
than the P-256 code where |i - 1| results in a negative/underflowed
value when |i| is zero.

Change-Id: I78cb404455c2340a4f8c9688d36c0d425bfcc50b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41685
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-06-30 15:04:06 +00:00
Ilya Tokar 7361ee42cf Enable shaext path for sha1.
This makes sha1 ~2x faster on Amd Rome:

BM_SHA1Hash/2               10.9MB/s ± 1%           14.0MB/s ± 1%  +28.77%        (p=0.000 n=10+10)
BM_SHA1Hash/4               21.9MB/s ± 1%           28.2MB/s ± 1%  +28.56%        (p=0.000 n=10+10)
BM_SHA1Hash/8               43.9MB/s ± 1%           56.3MB/s ± 2%  +28.36%        (p=0.000 n=10+10)
BM_SHA1Hash/16              88.1MB/s ± 1%          114.8MB/s ± 2%  +30.40%         (p=0.000 n=9+10)
BM_SHA1Hash/32               178MB/s ± 1%            229MB/s ± 2%  +28.64%        (p=0.000 n=10+10)
BM_SHA1Hash/64               240MB/s ± 1%            363MB/s ± 2%  +51.57%        (p=0.000 n=10+10)
BM_SHA1Hash/512              629MB/s ± 1%           1129MB/s ± 2%  +79.54%         (p=0.000 n=9+10)
BM_SHA1Hash/4k               794MB/s ± 0%           1538MB/s ± 1%  +93.76%         (p=0.000 n=8+10)
BM_SHA1Hash/32k              820MB/s ± 1%           1610MB/s ± 2%  +96.44%        (p=0.000 n=10+10)
BM_SHA1Hash/256k             822MB/s ± 1%           1624MB/s ± 1%  +97.48%        (p=0.000 n=10+10)
BM_SHA1Hash/1M               822MB/s ± 1%           1625MB/s ± 1%  +97.63%        (p=0.000 n=10+10)
BM_SHA1Hash/2M               824MB/s ± 1%           1626MB/s ± 1%  +97.32%        (p=0.000 n=10+10)
BM_SHA1Hash/4M               826MB/s ± 1%           1631MB/s ± 0%  +97.56%         (p=0.000 n=10+8)
BM_SHA1Hash/8M               824MB/s ± 1%           1625MB/s ± 1%  +97.14%        (p=0.000 n=10+10)
BM_SHA1Hash/16M              823MB/s ± 1%           1625MB/s ± 1%  +97.40%        (p=0.000 n=10+10)

Change-Id: Ic75eb717a71b35d0ca775c309e08396b2ab77641
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41884
Reviewed-by: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-06-30 14:58:34 +00:00
David Benjamin 5fa22ed85e Avoid relying on SSL_get_session's behavior during the handshake.
Mid-renegotiation, there are a lot of sets of TLS parameters flying
around. We need to be clear which one we want for each operation. There
were a few parts of TLS 1.2 which were relying on SSL_get_session to
abstract between the resumption session and a new session.

Implement that separately as ssl_handshake_session, so we're free to
avoid SSL_get_session returning an incomplete session mid-renegotiation.

This doesn't fixed the linked Chromium bug, but it is necessary to do
so. (I'm trying to separate the SSL_get_session change from the
dependencies within the library.)

Update-Note: SSL_generate_key_block will now fail mid-handshake. It is
ambiguous which key block to use and, in some cases, we may not even be
able to compute the right key block.

Bug: chromium:1010748
Change-Id: I30c8a683bb506310e37adbd05a28e3b8de6e6836
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41865
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-06-29 16:18:30 +00:00
David Benjamin b3c5ac51d5 Add a -wait-for-debugger flag to runner.
xterm on macOS is surprisingly difficult to get at these days. Instead,
add an option to make bssl_shim SIGSTOP itself so a debugger can resume
it.

Change-Id: Ie3cf02744557f46c8fa08c162276b5ff851a51c7
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41864
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2020-06-29 15:41:10 +00:00
David Benjamin 86f86cbdf7 Add missing OPENSSL_EXPORT to X509_get_X509_PUBKEY.
Thanks to Daniel Stenberg for noticing this.

Change-Id: I4e1e75d879dc8a09a9d077d710a69804b31ad7bd
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41924
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2020-06-29 15:19:03 +00:00
David Benjamin 430a742303 Const-correct various functions in crypto/asn1.
The const ASN1_TIME getters don't work well because some const functions
aren't marked as such. I took a pass over the header and fixed the ones
I noticed.

Change-Id: I7eede530abc14ba0aab5763561c6f2dcf09e9659
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41824
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-06-23 17:57:25 +00:00
Pete Bentley d1d8eee76b Remove uneeded switch statement.
Warnings for switch statements with just a default case are
now fatal with the latest Windows toolchain used by Github
workflows. So indirectly this was breaking Conscrypt's
continuous integration and possibly other projects using
BoringSSL which run CI on Windows.

Example: https://github.com/google/conscrypt/runs/793502854?check_suite_focus=true

Change-Id: Ia09b86f3292299089c6536862a170677a8024984
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41844
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-06-22 14:06:04 +00:00
David Benjamin 33f8d33af0 Convert X.509 accessor macros to proper functions.
We'll need the accessors to be functions if we ever make X509 opaque.
Functions are also type-checked and avoid confusing code search's cross
reference features.

Update-Note: This should be compatible, but it is possible that someone,
e.g., passed in a bssl::UniquePtr<X509> to an accessor and relied on
operator->. Callers may also run afoul of const correctness. I mirrored
OpenSSL 1.1.1's consts, so it should at least be compatible with
third-party code.

Change-Id: I65dadc4e9ac0042576dc4db0f194d2e6b786ccca
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41808
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-06-19 22:28:52 +00:00
David Benjamin d206a11d48 Remove X509_CINF_get_issuer and X509_CINF_get_extensions.
The X509_CINF_* macros were removed before OpenSSL 1.0.2 was released
but after we forked. X509_CINF_set_modified and X509_CINF_get_signature
have some users to clean up, but these two are unused.

(OpenSSL 1.1.x's new X.509 API effectively no longer exposes X509_CINF
at all. If we could align, that would simplify switching to retaining
the full encoding rather than just TBSCertificate. But I think we'll
need to add some functions to replace a few use cases they missed.)

Update-Note: Two unused macros were removed. If there were uses, the
X509-level accessors can be used instead.

Change-Id: I9b5c7c08196885ee0bccc2658b1ad177bf3100e7
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41807
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-06-19 22:13:52 +00:00
David Benjamin beaf594f8b Remove X509_get_signature_type.
This macro dates to SSLeay. It is never used and for good reason: it
doesn't do anything. EVP_PKEY_type returns NID_undef if the NID is not
key type, but it is being passed in a signature algorithm type. This
means that, except for invalid certificates, or the rare algorithms
where the two OIDs match (Ed25519), it always returns NID_undef.

Update-Note: If there are any calls to X509_get_signature_type, remove
them. It more-or-less always returned NID_undef.

Change-Id: I6e2e41f171143c28f2afce2890f029b776cc36b5
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41806
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-06-19 21:46:02 +00:00
David Benjamin 991d31bbf1 clang-format x509.h and run comment converter.
We never updated it to OpenSSL's new indentation style and it's already
pretty difficult to directly apply patches from upstream anyway.

Change-Id: I78f7f644c6d427f27c29f51c4e8ba54476ddeb2b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41805
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-06-19 21:35:42 +00:00
David Benjamin 9dd9d4fc24 Check AlgorithmIdentifier parameters for RSA and ECDSA signatures.
This aligns with the Chromium certificate verifier, which allows NULL or
empty for RSA and requires empty for ECDSA.

Bug: 342
Change-Id: I34acf68f63b4d133dd47b73144b2f27224c499ee
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41804
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-06-19 21:30:22 +00:00
David Benjamin a3cc7780e7 Remove some unimplemented prototypes.
We don't have the corresponding functions anyway.

Change-Id: I9771771f011da295db708ed8bc635b4748d0101b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41784
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-06-19 18:26:12 +00:00
David Benjamin dd86e75b24 Check the X.509 version when parsing.
This checks the X.509 version is valid and consistent with fields new to
those versions. These checks are also implemented by Chromium's
certificate verifier and should be compatible.

Update-Note: The X.509 parser is now a bit stricter. This may break some
malformed certificates which were previously incorrectly accepted.

Bug: 348, 351
Change-Id: I56f35d768d5e72948d22a9546fba3d257a75f409
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41746
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-06-19 18:16:11 +00:00
David Benjamin fd86eaa868 Fix x509v3_cache_extensions error-handling.
This imports https://github.com/openssl/openssl/pull/10756 from upstream
with a number of changes:

- Add tests.

- Rather than blindly return false in cert_self_signed, make that
  function a tri-state return. This gives better error-reporting when the
  leaf certificate has a bad extension and reduces the risk of confusing
  the verifier.

- Give x509v3_cache_extensions a return value rather than expecting
  everyone to check EXFLAG_INVALID. Switch X509_check_purpose calls to
  it when applicable.

- Rather than setting EXFLAG_INVALID on bad CRLs, fail the parse
  altogether. We're already in the d2i callback. (Nothing checks
  EXFLAG_INVALID on CRLs.)

- I've intentionally left the error unchecked in X509_cmp. OpenSSL's
  strategy is to return -2, but that's not a consistent comparison
  and may mess up sorts that depend on transitivity. This retains the
  current behavior where we consider all undigestable certs as equal
  to each other (modulo the opportunistic TBSCertificate double-check
  which should work most of the time). This is terrible, so I've filed
  https://crbug.com/boringssl/355 to track fixes here.

That last fix caught that I misread the spec when I generated
kKnownCriticalCRL and kUnknownCriticalCRL2. This fixes those and uses
the old kKnownCriticalCRL as a test for invalid extensions. (Those CRLs
were assembled by hand, so they don't indicate any software has been
encoding them wrong.)

Update-Note: The X.509 verifier now correctly rejects syntax errors in
important certificate extensions. This may break some malformed
certificates which were incorrectly accepted before.

Bug: 345
Change-Id: Ifb3a98ba62cd296920546bc718fda524bd55c024
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41745
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-06-19 16:55:51 +00:00
David Benjamin cbac9c3a2d Work around Windows command-line limits in embed_test_data.go.
Change-Id: I020f7c75d2ed160b16a62cb909d2113c318feb3c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41764
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-06-18 22:48:41 +00:00
David Benjamin 5ddc5b14d9 Move crypto/x509 test data into its own directory.
I'm about to add a lot more of these.

Change-Id: I2556e301dbed3ceb450e7070ffed46dc4d6de2b4
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41744
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-06-18 22:39:51 +00:00
David Benjamin 1b8194715e Test resumability of same, different, and default ticket keys.
If we were to accidentally leave the ticket keys zero-initialized, the
only tests that notice are DefaultTicketKeyInitialization (initial key
is not all zeros) and DefaultTicketKeyRotation (old key is not new key),
by way of querying the keys themselves.

Add some tests which additionally test the effects on resumption itself.

Change-Id: I3bfd3f1e082e3a466105dbdffa18621b81c53d17
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41564
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-06-18 22:09:51 +00:00
Jesko Jochum c179854243 Fixes warning when redefining PATH_MAX when building with MINGW.
Fixes warning thrown when compiling digest.cc with MinGW64, by only defining PATH_MAX, if it has not yet been defined.
Else building with MinGW64, throws the following warning:

<PATH_TO_SOURCE_FOLDER>\boringssl\src\tool\digest.cc:39: warning: "PATH_MAX" redefined
   39 | #define PATH_MAX MAX_PATH
      |
In file included from C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.3.0/include-fixed/limits.h:194,
                 from C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.3.0/include-fixed/syslimits.h:7,
                 from C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.3.0/include-fixed/limits.h:34,
                 from C:/msys64/mingw64/x86_64-w64-mingw32/include/pthread.h:67,
                 from C:/msys64/mingw64/include/c++/9.3.0/x86_64-w64-mingw32/bits/gthr-default.h:35,
                 from C:/msys64/mingw64/include/c++/9.3.0/x86_64-w64-mingw32/bits/gthr.h:148,
                 from C:/msys64/mingw64/include/c++/9.3.0/ext/atomicity.h:35,
                 from C:/msys64/mingw64/include/c++/9.3.0/memory:73,
                 from <PATH_TO_SOURCE_FOLDER>/boringssl/src/include/openssl/base.h:473,
                 from <PATH_TO_SOURCE_FOLDER>\boringssl\src\tool\digest.cc:15:
C:/msys64/mingw64/x86_64-w64-mingw32/include/limits.h:20: note: this is the location of the previous definition
   20 | #define PATH_MAX 260
      |

Change-Id: I29eb33ee8fad9e4e80d9348a0d5e4057dfac620c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41705
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-06-17 17:22:18 +00:00
David Benjamin 8afdbf04bd Abstract fd operations better in tool.
Windows and POSIX implement very similar fd operations, but differ
slightly:

- ssize_t in POSIX is usually int on Windows.
- POSIX needs EINTR retry loops.
- Windows wants _open rather than open, etc.
- POSIX fds and sockets are the same thing, while Windows sockets are
  HANDLEs and leaves fd as a C runtime construct.

Rather than ad-hoc macros and redefinitions of ssize_t (which reportedly
upset MINGW), add some actual abstractions. While I'm here, add a scoped
file descriptor type.

That still leaves recv/send which are only used in one file, so defined
a socket_result_t for them.

Change-Id: I17fca2a50c77191f573852bfd27553996e3e9c3f
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41725
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-06-16 20:48:22 +00:00
David Benjamin 884614c24f Use CMAKE_SIZEOF_VOID_P instead of CMAKE_CL_64
CMake's documentation says this is preferred.
https://cmake.org/cmake/help/latest/variable/CMAKE_CL_64.html

Reportedly, it also works better with MINGW, though we do not currently
support MINGW with the CMake build. See
https://boringssl-review.googlesource.com/c/boringssl/+/41704/

Change-Id: Ie5794306beeeff816b34ee98c7a0f8e0d4f99ec8
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41724
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-06-16 15:20:28 +00:00
David Benjamin cd8f3d36fe Enforce the keyUsage extension in TLS 1.2 client certs.
I've left this independent of SSL_set_enforce_rsa_key_usage because
client certificates in TLS always use the digitalSignature bit, RSA or
otherwise, so it's less likely that someone has messed it up, unlike
TLS 1.2 RSA server certificates.

Update-Note: Client certificates which do not support the
digitalSignature key usage will be rejected. They should either include
that bit or omit the keyUsage extension.

Bug: 349
Change-Id: I97bbf0c8e394f219ff75b686e0c14019f6d8c9a8
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41664
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-06-15 16:34:03 +00:00
David Benjamin 72b095d0d4 Reword some comments.
There were a handful of comments that use "blacklist" and "whitelist".
They are easy to fix.

Change-Id: I49a9592393b43fc85e92b4a00a585b504dede75a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41645
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-06-12 21:17:03 +00:00
Adam Langley 7f90eda55e Add “Z Computation” KAT.
FIPS updates will make this useful / mandatory in the future.

Change-Id: I9921e4f3fc8a8315dc85dc366f331b456572d49e
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41644
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-06-12 19:01:37 +00:00
Adam Langley 9c256d1d7f acvptool: handle negative sizeConstraint.
The NIST server has been updated and is now sending a sizeConstraint of
-1 to indicate that the large-upload process isn't needed. However, the
code was trying to put that in a uint64, which caused a parse error.

Change-Id: I9ee16918df13c229b0e889fa1248eb2e0a6a5fb2
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41605
Reviewed-by: David Benjamin <davidben@google.com>
2020-06-11 20:41:51 +00:00
Adam Langley 0313b59d5f Let memory hooks override the size prefix.
In order to efficiently track heap operations, the memory hooks may need
to store other information in the prefix area than the size that
BoringSSL uses by default. This change lets them manage the prefix how
they wish.

Change-Id: I5a4d98bed100aff2deaaabb3d23fab02f0be82aa
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41584
Reviewed-by: Adam Langley <alangley@gmail.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <alangley@gmail.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-06-11 18:41:45 +00:00
Adam Langley fbaf1c0546 acvptool: go fmt
Change-Id: If90e35bf4ef75d12cdbddc118611127b74bbafe6
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41604
Reviewed-by: Adam Langley <agl@google.com>
2020-06-10 22:15:02 +00:00
David Benjamin 251b5169fd Assert md_size > 0.
md_size is the size of a hash, so it cannot be zero. Add an assert since
it appears to have caused some confusion. The j >= md_size and
j -= md_size logic implicitly assumes md_size > 0. (It's another way to
stick a % md_size elsewhere which, likewise, assumes md_size > 0.)

The bug report itself is a false positive, but locally documenting
assumptions is good.

Bug: chromium:1092697
Change-Id: I3be0992552a300c6786cf1dc5ecfa881173a42e6
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41544
Reviewed-by: Steven Valdez <svaldez@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-06-09 17:08:35 +00:00
Adam Langley 88024df121 Remove -enable-ed25519 compat hack.
Change-Id: I2d5843b2dc957f8ae8e4d9a41cecd3268220cc1d
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41504
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-06-02 15:46:08 +00:00
Adam Langley 53a17f5524 Add a |SSL_process_tls13_new_session_ticket|.
This API processes a given NewSessionTicket message and returns a resumable
|SSL_SESSION| object that contains the ticket.

(Change by Cesar Ghali.)

Change-Id: I7426933b043865ca54d3cf597f7ecd54d493bf35
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41464
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-05-28 19:39:26 +00:00
David Benjamin 2309f645e5 Use ctr32 optimizations for AES_ctr128_encrypt.
There are a decent number of uses of this function directly. I've
attached this to bug 338. Arguably it makes it worse, though it does
help with aligning on ctr32, if that works out.

Bug: 338
Change-Id: I3dfc1305d359ec0c88d4f298fe1928bef7ec9877
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41426
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-05-26 19:04:16 +00:00
David Benjamin 8819e0be62 Test AES mode wrappers.
AES_ctr128_encrypt, in particular, has a decent number of external
callers but is completely untested. I haven't included
AES_cfb128_encrypt because its EVP_CIPHER counterpart is tested in
decrept_test. But the EVP_CIPHER counterpart simply calls
AES_cfb128_encrypt, so it's tested transitively.

Change-Id: I0133dbd5b13c2b4045a89a04f29240008a279186
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41425
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-05-26 18:03:03 +00:00
David Benjamin 81a998a637 Bump minimum CMake version.
CMake 3.2.1 was released in March 2015, which was over five years ago.

Change-Id: I8b76e1de3dba8732a143f86a3956c83fbb4306a7
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41444
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-05-26 16:37:04 +00:00
Nick Harper 851943277f Modify how QUIC 0-RTT go/no-go decision is made.
The previous implementation was too strict in its byte-for-byte equality
check including Transport Parameters, because the Transport Parameters
contain a field that QUIC requires be different on each connection. This
change still has BoringSSL do a byte-for-byte check, but now it is only
done over the quic_early_data_context. An additional requirement is
imposed that the quic_early_data_context must be set for early data
capable tickets to be issued.

Bug: 295
Change-Id: I5145c10752b41908b6807c3a3c967653b0c13f37
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41427
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-05-26 16:31:02 +00:00
David Benjamin 9701e84eff Remove RAND_set_urandom_fd.
Also update the documentation for RAND_enable_fork_unsafe_buffering. The
fd parameter is no longer used.

Update-Note: RAND_set_urandom_fd no longer exists. This was only called
by Chromium, which now uses CRYPTO_pre_sandbox_init.

Change-Id: I1659c1cc84a6f1edc01f6105fc07e80856e457fc
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41424
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-05-20 18:55:59 +00:00
David Benjamin 7b31d69f19 Document that getrandom support must be consistent.
Syscall-filtering sandboxes may make getrandom fail without crashing.
This will sometimes trigger the /dev/urandom fallback and sometimes not.

Change-Id: Ic824e5bfe6fcb99105fd285184243c4620447327
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41404
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2020-05-20 18:55:29 +00:00
Anna Sarai Rosenberg 8f12996be3 Fix docs link for SSL_CTX_load_verify_locations
Link is outdated; results in 404. Update link to match docs version in other links with redirected path to current link for that version.

Change-Id: I4c9bb2fe48d1b2bbf699773259d5eebad9461ddd
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41385
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-05-18 17:00:25 +00:00
Steven Valdez 78b3337a10 Fix TRUST_TOKEN experiment_v1 SRR map.
Change-Id: I9e5c9b016cc0b3b7926df850d470e6367eb9c0bc
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41364
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-05-14 19:21:22 +00:00
David Benjamin 3e4dfbb2f8 Add CRYPTO_pre_sandbox_init.
The intent is to replace the logic in [0] and allows Chromium to set up
the MADV_WIPEONFORK page without increasing sandbox syscall surface.
From there we can remove RAND_set_urandom_fd and trim a bit of
complexity from the PRNG logic.

[0] https://source.chromium.org/chromium/chromium/src/+/master:content/app/content_main_runner_impl.cc;l=333-341;drc=975850fa57e140ec696114477e9416a19f06d29f

Change-Id: I9b679e15da551a10302389556c6c77d192be662a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41326
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-05-14 18:17:12 +00:00
David Benjamin 9cf9d3eb06 Still query getauxval if reading /proc/cpuinfo fails.
If BoringSSL is used in a sandbox without /proc/cpuinfo, we will
silently act as if the CPU is missing capabilities, even though
getauxval may be available. We use /proc/cpuinfo to work around a
missing AT_HWCAP2 and ignore a particular broken CPU.

Ignoring the former fails closed, so it's safe to proceed. The latter
fails closed, but it is now vanishingly rare (even missing AT_HWCAP2 has
largely dropped off), so instead proceed with getauxval. This makes the
/proc paths largely optional.

Change-Id: Ib198c4f78ccdae874d55669b6a7508dfbeac0f44
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41325
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-05-14 17:33:22 +00:00
Nick Harper be28dd623f Add missing header to ec/wnaf.c
a810d82 added calls to OPENSSL_malloc in this file, but openssl/mem.h
was missing.

Change-Id: I77e19e61e92b1e73702cb3eb93b9c6e22aca9596
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41344
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-05-14 00:09:11 +00:00
David Benjamin b7acfff8e7 Fix OPENSSL_TSAN typo.
We weren't actually reducing MAX_BLINDINGS_PER_RSA under TSan.

Change-Id: Ib33dc1a1c0312bd3309a64f2600ec4d6e2ec9ddb
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41324
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2020-05-13 17:00:31 +00:00
David Benjamin 49e95dc0f3 Fix p256-x86_64-table.h indentation.
This makes clang-format a no-op. (I would not recommend running
clang-format on that file. It takes a while.)

Change-Id: Ie4bd93340be8fe586e774ce16b5aed1ab626bb0c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41165
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2020-05-12 19:40:02 +00:00
Ilya Tokar 1274d1d977 Enable avx2 implementation of sha1.
Before:
Did 19655000 SHA-1 (16 bytes) operations in 2000053us (157.2 MB/sec)
Did 5112000 SHA-1 (256 bytes) operations in 2000126us (654.3 MB/sec)
Did 1280000 SHA-1 (1350 bytes) operations in 2000559us (863.8 MB/sec)
Did 229000 SHA-1 (8192 bytes) operations in 2004784us (935.7 MB/sec)
Did 116000 SHA-1 (16384 bytes) operations in 2008224us (946.4 MB/sec)

After:
Did 20506000 SHA-1 (16 bytes) operations in 2000062us (164.0 MB/sec) [+4.3%]
Did 5659000 SHA-1 (256 bytes) operations in 2000100us (724.3 MB/sec) [+10.7%]
Did 1454000 SHA-1 (1350 bytes) operations in 2000739us (981.1 MB/sec) [+13.6%]
Did 255000 SHA-1 (8192 bytes) operations in 2000733us (1044.1 MB/sec) [+11.6%]
Did 129000 SHA-1 (16384 bytes) operations in 2009483us (1051.8 MB/sec) [+11.1%]

Change-Id: Idaf75e92b2da4d83b597771aca1123f2884d7687
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41284
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-05-12 19:32:02 +00:00
David Benjamin d4d501c159 Trim Z coordinates from the OPENSSL_SMALL P-256 tables.
The small P-256 tables currently store 2 * 16 points in Jacobian
coordinates, but all the Z values are one, except for the two entries
which store infinity. Instead, store only affine coordinates and omit
the infinity entries. (We can recover infinity with constant-time
selects.)

This trims 1152 bytes from the table. Comparing the sizes of the bssl
tool (stripped, otherwise debug symbols undo the size gain), the binary
is 4096 bytes smaller, but I suspect this is just an artifact of
something rounding to page sizes.

Along the way, I've scripted the table generation and merged it into a
much generalized version of make_p256-x86_64-table.go.

As a bonus, by cutting the size of the table we scan, it's faster!
(ECDSA verify was already not scanning a table, so that one staying the
same is expected.)

Before:
Did 22302 ECDH P-256 operations in 4009795us (5561.9 ops/sec)
Did 62000 ECDSA P-256 signing operations in 4020075us (15422.6 ops/sec)
Did 26544 ECDSA P-256 verify operations in 4056526us (6543.5 ops/sec)

After:
Did 23001 ECDH P-256 operations in 4016544us (5726.6 ops/sec) [+3.0%]
Did 66000 ECDSA P-256 signing operations in 4043083us (16324.2 ops/sec) [+5.8%]
Did 26544 ECDSA P-256 verify operations in 4051220us (6552.1 ops/sec) [+0.1%]

Change-Id: Ie88898fd56e57505e3a325c50bbaf0dc5d42eeb3
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41164
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-05-12 19:24:22 +00:00
David Benjamin a810d82575 Use public multi-scalar mults in Trust Tokens where applicable.
The input points are all public, so we can use a faster multi-scalar
multiplication. This generalizes ec_point_mul_scalar_public to
ec_point_mul_scalar_public_batch. To support the batched DLEQ
construction, this function takes an arbirarily-length array of points
and allocates some temporaries if necessary.

First, to confirm that this doesn't affect the basic ECDSA verify case:
Before:
Did 6324 ECDSA P-384 verify operations in 3069342us (2060.4 ops/sec)
After:
Did 6324 ECDSA P-384 verify operations in 3063355us (2064.4 ops/sec) [+0.2%]

Results for Trust Tokens issue (Exp1) and finish_issuance (both):
Before:
Did 147 TrustToken-Exp0-Batch1 finish_issuance operations in 2059145us (71.4 ops/sec)
Did 14 TrustToken-Exp0-Batch10 finish_issuance operations in 2085888us (6.7 ops/sec)
Did 357 TrustToken-Exp1-Batch1 issue operations in 2068238us (172.6 ops/sec)
Did 286 TrustToken-Exp1-Batch1 finish_issuance operations in 2090932us (136.8 ops/sec)
Did 63 TrustToken-Exp1-Batch10 issue operations in 2068201us (30.5 ops/sec)
Did 56 TrustToken-Exp1-Batch10 finish_issuance operations in 2064796us (27.1 ops/sec)

After:
Did 168 TrustToken-Exp0-Batch1 finish_issuance operations in 2058891us (81.6 ops/sec) [+14.3%]
Did 16 TrustToken-Exp0-Batch10 finish_issuance operations in 2075742us (7.7 ops/sec) [+14.8%]
Did 378 TrustToken-Exp1-Batch1 issue operations in 2067956us (182.8 ops/sec) [+5.9%]
Did 336 TrustToken-Exp1-Batch1 finish_issuance operations in 2097757us (160.2 ops/sec) [+17.1%]
Did 105 TrustToken-Exp1-Batch10 issue operations in 2069934us (50.7 ops/sec) [+66.5%]
Did 88 TrustToken-Exp1-Batch10 finish_issuance operations in 2014621us (43.7 ops/sec) [+61.1%]

(This CL doesn't affect other operations.)

Change-Id: Ie643b06f44990ab52bf892a007732fde61cdffe5
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41285
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-05-12 17:38:55 +00:00
Steven Valdez b55a8c1580 Use batched DLEQ proofs for Trust Token.
Before:
Did 867 TrustToken-Exp1-Batch1 generate_key operations in 1029740us (842.0 ops/sec)
Did 1441 TrustToken-Exp1-Batch1 begin_issuance operations in 1021088us (1411.2 ops/sec)
Did 200 TrustToken-Exp1-Batch1 issue operations in 1003145us (199.4 ops/sec)
Did 154 TrustToken-Exp1-Batch1 finish_issuance operations in 1053858us (146.1 ops/sec)
Did 5128000 TrustToken-Exp1-Batch1 begin_redemption operations in 1000076us (5127610.3 ops/sec)
Did 517 TrustToken-Exp1-Batch1 redeem operations in 1031054us (501.4 ops/sec)
Did 15000 TrustToken-Exp1-Batch1 finish_redemption operations in 1041906us (14396.7 ops/sec)
Did 870 TrustToken-Exp1-Batch10 generate_key operations in 1020929us (852.2 ops/sec)
Did 154 TrustToken-Exp1-Batch10 begin_issuance operations in 1085963us (141.8 ops/sec)
Did 20 TrustToken-Exp1-Batch10 issue operations in 1040995us (19.2 ops/sec)
Did 14 TrustToken-Exp1-Batch10 finish_issuance operations in 1009041us (13.9 ops/sec)
Did 5138000 TrustToken-Exp1-Batch10 begin_redemption operations in 1000114us (5137414.3 ops/sec)
Did 528 TrustToken-Exp1-Batch10 redeem operations in 1026978us (514.1 ops/sec)
Did 15000 TrustToken-Exp1-Batch10 finish_redemption operations in 1016920us (14750.4 ops/sec)

After:
Did 900 TrustToken-Exp1-Batch1 generate_key operations in 1032678us (871.5 ops/sec) [+3.5%]
Did 1410 TrustToken-Exp1-Batch1 begin_issuance operations in 1004439us (1403.8 ops/sec) [-0.5%]
Did 154 TrustToken-Exp1-Batch1 issue operations in 1068370us (144.1 ops/sec) [-27.7%]
Did 121 TrustToken-Exp1-Batch1 finish_issuance operations in 1048767us (115.4 ops/sec) [-21.0%]
Did 5179000 TrustToken-Exp1-Batch1 begin_redemption operations in 1000159us (5178176.7 ops/sec) [+1.0%]
Did 572 TrustToken-Exp1-Batch1 redeem operations in 1093354us (523.2 ops/sec) [+4.3%]
Did 15000 TrustToken-Exp1-Batch1 finish_redemption operations in 1001506us (14977.4 ops/sec) [+4.0%]
Did 913 TrustToken-Exp1-Batch10 generate_key operations in 1027546us (888.5 ops/sec) [+4.3%]
Did 154 TrustToken-Exp1-Batch10 begin_issuance operations in 1051530us (146.5 ops/sec) [+3.3%]
Did 26 TrustToken-Exp1-Batch10 issue operations in 1027599us (25.3 ops/sec) [+31.7%]
Did 24 TrustToken-Exp1-Batch10 finish_issuance operations in 1055615us (22.7 ops/sec) [+63.9%]
Did 5100000 TrustToken-Exp1-Batch10 begin_redemption operations in 1000201us (5098975.1 ops/sec) [-0.7%]
Did 561 TrustToken-Exp1-Batch10 redeem operations in 1072683us (523.0 ops/sec) [+1.7%]
Did 15000 TrustToken-Exp1-Batch10 finish_redemption operations in 1006697us (14900.2 ops/sec) [+1.0%]

Change-Id: Ibdc08f9d63e62dda14a2cd9e9d8be27c8723675b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40865
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-05-12 17:09:54 +00:00
Nick Harper 7c522995d1 Restrict when 0-RTT will be accepted in QUIC.
QUIC imposes additional restrictions on when 0-RTT data can be accepted.
With this change, a QUIC server configured to support 0-RTT will only
accept early data if the transport parameters and application protocol
specific context are a byte-for-byte match from the original connection
to the 0-RTT resumption attempt.

Bug: 295
Change-Id: Ie5d4688d1c9076b49f2131bb66b27c87e2ba041a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41145
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-05-08 15:08:00 +00:00
Nick Harper e32549edf9 Disable TLS 1.3 compatibility mode for QUIC.
Bug: 335
Change-Id: Ic22dafbc4ada3af56260bc7213f0078876e56c3d
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41244
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-05-07 23:25:51 +00:00
David Benjamin d4a97fa65f Use a 5-bit comb for some Trust Tokens multiplications.
Several of the Trust Tokens multiplications use repeated points (G, H,
and the public keys). We can precompute a 5-bit comb for those points
and perform only 1/5th as many doubles in the multiplication.

Before:
Did 483 TrustToken-Exp0-Batch1 generate_key operations in 2017082us (239.5 ops/sec)
Did 1449 TrustToken-Exp0-Batch1 begin_issuance operations in 2086097us (694.6 ops/sec)
Did 176 TrustToken-Exp0-Batch1 issue operations in 2089640us (84.2 ops/sec)
Did 147 TrustToken-Exp0-Batch1 finish_issuance operations in 2027924us (72.5 ops/sec)
Did 12284000 TrustToken-Exp0-Batch1 begin_redemption operations in 2000151us (6141536.3 ops/sec)
Did 483 TrustToken-Exp0-Batch1 redeem operations in 2063241us (234.1 ops/sec)
Did 35000 TrustToken-Exp0-Batch1 finish_redemption operations in 2050694us (17067.4 ops/sec)
Did 483 TrustToken-Exp0-Batch10 generate_key operations in 2003222us (241.1 ops/sec)
Did 138 TrustToken-Exp0-Batch10 begin_issuance operations in 2000845us (69.0 ops/sec)
Did 16 TrustToken-Exp0-Batch10 issue operations in 2010264us (8.0 ops/sec)
Did 14 TrustToken-Exp0-Batch10 finish_issuance operations in 2036137us (6.9 ops/sec)
Did 12106000 TrustToken-Exp0-Batch10 begin_redemption operations in 2000126us (6052618.7 ops/sec)
Did 483 TrustToken-Exp0-Batch10 redeem operations in 2062366us (234.2 ops/sec)
Did 35000 TrustToken-Exp0-Batch10 finish_redemption operations in 2023617us (17295.8 ops/sec)

Did 1254 TrustToken-Exp1-Batch1 generate_key operations in 2086776us (600.9 ops/sec)
Did 3612 TrustToken-Exp1-Batch1 begin_issuance operations in 2052090us (1760.2 ops/sec)
Did 420 TrustToken-Exp1-Batch1 issue operations in 2002421us (209.7 ops/sec)
Did 378 TrustToken-Exp1-Batch1 finish_issuance operations in 2078074us (181.9 ops/sec)
Did 12843000 TrustToken-Exp1-Batch1 begin_redemption operations in 2000068us (6421281.7 ops/sec)
Did 1210 TrustToken-Exp1-Batch1 redeem operations in 2083419us (580.8 ops/sec)
Did 35000 TrustToken-Exp1-Batch1 finish_redemption operations in 2023704us (17295.0 ops/sec)
Did 1239 TrustToken-Exp1-Batch10 generate_key operations in 2060962us (601.2 ops/sec)
Did 357 TrustToken-Exp1-Batch10 begin_issuance operations in 2031131us (175.8 ops/sec)
Did 42 TrustToken-Exp1-Batch10 issue operations in 2045185us (20.5 ops/sec)
Did 36 TrustToken-Exp1-Batch10 finish_issuance operations in 2028604us (17.7 ops/sec)
Did 12435000 TrustToken-Exp1-Batch10 begin_redemption operations in 2000084us (6217238.9 ops/sec)
Did 1176 TrustToken-Exp1-Batch10 redeem operations in 2023934us (581.0 ops/sec)
Did 35000 TrustToken-Exp1-Batch10 finish_redemption operations in 2002899us (17474.7 ops/sec)

After:
Did 875 TrustToken-Exp0-Batch1 generate_key operations in 2028222us (431.4 ops/sec) [+80.2%]
Did 1449 TrustToken-Exp0-Batch1 begin_issuance operations in 2097298us (690.9 ops/sec) [-0.5%]
Did 207 TrustToken-Exp0-Batch1 issue operations in 2083578us (99.3 ops/sec) [+18.0%]
Did 147 TrustToken-Exp0-Batch1 finish_issuance operations in 2018783us (72.8 ops/sec) [+0.5%]
Did 12020250 TrustToken-Exp0-Batch1 begin_redemption operations in 2000036us (6010016.8 ops/sec) [-2.1%]
Did 525 TrustToken-Exp0-Batch1 redeem operations in 2077137us (252.8 ops/sec) [+8.0%]
Did 35000 TrustToken-Exp0-Batch1 finish_redemption operations in 2006257us (17445.4 ops/sec) [+2.2%]
Did 903 TrustToken-Exp0-Batch10 generate_key operations in 2091846us (431.7 ops/sec) [+79.0%]
Did 138 TrustToken-Exp0-Batch10 begin_issuance operations in 2006432us (68.8 ops/sec) [-0.3%]
Did 19 TrustToken-Exp0-Batch10 issue operations in 2000665us (9.5 ops/sec) [+19.3%]
Did 14 TrustToken-Exp0-Batch10 finish_issuance operations in 2045846us (6.8 ops/sec) [-0.5%]
Did 12124000 TrustToken-Exp0-Batch10 begin_redemption operations in 2000055us (6061833.3 ops/sec) [+0.2%]
Did 525 TrustToken-Exp0-Batch10 redeem operations in 2076637us (252.8 ops/sec) [+7.9%]
Did 35000 TrustToken-Exp0-Batch10 finish_redemption operations in 2000072us (17499.4 ops/sec) [+1.2%]

Did 2142 TrustToken-Exp1-Batch1 generate_key operations in 2031447us (1054.4 ops/sec) [+75.5%]
Did 3633 TrustToken-Exp1-Batch1 begin_issuance operations in 2073265us (1752.3 ops/sec) [-0.4%]
Did 504 TrustToken-Exp1-Batch1 issue operations in 2043677us (246.6 ops/sec) [+17.6%]
Did 378 TrustToken-Exp1-Batch1 finish_issuance operations in 2086624us (181.2 ops/sec) [-0.4%]
Did 12548250 TrustToken-Exp1-Batch1 begin_redemption operations in 2000020us (6274062.3 ops/sec) [-2.3%]
Did 1281 TrustToken-Exp1-Batch1 redeem operations in 2067790us (619.5 ops/sec) [+6.7%]
Did 35000 TrustToken-Exp1-Batch1 finish_redemption operations in 2012117us (17394.6 ops/sec) [+0.6%]
Did 2184 TrustToken-Exp1-Batch10 generate_key operations in 2069977us (1055.1 ops/sec) [+75.5%]
Did 357 TrustToken-Exp1-Batch10 begin_issuance operations in 2041930us (174.8 ops/sec) [-0.5%]
Did 50 TrustToken-Exp1-Batch10 issue operations in 2063927us (24.2 ops/sec) [+18.0%]
Did 36 TrustToken-Exp1-Batch10 finish_issuance operations in 2038115us (17.7 ops/sec) [-0.5%]
Did 12693000 TrustToken-Exp1-Batch10 begin_redemption operations in 2000070us (6346277.9 ops/sec) [+2.1%]
Did 1281 TrustToken-Exp1-Batch10 redeem operations in 2066940us (619.8 ops/sec) [+6.7%]
Did 35000 TrustToken-Exp1-Batch10 finish_redemption operations in 2020506us (17322.4 ops/sec) [-0.9%]

Change-Id: Id26600c07401d6567275155aa389839ac0e87013
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41124
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2020-05-07 18:16:27 +00:00
David Benjamin 5f43b12d52 Use a (mostly) constant-time multi-scalar mult for Trust Tokens.
With multi-scalar multiplication, we're stuck pondering the doubling
case. But it's fine for trust tokens, because the points are independent
and the scalars are uniformly generated and not under attacker control.
That means the probability of hitting a double is negligible. (It's
equivalent to accidentally finding the discrete log of two independent
points.)

Before:
Did 306 TrustToken-Exp0-Batch1 generate_key operations in 2000725us (152.9 ops/sec)
Did 1428 TrustToken-Exp0-Batch1 begin_issuance operations in 2080325us (686.4 ops/sec)
Did 105 TrustToken-Exp0-Batch1 issue operations in 2070658us (50.7 ops/sec)
Did 88 TrustToken-Exp0-Batch1 finish_issuance operations in 2023864us (43.5 ops/sec)
Did 12283000 TrustToken-Exp0-Batch1 begin_redemption operations in 2000063us (6141306.5 ops/sec)
Did 315 TrustToken-Exp0-Batch1 redeem operations in 2084451us (151.1 ops/sec)
Did 35000 TrustToken-Exp0-Batch1 finish_redemption operations in 2024388us (17289.2 ops/sec)
Did 315 TrustToken-Exp0-Batch10 generate_key operations in 2045481us (154.0 ops/sec)
Did 138 TrustToken-Exp0-Batch10 begin_issuance operations in 2022158us (68.2 ops/sec)
Did 10 TrustToken-Exp0-Batch10 issue operations in 2148640us (4.7 ops/sec)
Did 8 TrustToken-Exp0-Batch10 finish_issuance operations in 2047452us (3.9 ops/sec)
Did 12167000 TrustToken-Exp0-Batch10 begin_redemption operations in 2000118us (6083141.1 ops/sec)
Did 315 TrustToken-Exp0-Batch10 redeem operations in 2084853us (151.1 ops/sec)
Did 35000 TrustToken-Exp0-Batch10 finish_redemption operations in 2014997us (17369.8 ops/sec)

Did 777 TrustToken-Exp1-Batch1 generate_key operations in 2034967us (381.8 ops/sec)
Did 3612 TrustToken-Exp1-Batch1 begin_issuance operations in 2052618us (1759.7 ops/sec)
Did 264 TrustToken-Exp1-Batch1 issue operations in 2084327us (126.7 ops/sec)
Did 220 TrustToken-Exp1-Batch1 finish_issuance operations in 2024603us (108.7 ops/sec)
Did 12691000 TrustToken-Exp1-Batch1 begin_redemption operations in 2000111us (6345147.8 ops/sec)
Did 777 TrustToken-Exp1-Batch1 redeem operations in 2070867us (375.2 ops/sec)
Did 35000 TrustToken-Exp1-Batch1 finish_redemption operations in 2019118us (17334.3 ops/sec)
Did 798 TrustToken-Exp1-Batch10 generate_key operations in 2090816us (381.7 ops/sec)
Did 357 TrustToken-Exp1-Batch10 begin_issuance operations in 2032751us (175.6 ops/sec)
Did 25 TrustToken-Exp1-Batch10 issue operations in 2046353us (12.2 ops/sec)
Did 21 TrustToken-Exp1-Batch10 finish_issuance operations in 2015579us (10.4 ops/sec)
Did 12695000 TrustToken-Exp1-Batch10 begin_redemption operations in 2000126us (6347100.1 ops/sec)
Did 740 TrustToken-Exp1-Batch10 redeem operations in 2032413us (364.1 ops/sec)
Did 35000 TrustToken-Exp1-Batch10 finish_redemption operations in 2011564us (17399.4 ops/sec)

After:
Did 483 TrustToken-Exp0-Batch1 generate_key operations in 2003131us (241.1 ops/sec) [+57.7%]
Did 1449 TrustToken-Exp0-Batch1 begin_issuance operations in 2089317us (693.5 ops/sec) [+1.0%]
Did 176 TrustToken-Exp0-Batch1 issue operations in 2094210us (84.0 ops/sec) [+65.7%]
Did 147 TrustToken-Exp0-Batch1 finish_issuance operations in 2006750us (73.3 ops/sec) [+68.5%]
Did 12217000 TrustToken-Exp0-Batch1 begin_redemption operations in 2000094us (6108212.9 ops/sec) [-0.5%]
Did 483 TrustToken-Exp0-Batch1 redeem operations in 2058132us (234.7 ops/sec) [+55.3%]
Did 35000 TrustToken-Exp0-Batch1 finish_redemption operations in 2026970us (17267.2 ops/sec) [-0.1%]
Did 504 TrustToken-Exp0-Batch10 generate_key operations in 2086204us (241.6 ops/sec) [+56.9%]
Did 144 TrustToken-Exp0-Batch10 begin_issuance operations in 2084670us (69.1 ops/sec) [+1.2%]
Did 16 TrustToken-Exp0-Batch10 issue operations in 2008793us (8.0 ops/sec) [+71.1%]
Did 14 TrustToken-Exp0-Batch10 finish_issuance operations in 2033577us (6.9 ops/sec) [+76.2%]
Did 12026000 TrustToken-Exp0-Batch10 begin_redemption operations in 2000018us (6012945.9 ops/sec) [-1.2%]
Did 483 TrustToken-Exp0-Batch10 redeem operations in 2056418us (234.9 ops/sec) [+55.5%]
Did 35000 TrustToken-Exp0-Batch10 finish_redemption operations in 2046766us (17100.1 ops/sec) [-1.6%]

Did 1239 TrustToken-Exp1-Batch1 generate_key operations in 2060737us (601.2 ops/sec) [+57.5%]
Did 3675 TrustToken-Exp1-Batch1 begin_issuance operations in 2085293us (1762.3 ops/sec) [+0.1%]
Did 420 TrustToken-Exp1-Batch1 issue operations in 2008121us (209.2 ops/sec) [+65.1%]
Did 378 TrustToken-Exp1-Batch1 finish_issuance operations in 2077226us (182.0 ops/sec) [+67.5%]
Did 12783000 TrustToken-Exp1-Batch1 begin_redemption operations in 2000134us (6391071.8 ops/sec) [+0.7%]
Did 1197 TrustToken-Exp1-Batch1 redeem operations in 2056802us (582.0 ops/sec) [+55.1%]
Did 35000 TrustToken-Exp1-Batch1 finish_redemption operations in 2030955us (17233.3 ops/sec) [-0.6%]
Did 1260 TrustToken-Exp1-Batch10 generate_key operations in 2095507us (601.3 ops/sec) [+57.5%]
Did 357 TrustToken-Exp1-Batch10 begin_issuance operations in 2029693us (175.9 ops/sec) [+0.2%]
Did 42 TrustToken-Exp1-Batch10 issue operations in 2050856us (20.5 ops/sec) [+67.6%]
Did 36 TrustToken-Exp1-Batch10 finish_issuance operations in 2027488us (17.8 ops/sec) [+70.4%]
Did 12140000 TrustToken-Exp1-Batch10 begin_redemption operations in 2000070us (6069787.6 ops/sec) [-4.4%]
Did 1210 TrustToken-Exp1-Batch10 redeem operations in 2079615us (581.8 ops/sec) [+59.8%]
Did 34000 TrustToken-Exp1-Batch10 finish_redemption operations in 2052918us (16561.8 ops/sec) [-4.8%]

Change-Id: Idd51d7e1d18f3b94edc4105e68fd50b5f44d87cd
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41104
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2020-05-07 17:10:36 +00:00
David Benjamin ce1665b825 Batch inversions in Trust Tokens.
The DLEQ and DLEQOR proofs require converting many Jacobian points to
affine, some multiple times. The inversions involved can be batched.

This buys us a +5-8% improvement in token issuance speed. issue and
finish_issue should each only perform two inversions per token now. We
could save an inversion per token by changing the dleq_generate and
dleq_verify function signatures, but that would complicate the likely
more valuable batched DLEQ(OR) optimization, so I've left those alone.

Before:
Did 300 TrustToken-Exp0-Batch1 generate_key operations in 2031798us (147.7 ops/sec)
Did 1449 TrustToken-Exp0-Batch1 begin_issuance operations in 2093639us (692.1 ops/sec)
Did 96 TrustToken-Exp0-Batch1 issue operations in 2044310us (47.0 ops/sec)
Did 84 TrustToken-Exp0-Batch1 finish_issuance operations in 2072137us (40.5 ops/sec)
Did 12170000 TrustToken-Exp0-Batch1 begin_redemption operations in 2000098us (6084701.8 ops/sec)
Did 315 TrustToken-Exp0-Batch1 redeem operations in 2091938us (150.6 ops/sec)
Did 35000 TrustToken-Exp0-Batch1 finish_redemption operations in 2004900us (17457.2 ops/sec)
Did 308 TrustToken-Exp0-Batch10 generate_key operations in 2067860us (148.9 ops/sec)
Did 138 TrustToken-Exp0-Batch10 begin_issuance operations in 2005706us (68.8 ops/sec)
Did 9 TrustToken-Exp0-Batch10 issue operations in 2107753us (4.3 ops/sec)
Did 8 TrustToken-Exp0-Batch10 finish_issuance operations in 2193489us (3.6 ops/sec)
Did 12046750 TrustToken-Exp0-Batch10 begin_redemption operations in 2000025us (6023299.7 ops/sec)
Did 315 TrustToken-Exp0-Batch10 redeem operations in 2091940us (150.6 ops/sec)
Did 35000 TrustToken-Exp0-Batch10 finish_redemption operations in 2008851us (17422.9 ops/sec)

Did 756 TrustToken-Exp1-Batch1 generate_key operations in 2051005us (368.6 ops/sec)
Did 3633 TrustToken-Exp1-Batch1 begin_issuance operations in 2072577us (1752.9 ops/sec)
Did 242 TrustToken-Exp1-Batch1 issue operations in 2052091us (117.9 ops/sec)
Did 210 TrustToken-Exp1-Batch1 finish_issuance operations in 2058740us (102.0 ops/sec)
Did 12477000 TrustToken-Exp1-Batch1 begin_redemption operations in 2000004us (6238487.5 ops/sec)
Did 777 TrustToken-Exp1-Batch1 redeem operations in 2084953us (372.7 ops/sec)
Did 35000 TrustToken-Exp1-Batch1 finish_redemption operations in 2028286us (17255.9 ops/sec)
Did 756 TrustToken-Exp1-Batch10 generate_key operations in 2051178us (368.6 ops/sec)
Did 357 TrustToken-Exp1-Batch10 begin_issuance operations in 2041875us (174.8 ops/sec)
Did 23 TrustToken-Exp1-Batch10 issue operations in 2026494us (11.3 ops/sec)
Did 20 TrustToken-Exp1-Batch10 finish_issuance operations in 2048478us (9.8 ops/sec)
Did 12492000 TrustToken-Exp1-Batch10 begin_redemption operations in 2000053us (6245834.5 ops/sec)
Did 777 TrustToken-Exp1-Batch10 redeem operations in 2084956us (372.7 ops/sec)
Did 36000 TrustToken-Exp1-Batch10 finish_redemption operations in 2021991us (17804.2 ops/sec)

After:
Did 315 TrustToken-Exp0-Batch1 generate_key operations in 2046638us (153.9 ops/sec) [+4.2%]
Did 1449 TrustToken-Exp0-Batch1 begin_issuance operations in 2087930us (694.0 ops/sec) [+0.3%]
Did 105 TrustToken-Exp0-Batch1 issue operations in 2071104us (50.7 ops/sec) [+8.0%]
Did 88 TrustToken-Exp0-Batch1 finish_issuance operations in 2023502us (43.5 ops/sec) [+7.3%]
Did 11847000 TrustToken-Exp0-Batch1 begin_redemption operations in 2000041us (5923378.6 ops/sec) [-2.7%]
Did 315 TrustToken-Exp0-Batch1 redeem operations in 2084116us (151.1 ops/sec) [+0.4%]
Did 35000 TrustToken-Exp0-Batch1 finish_redemption operations in 2003732us (17467.4 ops/sec) [+0.1%]
Did 315 TrustToken-Exp0-Batch10 generate_key operations in 2046863us (153.9 ops/sec) [+3.3%]
Did 138 TrustToken-Exp0-Batch10 begin_issuance operations in 2000108us (69.0 ops/sec) [+0.3%]
Did 10 TrustToken-Exp0-Batch10 issue operations in 2149283us (4.7 ops/sec) [+9.0%]
Did 8 TrustToken-Exp0-Batch10 finish_issuance operations in 2046416us (3.9 ops/sec) [+7.2%]
Did 12112000 TrustToken-Exp0-Batch10 begin_redemption operations in 2000077us (6055766.9 ops/sec) [+0.5%]
Did 315 TrustToken-Exp0-Batch10 redeem operations in 2084427us (151.1 ops/sec) [+0.4%]
Did 35000 TrustToken-Exp0-Batch10 finish_redemption operations in 2015111us (17368.8 ops/sec) [-0.3%]

Did 777 TrustToken-Exp1-Batch1 generate_key operations in 2029777us (382.8 ops/sec) [+3.9%]
Did 3654 TrustToken-Exp1-Batch1 begin_issuance operations in 2093484us (1745.4 ops/sec) [-0.4%]
Did 252 TrustToken-Exp1-Batch1 issue operations in 2024557us (124.5 ops/sec) [+5.5%]
Did 220 TrustToken-Exp1-Batch1 finish_issuance operations in 2034633us (108.1 ops/sec) [+6.0%]
Did 12659000 TrustToken-Exp1-Batch1 begin_redemption operations in 2000112us (6329145.6 ops/sec) [+1.5%]
Did 777 TrustToken-Exp1-Batch1 redeem operations in 2073783us (374.7 ops/sec) [+0.5%]
Did 35000 TrustToken-Exp1-Batch1 finish_redemption operations in 2050371us (17070.1 ops/sec) [-1.1%]
Did 768 TrustToken-Exp1-Batch10 generate_key operations in 2025482us (379.2 ops/sec) [+2.9%]
Did 357 TrustToken-Exp1-Batch10 begin_issuance operations in 2034429us (175.5 ops/sec) [+0.4%]
Did 25 TrustToken-Exp1-Batch10 issue operations in 2049293us (12.2 ops/sec) [+7.5%]
Did 21 TrustToken-Exp1-Batch10 finish_issuance operations in 2022256us (10.4 ops/sec) [+6.4%]
Did 12702000 TrustToken-Exp1-Batch10 begin_redemption operations in 2000015us (6350952.4 ops/sec) [+1.7%]
Did 777 TrustToken-Exp1-Batch10 redeem operations in 2072048us (375.0 ops/sec) [+0.6%]
Did 35000 TrustToken-Exp1-Batch10 finish_redemption operations in 2024580us (17287.5 ops/sec) [-2.9%]

Change-Id: Ia1b09cd14aa8ce0935d18033fb4bd75666a258e9
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41086
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2020-05-07 16:45:06 +00:00
David Benjamin 54a59c68b7 Rearrange the DLEQ logic slightly.
The DLEQ logic needs to convert many points to affine coordinates at the
Hc computations. Rearrange things so the two happen concurrently, which
will allow us to batch the inversions.

Change-Id: I09bb053788f1555547272bf9af19b54e0fe7c325
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41085
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2020-05-05 18:55:28 +00:00
Steven Valdez 54304734eb Use token hash to encode private metadata for Trust Token Experiment V1.
Bug: 328
Change-Id: Iaf3ff1bbe2f21c622b974081281848c60a01f142
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40764
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-05-05 18:37:58 +00:00
David Benjamin 802523aa5f Introduce an EC_AFFINE abstraction.
PMBTokens ends up converting the same point to affine coordinates
repeatedly. Additionally, it converts many affine coordinates at once,
which we can batch. Introduce an EC_AFFINE type to store affine points
and move the inversion to the Jacobian -> affine conversion.

This does mean we lose the (negligible) Montgomery reduction
optimization in EC_GFp_mont. point_get_affine_coordinates no longer
breaks the EC_FELEM abstraction around Montgomery form.

Unfortunately, this complicates hardening of the callers not checking
return values because EC_AFFINE cannot represent the point at infinity
and, due to OpenSSL's API limitations, groups may not have generators
available and the generator is not affine at the type level. (EC_AFFINE
cannot represent the point at infinity.) Thus this CL:

- Tidies up some duplicate code in setting up the generator and ensures
  it always has Z = 1.
- ec_point_set_affine_coordinates hardens against unused results if the
  generator is configured. But this is ultimately an internal function.
- Retains the hardening on the public APIs by adding calls to
  ec_set_to_safe_point in two places.

This CL does not apply the optimization to Trust Tokens, only introduces
the EC_AFFINE abstraction. It additionally continues to store EC_POINTs
(used in ECDH and ECDSA) in Jacobian form. See
https://crbug.com/boringssl/326#c4 for a discussion on why this is
tricky. Those protocols are hopefully simple enough that they don't need
complexity around inversions.

Having an EC_AFFINE type will also be useful for computing custom tables
for Trust Token public keys, which gives a nice speedup.

Bug: 326
Change-Id: I11b010a33f36a15bac9939351df5205bd35cc665
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41084
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2020-05-05 16:55:18 +00:00
David Benjamin 73e0401e3d Make the fuzzer PRNG thread-safe.
We run some unit tests with multiple threads now. While that makes it no
longer deterministic, we should at least be thread-safe.

Change-Id: I5d75f2ff1ce76d0b7914cd6ea61bcf640aa085ab
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41184
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2020-05-04 18:27:17 +00:00
Adam Langley cccfb9bcf2 Disable fork-detect tests under TSAN.
TSAN can't cope with the pattern of forking and threading here and
exits with an error.

Change-Id: I3673004b62a45c5e910a4597f89764682a0b8d0a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41224
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-05-04 15:19:06 +00:00
David Benjamin aa764c46eb Introduce TRUST_TOKENS_experiment_v1.
This starts a new branch of the protocol using P-384 and draft-07 of
hash-to-curve. Mark it unstable for now as we aim to add batching and
other fixes.

Did 154 TrustToken-Exp0-Batch1 generate_key operations in 1033312us (149.0 ops/sec)
Did 748 TrustToken-Exp0-Batch1 begin_issuance operations in 1078707us (693.4 ops/sec)
Did 48 TrustToken-Exp0-Batch1 issue operations in 1030056us (46.6 ops/sec)
Did 44 TrustToken-Exp0-Batch1 finish_issuance operations in 1092816us (40.3 ops/sec)
Did 6040750 TrustToken-Exp0-Batch1 begin_redemption operations in 1000009us (6040695.6 ops/sec)
Did 154 TrustToken-Exp0-Batch1 redeem operations in 1023722us (150.4 ops/sec)
Did 18000 TrustToken-Exp0-Batch1 finish_redemption operations in 1021087us (17628.3 ops/sec)
Did 154 TrustToken-Exp0-Batch10 generate_key operations in 1032878us (149.1 ops/sec)
Did 72 TrustToken-Exp0-Batch10 begin_issuance operations in 1050908us (68.5 ops/sec)
Did 4 TrustToken-Exp0-Batch10 issue operations in 1051989us (3.8 ops/sec)
Did 4 TrustToken-Exp0-Batch10 finish_issuance operations in 1214996us (3.3 ops/sec)
Did 5987000 TrustToken-Exp0-Batch10 begin_redemption operations in 1000068us (5986592.9 ops/sec)
Did 154 TrustToken-Exp0-Batch10 redeem operations in 1037898us (148.4 ops/sec)
Did 18000 TrustToken-Exp0-Batch10 finish_redemption operations in 1024788us (17564.6 ops/sec)

Did 396 TrustToken-Exp1-Batch1 generate_key operations in 1060955us (373.2 ops/sec)
Did 1925 TrustToken-Exp1-Batch1 begin_issuance operations in 1093039us (1761.1 ops/sec)
Did 121 TrustToken-Exp1-Batch1 issue operations in 1022292us (118.4 ops/sec)
Did 110 TrustToken-Exp1-Batch1 finish_issuance operations in 1076011us (102.2 ops/sec)
Did 6322000 TrustToken-Exp1-Batch1 begin_redemption operations in 1000144us (6321089.8 ops/sec)
Did 407 TrustToken-Exp1-Batch1 redeem operations in 1087774us (374.2 ops/sec)
Did 18000 TrustToken-Exp1-Batch1 finish_redemption operations in 1031736us (17446.3 ops/sec)
Did 407 TrustToken-Exp1-Batch10 generate_key operations in 1090415us (373.3 ops/sec)
Did 187 TrustToken-Exp1-Batch10 begin_issuance operations in 1065754us (175.5 ops/sec)
Did 11 TrustToken-Exp1-Batch10 issue operations in 1005738us (10.9 ops/sec)
Did 10 TrustToken-Exp1-Batch10 finish_issuance operations in 1066494us (9.4 ops/sec)
Did 6302000 TrustToken-Exp1-Batch10 begin_redemption operations in 1000029us (6301817.2 ops/sec)
Did 407 TrustToken-Exp1-Batch10 redeem operations in 1087692us (374.2 ops/sec)
Did 18000 TrustToken-Exp1-Batch10 finish_redemption operations in 1014611us (17740.8 ops/sec)

Change-Id: I7ea9a8ab8ad48acfbf50026e251cc6e1d5b8ba7f
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41069
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
2020-05-04 14:20:47 +00:00
David Benjamin 69402f33f3 Route PMBToken calls through TRUST_TOKEN_METHOD.
Change-Id: I8b87484ea94cf1f931fa66216aab4654abe26bd3
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41068
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2020-05-04 13:40:46 +00:00
David Benjamin 239634da1b Introduce a TRUST_TOKEN_METHOD hook to select TRUST_TOKEN variations.
For now, it does nothing. This will make it easier to transition between
versions of the experiment while the protocol evolves.

Update-Note: Pass TRUST_TOKEN_experiment_v0() into any existing code
that now needs a TRUST_TOKEN_METHOD.

Change-Id: I434e18c794ab30545e367eb902e434e6311b7497
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41066
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2020-05-01 20:21:02 +00:00
Adam Langley ad5582985c fork_detect: be robust to qemu.
fork_detect needs to know whether |MADV_WIPEONFORK| is supported by the
kernel or not. However, current versions of qemu ignore madvise calls
and just return zero, making it seems like it's supported when it's
actually not. Therefore, try an madvise with -1 to ensure that clearly
bogus values actually produce and error before trusting the result of
calling with |MADV_WIPEONFORK|.

Change-Id: I7f72714d5794274acabd0bee0b0ac470e1933774
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41024
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2020-05-01 18:35:42 +00:00
David Benjamin 90bb72c6a6 Move serialization of points inside pmbtoken.c.
This reduces the number of places that know about the group and allows
us to abstract between different PMBTokens variations. Although the
abstraction isn't quite clean with the key_id in the TRUST_TOKEN
serialization, so we may need to ponder this.

Change-Id: Ia892340057025794aaf7c44a64c4d195a969715f
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41065
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2020-05-01 18:16:12 +00:00
David Benjamin 090ee96bf6 Introduce PMBTOKENS key abstractions.
Start tidying up the TRUST_TOKENS/PMBTOKENS split.

Change-Id: Iabcbc864f4016dfcb22438387446b04d31b64beb
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41064
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
2020-05-01 17:52:31 +00:00
David Benjamin 17078f21a5 Fix the types used in token counts.
The number of tokens is inconsistent throughout the API. max_batchsize
is a uint16_t. max_issuance is a size_t. out_tokens_issued is a
uint8_t*. The serialization only supports up to uint16_t.

Standardize on size_t. The natural size for a count of elements is
size_t. Protocol limitations can be handled within the implementation.
Additionally, it is best not to use small types for counters in public
APIs in C/C++ because the language has implicit truncating conversions.
(Whereas code points or other enum-like values are fine because the
caller won't managed to get a 32-bit cipher suite.)

Update-Note: Fix callers of TRUST_TOKEN_ISSUER_issue to use size_t
instead of uint8_t. The max_batchsize changes should go through without
changes to the caller.

Change-Id: I9be5dd8f61abdbe5a1dbe70b8dc72d06114b1022
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41044
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2020-05-01 17:29:22 +00:00
David Benjamin dc06e320d8 Remove unused code from ghash-x86_64.pl.
Thanks to Brian Smith for pointing these out in
https://boringssl-review.googlesource.com/c/boringssl/+/38724.

Change-Id: I715da0778346fcc45aab19855050e18fe95a9185
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41144
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-05-01 16:01:21 +00:00
David Benjamin eeb5bb3561 Switch the P-384 hash-to-curve to draft-07.
Leave the P-521 one alone as it's part of the current trust token
experiment. But suffix all the functions by their draft until everything
stabilizes. Also remove the ref_for_testing function since we can cite
the fixed test vectors from the upstream PR.

Change-Id: Ied89d26848c8ec1f6e8414a2385d9f3e491d7fb2
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41067
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2020-04-30 20:23:27 +00:00
Steven Valdez 6a7184066f Add hash-to-curve code for P384.
Change-Id: I34c3609641c23aed14f2324c6887250369ae8b5f
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40944
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-04-29 17:16:17 +00:00
David Benjamin b36f52d187 Write down the expressions for all the NIST primes.
I find myself needing to look them up frequently and this is easier than
digging through https://www.secg.org/SEC2-Ver-1.0.pdf each time.

Change-Id: I4aa7cdf2c8f114a0f2ba8b9bd7ee394d3201d731
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40984
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-04-27 17:27:49 +00:00
Adam Langley 21aede9179 Move fork_detect files into rand/
Files in the top-level of fipsmodule/ are considered be FIPS-support
files by generate_build_files.py. However, fork_detect is different.
Rather than have more special cases in the support scripts, this change
moves fork_detect into fipsmodule/rand. It's not a perfect fit, and
maybe it could have been its own directory, but it's not bad and fixes
the build for now.

Change-Id: I875088dd458069190dade870e085865e1306f55a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40964
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2020-04-26 21:38:36 +00:00
David Benjamin b1086cdb12 Harden against fork via MADV_WIPEONFORK.
Linux 4.14 and up support MADV_WIPEONFORK, which can be used to reliably
and efficiently detect forks. Use it to harden the PRNG and RSA blinding
caches.

On the RSA side, we currently cache blinding values. (Alas, removing the cache
gives a *very* noticeable perf hit. There is some low-hanging fruit to trim a
few Montgomery reductions, but it didn't offset much last I toyed with it.)
Now, on Linux 4.14 and up, this cache is fork-safe.

Since not all platforms that support fork also support fork detection,
this should only be used as a hardening measure. Now, when detection is
present, BoringSSL will skip doing per-call entropy draws from the
kernel. (This might regress protection against VM cloning when no fast
RDRAND is available. However, we need to do something for AMD machines.
Hypervisors that clone VMs are going to need to signal the kernel to
wipe WIPEONFORK pages.)

Upgrade-Note: BoringSSL now calls some more syscalls on Linux. If this offends
sandboxes, let us know. We can loosen the sandbox or add a mechanism to prime
the MADV_WIPEONFORK page before entering it.

Change-Id: I6ba43951aeaa2b9b81f74f9e5a7a0ce2de0438a4
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/34745
Reviewed-by: Adam Langley <alangley@gmail.com>
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2020-04-26 18:31:56 +00:00
David Benjamin 14d192e930 Fix typo in comment.
Change-Id: I67a012a54a2818ec12c1829a746e2d7f796616d6
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40924
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2020-04-24 16:01:58 +00:00
David Benjamin 21f694210c Use faster addition chains for P-256 field inversion.
Switch to the addition chains by Brian Smith in
https://briansmith.org/ecc-inversion-addition-chains-01#p256_field_inversion

The new addition chains are a bit faster when measured independently.
They aren't, however, noticeable when measured with everything else in
ECDH. Rather, the motivation is just to align fiat_p256, nistz256, and a
possible future fiat_p384 import.

Since it's free, I've included the (negligible) z^-2 optimization, but
if we ever want a z^-1 abstraction, it doesn't actually matter. In the
meantime, it replaces the (even more negligible) Montgomery conversion
optimization which is a bit less odd on the EC_FELEM abstraction. (I'm
pondering whether we want an EC_AFFINE abstraction given how the Trust
Tokens DLEQ proofs work.)

fiat_p256 (64-bit):
Before:
Did 539000 P-256 get x operations in 5007148us (107646.1 ops/sec)
Did 532000 P-256 get x and y operations in 5008736us (106214.4 ops/sec)
After:
Did 607000 P-256 get x operations in 5005225us (121273.3 ops/sec)
Did 594000 P-256 get x and y operations in 5001251us (118770.3 ops/sec)

nistz256:
Before:
Did 1472000 P-256 get x operations in 5003286us (294206.6 ops/sec)
Did 1445000 P-256 get x and y operations in 5002052us (288881.4 ops/sec)
After:
Did 1491000 P-256 get x operations in 5002524us (298049.5 ops/sec)
Did 1452000 P-256 get x and y operations in 5003193us (290214.7 ops/sec)

I haven't bothered checking in the benchmarks as those operations
standalone are largely artificial. They're a consequence of using the
same type for affine and Jacobian points.

Change-Id: I71e0d50a8712198f9cb8f68d50894d14a6091635
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40867
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-04-23 21:31:07 +00:00
David Benjamin 47b1e39042 Tidy up third_party/fiat.
Originally, when we imported fiat-crypto field operations, the pipeline
was in early stages and the generated code had to be manually integrated
with the rest of the curve implementation, so we moved all our
supporting code to third_party/fiat for simplicity. Over time more
supporting code, like the table generators, landed there to be next to
its callers.

fiat-crypto now generates standalone files which we #include into the
supporting code. This moves the supporting code back to the usual
location. It also updates the README.md file to reflect the new
pipeline. (Most of it was a documentation of the old pipeline, which was
much more manual.)

Change-Id: I64db7235feb6566f0d3cd4db3a7146050edaf25a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40904
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-04-23 19:50:07 +00:00
David Benjamin 25ab623a86 Prefix g_pre_comp in p256.c as well.
I missed a symbol.

Change-Id: I83c6828620a54eaab26cad08b1714402a2758fc0
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40905
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-04-23 19:05:07 +00:00
David Benjamin 8bbc5e9a61 Add missing curve check to ec_hash_to_scalar_p521_xmd_sha512.
The bounds on k make this a little tricky to test, so stick an assert(0)
as that codepath should be impossible.

Change-Id: I03958ed36bff4f0b420a446c6d49eca944f45da2
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40885
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2020-04-23 17:44:57 +00:00
David Benjamin 1d8ef2c666 Add a tool to compare the output of bssl speed.
I've been doing it by hand this whole time.

Change-Id: Ib64dcca81c33ebe7b81cd8e3d579b9fca02e1096
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40745
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-04-23 17:15:27 +00:00
David Benjamin 21712d52c4 Benchmark ECDH slightly more accurately.
We really need a better ECDH API in the first place, but ECDH would not
extract the y-coordinate which saves a couple multiplications. (This is
entirely unnoticeable between everything else going on in ECDH.)

Change-Id: I663554577b0cfc373067f9db4d2116a3dfbf1478
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40866
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2020-04-23 16:52:47 +00:00
David Benjamin c878b651ce Align remaining Intel copyright notice.
https://boringssl-review.googlesource.com/c/boringssl/+/25588/ missed
one of the files.

Change-Id: Iba3aa37f5ecd69fd35054c44cbd5f8988a05f76e
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40868
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-04-23 15:59:37 +00:00
David Benjamin e2af857ddc Don't retain T in PMBTOKEN_PRETOKEN.
We only need r, t, and T'.

Change-Id: I736c5638c73e80c99036182fa3cd30397c33d923
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40884
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2020-04-23 15:17:47 +00:00
David Benjamin cbe128b3e3 Check for trailing data in TRUST_TOKEN_CLIENT_finish_issuance.
Change-Id: I2dec3ca3651c81e25370dfd7d10bd27c1803cc38
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40847
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-04-22 20:15:36 +00:00
David Benjamin 13d09f0527 Properly namespace everything in third_party/fiat/p256.c.
This file gets #included into other files, so we shouldn't use generic
names like 'fe'. This will let us import other fiat-crypto curves in the
future, if we want them.

Change-Id: Ie4e222729bde7e4ccd368b86fb9048a2ea4a58ac
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40824
Reviewed-by: David Benjamin <davidben@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-04-22 20:04:56 +00:00
David Benjamin baca5b4fa0 Update fiat-crypto.
This pulls in the latest upstream files and reapplies our value_barrier patch.
In particular, https://github.com/mit-plv/fiat-crypto/pull/723 made 64-bit
P-256 faster!

32-bit x86, gcc
Before:
Did 3150 ECDH P-256 operations in 4027477us (782.1 ops/sec)
Did 9912 ECDSA P-256 signing operations in 4067212us (2437.1 ops/sec)
Did 3772 ECDSA P-256 verify operations in 4059197us (929.2 ops/sec)
Did 74800 Ed25519 key generation operations in 4020883us (18602.9 ops/sec)
Did 74000 Ed25519 signing operations in 4001827us (18491.6 ops/sec)
Did 21371 Ed25519 verify operations in 4024606us (5310.1 ops/sec)
Did 78000 Curve25519 base-point multiplication operations in 4051574us (19251.8 ops/sec)
Did 25133 Curve25519 arbitrary point multiplication operations in 4063280us (6185.4 ops/sec)
After:
Did 3250 ECDH P-256 operations in 4025179us (807.4 ops/sec) [+3.2%]
Did 10277 ECDSA P-256 signing operations in 4084926us (2515.8 ops/sec) [+3.2%]
Did 3895 ECDSA P-256 verify operations in 4048734us (962.0 ops/sec) [+3.5%]
Did 74480 Ed25519 key generation operations in 4002460us (18608.6 ops/sec) [+0.0%]
Did 74000 Ed25519 signing operations in 4004425us (18479.6 ops/sec) [-0.1%]
Did 21756 Ed25519 verify operations in 4038856us (5386.7 ops/sec) [+1.4%]
Did 78000 Curve25519 base-point multiplication operations in 4031991us (19345.3 ops/sec) [+0.5%]
Did 25133 Curve25519 arbitrary point multiplication operations in 4064925us (6182.9 ops/sec) [-0.0%]

x86_64, clang, OPENSSL_SMALL
Before:
Did 20090 ECDH P-256 operations in 4019408us (4998.2 ops/sec)
Did 56000 ECDSA P-256 signing operations in 4004370us (13984.7 ops/sec)
Did 23562 ECDSA P-256 verify operations in 4062283us (5800.2 ops/sec)
Did 127000 Ed25519 key generation operations in 4005053us (31709.9 ops/sec)
Did 128000 Ed25519 signing operations in 4021902us (31825.7 ops/sec)
Did 71000 Ed25519 verify operations in 4036015us (17591.6 ops/sec)
Did 132000 Curve25519 base-point multiplication operations in 4002101us (32982.7 ops/sec)
Did 93000 Curve25519 arbitrary point multiplication operations in 4023827us (23112.3 ops/sec)
After:
Did 22263 ECDH P-256 operations in 4005099us (5558.7 ops/sec) [+11.2%]
Did 61000 ECDSA P-256 signing operations in 4024810us (15156.0 ops/sec) [+8.4%]
Did 27426 ECDSA P-256 verify operations in 4038547us (6791.1 ops/sec) [+17.1%]
Did 128000 Ed25519 key generation operations in 4015033us (31880.2 ops/sec) [+0.5%]
Did 127000 Ed25519 signing operations in 4003894us (31719.1 ops/sec) [-0.3%]
Did 70000 Ed25519 verify operations in 4017446us (17424.0 ops/sec) [-1.0%]
Did 132000 Curve25519 base-point multiplication operations in 4006282us (32948.3 ops/sec) [-0.1%]
Did 93000 Curve25519 arbitrary point multiplication operations in 4025190us (23104.5 ops/sec) [-0.0%]

Change-Id: I2f705772899c701480ca0e0885e6b75dd1bb1f5d
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40746
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-04-22 19:06:26 +00:00
David Benjamin a27ed585fa Add missing ERR_LIB_TRUST_TOKEN constants.
Also fix the numbering. ERR_LIB_USER probably ought to be last.

Change-Id: I2eb94dc129aa40b36711a7c20a9dfedf9944fc21
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40846
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-04-22 15:07:24 +00:00
Steven Valdez 188b65a791 Add bssl speed support for hashtocurve and trusttoken.
Change-Id: I74bee1855c593131bf1451553de6a56b4e0e8a54
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40804
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-04-22 03:20:44 +00:00
Steven Valdez 78987bb7bb Implement DLEQ checks for Trust Token.
Change-Id: I6f263b775aafad6616b31af59096c3b4229fe3e1
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40684
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-04-21 13:42:50 +00:00
David Benjamin 367d64f84c Fix error-handling in EVP_BytesToKey.
This only matters on malloc failure and I think, even then,
EVP_DigestInit_ex will only fail the first time around the loop so it
wouldn't actually leak anything. Nonetheless, that should be a goto err.

Change-Id: Ieea9db387f9c16915c3a0026c6fd48036da2cfef
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40748
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-04-17 18:40:28 +00:00
Steven Valdez 8f3019e849 Fix Trust Token CBOR.
CBOR requires map keys to be sorted by length followed by alphabet,
but only some parsers enforce this requirement.

Change-Id: I63cad4ec27f1509704be7a755b5486b0f4baa800
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40747
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-04-17 16:42:58 +00:00
David Benjamin 7853619553 Match parameter names between header and source.
clang-tidy flagged this in a diff. Running a full clang-tidy would
probably reveal others, but ah well.

Change-Id: Ib004f7df4fd53b326686810c314869b35b35e547
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40749
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-04-17 16:37:18 +00:00
Steven Valdez 538a124d70 Trust Token Implementation.
Trust Token implementation based on PrivacyPass using the PMBToken construction.
This implementation currently omits the DLEQ proofs.

https://github.com/alxdavids/privacy-pass-ietf/blob/master/draft-davidson-pp-protocol.md
https://eprint.iacr.org/2020/072.pdf

Change-Id: If236cc8beaf33a80bdad2991c3163f9dd0cb7571
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39244
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-04-17 01:41:02 +00:00
Adam Langley f37eb8d6a8 Include mem.h for |CRYPTO_memcmp|
Change-Id: I3009326a5fa0c28bd3d214254e9beda4ea779833
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40744
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2020-04-16 21:10:07 +00:00
Adam Langley 9a798eb531 acvptool: add subprocess tests.
(Written by Dan Janni.)

Change-Id: Ice03bb3e717b361af367cce7425f43d65e79cadc
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40724
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-04-16 17:00:17 +00:00
Adam Langley 3c11bf53e9 Add SHA-512-256.
(Not wired up into all the signature verifiers because we don't need or
recommend that.)

Change-Id: Ia212a1f0e1c389a31d303e00a6fafb0ec3db7c71
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40704
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-04-15 21:23:37 +00:00
David Benjamin 9fc31378f0 Make ec_GFp_simple_cmp constant-time.
We need a constant-time point equality for two reasons. First, although
multiplication results are usually public, their Jacobian Z coordinates
may be secret, or at least are not obviously public. Second, more
complex protocols will sometimes manipulate secret points, notably
PMBTokens.

While here I've renamed the inner function to points_equal without the
flipped return value, to be less confusing.

Update-Note: This does mean that we pay a 6M+2S Jacobian comparison
where comparing two publicly affine points should cost no field
operations at all. Code which compares two EC public keys for equality
will be slightly slower. I wouldn't expect this to matter (if you
actually use the public keys, you'll pay much much more) If it does, we
can restore this optimization by keeping better track of affine vs.
Jacobian forms. See https://crbug.com/boringssl/326.

Bug: 326, chromium:1014199
Change-Id: I67c9a56bc9b66f30c0b500a29e8bf90427d89061
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40665
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-04-13 21:33:44 +00:00
David Benjamin f883b98cfd Tidy up CRYPTO_sysrand variants.
We can extend the inline function trick to avoid needing to add extra
wrappers to the fuzzer PRNG.

Change-Id: Ie007a4ccaf0e2d703a3710e4298a774af861d514
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40624
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-04-13 19:15:28 +00:00
David Benjamin 3d22c8260a Do a better job testing EC_POINT_cmp.
If EC_POINT_cmp always returns points are equal, our tests barely
notice.

Change-Id: I1a78d95af2fad3d97c2db013468d34159807ff21
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40664
Reviewed-by: Adam Langley <agl@google.com>
2020-04-13 19:02:38 +00:00
David Benjamin 2a8e294b70 Follow-up comments to hash_to_scalar.
See
https://boringssl-review.googlesource.com/c/boringssl/+/40646/3#message-ee607e82b0c62dd73a1b8a81f03acd9329cbbf02

Additionally, to be consistent with hash_to_field, we ought to use a
big-endian value. It's also probably time to have some common functions
for dealing with converting BN_ULONG[]s to and from big-endian bytes.
Coding all those free-handed is a little tedious and error-prone.

Change-Id: I6bdcd9362cee60e160e5a8eca25206b052206e1f
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40647
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-04-10 18:35:25 +00:00
David Benjamin 28987cf081 Add a hash_to_scalar variation of P-521's hash_to_field.
DLEQ proofs for PMBTokens need a random oracle over scalars as well as
field elements. (Interestingly, draft-irtf-cfrg-voprf-03 section 5.1
does not specify as strong of requirements, but then their reference
implementation does rejection sampling, so it's unclear.)

Reusing the hash_to_field operation so hash calls use the domain
separation tag consistently with other hash-to-curve operations seems
prudent, so implement a companion function until the actual construction
solidifies.

Change-Id: I92d807bfddcca26db690cce0a3da551143c25ff3
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40646
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
2020-04-10 15:37:52 +00:00
David Benjamin f9e0cda2d8 Add SSL_SESSION_copy_without_early_data.
While we could store an extra boolean along with each session in the
session cache and then disable early data on a per-socket level, that
causes SSL_early_data_reason to report confusing values. Clearing it
at the session seems simpler. Since sessions are intended to be
mutable, do this as a copy operation.

Bug: chromium:1066623
Change-Id: I599b1559b696805e330ab5c2d61e4158440daef8
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40464
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-04-09 18:50:29 +00:00
David Benjamin 5902657734 Double-check secret EC point multiplications.
Doing a Jacobian point-on-curve check has negligible cost compared to
the point operations. We may as well perform one to add some defense
against potential bugs and such. (We already double-check RSA
operations.)

Before:
Did 40000 ECDH P-224 operations in 3014872us (13267.6 ops/sec)
Did 55000 ECDH P-256 operations in 3026351us (18173.7 ops/sec)
Did 3410 ECDH P-384 operations in 3053181us (1116.9 ops/sec)
Did 1364 ECDH P-521 operations in 3079656us (442.9 ops/sec)
Did 83000 ECDSA P-224 signing operations in 3013476us (27542.9 ops/sec)
Did 41000 ECDSA P-224 verify operations in 3073530us (13339.7 ops/sec)
Did 168000 ECDSA P-256 signing operations in 3008562us (55840.6 ops/sec)
Did 60000 ECDSA P-256 verify operations in 3038517us (19746.5 ops/sec)
Did 6169 ECDSA P-384 signing operations in 3066741us (2011.6 ops/sec)
Did 6231 ECDSA P-384 verify operations in 3054468us (2040.0 ops/sec)
Did 2418 ECDSA P-521 signing operations in 3058901us (790.5 ops/sec)
Did 2418 ECDSA P-521 verify operations in 3048765us (793.1 ops/sec)

After:
Did 39600 ECDH P-224 operations in 3001966us (13191.4 ops/sec)
Did 55000 ECDH P-256 operations in 3033098us (18133.3 ops/sec)
Did 3441 ECDH P-384 operations in 3088436us (1114.2 ops/sec)
Did 1364 ECDH P-521 operations in 3087711us (441.8 ops/sec)
Did 83000 ECDSA P-224 signing operations in 3029486us (27397.4 ops/sec)
Did 40000 ECDSA P-224 verify operations in 3005452us (13309.1 ops/sec)
Did 168000 ECDSA P-256 signing operations in 3011387us (55788.2 ops/sec)
Did 60000 ECDSA P-256 verify operations in 3030343us (19799.7 ops/sec)
Did 6076 ECDSA P-384 signing operations in 3023469us (2009.6 ops/sec)
Did 6231 ECDSA P-384 verify operations in 3056138us (2038.8 ops/sec)
Did 2418 ECDSA P-521 signing operations in 3057375us (790.9 ops/sec)
Did 2449 ECDSA P-521 verify operations in 3083418us (794.2 ops/sec)

Change-Id: Icedc51e340c8f3a21f96a535395814575e0c89b2
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40592
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-04-09 18:11:29 +00:00
David Benjamin d2c5b7da2f Make ec_felem_equal constant-time.
This doesn't fix any particular issue, but we may as well use
the constant-time comparison to be more robust.

Change-Id: I96dffce7fe153a7dd4eec226a6b42dcea240c3f1
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40591
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-04-09 15:45:09 +00:00
David Benjamin 0f86c142a7 Fix hash-to-curve comment.
511S + 3M isn't even enough operations to get up to 2^519-1. I dropped a
a bunch of terms. (We can get up to 2^512-1 with 511S + 9M. Then an
additional 7S + 3M finishes it up.)

Change-Id: Ibb1bc3491dfb09ab8a917498e99deb66e4894cf0
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40644
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-04-09 15:32:38 +00:00
David Benjamin f20772cc0a Make ec_GFp_simple_is_on_curve constant-time.
This function (by way of EC_POINT_is_on_curve) is used by callers in two
places:

- To check the affine result of decoding a point. (This is no longer
  necessary because we'll always do it internally, but folks still do
  it.)

- To check the Jacobian result of a multiplication as fault protection.
  (Tink does this. We should probably do it in the library.)

That function's implementations of affine and Jacobian checks are mostly
constant-time, but branching between the two isn't. Since the difference
is small (2S + 1M vs 2S + 3M) compared to what one would be doing with
an affine point (point multiplication), this probably isn't worth
worrying about. Conservatively do the Jacobian check so folks like Tink
aren't accidentally introducing side channels.

Change-Id: I3140167868e027004906293df547add43ae40552
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40590
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-04-09 15:03:48 +00:00
David Benjamin a49c617197 Implement draft-irtf-cfrg-hash-to-curve-06.
This implements hash-to-curve for P-521, which is needed by the
PMBTokens construction in https://eprint.iacr.org/2020/072.pdf. It is
only an internal function for now, operating on EC_RAW_POINT, so that
PMBTokens can avoid allocating EC_POINTs everywhere. If we ever have a
need to expose this outside, we can add an EC_POINT wrapper (hopefully
by then the draft will be stable).

Note this implements two versions of the function due to a spec issue in
P521_XMD:SHA-512_SSWU_RO_. One of them only exists to test against the
original test vectors. See
https://github.com/cfrg/draft-irtf-cfrg-hash-to-curve/issues/237

Bug: chromium:1014199
Change-Id: I7207d1bcb8b20f7111c2ffb40e2794ad2d3d0000
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40589
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-04-08 22:18:51 +00:00
Adam Langley 4143943085 Update list of tested SDE configurations.
This is taken from the help output of the current version of SDE.

Change-Id: I0513088a52d6692dd419f323b72411e107ed9636
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40584
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-04-08 18:45:11 +00:00
Adam Langley 7a22a65098 Only draw from RDRAND for additional_data if it's fast.
We seek to incorporate entropy into every |RAND_bytes| call to avoid
problems with fork() and VM cloning. However, on some chips, RDRAND is
significantly slower than a system call thus crushing the performance of
|RAND_bytes|.

This change disables use of RDRAND for this opportunistic draw for
non-Intel chips. BoringSSL will then fall back to either the OS, or
nothing (if fork-unsafe mode has been set).

RDRAND is still used for seeding the PRNG whenever it is available.

This now adds a new blocking case: RDRAND may be used for seeding, but
the syscall to get additional_data was still blocking. Previously that
didn't matter because, if a syscall was used to get additional_data,
then a blocking one had already been used to seed. Thus the syscall for
additional_data is now non-blocking.

Also, we had both |hwrand| and |rdrand| names hanging around. We don't
support entropy instructions other than RDRAND, so unify around |rdrand|
naming. If we ever do add support for more we can properly abstract at
that time.

Change-Id: I91121b270a2ebc667543dad1324f37285daad893
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40565
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-04-08 18:29:21 +00:00
David Benjamin ea53011c6e Generalize bn_from_montgomery_small.
Montgomery reduction works when the input is at most N*R (N^2 is a
tighter bound that's easier to describe and usually suffices). This is
useful when reducing product-sized values. In particular,
hash-to-curve's hash_to_field function requires a reduction. Generalize
this so we can implement it with Montgomery reduction.

Bug: chromium:1014199
Change-Id: I1a07f9b94823742384a98c0c6fecdedfe5240b7b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40588
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-04-08 00:40:10 +00:00
David Benjamin ad5e3e3597 Remove BIGNUM from uncompressed coordinate parsing.
Compressed coordinates still use BIGNUM. I've moved the curve check to
an EC_FELEM-based ec_point_set_affine_coordinates and implemented a
tighter one than ec_GFp_simple_is_on_curve, which currently needs to
branch on Jacobian vs. affine and potentially leaks information. (A
later CL will make it conservatively always perform a Jacobian check.)

The Trust Tokens implementation will eventually need to deserialize
points, so this avoids needing to allocate EC_POINTs everywhere.
Likewise if we ever get around to adding a better ECDH, this will let us
avoid pulling in BIGNUMs.

Bug: chromium:1014199, 242
Change-Id: I93162ba3680d38cb3c0eacff1eb8f42a445246ea
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40587
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-04-07 23:46:10 +00:00
David Benjamin 58add794d9 Add EC_RAW_POINT serialization function.
This avoids some unnecessary EC_POINT allocations in the in-progress Trust
Tokens implementation.

Bug: chromium:1014199
Change-Id: I64e1fca61d111eacec02648e68972be30fd5a48f
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40586
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-04-07 23:14:30 +00:00
David Benjamin 1d43e57c30 Base EC_FELEM conversions on bytes rather than BIGNUMs.
It is tricky to create EC_FELEMs right now. This will simplify making them.

Change-Id: Icde518efed61381004e2e5569a45d653af48ca2a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40585
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-04-07 23:10:10 +00:00
David Benjamin 47a6f5b4bf runner: Replace supportsVersions calls with allVersions.
Save a few lines.

Change-Id: I9e3bdd00e31d5c832c29df68be0207e13a36fc8e
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40604
Reviewed-by: Nick Harper <nharper@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-04-07 23:06:10 +00:00
Nick Harper e8434d304c Enable QUIC for some perMessageTest runner tests
Change-Id: I7b944a5456e04a2fb1b0248a020d288065064043
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40304
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-04-07 22:51:10 +00:00
David Benjamin b65e630ec0 Move BN_nnmod calls out of low-level group_set_curve.
group_set_curve is called when instantiating the built-in curves and
when creating arbitrary curves. The former has non-NULL BN_CTXs and
fully reduced inputs. Move the logic for this to the deprecated
EC_GROUP_new_curve_GFp function so it can be dropped from most binaries.

Change-Id: I5ff60d6d51acb79fbcb32588e6324a5b2627b6d2
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40544
Reviewed-by: Adam Langley <agl@google.com>
2020-04-07 20:54:45 +00:00
David Benjamin bd1fa86feb Clean up various EC inversion functions.
This fixes two issues. First, we have been lax about whether the
low-level inversion functions fail on zero input or output zero. Fix the
documentation and call the latter inv0 or inverse0 to match the
terminology used in draft-irtf-cfrg-hash-to-curve. (Although we may not
actually need inv0 given the optimization in D.2.)

This has no actual effect because the functions were only used in
contexts where the inputs were already guaranteed to be non-zero. Still,
we should be consistent here.

Second, ec_scalar_inv_montgomery and ec_scalar_inv_montgomery_vartime
claim to perform the same operation, but they do not. First, one
computed inv0 and the other computed inv (except only in some
implementations, so fix it to be consistent). Second, the former
computes inverses in the Montgomery domain, while the latter converts to
the Montgomery domain and then inverts. Rename it to
ec_scalar_to_montgomery_inv_vartime, which is... questionably
understandable but at least looks different.

Change-Id: I9b4829ce5013bdb9528078a093f41b1b158df265
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40526
Reviewed-by: Adam Langley <agl@google.com>
2020-04-07 20:28:59 +00:00
David Benjamin 243a29241c Start to organize ec/internal.h a little.
Change-Id: I1de8ca164641d1e3d1fc36246205a7c0e60e0034
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40525
Reviewed-by: Adam Langley <agl@google.com>
2020-04-07 19:34:55 +00:00
Adam Langley 12840915a1 Fix CFI for AVX2 ChaCha20-Poly1305.
When running ABI tests on an AVX2-enabled system, they flag the
ChaCha20-Poly1305 assembly. The issue appears pretty simple: the code
has chunks of code after the mainline `ret` instruction the there's a
CFI directive that undoes the adjustments for restoring registers, but
it only accounts for six saved registers and there are actually seven.

At least, with this, the ABI tests are happy.

Change-Id: Ia6d1d89f564148db43852b245916a8c2cdfb1e6b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40564
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-04-07 19:33:30 +00:00
David Benjamin 300ef4767d Remove unused function prototype.
This function was removed in
https://boringssl-review.googlesource.com/c/boringssl/+/33065.

Change-Id: Ib8adefeabafa58e22e1b0fdd406f73c234c2e5e7
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40524
Reviewed-by: Adam Langley <agl@google.com>
2020-04-07 19:17:12 +00:00
Nick Harper af6bfbee47 Enable more runner tests for QUIC
Change-Id: Id1922197c5218460210e6404ad60b60afc591984
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40284
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-04-06 18:51:17 +00:00
Nick Harper 72cff81939 Require QUIC method with Transport Parameters and vice versa
Bug: 296, 322

Change-Id: I297f53674ee7177f61d75695f47b5caeed78bd17
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40384
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-04-03 21:52:34 +00:00
Adam Langley ee2660203b acvptool: support non-interactive mode.
Most people won't need the interactive mode and it's use of x/crypto can
be problematic in some contexts.

Change-Id: I33e0178726ee485f3967c0b71c9d538524af9286
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40504
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-04-02 17:00:33 +00:00
Nick Harper 6bfd25c755 Add is_quic bit to SSL_SESSION
This bit is used to prevent cross-protocol resumption between QUIC and
TLS-over-TCP.

Bug: 221
Change-Id: I8ab5341f00ae96c0a5f7ac3999f61edc7cbeca1c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40444
Commit-Queue: Nick Harper <nharper@chromium.org>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-04-01 21:38:22 +00:00
David Benjamin d5aae81fb7 Update SDE.
Change-Id: I7f5209dff570b1b2efd8d1d53ece818219bbf98c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40470
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-04-01 18:43:51 +00:00
David Benjamin 7c719d1246 Update tools.
This skips vs_toolchain.py because Chromium is now using VS2019, but we're
still testing 2015 and 2017.

Change-Id: Ib46eba76c8a3309d82be6e88e2baa4d8a93d222a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40469
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-04-01 18:21:41 +00:00
David Benjamin cdc5c184b3 Add simpler getters for DH and DSA.
These come from OpenSSL 1.1.1. I don't think any third-party code is
using them yet, but OpenSSL 1.1.0 is EOL, so newer code may use them and
they're much more convenient when porting over existing uses of DH and
DSA.

Bug: 325
Change-Id: I767496da4b458a3871dea23a1405b1e7e40b3de5
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40484
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-04-01 18:01:12 +00:00
Adam Langley 0cf14d3ec8 Don't define default implementations for weak symbols.
See https://github.com/facebook/folly/blob/d72b38e4aa7a42d9ff49705020e0916851d0e3cc/folly/memory/Malloc.h#L89-L97

This should work as well and be more robust to the pattern used in
Folly. The branch-predictor in modern CPUs probably makes it equally
fast.

Change-Id: I65b115c16d103b8a5492354411b55f3ef906b097
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40405
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-04-01 16:18:51 +00:00
Adam Langley 732b70ee20 Don't automatically run all tests for ABI testing.
We have good coverage for individual functions now and this makes
running tests when building for shared libraries more complex.

Change-Id: Ie69d234e1eed04e341b5192e174c4dae553c8706
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40404
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-04-01 15:20:21 +00:00
Adam Langley 577eadc424 Fix test build with recent Clang.
Some configurations of Clang hate not using a reference in a C++
range-for loop.

Change-Id: I90abf99625df4bbb67e835411bd85d995252beae
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40471
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-04-01 14:49:21 +00:00
David Benjamin 141062fe7f Remove LCM dependency from RSA_check_key.
Instead of checking d * e = 1 (mod lcm(p-1, q-1)), we can separately
check d * e = 1 (mod p-1) and d * e = 1 (mod q-1). This drops an LCM
dependency from key import and is 2x faster.

(Our constant-time LCM implementation can probably be faster if we
tried, but now it's only used in RSA keygen, so it doesn't matter much.
It's also using the unoptimized constant-time division, which is
probably the next target if we decide we care about speeding this up.)

Before:
Did 6768 RSA 2048 checking operations in 3015824us (2244.2 ops/sec)
Did 5610 RSA 2048 signing operations in 3033396us (1849.4 ops/sec)
Did 1953 RSA 4096 checking operations in 3060828us (638.1 ops/sec)
Did 817 RSA 4096 signing operations in 3021092us (270.4 ops/sec)
After:
Did 13175 RSA 2048 checking operations in 3090576us (4263.0 ops/sec)
Did 5610 RSA 2048 signing operations in 3032966us (1849.7 ops/sec)
Did 3720 RSA 4096 checking operations in 3085971us (1205.5 ops/sec)
Did 820 RSA 4096 signing operations in 3027312us (270.9 ops/sec)

Bug: 316
Change-Id: Ie29554c02d31f586dd0f8bdee03a227f1d5dc916
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40146
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-03-31 23:11:26 +00:00
David Benjamin ce9b8737cb Simplify bn_sub_part_words.
This function does not need to be so complex. The bulk of
the work is done by bn_sub_words. The unrolled loop is only used when
bn_sub_part_words is called in different-length inputs.

bn_sub_part_words is itself only called from bn_abs_sub_consttime and
bn_mul_part_recursive. bn_abs_sub_consttime is used to compute p - q in
RSA key generation so it never sees different-width inputs.
bn_mul_part_recursive is called from bn_mul_impl if all of the following
are true:

- Both inputs are at least 16 words long (1024 bits on 64-bit platforms
  and 512 bits on 32-bit).

- The two inputs are within one word from each other.

- The length of the larger input is one more than a power of two.

The first condition rules out all EC configurations except P-521 on
32-bit platforms. The EC code uses bn_mul_mont assembly if available, so
this only affects non-x86 and non-ARM 32-bit architectures. Building for
32-bit x86 without assembly shows no significant change:

Before:
Did 88 ECDH P-521 operations in 1014591us (86.7 ops/sec)
Did 165 ECDSA P-521 signing operations in 1066428us (154.7 ops/sec)
Did 150 ECDSA P-521 verify operations in 1001749us (149.7 ops/sec)
After:
Did 90 ECDH P-521 operations in 1045905us (86.0 ops/sec)
Did 165 ECDSA P-521 signing operations in 1071189us (154.0 ops/sec)
Did 154 ECDSA P-521 verify operations in 1050509us (146.6 ops/sec)

RSA does meet the first condition, but the third condition rules out all
common RSA sizes, with one quirk: RSA_check_key uses the non-normalized
BIGNUMs, but RSA_check_key is not called as part of private key
operations. (https://crbug.com/boringssl/316 discusses what to do about
RSA longer term. It's kind of a mess right now.)

Bug: 314
Change-Id: I0bd604e2cd6a75c266f64476c23a730ca1721ea6
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40145
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-03-31 22:56:39 +00:00
David Benjamin 8b4fa1b6b5 No-op commit to test Windows SDE bots.
Change-Id: I10210ed7f4a40925f68383d16ec619a2cf43308f
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40468
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-03-31 22:27:03 +00:00
Adam Langley 6c17797205 ABI-test each AEAD.
This keeps coverage for some assembly once we stop ABI testing by
default.

Change-Id: I2937a2961c19de560cb63e180646eb0e7d59d4ec
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40424
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-03-31 16:16:44 +00:00
Wiktor Garbacz 9ae40ce9ad Add memory tracking and sanitization hooks
Intended use is sanitization of BoringSSL allocations.

Change-Id: Ia577f944d19e5b0b77373fedd0970e2c0c97cd21
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39824
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-03-25 17:45:13 +00:00
David Benjamin 5cd0724ecb Add X509_STORE_CTX_get0_chain.
In OpenSSL 1.1.x, the preferred spelling of X509_STORE_CTX_get_chain is
X509_STORE_CTX_get0_chain.

Change-Id: I20281c7ae86371a72ac70fb9a8719f4810e0747c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40366
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-03-24 01:51:30 +00:00
David Benjamin 0064c290d1 Add DH_set_length.
OpenSSH uses this function.

Change-Id: I73c4c1647f61824f771022606f95bff7f6d3d77a
Update-Note: Set HAVE_DH_SET_LENGTH in OpenSSH.
Bug: 325
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40365
Reviewed-by: Adam Langley <agl@google.com>
2020-03-23 23:30:01 +00:00
David Benjamin dea1d44988 Static assert that CRYPTO_MUTEX is sufficiently aligned.
Bug: 325

Change-Id: I55d4d7fcb91602c8d2a371be5011e1a5df157819
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40364
Reviewed-by: Adam Langley <agl@google.com>
2020-03-23 23:28:24 +00:00
Yannic Bonenberger 7fe639cc2d [bazel] Format toplevel BUILD file with buildifier
This change was generated with
  buildifier -type build -lint=fix -warnings=all util/BUILD.toplevel

Change-Id: I4200fb484ec205c37abcb9b657c4ce74796a411c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40324
Reviewed-by: Adam Langley <agl@google.com>
2020-03-23 14:51:06 +00:00
Adam Langley 964256d066 Add |SSL_CTX_get0_chain|.
This is the getter counterpart to |SSL_CTX_set_chain_and_key|. There's
no |SSL*| because a) we didn't need it and b) then you have to worry
about config discarding and it doesn't end up being very useful.

Change-Id: Iba75d0165d7e555d0f793687b1f5e1e6c6f7c738
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40264
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-03-19 22:53:55 +00:00
David Benjamin 5298ef99bf Configure QUIC secrets inside set_{read,write}_state.
set_write_state flushes buffered handshake data, and we should finish
writing to a level before moving on to the next one.

I've moved the callback into set_{read,write}_state to ensure we still
update read_level and write_level after installing secrets, since that's
how we decide what level to write things and we should never write
alerts with keys we don't have. (I believe the only way this can come up
is if the QUIC callback itself fails, but it still seems prudent to
defer updating the levels.)

This does unfortunately mean a goofy secret_for_quic parameter, though
it is arguably more "correct" in that QUIC would ideally be a third
SSL_PROTOCOL_METHOD, rather than escape hatches over TLS. Probably a
cleaner abstraction would be for set_read_state and set_write_state to
take the secret and derive an SSLAEADContext internally.

Update-Note: See b/151142920#comment9
Change-Id: I4bbb76e15b5d95615ea643bccf796db87fae4989
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40244
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2020-03-16 16:45:10 +00:00
Nick Harper 80ddfc7d1b Allow setting QUIC transport parameters after parsing the client's
Our server code (unfortunately) conditions its transport parameters
based on the client's transport parameters. Instead of using
hs->config->quic_transport_params to check whether QUIC is in use, this
replaces it with ssl->quic_method.

Change-Id: I6817e9f674a70f4568b0c469c96dfdf1c1c91709
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40224
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-03-13 20:04:56 +00:00
Adam Langley 959c76d928 Fix comment for |BORINGSSL_self_test|.
The hash-based omission of the self tests for Android was moved around,
but the comment wasn't updated to match.

Change-Id: I66c3b4e9b48df00e8134cee3feb72469f92d51a4
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40184
Commit-Queue: Adam Langley <alangley@gmail.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-03-11 18:23:46 +00:00
Steven Valdez 0b710a305b Trust Token Key Generation.
Trust Token is a new protocol to issue and redeem provably anonymized
tokens. To allow for development of key storage/management for Trust
Token, this CL provides the function to generate Trust Token keys.

Bug: chromium:1014199
Change-Id: If764e027b202f07be13c64f7be66dfaff71c45e7
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40064
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-03-04 21:16:08 +00:00
David Benjamin 1e859054c3 Revise QUIC encryption secret APIs.
The original API separated when keys were exported to QUIC from when
they were "active". This means the obligations on QUIC are unclear. For
instance we added SSL_quic_read_level and SSL_quic_write_level to
capture when keys were active, yet QUICHE never used them anyway. It
would be better to defer releasing keys to when they are needed.

In particular, we should align our API with the guidelines in
https://github.com/quicwg/base-drafts/issues/3173.

This means we need separate read and write callbacks, which
unfortunately means the invariants around ACKs must now be covered in
prose.

We'll likely remove SSL_quic_read_level and SSL_quic_write_level in a
later CL as QUIC has no need to know this anymore. (It should simply
feed handshake data to BoringSSL as it sees it and, if we reject it,
report a suitably error.) The notion of a "current" encryption level is
a little odd given the interaction between 0-RTT and
ServerHello..Finished ACKs.

Update-Note: This is an incompatible change to SSL_QUIC_METHOD.
BORINGSSL_API_VERSION can be used to distinguish the two revisions.

Bug: 303
Change-Id: I6c9dca1ae156d26a80c366a4ba969dcb04e65349
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40127
Reviewed-by: Nick Harper <nharper@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-03-03 17:15:15 +00:00
David Benjamin bfe527fa35 Fix ec_point_mul_scalar_public's documentation.
At the time the comment was written, the secret multiplication operation
hadn't been split yet.

Change-Id: Idd283461c357b47e91b73fac489d1828c4ce2a0c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40065
Reviewed-by: Steven Valdez <svaldez@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-03-03 17:09:35 +00:00
David Benjamin 2fb729d4f3 Don't infinite loop when QUIC tests fail.
Change-Id: I33714c68ab8ba841c614afd2ea9a57a6e9b8c27a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40126
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2020-03-02 18:57:19 +00:00
David Benjamin 44099d5925 Tidy up transitions out of 0-RTT keys on the client.
This change does two things. First, it funnels the transition out of
0-RTT into one function so that, later, when QUIC releases keys in
set_(read|write)_state, we can handle the QUIC quirks better.

Second, it switches to handshake (or initial) keys as soon as 0-RTT is
closed. In particular, if EncryptedExtensions reports a 0-RTT reject, we
switch keys before processing Certificate. This way, if we then reject
the server certificate, we send the alert with keys the server can read.

If there is an error in EncryptedExtensions or earlier, we do not know
whether the server is expecting 0-RTT-encrypted alerts or
handshake-encrypted alerts, so we cannot reliably send an alert. This is
fine because all such error cases are server implementation bugs and
alerts are purely a debugging courtesy. However, after a 0-RTT reject,
we may reject the Certificate message due to local policy, in which case
the certificate error alerts make more sense.

Bug: 303
Change-Id: I4c4bc9c8ab2c2ecb89e20141518e1b7ea7b39af3
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40125
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-03-02 18:29:59 +00:00
David Benjamin 3280287c06 Remove bn_sub_part_words assembly.
The assembly only existed for 32-bit x86, which is much less relevant
these days. It's also just a pile of ADDs, ADCs, etc., which compilers
should be able to figure out by now.

This frees us up to clean up that function, including the weird cl/dl
calling convention. No noticeable difference in RSA benchmarks:

Before:
Did 224 RSA 2048 signing operations in 1006100us (222.6 ops/sec)
Did 9240 RSA 2048 verify (same key) operations in 1078563us (8567.0 ops/sec)
Did 8541 RSA 2048 verify (fresh key) operations in 1064996us (8019.7 ops/sec)
Did 32 RSA 4096 signing operations in 1052851us (30.4 ops/sec)
Did 2365 RSA 4096 verify (same key) operations in 1093337us (2163.1 ops/sec)
Did 2222 RSA 4096 verify (fresh key) operations in 1090037us (2038.5 ops/sec)

After:
Did 231 RSA 2048 signing operations in 1018908us (226.7 ops/sec)
Did 9394 RSA 2048 verify (same key) operations in 1095548us (8574.7 ops/sec)
Did 8525 RSA 2048 verify (fresh key) operations in 1062449us (8023.9 ops/sec)
Did 32 RSA 4096 signing operations in 1050236us (30.5 ops/sec)
Did 2376 RSA 4096 verify (same key) operations in 1098509us (2162.9 ops/sec)
Did 2233 RSA 4096 verify (fresh key) operations in 1094724us (2039.8 ops/sec)

Bug: 314
Change-Id: I86a27b2550ab8bec2a9930cc509f4c29d6036b35
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40144
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2020-02-28 17:56:19 +00:00
David Benjamin b092192965 Keep the encryption state and encryption level in sync.
This is a little bit of internal cleanup. The original intent was so
QUIC could install secrets in set_(read|write)_state, but that was
somewhat annoying, so I've left it just before the call for now.

There is one TLS 1.3 state transition which doesn't carry an encryption
level: switching from 0-RTT keys back to unencrypted on an HRR-based
0-RTT reject. The TCP code doesn't care about write_level and the QUIC
code is currently fine because we never "install" the 0-RTT keys. But we
should get this correct.

This also opens the door for DTLS 1.3, if we ever implement it, because
DTLS 1.3 will need to know which level it is to handle 0-RTT keys funny.
(Clients sending 0-RTT will briefly have handshake and 0-RTT write keys
active simultaneously.)

QUIC has the same property, but we can fudge it because only the caller
is aware of this.

Change-Id: Ia76d787e1b96a058d9818948b6d9a051e8592207
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40124
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-02-24 22:16:24 +00:00
Shelley Vohr 6432bb46ab Add ECDSA_SIG_get0_r and ECDSA_SIG_get0_s.
OpenSSL 1.1.1 added some more convenient versions of ECDSA_SIG_get0.
Node.js uses them.

Change-Id: I425e8a0c2e43c34130f30d902090b839f1a67186
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40044
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-02-18 22:08:35 +00:00
Adam Langley 472d91c39c Fix a couple of comment typos.
Thanks to Tobias Thierer for pointing these out.

(No semantic change.)

Change-Id: Ia191da6353a11b090201adf813e2ca271acaff2e
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40104
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-02-18 20:36:28 +00:00
David Benjamin a12a2497ff Const-correct various X509_NAME APIs.
Half of them were marked const and half weren't.

Change-Id: Ia9135f743b06f07aafac8655ded84d01e59cf481
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39764
Reviewed-by: Adam Langley <agl@google.com>
2020-02-17 17:46:12 +00:00
Adam Langley 7940ed1f30 Ignore old -enable-ed25519 flag.
Change 1766935f76 removed this flag but it's useful if bssl_shim ignores
it to reduce noise in cross-version testing. This can be dropped in
three months once the old versions have aged out.

Change-Id: I73f2bebeb5e8c178253fbb6915026e06b6ad58bc
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40084
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-02-14 23:50:28 +00:00
Adam Langley f1efbc8f8b Provide __NR_getrandom fillins in urandom test too.
The urandom test added in 3e502c84f0 assumed that __NR_getrandom was
defined by the system's headers, but urandom.c doesn't. This change
pulls the fills for that system call into a common header that's used by
both.

Change-Id: I71c3b9bfa69c34b320e724a4c977cd63163cbdec
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40067
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2020-02-14 19:14:38 +00:00
David Benjamin aadb46369a Skip RSATest.DISABLED_BlindingCacheConcurrency in SDE.
The SDE bot has started developing flakes with that many threads.
(Unclear if it is due to SDE or running too many copies of the test
in parallel.)

Change-Id: I0081b6d75882b946bdccee5405dc688d0035d565
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40066
Reviewed-by: Adam Langley <agl@google.com>
2020-02-14 18:39:56 +00:00
David Benjamin 754d4c99c8 Fix client handling of 0-RTT rejects with cipher mismatch.
Servers can only accept 0-RTT if the ciphers match. If they reject
0-RTT, however, they may change the cipher suite and even the PRF hash.
This is tricky, however, because the 0-RTT accept or reject signal comes
in EncryptedExtensions, which is *after* the new cipher suite is
installed. (Although a client could infer 0-RTT is rejected based on the
cipher suite if it wanted.)

While we correctly handled the PRF hash switch, we get the cipher suite
mixed up due to dependency on SSL_get_session and incorrectly decrypt
EncryptedExtensions. Fix this and add some tests.

Change-Id: Ia20f2ed665cf601d30a38f0c8d4786c4c111019f
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40005
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-02-14 17:20:17 +00:00
David Benjamin 83ea777db5 runner: Tidy up 0-RTT support.
earlyCipherSuite is a remnant of early exporters, which we've since
removed. Also runner should perform the cipher suite matching check for
0-RTT.

Change-Id: Ia6dc2ff6cf7072d94820e8755acd555037c557f1
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40004
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-02-14 16:44:37 +00:00
David Benjamin 0dc70e462c Add X509_getm_notBefore and X509_getm_notAfter.
This functions were added in OpenSSL 1.1.0.

Change-Id: I1ee78ba124534d6e3e47edf75c0b4fed51388a6e
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/40024
Reviewed-by: Adam Langley <agl@google.com>
2020-02-14 16:06:40 +00:00
David Benjamin 0c30649ba6 Clean up TLS 1.3 handback logic.
There's no need to treat the 1-RTT and 0-RTT handback flows differently.
This aligns the 1-RTT handback with the 0-RTT point. This consistently
installs the decryption keys in the state machine after handback rather
than while applying the handback.

Update-Note: This changes the serialization format for TLS 1.3 split
handshakes, which were only just added.

Change-Id: I0e109cb8d9ecd3c8658dfa26059cbe0139f82eed
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39988
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Matt Braithwaite <mab@google.com>
2020-02-13 19:57:57 +00:00
David Benjamin f9cc26f9c1 Require handshake flights end at record boundaries.
The TLS handshake runs over a sequence of messages, serialized onto a
stream, which is then packetized into records, with no correlation to
message boundaries.

TLS messages may span records, so a TLS implementation will buffer up
excess data in a record for the next message. If not checked, that next
message may a round-trip or even a key change later. Carrying data
across a key change has security consequences, so we reject any excess
data across key changes (see ChangeCipherSpec synchronization tests and
(d)tls_set_read_state). However, we do not currently check it across
network round trips that do not change keys.

For instance, a TLS 1.2 client may pack part of ClientKeyExchange (the
first byte, at least, is deterministic) into the ClientHello record,
before even receiving ServerHello. Most TLS implementations will accept
this.

However, the handback logic does *not* serialize excess data in hs_buf.
There shouldn't be any, but if the peer is doing strange things as
above, that data will get silently dropped. The way TLS 1.3 0-RTT
handback logic works (the key isn't installed until after handback),
this data is even silently dropped though there is a key change.

To keep all our behavior consistent, check for unprocessed handshake
data at the end of each flight and reject it. Add a bunch of tests.

Update-Note: If the peer packs data across handshake flights, or packs
HelloRequest into the same record as Finished, this will now be an
error. (The former is pathologically odd behavior. The latter is also
rejected by Schannel and also odd.)

Change-Id: I9412bbdea09ee7fdcfeb78d3456329505a190641
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39987
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-02-13 19:30:40 +00:00
David Benjamin 21a879a78a Delete unreachable DTLS check.
It is impossible for us to have an unconsumed ChangeCipherSpec message
in dtls_has_unprocessed_handshake_data.
dtls_has_unprocessed_handshake_data is only called in
dtls1_set_read_state and, in DTLS 1.2 and earlier, we only ever switch
the cipher state immediately after consuming ChangeCipherSpec.

Remove this because later commits will check
has_unprocessed_handshake_data in more places and we have a test
(StrayChangeCipherSpec) which asserts we do tolerate arbitrarily early
ChangeCipherSpecs messages.

There may be something to be said for rejecting this (the peer would
have to be doing something weird and sending ChangeCipherSpec in the
wrong flight), but ChangeCipherSpec in DTLS is predictable and
informationless, so this is probably not worth worrying about.

Change-Id: I1bc2952c0ba5231a7f962b9f7ca4c63271ec079f
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39986
Reviewed-by: Adam Langley <agl@google.com>
2020-02-11 21:47:07 +00:00
David Benjamin 82a4b2234e Rename TLS-specific functions to tls_foo from ssl3_foo.
Some of the TLS-specific functions begin with ssl3_, otherwise with
tls_. Align on tls_ since we don't implement SSL 3.0 anymore. (Plain ssl_
means common to TLS and DTLS, which is an odd backronym, but SSL_foo for
the APIs are thoroughly stuck.)

Change-Id: Ib7acffd21ee370bb9bed46789fb511d00fac24ca
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39985
Reviewed-by: Adam Langley <agl@google.com>
2020-02-11 21:38:53 +00:00
David Benjamin f6cc8ddf52 Rename ssl3_choose_cipher.
We don't support SSL 3.0 anymore. It's also file-local, so it can be
choose_cipher.

Change-Id: Idab96496eda69c7fd906aa788ac26e8d30c317d5
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39984
Reviewed-by: Adam Langley <agl@google.com>
2020-02-11 21:37:39 +00:00
Matthew Braithwaite 8f299d5e03 SSL_apply_handback: don't choke on trailing data.
It may be useful for future extensibility.

Change-Id: I415095140367a44a2c8dd636998721399232c400
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39964
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-02-11 01:14:36 +00:00
Matthew Braithwaite 4f3e8212ea ssl_test: test early data with split handshakes.
This helps to clarify where SSL_set_early_data_enabled() needs to be
called: in the shim tests it was being set everywhere, which concealed
the fact that the |enable_early_data| bit was not being set by
SSL_apply_handback().

Change-Id: I35bfdc6dd43f4fa07ef79eb02e4624b59fcdda5e
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39385
Commit-Queue: Matt Braithwaite <mab@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-02-10 21:19:46 +00:00
Adam Langley 7964a1d676 Check for overflow in massive mallocs.
Hopefully it never happens, but a malloc of nearly the whole address
space should fail cleanly.

Change-Id: I82499e3236a1a485f5518b1c048899b1df3e8488
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39864
Reviewed-by: David Benjamin <davidben@google.com>
2020-02-10 17:43:35 +00:00
David Benjamin 7e43e2e8ee Add more convenient RSA getters.
OpenSSL 1.1.0's RSA getters can be inconvenient because they return a number of
fields via output parameters. OpenSSL 1.1.1 adds individual getters for each of
the fields, which is a bit simpler. Align with them.

Note our OPENSSL_VERSION_NUMBER is still 1.1.0. Adding these functions may
cause friction with third-party packages which polyfill these functions based
on OPENSSL_VERSION_NUMBER, though none appear to be doing this right now.
Between this and TLS 1.3, we probably should switch the version to 1.1.1 at
some point anyway.

Change-Id: Iada5a0315c403cc221688af53fc4ba165d65e99c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39944
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-02-07 19:36:22 +00:00
David Benjamin 1766935f76 Remove SSL_CTX_set_ed25519_enabled.
We never ended up using this, and callers can still configure
SSL_CTX_set_verify_algorithm_prefs to enable Ed25519 on the receiving
side. (On the sending side, this API was never needed because it's a
function of what certificate you configure.) This was just a way to
tweak the default without requiring callers restate the order.

Change-Id: I38d7f91d85430f37fc7e278d77466e78a0cbfa0d
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39848
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-02-06 23:54:44 +00:00
David Benjamin 6ab75bf21f Improve signature algorithm tests.
ecdsa_sha1 and ecdsa_secp521_sha512 are disabled by default but a caller
could still enable them by configuring the verify preferences. Improve
the tests to distinguish these cases better. Also, as this is getting
unwieldy, cut down on duplicated code between the client and server
signatures.

Change-Id: I1530f4cb43d8e9d675f7fdc4693034287fcac153
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39847
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-02-06 20:02:23 +00:00
Adam Langley 2a4ce17243 bazel: explicitly load C++ rules
Starting with Bazel 3.0, C++ rules will require loads. See
https://github.com/bazelbuild/bazel/issues/8743

Thanks to Yannic Bonenberger for noting this in
https://boringssl-review.googlesource.com/c/boringssl/+/39825

Change-Id: I8e274c82ade6c7ec569989026190f6a0a88b47ed
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39924
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-02-06 19:15:03 +00:00
Adam Langley fbea9de163 Check enum values in handoff.
Casting an out-of-range value to an enum is undefined behaviour in C.

Bug: oss-fuzz:20546
Change-Id: I11c6bc533b898430bd791e3cdcb271943b95c101
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39904
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-02-06 18:24:43 +00:00
David Benjamin 921bb9e224 Restore fuzz/cert_corpus.
This was accidentally deleted in https://boringssl-review.googlesource.com/c/boringssl/+/39805

Change-Id: Iba1ee7b03e0e531a4aa86ec6c048523d87bd2c72
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39884
Reviewed-by: Adam Langley <agl@google.com>
2020-02-06 17:55:42 +00:00
David Benjamin bf17f4f6f1 Add a -sigalgs option to bssl client.
Change-Id: I6247e02c6a9a9cc6ff5005eafe96f89f864cb12c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39846
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-02-06 00:53:13 +00:00
David Benjamin f0a815cce5 Add SSL_set_verify_algorithm_prefs.
We already had the state for it, but no API. This will allow us to
configure the signature preferences individually per socket in Chromium
and get a better measurement for how often SHA-1 in TLS 1.2 is still
needed. See associated bug for details.

Bug: chromium:658905
Change-Id: Id6198afc91f8275492995992e03d75a7ff328909
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39845
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-02-06 00:43:12 +00:00
David Benjamin ebad508ef1 Switch verify sigalg pref functions to SSL_HANDSHAKE.
Functions that take SSL* do not necessarily have an ssl->config
available because it is released post-handshake, whereas hs->config can
be accessed without a null check.

Change-Id: I3d9f3838c1f2d79f92beac363a90fb6046671053
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39844
Reviewed-by: Adam Langley <agl@google.com>
2020-02-05 23:21:08 +00:00
David Schinazi 10165d82c1 Add SSL_AD_NO_APPLICATION_PROTOCOL
This is based on AGL's comment on
https://boringssl-review.googlesource.com/c/boringssl/+/39784

Change-Id: I3204a64084288a2c025bc3e4c769a153126a1f9f
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39785
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-02-05 14:36:02 +00:00
Matthew Braithwaite 3d53d1ffe6 Refresh corpora due to TLS 1.3 changes in handoff serialization.
Along the way, update |refresh_ssl_corpora.sh| to use the right
handshaker path.

How to:

(rm -rf build-fuzz && mkdir build-fuzz && cd build-fuzz && CC=clang CXX=clang++ cmake -GNinja -DFUZZ=1 .. && ninja all)

(rm -rf build-no-fuzzer-mode && mkdir build-no-fuzzer-mode && cd build-no-fuzzer-mode && CC=clang CXX=clang++ cmake -GNinja -DFUZZ=1 -DNO_FUZZER_MODE=1 .. && ninja all)

(cd ~/boringssl/fuzz && ../fuzz/refresh_ssl_corpora.sh ../build-fuzz ../build-no-fuzzer-mode ) 2>&1 | tee /tmp/refresh-log

Change-Id: I1115dfe45d25bd74ace1048c80d614afb26223ee
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39805
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Matt Braithwaite <mab@google.com>
2020-02-05 00:34:02 +00:00
Matthew Braithwaite 9e23361aa0 handoff: set |enable_early_data| as part of handback.
This doesn't change the serialization: it just adds
|enable_early_data| to the list of early data fields that get updated
by SSL_apply_handback().

This is needed because, for example, add_new_session_tickets(), which
runs after handback, performs certain actions iff |enable_early_data|
is set.  Plus it just seems cleaner.

Change-Id: Ibcdb745ff9bcbeb2af2475f69f9f798937e7ee63
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39804
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Matt Braithwaite <mab@google.com>
2020-02-04 22:14:27 +00:00
David Schinazi 032fc660bc Add 109 and 120 to SSL_alert_desc_string_long
Change-Id: Ie50fcbabec73bf14895c4eaba134409e010679c4
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39784
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-02-04 16:41:56 +00:00
Matthew Braithwaite 6192ccbbfd runner: enable split handshake tests for TLS 1.3.
Although the new tests are enabled by default, there is a flag to
(continue to) skip them.  This is to allow for inter-version
compatibility testing to be performed without a monstrous number of
failures from old versions that don't yet have TLS 1.3 support.

Change-Id: I9f5e201a21f775442859e127c906b5f77ad8755b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39388
Commit-Queue: Matt Braithwaite <mab@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-02-04 00:02:33 +00:00
Matthew Braithwaite f3c98ce9b7 Make TLS 1.3 split handshakes work with early data.
Change-Id: Ib051447a4bdde4e08e84e54ec619d47535bb472c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39384
Commit-Queue: Matt Braithwaite <mab@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-02-03 22:54:43 +00:00
Matthew Braithwaite 093a823923 Split half-RTT tickets out into a separate TLS 1.3 state.
This is prefactoring to allow a split handshake to be handed back
prior to sending the half-RTT ticket.

Change-Id: Ib5c335b3109a024391c2ec2cab0749eae43f4646
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39744
Commit-Queue: Matt Braithwaite <mab@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-01-29 20:40:05 +00:00
Augusto Righetto bc7e2cb92d Use BCryptGenRandom when building as Windows UWP app.
RtlGenRandom is a legacy API that might be altered and is unavailable
for UWP apps. BCryptGenRandom is the recommended API for generating
random numbers on UWP.

This change causes BCryptGenRandom to be used for UWP apps and
RtlGenRandom to be used on non-UWP apps (i.e. desktop apps). For non-UWP
configurations, RtlGenRandom is used instead of BCryptGenRandom to avoid
accessing resources that may be unavailable inside the Chromium sandbox.

Bug: 307
Change-Id: I49f445198b7b4f300a752f45e221a2875d17099e
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39584
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2020-01-28 16:27:53 +00:00
David Benjamin 1cc95ac07c Define EVP compatibility constants for X448 and Ed448.
We do not support these, but Node expects the constants to be there, so
define them. Also fill in X25519's OID. Now that we can wrap it in
EVP_PKEY, we should have the OID there. (Our serializers don't use the
giant OID table, which is why it didn't matter.)

Change-Id: Ie0637f0e525c5704a9354c743075c027ace2f631
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39724
Reviewed-by: Adam Langley <agl@google.com>
2020-01-22 23:03:16 +00:00
Adam Langley a0cdbf989c Allow shared libraries in the external CMake build.
It's trivial to add and someone requested it. Although we don't
generally take external requests, I suspect that gRPC will ask for it
soon enough so worth doing.

BUG=309

Change-Id: I59d6b4f8b26841a95ccf09c753e2afc28e13722b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39664
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-01-21 17:31:57 +00:00
Adam Langley a965a25952 Add a few little-endian functions to CBS/CBB.
Change-Id: Idf962d587f031c1feed541a43be55dc9a65ca444
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39607
Reviewed-by: David Benjamin <davidben@google.com>
2020-01-17 19:13:18 +00:00
Adam Langley 89730072b8 Move iOS asm tricks up in external CMake build.
This block needs to come before enable_language in order to have the
correct effect.

Change-Id: I2c0e3332c055828381694305e14f2f54b50bb06b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39644
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-01-17 16:39:30 +00:00
David Benjamin f22e5fbaba Try again to deal with expensive tests.
BlindingCacheConcurrency is crashing on older macOS in Chromium and
Wycheproof primality tests are timing out on Windows. Just disable them
both by default and reenable only when running tests standalone.

Bug: chromium:1042657
Change-Id: Ib3151e883269d1c03154560c2c6f89467cc0113c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39625
Reviewed-by: Adam Langley <agl@google.com>
2020-01-17 01:21:15 +00:00
David Benjamin e1148bdf89 Restore ARM CPU variation tests on builders.
After
https://boringssl.googlesource.com/boringssl/+/9351266ba520336aa082fd256386a46bd1382558,
all_tests.go now sees runtime.GOOS == "android".

Change-Id: If7c5ec448c2ea4bc7efff79acf9aaa55690eda04
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39626
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-01-17 00:25:00 +00:00
David Benjamin f249840c94 Remove SSL_CTX_set_rsa_pss_rsae_certs_enabled.
We never ended up using this, and it'll only become less relevant over
time.

Change-Id: I44c750aee24df8e9eecc28b46540d8b3139004ff
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39608
Reviewed-by: Adam Langley <agl@google.com>
2020-01-16 23:39:20 +00:00
David Benjamin 986afedaa7 Work around another NULL/0 C language bug.
memchr should be OPENSSL_memchr to avoid tripping the memchr variant
of the memcpy(NULL, NULL, 0) language flaw.

Change-Id: I5c945fa6df026d56073f3c5839c0d19cecaf1aa0
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39624
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-01-16 22:22:59 +00:00
David Benjamin 0416e8c305 Use the MAYBE/DISABLED pattern in RSATest.BlindingCacheConcurrency.
Change-Id: Ia3565c117eb952a106bc5f1ab7d5231708854483
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39606
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-01-15 22:31:48 +00:00
David Benjamin 31e64a295e Switch an #if-0-gated test to DISABLED_Foo.
This is still runnable with --gtest_also_run_disabled_tests and ensures
it keeps compiling at least.

Change-Id: I15bdcb97e74574c04c1119da3945dd6c0350beea
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39605
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-01-15 22:30:08 +00:00
Matthew Braithwaite 98b4cdba1e Proxy: send whole SSL records through the handshaker.
In split handshake tests, it is already the case that the handshaker
must signal the proxy when it wants to read more data.  But there was
not a lot of specificity about exactly how much data would be read.

The case of rejecting early data sent with a second ClientHello,
following a HelloRetryRequest,[1] requires this to be nailed down, in
order that the handshaker should not process the early data.

This commit changes the handshaker to read exactly one SSL record and
then stop, when it is asked to read.  The pattern of I/O operations
remains undefined.

[1] See SkipEarlyData-SecondClientHelloEarlyData-TLS13-Split.

Change-Id: I30f58e57fc5ebff3f7c7ef8482cc629e42fef6a4
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39524
Commit-Queue: Matt Braithwaite <mab@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-01-15 21:36:18 +00:00
David Benjamin 0dcc6e231d Disable Wycheproof primality test cases on non-x86 (too slow)
I had hoped outputting regularly would solve things, but one of
Chromium's Android builders is still timing out. Limit it to x86 and
x86_64, which typically is correlated with a more powerful CPU in
downstream CIs.

This isn't great, but we still run non-Wycheproof primality tests and
primality testing doesn't have any dedicated platform-specific assembly.
It does run platform-specific assembly by way of lower-level BIGNUM
operations, but those are also tested elsewhere. bn_mod_u16_consttime
depends on 32-bit vs 64-bit, but that is covered by running on both
32-bit and 64-bit x86.

Use the GTest DISABLED_Foo mechanism so they may still be run manually
with --gtest_also_run_disabled_tests.

Change-Id: Ie422096db5bb4186145532f4fd2d4063372b8988
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39604
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-01-15 21:08:58 +00:00
Matthew Braithwaite f06254c739 test_state.cc: serialize the test clock.
This is needed for some TLS 1.3 split-handshake tests.  Because
TestState::Deserialize doesn't check for CBS_len() == 0, it should be
a compatible change to tack additional data onto the end of the
serialized test state.

Change-Id: I16464b6e27ab2e9afd0d505719095b4895e652a4
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39546
Commit-Queue: Matt Braithwaite <mab@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-01-15 20:38:44 +00:00
David Benjamin 8e8759f0d3 Output after every Wycheproof primality test.
Running that many primality tests, particularly on large numbers, in a
single test case is slow and timing out Chromium's test runner.

Change-Id: I07363744970545b2b4fcd7be264e20c338765dea
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39564
Reviewed-by: Adam Langley <agl@google.com>
2020-01-15 17:12:02 +00:00
Adam Langley ff631133c4 Maybe fix generated-CMake build on Android and iOS.
Based on reports, these changes seem like good suspects for build
failures reported, while using the generated CMake build, on iOS and
Android. By checking this in, this change will appear in the
master-with-bazel branch, making it easier for consumers to test.

Change-Id: Icbcebe85f10fad76e3224333c769d0818ae45244
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39545
Reviewed-by: David Benjamin <davidben@google.com>
2020-01-15 16:59:50 +00:00
David Benjamin f50a8a77bd Detect the NDK path from CMAKE_TOOLCHAIN_FILE.
The NDK toolchain file uses either ANDROID_NDK or CMAKE_TOOLCHAIN_FILE,
so look at both. In particular, our builders don't pass in ANDROID_NDK.

Change-Id: Ic7fabdbd16adc3d38389d338b38839b67dde6523
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39544
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-01-13 23:50:48 +00:00
David Benjamin 9351266ba5 Tell Go to build for GOOS=android when running on Android.
This is a speculative fix for the CI flakiness on Android. It seems
Android and Linux ARM ABIs may differ slightly in handling of thread
locals, so we should build for GOOS=android. That requires cgo and
pointing CC at a suitable target-specific compiler from the NDK. Detect
those values from CMakeCache.txt.

Change-Id: I2da75bf9ca6df3e5e677c2151ece8c5e20740fc3
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39504
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-01-13 19:54:08 +00:00
David Benjamin c556d87ddf Reland bitsliced aes_nohw implementation.
This relands
https://boringssl-review.googlesource.com/c/boringssl/+/39206. See that
CL description for details on the change.

The CL was originally reverted due to a number of ARM-only test
failures. First, there was a test-only issue, resolved in
https://boringssl-review.googlesource.com/c/boringssl/+/39306.

Second, the implementation did not work in unoptimized Android Thumb2
builds. This was caused by a clang bug introduced in
https://reviews.llvm.org/rL340261 and fixed in
https://reviews.llvm.org/rL351310. aes_nohw_(un)compact_block have
been rewritten in an attempt to dodge the bug. Performance of optimized
builds with clang and gcc do not appear to be affected by the rewrite.
See the delta from patch set 1.

(I had hoped to improve precommit CQ coverage before landing this, but
both failures turned out to be ARM-only. Either way, there are now
32-bit and 64-bit SSE2-less configurations so the 32-bit and 64-bit
implementations have CQ coverage.)

Change-Id: If5f9f5ea570686a15258ecd7cf49bdbc12dc34c5
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39444
Reviewed-by: Adam Langley <agl@google.com>
2020-01-13 19:14:52 +00:00
Pete Bentley 3e96cd4b76 Add bssl client option to load a hashed directory of cacerts.
Useful for debugging TLS issues on Android.

Change-Id: Ibdf9233b30e297dbab6be86a4f6b1a9eab593dbf
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39464
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2020-01-10 16:38:49 +00:00
David Benjamin b0d449aea2 No-op change to run the new NO_SSE2 builders.
Change-Id: Ie54d4faf911d1106f27aa7e8f0be341cf1ed8a62
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39424
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-01-09 20:34:48 +00:00
David Benjamin 0deb91ab3f Clarify that we perform the point-on-curve check.
Points not on the curve are invalid inputs to EC functions, so EC
implementations should check the curve equation whenever importing
points from the caller. Sadly, a number of implementations, including
older OpenSSLs, miss this important check, so careful callers want this
clarified in the documentation.

Also update the note about OpenSSL to reflect the current behavior.

While I'm here, const-correct EC_KEY_key2buf.

Change-Id: I6fde5c823c4f3f6b141ba1566f427d96cd5881df
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39364
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-01-07 17:04:27 +00:00
Adam Langley 604320f8a3 Reduce size of BlindingCacheConcurrency test under TSAN.
When building with TSAN, having 2048 threads causes crypto_test to run
for more than 20 minutes (when I gave up), vs about two minutes
normally. This will remove our TSAN coverage (due to timeouts) unless we
trim the size of the test.

Change-Id: I381c77a8e9e09c49f3476c38993db40ffdac60d6
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39346
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2020-01-06 20:17:02 +00:00
David Benjamin 2feab0c085 Compare vpaes/bsaes conversions against a reference implementation.
We no longer pair bsaes with aes_nohw and
https://boringssl-review.googlesource.com/c/boringssl/+/39206 aimed to
replace it with a different implementation. This fixes an ARM test
failure when relanding
https://boringssl-review.googlesource.com/c/boringssl/+/39206.

Change-Id: I8c9553f75470cf571ecab279c9451d7228a86485
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39306
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-01-06 19:26:52 +00:00
David Benjamin 63d06626d3 Enable the SSE2 Poly1305 implementation on clang-cl.
poly1305_vec.c requires SSE2 intrinsics and uint128_t. Unlike MSVC, clang-cl
supports uint128_t just fine (as long as we do not do division). This makes
ChaCha20-Poly1305 much faster on Windows when built with clang-cl.

Before:
Did 2219000 ChaCha20-Poly1305 (16 bytes) seal operations in 1016000us (2184055.1 ops/sec): 34.9 MB/s
Did 1279500 ChaCha20-Poly1305 (256 bytes) seal operations in 1016000us (1259350.4 ops/sec): 322.4 MB/s
Did 428250 ChaCha20-Poly1305 (1350 bytes) seal operations in 1015000us (421921.2 ops/sec): 569.6 MB/s
Did 84000 ChaCha20-Poly1305 (8192 bytes) seal operations in 1016000us (82677.2 ops/sec): 677.3 MB/s
Did 39750 ChaCha20-Poly1305 (16384 bytes) seal operations in 1015000us (39162.6 ops/sec): 641.6 MB/s

After:
Did 2096250 ChaCha20-Poly1305 (16 bytes) seal operations in 1015000us (2065270.9 ops/sec): 33.0 MB/s
Did 1453250 ChaCha20-Poly1305 (256 bytes) seal operations in 1016000us (1430364.2 ops/sec): 366.2 MB/s
Did 642500 ChaCha20-Poly1305 (1350 bytes) seal operations in 1015000us (633004.9 ops/sec): 854.6 MB/s
Did 136250 ChaCha20-Poly1305 (8192 bytes) seal operations in 1016000us (134104.3 ops/sec): 1098.6 MB/s
Did 69750 ChaCha20-Poly1305 (16384 bytes) seal operations in 1016000us (68651.6 ops/sec): 1124.8 MB/s

(Benchmarks gathered in VM, but this is a significant difference.)

Change-Id: Ia0a856e75995623c5621d2e48d61d945c41b17de
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39345
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-01-06 19:15:52 +00:00
David Benjamin 056035edcc Remove alignment requirement on CRYPTO_poly1305_finish.
This dates to https://boringssl-review.googlesource.com/2850, which was
done in response to an ARM crash. I assume the ARM crash was due to
poly1305_arm.c casting pointers around, which is technically UB, even on
x86 since C says it is UB to cast pointers if the value would be
unaligned. (Also I believe it's a strict aliasing violation, though the
compilers really ought to give us a sanitizer for it if they're excited
about that optimization.)

Replace with memcpy, which any reasonable compiler would compile the
same on platforms that support unaligned access. ARM does support it
these days, so perhaps the crash came from an older ARM?

Benchmarks showed no difference with this CL.

Change-Id: I022bdb84f95e45c143ad19359f646ee1416d5ae9
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39344
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-01-06 19:10:12 +00:00
Adam Langley 2c58c2fda1 Fix double-free under load.
The BN_BLINDING cache, when 1024 threads are performing concurrent
private operations on one RSA key, can race to append a BN_BLINDING to a
cache which is just short of the maximum length. The cache ends up one
(or more) elements longer than the maximum length. That causes the index
of one of the cache elements to _be_ the supposed maximum length, but
that index is treated as a magic number that indicates that a
BN_BLINDING isn't from the cache and thus needs to be freed after use.
That BN_BLINDING is then double-freed when the cache itself is freed.

See internal bug b/147126942.

Since the fact that someone hit this means that 1024 threads working on
a single RSA key is a thing that's happening, take the opportunity to
grow the cache by doubling rather than by single elements at a time.
Once the number of extensions is so reduced, the trick of unlocking to
keep a few allocations outside of the lock (which caused the problem)
can be discarded.

Change-Id: I32dd16d825b702b31ee9b776414c4e6afe883724
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39324
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2020-01-06 17:34:02 +00:00
David Benjamin aaa1a84d63 Add some XTS tests.
For some reason, these also fail with the reverted aes_nohw on 32-bit
Android. (Still trying to figure out why that happens.)

Change-Id: Ia9ef34e97b473585424120620b1d937220cd2c31
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39305
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-01-03 23:14:49 +00:00
David Benjamin 8959a49cc1 Add EncodeHex and DecodeHex functions to test_util.h.
We have enough copies of these.

Change-Id: I1ff8915b8ca781dc070e802e634d1dc12832e272
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39304
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-01-03 23:10:49 +00:00
David Benjamin 6c95434cc9 Revert "Replace aes_nohw with a bitsliced implementation."
This reverts commit b3ac6bb39a.

Reason for revert: 32-bit version seems to be broken. I'll debug this
and improve pre-commit CQ coverage before relanding.

Original change's description:
> Replace aes_nohw with a bitsliced implementation.
> 
> aes_nohw is currently one of several variable-time table-based
> implementations in C or assembly (armv4, x86, and x86_64). Replace all
> of these with a C bitsliced implementation, with 32-bit, 64-bit, and
> 128-bit (SSE2) variants. This is based on the algorithms described in:
> 
> https://bearssl.org/constanttime.html#aes
> https://eprint.iacr.org/2009/129.pdf
> https://eprint.iacr.org/2009/191.pdf
> 
> This makes our AES implementation constant-time in all build
> configurations!
> 
> There were far too many benchmarks to put in the commit message.
> Instead, please refer to this fancy spreadsheet:
> https://docs.google.com/spreadsheets/d/1wDCzfkPl7brfjWJKq55awQjwCPhOYI8O7zSQZuEc2Xg/edit?usp=sharing
> 
> Parallel modes on x86 and x86_64 do fine due to the SSE2 code. AES-GCM
> actually gets faster. The 64-bit (4x) bitsliced implementation is less
> effective at speeding parallel modes but still helps. The 32-bit (2x)
> bitsliced implementation even less.
> 
> Non-parallel modes, sadly, take a *dramatic* performance hit. I tried a
> constant-time table lookup for comparison, but bitslicing was still
> better. This implementation performs comparably to the table in
> BearSSL's documentation, which suggests I didn't do anything obviously
> wrong. (Note BearSSL's table for 'ct' corresponds to a 32-bit bitsliced
> implementation compiled for 64-bit. Compiling this implementation for
> 64-bit matches, but compiling it for 32-bit seems to be considerably
> slower.)
> 
> Assumptions that may make this palatable:
> 
> - AES-GCM is by far the most important AES mode, and we perform okay
>   with it. Modern things aren't built out of CBC.
> 
> - A nontrivial chunk of Chrome users on Windows don't have SSSE3 and
>   would be affected by this change. They would get the SSE2 version
>   which performs well for AES-GCM *and* is constant-time.
> 
> - ARM devices are primarily mobile which cycles hardware much faster.
>   Chrome for Android has required NEON for several years now, so it
>   would not run this code. (Aside from https://crbug.com/341598.)
> 
> - aarch64 mandates NEON, so it would not run this code.
> 
> - QUIC packet number encryption does use a one-off block operation, but
>   only once per packet.
> 
> - Arguably this is undoing a performance gain that we never earned. That
>   said, it was a dramatic performance gain in places.
> 
> As an alternative, we could just check in the SSE2 version and drop the
> x86 and x86_64 table-based assembly, but this still leaves the generic
> code with cache-timing side channels.
> 
> Change-Id: I0f4b4467a49790509503c529d7c0940318096a00
> Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39206
> Commit-Queue: Adam Langley <agl@google.com>
> Reviewed-by: Adam Langley <agl@google.com>

TBR=agl@google.com,davidben@google.com

Change-Id: Iffaf01a98ab40bbfa009c451aa20ba3eb923eab9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39285
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2020-01-03 17:47:29 +00:00
David Benjamin b3ac6bb39a Replace aes_nohw with a bitsliced implementation.
aes_nohw is currently one of several variable-time table-based
implementations in C or assembly (armv4, x86, and x86_64). Replace all
of these with a C bitsliced implementation, with 32-bit, 64-bit, and
128-bit (SSE2) variants. This is based on the algorithms described in:

https://bearssl.org/constanttime.html#aes
https://eprint.iacr.org/2009/129.pdf
https://eprint.iacr.org/2009/191.pdf

This makes our AES implementation constant-time in all build
configurations!

There were far too many benchmarks to put in the commit message.
Instead, please refer to this fancy spreadsheet:
https://docs.google.com/spreadsheets/d/1wDCzfkPl7brfjWJKq55awQjwCPhOYI8O7zSQZuEc2Xg/edit?usp=sharing

Parallel modes on x86 and x86_64 do fine due to the SSE2 code. AES-GCM
actually gets faster. The 64-bit (4x) bitsliced implementation is less
effective at speeding parallel modes but still helps. The 32-bit (2x)
bitsliced implementation even less.

Non-parallel modes, sadly, take a *dramatic* performance hit. I tried a
constant-time table lookup for comparison, but bitslicing was still
better. This implementation performs comparably to the table in
BearSSL's documentation, which suggests I didn't do anything obviously
wrong. (Note BearSSL's table for 'ct' corresponds to a 32-bit bitsliced
implementation compiled for 64-bit. Compiling this implementation for
64-bit matches, but compiling it for 32-bit seems to be considerably
slower.)

Assumptions that may make this palatable:

- AES-GCM is by far the most important AES mode, and we perform okay
  with it. Modern things aren't built out of CBC.

- A nontrivial chunk of Chrome users on Windows don't have SSSE3 and
  would be affected by this change. They would get the SSE2 version
  which performs well for AES-GCM *and* is constant-time.

- ARM devices are primarily mobile which cycles hardware much faster.
  Chrome for Android has required NEON for several years now, so it
  would not run this code. (Aside from https://crbug.com/341598.)

- aarch64 mandates NEON, so it would not run this code.

- QUIC packet number encryption does use a one-off block operation, but
  only once per packet.

- Arguably this is undoing a performance gain that we never earned. That
  said, it was a dramatic performance gain in places.

As an alternative, we could just check in the SSE2 version and drop the
x86 and x86_64 table-based assembly, but this still leaves the generic
code with cache-timing side channels.

Change-Id: I0f4b4467a49790509503c529d7c0940318096a00
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39206
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2020-01-03 16:41:59 +00:00
Adam Langley cbae965ca0 Switch HRSS inversion algorithm.
This algorithm is much simplier and more obvious than the one from the
HRSS paper. Unfortunately it's not immediately any faster (roughly a
no-op on most platforms, +5% on ARM) but it does allow a bunch of
constant-time rotation code to be deleted.

Since it's simplier, however, it's easier to speed-up a little with
future changes.

Change-Id: Ic0e92c77c44ea9aeb6fe35940af9767084fe5f58
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39084
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-12-20 21:54:43 +00:00
David Benjamin 6c5e4a4bc9 Run EVP_CIPHER tests in-place.
I had a bug that was only caught in ssl_test. This would have caught it
in crypto_test (although only via Wycheproof test vectors; our
EVP_CIPHER CBC test vectors are all short.)

Change-Id: I8dc1457796cb6a8c0be808639657ce74967225ad
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39205
Reviewed-by: Adam Langley <agl@google.com>
2019-12-20 18:32:27 +00:00
David Benjamin 6887d5e81b Add an option to disable SSE2 intrinsics for testing.
We have some code which uses SSE2 intrinsics which, since they don't
have complicated build requirements, is enabled even with
OPENSSL_NO_ASM. x86_64 mandates SSE2 and people building for x86 tend to
mandate it anyway these days. This is great, but we still have generic
32-bit and 64-bit code configurations for other platforms.

32-bit generic code is covered by testing 32-bit ARM with NEON disabled.
However, 64-bit ARM always has NEON available, so we have no SIMD-less
64-bit platforms in our CI.

The immediate motivation is some bitsliced AES code I'm working on,
however I believe this also applies to the existing HRSS code. This also
fixes the HRSS feature checks to only look at __SSE2__, not __SSE__.
__SSE__ isn't sufficient and we don't compile if GCC or Clang is told
-msse -mno-sse2.

Change-Id: Iebb23f1664a2f62e0b4333e0e99f7d5f6c7f384d
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39204
Reviewed-by: Adam Langley <agl@google.com>
2019-12-20 18:29:26 +00:00
Adam Langley 522e2df089 Dummy change to trigger master-with-bazel builder.
Change-Id: I0ac60d7b67f8f680a8faaba736eb85aa6a94b6a2
2019-12-18 12:06:18 -08:00
Adam Langley c58a85f8ca Drop use of alignas(64) in aead_test.cc
Reportedly, GCC 8 and 9, on aarch64, rejects this with:

  crypto/cipher_extra/aead_test.cc:545:54: error: requested alignment 64 is larger than 16 [-Werror=attributes]

The only other uses of alignas(x), with x > 16, are in x86-64-only code.

Change-Id: I1c93732cb40a783c2ef7271b1df9baae644b4305
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39224
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-12-18 18:26:40 +00:00
Adam Langley cfd80a9b24 Add standalone CMake build to generate_build_files.py
This change adds a 'cmake' build type to generate_build_files.py, which
creates a standalone, CMake build without (most) of the complexities of
the full development CMake build.

(This is just a sketch for now. Some deduplication of the CMake is
called for before landing, presuming that this is useful.)

Change-Id: I1f91a8905cabaedf8f9ec588da5784edd67bfed0
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38744
Reviewed-by: Adam Langley <agl@google.com>
2019-12-17 22:00:50 +00:00
Matthew Braithwaite cc0c28654a TLS 1.3 split handshake initial support.
This does not change the wire format for any existing (TLS 1.2 and
lower) cases, which means it should not affect interoperability of
anything that exists.

Most tests pass, but I'll land those in a separate commit, after
nailing down some loose ends, and in order to have more time to reason
about interoperability effects.

Some features are not supported yet, e.g early data.

Change-Id: I7bb377017324cb3d98df75c5d6ed4757c6901ed7
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38926
Reviewed-by: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Matt Braithwaite <mab@google.com>
2019-12-16 23:05:32 +00:00
David Benjamin be1d14b789 Import Wycheproof primality tests.
Change-Id: I885fb8f282b6339bdb061fde1c8d3d74706de5b5
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39196
Reviewed-by: Adam Langley <agl@google.com>
2019-12-16 22:20:51 +00:00
David Benjamin 0df6edff4f Split BN_prime_checks into two constants for generation and validation.
Although (somewhat) documented in prose, it is not obvious from the name
that BN_prime_checks only works for randomly-selected candidate primes.
Split into BN_prime_checks_for_generation and
BN_prime_checks_for_validation. Fix internal call sites. Notably,
DH_check now uses more iterations.

Consistently call the parameter 'checks' rather than 'iterations', to
match BN_prime_checks.

This is in preparation for importing the Wycheproof primality testing
vectors, some of which include Miller-Rabin worst case values.
(Realistically the blinding mechanism meant, even for those inputs, our
false positive rate was at most ~2^-64 anyway, but best to keep the use
cases clear.)

Update-Note: DH_check may be slower after this change.
Change-Id: Ic13d03d8631e74bf2958979ee5ef45a69e603f46
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39195
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-12-16 22:20:22 +00:00
David Benjamin 9511ca4c03 Add some Miller-Rabin tests from Wycheproof.
Wycheproof's primality testing vectors include worst case values where
1/4 of witnesses are false. Add some test cases for true and false
witnesses.

Change-Id: I66050fd34694ca1cc145f950500d110c22d8bd42
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39194
Reviewed-by: Adam Langley <agl@google.com>
2019-12-16 20:26:32 +00:00
David Benjamin a165168277 Import Wycheproof PKCS#1 decrypt tests.
Change-Id: I2f9bca4233b42ff5604e1516ad482142470467dd
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39193
Reviewed-by: Adam Langley <agl@google.com>
2019-12-16 20:25:35 +00:00
David Benjamin 355828a2f7 Import Wycheproof OAEP tests.
Change-Id: I49fb836e92ee6c0b668b3921f6f873b8f79e793d
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39192
Reviewed-by: Adam Langley <agl@google.com>
2019-12-16 20:24:27 +00:00
David Benjamin e5905d01c3 Import Wycheproof PKCS#1 signing tests.
In doing so, add an IgnoreAllInstructions option for FileTest. FileTest
tracks unused fields so test drivers don't accidentally miss a portion
of the test. Wycheproof tests, however, have many different key formats
in instructions. These are tedious to list out, so add an option to
ignore them, on the assumption that checking attributes is more useful
than instructions.

Change-Id: I01cc9f3a95577d576c8c2dd68f5092fceb3215b1
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39191
Reviewed-by: Adam Langley <agl@google.com>
2019-12-16 20:21:41 +00:00
David Benjamin 305a03a8b0 Skip JWK keys when converting Wycheproof tests.
We expand the dictionaries, which is no longer JWK anyway.

Change-Id: I26f0b8beedf82a7efe40a536171eab940c0ec7d5
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39190
Reviewed-by: Adam Langley <agl@google.com>
2019-12-16 20:19:46 +00:00
David Benjamin 55ed2a60d3 Import Wycheproof's size-specific RSA PKCS#1 verifying tests.
It's unclear to me whether the normal rsa_signature_test.txt file is
still needed with these, but I've left it in for now.

Change-Id: I6db9c9556820263c2b0bc37d144e6403b9a7a178
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39189
Reviewed-by: Adam Langley <agl@google.com>
2019-12-16 20:18:35 +00:00
David Benjamin 906bbef001 Handle "acceptable" Wycheproof inputs unambiguously.
This CL updates the JSON conversion to preserve the flags. A
WycheproofResult now captures both "result" and "flags". An "acceptable"
test case's validity is determined by its flags. By default, we consider
an "acceptable" case as invalid, but a test driver may mark some of them
as valid by listing the flags as a parameter.

Previously, some Wycheproof tests (I think it was x25519_tests.txt?) did
not contain enough information to resolve this unambiguously. This has
since been fixed.

This also makes the converted files smaller because we no longer expand the
flags into comments.

Change-Id: I2ca02d7f1b95f250409e8b23c4ad7bb595d77fdf
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39188
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-12-16 20:17:51 +00:00
David Benjamin 62f662dbeb Import Wycheproof XChaCha20-Poly1305 tests.
Change-Id: Iaa10ebfc61aa2f928f057a62737d5d97743d6305
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39187
Reviewed-by: Adam Langley <agl@google.com>
2019-12-16 20:17:00 +00:00
David Benjamin b19efcc1cf Import Wycheproof HMAC tests.
Change-Id: I712ac83efc3bf1edfd4485cb0e822f5719629293
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39186
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-12-16 20:14:01 +00:00
David Benjamin 8e71fe9ca8 Import Wycheproof HKDF tests.
Change-Id: Iece24241327778eb092a069fd1a0784c9d2a7363
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39185
Reviewed-by: Adam Langley <agl@google.com>
2019-12-16 18:58:12 +00:00
Matthew Braithwaite 82dbb53f77 bytestring: add methods for int64.
I guess there's a first time for everything.  Today, it's negative
ASN.1 INTEGERs.  This benefits TLS 1.3 split handshakes.

Change-Id: I886bc513d644dde756db11488d09f450032e464b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39124
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-12-16 18:55:32 +00:00
David Benjamin 15cd8bf433 Update Wycheproof test vectors.
Wycheproof have added many more tests. They'll be imported in subsequent
CLs.

Change-Id: I69d8e09328b08edbd0a96757db26b380d7a7c7ee
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39184
Reviewed-by: Adam Langley <agl@google.com>
2019-12-16 18:53:44 +00:00
Nick Harper b14530e636 Add mock QUIC transport to runner
The mock QUIC transport used has a very simple record layer: A record
starts with a single byte (either 'H' or 'A') identifying the record to
be handshake or application data, then a 4-byte network order integer
indicating the length of the payload, followed by the encryption secret
that would be used for protecting that payload, followed by the payload
itself. The encoded length is only the length of the payload, not that
of the payload and secret (or the whole record).

Bug: 293
Change-Id: Icb706a94ef1ad77e86ef8728b73db8832ee65e1b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39144
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-12-13 21:49:40 +00:00
David Benjamin cb3f04f584 Add test vectors for CVE-2019-1551 (not affected).
This was a bug in the 512-bit RSAZ code, which we removed in
https://boringssl-review.googlesource.com/12841. Import the test vectors
anyway.

(Imported from upstream's 08fb832377cd90c08a2d233b3230b95a9b9f6e24.)

Change-Id: Ie057c54e6e77ac943805dafd74afcb84cf67e918
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39064
Reviewed-by: Adam Langley <agl@google.com>
2019-12-06 17:17:57 +00:00
David Benjamin b63123ca02 Fix check_bn_tests.go.
Go and OpenSSL disagree on 0^-1 (mod 1). Also if the input is ill-formed
and there is no inverse, report an error rather than crashing.

Change-Id: Id5b0b70cd7498e0c7526ec6a7bc5480cd9718f41
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39044
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-12-05 18:11:57 +00:00
David Benjamin 243b5cc9e3 Fix MSan error in SSLTest.Handoff test.
Apparently I forgot to put MSan on the CQ, just CI.

Change-Id: I1f47c3bd92f6db6a67e0a4ecc113a6ea214f642f
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39024
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-12-04 16:49:42 +00:00
Matthew Braithwaite 134fb89c4f SSLTest.Handoff: extend to include a session resumption.
This was a tricky thing to get right for both TLS 1.2 and TLS 1.3, and
having this test around made it easier.

Change-Id: I47f55160c7e267d122f310165a17a1f9402dadd7
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38925
Commit-Queue: Matt Braithwaite <mab@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-12-04 00:00:14 +00:00
Jooyung Han 9ad9cda088 inject_hash preserves filemode
Previously, inject_hash writes output file with 0644 regardless of
input file.

Now it preserves filemode of input when writing output file.

Change-Id: I00db775e1b28f6d9a72986276e32a9b944317949
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38844
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-12-03 18:57:23 +00:00
Matthew Braithwaite 08e1fe05e6 Move TLS 1.3 state machine constants to internal.h.
This benefits TLS 1.3 split handshakes, which need the constants to
put an |SSL| into the correct state after SSL_apply_handback().

Change-Id: I2dc5b108d7393fb30708b89c53adcc73056d4f0b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38924
Commit-Queue: Matt Braithwaite <mab@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-12-03 00:59:11 +00:00
David Benjamin 31db68195b Add a ppc64le ABI tester.
Now we have ABI tests for every architecture where we have assembly.

Change-Id: I59bc2d0f72f2325e9f294b1fc08287bb93fc9cd2
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39008
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-12-02 23:12:31 +00:00
David Benjamin c73375467c Allocate small TLS read buffers inline.
Our TLS read patterns are always read(5); read(record_size); read(5);
read(record_size); ...;. Allocate the 5-byte reads inline in SSLBuffer.
This avoids bouncing on a 5-byte malloc to learn a socket is idle and
avoids calling malloc twice on each record.

This costs a few bytes but means we malloc once per record, rather than
twice per record + once each time the state machine is run while idle.

Change-Id: I4f6dafe4141cbb890b921a5fa8d528c1fb98a0b4
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39004
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-12-02 22:14:18 +00:00
David Benjamin b8b0e9f485 Remove unused labels from ARM ABI test assembly.
I think these were copied over from the x86_64 one on accident.

Change-Id: I0a8bb28bb0b9e94739f4696146e2418e84cb2b87
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39007
Reviewed-by: Adam Langley <agl@google.com>
2019-12-02 21:48:35 +00:00
David Benjamin 469446c736 Update AAPCS and AAPCS64 links.
The old ones disappeared. Switch to the developer.arm.com pointers.
Hopefully they are more stable. (Interestingly, the "Download PDF" link
for AAPCS64 now points to a GitHub repo.)

Change-Id: Ifa81e95978285409a6323f007d041515d4f270ee
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39006
Reviewed-by: Adam Langley <agl@google.com>
2019-12-02 21:48:27 +00:00
David Benjamin 5746add69c Fix EVP_has_aes_hardware on ppc64le.
Change-Id: I5e0bc02e591b86ccc30d35eeed2c7065910dd24a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/39005
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-12-02 21:48:21 +00:00
David Benjamin 98ba3bd6e7 Remove remnants of end_of_early_data alert from tests.
It changed from an alert to a handshake message in the
standardization process.

Change-Id: Ib3e5b29ccf83b72d78a714f604957ca55594d5e3
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38604
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-12-02 20:07:53 +00:00
David Benjamin f8fcab9d81 Add a test for ERR_error_string_n.
The truncation logic has some non-trivial bits around preserving colon
separators which we ought to test.

Change-Id: Id2784546f6578ebd85ba6bf1010c575cc371ef1b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38965
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-12-02 17:52:12 +00:00
David Benjamin e0d95adb24 Remove post-quantum experiment signal extension.
The experiment has concluded, so we don't need this anymore.

Change-Id: Id99722394d5d0525f536bddea5df6cde8bb44c94
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38944
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-12-02 17:40:22 +00:00
David Benjamin 35c1075e83 Give ERR_error_string_n a return value for convenience.
ERR_error_string_n needs to be called in a separate statement, compared
to ERR_error_string(err, NULL), which returns a buffer and is very
convenient to use in an expression. This is unfortunate because it is
not thread-safe.

Give ERR_error_string_n a return value to align. Fixing callers still
requires allocating a buffer somewhere, but the rest of the expression
can remain relatively unperturbed.

Change-Id: I273c9df97f0bb113cdc57cf3896c42195910c67a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38964
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-12-02 16:53:32 +00:00
David Benjamin ee0716f386 Defer early keys to QUIC clients to after certificate reverification.
On a client using SSL_CTX_set_reverify_on_resume, we currently release
the early data keys before reverification rather than afterwards. This
means the QUIC implementation needs to watch for SSL_do_handshake's
return value before using the keys we've released. It is better to be
robust, so defer releasing the keys in the first place.

To avoid oddities around TCP and QUIC differences, tweak the 0-RTT cert
reverification to not send an alert on error. Sending such an alert
under early data is somewhat questionable given the server may not be
able to read it anyway.

Bug: 303
Change-Id: I42c16f9f046322d0b03cb0b425e11471f2fbe52a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38885
Reviewed-by: Nick Harper <nharper@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-11-27 15:49:42 +00:00
David Benjamin fd32089f47 Defer releasing early secrets to QUIC servers.
We want the QUIC/TLS interface to never release a read key without the
corresponding write key for ACKs. This is mostly done by shipping both keys
simultaneously, but 0-RTT is weird because it is ACKed by 1-RTT.

Note this means we actually release 0-RTT keys to the server *after* the 1-RTT
keys. This is kinda weird but more directly maintains our invariant.

(We may want to revisit the key configuring API in light of
https://github.com/quicwg/base-drafts/issues/3159 and
https://github.com/quicwg/base-drafts/issues/3173, but start with this more
local tweak.)

Bug: 303
Change-Id: I317fe6ae8150533738373c219f19d3034bb040ad
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38884
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Nick Harper <nharper@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2019-11-27 14:15:33 +00:00
David Benjamin 75148d7abf Halve the size of the kNIDsIn* constants
We have not and are unlikely to ever allocate 65K NIDs, so these ables can use
uint16_t and halve their size.

Bug: 300
Change-Id: I5c69a366588f26df75b7b642bee6dd12ad8cc661
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38904
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-11-20 15:09:27 +00:00
Adam Langley 6ba98ff601 modulewrapper: manage buffer with |unique_ptr|.
This doesn't actually matter, but ASan otherwise complains about the
memory leak on process exit.

Change-Id: Ic7cf591b7687f10c3a5bc304e1321f4deecdcb10
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38804
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-11-12 23:49:31 +00:00
David Benjamin af609d885b Add missing boringssl_prefix_symbols_asm.h include.
This file probably should be switched to perlasm, but this is an easier fix for
now. It touches ymm registers, so Windows will be a little fussy.

Change-Id: I7b89435cb5c3e908b3bc784d7c305f115e707358
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38864
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-11-12 23:34:21 +00:00
Gurleen Grewal 913a240c28 acvptool: add support for ECDSA
Change-Id: I0c643de16d5215a20bb21e8523efccd5555098eb
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38764
Reviewed-by: Gurleen Grewal <gurleengrewal@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-11-12 23:13:24 +00:00
David Benjamin 5d62952b2a Inline gcm_init_4bit into gcm_init_ssse3.
In doing so, convert an unnecessary macro into an inline function and
avoid needing to fix up the word order. gcm.c likes to store things with
the words byteswapped and the words unswapped.

Change-Id: Ifa4cbe9ceaaf2d4cd3b6133d442603343b409cc3
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38785
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-11-12 05:59:55 +00:00
David Benjamin a2518dd077 Vectorize gcm_mul32_nohw and replace gcm_gmult_4bit_mmx.
This shrinks the perf gap between nohw and 4bit_mmx. Replace 4bit_mmx
and fix the last remaining variable-time GHASH implementation, covering
32-bit x86 without SSSE3.

Before:
Did 2065000 AES-128-GCM (16 bytes) seal operations in 1000154us (2064682.0 ops/sec): 33.0 MB/s
Did 368000 AES-128-GCM (256 bytes) seal operations in 1002435us (367106.1 ops/sec): 94.0 MB/s
Did 77000 AES-128-GCM (1350 bytes) seal operations in 1001225us (76905.8 ops/sec): 103.8 MB/s
Did 14000 AES-128-GCM (8192 bytes) seal operations in 1067523us (13114.5 ops/sec): 107.4 MB/s
Did 6572 AES-128-GCM (16384 bytes) seal operations in 1015976us (6468.7 ops/sec): 106.0 MB/s
After:
Did 1995000 AES-128-GCM (16 bytes) seal operations in 1000374us (1994254.1 ops/sec): 31.9 MB/s
Did 319000 AES-128-GCM (256 bytes) seal operations in 1000196us (318937.5 ops/sec): 81.6 MB/s
Did 66000 AES-128-GCM (1350 bytes) seal operations in 1002823us (65814.2 ops/sec): 88.8 MB/s
Did 12000 AES-128-GCM (8192 bytes) seal operations in 1079294us (11118.4 ops/sec): 91.1 MB/s
Did 5511 AES-128-GCM (16384 bytes) seal operations in 1006218us (5476.9 ops/sec): 89.7 MB/s
(Note fallback AES is dampening the perf hit. Pairing with AESNI to
roughly isolate GHASH shows a 40% hit.)

That just leaves aes_nohw...

Change-Id: I7d842806c54a5a057895fa2e7665633330e34b72
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38784
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-11-12 01:01:38 +00:00
David Benjamin 9855c1c59a Add a constant-time fallback GHASH implementation.
We have several variable-time table-based GHASH implementations, called
"4bit" in the code. We have a fallback one in C and assembly
implementations for x86, x86_64, and armv4. This are used if assembly is
off or if the hardware lacks NEON or SSSE3.

Note these benchmarks are all on hardware several generations beyond
what would actually run this code, so it's a bit artificial.

Implement a constant-time implementation of GHASH based on the notes in
https://bearssl.org/constanttime.html#ghash-for-gcm, as well as the
reduction algorithm described in
https://crypto.stanford.edu/RealWorldCrypto/slides/gueron.pdf.

This new implementation is actually faster than the fallback C code for
both 32-bit and 64-bit. It is slower than the assembly implementations,
particularly for 32-bit. I've left 32-bit x86 alone but replaced the
x86_64 and armv4 ones.  The perf hit on x86_64 is smaller and affects a
small percentage of 64-bit Chrome on Windows users. ARM chips without
NEON is rare (Chrome for Android requires it), so replace that too.

The answer for 32-bit x86 is unclear. More 32-bit Chrome on Windows
users lack SSSE3, and the perf hit is dramatic. gcm_gmult_4bit_mmx uses
SSE2, so perhaps we can close the gap with an SSE2 version of this
strategy, or perhaps we can decide this perf hit is worth fixing the
timing leaks.

32-bit x86 with OPENSSL_NO_ASM
Before: (4bit C)
Did 1136000 AES-128-GCM (16 bytes) seal operations in 1000762us (1135135.0 ops/sec): 18.2 MB/s
Did 190000 AES-128-GCM (256 bytes) seal operations in 1003533us (189331.1 ops/sec): 48.5 MB/s
Did 40000 AES-128-GCM (1350 bytes) seal operations in 1022114us (39134.6 ops/sec): 52.8 MB/s
Did 7282 AES-128-GCM (8192 bytes) seal operations in 1117575us (6515.9 ops/sec): 53.4 MB/s
Did 3663 AES-128-GCM (16384 bytes) seal operations in 1098538us (3334.4 ops/sec): 54.6 MB/s
After:
Did 1503000 AES-128-GCM (16 bytes) seal operations in 1000054us (1502918.8 ops/sec): 24.0 MB/s
Did 252000 AES-128-GCM (256 bytes) seal operations in 1001173us (251704.8 ops/sec): 64.4 MB/s
Did 53000 AES-128-GCM (1350 bytes) seal operations in 1016983us (52114.9 ops/sec): 70.4 MB/s
Did 9317 AES-128-GCM (8192 bytes) seal operations in 1056367us (8819.9 ops/sec): 72.3 MB/s
Did 4356 AES-128-GCM (16384 bytes) seal operations in 1000445us (4354.1 ops/sec): 71.3 MB/s

64-bit x86 with OPENSSL_NO_ASM
Before: (4bit C)
Did 2976000 AES-128-GCM (16 bytes) seal operations in 1000258us (2975232.4 ops/sec): 47.6 MB/s
Did 510000 AES-128-GCM (256 bytes) seal operations in 1000295us (509849.6 ops/sec): 130.5 MB/s
Did 106000 AES-128-GCM (1350 bytes) seal operations in 1001573us (105833.5 ops/sec): 142.9 MB/s
Did 18000 AES-128-GCM (8192 bytes) seal operations in 1003895us (17930.2 ops/sec): 146.9 MB/s
Did 9000 AES-128-GCM (16384 bytes) seal operations in 1003352us (8969.9 ops/sec): 147.0 MB/s
After:
Did 2972000 AES-128-GCM (16 bytes) seal operations in 1000178us (2971471.1 ops/sec): 47.5 MB/s
Did 515000 AES-128-GCM (256 bytes) seal operations in 1001850us (514049.0 ops/sec): 131.6 MB/s
Did 108000 AES-128-GCM (1350 bytes) seal operations in 1004941us (107469.0 ops/sec): 145.1 MB/s
Did 19000 AES-128-GCM (8192 bytes) seal operations in 1034966us (18358.1 ops/sec): 150.4 MB/s
Did 9250 AES-128-GCM (16384 bytes) seal operations in 1005269us (9201.5 ops/sec): 150.8 MB/s

32-bit ARM without NEON
Before: (4bit armv4 asm)
Did 952000 AES-128-GCM (16 bytes) seal operations in 1001009us (951040.4 ops/sec): 15.2 MB/s
Did 152000 AES-128-GCM (256 bytes) seal operations in 1005576us (151157.1 ops/sec): 38.7 MB/s
Did 32000 AES-128-GCM (1350 bytes) seal operations in 1024522us (31234.1 ops/sec): 42.2 MB/s
Did 5290 AES-128-GCM (8192 bytes) seal operations in 1005335us (5261.9 ops/sec): 43.1 MB/s
Did 2650 AES-128-GCM (16384 bytes) seal operations in 1004396us (2638.4 ops/sec): 43.2 MB/s
After:
Did 540000 AES-128-GCM (16 bytes) seal operations in 1000009us (539995.1 ops/sec): 8.6 MB/s
Did 90000 AES-128-GCM (256 bytes) seal operations in 1000028us (89997.5 ops/sec): 23.0 MB/s
Did 19000 AES-128-GCM (1350 bytes) seal operations in 1022041us (18590.3 ops/sec): 25.1 MB/s
Did 3150 AES-128-GCM (8192 bytes) seal operations in 1003199us (3140.0 ops/sec): 25.7 MB/s
Did 1694 AES-128-GCM (16384 bytes) seal operations in 1076156us (1574.1 ops/sec): 25.8 MB/s
(Note fallback AES is dampening the perf hit.)

64-bit x86 with OPENSSL_ia32cap=0
Before: (4bit x86_64 asm)
Did 2615000 AES-128-GCM (16 bytes) seal operations in 1000220us (2614424.8 ops/sec): 41.8 MB/s
Did 431000 AES-128-GCM (256 bytes) seal operations in 1001250us (430461.9 ops/sec): 110.2 MB/s
Did 89000 AES-128-GCM (1350 bytes) seal operations in 1002209us (88803.8 ops/sec): 119.9 MB/s
Did 16000 AES-128-GCM (8192 bytes) seal operations in 1064535us (15030.0 ops/sec): 123.1 MB/s
Did 8261 AES-128-GCM (16384 bytes) seal operations in 1096787us (7532.0 ops/sec): 123.4 MB/s
After:
Did 2355000 AES-128-GCM (16 bytes) seal operations in 1000096us (2354773.9 ops/sec): 37.7 MB/s
Did 373000 AES-128-GCM (256 bytes) seal operations in 1000981us (372634.4 ops/sec): 95.4 MB/s
Did 77000 AES-128-GCM (1350 bytes) seal operations in 1003557us (76727.1 ops/sec): 103.6 MB/s
Did 13000 AES-128-GCM (8192 bytes) seal operations in 1003058us (12960.4 ops/sec): 106.2 MB/s
Did 7139 AES-128-GCM (16384 bytes) seal operations in 1099576us (6492.5 ops/sec): 106.4 MB/s
(Note fallback AES is dampening the perf hit. Pairing with AESNI to roughly
isolate GHASH shows a 40% hit.)

For comparison, this is what removing gcm_gmult_4bit_mmx would do.
32-bit x86 with OPENSSL_ia32cap=0
Before:
Did 2014000 AES-128-GCM (16 bytes) seal operations in 1000026us (2013947.6 ops/sec): 32.2 MB/s
Did 367000 AES-128-GCM (256 bytes) seal operations in 1000097us (366964.4 ops/sec): 93.9 MB/s
Did 77000 AES-128-GCM (1350 bytes) seal operations in 1002135us (76836.0 ops/sec): 103.7 MB/s
Did 13000 AES-128-GCM (8192 bytes) seal operations in 1011394us (12853.5 ops/sec): 105.3 MB/s
Did 7227 AES-128-GCM (16384 bytes) seal operations in 1099409us (6573.5 ops/sec): 107.7 MB/s
If gcm_gmult_4bit_mmx were replaced:
Did 1350000 AES-128-GCM (16 bytes) seal operations in 1000128us (1349827.2 ops/sec): 21.6 MB/s
Did 219000 AES-128-GCM (256 bytes) seal operations in 1000090us (218980.3 ops/sec): 56.1 MB/s
Did 46000 AES-128-GCM (1350 bytes) seal operations in 1017365us (45214.8 ops/sec): 61.0 MB/s
Did 8393 AES-128-GCM (8192 bytes) seal operations in 1115579us (7523.4 ops/sec): 61.6 MB/s
Did 3840 AES-128-GCM (16384 bytes) seal operations in 1001928us (3832.6 ops/sec): 62.8 MB/s
(Note fallback AES is dampening the perf hit. Pairing with AESNI to roughly
isolate GHASH shows a 73% hit. gcm_gmult_4bit_mmx is almost 4x as faster.)

Change-Id: Ib28c981e92e200b17fb9ddc89aef695ac6733a43
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38724
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-11-12 00:27:02 +00:00
Pete Bentley 98f969491c Conditionally define PTRACE_O_EXITKILL in urandom_test.cc
On older Linux distributions (e.g. Centos 7 which we still use for
Conscrypt releases) PTRACE_O_EXITKILL is defined in <linux/ptrace.h>
but this can't be included alongside <sys/ptrace.h> due to conflicting
defines, so this is the path of least resistance for portability.

Could also define this as 0 if undefined, but all distributions seem
to use 1<<20, and Centos 7 kernels should have support as they are 3.10
and later and PTRACE_O_EXITKILL was introduced around 3.8.

Change-Id: Ib8a6e0dbc62613e30c38a6cc09522c2d7b92577b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38704
Reviewed-by: Adam Langley <agl@google.com>
2019-11-08 15:49:37 +00:00
David Benjamin 43890dbd69 Fix build warning if _SCL_SECURE_NO_WARNINGS is defined globally
Thanks to shohei.yoshida@dena.jp for reporting the issue and providing
a patch.

Bug: 302
Change-Id: I1200a917ef4b791822712feafece19cb21988d55
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38684
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-11-07 16:09:13 +00:00
Adam Langley 279740ed8d modulewrapper: use a raw string.
The quoting in the JSON configuration string was getting a little out of
hand. Use a C++ raw string instead.

Change-Id: I568672480e967361f8269382f73e3c41bc71a0b7
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38665
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-11-05 20:19:12 +00:00
Adam Langley d709b0d892 acvptool: add license headers.
Change-Id: I0da3e2a89cc502563d74dbbbdb0dddacfaaf5f9c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38664
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-11-05 20:01:21 +00:00
Matthew Braithwaite 58d56f4c59 Enable TLS 1.3 by default.
Update-Note: If calling code does not work with TLS 1.3, the simplest
fix is to call SSL_CTX_set_max_proto_version(ctx, TLS1_2_VERSION).

Change-Id: Ic99861753dac117c52aea1988a6c4227a32984ca
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38624
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-11-05 19:44:12 +00:00
Gurleen Grewal 9294306578 acvptool: Add support for DRBG
Change-Id: Ia9dda0826787aea4d63536524074e343ff6c87d9
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38644
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: Gurleen Grewal <gurleengrewal@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-11-05 19:29:15 +00:00
David Benjamin f0bdf5c9a1 Discard user_canceled alerts in TLS 1.3.
Warning alerts do not exist in TLS 1.3, but RFC 8446 section 6.1
continues to define user_canceled as a signal to cancel the handshake,
without specifying how to handle it. JDK11 misuses it to signal
full-duplex connection close after the handshake. As a workaround, skip
user_canceled as in TLS 1.2. This matches NSS and OpenSSL.

Bug: b/135941563
Change-Id: I7ef546f1f166741b9f112686c75e6757331948f0
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38605
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-10-31 19:20:03 +00:00
David Benjamin 6be491b7bb Work around more C language bugs with empty spans.
C's specification text around pointer arithmetic is buggy and fails to
account for empty spans. Empty spans are typically represented as
ptr=NULL and len=0, so (T*)NULL + 0 must be defined for ptr + len to
reliably work. C++ does not have this bug and specifies this correctly.
See https://crbug.com/1019588.

This language bug has made its way over to newer versions of UBSan,
which enforce this. In the short term, add bogus length checks as a
workaround. However, unlike the memcpy language bug, we cannot address
this systematically. In the long term, we need to switch libcrypto to
building as C++ for a real fix.

To test this, update our clang revision to that in
https://chromium-review.googlesource.com/c/chromium/src/+/1879890. Note
that clang revision was later reverted in Chromium for seemingly
unrelated reasons.

This newer UBSan also catches a memcpy/OPENSSL_memcpy issue in
siphash.c, from the earlier C NULL bug we'd been working around.

Bug: chromium:1019588, chromium:1019644
Change-Id: I460e547c8cd740db68da8cc2a3a970276ec92e90
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38584
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-10-30 17:02:32 +00:00
David Benjamin bf7b331d1b No-op commit to test the new builder.
Change-Id: I9f29265715a784e0213425935421639d705cbe31
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38565
Reviewed-by: David Benjamin <davidben@google.com>
2019-10-29 17:56:33 +00:00
Gurleen Grewal 2085c7c2c6 acvptool: Add support for HMAC
Change-Id: Ie3e3748cc1eb0e2f66ef052847179deaf0de239b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38544
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-10-28 18:45:59 +00:00
Shelley Vohr 706da620b2 Add stub functions for RSA-PSS keygen parameters.
These functions are used by Node.js in
https://github.com/nodejs/node/pull/26960. BoringSSL does not
support EVP_PKEY_RSA_PSS keys, so they always fail.

This simplifies building Node with BoringSSL.

Change-Id: I81c4cdba8791a60d965bc176d09e5c818153860c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38524
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-10-23 22:38:19 +00:00
Kris Kwiatkowski b11902a385 HelloRetryRequest getter
Adds getter indicating whether HelloRetryRequest was triggered
during TLSv1.3 handshake.

Change-Id: I84922188ded81ec89259b5f333c80494426759f8
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37304
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-10-23 21:26:29 +00:00
Adam Langley fe37af11a6 Add break-tests-android.sh script.
This addition duplicates the existing break-tests.sh script, but for the
Android context.

Change-Id: I54d0881e11231770978633f03af4bf9dc228611b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38465
Reviewed-by: David Benjamin <davidben@google.com>
2019-10-23 19:46:15 +00:00
Shelley Vohr 3ab3b1283f Add compatibility functions for sigalgs
Node.js recently added an option to override signature algorithms in https://github.com/nodejs/node/pull/29598
which make use of several NIDs and SSL_get_shared_sigalgs. This CL adds
NIDs for Ed448 (but does not implement it) and a shim function for
SSL_get_shared_sigalgs that simply returns 0. This enables Electron to
reduce its patch surface.

Change-Id: I833d30b0248ca68ebce4767dd58d5f087fd1e18e
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38404
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-10-22 16:58:58 +00:00
Adam Langley de1d2881ae Run AES-192-GCM in CAVP tests.
Change-Id: I8fbba51ac650c648893fcd21da5c3018cd7810be
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38426
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-10-22 16:15:18 +00:00
David Benjamin 3ba9586bc0 Rename a number of BUF_* functions to OPENSSL_*.
Upstream did this in 7644a9aef8932ed4d1c3f25ed776c997702982be, so align
with them. Add the new OPENSSL_* names and switch all callers witihn the
library to match. Keep the old BUF_* names around for compatibility.

Note there were two functions where we already had an OPENSSL_* version:
OPENSSL_strdup and OPENSSL_strnlen. The former now gains a NULL check to
align with BUF_strdup. The latter gets deduplicated; we had two
implementations.

Change-Id: Ia1cd4527a752fcd62e142ed1e1d7768d323279ba
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38425
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-10-21 21:06:07 +00:00
Adam Langley 31f94b0bf7 List bn_div fuzzer in documentation.
c951e5560b added it back in the build, but it should be listed in
documentation too. Picked 384 bytes on the assumption that the largest
specialisation that we're likely to have is 1024-bit for RSA 2048.

Change-Id: I13fb46dceedb7a62616db6a2b39634a0b6fed508
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38444
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-10-21 16:29:53 +00:00
David Van Cleve c951e5560b Reenable bn_div fuzzer.
It looks like the bn_div fuzzer was inadvertently removed from
fuzz/'s CMakeLists during an earlier refactor [1]. This change
adds it back.

[1]: https://boringssl-review.googlesource.com/c/boringssl/+/31324/

Change-Id: I8bb4b224eedff60cc5cd6df7fa39d9c39d499a56
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38424
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-10-21 15:46:02 +00:00
Adam Langley 7f02881e96 Drop CECPQ2b code.
The experiment which motivated CECPQ2b has concluded (although the
results haven't been published yet) and the SIKE code is causing some
issues for gRPC in gprc/grpc#20100. Also, this is code size that takes
up space in Android etc.

Change-Id: I43b0b8c420f236c0fe9b40bf2517d2fde98495d5
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38384
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-10-18 22:33:00 +00:00
Adam Langley 7de9498a88 Add urandom_test to all_tests.json
Change-Id: I4e30bc8b8c1bd1215f516a6c89735782cfbf8ef5
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38284
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-10-18 21:44:29 +00:00
David Benjamin e481d94a6f Fix the standalone Android FIPS build.
Change-Id: Idce6c93f5a37e1f05afaa6fb928e15b92d75e911
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38365
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-10-18 21:21:29 +00:00
Adam Langley da8caf5b10 Add sanity checks to FIPS module construction.
If -ffunction-sections or -fdata-sections is enabled when doing a FIPS
shared build, the linker script won't do what's expected and will
silently end up including very little (or nothing) in the integrity
check.

This changes alters the linker script to discard any text or data
sections other than the main one, which should make this failure much
more obvious.

Also, add assertions (that are always enabled) in the module to check
that a few obvious things that should be inside the module boundaries
actually are.

Change-Id: I91178e213a28a7c0c4a38155974e452cd9d558d1
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38324
Reviewed-by: Adam Langley <agl@google.com>
2019-10-18 20:37:54 +00:00
Adam Langley 20ae5e6f6c Correct relative path.
This path has always had one-too-few “..” elements since the file first
appeared, but everyone seems to have lived with it, presumably because
/include is in the search path and the compiler tries relative to that.

Change-Id: I30006209ad74d064ded5dd2cd34b1f14806dcffe
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38344
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-10-18 17:49:29 +00:00
Adam Langley 3e502c84f0 Add test for urandom.c
This change adds a test to try and prevent errors like b8f760191e. Since
it's challenging to test this code, it uses ptrace to capture a trace of
the PRNG behaviour and checks that the observed behaviour matches a much
smaller model of the code. The model is hopefully easier to read and
believe correct.

Change-Id: I00b811dc5692e2fbe3dcc16c622d4eb706f16ce0
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38265
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-10-17 21:38:38 +00:00
Pete Bentley 76918d0164 break-hash.go: Search ELF dynamic symbols if symbols not found.
Allows the utility to work on shared libraries.

Also, don't printf the output from hex.Dump() as it may contain
formatting chars such as %.

Change-Id: I3c091436271c132417fd0212955a6575ef57af50
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38244
Reviewed-by: Adam Langley <agl@google.com>
2019-10-17 15:12:28 +00:00
Adam Langley 9709ad52eb Fix $OPENSSL_ia32cap handling.
The comment says that an "0x" prefix indicates a hex value. However we
always passed PRIu64 as the format specifier for |sscanf|, and |sscanf|
isn't documented to handle an 0x prefix expect for "i"-family format
specifiers. With |PRIu64|, |sscanf| reads any leading "0x" as just zero.

Instead, check for "0x" ourselves and use |PRIx64| if found to parse hex
values.

Change-Id: Id5ed7009d30902022e5ee640e8931bf1431dedc0
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38264
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-10-16 21:25:03 +00:00
David Benjamin eec840da62 Switch probable_prime to rejection sampling.
This is much more straightforward, and aligns better with what our
actual RSA key generation logic does.

Change-Id: I45f368b10f42558b91c2d022847505ddab2f7094
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38170
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-10-15 22:06:37 +00:00
David Benjamin a93bebafb8 Rename the last remnants of the early_data_info extension.
The extension was renamed to just 'early_data' at some point in TLS
1.3's development.

Change-Id: I9d1de10aaeb347237b52a226e9533307f5c269ce
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38224
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-10-15 21:24:17 +00:00
David Benjamin 31302a473a Fix up BN_GENCB_call calls.
Use the constants when defined. Also OpenSSL uses 0-indexed iteration
counts rather than 1-indexed. This likely changed when we tried to align
with the 1-indexed FIPS 186-4 algorithm.

Also fix the safe prime call. BN_GENCB_call(cb, i, c1 - 1) doesn't make
sense since the first parameter should be an event constant. OpenSSL
does BN_GENCB_call(cb, 2, c1 - 1).

This also doesn't make sense. OpenSSL documents 2 as meaning the prime
has been found. That function is interleaving the p and (p-1)/2 checks
to save the full iteration count on p if (p-1)/2 is composite anyway.

That also doesn't work because the blinding mechanism runs even if the
iteration count is 1, so we're actually paying for the blinding four
times. Add a TODO to address this.

(I can only assume we just never try to generate safe primes. Moreover,
we don't even use BN_generate_prime_ex in RSA keygen. Still, that
function needs work.)

Change-Id: I6f0b7cd10da28484362c92db0c806c1c3045d415
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38169
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-10-15 20:50:47 +00:00
David Benjamin a7a75f208c Do fewer trial divisions for larger RSA keygens.
Now that Miller-Rabin can reject composites faster, we can do fewer
trial divisions. Halving the table seems to improve things for RSA-3072
and RSA-4096. I left RSA-2048 alone since measurements with it halved
were a bit more of a wash.

(Although now that I've left it alone, it's gotten faster, so these
numbers are generally noisy.)

Before:
Did 320 RSA 2048 key-gen operations in 30132984us (10.6 ops/sec)
  min: 27703us, median: 81774us, max: 375687us
Did 84 RSA 3072 key-gen operations in 30166627us (2.8 ops/sec)
  min: 86961us, median: 322184us, max: 1170392us
Did 30 RSA 4096 key-gen operations in 30644802us (1.0 ops/sec)
  min: 260916us, median: 772364us, max: 2743435us

After:
Did 345 RSA 2048 key-gen operations in 30103781us (11.5 ops/sec)
  min: 23359us, median: 75033us, max: 267159us
Did 91 RSA 3072 key-gen operations in 30185495us (3.0 ops/sec)
  min: 72531us, median: 267385us, max: 1119039us
Did 38 RSA 4096 key-gen operations in 30473203us (1.2 ops/sec)
  min: 228529us, median: 720027us, max: 2039681us

Change-Id: I52d431347a70572034ced5b7778a2edac8f15173
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38168
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-10-15 20:29:17 +00:00
Adam Langley f3bd757ee5 Fix GRND_NONBLOCK flag when calling getrandom.
I screwed up in 56b6c714c9 and got the direction of this condition
backwards. This doesn't cause a security problem because:
  a) wait_for_entropy will ensure that the pool is initialised.
  b) if GRNG_NONBLOCK is set when not expected, any EAGAIN will
     cause an abort anyway.

However, when coupled with opportunistic entropy collection on platforms
with RDRAND, this could cause an unexpected blocking getrandom call.

This this change, `strace -e getrandom bssl rand 1` shows two getrandom
calls with GRNG_NONBLOCK set, as expected. (The first being the probe to
check whether the kernel supports getrandom, and the second being the
opportunistic entropy gathering to augment RDRAND.)

Change-Id: I98ed1cef90df510f24cf2df1fba9b886fcbf3355
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38204
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-10-15 20:00:07 +00:00
David Benjamin 642664838a Simplify bn_miller_rabin_iteration slightly.
We don't need both mask variables. If we know we have a composite
witness, we return immediately, so the only time we mask off
instructions is when we know we have a nonwitness.

Change-Id: I2b99f3114a79ce2dc1a37706835d2abfe93a716e
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38167
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-10-15 19:34:44 +00:00
David Benjamin 841a40a276 Add some notes on RSA key generation performance.
Change-Id: I8c0cadddcfc7d8b14adbc3ed3b75332859deea42
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38166
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-10-15 18:56:16 +00:00
David Benjamin fba30c389c Break early on composites in the primality test.
|a| is usually much smaller than |w_bits|. We only need to loop up to
|w_bits| and hide |a| when the value is possibly composite. If
Miller-Rabin has not hit -1 by then, break early.

This speeds up RSA keygen by a bit.

Before:
Did 248 RSA 2048 key-gen operations in 30041496us (8.3 ops/sec)
  min: 31690us, median: 109097us, max: 373911us
Did 71 RSA 3072 key-gen operations in 30096719us (2.4 ops/sec)
  min: 108650us, median: 370844us, max: 1768070us
Did 27 RSA 4096 key-gen operations in 32829007us (0.8 ops/sec)
  min: 205485us, median: 1107051us, max: 4035040us

After:
Did 340 RSA 2048 key-gen operations in 30026342us (11.3 ops/sec)
  min: 24681us, median: 77749us, max: 350477us
Did 67 RSA 3072 key-gen operations in 30089075us (2.2 ops/sec)
  min: 75070us, median: 394220us, max: 1101562us
Did 38 RSA 4096 key-gen operations in 30283788us (1.3 ops/sec)
  min: 284947us, median: 742688us, max: 1970468us

Change-Id: If1b48e9306c3fe1be56c304143e206c3bdb3301d
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38165
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-10-15 18:41:56 +00:00
David Benjamin 18d145e651 Extract and test the deterministic part of Miller-Rabin.
This way we test not only that we match expectations for primes and
composites but that the core test correctly reports false witnesses. I
made an initial attempt to gather some interesting test input, but
probably one can do better.

Change-Id: I7c29afb534bd6980ef42a893e86d86bd44af8349
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38164
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-10-15 18:31:36 +00:00
Adam Langley 5cf3298140 Fix the FIPS + fuzzing build.
Recent changes to the PRNG seeding in FIPS mode broke the build when
trying to build with both FIPS and fuzzing enabled.

Change-Id: I069b4af1fdd4efaef96e3e3b3a1e0197faabe2e1
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38184
Reviewed-by: Matt Braithwaite <mab@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-10-14 21:32:23 +00:00
Adam Langley 2865bce1b2 FIPS.md: document some recent Android changes.
Change-Id: I48cc5fc6211a1a557cfeb1aad5688753bc7b5dfd
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38124
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-10-11 22:34:25 +00:00
David Benjamin bc4c09df64 Add a function to derive an EC key from some input secret.
Chrome sync folks need to do this. Add a function for it. There doesn't
seem to be a standard way to do it, so pick something arbitrary.

Bug: chromium:1010968
Change-Id: Ib55456e4af5849cd9da33f397e8f12deb6f02917
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38144
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-10-11 21:17:19 +00:00
David Benjamin 7458ded264 Fix run_android_tests.go with shared library builds.
In particular, the FIPS builds use shared libraries.

Change-Id: I4ca3a289ad3af8ab24c4bf1aecd5de67f9496f15
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38147
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-10-11 21:16:38 +00:00
David Benjamin 86ee70b6ff No-op change to test new builders.
Change-Id: I3f715b35968168e4e80fb643e28d4169797c0898
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38146
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-10-11 18:44:38 +00:00
Adam Langley c48c8b6f64 Move no-exec-stack sections outside of #ifs.
When building with |OPENSSL_NO_ASM|, the section that marks assembly
files as no-exec-stack will currently be omitted. That results in an
empty assembly file but that's still enough to trigger warnings:

warning: crypto_tests/trampoline-x86_64.o: missing .note.GNU-stack section implies executable stack

This change makes it so that the section marker will always be emitted,
even if the file is otherwise empty.

Change-Id: I2d08d34ed9dbe9e9592c88dcd42d3ba4fa3d7652
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38084
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-10-10 17:27:51 +00:00
Alessandro Ghedini 12049fd3ad Add |SSL_get_min_proto_version| and |SSL_get_max_proto_version|
This makes it possible to fetch the min and max versions configured
directly on SSL objects (as opposed to SSL_CTX ones).

This is useful when configuring supported TLS versions on per-connection
basis.

Change-Id: Ibccc92c5f7668e9a7be5a01d6f84089608382407
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38104
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-10-10 16:56:41 +00:00
Adam Langley 4ca15d5dcb Make FIPS build work for Android cross-compile.
Change-Id: I67db234ad80fa1eb4af4e28ac7b5236dd6ec4b63
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38065
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-10-09 20:16:11 +00:00
Pete Bentley 56b6c714c9 Enable optional GRND_RANDOM flag to be passed to getrandom on Android.
Introduces optional extra flags for getrandom which are ORed in when
reading a FIPS seed.  Setting the Android read-only system property
ro.boringcrypto.hwrand to true will set the extra flags to GRND_RANDOM.

Testing: Built and tested on AOSP as http://r.android.com/1134926
and verified behaviour via the extra printfs in that CL and also
observing the flags passed to getrandom using strace.

Change-Id: Idd782df65ba0d49b8b1357b346caa4ef747587f1
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38024
Reviewed-by: David Benjamin <davidben@google.com>
2019-10-09 19:46:17 +00:00
David Benjamin 8fe1584023 Switch cert_compression_algs to GrowableArray.
It's much less typing than STACK_OF(T).

Change-Id: Idda99549ba35ff8d02fb6e3790f30f6566236076
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38044
Reviewed-by: Dan McArdle <dmcardle@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-10-08 21:41:56 +00:00
Daniel McArdle ff746c103f Add GrowableArray<T> to ssl/internal.h.
Change-Id: I07aced6d2830dd5a2a04c296b1ffe7e8557369fe
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37504
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-10-08 21:23:05 +00:00
Goutam Tamvada 49de1fc291 Fixed quic_method lookup in TLS 1.3 server side handshake.
Commit 3cbb0299a allows for quic_method to be configured
per-connection. However, before this, do_send_new_session_ticket()
in ssl/tls13_server.cc read quic_method from the underlying
SSL context.

Change-Id: I04ea2be23dc8e32b3232b8f59e266bd381e8f3c4
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/38004
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-10-04 22:09:32 +00:00
David Benjamin 9c49713ba8 Add .note.GNU-stack at the source level.
GNU-based toolchains on ELF platforms default the stack to executable
and rely on a .note.GNU-stack section in *each* object file to flip it
off. The compiler knows to do this for its object files, but assembly
does everything by hand. See this link for details:
https://www.airs.com/blog/archives/518

We do this in the cmake build by passing -Wa,--noexecstack to the
assembler. However, since we have to deal with many buildsystems, it
would be more robust to put it in the source.

It's unclear whether this should be gated on ELF or Linux. The Gentoo
and Ubuntu documents recommend checking for Linux with gas, but only ELF
with NASM.
https://wiki.gentoo.org/wiki/Hardened/GNU_stack_quickstart
https://wiki.ubuntu.com/SecurityTeam/Roadmap/ExecutableStacks

At the same time, these links suggest it is an ELF-wide issue and not
just Linux:
https://github.com/golang/go/issues/5392
https://reviews.freebsd.org/D11033

https://github.com/openssl/openssl/issues/4575 also discusses this but
the rationale lists both ELF and non-ELF platforms, so it's unclear.

Treat it as ELF-wide for now. We can revisit this if necessary.

Update-Note: If there is a build failure due to .note.GNU-stack, holler.
Change-Id: Ic59096aa1fc2bf5380a412c9991de22cb46c0faf
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37984
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-10-03 22:10:36 +00:00
Adam Langley 6a2609dae2 -Wno-vla -> -Wvla
Advice from the build folks changed. See b/141974065.

Change-Id: Ib981018ed49ef04d1f87a91b0ef8f7bc4bd524f7
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37964
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-10-03 21:31:43 +00:00
David Benjamin 0e7dbd579b Add an option for explicit renegotiations.
Chromium's renegotiation handling currently relies on reads being the only
thing that can discover a renegotiation. However, for a number of reasons, we
would like to eagerly drive the read loop after a handshake:

- 0-RTT + HTTP/1.1 will otherwise not pick up ServerHellos until after we send
  a request. In particular, if we preconnect a 0-RTT socket sufficiently in
  advance, such that the ServerHello comes in by the time we use it, we should
  send 1-RTT data rather than 0-RTT.

- In TLS 1.2 False Start, if HTTP/1.1 or preconnect, we will not pick up the
  server Finished and NewSessionTicket until later. This way we pick it up
  sooner.

- If the server does not implement
  https://boringssl-review.googlesource.com/c/boringssl/+/34948, this plugs the
  theoretical deadlock on the client end. The False Start and 0-RTT scenarios
  above also have theoretical deadlocks and cannot be mitigated on the server.

- TLS 1.3 client certificate alerts interact badly with TCP reset. Eagerly
  reading from the socket makes it behave slightly better, though it's still
  not reliable unless the server defers closing the socket.

So we can SSL_peek without triggering a renegotiation, add an
ssl_renegotiate_explicit mode to defer processing the renegotiation.

Bug: chromium:950706, chromium:958638
Change-Id: I78242d93d651b7a32a5c4c24ea9032ef63a027cf
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37944
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-10-03 21:12:43 +00:00
Zola Bridges f10ea55e91 tool: add -json flag to |speed|
Add a flag to speed.cc to generate machine-readable benchmark results.

Change-Id: I24a4324c5195b15494dc6d9471aa91c27b9f881d
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37865
Reviewed-by: Adam Langley <alangley@gmail.com>
Reviewed-by: Zola Bridges <zbrid@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-10-02 19:30:10 +00:00
Adam Langley 95017b9bf4 Set -Wno-vla.
Would have avoided 6e7255c17e.

Change-Id: I94eeea70f6ee0b48c1a15b512d652579d65d0edf
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37924
Commit-Queue: Adam Langley <alangley@gmail.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-10-02 19:15:49 +00:00
Pete Bentley 6e7255c17e Use a pointer to module_hash in boringssl_fips_self_test() args.
1) Matches signature in internal.h
2) Works around presubmit build errors in Trusty: b/141974065

Nit: Should probably be const uint8_t *const module_hash
Change-Id: Id16ceea8442f4e8e588f84a8ef45e2320435809b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37904
Commit-Queue: Pete Bentley <prb@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-10-02 13:39:35 +00:00
Adam Langley 9638f8fba9 Use a smaller hex digest in FIPS flag files when SHA-256 used.
1458b49a9e switched to using HMAC-SHA256 for FIPS integrity checks on
Android. However, the flag file was named after a full 64-byte hex
digest. The additional 32 bytes weren't uninitialised, but are still
superfluous. This change gets rid of them.

Change-Id: I192af9eb2b94833cdea3620a153d4fd05c7265b9
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37864
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-10-01 19:18:33 +00:00
Adam Langley 1458b49a9e Switch to using SHA-256 for FIPS integrity check on Android.
SHA-256 is likely to be faster on these devices given that a) some will
be 32-bit and b) some will have SHA-256 instructions.

BUG=141710485

Change-Id: I3a3fbb2b8db4f1a4d3059b39b188aee0e0462dd4
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37845
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-09-30 21:51:37 +00:00
David Benjamin 40633ac196 Use getentropy on macOS 10.12 and later.
Bug: 287
Change-Id: I40760bdba8dcaab9c5c38d52d6479138f52eccbd
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37284
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-09-30 18:30:23 +00:00
Matthew Braithwaite 6f80629b6c Move #include of "internal.h", which defines |OPENSSL_URANDOM|.
Change-Id: Ib8f8f3ae49342478def9233716a49eed1398b355
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37844
Commit-Queue: Matt Braithwaite <mab@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-09-30 18:10:13 +00:00
David Benjamin b9a8fd766e Style nit.
Output parameters should be prefixed with out_.

Change-Id: I7ba9ef6f666301140127fdf5d747cfe3755cf53e
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37788
Reviewed-by: Adam Langley <agl@google.com>
2019-09-30 18:06:10 +00:00
David Benjamin 45610f9afb Assert that BN_CTX_end is actually called.
If a function forgets to BN_CTX_end, everything will work but we'll use
more memory than intended. Catch such errors by asserting in
BN_CTX_free.

Update-Note: BN_CTX is exposed publicly. Some callers may have been
using it wrong and trip this assert. If so, add the missing BN_CTX_end
calls.

Change-Id: I9c38431376a256e5176fd295c0114a10a7f588bd
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37787
Reviewed-by: Adam Langley <agl@google.com>
2019-09-30 18:05:44 +00:00
David Benjamin 6784dc718c Test some known large primes.
Extracted from openssl genrsa.

Change-Id: Ida17de016ce589172cba4a4a030770d208701c9c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37786
Reviewed-by: Adam Langley <agl@google.com>
2019-09-30 18:05:09 +00:00
David Benjamin e7e5a23b4e Test some Euler pseudoprimes.
The Miller-Rabin test is an extension of the Fermat test (in addition to
looking for a^(n-1) != 1, it also looks for a non-trivial square root of
unity). It thus seems prudent to sanity-check we indeed reject Fermat
pseudoprimes. Euler pseudoprimes are a stronger constraint, so test
those.

Change-Id: I959769de2da3f8579403621bcf893e7c9247ca33
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37785
Reviewed-by: Adam Langley <agl@google.com>
2019-09-30 18:03:50 +00:00
David Benjamin 6dfb479755 Be consistent about Miller-Rabin vs Rabin-Miller.
We mostly say Miller-Rabin but sometimes say Rabin-Miller. git log -S
suggests this is mostly my fault for picking the less common order.
Miller-Rabin is also the more common order according to the internet, so
use that.

Change-Id: Id18853469a641af6d1c37d3ec87c3110e01e6b71
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37784
Reviewed-by: Adam Langley <agl@google.com>
2019-09-30 18:03:08 +00:00
Michel Promonet bd522862a0 fix build with armv6 Error: .size expression for _vpaes_decrypt_consts does not evaluate to a constant
Before change cross compiling with https://sourceforge.net/projects/raspberry-pi-cross-compilers/files/Raspberry%20Pi%20GCC%20Cross-Compiler%20Toolchains/GCC%209.1.0/Raspberry%20Pi%201%2C%20Zero/cross-gcc-9.1.0-pi_0-1.tar.gz
 fails
arm-linux-gnueabihf-gcc  -march=armv6 -mfloat-abi=hard -mfpu=vfp -marm -c vpaes-armv7.S -o vpaes-armv7.o
/tmp/cctW8fgE.s: Assembler messages:
/tmp/cctW8fgE.s: Error: .size expression for _vpaes_decrypt_consts does not evaluate to a constant

Bug: 291
Change-Id: Ib2bf608943bbb406b33181a75f1ade2c4bab09ba
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37824
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-09-30 17:20:03 +00:00
David Benjamin 0bb4345bfe Mark ssl_early_data_reason_t values stable.
SSL_get_early_data_reason solely exists for histogramming purposes. To
save everyone a lot of boilerplate, just make the values stable.

Change-Id: I3fd3d294de1a66a8eaea96cd6491495f93b1b117
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37766
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-09-27 20:17:03 +00:00
David Benjamin 0de64a749b Make the dispatch tests opt-in.
The assembly dispatch tests currently assume NDEBUG is consistently
defined between C/C++ and assembly. While this is usually the case for
UNIX, CMake does not pass NDEBUG to NASM. This is giving gRPC some
difficulties in updating BoringSSL, so switch it to an opt-in
-DBORINGSSL_DISPATCH_TEST flag instead.

Update-Note: If you were copying NDEBUG over to assembly files, that's
no longer required (though it's harmless to leave it in). If you want to
run ImplDispatchTest.*, build both C/C++ and assembly with
-DBORINGSSL_DISPATCH_TEST in your debug builds. (Don't enable it in
release builds. It causes assembly to scribble in some globals.)

Change-Id: I9ab3371dc0f0a40b27b44ef93835e007a6346900
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37764
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-09-27 19:02:43 +00:00
David Benjamin 63e96f2a29 Bound the number of API calls in ssl_ctx_api.cc.
By spamming just two bytes, this fuzzer can bounce between
SSL_CTX_use_certificate and SSL_CTX_get0_certificate, which continually
runs d2i_X509 on some certificate.

Doing that nearly 400,000 times is not particularly useful. Bound the
number of API calls. Start with 10,000 and see if the fuzzers are still
unhappy.

Bug: oss-fuzz:17748
Change-Id: I074fa08475fffcb86c02e64dcb9c5c7c69bcda71
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37765
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-09-27 15:52:53 +00:00
Adam Langley 3a3552247e Only attempt to mprotect FIPS module for AArch64.
This need doesn't arise on other Android platforms at the current time.

Change-Id: I38c9b5417ec6717210f5797d86d226ab0d9a4232
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37744
Reviewed-by: Adam Langley <agl@google.com>
2019-09-25 23:18:21 +00:00
David Benjamin 622e46bf27 Opportunistically read entropy from the OS in FIPS mode.
Even if RDRAND works, still mix in /dev/urandom or
getrandom(GRND_NONBLOCK) in the likely case that the entropy pool has
been initialized.

Change-Id: Ia61fc6eb07e90ae725a1781311c0ecc2fdabca87
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37664
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-09-24 17:05:18 +00:00
Matthew Braithwaite 1f1af82f40 Update INSTANTIATE_TEST_SUITE_P calls missing first argument.
This is going to be disallowed, apparently.

Change-Id: I73868e1145f3e4e2438c2a31146ba0767b9f01fe
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37684
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-09-24 16:49:29 +00:00
Pete Bentley 15b4fb2acf Ignore build32 and build64 subdirectories.
Used for Conscrypt local builds:
https://github.com/google/conscrypt/blob/master/BUILDING.md

Change-Id: I7eaa225cdc3c79cb5ac4902d222d408169f7ded0
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37724
Commit-Queue: Pete Bentley <prb@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-09-24 16:10:38 +00:00
Pete Bentley 09a9ec0360 Add page protection logic to BCM self test.
On Android only, assume code is compiled for Execute-only memory, so add
Read permission for the duration of the self test and
then mark the pages Execute-only again.

NB if libcrypto is not compiled for Execute-only memory, then attempting
to change the page permissions to PROT_EXEC at the start of the self
test does not cause it to fail, however changing it to PROT_NONE does.

Bug: 134580074
Test: m && flashall
Test: Manual tests described above.

Change-Id: Ibbf8405a5a9b162ce26532127aaf62c539cd9163
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37644
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-09-23 15:50:35 +00:00
David Benjamin 6e8d5f4a4f Disable unwind tests in FIPS mode.
Delocate currently breaks things.

Bug: 289
Change-Id: Ia8c601b954e2dfda9bb4eccdde12dcd64e8559c7
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37624
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-09-20 00:10:53 +00:00
Adam Langley 398ca1c3d6 Disable RDRAND on AMD family 0x17, models 0x70–0x7f.
Change-Id: I634a3077beedf40816a1f6179ccf92d853979601
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37604
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-09-19 21:40:36 +00:00
Adam Langley bb50783805 Don't allow SGC EKUs for server certificates.
The Server Gated Cryptography EKUs are a left-over from 1990's export
regulations. For historical reaons, the SGC EKUs are accepted as a valid
substitute for a server authentication EKU, but they shouldn't be. This
change makes it so that we ignore them.

Change-Id: Ie184c52f588ae391a95d61c474ee6324bdd8f4f2
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37545
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-09-19 19:56:46 +00:00
Adam Langley 04a89c8435 Add |SSL_CIPHER_get_value| to get the IANA number of a cipher suite.
Change-Id: I1d642e0bf319421d49b48f25803280046a85a176
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37585
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-09-18 21:55:39 +00:00
Shelley Vohr 98e848aa34 Add XOF compilation compatibility flags
This CL adds compatibility flags for XOF digests in service of easing
compatibility between OpenSSL and BoringSSL. See this logic in Node:
https://github.com/nodejs/node/blob/master/src/node_crypto.cc#L4599-L4611

Change-Id: I7f12bed8fb1ea2d9e49dba14ed0c4c819596c70d
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37564
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-09-18 21:38:09 +00:00
David Benjamin 0c4d013916 Replace BIO_printf with ASN1_STRING_print in GENERAL_NAME_print
(Imported from upstream's 8479e9e97354add3c562670db66b5f8151dc3b2e.)

Change-Id: I55843a519b9b361de1b175c09382bbf18d4acfff
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37584
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-09-18 21:26:39 +00:00
David Benjamin a7d9ac2af4 Trigger a build on the ARM mode builder.
Checking that it works right.

Change-Id: If27b127bc3d78dc96d6636ba5b4b3c0316366939
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37527
Reviewed-by: David Benjamin <davidben@google.com>
2019-09-16 21:31:16 +00:00
David Benjamin 053880d3f7 Fix vpaes-armv7.pl in ARM mode.
This file runs against the limit of ARMv7's ADR pseudo-instruction. ADR
expands to an ADD or SUB of the pc register to find an address. That
immediate must fit in ARM's encoding scheme: 8 bits of constant and 4
bits of rotation. This means larger values must be more aligned.

ARM additionally has two encodings, ARM and Thumb mode. Our assembly
files may use either encoding (do we actually need to support this?). In
ARM mode, the distances get large enough to require 16-byte alignment.
Moving constants closer to their use resolves most of this, but common
constants in _vpaes_consts are used by the whole file. Affected ADR
instructions must be placed at 8 mod 16 (the pc register is 8 ahead).
Instructions with this constraint have been commented.

For details on ARM's immediate value encoding scheme, see
https://alisdair.mcdiarmid.org/arm-immediate-value-encoding/

Update-Note: See b/141080375
Change-Id: Iadac36d800bb45901b513055fcc28a3a60f9060c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37524
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-09-16 21:07:01 +00:00
Adam Langley 0142c87a26 Add AES-192-GCM support to EVP_AEAD.
(But don't use it for anything new; interop only.)

Change-Id: I59dfb0d3fd4745b5f8d75aa38f7846431d3348c3
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37444
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-09-16 18:28:31 +00:00
Shelley Vohr 012a444265 Add AES-256 CFB to libdecrepit.
Electron builds Node.js with BoringSSL. They want to match OpenSSL as
much as possible and thus have a patch[1] that adds AES-256 CFB mode.
However, that patch makes libcrypto depend on libdecrepit, which can't
be done in general. This change lands the AES-256 CFB support in
libdecrepit without the libcrypto bit and, in order for BoringSSL to
remain consistent, without advertising support in
EVP_CIPHER_do_all_sorted. This will let Electron reduce the size of
their patch a bit.

[1] https://github.com/electron/electron/blob/master/patches/boringssl/expose_aes-cfb.patch

Change-Id: If628d22a595b354623439c587542e414e43e4045
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37264
Reviewed-by: Adam Langley <agl@google.com>
2019-09-16 18:11:40 +00:00
David Benjamin ec92ec471c Parse explicit EC curves more strictly.
Wycheproof has a series of ECDH tests for whether we reject misspelled
explicit versions of named curves in public keys, including the wrong
cofactor. We pass those tests easily because we reject those in public
keys altogether, consistent with RFC 5480.

However, we do parse explicit curves for private keys, for compatibility
with keys produced by older OpenSSLs with unfortunate defaults. Were
that parser enabled for public keys too, we would trip some of these
Wycheproof tests because we ignore the cofactor.

Tighten the parser up. If the cofactor is not one, ignore the curve.
Also syntax-check the seed, even though we ignore it.

Change-Id: I39936e027a72d2dc5532beb2407575ad8042d4c9
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37484
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-09-16 16:55:31 +00:00
David Benjamin b82f945ebc Use the Go 1.13 standard library ed25519.
Less code to carry around.

Change-Id: Ia5397f992e3cbaf0a868ed51c02154c6f5805205
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37465
Reviewed-by: Adam Langley <agl@google.com>
2019-09-13 22:53:24 +00:00
David Benjamin 68489e6da5 Update build tools.
Change-Id: Ifce1fc2802e3d3badb3f08ae65c2bbf3c9434d07
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37464
Reviewed-by: Adam Langley <agl@google.com>
2019-09-13 22:51:54 +00:00
David Benjamin f4d8b96920 Use ScopedEVP_AEAD_CTX in ImplDispatchTest.AEAD_AES_GCM.
EVP_AEAD_CTX_cleanup is often a no-op now that the data is embedded, but
best to be tidy.

Change-Id: I1ba56e5e36d6e69ae1ba07e40c4a7bda7329fa79
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37430
Reviewed-by: Adam Langley <agl@google.com>
2019-09-13 17:48:50 +00:00
David Benjamin ccaee0a64c Use a mix of bsaes and vpaes for CTR on NEON.
tl;dr: AES is now constant-time on 32-bit ARM with NEON. Combined with
all the past work, we now have constant-time AES and GHASH on ARM and
x86 chips, 32-bit and 64-bit, provided NEON (required by Chrome on
Android, aside from https://crbug.com/341598) or SSSE3 (almost all
Chrome on Windows users) is available!

CTR-like bsaes modes is harder to resolve than CBC decryption. They use
both bulk (ctr128_f) and one-off (block128_f) operations. We currently
use ctr128_f of bsaes and block128_f of aes_nohw (not constant-time),
which hits 22.0 MB/s on my test chip.

Implement a vpaes/bsaes hybrid to get the best of both worlds. The key
is kept in vpaes form and, when the input is large enough, we convert
the key to bsaes on-demand. This retains bsaes performance, but with no
variable-time gaps.

Alternatives considered:

- Convert to bsaes form immediately and only use bsaes. This makes the
  one-off block128_f calls very expensive. One 8-block batch of
  bsaes_ctr32_encrypt_blocks costs as much as 5.76 vpaes_encrypt calls.

- Do the above, but fold the one-off calls into bsaes batches because
  GCM is parallelizable. This is a mess with the current internal
  structure and doesn't apply to, e.g., CCM.

- Drop bsaes in favor of vpaes. However, even with
  vpaes_ctr32_encrypt_blocks, vpaes is 15.5 MB/s. The hybrid is a 40%
  win on an important platform.

- Try to narrow the gap, as we did for x86_64, with a "2x" optimization.
  I attempted this here but the register pressure was tricky. (x86_64
  was already tight and NEON can't address memory in vtbl.) If I ignored
  this (gives wrong answer), the gap was still 20-25%. Perf here is
  slower overall (20 MB/s for old ARM vs 120-140 MB/s for old x86_64),
  so that gap is scarier.

I retained vpaes_ctr32_encrypt_blocks because it's fairly compact (only
84 bytes assembled), though it's less important in the bsaes hybrid.

Cortex-A53 (Raspberry Pi 3 Model B+)
Before:
Did 267000 AES-128-GCM (16 bytes) seal operations in 2004871us (133175.7 ops/sec): 2.1 MB/s
Did 135000 AES-128-GCM (256 bytes) seal operations in 2013825us (67036.6 ops/sec): 17.2 MB/s
Did 31000 AES-128-GCM (1350 bytes) seal operations in 2059039us (15055.6 ops/sec): 20.3 MB/s
Did 5565 AES-128-GCM (8192 bytes) seal operations in 2073607us (2683.7 ops/sec): 22.0 MB/s
Did 2709 AES-128-GCM (16384 bytes) seal operations in 2020264us (1340.9 ops/sec): 22.0 MB/s
Did 209000 AES-256-GCM (16 bytes) seal operations in 2005654us (104205.4 ops/sec): 1.7 MB/s
Did 109000 AES-256-GCM (256 bytes) seal operations in 2011293us (54194.0 ops/sec): 13.9 MB/s
Did 25000 AES-256-GCM (1350 bytes) seal operations in 2082385us (12005.5 ops/sec): 16.2 MB/s
Did 4452 AES-256-GCM (8192 bytes) seal operations in 2080729us (2139.6 ops/sec): 17.5 MB/s
Did 2226 AES-256-GCM (16384 bytes) seal operations in 2079819us (1070.3 ops/sec): 17.5 MB/s

After:
Did 542000 AES-128-GCM (16 bytes) seal operations in 2003408us (270539.0 ops/sec): 4.3 MB/s [+104.8%]
Did 124000 AES-128-GCM (256 bytes) seal operations in 2012579us (61612.5 ops/sec): 15.8 MB/s [-8.1%]
Did 30000 AES-128-GCM (1350 bytes) seal operations in 2020636us (14846.8 ops/sec): 20.0 MB/s [-1.5%]
Did 5502 AES-128-GCM (8192 bytes) seal operations in 2068807us (2659.5 ops/sec): 21.8 MB/s [-0.9%]
Did 2772 AES-128-GCM (16384 bytes) seal operations in 2085176us (1329.4 ops/sec): 21.8 MB/s [-0.9%]
Did 459000 AES-256-GCM (16 bytes) seal operations in 2003587us (229089.1 ops/sec): 3.7 MB/s [+117.6%]
Did 100000 AES-256-GCM (256 bytes) seal operations in 2018311us (49546.4 ops/sec): 12.7 MB/s [-8.6%]
Did 24000 AES-256-GCM (1350 bytes) seal operations in 2026975us (11840.3 ops/sec): 16.0 MB/s [-1.2%]
Did 4410 AES-256-GCM (8192 bytes) seal operations in 2079581us (2120.6 ops/sec): 17.4 MB/s [-0.6%]
Did 2226 AES-256-GCM (16384 bytes) seal operations in 2099318us (1060.3 ops/sec): 17.4 MB/s [-0.6%]

Bug: 256
Change-Id: Ib74ab7e63974d3ddae8ce5fc35c9b44e73dce305
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37429
Reviewed-by: Adam Langley <agl@google.com>
2019-09-13 17:47:18 +00:00
David Benjamin 701d95a2a8 Use vpaes + conversion to setup CBC decrypt on NEON.
Our bsaes CBC decrypt implementation does not need a block128_f, so we
can just convert the key once and move on.

Bug: 256
Change-Id: Ie96571a479c74734a12318c2210066eb7be0971c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37428
Reviewed-by: Adam Langley <agl@google.com>
2019-09-13 17:27:53 +00:00
David Benjamin 7d4b13b445 Add NEON vpaes-to-bsaes key converters.
This was translated from
https://boringssl-review.googlesource.com/c/boringssl/+/33588

vpaes is disappointing on NEON, but we have no constant-time key
schedule functions for bsaes. Implement key conversion functions.

Bug: 256
Change-Id: Icf5fd6a9a948b8fb18f7a0cdd60a1c4d57bb9332
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37427
Reviewed-by: Adam Langley <agl@google.com>
2019-09-13 17:26:14 +00:00
David Benjamin 68fb238645 Add vpaes-armv7.pl and replace non-parallel modes.
This is translated from vpaes-armv8.pl. See top of the new file for
details. Unfortunately, vpaes's performance is disappointing here. The
vpaes paper notes NEON's vector permutation instructions are not very
fast. But this is now constant-time.

Parallel modes, notably CTR derivatives, are performance-sensitive and
worth further work. (They currently use bsaes.) Thus this CL only
replaces non-parallel uses, which currently use a variable-time
table-based implementation.

Note QUIC packet number encryption will do a single one-off AES block
operation per packet and use this file. But the single-block speeds
below should be fine for a per-packet operation.

Alternatives considered: I toyed with BearSSL's 32-bit C bitsliced
implementation, but it appears to be slower than this implementation.

Cortex-A53 (Raspberry Pi 3 Model B+)
Before:
Did 124000 AES-128-CBC-SHA1 (16 bytes) seal operations in 1005644us (123304.1 ops/sec): 2.0 MB/s
Did 45000 AES-128-CBC-SHA1 (256 bytes) seal operations in 1009513us (44575.9 ops/sec): 11.4 MB/s
Did 12000 AES-128-CBC-SHA1 (1350 bytes) seal operations in 1009735us (11884.3 ops/sec): 16.0 MB/s
Did 2266 AES-128-CBC-SHA1 (8192 bytes) seal operations in 1060631us (2136.5 ops/sec): 17.5 MB/s
Did 1078 AES-128-CBC-SHA1 (16384 bytes) seal operations in 1002268us (1075.6 ops/sec): 17.6 MB/s
Did 114000 AES-256-CBC-SHA1 (16 bytes) seal operations in 1004576us (113480.7 ops/sec): 1.8 MB/s
Did 38000 AES-256-CBC-SHA1 (256 bytes) seal operations in 1001777us (37932.6 ops/sec): 9.7 MB/s
Did 9999 AES-256-CBC-SHA1 (1350 bytes) seal operations in 1028518us (9721.8 ops/sec): 13.1 MB/s
Did 1892 AES-256-CBC-SHA1 (8192 bytes) seal operations in 1095702us (1726.7 ops/sec): 14.1 MB/s
Did 902 AES-256-CBC-SHA1 (16384 bytes) seal operations in 1038989us (868.2 ops/sec): 14.2 MB/s
Did 2094000 AES-128 encrypt setup operations in 1000296us (2093380.4 ops/sec)
Did 1505000 AES-128 encrypt operations in 1000596us (1504103.6 ops/sec)
Did 465000 AES-128 decrypt setup operations in 1000354us (464835.4 ops/sec)
Did 1468000 AES-128 decrypt operations in 1000178us (1467738.7 ops/sec)
Did 1751000 AES-256 encrypt setup operations in 1000189us (1750669.1 ops/sec)
Did 1113000 AES-256 encrypt operations in 1000004us (1112995.5 ops/sec)
Did 339000 AES-256 decrypt setup operations in 1002970us (337996.2 ops/sec)
Did 1103000 AES-256 decrypt operations in 1000882us (1102028.0 ops/sec)

After:
Did 119000 AES-128-CBC-SHA1 (16 bytes) seal operations in 1000259us (118969.2 ops/sec): 1.9 MB/s [-5.0%]
Did 39000 AES-128-CBC-SHA1 (256 bytes) seal operations in 1001341us (38947.8 ops/sec): 10.0 MB/s [-12.3%]
Did 10571 AES-128-CBC-SHA1 (1350 bytes) seal operations in 1067614us (9901.5 ops/sec): 13.4 MB/s [-16.3%]
Did 1903 AES-128-CBC-SHA1 (8192 bytes) seal operations in 1090907us (1744.4 ops/sec): 14.3 MB/s [-18.3%]
Did 957 AES-128-CBC-SHA1 (16384 bytes) seal operations in 1093380us (875.3 ops/sec): 14.3 MB/s [-18.8%]
Did 108000 AES-256-CBC-SHA1 (16 bytes) seal operations in 1005090us (107453.1 ops/sec): 1.7 MB/s [-5.6%]
Did 33000 AES-256-CBC-SHA1 (256 bytes) seal operations in 1026530us (32147.1 ops/sec): 8.2 MB/s [-15.5%]
Did 8393 AES-256-CBC-SHA1 (1350 bytes) seal operations in 1064768us (7882.5 ops/sec): 10.6 MB/s [-19.1%]
Did 1496 AES-256-CBC-SHA1 (8192 bytes) seal operations in 1090316us (1372.1 ops/sec): 11.2 MB/s [-20.6%]
Did 737 AES-256-CBC-SHA1 (16384 bytes) seal operations in 1070396us (688.5 ops/sec): 11.3 MB/s [-20.4%]
Did 695000 AES-128 encrypt setup operations in 1000325us (694774.2 ops/sec) [-66.8%]
Did 1043000 AES-128 encrypt operations in 1000568us (1042407.9 ops/sec) [-30.7%]
Did 495000 AES-128 decrypt setup operations in 1000680us (494663.6 ops/sec) [-6.4%]
Did 743000 AES-128 decrypt operations in 1000892us (742337.8 ops/sec) [-49.4%]
Did 550000 AES-256 encrypt setup operations in 1000228us (549874.6 ops/sec) [-68.6%]
Did 786000 AES-256 encrypt operations in 1000978us (785232.0 ops/sec) [-29.4%]
Did 377000 AES-256 decrypt setup operations in 1002252us (376152.9 ops/sec) [-11.3%]
Did 547000 AES-256 decrypt operations in 1000168us (546908.1 ops/sec) [-50.3%]

Bug: 266
Change-Id: Ia5f9c90bcf5e713e40cacc954c604a6ffb432d6c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37426
Reviewed-by: Adam Langley <agl@google.com>
2019-09-13 17:21:58 +00:00
David Benjamin 5588ec7a8b Correct comments for x86_64 _vpaes_encrypt_core_2x.
The prose and the register listing didn't match. (I suspect I wrote the
register listing before I decided which preheat registers to preserve.)

Change-Id: Ib461573ea50fdf5a806266c22805f6ba3470a6ec
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37425
Reviewed-by: Adam Langley <agl@google.com>
2019-09-13 17:14:37 +00:00
David Benjamin 25e36da50f Add benchmarks for AES block operations.
While not the most important operation, it is used in QUIC packet number
encryption.

Change-Id: I13a04e7a24d90c30804bb6020547d6060e1e7e87
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37424
Reviewed-by: Adam Langley <agl@google.com>
2019-09-13 17:13:48 +00:00
Pete Bentley e60b080dda Only write self test flag files if an environment variable is set.
Prevents arbitrary processes linked against libcrypto, which run
before the self test binaries, from triggering SELinux audit logs.

Fails safe. I.e. default is not to write a flag file which in turn
will mean all processes loading libcrypto run a full set of KAT tests
until the variable is set.

Alternative considered:  Use a weak gloabl symbol containing the flag
(defaulting to "don't write") and override in the self test binaries.
However at the very least this would need to be in a separate object
file other than bcm.o to prevent local symbol resolution, so unsure
if that would be acceptable.

Change-Id: I32b20699bdd7ecaff06fc5f79b213d9a9d5f6253
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37404
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-09-12 15:45:49 +00:00
David Benjamin 5ce7022394 Const-correct EC_KEY_set_public_key_affine_coordinates.
Change-Id: I8f4dd4b0164ec93b6134e406017a74e49e805b02
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37384
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-09-10 19:50:06 +00:00
Adam Langley f7b830d8df Revert "Fix VS build when assembler is enabled"
This reverts commit 791f2822b2.

The use of $<COMPILE_LANGUAGE:CXX> causes issues for the Visual Studio
output of CMake[1] and the original CMake bug[2] was fixed in 3.13.0.

[1] https://github.com/grpc/grpc/pull/20100#issuecomment-528817457
[2] https://gitlab.kitware.com/cmake/cmake/merge_requests/2179

Change-Id: I74ec9d258d2c068e0c58d97deda8aa3794d387e5
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37364
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-09-06 16:13:01 +00:00
Alexei Lozovsky 356a9a0895 Support compilation via emscripten
It turns out that emcc does not like "-ggdb" flag. Disable it if we
detect that we're being compiled by Emscripten toolchain (e.g., when
compiling to WebAssembly).

Change-Id: Ic6a11251a79cdb370c1bdce48aec5428b2f2f306
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37344
Reviewed-by: Adam Langley <alangley@gmail.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-09-06 15:10:43 +00:00
David Benjamin d041f11134 Fix cross-compile of Android on Windows.
When running the ARM perlasm files on Windows, close STDOUT fails. There
appears to be some weird quirk on Windows when one replaces STDOUT with
a pipe. The x86_64.pl files all avoid this by opening OUT and then
setting *STDOUT=*OUT. Align all the ARM files with that pattern.

See https://ci.appveyor.com/project/conscrypt/conscrypt

Change-Id: Ibee9427a05d806f7f23a6d9817394cfabf2f534a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37324
Reviewed-by: Kenny Root <kroot@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-09-04 17:20:44 +00:00
David Benjamin 3b62960c5c Move the config->async check into RetryAsync.
Change-Id: Ica2776825a55fe501a7b03cf2dd0ff7ba0338ec9
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37185
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2019-08-28 04:25:55 +00:00
David Benjamin d0b979432e Clear *out in ReadHandshakeData's empty case.
This is test-only code and a no-op, but it's prudent to avoid making
assumptions about the initial state of *out. Hopefully someday later we can
assume std::optional or pull in absl::optional.

Change-Id: I85af87bb2cc3cda3d40801c91e6abe4f5a7d89f8
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37184
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2019-08-28 03:59:21 +00:00
David Benjamin d63435779f Add initial support for 0-RTT with QUIC.
This adapts our existing API for QUIC, although I'm not entirely
convinced the shape of it fits as it does with TCP. Things that needed
to be changed:

- There is a slight ordering issue on the server with HRR and releasing
  the 0-RTT keys to QUIC.

- Remove EndOfEarlyData.

- At the early return point for the server, QUIC needs to have installed
  the client traffic secrets earlier.

- The maximum early data value is a constant in QUIC.

- QUIC never installs early secrets at the TLS level. (In particular,
  this avoids nuisances with do_send_second_client_hello's null cipher
  not updating the encryption level.)

- The read/write secrets for 0-RTT keys were mixed up.

As the QUIC tests are getting a bit unwieldy, I tidied them up a bit.
This CL does *not* handle the QUIC transport parameters or HTTP/3
server SETTINGS frame interactions with 0-RTT. That will be done in a
separate CL.

I suspect if we ever implement DTLS 1.3, we'll find ourselves wanting to
align some of the QUIC bits here with DTLS and perhaps refine the
handshake/transport abstractions a bit.

Bug: 221
Change-Id: I61f701d7241dbc99e5dbf57ae6c283e10b85b049
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37145
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2019-08-27 23:41:41 +00:00
David Benjamin 95dd54e57f Have some more fun with spans.
Change-Id: I309902cb3ef4c772781af71b0cbc1abfefc513f6
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37224
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-08-27 20:44:37 +00:00
Manoj Gupta 1e547722d4 Add OPENSSL_FALLTHROUGH to a few files.
This is a followup of
https://boringssl-review.googlesource.com/c/boringssl/+/37244

There are a few files that needs the OPENSSL_FALLTHROUGH
annotation so that they compile with clang.

Bug: chromium:997709
Test: CQ
Change-Id: I05f9f85fdb39fbcb8c1193a7b0c335287022719d
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37247
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-08-27 01:34:18 +00:00
Adam Langley fbebe833b1 Limit __attribute__ ((fallthrough)) to Clang >= 5.
With Clang 3.5, this fails and breaks gRPC's build:

third_party/boringssl/crypto/bio/fd.c:196:7: error: declaration does not declare anything [-Werror,-Wmissing-declarations]
      OPENSSL_FALLTHROUGH;
      ^~~~~~~~~~~~~~~~~~~
third_party/boringssl/crypto/bio/../internal.h:192:29: note: expanded from macro 'OPENSSL_FALLTHROUGH'

Clang 5, empirically, is happy, so limit this to Clang >= 5.

Change-Id: I82430b415955ec7d664abe3ffe024e6bb28346c2
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37246
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-08-26 21:35:02 +00:00
Adam Langley cf67ec09e4 Make |EVP_CIPHER_CTX_reset| return one.
(It does upstream.)

Change-Id: I0c00e393b32a7ed237abba682b45d81889cf9fa8
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37245
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-08-26 20:30:58 +00:00
Manoj Gupta 05cd93068b Add Fallthru support for clang 10.
clang has gained supoprted for __attribute__ ((fallthrough))
in https://reviews.llvm.org/rL369414.
Detect the support in clang and enable it as OPENSSL_FALLTHROUGH.
This is needed to fix ToT clang builds.

Bug: chromium:997709
Test: CQ
Change-Id: Iefa17687f6b5e8c95f359f167e9049d9a69c5302
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37244
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-08-26 16:48:48 +00:00
Adam Langley a8ffaf1bf2 Add self-test suppression flag file for Android FIPS builds.
FIPS IG 9.11 allows for a shared library to skip running self tests if
they have already run successfully for a given module and environment.
This change has Android FIPS builds read and write a flag file in
/dev/boringssl to implement this. The flag file is named after the hash
of the module to ensure specificity.

Change-Id: I5c4e7b6244831746e61c5f78f703b0b4fb0ddd10
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37204
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-08-23 00:20:22 +00:00
David Benjamin f350351a9a Align 0-RTT and resumption state machines slightly
QUIC is going to make this flow a bit more complicated, so let's simplify it a
bit. The client flight states already know to skip themselves in 1-RTT
resumption, so just run through the same states. Also remove a redundant
early_data_offered check.

(I think we originally skipped the states because we do half-RTT tickets and
the transcript bits were precomputed.)

Bug: 221
Change-Id: I3a62c864458012e74b46f7ef212abc125760c12d
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37144
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-08-22 15:43:08 +00:00
Adam Langley e39d136568 Require getrandom in Android FIPS builds.
In order to make the entropy story a little simplier, drop support for
using /dev/urandom from Android FIPS builds.

Change-Id: I4c35618dcae1550142e60a886a8b51ba0df765a3
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37205
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-08-22 14:57:58 +00:00
Gurleen Grewal 9747a53284 acvp: allow passing custom subprocess I/O.
Change-Id: Ic87cdc84b7684c344af7aa2ef8673264d402c492
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37164
Reviewed-by: Adam Langley <alangley@gmail.com>
2019-08-21 22:13:42 +00:00
David Benjamin bd2a8d689b Add a function to convert SSL_ERROR_* values to strings.
Unexpected SSL_ERROR_* values usually mean the caller didn't handle an
error case for some opt-in feature, but it still would be handy to
stringify them when logging.

Change-Id: If1c44a180b5c124a51ba61410ba02bd637f3429a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37188
Reviewed-by: Adam Langley <agl@google.com>
2019-08-21 21:55:42 +00:00
David Benjamin f492830ed9 Fold SSL_want constants into SSL_get_error constants.
There's no sense in having two of these (with similar but slightly
different numbers, no less!). Fold them together and remove the
redundant SSL_want constants. Almost everything uses SSL_get_error.

Update-Note: Most of the SSL_want constants have been removed, except
SSL_NOTHING, SSL_READING, and SSL_WRITING which are used by external
code.

Change-Id: I75727f7cf6333694767ce8129ee6815fd464c163
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37187
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-08-21 21:54:38 +00:00
David Benjamin e530ea387c Use spans for the various TLS 1.3 secrets.
This undoes a lot of the MakeConstSpans and MakeSpans that were just
added, though it does require a bit of helper machinery. This should
make us much more consistent about which buffer is sized with which size
(even though they are secretly all the same size).

Change-Id: I772ffd2e69141ff20511bcd3add865afa82cf3a0
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37127
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2019-08-20 13:53:08 +00:00
David Benjamin b244e3a5fc Switch another low-level function to spans.
Get this out of the way for the various TLS 1.3 secrets to use spans.

Change-Id: Ia6c3fa4b35ecfad721af665f54bde5ab16baf7ca
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37126
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2019-08-20 13:52:38 +00:00
David Benjamin 79b8b3a419 Switch tls13_enc.cc to spans.
The callers become filled with MakeConstSpans, but the various TLS 1.3
secrets will get fixed in a subsequent CL. We do still need a better
pattern for the EVP_MAX_MD_SIZE buffers.

Change-Id: Ide9c173bf0760ecdb8cc45e63969457c20310de2
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37125
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2019-08-20 13:51:08 +00:00
David Benjamin 9806ae005b Check the second ClientHello's PSK binder on resumption.
We perform all our negotiation based on the first ClientHello (for
consistency with what |select_certificate_cb| observed), which is in the
transcript, so we can ignore most of the second one.

However, we ought to check the second PSK binder. That covers the client
key share, which we do consume. In particular, we'll want to check if it
we ever send half-RTT data on these connections (we do not currently do
this). It is also a tricky computation, so we enforce the peer handled
it correctly.

Tested that both Chrome and Firefox continue to interop with this check,
when configuring uncommon curve preferences that trigger HRR. (Normally
neither browser sees HRRs against BoringSSL servers.)

Update-Note: This does enforce some client behavior that we hadn't been
    enforcing previously. However, it only figures into TLS 1.3 (not many
    implementations yet), and only clients which hit HelloRetryRequest
    (rare), so this should be low risk.
Change-Id: I42126585ec0685d009542094192e674cbd22520d
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37124
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2019-08-19 16:44:43 +00:00
Pete Bentley 44544d9d2d Introduce libcrypto_bcm_sources for Android.
Splits Android sources into two groups allowing different
compilation rules.

Also make output conform to Android blueprint style guide by
remove the final blank line.

AOSP change: http://r.android.com/c/platform/external/boringssl/+/1103191

Test: Built using AOSP change above.
Change-Id: I45ce32c75a524757fe87654b8c77a2195b365c84
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37084
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-08-16 19:28:40 +00:00
David Benjamin 8c98bac1ac Remove stale TODO.
We no longer accept all ticket age skews.

Change-Id: Ie4a143cf5762177d9ec8aa5784073b3e63630df3
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37105
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-08-16 14:30:20 +00:00
David Benjamin eca48e52ed Add an android-cmake option to generate_build_files.py
The Android emulator uses a custom CMake-based build. It's a little
goofy to generate a CMake file list when our standalone build is already
CMake, but our standalone build doesn't use pregenerated files.

(Long-term, I hope we can unify the file lists under sources.cmake and,
to help out Mundane, allow the standalone build to optionally consume
pregenerated files. But for now just making yet another build output is
simplest.)

Bug: b/139120013
Change-Id: Id5b8b4ed83bc21d261663cb8defe9e19b64c639b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37065
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-08-13 18:12:58 +00:00
David Benjamin fd863b6a20 Add a QUIC test for HelloRetryRequest.
There's no reason to believe it doesn't work, but as it's a slightly different
flow (two unencrypted ClientHellos), it makes sense to test it.

Change-Id: Ic230f7720b459c99b9662cbab847d730d772ab2c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37064
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2019-08-13 17:51:28 +00:00
Bob Haarman bc2a2013e0 Add missing ".text" to Windows code for dummy_chacha20_poly1305_asm
This explicitly sets the section for the dummy_chacha20_poly1305_asm
symbol we generate for Windows. Without explicitly setting the
section, NASM would store it as an undefined symbol rather than a
defined symbol, resulting in a broken object file.

Change-Id: If8ff18f714be5e46af59ff869ae93e64e2c6e44b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37024
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-08-09 22:05:17 +00:00
Adam Langley ae223d6138 Update TODO to note that Clang git doesn't have the POWER bug.
Change-Id: Ibe3d43440746b273eb7ddcf7235b132424ca0494
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/37004
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-08-08 21:12:19 +00:00
Adam Langley f5270004a2 Fix paths in break-tests.sh.
60cc4d4b moved several things into a cavp directory so that we didn't
have two directories called fipstools. This script needs to be updated
accordingly.

Change-Id: I91c5b529e16430422447fee024831f1f311f01b5
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36984
Reviewed-by: David Benjamin <davidben@google.com>
2019-08-08 21:12:13 +00:00
Adam Langley ab26b556a4 Fix POWER build with OPENSSL_NO_ASM.
Change-Id: I28892ff6a954fc925329fe8f63af469468f489b7
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36964
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-08-08 21:05:13 +00:00
Adam Langley 67f3ada0c5 Workaround Clang bug on POWER.
Change-Id: I07275700c0d46976fb0d5070554d19d62fb01b1e
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36944
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-08-08 20:41:33 +00:00
Peter Collingbourne 2c880a2047 Add assembly support for -fsanitize=hwaddress tagged globals.
As of LLVM r368102, Clang will set a pointer tag in bits 56-63 of the
address of a global when compiling with -fsanitize=hwaddress. This requires
an adjustment to assembly code that takes the address of such globals: the
code cannot use the regular R_AARCH64_ADR_PREL_PG_HI21 relocation to refer
to the global, since the tag would take the address out of range. Instead,
the code must use the non-checking (_NC) variant of the relocation (the
link-time check is substituted by a runtime check).

This change makes the necessary adjustment in all of the places where it
is needed when compiling with -fsanitize=hwaddress. While here, shrink the
code by an instruction in each of those places by folding the addend into
the load, and remove some dead code that seems to have been left over from
commit 293d9ee4e8.

We check for a sufficiently new clang before using the :pg_hi21_nc: relocation
variant because support for this variant was only added recently.

Change-Id: Ic9da8386e19c03c1e90c103a81232a254277e9a5
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36924
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-08-08 18:03:43 +00:00
David Benjamin 81080a729a Fix typo in valgrind constant-time annotations.
This was causing valgrind to complain its internals were confused.

Change-Id: I1ba064b80666d62bd82bef052c66b927764ea078
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36904
Reviewed-by: Adam Langley <agl@google.com>
2019-08-05 15:24:28 +00:00
Adam Langley 974f4dddfb acvp: add support for AES-ECB and AES-CBC.
Change-Id: I685701304576a519e68a13d22bd557fdbf5a84fb
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36884
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-08-02 17:13:47 +00:00
David Benjamin 303f1a86ac Fix misspelled TODO.
Change-Id: I0168e8cc4b8911576e7d9be72999c96dcc3d2fba
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36864
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-07-31 18:09:55 +00:00
Adam Langley 621c9d45e7 Move CCM fragments out of the FIPS module.
In order to clarify that CCM is not a service offered by the FIPS
module, move the CCM-related fragments of code out of the module to
where they are used in the outer part of libcrypto.

Change-Id: I64f95867a92fb90ea8bb460e2608c998669bb543
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36804
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-07-30 21:06:50 +00:00
David Benjamin 9f6acfc1f2 Add EVP_PKEY_base_id.
OpenSSL has two notions of key type because it supports multiple OIDs
for the same algorithm: NID_rsa vs NID_rsaEncryption and five distinct
spelling of DSA. We do not support these, so the base ID is simply the
ID.

Bug: 280
Change-Id: I966530901405a29a0cc35a2bea67304dda336e8a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36844
Reviewed-by: Adam Langley <alangley@gmail.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-07-30 14:53:40 +00:00
David Benjamin 57de2c357b Add some project links to README.md.
The bug tracker is a little difficult to find.

Bug: 278
Change-Id: Ic031fac1fab2d1718ea640c04523cf80ae7dc2e5
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36824
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-07-29 20:33:13 +00:00
David Benjamin ee4888c5ec Make alert_dispatch into a bool.
Due to padding and slightly silly field ordering, I think this actually ends up
a no-op memory-wise, but may amount to win with cleverer reordering or as
fields change.

Change-Id: I14e38d747a90112cf06c741aec148b77cc5902fb
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36791
Reviewed-by: Adam Langley <agl@google.com>
2019-07-23 20:19:25 +00:00
David Benjamin bc42402f31 Trim some more per-connection memory.
EVP_MAX_MD_SIZE is sized for the largest hash function supported, SHA-512, but
TLS never uses anything larger than SHA-384, which is plenty large enough. This
shaves 16 * 3 = 48 bytes of per-connection overhead plus an addition 16 * 7 =
112 bytes of per-handshake overhead. (Per-handshake structures are discarded
when the handshake completes, so this matters less.)

Change-Id: Iabe15d25fc9182ffcdde876facbe4d80c8143197
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36790
Reviewed-by: Adam Langley <agl@google.com>
2019-07-23 20:18:33 +00:00
David Benjamin 94b2871bc5 Remove SSL_export_early_keying_material.
We did not end up needing this feature. Removing it trims 64 bytes of
per-connection memory.

Change-Id: Ifb8e66af2d583b6bf00c63f509eda8e8691d452a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36789
Reviewed-by: Adam Langley <agl@google.com>
2019-07-23 20:17:40 +00:00
David Benjamin 2c65707928 Add EVP_PKEY support for X25519.
cryptography.io expects X25519 support to be exposed via EVP_PKEY. Also we're
considering using EVP_PKEY to pass in keys for ESNI. This unfortunately
requires adding some odd EVP_PKEY_set1_tls_encodedpoint and
EVP_PKEY_get1_tls_encodedpoint APIs which cryptography.io uses for X25519
because the EVP_PKEY "raw" functions did not exist at the time.

To test, implement EVP_PKEY_derive support in evp_tests.txt.

Change-Id: Ie0666bb9aba13eecf203156dc047ac49ef6d0093
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36788
Reviewed-by: Adam Langley <agl@google.com>
2019-07-23 20:15:48 +00:00
David Benjamin a866ba5d70 Make EVP_PKEY_bits return 253 for Ed25519.
OpenSSL returns 253, not 256, for both X25519 and Ed25519.
https://crypto.stackexchange.com/questions/62024/x25519-why-openssl-shows-253-bits

Change-Id: Ia1289ed3abaecf79a178476a61af724ac351671d
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36787
Reviewed-by: Adam Langley <agl@google.com>
2019-07-23 20:04:46 +00:00
David Benjamin ef0183c537 Make SSL_get_servername work in the early callback.
This avoids early callback users writing their own SNI parser and gives us a
place to surface the server name from ESNI in the future.

Update-Note: This isn't a breaking change, but users of
SSL_CTX_set_select_certificate_cb can likely drop a bit of code after this CL.

Bug: 275
Change-Id: I9685ae5cca8e0483de76229d12dac45ff8e9ec32
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36784
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-07-20 14:13:05 +00:00
David Benjamin 4dfd5af701 Only bypass the signature verification itself in fuzzer mode.
Keep the setup_ctx logic, which, among other things, checks if the
signature algorithm is valid. This cuts down on some unnecessary
fuzzer-mode suppressions.

Change-Id: I644f75630791c9741a1b372e5f83ae7ff9f01c2f
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36766
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-07-19 23:31:14 +00:00
Adam Langley 9f5c419b9f Move the PQ-experiment signal to SSL_CTX.
In the case where I need it, it's easier for it to be on the context
rather than on each connection.

Change-Id: I5da2929ae6825d6b3151ccabb813cb8ad16416a1
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36746
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-07-19 23:11:44 +00:00
David Benjamin b9e2b8adcd Name cipher suite tests in runner by IETF names.
The names of those tests don't actually matter to the shim because we
don't pass them in anywhere. Note hasComponent() is also used by the
signature algorithm tests, so that also needs to use underscores as a
result.

Change-Id: I393df4c6ffebcc66a55f256df5a641ad87e66441
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36765
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-07-19 22:53:04 +00:00
David Benjamin 66e106026a Align TLS 1.3 cipher suite names with OpenSSL.
There are two naming conventions for TLS cipher suites, the standard
IETF names (SSL_CIPHER_standard_name) and the ad-hoc OpenSSL names
(SSL_CIPHER_get_name). When we added TLS 1.3, we had to come up with
OpenSSL-style names for the cipher suites.

OpenSSL-style names use hyphens rather than underscores (and omit
underscores in odd places), so the natural name for
TLS_AES_128_GCM_SHA256 would have been "AES128-GCM-SHA256". However,
that name is already taken by TLS_RSA_WITH_AES_128_GCM_SHA256 because
OpenSSL's naming convention treats the legacy RSA key exchange as
default. Instead, we used an "AEAD-" prefix to indicate the ciphers only
specified the AEAD.

Since then, OpenSSL has implemented TLS 1.3. Instead, they simply made
the OpenSSL-style name match the standard name starting TLS 1.3,
underscores and all. (This is why openssl s_client will return very
different-looking cipher names in TLS 1.2 and TLS 1.3.)

Align with OpenSSL and do the same.

Update-Note: SSL_CIPHER_get_name will return different values for TLS
1.3 ciphers than before. Note that we did not allow TLS 1.3 ciphers to
be configured at all, so no cipher suite configurations will need to
change, but code logging or asserting on the result of a TLS connection
may observe differences.

It is also recommended that consumers replace uses of
SSL_CIPHER_get_name with SSL_CIPHER_standard_name which gives a much
more consistent naming convention. (BoringSSL supports both standard and
OpenSSL names in the cipher suite configuration, so there's no need to
use OpenSSL names at all.)

Change-Id: I40b1de0689dd7b32af88602acc063934f2877999
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36764
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-07-19 21:34:34 +00:00
Adam Langley 07432f325d Prefix all the SIKE symbols.
I should have noticed this previously, but the SIKE code was exporting
symbols called generic things like “params”. They're not dynamically
exported, but BoringSSL is often statically linked so better to ensure
that these things are prefixed to avoid the risk of collisions.

Change-Id: I3a942dbc8f4eab703d5f1d6898f67513fd7b578c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36745
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-07-19 18:15:13 +00:00
Adam Langley 1a3178cf02 Rename SIKE's params.c.
We already have crypto/dh/params.c and some of our downstream consumers
cannot take two source files with the same name in the same build
target.

Change-Id: I324ace094c2215b443e98fc9ae69876ea1929efa
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36744
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-07-19 17:35:23 +00:00
Adam Langley a86c69888b Add post-quantum experiment signal extension.
When testing HRSS-SXY and SIKE, we also want a control group. However,
how are clients to indicate that they're part of the 1/3 of the
experiment population that's not advertising CECPQ? And how are servers
to indicate that they would have negotiated CECPQ2 / 2b if only the
client had asked?

This change adds a temporary signaling extension to solve these issues.

Change-Id: Ic087a09149ef10141568b734396981ae97950a9b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36725
Reviewed-by: David Benjamin <davidben@google.com>
2019-07-18 23:39:56 +00:00
Adam Langley 0fc4979ddc Fix shim error message endings.
A few fprintfs were missing newlines at the end of the message. A few
more were missing periods. This change makes them all consistent.

Change-Id: Ib275a9543414f34a7bee5bb9ec3cba37c9ec3cf8
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36724
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-07-17 00:46:14 +00:00
Adam Langley b7f0c1b4d3 Add initial draft of ACVP tool.
ACVP will be the replacement for CAVP. CAVP is the FIPS 140 test-vector
program. This commit contains some very rough support for ACVP.
Currently it only supports hash functions and it's not hard to hit
corner cases, but it's enough of a framework to work from.

Change-Id: Ifcde18ac560710e252220282acd66d08e7507262
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36644
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-07-16 23:47:44 +00:00
Kris Kwiatkowski 3c8ae0fd3e Implements SIKE/p434
* CECPQ2b will use SIKE/p434 instead of SIKE/p503
* KEM uses SHA256 instead of HMAC-256
* implements new starting curve: y^2=x^3 + 6x^2 + x
* adds optimized implementation for aarch64
* adds optimized implementation for AMD64
  which do not support MULX/ADOX/ADCX
* syncs the SIKE test code with the NIST Round 2
  specification.
* removes references to field size from variables
  names, tests and defines.

Change-Id: I5359c6c62ad342354c6d337f7ee525158586ec93
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36704
Reviewed-by: Adam Langley <agl@google.com>
2019-07-16 22:30:03 +00:00
Adam Langley 09050cb498 Add SipHash-2-4.
The added code is a one-shot function. A handful of instructions could
be saved by having a context object for repeated use of the same key,
but perhaps it's not needed.

Selected the 2-4 variant to implement because it seems to be
overwhelmingly the most commonly used.

Change-Id: I1e4f699f7dd5a2d35e12245fa116bafbd3439979
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36664
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-07-10 21:14:32 +00:00
Yun Liu 365b7a0fcb Remove android_tools checkout
Remove it when recipe change https://chromium-review.googlesource.com/c/chromium/tools/build/+/1685789
checked in and works as expected.

Bug: chromium:428426
Change-Id: I649ba7f4bd003101c71d07faad2a0d1e957cb97e
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36626
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-07-09 14:38:19 +00:00
Adam Langley 0086bd65c4 Support key wrap with padding in CAVP.
Change-Id: I27a282ee2b11083a1137990b00a9d599dd1f48df
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36625
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-07-08 23:16:09 +00:00
Yun Liu 3f98fde5ad Add android_sdk checkout
Bug: chromium:428426
Change-Id: I12c2969fe8b37a604b14300433f3e3f09aeb24e6
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36584
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-07-08 21:35:59 +00:00
Adam Langley 60cc4d4b4e Move fipstools/ to util/fipstools/cavp
We have two “fipstools” directories, which is silly. Unify them into one
by moving CAVP stuff into a subdirectory of util/fipstools.

Change-Id: Ibeaa2205c58699f3d042445bfa6a6576a762da6f
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36624
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-07-08 18:45:34 +00:00
Steven Valdez d6f9c359d2 Factor out TLS cipher selection to ssl_choose_tls_cipher.
This is factored out since ESNI will need to do its own cipher selection.

Bug: 275
Change-Id: Id87fd91272fbcd9098b3f2a9caa78a2129b154b5
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36544
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-06-27 18:01:55 +00:00
Adam Langley cfcb0060e8 Emit empty signerInfos in PKCS#7 bundles.
This is our bug that we've had since the beginning of PKCS#7 writing
support in eeb9f491: the empty signerInfos SET wasn't emitted. Some
parsers, including OpenSSL, don't like this but it appears to have taken
five years for anyone to notice.

This change does not make parsing strict so that we continue to parse
old messages that we may have produced.

(As ever, PKCS#* should not be used expect where absolutely required for
interoperability.)

Bug: b:135982177

Change-Id: Ia7241de69f105657bdfb5ff75e909deae71748a0
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36564
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-06-25 18:48:43 +00:00
Nick Harper 7198a23368 Clarify language about default SSL_CTX session ticket key behavior.
Change-Id: I8017a99ed99562b48a44d09da6a9338f1de9078f
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36524
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-06-24 23:15:00 +00:00
Watson Ladd 629f321ffd Add an API to record use of delegated credential
Change-Id: Ie964dee5ff9f8c6d43208dd1d3947d9b427ea27d
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36424
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-06-21 21:34:45 +00:00
David Benjamin d59682c427 Fix runner tests with Go 1.13.
Go 1.13 will add Ed25519 support to the standard library. Switch the
order of our vendored Ed25519 bits so we do not get mixed up by this.
When Go 1.13 is released, we can then unwind all this in favor of the
standard library version.

Update-Note: See b/135634259
Change-Id: Iddc0ea58db5b2181cecacfcdd3cc058159271787
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36504
Reviewed-by: Adam Langley <agl@google.com>
2019-06-20 15:24:02 +00:00
David Benjamin 92b7c89e6e Add a value barrier to constant-time selects.
Clang recognizes the (mask & a) | (~mask & b) pattern as a select. While
it often optimizes this into a cmov, it sometimes inserts branches
instead, particularly when it detects a string of cmovs with the same
condition.

In the long term, we need language-level support for expressing our
constraints. In the short term, introduce value barriers to prevent the
compiler from reasoning about our bit tricks. Thanks to Chandler Carruth
for suggesting this pattern. It should be reasonably robust, short of
value-based PGO or the compiler learning to reason about empty inline
assembly blocks.

Apply barriers to our various constant-time selects. We should invest
more in the valgrind-based tooling to figure out if there are other
instances.

Change-Id: Icc24ce36a61f7fec021a762c27197b9c5bd28c5d
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36484
Reviewed-by: Chandler Carruth <chandlerc@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-06-19 17:19:13 +00:00
David Benjamin 12d9ed670d Avoid leaking intermediate states in point doubling special case.
Point addition formulas for short Weierstrass curves are often
incomplete and do not work for P + P. EC implementations usually rely on
constant-time operations never hitting this case, or at least it being
rare[0].

However, the condition checks several values. Our C functions use && and
||, and the P-256 assembly also branches. This can leak intermediate
values via a small side channel. Thanks to David Schrammel and Samuel
Weiser for reporting this.

nistz256 base point multiplication (keygen, ECDSA signing) is unaffected
due to ecp_nistz256_point_add_affine lacking a doubling case. nistp224
and nistp256 base point multiplication, on some compilers, are saved by
quirks of the "mixed" path. The generic code's base point multiplication
and all methods' arbitrary point multiplication (ECDH; ephemeral keys
makes this less interesting) are affected.

Fix the branches in the nistz256 assembly, and use bit operations in C.
Note the C versions are all different because P-224 believes true is 1,
P-256 believes true is any non-zero value, and the generic code believes
true is 0xf...f. This should be double-checked when reviewing.

Aside: The nistz256 assembly also special-cases nontrivial P + (-P) in
arbitrary point multiplication. Fortunately, the formulas in util.c hold
there and I believe one can show P + (-P) is unreachable for all curves.
Still, it would be nice to omit the branch if we can verify the assembly
works anyway.

[0] https://github.com/openssl/openssl/blob/03da376ff7504c63a1d00d57cf41bd7b7e93ff65/crypto/ec/ecp_nistp521.c#L1259

Change-Id: I8958624cd6b5272e5076c6c1605ab089e85f4cb7
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36465
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-06-19 17:19:04 +00:00
David Benjamin cef9d3f38d Split p224-64.c multiplication functions in three.
See I9c20b660ce4b58dc633588cfd5b2e97a40203ec3 for motivation. This aligns with
the other curves. In doing so, I removed the constant-time table lookups from
mul_public because it was easy, which gave a small performance improvement. I
did not further use ec_compute_wNAF, on the assumption that we do not care
enough about P-224 ECDSA performance to bother.

Before:
Did 63756 ECDSA P-224 verify operations in 5032477us (12668.9 ops/sec)
After:
Did 71914 ECDSA P-224 verify operations in 5042356us (14262.0 ops/sec) [+12.5%]

Change-Id: Ifd20293aca09e578c85d4692294caffc1b287909
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36464
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-06-14 22:00:47 +00:00
Adam Langley 8f574c37da Add AES-KWP
KWP is Key Wrap with Padding, defined in RFC 5649 and SP 800-38F. Like
Key Wrap, it's a poor-man's AEAD and shouldn't be used. However, some
existing systems use it and we need to interoperate.

The interface of the added functions is a little unfortunate, but they
match the interfaces of the existing Key Wrap functions which, in turn,
match functions in OpenSSL. Hopefully this way, if OpenSSL ever add
support, we'll line up.

Change-Id: I3496c288f32230a891261586ca2e9c4ee8456c09
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36324
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-06-13 22:43:59 +00:00
David Benjamin 18254e25a6 Discuss the doubling case in windowed Booth representation.
Using signed digits for point multiplication halves the size of the table,
which is a valuable optimization. However, it is dependent on the curve whether
the doubling case in point addition is reachable. Assuming my reasoning is
valid, the condition for the standard table strategy is:

  The non-trivial doubling case in single-point scalar multiplication may occur
  if and only if the 2^(w-1) bit of the group order is zero.

It would be nice to transcribe this to Coq someday but, for now, check in a
proof in prose. The condition also does not apply to EC_GFp_nistz256_method's
multi-level tables.

This file is now 91% comments by line count.

Change-Id: I29b394289793db957f99e80734e10ed59a96fcec
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36364
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-06-13 22:24:59 +00:00
David Benjamin 72791efa1b Update build tools.
Change-Id: I13238f2eac61dff052ce52083c20f717f212c98e
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36445
Reviewed-by: Adam Langley <agl@google.com>
2019-06-13 16:11:26 +00:00
David Benjamin 4745051fb0 Set a minimum CMake version of 3.0.
CMake 3.0 was released June 10, 2014, just over five years ago. Set the minimum
version to 3.0. This cleans up some Mac workarounds. (CMP0025 was introduced
in 3.0, so setting the minimum version to 3.0 also enables it.)

CMP0025 is important because Clang and Apple Clang use different version
numbers. Prior to CMake 3.0, both read as Clang. Starting CMake 3.0, with
CMP0025 enabled, they read as Clang and AppleClang. Without this, we cannot
sanely version-check clang.

Unfortunately, CMP0025 applies at compiler detection, so if BoringSSL is
imported as a CMake subproject, we are dependent on the root project setting
CMP0025. But if we successfully set a minumum of 3.0, we can reasonably ask
consumers to do the same, which will do so.

Next up: In December, we can raise the version to CMake 3.1, which adds support
for specifying C and C++ language versions in CMake. (Alternatively, Abseil's
minimum version is actually 3.5, so maybe we can update more aggressively
here.)

Update-Note: CMake 2.8 is no longer supported. Update your CMake to the latest
    version if it has not been updated in five years.

Change-Id: I3378567ad7575fc9fac69e05c403d69ea10332e2
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36444
Reviewed-by: Adam Langley <agl@google.com>
2019-06-13 16:11:02 +00:00
Kris Kwiatkowski 5b89336b4c Replace addc64,subc64,mul64 in SIKE Go code with functions from math/bits
* math/bits in Go 1.12 offers Add64,Sub64 and Mul64 which can replace
  handwritten functions in SIKE Go

Change-Id: Ie92aa2b2b5183e3588a4ab02fb9b3ea111fa8a33
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36384
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-06-13 00:34:46 +00:00
Adam Langley c0b4c72b6d Eliminate some superfluous conditions in SIKE Go code.
Change-Id: I6baae6b705c42bc08bfe09e17e0316b1e2fa563d
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36345
Reviewed-by: David Benjamin <davidben@google.com>
2019-06-05 18:24:22 +00:00
Adam Langley 567e463cec Fix various typos.
(Automated tooling flagged these.)

Change-Id: I1c0993efb85111bd4a4f1ea51dfe01a6cdd3edd3
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36344
Reviewed-by: David Benjamin <davidben@google.com>
2019-06-05 18:24:12 +00:00
Julien Desgats 20d43e2fa5 Fix name clash in test structures
Revealed by -lfto linking. Creating multiple classes with the same name
but different contents is illegal.

Change-Id: I184c34235f4f11e94d47dee1ca2d1a97de55d6ba
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36304
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-06-04 13:40:07 +00:00
Adam Langley 95147ea89f bcm: don't forget to cleanup HMAC_CTX.
(HMAC_CTXs have interior allocations.)

Change-Id: Ic0e67cf9c52db43e895088e602079c510bb8432a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36284
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-06-03 18:36:19 +00:00
Adam Langley c37e64cba5 Handle fips_shared_support.c getting built in other builds.
Other build systems will just take a list of the files, including
fips_shared_support.c, so better to make it a no-op in the
non-shared+FIPS case.

Also add it to the other cases so that the CMake build better matches
other builds in that respect.

Change-Id: I1bea4f6b8266da32340a5fc0fed5fc3680f3b18f
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36264
Reviewed-by: Adam Langley <agl@google.com>
2019-05-30 23:41:34 +00:00
David Benjamin 326f12135b Fix various mistakes in ec_GFp_nistp_recode_scalar_bits comment.
Change-Id: I9b94e2da1bdf83a51b3dc219c154c5706e493e85
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36244
Reviewed-by: Adam Langley <agl@google.com>
2019-05-30 20:57:16 +00:00
David Benjamin 4ef217a1e5 Fix filename in comment.
util-64.c was renamed.

Change-Id: I825b1ebe3e3f428e883ed72b51d50c6bf6ab69f7
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36226
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-05-30 20:57:07 +00:00
David Benjamin 0ad091adcd Split EC_METHOD.mul into two operations.
See I9c20b660ce4b58dc633588cfd5b2e97a40203ec3. Aside for p224-64.c, we'd
already split mul_public into a dedicated function, at which point it's
simpler to just have three functions.

This makes it clearer when we do and don't care about the doubling case
coming up and avoids a bunch of NULL checks.

Change-Id: I7c5dafa7f12f4f53937d912ba22c90cb5a786f04
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36225
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-05-30 20:55:46 +00:00
David Benjamin 6c428307d1 Split ec_point_mul_scalar into two operations.
While it appears that we internally support constant-time
dual multiplication, it is not actually constant-time. Integrating the
two operations means we hit the doubling branch. Instead, replace the
constant-time functions with single multiplication functions, one for
arbitrary points and one for the base point. This simplifies timing
analysis of the EC_METHODs.

This CL only changes the wrapper functions. A subsequent CL will change
the EC_METHOD hooks. We conservatively assume EC_POINT_mul callers
expect secret scalars and split it into two multiplications and an
addition if needed.

Update-Note: EC_POINT_mul may get slower if called with both g_scalar
and p_scalar non-NULL. If the scalars were secret, this plugs a timing
leak (note neither ECDH nor ECDSA signing use such an operation). If
acting on public scalars, notably ECDSA verify, this slowdown is not
inherently necessary. If necessary, we can expose a public version of
ec_point_mul_scalar_public, but callers should be using BoringSSL's
ECDSA verify API instead.

Change-Id: I9c20b660ce4b58dc633588cfd5b2e97a40203ec3
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36224
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-05-30 20:44:46 +00:00
Adam Langley d72e47fddb Add FIPS shared mode.
This change adds a FIPS integrity check using shared libraries. Unlike
with the static case, a shared build can take advantage of the linker
resolving relocations and thus doesn't need delocation. It does mean
that both .text and .rodata sections need to be handled, however, so the
hashing format is slightly different. inject-hash.go is updated to be
able to rewrite shared libraries to inject the correct hash value.

Change-Id: I9a71910cd6df3a85e4efac896b0913e65b5f875b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36024
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-05-30 19:03:16 +00:00
Adam Langley 9b896cf148 delocate: add test for .file handling.
This is to test that detection of the “md5” tag is correct (although
Clang itself emits inconsist .file directives at the moment) and that
the added .file directive has the correct file number.

Change-Id: I89b48fe16fe142165fb5653cae45c39960578735
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36204
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-05-29 18:43:42 +00:00
Adam Langley 09400e197e delocate: translate uleb128 and sleb128 directives
These directives contain labels that need to be mapped by delocate. This
starts to bite with DWARF5. Also, auto-detect whether the compiler is
emitting file directives with MD5 checksums and match that for the dummy
entry.

Change-Id: Ia6f3803287354bc77042a5629cf7e94ceb11b9f9
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36184
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-05-28 22:12:47 +00:00
Kris Kwiatkowski 78c88c999e Integrate SIKE with TLS key exchange.
Implements support for hybrid key exchange based on SIKEp503, a post
quantum, isogeny based KEM. This is a hybrid construction mixed with
X25519 key agreement. Code point is 0xFE32. Cloudflare's SIDH
implementation is used for testing. Key exchange can be used with TLS1.3
only.

Change-Id: I3a5f38d6f7d016274e5bcfb629249664e1d983eb
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35264
Reviewed-by: Adam Langley <alangley@gmail.com>
2019-05-24 16:52:33 +00:00
David Benjamin 6676b9ad1a Convert ecdsa_p224_key.pem to PKCS#8.
That file was added later, so it wasn't covered by
https://boringssl-review.googlesource.com/9020. Other stacks find PKCS#8 easier
to parse and it's all the same to us.

Change-Id: I56d721a3f33209944cd939552f610041344bbbcd
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36164
Reviewed-by: Adam Langley <agl@google.com>
2019-05-24 15:11:41 +00:00
Adam Langley 2e0d354690 Disable RDRAND on AMD chips before Zen.
There are reports that RDRAND on these chips can fail. Thus this change
disables the use RDRAND. Outside of FIPS mode, RDRAND is only used for
protection against forks and VM clones anyway.

(Note: I don't have any AMD chips to test on, so this is done blindly
from AMD's docs.)

Change-Id: Id61b2f6ba74c5ecf66804f7268a26e480a5bf815
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36144
Commit-Queue: Adam Langley <alangley@gmail.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-05-23 20:28:14 +00:00
Steven Valdez 5274cea404 Always store early data tickets.
This stores early data tickets regardless of whether early data is enabled in
the initial handshake, and provides an API to query whether early data would be
performed to allow for comparison between early data enabled and disabled
resumptions.

Change-Id: Id3ef62e36b5be48f6a39fcd7c67d332b7d495141
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35964
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-05-23 16:11:44 +00:00
David Benjamin 35a5a9e7be Align PKCS12_parse closer to OpenSSL.
OpenSSL uses the private key to find the leaf certificate. cryptography.io's
tests rely on this.

Update-Note: PKCS12_parse's behavior changes slightly. Affected callers are
recommended to switch to PKCS12_get_key_and_certs, which has much more
predictable behavior and has no pressures from 3rd-party software to match
OpenSSL's quirks.

Change-Id: I4ee2befbd56a0882ee166f00e748f2fe58ac6a86
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36125
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-05-21 17:08:43 +00:00
David Benjamin ff62b38b4b Support PKCS#12 KeyBags.
Unencrypted keys go in KeyBags instead of ShroudedKeyBags. OpenSSL generates
these when passed -keypbe NONE. Some of cryptography.io's tests use these.
Also, this is an absurd format.

Change-Id: I707a528118728eb898e923748caf52e7b936725d
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36106
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-05-20 22:48:26 +00:00
David Benjamin 302a4dee6c Support PKCS#8 blobs using PBES2 with HMAC-SHA256.
OpenSSL now defaults to HMAC-SHA256 instead of HMAC-SHA1. Support these.

This is needed for some of cryptography.io's tests to pass. For now, this does
not add support for creating such things or change the default, but I've added
a TODO marking the place where OpenSSL sticks the parameter in its API.

Change-Id: I29de2ee4fdcfa2363f94189f75930f55d5d0cf67
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36124
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-05-20 22:47:26 +00:00
David Benjamin b86baef384 Make EVP_PKEY_keygen work for Ed25519.
For cryptography.io.

Change-Id: I90d0a7526cd1283126400568a4596444457136ca
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36105
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-05-20 20:52:11 +00:00
David Benjamin d84cb4d163 Sync aesp8-ppc.pl with upstream.
This pulls in the following commits from upstream:
5dcfd6c50a216f81bf43e1f21bc5f3fc517ba47a,
41013cd63c068e2f271fabc92702ee67d800f0cb,
83cf7abf8e9abbd4d0b68c63dc1cb43374aafe63, and
13f6857db107b1b6f68daa7fc4a6dd1293428bb1. Of these, the first fixes a bug:

commit 5dcfd6c50a216f81bf43e1f21bc5f3fc517ba47a
Author: Daniel Axtens <dja@axtens.net>
Date:   Mon Mar 18 10:22:44 2019 +1100

    PPC assembly pack: fix copy-paste error in CTR mode

    There are two copy-paste errors in handling CTR mode. When dealing
    with a 2 or 3 block tail, the code branches to the CBC decryption exit
    path, rather than to the CTR exit path.

    This can lead to data corruption: in the Linux kernel we have a copy
    of this file, and the bug leads to corruption of the IV, which leads
    to data corruption when we call the encryption function again later to
    encrypt subsequent blocks.

    Originally reported to the Linux kernel by Ondrej Mosnáček <omosnacek@gmail.com>

This bug does not appear to have practical impact the way the function is used
in BoringSSL/OpenSSL. Unlike the CBC functions, the CTR32 functions do not
update the IV, which is the only difference between their epilogs. However, all
the callers either use a temporary buffer for the IV or clobber the counter
portion of the IV with an updated value anyway. (Confirmed that
CipherTest.TestVectors hits this case with AES-GCM and that the clobbered IV
matches in all but the counter portion.)

Change-Id: I25b781152c578155e0bcb0ee1c6d967e9e8cea88
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36104
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-05-20 19:36:11 +00:00
Adam Langley e0c533aa23 Update generate_build_files.py for SIKE.
Change-Id: Ifb0e83288a0923704b102d70353a3b3a51e5830b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36084
Reviewed-by: Adam Langley <agl@google.com>
2019-05-20 18:16:13 +00:00
David Benjamin 79ab5e8faa Fix the last casts in third_party/sike.
These even trip UBSan because they break alignment requirements. The
crypto_word_t isn't doing anything here, so just read bytes.

Change-Id: Icb6dfce2c3a10f8252bbb0889cbeedcf1e8d8e62
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36066
Reviewed-by: Adam Langley <alangley@gmail.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-05-17 13:51:48 +00:00
David Benjamin b4b41cad0a Remove no-op casts around tt1.
I believe this is defined, but it's also unnecessary.

Change-Id: I01313ece2134bd7afecb6c8539d35b5b06c6777a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36065
Reviewed-by: Adam Langley <alangley@gmail.com>
2019-05-17 00:21:36 +00:00
David Benjamin c93e525df1 Define p503 with crypto_word_t, not uint64_t.
Most of the crypto_word_t* casts in third_party/sike are due to p503
being defined with uint64_t. This is a strict aliasing violation and
easily avoided with a TOBN-like macro when defining p503.

This clears almost all of the casts. Also remove an unused stdbool.h
include.

Change-Id: Ife3a4ec620f8b7f4e09c87c6fc43d8b82396046b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36064
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <alangley@gmail.com>
2019-05-16 23:27:15 +00:00
Kris Kwiatkowski 7922e5abcc Add support for SIKE/p503 post-quantum KEM
Based on Microsoft's implementation available on github:
Source: https://github.com/Microsoft/PQCrypto-SIDH
Commit: 77044b76181eb61c744ac8eb7ddc7a8fe72f6919

Following changes has been applied

* In intel assembly, use MOV instead of MOVQ:
  Intel instruction reference in the Intel Software Developer's Manual
  volume 2A, the MOVQ has 4 forms. None of them mentions moving
  literal to GPR, hence "movq $rax, 0x0" is wrong. Instead, on 64bit
  system, MOV can be used.

* Some variables were wrongly zero-initialized (as per C99 spec).

* Rewrite x86_64 assembly to AT&T format.

* Move assembly for x86_64 and aarch64 to perlasm.

* Changes to aarch64 assembly, to avoid using x18 platform register.
  Assembly also correctly constructs linked list of stack-frames as
  described in AAPCS64, 5.2.3.

* Move constant values to .RODATA segment, as keeping them in .TEXT
  segment is not compatible with XOM.

* Fixes issue in arm64 code related to the fact that compiler doesn't
  reserve enough space for the linker to relocate address of a global
  variable when used by 'ldr' instructions. Solution is to use 'adrp'
  followed by 'add' instruction. Relocations for 'adrp' and 'add'
  instructions is generated by prefixing the label with :pg_hi21:
  and :lo12: respectively.

* Enable MULX and ADX. Code from MS doesn't support PIC. MULX can't
  reference global variable directly. Instead RIP-relative addressing
  can be used. This improves performance around 10%-13% on SkyLake

* Check if CPU supports BMI2 and ADOX instruction at runtime. On AMD64
  optimized implementation of montgomery multiplication and reduction
  have 2 implementations - faster one takes advantage of BMI2
  instruction set introduced in Haswell and ADOX introduced in
  Broadwell. Thanks to OPENSSL_ia32cap_P it can be decided at runtime
  which implementation to choose. As CPU configuration is static by
  nature, branch predictor will be correct most of the time and hence
  this check very often has no cost.

* Reuse some utilities from boringssl instead of reimplementing them.
  This includes things like:
  * definition of a limb size (use crypto_word_t instead of digit_t)
  * use functions for checking in constant time if value is 0 and/or
    less then
  * #define's used for conditional compilation

* Use SSE2 for conditional swap on vector registers. Improves
  performance a little bit.

* Fix f2elm_t definition. Code imported from MSR defines f2elm_t type as
  a array of arrays. This decays to a pointer to an array (when passing
  as an argument). In C, one can't assign const pointer to an array with
  non-const pointer to an array. Seems it violates 6.7.3/8 from C99
  (same for C11). This problem occures in GCC 6, only when -pedantic
  flag is specified and it occures always in GCC 4.9 (debian jessie).

* Fix definition of eval_3_isog. Second argument in eval_3_isog mustn't be
  const. Similar reason as above.

* Use HMAC-SHA256 instead of cSHAKE-256 to avoid upstreaming cSHAKE
  and SHA3 code.

* Add speed and unit tests for SIKE.

Some speed results:

Skylake (64-bit):

Did 408 SIKE/P503 generate operations in 1002573us (407.0 ops/sec)
Did 275 SIKE/P503 encap operations in 1070570us (256.9 ops/sec)
Did 264 SIKE/P503 decap operations in 1098955us (240.2 ops/sec)

Skylake (32-bit):

Did 9 SIKE/P503 generate operations in 1051620us (8.6 ops/sec)
Did 5 SIKE/P503 encap operations in 1038251us (4.8 ops/sec)
Did 5 SIKE/P503 decap operations in 1103617us (4.5 ops/sec)

Change-Id: I22f0bb1f9edff314a35cd74b48e8c4962568e330
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35204
Reviewed-by: Adam Langley <alangley@gmail.com>
2019-05-16 22:04:58 +00:00
Adam Langley c12b7cda72 tool: fix speed tests.
16K is a tested chunk size, but a couple of functions didn't have a
large enough buffer and so would fail. (Cleanly, but it stopped
subsequent executions.)

Change-Id: Ic11ba7b9055ab72dbf056a4c79dfc251cb511fb3
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/36044
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-05-14 19:12:15 +00:00
David Benjamin f014d609c0 Add an option to skip crypto_test_data.cc in GN too.
Chromium recently landed a presubmit that rejects files above 20MiB.
crypto_test_data.cc no longer fits.

Change-Id: I4236a4b56af743fbaf8f8600ccb0b88b41b925e8
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35944
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-05-08 15:31:18 +00:00
David Benjamin b29e1e15a3 Save and restore errors when ignoring ssl_send_alert result.
Out-of-band errors, the UNIX gift that keeps on giving...

We almost always ignore the result of ssl_send_alert, treating it as
largely a "best effort". Sending an alert is the only place in the TLS
stack where we call back to user code with state in the error queue. (If
we've put something in the error queue, it means we are in the process
of failing an operation.) That user code may mess up state by, say,
calling ERR_clear_error.

In particular, if the underlying BIO is implemented with SSL_write, as
in TLS tunneled over an HTTPS proxy, the call to SSL_write will
ERR_clear_error and clobber our error state. (SSL_write must
ERR_clear_error so that SSL_get_error works. This is one of the few
places we are sensitive to clearing the error queue.)

Split ssl_send_alert into a low-level ssl_send_alert_impl (for the two
places we do honor the return value) an ssl_send_alert wrapper which
saves and restores the error queue across the call, more explicitly
ignoring the return value.

This is intended as a minimal fix to https://crbug.com/959305, in case
we need to merge it to a release branch. As a follow-up, I plan to
rework the handshake state machine so it never calls ssl_send_alert,
instead returning the alert as part of the error. This is the last bit
of I/O still in the handshake. (We have the out_alert calling
convention, but I'm thinking it's worth a small sum type where the error
branch has an alert so we don't forget to supply one everywhere.

Update-Note: This changes our behavior when sending an alert fails.
Bug: chromium:959305
Change-Id: I24033205ad0f7ebd1797964489e4d46414a3e7ec
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35904
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-05-07 23:31:38 +00:00
David Benjamin 8728af4801 Reject obviously invalid DSA parameters during signing.
If g is zero, the retry loop will run infinitely. See
8f506274029903457c5f1d8663a012763f55cd37 from upstream.

Change-Id: I9e36002f2907dee3b5905e414e3c931d62b1a447
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35924
Reviewed-by: Adam Langley <agl@google.com>
2019-05-07 22:12:54 +00:00
David Benjamin b19b79d711 Make expect/expected flag and variable names match.
At one point we had -expect-foo and TestConfig::expect_foo for boolean
flags and -expect-bar and TestConfig::expected_bar for flags that take a
value. This seems to have been confusing and got applied inconsistently.

Match the variable names to the flag names and consistently use
"expect".

Change-Id: Ia346b91ad37b1177918c50392f9f80a384926e27
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35889
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-05-06 23:23:18 +00:00
David Benjamin 0ad8d575a2 clang-format Flag arrays in test_config.cc.
clang-format has slightly different opinions here. Use its opinions so
we don't have to format these by hand.

Change-Id: I65a204ad5ac24a7e454265957ef999539ec6c8aa
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35888
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-05-06 23:01:08 +00:00
David Benjamin 262fd6a09b Rename remnants of ticket_early_data_info.
At one point, the ticket early data extension was under a separate
ticket_early_data_info code point. That was later consolidated. Rename
the tests which still reference the "info" name.

Change-Id: Ie3c9257d32a95569906ad24e7b419434b9faae1c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35887
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-05-06 22:35:38 +00:00
David Benjamin 6433a91dcb Enforce the ticket_age parameter for 0-RTT.
For now just hard-code a tolerance of 1 minute.
SSL_get_early_data_reason and SSL_get_ticket_age_skew will allow us to
tune this.

Bug: 113
Change-Id: I85a530494d5405a3e11198d49bfa9cfd355f4f35
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35886
Reviewed-by: Adam Langley <agl@google.com>
2019-05-06 22:07:21 +00:00
David Benjamin 6477012ff5 Add SSL_get_early_data_reason.
This is to help servers diagnose 0-RTT rejects. (QUIC has a similar
feature, and this will help determine if we need to adjust the ticket
age skew.)

Bug: 113
Change-Id: Icc7e5df326b5fa82e744605021b1205298efba6a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35885
Reviewed-by: Adam Langley <agl@google.com>
2019-05-06 22:04:52 +00:00
David Benjamin 572edbf007 Remove implicit -on-resume for -expect-early-data-accept.
We have a generic mechanism for this now. While
-expect-early-data-accept only makes sense for the resumption leg, we
have some tests which send fake early data to a server on the first leg.
This is in preparation for adding an SSL_get_early_data_reason, where
asserting in those cases would be useful.

(Also -expect-early-data-reject works just fine for initial connections.
It might make sense to make that implicit from the lack of
-expect-early-data-accept?)

Change-Id: I41ad0c5bb538409628885183f88f7fbd619bc6aa
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35884
Reviewed-by: Adam Langley <agl@google.com>
2019-05-06 21:43:56 +00:00
John Sheu 787b26cc51 Use weak symbols only on supported platforms
Clang on Windows notably has a broken weak symbol implementation.  See:

    https://bugs.llvm.org/show_bug.cgi?id=37598

Change-Id: I417d08908f594c817626e4c225ea7c7429b35ca5
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35864
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-05-06 21:13:28 +00:00
Adam Langley ffe384cfe6 Fix spelling in comments.
(This triggers some internal tools.)

Change-Id: I63bb1e8cf92d63c8ab3c1f6556613daae3f43c54
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35844
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-05-01 18:23:54 +00:00
David Benjamin b3239c626d Add functions for "raw" EVP_PKEY serializations.
cryptography.io expects this API for Ed25519. Replace the now redundant
EVP_PKEY_new_ed25519_* functions. Ours were more static-linker-friendly,
but we weren't taking advantage of it and EVP_PKEY needs an overhaul to
be static-linker-friendly anyway.

Update-Note: EVP_PKEY_new_ed25519_public and
EVP_PKEY_new_ed25519_private are removed in favor of
EVP_PKEY_new_raw_{public,private}_key. I do not believe anyone was using
those functions.

Change-Id: Ibd12b4e9e37cd8dd4dbc7ebc4346ba52655d523a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35806
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-04-30 21:32:48 +00:00
David Benjamin f6eb56561a Remove stray underscores.
https://boringssl-review.googlesource.com/c/33424 missed a line.

I'm not sure why this runs right now. It errors if we turn the shaext
and avx2 code on. (NB: We shouldn't turn on AVX2 code without fixing its
CFI annotations. They're broken. It appears to allocates stack in a
loop.)

Change-Id: I17daa72aae8aad879c338433340155c331122397
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35824
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-04-30 19:36:08 +00:00
David Benjamin b96d470865 Add a compatibility EVP_DigestFinalXOF function.
This is to ease compiling against cryptography.io. (It expects anything
which has EVP_DigestSign to also have this function.)

Change-Id: I2bb4f4f01770d789e68fe84beed3393b1f004081
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35805
Reviewed-by: Adam Langley <agl@google.com>
2019-04-30 17:44:25 +00:00
David Benjamin e79cc432e3 Fix up EVP_DigestSign implementation for Ed25519.
The lengths involve an annoying input/output calling convention.

Change-Id: I848c8821604891f6a86099ced20287979a1143dd
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35804
Reviewed-by: Adam Langley <agl@google.com>
2019-04-30 17:43:28 +00:00
David Benjamin 1b878e7cc6 Check for errors when setting up X509_STORE_CTX.
Change-Id: Icf308d33374bf3d6505058eb4e82767f4b4b8a6b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35787
Reviewed-by: Adam Langley <agl@google.com>
2019-04-29 16:14:52 +00:00
David Benjamin 1e77ef4189 Convert a few more things from int to bool.
Change-Id: Iee4b8bbe82ea700e3c9c6538f981662a90747642
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35786
Reviewed-by: Adam Langley <agl@google.com>
2019-04-29 16:14:45 +00:00
David Benjamin 85eef297ee Compute the delegated credentials length prefix with CBB.
The length prefix is trivial in this case, but using CBB means we'll
check if the length fits in a u16.

Change-Id: I7deb2348fd7784e4f7d951f56dc176df3df9ef17
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35785
Reviewed-by: Adam Langley <agl@google.com>
2019-04-29 16:14:38 +00:00
David Benjamin a486c6c842 Convert the rest of ssl_test to GTest.
We never finished that up.

Change-Id: Iddb6a551ff88ee5475a3ccdd746cf3d38e4ba234
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35784
Reviewed-by: Adam Langley <agl@google.com>
2019-04-29 16:14:30 +00:00
David Benjamin 586235df2e Check for x18 usage in aarch64 assembly.
r18 (accessed as x18 and w18) is the platform register. The ABI testing
framework cannot touch it, but we can statically check that our assembly
leaves it alone.

Also fix a comment which cited the wrong register.

Change-Id: Iba2714eef5db19e2e93a6838d12a4e7c9011cc67
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35764
Reviewed-by: Adam Langley <agl@google.com>
2019-04-26 18:04:39 +00:00
David Benjamin c1d8c5b0e0 Handle errors from close in perlasm scripts.
If the xlate filter script fails, the outer script swallows the error,
unless we check the return value of close.

Change-Id: Ib506bb745a5d27b9d1df9329535bf81ad090f41f
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35724
Reviewed-by: Adam Langley <agl@google.com>
2019-04-26 18:03:21 +00: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
David Benjamin d1a6d23686 Test copying an EVP_MD_CTX.
We should have test coverage for this path.

Change-Id: I8bcd9e2481562b3ad1e447c03a52b8ff4ff25606
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35625
Reviewed-by: Adam Langley <agl@google.com>
2019-04-15 21:56:07 +00:00
David Benjamin 65dc45cb57 Fix EVP_CIPHER_CTX_copy for AES-GCM.
7578f3f0de made it work, but
26ba48a6fb regressed it by losing the
EVP_CIPH_CUSTOM_COPY flag. Additionally, we've since added an alignment
requirement to EVP_AES_GCM_CTX, which complicates things.

Thanks to Guido Vranken for catching this!

Bug: 270
Change-Id: I71784593dc5a34d1334c92a4daa93546ec0ee2c3
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35624
Reviewed-by: Adam Langley <agl@google.com>
2019-04-15 21:55:06 +00:00
David Benjamin 4a8c05ffe8 Check key sizes in AES_set_*_key.
AES_set_*_key used to call directly into aes_nohw_set_*_key which
gracefully handles some NULL parameters and invalid bit sizes. However,
we now enable optimized assembly implementations, not all of which
perform these checks. (vpaes does not.)

This is fine for the internal assembly functions themselves. Such checks
are better written in C than assembly, and the calling C code usually
already knows the key size. (Indeed aes_ctr_set_key already assumes the
assembly functions are infallible.) AES_set_*_key are public APIs,
however. The NULL check is silly, but we should handle length-like
checks in public APIs.

Change-Id: I259ae6b9811ceaa9dc5bd7173d5754ca7079cff8
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35564
Reviewed-by: Adam Langley <agl@google.com>
2019-04-11 15:33:57 +00:00
David Benjamin 31ef16ac2d Add missing nonce_len check to aead_aes_gcm_siv_asm_open.
Test invalid nonce lengths more thoroughly to cover this case on all our
AEADs. Thanks to Guido Vranken for catching this!

In doing so, this also reveals we have a ton of redundant error codes
(https://crbug.com/boringssl/269). I'll tidy that up in a separate
change as it may require some changes to code in Android. For now, this
change uses CIPHER_R_UNSUPPORTED_NONCE_SIZE just to be consistent with
the rest of that file.

Bug: 268
Change-Id: I0a479000ec3005ee55c828eaa92c8302b4625847
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35545
Reviewed-by: Adam Langley <agl@google.com>
2019-04-11 15:31:38 +00:00
David Benjamin 4a136ea005 Test AES-GCM-SIV with OPENSSL_SMALL.
https://boringssl-review.googlesource.com/16805 inadvertently restored
the OPENSSL_SMALL condition in aead_test.cc. I probably handled some
merge conflict wrong.

Change-Id: I1b29fbd4a0a57d94cd8b5bddf7c81ae10063e2a8
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35544
Reviewed-by: Adam Langley <agl@google.com>
2019-04-11 15:17:47 +00:00
David Benjamin ad9eee1628 Handle CBB_cleanup on child CBBs more gracefully.
Child and root CBBs share a type, but are different kinds of things. C++
programmers sometimes mistakenly believe they should use ScopedCBB for
everything. This mostly works because we NULL cbb->child->base on flush,
making CBB_cleanup a no-op. This zeroing also skips the assert in
CBB_cleanup. (If we ran it unconditionally, CBB_zero + CBB_cleanup would
not work.)

However, if a CBB operation fails and a function returns early, the
child CBB is not cleared. ScopedCBB will then call CBB_cleanup which
trips the assert but, in release build, misbehaves.

Run the assert unconditionally and, when the assert fails, still behave
well. To make this work with CBB_zero, negate is_top_level to is_child,
so a flushed child CBB and a (presumably) root CBB in the zero state are
distinguishable.

Update-Note: Code that was using CBB wrong may trip an assert in debug builds.
Change-Id: Ifea7759e1d0331f2e727c59bbafa355d70fb9dba
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35524
Reviewed-by: Adam Langley <agl@google.com>
2019-04-10 22:12:42 +00:00
David Benjamin be7006adac Update third_party/googletest.
The new version of googletest deprecates INSTANTIATE_TEST_CASE_P in
favor of INSTANTIATE_TEST_SUITE_P, so apply the change.

This requires blacklisting C4628 on MSVC 2015 which says about digraphs
given foo<::std::tuple<...>>. Disable that warning. Digraphs are not
useful and C++11 apparently explicitly disambiguates that.

It also requires applying
https://github.com/google/googletest/pull/2226, to deal with a warning
in older MSVC.

Update-Note: Consumers using BoringSSL with their own copy of googletest
must ensure googletest was updated to a version from 2019-01-03 or
later for INSTANTIATE_TEST_SUITE_P to work. (I believe all relevant
consumers are fine here. If anyone can't update googletest and is
building BoringSSL tests, building with
-DINSTANTIATE_TEST_SUITE_P=INSTANTIATE_TEST_CASE_P would work as
workaround.)

Bug: chromium:936651
Change-Id: I23ada8de34a53131cab88a36a88d3185ab085c64
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35504
Reviewed-by: Adam Langley <agl@google.com>
2019-04-10 22:09:43 +00:00
David Benjamin 387b07b78d Rename 'md' output parameter to 'out' and add bounds.
We usually name output parameters 'out'. (Someone made a C++ templating
change in Chromium which messed up const-ness, saw the compile error,
and thought it was in MD5_Final.) Also tag the parameters with the
sizes.

Sadly, there's a bit of goofiness around SHA224_Final/SHA256_Final and
SHA384_Final/SHA512_Final, but they're just documentation anyway.
(Though it does touch on the mess that is sha->md_len which would be
nice to clear through somehow.)

Change-Id: I1918b7eecfe13f13b217d01d4414ac2358802354
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35484
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-04-08 18:19:01 +00:00
David Benjamin a26d01719b Update other build tools.
Change-Id: If3c8de4b81559acd88e32928ac9884ace294fd1d
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35465
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-04-04 17:42:09 +00:00
David Benjamin 98348562f0 Update SDE to 8.35.0-2019-03-11.
The new version has trap flag emulation, which is great for our ABI
tests. This CL doesn't enable it yet, however. The emulation is slightly
off on when traps start and stop, so the ABI tester will need to tweaked
to be more lenient.

Change-Id: I0eb20176dc63eaa1c35f77379b34f7bb6c0b0407
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35464
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-04-04 17:41:28 +00:00
Christopher Patton be9953accf nit: Update references to draft-ietf-tls-subcerts.
Change-Id: Ica6ea6eaff1849c7ee42be671b22006fe3ee5ff4
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35444
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-04-01 19:54:35 +00:00
Nitish Sakhawalkar a4af5f85bd Support get versions with get_{min,max}_proto_version for context
When building node with boringssl, `SSL_CTX_get_min_proto_version` and
`SSL_CTX_get_max_proto_version` are used. Openssl exposes those; this
change adds support for boringssl.

For this to work right in DTLS, we switch conf_{min,max}_version to store wire
versions, rather than our internal normalized versions.

Change-Id: I282ed224806c41f69e6f166ca97c6cc05ff51f17
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35404
Reviewed-by: Nitish Sakhawalkar <nitsakh@gmail.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-03-27 12:46:26 +00:00
David Benjamin df11bed9ee Update ImplDispatchTest for bsaes-x86_64 removal.
I always forget to update this.

Bug: 256
Change-Id: I85fea8fa48da8d4ed6a1e1f001f5e1a74f1b706d
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35384
Reviewed-by: Adam Langley <agl@google.com>
2019-03-23 15:15:48 +00:00
David Benjamin 1a36dd4930 Unwind the large_inputs hint in aes_ctr_set_key.
With bsaes-x86_64.pl gone, it is no longer needed. Depending on how armv7 works
(if vpaes-armv7.pl is too slow AND on-demand vpaes->bsaes key conversion is not
viable), we may need to bring it back, but get it out of the way for now.

Bug: 256
Change-Id: I762c83097bd03d88574ae1ae16b88fca6826f655
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35365
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-03-23 07:06:02 +00:00
David Benjamin 32ce6032ff Add an optimized x86_64 vpaes ctr128_f and remove bsaes.
Brian Smith suggested applying vpaes-armv8's "2x" optimization to
vpaes-x86_64. The registers are a little tight (aarch64 has a whole 32
SIMD registers, while x86_64 only has 16), but it's doable with some
spills and makes vpaes much more competitive with bsaes. At small- and
medium-sized inputs, vpaes now matches bsaes. At large inputs, it's a
~10% perf hit.

bsaes is thus pulling much less weight. Losing an entire AES
implementation and having constant-time AES for SSSE3 is attractive.
Some notes:

- The fact that these are older CPUs tempers the perf hit, but CPUs
  without AES-NI are still common enough to matter.

- This CL does regress CBC decrypt performance nontrivially (see below).
  If this matters, we can double-up CBC decryption too. CBC in TLS is
  legacy and already pays a costly Lucky13 mitigation.

- The difference between 1350 and 8192 bytes is likely bsaes AES-GCM
  paying for two slow (and variable-time!) aes_nohw_encrypt
  calls for EK0 and the trailing partial block. At larger inputs, those
  two calls are more amortized.

- To that end, bsaes would likely be much faster on AES-GCM with smarter
  use of bsaes. (Fold one-off calls above into bulk data.) Implementing
  this is a bit of a nuisance though, especially considering we don't
  wish to regress hwaes.

- I'd discarded the key conversion idea, but I think I did it wrong.
  Benchmarks from
  https://boringssl-review.googlesource.com/c/boringssl/+/33589 suggest
  converting to bsaes format on-demand for large ctr32 inputs should
  give the best of both worlds, but at the cost of an entire AES
  implementation relative to this CL.

- ARMv7 still depends on bsaes and has no vpaes. It also has 16 SIMD
  registers, so my plan is to translate it, with the same 2x
  optimization, and see how it compares. Hopefully that, or some
  combination of the above, will work for ARMv7.

Sandy Bridge
bsaes (before):
Did 3144750 AES-128-GCM (16 bytes) seal operations in 5016000us (626943.8 ops/sec): 10.0 MB/s
Did 2053750 AES-128-GCM (256 bytes) seal operations in 5016000us (409439.8 ops/sec): 104.8 MB/s
Did 469000 AES-128-GCM (1350 bytes) seal operations in 5015000us (93519.4 ops/sec): 126.3 MB/s
Did 92500 AES-128-GCM (8192 bytes) seal operations in 5016000us (18441.0 ops/sec): 151.1 MB/s
Did 46750 AES-128-GCM (16384 bytes) seal operations in 5032000us (9290.5 ops/sec): 152.2 MB/s
vpaes-1x (for reference, not this CL):
Did 8684750 AES-128-GCM (16 bytes) seal operations in 5015000us (1731754.7 ops/sec): 27.7 MB/s [+177%]
Did 1731500 AES-128-GCM (256 bytes) seal operations in 5016000us (345195.4 ops/sec): 88.4 MB/s [-15.6%]
Did 346500 AES-128-GCM (1350 bytes) seal operations in 5016000us (69078.9 ops/sec): 93.3 MB/s [-26.1%]
Did 61250 AES-128-GCM (8192 bytes) seal operations in 5015000us (12213.4 ops/sec): 100.1 MB/s [-33.8%]
Did 32500 AES-128-GCM (16384 bytes) seal operations in 5031000us (6459.9 ops/sec): 105.8 MB/s [-30.5%]
vpaes-2x (this CL):
Did 8840000 AES-128-GCM (16 bytes) seal operations in 5015000us (1762711.9 ops/sec): 28.2 MB/s [+182%]
Did 2167750 AES-128-GCM (256 bytes) seal operations in 5016000us (432167.1 ops/sec): 110.6 MB/s [+5.5%]
Did 474000 AES-128-GCM (1350 bytes) seal operations in 5016000us (94497.6 ops/sec): 127.6 MB/s [+1.0%]
Did 81750 AES-128-GCM (8192 bytes) seal operations in 5015000us (16301.1 ops/sec): 133.5 MB/s [-11.6%]
Did 41750 AES-128-GCM (16384 bytes) seal operations in 5031000us (8298.5 ops/sec): 136.0 MB/s [-10.6%]

Penryn
bsaes (before):
Did 958000 AES-128-GCM (16 bytes) seal operations in 1000264us (957747.2 ops/sec): 15.3 MB/s
Did 420000 AES-128-GCM (256 bytes) seal operations in 1000480us (419798.5 ops/sec): 107.5 MB/s
Did 96000 AES-128-GCM (1350 bytes) seal operations in 1001083us (95896.1 ops/sec): 129.5 MB/s
Did 18000 AES-128-GCM (8192 bytes) seal operations in 1042491us (17266.3 ops/sec): 141.4 MB/s
Did 9482 AES-128-GCM (16384 bytes) seal operations in 1095703us (8653.8 ops/sec): 141.8 MB/s
Did 758000 AES-256-GCM (16 bytes) seal operations in 1000769us (757417.5 ops/sec): 12.1 MB/s
Did 359000 AES-256-GCM (256 bytes) seal operations in 1001993us (358285.9 ops/sec): 91.7 MB/s
Did 82000 AES-256-GCM (1350 bytes) seal operations in 1009583us (81221.7 ops/sec): 109.6 MB/s
Did 15000 AES-256-GCM (8192 bytes) seal operations in 1022294us (14672.9 ops/sec): 120.2 MB/s
Did 7884 AES-256-GCM (16384 bytes) seal operations in 1070934us (7361.8 ops/sec): 120.6 MB/s
vpaes-1x (for reference, not this CL):
Did 2030000 AES-128-GCM (16 bytes) seal operations in 1000227us (2029539.3 ops/sec): 32.5 MB/s [+112%]
Did 382000 AES-128-GCM (256 bytes) seal operations in 1001949us (381256.9 ops/sec): 97.6 MB/s [-9.2%]
Did 81000 AES-128-GCM (1350 bytes) seal operations in 1007297us (80413.2 ops/sec): 108.6 MB/s [-16.1%]
Did 14000 AES-128-GCM (8192 bytes) seal operations in 1031499us (13572.5 ops/sec): 111.2 MB/s [-21.4%]
Did 7008 AES-128-GCM (16384 bytes) seal operations in 1030706us (6799.2 ops/sec): 111.4 MB/s [-21.4%]
Did 1838000 AES-256-GCM (16 bytes) seal operations in 1000238us (1837562.7 ops/sec): 29.4 MB/s [+143%]
Did 321000 AES-256-GCM (256 bytes) seal operations in 1001666us (320466.1 ops/sec): 82.0 MB/s [-10.6%]
Did 67000 AES-256-GCM (1350 bytes) seal operations in 1010359us (66313.1 ops/sec): 89.5 MB/s [-18.3%]
Did 12000 AES-256-GCM (8192 bytes) seal operations in 1072706us (11186.7 ops/sec): 91.6 MB/s [-23.8%]
Did 5680 AES-256-GCM (16384 bytes) seal operations in 1009214us (5628.1 ops/sec): 92.2 MB/s [-23.5%]
vpaes-2x (this CL):
Did 2072000 AES-128-GCM (16 bytes) seal operations in 1000066us (2071863.3 ops/sec): 33.1 MB/s [+116%]
Did 432000 AES-128-GCM (256 bytes) seal operations in 1000732us (431684.0 ops/sec): 110.5 MB/s [+2.8%]
Did 92000 AES-128-GCM (1350 bytes) seal operations in 1000580us (91946.7 ops/sec): 124.1 MB/s [-4.2%]
Did 16000 AES-128-GCM (8192 bytes) seal operations in 1016422us (15741.5 ops/sec): 129.0 MB/s [-8.8%]
Did 8448 AES-128-GCM (16384 bytes) seal operations in 1073962us (7866.2 ops/sec): 128.9 MB/s [-9.1%]
Did 1865000 AES-256-GCM (16 bytes) seal operations in 1000043us (1864919.8 ops/sec): 29.8 MB/s [+146%]
Did 364000 AES-256-GCM (256 bytes) seal operations in 1001561us (363432.7 ops/sec): 93.0 MB/s [+1.4%]
Did 77000 AES-256-GCM (1350 bytes) seal operations in 1004123us (76683.8 ops/sec): 103.5 MB/s [-5.6%]
Did 14000 AES-256-GCM (8192 bytes) seal operations in 1071179us (13069.7 ops/sec): 107.1 MB/s [-10.9%]
Did 7008 AES-256-GCM (16384 bytes) seal operations in 1074125us (6524.4 ops/sec): 106.9 MB/s [-11.4%]

Penryn, CBC mode decryption
bsaes (before):
Did 159000 AES-128-CBC-SHA1 (16 bytes) open operations in 1001019us (158838.1 ops/sec): 2.5 MB/s
Did 114000 AES-128-CBC-SHA1 (256 bytes) open operations in 1006485us (113265.5 ops/sec): 29.0 MB/s
Did 65000 AES-128-CBC-SHA1 (1350 bytes) open operations in 1008441us (64455.9 ops/sec): 87.0 MB/s
Did 17000 AES-128-CBC-SHA1 (8192 bytes) open operations in 1005440us (16908.0 ops/sec): 138.5 MB/s
vpaes (after):
Did 167000 AES-128-CBC-SHA1 (16 bytes) open operations in 1003556us (166408.3 ops/sec): 2.7 MB/s [+8%]
Did 112000 AES-128-CBC-SHA1 (256 bytes) open operations in 1005673us (111368.2 ops/sec): 28.5 MB/s [-1.7%]
Did 56000 AES-128-CBC-SHA1 (1350 bytes) open operations in 1005647us (55685.5 ops/sec): 75.2 MB/s [-13.6%]
Did 13635 AES-128-CBC-SHA1 (8192 bytes) open operations in 1020486us (13361.3 ops/sec): 109.5 MB/s [-20.9%]

Bug: 256
Change-Id: I11ed773323ec7a5ee61080c9ed9ed4761849828a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35364
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-03-23 06:59:22 +00:00
David Benjamin 5501a26915 Add 16384 to the default bssl speed sizes.
When servers have a lot of data to send and aren't as latency-sensitive,
it makes sense to send large TLS records, so we care about measuring
both packet-sized and full-sized payloads.

Change-Id: Ib0cf5e0f8660f68a98a04fa86b5989d4a485528b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35344
Reviewed-by: Adam Langley <agl@google.com>
2019-03-20 23:01:43 +00:00
David Benjamin 4ca8d131d3 Rewrite BN_CTX.
While allocating near INT_MAX BIGNUMs or stack frames would never happen, we
should properly handle overflow here. Rewrite it to just be a STACK_OF(BIGNUM)
plus a stack of indices. Also simplify the error-handling. If we make the
errors truly sticky (rather than just sticky per frame), we don't need to keep
track of err_stack and friends.

Thanks to mlbrown for reporting the integer overflows in the original
implementation.

Bug: chromium:942269
Change-Id: Ie9c9baea3eeb82d65d88b1cb1388861f5cd84fe5
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35328
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-03-18 19:18:31 +00:00
David Benjamin c93be52c9e Save a temporary in BN_mod_exp_mont's w=1 case.
BN_mod_exp_mont is most commonly used in RSA verification, where the exponent
sizes are small enough to use 1-bit "windows". There's no need to allocate the
extra BIGNUM.

Change-Id: I14fb523dfae7d77d2cec10a0209f09f22031d1af
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35327
Reviewed-by: Adam Langley <agl@google.com>
2019-03-18 17:20:32 +00:00
David Benjamin 1c71844ef5 Reject long inputs in c2i_ASN1_INTEGER.
Thanks to mlbrown for reporting this.

Bug: chromium:942269
Change-Id: Ie06970f25a6ab0e08a8861d604b2177c8fd1d1a8
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35326
Reviewed-by: Adam Langley <agl@google.com>
2019-03-18 17:19:52 +00:00
David Benjamin 0dcab9302f Harden the lower level parts of crypto/asn1 against overflows.
The legacy ASN.1 stack contains an unsalvageable mix of integer types.
82dfea8d9e bounded all inputs to the template
machinery, but sometimes code will call ASN1_get_object directly, such as the
just deleted d2i_ASN1_UINTEGER.

Thanks to mlbrown for reporting the d2i_ASN1_UINTEGER overflow.

Bug: chromium:942269
Change-Id: I2d4c8b7faf5dadd1b68dbdb51a5feae071ea2cb6
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35325
Reviewed-by: Adam Langley <agl@google.com>
2019-03-18 17:19:12 +00:00
David Benjamin bab14fa753 Remove d2i_ASN1_UINTEGER.
It is unused. It dates to an old OpenSSL DSA serialization bug.

Bug: chromium:942269
Update-Note: Removing a function.
Change-Id: Ia98f7eb1dafcd832c744387475cc13b58bc82ffe
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35324
Reviewed-by: Adam Langley <agl@google.com>
2019-03-18 17:18:26 +00:00
David Benjamin fdb48f9861 Drop some unused bsaes to aes_nohw dependencies.
When the CBC and CTR EVP_CIPHER implementations use bsaes, they never
call dat->block. Note this is *not* true of aes_ctr_set_key which is
used in contexts where it needs single-block operations.

Bug: 256
Change-Id: Ibea4f2117a2220cd5cb09f6cf12b7a50c28bf794
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35168
Reviewed-by: Adam Langley <agl@google.com>
2019-03-14 21:43:58 +00:00
David Benjamin d22578f366 Adapt gcm_*_neon to aarch64.
This makes AES-GCM always constant-time on aarch64 (provided assembly is
enabled). Unlike vpaes, this does come at a binary size penalty of 1K
compared to the gcm_*_4bit version.

ABI testing already covered by GCMTest.ABI (GHASH_ASM_ARM covers both
OPENSSL_ARM and OPENSSL_AARCH64.)

Cortex-A53 (Raspberry Pi 3 Model B+)
Before:
Did 274000 AES-128-GCM (16 bytes) seal operations in 1003461us (273055.0 ops/sec): 4.4 MB/s
Did 53000 AES-128-GCM (256 bytes) seal operations in 1007689us (52595.6 ops/sec): 13.5 MB/s
Did 12000 AES-128-GCM (1350 bytes) seal operations in 1075908us (11153.4 ops/sec): 15.1 MB/s
Did 2068 AES-128-GCM (8192 bytes) seal operations in 1089037us (1898.9 ops/sec): 15.6 MB/s
After:
Did 298000 AES-128-GCM (16 bytes) seal operations in 1002917us (297133.3 ops/sec): 4.8 MB/s
Did 64000 AES-128-GCM (256 bytes) seal operations in 1001124us (63928.1 ops/sec): 16.4 MB/s
Did 14000 AES-128-GCM (1350 bytes) seal operations in 1015477us (13786.6 ops/sec): 18.6 MB/s
Did 2497 AES-128-GCM (8192 bytes) seal operations in 1057951us (2360.2 ops/sec): 19.3 MB/s

Bug: 265
Change-Id: I251bf0f2eae0578580bb14192755e5d8ff64cd14
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35285
Reviewed-by: Adam Langley <agl@google.com>
2019-03-14 21:43:27 +00:00
David Benjamin 4851041967 Patch out the aes_nohw fallback in bsaes_cbc_encrypt.
This plugs all bsaes fallback leaks for CBC outside of the key schedule.
The CBC EVP_CIPHERs never call the block function directly when there's
a stream.cbc function available.

This affects CBC decryptions of length < 128 or 16 mod 128.
Performance-wise, we don't really care about CBC apart from passing
glances at its use in TLS. There, the Lucky13 workaround mutes the
effects.

Cortex-A53 (Raspberry Pi 3 Model B+)
Before:
Did 78000 AES-128-CBC-SHA1 (16 bytes) open operations in 3020254us (25825.6 ops/sec): 0.4 MB/s
Did 75000 AES-128-CBC-SHA1 (32 bytes) open operations in 3005760us (24952.1 ops/sec): 0.8 MB/s
Did 71000 AES-128-CBC-SHA1 (64 bytes) open operations in 3038137us (23369.6 ops/sec): 1.5 MB/s
Did 67000 AES-128-CBC-SHA1 (96 bytes) open operations in 3027686us (22129.1 ops/sec): 2.1 MB/s
Did 64000 AES-128-CBC-SHA1 (112 bytes) open operations in 3005491us (21294.4 ops/sec): 2.4 MB/s
Did 59000 AES-128-CBC-SHA1 (128 bytes) open operations in 3020083us (19535.9 ops/sec): 2.5 MB/s
Did 53000 AES-128-CBC-SHA1 (240 bytes) open operations in 3020105us (17549.1 ops/sec): 4.2 MB/s
After:
Did 71668 AES-128-CBC-SHA1 (16 bytes) open operations in 3020896us (23724.1 ops/sec): 0.4 MB/s
Did 71000 AES-128-CBC-SHA1 (32 bytes) open operations in 3040826us (23348.9 ops/sec): 0.7 MB/s
Did 68000 AES-128-CBC-SHA1 (64 bytes) open operations in 3009913us (22592.0 ops/sec): 1.4 MB/s
Did 66000 AES-128-CBC-SHA1 (96 bytes) open operations in 3007597us (21944.4 ops/sec): 2.1 MB/s
Did 59000 AES-128-CBC-SHA1 (112 bytes) open operations in 3002878us (19647.8 ops/sec): 2.2 MB/s
Did 59000 AES-128-CBC-SHA1 (128 bytes) open operations in 3046786us (19364.7 ops/sec): 2.5 MB/s
Did 50000 AES-128-CBC-SHA1 (240 bytes) open operations in 3043643us (16427.7 ops/sec): 3.9 MB/s

Penryn (Mac mini, mid 2010)
Before:
Did 152000 AES-128-CBC-SHA1 (16 bytes) open operations in 1004422us (151330.8 ops/sec): 2.4 MB/s
Did 143000 AES-128-CBC-SHA1 (32 bytes) open operations in 1000443us (142936.7 ops/sec): 4.6 MB/s
Did 136000 AES-128-CBC-SHA1 (48 bytes) open operations in 1006580us (135111.0 ops/sec): 6.5 MB/s
Did 146000 AES-128-CBC-SHA1 (96 bytes) open operations in 1005731us (145168.0 ops/sec): 13.9 MB/s
Did 138000 AES-128-CBC-SHA1 (112 bytes) open operations in 1003330us (137542.0 ops/sec): 15.4 MB/s
Did 133000 AES-128-CBC-SHA1 (128 bytes) open operations in 1005876us (132223.1 ops/sec): 16.9 MB/s
Did 117000 AES-128-CBC-SHA1 (240 bytes) open operations in 1004922us (116426.9 ops/sec): 27.9 MB/s
After:
Did 159000 AES-128-CBC-SHA1 (16 bytes) open operations in 1000505us (158919.7 ops/sec): 2.5 MB/s
Did 157000 AES-128-CBC-SHA1 (32 bytes) open operations in 1006091us (156049.5 ops/sec): 5.0 MB/s
Did 154000 AES-128-CBC-SHA1 (48 bytes) open operations in 1002720us (153582.3 ops/sec): 7.4 MB/s
Did 146000 AES-128-CBC-SHA1 (96 bytes) open operations in 1002567us (145626.2 ops/sec): 14.0 MB/s
Did 135000 AES-128-CBC-SHA1 (112 bytes) open operations in 1001212us (134836.6 ops/sec): 15.1 MB/s
Did 133000 AES-128-CBC-SHA1 (128 bytes) open operations in 1006441us (132148.8 ops/sec): 16.9 MB/s
Did 115000 AES-128-CBC-SHA1 (240 bytes) open operations in 1005246us (114399.9 ops/sec): 27.5 MB/s

Bug: 256
Change-Id: I864b4455ada0d4d245380fce6f869dabb0686354
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35167
Reviewed-by: Adam Langley <agl@google.com>
2019-03-14 21:38:28 +00:00
David Benjamin 885a63fb74 Patch out the aes_nohw fallback in bsaes_ctr32_encrypt_blocks.
bsaes_ctr32_encrypt_blocks previously fell back to the table-based
aes_nohw_encrypt for inputs under 128 bytes. Instead, just run the usual
bsaes code, though it means we compute more blocks than needed.

This fixes some (but not all) the timing leaks and is needed for later
bsaes work.

Performance-wise, x86_64 actually sees a performance improvement for all but
tiny inputs. ARM does see a loss at small inputs however.

Cortex-A53 (Raspberry Pi 3 Model B+)
Before:
Did 299000 AES-128-GCM (16 bytes) seal operations in 1001123us (298664.6 ops/sec): 4.8 MB/s
Did 236000 AES-128-GCM (32 bytes) seal operations in 1001611us (235620.4 ops/sec): 7.5 MB/s
Did 167000 AES-128-GCM (64 bytes) seal operations in 1005706us (166052.5 ops/sec): 10.6 MB/s
Did 129000 AES-128-GCM (96 bytes) seal operations in 1006129us (128214.2 ops/sec): 12.3 MB/s
Did 116000 AES-128-GCM (112 bytes) seal operations in 1006302us (115273.5 ops/sec): 12.9 MB/s
Did 107000 AES-128-GCM (128 bytes) seal operations in 1000986us (106894.6 ops/sec): 13.7 MB/s
After:
Did 132000 AES-128-GCM (16 bytes) seal operations in 1005165us (131321.7 ops/sec): 2.1 MB/s
Did 128000 AES-128-GCM (32 bytes) seal operations in 1005966us (127240.9 ops/sec): 4.1 MB/s
Did 120000 AES-128-GCM (64 bytes) seal operations in 1003080us (119631.5 ops/sec): 7.7 MB/s
Did 113000 AES-128-GCM (96 bytes) seal operations in 1000557us (112937.1 ops/sec): 10.8 MB/s
Did 110000 AES-128-GCM (112 bytes) seal operations in 1000407us (109955.2 ops/sec): 12.3 MB/s
Did 108000 AES-128-GCM (128 bytes) seal operations in 1008830us (107054.7 ops/sec): 13.7 MB/s
(Inputs 128 bytes and up are unaffected by this CL.)

Nexus 7
Before:
Did 544000 AES-128-GCM (16 bytes) seal operations in 1001282us (543303.5 ops/sec): 8.7 MB/s
Did 475750 AES-128-GCM (32 bytes) seal operations in 1000244us (475633.9 ops/sec): 15.2 MB/s
Did 370500 AES-128-GCM (64 bytes) seal operations in 1000519us (370307.8 ops/sec): 23.7 MB/s
Did 300750 AES-128-GCM (96 bytes) seal operations in 1000122us (300713.3 ops/sec): 28.9 MB/s
Did 275750 AES-128-GCM (112 bytes) seal operations in 1000702us (275556.6 ops/sec): 30.9 MB/s
Did 251000 AES-128-GCM (128 bytes) seal operations in 1000214us (250946.3 ops/sec): 32.1 MB/s
After:
Did 296000 AES-128-GCM (16 bytes) seal operations in 1001129us (295666.2 ops/sec): 4.7 MB/s
Did 288750 AES-128-GCM (32 bytes) seal operations in 1000488us (288609.2 ops/sec): 9.2 MB/s
Did 267250 AES-128-GCM (64 bytes) seal operations in 1000641us (267078.8 ops/sec): 17.1 MB/s
Did 253250 AES-128-GCM (96 bytes) seal operations in 1000915us (253018.5 ops/sec): 24.3 MB/s
Did 248000 AES-128-GCM (112 bytes) seal operations in 1000091us (247977.4 ops/sec): 27.8 MB/s
Did 249000 AES-128-GCM (128 bytes) seal operations in 1000794us (248802.5 ops/sec): 31.8 MB/s

Penryn (Mac mini, mid 2010)
Before:
Did 1331000 AES-128-GCM (16 bytes) seal operations in 1000263us (1330650.0 ops/sec): 21.3 MB/s
Did 991000 AES-128-GCM (32 bytes) seal operations in 1000274us (990728.5 ops/sec): 31.7 MB/s
Did 780000 AES-128-GCM (48 bytes) seal operations in 1000278us (779783.2 ops/sec): 37.4 MB/s
Did 483000 AES-128-GCM (96 bytes) seal operations in 1000137us (482933.8 ops/sec): 46.4 MB/s
Did 428000 AES-128-GCM (112 bytes) seal operations in 1001132us (427516.1 ops/sec): 47.9 MB/s
Did 682000 AES-128-GCM (128 bytes) seal operations in 1000564us (681615.6 ops/sec): 87.2 MB/s
After:
Did 953000 AES-128-GCM (16 bytes) seal operations in 1000385us (952633.2 ops/sec): 15.2 MB/s
Did 903000 AES-128-GCM (32 bytes) seal operations in 1000998us (902099.7 ops/sec): 28.9 MB/s
Did 850000 AES-128-GCM (48 bytes) seal operations in 1000938us (849203.4 ops/sec): 40.8 MB/s
Did 736000 AES-128-GCM (96 bytes) seal operations in 1000886us (735348.5 ops/sec): 70.6 MB/s
Did 702000 AES-128-GCM (112 bytes) seal operations in 1000657us (701539.1 ops/sec): 78.6 MB/s
Did 676000 AES-128-GCM (128 bytes) seal operations in 1000405us (675726.3 ops/sec): 86.5 MB/s

Bug: 256
Change-Id: I9403da607dd1feaff7b3c9b76fe78b66018fb753
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35166
Reviewed-by: Adam Langley <agl@google.com>
2019-03-14 21:37:46 +00:00
David Benjamin aadcce380f Implement sk_find manually.
glibc inlines bsearch, so CFI does observe the function pointer mishap.
Binary search is easy enough, aside from thinking through the edge case
at the end, so just implement it by hand. As a bonus, it actually gives
O(lg N) behavior.

sk_*_find needs to return the *first* match, while bsearch does not
promise a particular one. sk_find thus performs a fixup step to find the
first one, but this is linear in the number of matching elements.
Instead, the binary search should take this into account.

This still leaves qsort, but it's not inlined, so hopefully we can leave
it alone.

Bug: chromium:941463
Change-Id: I5c94d6b15423beea3bdb389639466f8b3ff0dc5d
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35304
Reviewed-by: Adam Langley <agl@google.com>
2019-03-14 15:21:48 +00:00
David Benjamin 35941f2923 Make vpaes-armv8.pl compatible with XOM.
Change-Id: I27413467e5cac4e16ecbbb8d9a238ba5a8bcb9e7
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35284
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-03-11 23:17:06 +00:00
Adam Langley 1d1345377a Support three-argument instructions on x86-64.
Change-Id: I81c855cd4805d4a5016999669a0cb5261838f23a
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35224
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-03-11 21:41:40 +00:00
Watson Ladd 3390fd88d7 Correct outdated comments
Change-Id: Idc3a41d025fefa9017fce108bed63cb8af426c9b
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35244
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-03-07 21:55:09 +00:00
David Benjamin f9c8d30897 Remove SSL_get_structure_sizes.
With all those structures made opaque, it's not really useful as a build
sanity-check anymore.

Update-Note: This function is removed, but I don't see any actual uses.
Change-Id: Ib5640e778466da980596e7085d97104d22aa9d33
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35184
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-03-05 17:58:10 +00:00
David Benjamin b8d7b7498c Prefer vpaes over bsaes in AES-GCM-SIV and AES-CCM.
The AES-GCM-SIV code does not use ctr128_f at all so bsaes is simply
identical to aes_nohw. Also, while CCM encrypts with CTR mode, its MAC
is not parallelizable at all.

(Given the existence of non-parallelizable modes, we ought to make a
vpaes-armv7.pl to ensure constant-time AES on NEON. For now, pick the
right implementation for x86_64 at least.)

aes_ctr_set_key and friends probably aren't the right abstraction
(observe the large vs small inputs hint *almost* matches whether you
touch block128_f), but the right abstraction depends on a couple
questions:

- If you don't provide ctr128_f, is there a perf hit to implementing
  ctr128_f on top of your block128_f to unify calling code?

- It is almost certainly better to use bsaes with gcm.c by calling
  ctr128_f exclusively and paying some copies (a dedicated calling
  convention would be even better, but would be a headache) to integrate
  leading and trailing blocks into the CTR pass. Is this a win, loss, or
  no-op for hwaes, where block128_f is just fine? hwaes is the one mode
  we really should not regress.

Hopefully those will get answered as we continue to chip away at this.

Bug: 256
Change-Id: I8f0150b223b671e68f7da6faaff94a3bea398d4d
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35169
Reviewed-by: Adam Langley <agl@google.com>
2019-03-05 17:55:03 +00:00
David Benjamin da8bb847fd Tell ASan about the OPENSSL_malloc prefix.
OpenSSL's BN_mul function had a single-word buffer underflow (see
576129cd72ae054d246221f111aabf42b9c6d76d). We already independently
fixed this but, if we hadn't, ASan wouldn't have noticed because of
OPENSSL_malloc.

ASan has runtime hooks we can call to make it more accurate.

Change-Id: Ifc9c3837ece2bc456c5bdc960be707d7b1759904
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35165
Reviewed-by: Adam Langley <agl@google.com>
2019-03-05 17:53:16 +00:00
David Benjamin 8d685ec867 modes/asm/ghash-armv4.pl: address "infixes are deprecated" warnings.
This imports ce5eb5e8149d8d03660575f4b8504c993851988a and
1212818eb07add297fe562eba80ac46a9893781e from OpenSSL's 1.1.1 branch.

Change-Id: I121c0771371697191a163a28d972a7b3cee37762
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35164
Reviewed-by: Adam Langley <agl@google.com>
2019-03-05 17:52:28 +00:00
David Benjamin 55db667c62 Enable vpaes for aarch64, with CTR optimizations.
This patches vpaes-armv8.pl to add vpaes_ctr32_encrypt_blocks. CTR mode
is by far the most important mode these days. It should have access to
_vpaes_encrypt_2x, which gives a considerable speed boost. Also exclude
vpaes_ecb_* as they're not even used.

For iOS, this change is completely a no-op. iOS ARMv8 always has crypto
extensions, and we already statically drop all other AES
implementations.

Android ARMv8 is *not* required to have crypto extensions, but every
ARMv8 device I've seen has them. For those, it is a no-op
performance-wise and a win on size. vpaes appears to be about 5.6KiB
smaller than the tables. ARMv8 always makes SIMD (NEON) available, so we
can statically drop aes_nohw.

In theory, however, crypto-less Android ARMv8 is possible. Today such
chips get a variable-time AES. This CL fixes this, but the performance
story is complex.

The Raspberry Pi 3 is not Android but has a Cortex-A53 chip
without crypto extensions. (But the official images are 32-bit, so even
this is slightly artificial...) There, vpaes is a performance win.

Raspberry Pi 3, Model B+, Cortex-A53
Before:
Did 265000 AES-128-GCM (16 bytes) seal operations in 1003312us (264125.2 ops/sec): 4.2 MB/s
Did 44000 AES-128-GCM (256 bytes) seal operations in 1002141us (43906.0 ops/sec): 11.2 MB/s
Did 9394 AES-128-GCM (1350 bytes) seal operations in 1032104us (9101.8 ops/sec): 12.3 MB/s
Did 1562 AES-128-GCM (8192 bytes) seal operations in 1008982us (1548.1 ops/sec): 12.7 MB/s
After:
Did 277000 AES-128-GCM (16 bytes) seal operations in 1001884us (276479.1 ops/sec): 4.4 MB/s
Did 52000 AES-128-GCM (256 bytes) seal operations in 1001480us (51923.2 ops/sec): 13.3 MB/s
Did 11000 AES-128-GCM (1350 bytes) seal operations in 1007979us (10912.9 ops/sec): 14.7 MB/s
Did 2013 AES-128-GCM (8192 bytes) seal operations in 1085545us (1854.4 ops/sec): 15.2 MB/s

The Pixel 3 has a Cortex-A75 with crypto extensions, so it would never
run this code. However, artificially ignoring them gives another data
point (ARM documentation[*] suggests the extensions are still optional
on a Cortex-A75.) Sadly, vpaes no longer wins on perf over aes_nohw.
But, it is constant-time:

Pixel 3, AES/PMULL extensions ignored, Cortex-A75:
Before:
Did 2102000 AES-128-GCM (16 bytes) seal operations in 1000378us (2101205.7 ops/sec): 33.6 MB/s
Did 358000 AES-128-GCM (256 bytes) seal operations in 1002658us (357051.0 ops/sec): 91.4 MB/s
Did 75000 AES-128-GCM (1350 bytes) seal operations in 1012830us (74049.9 ops/sec): 100.0 MB/s
Did 13000 AES-128-GCM (8192 bytes) seal operations in 1036524us (12541.9 ops/sec): 102.7 MB/s
After:
Did 1453000 AES-128-GCM (16 bytes) seal operations in 1000213us (1452690.6 ops/sec): 23.2 MB/s
Did 285000 AES-128-GCM (256 bytes) seal operations in 1002227us (284366.7 ops/sec): 72.8 MB/s
Did 60000 AES-128-GCM (1350 bytes) seal operations in 1016106us (59049.0 ops/sec): 79.7 MB/s
Did 11000 AES-128-GCM (8192 bytes) seal operations in 1094184us (10053.2 ops/sec): 82.4 MB/s

Note the numbers above run with PMULL off, so the slow GHASH is
dampening the regression. If we test aes_nohw and vpaes paired with
PMULL on, the 20% perf hit becomes a 31% hit. The PMULL-less variant is
more likely to represent a real chip.

This is consistent with upstream's note in the comment, though it is
unclear if 20% is the right order of magnitude: "these results are worse
than scalar compiler-generated code, but it's constant-time and
therefore preferred".

[*] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.100458_0301_00_en/lau1442495529696.html

Bug: 246
Change-Id: If1dc87f5131fce742052498295476fbae4628dbf
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35026
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-03-04 20:31:39 +00:00
David Benjamin b1b4ff93ca Check in vpaes-armv8.pl from OpenSSL unused and unmodified.
This is done separately to make the diffs in the subsequent CL easier to
see. Imported from OpenSSL at revision
25ca718150cef41e1c1d9c2c8c58e2b1e2cad3fa.

Bug: 246
Change-Id: I9e7067ea177963fb9b77bf6fb39702ffe6e34ed4
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35025
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-03-04 20:23:09 +00:00
Jeremy Apthorp 1fa5abc0b4 silence unused variable warnings when using OPENSSL_clear_free
e.g. here: https://github.com/nodejs/node/blob/adbe3b837e8a2285238ec0fcba89c20882eb4cdb/src/node_crypto.cc#L3439

Change-Id: I2d43a3439d6a56c8eee3636b3c1f5ba615b233ba
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35144
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-03-04 19:55:29 +00:00
Jeremy Apthorp 19220dd6af Handle NULL public key in |EC_KEY_set_public_key|.
Node.js expects to be able to pass NULL to this function to clear the
current public key:
https://github.com/nodejs/node/blob/adbe3b837e8a2285238ec0fcba89c20882eb4cdb/src/node_crypto.cc#L5316

Change-Id: Id4e34d8e8b556c28000e4df12ff6f4432ad9220c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35124
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-03-04 19:45:29 +00:00
David Benjamin 5ce12e6436 Add a 32-bit SSSE3 GHASH implementation.
The 64-bit version can be fairly straightforwardly translated.

Ironically, this makes 32-bit x86 the first architecture to meet the
goal of constant-time AES-GCM given SIMD assembly. (Though x86_64 could
join by simply giving up on bsaes...)

Bug: 263
Change-Id: Icb2cec936457fac7132bbb5dbb094433bc14b86e
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/35024
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-03-04 19:02:52 +00:00
Robert Sloan ae1e08709f Also include abi_test.cc in ssl_test_files.
Change-Id: I1225f1623d4438a2ccaf482eddbe4f460cfaf78c
Reviewed-on: https://boringssl-review.googlesource.com/c/35104
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-03-02 04:15:28 +00:00
David Benjamin c3889634a1 Don't pull abi_test.cc into non-GTest targets.
The test_support is kind of a mess right now because it's sometimes used in
GTest targets and sometimes not. It really should be split into two libraries,
but do this for now to unbreak the Android build.

Change-Id: I7cd2b0f6ed9eda1a529ec3c69a92390e20da66f8
Reviewed-on: https://boringssl-review.googlesource.com/c/35084
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-03-01 20:24:27 +00:00
Alessandro Ghedini a6124742d0 Update *_set_cert_cb documentation regarding resumption
Since 34202b93b6 cert_cb is always called
before resumption is checked.

Change-Id: I27ca5653144027a1f545a90ecb6b68e64783a66a
Reviewed-on: https://boringssl-review.googlesource.com/c/35004
Reviewed-by: David Benjamin <davidben@google.com>
2019-02-27 17:26:07 +00:00
David Benjamin 1e0262ad87 Add a reference for Linux ARM ABI.
The Android NDK docs link to a ARM GNU/Linux Application Binary Interface
Supplement document. Also fix a type in trampoline-armv4.pl. The generic ARM
document is usually shortened AAPCS, not APCS.

I couldn't find a corresponding link for aarch64.

Change-Id: I6e5543f5c9e26955cd3945e9e7a5dcff27c2bd78
Reviewed-on: https://boringssl-review.googlesource.com/c/35064
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-02-27 17:18:02 +00:00
David Benjamin a57435e138 Remove __ARM_ARCH__ guard on gcm_*_v8.
OpenSSL's c1669e1c205dc8e695fb0c10a655f434e758b9f7 switched it to
__ARM_MAX_ARCH__, which we mirrored in assembly but not C. The C version
should be __ARM_MAX_ARCH__ to match. However, __ARM_MAX_ARCH__ is
hardcoded to 8, so just remove the check.

Change-Id: Ic873203db1478f49437b889b84ee7fb28eba1a6d
Reviewed-on: https://boringssl-review.googlesource.com/c/35045
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-02-27 02:26:21 +00:00
David Benjamin f1f73f8966 Fix bsaes-armv7.pl getting disabled by accident.
https://boringssl-review.googlesource.com/c/34188 accidentally disabled
it (__ARM_MAX_ARCH__ wasn't defined), which, in turn, masked a bug in
https://boringssl-review.googlesource.com/c/34874.

Remove the __ARM_MAX_ARCH__ check as that's hardcoded to 8 anyway. Then
revert the problematic part of the bsaes-armv7.pl change. That brings
back the somewhat questionable post-dispatch to pre-dispatch call, but I
hope to patch the fallbacks out soon anyway.

Change-Id: I567e55fe35cb716d5ed56580113a302617f5ad71
Reviewed-on: https://boringssl-review.googlesource.com/c/35044
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-02-27 02:06:21 +00:00
David Benjamin 6443173d03 Add an option to configure bssl speed chunk size.
bsaes, in its current incarnation, hits various pathological behaviors
at different input sizes. Make it easy to experiment around them.

Bug: 256
Change-Id: Ib6c6ca7d06a570dbf7d4d2ea81c1db0d94d3d0c4
Reviewed-on: https://boringssl-review.googlesource.com/c/34876
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-02-25 20:25:58 +00:00
David Benjamin 98ad4d77e3 Appease GCC's uninitialized value warning.
GCC notices that one function believes < 0 is the error while the other
believes it's != 0. unw_get_reg never returns positive, but match them.

Change-Id: I40af614e6b1400bf3d398bd32beb6d3ec702bc11
Reviewed-on: https://boringssl-review.googlesource.com/c/34985
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-02-22 23:56:14 +00:00
Adam Langley a367d9267f Set VPAES flags in x86-64 code.
The ImplDispatchTest was broken because the 64-bit VPAES code wasn't
setting the hit flags.

Change-Id: I30200db64337deba7ae9d70d8427decbdfceca58
Reviewed-on: https://boringssl-review.googlesource.com/c/34986
Reviewed-by: David Benjamin <davidben@google.com>
2019-02-22 23:41:50 +00:00
David Benjamin 65dc321492 Enable vpaes for AES_* functions.
This makes the AES_* functions meet our constant-time goals for
platforms where we have vpaes available. In particular, QUIC packet
number encryption needs single-block operations and those should have
vpaes available.

As a bonus, when vpaes is statically available, the aes_nohw_* functions
should be dropped by the linker. (Notably, NEON is guaranteed on
aarch64. Although vpaes-armv8.pl itself may take some more exploration.
https://crbug.com/boringssl/246#c4)

Bug: 263
Change-Id: Ie1c4727a166ec101a8453761757c87dadc188769
Reviewed-on: https://boringssl-review.googlesource.com/c/34875
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-02-22 23:09:19 +00:00
David Benjamin 3c19830f6f Avoid double-dispatch with AES_* vs aes_nohw_*.
In particular, consistently pair bsaes with aes_nohw.

Ideally the aes_nohw_* calls in bsaes-*.pl would be patched out and
bsaes grows its own constant-time key setup
(https://crbug.com/boringssl/256), but I'll sort that out separately. In
the meantime, avoid going through AES_* which now dispatch. This avoids
several nuisances:

1. If we were to add, say, a vpaes-armv7.pl the ABI tests would break.
   Fundamentally, we cannot assume that an AES_KEY has one and only one
   representation and must keep everything matching up.

2. AES_* functions should enable vpaes. This makes AES_* faster and
   constant-time for vector-capable CPUs
   (https://crbug.com/boringssl/263), relevant for QUIC packet number
   encryption, allowing us to add vpaes-armv8.pl
   (https://crbug.com/boringssl/246) without carrying a (likely) mostly
   unused AES implementation.

3. It's silly to double-dispatch when the EVP layer has already
   dispatched.

4. We should avoid asm calling into C. Otherwise, we need to test asm
   for ABI compliance as both caller and callee. Currently we only test
   it for callee compliance. When asm calls into asm, it *should* comply
   with the ABI as caller too, but mistakes don't matter as long as the
   called function triggers it. If the function is asm, this is fixed.
   If it is C, we must care about arbitrary C compiler output.

Bug: 263
Change-Id: Ic85af5c765fd57cbffeaf301c3872bad6c5bbf78
Reviewed-on: https://boringssl-review.googlesource.com/c/34874
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-02-22 22:51:51 +00:00
Kaustubha Govind c18353d214 Add uint64_t support in CBS and CBB.
We need these APIs to parse some Certificate Transparency structures.

Bug: chromium:634570
Change-Id: I4eb46058985a7369dc119ba6a1214913b237da39
Reviewed-on: https://boringssl-review.googlesource.com/c/34944
Reviewed-by: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-02-22 20:38:17 +00:00
David Benjamin f109f20873 Clear out a bunch of -Wextra-semi warnings.
Unfortunately, it's not enough to be able to turn it on thanks to the
PURE_VIRTUAL macro. But it gets us most of the way there.

Change-Id: Ie6ad5119fcfd420115fa49d7312f3586890244f4
Reviewed-on: https://boringssl-review.googlesource.com/c/34949
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-02-21 19:12:39 +00:00
Steven Valdez 0326105aa9 Add compiled python files to .gitignore.
Change-Id: If5d88d88bd1ea8189cc715cc38e70bd3b11c4b67
Reviewed-on: https://boringssl-review.googlesource.com/c/34950
Commit-Queue: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-02-21 17:41:59 +00:00
David Benjamin 24a18b8a40 Fix x86_64-xlate.pl comment regex.
This did not correctly capture lines like the following:

https://boringssl.googlesource.com/boringssl/+/refs/heads/master/crypto/chacha/asm/chacha-x86_64.pl#260
https://boringssl.googlesource.com/boringssl/+/refs/heads/master/crypto/fipsmodule/aes/asm/aes-x86_64.pl#992
https://boringssl.googlesource.com/boringssl/+/refs/heads/master/crypto/fipsmodule/aes/asm/aesni-x86_64.pl#641
https://boringssl.googlesource.com/boringssl/+/refs/heads/master/crypto/fipsmodule/aes/asm/bsaes-x86_64.pl#387
https://boringssl.googlesource.com/boringssl/+/refs/heads/master/crypto/fipsmodule/modes/asm/ghash-x86_64.pl#455
https://boringssl.googlesource.com/boringssl/+/refs/heads/master/crypto/fipsmodule/ec/asm/p256-x86_64-asm.pl#92

Reportedly that last one causes problems with some assemblers.

Change-Id: I82d6f0d81b902e48fad3c45947f84f02370eb1ab
Reviewed-on: https://boringssl-review.googlesource.com/c/34925
Reviewed-by: Adam Langley <agl@google.com>
2019-02-21 16:50:17 +00:00
David Benjamin 1908667015 Add go 1.11 to go.mod.
Go 1.12 really wants to record a version in go.mod if there is no
version in there. 1.12 is not yet released, so stick 1.11 in there for
now. We'll bump it to 1.12 and so on as we update our minimum versions.

Change-Id: I79ac85837149ab7cadd2f23acd8ab2d207a1a355
Reviewed-on: https://boringssl-review.googlesource.com/c/34924
Reviewed-by: Adam Langley <agl@google.com>
2019-02-21 16:42:44 +00:00
David Benjamin 104306f587 Remove STRICT_ALIGNMENT code from modes.
STRICT_ALIGNMENT is a remnant of OpenSSL code would cast pointers to
size_t* and load more than one byte at a time. Not all architectures
support unaligned access, so it did an alignment check and only enterred
this path if aligned or the underlying architecture didn't care.

This is UB. Unaligned casts in C are undefined on all architectures, so
we switch these to memcpy some time ago. Compilers can optimize memcpy
to the unaligned accesses we wanted. That left our modes logic as:

- If STRICT_ALIGNMENT is 1 and things are unaligned, work byte-by-byte.

- Otherwise, use the memcpy-based word-by-word code, which now works
  independent of STRICT_ALIGNMENT.

Remove the first check to simplify things. On x86, x86_64, and aarch64,
STRICT_ALIGNMENT is zero and this is a no-op. ARM is more complex. Per
[0], ARMv7 and up support unaligned access. ARMv5 do not. ARMv6 does,
but can run in a mode where it looks more like ARMv5.

For ARMv7 and up, STRICT_ALIGNMENT should have been zero, but was one.
Thus this change should be an improvement for ARMv7 (right now unaligned
inputs lose bsaes-armv7). The Android NDK does not even support the
pre-ARMv7 ABI anymore[1]. Nonetheless, Cronet still supports ARMv6 as a
library. It builds with -march=armv6 which GCC interprets as supporting
unaligned access, so it too did not want this code.

For completeness, should anyone still care about ARMv5 or be building
with an overly permissive -march flag, GCC does appear unable to inline
the memcpy calls. However, GCC also does not interpret
(uintptr_t)ptr % sizeof(size_t) as an alignment assertion, so such
consumers have already been paying for the memcpy here and throughout
the library.

In general, C's arcane pointer rules mean we must resort to memcpy
often, so, realistically, we must require that the compiler optimize
memcpy well.

[0] https://medium.com/@iLevex/the-curious-case-of-unaligned-access-on-arm-5dd0ebe24965
[1] https://developer.android.com/ndk/guides/abis#armeabi

Change-Id: I3c7dea562adaeb663032e395499e69530dd8e145
Reviewed-on: https://boringssl-review.googlesource.com/c/34873
Reviewed-by: Adam Langley <agl@google.com>
2019-02-14 17:39:36 +00:00
David Benjamin d8598ce03f Remove non-STRICT_ALIGNMENT code from xts.c.
Independent of the underlying CPU architecture, casting unaligned
pointers to uint64_t* is undefined. Just use a memcpy. The compiler
should be able to optimize that itself.

Change-Id: I39210871fca3eaf1f4b1d205b2bb0c337116d9cc
Reviewed-on: https://boringssl-review.googlesource.com/c/34872
Reviewed-by: Adam Langley <agl@google.com>
2019-02-14 17:32:11 +00:00
David Benjamin 4d8e1ce5e9 Patch XTS out of ARMv7 bsaes too.
Bug: 256
Change-Id: I822274bf05901d82b41dc9c9c4e6d0b5d622f3ff
Reviewed-on: https://boringssl-review.googlesource.com/c/34871
Reviewed-by: Adam Langley <agl@google.com>
2019-02-14 17:31:37 +00:00
David Benjamin fb35b147ca Remove stray prototype.
The function's since been renamed.

Change-Id: Id1a9788dfeb5c46b3463611b08318b3f253d03df
Reviewed-on: https://boringssl-review.googlesource.com/c/34870
Reviewed-by: Adam Langley <agl@google.com>
2019-02-14 17:31:14 +00:00
David Benjamin eb2c2cdf17 Always define GHASH.
There is a C implementation of gcm_ghash_4bit to pair with
gcm_gmult_4bit. It's even slightly faster per the numbers below (x86_64
OPENSSL_NO_ASM build), but, more importantly, we trim down the
combinatorial explosion of GCM implementations and free up complexity
budget for potentially using bsaes better in the future.

Old:
Did 2557000 AES-128-GCM (16 bytes) seal operations in 1000057us (2556854.3 ops/sec): 40.9 MB/s
Did 94000 AES-128-GCM (1350 bytes) seal operations in 1009613us (93105.0 ops/sec): 125.7 MB/s
Did 17000 AES-128-GCM (8192 bytes) seal operations in 1024768us (16589.1 ops/sec): 135.9 MB/s
Did 2511000 AES-256-GCM (16 bytes) seal operations in 1000196us (2510507.9 ops/sec): 40.2 MB/s
Did 84000 AES-256-GCM (1350 bytes) seal operations in 1000412us (83965.4 ops/sec): 113.4 MB/s
Did 15000 AES-256-GCM (8192 bytes) seal operations in 1046963us (14327.2 ops/sec): 117.4 MB/s

New:
Did 2739000 AES-128-GCM (16 bytes) seal operations in 1000322us (2738118.3 ops/sec): 43.8 MB/s
Did 100000 AES-128-GCM (1350 bytes) seal operations in 1008190us (99187.7 ops/sec): 133.9 MB/s
Did 17000 AES-128-GCM (8192 bytes) seal operations in 1006360us (16892.6 ops/sec): 138.4 MB/s
Did 2546000 AES-256-GCM (16 bytes) seal operations in 1000150us (2545618.2 ops/sec): 40.7 MB/s
Did 86000 AES-256-GCM (1350 bytes) seal operations in 1000970us (85916.7 ops/sec): 116.0 MB/s
Did 14850 AES-256-GCM (8192 bytes) seal operations in 1023459us (14509.6 ops/sec): 118.9 MB/s

While I'm here, tighten up some of the functions and align the ctr32 and
non-ctr32 paths.

Bug: 256
Change-Id: Id4df699cefc8630dd5a350d44f927900340f5e60
Reviewed-on: https://boringssl-review.googlesource.com/c/34869
Reviewed-by: Adam Langley <agl@google.com>
2019-02-14 17:30:55 +00:00
Watson Ladd 2f213f643f Update delegated credentials to draft-03
Change-Id: I0c648340ac7bb134fcda42c56a83f4815bbaa557
Reviewed-on: https://boringssl-review.googlesource.com/c/34884
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-02-13 20:04:33 +00:00
David Benjamin b22c9fea47 Use Windows symbol APIs in the unwind tester.
This should make things a bit easier to debug.

Update-Note: Test binaries on Windows now link to dbghelp.
Bug: 259
Change-Id: I9da1fc89d429080c5250238e4341445922b1dd8e
Reviewed-on: https://boringssl-review.googlesource.com/c/34868
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-02-12 20:42:47 +00:00
David Benjamin 2e819d8be4 Unwind RDRAND functions correctly on Windows.
But for the ABI conversion bits, these are just leaf functions and don't
even need unwind tables. Just renumber the registers on Windows to only
used volatile ones.

In doing so, this switches to writing rdrand explicitly. perlasm already
knows how to manually encode it and our minimum assembler versions
surely cover rdrand by now anyway. Also add the .size directive. I'm not
sure what it's used for, but the other files have it.

(This isn't a generally reusable technique. The more complex functions
will need actual unwind codes.)

Bug: 259
Change-Id: I1d5669bcf8b6e34939885d78aea6f60597be1528
Reviewed-on: https://boringssl-review.googlesource.com/c/34867
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-02-12 20:24:27 +00:00
David Benjamin 15ba2d11a9 Patch out unused aesni-x86_64 functions.
This shrinks the bssl binary by about 8k.

Change-Id: I571f258ccf7032ae34db3f20904ad9cc81cca839
Reviewed-on: https://boringssl-review.googlesource.com/c/34866
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-02-11 20:25:22 +00:00
David Benjamin cc2b8e2552 Add ABI tests for aesni-gcm-x86_64.pl.
Change-Id: Ic23fc5fbec2c4f8df5d06f807c6bd2c5e1f0e99c
Reviewed-on: https://boringssl-review.googlesource.com/c/34865
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-02-11 20:08:38 +00:00
David Benjamin 7a3b94cd2c Add ABI tests for x86_64-mont5.pl.
Fix some missing CFI bits.

Change-Id: I42114527f0ef8e03079d37a9f466d64a63a313f5
Reviewed-on: https://boringssl-review.googlesource.com/c/34864
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-02-11 19:27:13 +00:00
Jeremy Apthorp 7ef4223fb3 sync EVP_get_cipherbyname with EVP_do_all_sorted
EVP_get_cipherbyname should work on everything that EVP_do_all_sorted
lists, and conversely, there should be nothing that
EVP_get_cipherbyname works on that EVP_do_all_sorted doesn't list.

node.js uses these APIs to enumerate and instantiate ciphers.

Change-Id: I87fcedce62d06774f7c6ee7acc898326276be089
Reviewed-on: https://boringssl-review.googlesource.com/c/33984
Reviewed-by: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-02-11 17:20:23 +00:00
Katrin Leinweber d2a0ffdfa7 Hyperlink DOI to preferred resolver
Change-Id: Ib9983a74d5d2f8be7c96cedde17be5a4e9223d5e
Reviewed-on: https://boringssl-review.googlesource.com/c/34844
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-02-08 19:20:05 +00:00
David Benjamin a6c689e0da Remove stray semicolons.
Thanks to Nico Weber for pointing this out.

Change-Id: I763fd4a6f8fe467a027d5b249d9f76633ab4375a
Reviewed-on: https://boringssl-review.googlesource.com/c/34824
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2019-02-07 17:36:54 +00:00
Adam Langley 2d38b83976 Remove separate default group list for servers.
It's the same as for clients, and we're probably not going to change
that any time soon.

Change-Id: Ic48cb640e98b0957d264267b97b5393f1977c6e6
Reviewed-on: https://boringssl-review.googlesource.com/c/34665
Reviewed-by: David Benjamin <davidben@google.com>
2019-02-06 00:33:29 +00:00
Adam Langley fcc1ad78f9 Enable all curves (inc CECPQ2) during fuzzing.
Change-Id: I8083e841de135e9ec244609b1c20f0280ce20072
Reviewed-on: https://boringssl-review.googlesource.com/c/34664
Reviewed-by: David Benjamin <davidben@google.com>
2019-02-06 00:32:45 +00:00
David Benjamin 70fe610556 Implement ABI testing for aarch64.
This caught a bug in bn_mul_mont. Tested manually on iOS and Android.

Change-Id: I1819fcd9ad34dbe3ba92bba952507d86dd12185a
Reviewed-on: https://boringssl-review.googlesource.com/c/34805
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-02-05 21:44:04 +00:00
David Benjamin 55b9acda99 Fix ABI error in bn_mul_mont on aarch64.
This was caught by an aarch64 ABI tester. aarch64 has the same
considerations around small arguments as x86_64 does. The aarch64
version of bn_mul_mont does not mask off the upper words of the
argument.

The x86_64 version does, so size_t is, strictly speaking, wrong for
aarch64, but bn_mul_mont already has an implicit size limit to support
its internal alloca, so this doesn't really make things worse than
before.

Change-Id: I39bffc8fdb2287e45a2d1f0d1b4bd5532bbf3868
Reviewed-on: https://boringssl-review.googlesource.com/c/34804
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-02-05 21:17:54 +00:00
David Benjamin 0a87c4982c Implement ABI testing for ARM.
Update-Note: There's some chance this'll break iOS since I was unable to
test it there. The iPad I have to test on is too new to run 32-bit code
at all.

Change-Id: I6593f91b67a5e8a82828237d3b69ed948b07922d
Reviewed-on: https://boringssl-review.googlesource.com/c/34725
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-02-05 21:01:44 +00:00
David Benjamin 0a67eba62d Fix the order of Windows unwind codes.
The unwind tester suggests Windows doesn't care, but the documentation
says that unwind codes should be sorted in descending offset, which
means the last instruction should be first.

https://docs.microsoft.com/en-us/cpp/build/exception-handling-x64?view=vs-2017#struct-unwind_code

Bug: 259
Change-Id: I21e54c362e18e0405f980005112cc3f7c417c70c
Reviewed-on: https://boringssl-review.googlesource.com/c/34785
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-02-05 19:38:23 +00:00
David Benjamin 28f035f48b Implement unwind testing for Windows.
Unfortunately, due to most OpenSSL assembly using custom exception
handlers to unwind, most of our assembly doesn't work with
non-destructive unwind. For now, CHECK_ABI behaves like
CHECK_ABI_NO_UNWIND on Windows, and CHECK_ABI_SEH will test unwinding on
both platforms.

The tests do, however, work with the unwind-code-based assembly we
recently added, as well as the clmul-based GHASH which is also
code-based. Remove the ad-hoc SEH tests which intentionally hit memory
access exceptions, now that we can test unwind directly.

Now that we can test it, the next step is to implement SEH directives in
perlasm so writing these unwind codes is less of a chore.

Bug: 259
Change-Id: I23a57a22c5dc9fa4513f575f18192335779678a5
Reviewed-on: https://boringssl-review.googlesource.com/c/34784
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-02-05 19:22:15 +00:00
David Benjamin fc31677a1d Tolerate spaces when parsing .type directives.
The .type foo, @abi-omnipotent lines weren't being parsed correctly.
This doesn't change the generated files, but some internal state (used
in-progress work on perlasm SEH directives) wasn't quite right.

Change-Id: Id6aec79281a59f45b2eb2aea9f1fb8806b4c483e
Reviewed-on: https://boringssl-review.googlesource.com/c/34786
Reviewed-by: Adam Langley <agl@google.com>
2019-02-05 15:47:26 +00:00
David Benjamin 20a9b409bb runner: Don't generate an RSA key on startup.
RSA keygen isn't the fastest. Just use the existing one in
rsaCertificate.

Change-Id: Icd151232928e67e0a7d5becabf9dc96b0e9bfa22
Reviewed-on: https://boringssl-review.googlesource.com/c/34764
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2019-02-04 16:08:41 +00:00
David Benjamin 33f456b8b0 Don't use bsaes over vpaes for CTR-DRBG.
RAND_bytes rarely uses large enough inputs for bsaes to be worth it.
https://boringssl-review.googlesource.com/c/boringssl/+/33589 includes some
rough benchmarks of various bits here. Some observations:

- 8 blocks of bsaes costs roughly 6.5 blocks of vpaes. Note the comparison
  isn't quite accurate because I'm measuring bsaes_ctr32_encrypt_blocks against
  vpaes_encrypt and vpaes in CTR mode today must make do with a C loop. Even
  assuming a cutoff of 6 rather than 7 blocks, it's rare to ask for 96 bytes
  of entropy at a time.

- CTR-DRBG performs some stray block operations (ctr_drbg_update), which bsaes
  is bad at without extra work to fold them into the CTR loop (not really worth
  it).

- CTR-DRBG calculates a couple new key schedules every RAND_bytes call. We
  don't currently have a constant-time bsaes key schedule. Unfortunately, even
  plain vpaes loses to the current aes_nohw used by bsaes, but it's not
  constant-time. Also taking CTR-DRBG out of the bsaes equation

- Machines without AES hardware (clients) are not going to be RNG-bound. It's
  mostly servers pushing way too many CBC IVs that care. This means bsaes's
  current side channel tradeoffs make even less sense here.

I'm not sure yet what we should do for the rest of the bsaes mess, but it seems
clear that we want to stick with vpaes for the RNG.

Bug: 256
Change-Id: Iec8f13af232794afd007cb1065913e8117eeee24
Reviewed-on: https://boringssl-review.googlesource.com/c/34744
Reviewed-by: Adam Langley <agl@google.com>
2019-02-01 18:03:39 +00:00
David Benjamin 470bd56c9b perlasm/x86_64-xlate.pl: refine symbol recognition in .xdata.
Hexadecimals were erroneously recognized as symbols in .xdata.

(Imported from upstream's b068a9b914887af5cc99895754412582fbb0e10b)

Change-Id: I5d8e8e1969669a8961733802d9f034cf26c45552
Reviewed-on: https://boringssl-review.googlesource.com/c/34704
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-02-01 18:02:44 +00:00
David Benjamin 9978f0a865 Add instructions for debugging on Android with gdb.
Android's official documentation seems to assume you're using the NDK
build system or Android Studio. I extracted this from one of their
scripts a while back. May as well put it somewhere we can easily find
it.

Change-Id: I259abc54e6935ab537956a7cbf9f80e924a60b7a
Reviewed-on: https://boringssl-review.googlesource.com/c/34724
Reviewed-by: Adam Langley <agl@google.com>
2019-02-01 02:51:11 +00:00
Jesse Selover d7266ecc9b Enforce key usage for RSA keys in TLS 1.2.
For now, this is off by default and controlled by SSL_set_enforce_rsa_key_usage.
This may be set as late as certificate verification so we may start by enforcing
it for known roots.

Generalizes ssl_cert_check_digital_signature_key_usage to check any part of the
key_usage, and adds a new error KEY_USAGE_BIT_INCORRECT for the generalized
method.

Bug: chromium:795089
Change-Id: Ifa504c321bec3263a4e74f2dc48513e3b895d3ee
Reviewed-on: https://boringssl-review.googlesource.com/c/34604
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-01-30 21:28:34 +00:00
David Benjamin 1a51a5b4a6 Remove infra/config folder in master branch.
As of https://boringssl-review.googlesource.com/c/34584, the LUCI config
has been consolidated on the infra/config branch.

Change-Id: Idd9f38b99197b9ff324d98c4aecb5d8fe94a2f9e
Reviewed-on: https://boringssl-review.googlesource.com/c/34684
Reviewed-by: Andrii Shyshkalov <tandrii@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-01-30 00:21:43 +00:00
Filippo Valsorda 73308b6606 Avoid SCT/OCSP extensions in SH on {Omit|Empty}Extensions
They were causing a "panic: ServerHello unexpectedly contained extensions"
if the client unconditionally signals support for OCSP or SCTs.

Change-Id: Ia60639431daf78679b269dfe337c1af171fd7d8b
Reviewed-on: https://boringssl-review.googlesource.com/c/34644
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-01-29 00:51:31 +00:00
David Benjamin 23e1a1f2d3 Test and fix an ABI issue with small parameters.
Calling conventions must specify how to handle arguments smaller than a
machine word. Should the caller pad them up to a machine word size with
predictable values (zero/sign-extended), or should the callee tolerate
an arbitrary bit pattern?

Annoyingly, I found no text in either SysV or Win64 ABI documentation
describing any of this and resorted to experiment. The short answer is
that callees must tolerate an arbitrary bit pattern on x86_64, which
means we must test this. See the comment in abi_test::internal::ToWord
for the long answer.

CHECK_ABI now, if the type of the parameter is smaller than
crypto_word_t, fills the remaining bytes with 0xaa. This is so the
number is out of bounds for code expecting either zero or sign
extension. (Not that crypto assembly has any business seeing negative
numbers.)

Doing so reveals a bug in ecp_nistz256_ord_sqr_mont. The rep parameter
is typed int, but the code expected uint64_t. In practice, the compiler
will always compile this correctly because:

- On both Win64 and SysV, rep is a register parameter.

- The rep parameter is always a constant, so the compiler has no reason
  to leave garbage in the upper half.

However, I was indeed able to get a bug out of GCC via:

  uint64_t foo = (1ull << 63) | 2;  // Some global the compiler can't
                                    // prove constant.
  ecp_nistz256_ord_sqr_mont(res, a, foo >> 1);

Were ecp_nistz256_ord_sqr_mont a true int-taking function, this would
act like ecp_nistz256_ord_sqr_mont(res, a, 1). Instead, it hung. Fix
this by having it take a full-width word.

This mess has several consequences:

- ABI testing now ideally needs a functional testing component to fully cover
  this case. A bad input might merely produce the wrong answer. Still,
  this is fairly effective as it will cause most code to either segfault
  or loop forever. (Not the enc parameter to AES however...)

- We cannot freely change the type of assembly function prototypes. If the
  prototype says int or unsigned, it must be ignoring the upper half and
  thus "fixing" it to size_t cannot have handled the full range. (Unless
  it was simply wrong of the parameter is already bounded.) If the
  prototype says size_t, switching to int or unsigned will hit this type
  of bug. The former is a safer failure mode though.

- The simplest path out of this mess: new assembly code should *only*
  ever take word-sized parameters. This is not a tall order as the bad
  parameters are usually ints that should have been size_t.

Calling conventions are hard.

Change-Id: If8254aff8953844679fbce4bd3e345e5e2fa5213
Reviewed-on: https://boringssl-review.googlesource.com/c/34627
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-01-28 21:09:40 +00:00
David Benjamin ab578adf44 Add RSAZ ABI tests.
As part of this, move the CPU checks to C.

Change-Id: I17b701e1196c1ca116bbd23e0e669cf603ad464d
Reviewed-on: https://boringssl-review.googlesource.com/c/34626
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-01-28 21:00:49 +00:00
David Benjamin 3859fc883d Better document RSAZ and tidy up types.
It's an assembly function, so types are a little meaningless, but
everything is passed through as BN_ULONG, so be consistent. Also
annotate all the RSAZ prototypes with sizes.

Change-Id: I32e59e896da39e79c30ce9db52652fd645a033b4
Reviewed-on: https://boringssl-review.googlesource.com/c/34625
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-01-28 20:54:27 +00:00
David Benjamin e569c7e25d Add ABI testing for 32-bit x86.
This is much less interesting (stack-based parameters, Windows and SysV
match, no SEH concerns as far as I can tell) than x86_64, but it was
easy to do and I'm more familiar with x86 than ARM, so it made a better
second architecture to make sure all the architecture ifdefs worked out.

Also fix a bug in the x86_64 direction flag code. It was shifting in the
wrong direction, making give 0 or 1<<20 rather than 0 or 1.

(Happily, x86_64 appears to be unique in having vastly different calling
conventions between OSs. x86 is the same between SysV and Windows, and
ARM had the good sense to specify a (mostly) common set of rules.)

Since a lot of the assembly functions use the same names and the tests
were written generically, merely dropping in a trampoline and
CallerState implementation gives us a bunch of ABI tests for free.

Change-Id: I15408c18d43e88cfa1c5c0634a8b268a150ed961
Reviewed-on: https://boringssl-review.googlesource.com/c/34624
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-01-28 20:40:06 +00:00
David Benjamin 8cbb5f8f20 Add a very roundabout EC keygen API.
OpenSSL's EVP-level EC API involves a separate "paramgen" operation,
which is ultimately just a roundabout way to go from a NID to an
EC_GROUP. But Node uses this, and it's the pattern used within OpenSSL
these days, so this appears to be the official upstream recommendation.

Also add a #define for OPENSSL_EC_EXPLICIT_CURVE, because Node uses it,
but fail attempts to use it. Explicit curve encodings are forbidden by
RFC 5480 and generally a bad idea. (Parsing such keys back into OpenSSL
will cause it to lose the optimized path.)

Change-Id: I5e97080e77cf90fc149f6cf6f2cc4900f573fc64
Reviewed-on: https://boringssl-review.googlesource.com/c/34565
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-01-25 23:08:12 +00:00
David Benjamin 23dcf88e18 Add some Node compatibility functions.
This doesn't cover all the functions used by Node, but it's the easy
bits. (EVP_PKEY_paramgen will be done separately as its a non-trivial
bit of machinery.)

Change-Id: I6501e99f9239ffcdcc57b961ebe85d0ad3965549
Reviewed-on: https://boringssl-review.googlesource.com/c/34544
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-01-25 16:50:30 +00:00
Christopher Patton 6c1b376e1d Implement server support for delegated credentials.
This implements the server-side of delegated credentials, a proposed
extension for TLS:
https://tools.ietf.org/html/draft-ietf-tls-subcerts-02

Change-Id: I6a29cf1ead87b90aeca225335063aaf190a417ff
Reviewed-on: https://boringssl-review.googlesource.com/c/33666
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-01-24 20:06:58 +00:00
David Benjamin 4545503926 Add a constant-time pshufb-based GHASH implementation.
We currently require clmul instructions for constant-time GHASH
on x86_64. Otherwise, it falls back to a variable-time 4-bit table
implementation. However, a significant proportion of clients lack these
instructions.

Inspired by vpaes, we can use pshufb and a slightly different order of
incorporating the bits to make a constant-time GHASH. This requires
SSSE3, which is very common. Benchmarking old machines we had on hand,
it appears to be a no-op on Sandy Bridge and a small slowdown for
Penryn.

Sandy Bridge (Intel Pentium CPU 987 @ 1.50GHz):
(Note: these numbers are before 16-byte-aligning the table. That was an
improvement on Penryn, so it's possible Sandy Bridge is now better.)
Before:
Did 4244750 AES-128-GCM (16 bytes) seal operations in 4015000us (1057222.9 ops/sec): 16.9 MB/s
Did 442000 AES-128-GCM (1350 bytes) seal operations in 4016000us (110059.8 ops/sec): 148.6 MB/s
Did 84000 AES-128-GCM (8192 bytes) seal operations in 4015000us (20921.5 ops/sec): 171.4 MB/s
Did 3349250 AES-256-GCM (16 bytes) seal operations in 4016000us (833976.6 ops/sec): 13.3 MB/s
Did 343500 AES-256-GCM (1350 bytes) seal operations in 4016000us (85532.9 ops/sec): 115.5 MB/s
Did 65250 AES-256-GCM (8192 bytes) seal operations in 4015000us (16251.6 ops/sec): 133.1 MB/s
After:
Did 4229250 AES-128-GCM (16 bytes) seal operations in 4016000us (1053100.1 ops/sec): 16.8 MB/s [-0.4%]
Did 442250 AES-128-GCM (1350 bytes) seal operations in 4016000us (110122.0 ops/sec): 148.7 MB/s [+0.1%]
Did 83500 AES-128-GCM (8192 bytes) seal operations in 4015000us (20797.0 ops/sec): 170.4 MB/s [-0.6%]
Did 3286500 AES-256-GCM (16 bytes) seal operations in 4016000us (818351.6 ops/sec): 13.1 MB/s [-1.9%]
Did 342750 AES-256-GCM (1350 bytes) seal operations in 4015000us (85367.4 ops/sec): 115.2 MB/s [-0.2%]
Did 65250 AES-256-GCM (8192 bytes) seal operations in 4016000us (16247.5 ops/sec): 133.1 MB/s [-0.0%]

Penryn (Intel Core 2 Duo CPU P8600 @ 2.40GHz):
Before:
Did 1179000 AES-128-GCM (16 bytes) seal operations in 1000139us (1178836.1 ops/sec): 18.9 MB/s
Did 97000 AES-128-GCM (1350 bytes) seal operations in 1006347us (96388.2 ops/sec): 130.1 MB/s
Did 18000 AES-128-GCM (8192 bytes) seal operations in 1028943us (17493.7 ops/sec): 143.3 MB/s
Did 977000 AES-256-GCM (16 bytes) seal operations in 1000197us (976807.6 ops/sec): 15.6 MB/s
Did 82000 AES-256-GCM (1350 bytes) seal operations in 1012434us (80992.9 ops/sec): 109.3 MB/s
Did 15000 AES-256-GCM (8192 bytes) seal operations in 1006528us (14902.7 ops/sec): 122.1 MB/s
After:
Did 1306000 AES-128-GCM (16 bytes) seal operations in 1000153us (1305800.2 ops/sec): 20.9 MB/s [+10.8%]
Did 94000 AES-128-GCM (1350 bytes) seal operations in 1009852us (93082.9 ops/sec): 125.7 MB/s [-3.4%]
Did 17000 AES-128-GCM (8192 bytes) seal operations in 1012096us (16796.8 ops/sec): 137.6 MB/s [-4.0%]
Did 1070000 AES-256-GCM (16 bytes) seal operations in 1000929us (1069006.9 ops/sec): 17.1 MB/s [+9.4%]
Did 79000 AES-256-GCM (1350 bytes) seal operations in 1002209us (78825.9 ops/sec): 106.4 MB/s [-2.7%]
Did 15000 AES-256-GCM (8192 bytes) seal operations in 1061489us (14131.1 ops/sec): 115.8 MB/s [-5.2%]

Change-Id: I1c3760a77af7bee4aee3745d1c648d9e34594afb
Reviewed-on: https://boringssl-review.googlesource.com/c/34267
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-01-24 17:19:21 +00:00
Adam Langley 9801a07145 Tweak some slightly fragile tests.
These tests failed when CECPQ2 was enabled by default. Even if we're
not going to make CECPQ2 the default, it's worth fixing them to be more
robust.

Change-Id: Idef508bca9e17a4ef0e0a8a396755abd975f9908
Reviewed-on: https://boringssl-review.googlesource.com/c/34524
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-01-23 22:48:16 +00:00
Adam Langley 4bfab5d9d7 Make 256-bit ciphers a preference for CECPQ2, not a requirement.
If 256-bit ciphers are a requirement for CECPQ2 then that introduces a
link between supported ciphers and supported groups: offering CECPQ2
without a 256-bit cipher is invalid. But that's a little weird since
these things were otherwise independent.

So, rather than require a 256-bit cipher for CECPQ2, just prefer them.

Change-Id: I491749e41708cd9c5eeed5b4ae23c11e5c0b9725
Reviewed-on: https://boringssl-review.googlesource.com/c/34504
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-01-23 22:38:56 +00:00
David Benjamin fa81cc65dd Update comments around JDK11 workaround.
11.0.2 has since been released, but we are now aware of several more
bugs, so the workaround is unlikely to be removable for the foreseeable
future.

Change-Id: I8e7edcba2f002d0558a21e607306ddf9a205bfb3
Reviewed-on: https://boringssl-review.googlesource.com/c/34484
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-01-23 20:00:38 +00:00
David Benjamin c47f7936d0 Add a RelWithAsserts build configuration.
On our bots, debug unit tests take around 2.5x as long to complete as
release tests on Linux, 3x as long on macOS, and 6x as long on Windows.
Our tests are fast, so this does not particularly matter, but SDE
inflates a 13 second test run to 8 minutes. On Windows (MSVC), where we
don't but would like to test with SDE, the difference between optimized
and unoptimized is even larger, and test runs are slower in general.

This suggests running SDE tests in release mode. Release mode tests,
however, are less effective because they do not include asserts. Thus,
add a RelWithAsserts option.

(Chromium does something similar. I believe most of the test-running
configurations on the critical path run is_debug = false and
dcheck_always_on = true.)

Change-Id: I273dd86ab8ea039f34eca431483827c87dc5c461
Reviewed-on: https://boringssl-review.googlesource.com/c/34464
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-01-23 17:21:56 +00:00
Adam Langley 51011b4a26 Remove union from |SHA512_CTX|.
With 2fe0360a4e, we no longer use the
other member of this union so it can be removed.

Change-Id: Ideb7c47a72df0b420eb1e7d8c718e1cacb2129f5
Reviewed-on: https://boringssl-review.googlesource.com/c/34449
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-01-22 23:36:46 +00:00
David Benjamin 4f3f597d32 Avoid unwind tests on libc functions.
When built under UBSan, it gets confused inside a PLT stub.

Change-Id: Ib082ecc076ba2111337ff5921e465e4beb99aab5
Reviewed-on: https://boringssl-review.googlesource.com/c/34448
Reviewed-by: Adam Langley <agl@google.com>
2019-01-22 23:29:24 +00:00
David Benjamin 14c611cf91 Don't pass NULL,0 to qsort.
qsort shares the same C language bug as mem*. Two of our calls may see
zero-length lists. This trips UBSan.

Change-Id: Id292dd277129881001eb57b1b2db78438cf4642e
Reviewed-on: https://boringssl-review.googlesource.com/c/34447
Reviewed-by: Adam Langley <agl@google.com>
2019-01-22 23:28:38 +00:00
David Benjamin 9847cdd785 Fix signed left-shifts in curve25519.c.
Due to a language flaw in C, left-shifts on signed integers are
undefined for negative numbers. This makes them all but useless. Cast to
the unsigned type, left-shift, and cast back (casts are defined to wrap)
to silence UBSan.

Change-Id: I8fbe739aee1c99cf553462b675863e6d68c2b302
Reviewed-on: https://boringssl-review.googlesource.com/c/34446
Reviewed-by: Adam Langley <agl@google.com>
2019-01-22 23:27:34 +00:00
David Benjamin fc27a1919c Add an option to build with UBSan.
Change-Id: I31d5660fa4792bbb1ef8a721bad4bdbdb0e56863
Reviewed-on: https://boringssl-review.googlesource.com/c/34445
Reviewed-by: Adam Langley <agl@google.com>
2019-01-22 23:26:35 +00:00
David Benjamin 2fe0360a4e Fix undefined pointer casts in SHA-512 code.
Casting an unaligned pointer to uint64_t* is undefined, even on
platforms that support unaligned access. Additionally, dereferencing as
uint64_t violates strict aliasing rules. Instead, use memcpys which we
assume any sensible compiler can optimize. Also simplify the PULL64
business with the existing CRYPTO_bswap8.

This also removes the need for the
SHA512_BLOCK_CAN_MANAGE_UNALIGNED_DATA logic. The generic C code now
handles unaligned data and the assembly already can as well. (The only
problematic platform with assembly is old ARM, but sha512-armv4.pl
already handles this via an __ARM_ARCH__ check.  See also OpenSSL's
version of this file which always defines
SHA512_BLOCK_CAN_MANAGE_UNALIGNED_DATA if SHA512_ASM is defined.)

Add unaligned tests to digest_test.cc, so we retain coverage of
unaligned EVP_MD inputs.

Change-Id: Idfd8586c64bab2a77292af2fa8eebbd193e57c7d
Reviewed-on: https://boringssl-review.googlesource.com/c/34444
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-01-22 23:18:36 +00:00
Adam Langley 72f015562c HRSS: flatten sample distribution.
With HRSS-SXY, the sampling algorithm now longer has to be the same
between the two parties. Therefore we can change it at will (as long as
it remains reasonably uniform) and thus take the opportunity to make the
output distribution flatter.

Change-Id: I74c667fcf919fe11ddcf2f4fb8a540b5112268bf
Reviewed-on: https://boringssl-review.googlesource.com/c/34404
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-01-22 22:06:43 +00:00
Adam Langley c1615719ce Add test of assembly code dispatch.
The first attempt involved using Linux's support for hardware
breakpoints to detect when assembly code was run. However, this doesn't
work with SDE, which is a problem.

This version has the assembly code update a global flags variable when
it's run, but only in non-FIPS and non-debug builds.

Update-Note: Assembly files now pay attention to the NDEBUG preprocessor
symbol. Ensure the build passes the symbol in. (If release builds fail
to link due to missing BORINGSSL_function_hit, this is the cause.)

Change-Id: I6b7ced442b7a77d0b4ae148b00c351f68af89a6e
Reviewed-on: https://boringssl-review.googlesource.com/c/33384
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-01-22 20:22:53 +00:00
Adam Langley eadef4730e Simplify HRSS mod3 circuits.
The multiplication and subtraction circuits were found by djb using GNU
Superoptimizer, and the addition circuit is derived from the subtraction
one by hand. They depend on a different representation: -1 is now (1, 1)
rather than (1, 0), and the latter becomes undefined.

The following Python program checks that the circuits work:

values = [0, 1, -1]

def toBits(v):
    if v == 0:
        return 0, 0
    elif v == 1:
        return 0, 1
    elif v == -1:
        return 1, 1
    else:
        raise ValueError(v)

def mul((s1, a1), (s2, a2)):
    return ((s1 ^ s2) & a1 & a2, a1 & a2)

def add((s1, a1), (s2, a2)):
    t = s1 ^ a2
    return (t & (s2 ^ a1), (a1 ^ a2) | (t ^ s2))

def sub((s1, a1), (s2, a2)):
    t = a1 ^ a2
    return ((s1 ^ a2) & (t ^ s2), t | (s1 ^ s2))

def fromBits((s, a)):
    if s == 0 and a == 0:
        return 0
    if s == 0 and a == 1:
        return 1
    if s == 1 and a == 1:
        return -1
    else:
        raise ValueError((s, a))

def wrap(v):
    if v == 2:
        return -1
    elif v == -2:
        return 1
    else:
        return v

for v1 in values:
    for v2 in values:
        print v1, v2

        result = fromBits(mul(toBits(v1), toBits(v2)))
        if result != v1 * v2:
            raise ValueError((v1, v2, result))

        result = fromBits(add(toBits(v1), toBits(v2)))
        if result != wrap(v1 + v2):
            raise ValueError((v1, v2, result))

        result = fromBits(sub(toBits(v1), toBits(v2)))
        if result != wrap(v1 - v2):
            raise ValueError((v1, v2, result))

Change-Id: Ie1a4ca5a82c2651057efc62330eca6fdd9878122
Reviewed-on: https://boringssl-review.googlesource.com/c/34344
Reviewed-by: David Benjamin <davidben@google.com>
2019-01-21 21:32:35 +00:00
Adam Langley 20f4a043eb Add SSL_OP_NO_RENEGOTIATION
Since |ssl_renegotiate_never| is the default, this option is moot.
However, OpenSSL defines and supports it so this helps code that wishes
to support both.

Change-Id: I3a2f6e93a078d39526d10f9cd0a990953bd45825
Reviewed-on: https://boringssl-review.googlesource.com/c/34384
Reviewed-by: Adam Langley <alangley@gmail.com>
Commit-Queue: Adam Langley <alangley@gmail.com>
2019-01-21 18:08:55 +00:00
Adam Langley 899835fad4 Rename Fiat include files to end in .h
Otherwise generate_build_files.py thinks that they're top-level source
files.

Fixes grpc/grpc#17780

Change-Id: I9f14a816a5045c1101841a2ef7ef9868abcd5d12
Reviewed-on: https://boringssl-review.googlesource.com/c/34364
Reviewed-by: Adam Langley <agl@google.com>
2019-01-21 17:29:45 +00:00
David Benjamin 32e59d2d32 Switch to new fiat pipeline.
This new version makes it much easier to tell which code is handwritten
and which is verified. For some reason, it also is *dramatically* faster
for 32-bit x86 GCC. Clang x86_64, however, does take a small hit.
Benchmarks below.

x86, GCC 7.3.0, OPENSSL_SMALL
(For some reason, GCC used to be really bad at compiling the 32-bit curve25519
code. The new one fixes this. I'm not sure what changed.)
Before:
Did 17135 Ed25519 key generation operations in 10026402us (1709.0 ops/sec)
Did 17170 Ed25519 signing operations in 10074192us (1704.4 ops/sec)
Did 9180 Ed25519 verify operations in 10034025us (914.9 ops/sec)
Did 17271 Curve25519 base-point multiplication operations in 10050837us (1718.4 ops/sec)
Did 10605 Curve25519 arbitrary point multiplication operations in 10047714us (1055.5 ops/sec)
Did 7800 ECDH P-256 operations in 10018331us (778.6 ops/sec)
Did 24308 ECDSA P-256 signing operations in 10019241us (2426.1 ops/sec)
Did 9191 ECDSA P-256 verify operations in 10081639us (911.7 ops/sec)
After:
Did 99873 Ed25519 key generation operations in 10021810us (9965.6 ops/sec) [+483.1%]
Did 99960 Ed25519 signing operations in 10052236us (9944.1 ops/sec) [+483.4%]
Did 53676 Ed25519 verify operations in 10009078us (5362.7 ops/sec) [+486.2%]
Did 102000 Curve25519 base-point multiplication operations in 10039764us (10159.6 ops/sec) [+491.2%]
Did 60802 Curve25519 arbitrary point multiplication operations in 10056897us (6045.8 ops/sec) [+472.8%]
Did 7900 ECDH P-256 operations in 10054509us (785.7 ops/sec) [+0.9%]
Did 24926 ECDSA P-256 signing operations in 10050919us (2480.0 ops/sec) [+2.2%]
Did 9494 ECDSA P-256 verify operations in 10064659us (943.3 ops/sec) [+3.5%]

x86, Clang 8.0.0 trunk 349417, OPENSSL_SMALL
Before:
Did 82750 Ed25519 key generation operations in 10051177us (8232.9 ops/sec)
Did 82400 Ed25519 signing operations in 10035806us (8210.6 ops/sec)
Did 41511 Ed25519 verify operations in 10048919us (4130.9 ops/sec)
Did 83300 Curve25519 base-point multiplication operations in 10044283us (8293.3 ops/sec)
Did 49700 Curve25519 arbitrary point multiplication operations in 10007005us (4966.5 ops/sec)
Did 14039 ECDH P-256 operations in 10093929us (1390.8 ops/sec)
Did 40950 ECDSA P-256 signing operations in 10006757us (4092.2 ops/sec)
Did 16068 ECDSA P-256 verify operations in 10095996us (1591.5 ops/sec)
After:
Did 80476 Ed25519 key generation operations in 10048648us (8008.6 ops/sec) [-2.7%]
Did 79050 Ed25519 signing operations in 10049180us (7866.3 ops/sec) [-4.2%]
Did 40501 Ed25519 verify operations in 10048347us (4030.6 ops/sec) [-2.4%]
Did 81300 Curve25519 base-point multiplication operations in 10017480us (8115.8 ops/sec) [-2.1%]
Did 48278 Curve25519 arbitrary point multiplication operations in 10092500us (4783.6 ops/sec) [-3.7%]
Did 15402 ECDH P-256 operations in 10096705us (1525.4 ops/sec) [+9.7%]
Did 44200 ECDSA P-256 signing operations in 10037715us (4403.4 ops/sec) [+7.6%]
Did 17000 ECDSA P-256 verify operations in 10008813us (1698.5 ops/sec) [+6.7%]

x86_64, GCC 7.3.0
(Note these P-256 numbers are not affected by this change. Included to get a
sense of noise.)
Before:
Did 557000 Ed25519 key generation operations in 10011721us (55634.8 ops/sec)
Did 550000 Ed25519 signing operations in 10016449us (54909.7 ops/sec)
Did 190000 Ed25519 verify operations in 10014565us (18972.4 ops/sec)
Did 587000 Curve25519 base-point multiplication operations in 10015402us (58609.7 ops/sec)
Did 230000 Curve25519 arbitrary point multiplication operations in 10023827us (22945.3 ops/sec)
Did 179000 ECDH P-256 operations in 10016294us (17870.9 ops/sec)
Did 557000 ECDSA P-256 signing operations in 10014158us (55621.3 ops/sec)
Did 198000 ECDSA P-256 verify operations in 10036694us (19727.6 ops/sec)
After:
Did 569000 Ed25519 key generation operations in 10004965us (56871.8 ops/sec) [+2.2%]
Did 563000 Ed25519 signing operations in 10000064us (56299.6 ops/sec) [+2.5%]
Did 196000 Ed25519 verify operations in 10025650us (19549.9 ops/sec) [+3.0%]
Did 596000 Curve25519 base-point multiplication operations in 10008666us (59548.4 ops/sec) [+1.6%]
Did 229000 Curve25519 arbitrary point multiplication operations in 10028921us (22834.0 ops/sec) [-0.5%]
Did 182910 ECDH P-256 operations in 10014905us (18263.8 ops/sec) [+2.2%]
Did 562000 ECDSA P-256 signing operations in 10011944us (56133.0 ops/sec) [+0.9%]
Did 202000 ECDSA P-256 verify operations in 10046901us (20105.7 ops/sec) [+1.9%]

x86_64, GCC 7.3.0, OPENSSL_SMALL
Before:
Did 350000 Ed25519 key generation operations in 10002540us (34991.1 ops/sec)
Did 344000 Ed25519 signing operations in 10010420us (34364.2 ops/sec)
Did 197000 Ed25519 verify operations in 10030593us (19639.9 ops/sec)
Did 362000 Curve25519 base-point multiplication operations in 10004615us (36183.3 ops/sec)
Did 235000 Curve25519 arbitrary point multiplication operations in 10025951us (23439.2 ops/sec)
Did 32032 ECDH P-256 operations in 10056486us (3185.2 ops/sec)
Did 96354 ECDSA P-256 signing operations in 10007297us (9628.4 ops/sec)
Did 37774 ECDSA P-256 verify operations in 10044892us (3760.5 ops/sec)
After:
Did 343000 Ed25519 key generation operations in 10025108us (34214.1 ops/sec) [-2.2%]
Did 340000 Ed25519 signing operations in 10014870us (33949.5 ops/sec) [-1.2%]
Did 192000 Ed25519 verify operations in 10025082us (19152.0 ops/sec) [-2.5%]
Did 355000 Curve25519 base-point multiplication operations in 10013220us (35453.1 ops/sec) [-2.0%]
Did 231000 Curve25519 arbitrary point multiplication operations in 10010775us (23075.1 ops/sec) [-1.6%]
Did 31540 ECDH P-256 operations in 10009664us (3151.0 ops/sec) [-1.1%]
Did 99012 ECDSA P-256 signing operations in 10090296us (9812.6 ops/sec) [+1.9%]
Did 37695 ECDSA P-256 verify operations in 10092859us (3734.8 ops/sec) [-0.7%]

x86_64, Clang 8.0.0 trunk 349417
(Note these P-256 numbers are not affected by this change. Included to get a
sense of noise.)
Before:
Did 600000 Ed25519 key generation operations in 10000278us (59998.3 ops/sec)
Did 595000 Ed25519 signing operations in 10010375us (59438.3 ops/sec)
Did 184000 Ed25519 verify operations in 10013984us (18374.3 ops/sec)
Did 636000 Curve25519 base-point multiplication operations in 10005250us (63566.6 ops/sec)
Did 229000 Curve25519 arbitrary point multiplication operations in 10006059us (22886.1 ops/sec)
Did 179250 ECDH P-256 operations in 10026354us (17877.9 ops/sec)
Did 547000 ECDSA P-256 signing operations in 10017585us (54604.0 ops/sec)
Did 197000 ECDSA P-256 verify operations in 10013020us (19674.4 ops/sec)
After:
Did 560000 Ed25519 key generation operations in 10009295us (55948.0 ops/sec) [-6.8%]
Did 548000 Ed25519 signing operations in 10007912us (54756.7 ops/sec) [-7.9%]
Did 170000 Ed25519 verify operations in 10056948us (16903.7 ops/sec) [-8.0%]
Did 592000 Curve25519 base-point multiplication operations in 10016818us (59100.6 ops/sec) [-7.0%]
Did 214000 Curve25519 arbitrary point multiplication operations in 10043918us (21306.4 ops/sec) [-6.9%]
Did 180000 ECDH P-256 operations in 10026019us (17953.3 ops/sec) [+0.4%]
Did 550000 ECDSA P-256 signing operations in 10004943us (54972.8 ops/sec) [+0.7%]
Did 198000 ECDSA P-256 verify operations in 10021714us (19757.1 ops/sec) [+0.4%]

x86_64, Clang 8.0.0 trunk 349417, OPENSSL_SMALL
Before:
Did 326000 Ed25519 key generation operations in 10003266us (32589.4 ops/sec)
Did 322000 Ed25519 signing operations in 10026783us (32114.0 ops/sec)
Did 181000 Ed25519 verify operations in 10015635us (18071.7 ops/sec)
Did 335000 Curve25519 base-point multiplication operations in 10000359us (33498.8 ops/sec)
Did 224000 Curve25519 arbitrary point multiplication operations in 10027245us (22339.1 ops/sec)
Did 68552 ECDH P-256 operations in 10018900us (6842.3 ops/sec)
Did 184000 ECDSA P-256 signing operations in 10014516us (18373.3 ops/sec)
Did 76020 ECDSA P-256 verify operations in 10016891us (7589.2 ops/sec)
After:
Did 310000 Ed25519 key generation operations in 10022086us (30931.7 ops/sec) [-5.1%]
Did 308000 Ed25519 signing operations in 10007543us (30776.8 ops/sec) [-4.2%]
Did 173000 Ed25519 verify operations in 10005829us (17289.9 ops/sec) [-4.3%]
Did 321000 Curve25519 base-point multiplication operations in 10027058us (32013.4 ops/sec) [-4.4%]
Did 212000 Curve25519 arbitrary point multiplication operations in 10015203us (21167.8 ops/sec) [-5.2%]
Did 64059 ECDH P-256 operations in 10042781us (6378.6 ops/sec) [-6.8%]
Did 170000 ECDSA P-256 signing operations in 10030896us (16947.6 ops/sec) [-7.8%]
Did 72176 ECDSA P-256 verify operations in 10075369us (7163.6 ops/sec) [-5.6%]

Bug: 254
Change-Id: Ib04c773f01b542bcb8611cceb582466bfa6f6d52
Reviewed-on: https://boringssl-review.googlesource.com/c/34306
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-01-18 00:24:03 +00:00
David Benjamin f36c3ad3e4 Don't look for libunwind if cross-compiling.
pkg-config gets confused and doesn't know to look in, say,
/usr/lib/i386-linux-gnu when building for 32-bit. Fortunately, CMake
sets a CMAKE_CROSSCOMPILING variable whenever CMAKE_SYSTEM_NAME is set
manually (as done in util/32-bit-toolchain.cmake).

Change-Id: I638b4d54ea92ade4b2b5baa40a3c5e8c17914d46
Reviewed-on: https://boringssl-review.googlesource.com/c/34305
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-01-16 21:14:00 +00:00
David Benjamin 5590c715e2 Mark some unmarked array sizes in curve25519.c.
Change-Id: I92589f5d5e89c836cff3c26739b43eb65de67836
Reviewed-on: https://boringssl-review.googlesource.com/c/34304
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-01-16 20:49:29 +00:00
Adam Langley 823effe975 Revert "Fix protos_len size in SSL_set_alpn_protos and SSL_CTX_set_alpn_protos"
This reverts commit 35771ff8af. It breaks
tcnetty, which is tcnetty's fault but we have a large backlog from
Christmas to break with at the moment.

Bug: chromium:879657
Change-Id: Iafe93b335d88722170ec2689a25e145969e19e73
Reviewed-on: https://boringssl-review.googlesource.com/c/34324
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-01-16 20:02:16 +00:00
David Benjamin 73b1f181b6 Add ABI tests for GCM.
Change-Id: If28096e677104c6109e31e31a636fee82ef4ba11
Reviewed-on: https://boringssl-review.googlesource.com/c/34266
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-01-15 22:49:37 +00:00
David Benjamin 8285ccd8fc Fix SSL_R_TOO_MUCH_READ_EARLY_DATA.
https://boringssl-review.googlesource.com/15164 allocated a new error code by
hand, rather than using the make_errors.go script, which caused it to clobber
the error space reserved for alerts.

Change-Id: Ife92c45da2c1d3c5506439bd5781ae91240d16d8
Reviewed-on: https://boringssl-review.googlesource.com/c/34307
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-01-15 21:53:52 +00:00
David Benjamin b65ce68c8f Test CRYPTO_gcm128_tag in gcm_test.cc.
CRYPTO_gcm128_encrypt should be paired with CRYPTO_gcm128_tag, not
CRYPTO_gcm128_finish.

Change-Id: Ia3023a196fe5b613e9309b5bac19ea849dbc33b7
Reviewed-on: https://boringssl-review.googlesource.com/c/34265
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-01-15 18:19:57 +00:00
David Benjamin f18bd55240 Remove pointer cast in P-256 table.
We expect the table to have a slightly nested structure, so just
generate it that way. Avoid risking strict aliasing problems. Thanks to
Brian Smith for pointing this out.

Change-Id: Ie21610c4afab07a610d914265079135dba17b3b7
Reviewed-on: https://boringssl-review.googlesource.com/c/34264
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-01-15 00:16:17 +00:00
Adam Langley 3eac8b7708 Ignore new fields in forthcoming Wycheproof tests.
Change-Id: I95dd20bb71c18cecd4cae72bcdbd708ee5e92e77
Reviewed-on: https://boringssl-review.googlesource.com/c/34284
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-01-14 22:02:37 +00:00
David Benjamin 5349ddb747 Fix RSAZ's OPENSSL_cleanse.
https://boringssl-review.googlesource.com/28584 switched RSAZ's buffer
to being externally-allocated, which means the OPENSSL_cleanse needs to
be tweaked to match.

Change-Id: I0a7307ac86aa10933d10d380ef652c355fed3ee9
Reviewed-on: https://boringssl-review.googlesource.com/c/34191
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-01-14 20:04:39 +00:00
Alessandro Ghedini 3cbb0299a2 Allow configuring QUIC method per-connection
This allows sharing SSL_CTX between TCP and QUIC connections, such that
common settings can be configured without having to duplicate the
context.

Change-Id: Ie920e7f2a772dd6c6c7b63fdac243914ac5b7b26
Reviewed-on: https://boringssl-review.googlesource.com/c/33904
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-01-14 19:54:59 +00:00
Tom Tan de3c1f69cc Fix header file for _byteswap_ulong and _byteswap_uint64 from MSVC CRT
_byteswap_ulong and _byteswap_uint64 are documented (see below link) as coming from stdlib.h.
 On some build configurations stdlib.h is pulled in by intrin.h but that is not guaranteed. In particular,
this assumption causes build breaks when building Chromium for Windows ARM64 with clang-cl. This
 change switches the #include to use the documented header file, thus fixing Windows ARM64 with clang-cl.


https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/byteswap-uint64-byteswap-ulong-byteswap-ushort

Bug: chromium:893460
Change-Id: I738c7227a9e156c894c2be62b52228a5bbd88414
Reviewed-on: https://boringssl-review.googlesource.com/c/34244
Reviewed-by: David Benjamin <davidben@google.com>
Reviewed-by: Bruce Dawson <brucedawson@chromium.org>
Commit-Queue: David Benjamin <davidben@google.com>
2019-01-14 19:49:39 +00:00
David Benjamin 2bee229103 Add ABI tests for HRSS assembly.
The last instruction did not unwind correctly. Also add .type and .size
annotations so that errors show up properly.

Change-Id: Id18e12b4ed51bdabb90bd5ac66631fd989649eec
Reviewed-on: https://boringssl-review.googlesource.com/c/34190
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-01-09 04:10:25 +00:00
David Benjamin d99b549b8e Add AES ABI tests.
This involves fixing some bugs in aes_nohw_cbc_encrypt's annotations,
and working around a libunwind bug. In doing so, support .cfi_remember_state
and .cfi_restore_state in perlasm.

Change-Id: Iaedfe691356b0468327a6be0958d034dafa760e5
Reviewed-on: https://boringssl-review.googlesource.com/c/34189
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-01-09 03:54:55 +00:00
David Benjamin c0f4dbe4e2 Move aes_nohw, bsaes, and vpaes prototypes to aes/internal.h.
This is in preparation for adding ABI tests to them.

In doing so, update delocate.go so that OPENSSL_ia32cap_get is consistently
callable outside the module. Right now it's callable both inside and outside
normally, but not in FIPS mode because the function is generated. This is
needed for tests and the module to share headers that touch OPENSSL_ia32cap_P.

Change-Id: Idbc7d694acfb974e0b04adac907dab621e87de62
Reviewed-on: https://boringssl-review.googlesource.com/c/34188
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-01-09 03:35:55 +00:00
David Benjamin e592d595c4 Add direction flag checking to CHECK_ABI.
Linux and Windows ABIs both require that the direction flag be cleared
on function exit, so that functions can rely on it being cleared on
entry. (Some OpenSSL assembly preserves it, which is stronger, but we
only require what is specified by the ABI so CHECK_ABI works with C
compiler output.)

Change-Id: I1a320aed4371176b4b44fe672f1a90167b84160f
Reviewed-on: https://boringssl-review.googlesource.com/c/34187
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-01-09 03:22:15 +00:00
David Benjamin b2f56f9283 Add ABI tests for ChaCha20_ctr32.
Change-Id: I1fad7f954284000474e5723c3fa59fedceb52ad4
Reviewed-on: https://boringssl-review.googlesource.com/c/34186
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-01-09 03:11:45 +00:00
David Benjamin 5e350d13f5 Add ABI tests for MD5.
This does not actually matter, but writing new CFI directives with the
tester seemed like fun. (It caught two typos, one intentional and one
accidental.)

Change-Id: Iff3e0358f2e56caa26079f658fa7a682772150a1
Reviewed-on: https://boringssl-review.googlesource.com/c/34185
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-01-08 18:01:07 +00:00
David Benjamin 7076be5141 Refresh fuzzer corpus.
Change-Id: If5239e701f4e0a01758e17e58ede1ef6c00293b2
Reviewed-on: https://boringssl-review.googlesource.com/c/34204
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
2019-01-08 17:55:08 +00:00
Steven Valdez b84674b2d2 Delete the variants/draft code.
Change-Id: I84abfedc30e4c34e42285f3c366c2f504a3b9cf2
Reviewed-on: https://boringssl-review.googlesource.com/c/34144
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-01-08 17:38:41 +00:00
David Benjamin 6c597be1c6 Update tools.
Unfortunately, this requires partially reverting
https://boringssl-review.googlesource.com/31324. This is a mess.

While clang proper includes a fuzzer driver, Chromium doesn't use it.
Chromium builds exclusively with fuzzer-no-link and links to its own
copy of the fuzzer runtime[1]. As of [2], Chromium's clang (which we use
on bots) no longer includes the driver, so we must mimic them.

However, Chromium's setup is somewhat questionable because
fuzzer-no-link pulls in libclang_rt.fuzzer_no_main which still includes
most of libclang_rt.fuzzer, just not the one main function[3]. It
appears Chromium is actually linking two copies of
libclang_rt.fuzzer_no_main. Hopefully this mostly works out as Chromium's
clang and libFuzzer should be relatively aligned, but it's not a good
assumption for our build, which can take other Clangs too.

Thus, if you pass -DFUZZ=1 as-is, we will assume you are using a
"normal" Clang with all its relevant runtimes intact. If, however, you
are using Chromium clang, you must drop the matching libFuzzer where the
bots expected it and build with -DLIBFUZZER_FROM_DEPS=1.

This involves no changes to the bots because we never actually unwound
all the LIBFUZZER_FROM_DEPS bits before.

[1] https://cs.chromium.org/chromium/src/testing/libfuzzer/BUILD.gn?rcl=d21c49585f262e851e2984f96f52905782706325&l=14
[2] https://chromium.googlesource.com/chromium/src/+/c79bf2ea4cf65431dccb57cb2a44528c284645a1
[3] https://github.com/llvm-mirror/compiler-rt/blob/8ebc3668b07fc5cca6010265cd4795443f1c1bea/lib/fuzzer/CMakeLists.txt#L93-L107
    https://github.com/llvm-mirror/compiler-rt/blob/8ebc3668b07fc5cca6010265cd4795443f1c1bea/lib/fuzzer/FuzzerMain.cpp

Change-Id: I946b3c821c3d7e6def7e07f1381f58241611ba3d
Reviewed-on: https://boringssl-review.googlesource.com/c/34184
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-01-07 22:39:55 +00:00
Raul Tambre 35771ff8af Fix protos_len size in SSL_set_alpn_protos and SSL_CTX_set_alpn_protos
MakeConstSpan() takes size_t as the second argument, so protos_len ought to also be size_t.

Bug: chromium:879657
Change-Id: I93089ea20ce4b9c2b9d4d954dce807feb5341482
Reviewed-on: https://boringssl-review.googlesource.com/c/34164
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-01-07 18:14:42 +00:00
Christopher Patton 9cde848bd1 Use handshake parameters to decide if cert/key are available
Whether the host has a valid certificate or private key may depend on
the handshake parameters and not just its configuration. For example,
negotiating the delegated credential extension (see
https://tools.ietf.org/html/draft-ietf-tls-subcerts) requires an
alternate private key for the handshake.

Change-Id: I11cea1d11e731aa4018d980c010b8d8ebaa64c31
Reviewed-on: https://boringssl-review.googlesource.com/c/33664
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-01-04 19:29:33 +00:00
David Benjamin 1aaa7aa83c Add ABI tests for bn_mul_mont.
Bug: 181
Change-Id: Ibd606329278c6b727d95e762920a12b58bb8687a
Reviewed-on: https://boringssl-review.googlesource.com/c/33969
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-01-04 19:21:31 +00:00
David Benjamin 005f616217 Add ABI tests for SHA*.
Bug: 181
Change-Id: Ica9299613d7fd1b803533b7e489b9ba8fe816a24
Reviewed-on: https://boringssl-review.googlesource.com/c/33968
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-01-04 19:14:11 +00:00
Adam Langley 9dfaf25520 Make pkg-config optional.
Since libunwind, and therefore the CFI tests, are already optional,
might as well make pkg-config optional too.

(I'm not sure whether we actually want to support people using our
development build, but gRPC appear to be trying to do so:
https://github.com/grpc/grpc/issues/17638)

Change-Id: I16b4c53bd8a66933bc19fba29aed0d79ce2670c2
Reviewed-on: https://boringssl-review.googlesource.com/c/34124
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-01-04 16:09:11 +00:00
David Benjamin 5f85f2a061 Add DEPS rules to checkout Windows SDE.
Change-Id: Ia2398fa822fef1ac79f2062a8401bdd3ec963727
Reviewed-on: https://boringssl-review.googlesource.com/c/34104
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-01-04 00:39:28 +00:00
David Benjamin 2a622531af Add ABI tests for rdrand.
This one is easy. For others we may wish to get in the habit of pulling
assembly declarations into headers.

Bug: 181
Change-Id: I24c774e3c9b1f983585b9828b0783ceddd08f0e7
Reviewed-on: https://boringssl-review.googlesource.com/c/33967
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-01-04 00:07:26 +00:00
Adam Langley 3c79ba8156 Set NIDs for Blowfish and CAST.
I hadn't thought that we still had the NIDs for these, but it appears
that we do. In which case, might as well set them.

Change-Id: I0d459ecacda95298c7ef345b73639cc02c74914f
Reviewed-on: https://boringssl-review.googlesource.com/c/34045
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-01-03 22:41:25 +00:00
David Benjamin 17d553d299 Add a CFI tester to CHECK_ABI.
This uses the x86 trap flag and libunwind to test CFI works at each
instruction. For now, it just uses the system one out of pkg-config and
disables unwind tests if unavailable. We'll probably want to stick a
copy into //third_party and perhaps try the LLVM one later.

This tester caught two bugs in P-256 CFI annotations already:
I47b5f9798b3bcee1748e537b21c173d312a14b42 and
I9f576d868850312d6c14d1386f8fbfa85021b347

An earlier design used PTRACE_SINGLESTEP with libunwind's remote
unwinding features. ptrace is a mess around stop signals (see group-stop
discussion in ptrace(2)) and this is 10x faster, so I went with it. The
question of which is more future-proof is complex:

- There are two libunwinds with the same API,
  https://www.nongnu.org/libunwind/ and LLVM's. This currently uses the
  system nongnu.org for convenience. In future, LLVM's should be easier
  to bundle (less complex build) and appears to even support Windows,
  but I haven't tested this.  Moreover, setting the trap flag keeps the
  test single-process, which is less complex on Windows. That suggests
  the trap flag design and switching to LLVM later. However...

- Not all architectures have a trap flag settable by userspace. As far
  as I can tell, ARMv8's PSTATE.SS can only be set from the kernel. If
  we stick with nongnu.org libunwind, we can use PTRACE_SINGLESTEP and
  remote unwinding. Or we implement it for LLVM. Another thought is for
  the ptracer to bounce SIGTRAP back into the process, to share the
  local unwinding code.

- ARMv7 has no trap flag at all and PTRACE_SINGLESTEP fails. Debuggers
  single-step by injecting breakpoints instead. However, ARMv8's trap
  flag seems to work in both AArch32 and AArch64 modes, so we may be
  able to condition it on a 64-bit kernel.

Sadly, neither strategy works with Intel SDE. Adding flags to cpucap
vectors as we do with ARM would help, but it would not emulate CPUs
newer than the host CPU. For now, I've just had SDE tests disable these.

Annoyingly, CMake does not allow object libraries to have dependencies,
so make test_support a proper static library. Rename the target to
test_support_lib to avoid
https://gitlab.kitware.com/cmake/cmake/issues/17785

Update-Note: This adds a new optional test dependency, but it's disabled
by default (define BORINGSSL_HAVE_LIBUNWIND), so consumers do not need
to do anything. We'll probably want to adjust this in the future.

Bug: 181
Change-Id: I817263d7907aff0904a9cee83f8b26747262cc0c
Reviewed-on: https://boringssl-review.googlesource.com/c/33966
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-01-03 22:01:55 +00:00
David Benjamin e67b625e43 Fix some size_t to long casts.
Maybe someday we'll be able to turn on that warning. (The EVP_CIPHER
hooks take size_t while the functions took long.)

Change-Id: Ic4da44efca9419a7f703e232d3f92638eb4ab37a
Reviewed-on: https://boringssl-review.googlesource.com/c/34084
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-01-03 21:46:45 +00:00
Adam Langley 6effbf24bc Add EVP_CIPHER support for Blowfish and CAST to decrepit.
Postgres contains a “pqcrypto” module that showcases the worst of 90's
crypto, including Blowfish and CAST5 in CFB, CBC, and ECB modes. (Also,
64-bit keys for both of those.)

In order to minimise the patching needed to build Postgres, put these
things in decrepit.

Change-Id: I8390c5153dd7227eef07293a4363878d79df8b21
Reviewed-on: https://boringssl-review.googlesource.com/c/34044
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-01-03 21:34:46 +00:00
David Benjamin f77c8a38be Be less clever with CHECK_ABI.
Unwind testing will make CHECK_ABI much slower. The original
ptrace-based design is some 10,000x slower. I've found an alternate
design that's a mere 1,000x slower, but this probably warrants being
more straightforward. It also removes the weirdness where NDEBUG
controlled which tests were run.

While it does mean we need to write some extra tests for p256-x86_64.pl,
we otherwise do not directly unit test our assembly anyway. Usually we
test the public crypto APIs themselves. So, for most files, this isn't
actually extra work.

Bug: 181
Change-Id: I7cbb7f930c2ea6ae32a201da503dcd36844704f0
Reviewed-on: https://boringssl-review.googlesource.com/c/33965
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-01-03 21:02:24 +00:00
David Benjamin cc5a888fe5 Update SDE and add the Windows version.
Windows is sufficiently different from Linux that running tests under
SDE for Windows, particularly with the new ABI tests, is worthwhile.

Change-Id: I32c4f6de06b2e732ebb2c1492eb1766cae73c0e0
Reviewed-on: https://boringssl-review.googlesource.com/c/34064
Reviewed-by: Steven Valdez <svaldez@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-01-03 21:01:33 +00:00
Adam Langley e6bf9065af Remove pooling of PRNG state.
Prior to 82639e6f we used thread-local data for the PRNG state. That
change switched to using a mutex-protected pool instead in order to save
memory in heavily-threaded applications.

However, the pool mutex can get extremely hot in cases where the PRNG is
heavily used. 8e8f2504 was a short-term work around, but supporting both
modes is overly complex.

This change moves back to the state of the prior to 82639e6f. The best
way to review this is to diff the changed files against '82639e6f^' and
note that the only difference is a comment added in rand.c:
https://paste.googleplex.com/4997991748337664

Change-Id: I8febce089696fa6bc39f94f4a1e268127a8f78db
Reviewed-on: https://boringssl-review.googlesource.com/c/34024
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2019-01-03 20:19:44 +00:00
Jeremy Apthorp 7177c1d29f Add EC_KEY_key2buf for OpenSSL compatibility
Change-Id: If45ef3a9bb757bd0c7f592f40ececaf4aa2f607d
Reviewed-on: https://boringssl-review.googlesource.com/c/33824
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-01-03 16:32:21 +00:00
David Benjamin 43e636a2e4 Remove bundled copy of android-cmake.
I don't believe we use this anymore. People using it should upgrade to a newer
NDK (or, worst case, download android-cmake themselves).

Change-Id: Ia99d7b19d6f2ec3f4ffe90795813b00480dc2d60
Reviewed-on: https://boringssl-review.googlesource.com/c/34004
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-01-03 16:28:10 +00:00
David Benjamin 6f9f4cc443 Clarify build requirements.
The minimum versions are largely bogus, since we do not continuously test them.
Instead, we've been using Abseil's five year guidelines to decide when to rely
on tooling improvements. Document this.

Remove the note on how to build Ninja as that'll just get out of date. For
instance, they appear to support Python 3 when building now.

Explicitly call out that CMake 3.0 will be required next year (released June
2014). 3.0 is the minimum needed to distinguish Clang from AppleClang, without
which version checks on Clang don't work.

Also document that we require a C++11 compiler for more than just tests these
days.

Change-Id: I4e5766934edc1d69f7be01f48e855d400adfb5f2
Reviewed-on: https://boringssl-review.googlesource.com/c/33845
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-01-02 23:57:14 +00:00
Jeremy Apthorp 79c7ec06f6 Add EC_GROUP_order_bits for OpenSSL compatibility
Change-Id: I37149fa4274357d84befff85728ce2337131afa7
Reviewed-on: https://boringssl-review.googlesource.com/c/33804
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-01-02 23:51:14 +00:00
David Benjamin 0eaf783fbf Annotate leaf functions with .cfi_{startproc,endproc}
While gdb can figure it out, libunwind requires CFI directives to
unwind a leaf function, even though the directives are trivial.
Adding them matches what GCC outputs, and likely gdb has many
heuristics that less complex tools (e.g. profilers) may not.

Bug: 181
Change-Id: I25c72152de33109a29710a828aeb99c608dd0470
Reviewed-on: https://boringssl-review.googlesource.com/c/33964
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-01-02 23:49:24 +00:00
David Benjamin c2e8d016f5 Fix beeu_mod_inverse_vartime CFI annotations and preamble.
This was also caught by the in-progress unwind tester. There are two
issues here.  First, .cfi_endproc must come after ret to fully cover the
function.  More importantly, this function is confused about whether it
has a frame pointer or not.

It looks like it does (movq %rsp, %rbp), and annotates accordingly, but
it does not actually use the frame pointer. It cannot. $y4 is rbp and
gets clobbered immediately after the preamble!

Remove this instruction and align the CFI annotations with a
frame-pointer-less function.

Bug: 181
Change-Id: I47b5f9798b3bcee1748e537b21c173d312a14b42
Reviewed-on: https://boringssl-review.googlesource.com/c/33947
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-01-02 23:47:34 +00:00
David Benjamin a306b1b908 Fix CFI annotations in p256-x86_64-asm.pl.
This was caught by in-progress work to test unwind information. It was
incorrect at two instructions: immediately before we jump to
.Lpoint_double_shortcut$x. This is needed because
ecp_nistz256_point_add$x tries to be clever about not unwinding the
stack frame in its tail call.

It's also unlikely that the SEH handlers in this file are correct at
this point, but that will be handled separately while overhauling
everything else here. (For Win64, probably the only ABI-compliant option
is to just properly unwind the stack frame. Without a custom handler,
Win64 unwind codes are very restrictive.)

Bug: 181
Change-Id: I9f576d868850312d6c14d1386f8fbfa85021b347
Reviewed-on: https://boringssl-review.googlesource.com/c/33946
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-01-02 23:39:21 +00:00
David Benjamin 6ef1b64558 Add a comment about ecp_nistz256_point_add_affine's limitations.
ecp_nistz256_point_add_affine does not support the doubling case and,
unlike ecp_nistz256_point_add which does a tail call, computes the wrong
answer. Note TestPointAdd in the unit tests skips this case.

This works fine because we only use ecp_nistz256_point_add_affine for
the g_scalar term, which is fully computed before the p_scalar term.
(Additionally it requires that the windowing pattern never hit the
doubling case for single multiplication.)

But this is not obvious from reading the multiplication functions, so
leave a comment at the call site to point this out.

Change-Id: I08882466d98030cdc882a5be9e702ee404e80cce
Reviewed-on: https://boringssl-review.googlesource.com/c/33945
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2019-01-02 23:33:31 +00:00
David Benjamin 1c55e54eda Refresh p256-x86_64_tests.txt.
The old points weren't even on the curve. I probably had no clue what I
was doing at the time when I generated them. Refresh them with a
checked-in generate script.

Change-Id: Ib4613fe922edcf45fc4ea49fc4c2cc23a9a2a9bd
Reviewed-on: https://boringssl-review.googlesource.com/c/33944
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2019-01-02 23:29:31 +00:00
David Benjamin fb3f0638ba Fix some indentation nits.
perlasm's bizarre mix of asm and perl indentation and clever editors always
mess me up.

Change-Id: Iac906a636207867939cc327b4c21b8a982abce29
Reviewed-on: https://boringssl-review.googlesource.com/c/33844
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2019-01-02 19:26:54 +00:00
Adam Langley 8e8f250422 Use thread-local storage for PRNG states if fork-unsafe buffering is enabled.
We switched from thread-local storage to a mutex-pool in 82639e6f53
because, for highly-threaded processes, the memory used by all the
states could be quite large. I had judged that a mutex-pool should be
fine, but had underestimated the PRNG requirements of some of our jobs.

This change makes rand.c support using either thread-locals or a
mutex-pool. Thread-locals are used if fork-unsafe buffering is enabled.
While not strictly related to fork-safety, we already have the
fork-unsafe control, and it's already set by jobs that care a lot about
PRNG performance, so fits quite nicely here.

Change-Id: Iaf1e0171c70d4c8dbe1e42283ea13df5b613cb2d
Reviewed-on: https://boringssl-review.googlesource.com/c/31564
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2018-12-28 18:05:18 +00:00
David Benjamin 74944287e1 Add Win64 SEH unwind codes for the ABI test trampoline.
This is all manual right now. Once we've added SEH tests, we can add support
for emitting these in x86_64-xlate.pl, probably based on MASM and Yasm's unwind
directives, and unify with CFI. (Sadly, NASM does not support these
directives.) Then we can push that upstream to replace the error-prone and
non-standard custom handlers.

Change-Id: I5a734fd494b7eaafab24a00e6df624bd03b37d43
Reviewed-on: https://boringssl-review.googlesource.com/c/33785
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <alangley@gmail.com>
Commit-Queue: David Benjamin <davidben@google.com>
2018-12-21 16:38:03 +00:00
David Benjamin 5edf8957b5 Translate .L directives inside .byte too.
Win64 unwind tables place distances from the start of a function in
byte-wide values.

Change-Id: Ie2aad7f6f5b702a60933bd52d872a83cba4e73a9
Reviewed-on: https://boringssl-review.googlesource.com/c/33784
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <alangley@gmail.com>
2018-12-21 16:35:32 +00:00
David Benjamin 54efa1afc0 Add an ABI testing framework.
Dear reader, I must apologize in advance. This CL contains the following:

- A new 256-line perlasm file with non-trivial perl bits and a dual-ABI
  variadic function caller.

- C preprocessor gymnastics, with variadic macros and fun facts about
  __VA_ARGS__'s behavior on empty argument lists.

- C++ template gymnastics, including variadic arguments, template
  specialization, std::enable_if, and machinery to control template argument
  deduction.

Enjoy.

This tests that our assembly functions correctly honor platform ABI
conventions. Right now this only tests callee-saved registers, but it should be
extendable to SEH/CFI unwind testing with single-step debugging APIs.
Register-checking does not involve anything funny and should be compatible with
SDE. (The future unwind testing is unlikely to be compatible.)

This CL adds support for x86_64 SysV and Win64 ABIs. ARM, AArch64, and x86 can
be added in the future. The testing is injected in two places. First, all the
assembly tests in p256-x86_64-test.cc are now instrumented. This is the
intended workflow and should capture all registers.

However, we currently do not unit-test our assembly much directly. We should do
that as follow-up work[0] but, in the meantime, I've also wrapped all of the GTest
main function in an ABI test. This is imperfect as ABI failures may be masked
by other stack frames, but it costs nothing[1] and is pretty reliable at
catching Win64 xmm register failures.

[0] An alternate strategy would be, in debug builds, unconditionally instrument
every assembly call in libcrypto. But the CHECK_ABI macro would be difficult to
replicate in pure C, and unwind testing may be too invasive for this. Still,
something to consider when we C++ libcrypto.

[1] When single-stepped unwind testing exists, it won't cost nothing. The
gtest_main.cc call will turn unwind testing off.

Change-Id: I6643b26445891fd46abfacac52bc024024c8d7f6
Reviewed-on: https://boringssl-review.googlesource.com/c/33764
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <alangley@gmail.com>
Commit-Queue: David Benjamin <davidben@google.com>
2018-12-21 16:09:32 +00:00
Alessandro Ghedini 2cc6f449d7 Use same HKDF label as TLS 1.3 for QUIC as per draft-ietf-quic-tls-17
Change-Id: Ie9825634f0f290aa3af0e88477013f62e2e0c246
Reviewed-on: https://boringssl-review.googlesource.com/c/33724
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2018-12-19 20:25:34 +00:00
Adam Langley ba9ad6628c Add |SSL_key_update|.
This function allows a client to send a TLS 1.3 KeyUpdate message.

Change-Id: I69935253795a79d65a8c85b652378bf04b7058e2
Reviewed-on: https://boringssl-review.googlesource.com/c/33706
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2018-12-19 20:15:24 +00:00
Adam Langley 9700b44ff5 HRSS: omit reconstruction of ciphertext.
In [1], section 5.1, an optimised re-encryption process is given. In the
code, this simplifies to not needing to rebuild the ciphertext at all.

Thanks to John Schanck for pointing this out.

[1] https://eprint.iacr.org/2018/1174.pdf

Change-Id: I807bd509e936b7e82a43e8656444431546e9bbdf
Reviewed-on: https://boringssl-review.googlesource.com/c/33705
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2018-12-19 20:09:34 +00:00
Adam Langley a6a049a6fb Add start of infrastructure for checking constant-time properties.
Valgrind's checking of uninitialised memory behaves very much like a
check for constant-time code: branches and memory indexes based on
uninitialised memory trigger warnings. Therefore, if we can tell
Valgrind that some secret is “uninitialised”, it'll give us a warning if
we do something non-constant-time with it.

This was the idea behind https://github.com/agl/ctgrind. But tricks like
that are no longer needed because Valgrind now comes with support for
marking regions of memory as defined or not. Therefore we can use that
API to check constant-time code.

This CL defines |CONSTTIME_SECRET| and |CONSTTIME_DECLASSIFY|, which are
no-ops unless the code is built with
|BORINGSSL_CONSTANT_TIME_VALIDATION| defined, which it isn't by default.
So this CL is a no-op itself so far. But it does show that a couple of
bits of constant-time time are, in fact, constant-time—seemingly even
when compiled with optimisations, which is nice.

The annotations in the RSA code are a) probably not marking all the
secrets as secret, and b) triggers warnings that are a little
interesting:

The anti-glitch check calls |BN_mod_exp_mont| which checks that the
input is less than the modulus. Of course, it is because the input is
the RSA plaintext that we just decrypted, but the plaintext is supposed
to be secret and so branching based on its contents isn't allows by
Valgrind. The answer isn't totally clear, but I've run out of time on
this for now.

Change-Id: I1608ed0b22d201e97595fafe46127159e02d5b1b
Reviewed-on: https://boringssl-review.googlesource.com/c/33504
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2018-12-18 22:43:02 +00:00
Adam Langley c2897a158a Don't enable intrinsics on x86 without ABI support.
At some point after GCC 7.3, but before 8.2, GCC enabled the SSE ABI by
default. However, if it isn't enabled, the vector intrinsics in HRSS
cannot be used. (See https://github.com/grpc/grpc/issues/17540.)

Note that the intrinsics used are SSE2, but that should be ok because
they are guarded by a run-time check. The compile-time check for __SSE__
just ensures that GCC will build the code at all. (SDE does not simulate
anything that doesn't have SSE2, however.)

Change-Id: If092a06a441ed9d38576ea30351b3b40693a3399
Reviewed-on: https://boringssl-review.googlesource.com/c/33744
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2018-12-18 17:06:48 +00:00
Adam Langley f8068ce885 HRSS: be strict about unused bits being zero.
It's excessively complex to worry about leaving these few bits for
extensions. If we need to change things, we can spin a new curve ID in
TLS. We don't need to support two versions during the transition because
a fallback to X25519 is still fine.

Change-Id: I0a4019d5693db0f0f3a5379909d99c2e2c762560
Reviewed-on: https://boringssl-review.googlesource.com/c/33704
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2018-12-17 21:02:58 +00:00
David Benjamin 41c10e2b5f Disable AES-GCM-SIV assembly on Windows.
I'm working on a test harness to check our assembly correctly restores
callee-saved registers. It caught this.

While perlasm tries to smooth over the differences between Windows and SysV
ABIs, it does not capture the difference in xmm registers. All xmm registers
are volatile in SysV, while Windows makes xmm6 through xmm15 callee-saved.

Change-Id: Ia549b0f126885768f7fb330271a590174c483a3d
Reviewed-on: https://boringssl-review.googlesource.com/c/33685
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2018-12-17 17:54:07 +00:00
David Benjamin e1b2a65e7f Fix typo in AES-GCM-SIV comments.
Change-Id: I73bd495cf99bbc8a993a726b009d68e74c893420
Reviewed-on: https://boringssl-review.googlesource.com/c/33684
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-12-17 17:39:46 +00:00
Alessandro Ghedini 9b0970f1b0 Fix HRSS build error on ARM
Seeing the following errors with GCC 6 on ARM:

  crypto/hrss/hrss.c:212:12: error: function declaration isn't a prototype [-Werror=strict-prototypes]
   static int vec_capable() { return CRYPTO_is_NEON_capable(); }
              ^~~~~~~~~~~
  crypto/hrss/hrss.c: In function 'vec_capable':
  crypto/hrss/hrss.c:212:12: error: old-style function definition [-Werror=old-style-definition]

Change-Id: Ice540e6d436b8ada1dbc494f1feca10efff11687
Reviewed-on: https://boringssl-review.googlesource.com/c/33624
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2018-12-14 17:12:49 +00:00
David Benjamin 4cce955d14 Fix thread-safety bug in SSL_get_peer_cert_chain.
https://boringssl-review.googlesource.com/12704 pushed it just too far
to the edge. Once we have an established SSL_SESSION, any modifications
need to either be locked or done ahead of time. Do it ahead of time.
session->is_server gives a suitable place to check and X509s are
ref-counted so this should be cheap.

Add a regression test via TSan. Confirmed that TSan indeed catches this.

Change-Id: I30ce7b757d3a44465b318af3c98961ff3667483e
Reviewed-on: https://boringssl-review.googlesource.com/c/33606
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-12-13 19:30:49 +00:00
Adam Langley 200fe6786b Remove HRSS confirmation hash.
Since the underlying operation is deterministic the confirmation hash
isn't needed and SXY didn't use it in their proof.

Change-Id: I3a03c20ee79645cf94b10dbfe654c1b88d9aa416
Reviewed-on: https://boringssl-review.googlesource.com/c/33605
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2018-12-13 18:42:02 +00:00
Adam Langley 35a66d4aae Drop NEON assembly for HRSS.
Since we build Chrome with -mfpu=neon anyway, this isn't currently
needed. Additionally, I had included poly3_invert_vec in the assembly
but hadn't gotten around to wiring it up yet. That assembly referenced a
couple of functions in the C code that had been renamed. Surprisingly,
the NDK linker didn't have a problem with the undefined symbols since it
could statically find them to be unreachable.

But that isn't true everywhere. Some builds did fail because of the
undefined symbols although we're not sure what's different about them.
(Different NDK version perhaps?)

Change-Id: Ibac4724d24df05d6f6007499e1cd884e59889101
Reviewed-on: https://boringssl-review.googlesource.com/c/33604
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2018-12-13 17:43:07 +00:00
Adam Langley d6e1f230b3 Add |SSL_export_traffic_secrets|.
This allows an application to obtain the current TLS 1.3 traffic secrets
for a connection.

Change-Id: I8ad8d0559caba266f74081441dea54b22da3db20
Reviewed-on: https://boringssl-review.googlesource.com/c/33590
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2018-12-12 22:57:33 +00:00
David Benjamin 3adb1e5a37 Patch out the XTS implementation in bsaes.
We don't call it, so ship less code and reduce the number of places
where we must think about the bsaes -> aes_nohw fallback.

Bug: 256
Change-Id: I10ac2d70e18ec81e679631a9532c36d9edab1c6e
Reviewed-on: https://boringssl-review.googlesource.com/c/33586
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2018-12-12 22:27:13 +00:00
Adam Langley fc30467f28 Remove .file and .loc directives from HRSS ARM asm.
This is a workaround for https://bugs.llvm.org/show_bug.cgi?id=38740.

Change-Id: I74d5066c4c782745e003a608b3ccc002599bf6b4
Reviewed-on: https://boringssl-review.googlesource.com/c/33587
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2018-12-12 22:26:53 +00:00
David Benjamin 43cc9c6e86 Do not allow AES_128_GCM_SHA256 with CECPQ2.
Just forbid it altogether, so we don't need to worry about a mess of
equipreferences.

Change-Id: I4921ff326c6047e50c075d4311dd42219bf8318e
Reviewed-on: https://boringssl-review.googlesource.com/c/33585
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-12-12 20:05:52 +00:00
Adam Langley 1ea083d8b2 Always 16-byte align |poly| elements.
Even if the vector code isn't used in hrss.c, it might call external
assembly that still requires alignment.

Change-Id: I11ceb88f96deec6b20883872030ca090506ca150
Reviewed-on: https://boringssl-review.googlesource.com/c/33584
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2018-12-12 18:58:50 +00:00
Adam Langley 2526c66b72 Fix bug in HRSS tests.
I moved the |poly3_rand| code into a function and omitted to update a
|sizeof|.

Change-Id: I861fac4fe26ee3b5e5116d5cee71e64d9af9d175
Reviewed-on: https://boringssl-review.googlesource.com/c/33564
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2018-12-12 18:04:25 +00:00
Adam Langley 7b935937b1 Add initial HRSS support.
This change includes support for a variant of [HRSS], a post-quantum KEM
based on NTRU. It includes changes suggested in [SXY]. This is not yet
ready for any deployment: some breaking changes, like removing the
confirmation hash, are still planned.

(CLA for HRSS's assembly code noted in b/119426559.)

[HRSS] https://eprint.iacr.org/2017/667.pdf
[SXY] https://eprint.iacr.org/2017/1005.pdf

Change-Id: I85d813733b066d5c578484bdd248de3f764194db
Reviewed-on: https://boringssl-review.googlesource.com/c/33105
Reviewed-by: David Benjamin <davidben@google.com>
2018-12-12 17:35:02 +00:00
David Benjamin 602f4669ab Forbid empty CertificateRequestsupported_signature_algorithms in TLS 1.2.
See the IETF thread here:
https://www.ietf.org/mail-archive/web/tls/current/msg27292.html

In particular, although the original publication of RFC 5246 had a
syntax error in the field (the minimum length was unspecified), there is
an errata from 2012 to fix it to be non-empty.
https://www.rfc-editor.org/errata/eid2864

Currently, when empty, we implicitly interpret it as SHA1/*, matching
the server behavior in missing extension in ClientHellos. However that
text does not support doing it for CertificateRequests, and there is not
much reason to. That default (which is in itself confusing and caused
problems such as older OpenSSL only signing SHA-1 given SNI) was
because, at the time, there were concerns over making any ClientHello
extensions mandatory. This isn't applicable for CertificateRequest,
which can freely advertise their true preferences.

Change-Id: I113494d8f66769fde1362795fb08ff2f471ef31d
Reviewed-on: https://boringssl-review.googlesource.com/c/33524
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-12-11 20:08:12 +00:00
Adam Langley bf5021a6b8 Eliminate |OPENSSL_ia32cap_P| in C code in the FIPS module.
This can break delocate with certain compiler settings.

Change-Id: I76cf0f780d0e967390feed754e39b0ab25068f42
Reviewed-on: https://boringssl-review.googlesource.com/c/33485
Commit-Queue: Adam Langley <alangley@gmail.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2018-12-06 00:58:14 +00:00
David Benjamin 750fea158a Fix d2i_*_bio on partial reads.
If BIO_read returns partial reads, d2i_*_bio currently fails. This is a
partial (hah) regression from 419144adce.
The old a_d2i_fp.c code did *not* tolerate partial reads in the ASN.1
header, but it *did* tolerate them in the ASN.1 body. Since partial
reads are more likely to land in the body than the header, I think we
can say d2i_*_bio was "supposed to" tolerate this but had a bug in the
first few bytes.

Fix it for both cases. Add a regression test for this and the partial
write case (which works fine).

See also https://github.com/google/conscrypt/pull/587.

Change-Id: I886f6388f0b80621960e196cf2a56f5c02a14a04
Reviewed-on: https://boringssl-review.googlesource.com/c/33484
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-12-05 22:05:28 +00:00
Adam Langley ff433815b5 Fix |BN_HEX_FMT2|.
It appears to be only used in p256-x86_64_test.cc, which is obviously
64-bit only and do not affected by this. Internal code search doesn't
find any uses and GitHub just finds several thousand copies of bn.h.

Change-Id: If8185bf6275d90efa172c95cb67c62c86a17e394
Reviewed-on: https://boringssl-review.googlesource.com/c/33464
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2018-12-04 20:35:05 +00:00
Brian Smith 90247be1d9 Remove XOP code from sha512-x86_64.pl.
Other XOP code was removed already.

Change-Id: I0c457effebd22f89e722653b93905a0b2e3eb5c0
Reviewed-on: https://boringssl-review.googlesource.com/c/33424
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-12-04 01:10:32 +00:00
Brian Smith 36ee9a5a0d Pretend AMD XOP was never a thing.
It's not clear that any AMD XOP code paths are being properly tested.
AMD dropped XOP starting in Zen.

Here's the one place I found (without looking too hard) where it seems
there is a XOP code path in BoringSSL, in sha512-x86_64.pl. Most of the
other XOP code was removed.

```
$code.=<<___ if ($avx && $SZ==8);
	test	\$`1<<11`,%r10d		# check for XOP
	jnz	.Lxop_shortcut
```

Change-Id: Id3301b2c84648790d010dae546b8e21ece1c528d
Reviewed-on: https://boringssl-review.googlesource.com/c/33405
Reviewed-by: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2018-12-03 22:59:55 +00:00
Adam Langley e6ad7a027f Drop some explicit SSLKeyShare destructors.
We zero out memory in |OPENSSL_free| already.

Change-Id: I84a0f3cdfadd4544c0fade1d3d727baa6496ffe5
Reviewed-on: https://boringssl-review.googlesource.com/c/33446
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2018-12-03 22:51:05 +00:00
Brian Smith 96b05ed487 Assume hyper-threading-like vulnerabilities are always present.
It's not clear that CPUID will always report the correct value here,
especially for hyper-threading environments. It also isn't clear that
the assumptions made by AMD processors are correct and will always be
correct. It also seems likely that, if a code path is
security-sensitive w.r.t. SMT, it is probably also security-sensitive
w.r.t. other processor (mis)features. Finally, it isn't clear that all
dynamic analysis (fuzzing, SDE, etc.) is done separately for the cross
product of all CPU feature combinations * the value of this bit.

With all that in mind, instruct code sensitive to this bit to always
choose the more conservative path.

I only found one place that's sensitive to this bit, though I didn't
look too hard:

```
aes_nohw_cbc_encrypt:
    [...]
    leaq	OPENSSL_ia32cap_P(%rip),%r10
    mov	(%r10), %r10d
    [...]
    bt	\$28,%r10d
    jc	.Lcbc_slow_prologue
```

I didn't verify that the code in the HTT-enabled paths is any better
than the code in the HTT-disabled paths.

Change-Id: Ifd643e6a1301e5ca2174b84c344eb933d49e0067
Reviewed-on: https://boringssl-review.googlesource.com/c/33404
Reviewed-by: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2018-12-03 22:32:24 +00:00
David Benjamin eb7d5b69e9 Replace the last CRITICAL_SECTION with SRWLOCK.
We don't support Windows XP, so we can rely on SRWLOCK. Per
https://crbug.com/592752, SRWLOCKs are more efficient and less of a
hassle to use. We'd previously converted CRYPTO_MUTEX to SRWLOCK, but I
missed this one. Not that this one lock matters much, may as well. It's
less initialization code.

Change-Id: I7ae435be5202b0a19f42015c9abff932dc04dbc7
Reviewed-on: https://boringssl-review.googlesource.com/c/33445
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-12-03 20:37:35 +00:00
David Benjamin 278b3120ee Validate ClientHellos in tests some more.
This way we'll notice if we ever generate a bad padding extension or
duplicate an extension. This did require fixing one of the JDK11 test
vectors. When I manually added a padding extension, I forgot the
contents were all zeros and incorrectly put in "padding" instead.

Change-Id: Ifec5bb01a739014ed0fdf5b49b82a6b514646e9a
Reviewed-on: https://boringssl-review.googlesource.com/c/33444
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-12-03 20:31:55 +00:00
Brian Smith 0f5ecd3a85 Re-enable AES-NI on 32-bit x86 too.
commit 05750f23ae disabled AES-NI for
32-bit x86, perhaps unintentionally.

Change-Id: Ie950c4f49526257138ecc803df5ecfc115bc648d
Reviewed-on: https://boringssl-review.googlesource.com/c/33365
Reviewed-by: Adam Langley <agl@google.com>
2018-11-28 00:32:30 +00:00
David Benjamin e157dc9208 Make symbol-prefixing work on 32-bit x86.
On Linux, this introduces yet another symbol to blacklist.

Change-Id: Ieafe45a25f3b41da6c6934dd9488f4ee400bcab9
Reviewed-on: https://boringssl-review.googlesource.com/c/33350
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-11-27 22:35:17 +00:00
David Benjamin 8c23d3a5df Make Windows symbol-prefixing work.
This teaches read_symbols.go to use debug/pe, and fixes miscellaneous
issues with NASM. It also reveals a problem with this strategy of
getting symbols out at the linker level: inline functions.  I'm thinking
a better long-term mechanism may be to parse our header files.

Change-Id: I11b008543a7a97db3db9d4062ee4ddb910d174b7
Reviewed-on: https://boringssl-review.googlesource.com/c/33349
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-11-27 22:13:22 +00:00
David Benjamin c8cf62bba8 Support Windows-style ar files.
Apparently Windows' .lib files are also ar. Add tests.

Change-Id: Ie35f410268086b8fe6d4d1b491de3f30a46309dd
Reviewed-on: https://boringssl-review.googlesource.com/c/33348
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-11-27 22:06:15 +00:00
David Benjamin 1a0f908e92 Move __.SYMDEF handling to ar.go.
One less bit of special-casing in read_symbols.go. We filter out the
sysv-style symbol table, so we should filter out the macOS one too.

Add tests for util/ar to cover this and the Linux case.

Change-Id: Id16d8b0526c1b6e0149df1df4006848d7b3a4b2f
Reviewed-on: https://boringssl-review.googlesource.com/c/33347
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-11-27 21:53:36 +00:00
David Benjamin 00d72d342f Fix stack_test.cc in the prefixed build.
Uses of BORINGSSL_MAKE_DELETER must be inside BSSL_NAMESPACE_BEGIN for
the specializations to work.

Change-Id: Ib96cf5d235586b24c052973d7034c0e5a8019f17
Reviewed-on: https://boringssl-review.googlesource.com/c/33346
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-11-27 21:35:56 +00:00
David Benjamin 8b0dad4a7f Don't double-mangle C++ symbols on macOS.
The symbol-listing code already removes the leading underscore.

Change-Id: I2f93382af932e8027f2aa8596886ba685836b3a6
Reviewed-on: https://boringssl-review.googlesource.com/c/33345
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-11-27 20:57:56 +00:00
David Benjamin abbc59896f Make read_symbols.go a bit more idiomatic.
It's more verbose, but trimming the panics should make it easier to move
to a library (e.g. a symbol checker) or unit test later.

Change-Id: Iab37eff2689955e58057528be092d6dd5d8d26bc
Reviewed-on: https://boringssl-review.googlesource.com/c/33344
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2018-11-27 19:42:20 +00:00
David Benjamin 045ee41928 Unexport and rename hex_to_string, string_to_hex, and name_cmp.
Squatting these names is rather rude. Also hex_to_string and
string_to_hex do the opposite of what one would expect, so rename them
to something a bit less confusing.

Update-Note: This removes some random utility functions. name_cmp is
very specific to OpenSSL's config file format, so it's unlikely anyone
is relying on it. I removed the one use of hex_to_string and
string_to_hex I could find.

Change-Id: I01554885ad306251e6982100d0b15cd89b1cdea7
Reviewed-on: https://boringssl-review.googlesource.com/c/33364
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-11-27 00:08:39 +00:00
David Benjamin 9113e0996f Satisfy golint.
Errors are supposed to be fragments that go into sentences, rather than
sentences themselves.

Change-Id: I6569fce25535475162c85e7b0db7eeb62c93febd
Reviewed-on: https://boringssl-review.googlesource.com/c/33324
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-11-21 23:31:08 +00:00
David Benjamin bbc429148f Add a note that generated files are generated.
Folks keep assuming checked-in assembly files are the source. Between
the preprocessor, delocate, NASM not using the C preprocessor, and GAS's
arch-specific comment syntax, comment markers are kind of a disaster.
This set appears to work for now.

Change-Id: I48e26dafb444dfa310df80dcce87ac291fde8037
Reviewed-on: https://boringssl-review.googlesource.com/c/33304
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-11-21 20:05:05 +00:00
David Benjamin 6965d25602 Work around a JDK 11 TLS 1.3 bug.
JDK 11 shipped with a TLS 1.3 implementation enabled by default.
Unfortunately, that implementation does not work and fails to send the
SNI extension on resumption. See
https://bugs.openjdk.java.net/browse/JDK-8211806.

This means servers which enable TLS 1.3 will see JDK 11 clients work on
the first connection and then fail on all subsequent connections. Add
SSL_set_jdk11_workaround which configures a workaround to fingerprint
JDK 11 and disable TLS 1.3 with the faulty clients.

JDK 11 also implemented the downgrade signal, which means that
connections that trigger the workaround also must not send the downgrade
signal. Unfortunately, the downgrade signal's security properties are
sensitive to the existence of any unmarked TLS 1.2 ServerHello paths. To
salvage this, pick a new random downgrade marker for this scenario and
modify the client to treat it as an alias of the standard one.

Per the link above, JDK 11.0.2 will fix this bug. Hopefully the
workaround can be retired sometime after it is released.

Change-Id: I0627609a8cadf7cc214073eb7f1e880acdf613ef
Reviewed-on: https://boringssl-review.googlesource.com/c/33284
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-11-21 18:22:57 +00:00
David Benjamin 4f746a9073 Move ARM cpuinfo functions to the header.
ClusterFuzz folks want to switch to a shared library build, so call into
these another way. The new setup isn't quite ideal because the real code
builds as C and now tests as C++, but it should work.

Bug: chromium:907115
Change-Id: Ia1ffc18832739b09fee21b84ee5d181e61feaa15
Reviewed-on: https://boringssl-review.googlesource.com/c/33285
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-11-21 00:46:57 +00:00
Adam Langley a3ba8b3289 Regenerate obj_dat.h
clang-format seems to have decided to format things differently now.
This will eliminate diff noise in the future when there are actual
changes.

Change-Id: I1f94cf0f0859023b6c926119f39bf0a587464e52
Reviewed-on: https://boringssl-review.googlesource.com/c/33266
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2018-11-19 20:26:03 +00:00
Adam Langley c65a1f4949 go fmt
Change-Id: I48a1e9e27013bb91b783949b65463208516bb3d2
Reviewed-on: https://boringssl-review.googlesource.com/c/33265
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2018-11-19 20:20:01 +00:00
David Benjamin 293d9ee4e8 Support execute-only memory for AArch64 assembly.
Put data in .rodata and, rather than adr, use the combination of adrp :pg_hi21:
and add :lo12:. Unfortunately, iOS uses different syntax, so we must add more
transforms to arm-xlate.pl.

Tested manually by:

1. Use Android NDK r19-beta1

2. Follow usual instructions to configure CMake for aarch64, but pass
   -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld -Wl,-execute-only".

3. Build. Confirm with readelf -l tool/bssl that .text is not marked
   readable.

4. Push the test binaries onto a Pixel 3. Test normally and with
   --cpu={none,neon,crypto}. I had to pass --gtest_filter=-*Thread* to
   crypto_test. There appears to be an issue with some runtime function
   that's unrelated to our assembly.

No measurable performance difference.

Going forward, to support this, we will need to apply similar changes to
all other AArch64 assembly. This is relatively straightforward, but may
be a little finicky for dual-AArch32/AArch64 files (aesv8-armx.pl).

Update-Note: Assembly syntax is a mess. There's a decent chance some
assembler will get offend.

Change-Id: Ib59b921d4cce76584320fefd23e6bb7ebd4847eb
Reviewed-on: https://boringssl-review.googlesource.com/c/33245
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2018-11-19 19:58:15 +00:00
David Benjamin 4188c3f495 Remove cacheline striping in copy_from_prebuf.
The standard computation model for constant-time code is that memory
access patterns must be independent of secret data.
BN_mod_exp_mont_consttime was previously written to a slightly weaker
model: only cacheline access patterns must be independent of secret
data. It assumed accesses within a cacheline were indistinguishable.

The CacheBleed attack (https://eprint.iacr.org/2016/224.pdf) showed this
assumption was false. Cache lines may be divided into cache banks, and
the researchers were able to measure cache bank contention pre-Haswell.
For Haswell, the researchers note "But, as Haswell does show timing
variations that depend on low address bits [19], it may be vulnerable to
similar attacks."

OpenSSL's fix to CacheBleed was not to adopt the standard constant-time
computation model. Rather, it now assumes accesses within a 16-byte
cache bank are indistinguishable, at least in the C copy_from_prebuf
path. These weaker models failed before with CacheBleed, so avoiding
such assumptions seems prudent. (The [19] citation above notes a false
dependence between memory addresses with a distance of 4k, which may be
what the paper was referring to.) Moreover, the C path is largely unused
on x86_64 (which uses mont5 asm), so it is especially questionable for
the generic C code to make assumptions based on x86_64.

Just walk the entire table in the C implementation. Doing so as-is comes
with a performance hit, but the striped memory layout is, at that point,
useless. We regain the performance loss (and then some) by using a more
natural layout. Benchmarks below.

This CL does not touch the mont5 assembly; I haven't figured out what
it's doing yet.

Pixel 3, aarch64:
Before:
Did 3146 RSA 2048 signing operations in 10009070us (314.3 ops/sec)
Did 447 RSA 4096 signing operations in 10026666us (44.6 ops/sec)
After:
Did 3210 RSA 2048 signing operations in 10010712us (320.7 ops/sec)
Did 456 RSA 4096 signing operations in 10063543us (45.3 ops/sec)

Pixel 3, armv7:
Before:
Did 2688 RSA 2048 signing operations in 10002266us (268.7 ops/sec)
Did 459 RSA 4096 signing operations in 10004785us (45.9 ops/sec)
After:
Did 2709 RSA 2048 signing operations in 10001299us (270.9 ops/sec)
Did 459 RSA 4096 signing operations in 10063737us (45.6 ops/sec)

x86_64 Broadwell, mont5 assembly disabled:
(This configuration is not actually shipped anywhere, but seemed a
useful data point.)
Before:
Did 14274 RSA 2048 signing operations in 10009130us (1426.1 ops/sec)
Did 2448 RSA 4096 signing operations in 10046921us (243.7 ops/sec)
After:
Did 14706 RSA 2048 signing operations in 10037908us (1465.0 ops/sec)
Did 2538 RSA 4096 signing operations in 10059986us (252.3 ops/sec)

Change-Id: If41da911d4281433856a86c6c8eadf99cd33e2d8
Reviewed-on: https://boringssl-review.googlesource.com/c/33268
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2018-11-19 19:10:09 +00:00
David Benjamin 5963bff237 Tidy up type signature of BN_mod_exp_mont_consttime table.
It's a table of BN_ULONGs. No particular need to use unsigned char.

Change-Id: I397883cef9f39fb162c2b0bfbd6a70fe399757a2
Reviewed-on: https://boringssl-review.googlesource.com/c/33267
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-11-19 17:44:44 +00:00
Andrii Shyshkalov 09f5a040d4 No longer set CQ-Verified label on CQ success/failure.
R=davidben@google.com

Bug: chromium:906576
Change-Id: I56b16a76fabe37822a1a7eb3f075a476f83818ea
Reviewed-on: https://boringssl-review.googlesource.com/c/33270
Reviewed-by: David Benjamin <davidben@google.com>
2018-11-19 16:59:05 +00:00
David Benjamin 46e12b03f9 Print a message when simulating CPUs.
Make it more obvious something is happening.

Change-Id: Ie68d1e96a9bedd4b572c1cc99910348f89f07624
Reviewed-on: https://boringssl-review.googlesource.com/c/33244
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-11-16 23:12:27 +00:00
David Benjamin ce61710062 Move JSON test results code into a common module.
We can actually use modules now.

Change-Id: I0bd8abaf4e3318069f93fa17e89b4804d03944eb
Reviewed-on: https://boringssl-review.googlesource.com/c/33205
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-11-16 20:13:31 +00:00
Jesse Selover f241a59dcc In 0RTT mode, reverify the server certificate before sending early data.
Bug: chromium:347402
Change-Id: I1442b595ed7296b9d9fe88357565f68e1ab80ffd
Reviewed-on: https://boringssl-review.googlesource.com/c/32644
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-11-16 19:52:18 +00:00
Junghoon Jang e8ba1e3b21 Support assembly building for arm64e architecture.
iPhone XS/XS MAX/XR uses arm64e.

Change-Id: I89bd6b9307176c03fdc1a402ce6b8df080b00653
Reviewed-on: https://boringssl-review.googlesource.com/c/33224
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-11-16 01:43:53 +00:00
David Benjamin 6ce93ccb80 Simulate other ARM CPUs when running tests.
We test all Intel variants via SDE. For ARM, we can do the next best
thing and tweak with OPENSSL_armcap_P. If the host CPU does not support
the instructions we wish to test, skip it, but print something so we
know whether we need a more featureful test device.

Also fix the "CRASHED" status to "CRASH", to match
https://chromium.googlesource.com/chromium/src/+/master/docs/testing/json_test_results_format.md
(It's unclear if anything actually parses that JSON very carefully...)

Bug: 19
Change-Id: I811cc00a0d210a454287ac79c06f18fbc54f96dd
Reviewed-on: https://boringssl-review.googlesource.com/c/33204
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-11-15 00:58:09 +00:00
Adam Langley 444c2e59fb Merge P-224 contract into serialisation.
Contraction was always and only done immediately prior to calling
|p224_felem_to_generic| so merge it into that function.

Change-Id: If4fb46c6305ba724dfff15e8362a094c599f3f2c
Reviewed-on: https://boringssl-review.googlesource.com/c/33165
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-11-14 23:47:13 +00:00
Adam Langley 549b9024d4 Contract P-224 elements before returning them.
cfd50c63 switched to using the add/dbl of p224_64.c, but the outputs
weren't contracted before being returned and could be out of range,
giving invalid results.

Change-Id: I3cc295c7ddbff43375770dbafe73b37a668e4e6b
Reviewed-on: https://boringssl-review.googlesource.com/c/33184
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2018-11-14 22:38:12 +00:00
Steven Valdez e6eef1ca16 Add post-handshake support for the QUIC API.
Change-Id: I4956efabfb33f7bd60a4743a922c29ee4de18935
Reviewed-on: https://boringssl-review.googlesource.com/c/33004
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-11-14 18:54:36 +00:00
David Benjamin ce45588695 Speculatively remove __STDC_*_MACROS.
C99 added macros such as PRIu64 to inttypes.h, but it said to exclude them from
C++ unless __STDC_FORMAT_MACROS or __STDC_CONSTANT_MACROS was defined. This
text was never incorporated into any C++ standard and explicitly overruled in
C++11.

Some libc headers followed C99. Notably, glibc prior to 2.18
(https://sourceware.org/bugzilla/show_bug.cgi?id=15366) and old versions of the
Android NDK.

In the NDK, although it was fixed some time ago (API level 20), the NDK used to
use separate headers per API level. Only applications using minSdkVersion >= 20
would get the fix. Starting NDK r14, "unified" headers are available which,
among other things, make the fix available (opt-in) independent of
minSdkVersion. In r15, unified headers are opt-out, and in r16 they are
mandatory.

Try removing these and see if anyone notices. The former is past our five year
watermark. The latter is not and Android has hit
https://boringssl-review.googlesource.com/c/boringssl/+/32686 before, but
unless it is really widespread, it's probably simpler to ask consumers to
define __STDC_CONSTANT_MACROS and __STDC_FORMAT_MACROS globally.

Update-Note: If you see compile failures relating to PRIu64, UINT64_MAX, and
friends, update your glibc or NDK. As a short-term fix, add
__STDC_CONSTANT_MACROS and __STDC_FORMAT_MACROS to your build, but get in touch
so we have a sense of how widespread it is.

Bug: 198
Change-Id: I56cca5f9acdff803de1748254bc45096e4c959c2
Reviewed-on: https://boringssl-review.googlesource.com/c/33146
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-11-14 16:14:37 +00:00
David Benjamin 5ecfb10d54 Modernize OPENSSL_COMPILE_ASSERT, part 2.
The change seems to have stuck, so bring us closer to C/++11 static asserts.

(If we later find we need to support worse toolchains, we can always use
__LINE__ or __COUNTER__ to avoid duplicate typedef names and just punt on
embedding the message into the type name.)

Change-Id: I0e5bb1106405066f07740728e19ebe13cae3e0ee
Reviewed-on: https://boringssl-review.googlesource.com/c/33145
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-11-14 16:06:37 +00:00
David Benjamin 73d69f4d51 Switch docs to recommending NASM.
Chromium has now switched to building our assembly with NASM
(https://crbug.com/766721), which is more maintained. Next step
is to switch remaining folks (Conscrypt, not sure if there's anyone
else) and we'll drop Yasm.

Change-Id: If4f45399b48d0d7477afb47647e83e7250bf854f
Reviewed-on: https://boringssl-review.googlesource.com/c/33144
Reviewed-by: Adam Langley <agl@google.com>
2018-11-14 16:00:42 +00:00
Adam Langley 9a547e17eb Mark the |e| argument to |RSA_generate_key_ex| as const.
The function does not take ownership of |e| and this makes that clear.

Change-Id: I53bb5fa94bec5d16d1c904b59391d36df7abbde6
Reviewed-on: https://boringssl-review.googlesource.com/c/33164
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-11-14 15:57:25 +00:00
David Benjamin 5279ef5769 Clean up EC_POINT to byte conversions.
With the allocations and BN_CTX gone, ECDH and point2oct are much, much
shorter.

Bug: 242
Change-Id: I3421822e94100f7eb2f5f2373df7fb3b3311365e
Reviewed-on: https://boringssl-review.googlesource.com/c/33071
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-11-13 17:27:59 +00:00
Adam Langley c93ab63a53 Need cpu.h for |OPENSSL_ia32cap_P|.
(Otherwise the individual-file build breaks.)

Change-Id: Id3defd08cd2b49af1d8eb6890bd8454332c1aa1e
Reviewed-on: https://boringssl-review.googlesource.com/c/33124
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-11-13 17:15:39 +00:00
David Benjamin c1c81613ce Rename EC_MAX_SCALAR_*.
These are used for field elements too.

Change-Id: I74e3dbcafdce34ad507f64a0718e0420b56b51ae
Reviewed-on: https://boringssl-review.googlesource.com/c/33070
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-11-13 03:22:04 +00:00
David Benjamin 9f152adfcf Use EC_RAW_POINT in ECDSA.
Now the only allocations in ECDSA are the ECDSA_SIG input and output.

Change-Id: If1fcde6dc2ee2c53f5adc16a7f692e22e9c238de
Reviewed-on: https://boringssl-review.googlesource.com/c/33069
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-11-13 02:06:46 +00:00
David Benjamin 8618f2bfe0 Optimize EC_GFp_mont_method's cmp_x_coordinate.
For simplicity, punt order > field or width mismatches. Analogous
optimizations are possible, but the generic path works fine and no
commonly-used curve looks hits those cases.

Before:
Did 5888 ECDSA P-384 verify operations in 3094535us (1902.7 ops/sec)
After [+6.7%]:
Did 6107 ECDSA P-384 verify operations in 3007515us (2030.6 ops/sec)

Also we can fill in p - order generically and avoid extra copies of some
constants.

Change-Id: I38e1b6d51b28ed4f8cb74697b00a4f0fbc5efc3c
Reviewed-on: https://boringssl-review.googlesource.com/c/33068
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-11-13 01:48:21 +00:00
David Benjamin 0b3f497bcd Optimize EC_GFp_nistp256_method's cmp_x_coordinate.
Before:
Did 35496 ECDSA P-256 verify operations in 10027999us (3539.7 ops/sec)
After [+6.9%]:
Did 38170 ECDSA P-256 verify operations in 10090160us (3782.9 ops/sec)

Change-Id: Ib272d19954f46d96efc2b6d5dd480b5b85a34523
Reviewed-on: https://boringssl-review.googlesource.com/c/33067
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-11-13 00:52:18 +00:00
David Benjamin 4508745861 Remove unreachable code.
This is a remnant from just before
https://boringssl-review.googlesource.com/23074.

Change-Id: I3fded6107ac59f1129d040837da0c7cd109e7564
Reviewed-on: https://boringssl-review.googlesource.com/c/33106
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-11-12 23:34:36 +00:00
Adam Langley 2745ef9082 Also accept __ARM_NEON
The Clang used in the Android SDK, at least, defines both __ARM_NEON__
and __ARM_NEON for ARMv7, but only the latter for AArch64.

This change switches each use of __ARM_NEON__ to accept either.

Change-Id: I3b5d5badc9ff0210888fd456e9329dc53a2b9b09
Reviewed-on: https://boringssl-review.googlesource.com/c/33104
Commit-Queue: Adam Langley <alangley@gmail.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-11-12 22:12:08 +00:00
David Benjamin 76e441bd66 Remove some easy BN_CTXs.
Change-Id: Ie7ff03a2c5b2ae8f56816b02182df40ce7ca0065
Reviewed-on: https://boringssl-review.googlesource.com/c/33066
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-11-12 22:04:40 +00:00
David Benjamin be11d6d8d7 Push BIGNUM out of the cmp_x_coordinate interface.
This removes the failure cases for cmp_x_coordinate, this clearing our
earlier dilemma.

Change-Id: I057f705e49b0fb5c3fc9616ee8962a3024097b24
Reviewed-on: https://boringssl-review.googlesource.com/c/33065
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-11-12 21:46:36 +00:00
David Benjamin fa3aadcd40 Push BIGNUM out of EC_METHOD's affine coordinates hook.
This is in preparation for removing the BIGNUM from cmp_x_coordinate.

Change-Id: Id8394248e3019a4897c238289f039f436a13679d
Reviewed-on: https://boringssl-review.googlesource.com/c/33064
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-11-12 21:32:53 +00:00
David Benjamin adeb72b353 Fix r = p-n+epsilon ECDSA tests.
I forgot to refresh the public key in those tests, so they weren't
actually testing what they were supposed to. With this fix, injecting
too larger of a P_MINUS_ORDER into p256-x86_64.c now breaks tests.

Change-Id: I5d10a85c84b09629448beef67c86de607525fc71
Reviewed-on: https://boringssl-review.googlesource.com/c/33044
Reviewed-by: Adam Langley <agl@google.com>
2018-11-12 16:34:45 +00:00
David Benjamin f09df6930f Don't include openssl/ec_key.h under extern "C".
Reportedly some combination of C++ modules and old clang gets upset.
That seems an inadvisable combination, but including headers under
extern "C" is rude, so fix it.

Change-Id: I12f873e1be41697b67f2b1145387a3c6fc769c28
Reviewed-on: https://boringssl-review.googlesource.com/c/33024
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-11-09 19:33:34 +00:00
David Benjamin 7d10ab594c Abstract hs_buf a little.
Having to lazily create it is a little wordy, and we append to it in
three places now. V2ClientHello makes this slightly finicky, but I think
this is still clearer.

Change-Id: If931db0b56efd7f0728c0b7d119886864dd7933a
Reviewed-on: https://boringssl-review.googlesource.com/c/32824
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2018-11-09 19:01:04 +00:00
David Benjamin 4706ea728e Inline ec_GFp_simple_group_get_degree.
This function is not EC_METHOD-specific, nor is there any reason it
would be (we do not support GF2m).

Change-Id: I4896cd16a107ad6a99be445a0dc0896293e8c8f9
Reviewed-on: https://boringssl-review.googlesource.com/c/32884
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-11-08 23:56:02 +00:00
David Benjamin fbec517255 Better test boundary cases of ec_cmp_x_coordinate.
This is done in preparation of generalizing the optimization to all our
EC_METHODs.

Wycheproof happily does cover the case where x needed a reduction, but
they don't appear to check x being just above or below n, only x = p - 1
(adjusted downwards). Also we can tailor the test vectors a bit to the
x == r*z^2 (mod p) strategy to make sure we don't mess that up.

Additionally, the scenario is different for n > p. There is also the
nuisance of EC_FELEM vs EC_SCALAR having different widths. All our
built-in curves are well-behaved (same width, and consistently p < n),
but secp160r1 is reachable from custom curves and violates both
properties. Generate some tests to cover it as well.

Change-Id: Iefa5ebfe689a81870be21f04f5962ab161d38dab
Reviewed-on: https://boringssl-review.googlesource.com/c/32985
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-11-08 23:52:07 +00:00
Adam Langley 26b3fb0a77 Fix build when bcm.c is split up.
Some of the ec files now reference ECDSA_R_BAD_SIGNATURE. Instead, lift the
error-pushing to ecdsa.c.

Change-Id: Ice3e7a22c5099756599df0ab0b215c0752ada4ee
Reviewed-on: https://boringssl-review.googlesource.com/c/32984
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-11-08 22:35:51 +00:00
Adam Langley 9edbc7ff9f Revert "Revert "Speed up ECDSA verify on x86-64.""
This reverts commit e907ed4c4b. CPUID
checks have been added so hopefully this time sticks.

Change-Id: I5e0e5b87427c1230132681f936b3c70bac8263b8
Reviewed-on: https://boringssl-review.googlesource.com/c/32924
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-11-07 23:57:22 +00:00
Steven Valdez 384d0eaf19 Make SSL_get_current_cipher valid during QUIC callbacks.
Update-Note: This effectively reverts https://boringssl-review.googlesource.com/4733,
which was an attempt at a well-defined story during renegotiation and pre-handshake.
This is a behavior change, though one that matches OpenSSL upstream. It is also more
consistent with other functions, such as SSL_get_curve_id. Renegotiation is now
opt-in, so this is less critical, and, if we change the behavior mid-renegotiation,
we should do it consistently to all getters.

Change-Id: Ica6b386fb7c5ac524395de6650642edd27cac36f
Reviewed-on: https://boringssl-review.googlesource.com/c/32904
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-11-06 19:04:48 +00:00
David Benjamin ffbf95ad41 Devirtualize ec_simple_{add,dbl}.
Now that the tuned add/dbl implementations are exposed, these can be
specific to EC_GFp_mont_method and call the felem_mul and felem_sqr
implementations directly.

felem_sqr and felem_mul are still used elsewhere in simple.c, however,
so we cannot get rid of them yet.

Change-Id: I5ea22a8815279931afc98a6fc578bc85e3f8bdcc
Reviewed-on: https://boringssl-review.googlesource.com/c/32849
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-11-06 18:32:11 +00:00
Matthew Braithwaite 6ec9e40b28 Refresh fuzzer corpora for changes to split-handshake serialization.
Change-Id: I7922b4b26dabb6875e800472ee8453ca4a9922e0
Reviewed-on: https://boringssl-review.googlesource.com/c/32845
Reviewed-by: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-11-06 01:19:38 +00:00
Matthew Braithwaite c65eb2ceda Serialize SSL curve list in handoff and check it on application.
A split SSL handshake may involve 2 binaries, potentially built at
different versions: call them the "handoff/handback" binary and the
"handshake" binary.  We would like to guarantee that the
handoff/handback binary does not make any promises that the handshake
binary cannot keep.

d2ed382 serialized |kCiphers|; this commit extends the same approach
to |kNamedGroups|.

Change-Id: Idb13e54e9b189236309f6054a36872c5a4d96985
Reviewed-on: https://boringssl-review.googlesource.com/c/32825
Reviewed-by: David Benjamin <davidben@google.com>
2018-11-06 01:19:10 +00:00
Adam Langley e907ed4c4b Revert "Speed up ECDSA verify on x86-64."
This reverts commit 3d450d2844. It fails
SDE, looks like a missing CPUID check before using vector instructions.

Change-Id: I6b7dd71d9e5b1f509d2e018bd8be38c973476b4e
Reviewed-on: https://boringssl-review.googlesource.com/c/32864
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2018-11-06 00:29:15 +00:00
David Benjamin cfd50c63a1 Route the tuned add/dbl implementations out of EC_METHOD.
Some consumer stumbled upon EC_POINT_{add,dbl} being faster with a
"custom" P-224 curve than the built-in one and made "custom" clones to
work around this. Before the EC_FELEM refactor, EC_GFp_nistp224_method
used BN_mod_mul for all reductions in fallback point arithmetic (we
primarily support the multiplication functions and keep the low-level
point arithmetic for legacy reasons) which took quite a performance hit.

EC_FELEM fixed this, but standalone felem_{mul,sqr} calls out of
nistp224 perform a lot of reductions, rather than batching them up as
that implementation is intended. So it is still slightly faster to use a
"custom" curve.

Custom curves are the last thing we want to encourage, so just route the
tuned implementations out of EC_METHOD to close this gap. Now the
built-in implementation is always solidly faster than (or identical to)
the custom clone.  This also reduces the number of places where we mix
up tuned vs. generic implementation, which gets us closer to making
EC_POINT's representation EC_METHOD-specific.

Change-Id: I843e1101a6208eaabb56d29d342e886e523c78b4
Reviewed-on: https://boringssl-review.googlesource.com/c/32848
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-11-06 00:17:19 +00:00
Nir Drucker 3d450d2844 Speed up ECDSA verify on x86-64.
This commit improves the performance of ECDSA signature verification
(over NIST P-256 curve) for x86 platforms. The speedup is by a factor of 1.15x.
It does so by:
  1) Leveraging the fact that the verification does not need
     to run in constant time. To this end, we implemented:
    a) the function ecp_nistz256_points_mul_public in a similar way to
       the current ecp_nistz256_points_mul function by removing its constant
       time features.
    b) the Binary Extended Euclidean Algorithm (BEEU) in x86 assembly to
       replace the current modular inverse function used for the inversion.
  2) The last step in the ECDSA_verify function compares the (x) affine
     coordinate with the signature (r) value. Converting x from the Jacobian's
     representation to the affine coordinate requires to perform one inversions
     (x_affine = x * z^(-2)). We save this inversion and speed up the computations
     by instead bringing r to x (r_jacobian = r*z^2) which is faster.

The measured results are:
Before (on a Kaby Lake desktop with gcc-5):
Did 26000 ECDSA P-224 signing operations in 1002372us (25938.5 ops/sec)
Did 11000 ECDSA P-224 verify operations in 1043821us (10538.2 ops/sec)
Did 55000 ECDSA P-256 signing operations in 1017560us (54050.9 ops/sec)
Did 17000 ECDSA P-256 verify operations in 1051280us (16170.8 ops/sec)

After (on a Kaby Lake desktop with gcc-5):
Did 27000 ECDSA P-224 signing operations in 1011287us (26698.7 ops/sec)
Did 11640 ECDSA P-224 verify operations in 1076698us (10810.8 ops/sec)
Did 55000 ECDSA P-256 signing operations in 1016880us (54087.0 ops/sec)
Did 20000 ECDSA P-256 verify operations in 1038736us (19254.2 ops/sec)

Before (on a Skylake server platform with gcc-5):
Did 25000 ECDSA P-224 signing operations in 1021651us (24470.2 ops/sec)
Did 10373 ECDSA P-224 verify operations in 1046563us (9911.5 ops/sec)
Did 50000 ECDSA P-256 signing operations in 1002774us (49861.7 ops/sec)
Did 15000 ECDSA P-256 verify operations in 1006471us (14903.6 ops/sec)

After (on a Skylake server platform with gcc-5):
Did 25000 ECDSA P-224 signing operations in 1020958us (24486.8 ops/sec)
Did 10373 ECDSA P-224 verify operations in 1046359us (9913.4 ops/sec)
Did 50000 ECDSA P-256 signing operations in 1003996us (49801.0 ops/sec)
Did 18000 ECDSA P-256 verify operations in 1021604us (17619.4 ops/sec)

Developers and authors:
***************************************************************************
Nir Drucker (1,2), Shay Gueron (1,2)
(1) Amazon Web Services Inc.
(2) University of Haifa, Israel
***************************************************************************

Change-Id: Idd42a7bc40626bce974ea000b61fdb5bad33851c
Reviewed-on: https://boringssl-review.googlesource.com/c/31304
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-11-05 23:48:07 +00:00
Adam Langley 7f7e5e231e Include details about latest FIPS certification.
Change-Id: I84cda22a1086bce0da4797afae7975b3f39625de
Reviewed-on: https://boringssl-review.googlesource.com/c/32844
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-11-05 19:03:25 +00:00
Matthew Braithwaite d2ed382e64 Serialize SSL configuration in handoff and check it on application.
A split SSL handshake may involve 2 binaries, potentially built at
different versions: call them the "handoff/handback" binary and the
"handshake" binary.  We would like to guarantee that the
handoff/handback binary does not make any promises that the handshake
binary cannot keep.

As a start, this commit serializes |kCiphers| to the handoff message.
When the handoff message is applied to an |SSL|, any configured
ciphers not listed in the handoff message will be removed, in order to
prevent them from being negotiated.

Subsequent commits will apply the same approach to other lists of features.

Change-Id: Idf6dbeadb750c076ab0509c09b9d3f22eb162b9c
Reviewed-on: https://boringssl-review.googlesource.com/c/29264
Reviewed-by: Matt Braithwaite <mab@google.com>
2018-11-02 19:45:42 +00:00
David Benjamin e62bf02a13 Don't overflow state->calls on 16TiB RAND_bytes calls.
This is an extremely important and practical use case. The comment that
state->calls is bounded by the reseed interval isn't quite true. We only
check on entry to the function, which means that it may exceed it by one
call's worth. Switch it to a size_t (which doesn't actually increase
memory because the struct was already padded).

Change-Id: Ia7646fd5b4142789c1d613280223baa4cd1a4a9b
Reviewed-on: https://boringssl-review.googlesource.com/c/32804
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-11-02 18:33:43 +00:00
David Benjamin cc9d935256 Buffer up QUIC data within a level internally.
Avoid forcing the QUIC implementation to buffer this when we already have code
to do it. This also avoids QUIC implementations relying on this hook being
called for each individual message.

Change-Id: If2d70f045a25da1aa2b10fdae262cae331da06b1
Reviewed-on: https://boringssl-review.googlesource.com/c/32785
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-11-01 13:52:43 +00:00
Steven Valdez c8e0f90f83 Add an interface for QUIC integration.
0-RTT support and APIs to consume NewSessionTicket will be added in a
follow-up.

Change-Id: Ib2b2c6b618b3e33a74355fb53fdbd2ffafcc5c56
Reviewed-on: https://boringssl-review.googlesource.com/c/31744
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2018-10-31 20:38:10 +00:00
David Benjamin dc33220532 Remove OPENSSL_NO_THREADS.
Uses have been either migrated to
OPENSSL_NO_THREADS_CORRUPT_MEMORY_AND_LEAK_SECRETS_IF_THREADED or removed.

Update-Note: Anything still relying on OPENSSL_NO_THREADS should be updated to
either use OPENSSL_NO_THREADS_CORRUPT_MEMORY_AND_LEAK_SECRETS_IF_THREADED if a
single-threaded-only platform, or fixed to depend on the platform threading
library.

Change-Id: I02ec63bc7ede892bd6463f1a23e2cec70887fab3
Reviewed-on: https://boringssl-review.googlesource.com/c/32744
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-10-30 21:08:25 +00:00
David Benjamin 32345ce6f2 Minor fixes to bytestring.h header.
Ryan noticed that CBS_ASN1_{SEQUENCE,SET} used CBS_ASN1_CONSTRUCTED
before it was defined. The C preprocessor expands late, so this works,
but it is weird. Flip the order.

There was also some question about the constructed bit, which is
different from how ASN.1 formally specifies it. (ASN.1 believes the
constructed bit is a property of the element, not the tag. We fold it in
because it's entirely computable[*] from the type in DER, so it's easier
to fold it in.) Move existing text to the section header and expand on
it.

[*] DER forbids constructed strings so string types are always
primitive. ASN.1 forbids implicitly tagging CHOICE or ANY, so the
inherited constructed bit cannot vary by value.

Change-Id: Ieb91f9d6898d582dda19fec8b042051b67f217a8
Reviewed-on: https://boringssl-review.googlesource.com/c/32725
Reviewed-by: Ryan Sleevi <rsleevi@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-10-30 21:00:45 +00:00
David Benjamin 42d723f634 Test CBC padding more aggressively.
tls_cbc.c is concerned with the variation in where the padding+mac may
end, counted in blocks. Hash blocks are larger than block cipher blocks,
and the hash itself appends some padding. Thus maximal padding off a
64-hash.Size() bytes may not fully stress things.

Just run all inputs modulo the hash block size, so we don't have to
think very hard about the "most difficult" input.

Change-Id: I8da1427dfff855931c14a9135c22afbff4f367c0
Reviewed-on: https://boringssl-review.googlesource.com/c/32724
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-10-30 20:53:00 +00:00
David Benjamin ad898b1fb9 Restore CHECKED_CAST.
Although this macro is not public API and is unused in BoringSSL,
wpa_supplicant uses it to define its own stacks. Remove this once
wpa_supplicant has been fixed.

Change-Id: I1f85e06efe4057b6490bf93bf4dea773dcb491c5
Reviewed-on: https://boringssl-review.googlesource.com/c/32764
Reviewed-by: Robert Sloan <varomodt@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-10-30 20:47:00 +00:00
armfazh 144d924e0b Fix EVP_tls_cbc_digest_record is slow using SHA-384 and short messages
Symptom: When using larger hash functions and short messages,
these six blocks take too much time to be conditionally copied.

Observations:
 - SHA-384 consumes more data per iteration, unlike SHA-256.
 - The value of `kVarianceBlocks` must depend on the parameters
   of the selected hash algorithm.
 - Avoid magic constants.

Changes:
 - A new formula for the kVarianceBlocks value.
 - Stronger test vectors were created in change: 32724.
 - The new formula passes these tests.

Discussion:
 OpenSSL team: https://github.com/openssl/openssl/pull/7342
 Quoting mattcaswell:
> The "real" data that needs to be hashed has to be padded for the
> hashing algorithm. For SHA1 the smallest amount of padding that
> can be added is the "0x80" byte plus 8 bytes containing the message
> length, i.e. 9 bytes. If the data length is within 9 bytes of the
> end of the hash block boundary then the padding will push it into
> an extra block to be hashed.

Change-Id: Id1ad2389927014316eed2b453aac6e4c2a585c5c
Reviewed-on: https://boringssl-review.googlesource.com/c/32624
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-10-29 18:26:27 +00:00
David Benjamin aa8d29dbd1 Tidy up dsa_sign_setup.
This function is not exported, so we don't need the optional BN_CTX
logic. Additionally, the cleanup code can be made a bit simpler and more
idiomatic.

Change-Id: Ib326eab4813fd9de9ac1df8fdc9e470c26aff092
Reviewed-on: https://boringssl-review.googlesource.com/c/32704
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-10-25 21:51:57 +00:00
David Benjamin 53d9fdd548 Fix the build on glibc 2.15.
glibc didn't add getauxval or sys/auxv.h until 2.16. glib 2.16.0 is six
years old and thus glibc 2.15 is past our support horizon, however
Android is using an outdated sysroot. Temporarily allow this until they
fix their toolchain.

Change-Id: I24e231cf40829e446969f67bf15c32e0b007de4c
Reviewed-on: https://boringssl-review.googlesource.com/c/32686
Reviewed-by: Robert Sloan <varomodt@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-10-24 17:39:48 +00:00
David Benjamin 749d187063 Modernize OPENSSL_COMPILE_ASSERT.
MSVC 2015 supports the static_assert keyword in C mode (not quite what C11
specifies: _Static_assert is the keyword and static_assert is a macro in
assert.h, but close enough). GCC and Clang both support _Static_assert at all C
versions. GCC has supported it in GCC 4.6.

glibc supports the assert.h macro since glibc 2.16, but does condition it on
the version, so we likely can't rely on that yet. Still, this means we should
be able to rely on proper static assertions at this point. In particular, this
means we'd no longer worry about emitting multiple typedefs of the same name.

Though at some point, it'd be nice to rely on being built in C11 mode. Then we
can just pull in assert.h and use bare static_assert, and the atomics business
needn't be a build flag.

Update-Note: If static asserts break the build, it's this CL's fault.
Change-Id: I1b09043aae41242f6d40386c063e381d00b028d8
Reviewed-on: https://boringssl-review.googlesource.com/c/32604
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-10-24 00:55:44 +00:00
Robert Sloan 127a1ec080 Fix redefinition of AEAD asserts in e_aes.c.
Following https://boringssl-review.googlesource.com/c/32506. Many parts
of android don't have c11 support, and so they complain when these
asserts implicitly redefine, e.g. AEAD_state_too_small.

Failure reference: https://android-build.googleplex.com/builds/pending/P6876320/aosp_cf_x86_phone-userdebug/latest/view/logs/build_error.log

Change-Id: Icbdd9aec6bf3b3d87e15d7f4f37505a1639b59c0
Reviewed-on: https://boringssl-review.googlesource.com/c/32684
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-10-24 00:29:29 +00:00
Robert Sloan b64c53fcfd Guard sys/auxv.h include on !BORINGSSL_ANDROID.
Some versions of Android libc don't even include the header.

Change-Id: Ib1033d2b8a10ba69d834ac1ed2564870e0e35d61
Reviewed-on: https://boringssl-review.googlesource.com/c/32664
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-10-23 18:20:59 +00:00
Adam Langley 35fb591f24 Flatten EVP_AEAD_CTX
An EVP_AEAD_CTX used to be a small struct that contained a pointer to
an AEAD-specific context. That involved heap allocating the
AEAD-specific context, which was a problem for users who wanted to setup
and discard these objects quickly.

Instead this change makes EVP_AEAD_CTX large enough to contain the
AEAD-specific context inside itself. The dominant AEAD is AES-GCM, and
that's also the largest. So, in practice, this shouldn't waste too much
memory.

Change-Id: I795cb37afae9df1424f882adaf514a222e040c80
Reviewed-on: https://boringssl-review.googlesource.com/c/32506
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-10-22 23:12:57 +00:00
Jeremy Apthorp c0c9001440 Implement SSL_get_tlsext_status_type
It's used by Node.js[1], and is simple to implement.

[1]: https://github.com/nodejs/node/blob/e2f58c71ddf0f91256cc85e6bb226a068256c5eb/src/node_crypto.cc#L2390

Change-Id: Ie5c76b848623d00f7478aeae0214c25472de523c
Reviewed-on: https://boringssl-review.googlesource.com/c/32525
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-10-19 00:30:32 +00:00
David Benjamin 6f579c0e9e Fix documentation sectioning.
Sections are separated by two blank lines.

Change-Id: If4f94a3b8f96044e83ab116e7603f1654130a551
Reviewed-on: https://boringssl-review.googlesource.com/c/32584
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-10-18 19:53:35 +00:00
David Benjamin cbfe4f5a8e Remove support for GCC 4.7.
This reverts https://boringssl-review.googlesource.com/24924. As noted
there, GCC 4.7 support ends 2018-03-23, which has passed. GCC 4.8.0 was
released 2013-03-22, so we are now past the five year mark, matching
Abseil's guidelines.

Abseil also now explicitly lists supported compilers and explicitly
requires GCC 4.8+. https://abseil.io/docs/cpp/platforms/platforms

gRPC also now requires 4.8 per
https://github.com/grpc/grpc/issues/10036#issuecomment-290248204

Update-Note: On the off chance someone was using GCC 4.7, which only
started working in January, that'll no longer work.

Change-Id: Ie017822e903f98293e7b5e9bda10f104f17be7b3
Reviewed-on: https://boringssl-review.googlesource.com/c/32564
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-10-18 19:01:20 +00:00
Adam Langley dd412c428a Print the name of the binary when blocking in getrandom.
If a startup process blocks, it's very useful to know which it was.

Change-Id: I04dd541695a61cfceb8142ea45d4bd5e3492c6ec
Update-note: updates internal bug 117227663.
Reviewed-on: https://boringssl-review.googlesource.com/c/32544
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-10-18 18:13:12 +00:00
Adam Langley f8a8946841 Undo recent changes to |X509V3_EXT_conf_nid|.
cryptography.io wraps this function and so we have to keep the LHASH_OF
argument for now.

Change-Id: I4e071dee973c3931a4005678ce4135161a5861bd
Reviewed-on: https://boringssl-review.googlesource.com/c/32524
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-10-17 21:05:45 +00:00
David Benjamin 4b968339e3 Add a compatibility EVP_CIPH_OCB_MODE value.
Node references it these days. Also replace the no-op modes with negative
numbers rather than zero. Stream ciphers like RC4 report a "mode" of zero, so
code comparing the mode to a dummy value will get confused.

(I came across https://github.com/nodejs/node/pull/23635, though we'd have run
into it sooner or later anyway. Better to just define the value and avoid ifdef
proliferation.)

Change-Id: I223f25663e138480ad83f35aa16f5218f1425563
Reviewed-on: https://boringssl-review.googlesource.com/c/32464
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-10-16 19:41:50 +00:00
Aaron Green 0e150027f9 [util] Mark srtp.h as an SSL header file
This CL adds srtp.h to the list of SSLHeaderFiles, in order to move it
from ssl_h_files to crypto_h_files. The header file only includes an
inclusion of ssl.h. ssl_h_files can depend on crypt_h_files but not the
other way around.

Change-Id: If7410624a8b2bbbd5afb7f66ec6f491968faf24e
Reviewed-on: https://boringssl-review.googlesource.com/c/32505
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-10-16 19:26:06 +00:00
Aaron Green 8c659c1fce [rand] Disable RandTest.Fork on Fuchsia
This CL omits the RandTest.Fork unit test on Fuchsia, which does not
have fork().  Fuchsia has a bug (SEC-140) to create a suitable
replacement test.

Change-Id: Ic42f9149c24dc7321bfac1c718e9ecbb4a18b5d0
Reviewed-on: https://boringssl-review.googlesource.com/c/32504
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-10-16 18:57:29 +00:00
David Benjamin 6650898e09 Remove -fsanitize-cfi-icall-generalize-pointers.
Bug: chromium:785442
Change-Id: Ia073fcae716541bc9d008e3e2148e9f0ac30e637
Reviewed-on: https://boringssl-review.googlesource.com/c/32121
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-10-15 23:54:44 +00:00
David Benjamin b68b832238 Fix undefined function pointer casts in LHASH.
Bug: chromium:785442
Change-Id: I516e42684b913dc0de778dd9134f1ca108c04dfc
Reviewed-on: https://boringssl-review.googlesource.com/c/32120
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-10-15 23:53:24 +00:00
David Benjamin 1eff9482ca Use proper functions for lh_*.
As with sk_*, this. This doesn't fix the function pointer casts. Those
will be done in a follow-up change. Also add a test for lh_*_doall so we
cover both function pointer shapes.

Update-Note: This reworks how LHASH_OF(T) is implemented and also only
pulls in the definitions where used, but LHASH_OF(T) is never used
externally, so I wouldn't expect this to affect things.

Change-Id: I7970ce8c41b8589d6672b71dd03658d0e3bd89a7
Reviewed-on: https://boringssl-review.googlesource.com/c/32119
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-10-15 23:37:04 +00:00
Adam Langley b018908475 Better handle AVX-512 assembly syntax.
https://boringssl-review.googlesource.com/c/boringssl/+/24945 was mistaken in
that it thought that these AVX-512 assembly extensions were an
instruction-level thing, whereas they actually appear to be an argument-level
modifier.

This change parses them as such and unbreaks some AVX-512 instructions that can
be emitted by compilers with certain combinations of flags.

Change-Id: I9af5a4fec21f55d3198a248c9175252e229c355a
Reviewed-on: https://boringssl-review.googlesource.com/c/32484
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-10-15 23:31:23 +00:00
David Benjamin 80aa694975 Always push errors on BIO_read_asn1 failure.
This is consistent with the old behavior of d2i_*_fp and avoids tripping
Conscrypt's unnecessarily fragile error-handling (see
https://github.com/google/conscrypt/pull/552).

Additionally, by source inspection, CPython expects
ASN1_R_HEADER_TOO_LONG on EOF, analogously to PEM_R_NO_START_LINE. Fix
that. The other errors are a bit haphazard in the old implementation
(that code is really hard to follow), so I didn't match it too
carefully. In particular, OpenSSL would report ASN1_R_HEADER_TOO_LONG on
some generic tag parsing, but that is inconsistent with
ASN1_R_HEADER_TOO_LONG being an EOF signal.

Update-Note: https://boringssl-review.googlesource.com/32106 may have
caused some compatibility issues. This should fix it.

Change-Id: Idfe2746ffd7733de4338e14c58a40753e98a791e
Reviewed-on: https://boringssl-review.googlesource.com/c/32444
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-10-11 19:53:15 +00:00
David Benjamin 2d98d49cf7 Add a per-SSL TLS 1.3 downgrade enforcement option and improve tests.
Due to non-compliant middleboxes, it is possible we'll need to do some
surgery to this mechanism. Making it per-SSL is a little more flexible
and also eases some tests in Chromium until we get its SSL_CTX usage
fixed up.

Also fix up BoringSSL tests. We forgot to test it at TLS 1.0 and use the
-expect-tls13-downgrade flag.

Bug: 226
Change-Id: Ib39227e74e2d6f5e1fbc1ebcc091e751471b3cdc
Reviewed-on: https://boringssl-review.googlesource.com/c/32424
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-10-10 19:50:19 +00:00
Yoshisato Yanagisawa e341802802 Fix div.c to divide BN_ULLONG only if BN_CAN_DIVIDE_ULLONG defined.
Since clang-cl uses __udivti3 for __uint128_t division, linking div.obj
fails.  Let me make div.c use BN_CAN_DIVIDE_ULLONG to decide using
__uint128_t division instead of BN_ULLONG.

Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=787617
Change-Id: I3ebe245f6b8917d59409591992efbabddea08187
Reviewed-on: https://boringssl-review.googlesource.com/c/32404
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-10-10 15:33:35 +00:00
Aaron Green 28babde159 Include aes.h in mode/internal.h
block128_f was recently changed to take an AES_KEY instead of a void*,
but AES_KEY is not defined in base.h.  internal.h should not depend on
other sources to include aes.h for it.

Change-Id: I81aab5124ce4397eb76a83ff09779bfaea66d3c1
Reviewed-on: https://boringssl-review.googlesource.com/32364
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-10-03 17:36:04 +00:00
David Benjamin 62a4dcd256 Fix section header capitalization.
We only capitalize the first word. I've left Token Binding alone because
that appears to be the full name. But "QUIC Transport Parameters" just
describe's QUIC's transport parameters.

Change-Id: I7e0f69e24ff4080c0470c87825dffa1a9aa6df97
Reviewed-on: https://boringssl-review.googlesource.com/c/32344
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-10-03 16:23:08 +00:00
David Benjamin e1ee0f5b47 Fix build in consumers that flag unused parameters.
Change-Id: I4ec8a21264c2c73ebf8ca6a93b96eba29bd2d29e
Reviewed-on: https://boringssl-review.googlesource.com/c/32345
Reviewed-by: Robert Sloan <varomodt@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-10-02 22:49:32 +00:00
Aaron Green c1eef7f795 [perlasm] Hide OPENSSL_armcap_P in assembly
This CL changes adds a ".hidden OPENSSL_armcap_P" statement to the
".comm OPENSSL_armcap_P" statements for the sha*-armv8.pl files,
similar to what was doen for the sha*-armv4.pl files in CL 3471.

Change-Id: I524b3dce7e5cfe017498847fbf9b8a5df4b98fce
Reviewed-on: https://boringssl-review.googlesource.com/c/32324
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-10-02 20:36:43 +00:00
David Benjamin ce00828c89 Test the binary search more aggressively.
https://boringssl-review.googlesource.com/c/boringssl/+/32115/ wasn't
worth it, but we may as well keep the test.  Also add a comment about
the asymptotics in case it ever comes up.

Change-Id: Ic4773106f1003adc56b4ce36520a18d3ac2d6f13
Reviewed-on: https://boringssl-review.googlesource.com/32284
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-10-02 00:02:19 +00:00
David Benjamin fac6fb99da Opaquify CONF.
This removes the last mention of LHASH in public headers. This can only
break people who stack-allocate CONF or access the data field. The
latter does not happen (external code never calls lh_CONF_VALUE_*
functions). The former could not work as there would be no way to clean
it up.

Update-Note: CONF is now opaque.
Change-Id: Iad3796c4e75874530d7a70fde2f84a390def2d49
Reviewed-on: https://boringssl-review.googlesource.com/32118
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-10-01 23:56:19 +00:00
David Benjamin 9e97c022e6 Bring Mac and iOS builders back to the CQ.
The vpython issue appears to have gone away and hermetic Xcode sorted
out the other problem.

Bug: chromium:888687, chromium:890351
Change-Id: I9da893b7f21f0bc7c03e1e70c0e3e86f9720cec1
Reviewed-on: https://boringssl-review.googlesource.com/32304
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-10-01 23:31:45 +00:00
David Benjamin e17e14dfe1 Remove LHASH_OF mention in X509V3_EXT_conf_nid.
Everyone calls this with NULL anyway. People never actually use
lh_CONF_VALUE_* functions (or any other lh_* functions for that matter).

Also remove unused X509V3_EXT_CRL_add_conf prototype.

This removes one of the last mentions of LHASH_OF in public headers.

Update-Note: X509V3_EXT_conf_nid calls that pass a non-NULL first
    parameter will fail to compile.

Change-Id: Ia6302ef7b494efeb9b63ab75a18bc340909dcba3
Reviewed-on: https://boringssl-review.googlesource.com/32117
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-10-01 23:26:40 +00:00
David Benjamin a943613e40 Inline functions are apparently really complicated.
C and C++ handle inline functions differently. In C++, an inline function is
defined in just the header file, potentially emitted in multiple compilation
units (in cases the compiler did not inline), but each copy must be identical
to satsify ODR. In C, a non-static inline must be manually emitted in exactly
one compilation unit with a separate extern inline declaration.

In both languages, exported inline functions referencing file-local symbols are
problematic. C forbids this altogether (though GCC and Clang seem not to
enforce it). It works in C++, but ODR requires the definitions be identical,
including all names in the definitions resolving to the "same entity". In
practice, this is unlikely to be a problem, but an inline function that returns
a pointer to a file-local symbol could compile oddly.

Historically, we used static inline in headers. However, to satisfy ODR, use
plain inline in C++, to allow inline consumer functions to call our header
functions. Plain inline would also work better with C99 inline, but that is not
used much in practice, extern inline is tedious, and there are conflicts with
the old gnu89 model: https://stackoverflow.com/questions/216510/extern-inline

For dual C/C++ code, use a macro to dispatch between these. For C++-only
code, stop using static inline and just use plain inline.

Update-Note: If you see weird C++ compile or link failures in header
    functions, this change is probably to blame. Though this change
    doesn't affect C and non-static inline is extremely common in C++,
    so I would expect this to be fine.

Change-Id: Ibb0bf8ff57143fc14e10342854e467f85a5e4a82
Reviewed-on: https://boringssl-review.googlesource.com/32116
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-10-01 22:57:00 +00:00
David Benjamin 7c3ce519e8 Actually disable RandTest.Fork on iOS.
TARGET_OS_IPHONE isn't defined without including <TargetConditionals.h>. Oops.
Confirmed now that OPENSSL_IOS gets defined where we expect.

Update-Note: There is some chance this will fail to build on some macOS host
builds of Android? https://codereview.chromium.org/538563002 suggests something
weird happens. However those Android builds of BoringSSL would already be
problematic because they'd set OPENSSL_STATIC_ARMCAP thinking they were iOS.
Thus I've intentionally kept the assumption that __APPLE__ implies a Darwin
target. If it goes through, all is well. If not, we'll learn more about that
configuration and that we likely need to revise our OPENSSL_APPLE definition.

Bug: chromium:890115
Change-Id: I1df73ac2321391d2449edbeb9cfa295fd607f935
Reviewed-on: https://boringssl-review.googlesource.com/32204
Reviewed-by: Adam Langley <agl@google.com>
2018-10-01 20:34:39 +00:00
David Benjamin 52483994c8 Mostly fix undefined casts around STACK_OF's comparator.
The calls to qsort and bsearch are still invalid, but not avoidable
without reimplementing them. Fortunately, they cross libraries, so CFI
does not object.

With that, all that's left is LHASH!

Bug: chromium:785442
Change-Id: I6d29f60fac5cde1f7870d7cc515346e55b98315b
Reviewed-on: https://boringssl-review.googlesource.com/32114
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-10-01 20:25:15 +00:00
David Benjamin fb4e2e0f0c Fix undefined casts in sk_*_pop_free and sk_*_deep_copy.
Unfortunately, some projects are calling into sk_pop_free directly, so
we must leave a compatibility version around for now.

Bug: chromium:785442
Change-Id: I1577fce6f23af02114f7e9f7bf2b14e9d22fa9ae
Reviewed-on: https://boringssl-review.googlesource.com/32113
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-10-01 20:04:07 +00:00
David Benjamin cbc3e076fc Take iOS builders out of the CQ rotation too.
Bug: chromium:890351
Change-Id: Ia11b2b97f25d0c37e491641db6c48aa37c03de30
Reviewed-on: https://boringssl-review.googlesource.com/32224
Reviewed-by: Adam Langley <agl@google.com>
2018-10-01 17:41:54 +00:00
David Benjamin 792c1dc43e Rewrite PEM_X509_INFO_read_bio.
This fixes:

- Undefined function pointer casts.
- Missing X509_INFO_new malloc failure checks.
- Pointless (int) cast on strlen.
- Missing ERR_GET_LIB in PEM_R_NO_START_LINE check.
- Broken error-handling if passing in an existing stack and we hit a
  syntax error.

Bug: chromium:785442
Change-Id: I8be3523b0f13bdb3745938af9740d491486f8bf1
Reviewed-on: https://boringssl-review.googlesource.com/32109
Reviewed-by: Adam Langley <agl@google.com>
2018-10-01 17:35:10 +00:00
David Benjamin 73535ab252 Fix undefined block128_f, etc., casts.
This one is a little thorny. All the various block cipher modes
functions and callbacks take a void *key. This allows them to be used
with multiple kinds of block ciphers.

However, the implementations of those callbacks are the normal typed
functions, like AES_encrypt. Those take AES_KEY *key. While, at the ABI
level, this is perfectly fine, C considers this undefined behavior.

If we wish to preserve this genericness, we could either instantiate
multiple versions of these mode functions or create wrappers of
AES_encrypt, etc., that take void *key.

The former means more code and is tedious without C++ templates (maybe
someday...). The latter would not be difficult for a compiler to
optimize out. C mistakenly allowed comparing function pointers for
equality, which means a compiler cannot replace pointers to wrapper
functions with the real thing. (That said, the performance-sensitive
bits already act in chunks, e.g. ctr128_f, so the function call overhead
shouldn't matter.)

But our only 128-bit block cipher is AES anyway, so I just switched
things to use AES_KEY throughout. AES is doing fine, and hopefully we
would have the sense not to pair a hypothetical future block cipher with
so many modes!

Change-Id: Ied3e843f0e3042a439f09e655b29847ade9d4c7d
Reviewed-on: https://boringssl-review.googlesource.com/32107
Reviewed-by: Adam Langley <agl@google.com>
2018-10-01 17:35:02 +00:00
David Benjamin 419144adce Fix undefined function pointer casts in {d2i,i2d}_Foo_{bio,fp}
Lacking C++, this instead adds a mess of macros. With this done, all the
function-pointer-munging "_of" macros in asn1.h can also be removed.

Update-Note: A number of *really* old and unused ASN.1 macros were
removed.

Bug: chromium:785442
Change-Id: Iab260d114c7d8cdf0429759e714d91ce3f3c04b2
Reviewed-on: https://boringssl-review.googlesource.com/32106
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <alangley@gmail.com>
2018-10-01 17:34:53 +00:00
David Benjamin 217bfd3c96 Fix undefined function pointer casts in IMPLEMENT_PEM_*.
While it is okay to cast function pointers into different types for
generic storage, the pointer must be cast back to the exact same type
when calling. In particular, although C libraries do this sort of thing
all the time, calling a T* d2i function as a void* d2i function is
undefined:

  If the function is defined with a type that is not compatible with the
  type (of the expression) pointed to by the expression that denotes the
  called function, the behavior is undefined

Fix some instances in the PEM/ASN1 wrapper functions. Synthesize helper
functions instead.

This CL just addresses the function pointer issues. The inherited legacy
OpenSSL ASN.1 code is still full other questionable data pointer dances
that will be much more difficult to excise. Continuing to exise that
code altogether (it is already unshipped from Cronet and unshipped from
Chrome but for WebRTC) is probably a better tack there.

This removes one (of many many) places where we require
-fsanitize-cfi-icall-generalize-pointers.

Bug: chromium:785442
Change-Id: Id8056ead6ef471f0fdf263bb50dc659da500e8ce
Reviewed-on: https://boringssl-review.googlesource.com/32105
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <alangley@gmail.com>
2018-10-01 17:34:44 +00:00
Adam Langley 3474270abd Always print some diagnostic information when POST fails.
Debugging a POST failure when it prints nothing is painful. The
|check_test| helper already prints out information when it fails, but
some other paths were not handled. This change adds printfs for those
cases.

Change-Id: Ife71bb292a4f69679d0fa56686863aae9423e451
Updating-Note: updates internal bug 116469121
Reviewed-on: https://boringssl-review.googlesource.com/32145
Reviewed-by: David Benjamin <davidben@google.com>
2018-09-28 19:33:38 +00:00
David Benjamin 13fd627449 Disable RandTest.Fork on iOS.
iOS doesn't support fork.

Bug: chromium:890115
Change-Id: Idac6c0e180bbc1088ca5c562b8c1e646bff00b25
Reviewed-on: https://boringssl-review.googlesource.com/32164
Reviewed-by: Steven Valdez <svaldez@google.com>
2018-09-28 15:42:18 +00:00
David Benjamin 8d2f4b993f Const-correct sk_find and sk_delete_ptr.
Change-Id: I7ddc2c4827602ddac2a4aec5f9ccfa21d6c0bc40
Reviewed-on: https://boringssl-review.googlesource.com/32112
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <alangley@gmail.com>
2018-09-27 16:18:18 +00:00
David Benjamin 892a31b5fb Add a test for STACK_OF(T).
Amazingly, this module didn't have a unit test yet.

Change-Id: I021bb83cc747174196958db14c97154f0574c2e8
Reviewed-on: https://boringssl-review.googlesource.com/32111
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-09-26 23:28:50 +00:00
Matthew Braithwaite 7039f40368 Rename inject-hash: Bazel does not like hyphens.
(Only in package names.  Hyphens in file names are file.)

Change-Id: I80b705a780ffbad056abe7a7868d5682b30d2d44
Reviewed-on: https://boringssl-review.googlesource.com/32144
Commit-Queue: Matt Braithwaite <mab@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-09-26 21:50:36 +00:00
David Benjamin 5b33effa72 Rename OPENSSL_NO_THREADS, part 1.
BoringSSL depends on the platform's locking APIs to make internal global
state thread-safe, including the PRNG. On some single-threaded embedded
platforms, locking APIs may not exist, so this dependency may be disabled
with a build flag.

Doing so means the consumer promises the library will never be used in any
multi-threaded address space. It causes BoringSSL to be globally thread-unsafe.
Setting it inappropriately will subtly and unpredictably corrupt memory and
leak secret keys.

Unfortunately, folks sometimes misinterpreted OPENSSL_NO_THREADS as skipping an
internal thread pool or disabling an optionally extra-thread-safe mode. This is
not and has never been the case. Rename it to
OPENSSL_NO_THREADS_CORRUPT_MEMORY_AND_LEAK_SECRETS_IF_THREADED to clarify what
this option does.

Update-Note: As a first step, this CL makes both OPENSSL_NO_THREADS and
OPENSSL_NO_THREADS_CORRUPT_MEMORY_AND_LEAK_SECRETS_IF_THREADED work. A later CL
will remove the old name, so migrate callers after or at the same time as
picking up this CL.

Change-Id: Ibe4964ae43eb7a52f08fd966fccb330c0cc11a8c
Reviewed-on: https://boringssl-review.googlesource.com/32084
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-09-26 19:10:02 +00:00
David Benjamin 1764d7a3ea Fix ERR_GET_REASON checks.
Reason codes across libraries may collide. One must never check
ERR_GET_REASON without also checking ERR_GET_LIB.

Change-Id: I0b58ce27a5571ab173d231c1a673bce1cf0427aa
Reviewed-on: https://boringssl-review.googlesource.com/32110
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <alangley@gmail.com>
2018-09-26 19:02:42 +00:00
David Benjamin e7692f5598 Add a basic test for PEM_X509_INFO_read_bio.
This format is kind of silly, but it seems not completely unused? Add a
basic test for it before I rewrite it to fix the function pointer casts.

Change-Id: Ib2d1563419b72cf468180b9cda4d13e216b7eb3a
Reviewed-on: https://boringssl-review.googlesource.com/32108
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <alangley@gmail.com>
2018-09-26 17:42:58 +00:00
David Benjamin fb86b888ef Replace BIO_new + BIO_set_fp with BIO_new_fp.
It's a little bit shorter.

Change-Id: Ia1ba55d20ee4f2519a017871f5f5949081569e1a
Reviewed-on: https://boringssl-review.googlesource.com/32104
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-09-26 17:21:08 +00:00
David Benjamin c93711b1b5 Remove Mac try jobs from the CQ.
They're not working right now.

Bug: chromium:888687
Change-Id: I723a382d666e24c4f7f35c7b9369341b4bdebf1a
Reviewed-on: https://boringssl-review.googlesource.com/32124
Reviewed-by: Adam Langley <agl@google.com>
2018-09-26 17:09:56 +00:00
Joshua Liebow-Feeser 066b108957 Add util/read_symbols.go
- Add util/read_symbols.go to read exported symbols from an AR
  file for use with the symbol prefixing feature
- Move util/fipstools/fipscommon/ar.go -> util/ar/ar.go
- util/ar/ar.go: Support BSD-style AR files

Change-Id: I171b3b952e69c4b87ac04751b7dba3ea9bc2504e
Reviewed-on: https://boringssl-review.googlesource.com/32024
Reviewed-by: David Benjamin <davidben@google.com>
2018-09-24 20:25:48 +00:00
Adam Langley 5ede28c8a4 Tighten up getrandom handling.
While I don't believe EINTR can occur with a non-blocking getrandom call
when talking to the kernel directly, that may not be true when certain
sandboxing systems are being used.

Additionally, with this change we will no longer silently ignore errors
other than ENOSYS.

Update-Note: update internal bug 115344138.

Change-Id: I952c132cf325dcc17dc38e68f054abc41de1f8b0
Reviewed-on: https://boringssl-review.googlesource.com/32006
Reviewed-by: David Benjamin <davidben@google.com>
2018-09-20 16:15:51 +00:00
David Benjamin 4902598935 Remove SHA384_Transform from sha.h.
This function doesn't actually exist. (If it did, it would be the same as
SHA512_Transform. We currently omit SHA224 and SHA384's low-level transform
functions.)

Change-Id: Ia9d3d7c86e8f70fd5e4f13b8de4f08440dccbdcb
Reviewed-on: https://boringssl-review.googlesource.com/32064
Reviewed-by: Adam Langley <agl@google.com>
2018-09-20 14:57:36 +00:00
David Benjamin 371305f58a Push an error on sigalg mismatch in X509_verify.
It was failing but not pushing an error. See
https://github.com/google/conscrypt/pull/537

Change-Id: Iafba1a5c0c7ef8e0535b335aa93df6f520c3803e
Reviewed-on: https://boringssl-review.googlesource.com/32044
Reviewed-by: Adam Langley <agl@google.com>
2018-09-19 03:44:50 +00:00
David Benjamin ca4971cbae Sync bundled bits of golang.org/x/crypto.
We no longer need to fork them. This is in preparation for pulling it
via Go modules, but probably need to figure out the network issue first.
Slightly bad manners for CI to do that.

Change-Id: Ic258264f3c3559817d5e4921e4ad3282e94d05fe
Reviewed-on: https://boringssl-review.googlesource.com/31904
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-09-17 23:14:35 +00:00
David Benjamin 5baee45652 Use Go modules with delocate.
This makes running go test, etc., in util/fipstools/delocate work! This
adds a go_executable command to CMake like:

  go_executable(delocate boringssl.googlesource.com/boringssl/util/fipstools/delocate)

which internally gets dependencies and whatnot so it behaves like usual
Go.

Update-Note: delocate has been rearranged a bit.
Change-Id: I244a7317dd8d4f2ab77a0daa624ed3e0b385faef
Reviewed-on: https://boringssl-review.googlesource.com/31885
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-09-17 22:19:52 +00:00
David Benjamin 302ef5ee12 Keep the GCM bits in one place.
This avoids needing to duplicate the "This API differs [...]" comment.

Change-Id: If07c77bb66ecdae4e525fa01cc8c762dbacb52f1
Reviewed-on: https://boringssl-review.googlesource.com/32005
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-09-17 22:12:21 +00:00
David Benjamin 580be2b184 Trim 88 bytes from each AES-GCM EVP_AEAD.
EVP_AEAD reused portions of EVP_CIPHER's GCM128_CONTEXT which contains both the
key and intermediate state for each operation. (The legacy OpenSSL EVP_CIPHER
API has no way to store just a key.) Split out a GCM128_KEY and store that
instead.

Change-Id: Ibc550084fa82963d3860346ed26f9cf170dceda5
Reviewed-on: https://boringssl-review.googlesource.com/32004
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-09-17 22:05:51 +00:00
David Benjamin 0990a552eb Set up Go modules.
This should make it easier for us to reuse Go code properly.
util/fipstools is kind of a mess. runner has been using relative
imports, but Go seems to prefer this mechanism these days.

Update-Note: The import spelling in ssl/test/runner changes. Also we now
    require Go 1.11. Or you could clone us into GOPATH, but no one does
    that.

Change-Id: I8bf91e1e0345b3d0b3d17f5c642fe78b415b7dde
Reviewed-on: https://boringssl-review.googlesource.com/31884
Reviewed-by: Adam Langley <agl@google.com>
2018-09-17 21:04:17 +00:00
Chris Kennelly b5e4a225e4 Use sdallocx, if available, when deallocating.
Providing a size hint to the allocator is substantially faster,
especially as we already know/need the size for OPENSSL_cleanse.

We provide a weak symbol that falls back to free when a malloc with
sdallocx is not statically linked with BoringSSL.

Alternatives considered:
* Use dlsym():  This is prone to fail on statically linked binaries
  without symbols.  Additionally, the extra indirection adds call
  overhead above and beyond the linker resolved technique we're using.
* Use CMake rules to identify whether sdallocx is available:  Once the
  library is built, we may link against a variety of malloc
  implementations (not all of which may have sdallocx), so we need to
  have a fallback when the symbol is unavailable.

Change-Id: I3a78e88fac5b6e5d4712aa0347d2ba6b43046e07
Reviewed-on: https://boringssl-review.googlesource.com/31784
Reviewed-by: Chris Kennelly <ckennelly@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-09-17 21:02:59 +00:00
David Benjamin d1673c2191 Remove the add_alert hook.
This was added to support the no_certificate warning alert in SSLv3. That has
since been removed. In the long run, I would like for ssl_send_alert to go
through a flow similar to add_alert so the BIO-free APIs work right and avoid a
host of strangeness surrounding wpend_buf. For now, remove the unused hook.

Change-Id: I1995028b8af4ffa836028794e6b33b2cd1b2435b
Reviewed-on: https://boringssl-review.googlesource.com/31984
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-09-15 00:55:02 +00:00
David Benjamin 3f18c4c5b7 Fix doc.go error capitalization.
Change-Id: I98d31542563c15f8fa5a45db00f94d7a9aaa56bb
Reviewed-on: https://boringssl-review.googlesource.com/31964
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-09-14 20:47:26 +00:00
Adam Langley ff997452fc Don't include quotes in heredocs.
Unsurprisingly it doesn't work.

Change-Id: Ida2b9879184f2dfcce217559f8773553ecf0c33d
Reviewed-on: https://boringssl-review.googlesource.com/31947
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-09-14 16:51:00 +00:00
David Benjamin 5cf05ad21c Add missing bssl::UpRef overloads.
Change-Id: I840307526238219385ea6144739f5df78c596a4f
Reviewed-on: https://boringssl-review.googlesource.com/31946
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-09-14 16:45:54 +00:00
David Benjamin 350257db77 Roll back clang revision.
This picked up the Clang regression which broke the MSan bots. See
https://github.com/google/sanitizers/issues/993.

Change-Id: I9882efe3b7a2f62795e4387038008256744d6f57
Reviewed-on: https://boringssl-review.googlesource.com/31945
Reviewed-by: Adam Langley <agl@google.com>
2018-09-14 16:43:00 +00:00
David Benjamin 8b60cde1ad Update tools.
In particular, pull Go 1.11 to get module support. Also we don't need to
pull in libfuzzer anymore.

Change-Id: I8098f64cef59422d9d43f7eca5bf3ced69eb70c4
Reviewed-on: https://boringssl-review.googlesource.com/31864
Reviewed-by: Adam Langley <agl@google.com>
2018-09-13 17:57:30 +00:00
David Benjamin 689019fe40 Fix BORINGSSL_NO_CXX.
BSSL_NAMESPACE_BEGIN needs to be defined unconditionally.

Change-Id: I1770ca6b6c19f9c732ef00ba8c89b112b421929d
Reviewed-on: https://boringssl-review.googlesource.com/31824
Reviewed-by: Adam Langley <agl@google.com>
2018-09-11 16:39:42 +00:00
Phillipp Schoppmann bef6cc2933 Fix check of the pointer returned by BN_CTX_get
The check of `r` instead of `rr` was introduced in change
I298400b988e3bd108d01d6a7c8a5b262ddf81feb.

Change-Id: I4376a81c65856f6457b0a11276176bf35e9c647d
Reviewed-on: https://boringssl-review.googlesource.com/31844
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-09-11 16:35:22 +00:00
Adam Langley 695e589b0c Include newlines at the end of generated asm.
Perl's print doesn't automatically include a newline and the delocate
script doesn't like files that don't end with one.

Change-Id: Ib1bce2b3bb6fbe1a122bd88b58198b497c599adb
Reviewed-on: https://boringssl-review.googlesource.com/31804
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-09-10 16:47:13 +00:00
Adam Langley e77c27d734 Automatically disable assembly with MSAN.
MSAN is incompatible with hand-written assembly code. Previously we
required that OPENSSL_NO_ASM be set when building with MSAN, and the
CMake build would take care of this. However, with other build systems
it wasn't always so easy.

This change automatically disables assembly when the compiler is
configured for MSAN.

Change-Id: I6c219120f62d16b99bafc2efb02948ecbecaf87f
Reviewed-on: https://boringssl-review.googlesource.com/31724
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-09-07 21:12:37 +00:00
David Benjamin 967cd8219c Mark the C version of md5_block_data_order static.
This doesn't really matter, but once less visible symbol.

Change-Id: If4ee8cfe5c9db9d1c05ca74b8c6fee5cf3ea5a9b
Reviewed-on: https://boringssl-review.googlesource.com/31764
Reviewed-by: Adam Langley <agl@google.com>
2018-09-07 20:00:12 +00:00
Adam Langley d66809580a Reorder some extensions to better match Firefox.
Change-Id: I3e2056b3c958d0fc5f49c0caa5003dc37f598424
Reviewed-on: https://boringssl-review.googlesource.com/31264
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-09-07 17:59:18 +00:00
David Benjamin 19ac2666b9 Make symbol-prefixing work on ARM.
The assembly files need some includes. Also evp.h has some conflicting
macros. Finally, md5.c's pattern of checking if a function name is
defined needs to switch to checking MD5_ASM.

Change-Id: Ib1987ba6f279144f0505f6951dead53968e05f20
Reviewed-on: https://boringssl-review.googlesource.com/31704
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-09-07 17:43:05 +00:00
David Benjamin 4b85a94542 Document alternative functions to BIO_f_base64.
Also point out that we're a cryptography library, not a text encoding library.
Not that that'll dissuade anyone.

Change-Id: Ia324e08c5cdd108fa182d2610f80447262e0bd5c
Reviewed-on: https://boringssl-review.googlesource.com/31664
Reviewed-by: Adam Langley <agl@google.com>
2018-09-07 15:58:12 +00:00
David Benjamin 8525ff31ee Another batch of bools.
Change-Id: I5a7688b6e635e7ee6fc16173f9919bff16c4d59d
Reviewed-on: https://boringssl-review.googlesource.com/31604
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2018-09-07 15:06:55 +00:00
David Benjamin 632d1127df Add some RAND_bytes tests.
We're a far cry from the good old days when we just read from /dev/urandom
without any fuss...

In particular, the threading logic is slightly non-trivial and probably worth
some basic sanity checks. Also write a fork-safety test, and test the
fork-unsafe-buffering path.

The last one is less useful right now, since fork-unsafe-buffering is a no-op
with RDRAND enabled (although we do have an SDE bot...), but it's probably
worth exercising the code in
https://boringssl-review.googlesource.com/c/boringssl/+/31564.

Change-Id: I14b1fc5216f2a93183286aa9b35f5f2309107fb2
Reviewed-on: https://boringssl-review.googlesource.com/31684
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-09-06 23:54:57 +00:00
Joshua Liebow-Feeser 8c7c6356e6 Support symbol prefixes
- In base.h, if BORINGSSL_PREFIX is defined, include
  boringssl_prefix_symbols.h
- In all .S files, if BORINGSSL_PREFIX is defined, include
  boringssl_prefix_symbols_asm.h
- In base.h, BSSL_NAMESPACE_BEGIN and BSSL_NAMESPACE_END are
  defined with appropriate values depending on whether
  BORINGSSL_PREFIX is defined; these macros are used in place
  of 'namespace bssl {' and '}'
- Add util/make_prefix_headers.go, which takes a list of symbols
  and auto-generates the header files mentioned above
- In CMakeLists.txt, if BORINGSSL_PREFIX and BORINGSSL_PREFIX_SYMBOLS
  are defined, run util/make_prefix_headers.go to generate header
  files
- In various CMakeLists.txt files, add "global_target" that all
  targets depend on to give us a place to hook logic that must run
  before all other targets (in particular, the header file generation
  logic)
- Document this in BUILDING.md, including the fact that it is
  the caller's responsibility to provide the symbol list and keep it
  up to date
- Note that this scheme has not been tested on Windows, and likely
  does not work on it; Windows support will need to be added in a
  future commit

Change-Id: If66a7157f46b5b66230ef91e15826b910cf979a2
Reviewed-on: https://boringssl-review.googlesource.com/31364
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-09-06 20:07:52 +00:00
David Benjamin 492c9aa90c Fill in a fake session ID for TLS 1.3.
Historically, OpenSSL filled in a fake session ID for ticket-only
client sessions. Conscrypt relies on this to implement some weird Java
API where every session has an ID and may be queried out of the client
session cache and, e.g., revoked that way.

(Note that a correct client session cache is not keyed by session ID and
indeed this allows one server to knock out another server's sessions by
matching session IDs. But existing APIs are existing APIs.)

For consistency between TLS 1.2 and TLS 1.3, as well as matching
OpenSSL's TLS 1.3 implementation, do the same in TLS 1.3. Note this
smooths over our cross-version resumption tests by allowing for
something odd: it is now syntactically possible to resume a TLS 1.3
session at TLS 1.2. It doesn't matter either way, but now a different
codepath rejects certain cases.

Change-Id: I9caf4f0c3b2e2e24ae25752826d47bce77e65616
Reviewed-on: https://boringssl-review.googlesource.com/31525
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-09-06 18:12:11 +00:00
Adam Langley e84c375303 Create output directories for perlasm.
Flattening the build seems to have changed the order of actions when
using Make and output directories for perlasm are no longer created
before Perl is run. Additionally, if the output directory doesn't exist,
the perlasm scripts seem to output to stdout instead.

Change-Id: I59b801f7347951a3b9cef2ff084b28a00b2d5a3c
Reviewed-on: https://boringssl-review.googlesource.com/31645
Reviewed-by: Adam Langley <agl@google.com>
2018-09-06 15:47:57 +00:00
Adam Langley 3a08fbd2a4 Fix Fiat path.
(I'm not sure why this built anywhere, but it did.)

Change-Id: I47e5b9b689c597e38a74104ac9ddcadfc2fb063d
Reviewed-on: https://boringssl-review.googlesource.com/31644
Reviewed-by: Adam Langley <agl@google.com>
2018-09-06 15:38:25 +00:00
Adam Langley 3faf3db6d8 Fix GCC (8.2.1) build error.
Not sure that I think this is a very valid build error from GCC, but
it's easy enough to work around.

../crypto/cpu-arm-linux_test.cc: In member function ‘virtual void ARMLinuxTest_CPUInfo_Test::TestBody()’:
../crypto/cpu-arm-linux_test.cc:25:10: error: declaration of ‘struct ARMLinuxTest_CPUInfo_Test::TestBody()::Test’ shadows a previous local [-Werror=shadow]
   struct Test {
          ^~~~
In file included from ../crypto/cpu-arm-linux_test.cc:19:
../third_party/googletest/include/gtest/gtest.h:375:23: note: shadowed declaration is here
 class GTEST_API_ Test {

Change-Id: Icc1676a621ec26b3665adaf5daf7d6c6f5307ba8
Reviewed-on: https://boringssl-review.googlesource.com/31624
Reviewed-by: Adam Langley <agl@google.com>
2018-09-06 15:38:11 +00:00
David Benjamin 12f58786aa Some more bools.
Change-Id: I60d9e728c1ca5e788ee7df5e874fb6e8ea182fec
Reviewed-on: https://boringssl-review.googlesource.com/31524
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-09-06 13:49:57 +00:00
David Benjamin 681ff27720 Flatten most of the crypto target.
The fipsmodule is still separate as that's a lot of build mess. (Though
that too may be worth pulling in eventually. CMake usually has different
opinions on generated files if they're in the same directory. We might
be able to avoid the set_source_properties(GENERATED) thing.)

Change-Id: Ie1f9345009044d4f0e7541ca779e01bdc5ad62f6
Reviewed-on: https://boringssl-review.googlesource.com/31586
Reviewed-by: Adam Langley <agl@google.com>
2018-09-05 23:41:25 +00:00
David Benjamin 1fcae84a4f Flatten assembly files.
Change-Id: I37438652b7e73ce16e50b5b1b8ba011b5076ded8
Reviewed-on: https://boringssl-review.googlesource.com/31585
Reviewed-by: Adam Langley <agl@google.com>
2018-09-05 23:39:59 +00:00
David Benjamin d144539da6 Flatten the decrepit target.
https://boringssl-review.googlesource.com/c/boringssl/+/31364 wants to
add a dependency to each target, which is much easier with fewer of
them. Start with decrepit.

Change-Id: Ib3777063d545dfebe3e2b8448eb7e5bbb5c3aaac
Reviewed-on: https://boringssl-review.googlesource.com/31584
Reviewed-by: Adam Langley <agl@google.com>
2018-09-05 23:39:08 +00:00
David Benjamin 8e09d90142 Clarify "reference" and fix typo.
It was pointed out that "a reference" to C++ programmers means something
very different from what we intend.

Change-Id: I508196f8e3427ea71439c7871eae9b735a4fa5ca
Reviewed-on: https://boringssl-review.googlesource.com/31544
Reviewed-by: Adam Langley <agl@google.com>
2018-09-05 19:06:48 +00:00
David Benjamin 8cd61f710b Fix corner case in cpuinfo parser.
I realized looking at the sigalgs parser that I messed up the
space-splitting logic slightly. If the CPU features are "foo bar baz",
it would not parse "baz". This doesn't particular matter (the last one
is "crc32"), but better to parse it correctly.

Fix this and add a unit test. While I'm here, may as well add a fuzzer
too.

Change-Id: Ifc1603b8f70d975f391d10e51ede95deec31a83d
Reviewed-on: https://boringssl-review.googlesource.com/31464
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-09-05 00:00:14 +00:00
David Benjamin f016f814c8 Add some about ownership to API-CONVENTIONS.
In particular, we often don't say anything if using the "default" conventions,
but we don't say what those are.  We've also never documented
get0/get1/set0/set1.

Change-Id: I113593cfcdcb93e0009796649e4c19219e765caf
Reviewed-on: https://boringssl-review.googlesource.com/31504
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-09-04 23:36:09 +00:00
David Benjamin 92812cb73c Tidy up docs for #defines.
This removes the special-case for #defines in doc.go.

Change-Id: I6bf750485a94ad28c3975644c74a17c550bb3224
Reviewed-on: https://boringssl-review.googlesource.com/31505
Reviewed-by: Adam Langley <agl@google.com>
2018-09-04 22:32:01 +00:00
David Benjamin 53affef486 No negative moduli.
https://boringssl-review.googlesource.com/31085 wasn't right. We already forbid
creating BN_MONT_CTX on negative numbers, which means almost all moduli already
don't work with BN_mod_exp_mont. Only -1 happened to not get rejected, but it
computed the wrong value. Reject it instead.

Update-Note: BN_mod_exp* will no longer work for negative moduli. It already
didn't work for all negative odd moduli other than -1, so rejecting -1 and
negative evens is unlikely to be noticed.

Bug: 71
Change-Id: I7c713d417e2e6512f3e78f402de88540809977e3
Reviewed-on: https://boringssl-review.googlesource.com/31484
Reviewed-by: Adam Langley <agl@google.com>
2018-09-04 22:26:53 +00:00
Joshua Liebow-Feeser 67e64342c1 Document that ED25519_sign only fails on allocation failure
Change-Id: I45866c3a4aa98ebac51d4e554a22eb5add45002f
Reviewed-on: https://boringssl-review.googlesource.com/31404
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-08-29 18:35:12 +00:00
David Benjamin 2556f8ba60 Clarify thread-safety of key objects.
This often causes confusion since, for various silly reasons (intrinsic
ref-counting, FOO_METHOD, and RSA's cached Montgomery bits), the thread
safety of some functions don't match the usual const/non-const
distinction. Fix const-ness where easy and document it otherwise.

Change-Id: If2037a4874d7580cc79b18ee21f12ae0f47db7fd
Reviewed-on: https://boringssl-review.googlesource.com/31344
Reviewed-by: Ryan Sleevi <rsleevi@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-08-28 18:52:59 +00:00
Matthew Braithwaite e768212e7d shim: don't clear environment when invoking handshaker.
Change-Id: I266bf4dfbbc9b1867fbc91d44393c3f0a6ea9391
Reviewed-on: https://boringssl-review.googlesource.com/31405
Reviewed-by: Adam Langley <agl@google.com>
2018-08-28 17:50:26 +00:00
David Benjamin 6855e0a470 Switch the default TLS 1.3 variant to tls13_rfc.
Update-Note: If not explicitly configured to use tls13_all, callers that enable
TLS 1.3 will now only enable the final standard version.

Change-Id: Ifcfc65a9d8782c983df6e002925e8f77f45b6e53
Reviewed-on: https://boringssl-review.googlesource.com/31384
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-08-28 13:58:28 +00:00
Adam Langley 9c969bf491 Switch to Clang 6.0's fuzzer support.
With Clang 6.0, libFuzzer is now included and there's a new
-fsanitize=fuzzer command to enable the needed compiler actions.

Change-Id: If8c0d649f494655c5bb1e55ebdbf39450940c75b
Reviewed-on: https://boringssl-review.googlesource.com/31324
Reviewed-by: David Benjamin <davidben@google.com>
2018-08-27 17:18:56 +00:00
Adam Langley 7f4f41fa81 Don't depend on extension ordering to avoid an empty final extension.
In order to work around server bugs (see https://crbug.com/363583) we
need to ensure that the final extension is not empty. Doing this by
fixing the order of extensions is a little error-prone. Instead, insert
a padding extension to ensure this as neeeded.

Change-Id: I90760f2e6735082386c484c956a470aef38ed109
Reviewed-on: https://boringssl-review.googlesource.com/31284
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-08-23 23:36:15 +00:00
David Benjamin 23849f09af Fix TLS 1.3 downgrade tests.
The client downgrade detection tests were not asserting on the error (would
have caught the missing error string). Additionally, Downgrade-FalseStart-Draft
isn't testing what it's supposed to; it doesn't actually configure a draft
version or anything. Fix that and have it use ALPN rather than NPN, to match
the test above.

Change-Id: I0b759385641aa00994a912303a6f5bd65522b4bb
Reviewed-on: https://boringssl-review.googlesource.com/31204
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-08-22 15:47:11 +00:00
David Benjamin 1c2532ffe6 Fix error strings for SSL_R_TLS13_DOWNGRADE.
make_errors.go didn't seem to get run.

Change-Id: I12739fbab75b9f4898f73f206e404d101642b9c0
Reviewed-on: https://boringssl-review.googlesource.com/31184
Reviewed-by: Adam Langley <agl@google.com>
2018-08-22 01:26:47 +00:00
Steven Valdez 4ac9405eba Remove unused BORINGSSL_PREFIX.
Change-Id: Ifd7239106471bb59057b0a65c6e91837379c78bf
Reviewed-on: https://boringssl-review.googlesource.com/31164
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-08-21 14:53:16 +00:00
Joshua Liebow-Feeser 21558f43ce Document error behavior of PKCS5_PBKDF2_HMAC and EVP_PBE_scrypt
Change-Id: I5ce176538a53136aff3eea4af04b762ac9a5a994
Reviewed-on: https://boringssl-review.googlesource.com/31044
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-08-21 01:08:24 +00:00
Adam Langley 1c2779e819 Don't let a NULL mean the initial SSL_CTX in SSL_set_SSL_CTX.
We broke this a while back and nothing noticed. (Note dereference just
above.) Therefore I guess we don't need to support it.

Change-Id: I501d43825e89acb5f7f13998541dc8ff59452a99
Reviewed-on: https://boringssl-review.googlesource.com/31144
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-08-16 20:59:45 +00:00
Tom Bridgwater 929fd44f92 Update URL for GN quick start guide.
Bug: None
Change-Id: I01ea2bb0508b018e219ecc94108e6a4fbe247984
Reviewed-on: https://boringssl-review.googlesource.com/31124
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-08-16 20:18:41 +00:00
David Benjamin a130ce0b71 Update TLS 1.3 citations for the final RFC.
Change-Id: I2d1671a4f21a602191fd0c9b932244a376ac5713
Reviewed-on: https://boringssl-review.googlesource.com/31104
Reviewed-by: David Benjamin <davidben@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-08-16 18:37:50 +00:00
David Benjamin c4131a4a23 Support the allocating case of i2d_ASN1_{BOOLEAN,OBJECT}.
Imported from upstream's 0971432f6f6d8b40d797133621809bd31eb7bf4e and
7d4c97add12cfa5d4589880b09d6139c3203e2f4, but with missing tests added. Along
the way, make Bytes work with any Span<const uint8_t>-convertable type.

Change-Id: If365f981fe8a8274e12000309ffd99b1bb719842
Reviewed-on: https://boringssl-review.googlesource.com/31086
Reviewed-by: Adam Langley <agl@google.com>
2018-08-16 15:59:11 +00:00
David Benjamin 378cca8016 Handle a modulus of -1 correctly.
Historically, OpenSSL's modular exponentiation functions tolerated negative
moduli by ignoring the sign bit. The special case for a modulus of 1 should do
the same. That said, this is ridiculous and the only reason I'm importing this
is BN_abs_is_word(1) is marginally more efficient than BN_is_one() and we
haven't gotten around to enforcing positive moduli yet.

Thanks to Guido Vranken and OSSFuzz for finding this issue and reporting to
OpenSSL.

(Imported from upstream's 235119f015e46a74040b78b10fd6e954f7f07774.)

Change-Id: I526889dfbe2356753aa1e6ecfd3aa3dc3a8cd2b8
Reviewed-on: https://boringssl-review.googlesource.com/31085
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-08-16 15:57:10 +00:00
David Benjamin 01e8e625ad Don't allow RC4 in PEM.
This fixes uninitialized memory read reported by Nick Mathewson in
https://github.com/openssl/openssl/issues/6347.

It imports the memset from upstream's 2c739f72e5236a8e0c351c00047c77083dcdb77f,
but I believe that fix is incorrect and instead RC4 shouldn't be allowed in
this context. See
https://github.com/openssl/openssl/pull/6603#issuecomment-413066462 for
details.

Update-Note: Decoding a password-protected PEM block with RC4 will, rather than
derive garbage from uninitialized memory, simply fail. Trying to encode a
password-protect PEM block with an unsupported cipher will also fail, rather
than output garbage (e.g. tag-less AES-GCM).

Change-Id: Ib7e23dbf5514f0a523730926daad3c0bdb989417
Reviewed-on: https://boringssl-review.googlesource.com/31084
Reviewed-by: Adam Langley <agl@google.com>
2018-08-16 15:33:43 +00:00
Steven Valdez f1af129fb4 Implement TLS 1.3 anti-downgrade signal.
Change-Id: Ib4739350948ec339457d993daef582748ed8f100
Reviewed-on: https://boringssl-review.googlesource.com/30924
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-08-15 15:23:43 +00:00
Adam Langley ae3223957f Remove dummy PQ padding extension.
Results written up at https://www.imperialviolet.org/2018/04/11/pqconftls.html

Change-Id: I4614fbda555323c67a7ee4683441b59b995f97fb
Reviewed-on: https://boringssl-review.googlesource.com/31064
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-08-15 00:28:52 +00:00
Adam Langley cac346eddb Update Miller–Rabin check numbers.
This imports upstream's be4e1f79f631e49c76d02fe4644b52f907c374b2.

Change-Id: If0c4f066ba0ce540beaddd6a3e2540165d949dd2
Reviewed-on: https://boringssl-review.googlesource.com/31024
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-08-14 23:10:53 +00:00
Joshua Liebow-Feeser 978169951f Document error behavior of various functions
- Document error behavior of:
  - EVP_PKEY_assign_XXX
  - EVP_PKEY_set1_XXX
  - EVP_PKEY_assign
  - EVP_PKEY_set_type
  - EC_GROUP_new_by_curve_name
  - EC_KEY_set_group
  - ECDSA_size
  - HMAC_Final
- Document that EVP_parse_public_key sets the curve for EC keys

Change-Id: I498ae19a8729680216fee518f97bd0cbaab94c40
Reviewed-on: https://boringssl-review.googlesource.com/30985
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-08-14 20:42:21 +00:00
Joshua Liebow-Feeser dea6d90de2 Document failure conditions of some EVP, HMAC, and CBB functions
- Document failure conditions of EVP_MD_CTX_copy_ex,
  EVP_DigestInit_ex, HMAC_Init_ex, and CBB_init

Change-Id: I643d1b92e88e7f690fa555f7d908317a23e5cd95
Reviewed-on: https://boringssl-review.googlesource.com/30964
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-08-14 19:31:43 +00:00
David Benjamin 2865567748 Use Span/Array for ticket decryption.
This isn't actually shorter, but there is a bunch of slicing up of the ticket,
which Span makes a little easier to follow.

Change-Id: I7ea4dfe025641a3b88e2c9b8e34246fefc23412f
Reviewed-on: https://boringssl-review.googlesource.com/29865
Reviewed-by: Adam Langley <agl@google.com>
2018-08-14 19:00:34 +00:00
Jesse Selover 6b0d82229b Format ssl/internal.h with clang-format.
Fixed up the comment about ssl_version. There's one line which I
manually edited:
int (*check_client_CA_list)(STACK_OF(CRYPTO_BUFFER) *names);
where clang-format puts spaces on both sides of the second *.

Change-Id: Id1c0bd02f664df14b1e5bbd8abaf2687fb9179db
Reviewed-on: https://boringssl-review.googlesource.com/31004
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-08-14 17:50:40 +00:00
David Benjamin bc3286bb8c Add a pile of compatibility functions.
Change-Id: I75c8783139c717be34a9159a2291d2ae55ee71d5
Reviewed-on: https://boringssl-review.googlesource.com/30984
Reviewed-by: Adam Langley <agl@google.com>
2018-08-13 23:13:26 +00:00
Adam Langley 5e3c8a61ab Bound two other cases of PKCS#12 iteration counts.
The fuzzer found another place where it could cause a timeout by
providing a huge PBKDF2 iteration count. This change bounds another two
places where we parse out iteration counts and that's hopefully all of
them.

BUG=oss-fuzz:9853

Change-Id: I037fa09d2bee79e7435a9d40cbd89c07b4a9d443
Reviewed-on: https://boringssl-review.googlesource.com/30944
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-08-13 21:42:06 +00:00
Steven Valdez d451453067 Implement final TLS 1.3 RFC!!!
The anti-downgrade signal is being implemented in a follow-up change.

Change-Id: I5ea3ff429ed1389a3577026588fef3660d2d0615
Reviewed-on: https://boringssl-review.googlesource.com/30904
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
2018-08-13 20:34:23 +00:00
Jesse Selover 1c337e566d Option to reverify certs on resumption.
Works in the 1.3 and 1.2 client handshakes, not implemented on the
server for now.
Creates an SSL_CTX option to reverify the server certificate on session
resumption. Reverification only runs the client's certificate verify callback.
Adds new states to the client handshakes: state_reverify_server_certificate in
TLS 1.2, and state_server_certificate_reverify in TLS 1.3.
Adds a negative test to make sure that by default we don't verify the
certificate on resumption, and positive tests that make sure we do when the
new option is set.

Change-Id: I3a47ff3eacb3099df4db4c5bc57f7c801ceea8f1
Bug: chromium:347402
Reviewed-on: https://boringssl-review.googlesource.com/29984
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-08-10 20:06:22 +00:00
David Benjamin bdc409801f Add new curve/hash ECDSA combinations from Wycheproof.
Change-Id: I7bb36c4e4108a2b7d9481ab2cafc245ea31927c0
Reviewed-on: https://boringssl-review.googlesource.com/30847
Reviewed-by: Adam Langley <agl@google.com>
2018-08-10 18:26:06 +00:00
David Benjamin af37f84840 Add RSA-PSS tests from Wycheproof.
Along the way, split up the EVPTest Wycheproof tests into separate tests (they
shard better when running in parallel).

Change-Id: I5ee919f7ec7c35a7f2e0cc2af4142991a808a9db
Reviewed-on: https://boringssl-review.googlesource.com/30846
Reviewed-by: Adam Langley <agl@google.com>
2018-08-10 18:26:00 +00:00
David Benjamin f84c0dad7a Use newly-sharded ECDH tests.
Also remove some transition step for a recent format change. Together, this
removes the curve hacks in the converter, which can now be purely syntactic.
The RSA ones are still a bit all over the place in terms of sharded vs
combined, so leaving that alone for now.

Change-Id: I721d6b0de388a53a39543725e366dc5b52e83561
Reviewed-on: https://boringssl-review.googlesource.com/30845
Reviewed-by: Adam Langley <agl@google.com>
2018-08-10 18:25:51 +00:00
David Benjamin 367115b056 Fix SSL_CTX_set1_sigalgs fuzzer and make them all more type-safe.
The size of an int is 4, not 2. To avoid worrying about this, add a GetVector
counterpart to GetString that handles all this. Apply this uniformly to avoid
all the pointer casts. This is less important for vector<uint8_t>, but even
then we'll now notice a 1-byte OOB read since std::string is NUL-terminated.
Also it's shorter.

Change-Id: Ie96591cb8d8d52742f5fd30d70b6af0511109585
Reviewed-on: https://boringssl-review.googlesource.com/30864
Reviewed-by: Adam Langley <agl@google.com>
2018-08-10 18:24:36 +00:00
David Benjamin a711b53e0b Update Wycheproof test vectors.
This only updates the repository. We'll catch up with the new tests in a
subsequent commit.

Change-Id: I074a041479159ce1141af3241e7158599b648365
Reviewed-on: https://boringssl-review.googlesource.com/30844
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-08-10 17:56:29 +00:00
David Benjamin ad040c593f "Update" clang.
Chromium ended up reverting their most recent roll, so match that.

Change-Id: I54b6351591d9169651f450ec3e800c7c9c28735c
Reviewed-on: https://boringssl-review.googlesource.com/30806
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-08-10 16:39:23 +00:00
David Benjamin e6fd125d31 Align on a single CMake style.
We currently write a mix of "if (FOO)" and "if(FOO)". While the former looks
more like a usual language, CMake believes everything, even "if" and "else", is
just a really really funny function call (a "command").

We should pick something for consistency. Upstream CMake writes "if(FOO)", so
go with that one.

Change-Id: I67e0eb650a52670110b417312a362c9f161c8721
Reviewed-on: https://boringssl-review.googlesource.com/30807
Reviewed-by: Adam Langley <agl@google.com>
2018-08-10 16:22:31 +00:00
David Benjamin ddedf6d455 Fix SSL_CTX_set1_sigalgs_list fuzzer.
SSL_CTX_set1_sigalgs_list wants a NUL-terminated string, so we need to use
GetString to give it one.

Bug: oss-fuzz:9808
Change-Id: Id7f676aa514c36de9dea900763db3cbbf5c79a4c
Reviewed-on: https://boringssl-review.googlesource.com/30804
Reviewed-by: Adam Langley <agl@google.com>
2018-08-10 14:44:43 +00:00
David Benjamin 17dc94e874 Add -handshaker-path to run_test.
Otherwise ninja run_tests doesn't work right build directories named something
other than "build" on Linux.

Change-Id: I4d7ff319aed338870f5ac071e875fda549bbbd06
Reviewed-on: https://boringssl-review.googlesource.com/30824
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2018-08-10 14:31:47 +00:00
David Benjamin 678c841cbe Use -flto=thin in the CFI bot.
The CFI bot is currently failing on a mysterious error message, coming from the
recent clang roll.

  Called function is not the same type as the call!
    call void @EVP_MD_CTX_init(%struct.env_md_ctx_st* %8), !dbg !72123
  LLVM ERROR: Broken function found, compilation aborted!

Chromium actually passes -flto=thin, which seems to avoid the error, testing
locally. Why it does, I haven't the slightest clue. The offending calls to
EVP_MD_CTX_init (and EVP_MD_CTX_cleanup) are those buried in
bssl::ScopedEVP_MD_CTX. However, not all calls are problematic, only the one in
test_config.cc. What's more, if I add a call in async_bio.cc, linked into all
the same targets, the copy in test_config.cc is suddenly fine!?

Maybe there's just a bug in the LTO logic that ThinLTO avoids...

Change-Id: I5266eec75edea2a38dee8ad5591db8d65d3bdede
Reviewed-on: https://boringssl-review.googlesource.com/30805
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-08-10 14:18:28 +00:00
David Benjamin 4e446f27d0 Update citations to RFC 8410.
Confirmed the section numbers and sample key still match.

Change-Id: I6901154a54972a18e8a582a25d902c4fe760a0fc
Reviewed-on: https://boringssl-review.googlesource.com/30464
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-08-10 14:14:38 +00:00
David Benjamin 8625ec4b43 No-op commit to kick the bots.
Let's see if the TSan bot is working now.

Change-Id: Id86532f4cd2c4e216a0389c5030448afd707fdb7
Reviewed-on: https://boringssl-review.googlesource.com/30764
Reviewed-by: David Benjamin <davidben@google.com>
2018-08-09 23:09:23 +00:00
David Benjamin 69e91902f7 Work around missing MSan interceptor for posix_spawn.
Change-Id: I910dbfd0f6b0b4ef5a0c5155ee45a1658e1f4e70
Reviewed-on: https://boringssl-review.googlesource.com/30704
Reviewed-by: Adam Langley <agl@google.com>
2018-08-09 22:09:48 +00:00
David Benjamin e9ae99bba2 Add an option to statically link a custom libc++.
MSan and TSan both require instrumenting everything. Add some machinery so we
can do this on the bots.

Change-Id: I7d2106bc852ee976455d18787d3a20a35373a9e7
Reviewed-on: https://boringssl-review.googlesource.com/30644
Reviewed-by: Adam Langley <agl@google.com>
2018-08-09 21:37:04 +00:00
David Benjamin 1f0d54b8a1 Don't assert on uninitialized memory in tests.
ExpectTicketKeyChanged treats its input as an in/out parameter, but the first
time around there isn't a previous key. We could just call
SSL_CTX_get_tlsext_ticket_keys directly, but running it with the "previous"
keys as all zeros seems prudent; the ticket key rotation logic lazily
initializes keys and, were we to accidentally forget to initialize a key, the
zero key seems the most likely culprit.

Change-Id: I7167bef78e0bfcdb178195230ad84597f26d825c
Reviewed-on: https://boringssl-review.googlesource.com/30684
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-08-09 21:36:50 +00:00
David Benjamin 1beddac9ce Update tools.
Change-Id: Idb6818ad9b6af2b1cb604e71d936aaca7210aa57
Reviewed-on: https://boringssl-review.googlesource.com/30624
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-08-09 19:31:22 +00:00
Adam Langley 7c1f21a1d1 Add XChaCha20-Poly1305 AEAD.
This is a version of ChaCha20-Poly1305 that takes a 24-byte nonce,
making the nonce suitable for random generation. It's compatible with
the AEAD of the same name in libsodium.

Change-Id: Ie8b20ba551e5a290b390d362e487f06377166f4c
Reviewed-on: https://boringssl-review.googlesource.com/30384
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-08-09 18:49:09 +00:00
David Benjamin a3202d7bc1 Add EVP_CTRL_AEAD_* constants.
Upstream generalized most of the EVP_CTRL_GCM_* constants to be their general
AEAD API in 1.1.0. Define them for better compatibility with code that targets
OpenSSL 1.1.0.

Change-Id: Ieaed8379eebde3718e3048f6290c21cdeac01efd
Reviewed-on: https://boringssl-review.googlesource.com/30604
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-08-09 17:08:15 +00:00
Adam Langley 826ce15092 Support OpenSSL APIs SSL[_CTX]_set1_sigalgs[_list].
These functions can be used to configure the signature algorithms. One
of them is a string mini-languaging parsing function, which we generally
dislike because it defeats static analysis. However, some dependent
projects (in this case TensorFlow) need it and we also dislike making
people patch.

Change-Id: I13f990c896a7f7332d78b1c351357d418ade8d11
Reviewed-on: https://boringssl-review.googlesource.com/30304
Reviewed-by: Steven Valdez <svaldez@google.com>
2018-08-09 16:57:09 +00:00
David Benjamin e3ffaae0a3 Remove apparently unused cq_name field.
I got an automated email from the previous config update to remove this.

Change-Id: I45586d3bda3241a513bf2f6a8ec3b2a87fc4f2f9
Reviewed-on: https://boringssl-review.googlesource.com/30584
Reviewed-by: Ryan Tseng <hinoka@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-08-08 20:55:50 +00:00
David Benjamin ad8e29b00d Add linux_fuzz to the CQ.
We keep tripping it due to weird quirks in fuzzer mode.

Change-Id: Ie09113d42b24070b1749d38f56253bb7d9147f3f
Reviewed-on: https://boringssl-review.googlesource.com/30564
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-08-08 20:28:14 +00:00
Adam Langley 3314d1570c Escape backslashes in crypto test data.
embed_test_data.go assumes that it's working with 8KB chunks. However,
if the input file contains a '\' then the Go code thinks that it counts
as a byte, but the C compiler will probably merge it with the following
char and thus that string will be slightly too short. ASAN will detect
the out-of-bounds read when 8192 bytes are copied from the string.

Change-Id: If40ccfd39ea013bd6935fcc313cfe188fe985f67
Reviewed-on: https://boringssl-review.googlesource.com/30444
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-08-08 18:36:11 +00:00
Adam Langley 04e149f840 Set the fuzzer PBKDF2 limit to 2048.
Our test data uses values to up 2048 so the 1024 limit was causing tests
to fail in fuzzing mode.

Change-Id: I71b97be26376a04c13d1f438e5e36a5ffff1c1a4
Reviewed-on: https://boringssl-review.googlesource.com/30484
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-08-08 18:33:00 +00:00
Adam Langley c81965a8ad Set PBKDF2 limit in PKCS#12 to 100M.
The previous limit was |UINT_MAX|. Windows limits to 600K, but that's
already causing issues. This seems like a balance between being
completely crazy and still large enough not to have to worry for a long
time. It's still probably too large for backend systems wanting to
process arbitrary PKCS#12, but I don't think any fixed value will
satisfy all desires.

Change-Id: I01a3f78d5f2df086f8dbc0e8bacfb95153738f55
Reviewed-on: https://boringssl-review.googlesource.com/30424
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-08-08 17:09:36 +00:00
Adam Langley 2bcb315138 Limit the number of PBKDF2 iterations when fuzzing.
(Otherwise the fuzzer will discover that it can trigger extremely large
amounts of computation and start timing out.)

BUG=oss-fuzz:9767

Change-Id: Ibc1da5a90da169c7caf522f792530d1020f8cb54
Reviewed-on: https://boringssl-review.googlesource.com/30404
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-08-08 16:12:50 +00:00
Adam Langley 6410e18e91 Update several assembly files from upstream.
This change syncs several assembly files from upstream. The only meanful
additions are more CFI directives.

Change-Id: I6aec50b6fddbea297b79bae22cfd68d5c115220f
Reviewed-on: https://boringssl-review.googlesource.com/30364
Reviewed-by: Adam Langley <agl@google.com>
2018-08-07 18:57:17 +00:00
Adam Langley e27793940e Don't accept “SSL client” as a substitute for S/MIME in the Netscape cert type extension.
I believe that case was the only way that X509_check_purpose could
return anything other than zero or one. Thus eliminate the last use of
X509_V_FLAG_X509_STRICT.

Change-Id: If2f071dfa934b924491db2b615ec17390564e7de
Reviewed-on: https://boringssl-review.googlesource.com/30344
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Matt Braithwaite <mab@google.com>
2018-08-06 21:52:28 +00:00
Matthew Braithwaite e833a6dfa2 handshaker: kick PRNG when resuming in UNSAFE_DETERMINISTIC_MODE.
In fuzzing builds, session resumptions fail if the PRNG behaves the
same as in the initial session.  Not sure of the reason, but a kick to
the PRNG fixes the problem and doesn't compromise determinism, so
... *shrug*?

Change-Id: I8181d98fdff16ae82255e9cda33ce5c4c40b5399
Reviewed-on: https://boringssl-review.googlesource.com/30284
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-08-03 23:11:46 +00:00
Steven Valdez 74bfa0c082 Fix header include for handshake.
This should hopefully fix a build failure on the fuzzers.

Change-Id: If8db8dee768a83538cf37a65ec23c3f68f2be6a2
Reviewed-on: https://boringssl-review.googlesource.com/30264
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-08-02 13:55:01 +00:00
Steven Valdez e5388e097a Add handshaker as run_tests dependency.
Change-Id: I545a61794d6dbb187d973351da6d54e33a608d0d
Reviewed-on: https://boringssl-review.googlesource.com/30244
Reviewed-by: Matt Braithwaite <mab@google.com>
2018-08-01 23:47:11 +00:00
Adam Langley 8bd1d07535 Require basicConstraints cA flag in intermediate certs.
OpenSSL 1.0.2 (and thus BoringSSL) accepts keyUsage certSign or a
Netscape CA certificate-type in lieu of basicConstraints in an
intermediate certificate (unless X509_V_FLAG_X509_STRICT) is set.

Update-Note: This change tightens the code so that basicConstraints is required for intermediate certificates when verifying chains. This was previously only enabled if X509_V_FLAG_X509_STRICT was set, but that flag also has other effects.

Change-Id: I9e41f4c567084cf30ed08f015a744959982940af
Reviewed-on: https://boringssl-review.googlesource.com/30185
Reviewed-by: Matt Braithwaite <mab@google.com>
2018-08-01 19:10:19 +00:00
Adam Langley 0224a3294a Add X509_V_FLAG_REQUIRE_CA_BASIC_CONSTRAINTS.
This change adds a new flag, X509_V_FLAG_REQUIRE_CA_BASIC_CONSTRAINTS,
which causes basicConstraints with isCA to be required for intermediate
CA certificates. Without this, intermediates are also acceptable if
they're missing basicConstraints, but include either a certSign
keyUsage, or a CA Netscape certificate type.

This is a short-term change for patching. I'll undo a lot of it and make
this the default in the next change.

Change-Id: I7f42ffd76c57de3037f054108951e230c1b4e415
Reviewed-on: https://boringssl-review.googlesource.com/30184
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Matt Braithwaite <mab@google.com>
2018-08-01 18:55:50 +00:00
Adam Langley e7b78770ec Ask shim whether it supports split handshakes.
The runner currently expects split handshake tests to work is GOOS is
"linux", but that includes Android, which the shim doesn't support.

Rather than try to align these two conditions, have the runner ask the
shim whether it supports split handshakes or not.

Change-Id: I7bea0d94142c4b6ee42b8f54c67b8611da93feb3
Reviewed-on: https://boringssl-review.googlesource.com/30204
Reviewed-by: Matt Braithwaite <mab@google.com>
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-08-01 17:14:58 +00:00
Matthew Braithwaite 548c27646a shim: perform split handshakes in a separate binary.
The new binary, called |handshaker|, allows split-handshakes to be
tested using shim and handshaker binaries built at different
revisions.

The shim now proxies traffic to the handshaker during the split
handshake.  The handoff and handback steps serialize additional state
about the test being performed, and its results.

The proxy and handshaker make heavy use of Unix-isms, and so
split-handshake tests are now restricted to Linux.

Change-Id: I048f0540c3978a31b3e573e00da17caf41a8059e
Reviewed-on: https://boringssl-review.googlesource.com/29348
Reviewed-by: Adam Langley <agl@google.com>
2018-08-01 01:44:53 +00:00
Adam Langley c448f1759a Fix the build with FIPS + NO_ASM.
Setting OPENSSL_NO_ASM skips enabling the “ASM” language in CMake.
However, the FIPS module fundamentally needs to build asm because
delocate works via textual assembly. Thus this combination is currently
broken with CMake.

This change ensures that support for building asm is enabled in CMake
for this combination.

Change-Id: I4516cf3a6f579ee7c72f04ac25d15785926cf125
Reviewed-on: https://boringssl-review.googlesource.com/29884
Reviewed-by: Adam Langley <agl@google.com>
2018-07-30 22:43:25 +00:00
Adam Langley fadd8b4244 Add script for showing FIPS self-test failures.
Change-Id: I6e98a518ea9a29d9de7691a430fbbbd2a504c08d
Reviewed-on: https://boringssl-review.googlesource.com/30124
Reviewed-by: Adam Langley <agl@google.com>
2018-07-30 22:41:04 +00:00
Adam Langley 4732c544f7 Add ECDH_compute_key_fips inside the module.
This change adds a function so that an ECDH and the hashing of the
resulting 'x' coordinate can occur inside the FIPS boundary.

Change-Id: If93c20a70dc9dcbca49056f10915d3ce064f641f
Reviewed-on: https://boringssl-review.googlesource.com/30104
Reviewed-by: Adam Langley <agl@google.com>
2018-07-30 22:40:31 +00:00
Michał Janiszewski c4f3b8a22a Add a compile time verification ciphers are sorted for bsearch()
Change-Id: Ibdf5b5194087a44088563141f1de2801cade231b
Reviewed-on: https://boringssl-review.googlesource.com/30144
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-07-30 22:17:31 +00:00
Adam Langley 23e9aec99b Support Wycheproof vectors with the curve given in the group.
Future versions of the Wycheproof vectors will specify the curve for a
group of tests, rather than for each test. This change works with both
the old and new style.

Change-Id: I0d9a503c8357eb4c617544e727d8f4a703c2c2b0
Reviewed-on: https://boringssl-review.googlesource.com/30084
Reviewed-by: Adam Langley <agl@google.com>
2018-07-27 16:45:12 +00:00
Ryan Tseng f3bfab0035 Comment change in codereview.settings
gcl is long deprecated, "git cl" is what this is used for now.

TBR: davidben
Change-Id: I5980b8ff3a7c384f4650e195eb6e4daf52da5ae2
Reviewed-on: https://boringssl-review.googlesource.com/30064
Reviewed-by: Ryan Tseng <hinoka@google.com>
2018-07-26 00:23:04 +00:00
David Benjamin ed09f2d5cd Move the MSan sanity check to a source file.
OSS-Fuzz builds fuzz/*.c without matching config, which pulls in
crypto/internal.h. See
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9583.

Change-Id: I4bd16f8741816ebef00d8102fd1f79b0cb16f6a3
Reviewed-on: https://boringssl-review.googlesource.com/30024
Reviewed-by: Adam Langley <agl@google.com>
2018-07-25 15:15:19 +00:00
Daniel Hirche 9af1edbe22 Don't build test/malloc.cc with TSAN.
Change-Id: I33c5259f066693c912ba751dff0205ae240f4a92
Reviewed-on: https://boringssl-review.googlesource.com/29964
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-07-24 15:38:09 +00:00
David Benjamin 22ac2d9b25 Fail the build if MSan is built with assembly.
MSan works by instrumenting memory accesses in the compiler. Accesses from
uninstrumented code, such as assembly, are invisible to it. MSan will
incorrectly report reads from assembly-initialized memory as uninitialized.

To avoid confusing downstream consumers with false positives, catch this at
compile-time with a more useful error.

Update-Note: BoringSSL with MSan and assembly doesn't work, but now rather than
crashing at runtime, it will fail to build altogether. It's possible someone
was building BoringSSL with MSan and either not running it at all or just not
exercising the codepaths that break.

Bug: 252
Change-Id: I0c8b0fa3c2d1e584b3f40d532a668a8c9be06cb7
Reviewed-on: https://boringssl-review.googlesource.com/29928
Reviewed-by: Adam Langley <agl@google.com>
2018-07-23 19:07:41 +00:00
David Benjamin fc04cb217d Add some TSan coverage of CRYPTO_BUFFER.
There were some subtleties in this one. I'm not sure if TSan covers it all, but
it's better than nothing.

Change-Id: I239e3aee2fea84caa2e48f555d08c6d89f430402
Reviewed-on: https://boringssl-review.googlesource.com/29927
Reviewed-by: Adam Langley <agl@google.com>
2018-07-23 19:04:44 +00:00
David Benjamin 6c04bd1114 Add some basic SSL_CTX threading tests.
This covers some of the session cache bits and the SSL_CTX_get0_certificate
quirk.

Change-Id: Ia2a5e93075de43aaf5fce086e376954f58671536
Reviewed-on: https://boringssl-review.googlesource.com/29926
Reviewed-by: Adam Langley <agl@google.com>
2018-07-23 19:02:38 +00:00
David Benjamin c5f680ec36 Add a thread test for RSA.
The business with cached Montgomery contexts is not trivial.

Change-Id: I60d34ed5f55509372c82534d1c2233a4ad67ab34
Reviewed-on: https://boringssl-review.googlesource.com/29925
Reviewed-by: Adam Langley <agl@google.com>
2018-07-23 19:00:03 +00:00
David Benjamin 5852cfccbc Add a basic TSan test for ref-counts.
Confirmed that, if the locks are commented out, TSan catches the threading
error.

Change-Id: I3e4ef9a7ca85fdbacf8c8b13694a5a54c6d5f99b
Reviewed-on: https://boringssl-review.googlesource.com/29924
Reviewed-by: Adam Langley <agl@google.com>
2018-07-23 18:57:19 +00:00
David Benjamin 20b6a4e2a1 Clear r->neg in bn_mod_{add,sub}_consttime.
Otherwise, if the output BIGNUM was previously negative, we'd incorrectly give
a negative result. Thanks to Guide Vranken for reporting this issue!

Fortunately, this does not appear to come up in any existing caller. This isn't
all that surprising as negative numbers never really come up in cryptography.
Were it not for OpenSSL historically designing a calculator API, we'd just
delete the bit altogether. :-(

Bug: chromium:865924
Change-Id: I28fdc986dfaba3e38435b14ebf07453d537cc60a
Reviewed-on: https://boringssl-review.googlesource.com/29944
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-07-20 23:45:06 +00:00
Matthew Braithwaite d154c7ccbc shim: call SSL_CTX_set_tlsext_ticket_keys() only once.
rather than twice, with the second call overriding the first.

Change-Id: Ieb139928edcbe75f1d2e7c2c52c46950d6343a6c
Reviewed-on: https://boringssl-review.googlesource.com/29904
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-07-19 21:33:31 +00:00
Matthew Braithwaite 6d597a34b6 shim: rewrite MoveTestState() to use a serialized representation.
This helps with creating a separate binary to perform split
handshakes, in that the test state must be communicated to, and
retrieved from, the handshaker binary using a socket.

Change-Id: I9d70a9bb3d97dd339aab4f51c6de75f71e4fe72d
Reviewed-on: https://boringssl-review.googlesource.com/29704
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-07-19 21:20:01 +00:00
David Benjamin 0cbb1af41f Don't mint TLS 1.3 tickets if SSL_OP_NO_TICKETS is set.
Change-Id: I03e05acb024e34beaeaf2f02860da1763e08a093
Reviewed-on: https://boringssl-review.googlesource.com/29844
Reviewed-by: Adam Langley <agl@google.com>
2018-07-18 23:47:36 +00:00
David Benjamin 5869eb3951 Test cert_cb and certificate verify ordering.
In particular, although CertificateRequest comes before Certificate and
CertificateVerify in TLS 1.3, we must not resolve the CertificateRequest until
afterwards. (This is rather annoying ordering, but does mean the
CertificateRequest is covered in the signature, which is nice to have.)

Change-Id: Iab95813de5efd674aa8e2459cfc7456b146ee754
Reviewed-on: https://boringssl-review.googlesource.com/29826
Reviewed-by: Jesse Selover <jselover@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-07-17 20:40:35 +00:00
David Benjamin c59b9aace6 Remove more remnants of SSLv3.
Mostly in comments, but there is one special-case around renegotiation_info
that can now be removed.

Change-Id: I2a9114cbff05e0cfff95fe93270fe42379728012
Reviewed-on: https://boringssl-review.googlesource.com/29824
Reviewed-by: Steven Valdez <svaldez@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-07-17 20:02:35 +00:00
David Benjamin 8d1203d6c5 Fix some malloc error handling.
Thanks to Tom Thorogood for catching this.

Change-Id: I09fa5d9822b9ba13b106add251e26c6ebee21b03
Reviewed-on: https://boringssl-review.googlesource.com/29825
Reviewed-by: Tom Thorogood <me+google@tomthorogood.co.uk>
Reviewed-by: Steven Valdez <svaldez@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-07-17 20:01:26 +00:00
David Benjamin 861abccb95 Switch a bunch of ints to bools.
Change-Id: I52eb029a13a126576ff8dfed046bafa465e7ce09
Reviewed-on: https://boringssl-review.googlesource.com/29809
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2018-07-17 01:41:49 +00:00
William D. Irons 3218c1db82 Add support for building ppc64le with bazel
This commit is to allow Tensorflow to build with boringssl on ppc64le
and RHEL7.5/gcc 4.8.5.

All the instructions used by linux_x86_64 also need to bet set for
linux_ppc64le

Change-Id: I4ccf8a61fe3bdd0a49944b48ce7863b97f957a85
Reviewed-on: https://boringssl-review.googlesource.com/29784
Reviewed-by: Adam Langley <agl@google.com>
2018-07-16 17:48:12 +00:00
David Benjamin 35b4a1255c Namespace CertCompressionAlg and use more scopers.
Change-Id: I52ab2dbf92bbdbc8cb0dd811bf9eaafe0c903b66
Reviewed-on: https://boringssl-review.googlesource.com/29808
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-07-15 14:12:13 +00:00
David Benjamin 89b9ecf0de Add more scopers.
Change-Id: I68d77534a7c0e8ea89ff02fba1228d67e7a793eb
Reviewed-on: https://boringssl-review.googlesource.com/29807
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-07-15 14:11:53 +00:00
David Benjamin bc118ee64c Add SSL_get0_peer_verify_algorithms.
Callers who use SSL_get0_certificate_types today will find an empty list
in TLS 1.3, which removed it. To provide feature parity, add an accessor
for the signature algorithms list. SSL_get_signature_algorithm_key_type
can be used to map it to a key type.

"Peer signature algorithms" was already taken in the public API by
SSL_get_peer_signature_algorithm to refer to which the peer selected, so
I named this matching SSL_CTX_set_verify_algorithm_prefs.

Change-Id: I12d411d7350e744ed9f88c610df48e0d9fc13256
Reviewed-on: https://boringssl-review.googlesource.com/29684
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Vartanian <flooey@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2018-07-14 03:50:40 +00:00
David Benjamin 0a3e07ac1d Remove custom extensions support.
Update-Note: Custom extensions APIs are removed.
Change-Id: Ic5e0fb3c018bf15d35d9149623f6b29940041b59
Reviewed-on: https://boringssl-review.googlesource.com/29685
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-07-14 03:33:00 +00:00
David Benjamin 42ea84b317 Update Wycheproof test vectors.
They've since added new files that split up ECDH and RSA. The former especially
could be useful. A later commit will switch to those. Along the way, fix the
aes_cmac_test.json entry in the convert_wycheproof.go which got lost at some
point.

Change-Id: I9c4a2e5fc5f3e0935482f583c5466c1b64fe325e
Reviewed-on: https://boringssl-review.googlesource.com/29686
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-07-13 20:46:20 +00:00
Matthew Braithwaite ce77762686 shim: extract a |DoSplitHandshake| helper function.
This makes the shim code read more naturally, in that the split-
handshake special case now lives in its own file.

This helps with creating a separate binary to perform split
handshakes.

Change-Id: I7970a8f368417791d18d4d44eeb379ef4b46c960
Reviewed-on: https://boringssl-review.googlesource.com/29347
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2018-07-13 19:57:17 +00:00
Adam Langley 79f1a49c3a Update delocate to handle new compiler output.
Delocate failed with some versions of Clang that reference
OPENSSL_ia32cap_P with an orq instruction.

Change-Id: I448d291594f5f147424e6f7014a681c4201b0aee
Reviewed-on: https://boringssl-review.googlesource.com/29764
Reviewed-by: Adam Langley <alangley@gmail.com>
2018-07-13 19:37:15 +00:00
David Benjamin a4e9f8d332 Simplify SSLTranscript.
With SSL 3.0 gone, there's no need to split up MD5 and SHA-1.

Change-Id: Ia4236c738dfa6743f1028c2d53761c95cba96288
Reviewed-on: https://boringssl-review.googlesource.com/29744
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-07-13 16:23:40 +00:00
Adam Langley e0afc85719 Send an alert if we fail to pick a signature algorithm.
Change-Id: Id7f5ef9932c4c491bd15085e3c604ebfcf259b7c
Reviewed-on: https://boringssl-review.googlesource.com/29665
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-07-10 15:38:12 +00:00
Adam Langley 428fb3ad52 Make |BORINGSSL_MAKE_UP_REF| a no-op when C++ is disabled.
Change-Id: I436cc772eb975ad989035ee154a2e050c65e2961
Reviewed-on: https://boringssl-review.googlesource.com/29664
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-07-10 14:59:12 +00:00
Matthew Braithwaite c312fd02f6 Remove MoveTestConfig().
In f2bc5f4 davidben pointed out that this function seems unnecessary
in my desired end-state.  In fact, I think it may have been
unnecessary since 56986f90.  (This was easier to miss at the time,
since at the time the function was part of MoveExData(), having not
yet been factored out.)

Change-Id: Ia9b4a909c93cb595666bcf7356a9f9a085901455
Reviewed-on: https://boringssl-review.googlesource.com/29604
Commit-Queue: Matt Braithwaite <mab@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-07-09 18:50:50 +00:00
Adam Langley 82639e6f53 Use a pool of |rand_state| objects.
Previously we used thread-local state objects in rand.c. However, for
applications with large numbers of threads, this can lead to excessive
memory usage.

This change causes us to maintain a mutex-protected pool of state
objects where the size of the pool equals the maximum concurrency of
|RAND_bytes|. This might lead to state objects bouncing between CPUs
more often, but should help the memory usage problem.

Change-Id: Ie83763d3bc139e64ac17bf7e015ad082b2f8a81a
Reviewed-on: https://boringssl-review.googlesource.com/29565
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-07-06 21:25:37 +00:00
David Benjamin 4685376b2b Remove other unnecessary tlsext_ prefixes.
Change-Id: Ib31a12527006ff57beb99bcfd0bf1f906773e1ca
Reviewed-on: https://boringssl-review.googlesource.com/29593
Reviewed-by: Adam Langley <agl@google.com>
2018-07-06 19:49:13 +00:00
David Benjamin 7bb0fbf77b C++ the ticket keys a bit.
While I'm here, remove the silly "tlsext_" prefix. At this point it's no
longer novel that a feature is encoded in an extension.

Change-Id: Ib5fbd2121333a213bdda0332885a8c90036ebc4d
Reviewed-on: https://boringssl-review.googlesource.com/29592
Reviewed-by: Adam Langley <agl@google.com>
2018-07-06 19:47:08 +00:00
David Benjamin 0ce090acd6 A bunch more scopers.
Change-Id: I5c8dbfec4a404d8d1501725a90b383eb3e05c664
Reviewed-on: https://boringssl-review.googlesource.com/29591
Reviewed-by: Adam Langley <agl@google.com>
2018-07-06 19:43:08 +00:00
David Benjamin 50596f8f54 Switch some easy SSL fields to UniquePtr.
Change-Id: I982ecda5a19187708b15e8572e6d0000c22ed87c
Reviewed-on: https://boringssl-review.googlesource.com/29590
Reviewed-by: Adam Langley <agl@google.com>
2018-07-06 19:30:51 +00:00
David Benjamin c1389f2ce8 Give SSL and SSL_CTX dummy constructor and destructor.
This doesn't actually make use of much of C++ yet. (SSL_CTX and
SSL/SSL_CONFIG carry analogous versions of a number of fields. It's
difficult to switch them to UniquePtr separately.)

Change-Id: Ia948f539c5c90e2d8301193f719604a31be17fc4
Reviewed-on: https://boringssl-review.googlesource.com/29589
Reviewed-by: Adam Langley <agl@google.com>
2018-07-06 19:01:56 +00:00
David Benjamin 4979803755 Unsplit SSL and SSL_CTX.
This doesn't give them a destructor yet, just shifts things around. In
doing so, it reveals that we inconsistently allowed internal code, but
not external code, to call functions like bssl::SSL_CTX_set_handoff_mode
without a namespace because of ADL. External code doesn't get to do
this because it doesn't see that ssl_ctx_st has a base class in
namespace bssl.

Change-Id: I2ab3b00fff2d6369e850606eed63017e4f8cf8c4
Reviewed-on: https://boringssl-review.googlesource.com/29588
Reviewed-by: Adam Langley <agl@google.com>
2018-07-06 18:56:03 +00:00
David Benjamin e7b2b13fd4 Add link to CMake bugfix.
Change-Id: I6d82cbb33a5ac2acf3f4e0993210e0bddba8f1ad
Reviewed-on: https://boringssl-review.googlesource.com/29644
Reviewed-by: Adam Langley <agl@google.com>
2018-07-06 18:54:12 +00:00
Adam Langley c7db3232c3 Add “bssl::” prefix to |UpRef| and |PushToStack| in fuzzer code.
Change-Id: Ie3ed310869f3068d5be8292448a27679fa91a7a7
Reviewed-on: https://boringssl-review.googlesource.com/29624
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-07-05 14:36:02 +00:00
Adam Langley 859679518d Drop C++ from certificate compression API.
It's 2018, but passing STL objects across the API boundary turns out to
still be more bother than it's worth. Since we're dropping UniquePtr in
the API anyway, go the whole way and make it a plain-C API.

Change-Id: Ic0202012e5d81afe62d71b3fb57e6a27a8f63c65
Update-note: this will need corresponding changes to the internal use of SSL_CTX_add_cert_compression_alg.
Reviewed-on: https://boringssl-review.googlesource.com/29564
Reviewed-by: David Benjamin <davidben@google.com>
2018-07-04 16:39:14 +00:00
Matthew Braithwaite d2f87a7779 shim: move handshake helper functions into their own file.
To wit, |RetryAsync| and |CheckIdempotentError|.

This helps with creating a separate binary to perform split
handshakes.

Separate handshake utilities

Change-Id: I81d0bc38f58e7e1a92b58bf09407452b345213b4
Reviewed-on: https://boringssl-review.googlesource.com/29346
Commit-Queue: Matt Braithwaite <mab@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-07-03 23:30:20 +00:00
Matthew Braithwaite f2bc5f490a shim: move |TestState| and |TestConfig| to their own files.
This makes |TestState| and |TestConfig| accessible outside
bssl_shim.cc, as well as the functions SetupCtx() and NewSSL(), which
become methods on |TestConfig|.  A whole mess of callbacks move in
order to support this change.

Along the way, some bits of global state are moved (e.g. the global
test clock) and made self-initializing.

This helps with creating a separate binary to perform split
handshakes.

Change-Id: I39b00a1819074882353f5f04ed01312916f3cccb
Reviewed-on: https://boringssl-review.googlesource.com/29345
Commit-Queue: Matt Braithwaite <mab@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-07-03 23:14:56 +00:00
David Benjamin bfdd1a9308 Give SSL_SESSION a destructor.
Previously we'd partially attempted the ssl_st / bssl::SSLConnection
subclassing split, but that gets messy when we actually try to add a
destructor, because CRYPTO_EX_DATA's cleanup function needs an ssl_st*,
not a bssl::SSLConnection*. Downcasting is technically undefined at this
point and will likely offend some CFI-like check.

Moreover, it appears that even with today's subclassing split,
New<SSL>() emits symbols like:

W ssl_st*& std::forward<ssl_st*&>(std::remove_reference<ssl_st*&>::type&)

The compiler does not bother emitting them in optimized builds, but it
does suggest we can't really avoid claiming the ssl_st type name at the
symbol level, short of doing reinterpret_casts at all API boundaries.
And, of course, we've already long claimed it at the #include level.

So I've just left this defining directly on ssl_session_st. The cost is
we need to write some silly "bssl::" prefixes in the headers, but so it
goes. In the likely event we change our minds again, we can always
revise this.

Change-Id: Ieb429e8eaabe7c2961ef7f8d9234fb71f19a5e2a
Reviewed-on: https://boringssl-review.googlesource.com/29587
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-07-03 22:57:56 +00:00
David Benjamin 58150ed59b Add lh_FOO_retrieve_key to avoid stack-allocating SSL_SESSION.
lh_FOO_retrieve is often called with a dummy instance of FOO that has
only a few fields filled in. This works fine for C, but a C++
SSL_SESSION with destructors is a bit more of a nuisance here.

Instead, teach LHASH to allow queries by some external key type. This
avoids stack-allocating SSL_SESSION. Along the way, fix the
make_macros.sh script.

Change-Id: Ie0b482d4ffe1027049d49db63274c7c17f9398fa
Reviewed-on: https://boringssl-review.googlesource.com/29586
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-07-03 22:56:46 +00:00
David Benjamin 63c79122e0 Remove the redundant version check in ssl_session_cmp.
This partitions the session ID space of the internal cache by version,
which is nominally something we want, but we must check the version
externally anyway for both tickets and external session cache. That
makes this measure redundant. (Servers generate session IDs and 2^256 is
huge, so there would never accidentally be a collision.)

This cuts down on the "key" in the internal session cache, which will
simplify adding something like an lh_SSL_SESSION_retrieve_key function.
(LHASH is currently lax about keys because it can freely stack-allocate
partially-initialized structs. C++ is a bit more finicky about this.)

Change-Id: I656fd9dbf023dccb163d2e8049eff8f1f9a0e21b
Reviewed-on: https://boringssl-review.googlesource.com/29585
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-07-03 22:54:16 +00:00
David Benjamin 53d2c7a84a Remove fail_second_ddos_callback.
We have generic -on-resume prefixes now. This avoids the global counter.

Change-Id: I7596ed3273e826b744d8545f7ed2bdd5e9190958
Reviewed-on: https://boringssl-review.googlesource.com/29594
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Matt Braithwaite <mab@google.com>
2018-07-03 22:52:26 +00:00
David Benjamin 2908dd141f Add bssl::UpRef.
bssl::UniquePtr and FOO_up_ref do not play well together. Add a helper
to simplify this. This allows us to write things like:

   foo->cert = UpRef(bar->cert);

instead of:

   if (bar->cert) {
     X509_up_ref(bar->cert.get());
   }
   foo->cert.reset(bar->cert.get());

This also plays well with PushToStack. To append something to a stack
while taking a reference, it's just:

   PushToStack(certs, UpRef(cert))

Change-Id: I99ae8de22b837588a2d8ffb58f86edc1d03ed46a
Reviewed-on: https://boringssl-review.googlesource.com/29584
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-07-03 22:47:36 +00:00
David Benjamin 2e74fdaa4a Don't redefine alignas in C++.
alignas in C++11 is a bit more flexible than
__attribute__((aligned(x))), and we already require C++11 in tests.

Change-Id: If61c35daa5fcaaca5119dcc6808a3e746befc170
Reviewed-on: https://boringssl-review.googlesource.com/29544
Reviewed-by: Adam Langley <agl@google.com>
2018-07-03 22:11:32 +00:00
David Benjamin aaef833433 Use more accessors in ssl_test.cc
Fewer things we need to update as the internals change.

Change-Id: If615a56557c8acbe08501f091e9fe21e5ff8072c
Reviewed-on: https://boringssl-review.googlesource.com/29525
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-07-03 22:10:46 +00:00
David Benjamin 0363de9a6b Namespace SSL_X509_METHOD.
Change-Id: I19296822354acea9956b9606d2209675151f511d
Reviewed-on: https://boringssl-review.googlesource.com/29524
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-07-03 21:41:36 +00:00
David Benjamin a3a71e9d33 Flip SSL_SESSION fields to bool.
Change-Id: I0a3648437f78f37a4b710aaea73084a19be607c5
Reviewed-on: https://boringssl-review.googlesource.com/29485
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-07-03 21:26:16 +00:00
Matthew Braithwaite 997ff094af shim: move |SettingsWriter| into its own file.
This helps with creating a separate binary to perform split
handshakes.

Change-Id: Ie4bab40bebf39e79a90d45fabb566b7ce90945bb
Reviewed-on: https://boringssl-review.googlesource.com/29344
Commit-Queue: Matt Braithwaite <mab@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-07-02 22:26:28 +00:00
Guillaume Egles 791f2822b2 Fix VS build when assembler is enabled
The whitespace in the _STL_EXTRA_DISABLED_WARNINGS value was creating issues
for the CMake generated assembler build script called by VS.

By narrowing the build scope of this STL (and thus C++ only) variable to only C++
we avoid the problem altogether as it will not be passed to the assembler script.

Change-Id: Id422bdd991492f39acc82d52af2ea6d952deb6c6
Reviewed-on: https://boringssl-review.googlesource.com/29504
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-06-29 20:38:22 +00:00
David Benjamin 26f8297177 Switch to 64-bit tools on Windows.
It's 2018. I'm not sure why I added the 32-bit ones; even the 32-bit
bots build and run on 64-bit Windows. ninja.exe in depot_tools is also a
64-bit binary. I suspect this is because some of the depot_tools bits
use --platform=win32, but that's just the sys.platform string.

Alas, I stupidly named these "win32" way back. Dealing with the rename
is probably more trouble than worth it right now since the build recipes
refer to the name. Something to deal with later. (Regardless we'll want
"win32" to point to 64-bit binaries so that try jobs can test it.)

Also add the missing nasm-win32.exe to .gitignore.

For some reason the 64-bit Yasm binary does not work on the vs2017 CQ
bots, so I've left it alone. Hopefully it should be replaced by NASM
later anyway.

Change-Id: If65ececddbc6526ceebaafbef56eddea8ece58ba
Reviewed-on: https://boringssl-review.googlesource.com/29384
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-06-29 18:05:31 +00:00
David Benjamin 0cc51a793e Remove reference to SSL3 in PORTING.md.
We don't support SSL3 at all now. Actually we haven't supported renego
SSL3 in even longer, so this was false even before yesterday.

Change-Id: Ie759477fa84099dd486c4c4604080ecf8ecdf434
Reviewed-on: https://boringssl-review.googlesource.com/29484
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-06-29 17:46:32 +00:00
Adam Barth 9c3b120b61 [fuchsia] Update to zx_cprng_draw
This change moves to the final version of zx_cprng_draw, which cannot
fail. If the syscall would fail, either the operating system terminates
or the kernel kills the userspace process (depending on where the error
comes from).

Change-Id: Iea9563c9f63ea5802e2cde741879fa58c19028f4
Reviewed-on: https://boringssl-review.googlesource.com/29424
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-06-28 21:08:18 +00:00
Alessandro Ghedini a0373182eb Update QUIC transport parameters extension codepoint
This was changed in draft-ietf-quic-tls-13 to use a codepoint from the
reserved range.

Change-Id: Ia3cda249a3f37bc244d5c8a7765ec34a5708c9ae
Reviewed-on: https://boringssl-review.googlesource.com/29464
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-06-28 17:41:58 +00:00
David Benjamin 9bb15f58f7 Remove SSL 3.0 implementation.
Update-Note: SSL_CTX_set_min_proto_version(SSL3_VERSION) now fails.
   SSL_OP_NO_SSLv3 is now zero. Internal SSL3-specific "AEAD"s are gone.

Change-Id: I34edb160be40a5eea3e2e0fdea562c6e2adda229
Reviewed-on: https://boringssl-review.googlesource.com/29444
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-06-28 16:54:58 +00:00
David Benjamin fec83fc78d Order draft-28 over draft-23.
This doesn't particularly matter since most clients don't typically
advertise both versions, but we should presumably prefer the newer one.

Change-Id: If636e446c6af2049fc5743eb5fef04b780b29af9
Reviewed-on: https://boringssl-review.googlesource.com/29445
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-06-27 21:06:09 +00:00
David Benjamin 3815720cf3 Add a bunch of compatibility functions for PKCS#7.
The full library is a bit much, but this is enough to appease most of
cryptography.io.

Change-Id: I1bb0d83744c4550d5fe23c5c98cfd7e36b17fcc9
Reviewed-on: https://boringssl-review.googlesource.com/29365
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-06-26 18:42:49 +00:00
David Benjamin eaf0a17db8 Add a copy of NASM to util/bot/ in BoringSSL.
This is to transition BoringSSL's Windows build from Yasm to NASM. This
change itself is a no-op for now, but a later change to the BoringSSL
recipes will add a pair of standalone builders here. Then I'll get the
change I have lying around for Chromium moving.

Bug: chromium:766721
Change-Id: I4dca1c299f93bc5c01695983fe0478490c472deb
Reviewed-on: https://boringssl-review.googlesource.com/29324
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-06-26 15:47:29 +00:00
David Benjamin 79c97bf37c Allow empty return values from PKCS7_get_*.
Right now we're inconsistent about it. If the OPTIONAL container is
missing, we report an error, but if the container is empty, we happily
return nothing. The latter behavior is more convenient for emulating
OpenSSL's PKCS#7 functions.

These are our own functions, so we have some leeway here. Looking
through callers, they appear to handle this fine.

Update-Note: This is a behavior change.
Change-Id: I1321025a64df3054d380003c90e57d9eb95e610f
Reviewed-on: https://boringssl-review.googlesource.com/29364
Reviewed-by: Adam Langley <agl@google.com>
2018-06-26 07:24:51 +00:00
David Benjamin 8803c0589d Properly advance the CBS when parsing BER structures.
CBS_asn1_ber_to_der was a little cumbersome to use. While it, in theory,
allowed callers to consistently advance past the element, no caller
actually did so consistently. Instead they would advance if conversion
happened, and not if it was already DER. For the PKCS7_* functions, this
was even caller-exposed.

Change-Id: I658d265df899bace9ba6616cb465f19c9e6c3534
Reviewed-on: https://boringssl-review.googlesource.com/29304
Reviewed-by: Adam Langley <agl@google.com>
2018-06-26 07:23:10 +00:00
Jesse Selover b4810de60f Make X509 time validation stricter.
Copy of OpenSSL change
https://github.com/openssl/openssl/commit/80770da39ebba0101079477611b7ce2f426653c5.

This additionally fixes some bugs which causes time validation to
fail when the current time and certificate timestamp are near the
2050 UTCTime/GeneralizedTime cut-off.

Update-Note: Some invalid X.509 timestamps will be newly rejected.

Change-Id: Ie131c61b6840c85bed974101f0a3188e7649059b
Reviewed-on: https://boringssl-review.googlesource.com/29125
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-06-25 17:54:33 +00:00
Adam Langley 03de6813d8 Write error messages in the FIPS module to stderr.
Previously, delocate.go couldn't handle GOT references and so |stderr|
was a problematic symbol. We can cope with them now, so write FIPS
power-on test and urandom errors to stderr rather than stdout.

Change-Id: If6d7c19ee5f22dcbd74fb01c231500c2e130e6f7
Update-note: resolves internal bug 110102292.
Reviewed-on: https://boringssl-review.googlesource.com/29244
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-06-25 10:30:42 +00:00
Adam Langley bcfb49914b Add special AES-GCM AEAD for TLS 1.3.
This change adds an AES-GCM AEAD that enforces nonce uniqueness inside
the FIPS module, like we have for TLS 1.2. While TLS 1.3 has not yet
been mentioned in the FIPS 140 IG, we expect it to be in the next ~12
months and so are preparing for that.

Change-Id: I65a7d8196b08dc0033bdde5c844a73059da13d9e
Reviewed-on: https://boringssl-review.googlesource.com/29224
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-06-25 10:23:22 +00:00
David Benjamin 954eefae58 Actually add AES-192-OFB.
I forgot about this file.

Change-Id: Icb98ffe3ed682a80d7a809a4585a5537fed0ba1c
Reviewed-on: https://boringssl-review.googlesource.com/29284
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-06-21 22:03:34 +00:00
Adam Langley 0080d83b9f Implement the client side of certificate compression.
Change-Id: I0aced480af98276ebfe0970b4afb9aa957ee07cb
Reviewed-on: https://boringssl-review.googlesource.com/29024
Reviewed-by: Adam Langley <agl@google.com>
2018-06-18 22:16:11 +00:00
David Benjamin f6e5d0d5a1 Add AES-192-OFB.
cryptography.io gets offended if the library supports some OFB sizes but
not others.

Change-Id: I7fc7b12e7820547a82aae84d9418457389a482fe
Reviewed-on: https://boringssl-review.googlesource.com/29204
Reviewed-by: Adam Langley <agl@google.com>
2018-06-18 21:58:46 +00:00
David Benjamin 7139f755b6 Fix some timing leaks in the DSA code.
The DSA code is deprecated and will, hopefully, be removed in the future.
Nonetheless, this is easy enough to fix. It's the analog of the work we'd
already done for ECDSA.

- Document more clearly that we don't care about the DSA code.

- Use the existing constant-time modular addition function rather than
  the ad-hoc code.

- Reduce the digest to satisfy modular operations' invariants. (The
  underlying algorithms could accept looser bounds, but we reduce for
  simplicity.) There's no particular reason to do this in constant time,
  but we have the code for it, so we may as well.

- This additionally adds a missing check that num_bits(q) is a multiple
  of 8. We otherwise don't compute the right answer. Verification
  already rejected all 160-, 224-, and 256-bit keys, and we only
  generate DSA parameters where the length of q matches some hash
  function's length, so this is unlikely to cause anyone trouble.

- Use Montgomery reduction to perform the modular multiplication. This
  could be optimized to save a couple Montgomery reductions as in ECDSA,
  but DSA is deprecated, so I haven't bothered optimizing this.

- The reduction from g^k (mod p) to r = g^k (mod p) (mod q) is left
  in variable time, but reversing it would require a discrete log
  anyway. (The corresponding ECDSA operation is much easier to make
  constant-time due to Hasse's theorem, though that's actually still a
  TODO. I need to finish lifting EC_FELEM up the stack.)

Thanks to Keegan Ryan from NCC Group for reporting the modular addition issue
(CVE-2018-0495). The remainder is stuff I noticed along the way.

Update-Note: See the num_bits(q) change.

Change-Id: I4f032b041e2aeb09f9737a39f178c24e6a7fa1cb
Reviewed-on: https://boringssl-review.googlesource.com/29145
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-06-15 02:37:45 +00:00
David Benjamin 9f9c938af0 Revert "Reland "Revert "Add other Windows configurations to the CQ."""
This reverts commit 43eb0af5f1.

Reason for revert: Hopefully this is resolved by https://boringssl.googlesource.com/boringssl/+/7c8e725e55a72c914eb3a33af6cc65b4188102c6 ?

Original change's description:
> Reland "Revert "Add other Windows configurations to the CQ.""
> 
> This reverts commit 23e92d5d16.
> 
> Reason for revert: Nope. Still doesn't work. Back to poking infra
> about it...
> 
> Original change's description:
> > Revert "Revert "Add other Windows configurations to the CQ.""
> > 
> > This reverts commit 98831738f2.
> > 
> > Let's try this again. tandrii@ says this should be resolved as of
> > https://crbug.com/840505. (That was a while ago. I'd forgotten about
> > it.)
> > 
> > Change-Id: Ib49a629198a33d44ff1c3aa13af5825def1a5c4d
> > Reviewed-on: https://boringssl-review.googlesource.com/28924
> > Reviewed-by: Steven Valdez <svaldez@google.com>
> > Commit-Queue: Steven Valdez <svaldez@google.com>
> > CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
> 
> TBR=davidben@google.com,svaldez@google.com
> 
> Change-Id: Iecd0710075f1fedc4dea69283d018042fb1a2490
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://boringssl-review.googlesource.com/29104
> Commit-Queue: David Benjamin <davidben@google.com>
> Reviewed-by: David Benjamin <davidben@google.com>
> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>

TBR=davidben@google.com,svaldez@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: I583641be42e6e6e93eb30adbe56ae20812608103
Reviewed-on: https://boringssl-review.googlesource.com/29184
Reviewed-by: David Benjamin <davidben@google.com>
2018-06-14 20:06:36 +00:00
David Benjamin 23aa4d228a Update tools.
Change-Id: I4cc9b9fc13a20080d78f9b9bca1e24571f46f117
Reviewed-on: https://boringssl-review.googlesource.com/29146
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-06-14 13:58:05 +00:00
David Benjamin dd935202c9 Zero-initialize tmp in ec_GFp_simple_mul_single.
Although the original value of tmp does not matter, the selects
ultimately do bit operations on the uninitialized values and thus depend
on them behaving like *some* consistent concrete value. The C spec
appears to allow uninitialized values to resolve to trap
representations, which means this isn't quite valid..

(If I'm reading it wrong and the compiler must behave as if there were a
consistent value in there, it's probably fine, but there's no sense in
risking compiler bugs on a subtle corner of things.)

Change-Id: Id4547b0ec702414b387e906c4de55595e6214ddb
Reviewed-on: https://boringssl-review.googlesource.com/29124
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-06-13 19:58:24 +00:00
Adam Barth 6ff2ba80b7 [fuchsia] Update to zx_cprng_draw_new
This version doesn't have short reads. We'll eventually rename the
syscall back to zx_cprng_draw once all the clients have migrated to the
new semantics.

Change-Id: I7a7f6751e4d85dcc9b0a03a533dd93f3cbee277f
Reviewed-on: https://boringssl-review.googlesource.com/29084
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-06-12 14:58:43 +00:00
David Benjamin 43eb0af5f1 Reland "Revert "Add other Windows configurations to the CQ.""
This reverts commit 23e92d5d16.

Reason for revert: Nope. Still doesn't work. Back to poking infra
about it...

Original change's description:
> Revert "Revert "Add other Windows configurations to the CQ.""
> 
> This reverts commit 98831738f2.
> 
> Let's try this again. tandrii@ says this should be resolved as of
> https://crbug.com/840505. (That was a while ago. I'd forgotten about
> it.)
> 
> Change-Id: Ib49a629198a33d44ff1c3aa13af5825def1a5c4d
> Reviewed-on: https://boringssl-review.googlesource.com/28924
> Reviewed-by: Steven Valdez <svaldez@google.com>
> Commit-Queue: Steven Valdez <svaldez@google.com>
> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>

TBR=davidben@google.com,svaldez@google.com

Change-Id: Iecd0710075f1fedc4dea69283d018042fb1a2490
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://boringssl-review.googlesource.com/29104
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-06-12 13:23:55 +00:00
David Benjamin 23e92d5d16 Revert "Revert "Add other Windows configurations to the CQ.""
This reverts commit 98831738f2.

Let's try this again. tandrii@ says this should be resolved as of
https://crbug.com/840505. (That was a while ago. I'd forgotten about
it.)

Change-Id: Ib49a629198a33d44ff1c3aa13af5825def1a5c4d
Reviewed-on: https://boringssl-review.googlesource.com/28924
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-06-11 20:01:42 +00:00
David Benjamin 4665da6e91 Add OFB ciphers to EVP_get_cipherbyname.
This is so they're exposed out of cryptography.io.

Change-Id: I225a35605ae8f3da091e95241ce072eeeabcd855
Reviewed-on: https://boringssl-review.googlesource.com/29044
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-06-11 19:46:43 +00:00
David Benjamin 3b2ff028c4 Add SSL_SESSION_get0_id_context.
This matches OpenSSL 1.1.0. Someone requested it.

Change-Id: I230bb9ec646cd32e71413a68e93058818c8f2aad
Reviewed-on: https://boringssl-review.googlesource.com/29004
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-06-11 14:25:23 +00:00
Loo Rong Jie b570fd9fd6 Link advapi32.lib when linking crypto.
This is needed for RtlGenRandom [0] in crypto/rand_extra/windows.c [1].

Linker error actually shows "SystemFunction036" instead of "RtlGenRandom".

[0]: https://msdn.microsoft.com/en-us/library/windows/desktop/aa387694(v=vs.85).aspx
[1]: https://github.com/google/boringssl/blob/f21650709a6f76e829ddcc77fe221c9d6a5c12de/crypto/rand_extra/windows.c#L44

Change-Id: Ie52e0a1d507e3598ba3ae3c449d0088981c06d8a
Reviewed-on: https://boringssl-review.googlesource.com/28884
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-06-07 19:05:59 +00:00
Adam Langley 070151c96f Update ECDH and EVP tests to accept latest Wycheproof vectors.
(This upstreams a change that was landed internally.)

Change-Id: Ic32793f8b1ae2d03e8ccbb0a9ac5f62add4c295b
Reviewed-on: https://boringssl-review.googlesource.com/28984
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-06-07 16:54:30 +00:00
David Benjamin 1c68fa2350 Hide SSL_SESSION.
The last libssl struct is now opaque! (Promote the SSL_MAX_* constants
as folks use them pretty frequently.)

Update-Note: SSL_SESSION is now opaque. I believe everything handles
this now.

Bug: 6
Change-Id: I8cd29d16173e4370f3341c0e6f0a56e00ea188e9
Reviewed-on: https://boringssl-review.googlesource.com/28964
Reviewed-by: Adam Langley <agl@google.com>
2018-06-07 02:58:27 +00:00
Matthew Braithwaite 3e2b3ee25f Hand back in-progress handshakes after a session resumption.
And since there are now 3 different points in the state machine where
a handback can occur, introduce an enum to describe them.

Change-Id: I41866214c39d27d1bbd965d28eb122c0e1f9902a
Reviewed-on: https://boringssl-review.googlesource.com/28344
Commit-Queue: Matt Braithwaite <mab@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-06-06 21:17:36 +00:00
David Benjamin 5267ef7b4a Reject unexpected application data in bidirectional shutdown.
Update-Note: This tweaks the SSL_shutdown behavior. OpenSSL's original
SSL_shutdown behavior was an incoherent mix of discarding the record and
rejecting it (it would return SSL_ERROR_SYSCALL but retrying the
operation would discard it). SSLeay appears to have intended to discard
it, so we previously "fixed" it actually discard.

However, this behavior is somewhat bizarre and means we skip over
unbounded data, which we typically try to avoid. If you are trying to
cleanly shutdown the TLS portion of your protocol, surely it is at a
point where additional data is a syntax error. I suspect I originally
did not realize that, because the discarded record did not properly
continue the loop, SSL_shutdown would appear as if it rejected the data,
and so it's unlikely anyone was relying on that behavior.

Discussion in https://github.com/openssl/openssl/pull/6340 suggests
(some of) upstream also prefers rejecting.

Change-Id: Icde419049306ed17eb06ce1a7e1ff587901166f3
Reviewed-on: https://boringssl-review.googlesource.com/28864
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2018-06-04 21:39:58 +00:00
Adam Langley a307cb7d58 Preliminary support for compressed certificates.
This change adds server-side support for compressed certificates.

(Although some definitions for client-side support are included in the
headers, there's no code behind them yet.)

Change-Id: I0f98abf0b782b7337ddd014c58e19e6b8cc5a3c2
Reviewed-on: https://boringssl-review.googlesource.com/27964
Reviewed-by: David Benjamin <davidben@google.com>
2018-06-04 21:24:20 +00:00
David Benjamin c1e4f338b1 Use std::thread in thread_test.cc.
The STL already came up with a threading abstraction for us. If this
sticks, that also means we can more easily write tests elsewhere that
use threads. (A test that makes a bunch of TLS connections on a shared
SSL_CTX run under TSan would be nice. Likewise with some of the messy
RSA locking.)

Update-Note: This adds a dependency from crypto_test to C++11 threads.
Hopefully it doesn't cause issues.

Change-Id: I26f89f6b3b79240e516017877d06fd9a815fc315
Reviewed-on: https://boringssl-review.googlesource.com/28865
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-06-04 17:32:48 +00:00
Adam Langley 1627871d18 Include bn/internal.h for RSAZ code.
When building files separately, omitting this causes some #defines to be
missing.

Change-Id: I235231467d3f51ee0a53325698356aefa72c6a67
Reviewed-on: https://boringssl-review.googlesource.com/28944
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-06-04 17:26:29 +00:00
David Benjamin 7bf0bccd61 Add missing <condition_variable> include.
Change-Id: I07040cabcef191f0ab4a7b0e9bd4d46b37b09169
std::condition_variable has its own header to include.
Reviewed-on: https://boringssl-review.googlesource.com/28904
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-06-04 15:08:29 +00:00
David Benjamin caf8ddd0ba Add SSL_SESSION_set1_id.
This matches the OpenSSL 1.1.0 spelling. I'd thought we could hide
SSL_SESSION this pass, but I missed one test that messed with session
IDs!

Bug: 6
Change-Id: I84ea113353eb0eaa2b06b68dec71cb9061c047ca
Reviewed-on: https://boringssl-review.googlesource.com/28866
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-06-04 14:25:28 +00:00
David Benjamin 81a6f6d8de Add a tool to check for filename collisions.
GN does not like multiple files in the same target that share a name, so
add a script to check for this. A follow-up changes will hook that up to
the builders, so we'll flag this in try jobs rather than when the change
trickles downstream.

Change-Id: Ic413dd9aeed6da54fc85dea07f80fe7084be9e9e
Reviewed-on: https://boringssl-review.googlesource.com/28844
Reviewed-by: Adam Langley <agl@google.com>
2018-05-31 19:02:43 +00:00
David Benjamin fe7a17440f Fix typo.
Change-Id: Id7d8c8acf2f441dc34be7d363fb4dd2dfcb0e1c4
Reviewed-on: https://boringssl-review.googlesource.com/28804
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-30 15:42:35 +00:00
David Benjamin a827d1809c Match OpenSSL's EVP_MD_CTX_reset return value.
In neither OpenSSL nor BoringSSL can this function actually fail, but
OpenSSL makes it return one anyway. Match them for compatibility.

Change-Id: I497437321ad9ccc5da738f06cd5b19c467167575
Reviewed-on: https://boringssl-review.googlesource.com/28784
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-29 17:07:16 +00:00
David Benjamin 9229b4fb86 Fix typo in build flags.
Change-Id: Ifa2f9f6ae00e6af5ce22254496ed37e2774b79e8
Reviewed-on: https://boringssl-review.googlesource.com/28747
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-29 14:33:16 +00:00
David Benjamin 700631bdf0 Pack encrypted handshake messages together.
We have a successful TLS 1.3 deployment, in spite of non-compliant
middleboxes everywhere, so now let's get this optimization in. It would
have been nice to test with this from the beginning, but sadly we forgot
about it. Ah well. This shaves 63 bytes off the server's first flight,
and then another 21 bytes off the pair of NewSessionTickets.

So we'll more easily notice in case of anything catastrophic, tie this
behavior to draft 28.

Update-Note: This slightly tweaks our draft-28 behavior.

Change-Id: I4f176a919bf7181239d6ebb31e7870f12364e0f9
Reviewed-on: https://boringssl-review.googlesource.com/28744
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-29 14:28:56 +00:00
David Benjamin 81d4a03bb0 Update tools.
Change-Id: I290af4599231040887f41c922550bb87dfb98cb0
Reviewed-on: https://boringssl-review.googlesource.com/28746
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-29 14:24:35 +00:00
David Benjamin f86693dff7 Document the correct nonce length for AES-GCM.
It would be nice to restrict these, limiting the incorrect sizes to a
separate EVP_AEAD, but start by documenting this.

Bug: 34
Change-Id: I09845882f76a53a010355ceefd168d4fc10a0681
Reviewed-on: https://boringssl-review.googlesource.com/28745
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-24 22:13:07 +00:00
David Benjamin 5601bdac1a Rename crypto/rsa_extra/print.c.
It appears Chromium still gets upset when two files in a target share a
base name.

Change-Id: I9e6f182d97405e7e70b2bcf8ced7c80ba23edca1
Reviewed-on: https://boringssl-review.googlesource.com/28724
Reviewed-by: Adam Langley <agl@google.com>
2018-05-23 22:36:14 +00:00
Adam Langley 990a32327c Add --embed_test_data=false option to generate_build_files.py
This allows consumers not to use crypto_test_data.cc (which embeds all
the test files), although they'll have to provide their own
implementation of that functionality.

Change-Id: I309d5b3bd9495137e1df788b34048794b0072f3b
Reviewed-on: https://boringssl-review.googlesource.com/28706
Reviewed-by: David Benjamin <davidben@google.com>
2018-05-22 17:24:42 +00:00
Adam Langley 239c05a782 Allow convert_wycheproof.go to be used one file at a time.
Change-Id: I3c1d77ac9dea6faefc3711e84cf93191f35fe755
Reviewed-on: https://boringssl-review.googlesource.com/28705
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-22 17:19:45 +00:00
Adam Langley 576b637861 Move convert_wycheproof.go to util/
This file is not part of the Wycheproof project and consumers of
BoringSSL who wish to provide Wycheproof themselves (and not have
third_party/wycheproof_testvectors) need it in another location.

Change-Id: I730fe294f46a9aac77b858a91a03ee64fb8ea579
Reviewed-on: https://boringssl-review.googlesource.com/28704
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-22 17:16:36 +00:00
Adam Vartanian 189270cd19 Ignore Spectre mitigation warning.
VS2017 has added a new warning that indicates where Spectre mitigation
code would be inserted if /Qspectre were specified.

Change-Id: If80cd6a7d0c5a45313f4c3644b304cadecf465b0
Reviewed-on: https://boringssl-review.googlesource.com/28684
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-22 15:26:15 +00:00
David Benjamin c93724b530 Benchmark TLS AES-CBC ciphers in both directions.
Between CBC being only parallelizable in one direction, bsaes vs vpaes,
and the Lucky 13 fix, seal and open look very different here. Benchmark
both directions.

Change-Id: I9266ab2800adc29dbeee0ca74502addb92409e23
Reviewed-on: https://boringssl-review.googlesource.com/28644
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-21 23:08:46 +00:00
Brian Smith fee8709f69 Replace |alloca| in |BN_mod_exp_mont_consttime|.
|alloca| is dangerous and poorly specified, according to any
description of |alloca|. It's also hard for some analysis tools to
reason about.

The code here assumed |alloca| is a macro, which isn't a valid
assumption. Depending on what which headers are included and what
toolchain is being used, |alloca| may or may not be defined as a macro,
and this might change over time if/when toolchains are updated. Or, we
might be doing static analysis and/or dynamic analysis with a different
configuration w.r.t. the availability of |alloca| than production
builds use.

Regardless, the |alloca| code path only kicked in when the inputs are
840 bits or smaller. Since the multi-prime RSA support was removed, for
interesting RSA key sizes the input will be at least 1024 bits and this
code path won't be triggered since powerbufLen will be larger than 3072
bytes in those cases. ECC inversion via Fermat's Little Theorem has its
own constant-time exponentiation so there are no cases where smaller
inputs need to be fast.

The RSAZ code avoids the |OPENSSL_malloc| for 2048-bit RSA keys.
Increasingly the RSAZ code won't be used though, since it will be
skipped over on Broadwell+ CPUs. Generalize the RSAZ stack allocation
to work for non-RSAZ code paths. In order to ensure this doesn't cause
too much stack usage on platforms where RSAZ wasn't already being used,
only do so on x86-64, which already has this large stack size
requirement due to RSAZ.

This change will make it easier to refactor |BN_mod_exp_mont_consttime|
to do that more safely and in a way that's more compatible with various
analysis tools.

This is also a step towards eliminating the |uintptr_t|-based alignment
hack.

Since this change increases the number of times |OPENSSL_free| is
skipped, I've added an explicit |OPENSSL_cleanse| to ensure the
zeroization is done. This should be done regardless of the other changes
here.

Change-Id: I8a161ce2720a26127e85fff7513f394883e50b2e
Reviewed-on: https://boringssl-review.googlesource.com/28584
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-05-21 19:43:05 +00:00
Adam Langley 63e2a08123 Spell Falko Strenzke's name correctly.
Thanks to Brian Smith for pointing this out.

Change-Id: I27ae58df0028bc6aa3a11741acb5453369e202cc
Reviewed-on: https://boringssl-review.googlesource.com/28625
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-21 18:18:04 +00:00
David Benjamin 982279b366 Add a PKCS#12 fuzzer.
Change-Id: Iee3a3d46d283bd6cbb46940e630916aacdd71db6
Reviewed-on: https://boringssl-review.googlesource.com/28552
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-15 23:58:32 +00:00
David Benjamin 2f5100e629 More compatibility stuff.
cryptography.io wants things exposed out of EVP_get_cipherby* including,
sadly, ECB mode.

Change-Id: I9bac46f8ffad1a79d190cee3b0c0686bf540298e
Reviewed-on: https://boringssl-review.googlesource.com/28464
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-15 23:57:53 +00:00
David Benjamin 9b2c6a93e5 Extract friendly names attached to certificates.
OpenSSL staples each certificate's friendly name to the X509 with
X509_alias_set1. Mimic this. pyOpenSSL expects to find it there.

Update-Note: We actually parse some attributes now. PKCS#12 files with
malformed ones may not parse.

Change-Id: I3b78958eedf195509cd222ea4f0c884be3753770
Reviewed-on: https://boringssl-review.googlesource.com/28551
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-15 23:44:53 +00:00
David Benjamin 22ae0b8577 Try both null and empty passwords when decoding PKCS#12.
PKCS#12 encodes passwords as NUL-terminated UCS-2, so the empty password
is encoded as {0, 0}. Some implementations use the empty byte array for
"no password". OpenSSL considers a non-NULL password as {0, 0} and a
NULL password as {}. It then, in high-level PKCS#12 parsing code, tries
both options.

Match this behavior to appease pyOpenSSL's tests.

Change-Id: I07ef91d54454b6f2647f86b7eb9b13509b2876d3
Reviewed-on: https://boringssl-review.googlesource.com/28550
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-05-15 23:41:32 +00:00
David Benjamin 910320a3a0 Restore some revocation-related X.509 extensions.
These are tied to OPENSSL_NO_OCSP in upstream but do not actually depend
on most of the OCSP machinery. The CRL invdate extension, in particular,
isn't associated with OCSP at all. cryptography.io gets upset if these
two extensions aren't parseable, and they're tiny.

I do not believe this actually affects anything beyond functions like
X509_get_ext_d2i. In particular, the list of NIDs for the criticality
check is elsewhere.

Change-Id: I889f6ebf4ca4b34b1d9ff15f45e05878132826a1
Reviewed-on: https://boringssl-review.googlesource.com/28549
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-05-15 23:36:08 +00:00
David Benjamin db196aab50 Distinguish unrecognized SPKI/PKCS8 key types from syntax errors.
Change-Id: Ia24aae31296772e2ddccf78f10a6640da459adf7
Reviewed-on: https://boringssl-review.googlesource.com/28548
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-05-15 23:36:02 +00:00
Adam Langley 91254c244c Rename |asm_AES_*| to |aes_nohw_*|.
Rather than have plain-C functions, asm functions, and accelerated
functions, just have accelerated and non-accelerated, where the latter
are either provided by assembly or by C code.

Pertinently, this allows Aarch64 to use hardware accel for the basic
|AES_*| functions.

Change-Id: I0003c0c7a43d85a3eee8c8f37697f61a3070dd40
Reviewed-on: https://boringssl-review.googlesource.com/28385
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-15 23:02:52 +00:00
David Benjamin d12f2ba55e Tweak RSA errors for compatibility.
cryptography.io wants RSA_R_BLOCK_TYPE_IS_NOT_02, only used by the
ancient RSA_padding_check_SSLv23 function. Define it but never emit it.

Additionally, it's rather finicky about RSA_R_TOO_LARGE* errors. We
merged them in BoringSSL because having RSA_R_TOO_LARGE,
RSA_R_TOO_LARGE_FOR_MODULUS, and RSA_R_TOO_LARGE_FOR_KEY_SIZE is a
little silly. But since we don't expect well-behaved code to condition
on error codes anyway, perhaps that wasn't worth it.  Split them back
up.

Looking through OpenSSL, there is a vague semantic difference:

RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY - Specifically emitted if a digest is
too big for PKCS#1 signing with this key.

RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE - You asked me to sign or encrypt a
digest/plaintext, but it's too big for this key.

RSA_R_DATA_TOO_LARGE_FOR_MODULUS - You gave me an RSA ciphertext or
signature and it is not fully reduced modulo N.
-OR-
The padding functions produced something that isn't reduced, but I
believe this is unreachable outside of RSA_NO_PADDING.

RSA_R_DATA_TOO_LARGE - Some low-level padding function was told to copy
a digest/plaintext into some buffer, but the buffer was too small. I
think this is basically unreachable.
-OR-
You asked me to verify a PSS signature, but I didn't need to bother
because the digest/salt parameters you picked were too big.

Update-Note: This depends on cl/196566462.
Change-Id: I2e539e075eff8bfcd52ccde365e975ebcee72567
Reviewed-on: https://boringssl-review.googlesource.com/28547
Reviewed-by: Adam Langley <agl@google.com>
2018-05-15 23:02:49 +00:00
David Benjamin fa544f1c05 Reject if the ALPN callback returned an empty protocol.
If the callback returns an empty ALPN, we forget we negotiated ALPN at
all (bssl::Array does not distinguish null and empty). Empty ALPN
protocols are forbidden anyway, so reject these ahead of time.

Change-Id: I42f1fc4c843bc865e23fb2a2e5d57424b569ee99
Reviewed-on: https://boringssl-review.googlesource.com/28546
Reviewed-by: Adam Langley <agl@google.com>
2018-05-15 23:02:39 +00:00
Daniel Hirche e6737a8656 x509_test: Fix gcc-8 build
gcc-8 complains that struct Test shadows class Test from googletest.

Change-Id: Ie0c61eecebc726973c6aaa949e338da3d4474977
Reviewed-on: https://boringssl-review.googlesource.com/28524
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-15 22:58:22 +00:00
David Benjamin 911cc0a0aa The legacy client OCSP callback should run without server OCSP.
It's conditioned in OpenSSL on client offer, not server accept.

Change-Id: Iae5483a33d9365258446ce0ae34132aeb4a92c66
Reviewed-on: https://boringssl-review.googlesource.com/28545
Reviewed-by: Adam Langley <agl@google.com>
2018-05-15 22:57:41 +00:00
David Benjamin d6e31f6a56 Return more placeholder version strings.
PyOpenSSL's tests expect all of the outputs to be distinct. OpenSSL also
tends to prefix the return values with strings like "compiler:", so do
something similar.

Change-Id: Ic411c95a276b477641ebad803ac309b3035c1b13
Reviewed-on: https://boringssl-review.googlesource.com/28544
Reviewed-by: Adam Langley <agl@google.com>
2018-05-15 22:57:30 +00:00
David Benjamin 9db1a0017a Support 3DES-CMAC.
cryptography.io depends on this. Specifically, it assumes that any time
a CBC-mode cipher is defined, CMAC is also defined. This is incorrect;
CMAC also requires an irreducible polynomial to represent GF(2^b).
However, one is indeed defined for 64-bit block ciphers such as 3DES.

Import tests from CAVP to test it. I've omitted the 65536-byte inputs
because they're huge and FileTest doesn't like lines that long.

Change-Id: I35b1e4975f61c757c70616f9b372b91746fc7e4a
Reviewed-on: https://boringssl-review.googlesource.com/28466
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-05-15 22:23:26 +00:00
David Benjamin 62abcebb01 Add a driver for Wycheproof CMAC tests.
Change-Id: Iafe81d22647c99167ab27a5345cfa970755112ac
Reviewed-on: https://boringssl-review.googlesource.com/28465
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-05-15 21:19:42 +00:00
David Benjamin 370bb35627 Refresh TLS fuzzer corpora.
Change-Id: I2a1db17aa667c98a7de66ff5af5c76e13c5b8976
Reviewed-on: https://boringssl-review.googlesource.com/28504
Reviewed-by: David Benjamin <davidben@google.com>
2018-05-14 22:53:55 +00:00
Adam Langley 05750f23ae Revert "Revert "Revert "Revert "Make x86(-64) use the same aes_hw_* infrastructure as POWER and the ARMs.""""
This was reverted a second time because it ended up always setting the
final argument to CRYPTO_gcm128_init to zero, which disabled some
acceleration of GCM on ≥Haswell. With this update, that argument will be
set to 1 if |aes_hw_*| functions are being used.

Probably this will need to be reverted too for some reason. I'm hoping
to fill the entire git short description with “Revert”.

Change-Id: Ib4a06f937d35d95affdc0b63f29f01c4a8c47d03
Reviewed-on: https://boringssl-review.googlesource.com/28484
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-14 22:09:29 +00:00
David Benjamin 5b220ee70d Add APIs to query authentication properties of SSL_SESSIONs.
This is so Chromium can verify the session before offering it, rather
than doing it after the handshake (at which point it's too late to punt
the session) as we do today. This should, in turn, allow us to finally
verify certificates off a callback and order it correctly relative to
CertificateRequest in TLS 1.3.

(It will also order "correctly" in TLS 1.2, but this is useless. TLS 1.2
does not bind the CertificateRequest to the certificate at the point the
client needs to act on it.)

Bug: chromium:347402
Change-Id: I0daac2868c97b820aead6c3a7e4dc30d8ba44dc4
Reviewed-on: https://boringssl-review.googlesource.com/28405
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2018-05-14 19:10:48 +00:00
Adam Langley 69271b5d4f Revert "Revert "Revert "Make x86(-64) use the same aes_hw_* infrastructure as POWER and the ARMs."""
gcm.c's AES-NI code wasn't triggering. (Thanks Brain for noting.)

Change-Id: Ic740e498b94fece180ac35c449066aee1349cbd5
Reviewed-on: https://boringssl-review.googlesource.com/28424
Reviewed-by: Adam Langley <alangley@gmail.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-12 15:18:16 +00:00
Adam Langley 7d1f35985b Show an error before we abort the process for an entropy failure.
Change-Id: I8d8483d38de15dcde18141bb9cc9e79d585d24ad
Reviewed-on: https://boringssl-review.googlesource.com/27045
Reviewed-by: Adam Langley <agl@google.com>
2018-05-11 22:30:24 +00:00
David Benjamin 103ed08549 Implement legacy OCSP APIs for libssl.
Previously, we'd omitted OpenSSL's OCSP APIs because they depend on a
complex OCSP mechanism and encourage the the unreliable server behavior
that hampers using OCSP stapling to fix revocation today. (OCSP
responses should not be fetched on-demand on a callback. They should be
managed like other server credentials and refreshed eagerly, so
temporary CA outage does not translate to loss of OCSP.)

But most of the APIs are byte-oriented anyway, so they're easy to
support. Intentionally omit the one that takes a bunch of OCSP_RESPIDs.

The callback is benign on the client (an artifact of OpenSSL reading
OCSP and verifying certificates in the wrong order). On the server, it
encourages unreliability, but pyOpenSSL/cryptography.io depends on this.
Dcument that this is only for compatibility with legacy software.

Also tweak a few things for compatilibility. cryptography.io expects
SSL_CTX_set_read_ahead to return something, SSL_get_server_tmp_key's
signature was wrong, and cryptography.io tries to redefine
SSL_get_server_tmp_key if SSL_CTRL_GET_SERVER_TMP_KEY is missing.

Change-Id: I2f99711783456bfb7324e9ad972510be8a95e845
Reviewed-on: https://boringssl-review.googlesource.com/28404
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-05-11 22:21:26 +00:00
David Benjamin 7b832ad118 Don't crash if asked to treat PBES2 as a PBES1 scheme.
Change-Id: I5d0570634a9ebf553f8c3d22e7cced9d2b972abf
Reviewed-on: https://boringssl-review.googlesource.com/28330
Reviewed-by: Adam Langley <agl@google.com>
2018-05-11 22:00:04 +00:00
David Benjamin f05e3eafbc Add a bunch of X509_STORE getters and setters.
These were added in OpenSSL 1.1.0.

Change-Id: I261e0e0ccf82544883c4a2ef5c5dc4a651c0c756
Reviewed-on: https://boringssl-review.googlesource.com/28329
Reviewed-by: Adam Langley <agl@google.com>
2018-05-11 21:59:58 +00:00
David Benjamin 2e67153de4 Add PKCS12_create.
PyOpenSSL calls this function these days. Tested by roundtripping with
ourselves and also manually confirming our output interoperates with
OpenSSL.  (For anyone repeating this experiment, the OpenSSL
command-line tool has a bug and does not correctly output friendlyName
attributes with non-ASCII characters. I'll send them a PR to fix this
shortly.)

Between this and the UTF-8 logic earlier, the theme of this patch series
seems to be "implement in C something I last implemented in
JavaScript"...

Change-Id: I258d563498d82998c6bffc6789efeaba36fe3a5e
Reviewed-on: https://boringssl-review.googlesource.com/28328
Reviewed-by: Adam Langley <agl@google.com>
2018-05-11 21:59:34 +00:00
David Benjamin a3c2517bd9 Add i2d_PKCS12*.
This is not very useful without PKCS12_create, which a follow-up change
will implement.

Change-Id: I355ccd22a165830911ae189871ab90a6101f42ae
Reviewed-on: https://boringssl-review.googlesource.com/28327
Reviewed-by: Adam Langley <agl@google.com>
2018-05-11 21:59:20 +00:00
David Benjamin bc2562e50e Treat PKCS#12 passwords as UTF-8.
This aligns with OpenSSL 1.1.0's behavior, which deviated from OpenSSL
1.0.2. OpenSSL 1.0.2 effectively assumed input passwords were always
Latin-1.

Update-Note: If anyone was using PKCS#12 passwords with non-ASCII
characters, this changes them from being encoding-confused to hopefully
interpretting "correctly". If this breaks anything, we can add a
fallback to PKCS12_get_key_and_certs/PKCS12_parse, but OpenSSL 1.1.0
does not have such behavior. It only implements a fallback in the
command-line tool, not the APIs.

Change-Id: I0aa92db26077b07a40f85b89f4d3e0f6b0d7be87
Reviewed-on: https://boringssl-review.googlesource.com/28326
Reviewed-by: Adam Langley <agl@google.com>
2018-05-11 21:58:56 +00:00
David Benjamin ae153bb9a6 Use new encoding functions in ASN1_mbstring_ncopy.
Update-Note: This changes causes BoringSSL to be stricter about handling
Unicode strings:
  · Reject code points outside of Unicode
  · Reject surrogate values
  · Don't allow invalid UTF-8 to pass through when the source claims to
    be UTF-8 already.
  · Drop byte-order marks.

Previously, for example, a UniversalString could contain a large-valued
code point that would cause the UTF-8 encoder to emit invalid UTF-8.

Change-Id: I94d9db7796b70491b04494be84249907ff8fb46c
Reviewed-on: https://boringssl-review.googlesource.com/28325
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-05-11 21:58:47 +00:00
David Benjamin 99767ecdd4 Enable ADX assembly.
Build (and carry) issues are now resolved (as far as we know). Let's try
this again...

Measurements on a Skylake VM (so a little noisy).

Before:
Did 3135 RSA 2048 signing operations in 3015866us (1039.5 ops/sec)
Did 89000 RSA 2048 verify (same key) operations in 3007271us (29594.9 ops/sec)
Did 66000 RSA 2048 verify (fresh key) operations in 3014363us (21895.2 ops/sec)
Did 324 RSA 4096 signing operations in 3004364us (107.8 ops/sec)
Did 23126 RSA 4096 verify (same key) operations in 3003398us (7699.9 ops/sec)
Did 21312 RSA 4096 verify (fresh key) operations in 3017043us (7063.9 ops/sec)
Did 31040 ECDH P-256 operations in 3024273us (10263.6 ops/sec)
Did 91000 ECDSA P-256 signing operations in 3019740us (30135.0 ops/sec)
Did 25678 ECDSA P-256 verify operations in 3046975us (8427.4 ops/sec)

After:
Did 3640 RSA 2048 signing operations in 3035845us (1199.0 ops/sec)
Did 129000 RSA 2048 verify (same key) operations in 3003691us (42947.2 ops/sec)
Did 105000 RSA 2048 verify (fresh key) operations in 3029935us (34654.2 ops/sec)
Did 510 RSA 4096 signing operations in 3014096us (169.2 ops/sec)
Did 38000 RSA 4096 verify (same key) operations in 3092814us (12286.5 ops/sec)
Did 34221 RSA 4096 verify (fresh key) operations in 3003817us (11392.5 ops/sec)
Did 38000 ECDH P-256 operations in 3061758us (12411.2 ops/sec)
Did 116000 ECDSA P-256 signing operations in 3001637us (38645.6 ops/sec)
Did 35100 ECDSA P-256 verify operations in 3023872us (11607.6 ops/sec)

Tested with Intel SDE.

Change-Id: Ib27c0d6012d14274e331ab03f958e5a0c8b7e885
Reviewed-on: https://boringssl-review.googlesource.com/28104
Reviewed-by: Adam Langley <agl@google.com>
2018-05-11 21:57:13 +00:00
David Benjamin b06f92da7b Add new character encoding functions.
These will be used for the PKCS#12 code and to replace some of the
crypto/asn1 logic. So far they support the ones implemented by
crypto/asn1, which are Latin-1, UCS-2 (ASN.1 BMPStrings can't go beyond
the BMP), UTF-32 (ASN.1 UniversalString) and UTF-8.

Change-Id: I3d5c0d964cc6f97c3a0a1e352c9dd7d8cc0d87f2
Reviewed-on: https://boringssl-review.googlesource.com/28324
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-05-11 21:55:26 +00:00
Adam Langley 29d97ff333 Revert "Revert "Make x86(-64) use the same aes_hw_* infrastructure as POWER and the ARMs.""
This relands
https://boringssl-review.googlesource.com/c/boringssl/+/28026 with a
change to avoid calling the Aarch64 hardware functions when the set has
been set by C code, since these are seemingly incompatible.

Change-Id: I91f3ed41cf6f7a7ce7a0477753569fac084c528b
Reviewed-on: https://boringssl-review.googlesource.com/28384
Reviewed-by: Adam Langley <agl@google.com>
2018-05-11 19:16:49 +00:00
Adam Langley aca24c8724 Revert "Make x86(-64) use the same aes_hw_* infrastructure as POWER and the ARMs."
Broke Aarch64 on the main builders (but not the trybots, somehow.)

Change-Id: I53eb09c99ef42a59628b0506b5ddb125299b554a
Reviewed-on: https://boringssl-review.googlesource.com/28364
Reviewed-by: Adam Langley <agl@google.com>
2018-05-11 17:39:50 +00:00
David Benjamin 5f001d1423 Const-correct some functions.
Callers should not mutate these.

Update-Note: I believe I've fixed up everything. If I missed one, the
fix should be straightforward.

Change-Id: Ifbce4961204822f57502a0de33aaa5a2a08b026d
Reviewed-on: https://boringssl-review.googlesource.com/28266
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2018-05-11 15:10:35 +00:00
Adam Langley 26ba48a6fb Make x86(-64) use the same aes_hw_* infrastructure as POWER and the ARMs.
This also happens to make the AES_[en|de]crypt functions use AES-NI
(where available) on Intel.

Update-Note: this substantially changes how AES-NI is triggered. Worth running bssl speed (on both k8 and ppc), before and after, to confirm that there are no regressions.

Change-Id: I5f22c1975236bbc1633c24ab60d683bca8ddd4c3
Reviewed-on: https://boringssl-review.googlesource.com/28026
Reviewed-by: David Benjamin <davidben@google.com>
2018-05-11 00:16:39 +00:00
Steven Valdez 56c4ed9ad7 Allow enabling all TLS 1.3 variants by setting |tls13_default|.
Update-Note: Enabling TLS 1.3 now enables both draft-23 and draft-28
by default, in preparation for cycling all to draft-28.
Change-Id: I9405f39081f2e5f7049aaae8a9c85399f21df047
Reviewed-on: https://boringssl-review.googlesource.com/28304
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-05-10 20:27:34 +00:00
David Benjamin 65359f0887 Don't keep trying to read from stdin after EOF.
I added the flag but forgot to do anything with it.

Change-Id: I5ad7e1ceed7eca60a3a096c079092ae30b2becbe
Reviewed-on: https://boringssl-review.googlesource.com/28305
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-10 19:41:24 +00:00
Matthew Braithwaite d4e091ece9 Refresh TLS fuzzer corpora.
Change-Id: I3c013d10f0dbd2a46c5e7d62ecff40e6b7e2be8a
Reviewed-on: https://boringssl-review.googlesource.com/28144
Reviewed-by: David Benjamin <davidben@google.com>
2018-05-10 19:16:35 +00:00
David Benjamin 418cdc4df4 Use the right alert for bad CA lists.
Bug: 245
Change-Id: I6bfaf2dbe4996219773742a88c401d6cfffe3a3d
Reviewed-on: https://boringssl-review.googlesource.com/28284
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-09 18:04:38 +00:00
Matthew Braithwaite 3babc86d0f Expand the documentation of |SSL_set_shed_handshake_config|.
Change-Id: I49a693ef8aef2a0d83bc5d1c71bd896e28bf1a98
Reviewed-on: https://boringssl-review.googlesource.com/28246
Commit-Queue: Matt Braithwaite <mab@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-05-08 23:23:55 +00:00
David Benjamin 8094b54eb1 Add BIO versions of i2d_DHparams and d2i_DHparams.
Change-Id: Ie643aaaa44aef67932b107d31ef92c2649738051
Reviewed-on: https://boringssl-review.googlesource.com/28269
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-08 23:12:15 +00:00
David Benjamin 02de7bd3a0 Add some more accessors to SSL_SESSION.
Hopefully this is the last of it before we can hide the struct. We're
missing peer_sha256 accessors, and some test wants to mutate the ticket
in a test client.

Change-Id: I1a30fcc0a1e866d42acbc07a776014c9257f7c86
Reviewed-on: https://boringssl-review.googlesource.com/28268
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-05-08 22:50:45 +00:00
Adam Langley f64c373784 Fix build with GCC 4.9.2 and -Wtype-limits.
gRPC builds on Debian Jessie, which has GCC 4.9.2, and builds with
-Wtype-limits, which makes it warn about code intended for 64-bit
systems when building on 32-bit systems.

We have tried to avoid these issues with Clang previously by guarding
with “sizeof(size_t) > 4”, but this version of GCC isn't smart enough to
figure that out.

Change-Id: I800ceb3891436fa7c81474ede4b8656021568357
Reviewed-on: https://boringssl-review.googlesource.com/28247
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-08 22:21:45 +00:00
David Benjamin bb3a456930 Move some RSA keygen support code into separate files.
This was all new code. There was a request to make this available under
ISC.

Change-Id: Ibabbe6fbf593c2a781aac47a4de7ac378604dbcf
Reviewed-on: https://boringssl-review.googlesource.com/28267
Reviewed-by: Adam Langley <agl@google.com>
2018-05-08 21:25:46 +00:00
David Benjamin 5d626b223b Add some more compatibility functions.
Change-Id: I56afcd896cb9de1c69c788b4f6395f4e78140d81
Reviewed-on: https://boringssl-review.googlesource.com/28265
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-08 20:51:15 +00:00
Martin Kreichgauer 044f637fef reformat third_party/wycheproof_testvectors/METADATA
Change-Id: Ib12f41dec023e20dfd1182513bf11571950d7c85
Reviewed-on: https://boringssl-review.googlesource.com/28245
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-08 19:00:35 +00:00
David Benjamin 477a9262f2 Bump BORINGSSL_API_VERSION.
Update-Note: https://boringssl-review.googlesource.com/28224 added
i2d_re_X509_tbs which was a 1.0.2 API we'd missed. Adding it is
ultimately more compatible, but will break
https://github.com/google/certificate-transparency/blob/master/cpp/log/cert.cc#L34
due to its OPENSSL_IS_BORINGSSL ifdef.

Bump BORINGSSL_API_VERSION so that we can patch that file with a
BORINGSSL_API_VERSION version check.

Change-Id: I9c83f5138a0215b554351b67ed51714d04428bd2
Reviewed-on: https://boringssl-review.googlesource.com/28264
Reviewed-by: Adam Langley <agl@google.com>
2018-05-08 17:40:55 +00:00
Adam Langley 57eaeaba24 Fix include path.
This happened to be working only because of lucky -I argument and At the
same time, include digest.h since this file references |EVP_sha1| and
other digest-related functions.

Change-Id: I0095ea8f5ef21f6e63b3dc819932b38178e09693
Reviewed-on: https://boringssl-review.googlesource.com/28244
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-08 16:26:05 +00:00
David Benjamin 91374e0cd2 Add a stub e_os2.h header.
Some third-party projects include it for some inexplicable reason.

Change-Id: I57c406d77d82a4a9ba6b54519023f2b02f2eb5e2
Reviewed-on: https://boringssl-review.googlesource.com/28225
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-08 01:32:14 +00:00
David Benjamin 0318b051ee Add some OpenSSL compatibility functions and hacks.
Change-Id: Ie42e57441f5fd7d1557a7fc1c648cf3f28b9c4db
Reviewed-on: https://boringssl-review.googlesource.com/28224
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-08 01:22:04 +00:00
David Benjamin 1d339558ac Fix clang-cl build.
I missed the return value of operator=.

Change-Id: Ic8d6ec8feb47e922be56f5fba7aff019c322d6fa
Reviewed-on: https://boringssl-review.googlesource.com/28190
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-07 19:34:11 +00:00
David Benjamin 26aa7c88d1 Handle blocked writes in bssl client/server.
On Windows, just switching the socket to blocking doesn't work. Instead,
switch the stdin half of the waiter to waiting for either socket write
or stdin read, depending on whether we're in the middle of trying to
write a buffer.

Change-Id: I81414898f0491e78e6ab5b28c12148a3909ec1e0
Reviewed-on: https://boringssl-review.googlesource.com/28167
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-07 19:11:35 +00:00
David Benjamin ed188fd8ef Enforce supported_versions in the second ServerHello.
We forgot to do this in our original implementation on general ecosystem
grounds. It's also mandated starting draft-26.

Just to avoid unnecessary turbulence, since draft-23 is doomed to die
anyway, condition this on our draft-28 implementation. (We don't support
24 through 27.)

We'd actually checked this already on the Go side, but the spec wants a
different alert.

Change-Id: I0014cda03d7129df0b48de077e45f8ae9fd16976
Reviewed-on: https://boringssl-review.googlesource.com/28124
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2018-05-07 19:05:20 +00:00
David Benjamin 3d9705d0a4 Fix bssl handling of buffered read data.
If the peer sends us one record that exceeds buffer, the socket will no
longer flag as readable, because data has been consumed, but SSL_read
should still be called to drain data. bssl would instead not notice and
only surface the data later on.

This can (currently) be reproduced by sending "HEAD / HTTP/1.1" to
www.google.com.

Change-Id: I73cdbe104ba6be56fc033429999e630f0eb852d8
Reviewed-on: https://boringssl-review.googlesource.com/28166
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-07 19:05:00 +00:00
David Benjamin 28385db6e1 Fix bssl select loop on Windows.
While |WaitForMultipleObjects| works for both sockets and stdin, the
latter is often a line-buffered console. The |HANDLE| is considered
readable if there are any console events available, but reading blocks
until a full line is available. (In POSIX, line buffering is implemented
in the kernel via termios, which is differently concerning, but does
mean |select| works as expected.)

So that |Wait| reflects final stdin read, we spawn a stdin reader thread
that writes to an in-memory buffer and signals a |WSAEVENT| to
coordinate with the socket. This is kind of silly, but it works.

I tried just writing it to a pipe, but it appears
|WaitForMultipleObjects| does not work on pipes!

Change-Id: I2bfa323fa91aad7d2035bb1fe86ee6f54b85d811
Reviewed-on: https://boringssl-review.googlesource.com/28165
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-07 19:04:00 +00:00
David Benjamin 2a92847c24 Restore some MSVC warnings.
bcm.c means e_aes.c can no longer be lazy about warning push/pop.

Change-Id: I558041bab3baa00e3adc628fe19486545d0f6be3
Reviewed-on: https://boringssl-review.googlesource.com/28164
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-07 19:03:30 +00:00
David Benjamin bf33114b51 Rename third_party/wycheproof to satisfy a bureaucrat.
Make it clear this is not a pristine full copy of all of Wycheproof as a
library.

Change-Id: I1aa5253a1d7c696e69b2e8d7897924f15303d9ac
Reviewed-on: https://boringssl-review.googlesource.com/28188
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Martin Kreichgauer <martinkr@google.com>
Reviewed-by: Martin Kreichgauer <martinkr@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-07 18:33:50 +00:00
David Benjamin 98831738f2 Revert "Add other Windows configurations to the CQ."
This reverts commit b0412a6eba. It's still
flaky.

Change-Id: I234e67bf9114cab495ab6d93415c01e0168684fb
Reviewed-on: https://boringssl-review.googlesource.com/28189
Reviewed-by: David Benjamin <davidben@google.com>
2018-05-07 18:29:32 +00:00
David Benjamin b0412a6eba Add other Windows configurations to the CQ.
They were flaky half a year ago, but maybe infra has fixed whatever the
issue was. We're on a different swarming pool now.

Change-Id: I6e9faa3e84d373a650ad67915ce93b293a968da8
Reviewed-on: https://boringssl-review.googlesource.com/28187
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-07 18:09:39 +00:00
David Benjamin 3c37d0aba5 Reland "Fix bssl client/server's error-handling."
Rather than printing the SSL_ERROR_* constants, print the actual error.
This should be a bit more understandable. Debugging this also uncovered
some other issues on Windows:

- We were mixing up C runtime and Winsock errors, which are separate in
  Windows.

- The thread local implementation interferes with WSAGetLastError due to
  a quirk of TlsGetValue. This could affect other Windows consumers.
  (Chromium uses a custom BIO, so it isn't affected.)

- SocketSetNonBlocking also interferes with WSAGetLastError.

- Listen for FD_CLOSE along with FD_READ. Connection close does not
  signal FD_READ. (The select loop only barely works on Windows anyway
  due to issues with stdin and line buffering, but if we take stdin out
  of the equation, FD_CLOSE can be tested.)

Change-Id: Ia8d42b5ac39ebb3045d410dd768f83a3bb88b2cb
Reviewed-on: https://boringssl-review.googlesource.com/28186
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-07 17:19:59 +00:00
Steven Valdez 0cdbc876a2 Revert "Fix bssl client/server's error-handling."
This reverts commit e7ca8a5d78.

Change-Id: Ib2f923760dc54400f45e9327b3a45466be1dd6d1
Reviewed-on: https://boringssl-review.googlesource.com/28184
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-07 16:53:09 +00:00
David Benjamin e7ca8a5d78 Fix bssl client/server's error-handling.
Rather than printing the SSL_ERROR_* constants, print the actual error.
This should be a bit more understandable. Debugging this also uncovered
some other issues on Windows:

- We were mixing up C runtime and Winsock errors, which are separate in
  Windows.

- The thread local implementation interferes with WSAGetLastError due to
  a quirk of TlsGetValue. This could affect other Windows consumers.
  (Chromium uses a custom BIO, so it isn't affected.)

- SocketSetNonBlocking also interferes with WSAGetLastError.

- Listen for FD_CLOSE along with FD_READ. Connection close does not
  signal FD_READ. (The select loop only barely works on Windows anyway
  due to issues with stdin and line buffering, but if we take stdin out
  of the equation, FD_CLOSE can be tested.)

Change-Id: If991259915acc96606a314fbe795fe6ea1e295e8
Reviewed-on: https://boringssl-review.googlesource.com/28125
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-07 15:44:08 +00:00
Matthew Braithwaite e30fac6371 Fuzz SSL_serialize_handoff() and SSL_serialize_handback().
This is done by adding two new tagged data types to the shim's
transcript: one for the serialized handoff, and another for the
serialized handback.

Then, the handshake driver in |TLSFuzzer| is modified to be able to
drive a handoff+handback sequence in the same way as was done for
testing: by swapping |BIO|s into additional |SSL| objects.  (If a
particular transcript does not contain a serialized handoff, this is a
no-op.)

Change-Id: Iab23e4dc27959ffd3d444adc41d40a4274e83653
Reviewed-on: https://boringssl-review.googlesource.com/27204
Commit-Queue: Matt Braithwaite <mab@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-05-05 02:41:04 +00:00
Matthew Braithwaite 9fdf7cb97a SSL_apply_handback: check session is where it's expected to be.
Found by fuzzing.

Change-Id: I831f7869b16486eef7ac887ee199450e38461086
Reviewed-on: https://boringssl-review.googlesource.com/28044
Commit-Queue: Matt Braithwaite <mab@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-05-05 02:25:24 +00:00
Matthew Braithwaite 0e9e0ba18c SSL_apply_handback: check that SSL version is valid.
Along the way, check the version against the cipher to make sure the
combination is possible.

(Found by fuzzing: a bad version trips an assert.)

Change-Id: Ib0a284fd5fd9b7ba5ceba63aa6224966282a2cb7
Reviewed-on: https://boringssl-review.googlesource.com/27265
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-05-04 18:27:34 +00:00
Steven Valdez 537553ff7f Prevent out of bound read in do_buf (a_strex).
(Imported from upstream's 7e6c0f56e65af0727d87615342df1272cd017e9f)

Change-Id: I1d060055c923f78311265510a3fbe17a34ecc1d4
Reviewed-on: https://boringssl-review.googlesource.com/28084
Commit-Queue: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-04 18:22:34 +00:00
David Benjamin 179c4e257a Update Wycheproof, add keywrap tests, and fix a bug.
The bug, courtesy of Wycheproof, is that AES key wrap requires the input
be at least two blocks, not one. This also matches the OpenSSL behavior
of those two APIs.

Update-Note: AES_wrap_key with in_len = 8 and AES_unwrap_key with
in_len = 16 will no longer work.

Change-Id: I5fc63ebc16920c2f9fd488afe8c544e0647d7507
Reviewed-on: https://boringssl-review.googlesource.com/27925
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-05-04 17:08:44 +00:00
Matthew Braithwaite cf341d028f Add missing #include of <openssl/mem.h>.
Change-Id: I0674f4e9b15b546237600fb2486c46aac7cb0716
Reviewed-on: https://boringssl-review.googlesource.com/28027
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-04 16:51:04 +00:00
David Benjamin f6d9f0b58e bn/asm/*-mont.pl: fix memory access pattern in final subtraction.
Montgomery multiplication post-conditions in some of code paths were
formally non-constant time. Cache access pattern was result-neutral,
but a little bit asymmetric, which might have produced a signal [if
processor reordered load and stores at run-time].

(Imported from upstream's 774ff8fed67e19d4f5f0df2f59050f2737abab2a.)

Change-Id: I77443fb79242b77e704c34d69f1de9e3162e9538
Reviewed-on: https://boringssl-review.googlesource.com/27987
Reviewed-by: Adam Langley <agl@google.com>
2018-05-03 23:21:22 +00:00
Adam Langley 3e87165d3c Avoid compiler errors for Android ARMv7.
(It complains that the comparison is always false with NDK r17 beta 2.)

Change-Id: I6b695fd0e86047f0c1e4267290e63db3184a958a
Reviewed-on: https://boringssl-review.googlesource.com/28025
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-03 19:11:34 +00:00
Steven Valdez dd444b1d8e Fix bugs in X509_NAME_add_entry.
|set| should be evaluated to determine whether to insert/append before
it is reused as a temporary variable.

When incrementing the |set| of X509_NAME_ENTRY, the inserted entry
should not be incremented.

Thanks to Ingo Schwarze for extensive debugging and the initial
fix.

(Imported from upstream bbf27cd58337116c57a1c942153330ff83d5540a)

Change-Id: Ib45d92fc6d52d7490b01d3c475eafc42dd6ef721
Reviewed-on: https://boringssl-review.googlesource.com/28005
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-05-03 17:40:43 +00:00
Adam Langley 0c9ac2e7bf Drop FULL_UNROLL code in aes.c.
We've never defined this so this code has always been dead.

Change-Id: Ibcc4095bf812c7e1866c5f39968789606f0995ae
Reviewed-on: https://boringssl-review.googlesource.com/28024
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-03 16:10:14 +00:00
David Benjamin 0ca921431a Temporarily restore SHA256 and SHA384 cipher suite aliases.
https://boringssl-review.googlesource.com/27944 inadvertently caused
SHA256 and SHA384 aliases to be rejected in
SSL_CTX_set_strict_cipher_list. While this is the desired end state, in
case the removal needs to be reverted, we should probably defer this to
post-removal cleanup.

Otherwise we might update someone's "ALL:!SHA256" cipher string to
account for the removal, and then revert the removal underneath them.

Change-Id: Id516a27a2ecefb5871485d0ae18067b5bbb536bb
Reviewed-on: https://boringssl-review.googlesource.com/28004
Reviewed-by: Adam Langley <agl@google.com>
2018-05-03 15:48:50 +00:00
David Benjamin b95d4b4cb3 Move srtp_profiles to SSL_CONFIG.
These are also not needed after the handshake.

Change-Id: I5de2d5cf18a3783a6c04c0a8fe311069fb51b939
Reviewed-on: https://boringssl-review.googlesource.com/27986
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-03 15:20:13 +00:00
David Benjamin 98472cb30d Consistently use session_ctx for session caching.
The TLS 1.3 client logic used ctx instead. This is all moot as
SSL_set_SSL_CTX on a client really wouldn't work, but we should be
consistent. Unfortunately, this moves moving the pointer back to SSL
from SSL_CONFIG.

Change-Id: I45f8241e16f499ad416afd5eceb52dc82af9c4f4
Reviewed-on: https://boringssl-review.googlesource.com/27985
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-02 20:15:08 +00:00
David Benjamin 8e75ae4880 Add a Wycheproof driver for AES-CBC.
Change-Id: I782ea51e1db8d05f552832a7c6910954fa2dda5f
Reviewed-on: https://boringssl-review.googlesource.com/27924
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-05-02 19:41:48 +00:00
David Benjamin 302bb3964a Small curve25519 cleanups.
Per Brian, x25519_ge_frombytes_vartime does not match the usual
BoringSSL return value convention, and we're slightly inconsistent about
whether to mask the last byte with 63 or 127. (It then gets ANDed with
64, so it doesn't matter which.) Use 127 to align with the curve25519
RFC. Finally, when we invert the transformation, use the same constants
inverted so that they're parallel.

Bug: 243, 244
Change-Id: I0e3aca0433ead210446c58d86b2f57526bde1eac
Reviewed-on: https://boringssl-review.googlesource.com/27984
Reviewed-by: Adam Langley <agl@google.com>
2018-05-02 19:24:00 +00:00
David Benjamin 6e678eeb6e Remove legacy SHA-2 CBC ciphers.
All CBC ciphers in TLS are broken and insecure. TLS 1.2 introduced
AEAD-based ciphers which avoid their many problems. It also introduced
new CBC ciphers based on HMAC-SHA256 and HMAC-SHA384 that share the same
flaws as the original HMAC-SHA1 ones. These serve no purpose. Old
clients don't support them, they have the highest overhead of all TLS
ciphers, and new clients can use AEADs anyway.

Remove them from libssl. This is the smaller, more easily reverted
portion of the removal. If it survives a week or so, we can unwind a lot
more code elsewhere in libcrypto. This removal will allow us to clear
some indirect calls from crypto/cipher_extra/tls_cbc.c, aligning with
the recommendations here:

https://github.com/HACS-workshop/spectre-mitigations/blob/master/crypto_guidelines.md#2-avoid-indirect-branches-in-constant-time-code

Update-Note: The following cipher suites are removed:
- TLS_RSA_WITH_AES_128_CBC_SHA256
- TLS_RSA_WITH_AES_256_CBC_SHA256
- TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
- TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
- TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
- TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384

Change-Id: I7ade0fc1fa2464626560d156659893899aab6f77
Reviewed-on: https://boringssl-review.googlesource.com/27944
Reviewed-by: Adam Langley <agl@google.com>
2018-05-02 19:21:56 +00:00
David Benjamin 71666cb87c Allow renego and config shedding to coexist more smoothly.
Chrome needs to support renegotiation at TLS 1.2 + HTTP/1.1, but we're
free to shed the handshake configuration at TLS 1.3 or HTTP/2.

Rather than making config shedding implicitly disable renegotiation,
make the actual shedding dependent on a combination of the two settings.
If config shedding is enabled, but so is renegotiation (including
whether we are a client, etc.), leave the config around. If the
renegotiation setting gets disabled again after the handshake,
re-evaluate and shed the config then.

Bug: 123
Change-Id: Ie833f413b3f15b8f0ede617991e3fef239d4a323
Reviewed-on: https://boringssl-review.googlesource.com/27904
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Matt Braithwaite <mab@google.com>
2018-05-01 23:28:59 +00:00
Matthew Braithwaite b7bc80a9a6 SSL_CONFIG: new struct for sheddable handshake configuration.
|SSL_CONFIG| is a container for bits of configuration that are
unneeded after the handshake completes.  By default it is retained for
the life of the |SSL|, but it may be shed at the caller's option by
calling SSL_set_shed_handshake_config().  This is incompatible with
renegotiation, and with SSL_clear().

|SSL_CONFIG| is reachable by |ssl->config| and by |hs->config|.  The
latter is always non-NULL.  To avoid null checks, I've changed the
signature of a number of functions from |SSL*| arguments to
|SSL_HANDSHAKE*| arguments.

When configuration has been shed, setters that touch |SSL_CONFIG|
return an error value if that is possible.  Setters that return |void|
do nothing.

Getters that request |SSL_CONFIG| values will fail with an |assert| if
the configuration has been shed.  When asserts are compiled out, they
will return an error value.

The aim of this commit is to simplify analysis of split-handshakes by
making it obvious that some bits of state have no effects beyond the
handshake.  It also cuts down on memory usage.

Of note: |SSL_CTX| is still reachable after the configuration has been
shed, and a couple things need to be retained only for the sake of
post-handshake hooks.  Perhaps these can be fixed in time.

Change-Id: Idf09642e0518945b81a1e9fcd7331cc9cf7cc2d6
Bug: 123
Reviewed-on: https://boringssl-review.googlesource.com/27644
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-05-01 20:40:16 +00:00
Matthew Braithwaite a2dd781884 Defer writing the shim settings.
This is prefactoring for a coming change to the shim that will write
handoff and handback messages (which are serialized SSLConnection
objects) to the transcript.

This breaks the slightly tenuous ordering between the runner and the
shim. Fix the runner to wait until the shim has exited before
appending the transcript.

Change-Id: Iae34d28ec1addfe3ec4f3c77008248fe5530687c
Reviewed-on: https://boringssl-review.googlesource.com/27184
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-01 19:49:46 +00:00
David Benjamin 3f944674b2 Add an ECDH Wycheproof driver.
Unfortunately, this driver suffers a lot from Wycheproof's Java
heritgate, but so it goes. Their test formats bake in a lot of Java API
mistakes.

Change-Id: I3299e85efb58e99e4fa34841709c3bea6518968d
Reviewed-on: https://boringssl-review.googlesource.com/27865
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-01 19:38:07 +00:00
David Benjamin 7760af4bce Print tcId in converted Wycheproof files.
This is to make it easier to correlate the two.

Change-Id: I62aa381499d67ae279bbe86eebeb9a5bc9ef5266
Reviewed-on: https://boringssl-review.googlesource.com/27864
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-01 19:09:16 +00:00
David Benjamin 5505328633 Add AEAD Wycheproof drivers.
Change-Id: I840863c445fd9dac3fd60ac4b1c572ea7d924c9c
Reviewed-on: https://boringssl-review.googlesource.com/27826
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-01 18:36:00 +00:00
Matthew Braithwaite 58d6fc48cc Add missing #include of <openssl/err.h>.
Change-Id: Ib2ce220e31a4f808999934197a7f43b8723131e8
Reviewed-on: https://boringssl-review.googlesource.com/27884
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-05-01 01:00:44 +00:00
David Benjamin c596415ec6 Add a DSA Wycheproof driver.
DSA is deprecated and will ultimately be removed but, in the
meantime, it still ought to be tested.

Change-Id: I75af25430b8937a43b11dced1543a98f7a6fbbd3
Reviewed-on: https://boringssl-review.googlesource.com/27825
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-04-30 16:04:31 +00:00
David Benjamin 5707274214 Add Ed25519 Wycheproof driver.
This works with basically no modifications.

Change-Id: I92f4d90f3c0ec8170d532cf7872754fadb36644d
Reviewed-on: https://boringssl-review.googlesource.com/27824
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-04-30 15:29:01 +00:00
David Benjamin 6ae7ddb755 Add some notes on how to handle breaking changes.
Change-Id: I55428636dbed0543dd772d74fe256f5d092e55fe
Reviewed-on: https://boringssl-review.googlesource.com/27704
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-04-28 00:04:41 +00:00
David Benjamin 8370fb6b41 Implement constant-time generic multiplication.
This is slower, but constant-time. It intentionally omits the signed
digit optimization because we cannot be sure the doubling case will be
unreachable for all curves. This is a fallback generic implementation
for curves which we must support for compatibility but which are not
common or important enough to justify curve-specific work.

Before:
Did 814 ECDH P-384 operations in 1085384us (750.0 ops/sec)
Did 1430 ECDSA P-384 signing operations in 1081988us (1321.6 ops/sec)
Did 308 ECDH P-521 operations in 1057741us (291.2 ops/sec)
Did 539 ECDSA P-521 signing operations in 1049797us (513.4 ops/sec)

After:
Did 715 ECDH P-384 operations in 1080161us (661.9 ops/sec)
Did 1188 ECDSA P-384 verify operations in 1069567us (1110.7 ops/sec)
Did 275 ECDH P-521 operations in 1060503us (259.3 ops/sec)
Did 506 ECDSA P-521 signing operations in 1084739us (466.5 ops/sec)

But we're still faster than the old BIGNUM implementation. EC_FELEM
more than paid for both the loss of points_make_affine and this CL.

Bug: 239
Change-Id: I65d71a731aad16b523928ee47618822d503ea704
Reviewed-on: https://boringssl-review.googlesource.com/27708
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-04-27 20:11:29 +00:00
David Benjamin 8b0dc7a720 Simplify ec_wNAF_mul table sizing.
w=4 appears to be the correct answer for P-224 through P-521. There's
nominally some optimizations in here for 70- and 20-bit primes, but
that's absurd.

Change-Id: Id4ccec779b17e375e9258c1784e46d7d3651c59a
Reviewed-on: https://boringssl-review.googlesource.com/27707
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-04-27 19:49:08 +00:00
David Benjamin 041dd68cec Clear mallocs in ec_wNAF_mul.
EC_POINT is split into the existing public EC_POINT (where the caller is
sanity-checked about group mismatches) and the low-level EC_RAW_POINT
(which, like EC_FELEM and EC_SCALAR, assume that is your problem and is
a plain old struct). Having both EC_POINT and EC_RAW_POINT is a little
silly, but we're going to want different type signatures for functions
which return void anyway (my plan is to lift a non-BIGNUM
get_affine_coordinates up through the ECDSA and ECDH code), so I think
it's fine.

This wasn't strictly necessary, but wnaf.c is a lot tidier now. Perf is
a wash; once we get up to this layer, it's only 8 entries in the table
so not particularly interesting.

Bug: 239
Change-Id: I8ace749393d359f42649a5bb0734597bb7c07a2e
Reviewed-on: https://boringssl-review.googlesource.com/27706
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-04-27 19:44:58 +00:00
David Benjamin e14e4a7ee3 Remove ec_compute_wNAF's failure cases.
Replace them with asserts and better justify why each of the internal
cases are not reachable. Also change the loop to count up to bits+1 so
it is obvious there is no memory error. (The previous loop shape made
more sense when ec_compute_wNAF would return a variable length
schedule.)

Change-Id: I9c7df6abac4290b7a3e545e3d4aa1462108e239e
Reviewed-on: https://boringssl-review.googlesource.com/27705
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-04-27 19:24:58 +00:00
David Benjamin 40d76f4f7d Add ECDSA and RSA verify Wycheproof drivers.
Along the way, add some utility functions for getting common things
(curves, hashes, etc.) in the names Wycheproof uses.

Change-Id: I09c11ea2970cf2c8a11a8c2a861d85396efda125
Reviewed-on: https://boringssl-review.googlesource.com/27786
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-04-27 18:58:38 +00:00
David Benjamin 5509bc06d8 Add a test driver for Wycheproof's x25519_test.json.
FileTest and Wycheproof express more-or-less the same things, so I've
just written a script to mechanically convert them. Saves writing a JSON
parser.

I've also left a TODO with other files that are worth converting. Per
Thai, the webcrypto variants of the files are just a different format
and will later be consolidated, so I've ignored those. The
curve/hash-specific ECDSA files and the combined one are intended to be
the same, so I've ignored the combined one. (Just by test counts, there
are some discrepancies, but Thai says he'll fix that and we can update
when that happens.)

Change-Id: I5fcbd5cb0e1bea32964b09fb469cb43410f53c2d
Reviewed-on: https://boringssl-review.googlesource.com/27785
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-04-27 18:55:38 +00:00
David Benjamin 855dabc9df Add an accessor for session->certs.
Chromium has some code which reaches into this field for memory
accounting.

This fixes a bug in doc.go where this line-wrapping confuses it. doc.go
needs a bit of a rewrite, but this is a bit better.

Change-Id: Ic9cc2c2fe9329d7bc366ccf91e0c9a92eae08ed2
Reviewed-on: https://boringssl-review.googlesource.com/27764
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-04-27 17:14:38 +00:00
David Benjamin bf4bcdf16e Fix some stuttering.
Pointed out by Brian in
https://boringssl-review.googlesource.com/c/boringssl/+/15325/11/crypto/internal.h#203.

Change-Id: Ic8d8672202f862e984e4503467d725ba030d5440
Reviewed-on: https://boringssl-review.googlesource.com/27804
Reviewed-by: Adam Langley <agl@google.com>
2018-04-27 15:56:57 +00:00
David Benjamin 2d10c3688c Check in a copy of Project Wycheproof test vectors.
This is just a pristine copy of the JSON files for now. It's not hooked
up to anything yet.

Change-Id: I608b4b0368578f159cad23950d70578ff4c23da3
Reviewed-on: https://boringssl-review.googlesource.com/27784
Reviewed-by: Adam Langley <agl@google.com>
2018-04-26 23:07:29 +00:00
Joshua Liebow-Feeser b8546dd8a9 Update location of root certificates on Fuchsia
Change-Id: I156552df15de5941be99736cca694db4677e2b2a
Reviewed-on: https://boringssl-review.googlesource.com/27744
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-04-25 21:32:20 +00:00
Adam Langley cece32610b Add SHA256_TransformBlocks.
Rather than expose a (potentially) assembly function directly, wrap it
in a C function to make visibility control easier.

Change-Id: I4a2dfeb8999ff021b2e10fbc54850eeadabbefff
Reviewed-on: https://boringssl-review.googlesource.com/27724
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-04-25 17:51:50 +00:00
David Benjamin ec4f0ddafc EC_GROUP_dup cannot fail.
We've since ref-counted it.

Change-Id: I5589e79f5bbba35b02ae659c7aa6ac76ba0082a3
Reviewed-on: https://boringssl-review.googlesource.com/27669
Reviewed-by: Adam Langley <agl@google.com>
2018-04-25 16:43:19 +00:00
David Benjamin 32e0d10069 Add EC_FELEM for EC_POINTs and related temporaries.
This introduces EC_FELEM, which is analogous to EC_SCALAR. It is used
for EC_POINT's representation in the generic EC_METHOD, as well as
random operations on tuned EC_METHODs that still are implemented
genericly.

Unlike EC_SCALAR, EC_FELEM's exact representation is awkwardly specific
to the EC_METHOD, analogous to how the old values were BIGNUMs but may
or may not have been in Montgomery form. This is kind of a nuisance, but
no more than before. (If p224-64.c were easily convertable to Montgomery
form, we could say |EC_FELEM| is always in Montgomery form. If we
exposed the internal add and double implementations in each of the
curves, we could give |EC_POINT| an |EC_METHOD|-specific representation
and |EC_FELEM| is purely a |EC_GFp_mont_method| type. I'll leave this
for later.)

The generic add and doubling formulas are aligned with the formulas
proved in fiat-crypto. Those only applied to a = -3, so I've proved a
generic one in https://github.com/mit-plv/fiat-crypto/pull/356, in case
someone uses a custom curve.  The new formulas are verified,
constant-time, and swap a multiply for a square. As expressed in
fiat-crypto they do use more temporaries, but this seems to be fine with
stack-allocated EC_FELEMs. (We can try to help the compiler later,
but benchamrks below suggest this isn't necessary.)

Unlike BIGNUM, EC_FELEM can be stack-allocated. It also captures the
bounds in the type system and, in particular, that the width is correct,
which will make it easier to select a point in constant-time in the
future. (Indeed the old code did not always have the correct width. Its
point formula involved halving and implemented this in variable time and
variable width.)

Before:
Did 77274 ECDH P-256 operations in 10046087us (7692.0 ops/sec)
Did 5959 ECDH P-384 operations in 10031701us (594.0 ops/sec)
Did 10815 ECDSA P-384 signing operations in 10087892us (1072.1 ops/sec)
Did 8976 ECDSA P-384 verify operations in 10071038us (891.3 ops/sec)
Did 2600 ECDH P-521 operations in 10091688us (257.6 ops/sec)
Did 4590 ECDSA P-521 signing operations in 10055195us (456.5 ops/sec)
Did 3811 ECDSA P-521 verify operations in 10003574us (381.0 ops/sec)

After:
Did 77736 ECDH P-256 operations in 10029858us (7750.5 ops/sec) [+0.8%]
Did 7519 ECDH P-384 operations in 10068076us (746.8 ops/sec) [+25.7%]
Did 13335 ECDSA P-384 signing operations in 10029962us (1329.5 ops/sec) [+24.0%]
Did 11021 ECDSA P-384 verify operations in 10088600us (1092.4 ops/sec) [+22.6%]
Did 2912 ECDH P-521 operations in 10001325us (291.2 ops/sec) [+13.0%]
Did 5150 ECDSA P-521 signing operations in 10027462us (513.6 ops/sec) [+12.5%]
Did 4264 ECDSA P-521 verify operations in 10069694us (423.4 ops/sec) [+11.1%]

This more than pays for removing points_make_affine previously and even
speeds up ECDH P-256 slightly. (The point-on-curve check uses the
generic code.)

Next is to push the stack-allocating up to ec_wNAF_mul, followed by a
constant-time single-point multiplication.

Bug: 239
Change-Id: I44a2dff7c52522e491d0f8cffff64c4ab5cd353c
Reviewed-on: https://boringssl-review.googlesource.com/27668
Reviewed-by: Adam Langley <agl@google.com>
2018-04-25 16:39:58 +00:00
David Benjamin 6a289b3ec4 Remove EC_POINTs_make_affine and related logic.
This does not appear to actually pull its weight. The purpose of this
logic is to switch some adds to the faster add_mixed in the wNAF code,
at the cost of a rather expensive inversion. This optimization kicks in
for generic curves, so P-384 and P-521:

With:
Did 32130 ECDSA P-384 signing operations in 30077563us (1068.2 ops/sec)
Did 27456 ECDSA P-384 verify operations in 30073086us (913.0 ops/sec)
Did 14122 ECDSA P-521 signing operations in 30077407us (469.5 ops/sec)
Did 11973 ECDSA P-521 verify operations in 30037330us (398.6 ops/sec)

Without:
Did 32445 ECDSA P-384 signing operations in 30069721us (1079.0 ops/sec)
Did 27056 ECDSA P-384 verify operations in 30032303us (900.9 ops/sec)
Did 13905 ECDSA P-521 signing operations in 30000430us (463.5 ops/sec)
Did 11433 ECDSA P-521 verify operations in 30021876us (380.8 ops/sec)

For single-point multiplication, the optimization is not useful. This
makes sense as we only have one table's worth of additions to convert
but still pay for the inversion. For double-point multiplication, it is
slightly useful for P-384 and very useful for P-521. However, the next
change to stack-allocate EC_FELEMs will more than compensate for
removing it.  (The immediate goal here is to simplify the EC_FELEM
story.)

Additionally, that this optimization was not useful for single-point
multiplication implies that, should we wish to recover this, a modest
8-entry pre-computed (affine) base point table should have the same
effect or better.

Update-Note: I do not believe anything was calling either of these
functions. (If necessary, we can always add no-op stubs as whether a
point is affine is not visible to external code. It previously kicked in
some optimizations, but those were removed for constant-time needs
anyway.)

Bug: 239
Change-Id: Ic9c51b001c45595cfe592274c7d5d652f4234839
Reviewed-on: https://boringssl-review.googlesource.com/27667
Reviewed-by: Adam Langley <agl@google.com>
2018-04-25 16:12:06 +00:00
David Benjamin 06c28d8e51 Simplify shim timeout logic.
I don't think this lock is actually needed. If the process exited by the
time we call shim.Process.Kill(), then the test ultimately finished. If
not, wait() will return that the process died by a signal.

Change-Id: I668a86583aba16fd00e0cd05071acc13059a2c42
Reviewed-on: https://boringssl-review.googlesource.com/27325
Reviewed-by: Adam Langley <agl@google.com>
2018-04-25 16:07:28 +00:00
David Benjamin 48b276db3d Give ssl_cipher_preference_list_st a destructor.
Change-Id: I578a284c6a8cae773a97d3d30ad8a5cd13f56164
Reviewed-on: https://boringssl-review.googlesource.com/27491
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2018-04-24 19:55:29 +00:00
David Benjamin 06d467c58a ghashv8-armx.pl: add Qualcomm Kryo results.
(Imported from upstream's 753316232243ccbf86b96c1c51ffcb41651d9ad5.)

Just to sync up a bit further.

Change-Id: I805150d0f0c10d68648fae83603b0d46231ae4ec
Reviewed-on: https://boringssl-review.googlesource.com/27685
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-04-24 19:48:59 +00:00
David Benjamin a7c8f2b7b0 ghashv8-armvx.pl: Fix various typos.
(Imported from upstream's 46f4e1bec51dc96fa275c168752aa34359d9ee51.)

Change-Id: Ie9c1e9cfc38a3962e3674a68bc0174d064272fc2
Reviewed-on: https://boringssl-review.googlesource.com/27684
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-04-24 19:48:49 +00:00
David Benjamin a63d0ad40d Require BN_mod_exp_mont* inputs be reduced.
If the caller asked for the base to be treated as secret, we should
provide that. Allowing unbounded inputs is not compatible with being
constant-time.

Additionally, this aligns with the guidance here:
https://github.com/HACS-workshop/spectre-mitigations/blob/master/crypto_guidelines.md#1-do-not-conditionally-choose-between-constant-and-non-constant-time

Update-Note: BN_mod_exp_mont_consttime and BN_mod_exp_mont now require
inputs be fully reduced. I believe current callers tolerate this.

Additionally, due to a quirk of how certain operations were ordered,
using (publicly) zero exponent tolerated a NULL BN_CTX while other
exponents required non-NULL BN_CTX. Non-NULL BN_CTX is now required
uniformly. This is unlikely to cause problems. Any call site where the
exponent is always zero should just be replaced with BN_value_one().

Change-Id: I7c941953ea05f36dc2754facb9f4cf83a6789c61
Reviewed-on: https://boringssl-review.googlesource.com/27665
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2018-04-24 18:29:29 +00:00
David Benjamin 52a68a9b43 Remove unused string.h include.
This is unused now that we use the silly memcpy, etc., wrappers to work
around the C NULL/0 language bug.

See https://android-review.googlesource.com/c/platform/external/boringssl/+/670794

Change-Id: I15c878cee6badb4551c8d5cfa1371a9bff4000fb
Reviewed-on: https://boringssl-review.googlesource.com/27666
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-04-24 17:42:39 +00:00
David Benjamin 5c0e0cec83 Remove Z = 1 special-case in generic point_get_affine.
As the point may be the output of some private key operation, whether Z
accidentally hit one is secret.

Bug: 239
Change-Id: I7db34cd3b5dd5ca4b96980e8993a9b4eda49eb88
Reviewed-on: https://boringssl-review.googlesource.com/27664
Reviewed-by: Adam Langley <alangley@gmail.com>
2018-04-24 16:16:53 +00:00
David Benjamin f5858ca008 Remove unnecessary endian flip in p224-64.c.
We have little-endian BIGNUM functions now.

Change-Id: Iffc46a14e75c6bba2e170b824b1a08c69d2e9d18
Reviewed-on: https://boringssl-review.googlesource.com/27594
Reviewed-by: Adam Langley <alangley@gmail.com>
2018-04-24 16:15:28 +00:00
David Benjamin b8f14b7d53 Add dedicated scalar inversion code to p256-x86_64.c.
This is adapted from upstream's
eb7916960bf50f436593abe3d5f2e0592d291017.

This gives a 22% win for ECDSA signing. (Upstream cites 30-40%, but they
are unnecessarily using BN_mod_exp_mont_consttime in their generic path.
The exponent is public. I expect part of their 30-40% is just offsetting
this.)

Did 506000 ECDSA P-256 signing operations in 25044595us (20204.0 ops/sec)
Did 170506 ECDSA P-256 verify operations in 25033567us (6811.1 ops/sec)

Did 618000 ECDSA P-256 signing operations in 25031294us (24689.1 ops/sec)
Did 182240 ECDSA P-256 verify operations in 25006918us (7287.6 ops/sec)

Most of the performance win appears to be from the assembly operations
and not the addition chain. I have a CL to graft the addition chain onto
the C implementation, but it did not show measurable improvement in
ECDSA verify. ECDSA sign gets 2-4% faster, but we're more concerned
about ECDSA verify in the OPENSSL_SMALL builds.

Change-Id: Ide166f98b146c025f7f80ed7906336c16818540a
Reviewed-on: https://boringssl-review.googlesource.com/27593
Reviewed-by: Adam Langley <alangley@gmail.com>
2018-04-24 16:14:57 +00:00
David Benjamin 364a51ec3a Abstract scalar inversion in EC_METHOD.
This introduces a hook for the OpenSSL assembly.

Change-Id: I35e0588f0ed5bed375b12f738d16c9f46ceedeea
Reviewed-on: https://boringssl-review.googlesource.com/27592
Reviewed-by: Adam Langley <alangley@gmail.com>
2018-04-24 16:13:24 +00:00
David Benjamin b27b579fdd Add some tests for scalar operations.
Largely random data, but make it easy to add things in the future.

Change-Id: I30bee790bd9671b4d0327c2244fe5cd1a8954f90
Reviewed-on: https://boringssl-review.googlesource.com/27591
Reviewed-by: Adam Langley <alangley@gmail.com>
2018-04-24 16:12:34 +00:00
David Benjamin 3861ae662a p256-x86_64-asm.pl: add .cfi and SEH handlers to new functions.
Imported from upstream's d5e11843fe430dfa89bdf83b6f7805c709dcdb41.

Change-Id: Ie6d64ef821b66531995b43d015ab2755558eaa57
Reviewed-on: https://boringssl-review.googlesource.com/27590
Reviewed-by: Adam Langley <alangley@gmail.com>
2018-04-24 16:10:08 +00:00
David Benjamin 5c30dab835 Import P-256 scalar multiplication assembly from OpenSSL.
This imports the assembly portion of
eb7916960bf50f436593abe3d5f2e0592d291017 from upstream. Note the
OPENSSL_ia32cap_P bits were tweaked to be delocate-compatible. Those
should be reviewed against the original file.

Change-Id: I19eef722225bb7928275e3d93890f80aa2f8734d
Reviewed-on: https://boringssl-review.googlesource.com/27589
Reviewed-by: Adam Langley <alangley@gmail.com>
2018-04-24 16:09:08 +00:00
David Benjamin 7121fe24e9 Align ECDSA sign/verify scalar inversions.
We were still using the allocating scalar inversion for ECDSA verify
because previously it seemed to be faster. It appears to have flipped
now, though probably was always just a wash.

While I'm here, save a multiplication by swapping the inversion and
Montgomery reduction.

Did 200000 ECDSA P-256 signing operations in 10025749us (19948.6 ops/sec)
Did 66234 ECDSA P-256 verify operations in 10061123us (6583.2 ops/sec)

Did 202000 ECDSA P-256 signing operations in 10020846us (20158.0 ops/sec)
Did 68052 ECDSA P-256 verify operations in 10020592us (6791.2 ops/sec)

The actual motivation is to get rid of the unchecked EC_SCALAR function
and align sign/verify in preparation for the assembly scalar ops.

Change-Id: I1bd3a5719a67966dc8edaa43535a3864b69f76d0
Reviewed-on: https://boringssl-review.googlesource.com/27588
Reviewed-by: Adam Langley <alangley@gmail.com>
2018-04-24 16:00:12 +00:00
David Benjamin 941f535438 Abstract away EC_SCALAR operations.
Just a little bit cleaner.

Change-Id: I0ed192a531b5aa853ba082caa6088e838f12c863
Reviewed-on: https://boringssl-review.googlesource.com/27587
Reviewed-by: Adam Langley <alangley@gmail.com>
2018-04-24 15:37:40 +00:00
David Benjamin 9291be5b27 Remove return values from bn_*_small.
No sense in adding impossible error cases we need to handle.
Additionally, tighten them a bit and require strong bounds. (I wasn't
sure what we'd need at first and made them unnecessarily general.)

Change-Id: I21a0afde90a55be2e9a0b8d7288f595252844f5f
Reviewed-on: https://boringssl-review.googlesource.com/27586
Reviewed-by: Adam Langley <alangley@gmail.com>
2018-04-24 15:34:32 +00:00
David Benjamin 3f8074c2de Fix the error on overly large group orders.
Change-Id: I9b11fabb79b5dfe031ac5ea2f021b28b87262761
Reviewed-on: https://boringssl-review.googlesource.com/27585
Reviewed-by: Adam Langley <alangley@gmail.com>
2018-04-24 15:27:17 +00:00
David Benjamin cd01254900 Explicitly guarantee BN_MONT_CTX::{RR,N} have the same width.
This is so the *_small functions can assume somewhat more uniform
widths, to simplify their error-handling.

Change-Id: I0420cb237084b253e918c64b0c170a5dfd99ab40
Reviewed-on: https://boringssl-review.googlesource.com/27584
Reviewed-by: Adam Langley <alangley@gmail.com>
2018-04-24 15:22:09 +00:00
Adam Langley e3aba378c9 Fix typo in ssl_cert_cache_chain_certs.
After e325c3f471, this typo bites and
causes SSL_CTX_get_extra_chain_certs to return an empty stack.

Change-Id: I6aa7093d1ca4f3ba0f520a644b14de5b3a3ccaa6
Reviewed-on: https://boringssl-review.googlesource.com/27604
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-04-23 19:21:01 +00:00
David Benjamin a2938719a4 Improve the RSA key generation failure probability.
The FIPS 186-4 algorithm we use includes a limit which hits a 2^-20
failure probability, assuming my math is right. We've observed roughly
2^-23. This is a little large at scale. (See b/77854769.)

To avoid modifying the FIPS algorithm, retry the whole thing four times
to bring the failure rate down to 2^-80. Along the way, now that I have
the derivation on hand, adjust
https://boringssl-review.googlesource.com/22584 to target the same
failure probability.

Along the way, fix an issue with RSA_generate_key where, if callers
don't check for failure, there may be half a key in there.

Change-Id: I0e1da98413ebd4ffa65fb74c67a58a0e0cd570ff
Reviewed-on: https://boringssl-review.googlesource.com/27288
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-04-20 21:34:05 +00:00
David Benjamin 9af9b946d2 Restore the BN_mod codepath for public Montgomery moduli.
https://boringssl-review.googlesource.com/10520 and then later
https://boringssl-review.googlesource.com/25285 made BN_MONT_CTX_set
constant-time, which is necessary for RSA's mont_p and mont_q. However,
due to a typo in the benchmark, they did not correctly measure.

Split BN_MONT_CTX creation into a constant-time and variable-time one.
The constant-time one uses our current algorithm and the latter restores
the original BN_mod codepath.

Should we wish to avoid BN_mod, I have an alternate version lying
around:

First, BN_set_bit + bn_mod_lshift1_consttime as now to count up to 2*R.
Next, observe that 2*R = BN_to_montgomery(2) and R*R =
BN_to_montgomery(R) = BN_to_montgomery(2^r_bits) Also observe that
BN_mod_mul_montgomery only needs n0, not RR. Split the core of
BN_mod_exp_mont into its own function so the caller handles conversion.
Raise 2*R to the r_bits power to get 2^r_bits*R = R*R.

The advantage of that algorithm is that it is still constant-time, so we
only need one BN_MONT_CTX_new. Additionally, it avoids BN_mod which is
otherwise (almost, but the remaining links should be easy to cut) out of
the critical path for correctness. One less operation to worry about.

The disadvantage is that it is gives a 25% (RSA-2048) or 32% (RSA-4096)
slower RSA verification speed. I went with the BN_mod one for the time
being.

Before:
Did 9204 RSA 2048 signing operations in 10052053us (915.6 ops/sec)
Did 326000 RSA 2048 verify (same key) operations in 10028823us (32506.3 ops/sec)
Did 50830 RSA 2048 verify (fresh key) operations in 10033794us (5065.9 ops/sec)
Did 1269 RSA 4096 signing operations in 10019204us (126.7 ops/sec)
Did 88435 RSA 4096 verify (same key) operations in 10031129us (8816.1 ops/sec)
Did 14552 RSA 4096 verify (fresh key) operations in 10053411us (1447.5 ops/sec)

After:
Did 9150 RSA 2048 signing operations in 10022831us (912.9 ops/sec)
Did 322000 RSA 2048 verify (same key) operations in 10028604us (32108.2 ops/sec)
Did 289000 RSA 2048 verify (fresh key) operations in 10017205us (28850.4 ops/sec)
Did 1270 RSA 4096 signing operations in 10072950us (126.1 ops/sec)
Did 87480 RSA 4096 verify (same key) operations in 10036328us (8716.3 ops/sec)
Did 80730 RSA 4096 verify (fresh key) operations in 10073614us (8014.0 ops/sec)

Change-Id: Ie8916d1634ccf8513ceda458fa302f09f3e93c07
Reviewed-on: https://boringssl-review.googlesource.com/27287
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-04-20 20:50:15 +00:00
David Benjamin 7e2a8a34ba Speed up variable windowed exponentation a bit.
The first non-zero window (which we can condition on for public
exponents) always multiplies by one. This means we can cut out one
Montgomery multiplication. It also means we never actually need to
initialize r to one, saving another Montgomery multiplication for P-521.

This, in turn, means we don't need the bn_one_to_montgomery optimization
for the public-exponent exponentations, so we can delete
bn_one_to_montgomery_small. (The function does currently promise to
handle p = 0, but this is not actually reachable, so it can just do a
reduction on RR.)

For RSA, where we're not doing many multiplications to begin with,
saving one is noticeable.

Before:
Did 92000 RSA 2048 verify (same key) operations in 3002557us (30640.6 ops/sec)
Did 25165 RSA 4096 verify (same key) operations in 3045046us (8264.2 ops/sec)

After:
Did 100000 RSA 2048 verify (same key) operations in 3002483us (33305.8 ops/sec)
Did 26603 RSA 4096 verify (same key) operations in 3010942us (8835.4 ops/sec)

(Not looking at the fresh key number yet as that still needs to be
fixed.)

Change-Id: I81a025a68d9b0f8eb0f9c6c04ec4eedf0995a345
Reviewed-on: https://boringssl-review.googlesource.com/27286
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-04-20 20:37:45 +00:00
Jesse Selover b1e6a85443 Change OPENSSL_cpuid_setup to reserve more extended feature space.
Copy of openssl change https://git.openssl.org/gitweb/?p=openssl.git;h=d6ee8f3dc4414cd97bd63b801f8644f0ff8a1f17

OPENSSL_ia32cap: reserve for new extensions.
Change-Id: I96b43c82ba6568bae848449972d3ad9d20f6d063
Reviewed-on: https://boringssl-review.googlesource.com/27564
Reviewed-by: David Benjamin <davidben@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-04-19 20:48:58 +00:00
Jesse Selover 35e7c994be Remove files from Trusty which can't link because of Trusty libc.
Change-Id: If3d93648cf6561c02c208895526ae1f1cbfa2b51
Reviewed-on: https://boringssl-review.googlesource.com/27524
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-04-19 19:06:58 +00:00
Adam Langley 6f6a237d46 delocate: put emitted labels in a specific file.
Otherwise Clang has to assign a file entry to the label which conflicts with
later, explicit, file entries.

Change-Id: Ifc782821517aa7b48ba3ef304d4468f2bc850ac2
Reviewed-on: https://boringssl-review.googlesource.com/27544
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-04-19 17:54:31 +00:00
David Benjamin 56b1a8efa6 Test the high-order bit in X25519.
This schism came up in passing again, and I realized we never added a
TLS-level test for this. Fix that.

Change-Id: I10f910bb5a975d6b3b73d99e7412ade35654fddb
Reviewed-on: https://boringssl-review.googlesource.com/27224
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-04-19 00:56:35 +00:00
David Benjamin 56ea9e2769 Fix bn_mod_exp_mont_small when exponentiating to zero.
It's defined to return one in Montgomery form, not a normal one.

(Not that this matters. This function is only used to Fermat's Little
Theorem. Probably it should have been less general, though we'd need to
make new test vectors first.)

Change-Id: Ia8d7588e6a413b25f01280af9aacef0192283771
Reviewed-on: https://boringssl-review.googlesource.com/27285
Reviewed-by: Adam Langley <agl@google.com>
2018-04-18 22:13:16 +00:00
David Benjamin e0ae249f03 Remove a = 0 special-case in BN_mod_exp_mont.
BN_mod_exp_mont is intended to protect the base, but not the exponent.
Accordingly, it shouldn't treat a base of zero as special.

Change-Id: Ib053e8ce65ab1741973a9f9bfeff8c353567439c
Reviewed-on: https://boringssl-review.googlesource.com/27284
Reviewed-by: Adam Langley <agl@google.com>
2018-04-18 22:03:16 +00:00
David Benjamin d319205007 Deny CRT to unbalanced RSA keys.
Our technique to perform the reduction only works for balanced key
sizes. For unbalanced keys, we fall back to variable-time logic.
Instead, fall back earlier to the non-CRT codepath, which is still
secure, just slower. This also aligns with the advice here:

https://github.com/HACS-workshop/spectre-mitigations/blob/master/crypto_guidelines.md#1-do-not-conditionally-choose-between-constant-and-non-constant-time

Update-Note: This is a performance hit (some keys will run 3x slower),
but only for keys with different-sized primes. I believe the Windows
crypto APIs will not accept such keys at all. There are two scenarios to
be concerned with for RSA performance:

1. Performance of reasonably-generated keys. Keys that BoringSSL or
anyone else reasonable generates will all be balanced, so this change
does not affect them.

2. Worst-case performance for DoS purposes. This CL does not change the
worst-case performance for RSA at a given bit size. In fact, it improves
it slightly. A sufficiently unbalanced RSA key is as slow as not doing
CRT at all.

In both cases, this change does not affect performance. The affected
keys are pathologically-generated ones that were not quite pathological
enough.

Bug: 235
Change-Id: Ie298dabb549ab9108fa9374aa86ebffe8b6c6c88
Reviewed-on: https://boringssl-review.googlesource.com/27504
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-04-17 15:14:04 +00:00
David Benjamin 024f5df3c8 Avoid some divisions in Lucky 13 fix.
data_plus_mac_size is secret. Values derived from it cannot quite be
safely divided by md_block_size because SHA-384 ciphers prevent that
field from being constant. We know the value is a power of two, so do
the strength reduction by hand.

Change-Id: Id62ab9e646f4e21d507a7059cfe84d49bbb986e6
Reviewed-on: https://boringssl-review.googlesource.com/27505
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-04-17 15:13:55 +00:00
David Benjamin e325c3f471 Give CERT a destructor.
Change-Id: I97f5290d908e59ece75fe5b8fa72d51c3cf62148
Reviewed-on: https://boringssl-review.googlesource.com/27489
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2018-04-16 20:25:23 +00:00
David Benjamin fceca8e27b Move srtp_profile to ssl->s3.
This too is connection-level state to be reset on SSL_clear.

Change-Id: I071c9431c28a7d0ff3eb20c679784d4aa4c236a5
Reviewed-on: https://boringssl-review.googlesource.com/27490
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2018-04-16 20:07:43 +00:00
David Benjamin e28552dec8 Add an API to disable RSA-PSS for certificates.
Chrome uses the platform certificate verifier and thus cannot reliably
expect PSS signatures to work in all configurations. Add an API for the
consumer to inform BoringSSL of this ability. We will then adjust our
advertisements accordingly.

Note that, because TLS 1.2 does not have the signature_algorithms_cert
extension, turning off TLS 1.3 and using this API will stop advertising
RSA-PSS. I believe this is the correct behavior given the semantics of
that code point.

The tests check the various combinations here, as well as checking that
the peer never sends signature_algorithms_cert identical to
signature_algorithms.

Bug: 229
Change-Id: I8c33a93efdc9252097e3899425b49548fc42a93a
Reviewed-on: https://boringssl-review.googlesource.com/27488
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2018-04-16 20:02:43 +00:00
David Benjamin c977532240 Pretty-print TicketAEADMethod tests.
It's hard to diagnose "20".

Change-Id: I57e8d0fb6e4937ddeca45b3645463ca0dc872ea6
Reviewed-on: https://boringssl-review.googlesource.com/27487
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2018-04-16 19:11:33 +00:00
David Benjamin 6879e19362 Rename SSL_SIGN_RSA_PSS_SHA* constants.
This reflects the change to add the key type into the constant. The old
constants are left around for now as legacy aliases and will be removed
later.

Change-Id: I67f1b50c01fbe0ebf4a2e9e89d3e7d5ed5f5a9d7
Reviewed-on: https://boringssl-review.googlesource.com/27486
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-04-16 19:00:03 +00:00
David Benjamin 5ad94767ab Remove legacy SSL_CTX_sess_set_get_cb overload.
Update-Note: I believe everything relying on this overload has since
    been updated.

Change-Id: I7facf59cde56098e5e3c79470293b67abb715f4c
Reviewed-on: https://boringssl-review.googlesource.com/27485
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-04-16 18:50:33 +00:00
David Benjamin 68478b7e9b Add runtime bounds checks to bssl::Span.
Better safe than sorry.

Change-Id: Ia99fa59ef1345835e01c330d99707bc8899a33a1
Reviewed-on: https://boringssl-review.googlesource.com/27484
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-04-16 16:26:33 +00:00
David Benjamin 9f0e7cb314 Move TB state to ssl->s3.
These are connection state, so they should be reset on SSL_clear.

Change-Id: I861fe52578836615d2719c9e1ff0911c798f336e
Reviewed-on: https://boringssl-review.googlesource.com/27384
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2018-04-13 18:10:44 +00:00
David Benjamin b8b1a9d8de Add SSL_SESSION_get0_cipher.
Conscrypt need this function right now. They ought to be fixed up to not
need this but, in the meantime, this API is also provided by OpenSSL and
will clear one most consumer reaching into SSL_SESSION.

Bumping the API since Conscrypt often involves multi-sided stuff.

Change-Id: I665ca6b6a17ef479133c29c23fc639f278128c69
Reviewed-on: https://boringssl-review.googlesource.com/27405
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-04-13 17:45:23 +00:00
Daniel Hirche 1414d86ff9 tool: Move the RSA specific code from |Speed| to |SpeedRSA|.
In addition, make use of bssl::ScopedEVP_MD_CTX in |SpeedHashChunk|,
otherwise the ctx doesn't get destroyed on failure.

Change-Id: I5828080cb9f4eb7c77cc2ff185d9aa8135311385
Reviewed-on: https://boringssl-review.googlesource.com/27464
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-04-13 17:35:13 +00:00
David Benjamin 27e4c3bab2 Add an OPENSSL_malloc_init stub.
OpenSSL 1.1.0 renamed that. Also clang-format wanted to smush it all
onto one line.

Change-Id: Icdaa0eefc503c4aab1b309ccb34625f5e811c537
Reviewed-on: https://boringssl-review.googlesource.com/27404
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-04-13 17:30:44 +00:00
Daniel Hirche de20810fb4 Fix return value in speed tool.
Change-Id: Iceed87c194201d28c4a51b1c19a59fe2f20b6a5e
Reviewed-on: https://boringssl-review.googlesource.com/27444
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-04-13 16:36:27 +00:00
Steven Valdez acddb8c134 Avoid modifying stack in sk_find.
Bug: 828680
Change-Id: Iae5d0a9bf938a67bfd69a720126ab431d79e43ec
Reviewed-on: https://boringssl-review.googlesource.com/27304
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-04-12 21:02:12 +00:00
Matthew Braithwaite c5154f7dbc SSL_serialize_handoff: serialize fewer things.
In the handoff+handback case, bssl_shim.cc creates 3 |SSL| objects:
one to receive the ClientHello, one to receive the handoff, and a
third one to receive the handback.

Before 56986f9, only the first of these received any configuration.
Since that commit, all 3 of them receive the same configuration.  That
means that the handback message no longer needs to serialize as many
things.

N.B. even before 56986f9, not all of the fields were necessary.  For
example, there was no reason to serialize |conf_max_version| and
|conf_min_version| in the handback, so far as I can tell.

This commit is mechanical: it simply removes everything that doesn't
cause any tests to fail.  In the long run, I'll need to carefully
check for two possibilities:

- Knobs that affect the handshake after the server's first message it
  sent.  These are troublesome because that portion of the handshake
  may run on a different |SSL|, depending on whether the handback is
  early or late.

- Getters that may be called post-handshake, and that callers may
  reasonably expect to reflect the value that was used during
  handshake.

(I'm not sure that either case exists!)

Change-Id: Ibf6e0be6609ad6e83ab50e69199e9b2d51e59a87
Reviewed-on: https://boringssl-review.googlesource.com/27364
Commit-Queue: Matt Braithwaite <mab@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-04-12 19:54:42 +00:00
Matthew Braithwaite 868ec7354b SSL_apply_handback: check that |max_send_fragment| is nonzero.
(Found by fuzzing: a zero value causes an infinite loop.)

Change-Id: I984fd88d85fb87616b5e806795c10334f4379744
Reviewed-on: https://boringssl-review.googlesource.com/27345
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-04-11 22:23:26 +00:00
James Robinson 98dd68fb97 [util] Generate separate GN source sets for headers and sources
This separates the source lists for the crypto and ssl targets from
their headers, so the header files can be listed in the 'public'
section of the targets. This allows tighter GN checking and expresses
the build structure more cleanly.

Change-Id: Ifb20c90977d7e858734654d9a03949be19a9c43a
Reviewed-on: https://boringssl-review.googlesource.com/27344
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-04-11 22:15:46 +00:00
Matthew Braithwaite 5b2a51de6c Check for nullptr result of SSLKeyShare::Create().
(Found by fuzzing.)

Change-Id: I5685a8ad1fedeb9535216e277c5a1fb1902d3338
Reviewed-on: https://boringssl-review.googlesource.com/27264
Commit-Queue: Matt Braithwaite <mab@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-04-10 22:55:53 +00:00
David Benjamin e2ab21d194 Use the actual record header, rather than reassembling it.
The last-minute TLS 1.3 change was done partly for consistency with DTLS
1.3, where authenticating the record header is less obviously pointless
than in TLS. There, reconstructing it would be messy. Instead, pass in
the record header and let SSLAEADContext decide whether or not to
assemble its own.

(While I'm here, reorder all the flags so the AD and nonce ones are
grouped together.)

Change-Id: I06e65d526b21a08019e5ca6f1b7c7e0e579e7760
Reviewed-on: https://boringssl-review.googlesource.com/27024
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-04-10 19:52:33 +00:00
David Benjamin f11ea19043 Actually benchmark RSA verification with a fresh key.
https://boringssl-review.googlesource.com/10522 didn't actually do what
it was supposed to do. In fact, it appears, not paying attention to it,
we've managed to make RSA verify slower than ECDSA verify. Oops.

Did 32000 RSA 2048 verify (same key) operations in 1016746us (31473.0 ops/sec)
Did 5525 RSA 2048 verify (fresh key) operations in 1067209us (5177.1 ops/sec)
Did 8957 ECDSA P-256 verify operations in 1078570us (8304.5 ops/sec)

The difference is in setting up the BN_MONT_CTX, either computing R^2 or n0.
I'm guessing R^2. The current algorithm needs to be constant-time, but we can
split out a variable-time one if necessary.

Change-Id: Ie064a0e464aaa803815b56a6734bc9e2becef1a7
Reviewed-on: https://boringssl-review.googlesource.com/27244
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-04-10 00:58:31 +00:00
David Benjamin bb2e1e1eea No-op comment to kick the bots.
Trigger some builds to see if the new kernel took.

Change-Id: Ib06c67b5da315ac46a757602abbf76626f46b279
2018-04-09 19:38:45 -04:00
David Benjamin 628b3c7f2f Don't write out a bad OID
If we don't have OID data for an object then we should fail if we
are asked to encode the ASN.1 for that OID.

(Imported from upstream's f3f8e72f494b36d05e0d04fe418f92b692fbb261.)

Change-Id: I3c3d3a3b236bca374fde3c0d02504140f2992602
Reviewed-on: https://boringssl-review.googlesource.com/27065
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-04-05 23:56:01 +00:00
David Benjamin dcd862c1cc No-op commit to kick the bots.
This is to confirm what kernel the bots are running, now that we've got
uname -a in there.

Change-Id: I8e940c6b1c1f2fc971da3bbcf28f0bc4f543841e
2018-04-05 17:13:18 -04:00
Adam Langley b2eaeb0b8b Drop some trial-division primes for 1024-bit candidates.
This is helpful at smaller sizes because the benefits of an unlikely hit
by trival-division are smaller.

The full set of kPrimes eliminates about 94.3% of random numbers. The
first quarter eliminates about 93.2% of them. But the little extra power
of the full set seems to be borderline for RSA 3072 and clearly positive
for RSA 4096.

Did 316 RSA 2048 key-gen operations in 30035598us (10.5 ops/sec)
  min: 19423us, median: 80448us, max: 394265us

Change-Id: Iee53f721329674ae7a08fabd85b4f645c24e119d
Reviewed-on: https://boringssl-review.googlesource.com/26944
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-04-05 03:53:01 +00:00
Steven Valdez 861f384d7b Implement TLS 1.3 draft28.
Change-Id: I7298c878bd2c8187dbd25903e397e8f0c2575aa4
Reviewed-on: https://boringssl-review.googlesource.com/26846
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-04-05 03:36:11 +00:00
David Benjamin eda47f5d98 Make generic point arithmetic slightly less variable-time.
The generic code special-cases affine points, but this leaks
information. (Of course, the generic code also doesn't have a
constant-time multiply and other problems, but one thing at a time.)

The optimization in point doubling is not useful. Point multiplication
more-or-less never doubles an affine point. The optimization in point
addition *is* useful because the wNAF code converts the tables to
affine. Accordingly, align with the P-256 code which adds a 'mixed'
parameter.

(I haven't aligned the formally-verified point formulas themselves yet;
initial testing suggests that the large number of temporaries take a
perf hit with BIGNUM. I'll check the results in EC_FELEM, which will be
stack-allocated, to see if we still need to help the compiler out.)

Strangly, it actually got a bit faster with this change. I'm guessing
because now it doesn't need to bother with unnecessary comparisons and
maybe was kinder to the branch predictor?

Before:
Did 2201 ECDH P-384 operations in 3068341us (717.3 ops/sec)
Did 4092 ECDSA P-384 signing operations in 3076981us (1329.9 ops/sec)
Did 3503 ECDSA P-384 verify operations in 3024753us (1158.1 ops/sec)
Did 992 ECDH P-521 operations in 3017884us (328.7 ops/sec)
Did 1798 ECDSA P-521 signing operations in 3059000us (587.8 ops/sec)
Did 1581 ECDSA P-521 verify operations in 3033142us (521.2 ops/sec)

After:
Did 2310 ECDH P-384 operations in 3092648us (746.9 ops/sec)
Did 4080 ECDSA P-384 signing operations in 3044588us (1340.1 ops/sec)
Did 3520 ECDSA P-384 verify operations in 3056070us (1151.8 ops/sec)
Did 992 ECDH P-521 operations in 3012779us (329.3 ops/sec)
Did 1792 ECDSA P-521 signing operations in 3019459us (593.5 ops/sec)
Did 1600 ECDSA P-521 verify operations in 3047749us (525.0 ops/sec)

Bug: 239
Change-Id: If5d13825fc98e4c58bdd1580cf0245bf7ce93a82
Reviewed-on: https://boringssl-review.googlesource.com/27004
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-04-04 21:33:22 +00:00
Matthew Braithwaite 56986f905f Hand back ECDHE split handshakes after the first server message.
This changes the contract for split handshakes such that on the
receiving side, the connection is to be driven until it returns
|SSL_ERROR_HANDBACK|, rather than until SSL_do_handshake() returns
success.

Change-Id: Idd1ebfbd943d88474d7c934f4c0ae757ff3c0f37
Reviewed-on: https://boringssl-review.googlesource.com/26864
Commit-Queue: Matt Braithwaite <mab@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-04-04 17:58:15 +00:00
David Benjamin ba9da449a4 Tolerate a null BN_CTX in BN_primality_test.
This used to work, but I broke it on accident in the recent rewrite.

Change-Id: I06ab5e06eb0c0a6b67ecc97919654e386f3c2198
Reviewed-on: https://boringssl-review.googlesource.com/26984
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Martin Kreichgauer <martinkr@google.com>
Reviewed-by: Martin Kreichgauer <martinkr@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-04-03 18:13:47 +00:00
David Benjamin 7a62ab1938 Clarify BN_prime_checks is only for random candidates.
The relevant result (Damgård, Landrock, and Pomerance, Average Case
Error Estimates for the Strong Probably Prime Test) is only applicable
for randomly selected candidates. It relies on there being very few odd
composites with many false witnesses.

(If testing an adversarially-selected composite, false witnesses are
bounded by ϕ(n)/4 for n != 9, so one needs about 40 iterations for a
2^-80 false positive rate.)

Change-Id: I2a063dac5f9042dcb9e6affee8d2ae575f2238a9
Reviewed-on: https://boringssl-review.googlesource.com/26972
Reviewed-by: Adam Langley <agl@google.com>
2018-04-02 18:29:56 +00:00
David Benjamin 5b05988add Implement field_{mul,sqr} in p224-64.c with p224_felems.
This is in preparation for representing field elements with
stack-allocated types in the generic code. While there is likely little
benefit in threading all the turned field arithmetic through all the
generic code, and the P-224 logic, in particular, does not have a tight
enough abstraction for this, the current implementations depend on
BN_div, which is not compatible with stack-allocating things and avoiding
malloc.

This also speeds things up slightly, now that benchmarks cover point
validation.

Before:
Did 82786 ECDH P-224 operations in 10024326us (8258.5 ops/sec)
After:
Did 89991 ECDH P-224 operations in 10012429us (8987.9 ops/sec)

Change-Id: I468483b49f5dc69187aebd62834365ce5caab795
Reviewed-on: https://boringssl-review.googlesource.com/26971
Reviewed-by: Adam Langley <agl@google.com>
2018-04-02 18:27:45 +00:00
David Benjamin c81ecf3436 Add test coverage for the a != -3 case.
Alas, it is reachable by way of the legacy custom curves API. Add a
basic test to ensure those codepaths work.

Change-Id: If631110045a664001133a0d07fdac4c67971a15f
Reviewed-on: https://boringssl-review.googlesource.com/26970
Reviewed-by: Adam Langley <agl@google.com>
2018-04-02 18:25:08 +00:00
David Benjamin 88b1a37e88 Include EC_POINT_oct2point in ECDH benchmarks.
This includes a point validation, which figures into the overall cost of
an ECDH operation. If, say, point validation is slow because it uses
generic code, we'd like it to show up in benchmarks.

(Later I'd like to replace this mess with a simple byte-oriented ECDH
API. When that happens, I'll update the benchmark accordingly.)

Change-Id: If8c33542d4b40572aac0a71ea2f658e7bc501f4b
Reviewed-on: https://boringssl-review.googlesource.com/26969
Reviewed-by: Adam Langley <agl@google.com>
2018-04-02 18:24:02 +00:00
David Benjamin 04018c5929 Remove EC_LOOSE_SCALAR.
ECDSA converts digests to scalars by taking the leftmost n bits, where n
is the number of bits in the group order. This does not necessarily
produce a fully-reduced scalar.

Montgomery multiplication actually tolerates this slightly looser bound,
so we did not bother with the conditional subtraction. However, this
subtraction is free compared to the multiplication, inversion, and base
point multiplication. Simplify things by keeping it fully-reduced.

Change-Id: If49dffefccc21510f40418dc52ea4da7e3ff198f
Reviewed-on: https://boringssl-review.googlesource.com/26968
Reviewed-by: Adam Langley <agl@google.com>
2018-04-02 18:22:58 +00:00
David Benjamin 9c1f8b4ac7 Add tests for large digests.
ECDSA's logic for converting digests to scalars sometimes produces
slightly unreduced values. Test these cases.

Change-Id: I67a5078db684ee82c286f41e71b13b57c3ee707b
Reviewed-on: https://boringssl-review.googlesource.com/26967
Reviewed-by: Adam Langley <agl@google.com>
2018-04-02 18:18:23 +00:00
David Benjamin 2257e8f3bf Use bn_rshift_words for the ECDSA bit-shift.
May as well use it. Also avoid an overflow with digest_len if someone
asks to sign a truly enormous digest.

Change-Id: Ia0a53007a496f9c7cadd44b1020ec2774b310936
Reviewed-on: https://boringssl-review.googlesource.com/26966
Reviewed-by: Adam Langley <agl@google.com>
2018-04-02 18:17:39 +00:00
David Benjamin 0645c05f5e Test the bit-shifting case in ECDSA.
For non-custom curves, this only comes up with P-521 and, even then,
only with excessively large hashes. Still, we should have test coverage
for this.

Change-Id: Id17a6f47d59d6dd4a43a93857fd3df490f9fa965
Reviewed-on: https://boringssl-review.googlesource.com/26965
Reviewed-by: Adam Langley <agl@google.com>
2018-04-02 18:14:27 +00:00
David Benjamin cbe77925f4 Extract the single-subtraction reduction into a helper function.
We do this in four different places, with the same long comment, and I'm
about to add yet another one.

Change-Id: If28e3f87ea71020d9b07b92e8947f3848473d99d
Reviewed-on: https://boringssl-review.googlesource.com/26964
Reviewed-by: Adam Langley <agl@google.com>
2018-04-02 18:13:45 +00:00
David Benjamin 25f3d84f4c Rewrite BN_rand without an extra malloc.
RSA keygen uses this to pick primes. May as well avoid bouncing on
malloc. (The BIGNUM internally allocates, of course, but that allocation
will be absorbed by BN_CTX in RSA keygen.)

Change-Id: Ie2243a6e48b9c55f777153cbf67ba5c06688c2f1
Reviewed-on: https://boringssl-review.googlesource.com/26887
Reviewed-by: Adam Langley <agl@google.com>
2018-04-02 18:07:12 +00:00
David Benjamin 85c2cd8a45 Fix up AUTHORITY_INFO_ACCESS/ACCESS_DESCRIPTION's deleter.
AUTHORITY_INFO_ACCESS is a STACK_OF(ACCESS_DESCRIPTION), so we want to
add a deleter for ACCESS_DESCRIPTION, at which point
AUTHORITY_INFO_ACCESS's deleter will show up for free.

Change-Id: Id9efb74093868c39a893de67dd26f1fc15379252
Reviewed-on: https://boringssl-review.googlesource.com/26973
Reviewed-by: Ryan Sleevi <rsleevi@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-04-02 17:07:46 +00:00
Adam Langley eb7c3008cc Only do 16 iterations to blind the primality test.
With this, in 0.02% of 1024-bit primes (which is what's used with an RSA
2048 generation), we'll leak that we struggled to generate values less
than the prime. I.e. that there's a greater likelihood of zero bits
after the leading 1 bit in the prime.

But this recovers all the speed loss from making key generation
constant-time, and then some.

Did 273 RSA 2048 key-gen operations in 30023223us (9.1 ops/sec)
  min: 23867us, median: 93688us, max: 421466us
Did 66 RSA 3072 key-gen operations in 30041763us (2.2 ops/sec)
  min: 117044us, median: 402095us, max: 1096538us
Did 31 RSA 4096 key-gen operations in 31673405us (1.0 ops/sec)
  min: 245109us, median: 769480us, max: 2659386us

Change-Id: Id82dedde35f5fbb36b278189c0685a13c7824590
Reviewed-on: https://boringssl-review.googlesource.com/26924
Reviewed-by: Adam Langley <alangley@gmail.com>
2018-03-30 22:31:36 +00:00
Adam Langley a0f1c8e3b1 Add RSA key generation to speed.cc
On a Skylake machine, the improvements to make RSA key generation
constant-time did slow things down a bit:

Before:

Did 217 RSA 2048 key-gen operations in 30231344us (7.2 ops/sec)
  min: 17154us, median: 117284us, max: 518336us
Did 70 RSA 3072 key-gen operations in 30188611us (2.3 ops/sec)
  min: 57759us, median: 348873us, max: 1760351us
Did 27 RSA 4096 key-gen operations in 30264235us (0.9 ops/sec)
  min: 202096us, median: 980160us, max: 4282915us

After:

Did 186 RSA 2048 key-gen operations in 30021173us (6.2 ops/sec)
  min: 74850us, median: 147650us, max: 407031us
Did 54 RSA 3072 key-gen operations in 30111667us (1.8 ops/sec)
  min: 292050us, median: 483786us, max: 1294105us
Did 18 RSA 4096 key-gen operations in 30662495us (0.6 ops/sec)
  min: 902547us, median: 1446689us, max: 3660302us

Change-Id: I52a96bb41bab759aa7ef6239bdfa533707a9eb3c
Reviewed-on: https://boringssl-review.googlesource.com/26904
Commit-Queue: Adam Langley <alangley@gmail.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-30 20:53:35 +00:00
David Benjamin 5833dd807e Limit the public exponent in RSA_generate_key_ex.
Windows CryptoAPI and Go bound public exponents at 2^32-1, so don't
generate keys which would violate that.

https://github.com/golang/go/issues/3161
https://msdn.microsoft.com/en-us/library/aa387685(VS.85).aspx

BoringSSL itself also enforces a 33-bit limit.

I don't currently have plans to take much advantage of it, but the
modular inverse step and one of the GCDs in RSA key generation are
helped by small public exponents[0]. In case someone feels inspired
later, get this limit enforced now. Use 32-bits as that's a more
convenient limit, and there's no requirement to produce e=2^32+1 keys.
(Is there still a requirement to accept them?)

[0] This isn't too bad, but it's only worth it if it produces simpler or
smaller code. RSA keygen is not performance-critical.

1. Make bn_mod_u16_consttime work for uint32_t. It only barely doesn't
   work. Maybe only accept 3 and 65537 and pre-compute, maybe call into
   bn_div_rem_words and friends, maybe just tighten the bound a hair
   longer.
2. Implement bn_div_u32_consttime by incorporating 32-bit chunks much
   like bn_mod_u32_consttime.
3. Perform one normal Euclidean algorithm iteration rather than using the
   binary version. u, v, B, and D are now single words, while A and C
   are full-width.
4. Continue with binary Euclidean algorithm (u and v are still secret),
   taking advantage of most values being small.

Update-Note: RSA_generate_key_ex will no longer generate keys with
   public exponents larger than 2^32-1. Everyone uses 65537, save some
   folks who use 3, so this shouldn't matter.

Change-Id: I0d28a29a30d9ff73bff282e34dd98e2b64c35c79
Reviewed-on: https://boringssl-review.googlesource.com/26365
Reviewed-by: Adam Langley <alangley@gmail.com>
2018-03-30 19:54:18 +00:00
David Benjamin c1c6eeb5e2 Check d is mostly-reduced in RSA_check_key.
We don't check it is fully reduced because different implementations use
Carmichael vs Euler totients, but if d exceeds n, something is wrong.
Note the fixed-width BIGNUM changes already fail operations with
oversized d.

Update-Note: Some blatantly invalid RSA private keys will be rejected at
    RSA_check_key time. Note that most of those keys already are not
    usable with BoringSSL anyway. This CL moves the failure from
    sign/decrypt to RSA_check_key.

Change-Id: I468dbba74a148aa58c5994cc27f549e7ae1486a2
Reviewed-on: https://boringssl-review.googlesource.com/26374
Reviewed-by: Adam Langley <alangley@gmail.com>
2018-03-30 19:54:10 +00:00
David Benjamin cba958f406 Make RSA_check_key constant-time and more meaningful.
Rather than recompute values the same as in key generation, where
possible, we check differently. In particular, most RSA values are
modular inverses of some value. Check each of them by multiplying and
using our naive constant-time division function.

Median of 29 RSA keygens: 0m0.218s -> 0m0.205s
(Accuracy beyond 0.1s is questionable.)

Bug: 238
Change-Id: Iaca19f12c045457013def844a17bf502ed09136e
Reviewed-on: https://boringssl-review.googlesource.com/26373
Reviewed-by: Adam Langley <alangley@gmail.com>
2018-03-30 19:54:00 +00:00
David Benjamin c4e4757b63 Make RSA key generation constant-time.
This leaves RSA_check_key, which will be fixed in subsequent commits.

Median of 29 RSA keygens: 0m0.220s -> 0m0.209s
(Accuracy beyond 0.1s is questionable.)

Bug: 238
Change-Id: I325f23fcc59302e68570908e5427b65471b799f6
Reviewed-on: https://boringssl-review.googlesource.com/26371
Reviewed-by: Adam Langley <alangley@gmail.com>
2018-03-30 19:53:52 +00:00
David Benjamin a44dae7fd3 Add a constant-time generic modular inverse function.
This uses the full binary GCD algorithm, where all four of A, B, C, and
D must be retained. (BN_mod_inverse_odd implements the odd number
version which only needs A and C.) It is patterned after the version
in the Handbook of Applied Cryptography, but tweaked so the coefficients
are non-negative and bounded.

Median of 29 RSA keygens: 0m0.225s -> 0m0.220s
(Accuracy beyond 0.1s is questionable.)

Bug: 238
Change-Id: I6dc13524ea7c8ac1072592857880ddf141d87526
Reviewed-on: https://boringssl-review.googlesource.com/26370
Reviewed-by: Adam Langley <alangley@gmail.com>
2018-03-30 19:53:44 +00:00
David Benjamin 1044553d6d Add new GCD and related primitives.
RSA key generation requires computing a GCD (p-1 and q-1 are relatively
prime with e) and an LCM (the Carmichael totient). I haven't made BN_gcd
itself constant-time here to save having to implement
bn_lshift_secret_shift, since the two necessary operations can be served
by bn_rshift_secret_shift, already added for Rabin-Miller. However, the
guts of BN_gcd are replaced. Otherwise, the new functions are only
connected to tests for now, they'll be used in subsequent CLs.

To support LCM, there is also now a constant-time division function.
This does not replace BN_div because bn_div_consttime is some 40x slower
than BN_div. That penalty is fine for RSA keygen because that operation
is not bottlenecked on division, so we prefer simplicity over
performance.

Median of 29 RSA keygens: 0m0.212s -> 0m0.225s
(Accuracy beyond 0.1s is questionable.)

Bug: 238
Change-Id: Idbfbfa6e7f5a3b8782ce227fa130417b3702cf97
Reviewed-on: https://boringssl-review.googlesource.com/26369
Reviewed-by: Adam Langley <alangley@gmail.com>
2018-03-30 19:53:36 +00:00
David Benjamin 23af438ccd Compute p - q in constant time.
Expose the constant-time abs_sub functions from the fixed Karatsuba code
in BIGNUM form for RSA to call into. RSA key generation involves
checking if |p - q| is above some lower bound.

BN_sub internally branches on which of p or q is bigger. For any given
iteration, this is not secret---one of p or q is necessarily the larger,
and whether we happened to pick the larger or smaller first is
irrelevant. Accordingly, there is no need to perform the p/q swap at the
end in constant-time.

However, this stage of the algorithm picks p first, sticks with it, and
then computes |p - q| for various q candidates. The distribution of
comparisons leaks information about p. The leak is unlikely to be
problematic, but plug it anyway.

Median of 29 RSA keygens: 0m0.210s -> 0m0.212s
(Accuracy beyond 0.1s is questionable.)

Bug: 238
Change-Id: I024b4e51b364f5ca2bcb419a0393e7be13249aec
Reviewed-on: https://boringssl-review.googlesource.com/26368
Reviewed-by: Adam Langley <alangley@gmail.com>
2018-03-30 19:53:28 +00:00
David Benjamin 8d9ee7d1fe Replace rsa_greater_than_pow2 with BN_cmp.
It costs us a malloc, but it's one less function to test and implement
in constant time, now that BN_cmp and BIGNUM are okay.

Median of 29 RSA keygens: 0m0.207s -> 0m0.210s
(Accuracy beyond 0.1s is questionable.)

Bug: 238
Change-Id: Ic56f92f0dcf04da1f542290a7e8cdab8036699ed
Reviewed-on: https://boringssl-review.googlesource.com/26367
Reviewed-by: Adam Langley <alangley@gmail.com>
2018-03-30 19:53:18 +00:00
David Benjamin 97ac45e2f7 Change the order of GCD and trial division.
RSA key generation currently does the GCD check before the primality
test, in hopes of discarding things invalid by other means before
running the expensive primality check.

However, GCD is about to get a bit more expensive to clear the timing
leak, and the trial division part of primality testing is quite fast.
Thus, split that portion out via a new bn_is_obviously_composite and
call it before GCD.

Median of 29 RSA keygens: 0m0.252s -> 0m0.207s
(Accuracy beyond 0.1s is questionable.)

Bug: 238
Change-Id: I3999771fb73cca16797cab9332d14c4ebeb02046
Reviewed-on: https://boringssl-review.googlesource.com/26366
Reviewed-by: Adam Langley <alangley@gmail.com>
2018-03-30 19:53:06 +00:00
David Benjamin 40729e374d Revert "Update SDE to 8.16.0."
This reverts commit 21ef155063. Doesn't
look like I succeeded in uploading that. Will sort that out later.

Change-Id: Ic5395abe46b2b99aaffd254afcd97157518c8ba8
Reviewed-on: https://boringssl-review.googlesource.com/26886
Reviewed-by: David Benjamin <davidben@google.com>
2018-03-30 17:59:40 +00:00
David Benjamin 21ef155063 Update SDE to 8.16.0.
Change-Id: If6891b9338352d4f1dc9f902d4e32ca358764675
Reviewed-on: https://boringssl-review.googlesource.com/26885
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-30 17:52:56 +00:00
David Benjamin 365e48c104 Update tools.
Change-Id: Ibbba2e2fa81b5f8b3a25ebadc50297f50dcb610e
Reviewed-on: https://boringssl-review.googlesource.com/26884
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-30 17:51:56 +00:00
Adam Langley 1902d818ac Tighten and test name-checking functions.
This change follows up from e759a9cd with more extensive changes and
tests:

If a name checking function (like |X509_VERIFY_PARAM_set1_host|) fails,
it now poisons the |X509_VERIFY_PARAM| so that all verifications will
fail. This is because we have observed that some callers are not
checking the return value of these functions.

Using a length of zero for a hostname to mean |strlen| is now an error.
It also an error for email addresses and IP addresses now, and doesn't
end up trying to call |strlen| on a (binary) IP address.

Setting an email address with embedded NULs now fails. So does trying to
configure an empty hostname or email with (NULL, 0).

|X509_check_*| functions in BoringSSL don't accept zero lengths (unlike
OpenSSL). It's now tested that such calls always fail.

Change-Id: I4484176f2aae74e502a09081c7e912c85e8d090b
Update-Note: several behaviour changes. See change description.
Reviewed-on: https://boringssl-review.googlesource.com/26764
Reviewed-by: David Benjamin <davidben@google.com>
2018-03-30 16:50:11 +00:00
David Benjamin 56f5eb9ffd Name constant-time functions more consistently.
I'm not sure why I separated "fixed" and "quick_ctx" names. That's
annoying and doesn't generalize well to, say, adding a bn_div_consttime
function for RSA keygen.

Change-Id: I751d52b30e079de2f0d37a952de380fbf2c1e6b7
Reviewed-on: https://boringssl-review.googlesource.com/26364
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-03-29 23:30:55 +00:00
David Benjamin e6f46e2563 Blind the range check for finding a Rabin-Miller witness.
Rabin-Miller requires selecting a random number from 2 to |w|-1.
This is done by picking an N-bit number and discarding out-of-range
values. This leaks information about |w|, so apply blinding. Rather than
discard bad values, adjust them to be in range.
Though not uniformly selected, these adjusted values
are still usable as Rabin-Miller checks.

Rabin-Miller is already probabilistic, so we could reach the desired
confidence levels by just suitably increasing the iteration count.
However, to align with FIPS 186-4, we use a more pessimal analysis: we
do not count the non-uniform values towards the iteration count. As a
result, this function is more complex and has more timing risk than
necessary.

We count both total iterations and uniform ones and iterate until we've
reached at least |BN_PRIME_CHECKS_BLINDED| and |iterations|,
respectively.  If the latter is large enough, it will be the limiting
factor with high probability and we won't leak information.

Note this blinding does not impact most calls when picking primes
because composites are rejected early. Only the two secret primes see
extra work.  So while this does make the BNTest.PrimeChecking test take
about 2x longer to run on debug mode, RSA key generation time is fine.

Another, perhaps simpler, option here would have to run
bn_rand_range_words to the full 100 count, select an arbitrary
successful try, and declare failure of the entire keygen process (as we
do already) if all tries failed. I went with the option in this CL
because I happened to come up with it first, and because the failure
probability decreases much faster. Additionally, the option in this CL
does not affect composite numbers, while the alternate would. This gives
a smaller multiplier on our entropy draw. We also continue to use the
"wasted" work for stronger assurance on primality. FIPS' numbers are
remarkably low, considering the increase has negligible cost.

Thanks to Nathan Benjamin for helping me explore the failure rate as the
target count and blinding count change.

Now we're down to the rest of RSA keygen, which will require all the
operations we've traditionally just avoided in constant-time code!

Median of 29 RSA keygens: 0m0.169s -> 0m0.298s
(Accuracy beyond 0.1s is questionable. The runs at subsequent test- and
rename-only CLs were 0m0.217s, 0m0.245s, 0m0.244s, 0m0.247s.)

Bug: 238
Change-Id: Id6406c3020f2585b86946eb17df64ac42f30ebab
Reviewed-on: https://boringssl-review.googlesource.com/25890
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-03-29 22:02:24 +00:00
David Benjamin 8eadca50a2 Don't leak |a| in the primality test.
(This is actually slightly silly as |a|'s probability distribution falls
off exponentially, but it's easy enough to do right.)

Instead, we run the loop to the end. This is still performant because we
can, as before, return early on composite numbers. Only two calls
actually run to the end. Moreover, running to the end has comparable
cost to BN_mod_exp_mont_consttime.

Median time goes from 0.140s to 0.231s. That cost some, but we're still
faster than the original implementation.

We're down to one more leak, which is that the BN_rand_range_ex call
does not hide |w1|. That one may only be solved probabilistically...

Median of 29 RSA keygens: 0m0.123s -> 0m0.145s
(Accuracy beyond 0.1s is questionable.)

Bug: 238
Change-Id: I4847cb0053118c572d2dd5f855388b5199fa6ce2
Reviewed-on: https://boringssl-review.googlesource.com/25888
Reviewed-by: Adam Langley <agl@google.com>
2018-03-28 01:44:31 +00:00
David Benjamin 9362ed9e14 Use a Barrett reduction variant for trial division.
Compilers use a variant of Barrett reduction to divide by constants,
which conveniently also avoids problematic operations on the secret
numerator. Implement the variant as described here:
http://ridiculousfish.com/blog/posts/labor-of-division-episode-i.html

Repurpose this to implement a constant-time BN_mod_word replacement.
It's even much faster! I've gone ahead and replaced the other
BN_mod_word calls on the primes table.

That should give plenty of budget for the other changes. (I am assuming
that a regression is okay, as RSA keygen is not performance-sensitive,
but that I should avoid anything too dramatic.)

Proof of correctness: https://github.com/davidben/fiat-crypto/blob/barrett/src/Arithmetic/BarrettReduction/RidiculousFish.v

Median of 29 RSA keygens: 0m0.621s -> 0m0.123s
(Accuracy beyond 0.1s is questionable, though this particular
improvement is quite solid.)

Bug: 238
Change-Id: I67fa36ffe522365b13feb503c687b20d91e72932
Reviewed-on: https://boringssl-review.googlesource.com/25887
Reviewed-by: Adam Langley <agl@google.com>
2018-03-28 01:42:18 +00:00
David Benjamin 232a6be6f1 Make primality testing mostly constant-time.
The extra details in Enhanced Rabin-Miller are only used in
RSA_check_key_fips, on the public RSA modulus, which the static linker
will drop in most of our consumers anyway. Implement normal Rabin-Miller
for RSA keygen and use Montgomery reduction so it runs in constant-time.

Note that we only need to avoid leaking information about the input if
it's a large prime. If the number ends up composite, or we find it in
our table of small primes, we can return immediately.

The leaks not addressed by this CL are:

- The difficulty of selecting |b| leaks information about |w|.
- The distribution of whether step 4.4 runs leaks information about w.
- We leak |a| (the largest power of two which divides w) everywhere.
- BN_mod_word in the trial division is not constant-time.

These will be resolved in follow-up changes.

Median of 29 RSA keygens: 0m0.521 -> 0m0.621s
(Accuracy beyond 0.1s is questionable.)

Bug: 238
Change-Id: I0cf0ff22079732a0a3ababfe352bb4327e95b879
Reviewed-on: https://boringssl-review.googlesource.com/25886
Reviewed-by: Adam Langley <agl@google.com>
2018-03-28 01:42:06 +00:00
David Benjamin 50418afb7f Add some EC base point multiplication test vectors.
Probably worth having actual test vectors for these, rather than
checking our code against itself. Additionally, small negative numbers
have, in the past been valuable test vectors (see long comment in
point_add from OpenSSL's ecp_nistp521.c).

Change-Id: Ia5aa8a80eb5b6d0089c3601c5fec2364e699794d
Reviewed-on: https://boringssl-review.googlesource.com/26848
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-27 23:33:24 +00:00
David Benjamin 718c88c961 Fix a bug in p224-64.c.
p224_felem_neg does not produce an output within the tight bounds
suitable for p224_felem_contract. This was found by inspection of the
code.

This only affects the final y-coordinate output of arbitrary-point
multiplication, so it is a no-op for ECDH and ECDSA.

Change-Id: I1d929458d1f21d02cd8e745d2f0f7040a6bb0627
Reviewed-on: https://boringssl-review.googlesource.com/26847
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-27 18:03:14 +00:00
Adam Langley 72bc2328b1 Note licenses for support code in the top-level LICENSE file.
This keeps some scripts happy.

Change-Id: I79be4f3d014b72fbe3f0793759ad2b42329a550c
Reviewed-on: https://boringssl-review.googlesource.com/26824
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-27 17:03:47 +00:00
David Benjamin 2e16f6ba81 Add a test for CRYPTO_memcmp.
This test is written in honor of CVE-2018-0733.

Change-Id: I8a41f917b08496870037f745f19bdcdb65b3d623
Reviewed-on: https://boringssl-review.googlesource.com/26845
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-27 16:22:47 +00:00
David Benjamin 2a19a17ca7 Limit ASN.1 constructed types recursive definition depth
Constructed types with a recursive definition could eventually exceed
the stack given malicious input with excessive recursion. Therefore we
limit the stack depth.

CVE-2018-0739

Credit to OSSFuzz for finding this issue.

(Imported from upstream's 9310d45087ae546e27e61ddf8f6367f29848220d.)

BoringSSL does not contain any such structures, but import this anyway
with a test.

Change-Id: I0e84578ea795134f25dae2ac8b565f3c26ef3204
Reviewed-on: https://boringssl-review.googlesource.com/26844
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-27 15:40:37 +00:00
David Benjamin 0970d397c4 Make various BIGNUM comparisons constant-time.
Primality testing checks for small words in random places.

Median of 29 RSA keygens: 0m0.811s -> 0m0.521s
(Accuracy beyond 0.1s is questionable, and this "speed up" is certainly
noise.)

Bug: 238
Change-Id: Ie5efab7291302a42ac6e283d25da0c094d8577e7
Reviewed-on: https://boringssl-review.googlesource.com/25885
Reviewed-by: Adam Langley <agl@google.com>
2018-03-26 18:53:53 +00:00
David Benjamin ad066861dd Add bn_usub_fixed.
There are a number of random subtractions in RSA key generation. Add a
fixed-width version.

Median of 29 RSA keygens: 0m0.859s -> 0m0.811s
(Accuracy beyond 0.1s is questionable.)

Bug: 238
Change-Id: I9fa0771b95a438fd7d2635fd77a332146ccc96d9
Reviewed-on: https://boringssl-review.googlesource.com/25884
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2018-03-26 18:53:43 +00:00
Adam Langley d89d65ba12 Add utility program for emitting P-256 x86-64 table.
No semantic change: the table is the same as before, but now with less
magic.

Change-Id: I351c2446e9765f25b7dfb901c9e98f12099a325c
Reviewed-on: https://boringssl-review.googlesource.com/26744
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-26 16:28:42 +00:00
David Benjamin 6ebef73213 Add bssl::UniquePtr<AUTHORITY_INFO_ACCESS>
Change-Id: I8a0c1196bd455a9193c411764f26e662f5b98649
Reviewed-on: https://boringssl-review.googlesource.com/26804
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-26 15:36:33 +00:00
David Benjamin 5fca613918 Fix typo in point_add.
Rather than writing the answer into the output, it wrote it into some
awkwardly-named temporaries. Thanks to Daniel Hirche for reporting this
issue!

Bug: chromium:825273
Change-Id: I5def4be045cd1925453c9873218e5449bf25e3f5
Reviewed-on: https://boringssl-review.googlesource.com/26785
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-23 21:12:29 +00:00
David Benjamin 6291af4e52 Add -DOPENSSL_SMALL to CMake.
Adding preprocessor flags requires a lot of typing in the CMake
command-line (-DCMAKE_C_FLAGS=-DOPENSSL_SMALL
-DCMAKE_CXX_FLAGS=-DOPENSSL_SMALL).

Change-Id: Ieafc4155d656306c1f22746f780faa5c1d3e27be
Reviewed-on: https://boringssl-review.googlesource.com/26784
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-23 21:07:48 +00:00
David Benjamin 441efad4d7 Add RSA_PSS_PARAMS to bssl::UniquePtr.
Change-Id: I471eb1c13aafb71ba5dc33f623811d5447cc85c6
Reviewed-on: https://boringssl-review.googlesource.com/26684
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2018-03-22 20:34:07 +00:00
Adam Langley e759a9cd84 Support the OpenSSL “pass zero for strlen” when setting X.509 hostnames.
BoringSSL does not generally support this quirk but, in this case, we
didn't make it a fatal error and it's instead a silent omission of
hostname checking. This doesn't affect Chrome but, in case something is
using BoringSSL and using this trick, this change makes it safe.

BUG=chromium:824799

Change-Id: If417817b997b9faa9963c09dfc95d06a5d445e0b
Reviewed-on: https://boringssl-review.googlesource.com/26724
Commit-Queue: Adam Langley <alangley@gmail.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-22 17:19:07 +00:00
David Benjamin d67e311ce4 Test BN_primality test with OEIS A014233 values .
These are composite numbers whose composite witnesses aren't in the
first however many prime numbers, so deterministically checking small
numbers may not work.

We don't check composite witnesses deterministically but these are
probably decent tests. (Not sure how else to find composites with
scarce witnesses, but these seemed decent candidates.)

Change-Id: I23dcb7ba603a64c1f7d1e9a16942e7c29c76da51
Reviewed-on: https://boringssl-review.googlesource.com/26645
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-22 16:26:37 +00:00
Adam Langley 88e6a05f46 Configure asmjs and wasm as generic, 32-bit machines.
Change-Id: Ia4fdd1eb848abacf43e18f6741ffa4ff79e40fd8
Reviewed-on: https://boringssl-review.googlesource.com/26664
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-20 23:24:06 +00:00
David Benjamin d61334d187 Document preferences for EC_GROUP_new_by_curve_name.
Folks should use curve25519 or P-256 if in doubt.

Change-Id: Ie35381ef739744788a80345286f7b21e2bb67c88
Reviewed-on: https://boringssl-review.googlesource.com/26646
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-20 20:15:06 +00:00
Andrii Shyshkalov 433c0aab3b CQ: use new luci.boringssl.try bucket.
Should land after https://boringssl-review.googlesource.com/c/boringssl/+/26264
lands.

R=davidben@google.com

Bug: chromium:813228
Change-Id: I66cd792f9e90c3161b7886ed17d5057295d82abe
Reviewed-on: https://boringssl-review.googlesource.com/26604
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-20 16:31:15 +00:00
David Benjamin ee764744e0 Add some BN_mod_inverse tests.
Generated randomly.

Change-Id: I51e6871ffddc4c5954a773db4473e944cb9818ed
Reviewed-on: https://boringssl-review.googlesource.com/26084
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-20 16:11:45 +00:00
David Benjamin 1bfb5c0f79 Add some tests for BN_gcd.
These were randomly generated.

Change-Id: I532afdaf469e6c80e518dae3a75547ff7cb0948f
Reviewed-on: https://boringssl-review.googlesource.com/26065
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-20 16:08:56 +00:00
David Benjamin 380fc326c3 Add RSA_check_key tests.
Change-Id: I5ac52de4217b32631b1d455f5d693d7b2aec665f
Reviewed-on: https://boringssl-review.googlesource.com/26372
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2018-03-19 22:29:40 +00:00
David Benjamin ac97cc0e51 Fill in missing check_bn_tests.go features.
Change-Id: Ic0421b628212521d673cb7053b0fb278c827ebf5
Reviewed-on: https://boringssl-review.googlesource.com/26064
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-19 21:41:00 +00:00
David Benjamin 4b6055defb Add better tests for BN_rand.
Change-Id: Iefeeeb12c4a5a12e8dffc6817bb368d68a074cd0
Reviewed-on: https://boringssl-review.googlesource.com/25889
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-19 21:18:45 +00:00
David Benjamin 8a1a5daa49 Send the fake session ID in the test suite.
NSS only enables compatibility mode on the server if the client
requested it by way of the session ID. This is slightly off as a client
has no way not to request it when offering a TLS 1.2 session, but it is
in the spec.

So our tests are usable for other stacks, send a fake session ID in the
runner by default. The existing EmptySessionID-TLS13* test asserts that
BoringSSL behaves as we expect it to on empty session IDs too. The
intent is that NSS will disable that test but can otherwise leave the
rest enabled.

Change-Id: I370bf90aba1805c2f6970ceee0d29ecf199f437d
Reviewed-on: https://boringssl-review.googlesource.com/26504
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-19 21:06:05 +00:00
Adam Langley d096c06b34 bytestring: document that |CBS_get_optional_asn1| can have a NULL output.
On the other hand, the type-specific
|CBS_get_optional_asn1_octet_string| must have a valid pointer and we
should check this in the “present” case or there could be a lucking
crash in some user waiting for an expected value to be missing.

Change-Id: Ida40e069ac7f0e50967e3f6c6b3fc01e49bd8894
Reviewed-on: https://boringssl-review.googlesource.com/26564
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-19 20:22:25 +00:00
sphawk 3ab1a69545 fix compilation error for non-english windows (like cjk)
add /utf-8 switch for msvc build. source code has several utf-8 characters
fix C2001 error. escape non-printable ascii code generated by embed_test_data.go
fix C4819 warning. add u8 keyword on utf-8 string literal (ripemd_test.cc)

Change-Id: I8c04dc7f0359e6ee27efada066863826d263d5cd
Reviewed-on: https://boringssl-review.googlesource.com/26484
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-15 17:52:23 +00:00
Adam Langley fa3e9c3385 Add |SSL_COMP_get[0_name|_id]|.
These functions are needed by MySQL 8.0:
https://github.com/mysql/mysql-server/blob/8.0/vio/viossl.cc#L459

Change-Id: I4f13fa26cfe695229d6c8df80bcfc218408184da
Reviewed-on: https://boringssl-review.googlesource.com/26544
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-15 17:34:33 +00:00
David Benjamin a0bc29a775 Remove remnants of the HRR message.
It has now been folded into ServerHello. Additionally, TLS 1.2 and TLS
1.3 ServerHellos are now more uniform, so we can avoid the extra
ServerHello parser.

Change-Id: I46641128c3f65fe37e7effca5bef4a76bf3ba84c
Reviewed-on: https://boringssl-review.googlesource.com/26524
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2018-03-13 21:10:03 +00:00
David Benjamin 10bfb89859 Fix 20-year-old typo in BN_mask_bits.
This clearly was supposed to be a return 1. See
https://github.com/openssl/openssl/issues/5537 for details.

(Additionally, now that our BIGNUMs may be non-minimal, this function
violates the rule that BIGNUM functions should not depend on widths. We
should use w >= bn_minimal_width(a) to retain the original behavior. But
the original behavior is nuts, so let's just fix it.)

Update-Note: BN_mask_bits no longer reports failure in some cases. These
    cases were platform-dependent and not useful, and code search confirms
    nothing was relying on it.

Change-Id: I31b1c2de6c5de9432c17ec3c714a5626594ee03c
Reviewed-on: https://boringssl-review.googlesource.com/26464
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-08 21:53:06 +00:00
David Benjamin 47d88415db Document that BN_bn2bin is not constant-time.
Change-Id: Id503850f92cc792229ed7558371e5038399c98d7
Reviewed-on: https://boringssl-review.googlesource.com/26385
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2018-03-07 21:44:51 +00:00
David Benjamin 3d2c6b0b0e Document EC_POINT_get_affine_coordinates_GFp allowing NULL x and y.
Change-Id: Iffc1f43afc0fed2166509775ac3c52f90eb7cddf
Reviewed-on: https://boringssl-review.googlesource.com/26384
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-07 21:32:51 +00:00
David Benjamin a6bfc45b62 Store EC_KEY's private key as an EC_SCALAR.
This isn't strictly necessary now that BIGNUMs are safe, but we get to
rely on type-system annotations from EC_SCALAR. Additionally,
EC_POINT_mul depends on BN_div, while the EC_SCALAR version does not.

Change-Id: I75e6967f3d35aef17278b94862f4e506baff5c23
Reviewed-on: https://boringssl-review.googlesource.com/26424
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-07 21:17:31 +00:00
David Benjamin d62fe6f3e8 Fold EC_KEY_copy into EC_KEY_dup.
EC_KEY_copy left unset fields alone, which meant it was possible to
create an EC_KEY with mismatched private key and group. Nothing was
using EC_KEY_copy anyway, and in keeping of us generally preferring
fresh objects over object reuse, remove it. EC_KEY_dup itself can also
be made simpler by using the very setters available.

Additionally, skip copying the method table. As of
https://boringssl-review.googlesource.com/16344, we no longer copy the
ex_data, so we probably shouldn't copy the method pointers either,
aligning with RSAPrivateKey_dup.

Update-Note: If I missed anything and someone uses EC_KEY_copy, it
   should be easy to port them to EC_KEY_dup.

Change-Id: Ibbdcea73345d91fa143fbe70a15bb527972693e8
Reviewed-on: https://boringssl-review.googlesource.com/26404
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-07 21:17:02 +00:00
Adam Langley 40cdb3b5da Don't test |initial_handshake_complete| for dummy PQ padding status.
Checking |initial_handshake_complete| was a mistake—it's not true for
False Start connections at the time when Chrome wants to measure whether
PQ padding was used or not.

Change-Id: I51757e00f3e02129666ee1ce31c30d63f1bcbe74
Reviewed-on: https://boringssl-review.googlesource.com/26444
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-07 20:27:11 +00:00
David Benjamin ec55dc15d3 Update tools.
Also remove the -Wtautological-constant-compare logic. I believe Clang
has since removed that problematic warning from -Wall and that check was
causing problems when we were embedded as a subproject in a project that
didn't set CMP0025.

(In that case, by the time our build file ran, the compiler had already
been detected and the damage done. This unfortunately means the next
Clang version check will hit the same issue, but let's deal with that
when we get there.)

Change-Id: Iea5f262899b74c5b84f707f4cf4ac4b3540c4acb
Reviewed-on: https://boringssl-review.googlesource.com/26375
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-05 20:49:21 +00:00
David Benjamin 929a9d7d42 Don't bother retrying in bn_blinding_create_param.
The probability of stumbling on a non-invertible b->A is negligible;
it's equivalent to accidentally factoring the RSA key. Relatedly,
document the slight caveat in BN_mod_inverse_blinded.

Change-Id: I308d17d12f5d6a12c444dda8c8fcc175ef2f5d45
Reviewed-on: https://boringssl-review.googlesource.com/26344
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-03-05 20:48:41 +00:00
David Benjamin f8058d4114 Add M=8 L=2 AES-128-CCM as well.
The Bluetooth Mesh spec uses both apparently. Also extract a pile of
test vectors from that document (thanks to Kyle Lund for showing me
which to extract).

Change-Id: I04a04fafb7386ca28adfe1446fa388e841778931
Reviewed-on: https://boringssl-review.googlesource.com/26324
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-03-02 18:45:06 +00:00
Adam Langley 8df8e64205 Record whether dummy PQ padding was used.
On reflection, I think we'll need to note whether dummy PQ padding was
echoed on a given connection. Otherwise measurements in Chrome will be
mixed with cases where people have MITM proxies that ignored the
extension, or possibly Google frontends that haven't been updated.

Therefore this change will be used to filter latency measurements in
Chrome to only include those where the extension was echoed and we'll
measure at levels of 1 byte (for control), 400 bytes, and 1100 bytes.

This also makes it an error if the server didn't echo an extension of
the same length as was sent.

Change-Id: Ib2a0b29cfb8719a75a28f3cf96710c57d88eaa68
Reviewed-on: https://boringssl-review.googlesource.com/26284
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-02-28 23:38:53 +00:00
Daniel Hirche 8d4f7e5421 Remove redundant assertion in fe_mul_121666_impl.
Change-Id: Ie2368dc9f6be791b7c3ad1c610dcd603634be6e4
Reviewed-on: https://boringssl-review.googlesource.com/26244
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-02-27 23:50:02 +00:00
Adam Langley 4702db6306 Update dummy PQ extension for round two.
In this round, Google servers will echo the extension in order to test
the latency of both parties sending a PQ key-agreement message.

The extension is sent (and echoed) for both full and resumption
handshakes. This is intended to mirror the overhead of TLS 1.3 (even
when using TLS 1.2), as a resumption in TLS 1.3 still does a fresh key
agreement.

Change-Id: I9ad163afac4fd1d916f9c7359ec32994e283abeb
Reviewed-on: https://boringssl-review.googlesource.com/26185
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-02-27 20:13:53 +00:00
Martin Kreichgauer 8041d8c40e third_party: re-format METATADA files
Change-Id: Ic2e9f54f5ced053c1463d5c09a74db5b2a3ea098
Reviewed-on: https://boringssl-review.googlesource.com/26224
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-02-27 19:57:12 +00:00
Adam Langley c01786403f Update link to CMVP certificate.
NIST redid their website and broke all the old links.

Change-Id: I5b7cba878404bb63e49f221f6203c8e1e6545af4
Reviewed-on: https://boringssl-review.googlesource.com/26204
Reviewed-by: Adam Langley <agl@google.com>
2018-02-26 22:14:35 +00:00
Adam Langley e745b25dcb Remove trailing whitespace from ssl/.
Change-Id: Ibcb27e1e5b14294c9d877db89ae62ef138e9e061
Reviewed-on: https://boringssl-review.googlesource.com/26184
Reviewed-by: Adam Langley <agl@google.com>
2018-02-26 22:05:13 +00:00
David Benjamin 672f6fc248 Always use adr with __thumb2__.
Thumb2 addresses are a bit a mess, depending on whether a label is
interpreted as a function pointer value (for use with BX and BLX) or as
a program counter value (for use with PC-relative addressing). Clang's
integrated assembler mis-assembles this code. See
https://crbug.com/124610#c54 for details.

Instead, use the ADR pseudo-instruction which has clear semantics and
should be supported by every assembler that handles the OpenSSL Thumb2
code. (In other files, the ADR vs SUB conditionals are based on
__thumb2__ already. For some reason, this one is based on __APPLE__, I'm
guessing to deal with an older version of clang assembler.)

It's unclear to me which of clang or binutils is "correct" or if this is
even a well-defined notion beyond "whatever binutils does". But I will
note that https://github.com/openssl/openssl/pull/4669 suggests binutils
has also changed behavior around this before.

See also https://github.com/openssl/openssl/pull/5431 in OpenSSL.

Bug: chromium:124610
Change-Id: I5e7a0c8c0f54a3f65cc324ad599a41883675f368
Reviewed-on: https://boringssl-review.googlesource.com/26164
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-02-22 22:28:15 +00:00
Daniel Hirche 36714fc8ee Remove redundant length-check in |ec_wNAF_mul|.
Right now, |g_wNAF| and |p_wNAF| are of same size.

This change makes GCC's "-Werror=logical-op" happy and adds a compile-time
assertion in case the initial size of either array ever changes.

Change-Id: I29e39a7a121a0a9d016c53da6b7c25675ddecbdc
Reviewed-on: https://boringssl-review.googlesource.com/26104
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-02-21 17:03:14 +00:00
Fred Gylys-Colwell 02d696f2a1 Delete |pthread_key_t| on dlclose.
When OPENSSL_DANGEROUS_RELEASE_PTHREAD_KEY is defined during the build,
this change adds a destructor function that is called when BoringSSL is
unloaded via |dlclose| or during process exit. Using |dlclose| with
BoringSSL is not supported and will leak memory, but this change allows
some code that is already doing it to survive longer.

Change-Id: Ifc6d6aae61ed0f15d61cd3dbb4ea9f8006e43dba
Reviewed-on: https://boringssl-review.googlesource.com/25784
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Reviewed-by: Fred Gylys-Colwell <fredgc@google.com>
2018-02-20 19:53:24 +00:00
Adam Langley ed626ec99b Merge NIAP and FIPS test suites.
When we do future FIPS or NIAP runs, we'll do everything. So no need for
a -niap option any longer.

Change-Id: I2c8b71951acca0734c1a15cfb6f61ec5ecee5884
Reviewed-on: https://boringssl-review.googlesource.com/26124
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-02-20 19:41:45 +00:00
David Benjamin 085955c567 Actually use the u64 cast.
The point was to remove the silly moduli.

Change-Id: I48c507c9dd1fc46e38e8991ed528b02b8da3dc1d
Reviewed-on: https://boringssl-review.googlesource.com/26044
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-02-16 20:02:56 +00:00
Steven Valdez f16cd4278f Add AES_128_CCM AEAD.
Change-Id: I830be64209deada0f24c3b6d50dc86155085c377
Reviewed-on: https://boringssl-review.googlesource.com/25904
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-02-16 15:57:27 +00:00
David Benjamin 78a832d793 Document RSAZ slightly better.
Better commit such details to comments before I forget them.

Change-Id: Ie36332235c692f4369413b4340a742b5ad895ce1
Reviewed-on: https://boringssl-review.googlesource.com/25984
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-02-15 18:14:04 +00:00
David Benjamin c03ecb93a2 Remove SSLv3_method and friends.
SSLv3_method, SSLv3_client_method, and SSLv3_server_method produce
SSL_CTXs which fail every handshake. They appear no longer necessary for
compatibility, so remove them.

SSLv3 is still accessible to callers who explicitly re-enable SSLv3 on a
TLS_method, but that will be removed completely later this year.
Meanwhile, clear out a weird hack we had here.

Update-Note: I believe there are no more callers of these functions. Any
   that were were already non-functional as these methods haven't been
   unable to handshake for a while now.

Change-Id: I622f785b428ab0ceab77b5a9db05b2b0df28145a
Reviewed-on: https://boringssl-review.googlesource.com/26004
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-02-15 15:29:18 +00:00
David Benjamin 1bf2337fe1 Reject compressed ECDH coordinates in TLS.
We don't advertise compressed coordinates (and point format negotiation
was deprecated in TLS 1.3), so reject them. Both Internet Explorer and
Firefox appear to reject them already.

Later I hope to add an easier to use ECDH API that acts on bytes, not
EC_POINT. This clears the way for that API to only accept uncompressed
coordinates. Compressed coordinates never got deployed over NIST curves,
for better or worse. At this point, there is no sense in changing that
as new protocols should use curve25519.

Change-Id: Id2f1be791ddcf155d596f4eb0b79351766c5cdab
Reviewed-on: https://boringssl-review.googlesource.com/26024
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-02-15 01:42:54 +00:00
Aaron Green 67968895b3 Remove unused strings.h #include from crypto/mem.c
crypto/mem.c #include's <strings.h>, but doesn't use call any functions
from it.

Change-Id: If60b31be7dd6b347bcb077a59825a557a2492081
Reviewed-on: https://boringssl-review.googlesource.com/25964
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-02-14 01:40:23 +00:00
David Benjamin 02cca1987b clang-format RSAZ C code.
Change-Id: I7fb9b06ec89ba11641454145708e157359b07cf0
Reviewed-on: https://boringssl-review.googlesource.com/25924
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2018-02-13 22:30:03 +00:00
David Benjamin 10443f5a6e Adjust comment on potential R^3 optimization.
It's doable, but a bit of effort due to the different radix.

Change-Id: Ibfa15c31bb37de930f155ee6d19551a2b6437073
Reviewed-on: https://boringssl-review.googlesource.com/25944
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2018-02-13 22:19:13 +00:00
Aaron Green 862e0d2e1b Add cpu-aarch64-fuchsia.c
Fuchsia/Zircon recently added support for exposing arm64 CPU features;
this CL uses the new system call to set OPENSSL_armcap_P.

Change-Id: I045dc0b58117afe6dae315a82bf9acfd8d99be1a
Reviewed-on: https://boringssl-review.googlesource.com/25865
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-02-13 20:12:47 +00:00
David Benjamin 638a408cd2 Add a tuned variable-time P-256 multiplication function.
This reuses wnaf.c's window scheduling, but has access to the tuned
field arithemetic and pre-computed base point table. Unlike wnaf.c, we
do not make the points affine as it's not worth it for a single table.
(We already precomputed the base point table.)

Annoyingly, 32-bit x86 gets slower by a bit, but the other platforms are
faster. My guess is that that the generic code gets to use the
bn_mul_mont assembly and the compiler, faced with the increased 32-bit
register pressure and the extremely register-poor x86, is making
bad decisions on the otherwise P-256-tuned C code. The three platforms
that see much larger gains are significantly more important than 32-bit
x86 at this point, so go with this change.

armv7a (Nexus 5X) before/after [+14.4%]:
Did 2703 ECDSA P-256 verify operations in 5034539us (536.9 ops/sec)
Did 3127 ECDSA P-256 verify operations in 5091379us (614.2 ops/sec)

aarch64 (Nexus 5X) before/after [+9.2%]:
Did 6783 ECDSA P-256 verify operations in 5031324us (1348.2 ops/sec)
Did 7410 ECDSA P-256 verify operations in 5033291us (1472.2 ops/sec)

x86 before/after [-2.7%]:
Did 8961 ECDSA P-256 verify operations in 10075901us (889.3 ops/sec)
Did 8568 ECDSA P-256 verify operations in 10003001us (856.5 ops/sec)

x86_64 before/after [+8.6%]:
Did 29808 ECDSA P-256 verify operations in 10008662us (2978.2 ops/sec)
Did 32528 ECDSA P-256 verify operations in 10057137us (3234.3 ops/sec)

Change-Id: I5fa643149f5bfbbda9533e3008baadfee9979b93
Reviewed-on: https://boringssl-review.googlesource.com/25684
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-02-12 22:00:48 +00:00
David Benjamin 6e4ff114fc Merge Intel copyright notice into standard
This was done by OpenSSL with the kind permission of Intel. This change
is imported from upstream's commit
dcf6e50f48e6bab92dcd2dacb27fc17c0de34199.

Change-Id: Ie8d3b700cd527a6e8cf66e0728051b2acd8cc6b9
Reviewed-on: https://boringssl-review.googlesource.com/25588
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-02-12 21:44:27 +00:00
David Benjamin f6cf8bbc84 Sync up AES assembly.
This syncs up with OpenSSL master as of
50ea9d2b3521467a11559be41dcf05ee05feabd6. The non-license non-spelling
changes are CFI bits, which were added in upstream in
b84460ad3a3e4fcb22efaa0a8365b826f4264ecf.

Change-Id: I42280985f834d5b9133eacafc8ff9dbd2f0ea59a
Reviewed-on: https://boringssl-review.googlesource.com/25704
Reviewed-by: Adam Langley <agl@google.com>
2018-02-11 01:03:17 +00:00
David Benjamin 6dc994265e Sync up some perlasm license headers and easy fixes.
These files are otherwise up-to-date with OpenSSL master as of
50ea9d2b3521467a11559be41dcf05ee05feabd6, modulo a couple of spelling
fixes which I've imported.

I've also reverted the same-line label and instruction patch to
x86_64-mont*.pl. The new delocate parser handles that fine.

Change-Id: Ife35c671a8104c3cc2fb6c5a03127376fccc4402
Reviewed-on: https://boringssl-review.googlesource.com/25644
Reviewed-by: Adam Langley <agl@google.com>
2018-02-11 01:00:35 +00:00
David Benjamin 0f4f6c2e02 p256-x86_64.pl: add CFI directives.
(Imported from upstream's 86e112788e2ab9740c0cabf3ae4b1eb67b386bab.)

Change-Id: I1ba11e47f1ec9846ea00c738db737c35ce7aaab1
Reviewed-on: https://boringssl-review.googlesource.com/25587
Reviewed-by: Adam Langley <agl@google.com>
2018-02-11 00:53:41 +00:00
David Benjamin 02808ddcaa p256-x86_64-asm.pl: Win64 SEH face-lift.
This imports 384e6de4c7e35e37fb3d6fbeb32ddcb5eb0d3d3f and
79ca382d4762c58c4b92fceb4e202e90c71292ae from upstream.

Differences from upstream:

- We've removed a number of unused functions.

- We never imported 3ff08e1dde56747011a702a9a5aae06cfa8ae5fc, which was
  to give the assembly control over the memory layout in the tables. So
  our "gather" is "select" (which is implemented the same because the
  memory layout never did change) and our "scatter" is in C.

Change-Id: I90d4a17da9f5f693f4dc4706887dec15f010071b
Reviewed-on: https://boringssl-review.googlesource.com/25586
Reviewed-by: Adam Langley <agl@google.com>
2018-02-11 00:52:23 +00:00
David Benjamin 05640fd373 p256-x86_64-asm.pl: Add OpenSSL copyright
As of upstream's 6aa36e8e5a062e31543e7796f0351ff9628832ce, the
corresponding file in OpenSSL has both an Intel and OpenSSL copyright
blocks.  To properly sync up with OpenSSL, use the OpenSSL copyright
block and our version of the Intel copyright block.

Change-Id: I4dc072a11390a54d0ce38ec0b8893e48f52638de
Reviewed-on: https://boringssl-review.googlesource.com/25585
Reviewed-by: Adam Langley <agl@google.com>
2018-02-11 00:50:19 +00:00
David Benjamin 8ae929f1e9 p256-x86_64.pl: update commentary with before-after performance data.
(Imported from upstream's f0e6871df2e4641d0532e8f99d26c7a6454d03df.)

Change-Id: I2b799ff2a133839b0fe9d9093799d3a86045d709
Reviewed-on: https://boringssl-review.googlesource.com/25584
Reviewed-by: Adam Langley <agl@google.com>
2018-02-11 00:49:54 +00:00
Daniel Hirche d25e62e772 Return NULL instead of zero in |bn_resized_from_ctx|.
Change-Id: I5fc029ceddfa60b2ccc97c138b94c1826f6d75fa
Reviewed-on: https://boringssl-review.googlesource.com/25844
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-02-10 23:10:54 +00:00
David Benjamin 38c20fe8d5 Fix threading issues with RSA freeze_private_key.
OpenSSL's RSA API is poorly designed and does not have a single place to
properly initialize the key. See
https://github.com/openssl/openssl/issues/5158.

To workaround this flaw, we must lazily instantiate pre-computed
Montgomery bits with locking. This is a ton of complexity. More
importantly, it makes it very difficult to implement RSA without side
channels. The correct in-memory representation of d, dmp1, and dmq1
depend on n, p, and q, respectively. (Those values have private
magnitudes and must be sized relative to the respective moduli.)

08805fe279 attempted to fix up the various
widths under lock, when we set up BN_MONT_CTX. However, this introduces
threading issues because other threads may access those exposed
components (RSA_get0_* also count as exposed for these purposes because
they are get0 functions), while a private key operation is in progress.

Instead, we do the following:

- There is no actual need to minimize n, p, and q, but we have minimized
  copies in the BN_MONT_CTXs, so use those.

- Store additional copies of d, dmp1, and dmq1, at the cost of more
  memory used. These copies have the correct width and are private,
  unlike d, dmp1, and dmq1 which are sadly exposed. Fix private key
  operations to use them.

- Move the frozen bit out of rsa->flags, as that too was historically
  accessible without locking.

(Serialization still uses the original BIGNUMs, but the RSAPrivateKey
serialization format already inherently leaks the magnitude, so this
doesn't matter.)

Change-Id: Ia3a9b0629f8efef23abb30bfed110d247d1db42f
Reviewed-on: https://boringssl-review.googlesource.com/25824
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-02-09 22:17:11 +00:00
Adam Langley 61dedd6815 Don't crash when failing to set affine coordinates when the generator is missing.
If a caller is in the process on constructing an arbitrary |EC_GROUP|,
and they try to create an |EC_POINT| to set as the generator which is
invalid, we would previously crash.

Change-Id: Ida91354257a02bd56ac29ba3104c9782b8d70f6b
Reviewed-on: https://boringssl-review.googlesource.com/25764
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-02-07 23:08:17 +00:00
David Benjamin 376f3f1727 Add BN_count_low_zero_bits.
This allows a BIGNUM consumer to avoid messing around with bn->d and
bn->top/width.

Bug: 232
Change-Id: I134cf412fef24eb404ff66c84831b4591d921a17
Reviewed-on: https://boringssl-review.googlesource.com/25484
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-02-06 03:10:54 +00:00
David Benjamin d24cb22c55 Make BN_cmp constant-time.
This is a bit easier to read than BN_less_than_consttime when we must do
>= or <=, about as much work to compute, and lots of code calls BN_cmp
on secret data. This also, by extension, makes BN_cmp_word
constant-time.

BN_equal_consttime is probably a little more efficient and is perfectly
readable, so leave that one around.

Change-Id: Id2e07fe312f01cb6fd10a1306dcbf6397990cf13
Reviewed-on: https://boringssl-review.googlesource.com/25444
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-02-06 03:10:44 +00:00
David Benjamin ac383701b7 Simplify bn_mul_part_recursive.
The loop and the outermost special-cases are basically the same.

Change-Id: I5e3ca60ad9a04efa66b479eebf8c3637a11cdceb
Reviewed-on: https://boringssl-review.googlesource.com/25406
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-02-06 03:04:04 +00:00
David Benjamin 6488f4e2ba Fix over-allocated bounds on bn_mul_part_recursive.
Same mistake as bn_mul_recursive.

Change-Id: I2374d37e5da61c82ccb1ad79da55597fa3f10640
Reviewed-on: https://boringssl-review.googlesource.com/25405
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-02-06 02:57:55 +00:00
David Benjamin 2bf82975ad Make bn_mul_part_recursive constant-time.
This follows similar lines as the previous cleanups and fixes the
documentation of the preconditions.

And with that, RSA private key operations, provided p and q have the
same bit length, should be constant time, as far as I know. (Though I'm
sure I've missed something.)

bn_cmp_part_words and bn_cmp_words are no longer used and deleted.

Bug: 234
Change-Id: Iceefa39f57e466c214794c69b335c4d2c81f5577
Reviewed-on: https://boringssl-review.googlesource.com/25404
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-02-06 02:51:54 +00:00
David Benjamin 6541308ff3 Don't allocate oversized arrays for bn_mul_recursive.
The power of two computations here were extremely confusing and one of
the comments mixed && and ||. Remove the cached k = j + j value.
Optimizing the j*8, j*8, j*2, and j*4 multiplications is the compiler's
job. If it doesn't manage it, it was only a couple shifts anyway.

With that fixed, it becomes easier to tell that rr was actaully
allocated twice as large as necessary. I suspect rr is also
incorrectly-allocated in the bn_mul_part_recursive case, but I'll wait
until I've checked that function over first. (The array size
documentation on the other bn_{mul,sqr}_recursive functions have had
mistakes before.)

Change-Id: I298400b988e3bd108d01d6a7c8a5b262ddf81feb
Reviewed-on: https://boringssl-review.googlesource.com/25364
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-02-06 02:51:44 +00:00
David Benjamin 34a2c5e476 Make bn_mul_recursive constant-time.
I left the input length as int because the calling convention passes
these messy deltas around. This micro-optimization is almost certainly
pointless, but bn_sub_part_words is written in assembly, so I've left it
alone for now. The documented preconditions were also all completely
wrong, so I've fixed them. We actually only call them for even tighter
bounds (one of dna or dnb is 0 and the other is 0 or -1), at least
outside bn_mul_part_recursive which I still need to read through.

This leaves bn_mul_part_recursive, which is reachable for RSA keys which
are not a power of two in bit width.

The first iteration of this had an uncaught bug, so I added a few more
aggressive tests generated with:

  A = 0x...
  B = 0x...

  # Chop off 0, 1 and > 1 word for both 32 and 64-bit.
  for i in (0, 1, 2, 4):
    for j in (0, 1, 2, 4):
      a = A >> (32*i)
      b = B >> (32*j)
      p = a * b
      print "Product = %x" % p
      print "A = %x" % a
      print "B = %x" % b
      print

Bug: 234
Change-Id: I72848d992637c0390cdd3c4f81cb919393b59eb8
Reviewed-on: https://boringssl-review.googlesource.com/25344
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-02-06 02:51:34 +00:00
David Benjamin b01dd1c622 Make bn_sqr_recursive constant-time.
We still need BN_mul and, in particular, bn_mul_recursive will either
require bn_abs_sub_words be generalized or that we add a parallel
bn_abs_sub_part_words, but start with the easy one.

While I'm here, simplify the i and j mess in here. It's patterned after
the multiplication one, but can be much simpler.

Bug: 234
Change-Id: If936099d53304f2512262a1cbffb6c28ae30ccee
Reviewed-on: https://boringssl-review.googlesource.com/25325
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-02-06 02:47:34 +00:00
David Benjamin 3b3e12d81e Simplify BN_bn2bin_padded.
There is no more need for the "constant-time" reading beyond bn->top. We
can write the bytes out naively because RSA computations no longer call
bn_correct_top/bn_set_minimal_width.

Specifically, the final computation is a BN_mod_mul_montgomery to remove
the blinding, and that keeps the sizes correct.

Bug: 237
Change-Id: I6e90d81c323b644e179d899f411479ea16deab98
Reviewed-on: https://boringssl-review.googlesource.com/25324
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-02-06 02:41:38 +00:00
David Benjamin be837402a9 Make the rest of RSA CRT constant-time.
Alas, the existence of RSA keys with q > p is obnoxious, but we can
canonicalize it away. To my knowledge, the remaining leaks in RSA are:

- Key generation. This is kind of hopelessly non-constant-time but
  perhaps deserves a more careful ponder. Though hopefully it does not
  come in at a measurable point for practical purposes.

- Private key serialization. RSAPrivateKey inherently leaks the
  magnitudes of d, dmp1, dmq1, and iqmp. This is unavoidable but
  hopefully does not come in at a measurable point for practical
  purposes.

- If p and q have different word widths, we currently fall back to the
  variable-time BN_mod rather than Montgomery reduction at the start of
  CRT. I can think of ways to apply Montgomery reduction, but it's
  probably better to deny CRT to such keys, if not reject them outright.

- bn_mul_fixed and bn_sqr_fixed which affect the Montgomery
  multiplication bn_mul_mont-less configurations, as well as the final
  CRT multiplication. We should fix this.

Bug: 233
Change-Id: I8c2ecf8f8ec104e9f26299b66ac8cbb0cad04616
Reviewed-on: https://boringssl-review.googlesource.com/25263
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-02-06 02:40:34 +00:00
David Benjamin 150ad30d28 Split BN_uadd into a bn_uadd_fixed.
This is to be used in constant-time RSA CRT.

Bug: 233
Change-Id: Ibade5792324dc6aba38cab6971d255d41fb5eb91
Reviewed-on: https://boringssl-review.googlesource.com/25286
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-02-06 02:39:45 +00:00
David Benjamin 5b10def1cf Compute mont->RR in constant-time.
Use the now constant-time modular arithmetic functions.

Bug: 236
Change-Id: I4567d67bfe62ca82ec295f2233d1a6c9b131e5d2
Reviewed-on: https://boringssl-review.googlesource.com/25285
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-02-06 01:40:24 +00:00
David Benjamin 6f564afbdd Make BN_mod_*_quick constant-time.
As the EC code will ultimately want to use these in "words" form by way
of EC_FELEM, and because it's much easier, I've implement these as
low-level words-based functions that require all inputs have the same
width. The BIGNUM versions which RSA and, for now, EC calls are
implemented on top of that.

Unfortunately, doing such things in constant-time and accounting for
undersized inputs requires some scratch space, and these functions don't
take BN_CTX. So I've added internal bn_mod_*_quick_ctx functions that
take a BN_CTX and the old functions now allocate a bit unnecessarily.
RSA only needs lshift (for BN_MONT_CTX) and sub (for CRT), but the
generic EC code wants add as well.

The generic EC code isn't even remotely constant-time, and I hope to
ultimately use stack-allocated EC_FELEMs, so I've made the actual
implementations here implemented in "words", which is much simpler
anyway due to not having to take care of widths.

I've also gone ahead and switched the EC code to these functions,
largely as a test of their performance (an earlier iteration made the EC
code noticeably slower). These operations are otherwise not
performance-critical in RSA.

The conversion from BIGNUM to BIGNUM+BN_CTX should be dropped by the
static linker already, and the unused BIGNUM+BN_CTX functions will fall
off when EC_FELEM happens.

Update-Note: BN_mod_*_quick bounce on malloc a bit now, but they're not
    really used externally. The one caller I found was wpa_supplicant
    which bounces on malloc already. They appear to be implementing
    compressed coordinates by hand? We may be able to convince them to
    call EC_POINT_set_compressed_coordinates_GFp.

Bug: 233, 236
Change-Id: I2bf361e9c089e0211b97d95523dbc06f1168e12b
Reviewed-on: https://boringssl-review.googlesource.com/25261
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-02-06 01:16:04 +00:00
David Benjamin eaa80b7069 Remove DSA k+q kludge.
With fixed-width BIGNUMs, this is no longer a concern. With this CL, I
believe we now no longer call BN_num_bits on BIGNUMs with secret
magnitude.

Of course, DSA then turns around and calls the variable-time BN_mod
immediately afterwards anyway. But the DSA is deprecated and doomed to
be removed someday anyway.

Change-Id: Iac1dab22aa51c0e7f5ca0f7f44a026a242a4eaa2
Reviewed-on: https://boringssl-review.googlesource.com/25284
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-02-06 00:51:54 +00:00
David Benjamin 08805fe279 Normalize RSA private component widths.
d, dmp1, dmq1, and iqmp have private magnitudes. This is awkward because
the RSAPrivateKey serialization leaks the magnitudes. Do the best we can
and fix them up before any RSA operations.

This moves the piecemeal BN_MONT_CTX_set_locked into a common function
where we can do more complex canonicalization on the keys.  Ideally this
would be done on key import, but the exposed struct (and OpenSSL 1.1.0's
bad API design) mean there is no single point in time when key import is
finished.

Also document the constraints on RSA_set0_* functions. (These
constraints aren't new. They just were never documented before.)

Update-Note: If someone tried to use an invalid RSA key where d >= n,
   dmp1 >= p, dmq1 >= q, or iqmp >= p, this may break. Such keys would not
   have passed RSA_check_key, but it's possible to manually assemble
   keys that bypass it.
Bug: 232
Change-Id: I421f883128952f892ac0cde0d224873a625f37c5
Reviewed-on: https://boringssl-review.googlesource.com/25259
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-02-05 23:58:53 +00:00
David Benjamin c7b6e0a664 Don't leak widths in bn_mod_mul_montgomery_fallback.
The fallback functions still themselves leak, but I've left TODOs there.

This only affects BN_mod_mul_montgomery on platforms where we don't use
the bn_mul_mont assembly, but BN_mul additionally affects the final
multiplication in RSA CRT.

Bug: 232
Change-Id: Ia1ae16162c38e10c056b76d6b2afbed67f1a5e16
Reviewed-on: https://boringssl-review.googlesource.com/25260
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-02-05 23:57:03 +00:00
David Benjamin 08d774a45f Remove some easy bn_set_minimal_width calls.
Functions that deserialize from bytes and Montgomery multiplication have
no reason to minimize their inputs.

Bug: 232
Change-Id: I121cc9b388033d684057b9df4ad0c08364849f58
Reviewed-on: https://boringssl-review.googlesource.com/25258
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-02-05 23:47:14 +00:00
David Benjamin 09633cc34e Rename bn->top to bn->width.
This has no behavior change, but it has a semantic one. This CL is an
assertion that all BIGNUM functions tolerate non-minimal BIGNUMs now.
Specifically:

- Functions that do not touch top/width are assumed to not care.

- Functions that do touch top/width will be changed by this CL. These
  should be checked in review that they tolerate non-minimal BIGNUMs.

Subsequent CLs will start adjusting the widths that BIGNUM functions
output, to fix timing leaks.

Bug: 232
Change-Id: I3a2b41b071f2174452f8d3801bce5c78947bb8f7
Reviewed-on: https://boringssl-review.googlesource.com/25257
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-02-05 23:44:24 +00:00
David Benjamin 23223ebbc1 Tidy BN_bn2hex and BN_print with non-minimal inputs.
These actually work as-is, but BN_bn2hex allocates more memory than
necessary, and we may as well skip the unnecessary words where we can.
Also add a test for this.

Bug: 232
Change-Id: Ie271fe9f3901d00dd5c3d7d63c1776de81a10ec7
Reviewed-on: https://boringssl-review.googlesource.com/25304
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-02-05 23:18:33 +00:00
David Benjamin cb4e300f17 Store EC field and orders in minimal form.
The order (and later the field) are used to size stack-allocated fixed
width word arrays. They're also entirely public, so this is fine.

Bug: 232
Change-Id: Ie98869cdbbdfea92dcad64a300f7e0b47bef6bf2
Reviewed-on: https://boringssl-review.googlesource.com/25256
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-02-05 23:17:34 +00:00
David Benjamin 226b4b51b5 Make the rest of BIGNUM accept non-minimal values.
Test this by re-running bn_tests.txt tests a lot. For the most part,
this was done by scattering bn_minimal_width or bn_correct_top calls as
needed. We'll incrementally tease apart the functions that need to act
on non-minimal BIGNUMs in constant-time.

BN_sqr was switched to call bn_correct_top at the end, rather than
sample bn_minimal_width, in anticipation of later splitting it into
BN_sqr (for calculators) and BN_sqr_fixed (for BN_mod_mul_montgomery).

BN_div_word also uses bn_correct_top because it calls BN_lshift so
officially shouldn't rely on BN_lshift returning something
minimal-width, though I expect we'd want to split off a BN_lshift_fixed
than change that anyway?

The shifts sample bn_minimal_width rather than bn_correct_top because
they all seem to try to be very clever around the bit width. If we need
constant-time versions of them, we can adjust them later.

Bug: 232
Change-Id: Ie17b39034a713542dbe906cf8954c0c5483c7db7
Reviewed-on: https://boringssl-review.googlesource.com/25255
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-02-05 23:05:34 +00:00
Adam Langley 45210dd4e2 Tidy up |ec_GFp_simple_point2oct| and friend.
(Just happened to see these as I went by.)

Change-Id: I348b163e6986bfca8b58e56885c35a813efe28f6
Reviewed-on: https://boringssl-review.googlesource.com/25725
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-02-05 04:40:59 +00:00
Adam Langley 2044181e01 Set output point to the generator when not on the curve.
Processing off-curve points is sufficiently dangerous to worry about
code that doesn't check the return value of
|EC_POINT_set_affine_coordinates| and |EC_POINT_oct2point|. While we
have integrated on-curve checks into these functions, code that ignores
the return value will still be able to work with an invalid point
because it's already been installed in the output by the time the check
is done.

Instead, in the event of an off-curve point, set the output point to the
generator, which is certainly on the curve and hopefully safe.

Change-Id: Ibc73dceb2d8d21920e07c4f6def2c8249cb78ca0
Reviewed-on: https://boringssl-review.googlesource.com/25724
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-02-05 02:03:29 +00:00
Adam Langley a312391050 cavp_tlskdf_test.cc: include errno.h since errno is referenced.
Change-Id: Id2d9923b3f0984be995a8057f60e714946f0f0b2
Reviewed-on: https://boringssl-review.googlesource.com/25664
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-02-02 22:50:27 +00:00
Adam Langley 091b455f09 Support running CAVP tests on an Android device.
This change allows run_cavp.go to execute tests on a connected Android
device and collect the results.

Change-Id: Ica83239c58d83907b82c591c4873a3de4ba0b3c0
Reviewed-on: https://boringssl-review.googlesource.com/25604
Reviewed-by: David Benjamin <davidben@google.com>
2018-02-02 22:34:17 +00:00
Adam Langley 472ba2c2dd Require that Ed25519 |s| values be < order.
https://tools.ietf.org/html/rfc8032#section-5.1.7 adds this requirement
to prevent signature malleability.

Change-Id: Iac9a3649d97fc69e6efb4aea1ab1e002768fadc9
Reviewed-on: https://boringssl-review.googlesource.com/25564
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-02-02 20:45:08 +00:00
David Benjamin f4b708cc1e Add a function which folds BN_MONT_CTX_{new,set} together.
These empty states aren't any use to either caller or implementor.

Change-Id: If0b748afeeb79e4a1386182e61c5b5ecf838de62
Reviewed-on: https://boringssl-review.googlesource.com/25254
Reviewed-by: Adam Langley <agl@google.com>
2018-02-02 20:23:25 +00:00
David Benjamin feffb87168 Make BN_bn2bin_padded work with non-minimal BIGNUMs.
Checking the excess words for zero doesn't need to be in constant time,
but it's free. BN_bn2bin_padded is a little silly as read_word_padded
only exists to work around bn->top being minimal. Once non-minimal
BIGNUMs are turned on and the RSA code works right, we can simplify
BN_bn2bin_padded.

Bug: 232
Change-Id: Ib81e30ca1e5a8ea90ab3278bf4ded219bac481ac
Reviewed-on: https://boringssl-review.googlesource.com/25253
Reviewed-by: Adam Langley <agl@google.com>
2018-02-02 20:16:50 +00:00
David Benjamin 385e4e9d98 Handle directive arguments with * in them.
Some of the CFI directives from upstream include expressions such as:

   .cfi_adjust_cfa_offset 32*5+8

(Also the latest version of peg moves the go generate line to
delocate.peg.go.)

Change-Id: I21bdf9ae44f81e4eca7b3565c4581a670f621a80
Reviewed-on: https://boringssl-review.googlesource.com/25624
Reviewed-by: Adam Langley <agl@google.com>
2018-02-02 19:59:06 +00:00
David Benjamin 6c41465548 Remove redundant bn->top computation.
One less to worry about.

Bug: 232
Change-Id: Ib7d38e18fee02590088d76363e17f774cfefa59b
Reviewed-on: https://boringssl-review.googlesource.com/25252
Reviewed-by: Adam Langley <agl@google.com>
2018-02-02 18:54:09 +00:00
David Benjamin 7979dbede2 Use bn_resize_words in BN_from_montgomery_word.
Saves a bit of work, and we get a width sanity-check.

Bug: 232
Change-Id: I1c6bc376c9d8aaf60a078fdc39f35b6f44a688c6
Reviewed-on: https://boringssl-review.googlesource.com/25251
Reviewed-by: Adam Langley <agl@google.com>
2018-02-02 18:52:49 +00:00
David Benjamin 76ce04bec8 Fix up BN_MONT_CTX_set with non-minimal values.
Give a non-minimal modulus, there are two possible values of R we might
pick: 2^(BN_BITS2 * width) or 2^(BN_BITS2 * bn_minimal_width).
Potentially secret moduli would make the former attractive and things
might even work, but our only secret moduli (RSA) have public bit
widths. It's more cases to test and the usual BIGNUM invariant is that
widths do not affect numerical output.

Thus, settle on minimizing mont->N for now. With the top explicitly made
minimal, computing |lgBigR| is also a little simpler.

This CL also abstracts out the < R check in the RSA code, and implements
it in a width-agnostic way.

Bug: 232
Change-Id: I354643df30530db7866bb7820e34241d7614f3c2
Reviewed-on: https://boringssl-review.googlesource.com/25250
Reviewed-by: Adam Langley <agl@google.com>
2018-02-02 18:52:15 +00:00
David Benjamin 0758b6837e Reject negative numbers in BN_{mod_mul,to,from}_montgomery.
These functions already require their inputs to be reduced mod N (or, in
some cases, bounded by R or N*R), so negative numbers are nonsense.  The
code still attempted to account for them by working on the absolute
value and fiddling with the sign bit. (The output would be in range (-N,
N) instead of [0, N).)

This complicates relaxing bn_correct_top because bn_correct_top is also
used to prevent storing a negative zero. Instead, just reject negative
inputs.

Upgrade-Note: These functions are public API, so some callers may
    notice. Code search suggests there is only one caller outside
    BoringSSL, and it looks fine.

Bug: 232
Change-Id: Ieba3acbb36b0ff6b72b8ed2b14882ec9b88e4665
Reviewed-on: https://boringssl-review.googlesource.com/25249
Reviewed-by: Adam Langley <agl@google.com>
2018-02-02 18:44:54 +00:00
David Benjamin 9a5bfc0350 Tidy up BN_mod_mul_montgomery.
This matches bn_mod_mul_montgomery_small and removes a bit of
unnecessary stuttering.

Change-Id: Ife249c6e8754aef23c144dbfdea5daaf7ed9f48a
Reviewed-on: https://boringssl-review.googlesource.com/25248
Reviewed-by: Adam Langley <agl@google.com>
2018-02-02 18:44:01 +00:00
David Benjamin 2ccdf584aa Factor out BN_to_montgomery(1) optimization.
This cuts down on a duplicated place where we mess with bn->top. It also
also better abstracts away what determines the value of R.

(I ordered this wrong and rebasing will be annoying. Specifically, the
question is what happens if the modulus is non-minimal. In
https://boringssl-review.googlesource.com/c/boringssl/+/25250/, R will
be determined by the stored width of mont->N, so we want to use mont's
copy of the modulus. Though, one way or another, the important part is
that it's inside the Montgomery abstraction.)

Bug: 232
Change-Id: I74212e094c8a47f396b87982039e49048a130916
Reviewed-on: https://boringssl-review.googlesource.com/25247
Reviewed-by: Adam Langley <agl@google.com>
2018-02-02 18:42:39 +00:00
David Benjamin dc8b1abb75 Do RSA sqrt(2) business in BIGNUM.
This is actually a bit more complicated (the mismatching widths cases
will never actually happen in RSA), but it's easier to think about and
removes more width-sensitive logic.

Bug: 232
Change-Id: I85fe6e706be1f7d14ffaf587958e930f47f85b3c
Reviewed-on: https://boringssl-review.googlesource.com/25246
Reviewed-by: Adam Langley <agl@google.com>
2018-02-02 18:32:32 +00:00
David Benjamin 43cf27e7d7 Add bn_copy_words.
This makes it easier going to and from non-minimal BIGNUMs and words
without worrying about the widths which are ultimately to become less
friendly.

Bug: 232
Change-Id: Ia57cb29164c560b600573c27b112ad9375a86aad
Reviewed-on: https://boringssl-review.googlesource.com/25245
Reviewed-by: Adam Langley <agl@google.com>
2018-02-02 18:24:39 +00:00
David Benjamin ad5cfdf541 Add initial support for non-minimal BIGNUMs.
Thanks to Andres Erbsen for extremely helpful suggestions on how finally
plug this long-standing hole!

OpenSSL BIGNUMs are currently minimal-width, which means they cannot be
constant-time. We'll need to either excise BIGNUM from RSA and EC or
somehow fix BIGNUM. EC_SCALAR and later EC_FELEM work will excise it
from EC, but RSA's BIGNUMs are more transparent.  Teaching BIGNUM to
handle non-minimal word widths is probably simpler.

The main constraint is BIGNUM's large "calculator" API surface. One
could, in theory, do arbitrary math on RSA components, which means all
public functions must tolerate non-minimal inputs. This is also useful
for EC; https://boringssl-review.googlesource.com/c/boringssl/+/24445 is
silly.

As a first step, fix comparison-type functions that were assuming
minimal BIGNUMs. I've also added bn_resize_words, but it is testing-only
until the rest of the library is fixed.

bn->top is now a loose upper bound we carry around. It does not affect
numerical results, only performance and secrecy. This is a departure
from the original meaning, and compiler help in auditing everything is
nice, so the final change in this series will rename bn->top to
bn->width. Thus these new functions are named per "width", not "top".

Looking further ahead, how are output BIGNUM widths determined? There's
three notions of correctness here:

1. Do I compute the right answer for all widths?

2. Do I handle secret data in constant time?

3. Does my memory usage not balloon absurdly?

For (1), a BIGNUM function must give the same answer for all input
widths. BN_mod_add_quick may assume |a| < |m|, but |a| may still be
wider than |m| by way of leading zeres. The simplest approach is to
write code in a width-agnostic way and rely on functions to accept all
widths. Where functions need to look at bn->d, we'll a few helper
functions to smooth over funny widths.

For (2), (1) is little cumbersome. Consider constant-time modular
addition. A sane type system would guarantee input widths match. But C
is weak here, and bifurcating the internals is a lot of work. Thus, at
least for now, I do not propose we move RSA's internal computation out
of BIGNUM. (EC_SCALAR/EC_FELEM are valuable for EC because we get to
stack-allocate, curves were already specialized, and EC only has two
types with many operations on those types. None of these apply to RSA.
We've got numbers mod n, mod p, mod q, and their corresponding
exponents, each of which is used for basically one operation.)

Instead, constant-time BIGNUM functions will output non-minimal widths.
This is trivial for BN_bin2bn or modular arithmetic. But for BN_mul,
constant-time[*] would dictate r->top = a->top + b->top. A calculator
repeatedly multiplying by one would then run out of memory.  Those we'll
split into a private BN_mul_fixed for crypto, leaving BN_mul for
calculators. BN_mul is just BN_mul_fixed followed by bn_correct_top.

[*] BN_mul is not constant-time for other reasons, but that will be
fixed separately.

Bug: 232
Change-Id: Ide2258ae8c09a9a41bb71d6777908d1c27917069
Reviewed-on: https://boringssl-review.googlesource.com/25244
Reviewed-by: Adam Langley <agl@google.com>
2018-02-02 18:03:46 +00:00
David Benjamin 884086e0e2 Remove x86_64 x25519 assembly.
Now that we have 64-bit C code, courtesy of fiat-crypto, the tradeoff
for carrying the assembly changes:

Assembly:
Did 16000 Curve25519 base-point multiplication operations in 1059932us (15095.3 ops/sec)
Did 16000 Curve25519 arbitrary point multiplication operations in 1060023us (15094.0 ops/sec)

fiat64:
Did 39000 Curve25519 base-point multiplication operations in 1004712us (38817.1 ops/sec)
Did 14000 Curve25519 arbitrary point multiplication operations in 1006827us (13905.1 ops/sec)

The assembly is still about 9% faster than fiat64, but fiat64 gets to
use the Ed25519 tables for the base point multiplication, so overall it
is actually faster to disable the assembly:

>>> 1/(1/15094.0 + 1/15095.3)
7547.324986004976
>>> 1/(1/38817.1 + 1/13905.1)
10237.73016319501

(At the cost of touching a 30kB table.)

The assembly implementation is no longer pulling its weight. Remove it
and use the fiat code in all build configurations.

Change-Id: Id736873177d5568bb16ea06994b9fcb1af104e33
Reviewed-on: https://boringssl-review.googlesource.com/25524
Reviewed-by: Adam Langley <agl@google.com>
2018-02-01 21:44:58 +00:00
David Benjamin fa65113400 Push an error if custom private keys fail.
The private key callback may not push one of its own (it's possible to
register a custom error library and whatnot, but this is tedious). If
the callback does not push any, we report SSL_ERROR_SYSCALL. This is not
completely wrong, as "syscall" really means "I don't know, something you
gave me, probably the BIO, failed so I assume you know what happened",
but most callers just check errno. And indeed cert_cb pushes its own
error, so this probably should as well.

Update-Note: Custom private key callbacks which push an error code on
    failure will report both that error followed by
    SSL_R_PRIVATE_KEY_OPERATION_FAILED. Callbacks which did not push any
    error will switch from SSL_ERROR_SYSCALL to SSL_ERROR_SSL with
    SSL_R_PRIVATE_KEY_OPERATION_FAILED.

Change-Id: I7e90cd327fe0cbcff395470381a3591364a82c74
Reviewed-on: https://boringssl-review.googlesource.com/25544
Reviewed-by: Adam Langley <agl@google.com>
2018-02-01 21:43:42 +00:00
David Benjamin 48669209b7 Fix fuzzer mode suppressions.
All the patterns need to account for a possible "-Split" version now.

Change-Id: Ie1b38ce10777d61d70a4d5a8bb2d44cdc98e4bfb
Reviewed-on: https://boringssl-review.googlesource.com/25504
Reviewed-by: Adam Langley <agl@google.com>
2018-01-31 22:57:51 +00:00
Adam Langley ddb57cfb51 Add tests for split handshakes.
This change adds a couple of focused tests to ssl_test.cc, but also
programmically duplicates many runner tests in a split-handshake mode.

Change-Id: I9dafc8a394581e5daf1318722e1015de82117fd9
Reviewed-on: https://boringssl-review.googlesource.com/25388
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-01-31 22:33:42 +00:00
Adam Langley 3fe8fa74ac Add initial, experimental support for split handshakes.
Split handshakes allows the handshaking of a TLS connection to be
performed remotely. This encompasses not just the private-key and ticket
operations – support for that was already available – but also things
such as selecting the certificates and cipher suites.

The the comment block in ssl.h for details. This is highly experimental
and will change significantly before its settled.

Change-Id: I337bdfa4c3262169e9b79dd4e70b57f0d380fcad
Reviewed-on: https://boringssl-review.googlesource.com/25387
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2018-01-31 22:24:17 +00:00
Steven Valdez 7e5dd25d47 Remove draft22 and experiment2.
Change-Id: I2486dc810ea842c534015fc04917712daa26cfde
Update-Note: Now that tls13_experiment2 is gone, the server should remove the set_tls13_variant call. To avoid further churn, we'll make the server default for future variants to be what we'd like to deploy.
Reviewed-on: https://boringssl-review.googlesource.com/25104
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-01-31 18:07:53 +00:00
Nick Harper 3c034b2cf3 Add support for QUIC transport params.
This adds support for sending the quic_transport_parameters
(draft-ietf-quic-tls) in ClientHello and EncryptedExtensions, as well as
reading the value sent by the peer.

Bug: boringssl:224
Change-Id: Ied633f557cb13ac87454d634f2bd81ab156f5399
Reviewed-on: https://boringssl-review.googlesource.com/24464
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-01-30 23:54:40 +00:00
David Benjamin a62dbf88d8 Move OPENSSL_FALLTHROUGH to internal headers.
Having it in base.h pollutes the global namespace a bit and, in
particular, causes clang to give unhelpful suggestions in consuming
projects.

Change-Id: I6ca1a88bdd1701f0c49192a0df56ac0953c7067c
Reviewed-on: https://boringssl-review.googlesource.com/25464
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-29 18:17:57 +00:00
Matthew Braithwaite 5301c10c53 ssl_verify_peer_cert: implement |SSL_VERIFY_NONE| as advertised.
Since SSL{,_CTX}_set_custom_verify take a |mode| parameter that may be
|SSL_VERIFY_NONE|, it should do what it says on the tin, which is to
perform verification and ignore the result.

Change-Id: I0d8490111fb199c6b325cc167cf205316ecd4b49
Reviewed-on: https://boringssl-review.googlesource.com/25224
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-01-26 22:42:17 +00:00
Adam Langley e8d2439cd3 Expose ssl_session_serialize to libssl.
This function can serialise a session to a |CBB|.

Change-Id: Icdb7aef900f03f947c3fa4625dd218401eb8eafc
Reviewed-on: https://boringssl-review.googlesource.com/25385
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-01-26 22:31:47 +00:00
David Benjamin 0ab3f0ca25 Notice earlier if a server echoes the TLS 1.3 compatibility session ID.
Mono's legacy TLS 1.0 stack, as a server, does not implement any form of
resumption, but blindly echos the ClientHello session ID in the
ServerHello for no particularly good reason.

This is invalid, but due to quirks of how our client checked session ID
equality, we only noticed on the second connection, rather than the
first. Flaky failures do no one any good, so break deterministically on
the first connection, when we realize something strange is going on.

Bug: chromium:796910
Change-Id: I1f255e915fcdffeafb80be481f6c0acb3c628846
Reviewed-on: https://boringssl-review.googlesource.com/25424
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2018-01-26 21:53:27 +00:00
Adam Langley 0ab86cf6f9 Require only that the nonce be strictly monotonic in TLS's AES-GCM
Previously we required that the calls to TLS's AES-GCM use an
incrementing nonce. This change relaxes that requirement so that nonces
need only be strictly monotonic (i.e. values can now be skipped). This
still meets the uniqueness requirements of a nonce.

Change-Id: Ib649a58bb93bf4dc0e081de8a5971daefffe9c70
Reviewed-on: https://boringssl-review.googlesource.com/25384
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-26 20:09:44 +00:00
Adam Langley 449a9e6a9e Make the gdb window larger.
Running can spawn gdb in an xterm, but the default xterm is rather
small. We could have everyone set their .Xdefaults, I presume, to solve
this, but very few people are running the old xterm these days.

Change-Id: I46eb3ff22f292eb44ce8c5124e83f1ab8aef9547
Reviewed-on: https://boringssl-review.googlesource.com/24846
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-26 19:59:23 +00:00
Adam Langley ab5a947d8e Reslice TLS AEAD setup.
This change reslices how the functions that generate the key block and
initialise the TLS AEADs are cut. This makes future changes easier.

Change-Id: I7e0f7327375301bed96f33c195b80156db83ce6d
Reviewed-on: https://boringssl-review.googlesource.com/24845
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-26 19:48:03 +00:00
Adam Langley c61b577197 Add some more utility functions to bytestring.
Change-Id: I7932258890b0b2226ff6841af45926e1b11979ba
Reviewed-on: https://boringssl-review.googlesource.com/24844
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-25 23:51:36 +00:00
David Benjamin 5a869aa3e8 Documentation typo.
Change-Id: Ie2e90cba642f416d3845171c96a3743846817657
Reviewed-on: https://boringssl-review.googlesource.com/25264
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-25 14:47:06 +00:00
David Benjamin 610cdbb102 Switch some ints to bools and Spans.
Change-Id: I505b29ae20fb660229900c4e046a0b1e5606d02c
Reviewed-on: https://boringssl-review.googlesource.com/25164
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2018-01-24 19:24:07 +00:00
David Benjamin 32b5940267 Don't leak the exponent bit width in BN_mod_exp_mont_consttime.
(See also https://github.com/openssl/openssl/pull/5154.)

The exponent here is one of d, dmp1, or dmq1 for RSA. This value and its
bit length are both secret. The only public upper bound is the bit width
of the corresponding modulus (RSA n, p, and q, respectively).

Although BN_num_bits is constant-time (sort of; see bn_correct_top notes
in preceding patch), this does not fix the root problem, which is that
the windows are based on the minimal bit width, not the upper bound. We
could use BN_num_bits(m), but BN_mod_exp_mont_consttime is public API
and may be called with larger exponents. Instead, use all top*BN_BITS2
bits in the BIGNUM. This is still sensitive to the long-standing
bn_correct_top leak, but we need to fix that regardless.

This may cause us to do a handful of extra multiplications for RSA keys
which are just above a whole number of words, but that is not a standard
RSA key size.

Change-Id: I5e2f12b70c303b27c597a7e513b7bf7288f7b0e3
Reviewed-on: https://boringssl-review.googlesource.com/25185
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-01-23 22:27:37 +00:00
David Benjamin cb1ad205d0 Use 51-bit limbs from fiat-crypto in 64-bit.
Our 64-bit performance was much lower than it could have been, since we
weren't using the 64-bit multipliers. Fortunately, fiat-crypto is
awesome, so this is just a matter of synthesizing new code and
integration work.

Functions without the signature fiat-crypto curly braces were written by
hand and warrant more review. (It's just redistributing some bits.)

These use the donna variants which takes (and proves) some of the
instruction scheduling from donna as that's significantly faster.
Glancing over things, I suspect but have not confirmed the gap is due to
this:
https://github.com/mit-plv/fiat-crypto/pull/295#issuecomment-356892413

Clang without OPENSSL_SMALL (ECDH omitted since that uses assembly and
is unaffected by this CL).

Before:
Did 105149 Ed25519 key generation operations in 5025208us (20924.3 ops/sec)
Did 125000 Ed25519 signing operations in 5024003us (24880.6 ops/sec)
Did 37642 Ed25519 verify operations in 5072539us (7420.7 ops/sec)

After:
Did 206000 Ed25519 key generation operations in 5020547us (41031.4 ops/sec)
Did 227000 Ed25519 signing operations in 5005232us (45352.5 ops/sec)
Did 69840 Ed25519 verify operations in 5004769us (13954.7 ops/sec)

Clang + OPENSSL_SMALL:

Before:
Did 68598 Ed25519 key generation operations in 5024629us (13652.4 ops/sec)
Did 73000 Ed25519 signing operations in 5067837us (14404.6 ops/sec)
Did 36765 Ed25519 verify operations in 5078684us (7239.1 ops/sec)
Did 74000 Curve25519 base-point multiplication operations in 5016465us (14751.4 ops/sec)
Did 45600 Curve25519 arbitrary point multiplication operations in 5034680us (9057.2 ops/sec)

After:
Did 117315 Ed25519 key generation operations in 5021860us (23360.9 ops/sec)
Did 126000 Ed25519 signing operations in 5003521us (25182.3 ops/sec)
Did 64974 Ed25519 verify operations in 5047790us (12871.8 ops/sec)
Did 134000 Curve25519 base-point multiplication operations in 5058946us (26487.7 ops/sec)
Did 86000 Curve25519 arbitrary point multiplication operations in 5050478us (17028.1 ops/sec)

GCC without OPENSSL_SMALL (ECDH omitted since that uses assembly and
is unaffected by this CL).

Before:
Did 35552 Ed25519 key generation operations in 5030756us (7066.9 ops/sec)
Did 38286 Ed25519 signing operations in 5001648us (7654.7 ops/sec)
Did 10584 Ed25519 verify operations in 5068158us (2088.3 ops/sec)

After:
Did 92158 Ed25519 key generation operations in 5024021us (18343.5 ops/sec)
Did 99000 Ed25519 signing operations in 5011908us (19753.0 ops/sec)
Did 31122 Ed25519 verify operations in 5069878us (6138.6 ops/sec)

Change-Id: Ic0c24d50b4ee2bbc408b94965e9d63319936107d
Reviewed-on: https://boringssl-review.googlesource.com/24805
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-01-23 22:25:07 +00:00
David Benjamin a1bc1ba47c Fix up CTR_DRBG_update comment.
The original comment was a little confusing. Also lowercase
CTR_DRBG_update to make our usual naming for static functions.

Bug: 227
Change-Id: I381c7ba12b788452d54520b7bc3b13bba8a59f2d
Reviewed-on: https://boringssl-review.googlesource.com/25204
Reviewed-by: Adam Langley <agl@google.com>
2018-01-23 22:19:03 +00:00
David Benjamin 8017cdde38 Make BN_num_bits_word constant-time.
(The BN_num_bits_word implementation was originally written by Andy
Polyakov for OpenSSL. See also
https://github.com/openssl/openssl/pull/5154.)

BN_num_bits, by way of BN_num_bits_word, currently leaks the
most-significant word of its argument via branching and memory access
pattern.

BN_num_bits is called on RSA prime factors in various places. These have
public bit lengths, but all bits beyond the high bit are secret. This
fully resolves those cases.

There are a few places where BN_num_bits is called on an input where
the bit length is also secret. The two left in BoringSSL are:

- BN_mod_exp_mont_consttime calls it on the RSA private exponent.

- The timing "fix" to add the order to k in DSA.

This does *not* fully resolve those cases as we still only look at the
top word. Today, that is guaranteed to be non-zero, but only because of
the long-standing bn_correct_top timing leak. Once that is fixed (I hope
to have patches soon), a constant-time BN_num_bits on such inputs must
count bits on each word.

Instead, those cases should not call BN_num_bits at all. The former uses
the bit width to pick windows, but it should be using the maximum bit
width. The next patch will fix this.  The latter is the same "fix" we
excised from ECDSA in a838f9dc7e.  That
should be excised from DSA after the bn_correct_top bug is fixed.

Thanks to Dinghao Wu, Danfeng Zhang, Shuai Wang, Pei Wang, and Xiao Liu
for reporting this issue.

Change-Id: Idc3da518cc5ec18bd8688b95f959b15300a57c14
Reviewed-on: https://boringssl-review.googlesource.com/25184
Reviewed-by: Adam Langley <agl@google.com>
2018-01-23 22:14:54 +00:00
David Benjamin b9f30bb6fe Unwind total_num from wNAF_mul.
The EC_POINTs are still allocated (for now), but everything else fits on
the stack nicely, which saves a lot of fiddling with cleanup and
allocations.

Change-Id: Ib8480737ecc97e6b40b2c05f217cd8d3dc82cb72
Reviewed-on: https://boringssl-review.googlesource.com/25150
Reviewed-by: Adam Langley <agl@google.com>
2018-01-23 22:04:58 +00:00
David Benjamin d86c0d2889 Pull the malloc out of compute_wNAF.
This is to simplify clearing unnecessary mallocs out of ec_wNAF_mul, and
perhaps to use it in tuned variable-time multiplication functions.

Change-Id: Ic390d2e8e20d0ee50f3643830a582e94baebba95
Reviewed-on: https://boringssl-review.googlesource.com/25149
Reviewed-by: Adam Langley <agl@google.com>
2018-01-23 21:53:58 +00:00
David Benjamin 6ca09409cc Always compute the maximum-length wNAF.
This cuts out another total_num-length array and simplifies things.
Leading zeros at the front of the schedule don't do anything, so it's
easier to just produce a fixed-length one. (I'm also hoping to
ultimately reuse this function in //third_party/fiat/p256.c and get the
best of both worlds for ECDSA verification; tuned field arithmetic
operations, precomputed table, and variable-time multiply.)

Change-Id: I771f4ff7dcfdc3ee0eff8d9038d6dc9a0be3d4e0
Reviewed-on: https://boringssl-review.googlesource.com/25148
Reviewed-by: Adam Langley <agl@google.com>
2018-01-23 21:51:25 +00:00
David Benjamin a42d7bee85 Reorganize curve25519.c slightly.
Adding 51-bit limbs will require two implementations of most of the
field operations. Group them together to make this more manageable. Also
move the representation-independent functions to the end.

Change-Id: I264e8ac64318a1d5fa72e6ad6f7ccf2f0a2c2be9
Reviewed-on: https://boringssl-review.googlesource.com/24804
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-01-23 21:42:14 +00:00
David Benjamin 0c1eafc6fe Add additional constants to make_curve25519_tables.py.
These are also constants that depend on the field representation.

Change-Id: I22333c099352ad64eb27fe15ffdc38c6ae7c07ff
Reviewed-on: https://boringssl-review.googlesource.com/24746
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-01-23 21:35:03 +00:00
David Benjamin 522ad7e8fc Use EC_SCALAR for compute_wNAF.
Note this switches from walking BN_num_bits to the full bit length of
the scalar. But that can only cause it to add a few extra zeros to the
front of the schedule, which r_is_at_infinity will skip over.

Change-Id: I91e087c9c03505566b68f75fb37dfb53db467652
Reviewed-on: https://boringssl-review.googlesource.com/25147
Reviewed-by: Adam Langley <agl@google.com>
2018-01-23 21:34:50 +00:00
David Benjamin 338eeb0c4f Remove r_is_inverted logic.
This appears to be pointless. Before, we would have a 50% chance of
doing an inversion at each non-zero bit but the first
(r_is_at_infinity), plus a 50% chance of doing an inversion at the end.
Now we would have a 50% chance of doing an inversion at each non-zero
bit. That's the same number of coin flips.

Change-Id: I8158fd48601cb041188826d4f68ac1a31a6fbbbc
Reviewed-on: https://boringssl-review.googlesource.com/25146
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-23 21:29:13 +00:00
David Benjamin 2d77d4084a Generate curve25519 tables with a script.
This is to make it easier to add new field element representations. The
Ed25519 logic in the script is partially adapted from RFC 8032's Python
code, but I replaced the point addition logic with the naive textbook
formula since this script only cares about being obviously correct.

Change-Id: I0b90bf470993c177070fd1010ac5865fedb46c82
Reviewed-on: https://boringssl-review.googlesource.com/24745
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-01-23 21:21:54 +00:00
David Benjamin 042b49cf3c Extract curve25519 tables into a separate header.
This is in preparation for writing a script to generate them. I'm
manually moving the existing tables over so it will be easier to confirm
the script didn't change the values.

Change-Id: Id83e95c80d981e19d1179d45bf47559b3e1fc86e
Reviewed-on: https://boringssl-review.googlesource.com/24744
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2018-01-23 21:08:49 +00:00
David Benjamin 5d9408714c Remove unnecessary window size cases.
The optimization for wsize = 1 only kicks in for 19-bit primes. The
cases for b >= 800 and cannot happen due to EC_MAX_SCALAR_BYTES.

Change-Id: If5ca908563f027172cdf31c9a22342152fecd12f
Reviewed-on: https://boringssl-review.googlesource.com/25145
Reviewed-by: Adam Langley <agl@google.com>
2018-01-23 21:08:39 +00:00
David Benjamin 4111dd2fc2 Don't compute a per-scalar window size in wNAF code.
Simplify things slightly. The probability of the scalar being small
enough to go down a window size is astronomically small. (2^-186 for
P-256 and 2^-84 for P-384.)

Change-Id: Ie879f0b06bcfd1e6e6e3bf3f54e0d7d6567525a4
Reviewed-on: https://boringssl-review.googlesource.com/25144
Reviewed-by: Adam Langley <agl@google.com>
2018-01-23 21:06:42 +00:00
David Benjamin 186df3a655 Implement fe_sq2_tt with fe_sq_tt.
fiat-crypto only generates fe_mul and fe_sq, but the original Ed25519
implementation we had also had fe_sq2 for computing 2*f^2. Previously,
we inlined a version of fe_mul.

Instead, we could implement it with fe_sq and fe_add. Performance-wise,
this seems to not regress. If anything, it makes it faster?

Before (clang, run for 10 seconds):
Did 243000 Ed25519 key generation operations in 10025910us (24237.2 ops/sec)
Did 250000 Ed25519 signing operations in 10035580us (24911.4 ops/sec)
Did 73305 Ed25519 verify operations in 10071101us (7278.7 ops/sec)
Did 184000 Curve25519 base-point multiplication operations in 10040138us (18326.4 ops/sec)
Did 186000 Curve25519 arbitrary point multiplication operations in 10052721us (18502.5 ops/sec)

After (clang, run for 10 seconds):
Did 242424 Ed25519 key generation operations in 10013117us (24210.6 ops/sec)
Did 253000 Ed25519 signing operations in 10011744us (25270.3 ops/sec)
Did 73899 Ed25519 verify operations in 10048040us (7354.6 ops/sec)
Did 194000 Curve25519 base-point multiplication operations in 10005389us (19389.6 ops/sec)
Did 195000 Curve25519 arbitrary point multiplication operations in 10028443us (19444.7 ops/sec)

Before (clang + OPENSSL_SMALL, run for 10 seconds):
Did 144000 Ed25519 key generation operations in 10019344us (14372.2 ops/sec)
Did 146000 Ed25519 signing operations in 10011653us (14583.0 ops/sec)
Did 74052 Ed25519 verify operations in 10005789us (7400.9 ops/sec)
Did 150000 Curve25519 base-point multiplication operations in 10007468us (14988.8 ops/sec)
Did 91392 Curve25519 arbitrary point multiplication operations in 10057678us (9086.8 ops/sec)

After (clang + OPENSSL_SMALL, run for 10 seconds):
Did 144000 Ed25519 key generation operations in 10066724us (14304.6 ops/sec)
Did 148000 Ed25519 signing operations in 10062043us (14708.7 ops/sec)
Did 74820 Ed25519 verify operations in 10058557us (7438.4 ops/sec)
Did 151000 Curve25519 base-point multiplication operations in 10063492us (15004.7 ops/sec)
Did 90402 Curve25519 arbitrary point multiplication operations in 10049141us (8996.0 ops/sec)

Change-Id: I31e9f61833492c3ff2dfd78e1dee5e06f43c850f
Reviewed-on: https://boringssl-review.googlesource.com/24724
Reviewed-by: Adam Langley <agl@google.com>
2018-01-23 20:49:50 +00:00
David Benjamin a7bc94489f Don't use the client_random entropy for GREASE.
No sense in tempting middleboxes unnecessarily.

Change-Id: Iec66f77195f6b8aa62be681917342e59eb7aba31
Reviewed-on: https://boringssl-review.googlesource.com/24964
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2018-01-23 19:10:40 +00:00
David Benjamin 44fd6eeef5 Split BORINGSSL_self_test into its own file.
Some non-FIPS consumers exclude bcm.c and build each fragment file
separately. This means non-FIPS code cannot live in bcm.c.
https://boringssl-review.googlesource.com/25044 made the self-test
function exist outside of FIPS code, so it needed to be moved into is
own file.

To avoid confusing generate_build_files.py, this can't be named
self_test.c, so I went with self_check.c.

Change-Id: I337b39b158bc50d6ca0a8ad1b6e15eb851095e1e
Reviewed-on: https://boringssl-review.googlesource.com/25124
Reviewed-by: Martin Kreichgauer <martinkr@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-22 23:06:41 +00:00
Martin Kreichgauer 98e24197ee add missing #includes
Change-Id: Ib067411d4cafe1838c2dc42fc8bfd9011490f45c
Reviewed-on: https://boringssl-review.googlesource.com/25064
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-22 21:54:08 +00:00
Shenghua Zhang a4f78775b9 [ndk] Change ndk deps in src and relocate to third_party/boringssl
Because the android sdk managed by CIPD (see go/use-adjective-apis),
its deps repo ndk needs to be relocated, as well as hooked by the root
DEPS instead of recursedeps. This CL addes android ndk deps in
util/bot/DEPS.

Bug: chromium:659808
Change-Id: I270053ae56ba1caaf9c67f2240855eafd499b782
Reviewed-on: https://boringssl-review.googlesource.com/24864
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-22 21:08:28 +00:00
Steven Valdez cb15cfda29 Add draft23 tests.
Change-Id: Ic77bc2f55e1e997ea20641cae66b0deddf1ef99c
Reviewed-on: https://boringssl-review.googlesource.com/25084
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-01-22 20:29:38 +00:00
Adam Langley f2e7b220c0 Extract FIPS KAT tests into a function.
This change adds |BORINGSSL_self_test|, which allows applications to run
the FIPS KAT tests on demand, even in non-FIPS builds.

Change-Id: I950b30a02ab030d5e05f2d86148beb4ee1b5929c
Reviewed-on: https://boringssl-review.googlesource.com/25044
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-01-22 20:16:38 +00:00
Nick Harper 36fcc4ca5d Implement Token Binding
Update-Note: Token Binding can no longer be configured with the custom
  extensions API. Instead, use the new built-in implementation. (The
  internal repository should be all set.)

Bug: 183

Change-Id: I007523a638dc99582ebd1d177c38619fa7e1ac38
Reviewed-on: https://boringssl-review.googlesource.com/20645
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-01-22 20:08:28 +00:00
David Benjamin 8d67f6f0cf Update tools.
This is a reland 9d1f96606c, which should
hopefuly be fine after afd1cd959e. Though
I've also gone ahead and gotten the latest versions of things.
(android_tools and clang updated.)

In particular, get the new NDK. Unfortunately, the new clang picks up
an unfortunate change for clang-cl that we now must work around.

http://llvm.org/viewvc/llvm-project?view=revision&revision=319116

Bug: 109
Change-Id: If19b09c585957fefaffa8c3197a50189402a555a
Reviewed-on: https://boringssl-review.googlesource.com/25025
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-22 18:30:18 +00:00
David Benjamin 017fbf0940 Fix sort order.
Change-Id: I459637397429109a2314355b571a42a61cb9dd49
Reviewed-on: https://boringssl-review.googlesource.com/25024
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-22 18:13:38 +00:00
Adam Langley 05a8434484 Support AVX-512 instructions with a writemask in delocate.
AVX-512 adds a new text instruction syntax to x86-64 assembly to specify
the writemask registers and the merge-masking vs zeroing-masking signal.

This change causes these tokens to be passed through.

Patch by Jeff McDonald.

Change-Id: Ib15b15ac684183cc5fba329a176b63b477bc24a3
Reviewed-on: https://boringssl-review.googlesource.com/24945
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-22 18:00:18 +00:00
David Benjamin bb1e5cbbe3 Use -gcv8 instead of -g cv8.
yasm accepts both, but nasm reportedly only accepts the former.

Change-Id: Iddcd33daac3f9063b4ddd50d82503b1984391c08
Reviewed-on: https://boringssl-review.googlesource.com/25004
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-22 16:11:38 +00:00
Frederik Kriewitz 5ab5484044 Support |alignof|/|alignas| in GCC 4.7.
(Note that support for GCC 4.7 ends 2018-03-23.)

Change-Id: Ia2ac6a735c8177a2b3a13f16197ff918266bc1cb
Reviewed-on: https://boringssl-review.googlesource.com/24924
Reviewed-by: Adam Langley <agl@google.com>
2018-01-20 02:04:57 +00:00
Adam Langley c7ef069ac9 Fix format-string error in delocate.go.
Errorf treats its argument as a format string and so “%rax” is a
problem.

Change-Id: I863ef361f07d0b8a348994efe45869202d0b31f1
Reviewed-on: https://boringssl-review.googlesource.com/24944
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-18 19:08:50 +00:00
Adam Langley 37c6eb4284 Support TLS KDF test for NIAP.
NIAP requires that the TLS KDF be tested by CAVP so this change moves
the PRF into crypto/fipsmodule/tls and adds a test harness for it. Like
the KAS tests, this is only triggered when “-niap” is passed to
run_cavp.go.

Change-Id: Iaa4973d915853c8e367e6106d829e44fcf1b4ce5
Reviewed-on: https://boringssl-review.googlesource.com/24666
Reviewed-by: Adam Langley <agl@google.com>
2018-01-16 22:57:17 +00:00
Adam Langley e80c7c065c Support KAS tests for NIAP.
This change adds support for two specific CAVP tests, in order to
meet NIAP requirements.

These tests are currently only run when “-niap” is passed to run_cavp.go
because they are not part of our FIPS validation (yet).

Change-Id: I511279651aae094702332130fac5ab64d11ddfdb
Reviewed-on: https://boringssl-review.googlesource.com/24665
Reviewed-by: Adam Langley <agl@google.com>
2018-01-16 22:57:01 +00:00
Adam Langley 92b8ecdd0d Change from configuring a FAX scanner function to a FAX next-line function.
In order to process some NIST FAX files, we needed to implement a custom
scanner function to skip over lines that are effectively comments, but
not marked as such.

In the near future we'll need to process KAS FAX files, for which we
need not only to skip over unmarked comment lines, but also to skip some
lines of the response which the FAX doesn't include.

For this we need a more powerful callback function, which this change
provides.

Change-Id: Ibb12b97ac65b3e85317d2e97386ef1c2ea263d4b
Reviewed-on: https://boringssl-review.googlesource.com/24664
Reviewed-by: Adam Langley <agl@google.com>
2018-01-16 22:56:50 +00:00
David Benjamin afd1cd959e Work around an NDK / Android bug.
The NDK r16 sometimes generates binaries with the DF_1_PIE, which the
runtime linker on Android N complains about. The next NDK revision
should work around this but, in the meantime, strip its error out.

https://github.com/android-ndk/ndk/issues/602
https://android-review.googlesource.com/c/platform/bionic/+/259790
https://android-review.googlesource.com/c/toolchain/binutils/+/571550

Change-Id: I99306d42f11179d5d19bd3f107a7386cc5c690db
Reviewed-on: https://boringssl-review.googlesource.com/24884
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-16 16:52:46 +00:00
Gabriel Redner 7c5e1400dd Fix reference to nonexistent function.
Change-Id: Ib02f1945117dfd7f7d46dbf0672091830c6f3481
Reviewed-on: https://boringssl-review.googlesource.com/24904
Reviewed-by: Adam Langley <agl@google.com>
2018-01-16 16:23:36 +00:00
David Benjamin 94cd196a80 Add files in third_party/fiat for Chromium to pick up.
Chromium's licenses.py is a little finicky.

Change-Id: I015a3565eb8f3cfecb357d142facc796a9c80888
Reviewed-on: https://boringssl-review.googlesource.com/24784
Reviewed-by: Adam Langley <agl@google.com>
2018-01-10 22:02:03 +00:00
David Benjamin b6317b98ee Update googletest.
The latest MSVC 2017 complains about std::tr1::tuple, which was fixed in
upstream GTest.

Upstream have also merged all our patches, we now no longer are carrying
a diff. (Thanks, Gennadiy!)

Change-Id: I6932687b8e8c1eff8c2edf42da0a12080e7b61dd
Reviewed-on: https://boringssl-review.googlesource.com/24685
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-10 12:11:44 +00:00
Alessandro Ghedini 11a5726ee3 tool: update selection of draft22 TLS 1.3 variant
Change-Id: I7085a07dd2f3d802ada049a2f771ff0c74f4f902
Reviewed-on: https://boringssl-review.googlesource.com/24764
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-10 12:08:54 +00:00
Adam Langley 512a289a8a Add support for dummy PQ padding.
This extension will be used to measure the latency impact of potentially
sending a post-quantum key share by default. At this time it's purely
measuring the impact of the client sending the key share, not the server
replying with a ciphertext.

We could use the existing padding extension for this but that extension
doesn't allow the server to echo it, so we would need a different
extension in the future anyway. Thus we just create one now.

We can assume that modern clients will be using TLS 1.3 by the time that
PQ key-exchange is established and thus the key share will be sent in
all ClientHello messages. However, since TLS 1.3 isn't quite here yet,
this extension is also sent for TLS 1.0–1.2 ClientHellos. The latency
impact should be the same either way.

Change-Id: Ie4a17551f6589b28505797e8c54cddbe3338dfe5
Reviewed-on: https://boringssl-review.googlesource.com/24585
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-01-10 00:27:31 +00:00
David Benjamin 3c92e80d7a Revert "Update tools."
This reverts commit 9d1f96606c.

Reason for revert: aarch64 bots are breaking for some reason.

Original change's description:
> Update tools.
> 
> In particular, get the new NDK. Unfortunately, the new clang picks up
> an unfortunate change for clang-cl that we now must work around.
> 
> http://llvm.org/viewvc/llvm-project?view=revision&revision=319116
> 
> Bug: 109
> Change-Id: I091ca7160683e70cd79b5c2b7a4267fea258ec17
> Reviewed-on: https://boringssl-review.googlesource.com/24644
> Reviewed-by: Steven Valdez <svaldez@google.com>
> Commit-Queue: David Benjamin <davidben@google.com>
> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>

TBR=davidben@google.com,svaldez@google.com

Change-Id: I98960f295987857c4e42c312059b6d5934bb5e43
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 109
Reviewed-on: https://boringssl-review.googlesource.com/24747
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-09 21:45:11 +00:00
David Benjamin 9d1f96606c Update tools.
In particular, get the new NDK. Unfortunately, the new clang picks up
an unfortunate change for clang-cl that we now must work around.

http://llvm.org/viewvc/llvm-project?view=revision&revision=319116

Bug: 109
Change-Id: I091ca7160683e70cd79b5c2b7a4267fea258ec17
Reviewed-on: https://boringssl-review.googlesource.com/24644
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-09 21:28:00 +00:00
David Benjamin 53ff70f68c Tidy up some warnings.
Updating clang seems to have upset the clang-cl build. I think because
they decided -Wall now matches MSVC's semantics, which is a little nuts.
Two of the warnings, however, weren't wrong, so fix those.

http://llvm.org/viewvc/llvm-project?view=revision&revision=319116

Change-Id: I168e52e4e70ca7b1069e0b0db241fb5305c12b1e
Reviewed-on: https://boringssl-review.googlesource.com/24684
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-09 16:01:32 +00:00
David Benjamin e2b8466fa7 Update CMake on Windows bots to 3.10.1.
The 3.10 update had to be rolled back due to a bug with clang-cl that
has since been fixed.

Change-Id: I31c28aedb533f20ab01f105f6f3f7b3ee9c91784
Reviewed-on: https://boringssl-review.googlesource.com/24324
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-09 15:56:42 +00:00
Steven Valdez 74666da5b3 Update key share extension number for draft23.
Change-Id: I7561fc7e04d726ea9e26f645da10e45b62a20627
Reviewed-on: https://boringssl-review.googlesource.com/24704
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-01-09 15:22:02 +00:00
David Benjamin 0c9b7b5de2 Align various point_get_affine_coordinates implementations.
The P-224 implementation was missing the optimization to avoid doing
extra work when asking for only one coordinate (ECDH and ECDSA both
involve an x-coordinate query). The P-256 implementation was missing the
optimization to do one less Montgomery reduction.

TODO - Benchmarks

Change-Id: I268d9c24737c6da9efaf1c73395b73dd97355de7
Reviewed-on: https://boringssl-review.googlesource.com/24690
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-08 20:03:42 +00:00
David Benjamin 9112631c1f Remove ftmp* comments from P-256 addition code.
These are remnants of the old code which had a bunch of ftmp variables.

Change-Id: Id14cf414cb67ff08e240970767f7a5a58e883ce4
Reviewed-on: https://boringssl-review.googlesource.com/24689
Reviewed-by: Adam Langley <agl@google.com>
2018-01-08 19:51:03 +00:00
David Benjamin 3ab6ad6abd Simplify EC_KEY_set_public_key_affine_coordinates.
EC_POINT_set_affine_coordinates_GFp already rejects coordinates which
are out of range. There's no need to double-check.

Change-Id: Id1685355c555dda66d2a14125cb0083342f37e53
Reviewed-on: https://boringssl-review.googlesource.com/24688
Reviewed-by: Adam Langley <agl@google.com>
2018-01-08 19:50:42 +00:00
David Benjamin 99084cdd76 Fold away ec_point_set_Jprojective_coordinates_GFp.
p224-64.c can just write straight into the EC_POINT, as the other files
do, which saves the mess around BN_CTX. It's also more correct.
ec_point_set_Jprojective_coordinates_GFp abstracts out field_encode, but
then we would want to abstract out field_decode too when reading.

That then allows us to inline ec_point_set_Jprojective_coordinates_GFp
into ec_GFp_simple_point_set_affine_coordinates and get rid of an
unnecessary tower of helper functions. Also we can use the precomputed
value of one rather than recompute it each time.

Change-Id: I8282dc66a4a437f5a3b6a1a59cc39be4cb71ccf9
Reviewed-on: https://boringssl-review.googlesource.com/24687
Reviewed-by: Adam Langley <agl@google.com>
2018-01-08 19:48:37 +00:00
David Benjamin 1eddb4be29 Make EC_POINT_set_compressed_coordinates_GFp use BIGNUM directly.
All the messing around with field_mul and field_sqr does the same thing
as calling EC_GROUP_get_curve_GFp. This is in preparation for ultimately
moving the field elements to an EC_FELEM type.

Where we draw the BIGNUM / EC_FELEM line determines what EC_FELEM
operations we need. Since we don't care much about the performance of
this function, leave it in BIGNUM so we don't need an EC_FELEM
BN_mod_sqrt just yet. We can push it down later if we feel so inclined.

Change-Id: Iec07240d40828df6b7a29fd1f430e3b390d5f506
Reviewed-on: https://boringssl-review.googlesource.com/24686
Reviewed-by: Adam Langley <agl@google.com>
2018-01-08 19:40:21 +00:00
Matthew Braithwaite 9770532afa Map NOT_YET_VALID errors to |certificate_expired|.
The language of RFC 5246 is "A certificate has expired or is not
currently valid", which sounds to me like |certificate_expired| should
pertain to any case where the current time is outside the
certificate's validity period.

Along the way, group the |unknown_ca| errors together.

Change-Id: I92c1fe3fc898283d0c7207625de36662cd0f784e
Reviewed-on: https://boringssl-review.googlesource.com/24624
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-05 23:40:40 +00:00
David Benjamin 92e332501a Add a function for encoding SET OF.
The Chromium certificate verifier ends up encoding a SET OF when
canonicalizing X.509 names. Requiring the caller canonicalize a SET OF
is complicated enough that we should probably sort it for folks. (We
really need to get this name canonicalization insanity out of X.509...)

This would remove the extra level of indirection in Chromium
net/cert/internal/verify_name_match.cc CBB usage.

Note this is not quite the same order as SET, but SET is kind of
useless. Since it's encoding heterogeneous values, it is reasonable to
require the caller just encode them in the correct order. In fact, a DER
SET is just SEQUENCE with a post-processing step on the definition to
fix the ordering of the fields. (Unless the SET contains an untagged
CHOICE, in which case the ordering is weird, but SETs are not really
used in the real world, much less SETs with untagged CHOICEs.)

Bug: 11
Change-Id: I51e7938a81529243e7514360f867330359ae4f2c
Reviewed-on: https://boringssl-review.googlesource.com/24444
Reviewed-by: Adam Langley <agl@google.com>
2018-01-05 23:39:02 +00:00
David Benjamin 00208b443c Use fiat-crypto's freeze function for fe_tobytes.
It requires a handful of additional intrinsics for now.

Fiat's freeze function only works on the tight bounds, so fe_isnonzero
gains an extra fe_carry. But all other calls of fe_tobytes are of tight
bounds anyway.

Change-Id: I834858cee7863c7344e456d7a7dbf4f414f04ae5
Reviewed-on: https://boringssl-review.googlesource.com/24545
Reviewed-by: Adam Langley <agl@google.com>
2018-01-05 23:38:26 +00:00
Adam Langley 2f9b47fb19 Better pack structs in ssl/internal.h
Change-Id: I632a5c9067860216f9252907b104ba605c33a50d
Reviewed-on: https://boringssl-review.googlesource.com/24584
Reviewed-by: David Benjamin <davidben@google.com>
2018-01-04 21:08:36 +00:00
Marek Gilbert 11850d5f61 Rename all googletest CMake targets
CMake targets are visible globally but gtest_main has boringssl-specific
behavior that isn't appropriate for general use.

This change makes it possible to use boringssl and abseil-cpp in the
same project (since abseil-cpp expects gtest_main to exist and be useful
for its own tests).

Change-Id: Icc81c11b8bb4b1e21cea7c9fa725b6c082bd5369
Reviewed-on: https://boringssl-review.googlesource.com/24604
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-04 16:30:54 +00:00
David Benjamin 915c121bb5 Remove some outdated preconditions and postconditions.
These date to the old code and have been replaced by the fe and fe_loose
bounds in the header file. Also fix up a comment that the comment
converter didn't manage to convert.

Change-Id: I2e3ea867a8cea2b347d09c304a17e532b2e36545
Reviewed-on: https://boringssl-review.googlesource.com/24525
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-03 23:03:32 +00:00
David Benjamin 3144d92ab8 Add some missing array parameter length annotations.
Not that anything checks them...

Change-Id: Iae1b5dbdb3c20a9ebd841bcd32cc5c725c68eb01
Reviewed-on: https://boringssl-review.googlesource.com/24524
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-03 22:34:22 +00:00
David Benjamin d9f49974e3 Support high tag numbers in CBS/CBB.
This is a reland of https://boringssl-review.googlesource.com/2330. I
believe I've now cleared the fallout.

Android's attestion format uses some ludicrously large tag numbers:
https://developer.android.com/training/articles/security-key-attestation.html#certificate_schema

Add support for these in CBS/CBB. The public API does not change for
callers who were using the CBS_ASN1_* constants, but it is no longer the
case that tag representations match their DER encodings for small tag
numbers. When passing tags into CBS/CBB, use CBS_ASN1_* constants. When
working with DER byte arrays (most commonly test vectors), use the
numbers themselves.

Bug: 214
Update-Note: The in-memory representation of CBS/CBB tags changes.
   Additionally, we now support tag numbers above 30. I believe I've now
   actually cleared the fallout of the former. There is one test in
   Chromium and the same test in the internal repository that needs
   fixing.

Change-Id: I49b9d30df01f023c646d31156360ff69c91626a3
Reviewed-on: https://boringssl-review.googlesource.com/24404
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-03 22:28:32 +00:00
David Benjamin 5bcaa113e2 Tighten EC_KEY's association with its group.
This is to simplify
https://boringssl-review.googlesource.com/c/boringssl/+/24445/.

Setting or changing an EC_KEY's group after the public or private keys
have been configured is quite awkward w.r.t. consistency checks. It
becomes additionally messy if we mean to store private keys as
EC_SCALARs (and avoid the BIGNUM timing leak), whose size is
curve-dependent.

Instead, require that callers configure the group before setting either
half of the keypair. Additionally, reject EC_KEY_set_group calls that
change the group. This will simplify clearing one more BIGNUM timing
leak.

Update-Note: This will break code which sets the group and key in a
    weird order. I checked calls of EC_KEY_new and confirmed they all
    set the group first. If I missed any, let me know.

Change-Id: Ie89f90a318b31b6b98f71138e5ff3de5323bc9a6
Reviewed-on: https://boringssl-review.googlesource.com/24425
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-03 22:15:11 +00:00
Matthew Braithwaite e15019572b SSL_alert_from_verify_result: expose.
This function maps |X509_V_ERR_*| to SSL alarm codes.  It's used
internally when certs are verified with X509_verify_cert(), and is
helpful to callers who want to call that function, but who also want
to report its errors in a less implementation-dependent way.

Change-Id: I2900cce2eb631489f0947c317beafafd3ea57a75
Reviewed-on: https://boringssl-review.googlesource.com/24564
Commit-Queue: Matt Braithwaite <mab@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-03 22:02:42 +00:00
Adam Langley ef16f19ef2 Support delocating vpbroadcastq.
(This can be generated with -mavx2.)

Change-Id: I6d92d9e93eb448357342ef86d050321f0ef40f9e
Reviewed-on: https://boringssl-review.googlesource.com/24504
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2018-01-02 21:06:52 +00:00
Adam Langley 380bc30f0c Fix |ASN1_INTEGER_set| when setting zero.
|ASN1_INTEGER_set| and |BN_to_ASN1_INTEGER| disagree about how to encode
zero. OpenSSL master has aligned around the behaviour of the latter
(i.e. a single zero byte) so fix |ASN1_INTEGER_set| to do that. (This is
also the form that DER requires.)

At the same time, fix undefined behaviour when negative a |long| whose
value is |LONG_MIN|.

Change-Id: I1198de35e61a286ac6472e99152f3d22fda59044
Reviewed-on: https://boringssl-review.googlesource.com/24485
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-01-02 16:11:31 +00:00
Adam Langley f8d05579b4 Add ASN1_INTEGET_set_uint64.
Change-Id: I3298875a376c98cbb60deb8c99b9548c84b014df
Reviewed-on: https://boringssl-review.googlesource.com/24484
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2018-01-02 16:01:31 +00:00
Andres Erbsen 0a54e99848 Add links to proofs of elliptic curve formulas.
Change-Id: I166f740185f26770b51759714efd5d634fbcc173
Reviewed-on: https://boringssl-review.googlesource.com/24424
Reviewed-by: David Benjamin <davidben@google.com>
2017-12-22 19:52:44 +00:00
David Benjamin 80ede1df8e Fix early_mac_len computation.
We would set it to block_size rather than zero. This doesn't cause
problems (the code behaves correctly with either value), but it is a
tiny missed optimization.

Change-Id: Ic751352750cc7ef74aa25a6cc96da82007199941
Reviewed-on: https://boringssl-review.googlesource.com/24364
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-12-21 21:41:39 +00:00
Andres Erbsen 36fce983b6 add fiat-crypto code generation readme
Change-Id: Ie4060121f6bc8da07d87db8ec8133ea17e99e1fe
Reviewed-on: https://boringssl-review.googlesource.com/24344
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-12-21 18:35:39 +00:00
David Benjamin 6df6540766 Add a draft TLS 1.3 anti-downgrade signal.
TLS 1.3 includes a server-random-based anti-downgrade signal, as a
workaround for TLS 1.2's ServerKeyExchange signature failing to cover
the entire handshake. However, because TLS 1.3 draft versions are each
doomed to die, we cannot deploy it until the final RFC. (Suppose a
draft-TLS-1.3 client checked the signal and spoke to a final-TLS-1.3
server. The server would correctly negotiate TLS 1.2 and send the
signal. But the client would then break. An anologous situation exists
with reversed roles.)

However, it appears that Cisco devices have non-compliant TLS 1.2
implementations[1] and copy over another server's server-random when
acting as a TLS terminator (client and server back-to-back).

Hopefully they are the only ones doing this. Implement a
measurement-only version with a different value. This sentinel must not
be enforced, but it will tell us whether enforcing it will cause
problems.

[1] https://www.ietf.org/mail-archive/web/tls/current/msg25168.html

Bug: 226
Change-Id: I976880bdb2ef26f51592b2f6b3b97664342679c8
Reviewed-on: https://boringssl-review.googlesource.com/24284
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2017-12-21 01:50:33 +00:00
David Benjamin 02e6256b16 Move early_data_accepted to ssl->s3.
This is connection state, not configuration, so it must live on
ssl->s3, otherwise SSL_clear will be confused.

Change-Id: Id7c87ced5248d3953e37946e2d0673d66bfedb08
Reviewed-on: https://boringssl-review.googlesource.com/24264
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-12-19 15:44:38 +00:00
David Benjamin a0c87adbf0 Add RSA_flags and RSA_METHOD_FLAG_NO_CHECK.
RSA_METHOD_FLAG_NO_CHECK is the same as our RSA_FLAG_OPAQUE. cURL uses
this to determine if it should call SSL_CTX_check_private_key.

Change-Id: Ie2953632346a31de346a4452f4eaad8435cf76e8
Reviewed-on: https://boringssl-review.googlesource.com/24245
Reviewed-by: Adam Langley <agl@google.com>
2017-12-18 23:56:15 +00:00
David Benjamin 0551feb3a1 Trim some unused RSA flags.
Update-Note: Some RSA_FLAG_* constants are gone. Code search says they
   were unused, but they can be easily restored if this breaks anything.
Change-Id: I47f642af5af9f8d80972ca8da0a0c2bd271c20eb
Reviewed-on: https://boringssl-review.googlesource.com/24244
Reviewed-by: Adam Langley <agl@google.com>
2017-12-18 23:55:27 +00:00
David Benjamin d90b8033d7 Clear the error queue in fuzzer-mode Channel ID hooks.
Otherwise it leaves something on the error queue and confuses
SSL_get_error, should the handshake state machine fail immediately
afterwards because of a BIO-level error.

Change-Id: I2c7b5e31368b9c5b2efa324166f52972430d6074
Reviewed-on: https://boringssl-review.googlesource.com/24247
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-12-18 21:56:32 +00:00
David Benjamin 287ac180ee Refresh fuzzer corpora.
The TLS 1.3 variants got renumbered (and many dropped).

Change-Id: I75f63e7188bb22eb115e7f4393e67dc696c013c5
Reviewed-on: https://boringssl-review.googlesource.com/24246
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
2017-12-18 21:54:26 +00:00
Steven Valdez 64cc121f41 Remove deprecated TLS 1.3 variants.
Upgrade-Note: SSL_CTX_set_tls13_variant(tls13_experiment) on the server
should switch to SSL_CTX_set_tls13_variant(tls13_experiment2).
(Configuring any TLS 1.3 variants on the server enables all variants,
so this is a no-op. We're just retiring some old experiments.)
Change-Id: I60f0ca3f96ff84bdf59e1a282a46e51d99047462
Reviewed-on: https://boringssl-review.googlesource.com/23784
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2017-12-18 21:20:32 +00:00
David Benjamin ea52ec98a5 Perform the RSA CRT reductions with Montgomery reduction.
The first step of RSA with the CRT optimization is to reduce our input
modulo p and q. We can do this in constant-time[*] with Montgomery
reduction. When p and q are the same size, Montgomery reduction's bounds
hold. We need two rounds of it because the first round gives us an
unwanted R^-1.

This does not appear to have a measurable impact on performance. Also
add a long TODO describing how to make the rest of the function
constant-time[*] which hopefully we'll get to later. RSA blinding should
protect us from it all, but make this constant-time anyway.

Since this and the follow-up work will special-case weird keys, add a
test that we don't break those unintentionally. (Though I am not above
breaking them intentionally someday...)

Thanks to Andres Erbsen for discussions on how to do this bit properly.

[*] Ignoring the pervasive bn_correct_top problem for the moment.

Change-Id: Ide099a9db8249cb6549be99c5f8791a39692ea81
Reviewed-on: https://boringssl-review.googlesource.com/24204
Reviewed-by: Adam Langley <agl@google.com>
2017-12-18 18:59:18 +00:00
David Benjamin f88242d1c1 SSL_export_keying_material should work in half-RTT.
QUIC will need to derive keys at this point. This also smooths over a
part of the server 0-RTT abstraction. Like with False Start, the SSL
object is largely in a functional state at this point.

Bug: 221
Change-Id: I4207d8cb1273a1156e728a7bff3943cc2c69e288
Reviewed-on: https://boringssl-review.googlesource.com/24224
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-12-18 16:53:13 +00:00
David Benjamin ebd87230ac Bring ERR_ERROR_STRING_BUF_LEN down to 120.
Originally, the only OpenSSL API to stringify errors was:

  char *ERR_error_string(unsigned long e, char *buf);

This API leaves callers a choice to either be thread unsafe (buf = NULL)
or pass in a buffer with unknown size. Indeed the original
implementation was just a bunch of unchecked sprintfs with, in the buf =
NULL case, a static 256-byte buffer.

https://github.com/openssl/openssl/blob/388f2f56f213dfada0370d48cb9bcc3c7e980b32/crypto/err/err.c#L374

Then ERR_error_string was documented that the buffer must be size 120.
Nowhere in the code was 120 significant. I expect OpenSSL just made up a
number.

https://github.com/openssl/openssl/commit/388f2f56f213dfada0370d48cb9bcc3c7e980b32

Then upstream added the ERR_error_string_n API. Although the
documentation stated 120 bytes, the internal buffer was 256, so the code
actually translates ERR_error_string to ERR_error_string_n(e, buf, 256),
not ERR_error_string_n(e, buf, 120)!

https://github.com/openssl/openssl/commit/e5c84d5152c11a3dfa436041d3336a6f403baad8

So the documentation was wrong all this time! OpenSSL 1.1.0 corrected
the documentation to 256, but, alas, a lot of code used the
documentation and sized the buffer at 120. We should fix all
ERR_error_string callers to ERR_error_string_n but, in the meantime,
using 120 is probably less effort.

Note this also affects ERR_print_errors_cb right now. We don't have
function codes, so 120 bytes leaves 60 bytes for the reason code. Our
longest one, TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST is 46 bytes,
so it's a little tight, but, if needed, we can recover 20-ish bytes by
shrinking the library names. We can also always make ERR_print_errors_cb
use a larger buffer.

Change-Id: I472a1a802f2e6281cc7515d2a452208d6bac1200
Reviewed-on: https://boringssl-review.googlesource.com/24184
Reviewed-by: Adam Langley <agl@google.com>
2017-12-14 19:47:23 +00:00
David Benjamin 875095aa7c Silence ARMv8 deprecated IT instruction warnings.
ARMv8 kindly deprecated most of its IT instructions in Thumb mode.
These files are taken from upstream and are used on both ARMv7 and ARMv8
processors. Accordingly, silence the warnings by marking the file as
targetting ARMv7. In other files, they were accidentally silenced anyway
by way of the existing .arch lines.

This can be reproduced by building with the new NDK and passing
-DCMAKE_ASM_FLAGS=-march=armv8-a. Some of our downstream code ends up
passing that to the assembly.

Note this change does not attempt to arrange for ARMv8-A/T32 to get
code which honors the constraints. It only silences the warnings and
continues to give it the same ARMv7-A/Thumb-2 code that backwards
compatibility dictates it continue to run.

Bug: chromium:575886, b/63131949
Change-Id: I24ce0b695942eaac799347922b243353b43ad7df
Reviewed-on: https://boringssl-review.googlesource.com/24166
Reviewed-by: Adam Langley <agl@google.com>
2017-12-14 01:56:22 +00:00
David Benjamin 9894ee9de2 Scope CMAKE_ASM_FLAGS workaround to the old NDK toolchain.
The one in the NDK works just fine. In particular, this means one can
pass -DCMAKE_ASM_FLAGS="-march=armv8-a" and test the ARMv8 assembler
warnings.

Additionally, make the workaround put the flags in the other order, so
-march is user-overridable.

Change-Id: I278ddd17ab688f83ee01f2aca4ff32307f5b0a2d
Reviewed-on: https://boringssl-review.googlesource.com/24164
Reviewed-by: Adam Langley <agl@google.com>
2017-12-14 01:55:26 +00:00
David Benjamin 528877962b Document the NDK's built-in toolchain file.
The third-party toolchain file doesn't actually work with newer NDKs,
and the one shipped with the NDK has fewer bugs.

Change-Id: I59e1db393f0d66b186fb71590fab14db7faa0756
Reviewed-on: https://boringssl-review.googlesource.com/24165
Reviewed-by: Adam Langley <agl@google.com>
2017-12-14 01:54:47 +00:00
David Benjamin 4358f104cf Remove clang assembler .arch workaround.
This makes it difficult to build against the NDK's toolchain file. The
problem is __clang__ just means Clang is the frontend and implies
nothing about which assembler. When using as, it is fine. When using
clang-as on Linux, one needs a clang-as from this year.

The only places where we case about clang's integrated assembler are iOS
(where perlasm strips out .arch anyway) and build environments like
Chromium which have a regularly-updated clang. Thus we can remove this
now.

Bug: 39
Update-Note: Holler if this breaks the build. If it doesn't break the
   build, you can probably remove any BORINGSSL_CLANG_SUPPORTS_DOT_ARCH
   or explicit -march armv8-a+crypto lines in your BoringSSL build.
Change-Id: I21ce54b14c659830520c2f1d51c7bd13e0980c68
Reviewed-on: https://boringssl-review.googlesource.com/24124
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-12-13 22:22:41 +00:00
David Benjamin a9c5b7b3fb Roll back CMake update on Windows bots.
CMake screwed up. See
https://github.com/Kitware/CMake/commit/f969f1a9ce1d0045b9d056fd08c4683c34c420fa.

It looks like CMake 3.10.1 is in the process of being released. While we
wait for them to put together that build, I'll just revert this real
quick. It's nice to keep them all at the same version, but we really
just needed a new one for Android.

Change-Id: I01b5a54b65df2194d7b84c825dfdcf0fb87fd06b
Reviewed-on: https://boringssl-review.googlesource.com/24144
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-12-13 21:56:50 +00:00
David Benjamin d870cbdd97 Update CMake to 3.10.0 on the bots.
The NDK toolchain file requires 3.6.0 or later. We were still using
3.5.0.

Change-Id: I216d33bed4187c7e62a2672eb4f92ce815b60b1c
Reviewed-on: https://boringssl-review.googlesource.com/24104
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-12-13 21:35:11 +00:00
David Benjamin 0c9c1aad35 Fix generate_build_files.py.
third_party/fiat/p256.c is weird. We need to switch everything to
sources.cmake.

Change-Id: I52e56e87a1ac5534b88a372ad68a1052fb019b67
Reviewed-on: https://boringssl-review.googlesource.com/24084
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-12-12 20:58:58 +00:00
Steven Valdez f98b582ded Fix tls13_variant check to check max_version.
Change-Id: I946e8903d745b0bf0c48701d16aa866464233ab7
Reviewed-on: https://boringssl-review.googlesource.com/24044
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2017-12-12 17:20:07 +00:00
David Benjamin 6fe960d174 Enable __asm__ and uint128_t code in clang-cl.
It actually works fine. I just forgot one of the typedefs last time.
This gives a roughly 2x improvement on P-256 in clang-cl +
OPENSSL_SMALL, the configuration used by Chrome.

Before:
Did 1302 ECDH P-256 operations in 1015000us (1282.8 ops/sec)
Did 4250 ECDSA P-256 signing operations in 1047000us (4059.2 ops/sec)
Did 1750 ECDSA P-256 verify operations in 1094000us (1599.6 ops/sec)

After:
Did 3250 ECDH P-256 operations in 1078000us (3014.8 ops/sec)
Did 8250 ECDSA P-256 signing operations in 1016000us (8120.1 ops/sec)
Did 3250 ECDSA P-256 verify operations in 1063000us (3057.4 ops/sec)

(These were taken on a VM, so the measurements are extremely noisy, but
this sort of improvement is visible regardless.)

Alas, we do need a little extra bit of fiddling because division does
not work (crbug.com/787617).

Bug: chromium:787617
Update-Note: This removes the MSan uint128_t workaround which does not
    appear to be necessary anymore.
Change-Id: I8361314608521e5bdaf0e7eeae7a02c33f55c69f
Reviewed-on: https://boringssl-review.googlesource.com/23984
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-12-11 22:46:26 +00:00
David Benjamin 650d8c393e Implement TLS 1.3 early exporters.
Bug: 222
Change-Id: I33ee56358a62afcd9c3921026d55efcc543a5c11
Reviewed-on: https://boringssl-review.googlesource.com/23945
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-12-11 21:33:26 +00:00
David Benjamin 8f53fc0a94 Fix fuzzer mode suppressions.
Change-Id: Ic79f189c0bb2abf5d87f59ee410cafb4fb116ab8
Reviewed-on: https://boringssl-review.googlesource.com/24004
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-12-11 20:12:11 +00:00
Andres Erbsen 46304abf7d ec/p256.c: fiat-crypto field arithmetic (64, 32)
The fiat-crypto-generated code uses the Montgomery form implementation
strategy, for both 32-bit and 64-bit code.

64-bit throughput seems slower, but the difference is smaller than noise between repetitions (-2%?)

32-bit throughput has decreased significantly for ECDH (-40%). I am
attributing this to the change from varibale-time scalar multiplication
to constant-time scalar multiplication. Due to the same bottleneck,
ECDSA verification still uses the old code (otherwise there would have
been a 60% throughput decrease). On the other hand, ECDSA signing
throughput has increased slightly (+10%), perhaps due to the use of a
precomputed table of multiples of the base point.

64-bit benchmarks (Google Cloud Haswell):

with this change:
Did 9126 ECDH P-256 operations in 1009572us (9039.5 ops/sec)
Did 23000 ECDSA P-256 signing operations in 1039832us (22119.0 ops/sec)
Did 8820 ECDSA P-256 verify operations in 1024242us (8611.2 ops/sec)

master (40e8c921ca):
Did 9340 ECDH P-256 operations in 1017975us (9175.1 ops/sec)
Did 23000 ECDSA P-256 signing operations in 1039820us (22119.2 ops/sec)
Did 8688 ECDSA P-256 verify operations in 1021108us (8508.4 ops/sec)

benchmarks on ARMv7 (LG Nexus 4):

with this change:
Did 150 ECDH P-256 operations in 1029726us (145.7 ops/sec)
Did 506 ECDSA P-256 signing operations in 1065192us (475.0 ops/sec)
Did 363 ECDSA P-256 verify operations in 1033298us (351.3 ops/sec)

master (2fce1beda0):
Did 245 ECDH P-256 operations in 1017518us (240.8 ops/sec)
Did 473 ECDSA P-256 signing operations in 1086281us (435.4 ops/sec)
Did 360 ECDSA P-256 verify operations in 1003846us (358.6 ops/sec)

64-bit tables converted as follows:

import re, sys, math

p = 2**256 - 2**224 + 2**192 + 2**96 - 1
R = 2**256

def convert(t):
    x0, s1, x1, s2, x2, s3, x3 = t.groups()
    v = int(x0, 0) + 2**64 * (int(x1, 0) + 2**64*(int(x2,0) + 2**64*(int(x3, 0)) ))
    w = v*R%p
    y0 = hex(w%(2**64))
    y1 = hex((w>>64)%(2**64))
    y2 = hex((w>>(2*64))%(2**64))
    y3 = hex((w>>(3*64))%(2**64))
    ww = int(y0, 0) + 2**64 * (int(y1, 0) + 2**64*(int(y2,0) + 2**64*(int(y3, 0)) ))
    if ww != v*R%p:
        print(x0,x1,x2,x3)
        print(hex(v))
        print(y0,y1,y2,y3)
        print(hex(w))
        print(hex(ww))
        assert 0
    return '{'+y0+s1+y1+s2+y2+s3+y3+'}'

fe_re = re.compile('{'+r'(\s*,\s*)'.join(r'(\d+|0x[abcdefABCDEF0123456789]+)' for i in range(4)) + '}')
print (re.sub(fe_re, convert, sys.stdin.read()).rstrip('\n'))

32-bit tables converted from 64-bit tables

Change-Id: I52d6e5504fcb6ca2e8b0ee13727f4500c80c1799
Reviewed-on: https://boringssl-review.googlesource.com/23244
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-12-11 17:55:46 +00:00
David Benjamin 21baf6421a Fix CustomExtensions-Server-EarlyDataAccepted test.
It's misnamed but, more importantly, doesn't do anything because the
test client isn't sending early data to begin with. We really need to
make these tests less error-prone to write. With this fix, the test
actually notices if we remove the server-side 0-RTT check.

Also remove MaxEarlyDataSize from the other server tests which
erroneously set it. Any test with sets that was likely copy-and-pasted
incorrectly.

Change-Id: Idc24bc1590e0316946022341185285418ab8c77b
Reviewed-on: https://boringssl-review.googlesource.com/23944
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-12-11 15:54:15 +00:00
David Benjamin eb9232f06f Fully reduce scalars in EC_POINT_mul.
Along the way, this allows us to tidy up the invariants associated with
EC_SCALAR. They were fuzzy around ec_point_mul_scalar and some
computations starting from the digest in ECDSA. The latter I've put into
the type system with EC_LOOSE_SCALAR.

As for the former, Andres points out that particular EC implementations
are only good for scalars within a certain range, otherwise you may need
extra work to avoid the doubling case. To simplify curve
implementations, we reduce them fully rather than do the looser bit size
check, so they can have the stronger precondition to work with.

Change-Id: Iff9a0404f89adf8f7f914f8e8246c9f3136453f1
Reviewed-on: https://boringssl-review.googlesource.com/23664
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-12-08 17:55:54 +00:00
David Benjamin 2b63addf6a Use uint32_t for unicode code points.
The newer clang-cl is unhappy about the tautological comparison on
Windows, but the comparison itself is unnecessary anyway, since the
values will never exceed uint32_t.

I think the reason it's not firing elsewhere is because on other 64-bit
platforms, it is not tautological because long is 64-bit. On other
32-bit platforms, I'm not sure we actually have a standalone trunk clang
builder right now.

Update-Note: UTF8_getc and UTF8_putc were unexported. No one appears to
    be calling them. (We're a crypto library, not a Unicode library.)
Change-Id: I0949ddea3131dca5f55d04e672c3ccf2915c41ab
Reviewed-on: https://boringssl-review.googlesource.com/23844
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-12-08 17:51:34 +00:00
David Benjamin 296a61d600 bn/asm/rsaz-avx2.pl: fix digit correction bug in rsaz_1024_mul_avx2.
Credit to OSS-Fuzz for finding this.

CVE-2017-3738

(Imported from upstream's 5630661aecbea5fe3c4740f5fea744a1f07a6253 and
77d75993651b63e872244a3256e37967bb3c3e9e.)

Confirmed with Intel SDE that the fix makes the test vector pass and
that, without the fix, the test vector does not. (Well, we knew the
latter already, since it was our test vector.)

Change-Id: I167aa3407ddab3b434bacbd18e099c55aa40ac4c
Reviewed-on: https://boringssl-review.googlesource.com/23884
Reviewed-by: Adam Langley <agl@google.com>
2017-12-07 16:54:32 +00:00
David Benjamin 2bc937068d Add X509_NAME_get0_der from OpenSSL 1.1.0.
Change-Id: Iaa616a09f944ce720c11236b031d0fa9deb47db3
Reviewed-on: https://boringssl-review.googlesource.com/23864
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-12-06 17:49:04 +00:00
David Benjamin d8dbde79f9 Don't allow negative EC_KEY private keys.
We check that the private key is less than the order, but we forgot the
other end.

Update-Note: It's possible some caller was relying on this, but since
    that function already checked the other half of the range, I'm
    expecting this to be a no-op change.

Change-Id: I4a53357d7737735b3cfbe97d379c8ca4eca5d5ac
Reviewed-on: https://boringssl-review.googlesource.com/23665
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2017-12-05 19:46:27 +00:00
David Benjamin 6979c7e8eb Disable Clang -Wtautological-constant-compare.
This is a recent Clang warning, but it's far too aggressive. The earlier
unsigned long silliness was worth fixing, but it otherwise complains on
32-bit platforms with:

  if (some_size_t > 0xffffffff) {
    ...
  }

which is unreasonable as, on 64-bit platforms, this check is meaningful
and requiring the programmer add ifdefs is error-prone. This matches
Chromium in https://crbug.com/767059.

Bug: chromium:767059
Change-Id: I0bb0f3a4b60f222e9d1b3c569471fbcf5518caed
Reviewed-on: https://boringssl-review.googlesource.com/23845
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2017-12-05 19:34:47 +00:00
David Benjamin 56d5d7085d Update tools.
The newer clang should hopefully fix the new linux_clang_cfi bot.

Note the VS2017 revision actually went backwards due to
https://chromium.googlesource.com/chromium/src/+/db45606398cf4389bf332b0cdcffd04e7de4a4f6

Change-Id: Icaca7a57596f063ccca490917d4b78813f2e9537
Reviewed-on: https://boringssl-review.googlesource.com/23824
Reviewed-by: Adam Langley <agl@google.com>
2017-12-04 21:39:54 +00:00
David Benjamin 494e4d0e89 Add an option for False Start without ALPN.
We can probably do this globally at this point since the cipher
requirements are much more restrict than they were in the beginning.
(Firefox, in particular, has done so far a while.) For now add a flag
since some consumer wanted this.

I'll see about connecting it to a Chrome field trial after our breakage
budget is no longer reserved for TLS 1.3.

Change-Id: Ib61dd5aae2dfd48b56e79873a7f3061a7631a5f8
Reviewed-on: https://boringssl-review.googlesource.com/23725
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-12-04 21:20:46 +00:00
David Benjamin a5462d3050 Actually deprecate ERR_remove_thread_state.
Change-Id: I1f22e51bff8714550fbc73b116c08894c5b24d3d
Reviewed-on: https://boringssl-review.googlesource.com/23804
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-12-04 17:04:27 +00:00
Michał Janiszewski d3ec6f1adb Add missing errno.h include to bio_test.cc
This fixes compilation on aarch64 and other architectures for Android.

Change-Id: I0b09ab06858c92d07e2376e244a4626a6af5037b
Reviewed-on: https://boringssl-review.googlesource.com/23764
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-12-04 01:32:37 +00:00
Adam Langley bc37ad91fe Fix alignment-violating cast.
Change-Id: Id8b69bb6103dd938f4c6d0d2ec24f3d50ba5513c
Update-Note: fixes b/70034392
Reviewed-on: https://boringssl-review.googlesource.com/23744
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-12-01 22:32:17 +00:00
Steven Valdez 9986f6b045 Fix renegotiation with TLS 1.3 draft 22.
Change-Id: I87edf7e1fee07da4bc93cc7ab524b79991a4206e
Reviewed-on: https://boringssl-review.googlesource.com/23724
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-12-01 17:56:55 +00:00
David Benjamin 48eaa28a12 Make EC_POINT_mul work with arbitrary BIGNUMs again.
Rejecting values where we'd previous called BN_nnmod may have been
overly ambitious. In the long run, all the supported ECC APIs (ECDSA*,
ECDH_compute_key, and probably some additional new ECDH API) will be
using the EC_SCALAR version anyway, so this doesn't really matter.

Change-Id: I79cd4015f2d6daf213e4413caa2a497608976f93
Reviewed-on: https://boringssl-review.googlesource.com/23584
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-30 21:58:17 +00:00
David Benjamin 2fc4f362cd Revert "Support high tag numbers in CBS/CBB."
This reverts commit 66801feb17. This
turned out to break a lot more than expected. Hopefully we can reland it
soon, but we need to fix up some consumers first.

Note due to work that went in later, this is not a trivial revert and
should be re-reviewed.

Change-Id: I6474b67cce9a8aa03f722f37ad45914b76466bea
Reviewed-on: https://boringssl-review.googlesource.com/23644
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-30 21:57:17 +00:00
David Benjamin 095b6c9baa Also add a decoupled OBJ_obj2txt.
We need it in both directions. Also I missed that in OBJ_obj2txt we
allowed uint64_t components, but in my new OBJ_txt2obj we only allowed
uint32_t. For consistency, upgrade that to uint64_t.

Bug: chromium:706445
Change-Id: I38cfeea8ff64b9acf7998e552727c6c3b2cc600f
Reviewed-on: https://boringssl-review.googlesource.com/23544
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-30 18:21:48 +00:00
Steven Valdez 1530ef3ec5 Add early data input from file.
Change-Id: I93a54e7a67acddb196ed53ce7fe49c718553948d
Reviewed-on: https://boringssl-review.googlesource.com/23604
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-30 17:29:45 +00:00
David Benjamin fb535892e5 runner: Rewrite some more parsers.
These were easy.

Change-Id: I5fc764b83d641b08b58ccbff36dbd28cb66efed0
Reviewed-on: https://boringssl-review.googlesource.com/23564
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-30 17:05:06 +00:00
Steven Valdez c5c31abe2b Enforce compression_method in TLS 1.3 draft 22.
Change-Id: Ic99a949258e62cad168c2c39507ca63100a8ffe5
Reviewed-on: https://boringssl-review.googlesource.com/23264
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-29 22:19:04 +00:00
Steven Valdez e6cefe41bb Update PR 1091 CL to use draft22 version.
Change-Id: Ifa811262fbca22222656da530f97daac3dcd6a5b
Reviewed-on: https://boringssl-review.googlesource.com/22944
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2017-11-29 16:11:24 +00:00
David Benjamin fc9c67599d Bound the input to the bn_mod_exp fuzzer.
This is not a speedy operation, so the fuzzers need a bit of help to
avoid timeouts.

Bug: chromium:786049
Change-Id: Ib56281b63eb6c895057f21254f0cc7c5c2d85ee4
Reviewed-on: https://boringssl-review.googlesource.com/23484
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-28 21:48:00 +00:00
David Benjamin a7673facf8 runner: Parse CertificateRequest with byteReader.
Bug: 212
Change-Id: I0ad4df330360789b16fc9db70565abdb3ae42a8f
Reviewed-on: https://boringssl-review.googlesource.com/23448
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-11-28 18:37:39 +00:00
David Benjamin 28b267b357 runner: Parse Certificate with byteReader.
Bug: 212
Change-Id: Ife51516ef0642730e601e146028b16ded99ab7ba
Reviewed-on: https://boringssl-review.googlesource.com/23447
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-28 17:42:49 +00:00
David Benjamin bd911af514 runner: Parse SH/HRR/EE with byteReader.
Bug: 212
Change-Id: I454db0bfd59bac3729338c6f8d9e51efde0735eb
Reviewed-on: https://boringssl-review.googlesource.com/23446
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-28 17:03:39 +00:00
David Benjamin 7ce2378750 runner: Send the right alert for handshake message parsing failures.
This throws me off every time.

Change-Id: I19848927fe821f7656dea0343361d70dae4007c9
Reviewed-on: https://boringssl-review.googlesource.com/23445
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-28 16:55:49 +00:00
David Benjamin 47b8f00fdc Reimplement OBJ_txt2obj and add a lower-level function.
OBJ_txt2obj is currently implemented using BIGNUMs which is absurd. It
also depends on the giant OID table, which is undesirable. Write a new
one and expose the low-level function so Chromium can use it without the
OID table.

Bug: chromium:706445
Change-Id: I61ff750a914194f8776cb8d81ba5d3eb5eaa3c3d
Reviewed-on: https://boringssl-review.googlesource.com/23364
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-11-27 21:29:00 +00:00
David Benjamin be8c8b4b1d runner: Add a byteReader type and convert ClientHello parsing.
Bug: 212
Change-Id: Iecbd8fddef1b55a438947ad60780e08cb4260c48
Reviewed-on: https://boringssl-review.googlesource.com/23444
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-27 21:18:40 +00:00
Steven Valdez 8c9ceadc58 Add switch to enable draft 22.
Change-Id: I60dc085fa02c152adb12a505b453fe8f84670d8b
Reviewed-on: https://boringssl-review.googlesource.com/23464
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-27 20:51:30 +00:00
David Benjamin 56aaf164ac Pretty-print large INTEGERs and ENUMERATEDs in hex.
This avoids taking quadratic time to pretty-print certificates with
excessively large integer fields. Very large integers aren't any more
readable in decimal than hexadecimal anyway, and the i2s_* functions
will parse either form.

Found by libFuzzer.

Change-Id: Id586cd1b0eef8936d38ff50433ae7c819f0054f3
Reviewed-on: https://boringssl-review.googlesource.com/23424
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2017-11-27 18:38:50 +00:00
David Benjamin 27bc0f26c8 Fix CBS tag class docs.
Change-Id: Ia7b3b5d9ce833a9cdfb94c8e0923f3cf17555fdd
Reviewed-on: https://boringssl-review.googlesource.com/23449
Reviewed-by: Adam Langley <agl@google.com>
2017-11-27 17:47:47 +00:00
Daniel Wagner-Hall 2fce1beda0 Remove spurious ;
DECLARE_STACK_OF adds a trailing ; so we don't need a second one added
here.

Compiling a project using boringssl which uses -Werror,-Wextra-semi I
get errors:

```
third_party/boringssl/include/openssl/stack.h:374:1: error: extra ';' outside of a function [-Werror,-Wextra-semi]
DEFINE_STACK_OF(void)
^
third_party/boringssl/include/openssl/stack.h:355:3: note: expanded from macro 'DEFINE_STACK_OF'
  BORINGSSL_DEFINE_STACK_OF_IMPL(type, type *, const type *) \
  ^
third_party/boringssl/include/openssl/stack.h:248:25: note: expanded from macro 'BORINGSSL_DEFINE_STACK_OF_IMPL'
  DECLARE_STACK_OF(name);                                                      \
                        ^
third_party/boringssl/include/openssl/stack.h:375:1: error: extra ';' outside of a function [-Werror,-Wextra-semi]
DEFINE_SPECIAL_STACK_OF(OPENSSL_STRING)
^
third_party/boringssl/include/openssl/stack.h:369:3: note: expanded from macro 'DEFINE_SPECIAL_STACK_OF'
  BORINGSSL_DEFINE_STACK_OF_IMPL(type, type, const type)
  ^
third_party/boringssl/include/openssl/stack.h:248:25: note: expanded from macro 'BORINGSSL_DEFINE_STACK_OF_IMPL'
  DECLARE_STACK_OF(name);                                                      \
                        ^
2 errors generated.
```

Change-Id: Icc39e2341eb76544be72d2d7d0bd29e2f1ed0bf9
Reviewed-on: https://boringssl-review.googlesource.com/23404
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-24 13:29:07 +00:00
David Benjamin e3b2a5d30d Const-correct X509_ALGOR_get0.
Matches the OpenSSL 1.1.0 spelling, which is what we advertise in
OPENSSL_VERSION_NUMBER now. Otherwise third-party code which uses it
will, in the long term, need ifdefs. Note this will require updates to
any existing callers (there appear to only be a couple of them), but it
should be straightforward.

Change-Id: I9dd1013609abca547152728a293529055dacc239
Reviewed-on: https://boringssl-review.googlesource.com/23325
Reviewed-by: Adam Langley <agl@google.com>
2017-11-22 22:52:38 +00:00
David Benjamin 61e9245543 Use some of the word-based functions for ECDSA verification.
This is only a hair faster than the signing change, but still something.
I kept the call to BN_mod_inverse_odd as that appears to be faster
(constant time is not a concern for verification).

Before:
Did 22855 ECDSA P-224 verify operations in 3015099us (7580.2 ops/sec)
Did 21276 ECDSA P-256 verify operations in 3083284us (6900.4 ops/sec)
Did 2635 ECDSA P-384 verify operations in 3032582us (868.9 ops/sec)
Did 1240 ECDSA P-521 verify operations in 3068631us (404.1 ops/sec)

After:
Did 23310 ECDSA P-224 verify operations in 3056226us (7627.1 ops/sec)
Did 21210 ECDSA P-256 verify operations in 3035765us (6986.7 ops/sec)
Did 2666 ECDSA P-384 verify operations in 3023592us (881.7 ops/sec)
Did 1209 ECDSA P-521 verify operations in 3054040us (395.9 ops/sec)

Change-Id: Iec995b1a959dbc83049d0f05bdc525c14a95c28e
Reviewed-on: https://boringssl-review.googlesource.com/23077
Reviewed-by: Adam Langley <agl@google.com>
2017-11-22 22:52:04 +00:00
David Benjamin 86c2b854b0 Don't use BN_nnmod to convert from field element to scalar.
Hasse's theorem implies at most one subtraction is necessary. This is
still using BIGNUM for now because field elements
(EC_POINT_get_affine_coordinates_GFp) are BIGNUMs.

This gives an additional 2% speedup for signing.

Before:
Did 16000 ECDSA P-224 signing operations in 1064799us (15026.3 ops/sec)
Did 19000 ECDSA P-256 signing operations in 1007839us (18852.2 ops/sec)
Did 1078 ECDSA P-384 signing operations in 1079413us (998.7 ops/sec)
Did 484 ECDSA P-521 signing operations in 1083616us (446.7 ops/sec)

After:
Did 16000 ECDSA P-224 signing operations in 1054918us (15167.1 ops/sec)
Did 20000 ECDSA P-256 signing operations in 1037338us (19280.1 ops/sec)
Did 1045 ECDSA P-384 signing operations in 1049073us (996.1 ops/sec)
Did 484 ECDSA P-521 signing operations in 1085492us (445.9 ops/sec)

Change-Id: I2bfe214f968eca7a8e317928c0f3daf1a14bca90
Reviewed-on: https://boringssl-review.googlesource.com/23076
Reviewed-by: Adam Langley <agl@google.com>
2017-11-22 22:51:53 +00:00
David Benjamin a838f9dc7e Make ECDSA signing 10% faster and plug some timing leaks.
None of the asymmetric crypto we inherented from OpenSSL is
constant-time because of BIGNUM. BIGNUM chops leading zeros off the
front of everything, so we end up leaking information about the first
word, in theory. BIGNUM functions additionally tend to take the full
range of inputs and then call into BN_nnmod at various points.

All our secret values should be acted on in constant-time, but k in
ECDSA is a particularly sensitive value. So, ecdsa_sign_setup, in an
attempt to mitigate the BIGNUM leaks, would add a couple copies of the
order.

This does not work at all. k is used to compute two values: k^-1 and kG.
The first operation when computing k^-1 is to call BN_nnmod if k is out
of range. The entry point to our tuned constant-time curve
implementations is to call BN_nnmod if the scalar has too many bits,
which this causes. The result is both corrections are immediately undone
but cause us to do more variable-time work in the meantime.

Replace all these computations around k with the word-based functions
added in the various preceding CLs. In doing so, replace the BN_mod_mul
calls (which internally call BN_nnmod) with Montgomery reduction. We can
avoid taking k^-1 out of Montgomery form, which combines nicely with
Brian Smith's trick in 3426d10119. Along
the way, we avoid some unnecessary mallocs.

BIGNUM still affects the private key itself, as well as the EC_POINTs.
But this should hopefully be much better now. Also it's 10% faster:

Before:
Did 15000 ECDSA P-224 signing operations in 1069117us (14030.3 ops/sec)
Did 18000 ECDSA P-256 signing operations in 1053908us (17079.3 ops/sec)
Did 1078 ECDSA P-384 signing operations in 1087853us (990.9 ops/sec)
Did 473 ECDSA P-521 signing operations in 1069835us (442.1 ops/sec)

After:
Did 16000 ECDSA P-224 signing operations in 1064799us (15026.3 ops/sec)
Did 19000 ECDSA P-256 signing operations in 1007839us (18852.2 ops/sec)
Did 1078 ECDSA P-384 signing operations in 1079413us (998.7 ops/sec)
Did 484 ECDSA P-521 signing operations in 1083616us (446.7 ops/sec)

Change-Id: I2a25e90fc99dac13c0616d0ea45e125a4bd8cca1
Reviewed-on: https://boringssl-review.googlesource.com/23075
Reviewed-by: Adam Langley <agl@google.com>
2017-11-22 22:51:40 +00:00
David Benjamin 66801feb17 Support high tag numbers in CBS/CBB.
Android's attestion format uses some ludicrously large tag numbers:
https://developer.android.com/training/articles/security-key-attestation.html#certificate_schema

Add support for these in CBS/CBB. The public API does not change for
callers who were using the CBS_ASN1_* constants, but it is no longer the
case that tag representations match their DER encodings for small tag
numbers.

Chromium needs https://chromium-review.googlesource.com/#/c/chromium/src/+/783254,
but otherwise I don't expect this to break things.

Bug: 214
Change-Id: I9b5dc27ae3ea020e9edaabec4d665fd73da7d31e
Reviewed-on: https://boringssl-review.googlesource.com/23304
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-22 22:34:05 +00:00
David Benjamin 02514002fd Use dec/jnz instead of loop in bn_add_words and bn_sub_words.
Imported from upstream's a78324d95bd4568ce2c3b34bfa1d6f14cddf92ef. I
think the "regression" part of that change is some tweak to BN_usub and
I guess the bn_*_words was to compensate for it, but we may as well
import it. Apparently the loop instruction is terrible.

Before:
Did 39871000 bn_add_words operations in 1000002us (39870920.3 ops/sec)
Did 38621750 bn_sub_words operations in 1000001us (38621711.4 ops/sec)

After:
Did 64012000 bn_add_words operations in 1000007us (64011551.9 ops/sec)
Did 81792250 bn_sub_words operations in 1000002us (81792086.4 ops/sec)

loop sets no flags (even doing the comparison to zero without ZF) while
dec sets all flags but CF, so Andres and I are assuming that because
this prevents Intel from microcoding it to dec/jnz, they otherwise can't
be bothered to add more circuitry since every compiler has internalized
by now to never use loop.

Change-Id: I3927cd1c7b707841bbe9963e3d4afd7ba9bd9b36
Reviewed-on: https://boringssl-review.googlesource.com/23344
Reviewed-by: Adam Langley <agl@google.com>
2017-11-22 21:56:05 +00:00
David Benjamin 2056d7290a Remove DSA_sign_setup too.
Change-Id: Ib406e7d1653fa57a863dbd5d4eb04401caf5de0a
Reviewed-on: https://boringssl-review.googlesource.com/23284
Reviewed-by: Adam Langley <agl@google.com>
2017-11-22 21:01:11 +00:00
David Benjamin 42a8cbe37c Remove ECDSA_sign_setup and friends.
These allow precomputation of k, but bypass our nonce hardening and also
make it harder to excise BIGNUM. As a bonus, ECDSATest.SignTestVectors
is now actually covering the k^-1 and r computations.

Change-Id: I4c71dae162874a88a182387ac43999be9559ddd7
Reviewed-on: https://boringssl-review.googlesource.com/23074
Reviewed-by: Adam Langley <agl@google.com>
2017-11-22 20:23:40 +00:00
David Benjamin 8dc226ca8f Add some missing OpenSSL 1.1.0 accessors.
wpa_supplicant appear to be using these.

Change-Id: I1f220cae69162901bcd9452e8daf67379c5e276c
Reviewed-on: https://boringssl-review.googlesource.com/23324
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-22 18:43:38 +00:00
David Benjamin 855d5046c7 Unwind legacy SSL_PRIVATE_KEY_METHOD hooks.
After much procrastinating, we finally moved Chromium to the new stuff.
We can now delete this. This is a breaking change for
SSL_PRIVATE_KEY_METHOD consumers, but it should be trivial (remove some
unused fields in the struct). I've bumped BORINGSSL_API_VERSION to ease
any multi-sided changes that may be needed.

Change-Id: I9fe562590ad938bcb4fcf9af0fadeff1d48745fb
Reviewed-on: https://boringssl-review.googlesource.com/23224
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-11-21 17:48:09 +00:00
David Benjamin 67623735e0 Fix memory leak on sk_X509_EXTENSION_push failure.
(Imported from upstream's c29f83c05f3a3c5641c5ddf054789a29d2163bf3.)

ext was being leaked. Upstream also did some stuff around *x which
wasn't strictly necessary (usually OpenSSL only provides basic
exception safety, not strong exception safety), but ah well.

Change-Id: I52d230990b05501b4cee6deee8dcacba4a926c18
Reviewed-on: https://boringssl-review.googlesource.com/23204
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-21 17:48:00 +00:00
David Benjamin c367ee5439 Add a CFI build flag.
This uses Clang's CFI feature.

Bug: 201
Change-Id: I7a42ec73dc8bfb3893ec69f2d2f4d7e3a2fd2cc4
Reviewed-on: https://boringssl-review.googlesource.com/23225
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-11-21 17:40:40 +00:00
Adam Langley 8c565fa86c Include a couple of missing header files.
mem.h for |OPENSSL_cleanse| and bn/internal.h for things like
|bn_less_than_words| and |bn_correct_top|.

Change-Id: I3c447a565dd9e4f18fb2ff5d59f80564b4df8cea
Reviewed-on: https://boringssl-review.googlesource.com/23164
Reviewed-by: Adam Langley <agl@google.com>
2017-11-20 20:36:38 +00:00
David Benjamin 8793942c5c Fix fuzzer mode suppressions.
Change-Id: I82f92019dccfaf927f7180a5af53c9ffae111861
Reviewed-on: https://boringssl-review.googlesource.com/23145
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-20 18:44:18 +00:00
David Benjamin 6d218d6d7a Remove unused function.
Change-Id: Id12ab478b6ba441fb1b6f4c2f9479384fc3fbdb6
Reviewed-on: https://boringssl-review.googlesource.com/23144
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2017-11-20 18:32:44 +00:00
David Benjamin 0a5f006736 Test that EC_POINT_mul works with the order.
|EC_POINT_mul| is almost exclusively used with reduced scalars, with
this exception. This comes from consumers following NIST SP 800-56A
section 5.6.2.3.2. (Though all our curves have cofactor one, so this
check isn't useful.)

Add a test for this so we don't accidentally break it.

Change-Id: I42492db38a1ea03acec4febdd7945c8a3933530a
Reviewed-on: https://boringssl-review.googlesource.com/23084
Reviewed-by: Adam Langley <agl@google.com>
2017-11-20 18:32:30 +00:00
David Benjamin e7c95d91f8 Run TLS 1.3 tests at all variants and fix bugs.
We were only running a random subset of TLS 1.3 tests with variants and
let a lot of bugs through as a result.

- HelloRetryRequest-EmptyCookie wasn't actually testing what we were
  trying to test.

- The second HelloRetryRequest detection needs tweaks in draft-22.

- The empty HelloRetryRequest logic can't be based on non-empty
  extensions in draft-22.

- We weren't sending ChangeCipherSpec correctly in HRR or testing it
  right.

- Rework how runner reads ChangeCipherSpec by setting a flag which
  affects the next readRecord. This cuts down a lot of cases and works
  correctly if the client didn't send early data. (In that case, we
  don't flush CCS until EndOfEarlyData and runner deadlocks waiting for
  the ChangeCipherSpec to arrive.)

Change-Id: I559c96ea3a8b350067e391941231713c6edb2f78
Reviewed-on: https://boringssl-review.googlesource.com/23125
Reviewed-by: Steven Valdez <svaldez@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-20 18:19:18 +00:00
David Benjamin 3bba5ccf35 Add EndOfEarlyData to per-message tests.
Change-Id: I9da9734625d1d9d2c783830d8b4aecd34f51acc6
Reviewed-on: https://boringssl-review.googlesource.com/23124
Reviewed-by: Steven Valdez <svaldez@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-20 18:10:38 +00:00
David Benjamin ac4d5346ad Add missing error path.
Error paths must always have OPENSSL_PUT_ERROR.

Change-Id: I0ed8c8288484a4ea69ec58317064ad3cd90ddd64
Reviewed-on: https://boringssl-review.googlesource.com/23104
Reviewed-by: Steven Valdez <svaldez@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-20 16:59:08 +00:00
David Benjamin b8d677bfd0 Deduplicate built-in curves and give custom curves an order_mont.
I still need to revive the original CL, but right now I'm interested in
giving every EC_GROUP an order_mont and having different ownership of
that field between built-in and custom groups is kind of a nuisance. If
I'm going to do that anyway, better to avoid computing the entire
EC_GROUP in one go.

I'm using some manual locking rather than CRYPTO_once here so that it
behaves well in the face of malloc errors. Not that we especially care,
but it was easy to do.

This speeds up our ECDH benchmark a bit which otherwise must construct the
EC_GROUP each time (matching real world usage).

Before:
Did 7619 ECDH P-224 operations in 1003190us (7594.8 ops/sec)
Did 7518 ECDH P-256 operations in 1060844us (7086.8 ops/sec)
Did 572 ECDH P-384 operations in 1055878us (541.7 ops/sec)
Did 264 ECDH P-521 operations in 1062375us (248.5 ops/sec)

After:
Did 8415 ECDH P-224 operations in 1066695us (7888.9 ops/sec)
Did 7952 ECDH P-256 operations in 1022819us (7774.6 ops/sec)
Did 572 ECDH P-384 operations in 1055817us (541.8 ops/sec)
Did 264 ECDH P-521 operations in 1060008us (249.1 ops/sec)

Bug: 20
Change-Id: I7446cd0a69a840551dcc2dfabadde8ee1e3ff3e2
Reviewed-on: https://boringssl-review.googlesource.com/23073
Reviewed-by: Adam Langley <agl@google.com>
2017-11-20 16:52:03 +00:00
David Benjamin 66f8235510 Enforce some bounds and invariants on custom curves.
Later code will take advantage of these invariants. Enforcing them on
custom curves avoids making them go through a custom codepath.

Change-Id: I23cee72a90c2e4846b41e03e6be26bc3abeb4a45
Reviewed-on: https://boringssl-review.googlesource.com/23072
Reviewed-by: Adam Langley <agl@google.com>
2017-11-20 16:27:51 +00:00
David Benjamin a08bba51a5 Add bn_mod_exp_mont_small and bn_mod_inverse_prime_mont_small.
These can be used to invert values in ECDSA. Unlike their BIGNUM
counterparts, the caller is responsible for taking values in and out of
Montgomery domain. This will save some work later on in the ECDSA
computation.

Change-Id: Ib7292900a0fdeedce6cb3e9a9123c94863659043
Reviewed-on: https://boringssl-review.googlesource.com/23071
Reviewed-by: Adam Langley <agl@google.com>
2017-11-20 16:23:48 +00:00
David Benjamin 40e4ecb793 Add "small" variants of Montgomery logic.
These use the square and multiply functions added earlier.

Change-Id: I723834f9a227a9983b752504a2d7ce0223c43d24
Reviewed-on: https://boringssl-review.googlesource.com/23070
Reviewed-by: Adam Langley <agl@google.com>
2017-11-20 16:23:01 +00:00
David Benjamin a01aa9aa9f Split BN_from_montgomery_word into a non-BIGNUM core.
bn_from_montgomery_in_place is actually constant-time. It is, of course,
only used by non-constant-time BIGNUM callers, but that will soon be
fixed.

Change-Id: I2b2c9943dc3b8d6a4b5b19a5bc4fa9ebad532bac
Reviewed-on: https://boringssl-review.googlesource.com/23069
Reviewed-by: Adam Langley <agl@google.com>
2017-11-20 16:22:43 +00:00
David Benjamin 6bc18a3bd4 Add bn_mul_small and bn_sqr_small.
As part of excising BIGNUM from EC scalars, we will need a "words"
version of BN_mod_mul_montgomery. That, in turn, requires BN_sqr and
BN_mul for cases where we don't have bn_mul_mont.

BN_sqr and BN_mul have a lot of logic in there, with the most complex
cases being not even remotely constant time. Fortunately, those only
apply to RSA-sized numbers, not EC-sized numbers. (With the exception, I
believe, of 32-bit P-521 which just barely exceeds the cutoff.) Imposing
a limit also makes it easier to stack-allocate temporaries (BN_CTX
serves a similar purpose in BIGNUM).

Extract bn_mul_small and bn_sqr_small and test them as part of
bn_tests.txt. Later changes will build on these.

If we end up reusing these functions for RSA in the future (though that
would require tending to the egregiously non-constant-time code in the
no-asm build), we probably want to extract a version where there is an
explicit tmp parameter as in bn_sqr_normal rather than the stack bits.

Change-Id: If414981eefe12d6664ab2f5e991a359534aa7532
Reviewed-on: https://boringssl-review.googlesource.com/23068
Reviewed-by: Adam Langley <agl@google.com>
2017-11-20 16:22:30 +00:00
David Benjamin 64619deaa3 Const-correct some of the low-level BIGNUM functions.
Change-Id: I8c6257e336f54a3a1786df9c4103fcf29177030a
Reviewed-on: https://boringssl-review.googlesource.com/23067
Reviewed-by: Adam Langley <agl@google.com>
2017-11-20 16:20:40 +00:00
David Benjamin bd275702d2 size_t a bunch of bn words bits.
Also replace a pointless call to bn_mul_words with a memset.

Change-Id: Ief30ddab0e84864561b73fe2776bd0477931cf7f
Reviewed-on: https://boringssl-review.googlesource.com/23066
Reviewed-by: Adam Langley <agl@google.com>
2017-11-20 16:20:28 +00:00
David Benjamin 73df153be8 Make BN_generate_dsa_nonce internally constant-time.
This rewrites the internals with a "words" variant that can avoid
bn_correct_top. It still ultimately calls bn_correct_top as the calling
convention is sadly still BIGNUM, but we can lift that calling
convention out incrementally.

Performance seems to be comparable, if not faster.

Before:
Did 85000 ECDSA P-256 signing operations in 5030401us (16897.3 ops/sec)
Did 34278 ECDSA P-256 verify operations in 5048029us (6790.4 ops/sec)

After:
Did 85000 ECDSA P-256 signing operations in 5021057us (16928.7 ops/sec)
Did 34086 ECDSA P-256 verify operations in 5010416us (6803.0 ops/sec)

Change-Id: I1159746dfcc00726dc3f28396076a354556e6e7d
Reviewed-on: https://boringssl-review.googlesource.com/23065
Reviewed-by: Adam Langley <agl@google.com>
2017-11-20 16:18:30 +00:00
David Benjamin b25140c7b6 Fix timing leak in BN_from_montgomery_word.
BN_from_montgomery_word doesn't have a constant memory access pattern.
Replace the pointer trick with constant_time_select_w. There is, of
course, still the bn_correct_top leak pervasive in BIGNUM itself.

I wasn't able to measure a performance on RSA operations before or after
this change, but the benchmarks would vary wildly run to run. But one
would assume the logic here is nothing compared to the actual reduction.

Change-Id: Ide761fde3a091a93679f0a803a287aa5d0d4600d
Reviewed-on: https://boringssl-review.googlesource.com/22904
Reviewed-by: Adam Langley <agl@google.com>
2017-11-20 16:18:09 +00:00
David Benjamin 8db94be1d6 Add ECDSA tests for custom curves.
We don't currently have test coverage for the order_mont bits (or lack
thereof) for custom curves.

Change-Id: I865d547c783226a5a3d3d203e10b0e59bad36984
Reviewed-on: https://boringssl-review.googlesource.com/23064
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2017-11-17 12:18:16 +00:00
Daniel Hirche 74b828f263 Clarify the documentation for |BN_is_bit_set|.
Change-Id: Ic859f19edff281334bd6975dd3c3b2931c901021
Reviewed-on: https://boringssl-review.googlesource.com/23044
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-15 14:23:11 +00:00
David Benjamin e6f30e4ce1 Add tests for post-handshake CCS in draft "22".
The current PR says the sender only skips it during the handshake. Add a
test that we got this right.

Change-Id: Ib27eb942f11d955b8a24e32321efe474037f5254
Reviewed-on: https://boringssl-review.googlesource.com/23024
Reviewed-by: David Benjamin <davidben@google.com>
Reviewed-by: Steven Valdez <svaldez@chromium.org>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-14 05:40:38 +00:00
David Benjamin 13761f2833 Fix TLSInnerPlaintext limit.
See https://github.com/tlswg/tls13-spec/pull/1083. We misread the
original text spec, but it turns out the original spec text required
senders have version-specific maximum send fragments. The PR fixes this
off-by-one issue. Align with the new spec text uniformly.

This is a wire format change for our existing drafts *only if* records
have padding. We don't currently send padding, so this is fine. Unpadded
records continue to be capped at 2^14 bytes of plaintext (or 2^14+1
bytes of TLSInnerPlaintext structure).

Change-Id: I01017cfd13162504bb163dd59afd74aff0896cc4
Reviewed-on: https://boringssl-review.googlesource.com/23004
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-14 05:38:48 +00:00
Steven Valdez ba8f1864c1 Disable 'draft 22' by default.
Change-Id: I1a0f264cbfa0eb5d4adac96d0fc24fa342f2b6a3
Reviewed-on: https://boringssl-review.googlesource.com/22946
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-12 03:26:05 +00:00
David Benjamin 4ddbc7bd0d Fix early data printout in bssl client.
Because the handshake returns early, it should query SSL_in_early_data.

Change-Id: I64d4c0e8de753832207d5c198c50d660f87afac6
Reviewed-on: https://boringssl-review.googlesource.com/22945
Reviewed-by: Steven Valdez <svaldez@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-11 06:35:25 +00:00
David Benjamin ca8c2c7eab Refresh TLS fuzzer corpora.
Change-Id: Ie5055d6d1d33690f27cdd978a0aa696307880579
Reviewed-on: https://boringssl-review.googlesource.com/22964
Reviewed-by: Steven Valdez <svaldez@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2017-11-11 06:34:10 +00:00
Steven Valdez 964b2377d0 Implement PR 1091 (TLS 1.3 draft '22').
This introduces a wire change to Experiment2/Experiment3 over 0RTT, however
as there is never going to be a 0RTT deployment with Experiment2/Experiment3,
this is valid.

Change-Id: Id541d195cbc4bbb3df7680ae2a02b53bb8ae3eab
Reviewed-on: https://boringssl-review.googlesource.com/22744
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-11 06:24:55 +00:00
David Benjamin 3bcbb37552 Fix -early-data documentation.
Change-Id: I76a87ebf2f8be731d6da2381710c1caa60298f6e
Reviewed-on: https://boringssl-review.googlesource.com/22924
Reviewed-by: Steven Valdez <svaldez@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-11 06:19:56 +00:00
David Benjamin a00fd08c2c Use consistent notation in ECDSA_do_verify comments.
Change-Id: Ia0cec71b5f8a6b7f03681b92cfacee13b2a74621
Reviewed-on: https://boringssl-review.googlesource.com/22890
Reviewed-by: Adam Langley <agl@google.com>
2017-11-10 22:44:01 +00:00
David Benjamin d66bbf3413 Tidy up BN_mod_exp_mont.
This was primarily for my own understanding, but this should hopefully
also be clearer and more amenable to using unsigned indices later.

Change-Id: I09cc3d55de0f7d9284d3b3168d8b0446274b2ab7
Reviewed-on: https://boringssl-review.googlesource.com/22889
Reviewed-by: Adam Langley <agl@google.com>
2017-11-10 22:43:54 +00:00
David Benjamin 607f9807e5 Remove BN_TBIT.
Normal shifts do the trick just fine and are less likely to tempt the
compiler into inserting a jump.

Change-Id: Iaa1da1b6f986fd447694fcde8f3525efb9eeaf11
Reviewed-on: https://boringssl-review.googlesource.com/22888
Reviewed-by: Adam Langley <agl@google.com>
2017-11-10 22:43:37 +00:00
David Benjamin bf3f6caaf3 Document some BIGNUM internals.
Change-Id: I8f044febf16afe04da8b176c638111a9574c4d02
Reviewed-on: https://boringssl-review.googlesource.com/22887
Reviewed-by: Adam Langley <agl@google.com>
2017-11-10 22:43:13 +00:00
David Benjamin 0a9222b824 Fix comment typo.
Change-Id: I482093000ee2e4ba371c78b4f7f8e8b121e71640
Reviewed-on: https://boringssl-review.googlesource.com/22886
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2017-11-10 22:22:42 +00:00
David Benjamin 238c274054 Capitalization nit.
We capitalize things Go-style.

Change-Id: Id002efb8a85e4e1886164421bba059d9ca425964
Reviewed-on: https://boringssl-review.googlesource.com/22885
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
2017-11-10 22:22:35 +00:00
David Benjamin 6aedfc137b Remove unnecessary loop over BN_generate_dsa_nonce.
BN_generate_dsa_nonce will never generate a zero value of k.

Change-Id: I06964b815bc82aa678ffbc80664f9d788cf3851d
Reviewed-on: https://boringssl-review.googlesource.com/22884
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-10 22:20:47 +00:00
David Benjamin 896332581e Appease UBSan on pointer alignment.
Even without strict-aliasing, C does not allow casting pointers to types
that don't match their alignment. After this change, UBSan is happy with
our code at default settings but for the negative left shift language
bug.

Note: architectures without unaligned loads do not generate the same
code for memcpy and pointer casts. But even ARMv6 can perform unaligned
loads and stores (ARMv5 couldn't), so we should be okay here.

Before:
Did 11086000 AES-128-GCM (16 bytes) seal operations in 5000391us (2217026.6 ops/sec): 35.5 MB/s
Did 370000 AES-128-GCM (1350 bytes) seal operations in 5005208us (73923.0 ops/sec): 99.8 MB/s
Did 63000 AES-128-GCM (8192 bytes) seal operations in 5029958us (12525.0 ops/sec): 102.6 MB/s
Did 9894000 AES-256-GCM (16 bytes) seal operations in 5000017us (1978793.3 ops/sec): 31.7 MB/s
Did 316000 AES-256-GCM (1350 bytes) seal operations in 5005564us (63129.7 ops/sec): 85.2 MB/s
Did 54000 AES-256-GCM (8192 bytes) seal operations in 5054156us (10684.3 ops/sec): 87.5 MB/s

After:
Did 11026000 AES-128-GCM (16 bytes) seal operations in 5000197us (2205113.1 ops/sec): 35.3 MB/s
Did 370000 AES-128-GCM (1350 bytes) seal operations in 5005781us (73914.5 ops/sec): 99.8 MB/s
Did 63000 AES-128-GCM (8192 bytes) seal operations in 5032695us (12518.1 ops/sec): 102.5 MB/s
Did 9831750 AES-256-GCM (16 bytes) seal operations in 5000010us (1966346.1 ops/sec): 31.5 MB/s
Did 316000 AES-256-GCM (1350 bytes) seal operations in 5005702us (63128.0 ops/sec): 85.2 MB/s
Did 54000 AES-256-GCM (8192 bytes) seal operations in 5053642us (10685.4 ops/sec): 87.5 MB/s

(Tested with the no-asm builds; most of this code isn't reachable
otherwise.)

Change-Id: I025c365d26491abed0116b0de3b7612159e52297
Reviewed-on: https://boringssl-review.googlesource.com/22804
Reviewed-by: Adam Langley <agl@google.com>
2017-11-10 21:07:03 +00:00
David Benjamin 929f842810 Remove custom memcpy and memset from poly1305_vec.
This avoids upsetting the C compiler. UBSan is offended by the alignment
violations in those functions. The business with offset is also
undefined behavior (pointer arithmetic is supposed to stay within a
single object).

There is a small performance cost, however:

Before:
Did 6636000 ChaCha20-Poly1305 (16 bytes) seal operations in 5000475us (1327073.9 ops/sec): 21.2 MB/s
Did 832000 ChaCha20-Poly1305 (1350 bytes) seal operations in 5003481us (166284.2 ops/sec): 224.5 MB/s
Did 155000 ChaCha20-Poly1305 (8192 bytes) seal operations in 5026933us (30833.9 ops/sec): 252.6 MB/s

After:
Did 6508000 ChaCha20-Poly1305 (16 bytes) seal operations in 5000160us (1301558.4 ops/sec): 20.8 MB/s
Did 831000 ChaCha20-Poly1305 (1350 bytes) seal operations in 5002865us (166104.8 ops/sec): 224.2 MB/s
Did 155000 ChaCha20-Poly1305 (8192 bytes) seal operations in 5013204us (30918.4 ops/sec): 253.3 MB/s

(Tested with the no-asm build which disables the custom stitched mode
assembly and ends up using this one.)

Change-Id: I76d74183f1e04ad3726463a8871ee64be04ce674
Reviewed-on: https://boringssl-review.googlesource.com/22784
Reviewed-by: Adam Langley <agl@google.com>
2017-11-10 20:53:30 +00:00
Adam Langley 0967853d68 Add CFI start/end for _aesni_ctr32[_ghash]_6x
These functions don't appear to do any stack manipulation thus all they
need are start/end directives in order for the correct CFI tables to be
emitted.

Change-Id: I4c94a9446030d363fa4bcb7c8975c689df3d21dc
Reviewed-on: https://boringssl-review.googlesource.com/22765
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-09 00:31:14 +00:00
Adam Langley ee2c1f3e68 aesni-gcm-x86_64.pl: sync CFI directives from upstream.
Change-Id: Id70cfc78c8d103117d4c2195206b023a5d51edc3
Reviewed-on: https://boringssl-review.googlesource.com/22764
Commit-Queue: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-09 00:18:23 +00:00
David Benjamin fa60369d6d Add error handling in ASN1_i2d_bio.
(Imported from 950d49d43900e67a1f9d02bc1a053a9fdc5c4257.)

Change-Id: Ia41c5076019b8cb16a9af9247b947fba7b20e87a
Reviewed-on: https://boringssl-review.googlesource.com/22725
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-08 23:20:33 +00:00
David Benjamin b8e2d6327a es/asm/{aes-armv4|bsaes-armv7}.pl: make it work with binutils-2.29.
It's not clear if it's a feature or bug, but binutils-2.29[.1]
interprets 'adr' instruction with Thumb2 code reference differently,
in a way that affects calculation of addresses of constants' tables.

(Imported from upstream's b82acc3c1a7f304c9df31841753a0fa76b5b3cda.)

Change-Id: Ia0f5233a9fcfaf18b9d1164bf1c88217c0cbb60d
Reviewed-on: https://boringssl-review.googlesource.com/22724
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-08 16:53:04 +00:00
Martin Kreichgauer 40e8c921ca change URL type in third_party METADATA files to GIT
Change-Id: Ibaf1b4d64a651c39b073f3c4a7aa861d9c728f8b
Reviewed-on: https://boringssl-review.googlesource.com/22704
Reviewed-by: David Benjamin <davidben@google.com>
2017-11-07 21:38:33 +00:00
Martin Kreichgauer aa4c3f218e fix a typo in third_party/fiat/METADATA
Change-Id: I91626b4e84f4a6b53be94d5e4823c634b6e7a5a1
Reviewed-on: https://boringssl-review.googlesource.com/22684
Reviewed-by: David Benjamin <davidben@google.com>
2017-11-07 19:43:31 +00:00
Daniel Hirche d5dda9b803 Align |BN_div| with its documentation.
Change-Id: Idd0dc9dafb4ea9adbf22257018138c49f7980fee
Reviewed-on: https://boringssl-review.googlesource.com/22604
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-06 22:55:30 +00:00
David Benjamin b1cbe19790 Say a bit more about BIO_METHOD.
The hooks should be self-explanatory, except it's non-obvious that
everything assumes BIOs implement BIO_flush.

Change-Id: If09997d3724c4a7608273dc592dc2d099c4353e9
Reviewed-on: https://boringssl-review.googlesource.com/22664
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-06 19:08:01 +00:00
David Benjamin 5b90eb98f6 Add a -require-any-client-cert flag to bssl server
Useful for testing client cert stuff.

Change-Id: Ieb3cb02a685b22c18cfc50b44170221017889a57
Reviewed-on: https://boringssl-review.googlesource.com/22644
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-06 17:44:20 +00:00
David Benjamin fdd5fed036 Also print name for SSL_SIGN_RSA_PKCS1_MD5_SHA1.
Missed one.

Change-Id: I61394db2dded0741cffa977071be998e3f4e4b50
Reviewed-on: https://boringssl-review.googlesource.com/22645
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-06 17:27:31 +00:00
Adam Langley b2c312d670 curve25519: fiat-crypto field arithmetic.
Each operation was translated from fiat-crypto output using fiat-crypto
prettyprint.py. For example fe_mul is synthesized in
https://github.com/mit-plv/fiat-crypto/blob/master/src/Specific/X25519/C32/femul.v,
and shown in the last Coq-compatible form at
https://github.com/mit-plv/fiat-crypto/blob/master/src/Specific/X25519/C32/femulDisplay.log.

Benchmarks on Google Cloud's unidentified Intel Xeon with AVX2:

git checkout $VARIANT && ( cd build && rm -rf * && CC=clang CXX=clang++ cmake -GNinja -DCMAKE_TOOLCHAIN_FILE=../util/32-bit-toolchain.cmake -DCMAKE_BUILD_TYPE=Release .. && ninja && ./tool/bssl speed -filter 25519 )

this branch:

Did 11382 Ed25519 key generation operations in 1053046us (10808.6 ops/sec)
Did 11169 Ed25519 signing operations in 1038080us (10759.3 ops/sec)
Did 2925 Ed25519 verify operations in 1001346us (2921.1 ops/sec)
Did 12000 Curve25519 base-point multiplication operations in 1084851us (11061.4 ops/sec)
Did 3850 Curve25519 arbitrary point multiplication operations in 1085565us (3546.5 ops/sec)

Did 11466 Ed25519 key generation operations in 1049821us (10921.9 ops/sec)
Did 11000 Ed25519 signing operations in 1013317us (10855.4 ops/sec)
Did 3047 Ed25519 verify operations in 1043846us (2919.0 ops/sec)
Did 12000 Curve25519 base-point multiplication operations in 1068924us (11226.2 ops/sec)
Did 3850 Curve25519 arbitrary point multiplication operations in 1090598us (3530.2 ops/sec)

Did 10309 Ed25519 key generation operations in 1003320us (10274.9 ops/sec)
Did 11000 Ed25519 signing operations in 1017862us (10807.0 ops/sec)
Did 3135 Ed25519 verify operations in 1098624us (2853.6 ops/sec)
Did 9000 Curve25519 base-point multiplication operations in 1046608us (8599.2 ops/sec)
Did 3132 Curve25519 arbitrary point multiplication operations in 1038963us (3014.5 ops/sec)

master:

Did 11564 Ed25519 key generation operations in 1068762us (10820.0 ops/sec)
Did 11104 Ed25519 signing operations in 1024278us (10840.8 ops/sec)
Did 3206 Ed25519 verify operations in 1049179us (3055.7 ops/sec)
Did 12000 Curve25519 base-point multiplication operations in 1073619us (11177.1 ops/sec)
Did 3550 Curve25519 arbitrary point multiplication operations in 1000279us (3549.0 ops/sec)
andreser@linux-andreser:~/boringssl$ build/tool/bssl speed -filter 25519
Did 11760 Ed25519 key generation operations in 1072495us (10965.1 ops/sec)
Did 10800 Ed25519 signing operations in 1003486us (10762.5 ops/sec)
Did 3245 Ed25519 verify operations in 1080399us (3003.5 ops/sec)
Did 12000 Curve25519 base-point multiplication operations in 1076021us (11152.2 ops/sec)
Did 3570 Curve25519 arbitrary point multiplication operations in 1005087us (3551.9 ops/sec)
andreser@linux-andreser:~/boringssl$ build/tool/bssl speed -filter 25519
Did 11438 Ed25519 key generation operations in 1041115us (10986.3 ops/sec)
Did 11000 Ed25519 signing operations in 1012589us (10863.2 ops/sec)
Did 3312 Ed25519 verify operations in 1082834us (3058.6 ops/sec)
Did 12000 Curve25519 base-point multiplication operations in 1061318us (11306.7 ops/sec)
Did 3580 Curve25519 arbitrary point multiplication operations in 1004923us (3562.5 ops/sec)

squashed: curve25519: convert field constants to unsigned.

import re, sys, math

def weight(i):
    return 2**int(math.ceil(25.5*i))

def convert(t):
    limbs = [x for x in t.groups() if x.replace('-','').isdigit()]
    v = sum(weight(i)*x for (i,x) in enumerate(map(int, limbs))) % (2**255-19)
    limbs = [(v % weight(i+1)) // weight(i) for i in range(10)]
    assert v == sum(weight(i)*x for (i,x) in enumerate(limbs))

    i = 0
    ret = ''
    for s in t.groups():
        if s.replace('-','').isdigit():
            ret += str(limbs[i])
            i += 1
        else:
            ret += s
    return ret

fe_re = re.compile(r'(\s*,\s*)'.join(r'(-?\d+)' for i in range(10)))
print (re.sub(fe_re, convert, sys.stdin.read()))

Change-Id: Ibd4f7f5c38e5c4d61c9826afb406baebe2be5168
Reviewed-on: https://boringssl-review.googlesource.com/22385
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-03 22:39:31 +00:00
Andres Erbsen 5b280a80df Move curve25519 code to third_party/fiat.
This change doesn't actually introduce any Fiat code yet. It sets up the
directory structure to make the diffs in the next change clearer.

Change-Id: I38a21fb36b18a08b0907f9d37b7ef5d7d3137ede
Reviewed-on: https://boringssl-review.googlesource.com/22624
Reviewed-by: David Benjamin <davidben@google.com>
2017-11-03 22:23:59 +00:00
David Benjamin 55761e6802 Use a higher iteration limit for RSA key generation at e = 3.
Generating a 2048-bit RSA key with e = 3 (don't do this), the failure
rate at 5*bits iterations appears to be around 7 failures in 1000 tries.
Bump the limit up to 32*bits. This should give a failure rate of around
2 failures in 10^14 tries.

(The FIPS 186-4 algorithm is meant for saner values of e, like 65537. e
= 3 implies a restrictive GCD requirement: the primes must both be 2 mod
3.)

Change-Id: Icd373f61e2eb90df5afaff9a0fc2b2fbb6ec3f0a
Reviewed-on: https://boringssl-review.googlesource.com/22584
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-03 19:37:31 +00:00
Andres Erbsen 431e767c23 curve25519: adhere to preconditions of fe_*.
Previously, the ed25519 and SPAKE implementations called field element
operations in ways that did not satisfy the preconditions about ranges
of limbs. Furthermore, replacing signed field arithmetic with unsigned field
arithmetic with similar specifications caused tests to fail.  This commit
addresses this in three steps:

(1) Split fe into fe and fe_loose, tracking the bounds
(2) Insert carry operations before uses of fe_add/fe_sub/fe_neg whose
input is already within only the loose bounds
(3) Assert that each field element is within the appropriate bounds at
the beginning and end of every field operation.

Throughput diff:

Ed25519 key generation: -2%
Ed25519 signing: -2%
Ed25519 verify: -2%
X25519: roughly unchanged

Detailed benchmarks on Google Cloud's unidentified Intel Xeon with AVX2:
git checkout $VARIANT && ( cd build && rm -rf * && CC=clang CXX=clang++ cmake -GNinja -DCMAKE_TOOLCHAIN_FILE=../util/32-bit-toolchain.cmake -DCMAKE_BUILD_TYPE=Release .. && ninja && ./tool/bssl speed -filter 25519 )

this branch:

Did 11206 Ed25519 key generation operations in 1029462us (10885.3 ops/sec)
Did 11104 Ed25519 signing operations in 1035735us (10720.9 ops/sec)
Did 3278 Ed25519 verify operations in 1087969us (3013.0 ops/sec)
Did 12000 Curve25519 base-point multiplication operations in 1078962us (11121.8 ops/sec)
Did 3610 Curve25519 arbitrary point multiplication operations in 1002767us (3600.0 ops/sec)

Did 11662 Ed25519 key generation operations in 1077690us (10821.3 ops/sec)
Did 10780 Ed25519 signing operations in 1011474us (10657.7 ops/sec)
Did 3289 Ed25519 verify operations in 1083638us (3035.1 ops/sec)
Did 12000 Curve25519 base-point multiplication operations in 1087477us (11034.7 ops/sec)
Did 3610 Curve25519 arbitrary point multiplication operations in 1017023us (3549.6 ops/sec)

Did 11018 Ed25519 key generation operations in 1011606us (10891.6 ops/sec)
Did 11000 Ed25519 signing operations in 1029961us (10680.0 ops/sec)
Did 3124 Ed25519 verify operations in 1045163us (2989.0 ops/sec)
Did 12000 Curve25519 base-point multiplication operations in 1081770us (11092.9 ops/sec)
Did 3610 Curve25519 arbitrary point multiplication operations in 1014503us (3558.4 ops/sec)

master:

Did 11662 Ed25519 key generation operations in 1059449us (11007.6 ops/sec)
Did 10908 Ed25519 signing operations in 1000081us (10907.1 ops/sec)
Did 3333 Ed25519 verify operations in 1078798us (3089.5 ops/sec)
Did 12000 Curve25519 base-point multiplication operations in 1072831us (11185.4 ops/sec)
Did 3850 Curve25519 arbitrary point multiplication operations in 1075821us (3578.7 ops/sec)

Did 11102 Ed25519 key generation operations in 1017540us (10910.6 ops/sec)
Did 11000 Ed25519 signing operations in 1013279us (10855.8 ops/sec)
Did 3311 Ed25519 verify operations in 1066866us (3103.5 ops/sec)
Did 12000 Curve25519 base-point multiplication operations in 1069668us (11218.4 ops/sec)
Did 3905 Curve25519 arbitrary point multiplication operations in 1095501us (3564.6 ops/sec)

Did 11206 Ed25519 key generation operations in 1014127us (11049.9 ops/sec)
Did 10908 Ed25519 signing operations in 1015821us (10738.1 ops/sec)
Did 3344 Ed25519 verify operations in 1100592us (3038.4 ops/sec)
Did 12000 Curve25519 base-point multiplication operations in 1072847us (11185.2 ops/sec)
Did 3570 Curve25519 arbitrary point multiplication operations in 1009373us (3536.8 ops/sec)

Change-Id: Ia014386daf36c913f3ea44c5f9a420b98670e465
Reviewed-on: https://boringssl-review.googlesource.com/22104
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-03 18:40:11 +00:00
David Benjamin 6cc352e216 Add helper functions for SSL_SIGN_*.
We end up writing these switch cases everywhere. Let consumers decompose
these a bit. The original thought was folks should write switch-cases so
they handle everything they support, but that's a pain. As long as
algorithm preferences are always configured, we can still add new
dimensions because folks won't be asked to sign algorithms that depend
on dimensions they don't understand.

Change-Id: I3dd7f067f2c55212f0201876546bc70fee032bcf
Reviewed-on: https://boringssl-review.googlesource.com/22524
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-11-03 16:05:11 +00:00
Daniel Hirche 2eb2889702 bn/exp: don't check |copy_to_prebuf|'s retval in |BN_mod_exp_mont_consttime|.
It always returns one, so just void it.

Change-Id: I8733cc3d6b20185e782cf0291e9c0dc57712bb63
Reviewed-on: https://boringssl-review.googlesource.com/22564
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-03 15:43:52 +00:00
David Benjamin 6dda166d21 Support additional curve names.
Node's default settings spell P-256 as prime256v1. This comes from
OpenSSL additionally allowing the long and short names of each curve's
NID. This works out to one additional name per curve for the ones we
support. To avoid depending on the giant OID table, this replicates the
names in libssl.

Change-Id: I456a2db6939eb6745e5a9d2f12cf6886e6265b9f
Reviewed-on: https://boringssl-review.googlesource.com/22545
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-03 01:32:49 +00:00
David Benjamin a02ed04d52 Add more compatibility symbols for Node.
Change-Id: Iaeff3adc6da216e965126eaa181427d5318f07d5
Reviewed-on: https://boringssl-review.googlesource.com/22544
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-03 01:31:50 +00:00
David Benjamin f7412cb072 Update tools.
Change-Id: Ibdfdc20b280a594f0f876b33ab8e40686d80f9ba
Reviewed-on: https://boringssl-review.googlesource.com/22504
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-02 20:30:39 +00:00
David Benjamin 2d07d30c44 bn/asm/x86_64-mont5.pl: fix carry bug in bn_sqrx8x_internal.
Credit to OSS-Fuzz for finding this.

CVE-2017-3736

(Imported from upstream's 668a709a8d7ea374ee72ad2d43ac72ec60a80eee and
420b88cec8c6f7c67fad07bf508dcccab094f134.)

This bug does not affect BoringSSL as we do not enable the ADX code.
Note the test vector had to be tweaked to take things in and out of
Montgomery form. (There may be something to be said for test vectors for
just BN_mod_mul_montgomery, though we'd need separate 64-bit and 32-bit
ones because R can be different.)

Change-Id: I832070731ac1c5f893f9c1746892fc4a32f023f5
Reviewed-on: https://boringssl-review.googlesource.com/22484
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-02 17:07:57 +00:00
Steven Valdez cd8470f7fa Adding support for draft 21 as a TLS 1.3 variant.
Change-Id: I46686aea9b68105cfe70a11db0e88052781e179c
Reviewed-on: https://boringssl-review.googlesource.com/22164
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-11-01 21:32:36 +00:00
David Benjamin cfc120eb22 Remove RC4 remnants in runner.
RC4 is dead and gone. This trims away the suiteNoDTLS flag.

Change-Id: I1ddc5d0811ad8cfb073e6e3c73100240bc649615
Reviewed-on: https://boringssl-review.googlesource.com/22469
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-01 16:45:36 +00:00
David Benjamin 3b903f252a Move the SSL_eNULL special-case into the matching function.
This avoids needing to keep track of which rules do and don't need it.

Change-Id: Id086b0622305f7f4acd3892f5d24d8e0c970febb
Reviewed-on: https://boringssl-review.googlesource.com/22468
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-01 16:45:06 +00:00
David Benjamin 5be3a74c49 Remove supports_cipher hook.
RC4 is gone. The only remaining exception was the dumb SSL_eNULL cipher,
which works fine in DTLS. It doesn't seem worth the trouble to retain
this special-case.

Change-Id: I31023b71192808e4d21e82109255dc4d6d381df8
Reviewed-on: https://boringssl-review.googlesource.com/22467
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-01 16:44:46 +00:00
David Benjamin dca1afb326 Fix up make_errors.go.
We broke C++ file scanning. It also was silently failing on Windows
because os.Rename's error was ignored. Also make it work on Windows; we
just need to close the files early.

Change-Id: I1aa976ef67a1feaf574c41cf07d2202c245f027a
Reviewed-on: https://boringssl-review.googlesource.com/22466
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-01 16:32:56 +00:00
David Benjamin f1db1a398d Another scoper conversion.
Change-Id: I2cc4b76d6368e8962aa601255e1d92e00614c9ec
Reviewed-on: https://boringssl-review.googlesource.com/22465
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-01 16:32:40 +00:00
David Benjamin 2637f3c431 Even more fun with Span.
Change-Id: If9f9fdc209b97f955b1ef3dea052393412865e59
Reviewed-on: https://boringssl-review.googlesource.com/22464
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-11-01 16:28:56 +00:00
Adam Langley 696c13bd6a Clear bottom three bits of password scalar in SPAKE2.
Due to a copy-paste error, the call to |left_shift_3| is missing after
reducing the password scalar in SPAKE2. This means that three bits of
the password leak in Alice's message. (Two in Bob's message as the point
N happens to have order 4l, not 8l.)

The “correct” fix is to put in the missing call to |left_shift_3|, but
that would be a breaking change. In order to fix this in a unilateral
way, we add points of small order to the masking point to bring it into
prime-order subgroup.

BUG=chromium:778101

Change-Id: I440931a3df7f009b324d2a3e3af2d893a101804f
Reviewed-on: https://boringssl-review.googlesource.com/22445
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-31 20:58:29 +00:00
Adam Langley 08e817d3e9 Fix Python code formatting in comment in SPAKE2.
Change-Id: I86f6d0b690b62bcb3b50177069f862ba220bee7d
Reviewed-on: https://boringssl-review.googlesource.com/22444
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-31 16:45:29 +00:00
David Benjamin ba94746eb2 Remove temporary logging.
Bug: 199
Change-Id: Ic8eb3e7901b89e5a57c959c650ea316e2eeeb45a
Reviewed-on: https://boringssl-review.googlesource.com/22424
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-30 20:47:16 +00:00
David Benjamin 4281bcd5d2 Revert assembly changes in "Hide CPU capability symbols in C."
This partially reverts commit 38636aba74.
Some build on Android seems to break now. I'm not really sure what the
situation is, but if the weird common symbols are still there (can we
remove them?), they probably ought to have the right flags.

Change-Id: Ief589d763d16b995ac6be536505acf7596a87b30
Reviewed-on: https://boringssl-review.googlesource.com/22404
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-30 20:39:57 +00:00
David Benjamin 8f06074a91 Handle malloc failures better in bn_test.cc.
Those EXPECTs should be ASSERTs to ensure bn is not null.

Change-Id: Icb54c242ffbde5f8eaa67f19f214c9eef13705ea
Reviewed-on: https://boringssl-review.googlesource.com/22366
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-30 18:53:48 +00:00
David Benjamin 4f94a8381a asn1_item_embed_new(): don't free an embedded item
An embedded item wasn't allocated separately on the heap, so don't
free it as if it was.

Issue discovered by Pavel Kopyl

(Imported from upstream's cdc3307d4257f4fcebbab3b2b44207e1a399da05 and
65d414434aeecd5aa86a46adbfbcb59b4344503a.)

I do not believe this is actually reachable in BoringSSL, even in the
face of malloc errors. The only field which sets ASN1_TFLG_COMBINE is in
X509_ATTRIBUTE. That field's value is X509_ATTRIBUTE_SET which cannot
fail to initialize. (It is a CHOICE whose initialization consists of
setting the selector to -1 and calling the type's callback which is
unset for this type.)

Change-Id: I29c080f8a4ddc2f3ef9c119d0d90a899d3cb78c5
Reviewed-on: https://boringssl-review.googlesource.com/22365
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-30 18:51:58 +00:00
David Benjamin a67b101594 Fix memory leak in GENERAL_NAME_set0_othername.
(Imported from upstream's deee898ef94a176a22fce3b9effc957cb75bb535.)

Change-Id: Ifcef31baa1f8b185c2014481ca9bb4e23fe74a53
Reviewed-on: https://boringssl-review.googlesource.com/22364
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-30 18:40:17 +00:00
David Benjamin 98ca81daae Use unsigned integers for masks.
1 << 31 is technically an undefined shift. It should be 1u << 31 to shut
UBSan up. I've also converted the others for consistency.

Change-Id: I1c6fe282f55c7032cea39f5ff1035a7711155f02
Reviewed-on: https://boringssl-review.googlesource.com/22344
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-30 18:39:58 +00:00
David Benjamin cb16f17b36 Check EC_POINT/EC_GROUP compatibility more accurately.
Currently we only check that the underlying EC_METHODs match, which
avoids the points being in different forms, but not that the points are
on the same curves. (We fixed the APIs early on so off-curve EC_POINTs
cannot be created.)

In particular, this comes up with folks implementating Java's crypto
APIs with ECDH_compute_key. These APIs are both unfortunate and should
not be mimicked, as they allow folks to mismatch the groups on the two
multiple EC_POINTs. Instead, ECDH APIs should take the public value as a
byte string.

Thanks also to Java's poor crypto APIs, we must support custom curves,
which makes this particularly gnarly. This CL makes EC_GROUP_cmp work
with custom curves and adds an additional subtle requirement to
EC_GROUP_set_generator.

Annoyingly, this change is additionally subtle because we now have a
reference cycle to hack around.

Change-Id: I2efbc4bd5cb65fee5f66527bd6ccad6b9d5120b9
Reviewed-on: https://boringssl-review.googlesource.com/22245
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-28 08:02:50 +00:00
Adam Langley 2a768d04c6 Fix overflow checks when converting ASN.1 integers to long.
(Credit to libFuzzer for finding this.)

Change-Id: I0353d686d883703d39145c5bdd1e56368a587a35
Reviewed-on: https://boringssl-review.googlesource.com/22324
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-27 19:08:08 +00:00
David Benjamin f5beb883c2 Disable macOS architecture hack on CMake 3.0.
Per the comment, it's no longer necessary. macOS i386 does not exist,
but apparently iOS i386 does! We can probably just remove it altogether,
but our cmake_minimum_required is nominally 2.8, so I just put the
version check in.

Bug: 210
Change-Id: I6e0617a3f292a218b2465eee85bd4814bd0e55c7
Reviewed-on: https://boringssl-review.googlesource.com/22304
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-27 18:58:08 +00:00
David Benjamin af92418b8b Generate bn_div and bn_mod_exp corpus from bn_tests.txt.
Also switch them to accepting a u16 length prefix. We appear not to have
any such tests right now, but RSA-2048 would involve modulus well larger
and primes just a hair larger than a u8 length prefix alows.

Change-Id: Icce8f1d976e159b945302fbba732e72913c7b724
Reviewed-on: https://boringssl-review.googlesource.com/22284
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-27 18:57:48 +00:00
David Benjamin 51073ce055 Refcount EC_GROUP.
I really need to resurrect the CL to make them entirely static
(https://crbug.com/boringssl/20), but, in the meantime, to make
replacing the EC_METHOD pointer in EC_POINT with EC_GROUP not
*completely* insane, make them refcounted.

OpenSSL did not do this because their EC_GROUPs are mutable
(EC_GROUP_set_asn1_flag and EC_GROUP_set_point_conversion_form). Ours
are immutable but for the two-function dance around custom curves (more
of OpenSSL's habit of making their objects too complex), which is good
enough to refcount.

Change-Id: I3650993737a97da0ddcf0e5fb7a15876e724cadc
Reviewed-on: https://boringssl-review.googlesource.com/22244
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-27 17:48:27 +00:00
David Benjamin d24fd47ff4 Fold EC_POINT_clear_free into EC_POINT_free.
All frees zero memory now.

Change-Id: I5b04a0d14f38d5a7422e148d077fcba85a593594
Reviewed-on: https://boringssl-review.googlesource.com/22225
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-27 17:41:19 +00:00
David Benjamin ed84291188 Revert "Pack encrypted handshake messages together."
This reverts commit 75d43b5785. Chatting
with EKR, there is some reason to believe that doing this might cause
more middlebox issues. Since we're still in the middle of working
towards viable deployment in the first place, revert this.

We can experiment with this later. I should have arranged for this to be
controlled more carefully anyway.

Change-Id: I0c8bf578f9d7364e913894e1bf3c2b8123dfd770
Reviewed-on: https://boringssl-review.googlesource.com/22204
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-27 14:36:37 +00:00
David Benjamin b26ab5c7bf Clear remaining BORINGSSL_ANDROID_SYSTEM ifdefs.
Both of these changes have stuck in Chrome for quite a while now. Let's
clear them.

Change-Id: I13094451be2584ecaaf6b60eedefb7212b7bcde2
Reviewed-on: https://boringssl-review.googlesource.com/22226
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-27 14:04:07 +00:00
David Benjamin 3f5d13812a Remove EVP_set_buggy_rsa_parser stub.
Change-Id: I848c79274119e73e39456c75231c8e3f6047fde2
Reviewed-on: https://boringssl-review.googlesource.com/22264
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-27 13:49:57 +00:00
David Benjamin fed560ff2a Clear no-op BN_MASK2 masks.
This is an OpenSSL thing to support platforms where BN_ULONG is not
actually the size it claims to be. We define BN_ULONG to uint32_t and
uint64_t which are guaranteed by C to implement arithemetic modulo 2^32
and 2^64, respectively. Thus there is no need for any of this.

Change-Id: I098cd4cc050a136b9f2c091dfbc28dd83e01f531
Reviewed-on: https://boringssl-review.googlesource.com/21784
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-27 02:38:45 +00:00
David Benjamin cba7987978 Revert "Use uint128_t and __asm__ in clang-cl."
This reverts commit f6942f0d22.

Reason for revert: This doesn't actually work in clang-cl. I
forgot we didn't have the clang-cl try bots enabled! :-( I
believe __asm__ is still okay, but I'll try it by hand
tomorrow.

Original change's description:
> Use uint128_t and __asm__ in clang-cl.
> 
> clang-cl does not define __GNUC__ but is still a functioning clang. We
> should be able to use our uint128_t and __asm__ code in it on Windows.
> 
> Change-Id: I67310ee68baa0c0c947b2441c265b019ef12af7e
> Reviewed-on: https://boringssl-review.googlesource.com/22184
> Commit-Queue: Adam Langley <agl@google.com>
> Reviewed-by: Adam Langley <agl@google.com>
> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>

TBR=agl@google.com,davidben@google.com

Change-Id: I5c7e0391cd9c2e8cc0dfde37e174edaf5d17db22
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://boringssl-review.googlesource.com/22224
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-27 00:22:06 +00:00
David Benjamin f6942f0d22 Use uint128_t and __asm__ in clang-cl.
clang-cl does not define __GNUC__ but is still a functioning clang. We
should be able to use our uint128_t and __asm__ code in it on Windows.

Change-Id: I67310ee68baa0c0c947b2441c265b019ef12af7e
Reviewed-on: https://boringssl-review.googlesource.com/22184
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-27 00:07:29 +00:00
David Benjamin acf2f34df5 Remove unused constant.
We never implemented psk_ke, so there's no need to define the constant.

Change-Id: I6e52596e1a2cf0b3db5e7cd96db6836f4290bf0b
Reviewed-on: https://boringssl-review.googlesource.com/22144
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-26 14:42:35 +00:00
David Benjamin 6675cfddef Unexport more of lhash.
There is also no need to make the struct public. Also tidy up includes a
bit.

Change-Id: I188848dfd8f9ed42925b2c55da8dc4751c29f146
Reviewed-on: https://boringssl-review.googlesource.com/22126
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-25 04:17:18 +00:00
David Benjamin 4455e59980 Clear some _CRT_SECURE_NO_WARNINGS warnings.
Some of the complaints seem a bit questionable or their replacements
problematic, but not using strcat, strcpy, and strncpy is easy and
safer.

Change-Id: I64faf24b4f39d1ea410e883f026350094975a9b5
Reviewed-on: https://boringssl-review.googlesource.com/22125
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-25 04:14:28 +00:00
David Benjamin 883b5461d5 runner: Check c.hand before changing ciphers.
This doesn't matter in so far as runner is not a real TLS
implementation, but it should enforce what there is to enforce just to
keep BoringSSL honest.

Bug: 80
Change-Id: I68940c33712d34a2437dc4dee31342e7f0f57c23
Reviewed-on: https://boringssl-review.googlesource.com/22069
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-25 03:45:26 +00:00
David Benjamin 75d43b5785 Pack encrypted handshake messages together.
This does not affect TLS 1.2 (beyond Channel ID or NPN) but, in TLS 1.3,
we send several encrypted handshake messages in a row. For the server,
this means 66 wasted bytes in TLS 1.3. Since OpenSSL has otherwise used
one record per message since the beginning and unencrypted overhead is
less interesting, leave that behavior as-is for the time being. (This
isn't the most pressing use of the breakage budget.) But TLS 1.3 is new,
so get this tight from the start.

Change-Id: I64dbd590a62469d296e1f10673c14bcd0c62919a
Reviewed-on: https://boringssl-review.googlesource.com/22068
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-25 03:38:56 +00:00
David Benjamin dd6c2e880f Check early ALPN before offering 0-RTT.
We enforce that servers don't send bogus ALPN values, so consumers may
assume that SSL_get0_alpn_selected won't have anything terribly weird.
To maintain that invariant in the face of folks whose ALPN preferences
change (consider a persisted session cache), we should decline to offer
0-RTT if early_alpn would have been rejected by the check anyway.

Change-Id: Ic3a9ba4041d5d4618742eb05e27033525d96ade1
Reviewed-on: https://boringssl-review.googlesource.com/22067
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-25 03:31:56 +00:00
David Benjamin 800046fecf Give DTLS1_STATE a destructor.
Change-Id: I3fb797bad91caf7d2aff09313734edfb58fb9f26
Reviewed-on: https://boringssl-review.googlesource.com/22066
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-25 03:23:26 +00:00
Param Reddy fadc975bf9 For Android there is no need to expicitly link pthread lib.
Change-Id: Ifbd1c6fb91a9e8c6e5d50aa2b2ff7684fbb248a9
See: https://groups.google.com/forum/#!topic/android-ndk/Dq05en_xoN8
Reviewed-on: https://boringssl-review.googlesource.com/22084
Reviewed-by: Matt Braithwaite <mab@google.com>
Commit-Queue: Matt Braithwaite <mab@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-25 00:21:46 +00:00
David Benjamin 049fdfc7e0 Give hm_fragment and DTLS_OUTGOING_MESSAGE destructors.
This is in preparation for giving DTLS_STATE one.

Change-Id: I3dfeeaad2d20c547d8e65d739bd0ad5bc1acf74a
Reviewed-on: https://boringssl-review.googlesource.com/22065
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-24 19:49:25 +00:00
David Benjamin 71ea6b127d Clear the last of ssl->s3->tmp.
new_*_len can just be computed rather than maintained as state.

Change-Id: If097ee9e68d8791fcfeb69052151faf0134c7c52
Reviewed-on: https://boringssl-review.googlesource.com/21948
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-24 19:35:35 +00:00
David Benjamin 32ce0ac0d8 Move init_buf and rwstate into SSL3_STATE.
This finally clears most of the SSL_clear special-cases.

Change-Id: I00fc240ccbf13f4290322845f585ca6f5786ad80
Reviewed-on: https://boringssl-review.googlesource.com/21947
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-24 18:55:05 +00:00
David Benjamin 8e7bbbab15 Use more scopers.
Change-Id: I34dd0a57efd5435fcdc59a3c7b1ce806bc0cbb3e
Reviewed-on: https://boringssl-review.googlesource.com/21946
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-24 17:50:05 +00:00
David Benjamin 941725789b Give SSL3_STATE a constructor and destructor.
Change-Id: I326bbc234cecb01741c177884ecabbc53367463d
Reviewed-on: https://boringssl-review.googlesource.com/21945
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-24 17:43:55 +00:00
David Benjamin a37f286f4e Remove the buggy RSA parser.
I've left EVP_set_buggy_rsa_parser as a no-op stub for now, but it
shouldn't need to last very long. (Just waiting for a CL to land in a
consumer.)

Bug: chromium:735616
Change-Id: I6426588f84dd0803661a79c6636a0414f4e98855
Reviewed-on: https://boringssl-review.googlesource.com/22124
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-24 17:39:46 +00:00
David Benjamin ea712e317f Make SSL3_BUFFER a proper C++ class.
As with SSLTranscript before, we temporarily need some nastiness in
SSL3_STATE, but this is in preparation of giving SSL3_STATE a
constructor and destructor.

Change-Id: Ifc0ce34fdcd8691d521d8ea03ff5e83dad43b4a3
Reviewed-on: https://boringssl-review.googlesource.com/21944
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-24 17:32:45 +00:00
David Benjamin 38636aba74 Hide CPU capability symbols in C.
Our assembly does not use the GOT to reference symbols, which means
references to visible symbols will often require a TEXTREL. This is
undesirable, so all assembly-referenced symbols should be hidden. CPU
capabilities are the only such symbols defined in C.

These symbols may be hidden by doing at least one of:

1. Build with -fvisibility=hidden
2. __attribute__((visibility("hidden"))) in C.
3. .extern + .hidden in some assembly file referencing the symbol.

We have lots of consumers and can't always rely on (1) happening. We
were doing (3) by way of d216b71f90 and
16e38b2b8f, but missed 32-bit x86 because
it doesn't cause a linker error.

Those two patches are not in upstream. Upstream instead does (3) by way
of x86cpuid.pl and friends, but we have none of these files.

Standardize on doing (2). This avoids accidentally getting TEXTRELs on
some 32-bit x86 build configurations.  This also undoes
d216b71f90 and
16e38b2b8f. They are no now longer needed
and reduce the upstream diff.

Change-Id: Ib51c43fce6a7d8292533635e5d85d3c197a93644
Reviewed-on: https://boringssl-review.googlesource.com/22064
Commit-Queue: Matt Braithwaite <mab@google.com>
Reviewed-by: Matt Braithwaite <mab@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-23 18:36:49 +00:00
Daniel Wagner-Hall 3b358b25b0 Specify -stdlib=libc++ if APPLE
If you specify any --target which refers to a x86_64-apple-darwin
triple, or a more specific variant derived from it, specifying
-stdlib=libc++ is required, otherwise clang falls back to libstdc++
which didn't include c++11, and fails to compile in very obscure ways
(simply failing to find any c++11 symbols).

Change-Id: I58025cea91eaa0c16d9b5831f9965889b75bbc31
Reviewed-on: https://boringssl-review.googlesource.com/21984
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-23 18:16:27 +00:00
Steven Valdez 7f8c553d7f Add BN fuzzer.
Change-Id: I09396e34d09a71bed40eefece1eae90ba2b5086f
Reviewed-on: https://boringssl-review.googlesource.com/21024
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-23 16:38:28 +00:00
David Benjamin f6632dae5f Make all read errors idempotent.
Now that we've gotten everything, test this by just making bssl_shim run
all errors twice. The manual tests added to ssl_test.cc may now be
removed.

Bug: 206
Change-Id: Iefa0eae83ba59b476e6b6c6f0f921d5d1b72cbfb
Reviewed-on: https://boringssl-review.googlesource.com/21886
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-17 21:28:51 +00:00
David Benjamin a031b61230 Replace open_close_notify with open_app_data.
While a fairly small hook, open_close_notify is pretty weird. It
processes things at the record level and not above. Notably, this will
break if it skips past a TLS 1.3 KeyUpdate.

Instead, it can share the core part of SSL_read/SSL_peek, with slight
tweaks to post-handshake processing. Note this does require some tweaks
to that code. Notably, to retain the current semantics that SSL_shutdown
does not call funny callbacks, we suppress tickets.

Change-Id: Ia0cbd0b9f4527f1b091dd2083a5d8c7efb2bac65
Reviewed-on: https://boringssl-review.googlesource.com/21885
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-17 21:19:31 +00:00
David Benjamin e8d0746b88 Prevent writing when write_shutdown is set.
Ideally we'd put this deep in the record layer, but sending alerts
currently awkwardly sets the field early, so we can't quite lock it out
this deep down.

This is mostly a sanity-check, but a later CL will fix SSL_shutdown's
post-handshake message processing, so this will help catch errors there.

Change-Id: I78e627c19547dbcdc85fb168795240d692baf031
Reviewed-on: https://boringssl-review.googlesource.com/21884
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-17 20:18:21 +00:00
David Benjamin d9229f9802 Lift BIO above SSL_PROTOCOL_METHOD.
This gets us closer to exposing BIO-free APIs. The next step is probably
to make the experimental bssl::OpenRecord function call a split out core
of ssl_read_impl.

Change-Id: I4acebb43f708df8c52eb4e328da8ae3551362fb9
Reviewed-on: https://boringssl-review.googlesource.com/21865
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-17 19:53:52 +00:00
David Benjamin 33febf6048 Don't call ssl3_read_message from ssl3_read_app_data.
With this change, it should now always be the case that rr->length is
zero on entry to ssl3_read_message. This will let us detach everything
but application data from rr. This pushes some init_buf invariants down
into tls_open_record so we don't need to maintain them everywhere.

Change-Id: I206747434e0a9603eea7d19664734fd16fa2de8e
Reviewed-on: https://boringssl-review.googlesource.com/21524
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-17 17:54:01 +00:00
David Benjamin 97250f4d64 Switch a bunch of things from int to bool.
Change-Id: I419c3a1459425fcd016c130d9699c5d89e66713c
Reviewed-on: https://boringssl-review.googlesource.com/21386
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-17 17:06:51 +00:00
David Benjamin 31aad2dc2c Make low-level record errors idempotent.
Enough were to make record processing idempotent (we either consume a
record or we don't), but some errors would cause us to keep processing
records when we should get stuck.

This leaves errors in the layer between the record bits and the
handshake. I'm hoping that will be easier to resolve once they do not
depend on BIO, at which point the checks added in this CL may move
around.

Bug: 206
Change-Id: I6b177079388820335e25947c5bd736451780ab8f
Reviewed-on: https://boringssl-review.googlesource.com/21366
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-17 16:05:41 +00:00
David Benjamin f8de2af7e3 Push read_shutdown logic down a layer.
We'll probably want to either move or add additional checks later, but
meanwhile this gets more code on the BIO-free side of the divide.

Change-Id: I3e2b570cdf1d70a262d952c20fd2d76ff4f70dd0
Reviewed-on: https://boringssl-review.googlesource.com/21365
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-17 15:39:51 +00:00
David Benjamin a05d427b41 Align dtls_open_record and tls_open_record more closely.
Ultimately the ssl_buffer_* code will be above SSL_PROTOCOL_METHOD, so
having the processing be analogous is simpler. This also means that DTLS
can surface errors out of dtls_open_record without the caller reading an
extra record.

Bug: 206
Change-Id: Ic1cb3a884763c8e875e1129b1cda226f72bc95b7
Reviewed-on: https://boringssl-review.googlesource.com/21364
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-17 15:19:01 +00:00
David Benjamin 3b777adb61 Remove remnants of blocking DTLS timeouts.
We only support non-blocking BIOs for DTLS as of
https://boringssl-review.googlesource.com/13945. This logic is a remnant
of that. It should not be necessary. All users of DTLSv1_get_timeout
call DTLSv1_handle_timeout. This gets it out of the way for
dtls_open_record calls which don't use dtls1_get_record.

We can restore it elsewhere if necessary, but I don't think we need it.

Change-Id: Idb737868358e4b59ad3cb2c994c7084ffcdb3709
Reviewed-on: https://boringssl-review.googlesource.com/21349
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-17 15:02:21 +00:00
David Benjamin 40e94701dc Always process handshake records in full.
This removes the last place where non-app-data hooks leave anything
uncomsumed in rrec. (There is still a place where non-app-data hooks see
a non-empty rrec an entrance. read_app_data calls into read_handshake.
That'll be fixed in a later patch in this series.)

This should not change behavior, though some error codes may change due
to some processing happening in a slightly different order.

Since we do this in a few places, this adds a BUF_MEM_append with tests.

Change-Id: I9fe1fc0103e47f90e3c9f4acfe638927aecdeff6
Reviewed-on: https://boringssl-review.googlesource.com/21345
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-17 14:53:11 +00:00
Daniel Hirche f66e88228a Fix documentation for |ssl_ticket_aead_method_st|.
Change-Id: I63b9972034fdc85bf2d23e7d46516755855fafbe
Reviewed-on: https://boringssl-review.googlesource.com/22024
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-17 09:17:42 +00:00
Dan Willemsen 2eb4bc5e89 Android.bp: Use target.linux for all linux kernel based targets
Now in Android.bp files, target.linux applies to all targets running a
linux kernel (android, linux_glibc, linux_bionic). So we can now share
sources between android and linux hosts.

Tested with:
https://android-review.googlesource.com/#/c/platform/external/boringssl/+/512517

Change-Id: I9c503f48cea17780e02bb38b419078a457d54f66
Reviewed-on: https://boringssl-review.googlesource.com/22004
Reviewed-by: Robert Sloan <varomodt@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-17 02:34:59 +00:00
Steven Valdez 619c8cec83 Fix uninitialized warning.
Bug: 207
Change-Id: I57a7f4b0783132965a22ed7ab64f0b839c62c73f
Reviewed-on: https://boringssl-review.googlesource.com/21964
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-16 19:09:02 +00:00
David Benjamin e1068b76bd Test RSA premaster unpad better.
RSABadValueTooLong should have the true one as a suffix, not a prefix,
so that the version check still works. Also do the padding manually to
catch a few other bad padding cases. This is sufficient coverage so that
disabling any one comparison in the padding check flags some failure.

Change-Id: Ibcad284e5ecee3e995f43101c09e4cf7694391e9
Reviewed-on: https://boringssl-review.googlesource.com/21904
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-13 18:22:58 +00:00
David Benjamin 168fb2e98c Fix DEPS defaults.
Not to land until these two changes are in:
https://chromium-review.googlesource.com/c/chromium/tools/build/+/716263
https://chromium-review.googlesource.com/c/chromium/tools/build/+/719010

Change-Id: I4e6d6fbcb6068405431dd3f9f38071c8af81d8b7
Reviewed-on: https://boringssl-review.googlesource.com/21825
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-13 18:22:24 +00:00
David Benjamin 11ac519d79 Test DTLS record/packet packing more aggressively.
Application records may be packed with other application data records or
with handshake records. We also were never testing CCS and handshake
being packed together. Implement this by moving the packing logic to the
bottom of BoGo's DTLS record layer.

Change-Id: Iabc14ec4ce7b99ed1f923ce9164077efe948c7a0
Reviewed-on: https://boringssl-review.googlesource.com/21844
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-13 17:32:55 +00:00
David Benjamin fdb7a3580f Add a test for SSL_pending.
To make sure I don't break it later on.

Change-Id: I0a326800593cd3196efaf2ec9f4042935ecf8eb8
Reviewed-on: https://boringssl-review.googlesource.com/21864
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-13 15:43:32 +00:00
David Benjamin 24f5b18f93 Update copies of tools.
d3868ac4d6f92e57376924a62e8d52f36d7a326561ec0bbd1d5681759a947134 sde-external-8.9.0-2017-08-06-lin.tar.bz2
9852d57e0d6b4509accb4f9faf862327a79c18b630aac4f35c65ce7a270a9230 strawberry-perl-5.26.1.1-32bit-portable.zip

I've left CMake alone for now because that involves building things and
there's some mess between newer CMakes trying to mess with the Android
NDK, so that needs to be tested out a bit.

Change-Id: I6beea9d4774474ac62e843c8668fcef7f6a6fc04
Reviewed-on: https://boringssl-review.googlesource.com/21824
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-12 19:31:25 +00:00
David Benjamin 75a1f23684 Have a bit more fun with Span.
Change-Id: Iba909603a72ec0d149d9898423c114304a5011fa
Reviewed-on: https://boringssl-review.googlesource.com/21644
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-12 19:01:34 +00:00
David Benjamin dbf12fc2ce Use new DEPS conditionals.
See
https://groups.google.com/a/chromium.org/d/msg/infra-announce/A6_zQKzCHDo/ZKqSptzeBgAJ.
This allows us to avoid checking out unnecessary things (right now every
Windows bot downloads clang). We also can maintain the SDE bits in DEPS
rather than having to update the recipe for it.

This is the first half of the change which conditions things on
variables but leaves the defaults as they are. This will be followed up
by a change to the recipe to set the variables, then to switch the
defaults.

Change-Id: Iebcc4d0a146d0b0df94f480e539d70cbf4c862d3
Reviewed-on: https://boringssl-review.googlesource.com/21804
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-12 18:12:06 +00:00
David Benjamin 5dde62364e Fix location of Clang stamp file.
It should be inside the llvm-build directory, otherwise it's not in
.gitignore and things get confused.

Change-Id: I5be31e0b0db69fff9935cbf6dbd9c612fd5a4769
Reviewed-on: https://boringssl-review.googlesource.com/21805
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-12 17:56:16 +00:00
David Benjamin 00f48c8273 Rename and move a few more ssl3_ functions around.
I think that's the last of the ssl3_ prefix being used for common
functions.

Change-Id: Id83e6f2065c3765931250bd074f6ebf1fc251696
Reviewed-on: https://boringssl-review.googlesource.com/21347
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-12 16:25:54 +00:00
David Benjamin d1e3ce1fb0 Rename ssl3_send_alert and ssl3_protocol_version.
These are common between TLS and DTLS so should not have the ssl3_
prefix. (TLS-only stuff should really have a tls_ prefix, but we still
have a lot of that one.)

This also fixes a stray reference to ssl3_send_client_key_exchange..

Change-Id: Ia05b360aa090ab3b5f075d5f80f133cbfe0520d4
Reviewed-on: https://boringssl-review.googlesource.com/21346
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-12 16:24:35 +00:00
David Benjamin 64950cb07f Don't rely on x509.h for SSL_FILETYPE_*.
We still have more links to cut for ssl.h to not pull in x509.h (notably
pem.h), but this resolves some easy ones. I've kept the constants the
same just in case, but nowhere are the constants mixed up by callers or
passed from one to the other in the functions' implementations. They're
completely independent.

Change-Id: Ic0896283378b5846afd6422bfe740951ac552f0e
Reviewed-on: https://boringssl-review.googlesource.com/21704
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-12 16:23:35 +00:00
David Benjamin 4e840357fd Fully hide LHASH_OF(SSL_SESSION).
It's no longer needed in the public header at all, now that we've hidden
the SSL_CTX struct.

Change-Id: I2fc6ddbeb52f000487627b433b9cdd7a4cde37a8
Reviewed-on: https://boringssl-review.googlesource.com/21684
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-12 16:22:59 +00:00
Adam Langley b15aa0aaef Add chacha.h to the list of documented headers.
Change-Id: Ifb227675cbc8e60128140768fb7d7f5f94928ac2
Reviewed-on: https://boringssl-review.googlesource.com/21764
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-12 15:27:34 +00:00
Alessandro Ghedini 01f26f3f32 Re-add hmac.h include to ssl.h.
Commit 9a4876e193 broke NGINX builds with
BoringSSL due to this missing include (OpenSSL builds work fine):

  src/event/ngx_event_openssl.c: In function ‘ngx_ssl_session_ticket_key_callback’:
  src/event/ngx_event_openssl.c:3065:13: error: implicit declaration of function ‘HMAC_Init_ex’; did you mean ‘SHA1_Init’? [-Werror=implicit-function-declaration]
           if (HMAC_Init_ex(hctx, key[0].hmac_key, size, digest, NULL) != 1) {
               ^~~~~~~~~~~~

Change-Id: Ie7170f05034d5fd8c85d1948b4ab9c9bb8447d13
Reviewed-on: https://boringssl-review.googlesource.com/21664
Reviewed-by: Adam Langley <agl@google.com>
2017-10-12 01:47:26 +00:00
Adam Langley 771df4416a Initialise a variable to zero for GCC 7.2.0.
GCC 7.2.0 (in Release builds) can't figure out that |type| is always
set:

../ssl/tls_record.cc: In function ‘bssl::OpenRecordResult bssl::OpenRecord(SSL*, bssl::Span<unsigned char>*, size_t*, uint8_t*, bssl::Span<unsigned char>)’:
../ssl/tls_record.cc:595:44: error: ‘type’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
       if (type != SSL3_RT_APPLICATION_DATA && type != SSL3_RT_ALERT) {
cc1plus: all warnings being treated as errors

Change-Id: I1ca9683a18d89097288018f48b50991bce185da8
Reviewed-on: https://boringssl-review.googlesource.com/21724
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2017-10-12 01:13:21 +00:00
David Benjamin 1f1ac63bff Fix typo in TODO comment.
Thanks to Alex Gaynor for reporting this.

Change-Id: I983ecb33cf017160f82582cc79e71f8ae7b30b99
Reviewed-on: https://boringssl-review.googlesource.com/21744
Reviewed-by: David Benjamin <davidben@google.com>
2017-10-11 23:30:42 +00:00
David Benjamin 666d16e262 Go through SSL_PROTOCOL_METHOD in the handshake.
The handshake should be generic between TLS and DTLS.

Change-Id: I6feb2f013dd5d771f206750653ab9d117d7ea716
Reviewed-on: https://boringssl-review.googlesource.com/21348
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-11 22:52:45 +00:00
David Benjamin 31640931e6 Switch all the extension callbacks to bools.
Change-Id: I4d24f7666aa862f2aaac91b6325a452ce2f219eb
Reviewed-on: https://boringssl-review.googlesource.com/21624
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-11 20:27:32 +00:00
David Benjamin 7e58c5ef20 Switch more things to bools.
Change-Id: I11e3cf9be7757fcf1dd50ca8d6d449aa83edf71f
Reviewed-on: https://boringssl-review.googlesource.com/21604
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-11 20:22:43 +00:00
David Benjamin 664e99a648 Make SSL_CTX opaque.
This frees us up to make SSL_CTX a C++ type and avoids a lot of
protrusions of otherwise private types into the global namespace.

Bug: 6
Change-Id: I8a0624a53a4d26ac4a483fa270c39ecdd07459ee
Reviewed-on: https://boringssl-review.googlesource.com/21584
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-11 16:46:20 +00:00
Steven Valdez be165a2e70 Fix missing TicketMaxEarlyDataInfo in first session ticket.
Change-Id: Ib24208e0ebdb1787c629ee29bd0115332ac36e73
Reviewed-on: https://boringssl-review.googlesource.com/21484
Reviewed-by: David Benjamin <davidben@google.com>
2017-10-10 21:03:10 +00:00
Bruce Dawson e05b72c257 Use constexpr to avoid kNamedGroups initializer
On some Chrome builds on Windows (including the official builds that we
ship) there are dynamic initializers for kNamedGroups in chrome.dll and
chrome_child.dll. Tagging this array with constexpr is guaranteed to
avoid this.

Bug: chromium:341941
Change-Id: I0e4ea0665b8ed9640b76b709dd300416be49e59e
Reviewed-on: https://boringssl-review.googlesource.com/21564
Reviewed-by: Bruce Dawson <brucedawson@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-10 21:01:59 +00:00
David Benjamin 2450027e59 Fold away clean boolean in BUF_MEM.
OPENSSL_free always zeros things now.

Change-Id: Iaad94f0d7ad51ade05ae89751321314d235d6d67
Reviewed-on: https://boringssl-review.googlesource.com/21384
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-10 18:58:20 +00:00
David Benjamin 03a4b96c12 Move has_message logic to ssl3_get_message.
This doesn't particularly matter but is more consistent with DTLS and
avoids the callback being potentially called from two places.

Change-Id: I2f57ca94d2d532c56f37a0bac7000c15b3b4b520
Reviewed-on: https://boringssl-review.googlesource.com/21344
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-10 15:48:57 +00:00
David Benjamin 23c25d5b3a Rename some things for consistency.
We usually use read/write rather than recv/send to describe the two
sides.

Change-Id: Ie3ac8c52c59ea9a5143f56b894f58cecd351dc7d
Reviewed-on: https://boringssl-review.googlesource.com/21304
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-10 15:39:07 +00:00
David Benjamin a84b6f26a9 Fix comment.
Clients need not accept CertificateRequest. We don't, have no intention
to, and post-handshake auth now requires an extension.

Change-Id: I2160c89e4a6988a7d743052b588d8aa2598ffabf
Reviewed-on: https://boringssl-review.googlesource.com/21305
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-10 15:33:07 +00:00
David Benjamin c64d123933 Push Span down a layer.
Change-Id: I893292b140d033a5aed7e08f928a6c32996bb983
Reviewed-on: https://boringssl-review.googlesource.com/21287
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-10 14:27:58 +00:00
David Benjamin 751d1a1c22 Fold ssl_open_record_fatal_alert into ssl_open_record_error.
The only difference is whether there's an alert to send back, but we'll
need to allow an "error without alert" in several cases anyway:

1. If the server sees an HTTP request or garbage instead of a
   ClientHello, it shouldn't send an alert.

2. Resurfaced errors.

Just make zero signal no alert for now. Later on, I'm thinking we might
just want to put the alert into the outgoing buffer and make it further
uniform.

This also gives us only one error state to keep track of rather than
two.

Bug: 206
Change-Id: Ia821d9f89abd2ca6010e8851220d4e070bc42fa1
Reviewed-on: https://boringssl-review.googlesource.com/21286
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-10 03:07:57 +00:00
David Benjamin e52f4c4642 Replay the entire error queue on ssl_hs_error.
This is analogous to the Go stack's handshakeErr field. Since it's quite
common for callers to run two I/O operations in parallel[*] like
SSL_read and SSL_write (or SSL_read and SSL_do_handshake for client
0-RTT). Accordingly, the new handshake state machine jams itself up on
handshake error, but to fully work with such callers, we should also
replay the error state.

This doesn't yet catch all cases (there are some parts of the read flow
which need to be fixed). Those will be resolved in later changes.

[*] Not actually in parallel, of course, but logically in parallel on a
non-blocking socket.

Bug: 206
Change-Id: I5a4d37a258b9e3fc555b732938b0528b839650f8
Reviewed-on: https://boringssl-review.googlesource.com/21285
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-09 21:53:33 +00:00
David Benjamin b25a8999be Add the ability to save and restore the error state.
This will be useful for the SSL stack to properly resurface handshake
failures. Leave this in a private header and, along the way, hide the
various types.

(ERR_NUM_ERRORS didn't change in meaning. The old documentation was
wrong.)

Bug: 206
Change-Id: I4c6ca98d162d11ad5e17e4baf439a18fbe371018
Reviewed-on: https://boringssl-review.googlesource.com/21284
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-09 21:43:13 +00:00
David Benjamin 89bd372a02 Revert "Add new bots to the CQ."
This reverts commit 73ffb74b9e. The CQ
versions seem to be broken for some reason. Will debug this later.

Change-Id: Ib5e30d612c55e907edf8ecede7f3d5e123d97bfb
Reviewed-on: https://boringssl-review.googlesource.com/21464
Reviewed-by: David Benjamin <davidben@google.com>
2017-10-09 21:38:10 +00:00
David Benjamin 73ffb74b9e Add new bots to the CQ.
We'll see if this becomes too burdensome.

Change-Id: I51546c3f6ee38e70a9397f9ce695035d382acfa0
Reviewed-on: https://boringssl-review.googlesource.com/21424
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-10-09 20:52:23 +00:00
Robert Sloan e091af4f37 Special-case Eureka in generate_build_targets.py.
This change upstreams
https://android-review.googlesource.com/#/c/platform/external/boringssl/+/504700
by bcf@, which adds generated makefile options for Eureka targets that
depend on the legacy Android.mk build system.

Change-Id: I9b98b7e6f245c6c2525357afe246b5002065127d
Reviewed-on: https://boringssl-review.googlesource.com/21444
Reviewed-by: David Benjamin <davidben@google.com>
2017-10-09 20:44:15 +00:00
Daniel Wagner-Hall 10154320fd Set -Wno-array-bounds on gcc<4.8
It spuriously complains about pointer math on function arguments which
are arrays.

Change-Id: I23b3494740196d5d46ce525a32dd43782e77f0ce
Reviewed-on: https://boringssl-review.googlesource.com/21404
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-09 20:43:39 +00:00
Adam Langley 2e9bb4eb96 Fix comment about EarlyCCS.
Thanks to Dimitar Vlahovski for pointing this out.

Change-Id: I417f52ec6c3e950bdab6079962b29976fb75c029
Reviewed-on: https://boringssl-review.googlesource.com/21324
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-06 22:46:57 +00:00
David Benjamin 861f28a624 Clear one more timeout when using gdb.
https://boringssl-review.googlesource.com/18605 got the other ones.

Change-Id: If00487a4dd8508496a31a0a565c965559e12879c
Reviewed-on: https://boringssl-review.googlesource.com/21264
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-06 17:23:07 +00:00
David Benjamin 4519a5a063 Pass -fmsc-version=1900 to clang-cl.
This matches the Chromium build. There are some build errors when using
the newer toolchain's headers. This might resolve it? clang-cl
apparently claims VS2013 by default and Microsoft's headers are
sensitive to this.

Change-Id: Ib849e33d8a28649d981ea73972f568fd81e534a1
Reviewed-on: https://boringssl-review.googlesource.com/21244
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-06 15:41:27 +00:00
David Benjamin 3b5b87f579 Teach vs_toolchain.py to load both MSVC 2015 and 2017.
The default is still 2015, but I'll use this to spin up some 2017 bots
as well.

Change-Id: Id189791c5c50ae5403f7d6db1cd486f8a3f43dfa
Reviewed-on: https://boringssl-review.googlesource.com/21165
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-06 14:47:50 +00:00
David Benjamin 75d36eacf8 No-op change to kick the bots
Change-Id: I6cd6a7eb670ad20dfdfc1895940fb023d18d37b3
2017-10-05 20:24:42 -04:00
David Benjamin 02afbd338e Build with clang-cl standalone.
Our build logic needed to revised and and clang implements more warnings
than MSVC, so GTest needed more fixes.

Bug: 200
Change-Id: I84c5dd0c51079dd9c990e08dbea7f9022a7d6842
Reviewed-on: https://boringssl-review.googlesource.com/21204
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-05 20:42:49 +00:00
David Benjamin 392cedd0a2 Fx DH_set0_pqg.
Typo.

Change-Id: Iab3e04339bb868fd6d247c6696f33f5b7150408d
Reviewed-on: https://boringssl-review.googlesource.com/21184
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Martin Kreichgauer <martinkr@google.com>
Reviewed-by: Martin Kreichgauer <martinkr@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-05 18:50:48 +00:00
David Benjamin 12fdd08a40 Remove C4245 suppression.
Chromium builds with this warning on. This lets us notice problems (of
which there were only one) sooner. I'll try to align the other warnings
in a follow-up.

Change-Id: Id0960b782733b799e1c3e82f89c2aaba0bdd6833
Reviewed-on: https://boringssl-review.googlesource.com/21164
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-05 17:34:58 +00:00
Daniel Wagner-Hall 1de690b992 Ignore unused value
Right now, compiling with the stock gcc on debian, cmake is compiling
with -Wall which gives an error because -Wunused-value.

The gcc version is gcc (Debian 4.7.2-5) 4.7.2.

Change-Id: Iafd4cc14a22fe788d4c7bdb05202fd856f0c6395
Reviewed-on: https://boringssl-review.googlesource.com/21144
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-05 15:20:48 +00:00
David Benjamin 6c1f2b77de Test that we tolerate server-sent supported groups.
I should have added this test in
https://boringssl-review.googlesource.com/10320. This is necessary in
TLS 1.3 and spec compliance and TLS 1.2 to tolerate some broken servers.

Change-Id: Ibb52eaa1e370062f83e84856ef7f1c2c79d6a5d3
Reviewed-on: https://boringssl-review.googlesource.com/21124
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-05 15:14:29 +00:00
David Benjamin a65c252f78 Further simplify error queue flags.
ERR_FLAGS_STRING is meaningless and we can use a bitfield for the mark
bit.

Change-Id: I6f677b55b11316147512171629196c651cb33ca9
Reviewed-on: https://boringssl-review.googlesource.com/21084
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-04 16:02:16 +00:00
David Benjamin 1c58471cc9 Add TLS 1.3 EXPORTER_SECRET to SSLKEYLOGFILE.
Per discussion in https://bugzilla.mozilla.org/show_bug.cgi?id=1287711.
Otherwise this feature won't work for QUIC.

Change-Id: Ia799bfd1e29c01161c4298fb3124c96f62ada9c5
Reviewed-on: https://boringssl-review.googlesource.com/21104
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-04 15:24:58 +00:00
David Benjamin e7136a978f Fix sha1.c's preprocessor checks.
sha1-altivec.c is not sensitive to OPENSSL_NO_ASM, so sha1.c needs to
disable the generic implementation accordingly.

Bug: 204
Change-Id: Ic655f8b76907f07da33afa863d1b24d62d42e23a
Reviewed-on: https://boringssl-review.googlesource.com/21064
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-03 22:24:34 +00:00
David Benjamin a4bafd33b3 Add SSL_SESSION_{get,set}_protocol_version.
SSL_SESSION_set_protocol_version is useful when unit-testing a session
cache.

Change-Id: I4b04e31d61ce40739323248e3e5fdae498c4645e
Reviewed-on: https://boringssl-review.googlesource.com/21044
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-03 19:52:34 +00:00
Steven Valdez 4c7f5fa023 Remove old TLS 1.3 variants (NoSessionID and RecordType).
Change-Id: I2428321218d0b5dce242e3843d39ca269e1eb686
Reviewed-on: https://boringssl-review.googlesource.com/20984
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: David Benjamin <davidben@google.com>
2017-10-03 18:12:23 +00:00
David Benjamin 51776b0aeb Document more of err.h.
A lot of the private functions are public APIs.

Change-Id: Icb5b6691088f27e16fb1d5f9fb8422e7cf2bab3e
Reviewed-on: https://boringssl-review.googlesource.com/21005
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-02 21:26:58 +00:00
David Benjamin e1c3dad959 Error data is always a NUL-terminated malloced string.
Cut down on the number of cases we need to worry about here. In
particular, it would be useful for the handshake to be able to replay an
error.

Change-Id: I2345faaff5503ede1324a5599e680de83f4b106e
Reviewed-on: https://boringssl-review.googlesource.com/21004
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-02 21:24:08 +00:00
David Benjamin f496249405 Switch int to bool in ssl_cipher.cc.
Change-Id: I815f9fa77e08f72b0130ea9ef0dda751bf2ed7a6
Reviewed-on: https://boringssl-review.googlesource.com/20826
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Martin Kreichgauer <martinkr@google.com>
2017-10-02 20:41:20 +00:00
David Benjamin ed9aed1ac6 int to bool in ssl_versions.cc.
Bug: 132
Change-Id: I1d6cd1dd7470a3f64ec91b954042ed3f8c6b561e
Reviewed-on: https://boringssl-review.googlesource.com/20825
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Martin Kreichgauer <martinkr@google.com>
2017-10-02 20:41:08 +00:00
David Benjamin 63a0797ff2 Remove now unnecessary _POSIX_C_SOURCE bits to work around macOS bug.
crypto/bio/bio_test.cc - I'm not sure where this was added for, but none
   of the functions used there appear to have feature macros documented.
crypto/bio/printf.c - -std=c99 provides (v)snprintf.
crypto/lhash/lhash_test.cc - we no longer call rand_r.
crypto/mem.c - we no longer call strdup and -std=c99 provides (v)snprintf.

Apple messed up their headers and, if _POSIX_C_SOURCE is defined but
_DARWIN_C_SOURCE isn't, pthread.h no longer defines mach_port_t. They
then shipped a version of libc++ headers that is missing this fix, so
the build breaks:
https://github.com/llvm-mirror/libcxx/commit/bcc92d75df0274b9593ebd097fcae60494e3bffc

If one uses XCode, they've hacked their pthread.h to provide mach_port_t
if defined(__cplusplus), but the standalone tools appear to be old and
missing this.

We can work around this by also defining _DARWIN_C_SOURCE in C++ files
that need _POSIX_C_SOURCE, but it appears none of these files actually
need it.

Change-Id: I5df9453730696100eb22b809febeb65053701322
Reviewed-on: https://boringssl-review.googlesource.com/20964
Reviewed-by: Adam Langley <agl@google.com>
2017-10-02 20:02:22 +00:00
David Benjamin b949355132 Add bssl::Span<T>::subspan and use it.
This roughly aligns with absl::Span<T>::subspan.

Bug: 132
Change-Id: Iaf29418c1b10e2d357763dec90b6cb1371b86c3b
Reviewed-on: https://boringssl-review.googlesource.com/20824
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Martin Kreichgauer <martinkr@google.com>
2017-10-02 19:33:28 +00:00
David Benjamin 312e1e4f66 Quote CMAKE_OSX_SYSROOT.
In case the XCode install is at, say "/Applications/Xcode 9.app". This
won't work if the path contains quotes, but it doesn't appear CMake
itself makes any effort to handle that right.

Change-Id: Ifecf6147d44ffdae8c2692b2d6c94bfafd8d7714
Reviewed-on: https://boringssl-review.googlesource.com/20944
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-10-02 19:22:17 +00:00
David Benjamin 575334657f Use BN_mod_exp_mont_consttime in dsa_priv_decode.
The exponent is secret, so we should be using the consttime variant. See
also upstream's f9cbf470180841966338db1f4c28d99ec4debec4.

Change-Id: I233d4223ded5b80711d7c8f906e3579c36b24cd0
Reviewed-on: https://boringssl-review.googlesource.com/20924
Reviewed-by: Adam Langley <agl@google.com>
2017-09-29 23:19:22 +00:00
David Benjamin 81f030b106 Switch OPENSSL_VERSION_NUMBER to 1.1.0.
Although we are derived from 1.0.2, we mimic 1.1.0 in some ways around
our FOO_up_ref functions and opaque libssl types. This causes some
difficulties when porting third-party code as any OPENSSL_VERSION_NUMBER
checks for 1.1.0 APIs we have will be wrong.

Moreover, adding accessors without changing OPENSSL_VERSION_NUMBER can
break external projects. It is common to implement a compatibility
version of an accessor under #ifdef as a static function. This then
conflicts with our headers if we, unlike OpenSSL 1.0.2, have this
function.

This change switches OPENSSL_VERSION_NUMBER to 1.1.0 and atomically adds
enough accessors for software with 1.1.0 support already. The hope is
this will unblock hiding SSL_CTX and SSL_SESSION, which will be
especially useful with C++-ficiation. The cost is we will hit some
growing pains as more 1.1.0 consumers enter the ecosystem and we
converge on the right set of APIs to import from upstream.

It does not remove any 1.0.2 APIs, so we will not require that all
projects support 1.1.0. The exception is APIs which changed in 1.1.0 but
did not change the function signature. Those are breaking changes.
Specifically:

- SSL_CTX_sess_set_get_cb is now const-correct.

- X509_get0_signature is now const-correct.

For C++ consumers only, this change temporarily includes an overload
hack for SSL_CTX_sess_set_get_cb that keeps the old callback working.
This is a workaround for Node not yet supporting OpenSSL 1.1.0.

The version number is set at (the as yet unreleased) 1.1.0g to denote
that this change includes https://github.com/openssl/openssl/pull/4384.

Bug: 91
Change-Id: I5eeb27448a6db4c25c244afac37f9604d9608a76
Reviewed-on: https://boringssl-review.googlesource.com/10340
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Reviewed-by: Adam Langley <agl@google.com>
2017-09-29 04:51:27 +00:00
David Benjamin ced6e76661 Make all_tests.go output cleaner.
It's a little hard to read with all those command-lines flying by. Only
print out full commands for failing tests.

Change-Id: I35f2febf7686dbc1ab428fe5d06afee2afa8bcaf
Reviewed-on: https://boringssl-review.googlesource.com/20905
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-28 21:28:50 +00:00
David Benjamin 737d2dffdf Convert ClientHello tests to GTest.
I was just passing by.

Change-Id: I0212b4a1a3fd2ad24d7157181cd55a92263a3727
Reviewed-on: https://boringssl-review.googlesource.com/20904
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-28 19:28:47 +00:00
David Benjamin e9c7b1c8ae Add SSL_SESSION_is_single_use.
Querying versions is a bit of a mess between DTLS and TLS and variants
and friends. Add SSL_SESSION_is_single_use which informs the caller
whether the session should be single-use.

Bug: chromium:631988
Change-Id: I745d8a5dd5dc52008fe99930d81fed7651b92e4e
Reviewed-on: https://boringssl-review.googlesource.com/20844
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-28 18:38:17 +00:00
David Benjamin 21fa684236 Have fun with lock scopers.
Change-Id: I2697349024769545c2c37173e6ed68640b7d3b78
Reviewed-on: https://boringssl-review.googlesource.com/20805
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-28 17:49:37 +00:00
David Benjamin 9eaa3bd55d Remove SSL_CTX_sessions and properly lock SSL_CTX_sess_number.
SSL_CTX_sessions is the only think making us expose LHASH as public API
and nothing uses it. Nothing can use it anyway as it's not thread-safe.
I haven't actually removed it yet since SSL_CTX is public, but once the
types are opaque, we could trim the number of symbols ssl.h pulls in
with some work.

Relatedly, fix thread safety of SSL_CTX_sess_number.

Change-Id: I75a6c93509d462cd5ed3ce76c587f0d1e7cd0797
Reviewed-on: https://boringssl-review.googlesource.com/20804
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-27 21:58:05 +00:00
David Benjamin 73d42e614c Inline ssl_clear_tls13_state.
The function has exactly one caller. Also add some comments.

Change-Id: I1566aed625449c91f25a777f5a4232d236019ed7
Reviewed-on: https://boringssl-review.googlesource.com/20673
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-27 18:32:34 +00:00
David Benjamin b1cf48ea41 Store the peer_sigalgs as an Array.
Bug: 132
Change-Id: I710dbd4906bb7a8b971831be0121df5b78e4f9e0
Reviewed-on: https://boringssl-review.googlesource.com/20672
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-27 18:30:13 +00:00
David Benjamin 879efc3f3b Switch more things to Array.
This adds a CBBFinishArray helper since we need to do that fairly often.

Bug: 132
Change-Id: I7ec0720de0e6ea31caa90c316041bb5f66661cd3
Reviewed-on: https://boringssl-review.googlesource.com/20671
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-27 18:29:43 +00:00
David Benjamin 08f5c76898 Convert more things to Array.
This adds a CopyFrom companion to Init as a replacement for CBS_stow.

Bug: 132
Change-Id: I4d77291b07552bd2286a09f8ba33655d6d97c853
Reviewed-on: https://boringssl-review.googlesource.com/20670
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-27 18:02:23 +00:00
David Benjamin 6b3ab72602 Add an implicit CBS to Span<const uint8_t> conversion.
They are exactly the same structure. Doing it in CBS allows us to switch
bssl::Span to absl::Span or a standard std::span in the future.

Bug: 132
Change-Id: Ibc96673c23233d557a1dd4d8768d2659d7a4ca0c
Reviewed-on: https://boringssl-review.googlesource.com/20669
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-27 18:01:05 +00:00
David Benjamin cf0ce676d6 Use Span and Array for the curve list.
There seems to be a GCC bug that requires kDefaultGroups having an
explicit cast, but this is still much nicer than void(const uint16_t **,
size_t *) functions.

Bug: 132
Change-Id: Id586d402ca0b8a01370353ff17295e71ee219ff3
Reviewed-on: https://boringssl-review.googlesource.com/20668
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-27 18:00:05 +00:00
David Benjamin 499742c60f Introduce bssl::Array<T> and use it in SSLKeyShare.
An Array<T> is an owning Span<T>. It's similar to absl::FixedArray<T>
but plays well with OPENSSL_malloc and doesn't implement inlining. With
OPENSSL_cleanse folded into OPENSSL_free, we could go nuts with
UniquePtr<uint8_t>, but having the pointer and length tied together is
nice for other reasons. Notably, Array<T> plays great with Span<T>.

Also switch the other parameter to a Span.

Bug: 132
Change-Id: I4cdcf810cf2838208c8ba9fcc6215c1e369dffb8
Reviewed-on: https://boringssl-review.googlesource.com/20667
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-27 17:29:23 +00:00
David Benjamin 6666886a9c Fix EnableIfContainer with MSVC 2015.
MSVC 2015's SFINAE implementation is broken. In particular, it seems not
to bother expanding EnableIfContainer unless we force it to by writing
::type. That means we need to use std::enable_if rather than
enable_if_t, even though it's quite wordy.

Change-Id: Ic643ab8a956991bb14af07832be80988f7735428
Reviewed-on: https://boringssl-review.googlesource.com/20764
Commit-Queue: Martin Kreichgauer <martinkr@google.com>
Reviewed-by: Martin Kreichgauer <martinkr@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-27 17:20:06 +00:00
David Benjamin 15868b3bba Revert "Work around a Java client bug when rotating certificates."
This reverts commit aba057a4e0 and
5a79ff5efd.

Change-Id: Ia53a3908491ec99ab25ea1d1bdedf322c2fbe5c4
Reviewed-on: https://boringssl-review.googlesource.com/20744
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-26 22:27:47 +00:00
David Benjamin 42e93b6cf5 Export EVP_parse_digest_algorithm and add EVP_marshal_digest_algorithm.
Chromium's OCSP code needs the OIDs and we already have them on hand.

Change-Id: Icab012ba4ae15ce029cbfe3ed93f89470137e7f6
Reviewed-on: https://boringssl-review.googlesource.com/20724
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-25 20:44:13 +00:00
David Benjamin 3a18bf0474 Tidy up alignof #defines.
We haven't supported MSVC 2013 for a while (we may even be able to drop
2015 in not too long). There is also no need to pull in stdalign.h in
C++. alignof and alignas are keywords.

Change-Id: Ib31d8166282592bcb9e1c543e57758ff55746404
Reviewed-on: https://boringssl-review.googlesource.com/20704
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-25 14:20:54 +00:00
David Benjamin e58f8a6b9a Simplify tls1_change_cipher_spec.
Rather than use those weird bitmasks, just pass an evp_aead_direction_t
and figure it out from there.

Change-Id: Ie52c6404bd0728d7d1ef964a3590d9ba0843c1d6
Reviewed-on: https://boringssl-review.googlesource.com/20666
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-22 15:18:17 +00:00
David Benjamin 38570b26b8 Clear a goto in d1_srtp.cc.
Bug: 132
Change-Id: I4ba12f1dfbbdc75cb3841dc70f9007bd8695da97
Reviewed-on: https://boringssl-review.googlesource.com/20665
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-22 15:15:48 +00:00
David Benjamin b7e5b08a20 Remove some redundant OPENSSL_cleanses.
Anything heap-allocated is automatically cleansed.

Change-Id: I88034251bcba7a3e74c0d1ec887dff5a4c16fa8b
Reviewed-on: https://boringssl-review.googlesource.com/20664
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-22 13:52:37 +00:00
David Benjamin b1b76aee3c Add SSL_CIPHER_get_prf_nid.
draft-ietf-quic-tls needs access to the cipher's PRF hash to size its
keys correctly.

Change-Id: Ie4851f990e5e1be724f262f608f7195f7ca837ca
Reviewed-on: https://boringssl-review.googlesource.com/20624
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-21 21:44:15 +00:00
David Benjamin cecf1a72ba Remove unused RSA_METHOD field.
We can finally trim this thing.

Change-Id: I8efd0be23ca11e39712e34734be5cdc70e8ffdc4
Reviewed-on: https://boringssl-review.googlesource.com/20604
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-21 19:01:46 +00:00
David Benjamin c03c218190 Fix some issues with name constraints test certs.
First, I spelled the wildcard name constraint in many_constraints.pem
wrong. It's .test, not *.test for name constraints. (This doesn't matter
for some_names*.pem, but it does to avoid a false negative in
many_names3.pem.)

Second, the CN of certs should be a host, not "Leaf". OpenSSL 1.1.0
checks "host-like" CNs against name constraints too and "Leaf" is
host-like.

I've also made the generator deterministic and checked it in, as PEM
blobs are not reviewable.

Change-Id: I195d9846315168a792cca829aff25c986339b8f5
Reviewed-on: https://boringssl-review.googlesource.com/20584
Reviewed-by: David Benjamin <davidben@google.com>
2017-09-20 21:06:00 +00:00
David Benjamin 4015000e19 Add a test for lots of names and constraints.
Change-Id: I0ad593cb5c73d61391aa7513054e5cf102334817
Reviewed-on: https://boringssl-review.googlesource.com/20524
Reviewed-by: Martin Kreichgauer <martinkr@google.com>
Commit-Queue: Martin Kreichgauer <martinkr@google.com>
2017-09-20 19:58:48 +00:00
Vincent Batts 60931e2d8a Explicit fallthrough on switch
Fixes failed compile with [-Werror=implicit-fallthrough=], which is
default on gcc-7.x on distributions like fedora.

Enabling no implicit fallthrough for more than just clang as well to
catch this going forward.

Change-Id: I6cd880dac70ec126bd7812e2d9e5ff804d32cadd
Signed-off-by: Vincent Batts <vbatts@redhat.com>
Reviewed-on: https://boringssl-review.googlesource.com/20564
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2017-09-20 19:58:25 +00:00
Adam Langley 6b35262272 Maintain EVP_MD_CTX invariants.
Thanks to Lennart Beringer for pointing that that malloc failures could
lead to invalid EVP_MD_CTX states. This change cleans up the code in
general so that fallible operations are all performed before mutating
objects. Thus failures should leave objects in a valid state.

Also, |ctx_size| is never zero and a hash with no context is not
sensible, so stop handling that case and simply assert that it doesn't
occur.

Change-Id: Ia60c3796dcf2f772f55e12e49431af6475f64d52
Reviewed-on: https://boringssl-review.googlesource.com/20544
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
2017-09-20 18:43:21 +00:00
Peter Wu 40b24c8154 Add "-www" option to server tool.
Add a simple dumb webserver that responds with the session status for
any GET request. This option is intended to be used with -loop to
generate automated responses to requests and serves two purposes: (1)
test that application data from clients can be decrypted, (2) test that
clients can decrypt data from the server and (3) early data indicator.

Change-Id: I2b8374ca7b8db4c8effab42e86b5e3139d9466e1
Reviewed-on: https://boringssl-review.googlesource.com/20305
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-19 20:01:03 +00:00
Peter Wu 5663b634f4 Write connection info to a BIO instead of stderr.
Make PrintConnectionInfo write to a BIO rather than stderr.
This prepares for writing connection details to the peer.

Change-Id: I88147952712da57f9a2a1e464371075df156741f
Reviewed-on: https://boringssl-review.googlesource.com/20304
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-19 19:50:44 +00:00
David Benjamin 1d6e36525d Remove CHROMIUM_ROLLING_MAGENTA_TO_ZIRCON scaffolding.
https://chromium-review.googlesource.com/c/chromium/src/+/669139 has
landed.

Bug: chromium:765754
Change-Id: I6f6c52f053698348673eaa1e2574801b3f6b2041
Reviewed-on: https://boringssl-review.googlesource.com/20505
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-18 21:34:32 +00:00
David Benjamin 2186fbc22c Refresh update_clang.py and download Windows Clang.
This is taken from Chromium and then pared down to remove unnecessary
bits. The Windows setup is somewhat more involved due to needing to copy
some DLL from Visual Studio.

Bug: 201
Change-Id: I0658f7a20ec4fdea007821d5ce331acd3cb494b2
Reviewed-on: https://boringssl-review.googlesource.com/20504
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-18 20:36:33 +00:00
David Benjamin 246e27d807 Switch the buggy RSA parser off by default.
I'll fully remove this once Chrome 62 hits stable, in case any bug
reports come in for Chrome 61. Meanwhile switch the default to off so
that other consumers pick up the behavior. (Should have done this sooner
and forgot.)

Bug: chromium:735616
Change-Id: Ib27c4072f228cd3b5cce283accd22732eeef46b2
Reviewed-on: https://boringssl-review.googlesource.com/20484
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-18 19:42:51 +00:00
David Benjamin f231d6bfa6 Remove CTR_DRBG_STATE alignment marker.
We don't get up to 16-byte alignment without additional work like
https://boringssl-review.googlesource.com/20204. This just makes UBSan
unhappy at us.

Change-Id: I55d9cb5b40e5177c3c7aac7828c1d22f2bfda9a6
Reviewed-on: https://boringssl-review.googlesource.com/20464
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-18 19:17:52 +00:00
Martin Kreichgauer 6dc892fcdf Remove redundant calls to |OPENSSL_cleanse| and |OPENSSL_realloc_clean|.
Change-Id: I5c85c4d072ec157b37ed95b284a26ab32c0c42d9
Reviewed-on: https://boringssl-review.googlesource.com/19824
Reviewed-by: Martin Kreichgauer <martinkr@google.com>
Commit-Queue: Martin Kreichgauer <martinkr@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-18 19:16:51 +00:00
David Benjamin c5cc88d800 Test that movsd without arguments is left as-is.
This works fine, but probably worth a test.

Change-Id: If060b473958c1664e450102cafe0ca28951bff49
Reviewed-on: https://boringssl-review.googlesource.com/20444
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-18 19:09:31 +00:00
Adam Langley e314e1c000 Support [v]movsd in delocate.
Newer versions of LLVM can emit this instruction. Note that there are
two different Intel instructions, both called “movsd”. The old one is an
auto-incrementing move that doesn't take any arguments. That's not the
one that is targetted in this change.

Change-Id: Id0c96e0c7fe0f6e4feb8a72b5bc0fa40878225b9
Reviewed-on: https://boringssl-review.googlesource.com/20425
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-18 18:49:26 +00:00
Adam Langley 32c5b8dee3 delocate vmovq correctly.
vmovq clears the upper 128 bits of a YMM register, while movq does not.
When translating vmovq to an XMM register, we need to use vmovq in the
final move in order to keep this behaviour.

Change-Id: I81b6eee3ee6db0ea90d7c5098fc7c4ccefaf3b12
Reviewed-on: https://boringssl-review.googlesource.com/20424
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-18 18:39:05 +00:00
Adam Langley e64ef27cbe Add EVP AES-128 CFB128 support via decrepit.
Change-Id: I37a438b5b4b18d18756ba4aeb9f8548caa333981
Reviewed-on: https://boringssl-review.googlesource.com/20384
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-18 18:34:06 +00:00
David Benjamin 9a127b43b8 Add CRYPTO_needs_hwcap2_workaround.
Bug: 203
Change-Id: I50384cce14509ab1ca36e6f0e9f192f9e458b313
Reviewed-on: https://boringssl-review.googlesource.com/20404
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-18 14:05:46 +00:00
David Benjamin 82dfea8d9e Bound everything parsed by the legacy ASN.1 stack.
crypto/asn1 routinely switches between int and long without overflow
checks. Fortunately, it funnels everything into a common entrypoint, so
we can uniformly bound all inputs to something which comfortably fits in
an int.

Change-Id: I340674c6b07820309dc5891024498878c82e225b
Reviewed-on: https://boringssl-review.googlesource.com/20366
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-15 22:57:22 +00:00
David Benjamin 288ca7dcb4 Remove ASN1_template_(i2d,d2i).
Thes are remnants of some old setup.

Change-Id: I09151fda9419fbe7514f2f609f70284965694bfa
Reviewed-on: https://boringssl-review.googlesource.com/20365
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-15 22:53:43 +00:00
David Benjamin 9a4876e193 Remove hmac.h include from ssl.h.
base.h pulls in all the forward declarations, so this isn't needed.  We
should also remove bio.h and buf.h, but cURL seems to depend on those.
Code search suggests this one is okay though.

  case:yes content:\bHMAC content:openssl/ssl.h -content:openssl/hmac.h

Change-Id: Id91686bd134649245855025940bc17f82823c734
Reviewed-on: https://boringssl-review.googlesource.com/20364
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-15 22:48:43 +00:00
David Benjamin f51f273ee8 Temporarily gate new Fuchsia APIs on CHROMIUM_ROLLING_MAGENTA_TO_ZIRCON.
This is to keep Chromium building.

Bug: chromium:765754
Change-Id: I312f747e27e53590a948305f80abc240bfd2063c
Reviewed-on: https://boringssl-review.googlesource.com/20344
Reviewed-by: Aaron Green <aarongreen@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
2017-09-15 19:13:35 +00:00
Aaron Green 36d59479a5 Update Fuchsia symbols that have been renamed
Fuchsia needed to rename Magenta to Zircon.  Several syscalls and status
codes changed as a result.

Change-Id: I64b5ae4537ccfb0a318452fed34040a2e8f5012e
Reviewed-on: https://boringssl-review.googlesource.com/20324
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-15 18:50:03 +00:00
David Benjamin 5a79ff5efd Clarify some comments.
Further testing suggests the behavior is slightly different than I
originally thought.

Change-Id: I3df6b3425dbb551e374159566ca969347d72a306
Reviewed-on: https://boringssl-review.googlesource.com/20284
Commit-Queue: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-14 21:15:23 +00:00
David Benjamin 33fc2ba4e2 Opaquify SSL_CIPHER.
Bug: 6
Change-Id: Ieb2a8816b63425dce64e26ac41ded894a6c5e61b
Reviewed-on: https://boringssl-review.googlesource.com/20264
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-13 20:30:00 +00:00
Peter Wu 368cc3b7e7 Add support for SSLKEYLOGFILE to server tool.
Mirrors the same functionality that is present in the client tool.

Tested by connecting the client with the server tool, verified that the
generated keylogs are identical.

Change-Id: Ic40b0ecb920383e01d7706574faf11fdb5c3fc7a
Reviewed-on: https://boringssl-review.googlesource.com/20244
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-13 18:25:20 +00:00
David Benjamin 683ffbbe57 Fix fuzzer mode suppressions.
Some tests got renamed.

Change-Id: I7ef788c10dc40de244778b9e80ae3a04afee3dd4
Reviewed-on: https://boringssl-review.googlesource.com/20226
Reviewed-by: Steven Valdez <svaldez@google.com>
2017-09-12 19:32:14 +00:00
David Benjamin 9c2b36adbd Refresh fuzzer corpus.
Change-Id: I547a46f77f732befe6731e7862e429568c033151
Reviewed-on: https://boringssl-review.googlesource.com/20225
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
2017-09-12 19:32:13 +00:00
Adam Langley a16e86ced5 Don't depend on 16-byte alignment from malloc.
Windows provides _aligned_malloc, so we could provide an
|OPENSSL_aligned_malloc| in the future. However, since we're still
trying to get the zeroisation change landed everywhere, a self-contained
change seems easier until that has settled down.

Change-Id: I47bbd811a7fa1758f3c0a8a766a1058523949b7f
Reviewed-on: https://boringssl-review.googlesource.com/20204
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-12 19:12:20 +00:00
Steven Valdez c7d4d21413 Add experiment without client CCS and fix session ID bug.
Change-Id: Id6cf63caf5a00d4d4ca66a5c7530c48c2d9ed91f
Reviewed-on: https://boringssl-review.googlesource.com/20164
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-12 18:05:50 +00:00
David Benjamin aba057a4e0 Work around a Java client bug when rotating certificates.
The Java client implementation of the 3SHAKE mitigation incorrectly
rejects initial handshakes when all of the following are true:

1. The ClientHello offered a session.
2. The session was successfully resumed previously.
3. The server declines the session.
4. The server sends a certificate with a different SAN list than in the
   previous session.

(Note the 3SHAKE mitigation is to reject certificates changes on
renegotiation, while Java's logic applies to initial handshakes as
well.)

The end result is long-lived Java clients break on some certificate
rotations. Fingerprint Java clients and decline all offered sessions.
This avoids (2) while still introducing new sessions to clear any
existing problematic sessions.

See also b/65323005.

Change-Id: Ib2b84c69b5ecba285ffb8c4d03de5626838d794e
Reviewed-on: https://boringssl-review.googlesource.com/20184
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-12 15:56:59 +00:00
Steven Valdez 1682126fd8 Add Experiment 2
Change-Id: If240cbeb133a23331cb6ca59eaacde7733592278
Reviewed-on: https://boringssl-review.googlesource.com/20144
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-11 16:53:16 +00:00
David Benjamin 54c259dec3 Clarify RSA_add_pkcs1_prefix must be released with OPENSSL_free.
Change-Id: I24b382ccbbbd33ad23c8f64fd91b1d4d41f6c576
Reviewed-on: https://boringssl-review.googlesource.com/20124
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-08 21:20:34 +00:00
David Benjamin a9c96bae8a Remove a DHE remnant from runner.
Change-Id: I98a42572af71e18839a29eb0f7547d17d08f2c22
Reviewed-on: https://boringssl-review.googlesource.com/20024
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-08 14:48:10 +00:00
David Benjamin 6881ec0465 Add a note to PORTING.md about free/OPENSSL_free mixups.
Change-Id: I7cf0e67148c0908e5a4c670251419a8bc15fbea9
Reviewed-on: https://boringssl-review.googlesource.com/20109
Reviewed-by: Martin Kreichgauer <martinkr@google.com>
2017-09-07 23:04:31 +00:00
David Benjamin 2978d055f6 Refresh TLS fuzzer corpus.
In particular, this starts a new DTLS corpus.

Bug: 124
Change-Id: I0fa0b38ac1cd213cef99badde693e75ed7357ab4
Reviewed-on: https://boringssl-review.googlesource.com/20108
Reviewed-by: David Benjamin <davidben@google.com>
2017-09-07 22:27:24 +00:00
David Benjamin 2ff44b183a Add DTLS fuzzers.
Bug: 124
Change-Id: Iff02be9df2806572e6d3f860b448f598f85778c3
Reviewed-on: https://boringssl-review.googlesource.com/20107
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-07 22:26:50 +00:00
David Benjamin a196ea15af Share all of fuzz/{client,server}.cc into fuzzer.h.
There's a lot of duplicated code between the two. This is in preparation
for adding two more of these fuzzers, this time for DTLS.

Bug: 124
Change-Id: I8ca2a02d599e2c88e30838d04b7cf07d4221aa76
Reviewed-on: https://boringssl-review.googlesource.com/20106
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-07 22:14:12 +00:00
David Benjamin e51fb0fa71 Fix empty fragment handling in DTLS message reassembly.
Found with libFuzzer.

Bug: chromium:763097
Change-Id: I806bcfc714c0629ff7f725e37f4c0045d4ec7ac6
Reviewed-on: https://boringssl-review.googlesource.com/20105
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-07 22:11:10 +00:00
David Benjamin 769b386e97 Fix error handling/cleanup
(Imported from upstream's 4d2df46cb38603c98fb49543738289c9176571d8.)

Change-Id: I62e5d6fa58c57c4f5d30d00baf14f2024278c1de
Reviewed-on: https://boringssl-review.googlesource.com/20104
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-07 22:06:50 +00:00
Martin Kreichgauer b86be3617d Guard against DoS in name constraints handling.
This guards against the name constraints check consuming large amounts
of CPU time when certificates in the presented chain contain an
excessive number of names (specifically subject email names or subject
alternative DNS names) and/or name constraints.

Name constraints checking compares the names presented in a certificate
against the name constraints included in a certificate higher up in the
chain using two nested for loops.

Move the name constraints check so that it happens after signature
verification so peers cannot exploit this using a chain with invalid
signatures. Also impose a hard limit on the number of name constraints
check loop iterations to further mitigate the issue.

Thanks to NCC for finding this issue.

Change-Id: I112ba76fe75d1579c45291042e448850b830cbb7
Reviewed-on: https://boringssl-review.googlesource.com/19164
Reviewed-by: Martin Kreichgauer <martinkr@google.com>
Commit-Queue: Martin Kreichgauer <martinkr@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-06 22:00:46 +00:00
Martin Kreichgauer 3c995f30e7 Fix overflow in c2i_ASN1_BIT_STRING.
c2i_ASN1_BIT_STRING takes length as a long but uses it as an int. Check bounds
before doing so. Previously, excessively large inputs to the function could
write a single byte outside the target buffer. (This is unreachable as
asn1_ex_c2i already uses int for the length.)

Thanks to NCC for finding this issue.

Change-Id: I7ae42214ca620d4159fa01c942153717a7647c65
Reviewed-on: https://boringssl-review.googlesource.com/19204
Reviewed-by: Martin Kreichgauer <martinkr@google.com>
Commit-Queue: Martin Kreichgauer <martinkr@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-06 21:58:26 +00:00
David Benjamin d0beda01f9 Properly report SSL_session_reused after a renegotiation.
We forgot to reset that value.

Change-Id: Ic869cb61da332983cc40223cbbdf23b455dd9766
Reviewed-on: https://boringssl-review.googlesource.com/20084
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-06 20:56:06 +00:00
David Benjamin 3d8f0808e4 Honor SSL_SESS_CACHE_CLIENT in TLS 1.3.
The new_session_cb callback should not be run if SSL_SESS_CACHE_CLIENT
is off.

Change-Id: I1ab320f33688f186b241d95c81775331a5c5b1a1
Reviewed-on: https://boringssl-review.googlesource.com/20065
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-06 20:31:17 +00:00
David Benjamin a861460c89 Make SNI per-connection, not per-session.
Right now we report the per-connection value during the handshake and
the per-session value after the handshake. This also trims our tickets
slightly by removing a largely unused field from SSL_SESSION.

Putting it on SSL_HANDSHAKE would be better, but sadly a number of
bindings-type APIs expose it after the handshake.

Change-Id: I6a1383f95da9b1b141b9d6adadc05ee1e458a326
Reviewed-on: https://boringssl-review.googlesource.com/20064
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-06 20:25:26 +00:00
Martin Kreichgauer c0e15d1d9d Zero memory in |OPENSSL_free|.
Allocations by |OPENSSL_malloc| are prefixed with their length.
|OPENSSL_free| zeros the allocation before calling free(), eliminating
the need for a separate call to |OPENSSL_cleanse| for sensitive data.

This change will be followed up by the cleanup in
https://boringssl-review.googlesource.com/c/boringssl/+/19824.

Change-Id: Ie272f07e9248d7d78af9aea81dacec0fdb7484c4
Reviewed-on: https://boringssl-review.googlesource.com/19544
Reviewed-by: Martin Kreichgauer <martinkr@google.com>
Commit-Queue: Martin Kreichgauer <martinkr@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-06 19:22:46 +00:00
Martin Kreichgauer a23b68f564 ssl/test/runner: Change ecdsa.PublicKey initialization
Change-Id: I4dea223825da4e4ab0bc789e738f470f5fe5d659
Reviewed-on: https://boringssl-review.googlesource.com/20044
Commit-Queue: Martin Kreichgauer <martinkr@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-06 18:19:16 +00:00
David Benjamin be90bf764a Clarify ERR_print_errors_* clear the error queue.
Change-Id: Ifaa0129cbacb2346a8d206436eca783060181a85
Reviewed-on: https://boringssl-review.googlesource.com/20004
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-05 17:31:25 +00:00
David Benjamin 28d6979b7e Print errors better in FileTestGTest.
Rather than clear them, even on failure, detect if an individual test
failed and dump the error queue there. We already do this at the GTest
level in ErrorTestEventListener, but that is too coarse-grained for the
file tests.

Change-Id: I3437626dcf3ec43f6fddd98153b0af73dbdcce84
Reviewed-on: https://boringssl-review.googlesource.com/19966
Reviewed-by: Steven Valdez <svaldez@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-05 17:24:15 +00:00
David Benjamin 24e36099ce Teach evp_test to verify by round-tripping.
We have no tests for encryption right now, and evp_tests.txt needs to
force RSA-PSS to have salt length 0, even though other salt values are
more common. This also lets us test the salt length -2 silliness.

Change-Id: I30f52d36c38732c9b63a02c66ada1d08488417d4
Reviewed-on: https://boringssl-review.googlesource.com/19965
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-05 15:48:25 +00:00
David Benjamin 8459d06599 Properly size_t EVP_PKEY_CTX_set0_rsa_oaep_label.
We do not expose EVP_PKEY_CTX_ctrl, so we can freely change the
semantics of EVP_PKEY_CTRL_RSA_OAEP_LABEL. That means we can pass in an
actual size_t rather than an int.

Not that anyone is actually going to exceed an INT_MAX-length RSA-OAEP
label.

Change-Id: Ifc4eb296ff9088c8815f4f8cd88100a407e4d969
Reviewed-on: https://boringssl-review.googlesource.com/19984
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-05 15:26:45 +00:00
David Benjamin ce3773f9fe Add a test for OAEP labels and custom digests.
It was pointed out that we have no test coverage of this. Fix this. Test
vector generated using Go's implementation.

Change-Id: Iddbc50d3b422e853f8afd50117492f4666a47373
Reviewed-on: https://boringssl-review.googlesource.com/19964
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-05 15:18:05 +00:00
David Benjamin 74795b32c6 More miscellaneous bools.
Change-Id: I0960fed68ef39e4523ef9f2ba89ffa92f09c4dce
Reviewed-on: https://boringssl-review.googlesource.com/19945
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-01 15:07:52 +00:00
David Benjamin 046bc1fbe8 SSL3_STATE ints to bools.
Change-Id: I0f153a3e22f960f2b600919b6bacac76b7a95093
Reviewed-on: https://boringssl-review.googlesource.com/19944
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-01 15:07:32 +00:00
David Benjamin 4cbb93195f Collapse client Finished states together.
By resolving Channel ID earlier, we can take advantage of
flight-by-flight writes.

Change-Id: I31265bda3390eb1faec976ac13d7a01ba5f6dd5f
Reviewed-on: https://boringssl-review.googlesource.com/19925
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-01 15:07:12 +00:00
David Benjamin fd45ee7da8 Replace bits in SSL_HANDSHAKE with bool.
Change-Id: I23f1449d8652a4aa3a9006e04c86c9430127800e
Reviewed-on: https://boringssl-review.googlesource.com/19924
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-09-01 15:05:52 +00:00
Steven Valdez d816874c52 Set SSL_in_init to false before new_session_cb.
This fixes a regression in Conscrypt added by
https://boringssl-review.googlesource.com/19144. SSL_get_session
otherwise attempts to return hs->new_session, but that has been released
at this point.

Change-Id: I55b41cbefb65b3ae3cfbfad72f6338bd66db3341
Reviewed-on: https://boringssl-review.googlesource.com/19904
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-08-31 15:43:25 +00:00
David Benjamin 1ab133a9da Fix some style guide samples.
Change-Id: I2a4c4b121da381687115a5959640ec6393a91e67
Reviewed-on: https://boringssl-review.googlesource.com/19844
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-08-31 14:24:45 +00:00
David Benjamin 6abaa316f0 Remove unnecessary parameter.
Change-Id: Ib6708b9a9f89ab8d548850575762032a36f9ba2f
Reviewed-on: https://boringssl-review.googlesource.com/19884
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-08-31 14:18:26 +00:00
David Benjamin 0a471910b4 Test empty extensions fields are omitted.
For historical reasons, TLS allows ServerHellos (and ClientHellos)
without extensions to omit the extensions fields entirely.
https://github.com/openssl/openssl/pull/4296 reports this is even
necessary for compatibility with extension-less clients. We continue to
do so, but add a test for it anyway.

Change-Id: I63c2e3a5f298674eb21952fca6914dad07d7c245
Reviewed-on: https://boringssl-review.googlesource.com/19864
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-08-31 14:17:36 +00:00
David Benjamin 2762b3542d Add X509_PUBKEY to bssl::UniquePtr.
Change-Id: I02d5c8f4a84facc2b120abc3268fb316670b7986
Reviewed-on: https://boringssl-review.googlesource.com/19804
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Matt Braithwaite <mab@google.com>
Reviewed-by: Matt Braithwaite <mab@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-08-30 17:23:31 +00:00
David Benjamin 3536809644 Update style guide for C++.
Change-Id: Ib8c681e221837407d7ae2578699b8a3f3227c1b7
Reviewed-on: https://boringssl-review.googlesource.com/19785
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-08-30 14:34:49 +00:00
David Benjamin c11ea942b7 Convert comments in ssl.
That's the last of it!

Change-Id: I93d1f5ab7e95b2ad105c34b24297a0bf77625263
Reviewed-on: https://boringssl-review.googlesource.com/19784
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-08-29 21:33:32 +00:00
David Benjamin 66d49b4952 Fix SSL_CTX client_CA list locking.
ctx->cached_x509_client_CA needs to be protected under a lock since
SSL_CTX_get_client_CA_list is a logically const operation. The fallback
in SSL_get_client_CA_list was not using this lock.

Change-Id: I2431218492d1a853cc1a59c0678b0b50cd9beab2
Reviewed-on: https://boringssl-review.googlesource.com/19765
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-08-29 20:44:42 +00:00
David Benjamin c79ae7aa8b Test SSL_add_client_CA.
That function actually got a little complicated after the CRYPTO_BUFFER
work.

Change-Id: Ib679a9f2bcc2c974fe059af49805b8200e77bd03
Reviewed-on: https://boringssl-review.googlesource.com/19764
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-08-29 20:36:02 +00:00
David Benjamin 3969fdf860 Test invalid certificates.
The fuzzer should discover this instantly, but it's a sufficiently
important failure case (don't accidentally drop the certificate on the
floor or anything weird like that) that it's probably worth testing.

Change-Id: I684932c2e8a88fcf9b2318bf46980d312c66f6ef
Reviewed-on: https://boringssl-review.googlesource.com/19744
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-08-29 20:27:58 +00:00
Steven Valdez 398085ba04 Simplify states with hs_wait_t returns.
Change-Id: Ie0014bf73625144503b649e84b43ca4b03a4df1f
Reviewed-on: https://boringssl-review.googlesource.com/19704
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-08-29 19:53:42 +00:00
David Benjamin e2ec654c9a Update to Go 1.9 on the bots.
Change-Id: I692424f05f543c98a994a444f0303ea0bda7c14f
Reviewed-on: https://boringssl-review.googlesource.com/19725
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-08-29 19:52:02 +00:00
David Benjamin 617b818b49 Add a test for SSL_R_NO_CIPHERS_AVAILABLE.
Easy bit of test coverage.

Change-Id: I0362fca926d82869b512e3c40dc53d6dc771dfc8
Reviewed-on: https://boringssl-review.googlesource.com/19724
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-08-29 19:49:32 +00:00
Steven Valdez 4d71a9a2ca Migrate TLS 1.2 and below state machines to the new style.
Bug: 128
Change-Id: Ief3779b1c43dd34a154a0f1d2f94d0da756bc07a
Reviewed-on: https://boringssl-review.googlesource.com/19144
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-08-29 19:23:22 +00:00
David Benjamin 8997b2aa57 Better test cert verification happening only once.
OpenSSL's API has a non-fatal "soft fail" mode (can we get rid of
this?), so we should set the flag even if config->verify_fail is true.

Change-Id: I5a2a3290b9bf45c682f3a629a8b6474b1090fc6e
Reviewed-on: https://boringssl-review.googlesource.com/19684
Commit-Queue: David Benjamin <davidben@google.com>
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-08-29 16:56:52 +00:00
4049 changed files with 887990 additions and 143339 deletions
+4
View File
@@ -4,4 +4,8 @@ AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
DerivePointerAlignment: false
PointerAlignment: Right
# TODO(davidben): The default for Google style is now Regroup, but the default
# IncludeCategories does not recognize <openssl/header.h>. We should
# reconfigure IncludeCategories to match. For now, keep it at Preserve.
IncludeBlocks: Preserve
+10 -2
View File
@@ -1,11 +1,15 @@
build/
build32/
build64/
ssl/test/runner/runner
*.pyc
*.swp
*.swo
doc/*.html
doc/doc.css
util/bot/android_tools
util/bot/android_ndk
util/bot/android_sdk/public
util/bot/cmake-linux64
util/bot/cmake-linux64.tar.gz
util/bot/cmake-mac
@@ -14,11 +18,15 @@ util/bot/cmake-win32
util/bot/cmake-win32.zip
util/bot/golang
util/bot/gyp
util/bot/libFuzzer
util/bot/libcxx
util/bot/libcxxabi
util/bot/llvm-build
util/bot/nasm-win32.exe
util/bot/perl-win32
util/bot/perl-win32.zip
util/bot/sde-linux64
util/bot/sde-linux64.tar.bz2
util/bot/sde-win32
util/bot/sde-win32.tar.bz2
util/bot/win_toolchain.json
util/bot/yasm-win32.exe
+65 -1
View File
@@ -98,7 +98,10 @@ objects. `bssl::UniquePtr<T>`, like other types, is forward-declared in
`openssl/base.h`. Code that needs access to the free functions, such as code
which destroys a `bssl::UniquePtr`, must include the corresponding module's
header. (This matches `std::unique_ptr`'s relationship with forward
declarations.)
declarations.) Note, despite the name, `bssl::UniquePtr` is also used with
reference-counted types. It owns a single reference to the object. To take an
additional reference, use the `bssl::UpRef` function, which will return a
separate `bssl::UniquePtr`.
### Stack-allocated types
@@ -175,6 +178,67 @@ These are usually for low-level cryptographic operations. These types may be
used freely without special cleanup conventions.
### Ownership and lifetime
When working with allocated objects, it is important to think about *ownership*
of each object, or what code is responsible for releasing it. This matches the
corresponding notion in higher-level languages like C++ and Rust.
Ownership applies to both uniquely-owned types and reference-counted types. For
the latter, ownership means the code is responsible for releasing one
reference. Note a *reference* in BoringSSL refers to an increment (and eventual
decrement) of an object's reference count, not `T&` in C++. Thus, to "take a
reference" means to increment the reference count and take ownership of
decrementing it.
As BoringSSL's APIs are primarily in C, ownership and lifetime obligations are
not rigorously annotated in the type signatures or checked at compile-time.
Instead, they are described in
[API documentation](https://commondatastorage.googleapis.com/chromium-boringssl-docs/headers.html).
This section describes some conventions.
Unless otherwise documented, functions do not take ownership of pointer
arguments. The pointer typically must remain valid for the duration of the
function call. The function may internally copy information from the argument or
take a reference, but the caller is free to release its copy or reference at any
point after the call completes.
A function may instead be documented to *take* or *transfer* ownership of a
pointer. The caller must own the object before the function call and, after
transfer, no longer owns it. As a corollary, the caller may no longer reference
the object without a separate guarantee on the lifetime. The function may even
release the object before returning. Callers that wish to independently retain a
transfered object must therefore take a reference or make a copy before
transferring. Callers should also take note of whether the function is
documented to transfer pointers unconditionally or only on success. Unlike C++
and Rust, functions in BoringSSL typically only transfer on success.
Likewise, output pointers may be owning or non-owning. Unless otherwise
documented, functions output non-owning pointers. The caller is not responsible
for releasing the output pointer, but it must not use the pointer beyond its
lifetime. The pointer may be released when the parent object is released or even
sooner on state change in the parent object.
If documented to output a *newly-allocated* object or a *reference* or *copy* of
one, the caller is responsible for releasing the object when it is done.
By convention, functions named `get0` return non-owning pointers. Functions
named `new` or `get1` return owning pointers. Functions named `set0` take
ownership of arguments. Functions named `set1` do not. They typically take a
reference or make a copy internally. These names originally referred to the
effect on a reference count, but the convention applies equally to
non-reference-counted types.
API documentation may also describe more complex obligations. For instance, an
object may borrow a pointer for longer than the duration of a single function
call, in which case the caller must ensure the lifetime extends accordingly.
Memory errors are one of the most common and dangerous bugs in C and C++, so
callers are encouraged to make use of tools such as
[AddressSanitizer](https://clang.llvm.org/docs/AddressSanitizer.html) and
higher-level languages.
## Thread safety
BoringSSL is internally aware of the platform threading library and calls into
+88
View File
@@ -0,0 +1,88 @@
# How to change BoringSSL's API
BoringSSL has more flexibility in changing things than many other library projects because we have a reasonable idea of who our users are. Still, breaking changes require some care. We depend on tight feedback loops with our consumers so that we can learn about mistakes and fix them. For that to work, updating BoringSSL must be smooth.
Ultimately, the strategy for each breaking change is decided on a case-by-case basis. This document provides guidelines and techniques to help with a smooth transition.
## Breakage risk
Traditionally, breaking changes are defined in terms of API or ABI surface. Exposed symbols and type signatures cannot change, etc. But this is a poor approximation of the true impact. Removing an API may not a breaking change if no one is using it. Conversely, [Hyrum's Law](http://www.hyrumslaw.com/) applies. Fixing a bug may be a breaking change for some consumer which was depending on that bug.
Thus, we do not think about whether a change is formally a breaking change, but about the *risk* of it breaking someone.
Some changes, such as internal cleanups or bug-fixes, are low risk and do not need special measures. Any problems can be handled when the affected consumer updates BoringSSL and notices.
Other changes, such as removing an API, forbidding some edge case, or adjusting some behavior, are more likely to break things. To help the consumer triage any resulting failures, include some text in the commit message, prefixed by `Update-Note: `. This can include what this change may break and instructions on how to fix the issue.
## Code Search
The vast majority of BoringSSL consumers are conveniently indexed in various Code Search instances. This can predict the impact of a risky change and identify code to fix ahead of time. The document &ldquo;How to Code Search&rdquo; in the (Google-only) [go/boringssl-folder](https://goto.google.com/boringssl-folder) includes notes on this.
## Evaluate a change's cost
If some change has high cost (from having to fix consumers) and relatively little benefit to BoringSSL, it may not be worth the trouble. For instance, it is likely not worth removing a small compatibility function in the corner of the library that is easily dropped by the static linker.
Conversely, a change that leads to a major improvement to all BoringSSL consumers, at the cost of fixing one or two consumers, is typically worth it.
## Fixing consumers
If code search reveals call sites that are definitely going to break, prefer to handle these before making the change. While unexpected breakage is always possible, we generally consider it the responsibility of the developer or group making a change to handle impact of that change. Teams are generally unhappy to be surprised by new migration work but happy to have migration work done for them.
In most cases, this is straightforward:
1. Add the replacement API.
2. As the replacement API enters each consuming repository, migrate callers to it.
3. Remove the original API once all consumers have been migrated.
The removal should still include an `Update-Note` tag, in case some were missed.
In some cases, this kind of staged approach is not feasible: perhaps the same code cannot simultaneously work before and after the change, or perhaps there are too many different versions in play. For instance, [Conscrypt](https://github.com/google/conscrypt) feeds into three different repositories. The GitHub repository consumes BoringSSL's `master` branch directly. It is pushed into Android, where it consumes Android's `external/boringssl`. Yet another copy is pushed into the internal repository, where it consumes that copy of BoringSSL. As each of these Conscrypts are updated independently from their corresponding BoringSSLs, Conscrypt upstream cannot rely on a new BoringSSL API until it is present in all copies of BoringSSL its downstreams rely on.
In that case, a multi-sided change may be more appropriate:
1. Upload the breaking change to Gerrit, but do not submit it yet. Increment the `BORINGSSL_API_VERSION` symbol.
2. Update the consuming repository with `#if BORINGSSL_API_VERSION < N` preprocessor logic. Leave a comment to remove this later, linking to your BoringSSL change.
3. When the `BORINGSSL_API_VERSION` check has propagated to relevant copies of the consuming repository, submit the BoringSSL change.
4. When the BoringSSL change has propagated to relevant copies of BoringSSL, remove the staging logic from the consumer.
Finally, in some cases, the consumer's change may be committed atomically with the BoringSSL update. This can only be done for code which only consumes one instance of BoringSSL (so the Conscrypt example above is not eligible). Check with that project's maintainer first or, better, be that project's maintainer.
If more complex changes are needed in some consumer, communicate with the relevant maintainers to plan the transition.
## Fail early, fail closed
When breaking changes do occur, they should fail as early and as detectably as possible.
Ideally, problematic consumers fail to compile. Prefer to remove functions completely over leaving an always failing stub function. Sometimes this is not possible due to other consumers, particularly bindings libraries. Alternatively, if a stub function can be reasonably justified as still satisfying the API constraints, consider adding one to improve compatibility. For example, BoringSSL has many no-op stubs corresponding to OpenSSL's many initialization functions.
If some parameter now must be `NULL`, change the type to an opaque struct pointer. Consumers passing non-`NULL` pointers will then fail to compile.
If breaking the compile is not feasible, break at runtime, in the hope that consumers have some amount of test coverage. When doing so, try to fail on the common case. In particular, do not rely on consumers adequately testing or even checking for failure cases. One strategy is to bring the object into a &ldquo;poison&rdquo; state: if an illegal operation occurs, set a flag to fail all subsequent ones.
In other functions, it may be appropriate to simply call `abort()`.
## Unexpected breakage
While we try to avoid breaking things, sometimes things unexpectedly break. Depending on the impact, we may fix the consumer, make a small fix to BoringSSL, or revert the change to either try again later or revise the approach.
If we do not ultimately fix the consumer, add a test in BoringSSL to capture the unexpected API contract, so future regressions are caught quickly.
## Canary changes and bake time
When planning a large project that depends on a breaking change, prefer to make the breaking change first&mdash;before committing larger changes. Or, when changing toolchain or language requirements, add a small instance of the dependency somewhere first then wait a couple of weeks for the change to appear in consumers. This ensures that reverting the change is still feasible if necessary.
While we rely on a tight feedback loop with our consumers, there are a few consumers which update less frequently. For extremely risky changes, such as introducing C++ to a target, it may be prudent to wait much longer.
## Third-party code
In many cases, we are interested in changing behavior which came from OpenSSL. OpenSSL's API surface is huge, but only a small subset is actually used. So we can and occasionally do change these behaviors. This is more complex than changing BoringSSL-only behavior due to third-party code.
We use BoringSSL with many third-party projects that normally use OpenSSL. Generally, we consider this our burden to make this work and do not encourage external projects to depend on BoringSSL. While we can and do maintain patches for this as necessary, it has overhead and so the cost of breaking third-party code is higher.
We lean fairly strongly towards making changes to BoringSSL over patching third-party code, unless the third-party change fixes a security problem.
Additionally, changing an OpenSSL API will not only affect third-party code we use today, but also any third-party code we use in the future. Thus Code Search is less useful as an absolute predictor, and the various other considerations in this document are more important.
If the patch to support a BoringSSL change can be generally useful to the third-party project, send it upstream. For instance, it may use the APIs better, clean up code, or help support newer versions of OpenSSL. In general, we try to target compatibility with &ldquo;most&rdquo; &ldquo;well-behaved&rdquo; OpenSSL consumers.
Finally, if some particular OpenSSL API or pattern is problematic to BoringSSL, it is likely problematic to OpenSSL too. Consider filing a bug with them to suggest a change, either in new code going forward or for the next API break. OpenSSL's release cycles and feedback loops are much longer than BoringSSL's, so this is usually not immediately useful, but it keeps the ecosystem moving in the right direction.
+77 -32
View File
@@ -2,9 +2,17 @@
## Build Prerequisites
* [CMake](https://cmake.org/download/) 2.8.11 or later is required.
The standalone CMake build is primarily intended for developers. If embedding
BoringSSL into another project with a pre-existing build system, see
[INCORPORATING.md](/INCORPORATING.md).
* Perl 5.6.1 or later is required. On Windows,
Unless otherwise noted, build tools must at most five years old, matching
[Abseil guidelines](https://abseil.io/about/compatibility). If in doubt, use the
most recent stable version of each tool.
* [CMake](https://cmake.org/download/) 3.0 or later is required.
* A recent version of Perl is required. On Windows,
[Active State Perl](http://www.activestate.com/activeperl/) has been
reported to work, as has MSYS Perl.
[Strawberry Perl](http://strawberryperl.com/) also works but it adds GCC
@@ -13,27 +21,27 @@
If Perl is not found by CMake, it may be configured explicitly by setting
`PERL_EXECUTABLE`.
* On Windows you currently must use [Ninja](https://ninja-build.org/)
to build; on other platforms, it is not required, but recommended, because
it makes builds faster.
* Building with [Ninja](https://ninja-build.org/) instead of Make is
recommended, because it makes builds faster. On Windows, CMake's Visual
Studio generator may also work, but it not tested regularly and requires
recent versions of CMake for assembly support.
* If you need to build Ninja from source, then a recent version of
[Python](https://www.python.org/downloads/) is required (Python 2.7.5 works).
* On Windows only, [Yasm](http://yasm.tortall.net/) is required. If not found
* On Windows only, [NASM](https://www.nasm.us/) is required. If not found
by CMake, it may be configured explicitly by setting
`CMAKE_ASM_NASM_COMPILER`.
* A C compiler is required. On Windows, MSVC 14 (Visual Studio 2015) or later
with Platform SDK 8.1 or later are supported. Recent versions of GCC (4.8+)
and Clang should work on non-Windows platforms, and maybe on Windows too.
To build the tests, you also need a C++ compiler with C++11 support.
* C and C++ compilers with C++11 support are required. On Windows, MSVC 14
(Visual Studio 2015) or later with Platform SDK 8.1 or later are supported.
Recent versions of GCC (4.8+) and Clang should work on non-Windows
platforms, and maybe on Windows too.
* [Go](https://golang.org/dl/) is required. If not found by CMake, the go
executable may be configured explicitly by setting `GO_EXECUTABLE`.
* The most recent stable version of [Go](https://golang.org/dl/) is required.
Note Go is exempt from the five year support window. If not found by CMake,
the go executable may be configured explicitly by setting `GO_EXECUTABLE`.
* To build the x86 and x86\_64 assembly, your assembler must support AVX2
instructions and MOVBE. If using GNU binutils, you must have 2.22 or later
* On x86_64 Linux, the tests have an optional
[libunwind](https://www.nongnu.org/libunwind/) dependency to test the
assembly more thoroughly.
## Building
@@ -79,14 +87,15 @@ for other variables which may be used to configure the build.
### Building for Android
It's possible to build BoringSSL with the Android NDK using CMake. This has
been tested with version 10d of the NDK.
It's possible to build BoringSSL with the Android NDK using CMake. Recent
versions of the NDK include a CMake toolchain file which works with CMake 3.6.0
or later. This has been tested with version r16b of the NDK.
Unpack the Android NDK somewhere and export `ANDROID_NDK` to point to the
directory. Then make a build directory as above and run CMake like this:
cmake -DANDROID_ABI=armeabi-v7a \
-DCMAKE_TOOLCHAIN_FILE=../third_party/android-cmake/android.toolchain.cmake \
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake \
-DANDROID_NATIVE_API_LEVEL=16 \
-GNinja ..
@@ -94,7 +103,22 @@ Once you've run that, Ninja should produce Android-compatible binaries. You
can replace `armeabi-v7a` in the above with `arm64-v8a` and use API level 21 or
higher to build aarch64 binaries.
For other options, see [android-cmake's documentation](./third_party/android-cmake/README.md).
For other options, see the documentation in the toolchain file.
To debug the resulting binaries on an Android device with `gdb`, run the
commands below. Replace `ARCH` with the architecture of the target device, e.g.
`arm` or `arm64`.
adb push ${ANDROID_NDK}/prebuilt/android-ARCH/gdbserver/gdbserver \
/data/local/tmp
adb forward tcp:5039 tcp:5039
adb shell /data/local/tmp/gdbserver :5039 /path/on/device/to/binary
Then run the following in a separate shell. Replace `HOST` with the OS and
architecture of the host machine, e.g. `linux-x86_64`.
${ANDROID_NDK}/prebuilt/HOST/bin/gdb
target remote :5039 # in gdb
### Building for iOS
@@ -105,6 +129,32 @@ architecture, matching values used in the `-arch` flag in Apple's toolchain.
Passing multiple architectures for a multiple-architecture build is not
supported.
### Building with Prefixed Symbols
BoringSSL's build system has experimental support for adding a custom prefix to
all symbols. This can be useful when linking multiple versions of BoringSSL in
the same project to avoid symbol conflicts.
In order to build with prefixed symbols, the `BORINGSSL_PREFIX` CMake variable
should specify the prefix to add to all symbols, and the
`BORINGSSL_PREFIX_SYMBOLS` CMake variable should specify the path to a file
which contains a list of symbols which should be prefixed (one per line;
comments are supported with `#`). In other words, `cmake ..
-DBORINGSSL_PREFIX=MY_CUSTOM_PREFIX
-DBORINGSSL_PREFIX_SYMBOLS=/path/to/symbols.txt` will configure the build to add
the prefix `MY_CUSTOM_PREFIX` to all of the symbols listed in
`/path/to/symbols.txt`.
It is currently the caller's responsibility to create and maintain the list of
symbols to be prefixed. Alternatively, `util/read_symbols.go` reads the list of
exported symbols from a `.a` file, and can be used in a build script to generate
the symbol list on the fly (by building without prefixing, using
`read_symbols.go` to construct a symbol list, and then building again with
prefixing).
This mechanism is under development and may change over time. Please contact the
BoringSSL maintainers if making use of it.
## Known Limitations on Windows
* Versions of CMake since 3.0.2 have a bug in its Ninja generator that causes
@@ -145,19 +195,14 @@ corresponding ARM feature.
Note that if a feature is enabled in this way, but not actually supported at
run-time, BoringSSL will likely crash.
## Assembling ARMv8 with Clang
## Binary Size
In order to support the ARMv8 crypto instructions, Clang requires that the
architecture be `armv8-a+crypto`. However, setting that as a general build flag
would allow the compiler to assume that crypto instructions are *always*
supported, even without testing for them.
The implementations of some algorithms require a trade-off between binary size
and performance. For instance, BoringSSL's fastest P-256 implementation uses a
148 KiB pre-computed table. To optimize instead for binary size, pass
`-DOPENSSL_SMALL=1` to CMake or define the `OPENSSL_SMALL` preprocessor symbol.
It's possible to set the architecture in an assembly file using the `.arch`
directive, but only very recent versions of Clang support this. If
`BORINGSSL_CLANG_SUPPORTS_DOT_ARCH` is defined then `.arch` directives will be
used with Clang, otherwise you may need to craft acceptable assembler flags.
# Running tests
# Running Tests
There are two sets of tests: the C/C++ tests and the blackbox tests. For former
are built by Ninja and can be run from the top-level directory with `go run
+356 -71
View File
@@ -1,7 +1,7 @@
cmake_minimum_required (VERSION 2.8.11)
cmake_minimum_required(VERSION 3.3)
# Defer enabling C and CXX languages.
project (BoringSSL NONE)
project(BoringSSL NONE)
if(WIN32)
# On Windows, prefer cl over gcc if both are available. By default most of
@@ -14,6 +14,11 @@ include(sources.cmake)
enable_language(C)
enable_language(CXX)
# This is a dummy target which all other targets depend on (manually - see other
# CMakeLists.txt files). This gives us a hook to add any targets which need to
# run before all other targets.
add_custom_target(global_target)
if(ANDROID)
# Android-NDK CMake files reconfigure the path and so Go and Perl won't be
# found. However, ninja will still find them in $PATH if we just name them.
@@ -28,28 +33,133 @@ else()
find_program(GO_EXECUTABLE go)
endif()
if (NOT GO_EXECUTABLE)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT CMAKE_CROSSCOMPILING)
find_package(PkgConfig QUIET)
if (PkgConfig_FOUND)
pkg_check_modules(LIBUNWIND libunwind-generic)
if(LIBUNWIND_FOUND)
add_definitions(-DBORINGSSL_HAVE_LIBUNWIND)
else()
message("libunwind not found. Disabling unwind tests.")
endif()
else()
message("pkgconfig not found. Disabling unwind tests.")
endif()
endif()
if(NOT GO_EXECUTABLE)
message(FATAL_ERROR "Could not find Go")
endif()
if (BORINGSSL_ALLOW_CXX_RUNTIME)
if(USE_CUSTOM_LIBCXX)
set(BORINGSSL_ALLOW_CXX_RUNTIME 1)
endif()
if(BORINGSSL_ALLOW_CXX_RUNTIME)
add_definitions(-DBORINGSSL_ALLOW_CXX_RUNTIME)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(C_CXX_FLAGS "-Wall -Werror -Wformat=2 -Wsign-compare -Wmissing-field-initializers -Wwrite-strings -ggdb -fvisibility=hidden -fno-common")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER)
if(NOT FIPS)
if(CMAKE_BUILD_TYPE_LOWER STREQUAL "relwithassert" OR
NOT CMAKE_BUILD_TYPE_LOWER MATCHES "rel")
add_definitions(-DBORINGSSL_DISPATCH_TEST)
# CMake automatically connects include_directories to the NASM
# command-line, but not add_definitions.
set(CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} -DBORINGSSL_DISPATCH_TEST")
endif()
endif()
# Add a RelWithAsserts build configuration. It is the same as Release, except it
# does not define NDEBUG, so asserts run.
foreach(VAR CMAKE_C_FLAGS CMAKE_CXX_FLAGS CMAKE_ASM_FLAGS)
string(REGEX REPLACE "(^| )[/-]DNDEBUG( |$)" " " "${VAR}_RELWITHASSERTS"
"${${VAR}_RELEASE}")
endforeach()
if(BORINGSSL_PREFIX AND BORINGSSL_PREFIX_SYMBOLS)
add_definitions(-DBORINGSSL_PREFIX=${BORINGSSL_PREFIX})
# CMake automatically connects include_directories to the NASM command-line,
# but not add_definitions.
set(CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} -DBORINGSSL_PREFIX=${BORINGSSL_PREFIX}")
# Use "symbol_prefix_include" to store generated header files
include_directories(${CMAKE_CURRENT_BINARY_DIR}/symbol_prefix_include)
add_custom_command(
OUTPUT symbol_prefix_include/boringssl_prefix_symbols.h
symbol_prefix_include/boringssl_prefix_symbols_asm.h
symbol_prefix_include/boringssl_prefix_symbols_nasm.inc
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/symbol_prefix_include
COMMAND ${GO_EXECUTABLE} run ${CMAKE_CURRENT_SOURCE_DIR}/util/make_prefix_headers.go -out ${CMAKE_CURRENT_BINARY_DIR}/symbol_prefix_include ${BORINGSSL_PREFIX_SYMBOLS}
DEPENDS util/make_prefix_headers.go
${CMAKE_BINARY_DIR}/${BORINGSSL_PREFIX_SYMBOLS})
# add_dependencies needs a target, not a file, so we add an intermediate
# target.
add_custom_target(
boringssl_prefix_symbols
DEPENDS symbol_prefix_include/boringssl_prefix_symbols.h
symbol_prefix_include/boringssl_prefix_symbols_asm.h
symbol_prefix_include/boringssl_prefix_symbols_nasm.inc)
add_dependencies(global_target boringssl_prefix_symbols)
elseif(BORINGSSL_PREFIX OR BORINGSSL_PREFIX_SYMBOLS)
message(FATAL_ERROR "Must specify both or neither of BORINGSSL_PREFIX and BORINGSSL_PREFIX_SYMBOLS")
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CLANG 1)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
set(EMSCRIPTEN 1)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CLANG)
# Note clang-cl is odd and sets both CLANG and MSVC. We base our configuration
# primarily on our normal Clang one.
set(C_CXX_FLAGS "-Werror -Wformat=2 -Wsign-compare -Wmissing-field-initializers -Wwrite-strings -Wvla")
if(MSVC)
# clang-cl sets different default warnings than clang. It also treats -Wall
# as -Weverything, to match MSVC. Instead -W3 is the alias for -Wall.
# See http://llvm.org/viewvc/llvm-project?view=revision&revision=319116
set(C_CXX_FLAGS "${C_CXX_FLAGS} -W3 -Wno-unused-parameter -fmsc-version=1900")
# googletest suppresses warning C4996 via a pragma, but clang-cl does not
# honor it. Suppress it here to compensate. See https://crbug.com/772117.
set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wno-deprecated-declarations")
else()
if(EMSCRIPTEN)
# emscripten's emcc/clang does not accept the "-ggdb" flag.
set(C_CXX_FLAGS "${C_CXX_FLAGS} -g")
else()
set(C_CXX_FLAGS "${C_CXX_FLAGS} -ggdb")
endif()
set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wall -fvisibility=hidden -fno-common")
endif()
if(CLANG)
set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wnewline-eof -fcolor-diagnostics")
else()
# GCC (at least 4.8.4) has a bug where it'll find unreachable free() calls
# and declare that the code is trying to free a stack pointer.
set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wno-free-nonheap-object")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_CXX_FLAGS} -Wmissing-prototypes -Wold-style-definition -Wstrict-prototypes")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ${C_CXX_FLAGS} -Wmissing-declarations")
if(NOT BORINGSSL_ALLOW_CXX_RUNTIME)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti")
if(CLANG OR NOT "7.0.0" VERSION_GREATER CMAKE_C_COMPILER_VERSION)
set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wimplicit-fallthrough")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_CXX_FLAGS} -Wmissing-prototypes -Wold-style-definition -Wstrict-prototypes")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${C_CXX_FLAGS} -Wmissing-declarations")
if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
if(NOT BORINGSSL_ALLOW_CXX_RUNTIME)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti")
endif()
endif()
# In GCC, -Wmissing-declarations is the C++ spelling of -Wmissing-prototypes
@@ -59,9 +169,14 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# https://gcc.gnu.org/onlinedocs/gcc-7.1.0/gcc/Warning-Options.html#Warning-Options
# https://clang.llvm.org/docs/DiagnosticsReference.html#wmissing-prototypes
# https://clang.llvm.org/docs/DiagnosticsReference.html#wmissing-declarations
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wmissing-prototypes -Wimplicit-fallthrough")
if(CLANG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wmissing-prototypes")
endif()
if(CMAKE_COMPILER_IS_GNUCXX AND "4.8" VERSION_GREATER CMAKE_C_COMPILER_VERSION)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-array-bounds")
endif()
elseif(MSVC)
set(MSVC_DISABLED_WARNINGS_LIST
"C4061" # enumerator 'identifier' in switch of enum 'enumeration' is not
@@ -78,8 +193,6 @@ elseif(MSVC)
# possible loss of data
"C4244" # 'function' : conversion from 'int' to 'uint8_t',
# possible loss of data
"C4245" # 'initializing' : conversion from 'long' to
# 'unsigned long', signed/unsigned mismatch
"C4267" # conversion from 'size_t' to 'int', possible loss of data
"C4371" # layout of class may have changed from a previous version of the
# compiler due to better packing of member '...'
@@ -102,6 +215,7 @@ elseif(MSVC)
# copy constructor is inaccessible or deleted
"C4626" # assignment operator could not be generated because a base class
# assignment operator is inaccessible or deleted
"C4628" # digraphs not supported with -Ze
"C4668" # 'symbol' is not defined as a preprocessor macro, replacing with
# '0' for 'directives'
# Disable this because GTest uses it everywhere.
@@ -113,6 +227,8 @@ elseif(MSVC)
"C4820" # 'bytes' bytes padding added after construct 'member_name'
"C5026" # move constructor was implicitly defined as deleted
"C5027" # move assignment operator was implicitly defined as deleted
"C5045" # Compiler will insert Spectre mitigation for memory load if
# /Qspectre switch specified
)
set(MSVC_LEVEL4_WARNINGS_LIST
# See https://connect.microsoft.com/VisualStudio/feedback/details/1217660/warning-c4265-when-using-functional-header
@@ -122,9 +238,8 @@ elseif(MSVC)
${MSVC_DISABLED_WARNINGS_LIST})
string(REPLACE "C" " -w4" MSVC_LEVEL4_WARNINGS_STR
${MSVC_LEVEL4_WARNINGS_LIST})
set(CMAKE_C_FLAGS "-Wall -WX ${MSVC_DISABLED_WARNINGS_STR} ${MSVC_LEVEL4_WARNINGS_STR}")
set(CMAKE_CXX_FLAGS "-Wall -WX ${MSVC_DISABLED_WARNINGS_STR} ${MSVC_LEVEL4_WARNINGS_STR}")
set(CMAKE_ASM_NASM_FLAGS "-g cv8")
set(CMAKE_C_FLAGS "-utf-8 -Wall -WX ${MSVC_DISABLED_WARNINGS_STR} ${MSVC_LEVEL4_WARNINGS_STR}")
set(CMAKE_CXX_FLAGS "-utf-8 -Wall -WX ${MSVC_DISABLED_WARNINGS_STR} ${MSVC_LEVEL4_WARNINGS_STR}")
endif()
if(WIN32)
@@ -134,18 +249,19 @@ if(WIN32)
# Allow use of fopen.
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
# VS 2017 and higher supports STL-only warning suppressions.
# A bug in CMake < 3.13.0 may cause the space in this value to
# cause issues when building with NASM. In that case, update CMake.
add_definitions("-D_STL_EXTRA_DISABLED_WARNINGS=4774 4987")
endif()
if((CMAKE_COMPILER_IS_GNUCXX AND CMAKE_C_COMPILER_VERSION VERSION_GREATER "4.7.99") OR
CMAKE_CXX_COMPILER_ID MATCHES "Clang")
CLANG)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshadow")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow")
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
if ((CMAKE_C_COMPILER_VERSION VERSION_GREATER "4.8.99") OR
CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if((CMAKE_C_COMPILER_VERSION VERSION_GREATER "4.8.99") OR CLANG)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
@@ -158,10 +274,14 @@ if(NOT WIN32)
endif()
if(FUZZ)
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(NOT CLANG)
message(FATAL_ERROR "You need to build with Clang for fuzzing to work")
endif()
if(CMAKE_C_COMPILER_VERSION VERSION_LESS "6.0.0")
message(FATAL_ERROR "You need Clang ≥ 6.0.0")
endif()
add_definitions(-DBORINGSSL_UNSAFE_DETERMINISTIC_MODE)
set(RUNNER_ARGS "-deterministic")
@@ -170,46 +290,86 @@ if(FUZZ)
set(RUNNER_ARGS ${RUNNER_ARGS} "-fuzzer" "-shim-config" "fuzzer_mode.json")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize-coverage=edge,indirect-calls,trace-pc-guard")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize-coverage=edge,indirect-calls,trace-pc-guard")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
link_directories(.)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address,fuzzer-no-link -fsanitize-coverage=edge,indirect-calls")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address,fuzzer-no-link -fsanitize-coverage=edge,indirect-calls")
endif()
add_definitions(-DBORINGSSL_IMPLEMENTATION)
if (BUILD_SHARED_LIBS)
if(BUILD_SHARED_LIBS)
add_definitions(-DBORINGSSL_SHARED_LIBRARY)
# Enable position-independent code globally. This is needed because
# some library targets are OBJECT libraries.
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
endif()
if (MSAN)
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(MSAN)
if(NOT CLANG)
message(FATAL_ERROR "Cannot enable MSAN unless using Clang")
endif()
if (ASAN)
if(ASAN)
message(FATAL_ERROR "ASAN and MSAN are mutually exclusive")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer")
set(OPENSSL_NO_ASM "1")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer")
endif()
if (ASAN)
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(ASAN)
if(NOT CLANG)
message(FATAL_ERROR "Cannot enable ASAN unless using Clang")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer")
endif()
if(CFI)
if(NOT CLANG)
message(FATAL_ERROR "Cannot enable CFI unless using Clang")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=cfi -fno-sanitize-trap=cfi -flto=thin")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=cfi -fno-sanitize-trap=cfi -flto=thin")
# We use Chromium's copy of clang, which requires -fuse-ld=lld if building
# with -flto. That, in turn, can't handle -ggdb.
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=lld")
string(REPLACE "-ggdb" "-g" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
string(REPLACE "-ggdb" "-g" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
# -flto causes object files to contain LLVM bitcode. Mixing those with
# assembly output in the same static library breaks the linker.
set(OPENSSL_NO_ASM "1")
endif()
if (GCOV)
if(TSAN)
if(NOT CLANG)
message(FATAL_ERROR "Cannot enable TSAN unless using Clang")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread")
endif()
if(UBSAN)
if(NOT CLANG)
message(FATAL_ERROR "Cannot enable UBSAN unless using Clang")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined")
if(NOT UBSAN_RECOVER)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-sanitize-recover=undefined")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-sanitize-recover=undefined")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-sanitize-recover=undefined")
endif()
endif()
if(GCOV)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
endif()
@@ -219,79 +379,193 @@ if(FIPS)
if(FIPS_BREAK_TEST)
add_definitions("-DBORINGSSL_FIPS_BREAK_${FIPS_BREAK_TEST}=1")
endif()
# Delocate does not work for ASan and MSan builds.
# The FIPS integrity check does not work for ASan and MSan builds.
if(NOT ASAN AND NOT MSAN)
set(FIPS_DELOCATE "1")
if(BUILD_SHARED_LIBS)
set(FIPS_SHARED "1")
else()
set(FIPS_DELOCATE "1")
endif()
endif()
if(FIPS_SHARED)
# The Android CMake files set -ffunction-sections and -fdata-sections,
# which is incompatible with FIPS_SHARED.
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} -fno-function-sections -fno-data-sections")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -fno-function-sections -fno-data-sections")
endif()
endif()
if(OPENSSL_SMALL)
add_definitions(-DOPENSSL_SMALL)
endif()
if(CONSTANT_TIME_VALIDATION)
add_definitions(-DBORINGSSL_CONSTANT_TIME_VALIDATION)
# Asserts will often test secret data.
add_definitions(-DNDEBUG)
endif()
function(go_executable dest package)
set(godeps "${CMAKE_SOURCE_DIR}/util/godeps.go")
if(${CMAKE_VERSION} VERSION_LESS "3.7" OR
NOT ${CMAKE_GENERATOR} STREQUAL "Ninja")
# The DEPFILE parameter to add_custom_command is new as of CMake 3.7 and
# only works with Ninja. Query the sources at configure time. Additionally,
# everything depends on go.mod. That affects what external packages to use.
execute_process(COMMAND ${GO_EXECUTABLE} run ${godeps} -format cmake
-pkg ${package}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE sources
RESULT_VARIABLE godeps_result)
add_custom_command(OUTPUT ${dest}
COMMAND ${GO_EXECUTABLE} build
-o ${CMAKE_CURRENT_BINARY_DIR}/${dest} ${package}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${sources} ${CMAKE_SOURCE_DIR}/go.mod)
else()
# Ninja expects the target in the depfile to match the output. This is a
# relative path from the build directory.
string(LENGTH "${CMAKE_BINARY_DIR}" root_dir_length)
math(EXPR root_dir_length "${root_dir_length} + 1")
string(SUBSTRING "${CMAKE_CURRENT_BINARY_DIR}" ${root_dir_length} -1 target)
set(target "${target}/${dest}")
set(depfile "${CMAKE_CURRENT_BINARY_DIR}/${dest}.d")
add_custom_command(OUTPUT ${dest}
COMMAND ${GO_EXECUTABLE} build
-o ${CMAKE_CURRENT_BINARY_DIR}/${dest} ${package}
COMMAND ${GO_EXECUTABLE} run ${godeps} -format depfile
-target ${target} -pkg ${package} -out ${depfile}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${godeps} ${CMAKE_SOURCE_DIR}/go.mod
DEPFILE ${depfile})
endif()
endfunction()
# CMake's iOS support uses Apple's multiple-architecture toolchain. It takes an
# architecture list from CMAKE_OSX_ARCHITECTURES, leaves CMAKE_SYSTEM_PROCESSOR
# alone, and expects all architecture-specific logic to be conditioned within
# the source files rather than the build. This does not work for our assembly
# files, so we fix CMAKE_SYSTEM_PROCESSOR and only support single-architecture
# builds.
if (NOT OPENSSL_NO_ASM AND CMAKE_OSX_ARCHITECTURES)
if(NOT OPENSSL_NO_ASM AND CMAKE_OSX_ARCHITECTURES)
list(LENGTH CMAKE_OSX_ARCHITECTURES NUM_ARCHES)
if (NOT ${NUM_ARCHES} EQUAL 1)
if(NOT ${NUM_ARCHES} EQUAL 1)
message(FATAL_ERROR "Universal binaries not supported.")
endif()
list(GET CMAKE_OSX_ARCHITECTURES 0 CMAKE_SYSTEM_PROCESSOR)
endif()
if (OPENSSL_NO_ASM)
if(OPENSSL_NO_SSE2_FOR_TESTING)
add_definitions(-DOPENSSL_NO_SSE2_FOR_TESTING)
endif()
if(OPENSSL_NO_ASM)
add_definitions(-DOPENSSL_NO_ASM)
set(ARCH "generic")
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set(ARCH "x86_64")
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "amd64")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "amd64")
set(ARCH "x86_64")
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64")
# cmake reports AMD64 on Windows, but we might be building for 32-bit.
if (CMAKE_CL_64)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(ARCH "x86_64")
else()
set(ARCH "x86")
endif()
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86")
set(ARCH "x86")
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i386")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i386")
set(ARCH "x86")
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")
set(ARCH "x86")
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
set(ARCH "aarch64")
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64")
set(ARCH "aarch64")
elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^arm*")
# Apple A12 Bionic chipset which is added in iPhone XS/XS Max/XR uses arm64e architecture.
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64e")
set(ARCH "aarch64")
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^arm*")
set(ARCH "arm")
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "mips")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "mips")
# Just to avoid the “unknown processor” error.
set(ARCH "generic")
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "ppc64le")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "ppc64le")
set(ARCH "ppc64le")
else()
message(FATAL_ERROR "Unknown processor:" ${CMAKE_SYSTEM_PROCESSOR})
endif()
if (ANDROID AND ${ARCH} STREQUAL "arm")
# The Android-NDK CMake files somehow fail to set the -march flag for
# assembly files. Without this flag, the compiler believes that it's
if(ANDROID AND NOT ANDROID_NDK_REVISION AND ${ARCH} STREQUAL "arm")
# The third-party Android-NDK CMake files somehow fail to set the -march flag
# for assembly files. Without this flag, the compiler believes that it's
# building for ARMv5.
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -march=${CMAKE_SYSTEM_PROCESSOR}")
set(CMAKE_ASM_FLAGS "-march=${CMAKE_SYSTEM_PROCESSOR} ${CMAKE_ASM_FLAGS}")
endif()
if (${ARCH} STREQUAL "x86" AND APPLE)
# With CMake 2.8.x, ${CMAKE_SYSTEM_PROCESSOR} evalutes to i386 on OS X,
# but clang defaults to 64-bit builds on OS X unless otherwise told.
# Set ARCH to x86_64 so clang and CMake agree. This is fixed in CMake 3.
set(ARCH "x86_64")
if(USE_CUSTOM_LIBCXX)
if(NOT CLANG)
message(FATAL_ERROR "USE_CUSTOM_LIBCXX only supported with Clang")
endif()
# CMAKE_CXX_FLAGS ends up in the linker flags as well, so use
# add_compile_options. There does not appear to be a way to set
# language-specific compile-only flags.
add_compile_options("-nostdinc++")
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -nostdlib++")
include_directories(
SYSTEM
util/bot/libcxx/include
util/bot/libcxxabi/include
)
# This is patterned after buildtools/third_party/libc++/BUILD.gn and
# buildtools/third_party/libc++abi/BUILD.gn in Chromium.
file(GLOB LIBCXX_SOURCES "util/bot/libcxx/src/*.cpp")
file(GLOB LIBCXXABI_SOURCES "util/bot/libcxxabi/src/*.cpp")
# This file is meant for exception-less builds.
list(REMOVE_ITEM LIBCXXABI_SOURCES "trunk/src/cxa_noexception.cpp")
# libc++ also defines new and delete.
list(REMOVE_ITEM LIBCXXABI_SOURCES "trunk/src/stdlib_new_delete.cpp")
if(TSAN)
# ThreadSanitizer tries to intercept these symbols. Skip them to avoid
# symbol conflicts.
list(REMOVE_ITEM LIBCXXABI_SOURCES "trunk/src/cxa_guard.cpp")
endif()
add_library(libcxxabi ${LIBCXXABI_SOURCES})
target_compile_definitions(
libcxxabi PRIVATE
-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
)
set_target_properties(libcxxabi PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes -Wno-implicit-fallthrough")
add_library(libcxx ${LIBCXX_SOURCES})
if(ASAN OR MSAN OR TSAN)
# Sanitizers try to intercept new and delete.
target_compile_definitions(
libcxx PRIVATE
-D_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS
)
endif()
target_compile_definitions(
libcxx PRIVATE
-D_LIBCPP_BUILDING_LIBRARY
-DLIBCXX_BUILDING_LIBCXXABI
)
target_link_libraries(libcxx libcxxabi)
endif()
# Add minimal googletest targets. The provided one has many side-effects, and
# googletest has a very straightforward build.
add_library(gtest third_party/googletest/src/gtest-all.cc)
target_include_directories(gtest PRIVATE third_party/googletest)
add_library(boringssl_gtest third_party/googletest/src/gtest-all.cc)
target_include_directories(boringssl_gtest PRIVATE third_party/googletest)
include_directories(third_party/googletest/include)
@@ -299,10 +573,21 @@ include_directories(third_party/googletest/include)
# themselves as dependencies next to the target definition.
add_custom_target(all_tests)
# On Windows, CRYPTO_TEST_DATA is too long to fit in command-line limits.
# TODO(davidben): CMake 3.12 has a list(JOIN) command. Use that when we've
# updated the minimum version.
set(EMBED_TEST_DATA_ARGS "")
foreach(arg ${CRYPTO_TEST_DATA})
set(EMBED_TEST_DATA_ARGS "${EMBED_TEST_DATA_ARGS}${arg}\n")
endforeach()
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/embed_test_data_args.txt"
"${EMBED_TEST_DATA_ARGS}")
add_custom_command(
OUTPUT crypto_test_data.cc
COMMAND ${GO_EXECUTABLE} run util/embed_test_data.go ${CRYPTO_TEST_DATA} >
${CMAKE_CURRENT_BINARY_DIR}/crypto_test_data.cc
COMMAND ${GO_EXECUTABLE} run util/embed_test_data.go -file-list
"${CMAKE_CURRENT_BINARY_DIR}/embed_test_data_args.txt" >
"${CMAKE_CURRENT_BINARY_DIR}/crypto_test_data.cc"
DEPENDS util/embed_test_data.go ${CRYPTO_TEST_DATA}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
@@ -311,8 +596,9 @@ add_library(crypto_test_data OBJECT crypto_test_data.cc)
add_subdirectory(crypto)
add_subdirectory(ssl)
add_subdirectory(ssl/test)
add_subdirectory(fipstools)
add_subdirectory(tool)
add_subdirectory(util/fipstools/cavp)
add_subdirectory(util/fipstools/acvp/modulewrapper)
add_subdirectory(decrepit)
if(FUZZ)
@@ -327,9 +613,8 @@ if(FUZZ)
add_subdirectory(fuzz)
endif()
if (NOT ${CMAKE_VERSION} VERSION_LESS "3.2")
# USES_TERMINAL is only available in CMake 3.2 or later.
set(MAYBE_USES_TERMINAL USES_TERMINAL)
if(UNIX AND NOT APPLE AND NOT ANDROID)
set(HANDSHAKER_ARGS "-handshaker-path" $<TARGET_FILE:handshaker>)
endif()
add_custom_target(
@@ -338,7 +623,7 @@ add_custom_target(
${CMAKE_BINARY_DIR}
COMMAND cd ssl/test/runner &&
${GO_EXECUTABLE} test -shim-path $<TARGET_FILE:bssl_shim>
${RUNNER_ARGS}
${HANDSHAKER_ARGS} ${RUNNER_ARGS}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
DEPENDS all_tests bssl_shim
${MAYBE_USES_TERMINAL})
DEPENDS all_tests bssl_shim handshaker
USES_TERMINAL)
+7 -11
View File
@@ -2,23 +2,17 @@
Modern fuzz testers are very effective and we wish to use them to ensure that no silly bugs creep into BoringSSL.
We primarily use Clang's [libFuzzer](http://llvm.org/docs/LibFuzzer.html) for fuzz testing and there are a number of fuzz testing functions in `fuzz/`. They are not built by default because they require libFuzzer at build time.
We use Clang's [libFuzzer](http://llvm.org/docs/LibFuzzer.html) for fuzz testing and there are a number of fuzz testing functions in `fuzz/`. They are not built by default because they require that the rest of BoringSSL be built with some changes that make fuzzing much more effective, but are completely unsafe for real use.
In order to build the fuzz tests you will need at least Clang 3.7. Pass `-DFUZZ=1` on the CMake command line to enable building BoringSSL with coverage and AddressSanitizer, and to build the fuzz test binaries. You'll probably need to set the `CC` and `CXX` environment variables too, like this:
In order to build the fuzz tests you will need at least Clang 6.0. Pass `-DFUZZ=1` on the CMake command line to enable building BoringSSL with coverage and AddressSanitizer, and to build the fuzz test binaries. You'll probably need to set the `CC` and `CXX` environment variables too, like this:
```
mkdir build
cd build
CC=clang CXX=clang++ cmake -GNinja -DFUZZ=1 ..
ninja
```
In order for the fuzz tests to link, the linker needs to find libFuzzer. This is not commonly provided and you may need to download the [Clang source code](http://llvm.org/releases/download.html) and do the following:
```
svn co http://llvm.org/svn/llvm-project/llvm/trunk/lib/Fuzzer
clang++ -c -g -O2 -std=c++11 Fuzzer/*.cpp -IFuzzer
ar ruv libFuzzer.a Fuzzer*.o
```
Then copy `libFuzzer.a` to the top-level of your BoringSSL source directory.
From the `build/` directory, you can then run the fuzzers. For example:
@@ -32,6 +26,8 @@ The recommended values of `max_len` for each test are:
| Test | `max_len` value |
|---------------|-----------------|
| `bn_div` | 384 |
| `bn_mod_exp` | 4096 |
| `cert` | 10000 |
| `client` | 20000 |
| `pkcs8` | 2048 |
+1 -1
View File
@@ -37,7 +37,7 @@ updating things more complex.
BoringSSL is designed to work with many different build systems. Currently,
different projects use [GYP](https://gyp.gsrc.io/),
[GN](https://chromium.googlesource.com/chromium/src/+/master/tools/gn/docs/quick_start.md),
[GN](https://gn.googlesource.com/gn/+/master/docs/quick_start.md),
[Bazel](https://bazel.build/) and [Make](https://www.gnu.org/software/make/) to
build BoringSSL, without too much pain.
+94 -35
View File
@@ -5,8 +5,9 @@ license. This license is reproduced at the bottom of this file.
Contributors to BoringSSL are required to follow the CLA rules for Chromium:
https://cla.developers.google.com/clas
Some files from Intel are under yet another license, which is also included
underneath.
Files in third_party/ have their own licenses, as described therein. The MIT
license, for third_party/fiat, which, unlike other third_party directories, is
compiled into non-test libraries, is included below.
The OpenSSL toolkit stays under a dual license, i.e. both the conditions of the
OpenSSL License and the original SSLeay license apply to the toolkit. See below
@@ -156,37 +157,95 @@ ISC license used for completely new code in BoringSSL:
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
Some files from Intel carry the following license:
The code in third_party/fiat carries the MIT license:
# Copyright (c) 2012, Intel Corporation
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the
# distribution.
#
# * Neither the name of the Intel Corporation nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
#
# THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION ""AS IS"" AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Copyright (c) 2015-2016 the fiat-crypto authors (see
https://github.com/mit-plv/fiat-crypto/blob/master/AUTHORS).
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Licenses for support code
-------------------------
Parts of the TLS test suite are under the Go license. This code is not included
in BoringSSL (i.e. libcrypto and libssl) when compiled, however, so
distributing code linked against BoringSSL does not trigger this license:
Copyright (c) 2009 The Go Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
BoringSSL uses the Chromium test infrastructure to run a continuous build,
trybots etc. The scripts which manage this, and the script for generating build
metadata, are under the Chromium license. Distributing code linked against
BoringSSL does not trigger this license.
Copyright 2015 The Chromium Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+43 -18
View File
@@ -6,17 +6,27 @@ BoringSSL support, provided they do not use removed APIs. In general, see if the
library compiles and, on failure, consult the documentation in the header files
and see if problematic features can be removed.
In some cases, BoringSSL-specific code may be necessary. In that case, the
`OPENSSL_IS_BORINGSSL` preprocessor macro may be used in `#ifdef`s. This macro
should also be used in lieu of the presence of any particular function to detect
OpenSSL vs BoringSSL in configure scripts, etc., where those are necessary.
Before using the preprocessor, however, contact the BoringSSL maintainers about
the missing APIs. If not an intentionally removed feature, BoringSSL will
typically add compatibility functions for convenience.
BoringSSL's `OPENSSL_VERSION_NUMBER` matches the OpenSSL version it targets.
Version checks for OpenSSL should ideally work as-is in BoringSSL. BoringSSL
also defines upstream's `OPENSSL_NO_*` feature macros corresponding to removed
features. If the preprocessor is needed, use these version checks or feature
macros where possible, especially when patching third-party projects. Such
patches are more generally useful to OpenSSL consumers and thus more
appropriate to send upstream.
For convenience, BoringSSL defines upstream's `OPENSSL_NO_*` feature macros
corresponding to removed features. These may also be used to disable code which
uses a removed feature.
In some cases, BoringSSL-specific code may be necessary. Use the
`OPENSSL_IS_BORINGSSL` preprocessor macro in `#ifdef`s. However, first contact
the BoringSSL maintainers about the missing APIs. We will typically add
compatibility functions for convenience. In particular, *contact BoringSSL
maintainers before working around missing OpenSSL 1.1.0 accessors*. BoringSSL
was originally derived from OpenSSL 1.0.2 but now targets OpenSSL 1.1.0. Some
newer APIs may be missing but can be added on request. (Not all projects have
been ported to OpenSSL 1.1.0, so BoringSSL also remains largely compatible with
OpenSSL 1.0.2.)
The `OPENSSL_IS_BORINGSSL` macro may also be used to distinguish OpenSSL from
BoringSSL in configure scripts. Do not use the presence or absence of particular
symbols to detect BoringSSL.
Note: BoringSSL does *not* have a stable API or ABI. It must be updated with its
consumers. It is not suitable for, say, a system library in a traditional Linux
@@ -39,15 +49,19 @@ code, particularly to avoid compiler warnings.
Most notably, the `STACK_OF(T)` types have all been converted to use `size_t`
instead of `int` for indices and lengths.
### Reference counts
### Reference counts and opaque types
Some external consumers increment reference counts directly by calling
`CRYPTO_add` with the corresponding `CRYPTO_LOCK_*` value.
`CRYPTO_add` with the corresponding `CRYPTO_LOCK_*` value. These APIs no longer
exist in BoringSSL. Instead, code which increments reference counts should call
the corresponding `FOO_up_ref` function, such as `EVP_PKEY_up_ref`.
These APIs no longer exist in BoringSSL. Instead, code which increments
reference counts should call the corresponding `FOO_up_ref` function, such as
`EVP_PKEY_up_ref`. Note that not all of these APIs are present in OpenSSL and
may require `#ifdef`s.
BoringSSL also hides some structs which were previously exposed in OpenSSL
1.0.2, particularly in libssl. Use the relevant accessors instead.
Note that some of these APIs were added in OpenSSL 1.1.0, so projects which do
not yet support 1.1.0 may need additional `#ifdef`s. Projects supporting OpenSSL
1.1.0 should not require modification.
### Error codes
@@ -109,7 +123,7 @@ feature, so BoringSSL rejects peer renegotiations by default.
To enable renegotiation, call `SSL_set_renegotiate_mode` and set it to
`ssl_renegotiate_once` or `ssl_renegotiate_freely`. Renegotiation is only
supported as a client in SSL3/TLS and the HelloRequest must be received at a
supported as a client in TLS and the HelloRequest must be received at a
quiet point in the application protocol. This is sufficient to support the
common use of requesting a new client certificate between an HTTP request and
response in (unpipelined) HTTP/1.1.
@@ -165,6 +179,17 @@ recommended to avoid the `out` parameter completely and always pass in `NULL`.
Note that less error-prone APIs are available for BoringSSL-specific code (see
below).
### Memory allocation
OpenSSL provides wrappers `OPENSSL_malloc` and `OPENSSL_free` over the standard
`malloc` and `free`. Memory allocated by OpenSSL should be released with
`OPENSSL_free`, not the standard `free`. However, by default, they are
implemented directly using `malloc` and `free`, so code which mixes them up
usually works.
In BoringSSL, these functions maintain additional book-keeping to zero memory
on `OPENSSL_free`, so any mixups must be fixed.
## Optional BoringSSL-specific simplifications
BoringSSL makes some changes to OpenSSL which simplify the API but remain
@@ -185,7 +210,7 @@ strings and loading algorithms, etc. All of these functions still exist in
BoringSSL for convenience, but they do nothing and are not necessary.
The one exception is `CRYPTO_library_init`. In `BORINGSSL_NO_STATIC_INITIALIZER`
builds, it must be called to query CPU capabitilies before the rest of the
builds, it must be called to query CPU capabilities before the rest of the
library. In the default configuration, this is done with a static initializer
and is also unnecessary.
+9
View File
@@ -21,6 +21,13 @@ these patches in multiple places was growing steadily.
Currently BoringSSL is the SSL library in Chrome/Chromium, Android (but it's
not part of the NDK) and a number of other apps/programs.
Project links:
* [API documentation](https://commondatastorage.googleapis.com/chromium-boringssl-docs/headers.html)
* [Bug tracker](https://bugs.chromium.org/p/boringssl/issues/list)
* [CI](https://ci.chromium.org/p/boringssl/g/main/console)
* [Code review](https://boringssl-review.googlesource.com)
There are other files in this directory which might be helpful:
* [PORTING.md](/PORTING.md): how to port OpenSSL-using code to BoringSSL.
@@ -31,3 +38,5 @@ There are other files in this directory which might be helpful:
* include/openssl: public headers with API documentation in comments. Also [available online](https://commondatastorage.googleapis.com/chromium-boringssl-docs/headers.html).
* [FUZZING.md](/FUZZING.md): information about fuzzing BoringSSL.
* [CONTRIBUTING.md](/CONTRIBUTING.md): how to contribute to BoringSSL.
* [BREAKING-CHANGES.md](/BREAKING-CHANGES.md): notes on potentially-breaking changes.
* [SANDBOXING.md](/SANDBOXING.md): notes on using BoringSSL in a sandboxed environment.
+138
View File
@@ -0,0 +1,138 @@
# Using BoringSSL in a Sandbox
Sandboxes are a valuable tool for securing applications, so BoringSSL aims to
support them. However, it is difficult to make concrete API guarantees with
sandboxes. Sandboxes remove low-level OS resources and system calls, which
breaks platform abstractions. A syscall-filtering sandbox may, for instance, be
sensitive to otherwise non-breaking changes to use newer syscalls
in either BoringSSL or the C library.
Some functions in BoringSSL, such as `BIO_new_file`, inherently need OS
resources like the filesystem. We assume that sandboxed consumers either avoid
those functions or make necessary resources available. Other functions like
`RSA_sign` are purely computational, but still have some baseline OS
dependencies.
Sandboxes which drop privileges partway through a process's lifetime are
additionally sensitive to OS resources retained across the transitions. For
instance, if a library function internally opened and retained a handle to the
user's home directory, and then the application called `chroot`, that handle
would be a sandbox escape.
This document attempts to describe these baseline OS dependencies and long-lived
internal resources. These dependencies may change over time, but we aim to
[work with sandboxed consumers](/BREAKING-CHANGES.md) when they do. However,
each sandbox imposes different constraints, so, above all, sandboxed consumers
must have ample test coverage to detect issues as they arise.
## Baseline dependencies
Callers must assume that any BoringSSL function may perform one of the following
operations:
### Memory allocation
Any BoringSSL function may allocate memory via `malloc` and related functions.
### Thread synchronization
Any BoringSSL function may call into the platform's thread synchronization
primitives, including read/write locks and the equivalent of `pthread_once`.
These must succeed, or BoringSSL will abort the process. Callers, however, can
assume that BoringSSL functions will not spawn internal threads, unless
otherwise documented.
Syscall-filtering sandboxes should note that BoringSSL uses `pthread_rwlock_t`
on POSIX systems, which is less common and may not be part of other libraries'
syscall surface. Additionally, thread synchronization primitives usually have an
atomics-based fast path. If a sandbox blocks a necessary pthreads syscall, it
may not show up in testing without lock contention.
### Standard error
Any BoringSSL function may write to `stderr` or file descriptor
`STDERR_FILENO` (2), either via `FILE` APIs or low-level functions like `write`.
Writes to `stderr` may fail, but there must some file at `STDERR_FILENO` which
will tolerate error messages from BoringSSL. (The file descriptor must be
allocated so calls to `open` do not accidentally open something else there.)
Note some C standard library implementations also log to `stderr`, so callers
should ensure this regardless.
### Entropy
Any BoringSSL function may draw entropy from the OS. On Windows, this uses
`RtlGenRandom` and, on POSIX systems, this uses `getrandom`, `getentropy`, or a
`read` from a file descriptor to `/dev/urandom`. These operations must succeed
or BoringSSL will abort the process. BoringSSL only probes for `getrandom`
support once and assumes support is consistent for the lifetime of the address
space (and any copies made via `fork`). If a syscall-filtering sandbox is
enabled partway through this lifetime and changes whether `getrandom` works,
BoringSSL may abort the process. Sandboxes are recommended to allow
`getrandom`.
Note even deterministic algorithms may require OS entropy. For example,
RSASSA-PKCS1-v1_5 is deterministic, but BoringSSL draws entropy to implement
RSA blinding.
Entropy gathering additionally has some initialization dependencies described in
the following section.
## Initialization
BoringSSL has some uncommon OS dependencies which are only used once to
initialize some state. Sandboxes which drop privileges after some setup work may
use `CRYPTO_pre_sandbox_init` to initialize this state ahead of time. Otherwise,
callers must assume any BoringSSL function may depend on these resources, in
addition to the operations above.
### CPU capabilities
On Linux ARM platforms, BoringSSL depends on OS APIs to query CPU capabilities.
32-bit and 64-bit ARM both depend on the `getauxval` function. 32-bit ARM, to
work around bugs in older Android devices, may additionally read `/proc/cpuinfo`
and `/proc/self/auxv`.
If querying CPU capabilities fails, BoringSSL will still function, but may not
perform as well.
### Entropy
On Linux systems without a working `getrandom`, drawing entropy from the OS
additionally requires opening `/dev/urandom`. If this fails, BoringSSL will
abort the process. BoringSSL retains the resulting file descriptor, even across
privilege transitions.
### Fork protection
On Linux, BoringSSL allocates a page and calls `madvise` with `MADV_WIPEONFORK`
to protect single-use state from `fork`. This operation must not crash, but if
it fails, BoringSSL will use alternate fork-safety strategies, potentially at a
performance cost. If it succeeds, BoringSSL assumes `MADV_WIPEONFORK` is
functional and relies on it for fork-safety. Sandboxes must not report success
if they ignore the `MADV_WIPEONFORK` flag. As of writing, QEMU will ignore
`madvise` calls and report success, so BoringSSL detects this by calling
`madvise` with -1. Sandboxes must cleanly report an error instead of crashing.
Once initialized, this mechanism does not require system calls in the steady
state, though note the configured page will be inherited across privilege
transitions.
## C and C++ standard library
BoringSSL depends on the C and C++ standard libraries which, themselves, do not
make any guarantees about sandboxes. If it produces the correct answer and has
no observable invalid side effects, it is possible, though unreasonable, for
`memcmp` to create and close a socket.
BoringSSL assumes that functions in the C and C++ library only have the platform
dependencies which would be "reasonable". For instance, a function in BoringSSL
which aims not to open files will still freely call any libc memory and
string functions.
Note some C functions, such as `strerror`, may read files relating to the user's
locale. BoringSSL may trigger these paths and assumes the sandbox environment
will tolerate this. BoringSSL additionally cannot make guarantees about which
system calls are used by standard library's syscall wrappers. In some cases, the
compiler may add dependencies. (Some C++ language features emit locking code.)
Syscall-filtering sandboxes may need updates as these dependencies change.
+27 -14
View File
@@ -31,10 +31,10 @@ Variable declarations in the middle of a function or inside a `for` loop are
allowed and preferred where possible. Note that the common `goto err` cleanup
pattern requires lifting some variable declarations.
Comments should be `/* C-style */` for consistency.
Comments should be `// C99-style` for consistency with C++.
When declaration pointer types, `*` should be placed next to the variable
name, not the type. So
When declaring pointer types, `*` should be placed next to the variable name,
not the type. So
uint8_t *ptr;
@@ -60,6 +60,19 @@ constants for flags. If adding values to an existing set of `#define`s,
continue with `#define`.
## libssl
libssl was originally written in C but is being incrementally rewritten in
C++11. As of writing, much of the style matches our C conventions rather than
Google C++. Additionally, libssl on Linux currently may not depend on the C++
runtime. See the C++ utilities in `ssl/internal.h` for replacements for
problematic C++ constructs. The `util/check_imported_libraries.go` script may be
used with a shared library build to check if a new construct is okay.
If unsure, match surrounding code. Discrepancies between it and Google C++ style
will be fixed over time.
## Formatting
Single-statement blocks are not allowed. All conditions and loops must
@@ -185,23 +198,23 @@ behavior of the function. Pay special note to success/failure behaviors
and caller obligations on object lifetimes. If this sacrifices
conciseness, consider simplifying the function's behavior.
/* EVP_DigestVerifyUpdate appends |len| bytes from |data| to the data which
* will be verified by |EVP_DigestVerifyFinal|. It returns one on success and
* zero otherwise. */
// EVP_DigestVerifyUpdate appends |len| bytes from |data| to the data which
// will be verified by |EVP_DigestVerifyFinal|. It returns one on success and
// zero otherwise.
OPENSSL_EXPORT int EVP_DigestVerifyUpdate(EVP_MD_CTX *ctx, const void *data,
size_t len);
Explicitly mention any surprising edge cases or deviations from common
return value patterns in legacy functions.
/* RSA_private_encrypt encrypts |flen| bytes from |from| with the private key in
* |rsa| and writes the encrypted data to |to|. The |to| buffer must have at
* least |RSA_size| bytes of space. It returns the number of bytes written, or
* -1 on error. The |padding| argument must be one of the |RSA_*_PADDING|
* values. If in doubt, |RSA_PKCS1_PADDING| is the most common.
*
* WARNING: this function is dangerous because it breaks the usual return value
* convention. Use |RSA_sign_raw| instead. */
// RSA_private_encrypt encrypts |flen| bytes from |from| with the private key in
// |rsa| and writes the encrypted data to |to|. The |to| buffer must have at
// least |RSA_size| bytes of space. It returns the number of bytes written, or
// -1 on error. The |padding| argument must be one of the |RSA_*_PADDING|
// values. If in doubt, |RSA_PKCS1_PADDING| is the most common.
//
// WARNING: this function is dangerous because it breaks the usual return value
// convention. Use |RSA_sign_raw| instead.
OPENSSL_EXPORT int RSA_private_encrypt(int flen, const uint8_t *from,
uint8_t *to, RSA *rsa, int padding);
+1 -1
View File
@@ -1,4 +1,4 @@
# This file is used by gcl to get repository specific information.
# This file is used by "git cl" to get repository specific information.
GERRIT_HOST: True
GERRIT_PORT: True
CODE_REVIEW_SERVER: https://boringssl-review.googlesource.com
+410 -126
View File
@@ -2,27 +2,27 @@ include_directories(../include)
if(NOT OPENSSL_NO_ASM)
if(UNIX)
if (${ARCH} STREQUAL "aarch64")
if(${ARCH} STREQUAL "aarch64")
# The "armx" Perl scripts look for "64" in the style argument
# in order to decide whether to generate 32- or 64-bit asm.
if (APPLE)
if(APPLE)
set(PERLASM_STYLE ios64)
else()
set(PERLASM_STYLE linux64)
endif()
elseif (${ARCH} STREQUAL "arm")
if (APPLE)
elseif(${ARCH} STREQUAL "arm")
if(APPLE)
set(PERLASM_STYLE ios32)
else()
set(PERLASM_STYLE linux32)
endif()
elseif (${ARCH} STREQUAL "ppc64le")
elseif(${ARCH} STREQUAL "ppc64le")
set(PERLASM_STYLE linux64le)
else()
if (${ARCH} STREQUAL "x86")
if(${ARCH} STREQUAL "x86")
set(PERLASM_FLAGS "-fPIC -DOPENSSL_IA32_SSE2")
endif()
if (APPLE)
if(APPLE)
set(PERLASM_STYLE macosx)
else()
set(PERLASM_STYLE elf)
@@ -38,21 +38,22 @@ if(NOT OPENSSL_NO_ASM)
endif()
# CMake does not add -isysroot and -arch flags to assembly.
if (APPLE)
if (CMAKE_OSX_SYSROOT)
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -isysroot ${CMAKE_OSX_SYSROOT}")
if(APPLE)
if(CMAKE_OSX_SYSROOT)
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -isysroot \"${CMAKE_OSX_SYSROOT}\"")
endif()
foreach(arch ${CMAKE_OSX_ARCHITECTURES})
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -arch ${arch}")
endforeach()
endif()
else()
if (${ARCH} STREQUAL "x86_64")
if(${ARCH} STREQUAL "x86_64")
set(PERLASM_STYLE nasm)
else()
set(PERLASM_STYLE win32n)
set(PERLASM_FLAGS "-DOPENSSL_IA32_SSE2")
endif()
set(CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} -gcv8")
# On Windows, we use the NASM output, specifically built with Yasm.
set(ASM_EXT asm)
@@ -61,8 +62,14 @@ if(NOT OPENSSL_NO_ASM)
endif()
function(perlasm dest src)
get_filename_component(dir ${dest} DIRECTORY)
if ("${dir}" STREQUAL "")
set(dir ".")
endif()
add_custom_command(
OUTPUT ${dest}
COMMAND ${CMAKE_COMMAND} -E make_directory ${dir}
COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${src} ${PERLASM_STYLE} ${PERLASM_FLAGS} ${ARGN} ${dest}
DEPENDS
${src}
@@ -77,79 +84,10 @@ function(perlasm dest src)
)
endfunction()
# Level 0.1 - depends on nothing outside this set.
add_subdirectory(stack)
add_subdirectory(lhash)
add_subdirectory(err)
add_subdirectory(buf)
add_subdirectory(base64)
add_subdirectory(bytestring)
add_subdirectory(pool)
# Level 0.2 - depends on nothing but itself
add_subdirectory(rc4)
add_subdirectory(conf)
add_subdirectory(chacha)
add_subdirectory(poly1305)
add_subdirectory(curve25519)
# Level 1, depends only on 0.*
add_subdirectory(digest_extra)
add_subdirectory(cipher_extra)
add_subdirectory(rand_extra)
add_subdirectory(bio)
add_subdirectory(bn_extra)
add_subdirectory(obj)
add_subdirectory(asn1)
# Level 2
add_subdirectory(engine)
add_subdirectory(dh)
add_subdirectory(dsa)
add_subdirectory(rsa_extra)
add_subdirectory(ec_extra)
add_subdirectory(ecdh)
add_subdirectory(ecdsa_extra)
# Level 3
add_subdirectory(cmac)
add_subdirectory(evp)
add_subdirectory(hkdf)
add_subdirectory(pem)
add_subdirectory(x509)
add_subdirectory(x509v3)
# Level 4
add_subdirectory(pkcs7)
add_subdirectory(pkcs8)
# Test support code
add_subdirectory(fipsmodule)
add_subdirectory(test)
add_subdirectory(fipsmodule)
add_library(
crypto_base
OBJECT
cpu-aarch64-linux.c
cpu-arm.c
cpu-arm-linux.c
cpu-intel.c
cpu-ppc64le.c
crypto.c
ex_data.c
mem.c
refcount_c11.c
refcount_lock.c
thread.c
thread_none.c
thread_pthread.c
thread_win.c
)
if(FIPS_DELOCATE)
if(FIPS_DELOCATE OR FIPS_SHARED)
SET_SOURCE_FILES_PROPERTIES(fipsmodule/bcm.o PROPERTIES EXTERNAL_OBJECT true)
SET_SOURCE_FILES_PROPERTIES(fipsmodule/bcm.o PROPERTIES GENERATED true)
@@ -160,65 +98,396 @@ if(FIPS_DELOCATE)
)
endif()
if(${ARCH} STREQUAL "arm")
set(
CRYPTO_ARCH_SOURCES
chacha/chacha-armv4.${ASM_EXT}
curve25519/asm/x25519-asm-arm.S
poly1305/poly1305_arm_asm.S
test/trampoline-armv4.${ASM_EXT}
)
endif()
if(${ARCH} STREQUAL "aarch64")
set(
CRYPTO_ARCH_SOURCES
chacha/chacha-armv8.${ASM_EXT}
test/trampoline-armv8.${ASM_EXT}
)
endif()
if(${ARCH} STREQUAL "ppc64le")
set(
CRYPTO_ARCH_SOURCES
test/trampoline-ppc.${ASM_EXT}
)
endif()
if(${ARCH} STREQUAL "x86")
set(
CRYPTO_ARCH_SOURCES
chacha/chacha-x86.${ASM_EXT}
test/trampoline-x86.${ASM_EXT}
)
endif()
if(${ARCH} STREQUAL "x86_64")
set(
CRYPTO_ARCH_SOURCES
chacha/chacha-x86_64.${ASM_EXT}
cipher_extra/aes128gcmsiv-x86_64.${ASM_EXT}
cipher_extra/chacha20_poly1305_x86_64.${ASM_EXT}
hrss/asm/poly_rq_mul.S
test/trampoline-x86_64.${ASM_EXT}
)
endif()
perlasm(chacha/chacha-armv4.${ASM_EXT} chacha/asm/chacha-armv4.pl)
perlasm(chacha/chacha-armv8.${ASM_EXT} chacha/asm/chacha-armv8.pl)
perlasm(chacha/chacha-x86.${ASM_EXT} chacha/asm/chacha-x86.pl)
perlasm(chacha/chacha-x86_64.${ASM_EXT} chacha/asm/chacha-x86_64.pl)
perlasm(cipher_extra/aes128gcmsiv-x86_64.${ASM_EXT} cipher_extra/asm/aes128gcmsiv-x86_64.pl)
perlasm(cipher_extra/chacha20_poly1305_x86_64.${ASM_EXT} cipher_extra/asm/chacha20_poly1305_x86_64.pl)
perlasm(test/trampoline-armv4.${ASM_EXT} test/asm/trampoline-armv4.pl)
perlasm(test/trampoline-armv8.${ASM_EXT} test/asm/trampoline-armv8.pl)
perlasm(test/trampoline-ppc.${ASM_EXT} test/asm/trampoline-ppc.pl)
perlasm(test/trampoline-x86.${ASM_EXT} test/asm/trampoline-x86.pl)
perlasm(test/trampoline-x86_64.${ASM_EXT} test/asm/trampoline-x86_64.pl)
add_custom_command(
OUTPUT err_data.c
COMMAND ${GO_EXECUTABLE} run err_data_generate.go > ${CMAKE_CURRENT_BINARY_DIR}/err_data.c
DEPENDS
err/err_data_generate.go
err/asn1.errordata
err/bio.errordata
err/bn.errordata
err/cipher.errordata
err/conf.errordata
err/dh.errordata
err/digest.errordata
err/dsa.errordata
err/ecdh.errordata
err/ecdsa.errordata
err/ec.errordata
err/engine.errordata
err/evp.errordata
err/hkdf.errordata
err/obj.errordata
err/pem.errordata
err/pkcs7.errordata
err/pkcs8.errordata
err/rsa.errordata
err/ssl.errordata
err/trust_token.errordata
err/x509.errordata
err/x509v3.errordata
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/err
)
add_library(
crypto
$<TARGET_OBJECTS:crypto_base>
$<TARGET_OBJECTS:stack>
$<TARGET_OBJECTS:lhash>
$<TARGET_OBJECTS:err>
$<TARGET_OBJECTS:base64>
$<TARGET_OBJECTS:bytestring>
$<TARGET_OBJECTS:pool>
$<TARGET_OBJECTS:fipsmodule>
$<TARGET_OBJECTS:digest_extra>
$<TARGET_OBJECTS:cipher_extra>
$<TARGET_OBJECTS:rc4>
$<TARGET_OBJECTS:conf>
$<TARGET_OBJECTS:chacha>
$<TARGET_OBJECTS:poly1305>
$<TARGET_OBJECTS:curve25519>
$<TARGET_OBJECTS:buf>
$<TARGET_OBJECTS:bn_extra>
$<TARGET_OBJECTS:bio>
$<TARGET_OBJECTS:rand_extra>
$<TARGET_OBJECTS:obj>
$<TARGET_OBJECTS:asn1>
$<TARGET_OBJECTS:engine>
$<TARGET_OBJECTS:dh>
$<TARGET_OBJECTS:dsa>
$<TARGET_OBJECTS:rsa_extra>
$<TARGET_OBJECTS:ec_extra>
$<TARGET_OBJECTS:ecdh>
$<TARGET_OBJECTS:ecdsa_extra>
$<TARGET_OBJECTS:cmac>
$<TARGET_OBJECTS:evp>
$<TARGET_OBJECTS:hkdf>
$<TARGET_OBJECTS:pem>
$<TARGET_OBJECTS:x509>
$<TARGET_OBJECTS:x509v3>
$<TARGET_OBJECTS:pkcs7>
$<TARGET_OBJECTS:pkcs8_lib>
asn1/a_bitstr.c
asn1/a_bool.c
asn1/a_d2i_fp.c
asn1/a_dup.c
asn1/a_enum.c
asn1/a_gentm.c
asn1/a_i2d_fp.c
asn1/a_int.c
asn1/a_mbstr.c
asn1/a_object.c
asn1/a_octet.c
asn1/a_print.c
asn1/a_strnid.c
asn1/a_time.c
asn1/a_type.c
asn1/a_utctm.c
asn1/a_utf8.c
asn1/asn1_lib.c
asn1/asn1_par.c
asn1/asn_pack.c
asn1/f_enum.c
asn1/f_int.c
asn1/f_string.c
asn1/tasn_dec.c
asn1/tasn_enc.c
asn1/tasn_fre.c
asn1/tasn_new.c
asn1/tasn_typ.c
asn1/tasn_utl.c
asn1/time_support.c
base64/base64.c
bio/bio.c
bio/bio_mem.c
bio/connect.c
bio/fd.c
bio/file.c
bio/hexdump.c
bio/pair.c
bio/printf.c
bio/socket.c
bio/socket_helper.c
bn_extra/bn_asn1.c
bn_extra/convert.c
buf/buf.c
bytestring/asn1_compat.c
bytestring/ber.c
bytestring/cbb.c
bytestring/cbs.c
bytestring/unicode.c
chacha/chacha.c
cipher_extra/cipher_extra.c
cipher_extra/derive_key.c
cipher_extra/e_aesccm.c
cipher_extra/e_aesctrhmac.c
cipher_extra/e_aesgcmsiv.c
cipher_extra/e_chacha20poly1305.c
cipher_extra/e_null.c
cipher_extra/e_rc2.c
cipher_extra/e_rc4.c
cipher_extra/e_tls.c
cipher_extra/tls_cbc.c
cmac/cmac.c
conf/conf.c
cpu-aarch64-fuchsia.c
cpu-aarch64-linux.c
cpu-arm-linux.c
cpu-arm.c
cpu-intel.c
cpu-ppc64le.c
crypto.c
curve25519/curve25519.c
curve25519/spake25519.c
dh/dh.c
dh/params.c
dh/check.c
dh/dh_asn1.c
digest_extra/digest_extra.c
dsa/dsa.c
dsa/dsa_asn1.c
ecdh_extra/ecdh_extra.c
ecdsa_extra/ecdsa_asn1.c
ec_extra/ec_asn1.c
ec_extra/ec_derive.c
ec_extra/hash_to_curve.c
err/err.c
err_data.c
engine/engine.c
evp/digestsign.c
evp/evp.c
evp/evp_asn1.c
evp/evp_ctx.c
evp/p_dsa_asn1.c
evp/p_ec.c
evp/p_ec_asn1.c
evp/p_ed25519.c
evp/p_ed25519_asn1.c
evp/p_rsa.c
evp/p_rsa_asn1.c
evp/p_x25519.c
evp/p_x25519_asn1.c
evp/pbkdf.c
evp/print.c
evp/scrypt.c
evp/sign.c
ex_data.c
hkdf/hkdf.c
hpke/hpke.c
hrss/hrss.c
lhash/lhash.c
mem.c
obj/obj.c
obj/obj_xref.c
pem/pem_all.c
pem/pem_info.c
pem/pem_lib.c
pem/pem_oth.c
pem/pem_pk8.c
pem/pem_pkey.c
pem/pem_x509.c
pem/pem_xaux.c
pkcs7/pkcs7.c
pkcs7/pkcs7_x509.c
pkcs8/pkcs8.c
pkcs8/pkcs8_x509.c
pkcs8/p5_pbev2.c
poly1305/poly1305.c
poly1305/poly1305_arm.c
poly1305/poly1305_vec.c
pool/pool.c
rand_extra/deterministic.c
rand_extra/forkunsafe.c
rand_extra/fuchsia.c
rand_extra/rand_extra.c
rand_extra/windows.c
rc4/rc4.c
refcount_c11.c
refcount_lock.c
rsa_extra/rsa_asn1.c
rsa_extra/rsa_print.c
stack/stack.c
siphash/siphash.c
thread.c
thread_none.c
thread_pthread.c
thread_win.c
trust_token/pmbtoken.c
trust_token/trust_token.c
x509/a_digest.c
x509/a_sign.c
x509/a_strex.c
x509/a_verify.c
x509/algorithm.c
x509/asn1_gen.c
x509/by_dir.c
x509/by_file.c
x509/i2d_pr.c
x509/rsa_pss.c
x509/t_crl.c
x509/t_req.c
x509/t_x509.c
x509/t_x509a.c
x509/x509.c
x509/x509_att.c
x509/x509_cmp.c
x509/x509_d2.c
x509/x509_def.c
x509/x509_ext.c
x509/x509_lu.c
x509/x509_obj.c
x509/x509_r2x.c
x509/x509_req.c
x509/x509_set.c
x509/x509_trs.c
x509/x509_txt.c
x509/x509_v3.c
x509/x509_vfy.c
x509/x509_vpm.c
x509/x509cset.c
x509/x509name.c
x509/x509rset.c
x509/x509spki.c
x509/x_algor.c
x509/x_all.c
x509/x_attrib.c
x509/x_crl.c
x509/x_exten.c
x509/x_info.c
x509/x_name.c
x509/x_pkey.c
x509/x_pubkey.c
x509/x_req.c
x509/x_sig.c
x509/x_spki.c
x509/x_val.c
x509/x_x509.c
x509/x_x509a.c
x509v3/pcy_cache.c
x509v3/pcy_data.c
x509v3/pcy_lib.c
x509v3/pcy_map.c
x509v3/pcy_node.c
x509v3/pcy_tree.c
x509v3/v3_akey.c
x509v3/v3_akeya.c
x509v3/v3_alt.c
x509v3/v3_bcons.c
x509v3/v3_bitst.c
x509v3/v3_conf.c
x509v3/v3_cpols.c
x509v3/v3_crld.c
x509v3/v3_enum.c
x509v3/v3_extku.c
x509v3/v3_genn.c
x509v3/v3_ia5.c
x509v3/v3_info.c
x509v3/v3_int.c
x509v3/v3_lib.c
x509v3/v3_ncons.c
x509v3/v3_ocsp.c
x509v3/v3_pci.c
x509v3/v3_pcia.c
x509v3/v3_pcons.c
x509v3/v3_pku.c
x509v3/v3_pmaps.c
x509v3/v3_prn.c
x509v3/v3_purp.c
x509v3/v3_skey.c
x509v3/v3_sxnet.c
x509v3/v3_utl.c
$<TARGET_OBJECTS:fipsmodule>
${CRYPTO_ARCH_SOURCES}
${CRYPTO_FIPS_OBJECTS}
)
if(FIPS_DELOCATE)
if(FIPS_SHARED)
set(EXTRA_INJECT_HASH_ARGS)
if(ANDROID)
set(EXTRA_INJECT_HASH_ARGS "-sha256")
endif()
# Rewrite libcrypto.so to inject the correct module hash value. This assumes
# UNIX-style library naming, but we only support FIPS mode on Linux anyway.
add_custom_command(
TARGET crypto POST_BUILD
COMMAND ${GO_EXECUTABLE} run
${CMAKE_CURRENT_SOURCE_DIR}/../util/fipstools/inject_hash/inject_hash.go
-o libcrypto.so -in-object libcrypto.so ${EXTRA_INJECT_HASH_ARGS}
# The DEPENDS argument to a POST_BUILD rule appears to be ignored. Thus
# go_executable isn't used (as it doesn't get built), but we list this
# dependency anyway in case it starts working in some CMake version.
DEPENDS ../util/fipstools/inject_hash/inject_hash.go
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
endif()
add_dependencies(crypto global_target)
if(FIPS_DELOCATE OR FIPS_SHARED)
add_dependencies(crypto bcm_o_target)
endif()
SET_TARGET_PROPERTIES(crypto PROPERTIES LINKER_LANGUAGE C)
if(NOT MSVC AND NOT ANDROID)
if(NOT WIN32 AND NOT ANDROID)
target_link_libraries(crypto pthread)
endif()
# TODO(davidben): Convert the remaining tests to GTest.
# Every target depends on crypto, so we add libcxx as a dependency here to
# simplify injecting it everywhere.
if(USE_CUSTOM_LIBCXX)
target_link_libraries(crypto libcxx)
endif()
# urandom_test is a separate binary because it needs to be able to observe the
# PRNG initialisation, which means that it can't have other tests running before
# it does.
add_executable(
urandom_test
fipsmodule/rand/urandom_test.cc
)
target_link_libraries(urandom_test test_support_lib boringssl_gtest crypto)
add_dependencies(urandom_test global_target)
add_dependencies(all_tests urandom_test)
add_executable(
crypto_test
abi_self_test.cc
asn1/asn1_test.cc
base64/base64_test.cc
buf/buf_test.cc
bio/bio_test.cc
bytestring/bytestring_test.cc
chacha/chacha_test.cc
@@ -227,10 +496,11 @@ add_executable(
cmac/cmac_test.cc
compiler_test.cc
constant_time_test.cc
cpu-arm-linux_test.cc
curve25519/ed25519_test.cc
curve25519/spake25519_test.cc
curve25519/x25519_test.cc
ecdh/ecdh_test.cc
ecdh_extra/ecdh_test.cc
dh/dh_test.cc
digest_extra/digest_test.cc
dsa/dsa_test.cc
@@ -244,32 +514,46 @@ add_executable(
fipsmodule/ec/ec_test.cc
fipsmodule/ec/p256-x86_64_test.cc
fipsmodule/ecdsa/ecdsa_test.cc
fipsmodule/md5/md5_test.cc
fipsmodule/modes/gcm_test.cc
fipsmodule/rand/ctrdrbg_test.cc
fipsmodule/rand/fork_detect_test.cc
fipsmodule/sha/sha_test.cc
hkdf/hkdf_test.cc
hpke/hpke_test.cc
hmac_extra/hmac_test.cc
hrss/hrss_test.cc
impl_dispatch_test.cc
lhash/lhash_test.cc
obj/obj_test.cc
pem/pem_test.cc
pkcs7/pkcs7_test.cc
pkcs8/pkcs8_test.cc
pkcs8/pkcs12_test.cc
poly1305/poly1305_test.cc
pool/pool_test.cc
rand_extra/rand_test.cc
refcount_test.cc
rsa_extra/rsa_test.cc
self_test.cc
stack/stack_test.cc
siphash/siphash_test.cc
test/file_test_gtest.cc
thread_test.cc
trust_token/trust_token_test.cc
x509/x509_test.cc
x509/x509_time_test.cc
x509v3/tab_test.cc
x509v3/v3name_test.cc
$<TARGET_OBJECTS:crypto_test_data>
$<TARGET_OBJECTS:gtest_main>
$<TARGET_OBJECTS:test_support>
$<TARGET_OBJECTS:boringssl_gtest_main>
)
target_link_libraries(crypto_test crypto gtest)
if (WIN32)
add_dependencies(crypto_test global_target)
target_link_libraries(crypto_test test_support_lib boringssl_gtest crypto)
if(WIN32)
target_link_libraries(crypto_test ws2_32)
endif()
add_dependencies(all_tests crypto_test)
+808
View File
@@ -0,0 +1,808 @@
/* Copyright (c) 2018, Google Inc.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
#include <gtest/gtest.h>
#include <gtest/gtest-spi.h>
#include <openssl/rand.h>
#include "test/abi_test.h"
static bool test_function_ok;
static int TestFunction(int a1, int a2, int a3, int a4, int a5, int a6, int a7,
int a8) {
test_function_ok = a1 == 1 || a2 == 2 || a3 == 3 || a4 == 4 || a5 == 5 ||
a6 == 6 || a7 == 7 || a8 == 8;
return 42;
}
TEST(ABITest, SanityCheck) {
EXPECT_NE(0, CHECK_ABI_NO_UNWIND(strcmp, "hello", "world"));
test_function_ok = false;
EXPECT_EQ(42, CHECK_ABI_SEH(TestFunction, 1, 2, 3, 4, 5, 6, 7, 8));
EXPECT_TRUE(test_function_ok);
#if defined(SUPPORTS_ABI_TEST)
abi_test::internal::CallerState state;
RAND_bytes(reinterpret_cast<uint8_t *>(&state), sizeof(state));
crypto_word_t argv[] = {
1, 2, 3, 4, 5, 6, 7, 8,
};
CHECK_ABI_SEH(abi_test_trampoline,
reinterpret_cast<crypto_word_t>(TestFunction), &state, argv, 8,
0 /* no breakpoint */);
#if defined(OPENSSL_X86_64)
if (abi_test::UnwindTestsEnabled()) {
EXPECT_NONFATAL_FAILURE(CHECK_ABI_SEH(abi_test_bad_unwind_wrong_register),
"was not recovered");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_SEH(abi_test_bad_unwind_temporary),
"was not recovered");
CHECK_ABI_NO_UNWIND(abi_test_bad_unwind_wrong_register);
CHECK_ABI_NO_UNWIND(abi_test_bad_unwind_temporary);
#if defined(OPENSSL_WINDOWS)
// The invalid epilog makes Windows believe the epilog starts later than it
// actually does. As a result, immediately after the popq, it does not
// realize the stack has been unwound and repeats the work.
EXPECT_NONFATAL_FAILURE(CHECK_ABI_SEH(abi_test_bad_unwind_epilog),
"unwound past starting frame");
CHECK_ABI_NO_UNWIND(abi_test_bad_unwind_epilog);
#endif // OPENSSL_WINDOWS
}
#endif // OPENSSL_X86_64
#endif // SUPPORTS_ABI_TEST
}
#if defined(OPENSSL_X86_64) && defined(SUPPORTS_ABI_TEST)
extern "C" {
void abi_test_clobber_rax(void);
void abi_test_clobber_rbx(void);
void abi_test_clobber_rcx(void);
void abi_test_clobber_rdx(void);
void abi_test_clobber_rsi(void);
void abi_test_clobber_rdi(void);
void abi_test_clobber_rbp(void);
void abi_test_clobber_r8(void);
void abi_test_clobber_r9(void);
void abi_test_clobber_r10(void);
void abi_test_clobber_r11(void);
void abi_test_clobber_r12(void);
void abi_test_clobber_r13(void);
void abi_test_clobber_r14(void);
void abi_test_clobber_r15(void);
void abi_test_clobber_xmm0(void);
void abi_test_clobber_xmm1(void);
void abi_test_clobber_xmm2(void);
void abi_test_clobber_xmm3(void);
void abi_test_clobber_xmm4(void);
void abi_test_clobber_xmm5(void);
void abi_test_clobber_xmm6(void);
void abi_test_clobber_xmm7(void);
void abi_test_clobber_xmm8(void);
void abi_test_clobber_xmm9(void);
void abi_test_clobber_xmm10(void);
void abi_test_clobber_xmm11(void);
void abi_test_clobber_xmm12(void);
void abi_test_clobber_xmm13(void);
void abi_test_clobber_xmm14(void);
void abi_test_clobber_xmm15(void);
} // extern "C"
TEST(ABITest, X86_64) {
// abi_test_trampoline hides unsaved registers from the caller, so we can
// safely call the abi_test_clobber_* functions below.
abi_test::internal::CallerState state;
RAND_bytes(reinterpret_cast<uint8_t *>(&state), sizeof(state));
CHECK_ABI_NO_UNWIND(abi_test_trampoline,
reinterpret_cast<crypto_word_t>(abi_test_clobber_rbx),
&state, nullptr, 0, 0 /* no breakpoint */);
CHECK_ABI_NO_UNWIND(abi_test_clobber_rax);
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_rbx),
"rbx was not restored after return");
CHECK_ABI_NO_UNWIND(abi_test_clobber_rcx);
CHECK_ABI_NO_UNWIND(abi_test_clobber_rdx);
#if defined(OPENSSL_WINDOWS)
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_rdi),
"rdi was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_rsi),
"rsi was not restored after return");
#else
CHECK_ABI_NO_UNWIND(abi_test_clobber_rdi);
CHECK_ABI_NO_UNWIND(abi_test_clobber_rsi);
#endif
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_rbp),
"rbp was not restored after return");
CHECK_ABI_NO_UNWIND(abi_test_clobber_r8);
CHECK_ABI_NO_UNWIND(abi_test_clobber_r9);
CHECK_ABI_NO_UNWIND(abi_test_clobber_r10);
CHECK_ABI_NO_UNWIND(abi_test_clobber_r11);
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r12),
"r12 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r13),
"r13 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r14),
"r14 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r15),
"r15 was not restored after return");
CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm0);
CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm1);
CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm2);
CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm3);
CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm4);
CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm5);
#if defined(OPENSSL_WINDOWS)
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm6),
"xmm6 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm7),
"xmm7 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm8),
"xmm8 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm9),
"xmm9 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm10),
"xmm10 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm11),
"xmm11 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm12),
"xmm12 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm13),
"xmm13 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm14),
"xmm14 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm15),
"xmm15 was not restored after return");
#else
CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm6);
CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm7);
CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm8);
CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm9);
CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm10);
CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm11);
CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm12);
CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm13);
CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm14);
CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm15);
#endif
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_set_direction_flag),
"Direction flag set after return");
EXPECT_EQ(0, abi_test_get_and_clear_direction_flag())
<< "CHECK_ABI did not insulate the caller from direction flag errors";
}
#endif // OPENSSL_X86_64 && SUPPORTS_ABI_TEST
#if defined(OPENSSL_X86) && defined(SUPPORTS_ABI_TEST)
extern "C" {
void abi_test_clobber_eax(void);
void abi_test_clobber_ebx(void);
void abi_test_clobber_ecx(void);
void abi_test_clobber_edx(void);
void abi_test_clobber_esi(void);
void abi_test_clobber_edi(void);
void abi_test_clobber_ebp(void);
void abi_test_clobber_xmm0(void);
void abi_test_clobber_xmm1(void);
void abi_test_clobber_xmm2(void);
void abi_test_clobber_xmm3(void);
void abi_test_clobber_xmm4(void);
void abi_test_clobber_xmm5(void);
void abi_test_clobber_xmm6(void);
void abi_test_clobber_xmm7(void);
} // extern "C"
TEST(ABITest, X86) {
// abi_test_trampoline hides unsaved registers from the caller, so we can
// safely call the abi_test_clobber_* functions below.
abi_test::internal::CallerState state;
RAND_bytes(reinterpret_cast<uint8_t *>(&state), sizeof(state));
CHECK_ABI_NO_UNWIND(abi_test_trampoline,
reinterpret_cast<crypto_word_t>(abi_test_clobber_ebx),
&state, nullptr, 0, 0 /* no breakpoint */);
CHECK_ABI_NO_UNWIND(abi_test_clobber_eax);
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_ebx),
"ebx was not restored after return");
CHECK_ABI_NO_UNWIND(abi_test_clobber_ecx);
CHECK_ABI_NO_UNWIND(abi_test_clobber_edx);
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_edi),
"edi was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_esi),
"esi was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_ebp),
"ebp was not restored after return");
CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm0);
CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm1);
CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm2);
CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm3);
CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm4);
CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm5);
CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm6);
CHECK_ABI_NO_UNWIND(abi_test_clobber_xmm7);
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_set_direction_flag),
"Direction flag set after return");
EXPECT_EQ(0, abi_test_get_and_clear_direction_flag())
<< "CHECK_ABI did not insulate the caller from direction flag errors";
}
#endif // OPENSSL_X86 && SUPPORTS_ABI_TEST
#if defined(OPENSSL_ARM) && defined(SUPPORTS_ABI_TEST)
extern "C" {
void abi_test_clobber_r0(void);
void abi_test_clobber_r1(void);
void abi_test_clobber_r2(void);
void abi_test_clobber_r3(void);
void abi_test_clobber_r4(void);
void abi_test_clobber_r5(void);
void abi_test_clobber_r6(void);
void abi_test_clobber_r7(void);
void abi_test_clobber_r8(void);
void abi_test_clobber_r9(void);
void abi_test_clobber_r10(void);
void abi_test_clobber_r11(void);
void abi_test_clobber_r12(void);
// r13, r14, and r15, are sp, lr, and pc, respectively.
void abi_test_clobber_d0(void);
void abi_test_clobber_d1(void);
void abi_test_clobber_d2(void);
void abi_test_clobber_d3(void);
void abi_test_clobber_d4(void);
void abi_test_clobber_d5(void);
void abi_test_clobber_d6(void);
void abi_test_clobber_d7(void);
void abi_test_clobber_d8(void);
void abi_test_clobber_d9(void);
void abi_test_clobber_d10(void);
void abi_test_clobber_d11(void);
void abi_test_clobber_d12(void);
void abi_test_clobber_d13(void);
void abi_test_clobber_d14(void);
void abi_test_clobber_d15(void);
} // extern "C"
TEST(ABITest, ARM) {
// abi_test_trampoline hides unsaved registers from the caller, so we can
// safely call the abi_test_clobber_* functions below.
abi_test::internal::CallerState state;
RAND_bytes(reinterpret_cast<uint8_t *>(&state), sizeof(state));
CHECK_ABI_NO_UNWIND(abi_test_trampoline,
reinterpret_cast<crypto_word_t>(abi_test_clobber_r4),
&state, nullptr, 0, 0 /* no breakpoint */);
CHECK_ABI_NO_UNWIND(abi_test_clobber_r0);
CHECK_ABI_NO_UNWIND(abi_test_clobber_r1);
CHECK_ABI_NO_UNWIND(abi_test_clobber_r2);
CHECK_ABI_NO_UNWIND(abi_test_clobber_r3);
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r4),
"r4 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r5),
"r5 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r6),
"r6 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r7),
"r7 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r8),
"r8 was not restored after return");
#if defined(OPENSSL_APPLE)
CHECK_ABI_NO_UNWIND(abi_test_clobber_r9);
#else
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r9),
"r9 was not restored after return");
#endif
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r10),
"r10 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r11),
"r11 was not restored after return");
CHECK_ABI_NO_UNWIND(abi_test_clobber_r12);
CHECK_ABI_NO_UNWIND(abi_test_clobber_d0);
CHECK_ABI_NO_UNWIND(abi_test_clobber_d1);
CHECK_ABI_NO_UNWIND(abi_test_clobber_d2);
CHECK_ABI_NO_UNWIND(abi_test_clobber_d3);
CHECK_ABI_NO_UNWIND(abi_test_clobber_d4);
CHECK_ABI_NO_UNWIND(abi_test_clobber_d5);
CHECK_ABI_NO_UNWIND(abi_test_clobber_d6);
CHECK_ABI_NO_UNWIND(abi_test_clobber_d7);
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d8),
"d8 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d9),
"d9 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d10),
"d10 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d11),
"d11 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d12),
"d12 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d13),
"d13 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d14),
"d14 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d15),
"d15 was not restored after return");
}
#endif // OPENSSL_ARM && SUPPORTS_ABI_TEST
#if defined(OPENSSL_AARCH64) && defined(SUPPORTS_ABI_TEST)
extern "C" {
void abi_test_clobber_x0(void);
void abi_test_clobber_x1(void);
void abi_test_clobber_x2(void);
void abi_test_clobber_x3(void);
void abi_test_clobber_x4(void);
void abi_test_clobber_x5(void);
void abi_test_clobber_x6(void);
void abi_test_clobber_x7(void);
void abi_test_clobber_x8(void);
void abi_test_clobber_x9(void);
void abi_test_clobber_x10(void);
void abi_test_clobber_x11(void);
void abi_test_clobber_x12(void);
void abi_test_clobber_x13(void);
void abi_test_clobber_x14(void);
void abi_test_clobber_x15(void);
void abi_test_clobber_x16(void);
void abi_test_clobber_x17(void);
// x18 is the platform register and off limits.
void abi_test_clobber_x19(void);
void abi_test_clobber_x20(void);
void abi_test_clobber_x21(void);
void abi_test_clobber_x22(void);
void abi_test_clobber_x23(void);
void abi_test_clobber_x24(void);
void abi_test_clobber_x25(void);
void abi_test_clobber_x26(void);
void abi_test_clobber_x27(void);
void abi_test_clobber_x28(void);
void abi_test_clobber_x29(void);
void abi_test_clobber_d0(void);
void abi_test_clobber_d1(void);
void abi_test_clobber_d2(void);
void abi_test_clobber_d3(void);
void abi_test_clobber_d4(void);
void abi_test_clobber_d5(void);
void abi_test_clobber_d6(void);
void abi_test_clobber_d7(void);
void abi_test_clobber_d8(void);
void abi_test_clobber_d9(void);
void abi_test_clobber_d10(void);
void abi_test_clobber_d11(void);
void abi_test_clobber_d12(void);
void abi_test_clobber_d13(void);
void abi_test_clobber_d14(void);
void abi_test_clobber_d15(void);
void abi_test_clobber_d16(void);
void abi_test_clobber_d17(void);
void abi_test_clobber_d18(void);
void abi_test_clobber_d19(void);
void abi_test_clobber_d20(void);
void abi_test_clobber_d21(void);
void abi_test_clobber_d22(void);
void abi_test_clobber_d23(void);
void abi_test_clobber_d24(void);
void abi_test_clobber_d25(void);
void abi_test_clobber_d26(void);
void abi_test_clobber_d27(void);
void abi_test_clobber_d28(void);
void abi_test_clobber_d29(void);
void abi_test_clobber_d30(void);
void abi_test_clobber_d31(void);
void abi_test_clobber_v8_upper(void);
void abi_test_clobber_v9_upper(void);
void abi_test_clobber_v10_upper(void);
void abi_test_clobber_v11_upper(void);
void abi_test_clobber_v12_upper(void);
void abi_test_clobber_v13_upper(void);
void abi_test_clobber_v14_upper(void);
void abi_test_clobber_v15_upper(void);
} // extern "C"
TEST(ABITest, AArch64) {
// abi_test_trampoline hides unsaved registers from the caller, so we can
// safely call the abi_test_clobber_* functions below.
abi_test::internal::CallerState state;
RAND_bytes(reinterpret_cast<uint8_t *>(&state), sizeof(state));
CHECK_ABI_NO_UNWIND(abi_test_trampoline,
reinterpret_cast<crypto_word_t>(abi_test_clobber_x19),
&state, nullptr, 0, 0 /* no breakpoint */);
CHECK_ABI_NO_UNWIND(abi_test_clobber_x0);
CHECK_ABI_NO_UNWIND(abi_test_clobber_x1);
CHECK_ABI_NO_UNWIND(abi_test_clobber_x2);
CHECK_ABI_NO_UNWIND(abi_test_clobber_x3);
CHECK_ABI_NO_UNWIND(abi_test_clobber_x4);
CHECK_ABI_NO_UNWIND(abi_test_clobber_x5);
CHECK_ABI_NO_UNWIND(abi_test_clobber_x6);
CHECK_ABI_NO_UNWIND(abi_test_clobber_x7);
CHECK_ABI_NO_UNWIND(abi_test_clobber_x8);
CHECK_ABI_NO_UNWIND(abi_test_clobber_x9);
CHECK_ABI_NO_UNWIND(abi_test_clobber_x10);
CHECK_ABI_NO_UNWIND(abi_test_clobber_x11);
CHECK_ABI_NO_UNWIND(abi_test_clobber_x12);
CHECK_ABI_NO_UNWIND(abi_test_clobber_x13);
CHECK_ABI_NO_UNWIND(abi_test_clobber_x14);
CHECK_ABI_NO_UNWIND(abi_test_clobber_x15);
CHECK_ABI_NO_UNWIND(abi_test_clobber_x16);
CHECK_ABI_NO_UNWIND(abi_test_clobber_x17);
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_x19),
"x19 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_x20),
"x20 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_x21),
"x21 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_x22),
"x22 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_x23),
"x23 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_x24),
"x24 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_x25),
"x25 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_x26),
"x26 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_x27),
"x27 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_x28),
"x28 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_x29),
"x29 was not restored after return");
CHECK_ABI_NO_UNWIND(abi_test_clobber_d0);
CHECK_ABI_NO_UNWIND(abi_test_clobber_d1);
CHECK_ABI_NO_UNWIND(abi_test_clobber_d2);
CHECK_ABI_NO_UNWIND(abi_test_clobber_d3);
CHECK_ABI_NO_UNWIND(abi_test_clobber_d4);
CHECK_ABI_NO_UNWIND(abi_test_clobber_d5);
CHECK_ABI_NO_UNWIND(abi_test_clobber_d6);
CHECK_ABI_NO_UNWIND(abi_test_clobber_d7);
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d8),
"d8 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d9),
"d9 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d10),
"d10 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d11),
"d11 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d12),
"d12 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d13),
"d13 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d14),
"d14 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_d15),
"d15 was not restored after return");
CHECK_ABI_NO_UNWIND(abi_test_clobber_d16);
CHECK_ABI_NO_UNWIND(abi_test_clobber_d18);
CHECK_ABI_NO_UNWIND(abi_test_clobber_d19);
CHECK_ABI_NO_UNWIND(abi_test_clobber_d20);
CHECK_ABI_NO_UNWIND(abi_test_clobber_d21);
CHECK_ABI_NO_UNWIND(abi_test_clobber_d22);
CHECK_ABI_NO_UNWIND(abi_test_clobber_d23);
CHECK_ABI_NO_UNWIND(abi_test_clobber_d24);
CHECK_ABI_NO_UNWIND(abi_test_clobber_d25);
CHECK_ABI_NO_UNWIND(abi_test_clobber_d26);
CHECK_ABI_NO_UNWIND(abi_test_clobber_d27);
CHECK_ABI_NO_UNWIND(abi_test_clobber_d28);
CHECK_ABI_NO_UNWIND(abi_test_clobber_d29);
CHECK_ABI_NO_UNWIND(abi_test_clobber_d30);
CHECK_ABI_NO_UNWIND(abi_test_clobber_d31);
// The lower halves of v8-v15 (accessed as d8-d15) must be preserved, but not
// the upper halves.
CHECK_ABI_NO_UNWIND(abi_test_clobber_v8_upper);
CHECK_ABI_NO_UNWIND(abi_test_clobber_v9_upper);
CHECK_ABI_NO_UNWIND(abi_test_clobber_v10_upper);
CHECK_ABI_NO_UNWIND(abi_test_clobber_v11_upper);
CHECK_ABI_NO_UNWIND(abi_test_clobber_v12_upper);
CHECK_ABI_NO_UNWIND(abi_test_clobber_v13_upper);
CHECK_ABI_NO_UNWIND(abi_test_clobber_v14_upper);
CHECK_ABI_NO_UNWIND(abi_test_clobber_v15_upper);
}
#endif // OPENSSL_AARCH64 && SUPPORTS_ABI_TEST
#if defined(OPENSSL_PPC64LE) && defined(SUPPORTS_ABI_TEST)
extern "C" {
void abi_test_clobber_r0(void);
// r1 is the stack pointer.
void abi_test_clobber_r2(void);
void abi_test_clobber_r3(void);
void abi_test_clobber_r4(void);
void abi_test_clobber_r5(void);
void abi_test_clobber_r6(void);
void abi_test_clobber_r7(void);
void abi_test_clobber_r8(void);
void abi_test_clobber_r9(void);
void abi_test_clobber_r10(void);
void abi_test_clobber_r11(void);
void abi_test_clobber_r12(void);
// r13 is the thread pointer.
void abi_test_clobber_r14(void);
void abi_test_clobber_r15(void);
void abi_test_clobber_r16(void);
void abi_test_clobber_r17(void);
void abi_test_clobber_r18(void);
void abi_test_clobber_r19(void);
void abi_test_clobber_r20(void);
void abi_test_clobber_r21(void);
void abi_test_clobber_r22(void);
void abi_test_clobber_r23(void);
void abi_test_clobber_r24(void);
void abi_test_clobber_r25(void);
void abi_test_clobber_r26(void);
void abi_test_clobber_r27(void);
void abi_test_clobber_r28(void);
void abi_test_clobber_r29(void);
void abi_test_clobber_r30(void);
void abi_test_clobber_r31(void);
void abi_test_clobber_f0(void);
void abi_test_clobber_f1(void);
void abi_test_clobber_f2(void);
void abi_test_clobber_f3(void);
void abi_test_clobber_f4(void);
void abi_test_clobber_f5(void);
void abi_test_clobber_f6(void);
void abi_test_clobber_f7(void);
void abi_test_clobber_f8(void);
void abi_test_clobber_f9(void);
void abi_test_clobber_f10(void);
void abi_test_clobber_f11(void);
void abi_test_clobber_f12(void);
void abi_test_clobber_f13(void);
void abi_test_clobber_f14(void);
void abi_test_clobber_f15(void);
void abi_test_clobber_f16(void);
void abi_test_clobber_f17(void);
void abi_test_clobber_f18(void);
void abi_test_clobber_f19(void);
void abi_test_clobber_f20(void);
void abi_test_clobber_f21(void);
void abi_test_clobber_f22(void);
void abi_test_clobber_f23(void);
void abi_test_clobber_f24(void);
void abi_test_clobber_f25(void);
void abi_test_clobber_f26(void);
void abi_test_clobber_f27(void);
void abi_test_clobber_f28(void);
void abi_test_clobber_f29(void);
void abi_test_clobber_f30(void);
void abi_test_clobber_f31(void);
void abi_test_clobber_v0(void);
void abi_test_clobber_v1(void);
void abi_test_clobber_v2(void);
void abi_test_clobber_v3(void);
void abi_test_clobber_v4(void);
void abi_test_clobber_v5(void);
void abi_test_clobber_v6(void);
void abi_test_clobber_v7(void);
void abi_test_clobber_v8(void);
void abi_test_clobber_v9(void);
void abi_test_clobber_v10(void);
void abi_test_clobber_v11(void);
void abi_test_clobber_v12(void);
void abi_test_clobber_v13(void);
void abi_test_clobber_v14(void);
void abi_test_clobber_v15(void);
void abi_test_clobber_v16(void);
void abi_test_clobber_v17(void);
void abi_test_clobber_v18(void);
void abi_test_clobber_v19(void);
void abi_test_clobber_v20(void);
void abi_test_clobber_v21(void);
void abi_test_clobber_v22(void);
void abi_test_clobber_v23(void);
void abi_test_clobber_v24(void);
void abi_test_clobber_v25(void);
void abi_test_clobber_v26(void);
void abi_test_clobber_v27(void);
void abi_test_clobber_v28(void);
void abi_test_clobber_v29(void);
void abi_test_clobber_v30(void);
void abi_test_clobber_v31(void);
void abi_test_clobber_cr0(void);
void abi_test_clobber_cr1(void);
void abi_test_clobber_cr2(void);
void abi_test_clobber_cr3(void);
void abi_test_clobber_cr4(void);
void abi_test_clobber_cr5(void);
void abi_test_clobber_cr6(void);
void abi_test_clobber_cr7(void);
void abi_test_clobber_ctr(void);
void abi_test_clobber_lr(void);
} // extern "C"
TEST(ABITest, PPC64LE) {
// abi_test_trampoline hides unsaved registers from the caller, so we can
// safely call the abi_test_clobber_* functions below.
abi_test::internal::CallerState state;
RAND_bytes(reinterpret_cast<uint8_t *>(&state), sizeof(state));
CHECK_ABI_NO_UNWIND(abi_test_trampoline,
reinterpret_cast<crypto_word_t>(abi_test_clobber_r14),
&state, nullptr, 0, 0 /* no breakpoint */);
CHECK_ABI_NO_UNWIND(abi_test_clobber_r0);
CHECK_ABI_NO_UNWIND(abi_test_clobber_r2);
CHECK_ABI_NO_UNWIND(abi_test_clobber_r3);
CHECK_ABI_NO_UNWIND(abi_test_clobber_r4);
CHECK_ABI_NO_UNWIND(abi_test_clobber_r5);
CHECK_ABI_NO_UNWIND(abi_test_clobber_r6);
CHECK_ABI_NO_UNWIND(abi_test_clobber_r7);
CHECK_ABI_NO_UNWIND(abi_test_clobber_r8);
CHECK_ABI_NO_UNWIND(abi_test_clobber_r9);
CHECK_ABI_NO_UNWIND(abi_test_clobber_r10);
CHECK_ABI_NO_UNWIND(abi_test_clobber_r11);
CHECK_ABI_NO_UNWIND(abi_test_clobber_r12);
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r14),
"r14 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r15),
"r15 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r16),
"r16 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r17),
"r17 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r18),
"r18 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r19),
"r19 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r20),
"r20 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r21),
"r21 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r22),
"r22 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r23),
"r23 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r24),
"r24 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r25),
"r25 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r26),
"r26 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r27),
"r27 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r28),
"r28 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r29),
"r29 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r30),
"r30 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_r31),
"r31 was not restored after return");
CHECK_ABI_NO_UNWIND(abi_test_clobber_f0);
CHECK_ABI_NO_UNWIND(abi_test_clobber_f1);
CHECK_ABI_NO_UNWIND(abi_test_clobber_f2);
CHECK_ABI_NO_UNWIND(abi_test_clobber_f3);
CHECK_ABI_NO_UNWIND(abi_test_clobber_f4);
CHECK_ABI_NO_UNWIND(abi_test_clobber_f5);
CHECK_ABI_NO_UNWIND(abi_test_clobber_f6);
CHECK_ABI_NO_UNWIND(abi_test_clobber_f7);
CHECK_ABI_NO_UNWIND(abi_test_clobber_f8);
CHECK_ABI_NO_UNWIND(abi_test_clobber_f9);
CHECK_ABI_NO_UNWIND(abi_test_clobber_f10);
CHECK_ABI_NO_UNWIND(abi_test_clobber_f11);
CHECK_ABI_NO_UNWIND(abi_test_clobber_f12);
CHECK_ABI_NO_UNWIND(abi_test_clobber_f13);
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_f14),
"f14 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_f15),
"f15 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_f16),
"f16 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_f17),
"f17 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_f18),
"f18 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_f19),
"f19 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_f20),
"f20 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_f21),
"f21 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_f22),
"f22 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_f23),
"f23 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_f24),
"f24 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_f25),
"f25 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_f26),
"f26 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_f27),
"f27 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_f28),
"f28 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_f29),
"f29 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_f30),
"f30 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_f31),
"f31 was not restored after return");
CHECK_ABI_NO_UNWIND(abi_test_clobber_v0);
CHECK_ABI_NO_UNWIND(abi_test_clobber_v1);
CHECK_ABI_NO_UNWIND(abi_test_clobber_v2);
CHECK_ABI_NO_UNWIND(abi_test_clobber_v3);
CHECK_ABI_NO_UNWIND(abi_test_clobber_v4);
CHECK_ABI_NO_UNWIND(abi_test_clobber_v5);
CHECK_ABI_NO_UNWIND(abi_test_clobber_v6);
CHECK_ABI_NO_UNWIND(abi_test_clobber_v7);
CHECK_ABI_NO_UNWIND(abi_test_clobber_v8);
CHECK_ABI_NO_UNWIND(abi_test_clobber_v9);
CHECK_ABI_NO_UNWIND(abi_test_clobber_v10);
CHECK_ABI_NO_UNWIND(abi_test_clobber_v11);
CHECK_ABI_NO_UNWIND(abi_test_clobber_v12);
CHECK_ABI_NO_UNWIND(abi_test_clobber_v13);
CHECK_ABI_NO_UNWIND(abi_test_clobber_v14);
CHECK_ABI_NO_UNWIND(abi_test_clobber_v15);
CHECK_ABI_NO_UNWIND(abi_test_clobber_v16);
CHECK_ABI_NO_UNWIND(abi_test_clobber_v17);
CHECK_ABI_NO_UNWIND(abi_test_clobber_v18);
CHECK_ABI_NO_UNWIND(abi_test_clobber_v19);
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_v20),
"v20 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_v21),
"v21 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_v22),
"v22 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_v23),
"v23 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_v24),
"v24 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_v25),
"v25 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_v26),
"v26 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_v27),
"v27 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_v28),
"v28 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_v29),
"v29 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_v30),
"v30 was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_v31),
"v31 was not restored after return");
CHECK_ABI_NO_UNWIND(abi_test_clobber_cr0);
CHECK_ABI_NO_UNWIND(abi_test_clobber_cr1);
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_cr2),
"cr was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_cr3),
"cr was not restored after return");
EXPECT_NONFATAL_FAILURE(CHECK_ABI_NO_UNWIND(abi_test_clobber_cr4),
"cr was not restored after return");
CHECK_ABI_NO_UNWIND(abi_test_clobber_cr5);
CHECK_ABI_NO_UNWIND(abi_test_clobber_cr6);
CHECK_ABI_NO_UNWIND(abi_test_clobber_cr7);
CHECK_ABI_NO_UNWIND(abi_test_clobber_ctr);
CHECK_ABI_NO_UNWIND(abi_test_clobber_lr);
}
#endif // OPENSSL_PPC64LE && SUPPORTS_ABI_TEST
-38
View File
@@ -1,38 +0,0 @@
include_directories(../../include)
add_library(
asn1
OBJECT
a_bitstr.c
a_bool.c
a_d2i_fp.c
a_dup.c
a_enum.c
a_gentm.c
a_i2d_fp.c
a_int.c
a_mbstr.c
a_object.c
a_octet.c
a_print.c
a_strnid.c
a_time.c
a_type.c
a_utctm.c
a_utf8.c
asn1_lib.c
asn1_par.c
asn_pack.c
f_enum.c
f_int.c
f_string.c
tasn_dec.c
tasn_enc.c
tasn_fre.c
tasn_new.c
tasn_typ.c
tasn_utl.c
time_support.c
)
+10 -5
View File
@@ -56,6 +56,7 @@
#include <openssl/asn1.h>
#include <limits.h>
#include <string.h>
#include <openssl/err.h>
@@ -69,7 +70,7 @@ int ASN1_BIT_STRING_set(ASN1_BIT_STRING *x, unsigned char *d, int len)
return M_ASN1_BIT_STRING_set(x, d, len);
}
int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a, unsigned char **pp)
int i2c_ASN1_BIT_STRING(const ASN1_BIT_STRING *a, unsigned char **pp)
{
int ret, j, bits, len;
unsigned char *p, *d;
@@ -139,6 +140,11 @@ ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,
goto err;
}
if (len > INT_MAX) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_STRING_TOO_LONG);
goto err;
}
if ((a == NULL) || ((*a) == NULL)) {
if ((ret = M_ASN1_BIT_STRING_new()) == NULL)
return (NULL);
@@ -211,8 +217,7 @@ int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value)
if (a->data == NULL)
c = (unsigned char *)OPENSSL_malloc(w + 1);
else
c = (unsigned char *)OPENSSL_realloc_clean(a->data,
a->length, w + 1);
c = (unsigned char *)OPENSSL_realloc(a->data, w + 1);
if (c == NULL) {
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
return 0;
@@ -228,7 +233,7 @@ int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value)
return (1);
}
int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n)
int ASN1_BIT_STRING_get_bit(const ASN1_BIT_STRING *a, int n)
{
int w, v;
@@ -245,7 +250,7 @@ int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n)
* which is not specified in 'flags', 1 otherwise.
* 'len' is the length of 'flags'.
*/
int ASN1_BIT_STRING_check(ASN1_BIT_STRING *a,
int ASN1_BIT_STRING_check(const ASN1_BIT_STRING *a,
unsigned char *flags, int flags_len)
{
int i, ok;
+18 -5
View File
@@ -62,17 +62,30 @@
int i2d_ASN1_BOOLEAN(int a, unsigned char **pp)
{
int r;
unsigned char *p;
unsigned char *p, *allocated = NULL;
r = ASN1_object_size(0, 1, V_ASN1_BOOLEAN);
if (pp == NULL)
return (r);
p = *pp;
if (*pp == NULL) {
if ((p = allocated = OPENSSL_malloc(r)) == NULL) {
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
return 0;
}
} else {
p = *pp;
}
ASN1_put_object(&p, 0, 1, V_ASN1_BOOLEAN, V_ASN1_UNIVERSAL);
*(p++) = (unsigned char)a;
*pp = p;
return (r);
*p = (unsigned char)a;
/*
* If a new buffer was allocated, just return it back.
* If not, return the incremented buffer pointer.
*/
*pp = allocated != NULL ? allocated : p + 1;
return r;
}
int d2i_ASN1_BOOLEAN(int *a, const unsigned char **pp, long length)
+17 -221
View File
@@ -58,240 +58,36 @@
#include <limits.h>
#include <openssl/buf.h>
#include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/mem.h>
static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb);
#ifndef NO_OLD_ASN1
# ifndef OPENSSL_NO_FP_API
void *ASN1_d2i_fp(void *(*xnew) (void), d2i_of_void *d2i, FILE *in, void **x)
{
BIO *b;
void *ret;
if ((b = BIO_new(BIO_s_file())) == NULL) {
OPENSSL_PUT_ERROR(ASN1, ERR_R_BUF_LIB);
return (NULL);
}
BIO_set_fp(b, in, BIO_NOCLOSE);
ret = ASN1_d2i_bio(xnew, d2i, b, x);
BIO_free(b);
return (ret);
}
# endif
void *ASN1_d2i_bio(void *(*xnew) (void), d2i_of_void *d2i, BIO *in, void **x)
{
BUF_MEM *b = NULL;
const unsigned char *p;
void *ret = NULL;
int len;
len = asn1_d2i_read_bio(in, &b);
if (len < 0)
goto err;
p = (unsigned char *)b->data;
ret = d2i(x, &p, len);
err:
if (b != NULL)
BUF_MEM_free(b);
return (ret);
}
#endif
void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x)
{
BUF_MEM *b = NULL;
const unsigned char *p;
void *ret = NULL;
int len;
len = asn1_d2i_read_bio(in, &b);
if (len < 0)
goto err;
p = (const unsigned char *)b->data;
ret = ASN1_item_d2i(x, &p, len, it);
err:
if (b != NULL)
BUF_MEM_free(b);
return (ret);
uint8_t *data;
size_t len;
// Historically, this function did not impose a limit in OpenSSL and is used
// to read CRLs, so we leave this without an external bound.
if (!BIO_read_asn1(in, &data, &len, INT_MAX)) {
return NULL;
}
const uint8_t *ptr = data;
void *ret = ASN1_item_d2i(x, &ptr, len, it);
OPENSSL_free(data);
return ret;
}
#ifndef OPENSSL_NO_FP_API
void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x)
{
BIO *b;
char *ret;
if ((b = BIO_new(BIO_s_file())) == NULL) {
BIO *b = BIO_new_fp(in, BIO_NOCLOSE);
if (b == NULL) {
OPENSSL_PUT_ERROR(ASN1, ERR_R_BUF_LIB);
return (NULL);
return NULL;
}
BIO_set_fp(b, in, BIO_NOCLOSE);
ret = ASN1_item_d2i_bio(it, b, x);
void *ret = ASN1_item_d2i_bio(it, b, x);
BIO_free(b);
return (ret);
return ret;
}
#endif
typedef struct asn1_const_ctx_st
{
const unsigned char *p;/* work char pointer */
int eos; /* end of sequence read for indefinite encoding */
int error; /* error code to use when returning an error */
int inf; /* constructed if 0x20, indefinite is 0x21 */
int tag; /* tag from last 'get object' */
int xclass; /* class from last 'get object' */
long slen; /* length of last 'get object' */
const unsigned char *max; /* largest value of p allowed */
const unsigned char *q;/* temporary variable */
const unsigned char **pp;/* variable */
int line; /* used in error processing */
} ASN1_const_CTX;
#define HEADER_SIZE 8
#define ASN1_CHUNK_INITIAL_SIZE (16 * 1024)
static int asn1_d2i_read_bio(BIO *in, BUF_MEM **pb)
{
BUF_MEM *b;
unsigned char *p;
int i;
ASN1_const_CTX c;
size_t want = HEADER_SIZE;
int eos = 0;
size_t off = 0;
size_t len = 0;
b = BUF_MEM_new();
if (b == NULL) {
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
return -1;
}
ERR_clear_error();
for (;;) {
if (want >= (len - off)) {
want -= (len - off);
if (len + want < len || !BUF_MEM_grow_clean(b, len + want)) {
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
goto err;
}
i = BIO_read(in, &(b->data[len]), want);
if ((i < 0) && ((len - off) == 0)) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NOT_ENOUGH_DATA);
goto err;
}
if (i > 0) {
if (len + i < len) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_TOO_LONG);
goto err;
}
len += i;
}
}
/* else data already loaded */
p = (unsigned char *)&(b->data[off]);
c.p = p;
c.inf = ASN1_get_object(&(c.p), &(c.slen), &(c.tag), &(c.xclass),
len - off);
if (c.inf & 0x80) {
uint32_t e;
e = ERR_GET_REASON(ERR_peek_error());
if (e != ASN1_R_TOO_LONG)
goto err;
else
ERR_clear_error(); /* clear error */
}
i = c.p - p; /* header length */
off += i; /* end of data */
if (c.inf & 1) {
/* no data body so go round again */
eos++;
if (eos < 0) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_HEADER_TOO_LONG);
goto err;
}
want = HEADER_SIZE;
} else if (eos && (c.slen == 0) && (c.tag == V_ASN1_EOC)) {
/* eos value, so go back and read another header */
eos--;
if (eos <= 0)
break;
else
want = HEADER_SIZE;
} else {
/* suck in c.slen bytes of data */
want = c.slen;
if (want > (len - off)) {
size_t chunk_max = ASN1_CHUNK_INITIAL_SIZE;
want -= (len - off);
if (want > INT_MAX /* BIO_read takes an int length */ ||
len + want < len) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_TOO_LONG);
goto err;
}
while (want > 0) {
/*
* Read content in chunks of increasing size
* so we can return an error for EOF without
* having to allocate the entire content length
* in one go.
*/
size_t chunk = want > chunk_max ? chunk_max : want;
if (!BUF_MEM_grow_clean(b, len + chunk)) {
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
goto err;
}
want -= chunk;
while (chunk > 0) {
i = BIO_read(in, &(b->data[len]), chunk);
if (i <= 0) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NOT_ENOUGH_DATA);
goto err;
}
/*
* This can't overflow because |len+want| didn't
* overflow.
*/
len += i;
chunk -= i;
}
if (chunk_max < INT_MAX/2)
chunk_max *= 2;
}
}
if (off + c.slen < off) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_TOO_LONG);
goto err;
}
off += c.slen;
if (eos <= 0) {
break;
} else
want = HEADER_SIZE;
}
}
if (off > INT_MAX) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_TOO_LONG);
goto err;
}
*pb = b;
return off;
err:
if (b != NULL)
BUF_MEM_free(b);
return -1;
}
-24
View File
@@ -59,30 +59,6 @@
#include <openssl/err.h>
#include <openssl/mem.h>
void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, void *x)
{
unsigned char *b, *p;
const unsigned char *p2;
int i;
char *ret;
if (x == NULL)
return (NULL);
i = i2d(x, NULL);
b = OPENSSL_malloc(i + 10);
if (b == NULL) {
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
return (NULL);
}
p = b;
i = i2d(x, &p);
p2 = b;
ret = d2i(NULL, &p2, i);
OPENSSL_free(b);
return (ret);
}
/*
* ASN1_ITEM version of dup: this follows the model above except we don't
* need to allocate the buffer. At some point this could be rewritten to
+25 -14
View File
@@ -56,6 +56,7 @@
#include <openssl/asn1.h>
#include <limits.h>
#include <string.h>
#include <openssl/err.h>
@@ -107,10 +108,9 @@ int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v)
return (1);
}
long ASN1_ENUMERATED_get(ASN1_ENUMERATED *a)
long ASN1_ENUMERATED_get(const ASN1_ENUMERATED *a)
{
int neg = 0, i;
long r = 0;
if (a == NULL)
return (0L);
@@ -120,23 +120,34 @@ long ASN1_ENUMERATED_get(ASN1_ENUMERATED *a)
else if (i != V_ASN1_ENUMERATED)
return -1;
if (a->length > (int)sizeof(long)) {
/* hmm... a bit ugly */
return (0xffffffffL);
}
if (a->data == NULL)
return 0;
OPENSSL_STATIC_ASSERT(sizeof(uint64_t) >= sizeof(long),
"long larger than uint64_t");
for (i = 0; i < a->length; i++) {
r <<= 8;
r |= (unsigned char)a->data[i];
if (a->length > (int)sizeof(uint64_t)) {
/* hmm... a bit ugly */
return -1;
}
uint64_t r64 = 0;
if (a->data != NULL) {
for (i = 0; i < a->length; i++) {
r64 <<= 8;
r64 |= (unsigned char)a->data[i];
}
if (r64 > LONG_MAX) {
return -1;
}
}
long r = (long) r64;
if (neg)
r = -r;
return (r);
return r;
}
ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai)
ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(const BIGNUM *bn, ASN1_ENUMERATED *ai)
{
ASN1_ENUMERATED *ret;
int len, j;
@@ -172,7 +183,7 @@ ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai)
return (NULL);
}
BIGNUM *ASN1_ENUMERATED_to_BN(ASN1_ENUMERATED *ai, BIGNUM *bn)
BIGNUM *ASN1_ENUMERATED_to_BN(const ASN1_ENUMERATED *ai, BIGNUM *bn)
{
BIGNUM *ret;
+10 -69
View File
@@ -56,92 +56,33 @@
#include <openssl/asn1.h>
#include <openssl/bio.h>
#include <openssl/err.h>
#include <openssl/mem.h>
int ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, void *x)
{
BIO *b;
int ret;
if ((b = BIO_new(BIO_s_file())) == NULL) {
OPENSSL_PUT_ERROR(ASN1, ERR_R_BUF_LIB);
return (0);
}
BIO_set_fp(b, out, BIO_NOCLOSE);
ret = ASN1_i2d_bio(i2d, b, x);
BIO_free(b);
return (ret);
}
int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, void *x)
{
char *b;
unsigned char *p;
int i, j = 0, n, ret = 1;
n = i2d(x, NULL);
b = (char *)OPENSSL_malloc(n);
if (b == NULL) {
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
return (0);
}
p = (unsigned char *)b;
i2d(x, &p);
for (;;) {
i = BIO_write(out, &(b[j]), n);
if (i == n)
break;
if (i <= 0) {
ret = 0;
break;
}
j += i;
n -= i;
}
OPENSSL_free(b);
return (ret);
}
int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x)
{
BIO *b;
int ret;
if ((b = BIO_new(BIO_s_file())) == NULL) {
BIO *b = BIO_new_fp(out, BIO_NOCLOSE);
if (b == NULL) {
OPENSSL_PUT_ERROR(ASN1, ERR_R_BUF_LIB);
return (0);
return 0;
}
BIO_set_fp(b, out, BIO_NOCLOSE);
ret = ASN1_item_i2d_bio(it, b, x);
int ret = ASN1_item_i2d_bio(it, b, x);
BIO_free(b);
return (ret);
return ret;
}
int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x)
{
unsigned char *b = NULL;
int i, j = 0, n, ret = 1;
n = ASN1_item_i2d(x, &b, it);
int n = ASN1_item_i2d(x, &b, it);
if (b == NULL) {
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
return (0);
return 0;
}
for (;;) {
i = BIO_write(out, &(b[j]), n);
if (i == n)
break;
if (i <= 0) {
ret = 0;
break;
}
j += i;
n -= i;
}
int ret = BIO_write_all(out, b, n);
OPENSSL_free(b);
return (ret);
return ret;
}
+63 -106
View File
@@ -57,6 +57,7 @@
#include <openssl/asn1.h>
#include <string.h>
#include <limits.h>
#include <openssl/err.h>
#include <openssl/mem.h>
@@ -114,7 +115,7 @@ int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y)
* followed by optional zeros isn't padded.
*/
int i2c_ASN1_INTEGER(ASN1_INTEGER *a, unsigned char **pp)
int i2c_ASN1_INTEGER(const ASN1_INTEGER *a, unsigned char **pp)
{
int pad = 0, ret, i, neg;
unsigned char *p, *n, pb = 0;
@@ -194,6 +195,16 @@ ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp,
unsigned char *to, *s;
int i;
/*
* This function can handle lengths up to INT_MAX - 1, but the rest of the
* legacy ASN.1 code mixes integer types, so avoid exposing it to
* ASN1_INTEGERS with larger lengths.
*/
if (len < 0 || len > INT_MAX / 2) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_TOO_LONG);
return NULL;
}
if ((a == NULL) || ((*a) == NULL)) {
if ((ret = M_ASN1_INTEGER_new()) == NULL)
return (NULL);
@@ -275,117 +286,52 @@ ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp,
return (NULL);
}
/*
* This is a version of d2i_ASN1_INTEGER that ignores the sign bit of ASN1
* integers: some broken software can encode a positive INTEGER with its MSB
* set as negative (it doesn't add a padding zero).
*/
ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp,
long length)
{
ASN1_INTEGER *ret = NULL;
const unsigned char *p;
unsigned char *s;
long len;
int inf, tag, xclass;
int i;
if ((a == NULL) || ((*a) == NULL)) {
if ((ret = M_ASN1_INTEGER_new()) == NULL)
return (NULL);
ret->type = V_ASN1_INTEGER;
} else
ret = (*a);
p = *pp;
inf = ASN1_get_object(&p, &len, &tag, &xclass, length);
if (inf & 0x80) {
i = ASN1_R_BAD_OBJECT_HEADER;
goto err;
}
if (tag != V_ASN1_INTEGER) {
i = ASN1_R_EXPECTING_AN_INTEGER;
goto err;
}
/*
* We must OPENSSL_malloc stuff, even for 0 bytes otherwise it signifies
* a missing NULL parameter.
*/
s = (unsigned char *)OPENSSL_malloc((int)len + 1);
if (s == NULL) {
i = ERR_R_MALLOC_FAILURE;
goto err;
}
ret->type = V_ASN1_INTEGER;
if (len) {
if ((*p == 0) && (len != 1)) {
p++;
len--;
}
OPENSSL_memcpy(s, p, (int)len);
p += len;
}
if (ret->data != NULL)
OPENSSL_free(ret->data);
ret->data = s;
ret->length = (int)len;
if (a != NULL)
(*a) = ret;
*pp = p;
return (ret);
err:
OPENSSL_PUT_ERROR(ASN1, i);
if ((ret != NULL) && ((a == NULL) || (*a != ret)))
M_ASN1_INTEGER_free(ret);
return (NULL);
}
int ASN1_INTEGER_set(ASN1_INTEGER *a, long v)
{
int j, k;
unsigned int i;
unsigned char buf[sizeof(long) + 1];
long d;
a->type = V_ASN1_INTEGER;
if (a->length < (int)(sizeof(long) + 1)) {
if (a->data != NULL)
OPENSSL_free(a->data);
if ((a->data =
(unsigned char *)OPENSSL_malloc(sizeof(long) + 1)) != NULL)
OPENSSL_memset((char *)a->data, 0, sizeof(long) + 1);
if (v >= 0) {
return ASN1_INTEGER_set_uint64(a, (uint64_t) v);
}
if (a->data == NULL) {
if (!ASN1_INTEGER_set_uint64(a, 0 - (uint64_t) v)) {
return 0;
}
a->type = V_ASN1_NEG_INTEGER;
return 1;
}
int ASN1_INTEGER_set_uint64(ASN1_INTEGER *out, uint64_t v)
{
uint8_t *const newdata = OPENSSL_malloc(sizeof(uint64_t));
if (newdata == NULL) {
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
return (0);
}
d = v;
if (d < 0) {
d = -d;
a->type = V_ASN1_NEG_INTEGER;
return 0;
}
for (i = 0; i < sizeof(long); i++) {
if (d == 0)
OPENSSL_free(out->data);
out->data = newdata;
v = CRYPTO_bswap8(v);
memcpy(out->data, &v, sizeof(v));
out->type = V_ASN1_INTEGER;
size_t leading_zeros;
for (leading_zeros = 0; leading_zeros < sizeof(uint64_t) - 1;
leading_zeros++) {
if (out->data[leading_zeros] != 0) {
break;
buf[i] = (int)d & 0xff;
d >>= 8;
}
}
j = 0;
for (k = i - 1; k >= 0; k--)
a->data[j++] = buf[k];
a->length = j;
return (1);
out->length = sizeof(uint64_t) - leading_zeros;
OPENSSL_memmove(out->data, out->data + leading_zeros, out->length);
return 1;
}
long ASN1_INTEGER_get(const ASN1_INTEGER *a)
{
int neg = 0, i;
long r = 0;
if (a == NULL)
return (0L);
@@ -395,20 +341,31 @@ long ASN1_INTEGER_get(const ASN1_INTEGER *a)
else if (i != V_ASN1_INTEGER)
return -1;
if (a->length > (int)sizeof(long)) {
OPENSSL_STATIC_ASSERT(sizeof(uint64_t) >= sizeof(long),
"long larger than uint64_t");
if (a->length > (int)sizeof(uint64_t)) {
/* hmm... a bit ugly, return all ones */
return -1;
}
if (a->data == NULL)
return 0;
for (i = 0; i < a->length; i++) {
r <<= 8;
r |= (unsigned char)a->data[i];
uint64_t r64 = 0;
if (a->data != NULL) {
for (i = 0; i < a->length; i++) {
r64 <<= 8;
r64 |= (unsigned char)a->data[i];
}
if (r64 > LONG_MAX) {
return -1;
}
}
long r = (long) r64;
if (neg)
r = -r;
return (r);
return r;
}
ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai)
+115 -219
View File
@@ -56,22 +56,17 @@
#include <openssl/asn1.h>
#include <limits.h>
#include <string.h>
#include <openssl/bytestring.h>
#include <openssl/err.h>
#include <openssl/mem.h>
static int traverse_string(const unsigned char *p, int len, int inform,
int (*rfunc) (unsigned long value, void *in),
void *arg);
static int in_utf8(unsigned long value, void *arg);
static int out_utf8(unsigned long value, void *arg);
static int type_str(unsigned long value, void *arg);
static int cpy_asc(unsigned long value, void *arg);
static int cpy_bmp(unsigned long value, void *arg);
static int cpy_univ(unsigned long value, void *arg);
static int cpy_utf8(unsigned long value, void *arg);
static int is_printable(unsigned long value);
#include "asn1_locl.h"
#include "../bytestring/internal.h"
static int is_printable(uint32_t value);
/*
* These functions take a string in UTF8, ASCII or multibyte form and a mask
@@ -88,55 +83,45 @@ int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len,
return ASN1_mbstring_ncopy(out, in, len, inform, mask, 0, 0);
}
OPENSSL_DECLARE_ERROR_REASON(ASN1, INVALID_BMPSTRING)
OPENSSL_DECLARE_ERROR_REASON(ASN1, INVALID_UNIVERSALSTRING)
OPENSSL_DECLARE_ERROR_REASON(ASN1, INVALID_UTF8STRING)
int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
int inform, unsigned long mask,
long minsize, long maxsize)
{
int str_type;
int ret;
char free_out;
int outform, outlen = 0;
ASN1_STRING *dest;
unsigned char *p;
int nchar;
size_t nchar = 0;
char strbuf[32];
int (*cpyfunc) (unsigned long, void *) = NULL;
if (len == -1)
len = strlen((const char *)in);
if (!mask)
mask = DIRSTRING_TYPE;
/* First do a string check and work out the number of characters */
int (*decode_func)(CBS *, uint32_t*);
int error;
switch (inform) {
case MBSTRING_BMP:
if (len & 1) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_BMPSTRING_LENGTH);
return -1;
}
nchar = len >> 1;
decode_func = cbs_get_ucs2_be;
error = ASN1_R_INVALID_BMPSTRING;
break;
case MBSTRING_UNIV:
if (len & 3) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_UNIVERSALSTRING_LENGTH);
return -1;
}
nchar = len >> 2;
decode_func = cbs_get_utf32_be;
error = ASN1_R_INVALID_UNIVERSALSTRING;
break;
case MBSTRING_UTF8:
nchar = 0;
/* This counts the characters and does utf8 syntax checking */
ret = traverse_string(in, len, MBSTRING_UTF8, in_utf8, &nchar);
if (ret < 0) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_UTF8STRING);
return -1;
}
decode_func = cbs_get_utf8;
error = ASN1_R_INVALID_UTF8STRING;
break;
case MBSTRING_ASC:
nchar = len;
decode_func = cbs_get_latin1;
error = ERR_R_INTERNAL_ERROR; // Latin-1 inputs are never invalid.
break;
default:
@@ -144,44 +129,92 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
return -1;
}
if ((minsize > 0) && (nchar < minsize)) {
/* Check |minsize| and |maxsize| and work out the minimal type, if any. */
CBS cbs;
CBS_init(&cbs, in, len);
size_t utf8_len = 0;
while (CBS_len(&cbs) != 0) {
uint32_t c;
if (!decode_func(&cbs, &c)) {
OPENSSL_PUT_ERROR(ASN1, error);
return -1;
}
if (nchar == 0 &&
(inform == MBSTRING_BMP || inform == MBSTRING_UNIV) &&
c == 0xfeff) {
/* Reject byte-order mark. We could drop it but that would mean
* adding ambiguity around whether a BOM was included or not when
* matching strings.
*
* For a little-endian UCS-2 string, the BOM will appear as 0xfffe
* and will be rejected as noncharacter, below. */
OPENSSL_PUT_ERROR(ASN1, ASN1_R_ILLEGAL_CHARACTERS);
return -1;
}
/* Update which output formats are still possible. */
if ((mask & B_ASN1_PRINTABLESTRING) && !is_printable(c)) {
mask &= ~B_ASN1_PRINTABLESTRING;
}
if ((mask & B_ASN1_IA5STRING) && (c > 127)) {
mask &= ~B_ASN1_IA5STRING;
}
if ((mask & B_ASN1_T61STRING) && (c > 0xff)) {
mask &= ~B_ASN1_T61STRING;
}
if ((mask & B_ASN1_BMPSTRING) && (c > 0xffff)) {
mask &= ~B_ASN1_BMPSTRING;
}
if (!mask) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_ILLEGAL_CHARACTERS);
return -1;
}
nchar++;
utf8_len += cbb_get_utf8_len(c);
}
if (minsize > 0 && nchar < (size_t)minsize) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_STRING_TOO_SHORT);
BIO_snprintf(strbuf, sizeof strbuf, "%ld", minsize);
ERR_add_error_data(2, "minsize=", strbuf);
return -1;
}
if ((maxsize > 0) && (nchar > maxsize)) {
if (maxsize > 0 && nchar > (size_t)maxsize) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_STRING_TOO_LONG);
BIO_snprintf(strbuf, sizeof strbuf, "%ld", maxsize);
ERR_add_error_data(2, "maxsize=", strbuf);
return -1;
}
/* Now work out minimal type (if any) */
if (traverse_string(in, len, inform, type_str, &mask) < 0) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_ILLEGAL_CHARACTERS);
return -1;
}
/* Now work out output format and string type */
outform = MBSTRING_ASC;
if (mask & B_ASN1_PRINTABLESTRING)
int (*encode_func)(CBB *, uint32_t) = cbb_add_latin1;
size_t size_estimate = nchar;
int outform = MBSTRING_ASC;
if (mask & B_ASN1_PRINTABLESTRING) {
str_type = V_ASN1_PRINTABLESTRING;
else if (mask & B_ASN1_IA5STRING)
} else if (mask & B_ASN1_IA5STRING) {
str_type = V_ASN1_IA5STRING;
else if (mask & B_ASN1_T61STRING)
} else if (mask & B_ASN1_T61STRING) {
str_type = V_ASN1_T61STRING;
else if (mask & B_ASN1_BMPSTRING) {
} else if (mask & B_ASN1_BMPSTRING) {
str_type = V_ASN1_BMPSTRING;
outform = MBSTRING_BMP;
encode_func = cbb_add_ucs2_be;
size_estimate = 2 * nchar;
} else if (mask & B_ASN1_UNIVERSALSTRING) {
str_type = V_ASN1_UNIVERSALSTRING;
encode_func = cbb_add_utf32_be;
size_estimate = 4 * nchar;
outform = MBSTRING_UNIV;
} else {
str_type = V_ASN1_UTF8STRING;
outform = MBSTRING_UTF8;
encode_func = cbb_add_utf8;
size_estimate = utf8_len;
}
if (!out)
return str_type;
if (*out) {
@@ -202,6 +235,7 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
}
*out = dest;
}
/* If both the same type just copy across */
if (inform == outform) {
if (!ASN1_STRING_set(dest, in, len)) {
@@ -211,183 +245,45 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
return str_type;
}
/* Work out how much space the destination will need */
switch (outform) {
case MBSTRING_ASC:
outlen = nchar;
cpyfunc = cpy_asc;
break;
case MBSTRING_BMP:
outlen = nchar << 1;
cpyfunc = cpy_bmp;
break;
case MBSTRING_UNIV:
outlen = nchar << 2;
cpyfunc = cpy_univ;
break;
case MBSTRING_UTF8:
outlen = 0;
traverse_string(in, len, inform, out_utf8, &outlen);
cpyfunc = cpy_utf8;
break;
}
if (!(p = OPENSSL_malloc(outlen + 1))) {
if (free_out)
ASN1_STRING_free(dest);
CBB cbb;
if (!CBB_init(&cbb, size_estimate + 1)) {
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
return -1;
goto err;
}
dest->length = outlen;
dest->data = p;
p[outlen] = 0;
traverse_string(in, len, inform, cpyfunc, &p);
CBS_init(&cbs, in, len);
while (CBS_len(&cbs) != 0) {
uint32_t c;
if (!decode_func(&cbs, &c) ||
!encode_func(&cbb, c)) {
OPENSSL_PUT_ERROR(ASN1, ERR_R_INTERNAL_ERROR);
goto err;
}
}
uint8_t *data = NULL;
size_t data_len;
if (/* OpenSSL historically NUL-terminated this value with a single byte,
* even for |MBSTRING_BMP| and |MBSTRING_UNIV|. */
!CBB_add_u8(&cbb, 0) ||
!CBB_finish(&cbb, &data, &data_len) ||
data_len < 1 ||
data_len > INT_MAX) {
OPENSSL_PUT_ERROR(ASN1, ERR_R_INTERNAL_ERROR);
OPENSSL_free(data);
goto err;
}
dest->length = (int)(data_len - 1);
dest->data = data;
return str_type;
}
/*
* This function traverses a string and passes the value of each character to
* an optional function along with a void * argument.
*/
static int traverse_string(const unsigned char *p, int len, int inform,
int (*rfunc) (unsigned long value, void *in),
void *arg)
{
unsigned long value;
int ret;
while (len) {
if (inform == MBSTRING_ASC) {
value = *p++;
len--;
} else if (inform == MBSTRING_BMP) {
value = *p++ << 8;
value |= *p++;
len -= 2;
} else if (inform == MBSTRING_UNIV) {
value = ((unsigned long)*p++) << 24;
value |= ((unsigned long)*p++) << 16;
value |= *p++ << 8;
value |= *p++;
len -= 4;
} else {
ret = UTF8_getc(p, len, &value);
if (ret < 0)
return -1;
len -= ret;
p += ret;
}
if (rfunc) {
ret = rfunc(value, arg);
if (ret <= 0)
return ret;
}
}
return 1;
}
/* Various utility functions for traverse_string */
/* Just count number of characters */
static int in_utf8(unsigned long value, void *arg)
{
int *nchar;
nchar = arg;
(*nchar)++;
return 1;
}
/* Determine size of output as a UTF8 String */
static int out_utf8(unsigned long value, void *arg)
{
int *outlen;
outlen = arg;
*outlen += UTF8_putc(NULL, -1, value);
return 1;
}
/*
* Determine the "type" of a string: check each character against a supplied
* "mask".
*/
static int type_str(unsigned long value, void *arg)
{
unsigned long types;
types = *((unsigned long *)arg);
if ((types & B_ASN1_PRINTABLESTRING) && !is_printable(value))
types &= ~B_ASN1_PRINTABLESTRING;
if ((types & B_ASN1_IA5STRING) && (value > 127))
types &= ~B_ASN1_IA5STRING;
if ((types & B_ASN1_T61STRING) && (value > 0xff))
types &= ~B_ASN1_T61STRING;
if ((types & B_ASN1_BMPSTRING) && (value > 0xffff))
types &= ~B_ASN1_BMPSTRING;
if (!types)
return -1;
*((unsigned long *)arg) = types;
return 1;
}
/* Copy one byte per character ASCII like strings */
static int cpy_asc(unsigned long value, void *arg)
{
unsigned char **p, *q;
p = arg;
q = *p;
*q = (unsigned char)value;
(*p)++;
return 1;
}
/* Copy two byte per character BMPStrings */
static int cpy_bmp(unsigned long value, void *arg)
{
unsigned char **p, *q;
p = arg;
q = *p;
*q++ = (unsigned char)((value >> 8) & 0xff);
*q = (unsigned char)(value & 0xff);
*p += 2;
return 1;
}
/* Copy four byte per character UniversalStrings */
static int cpy_univ(unsigned long value, void *arg)
{
unsigned char **p, *q;
p = arg;
q = *p;
*q++ = (unsigned char)((value >> 24) & 0xff);
*q++ = (unsigned char)((value >> 16) & 0xff);
*q++ = (unsigned char)((value >> 8) & 0xff);
*q = (unsigned char)(value & 0xff);
*p += 4;
return 1;
}
/* Copy to a UTF8String */
static int cpy_utf8(unsigned long value, void *arg)
{
unsigned char **p;
int ret;
p = arg;
/* We already know there is enough room so pass 0xff as the length */
ret = UTF8_putc(*p, 0xff, value);
*p += ret;
return 1;
err:
if (free_out)
ASN1_STRING_free(dest);
CBB_cleanup(&cbb);
return -1;
}
/* Return 1 if the character is permitted in a PrintableString */
static int is_printable(unsigned long value)
static int is_printable(uint32_t value)
{
int ch;
if (value > 0x7f)
+19 -136
View File
@@ -66,9 +66,9 @@
#include "../internal.h"
int i2d_ASN1_OBJECT(ASN1_OBJECT *a, unsigned char **pp)
int i2d_ASN1_OBJECT(const ASN1_OBJECT *a, unsigned char **pp)
{
unsigned char *p;
unsigned char *p, *allocated = NULL;
int objsize;
if ((a == NULL) || (a->data == NULL))
@@ -78,149 +78,32 @@ int i2d_ASN1_OBJECT(ASN1_OBJECT *a, unsigned char **pp)
if (pp == NULL || objsize == -1)
return objsize;
p = *pp;
if (*pp == NULL) {
if ((p = allocated = OPENSSL_malloc(objsize)) == NULL) {
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
return 0;
}
} else {
p = *pp;
}
ASN1_put_object(&p, 0, a->length, V_ASN1_OBJECT, V_ASN1_UNIVERSAL);
OPENSSL_memcpy(p, a->data, a->length);
p += a->length;
*pp = p;
return (objsize);
/*
* If a new buffer was allocated, just return it back.
* If not, return the incremented buffer pointer.
*/
*pp = allocated != NULL ? allocated : p + a->length;
return objsize;
}
int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num)
{
int i, first, len = 0, c, use_bn;
char ftmp[24], *tmp = ftmp;
int tmpsize = sizeof ftmp;
const char *p;
unsigned long l;
BIGNUM *bl = NULL;
if (num == 0)
return (0);
else if (num == -1)
num = strlen(buf);
p = buf;
c = *(p++);
num--;
if ((c >= '0') && (c <= '2')) {
first = c - '0';
} else {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_FIRST_NUM_TOO_LARGE);
goto err;
}
if (num <= 0) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_MISSING_SECOND_NUMBER);
goto err;
}
c = *(p++);
num--;
for (;;) {
if (num <= 0)
break;
if ((c != '.') && (c != ' ')) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_SEPARATOR);
goto err;
}
l = 0;
use_bn = 0;
for (;;) {
if (num <= 0)
break;
num--;
c = *(p++);
if ((c == ' ') || (c == '.'))
break;
if ((c < '0') || (c > '9')) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_INVALID_DIGIT);
goto err;
}
if (!use_bn && l >= ((ULONG_MAX - 80) / 10L)) {
use_bn = 1;
if (!bl)
bl = BN_new();
if (!bl || !BN_set_word(bl, l))
goto err;
}
if (use_bn) {
if (!BN_mul_word(bl, 10L)
|| !BN_add_word(bl, c - '0'))
goto err;
} else
l = l * 10L + (long)(c - '0');
}
if (len == 0) {
if ((first < 2) && (l >= 40)) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_SECOND_NUMBER_TOO_LARGE);
goto err;
}
if (use_bn) {
if (!BN_add_word(bl, first * 40))
goto err;
} else
l += (long)first *40;
}
i = 0;
if (use_bn) {
int blsize;
blsize = BN_num_bits(bl);
blsize = (blsize + 6) / 7;
if (blsize > tmpsize) {
if (tmp != ftmp)
OPENSSL_free(tmp);
tmpsize = blsize + 32;
tmp = OPENSSL_malloc(tmpsize);
if (!tmp)
goto err;
}
while (blsize--) {
BN_ULONG t = BN_div_word(bl, 0x80L);
if (t == (BN_ULONG)-1)
goto err;
tmp[i++] = (unsigned char)t;
}
} else {
for (;;) {
tmp[i++] = (unsigned char)l & 0x7f;
l >>= 7L;
if (l == 0L)
break;
}
}
if (out != NULL) {
if (len + i > olen) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_BUFFER_TOO_SMALL);
goto err;
}
while (--i > 0)
out[len++] = tmp[i] | 0x80;
out[len++] = tmp[0];
} else
len += i;
}
if (tmp != ftmp)
OPENSSL_free(tmp);
if (bl)
BN_free(bl);
return (len);
err:
if (tmp != ftmp)
OPENSSL_free(tmp);
if (bl)
BN_free(bl);
return (0);
}
int i2t_ASN1_OBJECT(char *buf, int buf_len, ASN1_OBJECT *a)
int i2t_ASN1_OBJECT(char *buf, int buf_len, const ASN1_OBJECT *a)
{
return OBJ_obj2txt(buf, buf_len, a, 0);
}
int i2a_ASN1_OBJECT(BIO *bp, ASN1_OBJECT *a)
int i2a_ASN1_OBJECT(BIO *bp, const ASN1_OBJECT *a)
{
char buf[80], *p = buf;
int i;
+1
View File
@@ -223,6 +223,7 @@ ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid)
return ttmp;
if (!stable)
return NULL;
sk_ASN1_STRING_TABLE_sort(stable);
found = sk_ASN1_STRING_TABLE_find(stable, &idx, &fnd);
if (!found)
return NULL;
+5 -6
View File
@@ -60,7 +60,6 @@
#include <time.h>
#include <openssl/asn1t.h>
#include <openssl/buf.h>
#include <openssl/err.h>
#include <openssl/mem.h>
@@ -101,7 +100,7 @@ ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t,
return ASN1_GENERALIZEDTIME_adj(s, t, offset_day, offset_sec);
}
int ASN1_TIME_check(ASN1_TIME *t)
int ASN1_TIME_check(const ASN1_TIME *t)
{
if (t->type == V_ASN1_GENERALIZEDTIME)
return ASN1_GENERALIZEDTIME_check(t);
@@ -111,7 +110,7 @@ int ASN1_TIME_check(ASN1_TIME *t)
}
/* Convert an ASN1_TIME structure to GeneralizedTime */
ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t,
ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(const ASN1_TIME *t,
ASN1_GENERALIZEDTIME **out)
{
ASN1_GENERALIZEDTIME *ret = NULL;
@@ -143,11 +142,11 @@ ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t,
str = (char *)ret->data;
/* Work out the century and prepend */
if (t->data[0] >= '5')
BUF_strlcpy(str, "19", newlen);
OPENSSL_strlcpy(str, "19", newlen);
else
BUF_strlcpy(str, "20", newlen);
OPENSSL_strlcpy(str, "20", newlen);
BUF_strlcat(str, (char *)t->data, newlen);
OPENSSL_strlcat(str, (char *)t->data, newlen);
done:
if (out != NULL && *out == NULL)
+1 -1
View File
@@ -61,7 +61,7 @@
#include <openssl/mem.h>
#include <openssl/obj.h>
int ASN1_TYPE_get(ASN1_TYPE *a)
int ASN1_TYPE_get(const ASN1_TYPE *a)
{
if ((a->value.ptr != NULL) || (a->type == V_ASN1_NULL))
return (a->type);
+13 -11
View File
@@ -59,6 +59,8 @@
#include <openssl/err.h>
#include <openssl/mem.h>
#include "asn1_locl.h"
/* UTF8 utilities */
/*
@@ -70,10 +72,10 @@
* incorrectly (not minimal length).
*/
int UTF8_getc(const unsigned char *str, int len, unsigned long *val)
int UTF8_getc(const unsigned char *str, int len, uint32_t *val)
{
const unsigned char *p;
unsigned long value;
uint32_t value;
int ret;
if (len <= 0)
return 0;
@@ -112,7 +114,7 @@ int UTF8_getc(const unsigned char *str, int len, unsigned long *val)
|| ((p[2] & 0xc0) != 0x80)
|| ((p[3] & 0xc0) != 0x80))
return -3;
value = ((unsigned long)(*p++ & 0x7)) << 18;
value = ((uint32_t)(*p++ & 0x7)) << 18;
value |= (*p++ & 0x3f) << 12;
value |= (*p++ & 0x3f) << 6;
value |= *p++ & 0x3f;
@@ -127,9 +129,9 @@ int UTF8_getc(const unsigned char *str, int len, unsigned long *val)
|| ((p[3] & 0xc0) != 0x80)
|| ((p[4] & 0xc0) != 0x80))
return -3;
value = ((unsigned long)(*p++ & 0x3)) << 24;
value |= ((unsigned long)(*p++ & 0x3f)) << 18;
value |= ((unsigned long)(*p++ & 0x3f)) << 12;
value = ((uint32_t)(*p++ & 0x3)) << 24;
value |= ((uint32_t)(*p++ & 0x3f)) << 18;
value |= ((uint32_t)(*p++ & 0x3f)) << 12;
value |= (*p++ & 0x3f) << 6;
value |= *p++ & 0x3f;
if (value < 0x200000)
@@ -144,10 +146,10 @@ int UTF8_getc(const unsigned char *str, int len, unsigned long *val)
|| ((p[4] & 0xc0) != 0x80)
|| ((p[5] & 0xc0) != 0x80))
return -3;
value = ((unsigned long)(*p++ & 0x1)) << 30;
value |= ((unsigned long)(*p++ & 0x3f)) << 24;
value |= ((unsigned long)(*p++ & 0x3f)) << 18;
value |= ((unsigned long)(*p++ & 0x3f)) << 12;
value = ((uint32_t)(*p++ & 0x1)) << 30;
value |= ((uint32_t)(*p++ & 0x3f)) << 24;
value |= ((uint32_t)(*p++ & 0x3f)) << 18;
value |= ((uint32_t)(*p++ & 0x3f)) << 12;
value |= (*p++ & 0x3f) << 6;
value |= *p++ & 0x3f;
if (value < 0x4000000)
@@ -167,7 +169,7 @@ int UTF8_getc(const unsigned char *str, int len, unsigned long *val)
* most 6 characters.
*/
int UTF8_putc(unsigned char *str, int len, unsigned long value)
int UTF8_putc(unsigned char *str, int len, uint32_t value)
{
if (!str)
len = 6; /* Maximum we will need */
+11 -2
View File
@@ -205,7 +205,11 @@ static int asn1_get_length(const unsigned char **pp, int *inf, long *rl,
} else
ret = i;
}
if (ret > LONG_MAX)
/*
* Bound the length to comfortably fit in an int. Lengths in this module
* often switch between int and long without overflow checks.
*/
if (ret > INT_MAX / 2)
return 0;
*pp = p;
*rl = (long)ret;
@@ -426,7 +430,7 @@ void ASN1_STRING_length_set(ASN1_STRING *x, int len)
return;
}
int ASN1_STRING_type(ASN1_STRING *x)
int ASN1_STRING_type(const ASN1_STRING *x)
{
return M_ASN1_STRING_type(x);
}
@@ -435,3 +439,8 @@ unsigned char *ASN1_STRING_data(ASN1_STRING *x)
{
return M_ASN1_STRING_data(x);
}
const unsigned char *ASN1_STRING_get0_data(const ASN1_STRING *x)
{
return x->data;
}
+6
View File
@@ -90,6 +90,12 @@ int OPENSSL_gmtime_diff(int *out_days, int *out_secs, const struct tm *from,
int asn1_utctime_to_tm(struct tm *tm, const ASN1_UTCTIME *d);
int asn1_generalizedtime_to_tm(struct tm *tm, const ASN1_GENERALIZEDTIME *d);
void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it,
int combine);
int UTF8_getc(const unsigned char *str, int len, uint32_t *val);
int UTF8_putc(unsigned char *str, int len, uint32_t value);
#if defined(__cplusplus)
} /* extern C */
+124
View File
@@ -12,12 +12,20 @@
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
#include <limits.h>
#include <stdio.h>
#include <vector>
#include <gtest/gtest.h>
#include <openssl/asn1.h>
#include <openssl/asn1t.h>
#include <openssl/bytestring.h>
#include <openssl/err.h>
#include <openssl/mem.h>
#include <openssl/obj.h>
#include <openssl/span.h>
#include "../test/test_util.h"
@@ -60,3 +68,119 @@ TEST(ASN1Test, LargeTags) {
EXPECT_EQ(Bytes(&kZero, 1), Bytes(obj->value.asn1_string->data,
obj->value.asn1_string->length));
}
TEST(ASN1Test, IntegerSetting) {
bssl::UniquePtr<ASN1_INTEGER> by_bn(M_ASN1_INTEGER_new());
bssl::UniquePtr<ASN1_INTEGER> by_long(M_ASN1_INTEGER_new());
bssl::UniquePtr<ASN1_INTEGER> by_uint64(M_ASN1_INTEGER_new());
bssl::UniquePtr<BIGNUM> bn(BN_new());
const std::vector<int64_t> kValues = {
LONG_MIN, -2, -1, 0, 1, 2, 0xff, 0x100, 0xffff, 0x10000, LONG_MAX,
};
for (const auto &i : kValues) {
SCOPED_TRACE(i);
ASSERT_EQ(1, ASN1_INTEGER_set(by_long.get(), i));
const uint64_t abs = i < 0 ? (0 - (uint64_t) i) : i;
ASSERT_TRUE(BN_set_u64(bn.get(), abs));
BN_set_negative(bn.get(), i < 0);
ASSERT_TRUE(BN_to_ASN1_INTEGER(bn.get(), by_bn.get()));
EXPECT_EQ(0, ASN1_INTEGER_cmp(by_bn.get(), by_long.get()));
if (i >= 0) {
ASSERT_EQ(1, ASN1_INTEGER_set_uint64(by_uint64.get(), i));
EXPECT_EQ(0, ASN1_INTEGER_cmp(by_bn.get(), by_uint64.get()));
}
}
}
typedef struct asn1_linked_list_st {
struct asn1_linked_list_st *next;
} ASN1_LINKED_LIST;
DECLARE_ASN1_ITEM(ASN1_LINKED_LIST)
DECLARE_ASN1_FUNCTIONS(ASN1_LINKED_LIST)
ASN1_SEQUENCE(ASN1_LINKED_LIST) = {
ASN1_OPT(ASN1_LINKED_LIST, next, ASN1_LINKED_LIST),
} ASN1_SEQUENCE_END(ASN1_LINKED_LIST)
IMPLEMENT_ASN1_FUNCTIONS(ASN1_LINKED_LIST)
static bool MakeLinkedList(bssl::UniquePtr<uint8_t> *out, size_t *out_len,
size_t count) {
bssl::ScopedCBB cbb;
std::vector<CBB> cbbs(count);
if (!CBB_init(cbb.get(), 2 * count) ||
!CBB_add_asn1(cbb.get(), &cbbs[0], CBS_ASN1_SEQUENCE)) {
return false;
}
for (size_t i = 1; i < count; i++) {
if (!CBB_add_asn1(&cbbs[i - 1], &cbbs[i], CBS_ASN1_SEQUENCE)) {
return false;
}
}
uint8_t *ptr;
if (!CBB_finish(cbb.get(), &ptr, out_len)) {
return false;
}
out->reset(ptr);
return true;
}
TEST(ASN1Test, Recursive) {
bssl::UniquePtr<uint8_t> data;
size_t len;
// Sanity-check that MakeLinkedList can be parsed.
ASSERT_TRUE(MakeLinkedList(&data, &len, 5));
const uint8_t *ptr = data.get();
ASN1_LINKED_LIST *list = d2i_ASN1_LINKED_LIST(nullptr, &ptr, len);
EXPECT_TRUE(list);
ASN1_LINKED_LIST_free(list);
// Excessively deep structures are rejected.
ASSERT_TRUE(MakeLinkedList(&data, &len, 100));
ptr = data.get();
list = d2i_ASN1_LINKED_LIST(nullptr, &ptr, len);
EXPECT_FALSE(list);
// Note checking the error queue here does not work. The error "stack trace"
// is too deep, so the |ASN1_R_NESTED_TOO_DEEP| entry drops off the queue.
ASN1_LINKED_LIST_free(list);
}
template <typename T>
void TestSerialize(T obj, int (*i2d_func)(T a, uint8_t **pp),
bssl::Span<const uint8_t> expected) {
int len = static_cast<int>(expected.size());
ASSERT_EQ(i2d_func(obj, nullptr), len);
std::vector<uint8_t> buf(expected.size());
uint8_t *ptr = buf.data();
ASSERT_EQ(i2d_func(obj, &ptr), len);
EXPECT_EQ(ptr, buf.data() + buf.size());
EXPECT_EQ(Bytes(expected), Bytes(buf));
// Test the allocating version.
ptr = nullptr;
ASSERT_EQ(i2d_func(obj, &ptr), len);
EXPECT_EQ(Bytes(expected), Bytes(ptr, expected.size()));
OPENSSL_free(ptr);
}
TEST(ASN1Test, SerializeObject) {
static const uint8_t kDER[] = {0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
0xf7, 0x0d, 0x01, 0x01, 0x01};
const ASN1_OBJECT *obj = OBJ_nid2obj(NID_rsaEncryption);
TestSerialize(obj, i2d_ASN1_OBJECT, kDER);
}
TEST(ASN1Test, SerializeBoolean) {
static const uint8_t kTrue[] = {0x01, 0x01, 0xff};
TestSerialize(0xff, i2d_ASN1_BOOLEAN, kTrue);
static const uint8_t kFalse[] = {0x01, 0x01, 0x00};
TestSerialize(0x00, i2d_ASN1_BOOLEAN, kFalse);
}
+1 -1
View File
@@ -93,7 +93,7 @@ ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_STRING **oct)
/* Extract an ASN1 object from an ASN1_STRING */
void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it)
void *ASN1_item_unpack(const ASN1_STRING *oct, const ASN1_ITEM *it)
{
const unsigned char *p;
void *ret;
+1 -1
View File
@@ -60,7 +60,7 @@
/* Based on a_int.c: equivalent ENUMERATED functions */
int i2a_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *a)
int i2a_ASN1_ENUMERATED(BIO *bp, const ASN1_ENUMERATED *a)
{
int i, n = 0;
static const char *h = "0123456789ABCDEF";
+1 -1
View File
@@ -58,7 +58,7 @@
#include <openssl/bio.h>
int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a)
int i2a_ASN1_INTEGER(BIO *bp, const ASN1_INTEGER *a)
{
int i, n = 0;
static const char *h = "0123456789ABCDEF";
+1 -1
View File
@@ -58,7 +58,7 @@
#include <openssl/bio.h>
int i2a_ASN1_STRING(BIO *bp, ASN1_STRING *a, int type)
int i2a_ASN1_STRING(BIO *bp, const ASN1_STRING *a, int type)
{
int i, n = 0;
static const char *h = "0123456789ABCDEF";
+49 -28
View File
@@ -56,6 +56,7 @@
#include <openssl/asn1.h>
#include <limits.h>
#include <string.h>
#include <openssl/asn1t.h>
@@ -65,6 +66,14 @@
#include "../internal.h"
/*
* Constructed types with a recursive definition (such as can be found in PKCS7)
* could eventually exceed the stack given malicious input with excessive
* recursion. Therefore we limit the stack depth. This is the maximum number of
* recursive invocations of asn1_item_embed_d2i().
*/
#define ASN1_MAX_CONSTRUCTED_NEST 30
static int asn1_check_eoc(const unsigned char **in, long len);
static int asn1_find_end(const unsigned char **in, long len, char inf);
@@ -81,11 +90,11 @@ static int asn1_check_tlen(long *olen, int *otag, unsigned char *oclass,
static int asn1_template_ex_d2i(ASN1_VALUE **pval,
const unsigned char **in, long len,
const ASN1_TEMPLATE *tt, char opt,
ASN1_TLC *ctx);
ASN1_TLC *ctx, int depth);
static int asn1_template_noexp_d2i(ASN1_VALUE **val,
const unsigned char **in, long len,
const ASN1_TEMPLATE *tt, char opt,
ASN1_TLC *ctx);
ASN1_TLC *ctx, int depth);
static int asn1_d2i_ex_primitive(ASN1_VALUE **pval,
const unsigned char **in, long len,
const ASN1_ITEM *it,
@@ -147,23 +156,14 @@ ASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **pval,
return NULL;
}
int ASN1_template_d2i(ASN1_VALUE **pval,
const unsigned char **in, long len,
const ASN1_TEMPLATE *tt)
{
ASN1_TLC c;
asn1_tlc_clear_nc(&c);
return asn1_template_ex_d2i(pval, in, len, tt, 0, &c);
}
/*
* Decode an item, taking care of IMPLICIT tagging, if any. If 'opt' set and
* tag mismatch return -1 to handle OPTIONAL
*/
int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
const ASN1_ITEM *it,
int tag, int aclass, char opt, ASN1_TLC *ctx)
static int asn1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in,
long len, const ASN1_ITEM *it, int tag, int aclass,
char opt, ASN1_TLC *ctx, int depth)
{
const ASN1_TEMPLATE *tt, *errtt = NULL;
const ASN1_COMPAT_FUNCS *cf;
@@ -188,6 +188,19 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
else
asn1_cb = 0;
/*
* Bound |len| to comfortably fit in an int. Lengths in this module often
* switch between int and long without overflow checks.
*/
if (len > INT_MAX/2) {
len = INT_MAX/2;
}
if (++depth > ASN1_MAX_CONSTRUCTED_NEST) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_TOO_DEEP);
goto err;
}
switch (it->itype) {
case ASN1_ITYPE_PRIMITIVE:
if (it->templates) {
@@ -203,7 +216,7 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
goto err;
}
return asn1_template_ex_d2i(pval, in, len,
it->templates, opt, ctx);
it->templates, opt, ctx, depth);
}
return asn1_d2i_ex_primitive(pval, in, len, it,
tag, aclass, opt, ctx);
@@ -326,7 +339,7 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
/*
* We mark field as OPTIONAL so its absence can be recognised.
*/
ret = asn1_template_ex_d2i(pchptr, &p, len, tt, 1, ctx);
ret = asn1_template_ex_d2i(pchptr, &p, len, tt, 1, ctx, depth);
/* If field not present, try the next one */
if (ret == -1)
continue;
@@ -444,7 +457,8 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
* attempt to read in field, allowing each to be OPTIONAL
*/
ret = asn1_template_ex_d2i(pseqval, &p, len, seqtt, isopt, ctx);
ret = asn1_template_ex_d2i(pseqval, &p, len, seqtt, isopt, ctx,
depth);
if (!ret) {
errtt = seqtt;
goto err;
@@ -514,6 +528,13 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
return 0;
}
int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
const ASN1_ITEM *it,
int tag, int aclass, char opt, ASN1_TLC *ctx)
{
return asn1_item_ex_d2i(pval, in, len, it, tag, aclass, opt, ctx, 0);
}
/*
* Templates are handled with two separate functions. One handles any
* EXPLICIT tag and the other handles the rest.
@@ -522,7 +543,7 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
static int asn1_template_ex_d2i(ASN1_VALUE **val,
const unsigned char **in, long inlen,
const ASN1_TEMPLATE *tt, char opt,
ASN1_TLC *ctx)
ASN1_TLC *ctx, int depth)
{
int flags, aclass;
int ret;
@@ -556,7 +577,7 @@ static int asn1_template_ex_d2i(ASN1_VALUE **val,
return 0;
}
/* We've found the field so it can't be OPTIONAL now */
ret = asn1_template_noexp_d2i(val, &p, len, tt, 0, ctx);
ret = asn1_template_noexp_d2i(val, &p, len, tt, 0, ctx, depth);
if (!ret) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_ASN1_ERROR);
return 0;
@@ -579,7 +600,7 @@ static int asn1_template_ex_d2i(ASN1_VALUE **val,
}
}
} else
return asn1_template_noexp_d2i(val, in, inlen, tt, opt, ctx);
return asn1_template_noexp_d2i(val, in, inlen, tt, opt, ctx, depth);
*in = p;
return 1;
@@ -592,7 +613,7 @@ static int asn1_template_ex_d2i(ASN1_VALUE **val,
static int asn1_template_noexp_d2i(ASN1_VALUE **val,
const unsigned char **in, long len,
const ASN1_TEMPLATE *tt, char opt,
ASN1_TLC *ctx)
ASN1_TLC *ctx, int depth)
{
int flags, aclass;
int ret;
@@ -661,8 +682,8 @@ static int asn1_template_noexp_d2i(ASN1_VALUE **val,
break;
}
skfield = NULL;
if (!ASN1_item_ex_d2i(&skfield, &p, len,
ASN1_ITEM_ptr(tt->item), -1, 0, 0, ctx)) {
if (!asn1_item_ex_d2i(&skfield, &p, len, ASN1_ITEM_ptr(tt->item),
-1, 0, 0, ctx, depth)) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_ASN1_ERROR);
goto err;
}
@@ -679,9 +700,8 @@ static int asn1_template_noexp_d2i(ASN1_VALUE **val,
}
} else if (flags & ASN1_TFLG_IMPTAG) {
/* IMPLICIT tagging */
ret = ASN1_item_ex_d2i(val, &p, len,
ASN1_ITEM_ptr(tt->item), tt->tag, aclass, opt,
ctx);
ret = asn1_item_ex_d2i(val, &p, len, ASN1_ITEM_ptr(tt->item), tt->tag,
aclass, opt, ctx, depth);
if (!ret) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_ASN1_ERROR);
goto err;
@@ -689,8 +709,9 @@ static int asn1_template_noexp_d2i(ASN1_VALUE **val,
return -1;
} else {
/* Nothing special */
ret = ASN1_item_ex_d2i(val, &p, len, ASN1_ITEM_ptr(tt->item),
-1, tt->flags & ASN1_TFLG_COMBINE, opt, ctx);
ret = asn1_item_ex_d2i(val, &p, len, ASN1_ITEM_ptr(tt->item),
-1, tt->flags & ASN1_TFLG_COMBINE, opt, ctx,
depth);
if (!ret) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NESTED_ASN1_ERROR);
goto err;
+3 -7
View File
@@ -192,7 +192,7 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
/* Use indefinite length constructed if requested */
if (aclass & ASN1_TFLG_NDEF)
ndef = 2;
/* fall through */
OPENSSL_FALLTHROUGH;
case ASN1_ITYPE_SEQUENCE:
i = asn1_enc_restore(&seqcontlen, out, pval, it);
@@ -256,12 +256,6 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
return 0;
}
int ASN1_template_i2d(ASN1_VALUE **pval, unsigned char **out,
const ASN1_TEMPLATE *tt)
{
return asn1_template_ex_i2d(pval, out, tt, -1, 0);
}
static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
const ASN1_TEMPLATE *tt, int tag, int iclass)
{
@@ -589,6 +583,8 @@ int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *putype,
otmp = (ASN1_OBJECT *)*pval;
cont = otmp->data;
len = otmp->length;
if (cont == NULL || len == 0)
return -1;
break;
case V_ASN1_NULL:
+2 -4
View File
@@ -59,8 +59,7 @@
#include <openssl/asn1t.h>
#include <openssl/mem.h>
static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it,
int combine);
#include "asn1_locl.h"
/* Free up an ASN1 structure */
@@ -74,8 +73,7 @@ void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
asn1_item_combine_free(pval, it, 0);
}
static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it,
int combine)
void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine)
{
const ASN1_TEMPLATE *tt = NULL, *seqtt;
const ASN1_EXTERN_FUNCS *ef;
+3 -2
View File
@@ -63,6 +63,7 @@
#include <openssl/mem.h>
#include <openssl/obj.h>
#include "asn1_locl.h"
#include "../internal.h"
@@ -201,7 +202,7 @@ static int asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it,
return 1;
memerr2:
ASN1_item_ex_free(pval, it);
asn1_item_combine_free(pval, it, combine);
memerr:
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
#ifdef CRYPTO_MDEBUG
@@ -211,7 +212,7 @@ static int asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it,
return 0;
auxerr2:
ASN1_item_ex_free(pval, it);
asn1_item_combine_free(pval, it, combine);
auxerr:
OPENSSL_PUT_ERROR(ASN1, ASN1_R_AUX_ERROR);
#ifdef CRYPTO_MDEBUG
-9
View File
@@ -1,9 +0,0 @@
include_directories(../../include)
add_library(
base64
OBJECT
base64.c
)
+2 -2
View File
@@ -98,8 +98,8 @@ static uint8_t conv_bin2ascii(uint8_t a) {
return ret;
}
OPENSSL_COMPILE_ASSERT(sizeof(((EVP_ENCODE_CTX *)(NULL))->data) % 3 == 0,
data_length_must_be_multiple_of_base64_chunk_size);
OPENSSL_STATIC_ASSERT(sizeof(((EVP_ENCODE_CTX *)(NULL))->data) % 3 == 0,
"data length must be a multiple of base64 chunk size");
int EVP_EncodedLength(size_t *out_len, size_t len) {
if (len + 2 < len) {
+9 -9
View File
@@ -39,14 +39,14 @@ enum encoding_relation {
invalid,
};
struct TestVector {
struct Base64TestVector {
enum encoding_relation relation;
const char *decoded;
const char *encoded;
};
// Test vectors from RFC 4648.
static const TestVector kTestVectors[] = {
static const Base64TestVector kTestVectors[] = {
{canonical, "", ""},
{canonical, "f", "Zg==\n"},
{canonical, "fo", "Zm8=\n"},
@@ -103,9 +103,9 @@ static const TestVector kTestVectors[] = {
"=======\n"},
};
class Base64Test : public testing::TestWithParam<TestVector> {};
class Base64Test : public testing::TestWithParam<Base64TestVector> {};
INSTANTIATE_TEST_CASE_P(, Base64Test, testing::ValuesIn(kTestVectors));
INSTANTIATE_TEST_SUITE_P(All, Base64Test, testing::ValuesIn(kTestVectors));
// RemoveNewlines returns a copy of |in| with all '\n' characters removed.
static std::string RemoveNewlines(const char *in) {
@@ -122,7 +122,7 @@ static std::string RemoveNewlines(const char *in) {
}
TEST_P(Base64Test, EncodeBlock) {
const TestVector &t = GetParam();
const Base64TestVector &t = GetParam();
if (t.relation != canonical) {
return;
}
@@ -140,7 +140,7 @@ TEST_P(Base64Test, EncodeBlock) {
}
TEST_P(Base64Test, DecodeBase64) {
const TestVector &t = GetParam();
const Base64TestVector &t = GetParam();
if (t.relation == valid) {
// The non-canonical encodings will generally have odd whitespace etc
// that |EVP_DecodeBase64| will reject.
@@ -164,7 +164,7 @@ TEST_P(Base64Test, DecodeBase64) {
}
TEST_P(Base64Test, DecodeBlock) {
const TestVector &t = GetParam();
const Base64TestVector &t = GetParam();
if (t.relation != canonical) {
return;
}
@@ -188,7 +188,7 @@ TEST_P(Base64Test, DecodeBlock) {
}
TEST_P(Base64Test, EncodeDecode) {
const TestVector &t = GetParam();
const Base64TestVector &t = GetParam();
EVP_ENCODE_CTX ctx;
const size_t decoded_len = strlen(t.decoded);
@@ -246,7 +246,7 @@ TEST_P(Base64Test, EncodeDecode) {
}
TEST_P(Base64Test, DecodeUpdateStreaming) {
const TestVector &t = GetParam();
const Base64TestVector &t = GetParam();
if (t.relation == invalid) {
return;
}
-18
View File
@@ -1,18 +0,0 @@
include_directories(../../include)
add_library(
bio
OBJECT
bio.c
bio_mem.c
connect.c
fd.c
file.c
hexdump.c
pair.c
printf.c
socket.c
socket_helper.c
)
+152 -9
View File
@@ -61,6 +61,7 @@
#include <limits.h>
#include <string.h>
#include <openssl/asn1.h>
#include <openssl/err.h>
#include <openssl/mem.h>
#include <openssl/thread.h>
@@ -177,6 +178,19 @@ int BIO_write(BIO *bio, const void *in, int inl) {
return ret;
}
int BIO_write_all(BIO *bio, const void *data, size_t len) {
const uint8_t *data_u8 = data;
while (len > 0) {
int ret = BIO_write(bio, data_u8, len > INT_MAX ? INT_MAX : (int)len);
if (ret <= 0) {
return 0;
}
data_u8 += ret;
len -= ret;
}
return 1;
}
int BIO_puts(BIO *bio, const char *in) {
return BIO_write(bio, in, strlen(in));
}
@@ -468,11 +482,52 @@ static int bio_read_all(BIO *bio, uint8_t **out, size_t *out_len,
}
}
// bio_read_full reads |len| bytes |bio| and writes them into |out|. It
// tolerates partial reads from |bio| and returns one on success or zero if a
// read fails before |len| bytes are read. On failure, it additionally sets
// |*out_eof_on_first_read| to whether the error was due to |bio| returning zero
// on the first read. |out_eof_on_first_read| may be NULL to discard the value.
static int bio_read_full(BIO *bio, uint8_t *out, int *out_eof_on_first_read,
size_t len) {
int first_read = 1;
while (len > 0) {
int todo = len <= INT_MAX ? (int)len : INT_MAX;
int ret = BIO_read(bio, out, todo);
if (ret <= 0) {
if (out_eof_on_first_read != NULL) {
*out_eof_on_first_read = first_read && ret == 0;
}
return 0;
}
out += ret;
len -= (size_t)ret;
first_read = 0;
}
return 1;
}
// For compatibility with existing |d2i_*_bio| callers, |BIO_read_asn1| uses
// |ERR_LIB_ASN1| errors.
OPENSSL_DECLARE_ERROR_REASON(ASN1, ASN1_R_DECODE_ERROR)
OPENSSL_DECLARE_ERROR_REASON(ASN1, ASN1_R_HEADER_TOO_LONG)
OPENSSL_DECLARE_ERROR_REASON(ASN1, ASN1_R_NOT_ENOUGH_DATA)
OPENSSL_DECLARE_ERROR_REASON(ASN1, ASN1_R_TOO_LONG)
int BIO_read_asn1(BIO *bio, uint8_t **out, size_t *out_len, size_t max_len) {
uint8_t header[6];
static const size_t kInitialHeaderLen = 2;
if (BIO_read(bio, header, kInitialHeaderLen) != (int) kInitialHeaderLen) {
int eof_on_first_read;
if (!bio_read_full(bio, header, &eof_on_first_read, kInitialHeaderLen)) {
if (eof_on_first_read) {
// Historically, OpenSSL returned |ASN1_R_HEADER_TOO_LONG| when
// |d2i_*_bio| could not read anything. CPython conditions on this to
// determine if |bio| was empty.
OPENSSL_PUT_ERROR(ASN1, ASN1_R_HEADER_TOO_LONG);
} else {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NOT_ENOUGH_DATA);
}
return 0;
}
@@ -481,6 +536,7 @@ int BIO_read_asn1(BIO *bio, uint8_t **out, size_t *out_len, size_t max_len) {
if ((tag & 0x1f) == 0x1f) {
// Long form tags are not supported.
OPENSSL_PUT_ERROR(ASN1, ASN1_R_DECODE_ERROR);
return 0;
}
@@ -494,34 +550,40 @@ int BIO_read_asn1(BIO *bio, uint8_t **out, size_t *out_len, size_t max_len) {
if ((tag & 0x20 /* constructed */) != 0 && num_bytes == 0) {
// indefinite length.
return bio_read_all(bio, out, out_len, header, kInitialHeaderLen,
max_len);
if (!bio_read_all(bio, out, out_len, header, kInitialHeaderLen,
max_len)) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NOT_ENOUGH_DATA);
return 0;
}
return 1;
}
if (num_bytes == 0 || num_bytes > 4) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_DECODE_ERROR);
return 0;
}
if (BIO_read(bio, header + kInitialHeaderLen, num_bytes) !=
(int)num_bytes) {
if (!bio_read_full(bio, header + kInitialHeaderLen, NULL, num_bytes)) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NOT_ENOUGH_DATA);
return 0;
}
header_len = kInitialHeaderLen + num_bytes;
uint32_t len32 = 0;
unsigned i;
for (i = 0; i < num_bytes; i++) {
for (unsigned i = 0; i < num_bytes; i++) {
len32 <<= 8;
len32 |= header[kInitialHeaderLen + i];
}
if (len32 < 128) {
// Length should have used short-form encoding.
OPENSSL_PUT_ERROR(ASN1, ASN1_R_DECODE_ERROR);
return 0;
}
if ((len32 >> ((num_bytes-1)*8)) == 0) {
// Length should have been at least one byte shorter.
OPENSSL_PUT_ERROR(ASN1, ASN1_R_DECODE_ERROR);
return 0;
}
@@ -531,6 +593,7 @@ int BIO_read_asn1(BIO *bio, uint8_t **out, size_t *out_len, size_t max_len) {
if (len + header_len < len ||
len + header_len > max_len ||
len > INT_MAX) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_TOO_LONG);
return 0;
}
len += header_len;
@@ -538,11 +601,12 @@ int BIO_read_asn1(BIO *bio, uint8_t **out, size_t *out_len, size_t max_len) {
*out = OPENSSL_malloc(len);
if (*out == NULL) {
OPENSSL_PUT_ERROR(ASN1, ERR_R_MALLOC_FAILURE);
return 0;
}
OPENSSL_memcpy(*out, header, header_len);
if (BIO_read(bio, (*out) + header_len, len - header_len) !=
(int) (len - header_len)) {
if (!bio_read_full(bio, (*out) + header_len, NULL, len - header_len)) {
OPENSSL_PUT_ERROR(ASN1, ASN1_R_NOT_ENOUGH_DATA);
OPENSSL_free(*out);
return 0;
}
@@ -555,3 +619,82 @@ void BIO_set_retry_special(BIO *bio) {
}
int BIO_set_write_buffer_size(BIO *bio, int buffer_size) { return 0; }
static struct CRYPTO_STATIC_MUTEX g_index_lock = CRYPTO_STATIC_MUTEX_INIT;
static int g_index = BIO_TYPE_START;
int BIO_get_new_index(void) {
CRYPTO_STATIC_MUTEX_lock_write(&g_index_lock);
// If |g_index| exceeds 255, it will collide with the flags bits.
int ret = g_index > 255 ? -1 : g_index++;
CRYPTO_STATIC_MUTEX_unlock_write(&g_index_lock);
return ret;
}
BIO_METHOD *BIO_meth_new(int type, const char *name) {
BIO_METHOD *method = OPENSSL_malloc(sizeof(BIO_METHOD));
if (method == NULL) {
return NULL;
}
OPENSSL_memset(method, 0, sizeof(BIO_METHOD));
method->type = type;
method->name = name;
return method;
}
void BIO_meth_free(BIO_METHOD *method) {
OPENSSL_free(method);
}
int BIO_meth_set_create(BIO_METHOD *method,
int (*create)(BIO *)) {
method->create = create;
return 1;
}
int BIO_meth_set_destroy(BIO_METHOD *method,
int (*destroy)(BIO *)) {
method->destroy = destroy;
return 1;
}
int BIO_meth_set_write(BIO_METHOD *method,
int (*write)(BIO *, const char *, int)) {
method->bwrite = write;
return 1;
}
int BIO_meth_set_read(BIO_METHOD *method,
int (*read)(BIO *, char *, int)) {
method->bread = read;
return 1;
}
int BIO_meth_set_gets(BIO_METHOD *method,
int (*gets)(BIO *, char *, int)) {
method->bgets = gets;
return 1;
}
int BIO_meth_set_ctrl(BIO_METHOD *method,
long (*ctrl)(BIO *, int, long, void *)) {
method->ctrl = ctrl;
return 1;
}
void BIO_set_data(BIO *bio, void *ptr) { bio->ptr = ptr; }
void *BIO_get_data(BIO *bio) { return bio->ptr; }
void BIO_set_init(BIO *bio, int init) { bio->init = init; }
int BIO_get_init(BIO *bio) { return bio->init; }
void BIO_set_shutdown(BIO *bio, int shutdown) { bio->shutdown = shutdown; }
int BIO_get_shutdown(BIO *bio) { return bio->shutdown; }
int BIO_meth_set_puts(BIO_METHOD *method, int (*puts)(BIO *, const char *)) {
// Ignore the parameter. We implement |BIO_puts| using |BIO_write|.
return 1;
}
+3 -6
View File
@@ -12,10 +12,6 @@
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
#if !defined(_POSIX_C_SOURCE)
#define _POSIX_C_SOURCE 201410L
#endif
#include <algorithm>
#include <string>
@@ -31,6 +27,7 @@
#if !defined(OPENSSL_WINDOWS)
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <string.h>
@@ -223,7 +220,7 @@ TEST_P(BIOASN1Test, ReadASN1) {
}
}
INSTANTIATE_TEST_CASE_P(, BIOASN1Test, testing::ValuesIn(kASN1TestParams));
INSTANTIATE_TEST_SUITE_P(All, BIOASN1Test, testing::ValuesIn(kASN1TestParams));
// Run through the tests twice, swapping |bio1| and |bio2|, for symmetry.
class BIOPairTest : public testing::TestWithParam<bool> {};
@@ -325,4 +322,4 @@ TEST_P(BIOPairTest, TestPair) {
EXPECT_EQ(Bytes("12345"), Bytes(buf, 5));
}
INSTANTIATE_TEST_CASE_P(, BIOPairTest, testing::Values(false, true));
INSTANTIATE_TEST_SUITE_P(All, BIOPairTest, testing::Values(false, true));
+7 -4
View File
@@ -56,6 +56,8 @@
#include <openssl/bio.h>
#if !defined(OPENSSL_TRUSTY)
#include <assert.h>
#include <errno.h>
#include <string.h>
@@ -72,7 +74,6 @@ OPENSSL_MSVC_PRAGMA(warning(push, 3))
OPENSSL_MSVC_PRAGMA(warning(pop))
#endif
#include <openssl/buf.h>
#include <openssl/err.h>
#include <openssl/mem.h>
@@ -147,7 +148,7 @@ static int split_host_and_port(char **out_host, char **out_port, const char *nam
}
}
*out_host = BUF_strndup(host, host_len);
*out_host = OPENSSL_strndup(host, host_len);
if (*out_host == NULL) {
return 0;
}
@@ -427,13 +428,13 @@ static long conn_ctrl(BIO *bio, int cmd, long num, void *ptr) {
bio->init = 1;
if (num == 0) {
OPENSSL_free(data->param_hostname);
data->param_hostname = BUF_strdup(ptr);
data->param_hostname = OPENSSL_strdup(ptr);
if (data->param_hostname == NULL) {
ret = 0;
}
} else if (num == 1) {
OPENSSL_free(data->param_port);
data->param_port = BUF_strdup(ptr);
data->param_port = OPENSSL_strdup(ptr);
if (data->param_port == NULL) {
ret = 0;
}
@@ -540,3 +541,5 @@ int BIO_set_nbio(BIO *bio, int on) {
int BIO_do_connect(BIO *bio) {
return BIO_ctrl(bio, BIO_C_DO_STATE_MACHINE, 0, NULL);
}
#endif // OPENSSL_TRUSTY
+6 -1
View File
@@ -56,6 +56,8 @@
#include <openssl/bio.h>
#if !defined(OPENSSL_TRUSTY)
#include <errno.h>
#include <string.h>
@@ -68,11 +70,11 @@ OPENSSL_MSVC_PRAGMA(warning(push, 3))
OPENSSL_MSVC_PRAGMA(warning(pop))
#endif
#include <openssl/buf.h>
#include <openssl/err.h>
#include <openssl/mem.h>
#include "internal.h"
#include "../internal.h"
static int bio_fd_non_fatal_error(int err) {
@@ -190,6 +192,7 @@ static long fd_ctrl(BIO *b, int cmd, long num, void *ptr) {
switch (cmd) {
case BIO_CTRL_RESET:
num = 0;
OPENSSL_FALLTHROUGH;
case BIO_C_FILE_SEEK:
ret = 0;
if (b->init) {
@@ -272,3 +275,5 @@ int BIO_set_fd(BIO *bio, int fd, int close_flag) {
int BIO_get_fd(BIO *bio, int *out_fd) {
return BIO_ctrl(bio, BIO_C_GET_FD, 0, (char *) out_fd);
}
#endif // OPENSSL_TRUSTY
+13 -8
View File
@@ -73,14 +73,17 @@
#include <openssl/bio.h>
#if !defined(OPENSSL_TRUSTY)
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <openssl/buf.h>
#include <openssl/err.h>
#include <openssl/mem.h>
#include "../internal.h"
#define BIO_FP_READ 0x02
#define BIO_FP_WRITE 0x04
@@ -103,13 +106,12 @@ BIO *BIO_new_file(const char *filename, const char *mode) {
return NULL;
}
ret = BIO_new(BIO_s_file());
ret = BIO_new_fp(file, BIO_CLOSE);
if (ret == NULL) {
fclose(file);
return NULL;
}
BIO_set_fp(ret, file, BIO_CLOSE);
return ret;
}
@@ -183,6 +185,7 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr) {
switch (cmd) {
case BIO_CTRL_RESET:
num = 0;
OPENSSL_FALLTHROUGH;
case BIO_C_FILE_SEEK:
ret = (long)fseek(fp, num, 0);
break;
@@ -204,16 +207,16 @@ static long file_ctrl(BIO *b, int cmd, long num, void *ptr) {
b->shutdown = (int)num & BIO_CLOSE;
if (num & BIO_FP_APPEND) {
if (num & BIO_FP_READ) {
BUF_strlcpy(p, "a+", sizeof(p));
OPENSSL_strlcpy(p, "a+", sizeof(p));
} else {
BUF_strlcpy(p, "a", sizeof(p));
OPENSSL_strlcpy(p, "a", sizeof(p));
}
} else if ((num & BIO_FP_READ) && (num & BIO_FP_WRITE)) {
BUF_strlcpy(p, "r+", sizeof(p));
OPENSSL_strlcpy(p, "r+", sizeof(p));
} else if (num & BIO_FP_WRITE) {
BUF_strlcpy(p, "w", sizeof(p));
OPENSSL_strlcpy(p, "w", sizeof(p));
} else if (num & BIO_FP_READ) {
BUF_strlcpy(p, "r", sizeof(p));
OPENSSL_strlcpy(p, "r", sizeof(p));
} else {
OPENSSL_PUT_ERROR(BIO, BIO_R_BAD_FOPEN_MODE);
ret = 0;
@@ -310,3 +313,5 @@ int BIO_rw_filename(BIO *bio, const char *filename) {
return BIO_ctrl(bio, BIO_C_SET_FILENAME,
BIO_CLOSE | BIO_FP_READ | BIO_FP_WRITE, (char *)filename);
}
#endif // OPENSSL_TRUSTY
-1
View File
@@ -55,7 +55,6 @@
#include <assert.h>
#include <string.h>
#include <openssl/buf.h>
#include <openssl/err.h>
#include <openssl/mem.h>
-4
View File
@@ -54,10 +54,6 @@
* copied and put under another distribution licence
* [including the GNU Public Licence.] */
#if !defined(_POSIX_C_SOURCE)
#define _POSIX_C_SOURCE 201410L // for snprintf, vprintf etc
#endif
#include <openssl/bio.h>
#include <assert.h>
+4
View File
@@ -57,6 +57,8 @@
#include <openssl/bio.h>
#if !defined(OPENSSL_TRUSTY)
#include <fcntl.h>
#include <string.h>
@@ -200,3 +202,5 @@ BIO *BIO_new_socket(int fd, int close_flag) {
BIO_set_fd(ret, fd, close_flag);
return ret;
}
#endif // OPENSSL_TRUSTY
+4
View File
@@ -18,6 +18,8 @@
#include <openssl/bio.h>
#include <openssl/err.h>
#if !defined(OPENSSL_TRUSTY)
#include <fcntl.h>
#include <string.h>
#include <sys/types.h>
@@ -112,3 +114,5 @@ int bio_sock_error(int sock) {
}
return error;
}
#endif // OPENSSL_TRUSTY
-10
View File
@@ -1,10 +0,0 @@
include_directories(../../include)
add_library(
bn_extra
OBJECT
bn_asn1.c
convert.c
)
-16
View File
@@ -42,22 +42,6 @@ int BN_parse_asn1_unsigned(CBS *cbs, BIGNUM *ret) {
return BN_bin2bn(CBS_data(&child), CBS_len(&child), ret) != NULL;
}
int BN_parse_asn1_unsigned_buggy(CBS *cbs, BIGNUM *ret) {
CBS child;
if (!CBS_get_asn1(cbs, &child, CBS_ASN1_INTEGER) ||
CBS_len(&child) == 0) {
OPENSSL_PUT_ERROR(BN, BN_R_BAD_ENCODING);
return 0;
}
// This function intentionally does not reject negative numbers or non-minimal
// encodings. Estonian IDs issued between September 2014 to September 2015 are
// broken. See https://crbug.com/532048 and https://crbug.com/534766.
//
// TODO(davidben): Remove this code and callers in March 2016.
return BN_bin2bn(CBS_data(&child), CBS_len(&child), ret) != NULL;
}
int BN_marshal_asn1(CBB *cbb, const BIGNUM *bn) {
// Negative numbers are unsupported.
if (BN_is_negative(bn)) {
+17 -12
View File
@@ -77,8 +77,9 @@ int BN_bn2cbb_padded(CBB *out, size_t len, const BIGNUM *in) {
static const char hextable[] = "0123456789abcdef";
char *BN_bn2hex(const BIGNUM *bn) {
int width = bn_minimal_width(bn);
char *buf = OPENSSL_malloc(1 /* leading '-' */ + 1 /* zero is non-empty */ +
bn->top * BN_BYTES * 2 + 1 /* trailing NUL */);
width * BN_BYTES * 2 + 1 /* trailing NUL */);
if (buf == NULL) {
OPENSSL_PUT_ERROR(BN, ERR_R_MALLOC_FAILURE);
return NULL;
@@ -94,7 +95,7 @@ char *BN_bn2hex(const BIGNUM *bn) {
}
int z = 0;
for (int i = bn->top - 1; i >= 0; i--) {
for (int i = width - 1; i >= 0; i--) {
for (int j = BN_BITS2 - 8; j >= 0; j -= 8) {
// strip leading zeros
int v = ((int)(bn->d[i] >> (long)j)) & 0xff;
@@ -153,7 +154,7 @@ static int decode_hex(BIGNUM *bn, const char *in, int in_len) {
in_len -= todo;
}
assert(i <= bn->dmax);
bn->top = i;
bn->width = i;
return 1;
}
@@ -222,7 +223,7 @@ static int bn_x2bn(BIGNUM **outp, const char *in, decode_func decode, char_test_
goto err;
}
bn_correct_top(ret);
bn_set_minimal_width(ret);
if (!BN_is_zero(ret)) {
ret->neg = neg;
}
@@ -347,7 +348,7 @@ int BN_print(BIO *bp, const BIGNUM *a) {
goto end;
}
for (i = a->top - 1; i >= 0; i--) {
for (i = bn_minimal_width(a) - 1; i >= 0; i--) {
for (j = BN_BITS2 - 4; j >= 0; j -= 4) {
// strip leading zeros
v = ((int)(a->d[i] >> (long)j)) & 0x0f;
@@ -366,17 +367,13 @@ end:
}
int BN_print_fp(FILE *fp, const BIGNUM *a) {
BIO *b;
int ret;
b = BIO_new(BIO_s_file());
BIO *b = BIO_new_fp(fp, BIO_NOCLOSE);
if (b == NULL) {
return 0;
}
BIO_set_fp(b, fp, BIO_NOCLOSE);
ret = BN_print(b, a);
BIO_free(b);
int ret = BN_print(b, a);
BIO_free(b);
return ret;
}
@@ -463,3 +460,11 @@ BIGNUM *BN_mpi2bn(const uint8_t *in, size_t len, BIGNUM *out) {
}
return out;
}
int BN_bn2binpad(const BIGNUM *in, uint8_t *out, int len) {
if (len < 0 ||
!BN_bn2bin_padded(out, (size_t)len, in)) {
return -1;
}
return len;
}
-9
View File
@@ -1,9 +0,0 @@
include_directories(../../include)
add_library(
buf
OBJECT
buf.c
)
+28 -95
View File
@@ -82,15 +82,11 @@ void BUF_MEM_free(BUF_MEM *buf) {
return;
}
if (buf->data != NULL) {
OPENSSL_cleanse(buf->data, buf->max);
OPENSSL_free(buf->data);
}
OPENSSL_free(buf->data);
OPENSSL_free(buf);
}
static int buf_mem_reserve(BUF_MEM *buf, size_t cap, int clean) {
int BUF_MEM_reserve(BUF_MEM *buf, size_t cap) {
if (buf->max >= cap) {
return 1;
}
@@ -109,17 +105,7 @@ static int buf_mem_reserve(BUF_MEM *buf, size_t cap, int clean) {
return 0;
}
char *new_buf;
if (buf->data == NULL) {
new_buf = OPENSSL_malloc(alloc_size);
} else {
if (clean) {
new_buf = OPENSSL_realloc_clean(buf->data, buf->max, alloc_size);
} else {
new_buf = OPENSSL_realloc(buf->data, alloc_size);
}
}
char *new_buf = OPENSSL_realloc(buf->data, alloc_size);
if (new_buf == NULL) {
OPENSSL_PUT_ERROR(BUF, ERR_R_MALLOC_FAILURE);
return 0;
@@ -130,12 +116,8 @@ static int buf_mem_reserve(BUF_MEM *buf, size_t cap, int clean) {
return 1;
}
int BUF_MEM_reserve(BUF_MEM *buf, size_t cap) {
return buf_mem_reserve(buf, cap, 0 /* don't clear old buffer contents. */);
}
static size_t buf_mem_grow(BUF_MEM *buf, size_t len, int clean) {
if (!buf_mem_reserve(buf, len, clean)) {
size_t BUF_MEM_grow(BUF_MEM *buf, size_t len) {
if (!BUF_MEM_reserve(buf, len)) {
return 0;
}
if (buf->length < len) {
@@ -145,95 +127,46 @@ static size_t buf_mem_grow(BUF_MEM *buf, size_t len, int clean) {
return len;
}
size_t BUF_MEM_grow(BUF_MEM *buf, size_t len) {
return buf_mem_grow(buf, len, 0 /* don't clear old buffer contents. */);
}
size_t BUF_MEM_grow_clean(BUF_MEM *buf, size_t len) {
return buf_mem_grow(buf, len, 1 /* clear old buffer contents. */);
return BUF_MEM_grow(buf, len);
}
char *BUF_strdup(const char *str) {
if (str == NULL) {
return NULL;
int BUF_MEM_append(BUF_MEM *buf, const void *in, size_t len) {
// Work around a C language bug. See https://crbug.com/1019588.
if (len == 0) {
return 1;
}
return BUF_strndup(str, strlen(str));
size_t new_len = buf->length + len;
if (new_len < len) {
OPENSSL_PUT_ERROR(BUF, ERR_R_OVERFLOW);
return 0;
}
if (!BUF_MEM_reserve(buf, new_len)) {
return 0;
}
OPENSSL_memcpy(buf->data + buf->length, in, len);
buf->length = new_len;
return 1;
}
char *BUF_strdup(const char *str) { return OPENSSL_strdup(str); }
size_t BUF_strnlen(const char *str, size_t max_len) {
size_t i;
for (i = 0; i < max_len; i++) {
if (str[i] == 0) {
break;
}
}
return i;
return OPENSSL_strnlen(str, max_len);
}
char *BUF_strndup(const char *str, size_t size) {
char *ret;
size_t alloc_size;
if (str == NULL) {
return NULL;
}
size = BUF_strnlen(str, size);
alloc_size = size + 1;
if (alloc_size < size) {
// overflow
OPENSSL_PUT_ERROR(BUF, ERR_R_MALLOC_FAILURE);
return NULL;
}
ret = OPENSSL_malloc(alloc_size);
if (ret == NULL) {
OPENSSL_PUT_ERROR(BUF, ERR_R_MALLOC_FAILURE);
return NULL;
}
OPENSSL_memcpy(ret, str, size);
ret[size] = '\0';
return ret;
return OPENSSL_strndup(str, size);
}
size_t BUF_strlcpy(char *dst, const char *src, size_t dst_size) {
size_t l = 0;
for (; dst_size > 1 && *src; dst_size--) {
*dst++ = *src++;
l++;
}
if (dst_size) {
*dst = 0;
}
return l + strlen(src);
return OPENSSL_strlcpy(dst, src, dst_size);
}
size_t BUF_strlcat(char *dst, const char *src, size_t dst_size) {
size_t l = 0;
for (; dst_size > 0 && *dst; dst_size--, dst++) {
l++;
}
return l + BUF_strlcpy(dst, src, dst_size);
return OPENSSL_strlcat(dst, src, dst_size);
}
void *BUF_memdup(const void *data, size_t size) {
if (size == 0) {
return NULL;
}
void *ret = OPENSSL_malloc(size);
if (ret == NULL) {
OPENSSL_PUT_ERROR(BUF, ERR_R_MALLOC_FAILURE);
return NULL;
}
OPENSSL_memcpy(ret, data, size);
return ret;
return OPENSSL_memdup(data, size);
}
+97
View File
@@ -0,0 +1,97 @@
/* Copyright (c) 2017, Google Inc.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
#include <openssl/buf.h>
#include <string.h>
#include <string>
#include <gtest/gtest.h>
TEST(BufTest, Basic) {
bssl::UniquePtr<BUF_MEM> buf(BUF_MEM_new());
ASSERT_TRUE(buf);
EXPECT_EQ(0u, buf->length);
// Use BUF_MEM_reserve to increase buf->max.
ASSERT_TRUE(BUF_MEM_reserve(buf.get(), 200));
EXPECT_GE(buf->max, 200u);
EXPECT_EQ(0u, buf->length);
// BUF_MEM_reserve with a smaller cap is a no-op.
size_t old_max = buf->max;
ASSERT_TRUE(BUF_MEM_reserve(buf.get(), 100));
EXPECT_EQ(old_max, buf->max);
EXPECT_EQ(0u, buf->length);
// BUF_MEM_grow can increase the length without reallocating.
ASSERT_EQ(100u, BUF_MEM_grow(buf.get(), 100));
EXPECT_EQ(100u, buf->length);
EXPECT_EQ(old_max, buf->max);
memset(buf->data, 'A', buf->length);
// If BUF_MEM_reserve reallocates, it preserves the contents.
ASSERT_TRUE(BUF_MEM_reserve(buf.get(), old_max + 1));
ASSERT_GE(buf->max, old_max + 1);
EXPECT_EQ(100u, buf->length);
for (size_t i = 0; i < 100; i++) {
EXPECT_EQ('A', buf->data[i]);
}
// BUF_MEM_grow should zero everything beyond buf->length.
memset(buf->data, 'B', buf->max);
ASSERT_EQ(150u, BUF_MEM_grow(buf.get(), 150));
EXPECT_EQ(150u, buf->length);
for (size_t i = 0; i < 100; i++) {
EXPECT_EQ('B', buf->data[i]);
}
for (size_t i = 100; i < 150; i++) {
EXPECT_EQ(0, buf->data[i]);
}
// BUF_MEM_grow can rellocate if necessary.
size_t new_len = buf->max + 1;
ASSERT_EQ(new_len, BUF_MEM_grow(buf.get(), new_len));
EXPECT_GE(buf->max, new_len);
EXPECT_EQ(new_len, buf->length);
for (size_t i = 0; i < 100; i++) {
EXPECT_EQ('B', buf->data[i]);
}
for (size_t i = 100; i < new_len; i++) {
EXPECT_EQ(0, buf->data[i]);
}
// BUF_MEM_grow can shink.
ASSERT_EQ(50u, BUF_MEM_grow(buf.get(), 50));
EXPECT_EQ(50u, buf->length);
for (size_t i = 0; i < 50; i++) {
EXPECT_EQ('B', buf->data[i]);
}
}
TEST(BufTest, Append) {
bssl::UniquePtr<BUF_MEM> buf(BUF_MEM_new());
ASSERT_TRUE(buf);
ASSERT_TRUE(BUF_MEM_append(buf.get(), nullptr, 0));
ASSERT_TRUE(BUF_MEM_append(buf.get(), "hello ", 6));
ASSERT_TRUE(BUF_MEM_append(buf.get(), nullptr, 0));
ASSERT_TRUE(BUF_MEM_append(buf.get(), "world", 5));
std::string str(128, 'A');
ASSERT_TRUE(BUF_MEM_append(buf.get(), str.data(), str.size()));
EXPECT_EQ("hello world" + str, std::string(buf->data, buf->length));
}
-12
View File
@@ -1,12 +0,0 @@
include_directories(../../include)
add_library(
bytestring
OBJECT
asn1_compat.c
ber.c
cbs.c
cbb.c
)
+9 -8
View File
@@ -29,10 +29,7 @@ static const unsigned kMaxDepth = 2048;
// is_string_type returns one if |tag| is a string type and zero otherwise. It
// ignores the constructed bit.
static int is_string_type(unsigned tag) {
if ((tag & 0xc0) != 0) {
return 0;
}
switch (tag & 0x1f) {
switch (tag & ~CBS_ASN1_CONSTRUCTED) {
case CBS_ASN1_BITSTRING:
case CBS_ASN1_OCTETSTRING:
case CBS_ASN1_UTF8STRING:
@@ -192,7 +189,7 @@ static int cbs_convert_ber(CBS *in, CBB *out, unsigned string_tag,
return looking_for_eoc == 0;
}
int CBS_asn1_ber_to_der(CBS *in, uint8_t **out, size_t *out_len) {
int CBS_asn1_ber_to_der(CBS *in, CBS *out, uint8_t **out_storage) {
CBB cbb;
// First, do a quick walk to find any indefinite-length elements. Most of the
@@ -203,18 +200,22 @@ int CBS_asn1_ber_to_der(CBS *in, uint8_t **out, size_t *out_len) {
}
if (!conversion_needed) {
*out = NULL;
*out_len = 0;
if (!CBS_get_any_asn1_element(in, out, NULL, NULL)) {
return 0;
}
*out_storage = NULL;
return 1;
}
size_t len;
if (!CBB_init(&cbb, CBS_len(in)) ||
!cbs_convert_ber(in, &cbb, 0, 0, 0) ||
!CBB_finish(&cbb, out, out_len)) {
!CBB_finish(&cbb, out_storage, &len)) {
CBB_cleanup(&cbb);
return 0;
}
CBS_init(out, *out_storage, len);
return 1;
}
+618 -48
View File
@@ -12,10 +12,6 @@
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
#if !defined(__STDC_CONSTANT_MACROS)
#define __STDC_CONSTANT_MACROS
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -46,10 +42,12 @@ TEST(CBSTest, Skip) {
}
TEST(CBSTest, GetUint) {
static const uint8_t kData[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
static const uint8_t kData[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
uint8_t u8;
uint16_t u16;
uint32_t u32;
uint64_t u64;
CBS data;
CBS_init(&data, kData, sizeof(kData));
@@ -61,12 +59,22 @@ TEST(CBSTest, GetUint) {
EXPECT_EQ(0x40506u, u32);
ASSERT_TRUE(CBS_get_u32(&data, &u32));
EXPECT_EQ(0x708090au, u32);
ASSERT_TRUE(CBS_get_u64(&data, &u64));
EXPECT_EQ(0xb0c0d0e0f101112u, u64);
ASSERT_TRUE(CBS_get_last_u8(&data, &u8));
EXPECT_EQ(0xcu, u8);
EXPECT_EQ(0x14u, u8);
ASSERT_TRUE(CBS_get_last_u8(&data, &u8));
EXPECT_EQ(0xbu, u8);
EXPECT_EQ(0x13u, u8);
EXPECT_FALSE(CBS_get_u8(&data, &u8));
EXPECT_FALSE(CBS_get_last_u8(&data, &u8));
CBS_init(&data, kData, sizeof(kData));
ASSERT_TRUE(CBS_get_u16le(&data, &u16));
EXPECT_EQ(0x0201u, u16);
ASSERT_TRUE(CBS_get_u32le(&data, &u32));
EXPECT_EQ(0x06050403u, u32);
ASSERT_TRUE(CBS_get_u64le(&data, &u64));
EXPECT_EQ(0x0e0d0c0b0a090807u, u64);
}
TEST(CBSTest, GetPrefixed) {
@@ -123,27 +131,27 @@ TEST(CBSTest, GetASN1) {
uint64_t value;
CBS_init(&data, kData1, sizeof(kData1));
EXPECT_FALSE(CBS_peek_asn1_tag(&data, 0x1));
EXPECT_TRUE(CBS_peek_asn1_tag(&data, 0x30));
EXPECT_FALSE(CBS_peek_asn1_tag(&data, CBS_ASN1_BOOLEAN));
EXPECT_TRUE(CBS_peek_asn1_tag(&data, CBS_ASN1_SEQUENCE));
ASSERT_TRUE(CBS_get_asn1(&data, &contents, 0x30));
ASSERT_TRUE(CBS_get_asn1(&data, &contents, CBS_ASN1_SEQUENCE));
EXPECT_EQ(Bytes("\x01\x02"), Bytes(CBS_data(&contents), CBS_len(&contents)));
CBS_init(&data, kData2, sizeof(kData2));
// data is truncated
EXPECT_FALSE(CBS_get_asn1(&data, &contents, 0x30));
EXPECT_FALSE(CBS_get_asn1(&data, &contents, CBS_ASN1_SEQUENCE));
CBS_init(&data, kData3, sizeof(kData3));
// zero byte length of length
EXPECT_FALSE(CBS_get_asn1(&data, &contents, 0x30));
EXPECT_FALSE(CBS_get_asn1(&data, &contents, CBS_ASN1_SEQUENCE));
CBS_init(&data, kData4, sizeof(kData4));
// long form mistakenly used.
EXPECT_FALSE(CBS_get_asn1(&data, &contents, 0x30));
EXPECT_FALSE(CBS_get_asn1(&data, &contents, CBS_ASN1_SEQUENCE));
CBS_init(&data, kData5, sizeof(kData5));
// length takes too many bytes.
EXPECT_FALSE(CBS_get_asn1(&data, &contents, 0x30));
EXPECT_FALSE(CBS_get_asn1(&data, &contents, CBS_ASN1_SEQUENCE));
CBS_init(&data, kData1, sizeof(kData1));
// wrong tag.
@@ -151,56 +159,72 @@ TEST(CBSTest, GetASN1) {
CBS_init(&data, NULL, 0);
// peek at empty data.
EXPECT_FALSE(CBS_peek_asn1_tag(&data, 0x30));
EXPECT_FALSE(CBS_peek_asn1_tag(&data, CBS_ASN1_SEQUENCE));
CBS_init(&data, NULL, 0);
// optional elements at empty data.
ASSERT_TRUE(CBS_get_optional_asn1(&data, &contents, &present, 0xa0));
ASSERT_TRUE(CBS_get_optional_asn1(
&data, &contents, &present,
CBS_ASN1_CONTEXT_SPECIFIC | CBS_ASN1_CONSTRUCTED | 0));
EXPECT_FALSE(present);
ASSERT_TRUE(
CBS_get_optional_asn1_octet_string(&data, &contents, &present, 0xa0));
ASSERT_TRUE(CBS_get_optional_asn1_octet_string(
&data, &contents, &present,
CBS_ASN1_CONTEXT_SPECIFIC | CBS_ASN1_CONSTRUCTED | 0));
EXPECT_FALSE(present);
EXPECT_EQ(0u, CBS_len(&contents));
ASSERT_TRUE(CBS_get_optional_asn1_octet_string(&data, &contents, NULL, 0xa0));
ASSERT_TRUE(CBS_get_optional_asn1_octet_string(
&data, &contents, NULL,
CBS_ASN1_CONTEXT_SPECIFIC | CBS_ASN1_CONSTRUCTED | 0));
EXPECT_EQ(0u, CBS_len(&contents));
ASSERT_TRUE(CBS_get_optional_asn1_uint64(&data, &value, 0xa0, 42));
ASSERT_TRUE(CBS_get_optional_asn1_uint64(
&data, &value, CBS_ASN1_CONTEXT_SPECIFIC | CBS_ASN1_CONSTRUCTED | 0, 42));
EXPECT_EQ(42u, value);
CBS_init(&data, kData6, sizeof(kData6));
// optional element.
ASSERT_TRUE(CBS_get_optional_asn1(&data, &contents, &present, 0xa0));
ASSERT_TRUE(CBS_get_optional_asn1(
&data, &contents, &present,
CBS_ASN1_CONTEXT_SPECIFIC | CBS_ASN1_CONSTRUCTED | 0));
EXPECT_FALSE(present);
ASSERT_TRUE(CBS_get_optional_asn1(&data, &contents, &present, 0xa1));
ASSERT_TRUE(CBS_get_optional_asn1(
&data, &contents, &present,
CBS_ASN1_CONTEXT_SPECIFIC | CBS_ASN1_CONSTRUCTED | 1));
EXPECT_TRUE(present);
EXPECT_EQ(Bytes("\x04\x01\x01"),
Bytes(CBS_data(&contents), CBS_len(&contents)));
CBS_init(&data, kData6, sizeof(kData6));
// optional octet string.
ASSERT_TRUE(
CBS_get_optional_asn1_octet_string(&data, &contents, &present, 0xa0));
ASSERT_TRUE(CBS_get_optional_asn1_octet_string(
&data, &contents, &present,
CBS_ASN1_CONTEXT_SPECIFIC | CBS_ASN1_CONSTRUCTED | 0));
EXPECT_FALSE(present);
EXPECT_EQ(0u, CBS_len(&contents));
ASSERT_TRUE(
CBS_get_optional_asn1_octet_string(&data, &contents, &present, 0xa1));
ASSERT_TRUE(CBS_get_optional_asn1_octet_string(
&data, &contents, &present,
CBS_ASN1_CONTEXT_SPECIFIC | CBS_ASN1_CONSTRUCTED | 1));
EXPECT_TRUE(present);
EXPECT_EQ(Bytes("\x01"), Bytes(CBS_data(&contents), CBS_len(&contents)));
CBS_init(&data, kData7, sizeof(kData7));
// invalid optional octet string.
EXPECT_FALSE(
CBS_get_optional_asn1_octet_string(&data, &contents, &present, 0xa1));
EXPECT_FALSE(CBS_get_optional_asn1_octet_string(
&data, &contents, &present,
CBS_ASN1_CONTEXT_SPECIFIC | CBS_ASN1_CONSTRUCTED | 1));
CBS_init(&data, kData8, sizeof(kData8));
// optional integer.
ASSERT_TRUE(CBS_get_optional_asn1_uint64(&data, &value, 0xa0, 42));
ASSERT_TRUE(CBS_get_optional_asn1_uint64(
&data, &value, CBS_ASN1_CONTEXT_SPECIFIC | CBS_ASN1_CONSTRUCTED | 0, 42));
EXPECT_EQ(42u, value);
ASSERT_TRUE(CBS_get_optional_asn1_uint64(&data, &value, 0xa1, 42));
ASSERT_TRUE(CBS_get_optional_asn1_uint64(
&data, &value, CBS_ASN1_CONTEXT_SPECIFIC | CBS_ASN1_CONSTRUCTED | 1, 42));
EXPECT_EQ(1u, value);
CBS_init(&data, kData9, sizeof(kData9));
// invalid optional integer.
EXPECT_FALSE(CBS_get_optional_asn1_uint64(&data, &value, 0xa1, 42));
EXPECT_FALSE(CBS_get_optional_asn1_uint64(
&data, &value, CBS_ASN1_CONTEXT_SPECIFIC | CBS_ASN1_CONSTRUCTED | 1, 42));
unsigned tag;
CBS_init(&data, kData1, sizeof(kData1));
@@ -217,6 +241,54 @@ TEST(CBSTest, GetASN1) {
Bytes(CBS_data(&contents), CBS_len(&contents)));
}
TEST(CBSTest, ParseASN1Tag) {
const struct {
bool ok;
unsigned tag;
std::vector<uint8_t> in;
} kTests[] = {
{true, CBS_ASN1_SEQUENCE, {0x30, 0}},
{true, CBS_ASN1_CONTEXT_SPECIFIC | CBS_ASN1_CONSTRUCTED | 4, {0xa4, 0}},
{true, CBS_ASN1_APPLICATION | 30, {0x5e, 0}},
{true, CBS_ASN1_APPLICATION | 31, {0x5f, 0x1f, 0}},
{true, CBS_ASN1_APPLICATION | 32, {0x5f, 0x20, 0}},
{true,
CBS_ASN1_PRIVATE | CBS_ASN1_CONSTRUCTED | 0x1fffffff,
{0xff, 0x81, 0xff, 0xff, 0xff, 0x7f, 0}},
// Tag number fits in unsigned but not |CBS_ASN1_TAG_NUMBER_MASK|.
{false, 0, {0xff, 0x82, 0xff, 0xff, 0xff, 0x7f, 0}},
// Tag number does not fit in unsigned.
{false, 0, {0xff, 0x90, 0x80, 0x80, 0x80, 0, 0}},
// Tag number is not minimally-encoded
{false, 0, {0x5f, 0x80, 0x1f, 0}},
// Tag number should have used short form.
{false, 0, {0x5f, 0x80, 0x1e, 0}},
};
for (const auto &t : kTests) {
SCOPED_TRACE(Bytes(t.in));
unsigned tag;
CBS cbs, child;
CBS_init(&cbs, t.in.data(), t.in.size());
ASSERT_EQ(t.ok, !!CBS_get_any_asn1(&cbs, &child, &tag));
if (t.ok) {
EXPECT_EQ(t.tag, tag);
EXPECT_EQ(0u, CBS_len(&child));
EXPECT_EQ(0u, CBS_len(&cbs));
CBS_init(&cbs, t.in.data(), t.in.size());
EXPECT_TRUE(CBS_peek_asn1_tag(&cbs, t.tag));
EXPECT_FALSE(CBS_peek_asn1_tag(&cbs, t.tag + 1));
EXPECT_TRUE(CBS_get_asn1(&cbs, &child, t.tag));
EXPECT_EQ(0u, CBS_len(&child));
EXPECT_EQ(0u, CBS_len(&cbs));
CBS_init(&cbs, t.in.data(), t.in.size());
EXPECT_FALSE(CBS_get_asn1(&cbs, &child, t.tag + 1));
}
}
}
TEST(CBSTest, GetOptionalASN1Bool) {
static const uint8_t kTrue[] = {0x0a, 3, CBS_ASN1_BOOLEAN, 1, 0xff};
static const uint8_t kFalse[] = {0x0a, 3, CBS_ASN1_BOOLEAN, 1, 0x00};
@@ -250,7 +322,11 @@ TEST(CBBTest, InitUninitialized) {
}
TEST(CBBTest, Basic) {
static const uint8_t kExpected[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc};
static const uint8_t kExpected[] = {1, 2, 3, 4, 5, 6, 7,
8, 9, 0xa, 0xb, 0xc, 0xd, 0xe,
0xf, 0x10, 0x11, 0x12, 0x13, 0x14, 3, 2,
10, 9, 8, 7, 0x12, 0x11, 0x10,
0xf, 0xe, 0xd, 0xc, 0xb};
uint8_t *buf;
size_t buf_len;
@@ -263,7 +339,11 @@ TEST(CBBTest, Basic) {
ASSERT_TRUE(CBB_add_u16(cbb.get(), 0x203));
ASSERT_TRUE(CBB_add_u24(cbb.get(), 0x40506));
ASSERT_TRUE(CBB_add_u32(cbb.get(), 0x708090a));
ASSERT_TRUE(CBB_add_bytes(cbb.get(), (const uint8_t *)"\x0b\x0c", 2));
ASSERT_TRUE(CBB_add_u64(cbb.get(), 0xb0c0d0e0f101112));
ASSERT_TRUE(CBB_add_bytes(cbb.get(), (const uint8_t *)"\x13\x14", 2));
ASSERT_TRUE(CBB_add_u16le(cbb.get(), 0x203));
ASSERT_TRUE(CBB_add_u32le(cbb.get(), 0x708090a));
ASSERT_TRUE(CBB_add_u64le(cbb.get(), 0xb0c0d0e0f101112));
ASSERT_TRUE(CBB_finish(cbb.get(), &buf, &buf_len));
bssl::UniquePtr<uint8_t> scoper(buf);
@@ -416,15 +496,42 @@ TEST(CBBTest, Misuse) {
}
TEST(CBBTest, ASN1) {
static const uint8_t kExpected[] = {0x30, 3, 1, 2, 3};
static const uint8_t kExpected[] = {
// SEQUENCE { 1 2 3 }
0x30, 3, 1, 2, 3,
// [4 CONSTRUCTED] { 4 5 6 }
0xa4, 3, 4, 5, 6,
// [APPLICATION 30 PRIMITIVE] { 7 8 9 }
0x5e, 3, 7, 8, 9,
// [APPLICATION 31 PRIMITIVE] { 10 11 12 }
0x5f, 0x1f, 3, 10, 11, 12,
// [PRIVATE 2^29-1 CONSTRUCTED] { 13 14 15 }
0xff, 0x81, 0xff, 0xff, 0xff, 0x7f, 3, 13, 14, 15,
};
uint8_t *buf;
size_t buf_len;
bssl::ScopedCBB cbb;
CBB contents, inner_contents;
ASSERT_TRUE(CBB_init(cbb.get(), 0));
ASSERT_TRUE(CBB_add_asn1(cbb.get(), &contents, 0x30));
ASSERT_TRUE(CBB_add_asn1(cbb.get(), &contents, CBS_ASN1_SEQUENCE));
ASSERT_TRUE(CBB_add_bytes(&contents, (const uint8_t *)"\x01\x02\x03", 3));
ASSERT_TRUE(
CBB_add_asn1(cbb.get(), &contents,
CBS_ASN1_CONTEXT_SPECIFIC | CBS_ASN1_CONSTRUCTED | 4));
ASSERT_TRUE(CBB_add_bytes(&contents, (const uint8_t *)"\x04\x05\x06", 3));
ASSERT_TRUE(
CBB_add_asn1(cbb.get(), &contents,
CBS_ASN1_APPLICATION | 30));
ASSERT_TRUE(CBB_add_bytes(&contents, (const uint8_t *)"\x07\x08\x09", 3));
ASSERT_TRUE(
CBB_add_asn1(cbb.get(), &contents,
CBS_ASN1_APPLICATION | 31));
ASSERT_TRUE(CBB_add_bytes(&contents, (const uint8_t *)"\x0a\x0b\x0c", 3));
ASSERT_TRUE(
CBB_add_asn1(cbb.get(), &contents,
CBS_ASN1_PRIVATE | CBS_ASN1_CONSTRUCTED | 0x1fffffff));
ASSERT_TRUE(CBB_add_bytes(&contents, (const uint8_t *)"\x0d\x0e\x0f", 3));
ASSERT_TRUE(CBB_finish(cbb.get(), &buf, &buf_len));
bssl::UniquePtr<uint8_t> scoper(buf);
@@ -432,7 +539,7 @@ TEST(CBBTest, ASN1) {
std::vector<uint8_t> test_data(100000, 0x42);
ASSERT_TRUE(CBB_init(cbb.get(), 0));
ASSERT_TRUE(CBB_add_asn1(cbb.get(), &contents, 0x30));
ASSERT_TRUE(CBB_add_asn1(cbb.get(), &contents, CBS_ASN1_SEQUENCE));
ASSERT_TRUE(CBB_add_bytes(&contents, test_data.data(), 130));
ASSERT_TRUE(CBB_finish(cbb.get(), &buf, &buf_len));
scoper.reset(buf);
@@ -442,7 +549,7 @@ TEST(CBBTest, ASN1) {
EXPECT_EQ(Bytes(test_data.data(), 130), Bytes(buf + 3, 130));
ASSERT_TRUE(CBB_init(cbb.get(), 0));
ASSERT_TRUE(CBB_add_asn1(cbb.get(), &contents, 0x30));
ASSERT_TRUE(CBB_add_asn1(cbb.get(), &contents, CBS_ASN1_SEQUENCE));
ASSERT_TRUE(CBB_add_bytes(&contents, test_data.data(), 1000));
ASSERT_TRUE(CBB_finish(cbb.get(), &buf, &buf_len));
scoper.reset(buf);
@@ -452,8 +559,8 @@ TEST(CBBTest, ASN1) {
EXPECT_EQ(Bytes(test_data.data(), 1000), Bytes(buf + 4, 1000));
ASSERT_TRUE(CBB_init(cbb.get(), 0));
ASSERT_TRUE(CBB_add_asn1(cbb.get(), &contents, 0x30));
ASSERT_TRUE(CBB_add_asn1(&contents, &inner_contents, 0x30));
ASSERT_TRUE(CBB_add_asn1(cbb.get(), &contents, CBS_ASN1_SEQUENCE));
ASSERT_TRUE(CBB_add_asn1(&contents, &inner_contents, CBS_ASN1_SEQUENCE));
ASSERT_TRUE(CBB_add_bytes(&inner_contents, test_data.data(), 100000));
ASSERT_TRUE(CBB_finish(cbb.get(), &buf, &buf_len));
scoper.reset(buf);
@@ -467,19 +574,18 @@ static void ExpectBerConvert(const char *name, const uint8_t *der_expected,
size_t der_len, const uint8_t *ber,
size_t ber_len) {
SCOPED_TRACE(name);
CBS in;
uint8_t *out;
size_t out_len;
CBS in, out;
uint8_t *storage;
CBS_init(&in, ber, ber_len);
ASSERT_TRUE(CBS_asn1_ber_to_der(&in, &out, &out_len));
bssl::UniquePtr<uint8_t> scoper(out);
ASSERT_TRUE(CBS_asn1_ber_to_der(&in, &out, &storage));
bssl::UniquePtr<uint8_t> scoper(storage);
if (out == NULL) {
EXPECT_EQ(Bytes(der_expected, der_len), Bytes(ber, ber_len));
} else {
EXPECT_EQ(Bytes(der_expected, der_len), Bytes(CBS_data(&out), CBS_len(&out)));
if (storage != nullptr) {
EXPECT_NE(Bytes(der_expected, der_len), Bytes(ber, ber_len));
EXPECT_EQ(Bytes(der_expected, der_len), Bytes(out, out_len));
} else {
EXPECT_EQ(Bytes(der_expected, der_len), Bytes(ber, ber_len));
}
}
@@ -490,6 +596,12 @@ TEST(CBSTest, BerConvert) {
static const uint8_t kIndefBER[] = {0x30, 0x80, 0x01, 0x01, 0x02, 0x00, 0x00};
static const uint8_t kIndefDER[] = {0x30, 0x03, 0x01, 0x01, 0x02};
// kIndefBER2 contains a constructed [APPLICATION 31] with an indefinite
// length.
static const uint8_t kIndefBER2[] = {0x7f, 0x1f, 0x80, 0x01,
0x01, 0x02, 0x00, 0x00};
static const uint8_t kIndefDER2[] = {0x7f, 0x1f, 0x03, 0x01, 0x01, 0x02};
// kOctetStringBER contains an indefinite length OCTET STRING with two parts.
// These parts need to be concatenated in DER form.
static const uint8_t kOctetStringBER[] = {0x24, 0x80, 0x04, 0x02, 0, 1,
@@ -534,6 +646,8 @@ TEST(CBSTest, BerConvert) {
sizeof(kSimpleBER));
ExpectBerConvert("kIndefBER", kIndefDER, sizeof(kIndefDER), kIndefBER,
sizeof(kIndefBER));
ExpectBerConvert("kIndefBER2", kIndefDER2, sizeof(kIndefDER2), kIndefBER2,
sizeof(kIndefBER2));
ExpectBerConvert("kOctetStringBER", kOctetStringDER, sizeof(kOctetStringDER),
kOctetStringBER, sizeof(kOctetStringBER));
ExpectBerConvert("kNSSBER", kNSSDER, sizeof(kNSSDER), kNSSBER,
@@ -653,6 +767,79 @@ TEST(CBSTest, ASN1Uint64) {
}
}
struct ASN1Int64Test {
int64_t value;
const char *encoding;
size_t encoding_len;
};
static const ASN1Int64Test kASN1Int64Tests[] = {
{0, "\x02\x01\x00", 3},
{1, "\x02\x01\x01", 3},
{-1, "\x02\x01\xff", 3},
{127, "\x02\x01\x7f", 3},
{-127, "\x02\x01\x81", 3},
{128, "\x02\x02\x00\x80", 4},
{-128, "\x02\x01\x80", 3},
{129, "\x02\x02\x00\x81", 4},
{-129, "\x02\x02\xff\x7f", 4},
{0xdeadbeef, "\x02\x05\x00\xde\xad\xbe\xef", 7},
{INT64_C(0x0102030405060708), "\x02\x08\x01\x02\x03\x04\x05\x06\x07\x08",
10},
{INT64_MIN, "\x02\x08\x80\x00\x00\x00\x00\x00\x00\x00", 10},
{INT64_MAX, "\x02\x08\x7f\xff\xff\xff\xff\xff\xff\xff", 10},
};
struct ASN1InvalidInt64Test {
const char *encoding;
size_t encoding_len;
};
static const ASN1InvalidInt64Test kASN1InvalidInt64Tests[] = {
// Bad tag.
{"\x03\x01\x00", 3},
// Empty contents.
{"\x02\x00", 2},
// Overflow.
{"\x02\x09\x01\x00\x00\x00\x00\x00\x00\x00\x00", 11},
// Leading zeros.
{"\x02\x02\x00\x01", 4},
// Leading 0xff.
{"\x02\x02\xff\xff", 4},
};
TEST(CBSTest, ASN1Int64) {
for (size_t i = 0; i < OPENSSL_ARRAY_SIZE(kASN1Int64Tests); i++) {
SCOPED_TRACE(i);
const ASN1Int64Test *test = &kASN1Int64Tests[i];
CBS cbs;
int64_t value;
uint8_t *out;
size_t len;
CBS_init(&cbs, (const uint8_t *)test->encoding, test->encoding_len);
ASSERT_TRUE(CBS_get_asn1_int64(&cbs, &value));
EXPECT_EQ(0u, CBS_len(&cbs));
EXPECT_EQ(test->value, value);
bssl::ScopedCBB cbb;
ASSERT_TRUE(CBB_init(cbb.get(), 0));
ASSERT_TRUE(CBB_add_asn1_int64(cbb.get(), test->value));
ASSERT_TRUE(CBB_finish(cbb.get(), &out, &len));
bssl::UniquePtr<uint8_t> scoper(out);
EXPECT_EQ(Bytes(test->encoding, test->encoding_len), Bytes(out, len));
}
for (size_t i = 0; i < OPENSSL_ARRAY_SIZE(kASN1InvalidInt64Tests); i++) {
const ASN1InvalidInt64Test *test = &kASN1InvalidInt64Tests[i];
CBS cbs;
int64_t value;
CBS_init(&cbs, (const uint8_t *)test->encoding, test->encoding_len);
EXPECT_FALSE(CBS_get_asn1_int64(&cbs, &value));
}
}
TEST(CBBTest, Zero) {
CBB cbb;
CBB_zero(&cbb);
@@ -787,3 +974,386 @@ TEST(CBSTest, BitString) {
CBS_asn1_bitstring_has_bit(&cbs, test.bit));
}
}
TEST(CBBTest, AddOIDFromText) {
const struct {
const char *text;
std::vector<uint8_t> der;
} kValidOIDs[] = {
// Some valid values.
{"0.0", {0x00}},
{"0.2.3.4", {0x2, 0x3, 0x4}},
{"1.2.3.4", {0x2a, 0x3, 0x4}},
{"2.2.3.4", {0x52, 0x3, 0x4}},
{"1.2.840.113554.4.1.72585",
{0x2a, 0x86, 0x48, 0x86, 0xf7, 0x12, 0x04, 0x01, 0x84, 0xb7, 0x09}},
// Test edge cases around the first component.
{"0.39", {0x27}},
{"1.0", {0x28}},
{"1.39", {0x4f}},
{"2.0", {0x50}},
{"2.1", {0x51}},
{"2.40", {0x78}},
// Edge cases near an overflow.
{"1.2.18446744073709551615",
{0x2a, 0x81, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f}},
{"2.18446744073709551535",
{0x81, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f}},
};
const char *kInvalidTexts[] = {
// Invalid second component.
"0.40",
"1.40",
// Invalid first component.
"3.1",
// The empty string is not an OID.
"",
// No empty components.
".1.2.3.4.5",
"1..2.3.4.5",
"1.2.3.4.5.",
// There must be at least two components.
"1",
// No extra leading zeros.
"00.1.2.3.4",
"01.1.2.3.4",
// Overflow for both components or 40*A + B.
"1.2.18446744073709551616",
"2.18446744073709551536",
};
const std::vector<uint8_t> kInvalidDER[] = {
// The empty string is not an OID.
{},
// Non-minimal representation.
{0x80, 0x01},
// Overflow. This is the DER representation of
// 1.2.840.113554.4.1.72585.18446744073709551616. (The final value is
// 2^64.)
{0x2a, 0x86, 0x48, 0x86, 0xf7, 0x12, 0x04, 0x01, 0x84, 0xb7, 0x09,
0x82, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00},
};
for (const auto &t : kValidOIDs) {
SCOPED_TRACE(t.text);
bssl::ScopedCBB cbb;
ASSERT_TRUE(CBB_init(cbb.get(), 0));
ASSERT_TRUE(CBB_add_asn1_oid_from_text(cbb.get(), t.text, strlen(t.text)));
uint8_t *out;
size_t len;
ASSERT_TRUE(CBB_finish(cbb.get(), &out, &len));
bssl::UniquePtr<uint8_t> free_out(out);
EXPECT_EQ(Bytes(t.der), Bytes(out, len));
CBS cbs;
CBS_init(&cbs, t.der.data(), t.der.size());
bssl::UniquePtr<char> text(CBS_asn1_oid_to_text(&cbs));
ASSERT_TRUE(text.get());
EXPECT_STREQ(t.text, text.get());
}
for (const char *t : kInvalidTexts) {
SCOPED_TRACE(t);
bssl::ScopedCBB cbb;
ASSERT_TRUE(CBB_init(cbb.get(), 0));
EXPECT_FALSE(CBB_add_asn1_oid_from_text(cbb.get(), t, strlen(t)));
}
for (const auto &t : kInvalidDER) {
SCOPED_TRACE(Bytes(t));
CBS cbs;
CBS_init(&cbs, t.data(), t.size());
bssl::UniquePtr<char> text(CBS_asn1_oid_to_text(&cbs));
EXPECT_FALSE(text);
}
}
TEST(CBBTest, FlushASN1SetOf) {
const struct {
std::vector<uint8_t> in, out;
} kValidInputs[] = {
// No elements.
{{}, {}},
// One element.
{{0x30, 0x00}, {0x30, 0x00}},
// Two identical elements.
{{0x30, 0x00, 0x30, 0x00}, {0x30, 0x00, 0x30, 0x00}},
// clang-format off
{{0x30, 0x02, 0x00, 0x00,
0x30, 0x00,
0x01, 0x00,
0x30, 0x02, 0x00, 0x00,
0x30, 0x03, 0x00, 0x00, 0x00,
0x30, 0x00,
0x30, 0x03, 0x00, 0x00, 0x01,
0x30, 0x01, 0x00,
0x01, 0x01, 0x00},
{0x01, 0x00,
0x01, 0x01, 0x00,
0x30, 0x00,
0x30, 0x00,
0x30, 0x01, 0x00,
0x30, 0x02, 0x00, 0x00,
0x30, 0x02, 0x00, 0x00,
0x30, 0x03, 0x00, 0x00, 0x00,
0x30, 0x03, 0x00, 0x00, 0x01}},
// clang-format on
};
for (const auto &t : kValidInputs) {
SCOPED_TRACE(Bytes(t.in));
bssl::ScopedCBB cbb;
CBB child;
ASSERT_TRUE(CBB_init(cbb.get(), 0));
ASSERT_TRUE(CBB_add_asn1(cbb.get(), &child, CBS_ASN1_SET));
ASSERT_TRUE(CBB_add_bytes(&child, t.in.data(), t.in.size()));
ASSERT_TRUE(CBB_flush_asn1_set_of(&child));
EXPECT_EQ(Bytes(t.out), Bytes(CBB_data(&child), CBB_len(&child)));
// Running it again should be idempotent.
ASSERT_TRUE(CBB_flush_asn1_set_of(&child));
EXPECT_EQ(Bytes(t.out), Bytes(CBB_data(&child), CBB_len(&child)));
// The ASN.1 header remain intact.
ASSERT_TRUE(CBB_flush(cbb.get()));
EXPECT_EQ(0x31, CBB_data(cbb.get())[0]);
}
const std::vector<uint8_t> kInvalidInputs[] = {
{0x30},
{0x30, 0x01},
{0x30, 0x00, 0x30, 0x00, 0x30, 0x01},
};
for (const auto &t : kInvalidInputs) {
SCOPED_TRACE(Bytes(t));
bssl::ScopedCBB cbb;
CBB child;
ASSERT_TRUE(CBB_init(cbb.get(), 0));
ASSERT_TRUE(CBB_add_asn1(cbb.get(), &child, CBS_ASN1_SET));
ASSERT_TRUE(CBB_add_bytes(&child, t.data(), t.size()));
EXPECT_FALSE(CBB_flush_asn1_set_of(&child));
}
}
template <class T>
static std::vector<uint8_t> LiteralToBytes(const T *str) {
std::vector<uint8_t> ret;
for (; *str != 0; str++) {
for (size_t i = 0; i < sizeof(T); i++) {
ret.push_back(static_cast<uint8_t>(*str >> (8 * (sizeof(T) - 1 - i))));
}
}
return ret;
}
static std::vector<uint32_t> LiteralToCodePoints(const char32_t *str) {
std::vector<uint32_t> ret;
for (; *str != 0; str++) {
ret.push_back(static_cast<uint32_t>(*str));
}
return ret;
}
TEST(CBBTest, Unicode) {
struct {
int (*decode)(CBS *, uint32_t *);
int (*encode)(CBB *, uint32_t);
std::vector<uint8_t> in;
std::vector<uint32_t> out;
bool ok;
} kTests[] = {
{cbs_get_utf8, cbb_add_utf8,
// This test string captures all four cases in UTF-8.
LiteralToBytes(u8"Hello, 世界! ¡Hola, 🌎!"),
LiteralToCodePoints(U"Hello, 世界! ¡Hola, 🌎!"), true},
// Some invalid inputs adapted from
// http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt
// 2.1 First possible sequence of a certain length. (5- and 6-bit
// sequences no longer exist.)
{cbs_get_utf8, cbb_add_utf8, {0xf8, 0x88, 0x80, 0x80, 0x80}, {}, false},
{cbs_get_utf8,
cbb_add_utf8,
{0xfc, 0x84, 0x80, 0x80, 0x80, 0x80},
{},
false},
// 3.1 Unexpected continuation bytes.
{cbs_get_utf8, cbb_add_utf8, {0x80}, {}, false},
{cbs_get_utf8, cbb_add_utf8, {0xbf}, {}, false},
// 3.2 Lonely start characters.
{cbs_get_utf8, cbb_add_utf8, {0xc0, ' '}, {}, false},
{cbs_get_utf8, cbb_add_utf8, {0xe0, ' '}, {}, false},
{cbs_get_utf8, cbb_add_utf8, {0xf0, ' '}, {}, false},
// 3.3 Sequences with last continuation byte missing
{cbs_get_utf8, cbb_add_utf8, {0xc0}, {}, false},
{cbs_get_utf8, cbb_add_utf8, {0xe0, 0x80}, {}, false},
{cbs_get_utf8, cbb_add_utf8, {0xf0, 0x80, 0x80}, {}, false},
// Variation of the above with unexpected spaces.
{cbs_get_utf8, cbb_add_utf8, {0xe0, 0x80, ' '}, {}, false},
{cbs_get_utf8, cbb_add_utf8, {0xf0, 0x80, 0x80, ' '}, {}, false},
// 4.1 Examples of an overlong ASCII character
{cbs_get_utf8, cbb_add_utf8, {0xc0, 0xaf}, {}, false},
{cbs_get_utf8, cbb_add_utf8, {0xe0, 0x80, 0xaf}, {}, false},
{cbs_get_utf8, cbb_add_utf8, {0xf0, 0x80, 0x80, 0xaf}, {}, false},
// 4.2 Maximum overlong sequences
{cbs_get_utf8, cbb_add_utf8, {0xc1, 0xbf}, {}, false},
{cbs_get_utf8, cbb_add_utf8, {0xe0, 0x9f, 0xbf}, {}, false},
{cbs_get_utf8, cbb_add_utf8, {0xf0, 0x8f, 0xbf, 0xbf}, {}, false},
// 4.3 Overlong representation of the NUL character
{cbs_get_utf8, cbb_add_utf8, {0xc0, 0x80}, {}, false},
{cbs_get_utf8, cbb_add_utf8, {0xe0, 0x80, 0x80}, {}, false},
{cbs_get_utf8, cbb_add_utf8, {0xf0, 0x80, 0x80, 0x80}, {}, false},
// 5.1 Single UTF-16 surrogates
{cbs_get_utf8, cbb_add_utf8, {0xed, 0xa0, 0x80}, {}, false},
{cbs_get_utf8, cbb_add_utf8, {0xed, 0xad, 0xbf}, {}, false},
{cbs_get_utf8, cbb_add_utf8, {0xed, 0xae, 0x80}, {}, false},
{cbs_get_utf8, cbb_add_utf8, {0xed, 0xb0, 0x80}, {}, false},
{cbs_get_utf8, cbb_add_utf8, {0xed, 0xbe, 0x80}, {}, false},
{cbs_get_utf8, cbb_add_utf8, {0xed, 0xbf, 0xbf}, {}, false},
// 5.2 Paired UTF-16 surrogates
{cbs_get_utf8,
cbb_add_utf8,
{0xed, 0xa0, 0x80, 0xed, 0xb0, 0x80},
{},
false},
{cbs_get_utf8,
cbb_add_utf8,
{0xed, 0xa0, 0x80, 0xed, 0xbf, 0xbf},
{},
false},
{cbs_get_utf8,
cbb_add_utf8,
{0xed, 0xad, 0xbf, 0xed, 0xb0, 0x80},
{},
false},
{cbs_get_utf8,
cbb_add_utf8,
{0xed, 0xad, 0xbf, 0xed, 0xbf, 0xbf},
{},
false},
{cbs_get_utf8,
cbb_add_utf8,
{0xed, 0xae, 0x80, 0xed, 0xb0, 0x80},
{},
false},
{cbs_get_utf8,
cbb_add_utf8,
{0xed, 0xae, 0x80, 0xed, 0xbf, 0xbf},
{},
false},
{cbs_get_utf8,
cbb_add_utf8,
{0xed, 0xaf, 0xbf, 0xed, 0xb0, 0x80},
{},
false},
{cbs_get_utf8,
cbb_add_utf8,
{0xed, 0xaf, 0xbf, 0xed, 0xbf, 0xbf},
{},
false},
// 5.3 Noncharacter code positions
{cbs_get_utf8, cbb_add_utf8, {0xef, 0xbf, 0xbe}, {}, false},
{cbs_get_utf8, cbb_add_utf8, {0xef, 0xbf, 0xbf}, {}, false},
{cbs_get_utf8, cbb_add_utf8, {0xef, 0xb7, 0x90}, {}, false},
{cbs_get_utf8, cbb_add_utf8, {0xef, 0xb7, 0xaf}, {}, false},
{cbs_get_utf8, cbb_add_utf8, {0xf0, 0x9f, 0xbf, 0xbe}, {}, false},
{cbs_get_utf8, cbb_add_utf8, {0xf0, 0x9f, 0xbf, 0xbf}, {}, false},
{cbs_get_latin1, cbb_add_latin1, LiteralToBytes("\xa1Hola!"),
LiteralToCodePoints(U"¡Hola!"), true},
// UCS-2 matches UTF-16 on the BMP.
{cbs_get_ucs2_be, cbb_add_ucs2_be, LiteralToBytes(u"Hello, 世界!"),
LiteralToCodePoints(U"Hello, 世界!"), true},
// It does not support characters beyond the BMP.
{cbs_get_ucs2_be, cbb_add_ucs2_be,
LiteralToBytes(u"Hello, 世界! ¡Hola, 🌎!"),
LiteralToCodePoints(U"Hello, 世界! ¡Hola, "), false},
// Unpaired surrogates and non-characters are also rejected.
{cbs_get_ucs2_be, cbb_add_ucs2_be, {0xd8, 0x00}, {}, false},
{cbs_get_ucs2_be, cbb_add_ucs2_be, {0xff, 0xfe}, {}, false},
{cbs_get_utf32_be, cbb_add_utf32_be,
LiteralToBytes(U"Hello, 世界! ¡Hola, 🌎!"),
LiteralToCodePoints(U"Hello, 世界! ¡Hola, 🌎!"), true},
// Unpaired surrogates and non-characters are rejected.
{cbs_get_utf32_be, cbb_add_utf32_be, {0x00, 0x00, 0xd8, 0x00}, {}, false},
{cbs_get_utf32_be, cbb_add_utf32_be, {0x00, 0x00, 0xff, 0xfe}, {}, false},
// Test that the NUL character can be encoded.
{cbs_get_latin1, cbb_add_latin1, {0}, {0}, true},
{cbs_get_utf8, cbb_add_utf8, {0}, {0}, true},
{cbs_get_ucs2_be, cbb_add_ucs2_be, {0, 0}, {0}, true},
{cbs_get_utf32_be, cbb_add_utf32_be, {0, 0, 0, 0}, {0}, true},
};
for (const auto &t : kTests) {
SCOPED_TRACE(Bytes(t.in));
// Test decoding.
CBS cbs;
CBS_init(&cbs, t.in.data(), t.in.size());
std::vector<uint32_t> out;
bool ok = true;
while (CBS_len(&cbs) != 0) {
uint32_t u;
if (!t.decode(&cbs, &u)) {
ok = false;
break;
}
out.push_back(u);
}
EXPECT_EQ(t.ok, ok);
EXPECT_EQ(t.out, out);
// Test encoding.
if (t.ok) {
bssl::ScopedCBB cbb;
ASSERT_TRUE(CBB_init(cbb.get(), 0));
for (uint32_t u : t.out) {
ASSERT_TRUE(t.encode(cbb.get(), u));
}
EXPECT_EQ(Bytes(t.in), Bytes(CBB_data(cbb.get()), CBB_len(cbb.get())));
}
}
static const uint32_t kBadCodePoints[] = {
// Surrogate pairs.
0xd800,
0xdfff,
// Non-characters.
0xfffe,
0xffff,
0xfdd0,
0x1fffe,
0x1ffff,
// Too big.
0x110000,
};
bssl::ScopedCBB cbb;
ASSERT_TRUE(CBB_init(cbb.get(), 0));
for (uint32_t v : kBadCodePoints) {
SCOPED_TRACE(v);
EXPECT_FALSE(cbb_add_utf8(cbb.get(), v));
EXPECT_FALSE(cbb_add_latin1(cbb.get(), v));
EXPECT_FALSE(cbb_add_ucs2_be(cbb.get(), v));
EXPECT_FALSE(cbb_add_utf32_be(cbb.get(), v));
}
// Additional values that are out of range.
EXPECT_FALSE(cbb_add_latin1(cbb.get(), 0x100));
EXPECT_FALSE(cbb_add_ucs2_be(cbb.get(), 0x10000));
EXPECT_EQ(1u, cbb_get_utf8_len(0));
EXPECT_EQ(1u, cbb_get_utf8_len(0x7f));
EXPECT_EQ(2u, cbb_get_utf8_len(0x80));
EXPECT_EQ(2u, cbb_get_utf8_len(0x7ff));
EXPECT_EQ(3u, cbb_get_utf8_len(0x800));
EXPECT_EQ(3u, cbb_get_utf8_len(0xffff));
EXPECT_EQ(4u, cbb_get_utf8_len(0x10000));
EXPECT_EQ(4u, cbb_get_utf8_len(0x10ffff));
}
+259 -15
View File
@@ -15,6 +15,7 @@
#include <openssl/bytestring.h>
#include <assert.h>
#include <limits.h>
#include <string.h>
#include <openssl/mem.h>
@@ -42,7 +43,7 @@ static int cbb_init(CBB *cbb, uint8_t *buf, size_t cap) {
base->error = 0;
cbb->base = base;
cbb->is_top_level = 1;
cbb->is_child = 0;
return 1;
}
@@ -74,11 +75,14 @@ int CBB_init_fixed(CBB *cbb, uint8_t *buf, size_t len) {
}
void CBB_cleanup(CBB *cbb) {
if (cbb->base) {
// Only top-level |CBB|s are cleaned up. Child |CBB|s are non-owning. They
// are implicitly discarded when the parent is flushed or cleaned up.
assert(cbb->is_top_level);
// Child |CBB|s are non-owning. They are implicitly discarded and should not
// be used with |CBB_cleanup| or |ScopedCBB|.
assert(!cbb->is_child);
if (cbb->is_child) {
return;
}
if (cbb->base) {
if (cbb->base->can_resize) {
OPENSSL_free(cbb->base->buf);
}
@@ -142,7 +146,7 @@ static int cbb_buffer_add(struct cbb_buffer_st *base, uint8_t **out,
return 1;
}
static int cbb_buffer_add_u(struct cbb_buffer_st *base, uint32_t v,
static int cbb_buffer_add_u(struct cbb_buffer_st *base, uint64_t v,
size_t len_len) {
if (len_len == 0) {
return 1;
@@ -167,7 +171,7 @@ static int cbb_buffer_add_u(struct cbb_buffer_st *base, uint32_t v,
}
int CBB_finish(CBB *cbb, uint8_t **out_data, size_t *out_len) {
if (!cbb->is_top_level) {
if (cbb->is_child) {
return 0;
}
@@ -308,6 +312,7 @@ static int cbb_add_length_prefixed(CBB *cbb, CBB *out_contents,
OPENSSL_memset(prefix_bytes, 0, len_len);
OPENSSL_memset(out_contents, 0, sizeof(CBB));
out_contents->base = cbb->base;
out_contents->is_child = 1;
cbb->child = out_contents;
cbb->child->offset = offset;
cbb->child->pending_len_len = len_len;
@@ -328,18 +333,47 @@ int CBB_add_u24_length_prefixed(CBB *cbb, CBB *out_contents) {
return cbb_add_length_prefixed(cbb, out_contents, 3);
}
// add_base128_integer encodes |v| as a big-endian base-128 integer where the
// high bit of each byte indicates where there is more data. This is the
// encoding used in DER for both high tag number form and OID components.
static int add_base128_integer(CBB *cbb, uint64_t v) {
unsigned len_len = 0;
uint64_t copy = v;
while (copy > 0) {
len_len++;
copy >>= 7;
}
if (len_len == 0) {
len_len = 1; // Zero is encoded with one byte.
}
for (unsigned i = len_len - 1; i < len_len; i--) {
uint8_t byte = (v >> (7 * i)) & 0x7f;
if (i != 0) {
// The high bit denotes whether there is more data.
byte |= 0x80;
}
if (!CBB_add_u8(cbb, byte)) {
return 0;
}
}
return 1;
}
int CBB_add_asn1(CBB *cbb, CBB *out_contents, unsigned tag) {
if (tag > 0xff ||
(tag & 0x1f) == 0x1f) {
// Long form identifier octets are not supported. Further, all current valid
// tag serializations are 8 bits.
cbb->base->error = 1;
if (!CBB_flush(cbb)) {
return 0;
}
if (!CBB_flush(cbb) ||
// |tag|'s representation matches the DER encoding.
!CBB_add_u8(cbb, (uint8_t)tag)) {
// Split the tag into leading bits and tag number.
uint8_t tag_bits = (tag >> CBS_ASN1_TAG_SHIFT) & 0xe0;
unsigned tag_number = tag & CBS_ASN1_TAG_NUMBER_MASK;
if (tag_number >= 0x1f) {
// Set all the bits in the tag number to signal high tag number form.
if (!CBB_add_u8(cbb, tag_bits | 0x1f) ||
!add_base128_integer(cbb, tag_number)) {
return 0;
}
} else if (!CBB_add_u8(cbb, tag_bits | tag_number)) {
return 0;
}
@@ -350,6 +384,7 @@ int CBB_add_asn1(CBB *cbb, CBB *out_contents, unsigned tag) {
OPENSSL_memset(out_contents, 0, sizeof(CBB));
out_contents->base = cbb->base;
out_contents->is_child = 1;
cbb->child = out_contents;
cbb->child->offset = offset;
cbb->child->pending_len_len = 1;
@@ -412,6 +447,10 @@ int CBB_add_u16(CBB *cbb, uint16_t value) {
return cbb_buffer_add_u(cbb->base, value, 2);
}
int CBB_add_u16le(CBB *cbb, uint16_t value) {
return CBB_add_u16(cbb, CRYPTO_bswap2(value));
}
int CBB_add_u24(CBB *cbb, uint32_t value) {
if (!CBB_flush(cbb)) {
return 0;
@@ -428,6 +467,21 @@ int CBB_add_u32(CBB *cbb, uint32_t value) {
return cbb_buffer_add_u(cbb->base, value, 4);
}
int CBB_add_u32le(CBB *cbb, uint32_t value) {
return CBB_add_u32(cbb, CRYPTO_bswap4(value));
}
int CBB_add_u64(CBB *cbb, uint64_t value) {
if (!CBB_flush(cbb)) {
return 0;
}
return cbb_buffer_add_u(cbb->base, value, 8);
}
int CBB_add_u64le(CBB *cbb, uint64_t value) {
return CBB_add_u64(cbb, CRYPTO_bswap8(value));
}
void CBB_discard_child(CBB *cbb) {
if (cbb->child == NULL) {
return;
@@ -473,3 +527,193 @@ int CBB_add_asn1_uint64(CBB *cbb, uint64_t value) {
return CBB_flush(cbb);
}
int CBB_add_asn1_int64(CBB *cbb, int64_t value) {
if (value >= 0) {
return CBB_add_asn1_uint64(cbb, value);
}
union {
int64_t i;
uint8_t bytes[sizeof(int64_t)];
} u;
u.i = value;
int start = 7;
// Skip leading sign-extension bytes unless they are necessary.
while (start > 0 && (u.bytes[start] == 0xff && (u.bytes[start - 1] & 0x80))) {
start--;
}
CBB child;
if (!CBB_add_asn1(cbb, &child, CBS_ASN1_INTEGER)) {
return 0;
}
for (int i = start; i >= 0; i--) {
if (!CBB_add_u8(&child, u.bytes[i])) {
return 0;
}
}
return CBB_flush(cbb);
}
int CBB_add_asn1_octet_string(CBB *cbb, const uint8_t *data, size_t data_len) {
CBB child;
if (!CBB_add_asn1(cbb, &child, CBS_ASN1_OCTETSTRING) ||
!CBB_add_bytes(&child, data, data_len) ||
!CBB_flush(cbb)) {
return 0;
}
return 1;
}
int CBB_add_asn1_bool(CBB *cbb, int value) {
CBB child;
if (!CBB_add_asn1(cbb, &child, CBS_ASN1_BOOLEAN) ||
!CBB_add_u8(&child, value != 0 ? 0xff : 0) ||
!CBB_flush(cbb)) {
return 0;
}
return 1;
}
// parse_dotted_decimal parses one decimal component from |cbs|, where |cbs| is
// an OID literal, e.g., "1.2.840.113554.4.1.72585". It consumes both the
// component and the dot, so |cbs| may be passed into the function again for the
// next value.
static int parse_dotted_decimal(CBS *cbs, uint64_t *out) {
*out = 0;
int seen_digit = 0;
for (;;) {
// Valid terminators for a component are the end of the string or a
// non-terminal dot. If the string ends with a dot, this is not a valid OID
// string.
uint8_t u;
if (!CBS_get_u8(cbs, &u) ||
(u == '.' && CBS_len(cbs) > 0)) {
break;
}
if (u < '0' || u > '9' ||
// Forbid stray leading zeros.
(seen_digit && *out == 0) ||
// Check for overflow.
*out > UINT64_MAX / 10 ||
*out * 10 > UINT64_MAX - (u - '0')) {
return 0;
}
*out = *out * 10 + (u - '0');
seen_digit = 1;
}
// The empty string is not a legal OID component.
return seen_digit;
}
int CBB_add_asn1_oid_from_text(CBB *cbb, const char *text, size_t len) {
if (!CBB_flush(cbb)) {
return 0;
}
CBS cbs;
CBS_init(&cbs, (const uint8_t *)text, len);
// OIDs must have at least two components.
uint64_t a, b;
if (!parse_dotted_decimal(&cbs, &a) ||
!parse_dotted_decimal(&cbs, &b)) {
return 0;
}
// The first component is encoded as 40 * |a| + |b|. This assumes that |a| is
// 0, 1, or 2 and that, when it is 0 or 1, |b| is at most 39.
if (a > 2 ||
(a < 2 && b > 39) ||
b > UINT64_MAX - 80 ||
!add_base128_integer(cbb, 40u * a + b)) {
return 0;
}
// The remaining components are encoded unmodified.
while (CBS_len(&cbs) > 0) {
if (!parse_dotted_decimal(&cbs, &a) ||
!add_base128_integer(cbb, a)) {
return 0;
}
}
return 1;
}
static int compare_set_of_element(const void *a_ptr, const void *b_ptr) {
// See X.690, section 11.6 for the ordering. They are sorted in ascending
// order by their DER encoding.
const CBS *a = a_ptr, *b = b_ptr;
size_t a_len = CBS_len(a), b_len = CBS_len(b);
size_t min_len = a_len < b_len ? a_len : b_len;
int ret = OPENSSL_memcmp(CBS_data(a), CBS_data(b), min_len);
if (ret != 0) {
return ret;
}
if (a_len == b_len) {
return 0;
}
// If one is a prefix of the other, the shorter one sorts first. (This is not
// actually reachable. No DER encoding is a prefix of another DER encoding.)
return a_len < b_len ? -1 : 1;
}
int CBB_flush_asn1_set_of(CBB *cbb) {
if (!CBB_flush(cbb)) {
return 0;
}
CBS cbs;
size_t num_children = 0;
CBS_init(&cbs, CBB_data(cbb), CBB_len(cbb));
while (CBS_len(&cbs) != 0) {
if (!CBS_get_any_asn1_element(&cbs, NULL, NULL, NULL)) {
return 0;
}
num_children++;
}
if (num_children < 2) {
return 1; // Nothing to do. This is the common case for X.509.
}
if (num_children > ((size_t)-1) / sizeof(CBS)) {
return 0; // Overflow.
}
// Parse out the children and sort. We alias them into a copy of so they
// remain valid as we rewrite |cbb|.
int ret = 0;
size_t buf_len = CBB_len(cbb);
uint8_t *buf = OPENSSL_memdup(CBB_data(cbb), buf_len);
CBS *children = OPENSSL_malloc(num_children * sizeof(CBS));
if (buf == NULL || children == NULL) {
goto err;
}
CBS_init(&cbs, buf, buf_len);
for (size_t i = 0; i < num_children; i++) {
if (!CBS_get_any_asn1_element(&cbs, &children[i], NULL, NULL)) {
goto err;
}
}
qsort(children, num_children, sizeof(CBS), compare_set_of_element);
// Rewind |cbb| and write the contents back in the new order.
cbb->base->len = cbb->offset + cbb->pending_len_len;
for (size_t i = 0; i < num_children; i++) {
if (!CBB_add_bytes(cbb, CBS_data(&children[i]), CBS_len(&children[i]))) {
goto err;
}
}
assert(CBB_len(cbb) == buf_len);
ret = 1;
err:
OPENSSL_free(buf);
OPENSSL_free(children);
return ret;
}
+235 -34
View File
@@ -12,11 +12,11 @@
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
#include <openssl/buf.h>
#include <openssl/mem.h>
#include <openssl/bytestring.h>
#include <assert.h>
#include <inttypes.h>
#include <string.h>
#include "internal.h"
@@ -60,7 +60,7 @@ int CBS_stow(const CBS *cbs, uint8_t **out_ptr, size_t *out_len) {
if (cbs->len == 0) {
return 1;
}
*out_ptr = BUF_memdup(cbs->data, cbs->len);
*out_ptr = OPENSSL_memdup(cbs->data, cbs->len);
if (*out_ptr == NULL) {
return 0;
}
@@ -72,7 +72,7 @@ int CBS_strdup(const CBS *cbs, char **out_ptr) {
if (*out_ptr != NULL) {
OPENSSL_free(*out_ptr);
}
*out_ptr = BUF_strndup((const char*)cbs->data, cbs->len);
*out_ptr = OPENSSL_strndup((const char*)cbs->data, cbs->len);
return (*out_ptr != NULL);
}
@@ -87,8 +87,8 @@ int CBS_mem_equal(const CBS *cbs, const uint8_t *data, size_t len) {
return CRYPTO_memcmp(cbs->data, data, len) == 0;
}
static int cbs_get_u(CBS *cbs, uint32_t *out, size_t len) {
uint32_t result = 0;
static int cbs_get_u(CBS *cbs, uint64_t *out, size_t len) {
uint64_t result = 0;
const uint8_t *data;
if (!cbs_get(cbs, &data, len)) {
@@ -112,7 +112,7 @@ int CBS_get_u8(CBS *cbs, uint8_t *out) {
}
int CBS_get_u16(CBS *cbs, uint16_t *out) {
uint32_t v;
uint64_t v;
if (!cbs_get_u(cbs, &v, 2)) {
return 0;
}
@@ -120,12 +120,50 @@ int CBS_get_u16(CBS *cbs, uint16_t *out) {
return 1;
}
int CBS_get_u16le(CBS *cbs, uint16_t *out) {
if (!CBS_get_u16(cbs, out)) {
return 0;
}
*out = CRYPTO_bswap2(*out);
return 1;
}
int CBS_get_u24(CBS *cbs, uint32_t *out) {
return cbs_get_u(cbs, out, 3);
uint64_t v;
if (!cbs_get_u(cbs, &v, 3)) {
return 0;
}
*out = v;
return 1;
}
int CBS_get_u32(CBS *cbs, uint32_t *out) {
return cbs_get_u(cbs, out, 4);
uint64_t v;
if (!cbs_get_u(cbs, &v, 4)) {
return 0;
}
*out = v;
return 1;
}
int CBS_get_u32le(CBS *cbs, uint32_t *out) {
if (!CBS_get_u32(cbs, out)) {
return 0;
}
*out = CRYPTO_bswap4(*out);
return 1;
}
int CBS_get_u64(CBS *cbs, uint64_t *out) {
return cbs_get_u(cbs, out, 8);
}
int CBS_get_u64le(CBS *cbs, uint64_t *out) {
if (!cbs_get_u(cbs, out, 8)) {
return 0;
}
*out = CRYPTO_bswap8(*out);
return 1;
}
int CBS_get_last_u8(CBS *cbs, uint8_t *out) {
@@ -156,10 +194,13 @@ int CBS_copy_bytes(CBS *cbs, uint8_t *out, size_t len) {
}
static int cbs_get_length_prefixed(CBS *cbs, CBS *out, size_t len_len) {
uint32_t len;
uint64_t len;
if (!cbs_get_u(cbs, &len, len_len)) {
return 0;
}
// If |len_len| <= 3 then we know that |len| will fit into a |size_t|, even on
// 32-bit systems.
assert(len_len <= 3);
return CBS_get_bytes(cbs, out, len);
}
@@ -175,18 +216,36 @@ int CBS_get_u24_length_prefixed(CBS *cbs, CBS *out) {
return cbs_get_length_prefixed(cbs, out, 3);
}
static int cbs_get_any_asn1_element(CBS *cbs, CBS *out, unsigned *out_tag,
size_t *out_header_len, int ber_ok) {
uint8_t tag, length_byte;
CBS header = *cbs;
CBS throwaway;
// parse_base128_integer reads a big-endian base-128 integer from |cbs| and sets
// |*out| to the result. This is the encoding used in DER for both high tag
// number form and OID components.
static int parse_base128_integer(CBS *cbs, uint64_t *out) {
uint64_t v = 0;
uint8_t b;
do {
if (!CBS_get_u8(cbs, &b)) {
return 0;
}
if ((v >> (64 - 7)) != 0) {
// The value is too large.
return 0;
}
if (v == 0 && b == 0x80) {
// The value must be minimally encoded.
return 0;
}
v = (v << 7) | (b & 0x7f);
if (out == NULL) {
out = &throwaway;
}
// Values end at an octet with the high bit cleared.
} while (b & 0x80);
if (!CBS_get_u8(&header, &tag) ||
!CBS_get_u8(&header, &length_byte)) {
*out = v;
return 1;
}
static int parse_asn1_tag(CBS *cbs, unsigned *out) {
uint8_t tag_byte;
if (!CBS_get_u8(cbs, &tag_byte)) {
return 0;
}
@@ -197,36 +256,72 @@ static int cbs_get_any_asn1_element(CBS *cbs, CBS *out, unsigned *out_tag,
// allotted bits), then the tag is more than one byte long and the
// continuation bytes contain the tag number. This parser only supports tag
// numbers less than 31 (and thus single-byte tags).
if ((tag & 0x1f) == 0x1f) {
return 0;
unsigned tag = ((unsigned)tag_byte & 0xe0) << CBS_ASN1_TAG_SHIFT;
unsigned tag_number = tag_byte & 0x1f;
if (tag_number == 0x1f) {
uint64_t v;
if (!parse_base128_integer(cbs, &v) ||
// Check the tag number is within our supported bounds.
v > CBS_ASN1_TAG_NUMBER_MASK ||
// Small tag numbers should have used low tag number form.
v < 0x1f) {
return 0;
}
tag_number = (unsigned)v;
}
tag |= tag_number;
*out = tag;
return 1;
}
static int cbs_get_any_asn1_element(CBS *cbs, CBS *out, unsigned *out_tag,
size_t *out_header_len, int ber_ok) {
CBS header = *cbs;
CBS throwaway;
if (out == NULL) {
out = &throwaway;
}
unsigned tag;
if (!parse_asn1_tag(&header, &tag)) {
return 0;
}
if (out_tag != NULL) {
*out_tag = tag;
}
uint8_t length_byte;
if (!CBS_get_u8(&header, &length_byte)) {
return 0;
}
size_t header_len = CBS_len(cbs) - CBS_len(&header);
size_t len;
// The format for the length encoding is specified in ITU-T X.690 section
// 8.1.3.
if ((length_byte & 0x80) == 0) {
// Short form length.
len = ((size_t) length_byte) + 2;
len = ((size_t) length_byte) + header_len;
if (out_header_len != NULL) {
*out_header_len = 2;
*out_header_len = header_len;
}
} else {
// The high bit indicate that this is the long form, while the next 7 bits
// encode the number of subsequent octets used to encode the length (ITU-T
// X.690 clause 8.1.3.5.b).
const size_t num_bytes = length_byte & 0x7f;
uint32_t len32;
uint64_t len64;
if (ber_ok && (tag & CBS_ASN1_CONSTRUCTED) != 0 && num_bytes == 0) {
// indefinite length
if (out_header_len != NULL) {
*out_header_len = 2;
*out_header_len = header_len;
}
return CBS_get_bytes(cbs, out, 2);
return CBS_get_bytes(cbs, out, header_len);
}
// ITU-T X.690 clause 8.1.3.5.c specifies that the value 0xff shall not be
@@ -235,27 +330,27 @@ static int cbs_get_any_asn1_element(CBS *cbs, CBS *out, unsigned *out_tag,
if (num_bytes == 0 || num_bytes > 4) {
return 0;
}
if (!cbs_get_u(&header, &len32, num_bytes)) {
if (!cbs_get_u(&header, &len64, num_bytes)) {
return 0;
}
// ITU-T X.690 section 10.1 (DER length forms) requires encoding the length
// with the minimum number of octets.
if (len32 < 128) {
if (len64 < 128) {
// Length should have used short-form encoding.
return 0;
}
if ((len32 >> ((num_bytes-1)*8)) == 0) {
if ((len64 >> ((num_bytes-1)*8)) == 0) {
// Length should have been at least one byte shorter.
return 0;
}
len = len32;
if (len + 2 + num_bytes < len) {
len = len64;
if (len + header_len + num_bytes < len) {
// Overflow.
return 0;
}
len += 2 + num_bytes;
len += header_len + num_bytes;
if (out_header_len != NULL) {
*out_header_len = 2 + num_bytes;
*out_header_len = header_len + num_bytes;
}
}
@@ -323,7 +418,10 @@ int CBS_peek_asn1_tag(const CBS *cbs, unsigned tag_value) {
if (CBS_len(cbs) < 1) {
return 0;
}
return CBS_data(cbs)[0] == tag_value;
CBS copy = *cbs;
unsigned actual_tag;
return parse_asn1_tag(&copy, &actual_tag) && tag_value == actual_tag;
}
int CBS_get_asn1_uint64(CBS *cbs, uint64_t *out) {
@@ -363,6 +461,56 @@ int CBS_get_asn1_uint64(CBS *cbs, uint64_t *out) {
return 1;
}
int CBS_get_asn1_int64(CBS *cbs, int64_t *out) {
CBS bytes;
if (!CBS_get_asn1(cbs, &bytes, CBS_ASN1_INTEGER)) {
return 0;
}
const uint8_t *data = CBS_data(&bytes);
const size_t len = CBS_len(&bytes);
if (len == 0 || len > sizeof(int64_t)) {
// An INTEGER is encoded with at least one octet.
return 0;
}
if (len > 1) {
if (data[0] == 0 && (data[1] & 0x80) == 0) {
return 0; // Extra leading zeros.
}
if (data[0] == 0xff && (data[1] & 0x80) != 0) {
return 0; // Extra leading 0xff.
}
}
union {
int64_t i;
uint8_t bytes[sizeof(int64_t)];
} u;
const int is_negative = (data[0] & 0x80);
memset(u.bytes, is_negative ? 0xff : 0, sizeof(u.bytes)); // Sign-extend.
for (size_t i = 0; i < len; i++) {
u.bytes[i] = data[len - i - 1];
}
*out = u.i;
return 1;
}
int CBS_get_asn1_bool(CBS *cbs, int *out) {
CBS bytes;
if (!CBS_get_asn1(cbs, &bytes, CBS_ASN1_BOOLEAN) ||
CBS_len(&bytes) != 1) {
return 0;
}
const uint8_t value = *CBS_data(&bytes);
if (value != 0 && value != 0xff) {
return 0;
}
*out = !!value;
return 1;
}
int CBS_get_optional_asn1(CBS *cbs, CBS *out, int *out_present, unsigned tag) {
int present = 0;
@@ -388,6 +536,7 @@ int CBS_get_optional_asn1_octet_string(CBS *cbs, CBS *out, int *out_present,
return 0;
}
if (present) {
assert(out);
if (!CBS_get_asn1(&child, out, CBS_ASN1_OCTETSTRING) ||
CBS_len(&child) != 0) {
return 0;
@@ -485,3 +634,55 @@ int CBS_asn1_bitstring_has_bit(const CBS *cbs, unsigned bit) {
return byte_num < CBS_len(cbs) &&
(CBS_data(cbs)[byte_num] & (1 << bit_num)) != 0;
}
static int add_decimal(CBB *out, uint64_t v) {
char buf[DECIMAL_SIZE(uint64_t) + 1];
BIO_snprintf(buf, sizeof(buf), "%" PRIu64, v);
return CBB_add_bytes(out, (const uint8_t *)buf, strlen(buf));
}
char *CBS_asn1_oid_to_text(const CBS *cbs) {
CBB cbb;
if (!CBB_init(&cbb, 32)) {
goto err;
}
CBS copy = *cbs;
// The first component is 40 * value1 + value2, where value1 is 0, 1, or 2.
uint64_t v;
if (!parse_base128_integer(&copy, &v)) {
goto err;
}
if (v >= 80) {
if (!CBB_add_bytes(&cbb, (const uint8_t *)"2.", 2) ||
!add_decimal(&cbb, v - 80)) {
goto err;
}
} else if (!add_decimal(&cbb, v / 40) ||
!CBB_add_u8(&cbb, '.') ||
!add_decimal(&cbb, v % 40)) {
goto err;
}
while (CBS_len(&copy) != 0) {
if (!parse_base128_integer(&copy, &v) ||
!CBB_add_u8(&cbb, '.') ||
!add_decimal(&cbb, v)) {
goto err;
}
}
uint8_t *txt;
size_t txt_len;
if (!CBB_add_u8(&cbb, '\0') ||
!CBB_finish(&cbb, &txt, &txt_len)) {
goto err;
}
return (char *)txt;
err:
CBB_cleanup(&cbb);
return NULL;
}
+28 -7
View File
@@ -24,12 +24,10 @@ extern "C" {
// CBS_asn1_ber_to_der reads a BER element from |in|. If it finds
// indefinite-length elements or constructed strings then it converts the BER
// data to DER and sets |*out| and |*out_length| to describe a malloced buffer
// containing the DER data. Additionally, |*in| will be advanced over the BER
// element.
//
// If it doesn't find any indefinite-length elements or constructed strings then
// it sets |*out| to NULL and |*in| is unmodified.
// data to DER, sets |out| to the converted contents and |*out_storage| to a
// buffer which the caller must release with |OPENSSL_free|. Otherwise, it sets
// |out| to the original BER element in |in| and |*out_storage| to NULL.
// Additionally, |*in| will be advanced over the BER element.
//
// This function should successfully process any valid BER input, however it
// will not convert all of BER's deviations from DER. BER is ambiguous between
@@ -39,7 +37,8 @@ extern "C" {
// must also account for BER variations in the contents of a primitive.
//
// It returns one on success and zero otherwise.
OPENSSL_EXPORT int CBS_asn1_ber_to_der(CBS *in, uint8_t **out, size_t *out_len);
OPENSSL_EXPORT int CBS_asn1_ber_to_der(CBS *in, CBS *out,
uint8_t **out_storage);
// CBS_get_asn1_implicit_string parses a BER string of primitive type
// |inner_tag| implicitly-tagged with |outer_tag|. It sets |out| to the
@@ -68,6 +67,28 @@ OPENSSL_EXPORT int CBS_get_asn1_implicit_string(CBS *in, CBS *out,
int CBB_finish_i2d(CBB *cbb, uint8_t **outp);
// Unicode utilities.
// The following functions read one Unicode code point from |cbs| with the
// corresponding encoding and store it in |*out|. They return one on success and
// zero on error.
OPENSSL_EXPORT int cbs_get_utf8(CBS *cbs, uint32_t *out);
OPENSSL_EXPORT int cbs_get_latin1(CBS *cbs, uint32_t *out);
OPENSSL_EXPORT int cbs_get_ucs2_be(CBS *cbs, uint32_t *out);
OPENSSL_EXPORT int cbs_get_utf32_be(CBS *cbs, uint32_t *out);
// cbb_get_utf8_len returns the number of bytes needed to represent |u| in
// UTF-8.
OPENSSL_EXPORT size_t cbb_get_utf8_len(uint32_t u);
// The following functions encode |u| to |cbb| with the corresponding
// encoding. They return one on success and zero on error.
OPENSSL_EXPORT int cbb_add_utf8(CBB *cbb, uint32_t u);
OPENSSL_EXPORT int cbb_add_latin1(CBB *cbb, uint32_t u);
OPENSSL_EXPORT int cbb_add_ucs2_be(CBB *cbb, uint32_t u);
OPENSSL_EXPORT int cbb_add_utf32_be(CBB *cbb, uint32_t u);
#if defined(__cplusplus)
} // extern C
#endif
+155
View File
@@ -0,0 +1,155 @@
/* Copyright (c) 2018, Google Inc.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
#include <openssl/bytestring.h>
#include "internal.h"
static int is_valid_code_point(uint32_t v) {
// References in the following are to Unicode 9.0.0.
if (// The Unicode space runs from zero to 0x10ffff (3.4 D9).
v > 0x10ffff ||
// Values 0x...fffe, 0x...ffff, and 0xfdd0-0xfdef are permanently reserved
// (3.4 D14)
(v & 0xfffe) == 0xfffe ||
(v >= 0xfdd0 && v <= 0xfdef) ||
// Surrogate code points are invalid (3.2 C1).
(v >= 0xd800 && v <= 0xdfff)) {
return 0;
}
return 1;
}
// BOTTOM_BITS returns a byte with the bottom |n| bits set.
#define BOTTOM_BITS(n) (uint8_t)((1u << (n)) - 1)
// TOP_BITS returns a byte with the top |n| bits set.
#define TOP_BITS(n) ((uint8_t)~BOTTOM_BITS(8 - (n)))
int cbs_get_utf8(CBS *cbs, uint32_t *out) {
uint8_t c;
if (!CBS_get_u8(cbs, &c)) {
return 0;
}
if (c <= 0x7f) {
*out = c;
return 1;
}
uint32_t v, lower_bound;
size_t len;
if ((c & TOP_BITS(3)) == TOP_BITS(2)) {
v = c & BOTTOM_BITS(5);
len = 1;
lower_bound = 0x80;
} else if ((c & TOP_BITS(4)) == TOP_BITS(3)) {
v = c & BOTTOM_BITS(4);
len = 2;
lower_bound = 0x800;
} else if ((c & TOP_BITS(5)) == TOP_BITS(4)) {
v = c & BOTTOM_BITS(3);
len = 3;
lower_bound = 0x10000;
} else {
return 0;
}
for (size_t i = 0; i < len; i++) {
if (!CBS_get_u8(cbs, &c) ||
(c & TOP_BITS(2)) != TOP_BITS(1)) {
return 0;
}
v <<= 6;
v |= c & BOTTOM_BITS(6);
}
if (!is_valid_code_point(v) ||
v < lower_bound) {
return 0;
}
*out = v;
return 1;
}
int cbs_get_latin1(CBS *cbs, uint32_t *out) {
uint8_t c;
if (!CBS_get_u8(cbs, &c)) {
return 0;
}
*out = c;
return 1;
}
int cbs_get_ucs2_be(CBS *cbs, uint32_t *out) {
// Note UCS-2 (used by BMPString) does not support surrogates.
uint16_t c;
if (!CBS_get_u16(cbs, &c) ||
!is_valid_code_point(c)) {
return 0;
}
*out = c;
return 1;
}
int cbs_get_utf32_be(CBS *cbs, uint32_t *out) {
return CBS_get_u32(cbs, out) && is_valid_code_point(*out);
}
size_t cbb_get_utf8_len(uint32_t u) {
if (u <= 0x7f) {
return 1;
}
if (u <= 0x7ff) {
return 2;
}
if (u <= 0xffff) {
return 3;
}
return 4;
}
int cbb_add_utf8(CBB *cbb, uint32_t u) {
if (!is_valid_code_point(u)) {
return 0;
}
if (u <= 0x7f) {
return CBB_add_u8(cbb, (uint8_t)u);
}
if (u <= 0x7ff) {
return CBB_add_u8(cbb, TOP_BITS(2) | (u >> 6)) &&
CBB_add_u8(cbb, TOP_BITS(1) | (u & BOTTOM_BITS(6)));
}
if (u <= 0xffff) {
return CBB_add_u8(cbb, TOP_BITS(3) | (u >> 12)) &&
CBB_add_u8(cbb, TOP_BITS(1) | ((u >> 6) & BOTTOM_BITS(6))) &&
CBB_add_u8(cbb, TOP_BITS(1) | (u & BOTTOM_BITS(6)));
}
if (u <= 0x10ffff) {
return CBB_add_u8(cbb, TOP_BITS(4) | (u >> 18)) &&
CBB_add_u8(cbb, TOP_BITS(1) | ((u >> 12) & BOTTOM_BITS(6))) &&
CBB_add_u8(cbb, TOP_BITS(1) | ((u >> 6) & BOTTOM_BITS(6))) &&
CBB_add_u8(cbb, TOP_BITS(1) | (u & BOTTOM_BITS(6)));
}
return 0;
}
int cbb_add_latin1(CBB *cbb, uint32_t u) {
return u <= 0xff && CBB_add_u8(cbb, (uint8_t)u);
}
int cbb_add_ucs2_be(CBB *cbb, uint32_t u) {
return u <= 0xffff && is_valid_code_point(u) && CBB_add_u16(cbb, (uint16_t)u);
}
int cbb_add_utf32_be(CBB *cbb, uint32_t u) {
return is_valid_code_point(u) && CBB_add_u32(cbb, u);
}
-48
View File
@@ -1,48 +0,0 @@
include_directories(../../include)
if (${ARCH} STREQUAL "arm")
set(
CHACHA_ARCH_SOURCES
chacha-armv4.${ASM_EXT}
)
endif()
if (${ARCH} STREQUAL "aarch64")
set(
CHACHA_ARCH_SOURCES
chacha-armv8.${ASM_EXT}
)
endif()
if (${ARCH} STREQUAL "x86")
set(
CHACHA_ARCH_SOURCES
chacha-x86.${ASM_EXT}
)
endif()
if (${ARCH} STREQUAL "x86_64")
set(
CHACHA_ARCH_SOURCES
chacha-x86_64.${ASM_EXT}
)
endif()
add_library(
chacha
OBJECT
chacha.c
${CHACHA_ARCH_SOURCES}
)
perlasm(chacha-armv4.${ASM_EXT} asm/chacha-armv4.pl)
perlasm(chacha-armv8.${ASM_EXT} asm/chacha-armv8.pl)
perlasm(chacha-x86.${ASM_EXT} asm/chacha-x86.pl)
perlasm(chacha-x86_64.${ASM_EXT} asm/chacha-x86_64.pl)
+9 -3
View File
@@ -44,9 +44,11 @@ if ($flavour && $flavour ne "void") {
( $xlate="${dir}../../perlasm/arm-xlate.pl" and -f $xlate) or
die "can't locate arm-xlate.pl";
open STDOUT,"| \"$^X\" $xlate $flavour $output";
open OUT,"| \"$^X\" $xlate $flavour $output";
*STDOUT=*OUT;
} else {
open STDOUT,">$output";
open OUT,">$output";
*STDOUT=*OUT;
}
sub AUTOLOAD() # thunk [simplified] x86-style perlasm
@@ -171,6 +173,10 @@ my @ret;
$code.=<<___;
#include <openssl/arm_arch.h>
@ Silence ARMv8 deprecated IT instruction warnings. This file is used by both
@ ARMv7 and ARMv8 processors and does not use ARMv8 instructions.
.arch armv7-a
.text
#if defined(__thumb2__) || defined(__clang__)
.syntax unified
@@ -1157,4 +1163,4 @@ foreach (split("\n",$code)) {
print $_,"\n";
}
close STDOUT;
close STDOUT or die "error closing STDOUT";
+18 -19
View File
@@ -28,6 +28,7 @@
# Denver 4.50/+82% 2.63 2.67(*)
# X-Gene 9.50/+46% 8.82 8.89(*)
# Mongoose 8.00/+44% 3.64 3.25
# Kryo 8.17/+50% 4.83 4.65
#
# (*) it's expected that doubling interleave factor doesn't help
# all processors, only those with higher NEON latency and
@@ -121,37 +122,32 @@ my ($a3,$b3,$c3,$d3)=map(($_&~3)+(($_+1)&3),($a2,$b2,$c2,$d2));
$code.=<<___;
#include <openssl/arm_arch.h>
.text
.extern OPENSSL_armcap_P
.section .rodata
.align 5
.Lsigma:
.quad 0x3320646e61707865,0x6b20657479622d32 // endian-neutral
.Lone:
.long 1,0,0,0
.LOPENSSL_armcap_P:
#ifdef __ILP32__
.long OPENSSL_armcap_P-.
#else
.quad OPENSSL_armcap_P-.
#endif
.asciz "ChaCha20 for ARMv8, CRYPTOGAMS by <appro\@openssl.org>"
.text
.globl ChaCha20_ctr32
.type ChaCha20_ctr32,%function
.align 5
ChaCha20_ctr32:
cbz $len,.Labort
adr @x[0],.LOPENSSL_armcap_P
#if __has_feature(hwaddress_sanitizer) && __clang_major__ >= 10
adrp @x[0],:pg_hi21_nc:OPENSSL_armcap_P
#else
adrp @x[0],:pg_hi21:OPENSSL_armcap_P
#endif
cmp $len,#192
b.lo .Lshort
#ifdef __ILP32__
ldrsw @x[1],[@x[0]]
#else
ldr @x[1],[@x[0]]
#endif
ldr w17,[@x[1],@x[0]]
ldr w17,[@x[0],:lo12:OPENSSL_armcap_P]
tst w17,#ARMV7_NEON
b.ne ChaCha20_neon
@@ -159,7 +155,8 @@ ChaCha20_ctr32:
stp x29,x30,[sp,#-96]!
add x29,sp,#0
adr @x[0],.Lsigma
adrp @x[0],:pg_hi21:.Lsigma
add @x[0],@x[0],:lo12:.Lsigma
stp x19,x20,[sp,#16]
stp x21,x22,[sp,#32]
stp x23,x24,[sp,#48]
@@ -379,7 +376,8 @@ ChaCha20_neon:
stp x29,x30,[sp,#-96]!
add x29,sp,#0
adr @x[0],.Lsigma
adrp @x[0],:pg_hi21:.Lsigma
add @x[0],@x[0],:lo12:.Lsigma
stp x19,x20,[sp,#16]
stp x21,x22,[sp,#32]
stp x23,x24,[sp,#48]
@@ -698,7 +696,8 @@ ChaCha20_512_neon:
stp x29,x30,[sp,#-96]!
add x29,sp,#0
adr @x[0],.Lsigma
adrp @x[0],:pg_hi21:.Lsigma
add @x[0],@x[0],:lo12:.Lsigma
stp x19,x20,[sp,#16]
stp x21,x22,[sp,#32]
stp x23,x24,[sp,#48]
@@ -1132,4 +1131,4 @@ foreach (split("\n",$code)) {
print $_,"\n";
}
close STDOUT; # flush
close STDOUT or die "error closing STDOUT"; # flush
+9 -2
View File
@@ -1,4 +1,11 @@
#!/usr/bin/env perl
#! /usr/bin/env perl
# Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the OpenSSL license (the "License"). You may not use
# this file except in compliance with the License. You can obtain a copy
# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html
#
# ====================================================================
# Written by Andy Polyakov <appro@openssl.org> for the OpenSSL
@@ -762,4 +769,4 @@ sub SSSE3ROUND { # critical path is 20 "SIMD ticks" per round
&asm_finish();
close STDOUT;
close STDOUT or die "error closing STDOUT";
+37 -1
View File
@@ -228,6 +228,7 @@ $code.=<<___;
.type ChaCha20_ctr32,\@function,5
.align 64
ChaCha20_ctr32:
.cfi_startproc
cmp \$0,$len
je .Lno_data
mov OPENSSL_ia32cap_P+4(%rip),%r10
@@ -241,12 +242,19 @@ $code.=<<___;
jnz .LChaCha20_ssse3
push %rbx
.cfi_push rbx
push %rbp
.cfi_push rbp
push %r12
.cfi_push r12
push %r13
.cfi_push r13
push %r14
.cfi_push r14
push %r15
.cfi_push r15
sub \$64+24,%rsp
.cfi_adjust_cfa_offset `64+24`
.Lctr32_body:
#movdqa .Lsigma(%rip),%xmm0
@@ -388,14 +396,22 @@ $code.=<<___;
.Ldone:
lea 64+24+48(%rsp),%rsi
mov -48(%rsi),%r15
.cfi_restore r15
mov -40(%rsi),%r14
.cfi_restore r14
mov -32(%rsi),%r13
.cfi_restore r13
mov -24(%rsi),%r12
.cfi_restore r12
mov -16(%rsi),%rbp
.cfi_restore rbp
mov -8(%rsi),%rbx
.cfi_restore rbx
lea (%rsi),%rsp
.cfi_adjust_cfa_offset `-64-24-48`
.Lno_data:
ret
.cfi_endproc
.size ChaCha20_ctr32,.-ChaCha20_ctr32
___
@@ -435,7 +451,9 @@ $code.=<<___;
.align 32
ChaCha20_ssse3:
.LChaCha20_ssse3:
.cfi_startproc
mov %rsp,%r9 # frame pointer
.cfi_def_cfa_register r9
___
$code.=<<___;
cmp \$128,$len # we might throw away some data,
@@ -547,8 +565,10 @@ $code.=<<___ if ($win64);
___
$code.=<<___;
lea (%r9),%rsp
.cfi_def_cfa_register rsp
.Lssse3_epilogue:
ret
.cfi_endproc
.size ChaCha20_ssse3,.-ChaCha20_ssse3
___
}
@@ -691,7 +711,9 @@ $code.=<<___;
.align 32
ChaCha20_4x:
.LChaCha20_4x:
.cfi_startproc
mov %rsp,%r9 # frame pointer
.cfi_def_cfa_register r9
mov %r10,%r11
___
$code.=<<___ if ($avx>1);
@@ -1131,8 +1153,10 @@ $code.=<<___ if ($win64);
___
$code.=<<___;
lea (%r9),%rsp
.cfi_def_cfa_register rsp
.L4x_epilogue:
ret
.cfi_endproc
.size ChaCha20_4x,.-ChaCha20_4x
___
}
@@ -1266,7 +1290,9 @@ $code.=<<___;
.align 32
ChaCha20_8x:
.LChaCha20_8x:
.cfi_startproc
mov %rsp,%r9 # frame register
.cfi_def_cfa_register r9
sub \$0x280+$xframe,%rsp
and \$-32,%rsp
___
@@ -1772,8 +1798,10 @@ $code.=<<___ if ($win64);
___
$code.=<<___;
lea (%r9),%rsp
.cfi_def_cfa_register rsp
.L8x_epilogue:
ret
.cfi_endproc
.size ChaCha20_8x,.-ChaCha20_8x
___
}
@@ -1811,7 +1839,9 @@ $code.=<<___;
.align 32
ChaCha20_avx512:
.LChaCha20_avx512:
.cfi_startproc
mov %rsp,%r9 # frame pointer
.cfi_def_cfa_register r9
cmp \$512,$len
ja .LChaCha20_16x
@@ -1991,8 +2021,10 @@ $code.=<<___ if ($win64);
___
$code.=<<___;
lea (%r9),%rsp
.cfi_def_cfa_register rsp
.Lavx512_epilogue:
ret
.cfi_endproc
.size ChaCha20_avx512,.-ChaCha20_avx512
___
}
@@ -2075,7 +2107,9 @@ $code.=<<___;
.align 32
ChaCha20_16x:
.LChaCha20_16x:
.cfi_startproc
mov %rsp,%r9 # frame register
.cfi_def_cfa_register r9
sub \$64+$xframe,%rsp
and \$-64,%rsp
___
@@ -2493,8 +2527,10 @@ $code.=<<___ if ($win64);
___
$code.=<<___;
lea (%r9),%rsp
.cfi_def_cfa_register rsp
.L16x_epilogue:
ret
.cfi_endproc
.size ChaCha20_16x,.-ChaCha20_16x
___
}
@@ -2746,4 +2782,4 @@ foreach (split("\n",$code)) {
print $_,"\n";
}
close STDOUT;
close STDOUT or die "error closing STDOUT";
+36 -19
View File
@@ -22,19 +22,49 @@
#include <openssl/cpu.h>
#include "../internal.h"
#include "internal.h"
#define U8TO32_LITTLE(p) \
(((uint32_t)((p)[0])) | ((uint32_t)((p)[1]) << 8) | \
((uint32_t)((p)[2]) << 16) | ((uint32_t)((p)[3]) << 24))
#if !defined(OPENSSL_NO_ASM) && \
(defined(OPENSSL_X86) || defined(OPENSSL_X86_64) || \
defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64))
// sigma contains the ChaCha constants, which happen to be an ASCII string.
static const uint8_t sigma[16] = { 'e', 'x', 'p', 'a', 'n', 'd', ' ', '3',
'2', '-', 'b', 'y', 't', 'e', ' ', 'k' };
// ChaCha20_ctr32 is defined in asm/chacha-*.pl.
void ChaCha20_ctr32(uint8_t *out, const uint8_t *in, size_t in_len,
const uint32_t key[8], const uint32_t counter[4]);
#define ROTATE(v, n) (((v) << (n)) | ((v) >> (32 - (n))))
// QUARTERROUND updates a, b, c, d with a ChaCha "quarter" round.
#define QUARTERROUND(a, b, c, d) \
x[a] += x[b]; x[d] = ROTATE(x[d] ^ x[a], 16); \
x[c] += x[d]; x[b] = ROTATE(x[b] ^ x[c], 12); \
x[a] += x[b]; x[d] = ROTATE(x[d] ^ x[a], 8); \
x[c] += x[d]; x[b] = ROTATE(x[b] ^ x[c], 7);
void CRYPTO_hchacha20(uint8_t out[32], const uint8_t key[32],
const uint8_t nonce[16]) {
uint32_t x[16];
OPENSSL_memcpy(x, sigma, sizeof(sigma));
OPENSSL_memcpy(&x[4], key, 32);
OPENSSL_memcpy(&x[12], nonce, 16);
for (size_t i = 0; i < 20; i += 2) {
QUARTERROUND(0, 4, 8, 12)
QUARTERROUND(1, 5, 9, 13)
QUARTERROUND(2, 6, 10, 14)
QUARTERROUND(3, 7, 11, 15)
QUARTERROUND(0, 5, 10, 15)
QUARTERROUND(1, 6, 11, 12)
QUARTERROUND(2, 7, 8, 13)
QUARTERROUND(3, 4, 9, 14)
}
OPENSSL_memcpy(out, &x[0], sizeof(uint32_t) * 4);
OPENSSL_memcpy(&out[16], &x[12], sizeof(uint32_t) * 4);
}
#if defined(CHACHA20_ASM)
void CRYPTO_chacha_20(uint8_t *out, const uint8_t *in, size_t in_len,
const uint8_t key[32], const uint8_t nonce[12],
@@ -69,12 +99,6 @@ void CRYPTO_chacha_20(uint8_t *out, const uint8_t *in, size_t in_len,
#else
// sigma contains the ChaCha constants, which happen to be an ASCII string.
static const uint8_t sigma[16] = { 'e', 'x', 'p', 'a', 'n', 'd', ' ', '3',
'2', '-', 'b', 'y', 't', 'e', ' ', 'k' };
#define ROTATE(v, n) (((v) << (n)) | ((v) >> (32 - (n))))
#define U32TO8_LITTLE(p, v) \
{ \
(p)[0] = (v >> 0) & 0xff; \
@@ -83,13 +107,6 @@ static const uint8_t sigma[16] = { 'e', 'x', 'p', 'a', 'n', 'd', ' ', '3',
(p)[3] = (v >> 24) & 0xff; \
}
// QUARTERROUND updates a, b, c, d with a ChaCha "quarter" round.
#define QUARTERROUND(a, b, c, d) \
x[a] += x[b]; x[d] = ROTATE(x[d] ^ x[a], 16); \
x[c] += x[d]; x[b] = ROTATE(x[b] ^ x[c], 12); \
x[a] += x[b]; x[d] = ROTATE(x[d] ^ x[a], 8); \
x[c] += x[d]; x[b] = ROTATE(x[b] ^ x[c], 7);
// chacha_core performs 20 rounds of ChaCha on the input words in
// |input| and writes the 64 output bytes to |output|.
static void chacha_core(uint8_t output[64], const uint32_t input[16]) {
+24
View File
@@ -23,7 +23,9 @@
#include <openssl/crypto.h>
#include <openssl/chacha.h>
#include "internal.h"
#include "../internal.h"
#include "../test/abi_test.h"
#include "../test/test_util.h"
@@ -234,3 +236,25 @@ TEST(ChaChaTest, TestVector) {
EXPECT_EQ(Bytes(kOutput, len), Bytes(buf.get(), len));
}
}
#if defined(CHACHA20_ASM) && defined(SUPPORTS_ABI_TEST)
TEST(ChaChaTest, ABI) {
uint32_t key[8];
OPENSSL_memcpy(key, kKey, sizeof(key));
static const uint32_t kCounterNonce[4] = {0};
std::unique_ptr<uint8_t[]> buf(new uint8_t[sizeof(kInput)]);
for (size_t len = 0; len <= 32; len++) {
SCOPED_TRACE(len);
CHECK_ABI(ChaCha20_ctr32, buf.get(), kInput, len, key, kCounterNonce);
}
for (size_t len : {32 * 2, 32 * 4, 32 * 8, 32 * 16, 32 * 24}) {
SCOPED_TRACE(len);
CHECK_ABI(ChaCha20_ctr32, buf.get(), kInput, len, key, kCounterNonce);
// Cover the partial block paths.
CHECK_ABI(ChaCha20_ctr32, buf.get(), kInput, len + 15, key, kCounterNonce);
}
}
#endif // CHACHA20_ASM && SUPPORTS_ABI_TEST
+45
View File
@@ -0,0 +1,45 @@
/* Copyright (c) 2018, Google Inc.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
#ifndef OPENSSL_HEADER_CHACHA_INTERNAL
#define OPENSSL_HEADER_CHACHA_INTERNAL
#include <openssl/base.h>
#if defined(__cplusplus)
extern "C" {
#endif
// CRYPTO_hchacha20 computes the HChaCha20 function, which should only be used
// as part of XChaCha20.
void CRYPTO_hchacha20(uint8_t out[32], const uint8_t key[32],
const uint8_t nonce[16]);
#if !defined(OPENSSL_NO_ASM) && \
(defined(OPENSSL_X86) || defined(OPENSSL_X86_64) || \
defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64))
#define CHACHA20_ASM
// ChaCha20_ctr32 is defined in asm/chacha-*.pl.
void ChaCha20_ctr32(uint8_t *out, const uint8_t *in, size_t in_len,
const uint32_t key[8], const uint32_t counter[4]);
#endif
#if defined(__cplusplus)
} // extern C
#endif
#endif // OPENSSL_HEADER_CHACHA_INTERNAL
-35
View File
@@ -1,35 +0,0 @@
include_directories(../../include)
if (${ARCH} STREQUAL "x86_64")
set(
CIPHER_ARCH_SOURCES
aes128gcmsiv-x86_64.${ASM_EXT}
chacha20_poly1305_x86_64.${ASM_EXT}
)
endif()
add_library(
cipher_extra
OBJECT
cipher_extra.c
derive_key.c
e_null.c
e_rc2.c
e_rc4.c
e_aesgcmsiv.c
e_aesctrhmac.c
e_chacha20poly1305.c
tls_cbc.c
e_tls.c
e_ssl3.c
${CIPHER_ARCH_SOURCES}
)
perlasm(aes128gcmsiv-x86_64.${ASM_EXT} asm/aes128gcmsiv-x86_64.pl)
perlasm(chacha20_poly1305_x86_64.${ASM_EXT} asm/chacha20_poly1305_x86_64.pl)
+345 -78
View File
@@ -25,8 +25,10 @@
#include "../fipsmodule/cipher/internal.h"
#include "../internal.h"
#include "../test/abi_test.h"
#include "../test/file_test.h"
#include "../test/test_util.h"
#include "../test/wycheproof_util.h"
struct KnownAEAD {
@@ -35,64 +37,66 @@ struct KnownAEAD {
const char *test_vectors;
// limited_implementation indicates that tests that assume a generic AEAD
// interface should not be performed. For example, the key-wrap AEADs only
// handle inputs that are a multiple of eight bytes in length and the
// SSLv3/TLS AEADs have the concept of “direction”.
// handle inputs that are a multiple of eight bytes in length and the TLS CBC
// AEADs have the concept of “direction”.
bool limited_implementation;
// truncated_tags is true if the AEAD supports truncating tags to arbitrary
// lengths.
bool truncated_tags;
// variable_nonce is true if the AEAD supports a variable nonce length.
bool variable_nonce;
// ad_len, if non-zero, is the required length of the AD.
size_t ad_len;
};
static const struct KnownAEAD kAEADs[] = {
{"AES_128_GCM", EVP_aead_aes_128_gcm, "aes_128_gcm_tests.txt", false, true,
0},
true, 0},
{"AES_128_GCM_NIST", EVP_aead_aes_128_gcm, "nist_cavp/aes_128_gcm.txt",
false, true, 0},
false, true, true, 0},
{"AES_192_GCM", EVP_aead_aes_192_gcm, "aes_192_gcm_tests.txt", false, true,
true, 0},
{"AES_256_GCM", EVP_aead_aes_256_gcm, "aes_256_gcm_tests.txt", false, true,
0},
true, 0},
{"AES_256_GCM_NIST", EVP_aead_aes_256_gcm, "nist_cavp/aes_256_gcm.txt",
false, true, 0},
#if !defined(OPENSSL_SMALL)
false, true, true, 0},
{"AES_128_GCM_SIV", EVP_aead_aes_128_gcm_siv, "aes_128_gcm_siv_tests.txt",
false, false, 0},
false, false, false, 0},
{"AES_256_GCM_SIV", EVP_aead_aes_256_gcm_siv, "aes_256_gcm_siv_tests.txt",
false, false, 0},
#endif
false, false, false, 0},
{"ChaCha20Poly1305", EVP_aead_chacha20_poly1305,
"chacha20_poly1305_tests.txt", false, true, 0},
"chacha20_poly1305_tests.txt", false, true, false, 0},
{"XChaCha20Poly1305", EVP_aead_xchacha20_poly1305,
"xchacha20_poly1305_tests.txt", false, true, false, 0},
{"AES_128_CBC_SHA1_TLS", EVP_aead_aes_128_cbc_sha1_tls,
"aes_128_cbc_sha1_tls_tests.txt", true, false, 11},
"aes_128_cbc_sha1_tls_tests.txt", true, false, false, 11},
{"AES_128_CBC_SHA1_TLSImplicitIV",
EVP_aead_aes_128_cbc_sha1_tls_implicit_iv,
"aes_128_cbc_sha1_tls_implicit_iv_tests.txt", true, false, 11},
"aes_128_cbc_sha1_tls_implicit_iv_tests.txt", true, false, false, 11},
{"AES_128_CBC_SHA256_TLS", EVP_aead_aes_128_cbc_sha256_tls,
"aes_128_cbc_sha256_tls_tests.txt", true, false, 11},
"aes_128_cbc_sha256_tls_tests.txt", true, false, false, 11},
{"AES_256_CBC_SHA1_TLS", EVP_aead_aes_256_cbc_sha1_tls,
"aes_256_cbc_sha1_tls_tests.txt", true, false, 11},
"aes_256_cbc_sha1_tls_tests.txt", true, false, false, 11},
{"AES_256_CBC_SHA1_TLSImplicitIV",
EVP_aead_aes_256_cbc_sha1_tls_implicit_iv,
"aes_256_cbc_sha1_tls_implicit_iv_tests.txt", true, false, 11},
"aes_256_cbc_sha1_tls_implicit_iv_tests.txt", true, false, false, 11},
{"AES_256_CBC_SHA256_TLS", EVP_aead_aes_256_cbc_sha256_tls,
"aes_256_cbc_sha256_tls_tests.txt", true, false, 11},
"aes_256_cbc_sha256_tls_tests.txt", true, false, false, 11},
{"AES_256_CBC_SHA384_TLS", EVP_aead_aes_256_cbc_sha384_tls,
"aes_256_cbc_sha384_tls_tests.txt", true, false, 11},
"aes_256_cbc_sha384_tls_tests.txt", true, false, false, 11},
{"DES_EDE3_CBC_SHA1_TLS", EVP_aead_des_ede3_cbc_sha1_tls,
"des_ede3_cbc_sha1_tls_tests.txt", true, false, 11},
"des_ede3_cbc_sha1_tls_tests.txt", true, false, false, 11},
{"DES_EDE3_CBC_SHA1_TLSImplicitIV",
EVP_aead_des_ede3_cbc_sha1_tls_implicit_iv,
"des_ede3_cbc_sha1_tls_implicit_iv_tests.txt", true, false, 11},
{"AES_128_CBC_SHA1_SSL3", EVP_aead_aes_128_cbc_sha1_ssl3,
"aes_128_cbc_sha1_ssl3_tests.txt", true, false, 9},
{"AES_256_CBC_SHA1_SSL3", EVP_aead_aes_256_cbc_sha1_ssl3,
"aes_256_cbc_sha1_ssl3_tests.txt", true, false, 9},
{"DES_EDE3_CBC_SHA1_SSL3", EVP_aead_des_ede3_cbc_sha1_ssl3,
"des_ede3_cbc_sha1_ssl3_tests.txt", true, false, 9},
"des_ede3_cbc_sha1_tls_implicit_iv_tests.txt", true, false, false, 11},
{"AES_128_CTR_HMAC_SHA256", EVP_aead_aes_128_ctr_hmac_sha256,
"aes_128_ctr_hmac_sha256.txt", false, true, 0},
"aes_128_ctr_hmac_sha256.txt", false, true, false, 0},
{"AES_256_CTR_HMAC_SHA256", EVP_aead_aes_256_ctr_hmac_sha256,
"aes_256_ctr_hmac_sha256.txt", false, true, 0},
"aes_256_ctr_hmac_sha256.txt", false, true, false, 0},
{"AES_128_CCM_BLUETOOTH", EVP_aead_aes_128_ccm_bluetooth,
"aes_128_ccm_bluetooth_tests.txt", false, false, false, 0},
{"AES_128_CCM_BLUETOOTH_8", EVP_aead_aes_128_ccm_bluetooth_8,
"aes_128_ccm_bluetooth_8_tests.txt", false, false, false, 0},
};
class PerAEADTest : public testing::TestWithParam<KnownAEAD> {
@@ -100,9 +104,9 @@ class PerAEADTest : public testing::TestWithParam<KnownAEAD> {
const EVP_AEAD *aead() { return GetParam().func(); }
};
INSTANTIATE_TEST_CASE_P(, PerAEADTest, testing::ValuesIn(kAEADs),
[](const testing::TestParamInfo<KnownAEAD> &params)
-> std::string { return params.param.name; });
INSTANTIATE_TEST_SUITE_P(All, PerAEADTest, testing::ValuesIn(kAEADs),
[](const testing::TestParamInfo<KnownAEAD> &params)
-> std::string { return params.param.name; });
// Tests an AEAD against a series of test vectors from a file, using the
// FileTest format. As an example, here's a valid test case:
@@ -539,10 +543,10 @@ TEST_P(PerAEADTest, AliasedBuffers) {
}
TEST_P(PerAEADTest, UnalignedInput) {
alignas(64) uint8_t key[EVP_AEAD_MAX_KEY_LENGTH + 1];
alignas(64) uint8_t nonce[EVP_AEAD_MAX_NONCE_LENGTH + 1];
alignas(64) uint8_t plaintext[32 + 1];
alignas(64) uint8_t ad[32 + 1];
alignas(16) uint8_t key[EVP_AEAD_MAX_KEY_LENGTH + 1];
alignas(16) uint8_t nonce[EVP_AEAD_MAX_NONCE_LENGTH + 1];
alignas(16) uint8_t plaintext[32 + 1];
alignas(16) uint8_t ad[32 + 1];
OPENSSL_memset(key, 'K', sizeof(key));
OPENSSL_memset(nonce, 'N', sizeof(nonce));
OPENSSL_memset(plaintext, 'P', sizeof(plaintext));
@@ -560,7 +564,7 @@ TEST_P(PerAEADTest, UnalignedInput) {
ASSERT_TRUE(EVP_AEAD_CTX_init_with_direction(
ctx.get(), aead(), key + 1, key_len, EVP_AEAD_DEFAULT_TAG_LENGTH,
evp_aead_seal));
alignas(64) uint8_t ciphertext[sizeof(plaintext) + EVP_AEAD_MAX_OVERHEAD];
alignas(16) uint8_t ciphertext[sizeof(plaintext) + EVP_AEAD_MAX_OVERHEAD];
size_t ciphertext_len;
ASSERT_TRUE(EVP_AEAD_CTX_seal(ctx.get(), ciphertext + 1, &ciphertext_len,
sizeof(ciphertext) - 1, nonce + 1, nonce_len,
@@ -568,7 +572,7 @@ TEST_P(PerAEADTest, UnalignedInput) {
ad_len));
// It must successfully decrypt.
alignas(64) uint8_t out[sizeof(ciphertext)];
alignas(16) uint8_t out[sizeof(ciphertext)];
ctx.Reset();
ASSERT_TRUE(EVP_AEAD_CTX_init_with_direction(
ctx.get(), aead(), key + 1, key_len, EVP_AEAD_DEFAULT_TAG_LENGTH,
@@ -582,7 +586,7 @@ TEST_P(PerAEADTest, UnalignedInput) {
}
TEST_P(PerAEADTest, Overflow) {
alignas(64) uint8_t key[EVP_AEAD_MAX_KEY_LENGTH];
uint8_t key[EVP_AEAD_MAX_KEY_LENGTH];
OPENSSL_memset(key, 'K', sizeof(key));
bssl::ScopedEVP_AEAD_CTX ctx;
@@ -606,48 +610,311 @@ TEST_P(PerAEADTest, Overflow) {
// as the input.)
}
// Test that EVP_aead_aes_128_gcm and EVP_aead_aes_256_gcm reject empty nonces.
// AES-GCM is not defined for those.
TEST(AEADTest, AESGCMEmptyNonce) {
static const uint8_t kZeros[32] = {0};
TEST_P(PerAEADTest, InvalidNonceLength) {
size_t valid_nonce_len = EVP_AEAD_nonce_length(aead());
std::vector<size_t> nonce_lens;
if (valid_nonce_len != 0) {
// Other than the implicit IV TLS "AEAD"s, none of our AEADs allow empty
// nonces. In particular, although AES-GCM was incorrectly specified with
// variable-length nonces, it does not allow the empty nonce.
nonce_lens.push_back(0);
}
if (!GetParam().variable_nonce) {
nonce_lens.push_back(valid_nonce_len + 1);
if (valid_nonce_len != 0) {
nonce_lens.push_back(valid_nonce_len - 1);
}
}
// Test AES-128-GCM.
uint8_t buf[16];
size_t len;
bssl::ScopedEVP_AEAD_CTX ctx;
ASSERT_TRUE(EVP_AEAD_CTX_init(ctx.get(), EVP_aead_aes_128_gcm(), kZeros, 16,
EVP_AEAD_DEFAULT_TAG_LENGTH, nullptr));
static const uint8_t kZeros[EVP_AEAD_MAX_KEY_LENGTH] = {0};
const size_t ad_len = GetParam().ad_len != 0 ? GetParam().ad_len : 16;
ASSERT_LE(ad_len, sizeof(kZeros));
EXPECT_FALSE(EVP_AEAD_CTX_seal(ctx.get(), buf, &len, sizeof(buf),
nullptr /* nonce */, 0, nullptr /* in */, 0,
nullptr /* ad */, 0));
uint32_t err = ERR_get_error();
EXPECT_EQ(ERR_LIB_CIPHER, ERR_GET_LIB(err));
EXPECT_EQ(CIPHER_R_INVALID_NONCE_SIZE, ERR_GET_REASON(err));
for (size_t nonce_len : nonce_lens) {
SCOPED_TRACE(nonce_len);
uint8_t buf[256];
size_t len;
std::vector<uint8_t> nonce(nonce_len);
bssl::ScopedEVP_AEAD_CTX ctx;
ASSERT_TRUE(EVP_AEAD_CTX_init_with_direction(
ctx.get(), aead(), kZeros, EVP_AEAD_key_length(aead()),
EVP_AEAD_DEFAULT_TAG_LENGTH, evp_aead_seal));
EXPECT_FALSE(EVP_AEAD_CTX_open(ctx.get(), buf, &len, sizeof(buf),
nullptr /* nonce */, 0, kZeros /* in */,
sizeof(kZeros), nullptr /* ad */, 0));
err = ERR_get_error();
EXPECT_EQ(ERR_LIB_CIPHER, ERR_GET_LIB(err));
EXPECT_EQ(CIPHER_R_INVALID_NONCE_SIZE, ERR_GET_REASON(err));
EXPECT_FALSE(EVP_AEAD_CTX_seal(ctx.get(), buf, &len, sizeof(buf),
nonce.data(), nonce.size(), nullptr /* in */,
0, kZeros /* ad */, ad_len));
uint32_t err = ERR_get_error();
EXPECT_EQ(ERR_LIB_CIPHER, ERR_GET_LIB(err));
// TODO(davidben): Merge these errors. https://crbug.com/boringssl/129.
if (ERR_GET_REASON(err) != CIPHER_R_UNSUPPORTED_NONCE_SIZE) {
EXPECT_EQ(CIPHER_R_INVALID_NONCE_SIZE, ERR_GET_REASON(err));
}
// Test AES-256-GCM.
ctx.Reset();
ASSERT_TRUE(EVP_AEAD_CTX_init(ctx.get(), EVP_aead_aes_256_gcm(), kZeros, 32,
EVP_AEAD_DEFAULT_TAG_LENGTH, nullptr));
EXPECT_FALSE(EVP_AEAD_CTX_seal(ctx.get(), buf, &len, sizeof(buf),
nullptr /* nonce */, 0, nullptr /* in */, 0,
nullptr /* ad */, 0));
err = ERR_get_error();
EXPECT_EQ(ERR_LIB_CIPHER, ERR_GET_LIB(err));
EXPECT_EQ(CIPHER_R_INVALID_NONCE_SIZE, ERR_GET_REASON(err));
EXPECT_FALSE(EVP_AEAD_CTX_open(ctx.get(), buf, &len, sizeof(buf),
nullptr /* nonce */, 0, kZeros /* in */,
sizeof(kZeros), nullptr /* ad */, 0));
err = ERR_get_error();
EXPECT_EQ(ERR_LIB_CIPHER, ERR_GET_LIB(err));
EXPECT_EQ(CIPHER_R_INVALID_NONCE_SIZE, ERR_GET_REASON(err));
ctx.Reset();
ASSERT_TRUE(EVP_AEAD_CTX_init_with_direction(
ctx.get(), aead(), kZeros, EVP_AEAD_key_length(aead()),
EVP_AEAD_DEFAULT_TAG_LENGTH, evp_aead_open));
EXPECT_FALSE(EVP_AEAD_CTX_open(ctx.get(), buf, &len, sizeof(buf),
nonce.data(), nonce.size(), kZeros /* in */,
sizeof(kZeros), kZeros /* ad */, ad_len));
err = ERR_get_error();
EXPECT_EQ(ERR_LIB_CIPHER, ERR_GET_LIB(err));
if (ERR_GET_REASON(err) != CIPHER_R_UNSUPPORTED_NONCE_SIZE) {
EXPECT_EQ(CIPHER_R_INVALID_NONCE_SIZE, ERR_GET_REASON(err));
}
}
}
#if defined(SUPPORTS_ABI_TEST)
// CHECK_ABI can't pass enums, i.e. |evp_aead_seal| and |evp_aead_open|. Thus
// these two wrappers.
static int aead_ctx_init_for_seal(EVP_AEAD_CTX *ctx, const EVP_AEAD *aead,
const uint8_t *key, size_t key_len) {
return EVP_AEAD_CTX_init_with_direction(ctx, aead, key, key_len, 0,
evp_aead_seal);
}
static int aead_ctx_init_for_open(EVP_AEAD_CTX *ctx, const EVP_AEAD *aead,
const uint8_t *key, size_t key_len) {
return EVP_AEAD_CTX_init_with_direction(ctx, aead, key, key_len, 0,
evp_aead_open);
}
// CHECK_ABI can pass, at most, eight arguments. Thus these wrappers that
// figure out the output length from the input length, and take the nonce length
// from the configuration of the AEAD.
static int aead_ctx_seal(EVP_AEAD_CTX *ctx, uint8_t *out_ciphertext,
size_t *out_ciphertext_len, const uint8_t *nonce,
const uint8_t *plaintext, size_t plaintext_len,
const uint8_t *ad, size_t ad_len) {
const size_t nonce_len = EVP_AEAD_nonce_length(EVP_AEAD_CTX_aead(ctx));
return EVP_AEAD_CTX_seal(ctx, out_ciphertext, out_ciphertext_len,
plaintext_len + EVP_AEAD_MAX_OVERHEAD, nonce,
nonce_len, plaintext, plaintext_len, ad, ad_len);
}
static int aead_ctx_open(EVP_AEAD_CTX *ctx, uint8_t *out_plaintext,
size_t *out_plaintext_len, const uint8_t *nonce,
const uint8_t *ciphertext, size_t ciphertext_len,
const uint8_t *ad, size_t ad_len) {
const size_t nonce_len = EVP_AEAD_nonce_length(EVP_AEAD_CTX_aead(ctx));
return EVP_AEAD_CTX_open(ctx, out_plaintext, out_plaintext_len,
ciphertext_len, nonce, nonce_len, ciphertext,
ciphertext_len, ad, ad_len);
}
TEST_P(PerAEADTest, ABI) {
uint8_t key[EVP_AEAD_MAX_KEY_LENGTH];
OPENSSL_memset(key, 'K', sizeof(key));
const size_t key_len = EVP_AEAD_key_length(aead());
ASSERT_LE(key_len, sizeof(key));
bssl::ScopedEVP_AEAD_CTX ctx_seal;
ASSERT_TRUE(
CHECK_ABI(aead_ctx_init_for_seal, ctx_seal.get(), aead(), key, key_len));
bssl::ScopedEVP_AEAD_CTX ctx_open;
ASSERT_TRUE(
CHECK_ABI(aead_ctx_init_for_open, ctx_open.get(), aead(), key, key_len));
alignas(2) uint8_t plaintext[512];
OPENSSL_memset(plaintext, 'P', sizeof(plaintext));
alignas(2) uint8_t ad_buf[512];
OPENSSL_memset(ad_buf, 'A', sizeof(ad_buf));
const uint8_t *const ad = ad_buf + 1;
ASSERT_LE(GetParam().ad_len, sizeof(ad_buf) - 1);
const size_t ad_len =
GetParam().ad_len != 0 ? GetParam().ad_len : sizeof(ad_buf) - 1;
uint8_t nonce[EVP_AEAD_MAX_NONCE_LENGTH];
const size_t nonce_len = EVP_AEAD_nonce_length(aead());
ASSERT_LE(nonce_len, sizeof(nonce));
alignas(2) uint8_t ciphertext[sizeof(plaintext) + EVP_AEAD_MAX_OVERHEAD + 1];
size_t ciphertext_len;
// Knock plaintext, ciphertext, and AD off alignment and give odd lengths for
// plaintext and AD. This hopefully triggers any edge-cases in the assembly.
ASSERT_TRUE(CHECK_ABI(aead_ctx_seal, ctx_seal.get(), ciphertext + 1,
&ciphertext_len, nonce, plaintext + 1,
sizeof(plaintext) - 1, ad, ad_len));
alignas(2) uint8_t plaintext2[sizeof(ciphertext) + 1];
size_t plaintext2_len;
ASSERT_TRUE(CHECK_ABI(aead_ctx_open, ctx_open.get(), plaintext2 + 1,
&plaintext2_len, nonce, ciphertext + 1, ciphertext_len,
ad, ad_len));
EXPECT_EQ(Bytes(plaintext + 1, sizeof(plaintext) - 1),
Bytes(plaintext2 + 1, plaintext2_len));
}
#endif // SUPPORTS_ABI_TEST
TEST(AEADTest, AESCCMLargeAD) {
static const std::vector<uint8_t> kKey(16, 'A');
static const std::vector<uint8_t> kNonce(13, 'N');
static const std::vector<uint8_t> kAD(65536, 'D');
static const std::vector<uint8_t> kPlaintext = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};
static const std::vector<uint8_t> kCiphertext = {
0xa2, 0x12, 0x3f, 0x0b, 0x07, 0xd5, 0x02, 0xff,
0xa9, 0xcd, 0xa0, 0xf3, 0x69, 0x1c, 0x49, 0x0c};
static const std::vector<uint8_t> kTag = {0x4a, 0x31, 0x82, 0x96};
// Test AES-128-CCM-Bluetooth.
bssl::ScopedEVP_AEAD_CTX ctx;
ASSERT_TRUE(EVP_AEAD_CTX_init(ctx.get(), EVP_aead_aes_128_ccm_bluetooth(),
kKey.data(), kKey.size(),
EVP_AEAD_DEFAULT_TAG_LENGTH, nullptr));
std::vector<uint8_t> out(kCiphertext.size() + kTag.size());
size_t out_len;
EXPECT_TRUE(EVP_AEAD_CTX_seal(ctx.get(), out.data(), &out_len, out.size(),
kNonce.data(), kNonce.size(), kPlaintext.data(),
kPlaintext.size(), kAD.data(), kAD.size()));
ASSERT_EQ(out_len, kCiphertext.size() + kTag.size());
EXPECT_EQ(Bytes(kCiphertext), Bytes(out.data(), kCiphertext.size()));
EXPECT_EQ(Bytes(kTag), Bytes(out.data() + kCiphertext.size(), kTag.size()));
EXPECT_TRUE(EVP_AEAD_CTX_open(ctx.get(), out.data(), &out_len, out.size(),
kNonce.data(), kNonce.size(), out.data(),
out.size(), kAD.data(), kAD.size()));
ASSERT_EQ(out_len, kPlaintext.size());
EXPECT_EQ(Bytes(kPlaintext), Bytes(out.data(), kPlaintext.size()));
}
static void RunWycheproofTestCase(FileTest *t, const EVP_AEAD *aead) {
t->IgnoreInstruction("ivSize");
std::vector<uint8_t> aad, ct, iv, key, msg, tag;
ASSERT_TRUE(t->GetBytes(&aad, "aad"));
ASSERT_TRUE(t->GetBytes(&ct, "ct"));
ASSERT_TRUE(t->GetBytes(&iv, "iv"));
ASSERT_TRUE(t->GetBytes(&key, "key"));
ASSERT_TRUE(t->GetBytes(&msg, "msg"));
ASSERT_TRUE(t->GetBytes(&tag, "tag"));
std::string tag_size_str;
ASSERT_TRUE(t->GetInstruction(&tag_size_str, "tagSize"));
size_t tag_size = static_cast<size_t>(atoi(tag_size_str.c_str()));
ASSERT_EQ(0u, tag_size % 8);
tag_size /= 8;
WycheproofResult result;
ASSERT_TRUE(GetWycheproofResult(t, &result));
std::vector<uint8_t> ct_and_tag = ct;
ct_and_tag.insert(ct_and_tag.end(), tag.begin(), tag.end());
bssl::ScopedEVP_AEAD_CTX ctx;
ASSERT_TRUE(EVP_AEAD_CTX_init(ctx.get(), aead, key.data(), key.size(),
tag_size, nullptr));
std::vector<uint8_t> out(msg.size());
size_t out_len;
// Wycheproof tags small AES-GCM IVs as "acceptable" and otherwise does not
// use it in AEADs. Any AES-GCM IV that isn't 96 bits is absurd, but our API
// supports those, so we treat SmallIv tests as valid.
if (result.IsValid({"SmallIv"})) {
// Decryption should succeed.
ASSERT_TRUE(EVP_AEAD_CTX_open(ctx.get(), out.data(), &out_len, out.size(),
iv.data(), iv.size(), ct_and_tag.data(),
ct_and_tag.size(), aad.data(), aad.size()));
EXPECT_EQ(Bytes(msg), Bytes(out.data(), out_len));
// Decryption in-place should succeed.
out = ct_and_tag;
ASSERT_TRUE(EVP_AEAD_CTX_open(ctx.get(), out.data(), &out_len, out.size(),
iv.data(), iv.size(), out.data(), out.size(),
aad.data(), aad.size()));
EXPECT_EQ(Bytes(msg), Bytes(out.data(), out_len));
// AEADs are deterministic, so encryption should produce the same result.
out.resize(ct_and_tag.size());
ASSERT_TRUE(EVP_AEAD_CTX_seal(ctx.get(), out.data(), &out_len, out.size(),
iv.data(), iv.size(), msg.data(), msg.size(),
aad.data(), aad.size()));
EXPECT_EQ(Bytes(ct_and_tag), Bytes(out.data(), out_len));
// Encrypt in-place.
out = msg;
out.resize(ct_and_tag.size());
ASSERT_TRUE(EVP_AEAD_CTX_seal(ctx.get(), out.data(), &out_len, out.size(),
iv.data(), iv.size(), out.data(), msg.size(),
aad.data(), aad.size()));
EXPECT_EQ(Bytes(ct_and_tag), Bytes(out.data(), out_len));
} else {
// Decryption should fail.
EXPECT_FALSE(EVP_AEAD_CTX_open(ctx.get(), out.data(), &out_len, out.size(),
iv.data(), iv.size(), ct_and_tag.data(),
ct_and_tag.size(), aad.data(), aad.size()));
// Decryption in-place should also fail.
out = ct_and_tag;
EXPECT_FALSE(EVP_AEAD_CTX_open(ctx.get(), out.data(), &out_len, out.size(),
iv.data(), iv.size(), out.data(), out.size(),
aad.data(), aad.size()));
}
}
TEST(AEADTest, WycheproofAESGCMSIV) {
FileTestGTest("third_party/wycheproof_testvectors/aes_gcm_siv_test.txt",
[](FileTest *t) {
std::string key_size_str;
ASSERT_TRUE(t->GetInstruction(&key_size_str, "keySize"));
const EVP_AEAD *aead;
switch (atoi(key_size_str.c_str())) {
case 128:
aead = EVP_aead_aes_128_gcm_siv();
break;
case 256:
aead = EVP_aead_aes_256_gcm_siv();
break;
default:
FAIL() << "Unknown key size: " << key_size_str;
}
RunWycheproofTestCase(t, aead);
});
}
TEST(AEADTest, WycheproofAESGCM) {
FileTestGTest("third_party/wycheproof_testvectors/aes_gcm_test.txt",
[](FileTest *t) {
std::string key_size_str;
ASSERT_TRUE(t->GetInstruction(&key_size_str, "keySize"));
const EVP_AEAD *aead;
switch (atoi(key_size_str.c_str())) {
case 128:
aead = EVP_aead_aes_128_gcm();
break;
case 192:
aead = EVP_aead_aes_192_gcm();
break;
case 256:
aead = EVP_aead_aes_256_gcm();
break;
default:
FAIL() << "Unknown key size: " << key_size_str;
}
RunWycheproofTestCase(t, aead);
});
}
TEST(AEADTest, WycheproofChaCha20Poly1305) {
FileTestGTest("third_party/wycheproof_testvectors/chacha20_poly1305_test.txt",
[](FileTest *t) {
t->IgnoreInstruction("keySize");
RunWycheproofTestCase(t, EVP_aead_chacha20_poly1305());
});
}
TEST(AEADTest, WycheproofXChaCha20Poly1305) {
FileTestGTest(
"third_party/wycheproof_testvectors/xchacha20_poly1305_test.txt",
[](FileTest *t) {
t->IgnoreInstruction("keySize");
RunWycheproofTestCase(t, EVP_aead_xchacha20_poly1305());
});
}
@@ -2253,4 +2253,4 @@ aes256gcmsiv_kdf();
print $code;
close STDOUT;
close STDOUT or die "error closing STDOUT";
@@ -1273,7 +1273,7 @@ do_length_block:\n";
pop %rbp
.cfi_adjust_cfa_offset -8
ret
.cfi_adjust_cfa_offset (8 * 6) + 288 + 32
.cfi_adjust_cfa_offset (8 * 7) + 288 + 32
################################################################################
seal_sse_128:
movdqu .chacha20_consts(%rip), $A0\nmovdqa $A0, $A1\nmovdqa $A0, $A2
@@ -2478,6 +2478,7 @@ if (!$win64) {
print $code;
} else {
print <<___;
.text
.globl dummy_chacha20_poly1305_asm
.type dummy_chacha20_poly1305_asm,\@abi-omnipotent
dummy_chacha20_poly1305_asm:
@@ -2485,4 +2486,4 @@ dummy_chacha20_poly1305_asm:
___
}
close STDOUT;
close STDOUT or die "error closing STDOUT";
+29
View File
@@ -94,20 +94,49 @@ const EVP_CIPHER *EVP_get_cipherbyname(const char *name) {
} else if (OPENSSL_strcasecmp(name, "des-cbc") == 0) {
return EVP_des_cbc();
} else if (OPENSSL_strcasecmp(name, "des-ede3-cbc") == 0 ||
// This is not a name used by OpenSSL, but tcpdump registers it
// with |EVP_add_cipher_alias|. Our |EVP_add_cipher_alias| is a
// no-op, so we support the name here.
OPENSSL_strcasecmp(name, "3des") == 0) {
return EVP_des_ede3_cbc();
} else if (OPENSSL_strcasecmp(name, "aes-128-cbc") == 0) {
return EVP_aes_128_cbc();
} else if (OPENSSL_strcasecmp(name, "aes-192-cbc") == 0) {
return EVP_aes_192_cbc();
} else if (OPENSSL_strcasecmp(name, "aes-256-cbc") == 0) {
return EVP_aes_256_cbc();
} else if (OPENSSL_strcasecmp(name, "aes-128-ctr") == 0) {
return EVP_aes_128_ctr();
} else if (OPENSSL_strcasecmp(name, "aes-192-ctr") == 0) {
return EVP_aes_192_ctr();
} else if (OPENSSL_strcasecmp(name, "aes-256-ctr") == 0) {
return EVP_aes_256_ctr();
} else if (OPENSSL_strcasecmp(name, "aes-128-ecb") == 0) {
return EVP_aes_128_ecb();
} else if (OPENSSL_strcasecmp(name, "aes-192-ecb") == 0) {
return EVP_aes_192_ecb();
} else if (OPENSSL_strcasecmp(name, "aes-256-ecb") == 0) {
return EVP_aes_256_ecb();
} else if (OPENSSL_strcasecmp(name, "aes-128-gcm") == 0) {
return EVP_aes_128_gcm();
} else if (OPENSSL_strcasecmp(name, "aes-192-gcm") == 0) {
return EVP_aes_192_gcm();
} else if (OPENSSL_strcasecmp(name, "aes-256-gcm") == 0) {
return EVP_aes_256_gcm();
} else if (OPENSSL_strcasecmp(name, "aes-128-ofb") == 0) {
return EVP_aes_128_ofb();
} else if (OPENSSL_strcasecmp(name, "aes-192-ofb") == 0) {
return EVP_aes_192_ofb();
} else if (OPENSSL_strcasecmp(name, "aes-256-ofb") == 0) {
return EVP_aes_256_ofb();
} else if (OPENSSL_strcasecmp(name, "des-ecb") == 0) {
return EVP_des_ecb();
} else if (OPENSSL_strcasecmp(name, "des-ede") == 0) {
return EVP_des_ede();
} else if (OPENSSL_strcasecmp(name, "des-ede-cbc") == 0) {
return EVP_des_ede_cbc();
} else if (OPENSSL_strcasecmp(name, "rc2-cbc") == 0) {
return EVP_rc2_cbc();
}
return NULL;
+236 -47
View File
@@ -51,19 +51,25 @@
* ====================================================================
*/
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <string>
#include <vector>
#include <gtest/gtest.h>
#include <openssl/aes.h>
#include <openssl/cipher.h>
#include <openssl/err.h>
#include <openssl/nid.h>
#include <openssl/span.h>
#include "../test/file_test.h"
#include "../test/test_util.h"
#include "../test/wycheproof_util.h"
static const EVP_CIPHER *GetCipher(const std::string &name) {
@@ -97,6 +103,8 @@ static const EVP_CIPHER *GetCipher(const std::string &name) {
return EVP_aes_192_ctr();
} else if (name == "AES-192-ECB") {
return EVP_aes_192_ecb();
} else if (name == "AES-192-OFB") {
return EVP_aes_192_ofb();
} else if (name == "AES-256-CBC") {
return EVP_aes_256_cbc();
} else if (name == "AES-128-CTR") {
@@ -111,8 +119,46 @@ static const EVP_CIPHER *GetCipher(const std::string &name) {
return nullptr;
}
static bool DoCipher(EVP_CIPHER_CTX *ctx, std::vector<uint8_t> *out,
bssl::Span<const uint8_t> in, size_t chunk,
bool in_place) {
size_t max_out = in.size();
if ((EVP_CIPHER_CTX_flags(ctx) & EVP_CIPH_NO_PADDING) == 0 &&
EVP_CIPHER_CTX_encrypting(ctx)) {
unsigned block_size = EVP_CIPHER_CTX_block_size(ctx);
max_out += block_size - (max_out % block_size);
}
out->resize(max_out);
if (in_place) {
std::copy(in.begin(), in.end(), out->begin());
in = bssl::MakeConstSpan(out->data(), in.size());
}
size_t total = 0;
int len;
while (!in.empty()) {
size_t todo = chunk == 0 ? in.size() : std::min(in.size(), chunk);
EXPECT_LE(todo, static_cast<size_t>(INT_MAX));
if (!EVP_CipherUpdate(ctx, out->data() + total, &len, in.data(),
static_cast<int>(todo))) {
return false;
}
EXPECT_GE(len, 0);
total += static_cast<size_t>(len);
in = in.subspan(todo);
}
if (!EVP_CipherFinal_ex(ctx, out->data() + total, &len)) {
return false;
}
EXPECT_GE(len, 0);
total += static_cast<size_t>(len);
out->resize(total);
return true;
}
static void TestOperation(FileTest *t, const EVP_CIPHER *cipher, bool encrypt,
size_t chunk_size, const std::vector<uint8_t> &key,
bool copy, bool in_place, size_t chunk_size,
const std::vector<uint8_t> &key,
const std::vector<uint8_t> &iv,
const std::vector<uint8_t> &plaintext,
const std::vector<uint8_t> &ciphertext,
@@ -129,65 +175,139 @@ static void TestOperation(FileTest *t, const EVP_CIPHER *cipher, bool encrypt,
bool is_aead = EVP_CIPHER_mode(cipher) == EVP_CIPH_GCM_MODE;
bssl::ScopedEVP_CIPHER_CTX ctx;
ASSERT_TRUE(EVP_CipherInit_ex(ctx.get(), cipher, nullptr, nullptr, nullptr,
encrypt ? 1 : 0));
bssl::ScopedEVP_CIPHER_CTX ctx1;
ASSERT_TRUE(EVP_CipherInit_ex(ctx1.get(), cipher, nullptr, nullptr, nullptr,
encrypt ? 1 : 0));
if (t->HasAttribute("IV")) {
if (is_aead) {
ASSERT_TRUE(
EVP_CIPHER_CTX_ctrl(ctx.get(), EVP_CTRL_GCM_SET_IVLEN, iv.size(), 0));
ASSERT_TRUE(EVP_CIPHER_CTX_ctrl(ctx1.get(), EVP_CTRL_AEAD_SET_IVLEN,
iv.size(), 0));
} else {
ASSERT_EQ(iv.size(), EVP_CIPHER_CTX_iv_length(ctx.get()));
ASSERT_EQ(iv.size(), EVP_CIPHER_CTX_iv_length(ctx1.get()));
}
}
bssl::ScopedEVP_CIPHER_CTX ctx2;
EVP_CIPHER_CTX *ctx = ctx1.get();
if (copy) {
ASSERT_TRUE(EVP_CIPHER_CTX_copy(ctx2.get(), ctx1.get()));
ctx = ctx2.get();
}
if (is_aead && !encrypt) {
ASSERT_TRUE(EVP_CIPHER_CTX_ctrl(ctx.get(), EVP_CTRL_GCM_SET_TAG, tag.size(),
ASSERT_TRUE(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, tag.size(),
const_cast<uint8_t *>(tag.data())));
}
// The ciphers are run with no padding. For each of the ciphers we test, the
// output size matches the input size.
std::vector<uint8_t> result(in->size());
ASSERT_EQ(in->size(), out->size());
int unused, result_len1 = 0, result_len2;
ASSERT_TRUE(EVP_CIPHER_CTX_set_key_length(ctx.get(), key.size()));
ASSERT_TRUE(EVP_CipherInit_ex(ctx.get(), nullptr, nullptr, key.data(),
iv.data(), -1));
// Note: the deprecated |EVP_CIPHER|-based AES-GCM API is sensitive to whether
ASSERT_TRUE(EVP_CIPHER_CTX_set_key_length(ctx, key.size()));
ASSERT_TRUE(
EVP_CipherInit_ex(ctx, nullptr, nullptr, key.data(), iv.data(), -1));
// Note: the deprecated |EVP_CIPHER|-based AEAD API is sensitive to whether
// parameters are NULL, so it is important to skip the |in| and |aad|
// |EVP_CipherUpdate| calls when empty.
if (!aad.empty()) {
int unused;
ASSERT_TRUE(
EVP_CipherUpdate(ctx.get(), nullptr, &unused, aad.data(), aad.size()));
EVP_CipherUpdate(ctx, nullptr, &unused, aad.data(), aad.size()));
}
ASSERT_TRUE(EVP_CIPHER_CTX_set_padding(ctx.get(), 0));
if (chunk_size != 0) {
for (size_t i = 0; i < in->size();) {
size_t todo = chunk_size;
if (i + todo > in->size()) {
todo = in->size() - i;
}
int len;
ASSERT_TRUE(EVP_CipherUpdate(ctx.get(), result.data() + result_len1, &len,
in->data() + i, todo));
result_len1 += len;
i += todo;
}
} else if (!in->empty()) {
ASSERT_TRUE(EVP_CipherUpdate(ctx.get(), result.data(), &result_len1,
in->data(), in->size()));
}
ASSERT_TRUE(
EVP_CipherFinal_ex(ctx.get(), result.data() + result_len1, &result_len2));
result.resize(result_len1 + result_len2);
ASSERT_TRUE(EVP_CIPHER_CTX_set_padding(ctx, 0));
std::vector<uint8_t> result;
ASSERT_TRUE(DoCipher(ctx, &result, *in, chunk_size, in_place));
EXPECT_EQ(Bytes(*out), Bytes(result));
if (encrypt && is_aead) {
uint8_t rtag[16];
ASSERT_LE(tag.size(), sizeof(rtag));
ASSERT_TRUE(
EVP_CIPHER_CTX_ctrl(ctx.get(), EVP_CTRL_GCM_GET_TAG, tag.size(), rtag));
EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, tag.size(), rtag));
EXPECT_EQ(Bytes(tag), Bytes(rtag, tag.size()));
}
// Additionally test low-level AES mode APIs. Skip runs where |copy| because
// it does not apply.
if (!copy) {
int nid = EVP_CIPHER_nid(cipher);
bool is_ctr = nid == NID_aes_128_ctr || nid == NID_aes_192_ctr ||
nid == NID_aes_256_ctr;
bool is_cbc = nid == NID_aes_128_cbc || nid == NID_aes_192_cbc ||
nid == NID_aes_256_cbc;
bool is_ofb = nid == NID_aes_128_ofb128 || nid == NID_aes_192_ofb128 ||
nid == NID_aes_256_ofb128;
if (is_ctr || is_cbc || is_ofb) {
AES_KEY aes;
if (encrypt || !is_cbc) {
ASSERT_EQ(0, AES_set_encrypt_key(key.data(), key.size() * 8, &aes));
} else {
ASSERT_EQ(0, AES_set_decrypt_key(key.data(), key.size() * 8, &aes));
}
// The low-level APIs all work in-place.
bssl::Span<const uint8_t> input = *in;
result.clear();
if (in_place) {
result = *in;
input = result;
} else {
result.resize(out->size());
}
bssl::Span<uint8_t> output = bssl::MakeSpan(result);
ASSERT_EQ(input.size(), output.size());
// The low-level APIs all use block-size IVs.
ASSERT_EQ(iv.size(), size_t{AES_BLOCK_SIZE});
uint8_t ivec[AES_BLOCK_SIZE];
OPENSSL_memcpy(ivec, iv.data(), iv.size());
if (is_ctr) {
unsigned num = 0;
uint8_t ecount_buf[AES_BLOCK_SIZE];
if (chunk_size == 0) {
AES_ctr128_encrypt(input.data(), output.data(), input.size(), &aes,
ivec, ecount_buf, &num);
} else {
do {
size_t todo = std::min(input.size(), chunk_size);
AES_ctr128_encrypt(input.data(), output.data(), todo, &aes, ivec,
ecount_buf, &num);
input = input.subspan(todo);
output = output.subspan(todo);
} while (!input.empty());
}
EXPECT_EQ(Bytes(*out), Bytes(result));
} else if (is_cbc && chunk_size % AES_BLOCK_SIZE == 0) {
// Note |AES_cbc_encrypt| requires block-aligned chunks.
if (chunk_size == 0) {
AES_cbc_encrypt(input.data(), output.data(), input.size(), &aes, ivec,
encrypt);
} else {
do {
size_t todo = std::min(input.size(), chunk_size);
AES_cbc_encrypt(input.data(), output.data(), todo, &aes, ivec,
encrypt);
input = input.subspan(todo);
output = output.subspan(todo);
} while (!input.empty());
}
EXPECT_EQ(Bytes(*out), Bytes(result));
} else if (is_ofb) {
int num = 0;
if (chunk_size == 0) {
AES_ofb128_encrypt(input.data(), output.data(), input.size(), &aes,
ivec, &num);
} else {
do {
size_t todo = std::min(input.size(), chunk_size);
AES_ofb128_encrypt(input.data(), output.data(), todo, &aes, ivec,
&num);
input = input.subspan(todo);
output = output.subspan(todo);
} while (!input.empty());
}
EXPECT_EQ(Bytes(*out), Bytes(result));
}
}
}
}
static void TestCipher(FileTest *t) {
@@ -229,17 +349,24 @@ static void TestCipher(FileTest *t) {
for (size_t chunk_size : chunk_sizes) {
SCOPED_TRACE(chunk_size);
// By default, both directions are run, unless overridden by the operation.
if (operation != kDecrypt) {
SCOPED_TRACE("encrypt");
TestOperation(t, cipher, true /* encrypt */, chunk_size, key, iv,
plaintext, ciphertext, aad, tag);
}
for (bool copy : {false, true}) {
SCOPED_TRACE(copy);
for (bool in_place : {false, true}) {
SCOPED_TRACE(in_place);
// By default, both directions are run, unless overridden by the
// operation.
if (operation != kDecrypt) {
SCOPED_TRACE("encrypt");
TestOperation(t, cipher, true /* encrypt */, copy, in_place,
chunk_size, key, iv, plaintext, ciphertext, aad, tag);
}
if (operation != kEncrypt) {
SCOPED_TRACE("decrypt");
TestOperation(t, cipher, false /* decrypt */, chunk_size, key, iv,
plaintext, ciphertext, aad, tag);
if (operation != kEncrypt) {
SCOPED_TRACE("decrypt");
TestOperation(t, cipher, false /* decrypt */, copy, in_place,
chunk_size, key, iv, plaintext, ciphertext, aad, tag);
}
}
}
}
}
@@ -285,3 +412,65 @@ TEST(CipherTest, CAVP_TDES_CBC) {
TEST(CipherTest, CAVP_TDES_ECB) {
FileTestGTest("crypto/cipher_extra/test/nist_cavp/tdes_ecb.txt", TestCipher);
}
TEST(CipherTest, WycheproofAESCBC) {
FileTestGTest(
"third_party/wycheproof_testvectors/aes_cbc_pkcs5_test.txt",
[](FileTest *t) {
t->IgnoreInstruction("type");
t->IgnoreInstruction("ivSize");
std::string key_size;
ASSERT_TRUE(t->GetInstruction(&key_size, "keySize"));
const EVP_CIPHER *cipher;
switch (atoi(key_size.c_str())) {
case 128:
cipher = EVP_aes_128_cbc();
break;
case 192:
cipher = EVP_aes_192_cbc();
break;
case 256:
cipher = EVP_aes_256_cbc();
break;
default:
FAIL() << "Unsupported key size: " << key_size;
}
std::vector<uint8_t> key, iv, msg, ct;
ASSERT_TRUE(t->GetBytes(&key, "key"));
ASSERT_TRUE(t->GetBytes(&iv, "iv"));
ASSERT_TRUE(t->GetBytes(&msg, "msg"));
ASSERT_TRUE(t->GetBytes(&ct, "ct"));
ASSERT_EQ(EVP_CIPHER_key_length(cipher), key.size());
ASSERT_EQ(EVP_CIPHER_iv_length(cipher), iv.size());
WycheproofResult result;
ASSERT_TRUE(GetWycheproofResult(t, &result));
bssl::ScopedEVP_CIPHER_CTX ctx;
std::vector<uint8_t> out;
const std::vector<size_t> chunk_sizes = {
0, 1, 2, 5, 7, 8, 9, 15, 16, 17, 31, 32, 33, 63, 64, 65, 512};
for (size_t chunk : chunk_sizes) {
SCOPED_TRACE(chunk);
for (bool in_place : {false, true}) {
SCOPED_TRACE(in_place);
if (result.IsValid()) {
ASSERT_TRUE(EVP_DecryptInit_ex(ctx.get(), cipher, nullptr,
key.data(), iv.data()));
ASSERT_TRUE(DoCipher(ctx.get(), &out, ct, chunk, in_place));
EXPECT_EQ(Bytes(msg), Bytes(out));
ASSERT_TRUE(EVP_EncryptInit_ex(ctx.get(), cipher, nullptr,
key.data(), iv.data()));
ASSERT_TRUE(DoCipher(ctx.get(), &out, msg, chunk, in_place));
EXPECT_EQ(Bytes(ct), Bytes(out));
} else {
ASSERT_TRUE(EVP_DecryptInit_ex(ctx.get(), cipher, nullptr,
key.data(), iv.data()));
EXPECT_FALSE(DoCipher(ctx.get(), &out, ct, chunk, in_place));
}
}
}
});
}
+1 -1
View File
@@ -86,7 +86,7 @@ int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md,
EVP_MD_CTX_init(&c);
for (;;) {
if (!EVP_DigestInit_ex(&c, md, NULL)) {
return 0;
goto err;
}
if (addmd++) {
if (!EVP_DigestUpdate(&c, md_buf, mds)) {
+447
View File
@@ -0,0 +1,447 @@
/* ====================================================================
* Copyright (c) 2008 The OpenSSL Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
*
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For written permission, please contact
* openssl-core@openssl.org.
*
* 5. Products derived from this software may not be called "OpenSSL"
* nor may "OpenSSL" appear in their names without prior written
* permission of the OpenSSL Project.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
*
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* ==================================================================== */
#include <openssl/aead.h>
#include <assert.h>
#include <openssl/cpu.h>
#include <openssl/cipher.h>
#include <openssl/err.h>
#include <openssl/mem.h>
#include "../fipsmodule/cipher/internal.h"
struct ccm128_context {
block128_f block;
ctr128_f ctr;
unsigned M, L;
};
struct ccm128_state {
union {
uint64_t u[2];
uint8_t c[16];
} nonce, cmac;
};
static int CRYPTO_ccm128_init(struct ccm128_context *ctx, const AES_KEY *key,
block128_f block, ctr128_f ctr, unsigned M,
unsigned L) {
if (M < 4 || M > 16 || (M & 1) != 0 || L < 2 || L > 8) {
return 0;
}
ctx->block = block;
ctx->ctr = ctr;
ctx->M = M;
ctx->L = L;
return 1;
}
static size_t CRYPTO_ccm128_max_input(const struct ccm128_context *ctx) {
return ctx->L >= sizeof(size_t) ? (size_t)-1
: (((size_t)1) << (ctx->L * 8)) - 1;
}
static int ccm128_init_state(const struct ccm128_context *ctx,
struct ccm128_state *state, const AES_KEY *key,
const uint8_t *nonce, size_t nonce_len,
const uint8_t *aad, size_t aad_len,
size_t plaintext_len) {
const block128_f block = ctx->block;
const unsigned M = ctx->M;
const unsigned L = ctx->L;
// |L| determines the expected |nonce_len| and the limit for |plaintext_len|.
if (plaintext_len > CRYPTO_ccm128_max_input(ctx) ||
nonce_len != 15 - L) {
return 0;
}
// Assemble the first block for computing the MAC.
OPENSSL_memset(state, 0, sizeof(*state));
state->nonce.c[0] = (uint8_t)((L - 1) | ((M - 2) / 2) << 3);
if (aad_len != 0) {
state->nonce.c[0] |= 0x40; // Set AAD Flag
}
OPENSSL_memcpy(&state->nonce.c[1], nonce, nonce_len);
for (unsigned i = 0; i < L; i++) {
state->nonce.c[15 - i] = (uint8_t)(plaintext_len >> (8 * i));
}
(*block)(state->nonce.c, state->cmac.c, key);
size_t blocks = 1;
if (aad_len != 0) {
unsigned i;
// Cast to u64 to avoid the compiler complaining about invalid shifts.
uint64_t aad_len_u64 = aad_len;
if (aad_len_u64 < 0x10000 - 0x100) {
state->cmac.c[0] ^= (uint8_t)(aad_len_u64 >> 8);
state->cmac.c[1] ^= (uint8_t)aad_len_u64;
i = 2;
} else if (aad_len_u64 <= 0xffffffff) {
state->cmac.c[0] ^= 0xff;
state->cmac.c[1] ^= 0xfe;
state->cmac.c[2] ^= (uint8_t)(aad_len_u64 >> 24);
state->cmac.c[3] ^= (uint8_t)(aad_len_u64 >> 16);
state->cmac.c[4] ^= (uint8_t)(aad_len_u64 >> 8);
state->cmac.c[5] ^= (uint8_t)aad_len_u64;
i = 6;
} else {
state->cmac.c[0] ^= 0xff;
state->cmac.c[1] ^= 0xff;
state->cmac.c[2] ^= (uint8_t)(aad_len_u64 >> 56);
state->cmac.c[3] ^= (uint8_t)(aad_len_u64 >> 48);
state->cmac.c[4] ^= (uint8_t)(aad_len_u64 >> 40);
state->cmac.c[5] ^= (uint8_t)(aad_len_u64 >> 32);
state->cmac.c[6] ^= (uint8_t)(aad_len_u64 >> 24);
state->cmac.c[7] ^= (uint8_t)(aad_len_u64 >> 16);
state->cmac.c[8] ^= (uint8_t)(aad_len_u64 >> 8);
state->cmac.c[9] ^= (uint8_t)aad_len_u64;
i = 10;
}
do {
for (; i < 16 && aad_len != 0; i++) {
state->cmac.c[i] ^= *aad;
aad++;
aad_len--;
}
(*block)(state->cmac.c, state->cmac.c, key);
blocks++;
i = 0;
} while (aad_len != 0);
}
// Per RFC 3610, section 2.6, the total number of block cipher operations done
// must not exceed 2^61. There are two block cipher operations remaining per
// message block, plus one block at the end to encrypt the MAC.
size_t remaining_blocks = 2 * ((plaintext_len + 15) / 16) + 1;
if (plaintext_len + 15 < plaintext_len ||
remaining_blocks + blocks < blocks ||
(uint64_t) remaining_blocks + blocks > UINT64_C(1) << 61) {
return 0;
}
// Assemble the first block for encrypting and decrypting. The bottom |L|
// bytes are replaced with a counter and all bit the encoding of |L| is
// cleared in the first byte.
state->nonce.c[0] &= 7;
return 1;
}
static int ccm128_encrypt(const struct ccm128_context *ctx,
struct ccm128_state *state, const AES_KEY *key,
uint8_t *out, const uint8_t *in, size_t len) {
// The counter for encryption begins at one.
for (unsigned i = 0; i < ctx->L; i++) {
state->nonce.c[15 - i] = 0;
}
state->nonce.c[15] = 1;
uint8_t partial_buf[16];
unsigned num = 0;
if (ctx->ctr != NULL) {
CRYPTO_ctr128_encrypt_ctr32(in, out, len, key, state->nonce.c, partial_buf,
&num, ctx->ctr);
} else {
CRYPTO_ctr128_encrypt(in, out, len, key, state->nonce.c, partial_buf, &num,
ctx->block);
}
return 1;
}
static int ccm128_compute_mac(const struct ccm128_context *ctx,
struct ccm128_state *state, const AES_KEY *key,
uint8_t *out_tag, size_t tag_len,
const uint8_t *in, size_t len) {
block128_f block = ctx->block;
if (tag_len != ctx->M) {
return 0;
}
// Incorporate |in| into the MAC.
union {
uint64_t u[2];
uint8_t c[16];
} tmp;
while (len >= 16) {
OPENSSL_memcpy(tmp.c, in, 16);
state->cmac.u[0] ^= tmp.u[0];
state->cmac.u[1] ^= tmp.u[1];
(*block)(state->cmac.c, state->cmac.c, key);
in += 16;
len -= 16;
}
if (len > 0) {
for (size_t i = 0; i < len; i++) {
state->cmac.c[i] ^= in[i];
}
(*block)(state->cmac.c, state->cmac.c, key);
}
// Encrypt the MAC with counter zero.
for (unsigned i = 0; i < ctx->L; i++) {
state->nonce.c[15 - i] = 0;
}
(*block)(state->nonce.c, tmp.c, key);
state->cmac.u[0] ^= tmp.u[0];
state->cmac.u[1] ^= tmp.u[1];
OPENSSL_memcpy(out_tag, state->cmac.c, tag_len);
return 1;
}
static int CRYPTO_ccm128_encrypt(const struct ccm128_context *ctx,
const AES_KEY *key, uint8_t *out,
uint8_t *out_tag, size_t tag_len,
const uint8_t *nonce, size_t nonce_len,
const uint8_t *in, size_t len,
const uint8_t *aad, size_t aad_len) {
struct ccm128_state state;
return ccm128_init_state(ctx, &state, key, nonce, nonce_len, aad, aad_len,
len) &&
ccm128_compute_mac(ctx, &state, key, out_tag, tag_len, in, len) &&
ccm128_encrypt(ctx, &state, key, out, in, len);
}
static int CRYPTO_ccm128_decrypt(const struct ccm128_context *ctx,
const AES_KEY *key, uint8_t *out,
uint8_t *out_tag, size_t tag_len,
const uint8_t *nonce, size_t nonce_len,
const uint8_t *in, size_t len,
const uint8_t *aad, size_t aad_len) {
struct ccm128_state state;
return ccm128_init_state(ctx, &state, key, nonce, nonce_len, aad, aad_len,
len) &&
ccm128_encrypt(ctx, &state, key, out, in, len) &&
ccm128_compute_mac(ctx, &state, key, out_tag, tag_len, out, len);
}
#define EVP_AEAD_AES_CCM_MAX_TAG_LEN 16
struct aead_aes_ccm_ctx {
union {
double align;
AES_KEY ks;
} ks;
struct ccm128_context ccm;
};
OPENSSL_STATIC_ASSERT(sizeof(((EVP_AEAD_CTX *)NULL)->state) >=
sizeof(struct aead_aes_ccm_ctx),
"AEAD state is too small");
#if defined(__GNUC__) || defined(__clang__)
OPENSSL_STATIC_ASSERT(alignof(union evp_aead_ctx_st_state) >=
alignof(struct aead_aes_ccm_ctx),
"AEAD state has insufficient alignment");
#endif
static int aead_aes_ccm_init(EVP_AEAD_CTX *ctx, const uint8_t *key,
size_t key_len, size_t tag_len, unsigned M,
unsigned L) {
assert(M == EVP_AEAD_max_overhead(ctx->aead));
assert(M == EVP_AEAD_max_tag_len(ctx->aead));
assert(15 - L == EVP_AEAD_nonce_length(ctx->aead));
if (key_len != EVP_AEAD_key_length(ctx->aead)) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BAD_KEY_LENGTH);
return 0; // EVP_AEAD_CTX_init should catch this.
}
if (tag_len == EVP_AEAD_DEFAULT_TAG_LENGTH) {
tag_len = M;
}
if (tag_len != M) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_TAG_TOO_LARGE);
return 0;
}
struct aead_aes_ccm_ctx *ccm_ctx = (struct aead_aes_ccm_ctx *)&ctx->state;
block128_f block;
ctr128_f ctr = aes_ctr_set_key(&ccm_ctx->ks.ks, NULL, &block, key, key_len);
ctx->tag_len = tag_len;
if (!CRYPTO_ccm128_init(&ccm_ctx->ccm, &ccm_ctx->ks.ks, block, ctr, M, L)) {
OPENSSL_PUT_ERROR(CIPHER, ERR_R_INTERNAL_ERROR);
return 0;
}
return 1;
}
static void aead_aes_ccm_cleanup(EVP_AEAD_CTX *ctx) {}
static int aead_aes_ccm_seal_scatter(
const EVP_AEAD_CTX *ctx, uint8_t *out, uint8_t *out_tag,
size_t *out_tag_len, size_t max_out_tag_len, const uint8_t *nonce,
size_t nonce_len, const uint8_t *in, size_t in_len, const uint8_t *extra_in,
size_t extra_in_len, const uint8_t *ad, size_t ad_len) {
const struct aead_aes_ccm_ctx *ccm_ctx =
(struct aead_aes_ccm_ctx *)&ctx->state;
if (in_len > CRYPTO_ccm128_max_input(&ccm_ctx->ccm)) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_TOO_LARGE);
return 0;
}
if (max_out_tag_len < ctx->tag_len) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BUFFER_TOO_SMALL);
return 0;
}
if (nonce_len != EVP_AEAD_nonce_length(ctx->aead)) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_INVALID_NONCE_SIZE);
return 0;
}
if (!CRYPTO_ccm128_encrypt(&ccm_ctx->ccm, &ccm_ctx->ks.ks, out, out_tag,
ctx->tag_len, nonce, nonce_len, in, in_len, ad,
ad_len)) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_TOO_LARGE);
return 0;
}
*out_tag_len = ctx->tag_len;
return 1;
}
static int aead_aes_ccm_open_gather(const EVP_AEAD_CTX *ctx, uint8_t *out,
const uint8_t *nonce, size_t nonce_len,
const uint8_t *in, size_t in_len,
const uint8_t *in_tag, size_t in_tag_len,
const uint8_t *ad, size_t ad_len) {
const struct aead_aes_ccm_ctx *ccm_ctx =
(struct aead_aes_ccm_ctx *)&ctx->state;
if (in_len > CRYPTO_ccm128_max_input(&ccm_ctx->ccm)) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_TOO_LARGE);
return 0;
}
if (nonce_len != EVP_AEAD_nonce_length(ctx->aead)) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_INVALID_NONCE_SIZE);
return 0;
}
if (in_tag_len != ctx->tag_len) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BAD_DECRYPT);
return 0;
}
uint8_t tag[EVP_AEAD_AES_CCM_MAX_TAG_LEN];
assert(ctx->tag_len <= EVP_AEAD_AES_CCM_MAX_TAG_LEN);
if (!CRYPTO_ccm128_decrypt(&ccm_ctx->ccm, &ccm_ctx->ks.ks, out, tag,
ctx->tag_len, nonce, nonce_len, in, in_len, ad,
ad_len)) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_TOO_LARGE);
return 0;
}
if (CRYPTO_memcmp(tag, in_tag, ctx->tag_len) != 0) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BAD_DECRYPT);
return 0;
}
return 1;
}
static int aead_aes_ccm_bluetooth_init(EVP_AEAD_CTX *ctx, const uint8_t *key,
size_t key_len, size_t tag_len) {
return aead_aes_ccm_init(ctx, key, key_len, tag_len, 4, 2);
}
static const EVP_AEAD aead_aes_128_ccm_bluetooth = {
16, // key length (AES-128)
13, // nonce length
4, // overhead
4, // max tag length
0, // seal_scatter_supports_extra_in
aead_aes_ccm_bluetooth_init,
NULL /* init_with_direction */,
aead_aes_ccm_cleanup,
NULL /* open */,
aead_aes_ccm_seal_scatter,
aead_aes_ccm_open_gather,
NULL /* get_iv */,
NULL /* tag_len */,
};
const EVP_AEAD *EVP_aead_aes_128_ccm_bluetooth(void) {
return &aead_aes_128_ccm_bluetooth;
}
static int aead_aes_ccm_bluetooth_8_init(EVP_AEAD_CTX *ctx, const uint8_t *key,
size_t key_len, size_t tag_len) {
return aead_aes_ccm_init(ctx, key, key_len, tag_len, 8, 2);
}
static const EVP_AEAD aead_aes_128_ccm_bluetooth_8 = {
16, // key length (AES-128)
13, // nonce length
8, // overhead
8, // max tag length
0, // seal_scatter_supports_extra_in
aead_aes_ccm_bluetooth_8_init,
NULL /* init_with_direction */,
aead_aes_ccm_cleanup,
NULL /* open */,
aead_aes_ccm_seal_scatter,
aead_aes_ccm_open_gather,
NULL /* get_iv */,
NULL /* tag_len */,
};
const EVP_AEAD *EVP_aead_aes_128_ccm_bluetooth_8(void) {
return &aead_aes_128_ccm_bluetooth_8;
}
+16 -16
View File
@@ -35,6 +35,15 @@ struct aead_aes_ctr_hmac_sha256_ctx {
SHA256_CTX outer_init_state;
};
OPENSSL_STATIC_ASSERT(sizeof(((EVP_AEAD_CTX *)NULL)->state) >=
sizeof(struct aead_aes_ctr_hmac_sha256_ctx),
"AEAD state is too small");
#if defined(__GNUC__) || defined(__clang__)
OPENSSL_STATIC_ASSERT(alignof(union evp_aead_ctx_st_state) >=
alignof(struct aead_aes_ctr_hmac_sha256_ctx),
"AEAD state has insufficient alignment");
#endif
static void hmac_init(SHA256_CTX *out_inner, SHA256_CTX *out_outer,
const uint8_t hmac_key[32]) {
static const size_t hmac_key_len = 32;
@@ -61,7 +70,8 @@ static void hmac_init(SHA256_CTX *out_inner, SHA256_CTX *out_outer,
static int aead_aes_ctr_hmac_sha256_init(EVP_AEAD_CTX *ctx, const uint8_t *key,
size_t key_len, size_t tag_len) {
struct aead_aes_ctr_hmac_sha256_ctx *aes_ctx;
struct aead_aes_ctr_hmac_sha256_ctx *aes_ctx =
(struct aead_aes_ctr_hmac_sha256_ctx *)&ctx->state;
static const size_t hmac_key_len = 32;
if (key_len < hmac_key_len) {
@@ -84,28 +94,16 @@ static int aead_aes_ctr_hmac_sha256_init(EVP_AEAD_CTX *ctx, const uint8_t *key,
return 0;
}
aes_ctx = OPENSSL_malloc(sizeof(struct aead_aes_ctr_hmac_sha256_ctx));
if (aes_ctx == NULL) {
OPENSSL_PUT_ERROR(CIPHER, ERR_R_MALLOC_FAILURE);
return 0;
}
aes_ctx->ctr =
aes_ctr_set_key(&aes_ctx->ks.ks, NULL, &aes_ctx->block, key, aes_key_len);
ctx->tag_len = tag_len;
hmac_init(&aes_ctx->inner_init_state, &aes_ctx->outer_init_state,
key + aes_key_len);
ctx->aead_state = aes_ctx;
return 1;
}
static void aead_aes_ctr_hmac_sha256_cleanup(EVP_AEAD_CTX *ctx) {
struct aead_aes_ctr_hmac_sha256_ctx *aes_ctx = ctx->aead_state;
OPENSSL_cleanse(aes_ctx, sizeof(struct aead_aes_ctr_hmac_sha256_ctx));
OPENSSL_free(aes_ctx);
}
static void aead_aes_ctr_hmac_sha256_cleanup(EVP_AEAD_CTX *ctx) {}
static void hmac_update_uint64(SHA256_CTX *sha256, uint64_t value) {
unsigned i;
@@ -180,7 +178,8 @@ static int aead_aes_ctr_hmac_sha256_seal_scatter(
size_t *out_tag_len, size_t max_out_tag_len, const uint8_t *nonce,
size_t nonce_len, const uint8_t *in, size_t in_len, const uint8_t *extra_in,
size_t extra_in_len, const uint8_t *ad, size_t ad_len) {
const struct aead_aes_ctr_hmac_sha256_ctx *aes_ctx = ctx->aead_state;
const struct aead_aes_ctr_hmac_sha256_ctx *aes_ctx =
(struct aead_aes_ctr_hmac_sha256_ctx *) &ctx->state;
const uint64_t in_len_64 = in_len;
if (in_len_64 >= (UINT64_C(1) << 32) * AES_BLOCK_SIZE) {
@@ -214,7 +213,8 @@ static int aead_aes_ctr_hmac_sha256_open_gather(
const EVP_AEAD_CTX *ctx, uint8_t *out, const uint8_t *nonce,
size_t nonce_len, const uint8_t *in, size_t in_len, const uint8_t *in_tag,
size_t in_tag_len, const uint8_t *ad, size_t ad_len) {
const struct aead_aes_ctr_hmac_sha256_ctx *aes_ctx = ctx->aead_state;
const struct aead_aes_ctr_hmac_sha256_ctx *aes_ctx =
(struct aead_aes_ctr_hmac_sha256_ctx *) &ctx->state;
if (in_tag_len != ctx->tag_len) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BAD_DECRYPT);
+62 -33
View File
@@ -27,7 +27,11 @@
#define EVP_AEAD_AES_GCM_SIV_NONCE_LEN 12
#define EVP_AEAD_AES_GCM_SIV_TAG_LEN 16
#if defined(OPENSSL_X86_64) && !defined(OPENSSL_NO_ASM)
// TODO(davidben): AES-GCM-SIV assembly is not correct for Windows. It must save
// and restore xmm6 through xmm15.
#if defined(OPENSSL_X86_64) && !defined(OPENSSL_NO_ASM) && \
!defined(OPENSSL_WINDOWS)
#define AES_GCM_SIV_ASM
// Optimised AES-GCM-SIV
@@ -36,15 +40,34 @@ struct aead_aes_gcm_siv_asm_ctx {
int is_128_bit;
};
// The assembly code assumes 8-byte alignment of the EVP_AEAD_CTX's state, and
// aligns to 16 bytes itself.
OPENSSL_STATIC_ASSERT(sizeof(((EVP_AEAD_CTX *)NULL)->state) + 8 >=
sizeof(struct aead_aes_gcm_siv_asm_ctx),
"AEAD state is too small");
#if defined(__GNUC__) || defined(__clang__)
OPENSSL_STATIC_ASSERT(alignof(union evp_aead_ctx_st_state) >= 8,
"AEAD state has insufficient alignment");
#endif
// asm_ctx_from_ctx returns a 16-byte aligned context pointer from |ctx|.
static struct aead_aes_gcm_siv_asm_ctx *asm_ctx_from_ctx(
const EVP_AEAD_CTX *ctx) {
// ctx->state must already be 8-byte aligned. Thus, at most, we may need to
// add eight to align it to 16 bytes.
const uintptr_t offset = ((uintptr_t)&ctx->state) & 8;
return (struct aead_aes_gcm_siv_asm_ctx *)(&ctx->state.opaque[offset]);
}
// aes128gcmsiv_aes_ks writes an AES-128 key schedule for |key| to
// |out_expanded_key|.
extern void aes128gcmsiv_aes_ks(
const uint8_t key[16], uint8_t out_expanded_key[16*15]);
// aes128gcmsiv_aes_ks writes an AES-128 key schedule for |key| to
// aes256gcmsiv_aes_ks writes an AES-256 key schedule for |key| to
// |out_expanded_key|.
extern void aes256gcmsiv_aes_ks(
const uint8_t key[16], uint8_t out_expanded_key[16*15]);
const uint8_t key[32], uint8_t out_expanded_key[16*15]);
static int aead_aes_gcm_siv_asm_init(EVP_AEAD_CTX *ctx, const uint8_t *key,
size_t key_len, size_t tag_len) {
@@ -64,13 +87,7 @@ static int aead_aes_gcm_siv_asm_init(EVP_AEAD_CTX *ctx, const uint8_t *key,
return 0;
}
struct aead_aes_gcm_siv_asm_ctx *gcm_siv_ctx =
OPENSSL_malloc(sizeof(struct aead_aes_gcm_siv_asm_ctx));
if (gcm_siv_ctx == NULL) {
return 0;
}
// malloc should return a 16-byte-aligned address.
struct aead_aes_gcm_siv_asm_ctx *gcm_siv_ctx = asm_ctx_from_ctx(ctx);
assert((((uintptr_t)gcm_siv_ctx) & 15) == 0);
if (key_bits == 128) {
@@ -80,17 +97,13 @@ static int aead_aes_gcm_siv_asm_init(EVP_AEAD_CTX *ctx, const uint8_t *key,
aes256gcmsiv_aes_ks(key, &gcm_siv_ctx->key[0]);
gcm_siv_ctx->is_128_bit = 0;
}
ctx->aead_state = gcm_siv_ctx;
ctx->tag_len = tag_len;
return 1;
}
static void aead_aes_gcm_siv_asm_cleanup(EVP_AEAD_CTX *ctx) {
struct aead_aes_gcm_siv_asm_ctx *gcm_siv_asm_ctx = ctx->aead_state;
OPENSSL_cleanse(gcm_siv_asm_ctx, sizeof(struct aead_aes_gcm_siv_asm_ctx));
OPENSSL_free(gcm_siv_asm_ctx);
}
static void aead_aes_gcm_siv_asm_cleanup(EVP_AEAD_CTX *ctx) {}
// aesgcmsiv_polyval_horner updates the POLYVAL value in |in_out_poly| to
// include a number (|in_blocks|) of 16-byte blocks of data from |in|, given
@@ -330,7 +343,7 @@ static int aead_aes_gcm_siv_asm_seal_scatter(
size_t *out_tag_len, size_t max_out_tag_len, const uint8_t *nonce,
size_t nonce_len, const uint8_t *in, size_t in_len, const uint8_t *extra_in,
size_t extra_in_len, const uint8_t *ad, size_t ad_len) {
const struct aead_aes_gcm_siv_asm_ctx *gcm_siv_ctx = ctx->aead_state;
const struct aead_aes_gcm_siv_asm_ctx *gcm_siv_ctx = asm_ctx_from_ctx(ctx);
const uint64_t in_len_64 = in_len;
const uint64_t ad_len_64 = ad_len;
@@ -413,7 +426,12 @@ static int aead_aes_gcm_siv_asm_open(const EVP_AEAD_CTX *ctx, uint8_t *out,
return 0;
}
const struct aead_aes_gcm_siv_asm_ctx *gcm_siv_ctx = ctx->aead_state;
if (nonce_len != EVP_AEAD_AES_GCM_SIV_NONCE_LEN) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_UNSUPPORTED_NONCE_SIZE);
return 0;
}
const struct aead_aes_gcm_siv_asm_ctx *gcm_siv_ctx = asm_ctx_from_ctx(ctx);
const size_t plaintext_len = in_len - EVP_AEAD_AES_GCM_SIV_TAG_LEN;
const uint8_t *const given_tag = in + plaintext_len;
@@ -540,7 +558,7 @@ static const EVP_AEAD aead_aes_256_gcm_siv_asm = {
NULL /* tag_len */,
};
#endif // X86_64 && !NO_ASM
#endif // X86_64 && !NO_ASM && !WINDOWS
struct aead_aes_gcm_siv_ctx {
union {
@@ -551,6 +569,15 @@ struct aead_aes_gcm_siv_ctx {
unsigned is_256:1;
};
OPENSSL_STATIC_ASSERT(sizeof(((EVP_AEAD_CTX *)NULL)->state) >=
sizeof(struct aead_aes_gcm_siv_ctx),
"AEAD state is too small");
#if defined(__GNUC__) || defined(__clang__)
OPENSSL_STATIC_ASSERT(alignof(union evp_aead_ctx_st_state) >=
alignof(struct aead_aes_gcm_siv_ctx),
"AEAD state has insufficient alignment");
#endif
static int aead_aes_gcm_siv_init(EVP_AEAD_CTX *ctx, const uint8_t *key,
size_t key_len, size_t tag_len) {
const size_t key_bits = key_len * 8;
@@ -569,26 +596,18 @@ static int aead_aes_gcm_siv_init(EVP_AEAD_CTX *ctx, const uint8_t *key,
}
struct aead_aes_gcm_siv_ctx *gcm_siv_ctx =
OPENSSL_malloc(sizeof(struct aead_aes_gcm_siv_ctx));
if (gcm_siv_ctx == NULL) {
return 0;
}
(struct aead_aes_gcm_siv_ctx *)&ctx->state;
OPENSSL_memset(gcm_siv_ctx, 0, sizeof(struct aead_aes_gcm_siv_ctx));
aes_ctr_set_key(&gcm_siv_ctx->ks.ks, NULL, &gcm_siv_ctx->kgk_block, key,
key_len);
gcm_siv_ctx->is_256 = (key_len == 32);
ctx->aead_state = gcm_siv_ctx;
ctx->tag_len = tag_len;
return 1;
}
static void aead_aes_gcm_siv_cleanup(EVP_AEAD_CTX *ctx) {
struct aead_aes_gcm_siv_ctx *gcm_siv_ctx = ctx->aead_state;
OPENSSL_cleanse(gcm_siv_ctx, sizeof(struct aead_aes_gcm_siv_ctx));
OPENSSL_free(gcm_siv_ctx);
}
static void aead_aes_gcm_siv_cleanup(EVP_AEAD_CTX *ctx) {}
// gcm_siv_crypt encrypts (or decrypts—it's the same thing) |in_len| bytes from
// |in| to |out|, using the block function |enc_block| with |key| in counter
@@ -704,6 +723,14 @@ static void gcm_siv_keys(
}
OPENSSL_memcpy(out_keys->auth_key, key_material, 16);
// Note the |ctr128_f| function uses a big-endian couner, while AES-GCM-SIV
// uses a little-endian counter. We ignore the return value and only use
// |block128_f|. This has a significant performance cost for the fallback
// bitsliced AES implementations (bsaes and aes_nohw).
//
// We currently do not consider AES-GCM-SIV to be performance-sensitive on
// client hardware. If this changes, we can write little-endian |ctr128_f|
// functions.
aes_ctr_set_key(&out_keys->enc_key.ks, NULL, &out_keys->enc_block,
key_material + 16, gcm_siv_ctx->is_256 ? 32 : 16);
}
@@ -713,7 +740,8 @@ static int aead_aes_gcm_siv_seal_scatter(
size_t *out_tag_len, size_t max_out_tag_len, const uint8_t *nonce,
size_t nonce_len, const uint8_t *in, size_t in_len, const uint8_t *extra_in,
size_t extra_in_len, const uint8_t *ad, size_t ad_len) {
const struct aead_aes_gcm_siv_ctx *gcm_siv_ctx = ctx->aead_state;
const struct aead_aes_gcm_siv_ctx *gcm_siv_ctx =
(struct aead_aes_gcm_siv_ctx *)&ctx->state;
const uint64_t in_len_64 = in_len;
const uint64_t ad_len_64 = ad_len;
@@ -773,7 +801,8 @@ static int aead_aes_gcm_siv_open_gather(const EVP_AEAD_CTX *ctx, uint8_t *out,
return 0;
}
const struct aead_aes_gcm_siv_ctx *gcm_siv_ctx = ctx->aead_state;
const struct aead_aes_gcm_siv_ctx *gcm_siv_ctx =
(struct aead_aes_gcm_siv_ctx *)&ctx->state;
struct gcm_siv_record_keys keys;
gcm_siv_keys(gcm_siv_ctx, &keys, nonce);
@@ -826,7 +855,7 @@ static const EVP_AEAD aead_aes_256_gcm_siv = {
NULL /* tag_len */,
};
#if defined(OPENSSL_X86_64) && !defined(OPENSSL_NO_ASM)
#if defined(AES_GCM_SIV_ASM)
static char avx_aesni_capable(void) {
const uint32_t ecx = OPENSSL_ia32cap_P[1];
@@ -859,4 +888,4 @@ const EVP_AEAD *EVP_aead_aes_256_gcm_siv(void) {
return &aead_aes_256_gcm_siv;
}
#endif // X86_64 && !NO_ASM
#endif // AES_GCM_SIV_ASM
+133 -43
View File
@@ -26,6 +26,7 @@
#include "../fipsmodule/cipher/internal.h"
#include "../internal.h"
#include "../chacha/internal.h"
#define POLY1305_TAG_LEN 16
@@ -34,6 +35,15 @@ struct aead_chacha20_poly1305_ctx {
uint8_t key[32];
};
OPENSSL_STATIC_ASSERT(sizeof(((EVP_AEAD_CTX *)NULL)->state) >=
sizeof(struct aead_chacha20_poly1305_ctx),
"AEAD state is too small");
#if defined(__GNUC__) || defined(__clang__)
OPENSSL_STATIC_ASSERT(alignof(union evp_aead_ctx_st_state) >=
alignof(struct aead_chacha20_poly1305_ctx),
"AEAD state has insufficient alignment");
#endif
// For convenience (the x86_64 calling convention allows only six parameters in
// registers), the final parameter for the assembly functions is both an input
// and output parameter.
@@ -68,9 +78,9 @@ static int asm_capable(void) {
return sse41_capable;
}
OPENSSL_COMPILE_ASSERT(sizeof(union open_data) == 48, wrong_open_data_size);
OPENSSL_COMPILE_ASSERT(sizeof(union seal_data) == 48 + 8 + 8,
wrong_seal_data_size);
OPENSSL_STATIC_ASSERT(sizeof(union open_data) == 48, "wrong open_data size");
OPENSSL_STATIC_ASSERT(sizeof(union seal_data) == 48 + 8 + 8,
"wrong seal_data size");
// chacha20_poly1305_open is defined in chacha20_poly1305_x86_64.pl. It decrypts
// |plaintext_len| bytes from |ciphertext| and writes them to |out_plaintext|.
@@ -108,7 +118,8 @@ static void chacha20_poly1305_seal(uint8_t *out_ciphertext,
static int aead_chacha20_poly1305_init(EVP_AEAD_CTX *ctx, const uint8_t *key,
size_t key_len, size_t tag_len) {
struct aead_chacha20_poly1305_ctx *c20_ctx;
struct aead_chacha20_poly1305_ctx *c20_ctx =
(struct aead_chacha20_poly1305_ctx *)&ctx->state;
if (tag_len == 0) {
tag_len = POLY1305_TAG_LEN;
@@ -123,23 +134,13 @@ static int aead_chacha20_poly1305_init(EVP_AEAD_CTX *ctx, const uint8_t *key,
return 0; // internal error - EVP_AEAD_CTX_init should catch this.
}
c20_ctx = OPENSSL_malloc(sizeof(struct aead_chacha20_poly1305_ctx));
if (c20_ctx == NULL) {
return 0;
}
OPENSSL_memcpy(c20_ctx->key, key, key_len);
ctx->aead_state = c20_ctx;
ctx->tag_len = tag_len;
return 1;
}
static void aead_chacha20_poly1305_cleanup(EVP_AEAD_CTX *ctx) {
struct aead_chacha20_poly1305_ctx *c20_ctx = ctx->aead_state;
OPENSSL_cleanse(c20_ctx->key, sizeof(c20_ctx->key));
OPENSSL_free(c20_ctx);
}
static void aead_chacha20_poly1305_cleanup(EVP_AEAD_CTX *ctx) {}
static void poly1305_update_length(poly1305_state *poly1305, size_t data_len) {
uint8_t length_bytes[8];
@@ -153,16 +154,15 @@ static void poly1305_update_length(poly1305_state *poly1305, size_t data_len) {
}
// calc_tag fills |tag| with the authentication tag for the given inputs.
static void calc_tag(uint8_t tag[POLY1305_TAG_LEN],
const struct aead_chacha20_poly1305_ctx *c20_ctx,
static void calc_tag(uint8_t tag[POLY1305_TAG_LEN], const uint8_t *key,
const uint8_t nonce[12], const uint8_t *ad, size_t ad_len,
const uint8_t *ciphertext, size_t ciphertext_len,
const uint8_t *ciphertext_extra,
size_t ciphertext_extra_len) {
alignas(16) uint8_t poly1305_key[32];
OPENSSL_memset(poly1305_key, 0, sizeof(poly1305_key));
CRYPTO_chacha_20(poly1305_key, poly1305_key, sizeof(poly1305_key),
c20_ctx->key, nonce, 0);
CRYPTO_chacha_20(poly1305_key, poly1305_key, sizeof(poly1305_key), key, nonce,
0);
static const uint8_t padding[16] = { 0 }; // Padding is all zeros.
poly1305_state ctx;
@@ -183,18 +183,16 @@ static void calc_tag(uint8_t tag[POLY1305_TAG_LEN],
CRYPTO_poly1305_finish(&ctx, tag);
}
static int aead_chacha20_poly1305_seal_scatter(
const EVP_AEAD_CTX *ctx, uint8_t *out, uint8_t *out_tag,
static int chacha20_poly1305_seal_scatter(
const uint8_t *key, uint8_t *out, uint8_t *out_tag,
size_t *out_tag_len, size_t max_out_tag_len, const uint8_t *nonce,
size_t nonce_len, const uint8_t *in, size_t in_len, const uint8_t *extra_in,
size_t extra_in_len, const uint8_t *ad, size_t ad_len) {
const struct aead_chacha20_poly1305_ctx *c20_ctx = ctx->aead_state;
if (extra_in_len + ctx->tag_len < ctx->tag_len) {
size_t extra_in_len, const uint8_t *ad, size_t ad_len, size_t tag_len) {
if (extra_in_len + tag_len < tag_len) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_TOO_LARGE);
return 0;
}
if (max_out_tag_len < ctx->tag_len + extra_in_len) {
if (max_out_tag_len < tag_len + extra_in_len) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BUFFER_TOO_SMALL);
return 0;
}
@@ -215,7 +213,7 @@ static int aead_chacha20_poly1305_seal_scatter(
return 0;
}
if (max_out_tag_len < ctx->tag_len) {
if (max_out_tag_len < tag_len) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BUFFER_TOO_SMALL);
return 0;
}
@@ -230,7 +228,7 @@ static int aead_chacha20_poly1305_seal_scatter(
for (size_t done = 0; done < extra_in_len; block_counter++) {
memset(block, 0, sizeof(block));
CRYPTO_chacha_20(block, block, sizeof(block), c20_ctx->key, nonce,
CRYPTO_chacha_20(block, block, sizeof(block), key, nonce,
block_counter);
for (size_t i = offset; i < sizeof(block) && done < extra_in_len;
i++, done++) {
@@ -242,35 +240,71 @@ static int aead_chacha20_poly1305_seal_scatter(
union seal_data data;
if (asm_capable()) {
OPENSSL_memcpy(data.in.key, c20_ctx->key, 32);
OPENSSL_memcpy(data.in.key, key, 32);
data.in.counter = 0;
OPENSSL_memcpy(data.in.nonce, nonce, 12);
data.in.extra_ciphertext = out_tag;
data.in.extra_ciphertext_len = extra_in_len;
chacha20_poly1305_seal(out, in, in_len, ad, ad_len, &data);
} else {
CRYPTO_chacha_20(out, in, in_len, c20_ctx->key, nonce, 1);
calc_tag(data.out.tag, c20_ctx, nonce, ad, ad_len, out, in_len, out_tag,
CRYPTO_chacha_20(out, in, in_len, key, nonce, 1);
calc_tag(data.out.tag, key, nonce, ad, ad_len, out, in_len, out_tag,
extra_in_len);
}
OPENSSL_memcpy(out_tag + extra_in_len, data.out.tag, ctx->tag_len);
*out_tag_len = extra_in_len + ctx->tag_len;
OPENSSL_memcpy(out_tag + extra_in_len, data.out.tag, tag_len);
*out_tag_len = extra_in_len + tag_len;
return 1;
}
static int aead_chacha20_poly1305_open_gather(
const EVP_AEAD_CTX *ctx, uint8_t *out, const uint8_t *nonce,
size_t nonce_len, const uint8_t *in, size_t in_len, const uint8_t *in_tag,
size_t in_tag_len, const uint8_t *ad, size_t ad_len) {
const struct aead_chacha20_poly1305_ctx *c20_ctx = ctx->aead_state;
static int aead_chacha20_poly1305_seal_scatter(
const EVP_AEAD_CTX *ctx, uint8_t *out, uint8_t *out_tag,
size_t *out_tag_len, size_t max_out_tag_len, const uint8_t *nonce,
size_t nonce_len, const uint8_t *in, size_t in_len, const uint8_t *extra_in,
size_t extra_in_len, const uint8_t *ad, size_t ad_len) {
const struct aead_chacha20_poly1305_ctx *c20_ctx =
(struct aead_chacha20_poly1305_ctx *)&ctx->state;
return chacha20_poly1305_seal_scatter(
c20_ctx->key, out, out_tag, out_tag_len, max_out_tag_len, nonce,
nonce_len, in, in_len, extra_in, extra_in_len, ad, ad_len, ctx->tag_len);
}
static int aead_xchacha20_poly1305_seal_scatter(
const EVP_AEAD_CTX *ctx, uint8_t *out, uint8_t *out_tag,
size_t *out_tag_len, size_t max_out_tag_len, const uint8_t *nonce,
size_t nonce_len, const uint8_t *in, size_t in_len, const uint8_t *extra_in,
size_t extra_in_len, const uint8_t *ad, size_t ad_len) {
const struct aead_chacha20_poly1305_ctx *c20_ctx =
(struct aead_chacha20_poly1305_ctx *)&ctx->state;
if (nonce_len != 24) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_UNSUPPORTED_NONCE_SIZE);
return 0;
}
alignas(4) uint8_t derived_key[32];
alignas(4) uint8_t derived_nonce[12];
CRYPTO_hchacha20(derived_key, c20_ctx->key, nonce);
OPENSSL_memset(derived_nonce, 0, 4);
OPENSSL_memcpy(&derived_nonce[4], &nonce[16], 8);
return chacha20_poly1305_seal_scatter(
derived_key, out, out_tag, out_tag_len, max_out_tag_len,
derived_nonce, sizeof(derived_nonce), in, in_len, extra_in, extra_in_len,
ad, ad_len, ctx->tag_len);
}
static int chacha20_poly1305_open_gather(
const uint8_t *key, uint8_t *out, const uint8_t *nonce,
size_t nonce_len, const uint8_t *in, size_t in_len, const uint8_t *in_tag,
size_t in_tag_len, const uint8_t *ad, size_t ad_len, size_t tag_len) {
if (nonce_len != 12) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_UNSUPPORTED_NONCE_SIZE);
return 0;
}
if (in_tag_len != ctx->tag_len) {
if (in_tag_len != tag_len) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BAD_DECRYPT);
return 0;
}
@@ -289,16 +323,16 @@ static int aead_chacha20_poly1305_open_gather(
union open_data data;
if (asm_capable()) {
OPENSSL_memcpy(data.in.key, c20_ctx->key, 32);
OPENSSL_memcpy(data.in.key, key, 32);
data.in.counter = 0;
OPENSSL_memcpy(data.in.nonce, nonce, 12);
chacha20_poly1305_open(out, in, in_len, ad, ad_len, &data);
} else {
calc_tag(data.out.tag, c20_ctx, nonce, ad, ad_len, in, in_len, NULL, 0);
CRYPTO_chacha_20(out, in, in_len, c20_ctx->key, nonce, 1);
calc_tag(data.out.tag, key, nonce, ad, ad_len, in, in_len, NULL, 0);
CRYPTO_chacha_20(out, in, in_len, key, nonce, 1);
}
if (CRYPTO_memcmp(data.out.tag, in_tag, ctx->tag_len) != 0) {
if (CRYPTO_memcmp(data.out.tag, in_tag, tag_len) != 0) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BAD_DECRYPT);
return 0;
}
@@ -306,6 +340,41 @@ static int aead_chacha20_poly1305_open_gather(
return 1;
}
static int aead_chacha20_poly1305_open_gather(
const EVP_AEAD_CTX *ctx, uint8_t *out, const uint8_t *nonce,
size_t nonce_len, const uint8_t *in, size_t in_len, const uint8_t *in_tag,
size_t in_tag_len, const uint8_t *ad, size_t ad_len) {
const struct aead_chacha20_poly1305_ctx *c20_ctx =
(struct aead_chacha20_poly1305_ctx *)&ctx->state;
return chacha20_poly1305_open_gather(c20_ctx->key, out, nonce, nonce_len, in,
in_len, in_tag, in_tag_len, ad, ad_len,
ctx->tag_len);
}
static int aead_xchacha20_poly1305_open_gather(
const EVP_AEAD_CTX *ctx, uint8_t *out, const uint8_t *nonce,
size_t nonce_len, const uint8_t *in, size_t in_len, const uint8_t *in_tag,
size_t in_tag_len, const uint8_t *ad, size_t ad_len) {
const struct aead_chacha20_poly1305_ctx *c20_ctx =
(struct aead_chacha20_poly1305_ctx *)&ctx->state;
if (nonce_len != 24) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_UNSUPPORTED_NONCE_SIZE);
return 0;
}
alignas(4) uint8_t derived_key[32];
alignas(4) uint8_t derived_nonce[12];
CRYPTO_hchacha20(derived_key, c20_ctx->key, nonce);
OPENSSL_memset(derived_nonce, 0, 4);
OPENSSL_memcpy(&derived_nonce[4], &nonce[16], 8);
return chacha20_poly1305_open_gather(
derived_key, out, derived_nonce, sizeof(derived_nonce), in, in_len,
in_tag, in_tag_len, ad, ad_len, ctx->tag_len);
}
static const EVP_AEAD aead_chacha20_poly1305 = {
32, // key len
12, // nonce len
@@ -323,6 +392,27 @@ static const EVP_AEAD aead_chacha20_poly1305 = {
NULL, // tag_len
};
static const EVP_AEAD aead_xchacha20_poly1305 = {
32, // key len
24, // nonce len
POLY1305_TAG_LEN, // overhead
POLY1305_TAG_LEN, // max tag length
1, // seal_scatter_supports_extra_in
aead_chacha20_poly1305_init,
NULL, // init_with_direction
aead_chacha20_poly1305_cleanup,
NULL /* open */,
aead_xchacha20_poly1305_seal_scatter,
aead_xchacha20_poly1305_open_gather,
NULL, // get_iv
NULL, // tag_len
};
const EVP_AEAD *EVP_aead_chacha20_poly1305(void) {
return &aead_chacha20_poly1305;
}
const EVP_AEAD *EVP_aead_xchacha20_poly1305(void) {
return &aead_xchacha20_poly1305;
}
+16
View File
@@ -57,6 +57,8 @@
#include <openssl/cipher.h>
#include <openssl/nid.h>
#include "../internal.h"
#define c2l(c, l) \
do { \
@@ -73,18 +75,25 @@
switch (n) { \
case 8: \
(l2) = ((uint32_t)(*(--(c)))) << 24L; \
OPENSSL_FALLTHROUGH; \
case 7: \
(l2) |= ((uint32_t)(*(--(c)))) << 16L; \
OPENSSL_FALLTHROUGH; \
case 6: \
(l2) |= ((uint32_t)(*(--(c)))) << 8L; \
OPENSSL_FALLTHROUGH; \
case 5: \
(l2) |= ((uint32_t)(*(--(c)))); \
OPENSSL_FALLTHROUGH; \
case 4: \
(l1) = ((uint32_t)(*(--(c)))) << 24L; \
OPENSSL_FALLTHROUGH; \
case 3: \
(l1) |= ((uint32_t)(*(--(c)))) << 16L; \
OPENSSL_FALLTHROUGH; \
case 2: \
(l1) |= ((uint32_t)(*(--(c)))) << 8L; \
OPENSSL_FALLTHROUGH; \
case 1: \
(l1) |= ((uint32_t)(*(--(c)))); \
} \
@@ -104,18 +113,25 @@
switch (n) { \
case 8: \
*(--(c)) = (uint8_t)(((l2) >> 24L) & 0xff); \
OPENSSL_FALLTHROUGH; \
case 7: \
*(--(c)) = (uint8_t)(((l2) >> 16L) & 0xff); \
OPENSSL_FALLTHROUGH; \
case 6: \
*(--(c)) = (uint8_t)(((l2) >> 8L) & 0xff); \
OPENSSL_FALLTHROUGH; \
case 5: \
*(--(c)) = (uint8_t)(((l2)) & 0xff); \
OPENSSL_FALLTHROUGH; \
case 4: \
*(--(c)) = (uint8_t)(((l1) >> 24L) & 0xff); \
OPENSSL_FALLTHROUGH; \
case 3: \
*(--(c)) = (uint8_t)(((l1) >> 16L) & 0xff); \
OPENSSL_FALLTHROUGH; \
case 2: \
*(--(c)) = (uint8_t)(((l1) >> 8L) & 0xff); \
OPENSSL_FALLTHROUGH; \
case 1: \
*(--(c)) = (uint8_t)(((l1)) & 0xff); \
} \
-460
View File
@@ -1,460 +0,0 @@
/* Copyright (c) 2014, Google Inc.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
#include <assert.h>
#include <limits.h>
#include <string.h>
#include <openssl/aead.h>
#include <openssl/cipher.h>
#include <openssl/err.h>
#include <openssl/hmac.h>
#include <openssl/md5.h>
#include <openssl/mem.h>
#include <openssl/sha.h>
#include "internal.h"
#include "../internal.h"
#include "../fipsmodule/cipher/internal.h"
typedef struct {
EVP_CIPHER_CTX cipher_ctx;
EVP_MD_CTX md_ctx;
} AEAD_SSL3_CTX;
static int ssl3_mac(AEAD_SSL3_CTX *ssl3_ctx, uint8_t *out, unsigned *out_len,
const uint8_t *ad, size_t ad_len, const uint8_t *in,
size_t in_len) {
size_t md_size = EVP_MD_CTX_size(&ssl3_ctx->md_ctx);
size_t pad_len = (md_size == 20) ? 40 : 48;
// To allow for CBC mode which changes cipher length, |ad| doesn't include the
// length for legacy ciphers.
uint8_t ad_extra[2];
ad_extra[0] = (uint8_t)(in_len >> 8);
ad_extra[1] = (uint8_t)(in_len & 0xff);
EVP_MD_CTX md_ctx;
EVP_MD_CTX_init(&md_ctx);
uint8_t pad[48];
uint8_t tmp[EVP_MAX_MD_SIZE];
OPENSSL_memset(pad, 0x36, pad_len);
if (!EVP_MD_CTX_copy_ex(&md_ctx, &ssl3_ctx->md_ctx) ||
!EVP_DigestUpdate(&md_ctx, pad, pad_len) ||
!EVP_DigestUpdate(&md_ctx, ad, ad_len) ||
!EVP_DigestUpdate(&md_ctx, ad_extra, sizeof(ad_extra)) ||
!EVP_DigestUpdate(&md_ctx, in, in_len) ||
!EVP_DigestFinal_ex(&md_ctx, tmp, NULL)) {
EVP_MD_CTX_cleanup(&md_ctx);
return 0;
}
OPENSSL_memset(pad, 0x5c, pad_len);
if (!EVP_MD_CTX_copy_ex(&md_ctx, &ssl3_ctx->md_ctx) ||
!EVP_DigestUpdate(&md_ctx, pad, pad_len) ||
!EVP_DigestUpdate(&md_ctx, tmp, md_size) ||
!EVP_DigestFinal_ex(&md_ctx, out, out_len)) {
EVP_MD_CTX_cleanup(&md_ctx);
return 0;
}
EVP_MD_CTX_cleanup(&md_ctx);
return 1;
}
static void aead_ssl3_cleanup(EVP_AEAD_CTX *ctx) {
AEAD_SSL3_CTX *ssl3_ctx = (AEAD_SSL3_CTX *)ctx->aead_state;
EVP_CIPHER_CTX_cleanup(&ssl3_ctx->cipher_ctx);
EVP_MD_CTX_cleanup(&ssl3_ctx->md_ctx);
OPENSSL_free(ssl3_ctx);
ctx->aead_state = NULL;
}
static int aead_ssl3_init(EVP_AEAD_CTX *ctx, const uint8_t *key, size_t key_len,
size_t tag_len, enum evp_aead_direction_t dir,
const EVP_CIPHER *cipher, const EVP_MD *md) {
if (tag_len != EVP_AEAD_DEFAULT_TAG_LENGTH &&
tag_len != EVP_MD_size(md)) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_UNSUPPORTED_TAG_SIZE);
return 0;
}
if (key_len != EVP_AEAD_key_length(ctx->aead)) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BAD_KEY_LENGTH);
return 0;
}
size_t mac_key_len = EVP_MD_size(md);
size_t enc_key_len = EVP_CIPHER_key_length(cipher);
assert(mac_key_len + enc_key_len + EVP_CIPHER_iv_length(cipher) == key_len);
AEAD_SSL3_CTX *ssl3_ctx = OPENSSL_malloc(sizeof(AEAD_SSL3_CTX));
if (ssl3_ctx == NULL) {
OPENSSL_PUT_ERROR(CIPHER, ERR_R_MALLOC_FAILURE);
return 0;
}
EVP_CIPHER_CTX_init(&ssl3_ctx->cipher_ctx);
EVP_MD_CTX_init(&ssl3_ctx->md_ctx);
ctx->aead_state = ssl3_ctx;
if (!EVP_CipherInit_ex(&ssl3_ctx->cipher_ctx, cipher, NULL, &key[mac_key_len],
&key[mac_key_len + enc_key_len],
dir == evp_aead_seal) ||
!EVP_DigestInit_ex(&ssl3_ctx->md_ctx, md, NULL) ||
!EVP_DigestUpdate(&ssl3_ctx->md_ctx, key, mac_key_len)) {
aead_ssl3_cleanup(ctx);
ctx->aead_state = NULL;
return 0;
}
EVP_CIPHER_CTX_set_padding(&ssl3_ctx->cipher_ctx, 0);
return 1;
}
static size_t aead_ssl3_tag_len(const EVP_AEAD_CTX *ctx, const size_t in_len,
const size_t extra_in_len) {
assert(extra_in_len == 0);
const AEAD_SSL3_CTX *ssl3_ctx = (AEAD_SSL3_CTX*)ctx->aead_state;
const size_t digest_len = EVP_MD_CTX_size(&ssl3_ctx->md_ctx);
if (EVP_CIPHER_CTX_mode(&ssl3_ctx->cipher_ctx) != EVP_CIPH_CBC_MODE) {
// The NULL cipher.
return digest_len;
}
const size_t block_size = EVP_CIPHER_CTX_block_size(&ssl3_ctx->cipher_ctx);
// An overflow of |in_len + digest_len| doesn't affect the result mod
// |block_size|, provided that |block_size| is a smaller power of two.
assert(block_size != 0 && (block_size & (block_size - 1)) == 0);
const size_t pad_len = block_size - ((in_len + digest_len) % block_size);
return digest_len + pad_len;
}
static int aead_ssl3_seal_scatter(const EVP_AEAD_CTX *ctx, uint8_t *out,
uint8_t *out_tag, size_t *out_tag_len,
const size_t max_out_tag_len,
const uint8_t *nonce, const size_t nonce_len,
const uint8_t *in, const size_t in_len,
const uint8_t *extra_in,
const size_t extra_in_len, const uint8_t *ad,
const size_t ad_len) {
AEAD_SSL3_CTX *ssl3_ctx = (AEAD_SSL3_CTX *)ctx->aead_state;
if (!ssl3_ctx->cipher_ctx.encrypt) {
// Unlike a normal AEAD, an SSL3 AEAD may only be used in one direction.
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_INVALID_OPERATION);
return 0;
}
if (in_len > INT_MAX) {
// EVP_CIPHER takes int as input.
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_TOO_LARGE);
return 0;
}
if (max_out_tag_len < aead_ssl3_tag_len(ctx, in_len, extra_in_len)) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BUFFER_TOO_SMALL);
return 0;
}
if (nonce_len != 0) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_IV_TOO_LARGE);
return 0;
}
if (ad_len != 11 - 2 /* length bytes */) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_INVALID_AD_SIZE);
return 0;
}
// Compute the MAC. This must be first in case the operation is being done
// in-place.
uint8_t mac[EVP_MAX_MD_SIZE];
unsigned mac_len;
if (!ssl3_mac(ssl3_ctx, mac, &mac_len, ad, ad_len, in, in_len)) {
return 0;
}
// Encrypt the input.
int len;
if (!EVP_EncryptUpdate(&ssl3_ctx->cipher_ctx, out, &len, in,
(int)in_len)) {
return 0;
}
const size_t block_size = EVP_CIPHER_CTX_block_size(&ssl3_ctx->cipher_ctx);
// Feed the MAC into the cipher in two steps. First complete the final partial
// block from encrypting the input and split the result between |out| and
// |out_tag|. Then encrypt the remainder.
size_t early_mac_len = (block_size - (in_len % block_size)) % block_size;
if (early_mac_len != 0) {
assert(len + block_size - early_mac_len == in_len);
uint8_t buf[EVP_MAX_BLOCK_LENGTH];
int buf_len;
if (!EVP_EncryptUpdate(&ssl3_ctx->cipher_ctx, buf, &buf_len, mac,
(int)early_mac_len)) {
return 0;
}
assert(buf_len == (int)block_size);
OPENSSL_memcpy(out + len, buf, block_size - early_mac_len);
OPENSSL_memcpy(out_tag, buf + block_size - early_mac_len, early_mac_len);
}
size_t tag_len = early_mac_len;
if (!EVP_EncryptUpdate(&ssl3_ctx->cipher_ctx, out_tag + tag_len, &len,
mac + tag_len, mac_len - tag_len)) {
return 0;
}
tag_len += len;
if (block_size > 1) {
assert(block_size <= 256);
assert(EVP_CIPHER_CTX_mode(&ssl3_ctx->cipher_ctx) == EVP_CIPH_CBC_MODE);
// Compute padding and feed that into the cipher.
uint8_t padding[256];
size_t padding_len = block_size - ((in_len + mac_len) % block_size);
OPENSSL_memset(padding, 0, padding_len - 1);
padding[padding_len - 1] = padding_len - 1;
if (!EVP_EncryptUpdate(&ssl3_ctx->cipher_ctx, out_tag + tag_len, &len, padding,
(int)padding_len)) {
return 0;
}
tag_len += len;
}
if (!EVP_EncryptFinal_ex(&ssl3_ctx->cipher_ctx, out_tag + tag_len, &len)) {
return 0;
}
tag_len += len;
assert(tag_len == aead_ssl3_tag_len(ctx, in_len, extra_in_len));
*out_tag_len = tag_len;
return 1;
}
static int aead_ssl3_open(const EVP_AEAD_CTX *ctx, uint8_t *out,
size_t *out_len, size_t max_out_len,
const uint8_t *nonce, size_t nonce_len,
const uint8_t *in, size_t in_len,
const uint8_t *ad, size_t ad_len) {
AEAD_SSL3_CTX *ssl3_ctx = (AEAD_SSL3_CTX *)ctx->aead_state;
if (ssl3_ctx->cipher_ctx.encrypt) {
// Unlike a normal AEAD, an SSL3 AEAD may only be used in one direction.
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_INVALID_OPERATION);
return 0;
}
size_t mac_len = EVP_MD_CTX_size(&ssl3_ctx->md_ctx);
if (in_len < mac_len) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BAD_DECRYPT);
return 0;
}
if (max_out_len < in_len) {
// This requires that the caller provide space for the MAC, even though it
// will always be removed on return.
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BUFFER_TOO_SMALL);
return 0;
}
if (nonce_len != 0) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_TOO_LARGE);
return 0;
}
if (ad_len != 11 - 2 /* length bytes */) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_INVALID_AD_SIZE);
return 0;
}
if (in_len > INT_MAX) {
// EVP_CIPHER takes int as input.
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_TOO_LARGE);
return 0;
}
// Decrypt to get the plaintext + MAC + padding.
size_t total = 0;
int len;
if (!EVP_DecryptUpdate(&ssl3_ctx->cipher_ctx, out, &len, in, (int)in_len)) {
return 0;
}
total += len;
if (!EVP_DecryptFinal_ex(&ssl3_ctx->cipher_ctx, out + total, &len)) {
return 0;
}
total += len;
assert(total == in_len);
// Remove CBC padding and MAC. This would normally be timing-sensitive, but
// SSLv3 CBC ciphers are already broken. Support will be removed eventually.
// https://www.openssl.org/~bodo/ssl-poodle.pdf
size_t data_len;
if (EVP_CIPHER_CTX_mode(&ssl3_ctx->cipher_ctx) == EVP_CIPH_CBC_MODE) {
unsigned padding_length = out[total - 1];
if (total < padding_length + 1 + mac_len) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BAD_DECRYPT);
return 0;
}
// The padding must be minimal.
if (padding_length + 1 > EVP_CIPHER_CTX_block_size(&ssl3_ctx->cipher_ctx)) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BAD_DECRYPT);
return 0;
}
data_len = total - padding_length - 1 - mac_len;
} else {
data_len = total - mac_len;
}
// Compute the MAC and compare against the one in the record.
uint8_t mac[EVP_MAX_MD_SIZE];
if (!ssl3_mac(ssl3_ctx, mac, NULL, ad, ad_len, out, data_len)) {
return 0;
}
if (CRYPTO_memcmp(&out[data_len], mac, mac_len) != 0) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BAD_DECRYPT);
return 0;
}
*out_len = data_len;
return 1;
}
static int aead_ssl3_get_iv(const EVP_AEAD_CTX *ctx, const uint8_t **out_iv,
size_t *out_iv_len) {
AEAD_SSL3_CTX *ssl3_ctx = (AEAD_SSL3_CTX *)ctx->aead_state;
const size_t iv_len = EVP_CIPHER_CTX_iv_length(&ssl3_ctx->cipher_ctx);
if (iv_len <= 1) {
return 0;
}
*out_iv = ssl3_ctx->cipher_ctx.iv;
*out_iv_len = iv_len;
return 1;
}
static int aead_aes_128_cbc_sha1_ssl3_init(EVP_AEAD_CTX *ctx, const uint8_t *key,
size_t key_len, size_t tag_len,
enum evp_aead_direction_t dir) {
return aead_ssl3_init(ctx, key, key_len, tag_len, dir, EVP_aes_128_cbc(),
EVP_sha1());
}
static int aead_aes_256_cbc_sha1_ssl3_init(EVP_AEAD_CTX *ctx, const uint8_t *key,
size_t key_len, size_t tag_len,
enum evp_aead_direction_t dir) {
return aead_ssl3_init(ctx, key, key_len, tag_len, dir, EVP_aes_256_cbc(),
EVP_sha1());
}
static int aead_des_ede3_cbc_sha1_ssl3_init(EVP_AEAD_CTX *ctx,
const uint8_t *key, size_t key_len,
size_t tag_len,
enum evp_aead_direction_t dir) {
return aead_ssl3_init(ctx, key, key_len, tag_len, dir, EVP_des_ede3_cbc(),
EVP_sha1());
}
static int aead_null_sha1_ssl3_init(EVP_AEAD_CTX *ctx, const uint8_t *key,
size_t key_len, size_t tag_len,
enum evp_aead_direction_t dir) {
return aead_ssl3_init(ctx, key, key_len, tag_len, dir, EVP_enc_null(),
EVP_sha1());
}
static const EVP_AEAD aead_aes_128_cbc_sha1_ssl3 = {
SHA_DIGEST_LENGTH + 16 + 16, // key len (SHA1 + AES128 + IV)
0, // nonce len
16 + SHA_DIGEST_LENGTH, // overhead (padding + SHA1)
SHA_DIGEST_LENGTH, // max tag length
0, // seal_scatter_supports_extra_in
NULL, // init
aead_aes_128_cbc_sha1_ssl3_init,
aead_ssl3_cleanup,
aead_ssl3_open,
aead_ssl3_seal_scatter,
NULL, // open_gather
aead_ssl3_get_iv,
aead_ssl3_tag_len,
};
static const EVP_AEAD aead_aes_256_cbc_sha1_ssl3 = {
SHA_DIGEST_LENGTH + 32 + 16, // key len (SHA1 + AES256 + IV)
0, // nonce len
16 + SHA_DIGEST_LENGTH, // overhead (padding + SHA1)
SHA_DIGEST_LENGTH, // max tag length
0, // seal_scatter_supports_extra_in
NULL, // init
aead_aes_256_cbc_sha1_ssl3_init,
aead_ssl3_cleanup,
aead_ssl3_open,
aead_ssl3_seal_scatter,
NULL, // open_gather
aead_ssl3_get_iv,
aead_ssl3_tag_len,
};
static const EVP_AEAD aead_des_ede3_cbc_sha1_ssl3 = {
SHA_DIGEST_LENGTH + 24 + 8, // key len (SHA1 + 3DES + IV)
0, // nonce len
8 + SHA_DIGEST_LENGTH, // overhead (padding + SHA1)
SHA_DIGEST_LENGTH, // max tag length
0, // seal_scatter_supports_extra_in
NULL, // init
aead_des_ede3_cbc_sha1_ssl3_init,
aead_ssl3_cleanup,
aead_ssl3_open,
aead_ssl3_seal_scatter,
NULL, // open_gather
aead_ssl3_get_iv,
aead_ssl3_tag_len,
};
static const EVP_AEAD aead_null_sha1_ssl3 = {
SHA_DIGEST_LENGTH, // key len
0, // nonce len
SHA_DIGEST_LENGTH, // overhead (SHA1)
SHA_DIGEST_LENGTH, // max tag length
0, // seal_scatter_supports_extra_in
NULL, // init
aead_null_sha1_ssl3_init,
aead_ssl3_cleanup,
aead_ssl3_open,
aead_ssl3_seal_scatter,
NULL, // open_gather
NULL, // get_iv
aead_ssl3_tag_len,
};
const EVP_AEAD *EVP_aead_aes_128_cbc_sha1_ssl3(void) {
return &aead_aes_128_cbc_sha1_ssl3;
}
const EVP_AEAD *EVP_aead_aes_256_cbc_sha1_ssl3(void) {
return &aead_aes_256_cbc_sha1_ssl3;
}
const EVP_AEAD *EVP_aead_des_ede3_cbc_sha1_ssl3(void) {
return &aead_des_ede3_cbc_sha1_ssl3;
}
const EVP_AEAD *EVP_aead_null_sha1_ssl3(void) { return &aead_null_sha1_ssl3; }
+24 -18
View File
@@ -42,15 +42,22 @@ typedef struct {
char implicit_iv;
} AEAD_TLS_CTX;
OPENSSL_COMPILE_ASSERT(EVP_MAX_MD_SIZE < 256, mac_key_len_fits_in_uint8_t);
OPENSSL_STATIC_ASSERT(EVP_MAX_MD_SIZE < 256,
"mac_key_len does not fit in uint8_t");
OPENSSL_STATIC_ASSERT(sizeof(((EVP_AEAD_CTX *)NULL)->state) >=
sizeof(AEAD_TLS_CTX),
"AEAD state is too small");
#if defined(__GNUC__) || defined(__clang__)
OPENSSL_STATIC_ASSERT(alignof(union evp_aead_ctx_st_state) >=
alignof(AEAD_TLS_CTX),
"AEAD state has insufficient alignment");
#endif
static void aead_tls_cleanup(EVP_AEAD_CTX *ctx) {
AEAD_TLS_CTX *tls_ctx = (AEAD_TLS_CTX *)ctx->aead_state;
AEAD_TLS_CTX *tls_ctx = (AEAD_TLS_CTX *)&ctx->state;
EVP_CIPHER_CTX_cleanup(&tls_ctx->cipher_ctx);
HMAC_CTX_cleanup(&tls_ctx->hmac_ctx);
OPENSSL_cleanse(&tls_ctx->mac_key, sizeof(tls_ctx->mac_key));
OPENSSL_free(tls_ctx);
ctx->aead_state = NULL;
}
static int aead_tls_init(EVP_AEAD_CTX *ctx, const uint8_t *key, size_t key_len,
@@ -73,11 +80,7 @@ static int aead_tls_init(EVP_AEAD_CTX *ctx, const uint8_t *key, size_t key_len,
assert(mac_key_len + enc_key_len +
(implicit_iv ? EVP_CIPHER_iv_length(cipher) : 0) == key_len);
AEAD_TLS_CTX *tls_ctx = OPENSSL_malloc(sizeof(AEAD_TLS_CTX));
if (tls_ctx == NULL) {
OPENSSL_PUT_ERROR(CIPHER, ERR_R_MALLOC_FAILURE);
return 0;
}
AEAD_TLS_CTX *tls_ctx = (AEAD_TLS_CTX *)&ctx->state;
EVP_CIPHER_CTX_init(&tls_ctx->cipher_ctx);
HMAC_CTX_init(&tls_ctx->hmac_ctx);
assert(mac_key_len <= EVP_MAX_MD_SIZE);
@@ -85,13 +88,11 @@ static int aead_tls_init(EVP_AEAD_CTX *ctx, const uint8_t *key, size_t key_len,
tls_ctx->mac_key_len = (uint8_t)mac_key_len;
tls_ctx->implicit_iv = implicit_iv;
ctx->aead_state = tls_ctx;
if (!EVP_CipherInit_ex(&tls_ctx->cipher_ctx, cipher, NULL, &key[mac_key_len],
implicit_iv ? &key[mac_key_len + enc_key_len] : NULL,
dir == evp_aead_seal) ||
!HMAC_Init_ex(&tls_ctx->hmac_ctx, key, mac_key_len, md, NULL)) {
aead_tls_cleanup(ctx);
ctx->aead_state = NULL;
return 0;
}
EVP_CIPHER_CTX_set_padding(&tls_ctx->cipher_ctx, 0);
@@ -102,7 +103,7 @@ static int aead_tls_init(EVP_AEAD_CTX *ctx, const uint8_t *key, size_t key_len,
static size_t aead_tls_tag_len(const EVP_AEAD_CTX *ctx, const size_t in_len,
const size_t extra_in_len) {
assert(extra_in_len == 0);
AEAD_TLS_CTX *tls_ctx = (AEAD_TLS_CTX *)ctx->aead_state;
const AEAD_TLS_CTX *tls_ctx = (AEAD_TLS_CTX *)&ctx->state;
const size_t hmac_len = HMAC_size(&tls_ctx->hmac_ctx);
if (EVP_CIPHER_CTX_mode(&tls_ctx->cipher_ctx) != EVP_CIPH_CBC_MODE) {
@@ -126,7 +127,7 @@ static int aead_tls_seal_scatter(const EVP_AEAD_CTX *ctx, uint8_t *out,
const uint8_t *extra_in,
const size_t extra_in_len, const uint8_t *ad,
const size_t ad_len) {
AEAD_TLS_CTX *tls_ctx = (AEAD_TLS_CTX *)ctx->aead_state;
AEAD_TLS_CTX *tls_ctx = (AEAD_TLS_CTX *)&ctx->state;
if (!tls_ctx->cipher_ctx.encrypt) {
// Unlike a normal AEAD, a TLS AEAD may only be used in one direction.
@@ -192,8 +193,7 @@ static int aead_tls_seal_scatter(const EVP_AEAD_CTX *ctx, uint8_t *out,
// block from encrypting the input and split the result between |out| and
// |out_tag|. Then feed the rest.
const size_t early_mac_len =
(block_size - (in_len % block_size) % block_size);
const size_t early_mac_len = (block_size - (in_len % block_size)) % block_size;
if (early_mac_len != 0) {
assert(len + block_size - early_mac_len == in_len);
uint8_t buf[EVP_MAX_BLOCK_LENGTH];
@@ -243,7 +243,7 @@ static int aead_tls_open(const EVP_AEAD_CTX *ctx, uint8_t *out, size_t *out_len,
size_t max_out_len, const uint8_t *nonce,
size_t nonce_len, const uint8_t *in, size_t in_len,
const uint8_t *ad, size_t ad_len) {
AEAD_TLS_CTX *tls_ctx = (AEAD_TLS_CTX *)ctx->aead_state;
AEAD_TLS_CTX *tls_ctx = (AEAD_TLS_CTX *)&ctx->state;
if (tls_ctx->cipher_ctx.encrypt) {
// Unlike a normal AEAD, a TLS AEAD may only be used in one direction.
@@ -299,6 +299,8 @@ static int aead_tls_open(const EVP_AEAD_CTX *ctx, uint8_t *out, size_t *out_len,
total += len;
assert(total == in_len);
CONSTTIME_SECRET(out, total);
// Remove CBC padding. Code from here on is timing-sensitive with respect to
// |padding_ok| and |data_plus_mac_len| for CBC ciphers.
size_t data_plus_mac_len;
@@ -375,11 +377,15 @@ static int aead_tls_open(const EVP_AEAD_CTX *ctx, uint8_t *out, size_t *out_len,
crypto_word_t good =
constant_time_eq_int(CRYPTO_memcmp(record_mac, mac, mac_len), 0);
good &= padding_ok;
CONSTTIME_DECLASSIFY(&good, sizeof(good));
if (!good) {
OPENSSL_PUT_ERROR(CIPHER, CIPHER_R_BAD_DECRYPT);
return 0;
}
CONSTTIME_DECLASSIFY(&data_len, sizeof(data_len));
CONSTTIME_DECLASSIFY(out, data_len);
// End of timing-sensitive code.
*out_len = data_len;
@@ -455,7 +461,7 @@ static int aead_des_ede3_cbc_sha1_tls_implicit_iv_init(
static int aead_tls_get_iv(const EVP_AEAD_CTX *ctx, const uint8_t **out_iv,
size_t *out_iv_len) {
const AEAD_TLS_CTX *tls_ctx = (AEAD_TLS_CTX*) ctx->aead_state;
const AEAD_TLS_CTX *tls_ctx = (AEAD_TLS_CTX *)&ctx->state;
const size_t iv_len = EVP_CIPHER_CTX_iv_length(&tls_ctx->cipher_ctx);
if (iv_len <= 1) {
return 0;
File diff suppressed because it is too large Load Diff
@@ -42,14 +42,707 @@ TAG_LEN: 20
NO_SEAL: 01
FAILS: 01
# Test with maximal padding.
# DIGEST: c6105cc86e18eb8376c16ea37693db5c07b77137
KEY: 8503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371e
# Test with maximal padding (0 mod 64).
# DIGEST: ceb2d295bd0efd37c6c34dab1854c80e986174fc
KEY: 37446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11b
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c748
AD: 1df3f4183aa23fd8d7efd8
CT: 7265eea4b391d880c6bc72d3282f663e5551c0a71ca35898047362694ee8f2710974350a2a38a13b0434d312
TAG: ead153f0c9488b88357e81187178465d2416ca97dbf7460c9519ed9957d9e74e62950447e49dd233e9c504876a90fa79273e597ed751da4f32a2c60cecbfb6641ca2e8938774cbc324affa9bb027d219730d57ca1981e87d0dcd0551618493f79ff8c0366383e0698a009bd976c63f089a8b901b5a08fabf0d3f798c349743634d5dd35a2195cf0b74b67d36d65be1aa920831906acbc57cd880964ec948e9c11614104721efb62a47600ee968418b1d197c3ce6ba6246d5ac1f07819f67c2cb3ca5162aedd354e2314d65d5e863964db421846da7603b9f11c503966834ed501885763da3e89a59f89f1e31f78111324b79637dd3b6aeeb71ccf2557f9725b86dd13088ce257cd6ea71706ff8ec9036f56d76c4
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba
AD: 2fd6773e0d0c302a5f47e0
CT: 2840fb36bc8e03c59de49315bd8a6e091f41fb020cdb174ed0ab84fab8f94c14e840fd37fc13f48490c2d2ffd4efeb4da8d98840f6ee5af812bcbbeeb7f2992b
TAG: a767b9c80eb4ab9270c0c08d6adc1bf56245929a79a4511a8a4ccd2c996611a0154c8101217b46b049331d3109a42093f223a8224e11fcecee906b2ef52e5650da0498e3f832101b7ef66fdbcef302f362e570e5e42d5dbc33d0d662913c78a8caf3a9e2e22949cf6d212efee4d9dc8d03fd6a00d41f3073c4b73149e8bf05d23b2dd88aab1c87ac948a3f96be79c52efe9488ceb9a1c5511b441a6ba4204beaf339539ff9b4443000b5b7c00261c663be3087c395ee448e724d1cfcbe10e15ccddcf50378fef972fa3aca38fdb1d131f1bc7ce166f4476a008883292f8422cc668e1c8e0cd53cb25a64324d187b14143563d8d1af9371602a068da959c587cd6a383d1ffc74190c0499b2d71390cdcf
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (1 mod 64).
# DIGEST: a07054c760cc66fc704edf950201005031f3faac
KEY: 446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be1
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2f
AD: d6773e0d0c302a5f47e037
CT: 2e7e6cd84e03e35d8977c9e1d4ce6784c4db3a87fa1b82e6f781e284e0d3914eb56acdde0374eed6283cc10e1f329821fefbf888dfc8fb42fa574cb64df6d88d2d
TAG: 80503493bfa3c2cd3817bb145fc579ebe050bf0e6310a29c9e1a7e98371833a25bea5c82bb6128cba6e27e7e796b49b49cd55ad123f90aade4d76a636104e5a4f6fc9c92997c0706d709145b208523c0c890394fcec38507fa0bad3d24fdc921416501e5c9b6964db81572bb933b67c4b5bb2070ad5068069592d35902ab93bad8d5121fe15bbb2bd27ad946a21f2ecd7e95c7f4c63ddd00589ac304d638307e798d9a55bfde231f5bd8a8f89cfae591b0234662647c3b42278f4157c4fb44fcc51862bbb2f03273f680d6dccee49b51bb4b881e5a1768dbc537e67073b796047fbce6f90eb54776d9f0237978f129af7efd4a3f380547e883d9976b38819acf9e0411769fc6898eaeca53f5def25f
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (2 mod 64).
# DIGEST: d059c266cf6233af730b7a229b19356a4c6fcf06
KEY: 6f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6
AD: 773e0d0c302a5f47e03744
CT: be77b79780ae8ccda54d5f995f7c1beee8ac61735285e34d9dd137058555e723daeafe392773f428ec528a14c2f52a86365c4929d98d4504c669db1d984e2f84f7bf
TAG: 24836360777dbacbbcea10d08e3d975a0bd32669871000178d167a1e40a6723b7c47ebd32e5df52cc4e0ee5459b355f285a0a93bd9fd016642221a335a2f09a4635f71d8575bdd081caa14b083aed01444df63e5cb01377b8a3ac31006c92621a894b71d50c85964234a5aae094a931e5456416236001f46d771767aee47f6b7c3493fc10b9f392dd629852623c1ff6f1e7dd3346d1aabd132301fa16ce88017fe3ca394d1c685942f1ed7b37f84a25682142b02ce138ae9b21c85db410cc3c266f6a490ffdaa0ce95e8b1f2da7f6e6ddda2d4570dc5619605fca903e47eb62d7419dfe49f354ac18762abbdfe5431a863b6f7371731ebb09ab41aba79e41be8603060fe921e4dc8b7f422392640
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (3 mod 64).
# DIGEST: 8aac0687e33041fcc18da154b41f20a6af2bfb28
KEY: 5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a7
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd677
AD: 3e0d0c302a5f47e037446f
CT: 82aba2e22933737ef55346865375b574f24066eabe39fb800ec790df3ad05f85a760332e8a1d45e7b0c2d969ac5689505510fe035db4ac1c5a8a01a6f6ac00ad3d8344
TAG: 090114b0a31c301edc2bed8e25298d4f913558ce3f6f607b0fce5f9e7b1c953601ce9890f0d8e8d6a71c5ccc4e0aab08942628d21f467bfbfc4996863e8fd296b7ce153568999980ac2980ca68b16c0b2edfe5efcfff121a7e4dfc8dd9387442c4847f7c572f668aa990334dc50a54480f673c338f1ea9c81cfb9d482f6e4ae163e412108ad5775aefe89173229efd58a0f56b411008f87e3aa307413779538057f5d846a1586920b1448b4fda27b65647b946bd5b7950a5e3e37ccca55b359b4726e26fc3d168a9e8bef56c1a61fcb2b55cca61bac0123190572c939584ffae1e913b82bbd8057f302a900d2a1a7ed1ab4a1b7c8c5cd56fc472d69d013bb897ea3d72d299da0df5fcc7a745dc
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (4 mod 64).
# DIGEST: 53658226c112b86438dd27b58a71f9e36fc73c1e
KEY: 91d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a729
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e
AD: 0d0c302a5f47e037446f58
CT: 3eceac2e338b4dfd9f4840d77db69ed23ee286b522cd4a324b04b1865cc772914c8d84abbf0db1a3a2d15401759b18d6fb3b7020cca1e31d136fb97b26bc772baf5a363c
TAG: 1b6a98c7f9b8c5c560add0eb46d2d7559ebce0894b876f0de8ec37031df30667cc3ea54a4e71d8bcfe575d6044d9f70852fcf9a1a6756643e28944b59856ed1ce9958045eae0aa64bba55b64aac0cacded741293262550b085b4cb143d8bb8f7061eda2911c86e1afce94a8afb4db1060c2da1e9bb0ca8747d71b706134e44bb7e4b73518ca9201d610860961a53438d6efb51031a1ba0fa9b437b8a3aebc0479bace7843b319c02b4987490bed351be2eced028a2d0c97a1e30ccbd820f4b3f669e33b74c1b550a8d9782b9ec7fa45b24dcd5b6788895d6246a4cdfb015c605741047c1d2323e207a8a622e55b6a19401bb67de62154392edb28ab3cdfbb2ae2f21c3181ee8033130e95e05
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (5 mod 64).
# DIGEST: 6b7d5268b0b5037afb5be5af6a0ceb34e7656ac4
KEY: d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d
AD: 0c302a5f47e037446f5891
CT: 5cfcf9e4dbe1a74e748665bf393c6fe93807ea36556590a1f2814c2b445988c1f6c2815f6b1f0fecae452d1bb89a055bc6f85bea11d99d0b0c62db8a81e3f0f3a557c208cd
TAG: 8e73adba964c6868bb3da63b0d528a22eea8bfb4be0b1030070436f5c442649857c9c4a32759c5071d7d741692368497a978b5668b912cdfb0c404e514411ff111ea9f1224cb4a9256dc57a8a4677fe576b554cf6e4f975ac3a81eefcaa0bb68ac5bb26b1bf54bf034a50a1b3265e0baa8a900f048246c7ea825234732c3f5b34c4ddc0adc46178d0adbd9a524502061ad4c6df62dcd8f8851f270dc452be39021d5f054b7aa35f5235739894c659bc06333d0e564c38521d820dd7cb0dbb8a018543ebe7799cbd674a14821a6f92d776aed736fb4ce19ffe6ad5b456c09cc597443ae1bb41be9ea0213edfc1339636facbfdf56a8944cc548fd35fd5fa4a7b8cfbce736c6c96465326a49
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (6 mod 64).
# DIGEST: 63efe7af502231420ed5aecce9a28446b257828d
KEY: 7df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c
AD: 302a5f47e037446f5891d7
CT: b2e315ef97a1b89b4625715c61946446fe1bf27aa60e65d0ad9849f71ec53ccbee951d3628efe2795949f88795b354df0ec68b21cd699cdd0f92f31f3d6013a4c1116165b4f5
TAG: 4e9eb0387d9121ea239b27016805f35c09c90904d9becd9ce23d77233e8b68c86e17f92ac31794be17386e5fe2f40e83147a7dea38bee4b9776fb4a4da85408b80ea7718d542a47e7e5d7db38c18560dbc37d49f4fae2e013c4b89ab59f2a529b389e2ce5b2c9f0883df472fb9ac58bc5e27dc21938344195de25f1e3c015b68e6c6f6111e037010a075e78e852f9b0b8e568359ba22eddd71714403309987ed20e381b8ff67f5fd5d9e8ce77b1517da2cd4c2909f83fe70b65af0ba8dfff1e0860ccd217a19a96d94ef3cfbe1214e204d4eab8045f97aaeae0946b455e01099513c5a763596c7495de135bd2ea2b9c01e7fcc5daa0e88bcb45ce5bd044dc300a281b2bfd18f6090f7eb
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (7 mod 64).
# DIGEST: 1a555c300a1d1bd5b03cdd6bf2a678621624eb05
KEY: f660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b5
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c30
AD: 2a5f47e037446f5891d77d
CT: 8221477092da15c94ec15f34ef2d540c87ab24236ee4d97ed3543f49f2daec059be7c0f157f2d869bae0bd4b9d214bd40ed01484c28019d6349cac27db29050831e5974b5426a9
TAG: 9f10a7816f0b558aaed826c53d63677dc443bd48fe1faf9d8e8542db0b3959d6754d0771ce1a23d67561626c7c521401c0a8882656ded33ace7965f5978bfa1c960ed9eb3831f45d28a4fb0ea44cbd9118f39eddbe3c56886bb4bd6593e13f2bf641e88adccaf76ab0356cb77654a1b27597b1b5fbbbf15b6c7673d92aa7073745721a299797b77c5b205ee44da405d634f971abf26bd7cffb21cd6f952eec7bc214d6ee0a31622c78259ba14072536751b87b968cc5e6ecb21d1b64c53f7ac24dd9344c2a03dbea3c5704bd283a8d28eb2ba5e4dc1b16a0edd6f4cb76aaf746b1a987d58ed73eb2b266a148ddbc033bd45712a3101f7b536d2d902b7e124e199442b149e3b603f199
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (8 mod 64).
# DIGEST: de9156349b578f2f44945ec6a676a67a829daea1
KEY: 60ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54e
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a
AD: 5f47e037446f5891d77df6
CT: 8a9f0d731d72929136ed9e6993cbb28013b336540f602c7203e6a38391dc07c8c3ce5b4ca62df582dea366c4b0b5aaabcf1959a7f0bc92047023c72225f5c071a588d95774f2e2c1
TAG: 84d60af507164a4f4958b6aed0525028918bba60b4affc1afea92c0ef485679506ffdf649b0d9bcefcfb8f1503b2e48937a3e732785d85b11a524363a55fc994e756148a3b7b2772881aaceee2ffeb0f18bd85feb215fc8352dc76d8ab5255d56db5e9f10c42b4a3447321d459ed20e536062a33e6cc598a61b905bcd579e6d68cbdfb94c3b100e05bc0009b9841fca15d909de6897276f9177cce5b049c45954b7cddb7610127c9dd40a61bd8e47b7a165940ef3084a0b523955741414a12d34aed68db231db939b1417069516333b2c0c57e843f098a55e375639ebd2acf658de1f385a1e29c5eb9efe14c16e29488a32bbfd127592c7c45807f2b3e8f57144b9cf60130592b62
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (9 mod 64).
# DIGEST: 12812df3aa7f3bbc899f6f248f5590e02570c292
KEY: ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f
AD: 47e037446f5891d77df660
CT: e3af374fb6f33c64fc2e4cc1e1b635bbe890f02359b6adb2a747beda433e003e30e1803f2169ff6abc81ff8095601cdff7aebae5fd8fc012387a70dd7db18e7eb79f87fcc1821ffdf6
TAG: 4f9730c5eeb9cb32e005afc571d2ed5b2de38670704f854c838d00584becf8583ee7e79d9609bb73abb70bd01ab228bcf6070ee1c1c97d4f6003f6a3ccb4b8af43dfb37bbeb707e1efa51b0447e6b31e82a3fecaacad99014a8d502c3db8a36665f85d62938de6ffe30c4749535bb124129caa1fa465d04c1005e64f7f4397607b4e6fc31b9c34961b7276185fc3211eda045c06a28aec0a1e0a0e2f1f6829a1ab372d0bedd711158696b062b9dcfbff4925dca71d4ad7f7c610d40bfc6e7d04f4990d6efdd059679c7137b5f5d28c9784fca307e2e1df33dfec10a242379ff30984c62c201738edd60007c9d56557692e8f73e5d0c83059d568312b3504de9691ad3d9b30a4a2
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (10 mod 64).
# DIGEST: f3c89f21c327fca4aa400fabea9e39780378e901
KEY: 82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fa
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47
AD: e037446f5891d77df660ed
CT: 98b22a9119610480bdfc5cb6e2a950ccac8741690574730b87fbeb113d5daac699c333ff21efd0e73d2252e95f64dd2699b940b490259cb5fd698756713c0e53ff69a733ea13587cbcb6
TAG: 63600a3d7fe8a782af7af230da63bc84dd993bcffaa5f76e5f63ef56407d0412b831dab138d117fbc081139cc49946a7631f488c11946c10530806ce7a781baa3bd072300a5cdf8aaa3b2657ea3732c1e24271c447e6d7f6a2afa0bef27aada30585c33479debc10cb72febb181c7f5f77490b339285bfbb0bf07c545ed5a0f3f183fefdc7138e330095636956328ab85a201e3cd6a2edc573d75327bdf615ffc8e6fd5e133558b831e24b67751098320e9afdfe7c7ef4598c29563113052c568263612fdc3c48d8e9a8a407bc2918ede467636dc0185d9423e9eaefef4126247012d5f1930c56dd9dd7c34d397f388e4f741953d76bb1eec911079936a8dfc584fb5b7c84e4
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (11 mod 64).
# DIGEST: e8e41988fad6c8b44c56544964cfe0a347b35b1e
KEY: 933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e0
AD: 37446f5891d77df660ed82
CT: 8795d6c225aa78fccaaff86101641081f4a440969633ca8d7830ffb14f629fa34dc4c15e8ff20a8940c7a484ee94503372e658615eb3fc07c2d2c399ae9ad7a77d684512d0ca273f77fcfe
TAG: 534574a93db9658b653cd395e981cd4a8992e817ba058f692c5f0c1682745097ed441781afe30827bcaa29d061e2d1554a949cf7b62077b768bc1ca8679618a5d2b32c0b7e735db6a27fd762a60aa19e60a60a9edb02f20e3e99fd4653732525a0c8d8042bd3ba5387f93a7e0da483173b3abcd3ff876badd75b81741abfe2baf21be1006d1cb85bc543ddc7493f8faf4e27619686ba324cf651a16e7ffc23ae7786eb8823300a5c65982228aecde99f53d43f86d9ec0d326eb3ece9f6cf1c6bf92d1599c5f9c391e9ba189195665d3018c38207717502bb60e020773618df614bb4e0309fa0809ab215f68f0d9d46c28950d3edad6c4f71dd5af9d03dfa39ae62482601ff
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (12 mod 64).
# DIGEST: d1c7b2c04dc25fe7b742a1d659aec20e1475ee4f
KEY: 3f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037
AD: 446f5891d77df660ed8293
CT: 694868cf990a1b8ef42fcb2b45cabf1bd78eee4b429c11b27a827762b9c319bc54a2b2c8eb2ac85063ef8ac7da8bc35b16c0a98822981dc9b246381780da7833eb718bc8518e2b176656ff5c
TAG: ca1dc8a003fd389a1eb1cfa4bf9746cdf45c548f8e52e0bb0dd456c1369686e0975fada75cd8fb261a01828fa1375941dcd8c718f82d6b64222dfbf7143ce980f3936b78e525c961b7d72d5d68127d0f98de541853ae36408ac489c5629c82f00a44dbdc89d665f94fb391c4a0618f31df9bcf39a07325b600265daaf53c2762396f9f6e83fb4f545aefaaeb447d4162ad401e1da2ec090d78d7b354d80fa975dcea9b897fc0f16681cd9a1aedc78cdcbf26249e18132e518b75849af55de38562ac32c50819a35156706510688f3a81e13e3bd5f61a0c2a8655c251f4732258c3cf34694be21caad599996c9a13303be173f916e90f606dfe1640bcf35e892eab6ca70f59ca019d27c58cb69b4cb3bcd484198d
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (13 mod 64).
# DIGEST: 116e20ff1e79e0af464d473b1e7c187f4dd66007
KEY: 62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be90
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e03744
AD: 6f5891d77df660ed82933f
CT: f2e78e183884c99ad7f199a02d87a1026c832b9a953919a98c2487bd0d724be407994fcce9e19b5a69f15ceef5d3b95c79d5fffede18a143cdfade5c0f80254cb38e47cc9c82488116640aebe9
TAG: 11f4ab3470df6f43596f9275964c3ecc22543daebbdb99004eb6c1e001b2119ef9b247f30481117102a179a7ca72c556a029b77d0ee2167190923012aef527b8a432576f8948a7dc77ebb79fc7a9dd1d981a4bab9c00e498c09902ffb9362113f6ad3ac6c1f792fe27d3a71aa19b9f769f2417ada3d303e3fd2600484c9f6b43e4ad834e60ce4d4885088087a96eb52ad989a9e9a43aa53a78e513743a8f08cb472a144af5a6abc17f217715e074aa470ba71d2b1b75e4ff3f597c4d1993412d37f94989c1df016f72b26c8d58d78a8a3295108e9bc061facdbc4c708a1d7e7c95bb8e365d4e933c0e519d08abef948abb67c5a3ebe938b91613ae9bcb6079436af3acbbdfacf77e8b935686d4ef7ed47b5b10
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (14 mod 64).
# DIGEST: c081d0d09b2c9eb39a372ef4a7b0246a0956b0f9
KEY: be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f
AD: 5891d77df660ed82933f62
CT: c7de96bb45663dfe6da2a64ffc9ddfa7c3dc63077079bd4bc2ce52fea89924a75664782a5026fb5a099ec460eb9c6d7c3d5ea383092c8f4c67a70fc499a7689bfc27df4da7c185d573e6f8d70cc6
TAG: 1d6cf11ee4afa8efb4e025dc32e0c73a6fcda2aa5c892031c7fde0d0d69e38e9e64e88a714184fbe73ca0f1dfd35ba3b0378a474cb4aaeb942a529cd199e20b7dd62654b97d92dc317975d5e26ca1378d41799a127c44a157982dc3677a4dd391e22b6906d303c2c60cde6052ffbdbe5f8bce22bc2ee42975f9892b68f228cb1f584b1a3fb2f15cb7bcf3d9650e72e796c46f7738986be7f7c30dc56c179299c9c368090f68b96735673f2279366122e5cd94d8d4ca2cbeddc3502d833bb365756cd511577a7499c199f403ce114ae47aabd351bd27e4595e3955e1d1c617a3d0ca2d6e4a2bc3275f5ef706fc4e02e48719958d37d172ad1473878686fca9420dafc83e0baaa9aefb1e50c98d6006ead6bd7
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (15 mod 64).
# DIGEST: 6f7bb1f9e2772eb909c315e653e4737cfed78a18
KEY: 8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f58
AD: 91d77df660ed82933f62be
CT: 3a77c0f70f9044fb3817d57be4f4e5ee4b27ffa586327f77c18346f9fef2608a552b551ac549f9e8d47c4959196162862fe2a35e44581971c2974d4a65a47ae719a7f5f070ad902b8a9e022abcf303
TAG: 825fc7dd84de7f3bcc941d0234090a9409e47dda077e0f3fd000965bde1d4ff30e15b23affe14d94515629f8c018d085f41aa3ebfd0498f621593d57aaec4bdd0e22df21668451b098429967c8eb8789f92a5578d177e5d2e326fc14fff272eb90368d56a777849cc5a1d54c6a458d32c26f4cf99e0f80c91e6df29aa53edb03df176b9873f5827686faf26dbb038813a8170f59e3ad85ad698308748d112b7fbca45156a4410cf32fb34fbbf27b66dddc0680f2bcd7cac6b8cefa83945fad84f77a396630029e6bfe9f15cbf5a884332de5ea7f558d783858c18761983080c13f9c06be367ad856cf159656ad140e84d6af4b4c3517b90f5ec0a8e6fe18d42ce3d194f695f9b7440d4118b8170705b766
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (16 mod 64).
# DIGEST: 172f4992e692a88f49628e5d3937959be01aed2e
KEY: c55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d4120
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891
AD: d77df660ed82933f62be8d
CT: f2f3a3d985eb38c406bb0db0d141188c680656db8a4484abad2c8973267e14458e2be7cb52f06ee2a0f68eaced13db714296319b2b3557454f5e9cb47e8943ea3e66f7bd25c5757375be7bdd65fef53b
TAG: 2c441fd3259628cab417df36374ededb37b9775c0ddff861a5b957a9237265000be0857b3b8482ccc5a348dbb9f4529da4baca8a8820468b1219fe4680221bad9a527d93ca499a988411021e0f9cbfbacc7851c63cc1886e934238d9b7f9cb6b330ad00da830b34c7e4398d148af7599a87770102622e7a68828dece16d4255bb319c75ab0046defe72269fe67780b34324eb3d57effa216411caea5661e64d8151707ffa86752c876590ec46926b7e963ced6a7fa95b1bd958e618bdf1775a9b3ff18c91ed490f39cffe0ab03bb5006cd321d8e6bbdb19597ad7692eb7a7685e075de1d383089f46c8a4bf1aa948bf08b89fde28696147c767f5fdf2aee8b8d4af2903452fc5876aa226d490140a55e
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (17 mod 64).
# DIGEST: 00133da1f7c63fd5f0eec364e9a359be02c1d3da
KEY: 5b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d7
AD: 7df660ed82933f62be8dc5
CT: 02fd26e7b51a1bc6ab6735045d2e42fdd1f31adba98ed5f8b3e89450853104633abf6cbb70ecfba2f5b39dc06f419746abae4a51d33829bb04140275021d183ba079d58c37d4147e8114bc2e3d1542b0be
TAG: 4bc0c3d3487bb74931c27253f0f0931d15a627ad88ac1ba563d97bcec53524870d8fefd1300feae23772902058f5f4a0c1c67eb5e4ca9d4f98692398a9019c3263d2191361b73038e3c9252502ca72070f1155952b3a0c787508d7c0c96e02036b2a26513fc69b19f1c51629fd7bdf015c0c45da5de1d6899f3cc3bdaea7a3d7bf1d0e8a8430fdd7ec70f93d7bb62fab821c1f0e9ad564d04081a3fb70b43b5ffd990e53938cd34084411c0c11db13bf2e28c6fa299c720f3f68ad751c20f6d12ce79382a1d0c4bf3a6bd3a695b3040193eab3c73aa4ee751447a5a46845c86e22909cebcbfc8b653f352072aad19b725dae4cf4d1c8bfe55605f0eec27682a6a365cf2e3e94ff769c2aeb328fbe6f
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (18 mod 64).
# DIGEST: 60a6821269be6c5b985576b245f106128eb0b325
KEY: 436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5d
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77d
AD: f660ed82933f62be8dc55b
CT: b2fe392acc286bdc73cac1aee34ecb3a3e3ae2ccdb065618e3c4a17f2b2668a2c11108b0bf8a8ffe20800a698e73c9b6ed4b0da61bf6fc22c33c75439445061e198f018f271a8698d87185b7df77daf9e757
TAG: 7a3dcda8c73da41cca4a85a9bb5226d8a94f2a39abaad492ee978b6051961be1f0023b673348fa17eb29430a340b3597c6aca9304be30abc5129bd65073aec837e55fe06c7787f4272e75c32b3f1777451e17853f4a4696cedbeabb57170f77efe9db657572035af08cbde5432478dc339147d433457d3a15f8820515a6f267dcd14cd9489352e1561414e3e1e0a85129976c24dd016d4621af0058ef4e19fe4bdfdbbec370fed7ef641434eb629fbb16fbcdd117e9b84ccf7ada8324f9815e4aa42c12d4f0609060545997afd4e6786a0457b0b2fc73ff7856adb51223d2408ce4c414ef2afe52a3bb67be43997898ba846045e96a27acf3f1bec0b755e424f57c69774cc13ada5227c7642f563
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (19 mod 64).
# DIGEST: e2593f3b6741a9ed9fa188fc06efd057556ee624
KEY: 6965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df6
AD: 60ed82933f62be8dc55b43
CT: 8780167385b8856be346b71b042332368067d5d9420b3793fe94bc1ba92991756523c7a8e0114af8fa7296ffef8fae01796b47edea43bdcaa8832a08e823c45c1ccfaf1190cc7fc73a67decbdf407c72740a7d
TAG: 974451fd4d9d6d1f88be4404869b435b4b687a1150b31a0671c93f52f76f2e4dd71bf4a3583f68ea5fa4a0dbf8c779f83e8dca1882e9bfca3e914e77ccbf40ac94769c44f9a8bcbc35a4f9920c6860078d369f57b407d353e8022263061bc974df29fa7c862f3d06213b1190cdd3e2091b2e26532356560efc3b21a499f4841869c993272b70f153985d45756a0b3250a1b91ee3f25a6afbc202f3ef81dc607068fc7214e69255342e662c64ffd8acbe86992ad20ce376d92ee0bfbee6a72a1f83f470d0bbf6ec22b364e842b84736d3923de92c488c102344fef6f78624989460a2c45fadec2a7bf722e2e6a34162363cc04720a50f0d309f64f9322a11b642b97f023cb82a521af6b1759d37
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (20 mod 64).
# DIGEST: 17450a437efe239e1858ac4062f34024305372be
KEY: 65aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce99
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660
AD: ed82933f62be8dc55b4369
CT: 2cd2031084f8742da110ab5d8f7290828857c867b38427c3f53be0dbe2cc94527d2f0aee90a38dee77c0ce115ef650b2ae65094e99ac9bf6da89e5440c1bb4f8ccd163427bb95b3ccd629e6881107d6c9a80cc37
TAG: 026560a6675920dfb199359bea1a03ef0d7d67d359bb6b94074eef54047e92a0940f8eb5d08aea137b7caa73904b66a8c99775e0d859e4c91d68dfab271a9401fb650a9afb83ec4b42b97a74db1908fdca0a06603cde524524ecb3bfa15a96b6e250edb83e7c59385357c075bf077ada33489dae99c2e5d5f17cdab9d23dfae4171e564bb91e3e78d61dc7f1712c2a4431e9451cc1f58df004d04ec50f77a2681969ed91e07df4ec90fd185ede409a5387538b115107a1fe22bb999082d4341ff5a6ae7af33cb27a64eff64492a08eae3c18e5914971e514f55e65ca93a8a19d7d4c2f3df76232cbac674c480e9f4316a8df7ed9d62f8144338249732dc1c3dfcc8647804c13a03a59eab926
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (21 mod 64).
# DIGEST: a35fc7d25f90dd9cbd35910d5532aca8aba88b29
KEY: aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed
AD: 82933f62be8dc55b436965
CT: cea9c7528706d506d75cf085c8475c081ee8c6145ca11610b73eb3e103a706faa66062f8edc10abaa7c3edb3fcaf43c202c4812e768fececaa04564414f45816fa5c0df5b7518ea3859be75c4567565358293e9232
TAG: 32de5af09080604ec6b6fc5a0a542837a54131fc87b1825666e5d56f09e15b76d47fd8086dab709567aacc3e59d395656ffadab861ba9a0e1c1b30321ce334b68724877ec6806245bdab9bc0f8e5af6582fe91a2ad95f7a6bd0ad1df9f9c2d2c20f78f2fb0bd2653fc8e8fefc9255541d789a0059820b30902c3e4344b68d4603b3fb8f5001df91fc9383dcfe76f219933078c602fe2813b9e59e8f996f8943c96c10f27d02f5bae69789870a61abb6c3b118f6cc348188495798b07424a750556a8d1e444b47283b096b9cd8b98b790445ba8ad8245a040a3cc96c2d72aba1474f949dc607c386c7cbbda952651f6d3260c82e5a06c517a89c5dfbefa069136e3c094ee1af26fc4c77e21
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (22 mod 64).
# DIGEST: 73eff0f03358879f900b6ebd515f0f4e5a6929e4
KEY: be477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8f
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82
AD: 933f62be8dc55b436965aa
CT: e967973079db00d2257d84817ff4c5faaf98024ac7eb71d22af3cbb92a001a558f5cce2e8c293d6dc2a968f69cb2731bf65954affbfdef4085123aa06baf0d80edd8d04ad4b1d48120f0db0df02ca13708f66a567ed0
TAG: b8f6b6618dc8b59b07566c1aecf97a9933b6546fd8882d14cf75b2065f17518722b5fd77f9449cdf4feb87e7943f9d48b56ab891514f608767f1711314974b020804b7227326185bcdd338e3a9df31f6c3a0190b25d02dab04ce23fab918d6176814877ffba65e410bab2ae256d4f5f937458d24a144f3c45f6fb27e9f95490e95eac4575d49d7dec6f72ebdf3efd9dc6c83ead51652223b18963651b8d957b7aa050b022e4beac68f928de0d1094dc756d8e1d2b89a1bcac0d3d40f0f71e67b166a6a56d8ea91df5c930566640be524f187be2065127cd15b2417f7d80b6a8cf781e0e90c6ef61cbc902e935ffd2dc9e84c4170fadb6f76b15d77c72b49b8aa30ad1efabef37d55b4bb
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (23 mod 64).
# DIGEST: dd6cea270655225cb4f4231f54c19eaaa146eac5
KEY: 477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed8293
AD: 3f62be8dc55b436965aabe
CT: df01c1a140da0e422919c0d34b231fa3cd767766fb35f8d78d715c44b9003e42cca112fa1543d74ac05e00da9b5740c03b5c4d1e558ceb8629adf3adb1771e6edd5b986094f724e675682e65af15bb3c0feeed8cb3407a
TAG: 25a40fa2eda366cc951e8965249500a657316c33538f874f861753eb038dc5cce0425824f138abde55bade8b0500af1f61b8ea69d4bd68de3fc403021c2224635535bc83dcbb429a8ea6c0ca2687a34e02d1dc45e7bebafd26b4814c0766e7fce5238767280ce0424a3f16a30b943622b8c1abe4eb6c279333e9d8f7bc32afb915bc5b0328147b57d02d68584afd85107302e3c84983cff39256313c4462b693c256edbbedadc50a52cd2a3c8255c1c34ba87a70cb652d74d8375ede59a57514bf5bc50532acc8be4b438daaa2d7d2caae6c291ea2c78e27766b6e2afa2551f3287a6a2a4bf747a1706cd66fd724fbe0e7e81197b1ac612c05cde5a62fa0d5c43d01e6300c7066057e
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (24 mod 64).
# DIGEST: 34dd9bf0ce19eff890ecad474388779f63b0af70
KEY: 7e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2ea
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f
AD: 62be8dc55b436965aabe47
CT: 889ed4c7bd5455821c5b95a67a277a197140816784e820ad8e126b3d3f0ddaca73e3eede78c1c1d3ff5c2a98c0cadd644393b7e3c2273aea2be1c6fd20374b71edbed5658237d819b5e4e206698c8cc8c12e017196776bbd
TAG: 57da1b6d2a9717b7f6f37f21dd9c686414ecd07bc24619b9d35c62c3548586bf726bdd33fcbbf64686556d1ece930f37c6f4c8bc1931a10c50269cc1dcd95bed9d9edb0463a266e6e51d2d90fa9c1a1a4dec6d21663df4f4b99060b37441cdc09386eb785b7cb0183df692d7846483998269e36d06bc7e3a010ebc798c83a5de0c4d6201f2b5b7187a7d99d109741a19e267cbe458063aa1ee66c7c2e0449549d03a9cac20d356c393de63d466ac3e04d63b88c26768f0b3fb18564acb1515ce4be0829aa99cb293adb9a0d3dde529827abeae270611c35277a4b373fb099cfc86a99483063014ec189429a243438447c9cd47a333b22e2c1c84845b79e23a661d411570c510f42c
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (25 mod 64).
# DIGEST: 7db8cfbd3b29f96d752346eeda3c2bb0bd070099
KEY: 0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62
AD: be8dc55b436965aabe477e
CT: 13833f78c9383bb4455972d6e7d8f22597e65de7dd01afa28fd99f9734366c522bcaef59c41487d84b3f84c1e0b7e5ff6de84206f54d5ae80ce80fe3cb68ea4edcd15897fd6fabe2a19904010538005668f2b05245e28bc0eb
TAG: a76458445b8ba4572e8aed335eeb6ef8126ccaebe8b4be3f799e1def09f8a81fddc2ddde86e2d011c4b61eb16bb74cc5a2c7e1b6d0107f6b749b93fe9f6589bf4ea2444cb63f5bdd3b65827fff3adf32044621aa164160ac4662506b42b0b13ac148e09abc016102ccc988362f5cf64b969fc056e3f302a830f9a0b7f3789bac1c940d5cd7e2dd61aa3c6b970c3d066504093d658fb5f9ac7fb22ce306f5a9d495ca7e29d02bb39123b5387c43ed9fa1b8a061a339ced5a9393b7dc6401921d0fe424c1f168451286961f8ac199c3f8f8d4b154c89d290a27cc53695e082bbec8a338ee09826555a3fba8fa4bdb663ba932db800df0a1b570450f33f936cb71622854b84b260c9
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (26 mod 64).
# DIGEST: 4abaa8453e8cfdefd918571a961d8351754ad5b4
KEY: dd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad40
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be
AD: 8dc55b436965aabe477e0c
CT: 03065bb245ba12ab90903bc081198fdfe45d7d3c6fa3b1f76bde831917376ec2a5b2ac2cf629de6bd3f23025b678ea9cc3bd7801f5510b58432a8bc17999304fec4de7ab9ac22d75897cac67ed57e30d4745588b36695dd005c5
TAG: 92877bfb09987df366759a1776b758dd9943472b933d5720e4d199002d4f3ffdd527c2cdb16993da7aec2ee53a24f6681c22fdb9f9f69a89704b6356441c6e87930b2ddc47bdc1fa0df00f7490c16e18a095b53288042525f60f0f37be0036f9a7dfa37ed3977456b3d8c4c4b2c47879a4495bbfd6a512fb59a40b20bce316ecc559aa825b4be8dbbc5dbe06fdd074c1f2132e954fb74fc97075e9c5052a0f86bb431f7fd99d62080140e0457f8b5deadb9b2528e61731488f25f0574283a1b30c80b2bfafcf0e4343ceb83dd20d2179a38866780025516e5f8216ab70c158ddfd0ad7a446969cc9f6eaf5c984ce8e9c38fd3b8a007a1c154bb4330fbee4329b8335f4ec4b23
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (27 mod 64).
# DIGEST: 0fb9d7ffcc7c9b84f34661d472ae2d4fa25d3d99
KEY: 46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409a
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8d
AD: c55b436965aabe477e0cdd
CT: 04c76011b9c4cc8ff18038d36a8c8b91debc8d0929ec173cfa5450f434308234e6a368f17a04ec0556dcf5ace0efb5ab51956d0daec5c530129aaa78309c3d0a04af17d02b0f91f70a82b2ea03522659f76d1919731ca52747da3d
TAG: bb70d9741043c7d3d9a3c5f7d2dc1517a91729b54dc8f49291e2201331a24fb24ad212398617237c77de3d6266fd32341893a9c8bb42e60123bf3bd4fd70a065d6f3d0ae98434d8cda789be46a5e5ad05033d18cdadb36e33fca58181909dbd3cc1733dfb4b6dba689a66f19bbadd35f830d6af1edcbedca45b2810cc82ce83d39ef9d6d17aefec9b7199575e8d08df3ecb9a407b41a9c1d851e923072c96c5ffc60d3987ad10f27aab7792a198a17c8bf88c586ab11cee5008ee7ea769c56ff8d644b51059b9b2ddcfaa92d3b3055a4b3921bf95c5c131c2485d869f642cd14cd4eb9b73740534f6c48c63f76c6f1e4dfcdd9dc3c07593ee6032a98aa10e1b7f095c505d2
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (28 mod 64).
# DIGEST: c68fec315401703e49722fe4b39cf28b14e9f50c
KEY: be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae0
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc5
AD: 5b436965aabe477e0cdd46
CT: 5d9af50991ea21f041a766d8d9036073eeb0ac083b8069619ee50c64c661bad73a9e2ca7f8b49ad9df79e47b49ca3c8ea9dc254854f116a49959c91481ba96463521bfdb74902a4b454d2c6af72d130175c33e8764b64bc93955f9f3
TAG: c3ccb45d8e69eccdb1f058a490d8de92f255953c16f27e21b49e4f29639452ff846aa45394972d895a0fcde901fee45211e835f6e4152de7475075e1e7ed832d45e0407eac1c6a0c88de4a9fb44d961b3be197e45af38a88d1070416c419046f6e43496e6fc1750de734c7773bba9b402dc96683d624117249f3d3f3d87f83a140018afde34dd5980e86e157d632acb7fa5400dd272fe74abe46652eab999b9ac1cb65a4a609f3bf9cf3c8434f9eca0bd440d665e772629c0cc76e0d9009e47f5667c0a0846ebbb1c1b23523262d3225bc23e3513ebed8f67c721cc0886efb251b374ee4e79f60c6fc7bfb81ad9ac88c0a782d3c4bb918cd21ca1f3b8e311f5e48b9e6d738ade59dafd07ca721aed0f6f7f98f1b
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (29 mod 64).
# DIGEST: 15e1aa5285beab679aaedbf51a86b4aebbe3d7df
KEY: 99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae021
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b
AD: 436965aabe477e0cdd46be
CT: 182dc2f9f412f305a8fa4813e8c8eb7a41f9708efb516fe3feaa6ae94c89b4437cbdba7c738fb97ef9739ed94d988bd60af5359194d2b5f8a48e3f5482c3be294ae65ce803e21acdee157d436188980be8e58c95a7a5a33e427473d4ba
TAG: 2751722d2433b908076080c82895c633135bed9c7486d2fec286ea11b279b5029784972d39c8732cb1631841a60e86ad8b17c41e9c0b54ea3dba7b15121532b7d7a7fe8f92e2280481c73590cc38bbec7888932be3d10ab251157ed0335ea1b06a379c4d19d7d860bba5164da684c9d0eeb20e65c0c63a60bf94f65fa4e0f61bb94786271d5ca588093446fd563a6d513d81d590244807ce399f4bbee2f09cd8145634c1ebf06bb408489fa362b06af21a934b1114dd8233c8cb629df7fc5ac619fe2701de7daf7d7295049e1909fda9864fd7cd088316be8dc7770237748de45c3dde6d476d233983392e1a3a96f9c6550d5a7df61e3818492806db44121c277df71b9e1e176e335a68f2811637a9ce17919d
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (30 mod 64).
# DIGEST: 8cc0b1164fc844e958e055b7ae43f2f95c29e8c3
KEY: 371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b43
AD: 6965aabe477e0cdd46be99
CT: 0990f57d9a7e9b64bcee741e158eb5749e9d7b34d43c6429754689d87fc45daaa618fc62d3dc111e5a1a7a06b2b14c5b0f3e2e463085e80da6ce4a6f7815cbf871376c8c87a36555b8a74e0a14421e1e4d74f7531546369ca81e4585f86b
TAG: 4e2e000dd4c6c0eac8aeb581fd352c8c8d4033ea944594afdaa87f05ae6be756e46cf27b7ee6eb01e9f4eb50918d2b438fc0d1eaaf7c6add8078a6a9d45be1e813c18b20eef740c85df67de7765974544f5482f9a0012192f3d84b2cf6c01141f6a8040158cf9ba03c5a1b580cfddf0a682955713a4cac6e0d3b6e273db3a91a1b8096f85fbc3c7a67e893885bae3b4c65d03d111da7e199780de379c6ee07a3657ecee397ce0c9d34ee5d39e8fc4a64c86a0d68182ea48b91c76f63011d0f0cdeaba4e1ff6a19686c5223a25a10af0fce79437322c0cab4786fdb4b93e687a1c7154bd294d784169b1bc7cc5c9f3b8bc3e1d8b808b448f926ce8731ab30a33cef85f57053ef081a8948178030a50c247e53
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (31 mod 64).
# DIGEST: b51001b6ff9d27bccf3103a4961280e0a1406257
KEY: 1eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae0211641
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b4369
AD: 65aabe477e0cdd46be9937
CT: 8d7999ec7a80e528bd6a8d2a9724930c93ee5cbb0c888d9b7c79d2449e638c03f3143f1927a1b261d66ff55bdeb7ff6616da99a2155f465d7c91f54963e7cbda7b61529381204ba43c9681260799ce66fec9b0e9882fc0ab474fd9134adb66
TAG: e9012cda52183ec3e658c42f819dd986216e84e14eb38a462e3db010070a3056db6b148863afa9af5849e3ae963730f02bcc2b419f9cb37659609dc730008a43c41e87312b546d3b67e1f092001bd8a1b81ea304126801f149b0a37d826e0fac21045be4087f76e3c44a796bb55b6e4565d44cba7a8a48d4ffad797982256e87b95f6599b53f2ad34299d90204acc139d115b66c78a2072c741c43c81bab9dace2c0088b2a5dacd917e75ff0de07ab5febad79eb5e0d03012503110bc0f62e2aedda35c9bed4b7c2131f96a4d0c9ca4d133ee032a787e499c92cd46b33e5bfb7f1d3de52db0c7e2a15232a7c3c064c90bcd23366bf982bfbd9694e92b709a86afa4c4a6eb8d5e9b48a20ef409acec78a8c
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (32 mod 64).
# DIGEST: aceed075f31ab159f6610f43ff0a6ed3a359bee1
KEY: b8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417d
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965
AD: aabe477e0cdd46be99371e
CT: c3e61ff897b490847e6539236d2e3b208baca2e83347b7ea2ac714f65a409638e59a5dce5c3a4109e6d6cdb8a232f5f8a2577101f9fb53aa50918f924c1a5361ef98d6672258b4adb37ca5f30d22893dbde262fa9cf72d2913c1901d70a0b7c1
TAG: a49c692364eda34c22ad3745a4339244b687f596bda16d4ff61c6697996214bffc78fe54bb30321d37f17a7ee146dd33771b9b922b475ed41e55de39f1573683e4c8147a9bc370d6f75882c991073181d3f5eaf31a9cfe0dd205540cf6a2b6c0898b3d1ebe351c7e036e136088fe88a07e2c512fd488dd5dfbaebe10e6627bebb2cccf1e9c985ec9f1924abd91d29f0862403c24496ba6c0535358de379a60adb764fe00f5e09f3487b075713a85452ebc21205279815653b39af6c7d84cb1a10178006c1b4ee3e53028c09ef59817abc2335fa2ee7a56ea18e2cbe533b7d30c80609151b58b3c711314b35d3be3df1cb6d5cddffc316a940cc78ba1734da1c09d1d05c2650ce3a0fbd60bedfef7a83f
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (33 mod 64).
# DIGEST: 976ca4c9819e25a204a024d05fbe7420f717bc58
KEY: da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aa
AD: be477e0cdd46be99371eb8
CT: 1944f256989b6acd7dc7c334d10ce71d9f2980cdb6adb03784061096955a3e10efe7cbf1c0aa1caab97cdeee4d08a8ff34d68e1b53a0df58e79a4c1d5d9b7eadb2430c0b8049b6c43a848fbc5e5feaf16c5ae08da38f973b18e33fde747702b882
TAG: 6e0c7a079e170b669fd211bd54c2cd2c51bdd5dc84c84e0da6104dd1d5f6e8b27847a4def48c030c515b680a5db67439f300d184d2c8fe18681c7fa25840b80f53ff494fab5e1694a604c1c12b3b113aeff88bc2c5bd31e84cf5474d6429b4cd08241e94a7f4276054fed2f2a0d863eac2671c9af96045447d6422b8789c4674feb8fb27098b5ef613f08573184271899f735af845e6b7ed9dafd4524247178415479fd60da081ae076331df7ea141df29a086b76bbe35dfd4f983e45b2f1316cc27d88c48b87d2934833eeb5bde5df0866e4a9d8894fc275d6677eda6ac6b41a0475aeb9a55ce7d7a04820b581e8565c9d9919685bdf0f163d77ac45a15e4717e2e716e49ddd079f18295bc7a05e7
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (34 mod 64).
# DIGEST: ad8cfe7556704bb1974e94f70d8743d147c5c3b4
KEY: 7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0c
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe
AD: 477e0cdd46be99371eb8da
CT: a850ddac6117f7b13e15c17621fc7c99f2276ed7337cde87ada287814150f8b3f3e8ba7108a1237fa6a9ddcebb07c234660ec93b8279bb4614be85c5973603568e885f5f8ea102d0621b5ba77fc58af4285c15996d6868c520f3e09ec5b6a468cc82
TAG: bce897e6a5dfbd940ec2c477af3411901f0f2fa9436ff3b4da7354189f097d231b95741788b45e9a56e7ca7a41b265489578bfe8667b1cd64a2ddd765144e770ae13fc2e9ad24575bfb97e0e012869ebfb52a9c7e181e79bc260442d166550435dd5c08b131ed3850f78a2e1df8a1ed026d9310a83f0b8449cf2baec42d7d7e31c4ec56d9d25246b34a479ecf8ab850c65fe8b2a6361fd185c25d6f253f556aa46825c535a4a54b855148e032d3e1ecb8d501802db1eac194a4bf7f3c70f8b8c33cd88d3362476e2080cbb4482fd9453ead6dc62a0dbc0649e41a699c53427ea8ff93fc9f2353356f695642ce7db49fffca401e9c275365dd0a339e3970d5810c5667c234986a65e1ce01e827e27
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (35 mod 64).
# DIGEST: 1dfd9608adabb5a55e12949f1c4bfcd5a77cb703
KEY: ac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe47
AD: 7e0cdd46be99371eb8da7d
CT: 0cc80c78b73b1bd898c6af38846d32837ed0712ab7cc48b01c6dd831f37237ca7634c90aba35b35da59b60aff8e6b9a622f5a481c98c03fc76c1375e4602e96c08a465f3085ec86b0a8e1ce8757df761400be6510f1cdff60b05bd46271650b9e5d5e4
TAG: 34a24675223b1e1d363b941da5d1566dc42a61c7c239a6684a497e7ef90a78d29c1aba0a9be91a8cc8a7cd578c77e62db1234da2b913e9500cf81df22cf481ee43f0818be959ec7fe49aeb7be270d227f633f65a003b19060ffe8bdfaaacd2c20ac65b43254252fb2fa8d2264f5664f3fdfaaefe7216c3f8bc6957656d218d5f98f5b377fd675a21d16769c499b82d4fa54be52ef8c96222b83fbe5bd3b456c9d181cfb5ce23639749e9e22dbc3979f07910b83c200c82a3dd449e5ae47486bd7f2cdc26c3beea2d3c490a801bf587e323725be1a76c32396e5c5ea24a9933706260d5aa16c847e00bdc5d96b0b96652a2c73e6141367debc228af6f944bcfd65a9269a7fb8c912c25ae2a6e8c
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (36 mod 64).
# DIGEST: ad2b43eee27e6267d8c5c1c3d558a07dcd6b1f5f
KEY: 997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef45
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e
AD: 0cdd46be99371eb8da7dac
CT: ad918e7428ca106cf043d6626772cd45ce998f32fea28c3253fd58f0fcc191bb4cd250b5dc6a7b352bb2aaa66601e280576fa60ad8c3aa58742462955fd7f33ddbbb5036128617c1fc3bfdf83100dfdd069042ad1887c2821afbcf822756226c69779d88
TAG: edae83839ae4bcbcf7da661a302815b024d7576e65ecb70c183411003b1d6c769a13de3444f82c7783ff5593d9983b369833cab8dfc80120e35bc86d3b00c307338163bd5de5863a1f2daee49b4f535ce455b131eba334b7c995dc25640833c6c0a7bac710ce37ae2b85e58179b57218e801c4a7e5dc19cb3c841c11c299a72efd9cdf249e9c4423cfff588895e38e5b2d166344ba53b083da555ae4a1e0278f5b7a557e9aec08ac70da44858306df69ad968c017f8b4c24a0b562be19e1f6416841387ee3cd9c8f7c8b3dd1fecff0609fc77c4d86fb1e387cd1932775e58b928f4022821c0b9dfc43912fe0d0755b2bc2f88682f6b11eaffb6caaab1e295755d1256810ce16d70b306ffd6e
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (37 mod 64).
# DIGEST: 3dcddb1e4f49633e7b7bd36f4056d16c53be7f5e
KEY: 7deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0c
AD: dd46be99371eb8da7dac99
CT: 8ef4db8a8444ddd056428a25b718aec0258fe05b5fe8d6d972ca6762875c030fa2b4822cf03e797a53046749e39646c8c6b373a1d77287f4124c19ef758eef75db8e4e03309b3d14e918bfd9499ae5c9e2f3079ab7da8ca7f00ab69d14ad96fdba1c58b813
TAG: b78d95ae68ef1121b27bf93eb67605bbcbfce1e0293fa37e0de4a959cc0a1a47a374f6727edfa9aa5a330e5c3df90a30d371304258624e8015a2fe7583e362f045087ac9ff6bfdb5371d9fc9d55f7dd91bf0310450c36d33538ad5f6057d0c8a0896217643c4f95ed6c93ec95dc6df838cd43d6f60dc3d48d489922dcb1fadc586dbbef4200a6b1d67d2024493fb4dfdaae7563edb5ae93fa2065d750a10919484fbb1389f93d2f28b62c8c6708122e0abe0ed22ddba815da8bd80393fe274f545e463dfc5f26bdc207f3f056263e799b3c89f9c740748a37b7f28cdfdbd9bc89155e466e9a1830dd6d0a206d27a588c56c3b6dc92d5202dd30ec0a2e1e31a0da1a5ddd9d905204f47cc25
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (38 mod 64).
# DIGEST: 25b982a242f669c013cab1c18da425330090e3cd
KEY: eafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd
AD: 46be99371eb8da7dac997d
CT: c107710a85a49250f3a4401fdf07a44f96560ca5e71d6021075b7b6e3ff8fd6f36c652f186dc82c8a21a8a743dcc007e6710214320cb5c5e788f8c5b020e4d0d89ec2fb780c9ea915966b9f9b1e2cb0f26fb6bf1aba6e6501f2571ef1299918d4d2e6b367e22
TAG: 3e7739cc9f98881f03a99d95250d460497e445cb24b4f8783c0010070484f8f379d74903d9a99f6a621791763af4e8e94ea305642643103b2dc0a0c1342f66154a0b4c4cac63e79d7121a2a44991273a9e1111208b3d9a5b6d11a6a28c83d16c9099d0a0247bf4670717ef0e8e6bd4e48c893ae189cab4f916862a8ebdfc0cb26cc545a9a08f01f8b4ce545914a35924f728c4e914b8cea6588116e9ebf592d4709e0c4efc8f0f8379fb30e35e36bfd68946ada030e35af5ed510a6061471659dd6780c1356c3dee7f69ab449a402456b63abd7e7763b4020db5216f099ef78a2125b42fe508cf94976b8e4e9ed65b38c254818e6aed084c037efabad7bd348e4e16099c7709cfd9116b
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (39 mod 64).
# DIGEST: 9d7958e23777ff2472f5a24dea5fc19c151dd921
KEY: fd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46
AD: be99371eb8da7dac997dea
CT: f90604401a507574dcfe5d7c5e0c36c5fa65d9a8f0a25daaa9fe5c50ffb3758f52c9c883c2f85d879f26845a130044d395b58497979cf24a9e18ee1f27d1eac4d0cd994a6338c5755c74419111b2bebed645c3d8b8071a7b5304eab2c33777eda01ce489f4a6d2
TAG: 8a94c9c05afa552672247d156dfc8d60e9e3e1e9eaee6e58c8fd6c1f9d41bff32571526cf035ef595cb5c5b2d64b2a98bfcadebe5ff66a6a2299af8e00fa27e621217c5ee1542a86ddaf93e293d01f20ba5f9093c1fb7a1b911e659027beceb9518f59d20cc54f958945dd44ec38f73fd475647a008de974e50facab9e6e878e3968249a91b4f71f4f86486d5e3bc2abd6dcc67989f58521ee78214dbd29bb7aca0f601842b1d36833748069e409c58de54f7f6e6f17b9e05127568a1566e70254589675f2802c153bd5106afa59e00ac753fb9c3f67508deb5bcb4e25d47e52852acceabb8e5e955e16c0b4448cd313c73ee2195f185f8869165de7f30a68efcfba1adab85e2eb975
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (40 mod 64).
# DIGEST: 09e9eab51bcb9faaa3bc3e473ff66b06e39653fa
KEY: 64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be
AD: 99371eb8da7dac997deafd
CT: ff258ef9f318036586c5ec9e956c10c9423ad3a8a5468527c02bda6878c45398b0c78f3fba4eba3785282b3aa4586d31b238fb941546bdd6e3d918444d45f79b2a5ce3df0e8769a952243cce1f17f736d21e44d8d49449e017e9aa5ea20863a2f6b2f7025de029e1
TAG: c113b619c1829f799e045047dc1587c35eea2e9b5735e9acffb8d5250acb5340d7e48f261c58f6e1dfa213980d35df3f14938a5d6c20908290444308c31cfc08d07cc3258a5221e3c8d72031ab52ed92cca76a189eef780048623f82af821d521b0489068af4ff2954bd73dbccc6d6d4124760a5c71fbf88435af2ef8eb24197c8d7b23358baa411d87dd4439249fa80b6f00c4a4c500b0b7113151bc4f385233318ccb3bdaf779d41c433b2424bb3651db990f9fa72649d657bb823f0e73fbdf08e6f81aae0552aaf37370f139e85da70fa52422fabd155d567988d1d2b930f89f72725d97c1b1aaa67217c552ba1b6a51cd97bf2ac7017a2a97298c6d86bab809b9b4a7e1776a8
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (41 mod 64).
# DIGEST: 7b17b7cb19107af8fc4671420e461060e2ef3e61
KEY: b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dc
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99
AD: 371eb8da7dac997deafd64
CT: 5e654ee6344f96fa117a2e1f9cdc08bfaca9c83b1c4d61891e49077c8ae7a8aa604e1b19995b32872087e04a59ed367e42f0ad3998cc2112035b33104164403a948ecf73c516f74adaa57688cee9417456f996847e0c637120478f7d88288b5403f0697c4834e4ea7f
TAG: 363ea1d1325e86bb389f4c97a844b76e43d76fd4750954352aa52f5cd174c3d902a71a8265fba870b1b0e3a1add011914df362dfbc8f075cb45d2cca5498b48c49f0872f8371bf37e334c33dba4170d101dfebf14a519d37647748d92ccbb24774caf56204c1e7efb4b765b63d5ccedc308ccf06bf614e7695bfbf9e416df526ad21c4fda82cdce18ea647b6f99fd2bfebeafa94e8b9e83fb2d85fcd5f8456ed2e374ac383230dd39c528408e3b53a92a3950883f6eed412c1a5875a5db61b98c089daf3419522fbabcaa33479d4f0140963f1bb788a2471aa0384b44c0c69a4fc46a892f9ec8cca4cf0d048e30eefb1a74f8fecf77a4d61f97e4835a85594d1df3a345f720fca
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (42 mod 64).
# DIGEST: 48586ad2eac603c136911b28e2c69f101a8ef371
KEY: fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be9937
AD: 1eb8da7dac997deafd64b1
CT: 59201549a3446dcbdf5c3fa8db930606f6e9bd374d8405e15d55493a82035491811f784fd4f0e3bdb6bdd2e01558783a00b32c53d7be31525343a5a2d72921222e32891149f8dd38303ffb584485df15dd4c6917d4d8ce80e1dd5192f30770873895a0219cafbe8dfaaf
TAG: 30b74b701e2777b537a16fa9b2d3bc9a86d718a4440ac3a0475eb675b352f215a847a286f042285b50764d14ddd3b3088189d7e26b96cdc33856347f3173c7cf4c9696ad560773e65878c4f8db001bf66a9e27e7f42593e9dc3f206e64502b4a11a235d5ff29cfeba3fcff20afac264c691a847a0b6c599bd9f7e4a57179f46b3880fac1b6cdc10444ee5875470d25c8a7bc20196aec1f028aea628092b5ecc973a058f083f4157dd9202d1f6b09c72374ea668041ab18045a383242b5e96ac127f6ff263c15d0a4999f61153ffc5d53bb77ed11b5b8bb3f2071b8ab14d92d161f7e39470913043b316ed3bf9baee35f8594785ff0f99a39b72e918bab81c49ec6c4c4ca459c
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (43 mod 64).
# DIGEST: c37456cfc543ba6e5848b9b8f4ac5a58a104b521
KEY: 65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371e
AD: b8da7dac997deafd64b1fc
CT: 54a2f87f11c6597b3013a0de46b61a8fcc28ab021465178138cdd76ef01c2701b3a48ca4d3cc885173bdeb33b7b27f9064d2f09ec187d0c9c482522fb29bb421595589aa69ec2ca4155f503bdb8f0f8d4d2f08531c0deaa386b9adad07e8aaa351e76ab938e435c7eee05b
TAG: 2b4f8a42097dfe879397a6fdd13c8e2611399c3c53d5cb5c0e41a4a49b99522b127dff5bbcdf4a5c6fa79440e8fecfbe1df30d34df7c3a399cd79164cd39ca50a3bb6ce2b95a46a3f50e47c9041dbf8f39aba1e807f66984619c62499bb5f0bed727c5214efe67ae9863b99daad6b2814484f9e96c3f6aa5a31417624052c69252de37d7f913e5a2715459f945958adef369e59fc7f704ba9d9646870561efd3c1bea0ba785a8a39698d7ccca3e0b6a6dc3b2570650ebaee1e133488b3a227fa97a8580737cb4852ae3e04c11df82816ec4d6bba8f9e63c9c48383466d9d145d27d18358e822af696a8d7c7aa65e2bc7ac32204a8271684e3803347423608666e23e90345c
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (44 mod 64).
# DIGEST: fc113d192686652653a15887974eb1f9b8e32248
KEY: de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f2
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8
AD: da7dac997deafd64b1fc65
CT: 0f0483dd1e9ef91f215f7f9817b7f82e0b96c0d3b2996b2a1d878d0be3a70c07a4bbbba3721e646405a8a7f44347557d482d7899044af37f6df054070eb4debf7471072af1e4c98dfb3c192e956b2931967d7fdf200b464be1ff1955a658bf86faa659db9fea5c63d26c13af
TAG: 176eae7a290cdf30272c219178d7a011400870bfb2ff611142d4e16fff9278cc5778770605f8914f09c3509fb6ec23bf5cdca390cf8dc0390502b3ac3026c47c167079f12302b6ea7eae668b6dac95a5541124aba8ecb8de4cac6c21ba17a2423ed4aac69e3292f3f4f031e9f54702c432d514726cf02ed646e0f60ed672b5f212e62aec4e51c8b8fbad3f1689f1b7dd775111695a342a279f7725da6ffa0e5a2ff5550159208bd30d28267c600e6b183dc1f72fbb4fd8013c5b4ec93f19dee5864bd854df3cabd5c813d4e3ec083d55ccdad4a0178e5d6cd262843d6309059033b987e366e66c67a3fcbba86730b5fcb4786989f86ff9b8a7318302123e0d53152a2a82a7cae76a81b017fc0b883ef6f8cca921
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (45 mod 64).
# DIGEST: bb6e5b5be84ee383caac0378cb6f541726ecf61f
KEY: 39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f256
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da
AD: 7dac997deafd64b1fc65de
CT: 978a10e04037ba7f0dec2576efaff6e5e4de5ab80b4b0c0b8a6209e22da05b8be0f832883e371c61c23b5bef969c004bf2a0f0fc8fbf1313078e12af2b3569a98ae5ee76a9bbb6da6806be3356c02dfa607c26094fd876d8f9dcc0395f3fe356b0a51d1f59582a7bdc7da9971e
TAG: 9b37a729911834f666621a052c9d776f126e500cab45ddae7ad020874d77976af6ec581efd91dbf46ccf346a9dbb3a42d08d23de1cc074788f6887c0b15d98610b19fd2c00752136af3faa32e933518093d667617ae1dfa4e4527779bef7ccc9a1b82d8ddc0eb1d7d9247d0382c6d98ab29f60bc897d28483f1c69fe9b0d37113d237f7b3c3509411058e1c0f36fac6014b6c5937ef005a7fc2e3352da4866384d63c6aac2fdf74cdd16acf782022e4c5f1fa528cd6c977425ab19d800664577b5e5cf0a82e7ba75716c75bdf87eb8c7bdf7346c89d453bcff89ed0b93d9eb1452b72390a799498e31ae691460e5daa8ae3506aab4877cb82e3378874c6c97064b33f969786ed84e81cd1c2e2925b56266ca72
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (46 mod 64).
# DIGEST: a27799fc2e00e7abec4c5939451a834c4606cf7a
KEY: f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7d
AD: ac997deafd64b1fc65de39
CT: eded0eef58434338153caefd914cb98ff516157445bfbd25c3c5cbcc0ad68ed1bf049ac292da027acab0310ef08d66040341721524982165cfe7f6dc495f7f5f36cc410470e3b42045b718f580713dac8074b0e76a0345d11c94a9800bb5e5eef1cb8d9ba5818799cd1ef69c4ed1
TAG: d7459df78edeb89e01ea8d685b5780b94ac339c36750f2d5bc09009c12a22893348bb74f8c38f96451e5204e0d940b9b84c6a89eea61d6a78eff111b806ad4a50c8456d13f79288cd3f3bdde755083dd64d13e1c887d8df5102deb5a23055a02b6cab1021efe6add18d00be8c3afd6f8e80bc539c76003caad47c1cf95085bf48bf9ab6d487ff4cbf5bbbe0f2a2972e6a165a2e5ad230f58fff76fb8ed563b810684daf4b5902ec8cdf2442c323e7c7630129a89432a1795380a949f1113facd9ee148e2d38d4457b508155dba0d8d4812aec13d67050e70e2ff98a1fc1dffa01dcc7eca4349a0b14f2507687314c49b3fe7cdbde2ac840bd8ff7fb7c36a037e7b7de485183fdcfda49a2281645ec1b153ba
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (47 mod 64).
# DIGEST: f30eaff92a640a397f98e6803623e8d1f0c1fea6
KEY: f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f0
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac
AD: 997deafd64b1fc65de39f4
CT: 7c433fc5255dd1e11f67c499c6a89c16b4b09355818cf304f11167bef253dc60c95486a840c3a8f77440f63a5c6a855931a90eea66a281d51d4198679e1420c824ae5c8bc0231444b65b69832b84c7b5ee2fb8484ac08727eb0cba0c14e7e0a9071cb0cdcf73d5d83ce53bba361ee4
TAG: 2e73871e9d71defb381e4e7d49d5d45880fa3effcb0cfe673ab52805e6273723cdf99557ed9ca838aa2229fe8eeadf7c6d94c91e867ca023fbb2d2835e420a3b026fb5e3915e38a7ac02d43a8c6ba8a149e99abec42967106bff6c80adf9be5c76503c95053c21472b9a338ed4c9c11b161ce83e2d6190f87e4dcf169e945335cc5acd699b983629d0bdc452f678232be0d31b9f231aaf4c3c3df79b1b8b2fd8802df0b71cc5e26b2a5c5c5ff0616bdff6cc7b1f09aff68d5e15dc9d61c1cb6a2c9602eab7794eb77af8bed198fadd854e8f8a47bf6bc11a8f75eec584f1901fbf012d1fafc03604ae49f9585272845677a1cbc27261d5d7fbe9bf1f1c9ea42c61b110cde99a3a602fc9eb6c825656d804
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (48 mod 64).
# DIGEST: 7227537c0113a9f46f7d332a0b37ee5303483d00
KEY: 3541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac99
AD: 7deafd64b1fc65de39f4f0
CT: bcdda7eecf3331f4e7605cfd33789ab585318bbd35047755402372403a4df125e7f5bdf857e49a3f74cb8e824576a226c1942fa86de07bbf564cfb384d8420a367963020613dd2f6bd4f371ca1b53532a7015dfdabd07497367aea8db92981418eff6b51eaafe2b6d5b3b4d1b8b95659
TAG: bea683141d42033e86b38d5e0614716ed53b7db5df93b0aa48b15e0111a46ee93c2971df88fa885f8f32e81222d9bb4b605640395e37e1ba474a17f0df48c488dd5a6051be2323f462cd94f81261289f076d60cf5907cac601e2709dc191a9ac5ef784733140ba8d45edded7e58d7316f92a9bd5aa86d6f8441604261a38359a8cbe57bd95522db7029db058a8b175eddaf8f258f2f479b348451b0786f15336e18077ba23eac377ea367d7e1afc08607ff63be2e613fea2e6097192ab41e40342e36688bad628ec273897c86e75e0b83d0d85fd13e850f29cfbe171a8d1b33b72a344a9e2bf292f0dad2ca754d45651a2067d9fb18c7a1845a9c145d4273ee2197dd0b4da66e88a7425a72fd541a78b
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (49 mod 64).
# DIGEST: d76570385cb65d30c3d636ff25c5efeb8d1ea08e
KEY: 41a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d03
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997d
AD: eafd64b1fc65de39f4f035
CT: ccecdb03830e84c5267a5b6f68dc909cafe94a1c872602961e8467b4b2723af537d79d723fc4e8f0397fe169186c23f50cf9e78af3156f507bfd38181dffcc05695583863d8a167df062cd16aeec0cc548a7b5e16b148ced8bc2a60a33a583779fef6d7160e0f6c31a03b8a0f1ed8e18e9
TAG: 5175c37f295f196bcfcaffb35c4cfecd88d1b9c773d3162c96eb74a23722e599ac728ad68e2ac70369e0c6d212826afe93cbbc61abfc309d3f4a6f0d22421e02d711a6c97b6592b561b49ef5f6516367cbd966414d9842eb963c79bd4a8e1550199fc9cbd58b5fa5b898db2244769a950ee62bf915a074d5196732ae69cdaff05266bbc049903f5d7c702633741471bc3f8e44a426d201c5ad5987db33687db05a42778617c253576361fcbeee62707d9119cc76fa0627fcd65df7bdfd26469bd4e0265355cf885e2e515d56307adb91be258befc45ce8b238f6177d24f38ec56f0d64a46124161992a30f8a64355823397012af08f1df378effd1f67fb30796956fcf28b0ff35f618060a955b6311
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (50 mod 64).
# DIGEST: 170369666d1f2337b29b5f14af68d47910388e7b
KEY: a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033f
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997dea
AD: fd64b1fc65de39f4f03541
CT: 2828ec3db18423dc583c7ac7dc5231da07af1756d7c032a866c64155626be3b3a686a93699023f6e421da24596baf99b45244d07d86a8973450afdb87ff2e9dbab6fcef52cd476f1f25f27f6bb3abf9b406704a14ce9682613125139b238d985ab8f68c17f7b824f279c01d820fb70502dab
TAG: 6af6f94f0ef92665d286e08fad2845c4c43f985b0cd0f09c6c6b4899c350a1a342f024c3ced7e54bb00b96d0e04c6d484e95b585a687258f4bdd1c00eb1d3f44e959b2dbb1444a292c81c92e3b1a01622fa377a583117bc2e170ea8c033864fe7dc09b7a9b1b5826ac8e38fd5849ac9024bcfb1c587be93b3da485adf297a77ecbec2a88fcd82e7eb952b6d012ec439310f624fd07de7bad33a5a59b72d88cb454d5da32d52012258c8754cc61dae82b26f8d6df7a4ca384ea88a30e12d4b07bc413791cded177d325c03a5a6c532641ca46ba2560cb3072733282305266985bc4afac41b171b28aae50266a00afb5a778e1c481a7799f29ba588ed3ebc65183517a31944921ae3a040731666daf
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (51 mod 64).
# DIGEST: 7c52593d1d37b0dc380297231c6cb7b64e04c493
KEY: 1be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb9
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd
AD: 64b1fc65de39f4f03541a1
CT: b463f7f24871b617a1001d2f73f9eb8fe39b5fe0b382d420af876defd68a893add2eb6cac45e56d669f4ac67a943a3b32daf0932072bd701f9291b5020bfa9133d2875d8f6ee78ce8c49d45b80329831799f1eee8c712683300e49c57dc8c1ad0b07465184483d669b04c183976289e3ad6070
TAG: 2e8b0999a7792a9cfe5148a8730e28ef92557e1b5d9c318d27d12fb1356fa0dff3467e865c530d4f20fdb765f7ec7e56b7ba28fb49309bdddb413182b07670cba711d6e5e3c086b4e4211f0f19666590bdc9a121e1430f6b0c64c07eff2d81e47a02d375fa46bf8d6fb8708f3a247287b595be7aa19414e3d2d39785a0bc8ef46b547bd4805a8460fdab65d81866dbc496581ec548c51f601e13289fcf3e45f1bb4a7777f9a9243282681aa1c746fac4a8433e1f477950eea76c24d318e95f0586eb5d21a16f8b2b58a14c4780eea922b97de4b1ea292f842c662534bea84213924e837cb546c26f3bc9951eca7593f4f01e3e6360cb14248d127a08d5e0b77f438479035769e0e12c856bf3bb
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (52 mod 64).
# DIGEST: 09a1659100052d13bebb4defd7f54f975a58ae2b
KEY: e112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95f
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64
AD: b1fc65de39f4f03541a11b
CT: adfffd8a654da994aa8adb618cf69b25ad5dff201cd3a84314796e0228ae3e01be77cd8052e950fd74e3d8fb0066705874a7319dda8bee7bf7748ad844a70b1ee0d774a6156fef109dba8346a68b48458728ebde458e5bd777a26291f98cafb175864fee2d335fe5a38f1738df9a5aeb13f25442
TAG: 0562ed87899d06eef5f3a7680c110360e5338af0b78416497e18291d4e8a75a219942acedc7d1493a15f6d35d1d8cd27b2bb26bcfd58dab2c747b4498ce1e56568226987124448509a7852588acf2dae587f0d13ca2ba54c50ea37c10e6c525b04caf0aa519662f258dee7fdbf17568ecb924c0f26701dad0952d3a57a8188d046439d7e35d73adbb39559adef95017029a9f6392d7282a1c84eae663d840184da4bbcbcf9c262d69ed2a7743aee175150e03bd3e6c38a8a1a762614ba2fbbb631ef56ffe3746dc95d9a15eae1f4f88e3180569e73b25b8eeb8474ec8dee041cdfcca5219514c5125395d83de633bf5bb05e4771e7a583f4e6a6d20af36235090454f8acab43984fda3f5740
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (53 mod 64).
# DIGEST: 230c3353ccbd95e4f0acbbb0073053a0186f833d
KEY: 12a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb0
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1
AD: fc65de39f4f03541a11be1
CT: 985481677ae867b2427182edf3de86d7b9956a4970b107ca7e01e90ee7cb02c6b9a46212e1b8ce67e7aca5e2d96272c2f412b5f16a7c1d00fe597f1390c3a686724c4846c78ae66b26ded18adb40f0d74c33a68032b97d440104cb7acc755ad7383c16013ec7fc519b293e4c624b132f91c44202c7
TAG: 62eaabaa53e386ce7d064c718e4761d14092263af3027efcf5c343ab46e1133d3131dc3cd7dd6b8b8d9ae6ca172fc10f5887dafb169aab9f0e7eda4a5b3436750ccf47f2e3e9965b46f3dfedcf38d61dff3cea927bb3ee8509d6a4288f2879d04095eab6b9e154d0e22da31cb51638ae978a0c5cfdac346ab551d359fdbe9aa34e9ceb15051d7e04e9788240a030c0ab7c19d00f32da1df539f08d158f34a1e3fa6ee8d10ec0d99675a3465c889fe2b6631ff2765a6b83f594315768fdb30c27d2747a6e9d4c5724a5e93704a1851d606dfe97150667309b27503b09c85d86ecd83caf1ec456ac19b7fa273af74714611b3e9a3359354c7b983d700775930bd90a629d88a3cf7cf17f5058
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (54 mod 64).
# DIGEST: 701e141608e71005d32dd1e29cd068aea736c9dd
KEY: a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc
AD: 65de39f4f03541a11be112
CT: a06030a844e38f9e049bcf318b10e1cd2db6b60a2611cf9788f0c1fb31a366d2038b3a1692865b926196594850807895523a851a993b77e49c911f840f28aaa42b4f427eead4e2a578d57b101bb4795aedcffc58212e0eaecadf503e3b208eeb72d53072caa44677d6667a0d22639db7aebc2f70ebb6
TAG: fabbfe986fa42c58408b2f008c7fed482ae568cb39c938aa531e49a85ee71fced2cdd2ebe97a35295977ccef50433b41c511d424a47274599f3f2a28678a4936c1382d6a9f5d41b4266ded97a2fb11ce4e4df03f9e976675b9b35eafbbb399eb86a79a8023de822f8c0d83da5516766f141f83d8075a77e7c55e987cd181f02d8d6f7c90775bace579d25fa1a969e4dec07a5ddbef63c67b6d76bff54dbc7fb87f8af639c392a8a32bee35255e24cc63cea90445ddbbb75e4c594d6d1441e198720c2fb7674822e52d0298fe24c6e1602fec34038e62a55cdfb5d3fe6479fe6b02b5fe648792636e03213e402f02e2a3cad928996e4b1d2fecbd97ec5ebac5ea2f9c4989599648b0577a
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (55 mod 64).
# DIGEST: 9aaf96b472ea76fd9ff4adf56dab5fe0400d18d6
KEY: 2933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65
AD: de39f4f03541a11be112a7
CT: d934f61f94d2b0aef2b63668352d2af2db2e225d0c8dd86b8d7c901de7425dca2a0d2f3bae9dbaef4946d18ebc2d9f4cff5c268cfc80b89c35f7b1a3de12173f9377a7ad9b33751fc89390cea9b44e80423702a9848c6d2562d24838e3b0511b81a737a4b65fac394da45f62f1f3b2bfaf0b4f3f0c5ca5
TAG: da6ed936480fd159c32347d94a17ae7bf9344d4bdb1bc0921d85456e9b48a2e2c24769bdda1cd6bed0b44e980873ec3c79b4346849366ca6d6a77e8b1091c6657a009691733da37706c0f480244ec0c7839648cd0eb63a28eaacdc8b60b1ab59f7d83bd142419a5a548df23f019e560c0c9a307b4c2498f69386eb13d4dcc64ca77c8f5f7c4b6e0c18a058eac72426ed4d541477e3a036b9a450af234670c94a4ceb7cd19c9ae113477431fc2ea30738a95c5753a4b8de9e0e4e1a0f7d52f67b2957a39ff1c6eef88bac3b927ab004d64f3522e0db7e80d27309b864996aa2bafe615139732cd492608cc128295132a4f40a70f8bfbb5b18b2fa45c55c87db39872bc5c1e3300f446f
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (56 mod 64).
# DIGEST: ac6871d354eac507556770d8b6bf10b5240273ed
KEY: 33c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de
AD: 39f4f03541a11be112a729
CT: 413d2c3fbc77845409ad66cc13432824ae4ae109379a9617e8b93d4f9b17fe0d0450476c3f98c229bf35e86fa792dceb4b3864761dd442c294e43b1cafe1fe086cd1ca5e1572fe2b3753c20a74b663b536f6e686d9765bafb10566f2b5cf02ee24e3dc69cb2be9392c991848b840418835603bdd83b2cf0f
TAG: 5df250368694b1d3b11119d8c787df534fe4526eb31af32c9289b0eaa4e9455b5cd4a44c13a335857f67fd2662317e086c1a299d794830ca08ca99df1aa79c8f49589dab551cc6269129b731e4d560c7e330fea2aeb5f06eab87738bccaae53b9661a78f3f08986f454519097a6c43837931a56caafd581ae52343dcb71b98ee0b36cb7037a1eac81f308f292eca92ff2c13c3b807aadaffc832f43ed98c0cab6174639b1ec48f3e8e3736f7a20069aaddc2414f1edffba78bbbc04babfe6d6f1a5ae8f77931f78974edb257d2ea6d5440bd7c8f8283ac0e362e1959bc35bca6f257da511f456466be60ff7451887e5ff221f30547e586cc76e7bf76dade793565d733e5705bfcf5
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (57 mod 64).
# DIGEST: 050258d6ad6bec54f8bc48c7ba2d669d6416c11e
KEY: c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39
AD: f4f03541a11be112a72933
CT: fca448fd13c6877aa9fc299953dc631df8024cebe774bb14839821b05485c4a8f1345697b072342343f6a5479d99d5ba0ab29db7760b1e21b37969333473e6fd16bcc5b52e1d6472fee31034d515f66439f092341036a48d637ec84d22af8d1848843aa33e3b2059f7f90a0db47dc41d8af3b5cd76f4b36ec3
TAG: 3071b853c877cc72cbec5c249fe76736e87793118f0890200b64cc9b91e26448b327dd87eb314c4c074af49091051b69122a2d13b8a7fc0b15a87e7e26b791ab3a74e399d429ef4e6ed69f2036e91909b11075ef19c6554f21b5b9b90fe20c9c633f71c666519774baaa12d8f819ddddbb592a99689ba34c44e59792da3d7750f4cfbfdad6e295a73ada8957eb9a7f7bbb4e8f82d4647bd41d5ca2a51cee58be3fcaf307382efec054d880b5866a38aa0dcc72911c9e9ff902ca3743873618b2b35c45cb32e496ac7c8c69c1818583ea5016a57f6e912859b1b1a22bd701113e6cbaac2a935a94cc3fa0b9d4c23ee573b0054eebaa3414c936aee6bd9782385d690c1eb570c5ed
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (58 mod 64).
# DIGEST: 70060f86c76e53512933c09deb5872eb23efad67
KEY: b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d617
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4
AD: f03541a11be112a72933c7
CT: 8c5849a917c328d68cdf4fc279b29efb0c3c1921621276ca19206c9941a5789b0aba7283e743f94a6e4142f7febc9ad35df30daffeaa5cd0cffe0fa2e4cd5ceb687def585b2634774a01a3f00ce2ca9951fb910b4386bd0d61d1e292b2b225ac55000fdce10131ba163c97f810a2b350fc8a59348253549e0cbd
TAG: 5beab8f1449d50a6e4a1a747fc2b9864cad962480673db6451ef7aa42b42e7f0edc3748a71df8ddb33d6f9bcc9024c7170bd7a5b81577f9594a87d90fe96a50a62d31c01368173aadd7dda6f7d4c413773649fa7e5aa0c3cbd0fc760666ce5d5ec5e4209c4eda0a8ba0d66e83ed3337067d8ecfb81d3d1c1bed7eceea2582f276c43fc15d5c2bf9d2558d3c3f4d8cdb8953d28b0221c70330c346640f1ea1acccba27466cc0ec3c14729a78f62c7537b1ca5e9f9bc74c4571be9b67f04533b1f8fa2f9232c216ecd81bd120197b558b2733d3d9bab706f67670327465722b2be2c6e3f2ee507620dce326f28400857cc28c697c9b10df0d093965c21ebc42f34d71963ca85db
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (59 mod 64).
# DIGEST: 58286fe273bf572a76a2725933dd969777c303c1
KEY: 4ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f0
AD: 3541a11be112a72933c7b5
CT: d0076d9cc2f829a33a0b1972f6c0d8c67718a7593975798e0667135db3ce31b4d9bea98710909313a4a2af88bae720963ee738f26bde44b54dd5820992569e5d2eea000baf5de9e0f76dc8e0b93244a8474beb7e922a5f30a5b5977611594af25ed35aab12a61de68f215d73173fd38f586b8c509459a5f7587d43
TAG: d8ffaeef22eb2181a48da72bbf57ba4562e3a1ebf9cd2a872f155fbadeb78c47e64ac6419fa1a9b1ce5a8e78e60ed1f8dcf02535613b959448f754b70d7159d2dd4814122b35418d4e554992b4789e04f018234c91de44b9de80f7ab406fb6fda6f086fc6b91ace53dffe012d703e71861d0b3ecab86a287a76857781254de544985ac5b11bedf29138500598f757ae295d8577ae7e597e9cd915d15124c7f1d9786f9666bc4b69eaa18e28227d87bdc8935e537d12360b53746ad0d7834ad830aa5307f69c3e4ff6e37ee6ba8937f75723ae4f64c2a04949b0db60c979fec6f485dd0cf14cacf5e8d0e624d9a8578e4028b8076a9cee1e5a0ba5b96e9f0f6e6ef98ae84a0
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (60 mod 64).
# DIGEST: ae701e5c8672dfaf728bf0f43f5e5247ea9ac13a
KEY: d4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e78
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f035
AD: 41a11be112a72933c7b54e
CT: 298f670117678bd139c60399dcab68bb0414829b458c747b0dda5dbd67f95fa393bfd2719f815a12a2b7c6b3e769b61ddb4651970b30451cee6166545d8e4c4554c8217898186dc02684c5025ee692e12130ab41ce75d79a4ba1a4dd02e0af581a645979c1a3c8c12f5b13e9c1113316eb31b8096b4eff1bf3f7ca10
TAG: ee9c1cae63b819ff804cc5a34d59d17a76539b7850d5164ae8ab252633acc10145c2c71b1a10b0a87cf2db361c6aeeae533201457c5952feb347f739b3c236845a887fd0974b052a4e71cffaaddd1f00c64c47251ae446a5875e1e1854ca2c032b4e01dc995f35d901b60d042aabcaad3c08cbfd12567cc789408b6710d81b6b7c6067e02f263763d74bc039e0430bc1f3b4c01f95f54492a9c5b81b8d279266b378bccc9073bf1f1db1ddd964f9b6b7ac8771ffbb55d1ff9d973cff3d4eeffa277427e0cc41a4457ad6c2f035b1c0f93880aca55888cadabcccfc9dcf53dc3924a4c03a5a7bf8416bba76d8a362893193811ddcb02b0a9ccf2ffb6902d7e0c434cc489d720487f4664d60f210433b8f71d98666
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (61 mod 64).
# DIGEST: 4f498d0aa9205160827626ef80c163275eca1f78
KEY: fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780a
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541
AD: a11be112a72933c7b54ed4
CT: f72c519566632f89513f3f278407845ff8096a5b63929f0ea6009c3cae0dbd853662c4017ee5729eab92f2c475f0a45533de67d4b941d4b16c1964986d8f4a16cc12f02c28442ddf5790f321b3942cb65964587f3fe55ab28064c52ce3d3598d3431788ed2c26fe1b196abfd35afa0f7c8206a6bc71d61cc4e1a086c4c
TAG: f8c75274342950e4893ca3b0e9fe95fa51343c628e1f04d9dd19ed928ef7af0a106b6bc6b70d0ebf552c0acc51b5af94dbb9f4fca444ed4eefff63e4746af9852d727d4465695b1113eda1becabbc56e2860b55b986d6122b93bb822865ab8bbf1409aef68cbe720befe0ebc6dbb639b3be391a161c2d9ed65a2898b3ea7cd993827aa8f2c60dd0d9e926cbffd8bbf6ac43fdbb61ff0024cdb9e668bd9980a39530a526c3c9cbbe1e4f46ae3e8229bc5e7c8b91855eae7a2aaa1b827d8b99ed19843aafb76cd361259c29dba7a02dfb40d9bd2d580aa12a6951f0f53ad5b283443c5bb8b4c9fcf569b30830d1844860256c18d753a8d80d1d0e8656623b1a06700fc513a7099590aa566d48eb6c078c4472d4f
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (62 mod 64).
# DIGEST: 8c043825b2a3764e8a0cc35a011696fb3ed03c2b
KEY: d0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a1
AD: 1be112a72933c7b54ed4fa
CT: bc6acdf0943ba34efbf9eb27fe9e968f23bc1d4f1eff7f86e836621422e7ad8e1adc03249475b6be8ec5d3e96e167af7e6b85ac87b5da2364b1e0d87d5c49d43ddea8e9b796580fc4fea7774f8210e4ec424aa029717937bf76b148e8af72e8badcc3f12dd259fd4dd9a325d81cfc7a193fb756b5d140fb703aaa6d71496
TAG: cdbcd83191a554bf922180902fd060fcc63a8dc39a90ccbca9fbfeefe9a09a9da72c8782f6d3ccd9e2b5a80816eb5bb6919580a8ec186b8b1e388a561b6c931b22dfe62544456f7344f4c18c4823f167b2ebb8a93e3edb8181f358e66db5a3966eae5e893e76b16e8bd5da922720f754bdb6edf3496b62d79b14f00f24c1b30ec6ea16d88cac2b336f2bd057e68d6075907de3c9e7434da017d8bc5348ad79ec14182e07fc70f4e33ca2aaa2216d29aaf4dffb583c1b5159eedd66a2515127c3db358c1ccd89da4cefaf75a6eb5a8a80396ffcef783973f552645885e20b91dc0cf4485e94d943ea4bff3704a4bd2e23388090fb7ff707cf80b0c71f6d4560b3be71edab2e0b8d5ded1998f3b1df51225495
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (63 mod 64).
# DIGEST: f3a432271c9be858725fd024071c4f479ca9a971
KEY: be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b7
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11b
AD: e112a72933c7b54ed4fad0
CT: 0e87c57c18fdc439c968a9dab086c88271be6dd00843879ae1563e4ed03d69f9fa09a29c1bf99b1c859323eb8452acb2f808f051669bb5e097e23b947369b5a0577157995d729a75ae7a65e293acace3124a8aec53328439e5f2103fc3a236728682fc129a5b0e203bd730303fdd23962d6ea7a35aae3691f6721dafdf18fa
TAG: d7453e8aea805b4c95ed51f1033b386cfd74fef1c205d51fe351ec3b1a3bb2e2b7debd8b20c688f4c516a61fbaa690eb635fe2974a71f45d1b4e2fdf3be4724c3eacadbc6d295ea9b6f53c249783f35898ee4818a67ce5b002f17a48199c779b17482ddf5448b6186cd979dea3d9c7b0ae3f106c4b90c960dd8899a67e9f18767b49497519c86c0b391098192299e4f85862d150bb3e439f05fc9f937c888c4f40684c25018fae0c6fedee92fc0035d073f3704f61d93e7e321a19512561676a216127e6a716d1f5ea43b67dcfaa1ffde7380c066efdc8acba10f2e790d4839419dbed3d89634ae785f7aa3ace1fa1720757066f4b75b883c0ed592b8cba79a400d5e442e23716a7a13c252a7ce156e219
TAG_LEN: 20
NO_SEAL: 01
@@ -42,14 +42,707 @@ TAG_LEN: 20
NO_SEAL: 01
FAILS: 01
# Test with maximal padding.
# DIGEST: c6105cc86e18eb8376c16ea37693db5c07b77137
KEY: 8503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8d
NONCE: c55b436965aabe477e0cdd46be99371e
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c748
AD: 1df3f4183aa23fd8d7efd8
CT: 7265eea4b391d880c6bc72d3282f663e5551c0a71ca35898047362694ee8f2710974350a2a38a13b0434d312
TAG: ead153f0c9488b88357e81187178465d2416ca97dbf7460c9519ed9957d9e74e62950447e49dd233e9c504876a90fa79273e597ed751da4f32a2c60cecbfb6641ca2e8938774cbc324affa9bb027d219730d57ca1981e87d0dcd0551618493f79ff8c0366383e0698a009bd976c63f089a8b901b5a08fabf0d3f798c349743634d5dd35a2195cf0b74b67d36d65be1aa920831906acbc57cd880964ec948e9c11614104721efb62a47600ee968418b1d197c3ce6ba6246d5ac1f07819f67c2cb3ca5162aedd354e2314d65d5e863964db421846da7603b9f11c503966834ed501885763da3e89a59f89f1e31f78111324b79637dd3b6aeeb71ccf2557f9725b86dd13088ce257cd6ea71706ff8ec9036f56d76c4
# Test with maximal padding (0 mod 64).
# DIGEST: ceb2d295bd0efd37c6c34dab1854c80e986174fc
KEY: 37446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac
NONCE: 997deafd64b1fc65de39f4f03541a11b
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba
AD: 2fd6773e0d0c302a5f47e0
CT: 2840fb36bc8e03c59de49315bd8a6e091f41fb020cdb174ed0ab84fab8f94c14e840fd37fc13f48490c2d2ffd4efeb4da8d98840f6ee5af812bcbbeeb7f2992b
TAG: a767b9c80eb4ab9270c0c08d6adc1bf56245929a79a4511a8a4ccd2c996611a0154c8101217b46b049331d3109a42093f223a8224e11fcecee906b2ef52e5650da0498e3f832101b7ef66fdbcef302f362e570e5e42d5dbc33d0d662913c78a8caf3a9e2e22949cf6d212efee4d9dc8d03fd6a00d41f3073c4b73149e8bf05d23b2dd88aab1c87ac948a3f96be79c52efe9488ceb9a1c5511b441a6ba4204beaf339539ff9b4443000b5b7c00261c663be3087c395ee448e724d1cfcbe10e15ccddcf50378fef972fa3aca38fdb1d131f1bc7ce166f4476a008883292f8422cc668e1c8e0cd53cb25a64324d187b14143563d8d1af9371602a068da959c587cd6a383d1ffc74190c0499b2d71390cdcf
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (1 mod 64).
# DIGEST: a07054c760cc66fc704edf950201005031f3faac
KEY: 446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac99
NONCE: 7deafd64b1fc65de39f4f03541a11be1
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2f
AD: d6773e0d0c302a5f47e037
CT: 2e7e6cd84e03e35d8977c9e1d4ce6784c4db3a87fa1b82e6f781e284e0d3914eb56acdde0374eed6283cc10e1f329821fefbf888dfc8fb42fa574cb64df6d88d2d
TAG: 80503493bfa3c2cd3817bb145fc579ebe050bf0e6310a29c9e1a7e98371833a25bea5c82bb6128cba6e27e7e796b49b49cd55ad123f90aade4d76a636104e5a4f6fc9c92997c0706d709145b208523c0c890394fcec38507fa0bad3d24fdc921416501e5c9b6964db81572bb933b67c4b5bb2070ad5068069592d35902ab93bad8d5121fe15bbb2bd27ad946a21f2ecd7e95c7f4c63ddd00589ac304d638307e798d9a55bfde231f5bd8a8f89cfae591b0234662647c3b42278f4157c4fb44fcc51862bbb2f03273f680d6dccee49b51bb4b881e5a1768dbc537e67073b796047fbce6f90eb54776d9f0237978f129af7efd4a3f380547e883d9976b38819acf9e0411769fc6898eaeca53f5def25f
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (2 mod 64).
# DIGEST: d059c266cf6233af730b7a229b19356a4c6fcf06
KEY: 6f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997d
NONCE: eafd64b1fc65de39f4f03541a11be112
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6
AD: 773e0d0c302a5f47e03744
CT: be77b79780ae8ccda54d5f995f7c1beee8ac61735285e34d9dd137058555e723daeafe392773f428ec528a14c2f52a86365c4929d98d4504c669db1d984e2f84f7bf
TAG: 24836360777dbacbbcea10d08e3d975a0bd32669871000178d167a1e40a6723b7c47ebd32e5df52cc4e0ee5459b355f285a0a93bd9fd016642221a335a2f09a4635f71d8575bdd081caa14b083aed01444df63e5cb01377b8a3ac31006c92621a894b71d50c85964234a5aae094a931e5456416236001f46d771767aee47f6b7c3493fc10b9f392dd629852623c1ff6f1e7dd3346d1aabd132301fa16ce88017fe3ca394d1c685942f1ed7b37f84a25682142b02ce138ae9b21c85db410cc3c266f6a490ffdaa0ce95e8b1f2da7f6e6ddda2d4570dc5619605fca903e47eb62d7419dfe49f354ac18762abbdfe5431a863b6f7371731ebb09ab41aba79e41be8603060fe921e4dc8b7f422392640
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (3 mod 64).
# DIGEST: 8aac0687e33041fcc18da154b41f20a6af2bfb28
KEY: 5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997dea
NONCE: fd64b1fc65de39f4f03541a11be112a7
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd677
AD: 3e0d0c302a5f47e037446f
CT: 82aba2e22933737ef55346865375b574f24066eabe39fb800ec790df3ad05f85a760332e8a1d45e7b0c2d969ac5689505510fe035db4ac1c5a8a01a6f6ac00ad3d8344
TAG: 090114b0a31c301edc2bed8e25298d4f913558ce3f6f607b0fce5f9e7b1c953601ce9890f0d8e8d6a71c5ccc4e0aab08942628d21f467bfbfc4996863e8fd296b7ce153568999980ac2980ca68b16c0b2edfe5efcfff121a7e4dfc8dd9387442c4847f7c572f668aa990334dc50a54480f673c338f1ea9c81cfb9d482f6e4ae163e412108ad5775aefe89173229efd58a0f56b411008f87e3aa307413779538057f5d846a1586920b1448b4fda27b65647b946bd5b7950a5e3e37ccca55b359b4726e26fc3d168a9e8bef56c1a61fcb2b55cca61bac0123190572c939584ffae1e913b82bbd8057f302a900d2a1a7ed1ab4a1b7c8c5cd56fc472d69d013bb897ea3d72d299da0df5fcc7a745dc
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (4 mod 64).
# DIGEST: 53658226c112b86438dd27b58a71f9e36fc73c1e
KEY: 91d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd
NONCE: 64b1fc65de39f4f03541a11be112a729
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e
AD: 0d0c302a5f47e037446f58
CT: 3eceac2e338b4dfd9f4840d77db69ed23ee286b522cd4a324b04b1865cc772914c8d84abbf0db1a3a2d15401759b18d6fb3b7020cca1e31d136fb97b26bc772baf5a363c
TAG: 1b6a98c7f9b8c5c560add0eb46d2d7559ebce0894b876f0de8ec37031df30667cc3ea54a4e71d8bcfe575d6044d9f70852fcf9a1a6756643e28944b59856ed1ce9958045eae0aa64bba55b64aac0cacded741293262550b085b4cb143d8bb8f7061eda2911c86e1afce94a8afb4db1060c2da1e9bb0ca8747d71b706134e44bb7e4b73518ca9201d610860961a53438d6efb51031a1ba0fa9b437b8a3aebc0479bace7843b319c02b4987490bed351be2eced028a2d0c97a1e30ccbd820f4b3f669e33b74c1b550a8d9782b9ec7fa45b24dcd5b6788895d6246a4cdfb015c605741047c1d2323e207a8a622e55b6a19401bb67de62154392edb28ab3cdfbb2ae2f21c3181ee8033130e95e05
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (5 mod 64).
# DIGEST: 6b7d5268b0b5037afb5be5af6a0ceb34e7656ac4
KEY: d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64
NONCE: b1fc65de39f4f03541a11be112a72933
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d
AD: 0c302a5f47e037446f5891
CT: 5cfcf9e4dbe1a74e748665bf393c6fe93807ea36556590a1f2814c2b445988c1f6c2815f6b1f0fecae452d1bb89a055bc6f85bea11d99d0b0c62db8a81e3f0f3a557c208cd
TAG: 8e73adba964c6868bb3da63b0d528a22eea8bfb4be0b1030070436f5c442649857c9c4a32759c5071d7d741692368497a978b5668b912cdfb0c404e514411ff111ea9f1224cb4a9256dc57a8a4677fe576b554cf6e4f975ac3a81eefcaa0bb68ac5bb26b1bf54bf034a50a1b3265e0baa8a900f048246c7ea825234732c3f5b34c4ddc0adc46178d0adbd9a524502061ad4c6df62dcd8f8851f270dc452be39021d5f054b7aa35f5235739894c659bc06333d0e564c38521d820dd7cb0dbb8a018543ebe7799cbd674a14821a6f92d776aed736fb4ce19ffe6ad5b456c09cc597443ae1bb41be9ea0213edfc1339636facbfdf56a8944cc548fd35fd5fa4a7b8cfbce736c6c96465326a49
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (6 mod 64).
# DIGEST: 63efe7af502231420ed5aecce9a28446b257828d
KEY: 7df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1
NONCE: fc65de39f4f03541a11be112a72933c7
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c
AD: 302a5f47e037446f5891d7
CT: b2e315ef97a1b89b4625715c61946446fe1bf27aa60e65d0ad9849f71ec53ccbee951d3628efe2795949f88795b354df0ec68b21cd699cdd0f92f31f3d6013a4c1116165b4f5
TAG: 4e9eb0387d9121ea239b27016805f35c09c90904d9becd9ce23d77233e8b68c86e17f92ac31794be17386e5fe2f40e83147a7dea38bee4b9776fb4a4da85408b80ea7718d542a47e7e5d7db38c18560dbc37d49f4fae2e013c4b89ab59f2a529b389e2ce5b2c9f0883df472fb9ac58bc5e27dc21938344195de25f1e3c015b68e6c6f6111e037010a075e78e852f9b0b8e568359ba22eddd71714403309987ed20e381b8ff67f5fd5d9e8ce77b1517da2cd4c2909f83fe70b65af0ba8dfff1e0860ccd217a19a96d94ef3cfbe1214e204d4eab8045f97aaeae0946b455e01099513c5a763596c7495de135bd2ea2b9c01e7fcc5daa0e88bcb45ce5bd044dc300a281b2bfd18f6090f7eb
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (7 mod 64).
# DIGEST: 1a555c300a1d1bd5b03cdd6bf2a678621624eb05
KEY: f660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc
NONCE: 65de39f4f03541a11be112a72933c7b5
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c30
AD: 2a5f47e037446f5891d77d
CT: 8221477092da15c94ec15f34ef2d540c87ab24236ee4d97ed3543f49f2daec059be7c0f157f2d869bae0bd4b9d214bd40ed01484c28019d6349cac27db29050831e5974b5426a9
TAG: 9f10a7816f0b558aaed826c53d63677dc443bd48fe1faf9d8e8542db0b3959d6754d0771ce1a23d67561626c7c521401c0a8882656ded33ace7965f5978bfa1c960ed9eb3831f45d28a4fb0ea44cbd9118f39eddbe3c56886bb4bd6593e13f2bf641e88adccaf76ab0356cb77654a1b27597b1b5fbbbf15b6c7673d92aa7073745721a299797b77c5b205ee44da405d634f971abf26bd7cffb21cd6f952eec7bc214d6ee0a31622c78259ba14072536751b87b968cc5e6ecb21d1b64c53f7ac24dd9344c2a03dbea3c5704bd283a8d28eb2ba5e4dc1b16a0edd6f4cb76aaf746b1a987d58ed73eb2b266a148ddbc033bd45712a3101f7b536d2d902b7e124e199442b149e3b603f199
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (8 mod 64).
# DIGEST: de9156349b578f2f44945ec6a676a67a829daea1
KEY: 60ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65
NONCE: de39f4f03541a11be112a72933c7b54e
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a
AD: 5f47e037446f5891d77df6
CT: 8a9f0d731d72929136ed9e6993cbb28013b336540f602c7203e6a38391dc07c8c3ce5b4ca62df582dea366c4b0b5aaabcf1959a7f0bc92047023c72225f5c071a588d95774f2e2c1
TAG: 84d60af507164a4f4958b6aed0525028918bba60b4affc1afea92c0ef485679506ffdf649b0d9bcefcfb8f1503b2e48937a3e732785d85b11a524363a55fc994e756148a3b7b2772881aaceee2ffeb0f18bd85feb215fc8352dc76d8ab5255d56db5e9f10c42b4a3447321d459ed20e536062a33e6cc598a61b905bcd579e6d68cbdfb94c3b100e05bc0009b9841fca15d909de6897276f9177cce5b049c45954b7cddb7610127c9dd40a61bd8e47b7a165940ef3084a0b523955741414a12d34aed68db231db939b1417069516333b2c0c57e843f098a55e375639ebd2acf658de1f385a1e29c5eb9efe14c16e29488a32bbfd127592c7c45807f2b3e8f57144b9cf60130592b62
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (9 mod 64).
# DIGEST: 12812df3aa7f3bbc899f6f248f5590e02570c292
KEY: ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de
NONCE: 39f4f03541a11be112a72933c7b54ed4
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f
AD: 47e037446f5891d77df660
CT: e3af374fb6f33c64fc2e4cc1e1b635bbe890f02359b6adb2a747beda433e003e30e1803f2169ff6abc81ff8095601cdff7aebae5fd8fc012387a70dd7db18e7eb79f87fcc1821ffdf6
TAG: 4f9730c5eeb9cb32e005afc571d2ed5b2de38670704f854c838d00584becf8583ee7e79d9609bb73abb70bd01ab228bcf6070ee1c1c97d4f6003f6a3ccb4b8af43dfb37bbeb707e1efa51b0447e6b31e82a3fecaacad99014a8d502c3db8a36665f85d62938de6ffe30c4749535bb124129caa1fa465d04c1005e64f7f4397607b4e6fc31b9c34961b7276185fc3211eda045c06a28aec0a1e0a0e2f1f6829a1ab372d0bedd711158696b062b9dcfbff4925dca71d4ad7f7c610d40bfc6e7d04f4990d6efdd059679c7137b5f5d28c9784fca307e2e1df33dfec10a242379ff30984c62c201738edd60007c9d56557692e8f73e5d0c83059d568312b3504de9691ad3d9b30a4a2
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (10 mod 64).
# DIGEST: f3c89f21c327fca4aa400fabea9e39780378e901
KEY: 82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39
NONCE: f4f03541a11be112a72933c7b54ed4fa
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47
AD: e037446f5891d77df660ed
CT: 98b22a9119610480bdfc5cb6e2a950ccac8741690574730b87fbeb113d5daac699c333ff21efd0e73d2252e95f64dd2699b940b490259cb5fd698756713c0e53ff69a733ea13587cbcb6
TAG: 63600a3d7fe8a782af7af230da63bc84dd993bcffaa5f76e5f63ef56407d0412b831dab138d117fbc081139cc49946a7631f488c11946c10530806ce7a781baa3bd072300a5cdf8aaa3b2657ea3732c1e24271c447e6d7f6a2afa0bef27aada30585c33479debc10cb72febb181c7f5f77490b339285bfbb0bf07c545ed5a0f3f183fefdc7138e330095636956328ab85a201e3cd6a2edc573d75327bdf615ffc8e6fd5e133558b831e24b67751098320e9afdfe7c7ef4598c29563113052c568263612fdc3c48d8e9a8a407bc2918ede467636dc0185d9423e9eaefef4126247012d5f1930c56dd9dd7c34d397f388e4f741953d76bb1eec911079936a8dfc584fb5b7c84e4
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (11 mod 64).
# DIGEST: e8e41988fad6c8b44c56544964cfe0a347b35b1e
KEY: 933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4
NONCE: f03541a11be112a72933c7b54ed4fad0
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e0
AD: 37446f5891d77df660ed82
CT: 8795d6c225aa78fccaaff86101641081f4a440969633ca8d7830ffb14f629fa34dc4c15e8ff20a8940c7a484ee94503372e658615eb3fc07c2d2c399ae9ad7a77d684512d0ca273f77fcfe
TAG: 534574a93db9658b653cd395e981cd4a8992e817ba058f692c5f0c1682745097ed441781afe30827bcaa29d061e2d1554a949cf7b62077b768bc1ca8679618a5d2b32c0b7e735db6a27fd762a60aa19e60a60a9edb02f20e3e99fd4653732525a0c8d8042bd3ba5387f93a7e0da483173b3abcd3ff876badd75b81741abfe2baf21be1006d1cb85bc543ddc7493f8faf4e27619686ba324cf651a16e7ffc23ae7786eb8823300a5c65982228aecde99f53d43f86d9ec0d326eb3ece9f6cf1c6bf92d1599c5f9c391e9ba189195665d3018c38207717502bb60e020773618df614bb4e0309fa0809ab215f68f0d9d46c28950d3edad6c4f71dd5af9d03dfa39ae62482601ff
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (12 mod 64).
# DIGEST: d1c7b2c04dc25fe7b742a1d659aec20e1475ee4f
KEY: 3f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f0
NONCE: 3541a11be112a72933c7b54ed4fad0be
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037
AD: 446f5891d77df660ed8293
CT: 694868cf990a1b8ef42fcb2b45cabf1bd78eee4b429c11b27a827762b9c319bc54a2b2c8eb2ac85063ef8ac7da8bc35b16c0a98822981dc9b246381780da7833eb718bc8518e2b176656ff5c
TAG: ca1dc8a003fd389a1eb1cfa4bf9746cdf45c548f8e52e0bb0dd456c1369686e0975fada75cd8fb261a01828fa1375941dcd8c718f82d6b64222dfbf7143ce980f3936b78e525c961b7d72d5d68127d0f98de541853ae36408ac489c5629c82f00a44dbdc89d665f94fb391c4a0618f31df9bcf39a07325b600265daaf53c2762396f9f6e83fb4f545aefaaeb447d4162ad401e1da2ec090d78d7b354d80fa975dcea9b897fc0f16681cd9a1aedc78cdcbf26249e18132e518b75849af55de38562ac32c50819a35156706510688f3a81e13e3bd5f61a0c2a8655c251f4732258c3cf34694be21caad599996c9a13303be173f916e90f606dfe1640bcf35e892eab6ca70f59ca019d27c58cb69b4cb3bcd484198d
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (13 mod 64).
# DIGEST: 116e20ff1e79e0af464d473b1e7c187f4dd66007
KEY: 62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f035
NONCE: 41a11be112a72933c7b54ed4fad0be90
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e03744
AD: 6f5891d77df660ed82933f
CT: f2e78e183884c99ad7f199a02d87a1026c832b9a953919a98c2487bd0d724be407994fcce9e19b5a69f15ceef5d3b95c79d5fffede18a143cdfade5c0f80254cb38e47cc9c82488116640aebe9
TAG: 11f4ab3470df6f43596f9275964c3ecc22543daebbdb99004eb6c1e001b2119ef9b247f30481117102a179a7ca72c556a029b77d0ee2167190923012aef527b8a432576f8948a7dc77ebb79fc7a9dd1d981a4bab9c00e498c09902ffb9362113f6ad3ac6c1f792fe27d3a71aa19b9f769f2417ada3d303e3fd2600484c9f6b43e4ad834e60ce4d4885088087a96eb52ad989a9e9a43aa53a78e513743a8f08cb472a144af5a6abc17f217715e074aa470ba71d2b1b75e4ff3f597c4d1993412d37f94989c1df016f72b26c8d58d78a8a3295108e9bc061facdbc4c708a1d7e7c95bb8e365d4e933c0e519d08abef948abb67c5a3ebe938b91613ae9bcb6079436af3acbbdfacf77e8b935686d4ef7ed47b5b10
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (14 mod 64).
# DIGEST: c081d0d09b2c9eb39a372ef4a7b0246a0956b0f9
KEY: be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541
NONCE: a11be112a72933c7b54ed4fad0be905d
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f
AD: 5891d77df660ed82933f62
CT: c7de96bb45663dfe6da2a64ffc9ddfa7c3dc63077079bd4bc2ce52fea89924a75664782a5026fb5a099ec460eb9c6d7c3d5ea383092c8f4c67a70fc499a7689bfc27df4da7c185d573e6f8d70cc6
TAG: 1d6cf11ee4afa8efb4e025dc32e0c73a6fcda2aa5c892031c7fde0d0d69e38e9e64e88a714184fbe73ca0f1dfd35ba3b0378a474cb4aaeb942a529cd199e20b7dd62654b97d92dc317975d5e26ca1378d41799a127c44a157982dc3677a4dd391e22b6906d303c2c60cde6052ffbdbe5f8bce22bc2ee42975f9892b68f228cb1f584b1a3fb2f15cb7bcf3d9650e72e796c46f7738986be7f7c30dc56c179299c9c368090f68b96735673f2279366122e5cd94d8d4ca2cbeddc3502d833bb365756cd511577a7499c199f403ce114ae47aabd351bd27e4595e3955e1d1c617a3d0ca2d6e4a2bc3275f5ef706fc4e02e48719958d37d172ad1473878686fca9420dafc83e0baaa9aefb1e50c98d6006ead6bd7
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (15 mod 64).
# DIGEST: 6f7bb1f9e2772eb909c315e653e4737cfed78a18
KEY: 8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a1
NONCE: 1be112a72933c7b54ed4fad0be905d41
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f58
AD: 91d77df660ed82933f62be
CT: 3a77c0f70f9044fb3817d57be4f4e5ee4b27ffa586327f77c18346f9fef2608a552b551ac549f9e8d47c4959196162862fe2a35e44581971c2974d4a65a47ae719a7f5f070ad902b8a9e022abcf303
TAG: 825fc7dd84de7f3bcc941d0234090a9409e47dda077e0f3fd000965bde1d4ff30e15b23affe14d94515629f8c018d085f41aa3ebfd0498f621593d57aaec4bdd0e22df21668451b098429967c8eb8789f92a5578d177e5d2e326fc14fff272eb90368d56a777849cc5a1d54c6a458d32c26f4cf99e0f80c91e6df29aa53edb03df176b9873f5827686faf26dbb038813a8170f59e3ad85ad698308748d112b7fbca45156a4410cf32fb34fbbf27b66dddc0680f2bcd7cac6b8cefa83945fad84f77a396630029e6bfe9f15cbf5a884332de5ea7f558d783858c18761983080c13f9c06be367ad856cf159656ad140e84d6af4b4c3517b90f5ec0a8e6fe18d42ce3d194f695f9b7440d4118b8170705b766
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (16 mod 64).
# DIGEST: 172f4992e692a88f49628e5d3937959be01aed2e
KEY: c55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11b
NONCE: e112a72933c7b54ed4fad0be905d4120
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891
AD: d77df660ed82933f62be8d
CT: f2f3a3d985eb38c406bb0db0d141188c680656db8a4484abad2c8973267e14458e2be7cb52f06ee2a0f68eaced13db714296319b2b3557454f5e9cb47e8943ea3e66f7bd25c5757375be7bdd65fef53b
TAG: 2c441fd3259628cab417df36374ededb37b9775c0ddff861a5b957a9237265000be0857b3b8482ccc5a348dbb9f4529da4baca8a8820468b1219fe4680221bad9a527d93ca499a988411021e0f9cbfbacc7851c63cc1886e934238d9b7f9cb6b330ad00da830b34c7e4398d148af7599a87770102622e7a68828dece16d4255bb319c75ab0046defe72269fe67780b34324eb3d57effa216411caea5661e64d8151707ffa86752c876590ec46926b7e963ced6a7fa95b1bd958e618bdf1775a9b3ff18c91ed490f39cffe0ab03bb5006cd321d8e6bbdb19597ad7692eb7a7685e075de1d383089f46c8a4bf1aa948bf08b89fde28696147c767f5fdf2aee8b8d4af2903452fc5876aa226d490140a55e
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (17 mod 64).
# DIGEST: 00133da1f7c63fd5f0eec364e9a359be02c1d3da
KEY: 5b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be1
NONCE: 12a72933c7b54ed4fad0be905d41203f
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d7
AD: 7df660ed82933f62be8dc5
CT: 02fd26e7b51a1bc6ab6735045d2e42fdd1f31adba98ed5f8b3e89450853104633abf6cbb70ecfba2f5b39dc06f419746abae4a51d33829bb04140275021d183ba079d58c37d4147e8114bc2e3d1542b0be
TAG: 4bc0c3d3487bb74931c27253f0f0931d15a627ad88ac1ba563d97bcec53524870d8fefd1300feae23772902058f5f4a0c1c67eb5e4ca9d4f98692398a9019c3263d2191361b73038e3c9252502ca72070f1155952b3a0c787508d7c0c96e02036b2a26513fc69b19f1c51629fd7bdf015c0c45da5de1d6899f3cc3bdaea7a3d7bf1d0e8a8430fdd7ec70f93d7bb62fab821c1f0e9ad564d04081a3fb70b43b5ffd990e53938cd34084411c0c11db13bf2e28c6fa299c720f3f68ad751c20f6d12ce79382a1d0c4bf3a6bd3a695b3040193eab3c73aa4ee751447a5a46845c86e22909cebcbfc8b653f352072aad19b725dae4cf4d1c8bfe55605f0eec27682a6a365cf2e3e94ff769c2aeb328fbe6f
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (18 mod 64).
# DIGEST: 60a6821269be6c5b985576b245f106128eb0b325
KEY: 436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112
NONCE: a72933c7b54ed4fad0be905d41203f5d
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77d
AD: f660ed82933f62be8dc55b
CT: b2fe392acc286bdc73cac1aee34ecb3a3e3ae2ccdb065618e3c4a17f2b2668a2c11108b0bf8a8ffe20800a698e73c9b6ed4b0da61bf6fc22c33c75439445061e198f018f271a8698d87185b7df77daf9e757
TAG: 7a3dcda8c73da41cca4a85a9bb5226d8a94f2a39abaad492ee978b6051961be1f0023b673348fa17eb29430a340b3597c6aca9304be30abc5129bd65073aec837e55fe06c7787f4272e75c32b3f1777451e17853f4a4696cedbeabb57170f77efe9db657572035af08cbde5432478dc339147d433457d3a15f8820515a6f267dcd14cd9489352e1561414e3e1e0a85129976c24dd016d4621af0058ef4e19fe4bdfdbbec370fed7ef641434eb629fbb16fbcdd117e9b84ccf7ada8324f9815e4aa42c12d4f0609060545997afd4e6786a0457b0b2fc73ff7856adb51223d2408ce4c414ef2afe52a3bb67be43997898ba846045e96a27acf3f1bec0b755e424f57c69774cc13ada5227c7642f563
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (19 mod 64).
# DIGEST: e2593f3b6741a9ed9fa188fc06efd057556ee624
KEY: 6965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a7
NONCE: 2933c7b54ed4fad0be905d41203f5dce
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df6
AD: 60ed82933f62be8dc55b43
CT: 8780167385b8856be346b71b042332368067d5d9420b3793fe94bc1ba92991756523c7a8e0114af8fa7296ffef8fae01796b47edea43bdcaa8832a08e823c45c1ccfaf1190cc7fc73a67decbdf407c72740a7d
TAG: 974451fd4d9d6d1f88be4404869b435b4b687a1150b31a0671c93f52f76f2e4dd71bf4a3583f68ea5fa4a0dbf8c779f83e8dca1882e9bfca3e914e77ccbf40ac94769c44f9a8bcbc35a4f9920c6860078d369f57b407d353e8022263061bc974df29fa7c862f3d06213b1190cdd3e2091b2e26532356560efc3b21a499f4841869c993272b70f153985d45756a0b3250a1b91ee3f25a6afbc202f3ef81dc607068fc7214e69255342e662c64ffd8acbe86992ad20ce376d92ee0bfbee6a72a1f83f470d0bbf6ec22b364e842b84736d3923de92c488c102344fef6f78624989460a2c45fadec2a7bf722e2e6a34162363cc04720a50f0d309f64f9322a11b642b97f023cb82a521af6b1759d37
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (20 mod 64).
# DIGEST: 17450a437efe239e1858ac4062f34024305372be
KEY: 65aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a729
NONCE: 33c7b54ed4fad0be905d41203f5dce99
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660
AD: ed82933f62be8dc55b4369
CT: 2cd2031084f8742da110ab5d8f7290828857c867b38427c3f53be0dbe2cc94527d2f0aee90a38dee77c0ce115ef650b2ae65094e99ac9bf6da89e5440c1bb4f8ccd163427bb95b3ccd629e6881107d6c9a80cc37
TAG: 026560a6675920dfb199359bea1a03ef0d7d67d359bb6b94074eef54047e92a0940f8eb5d08aea137b7caa73904b66a8c99775e0d859e4c91d68dfab271a9401fb650a9afb83ec4b42b97a74db1908fdca0a06603cde524524ecb3bfa15a96b6e250edb83e7c59385357c075bf077ada33489dae99c2e5d5f17cdab9d23dfae4171e564bb91e3e78d61dc7f1712c2a4431e9451cc1f58df004d04ec50f77a2681969ed91e07df4ec90fd185ede409a5387538b115107a1fe22bb999082d4341ff5a6ae7af33cb27a64eff64492a08eae3c18e5914971e514f55e65ca93a8a19d7d4c2f3df76232cbac674c480e9f4316a8df7ed9d62f8144338249732dc1c3dfcc8647804c13a03a59eab926
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (21 mod 64).
# DIGEST: a35fc7d25f90dd9cbd35910d5532aca8aba88b29
KEY: aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933
NONCE: c7b54ed4fad0be905d41203f5dce998f
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed
AD: 82933f62be8dc55b436965
CT: cea9c7528706d506d75cf085c8475c081ee8c6145ca11610b73eb3e103a706faa66062f8edc10abaa7c3edb3fcaf43c202c4812e768fececaa04564414f45816fa5c0df5b7518ea3859be75c4567565358293e9232
TAG: 32de5af09080604ec6b6fc5a0a542837a54131fc87b1825666e5d56f09e15b76d47fd8086dab709567aacc3e59d395656ffadab861ba9a0e1c1b30321ce334b68724877ec6806245bdab9bc0f8e5af6582fe91a2ad95f7a6bd0ad1df9f9c2d2c20f78f2fb0bd2653fc8e8fefc9255541d789a0059820b30902c3e4344b68d4603b3fb8f5001df91fc9383dcfe76f219933078c602fe2813b9e59e8f996f8943c96c10f27d02f5bae69789870a61abb6c3b118f6cc348188495798b07424a750556a8d1e444b47283b096b9cd8b98b790445ba8ad8245a040a3cc96c2d72aba1474f949dc607c386c7cbbda952651f6d3260c82e5a06c517a89c5dfbefa069136e3c094ee1af26fc4c77e21
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (22 mod 64).
# DIGEST: 73eff0f03358879f900b6ebd515f0f4e5a6929e4
KEY: be477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7
NONCE: b54ed4fad0be905d41203f5dce998f8f
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82
AD: 933f62be8dc55b436965aa
CT: e967973079db00d2257d84817ff4c5faaf98024ac7eb71d22af3cbb92a001a558f5cce2e8c293d6dc2a968f69cb2731bf65954affbfdef4085123aa06baf0d80edd8d04ad4b1d48120f0db0df02ca13708f66a567ed0
TAG: b8f6b6618dc8b59b07566c1aecf97a9933b6546fd8882d14cf75b2065f17518722b5fd77f9449cdf4feb87e7943f9d48b56ab891514f608767f1711314974b020804b7227326185bcdd338e3a9df31f6c3a0190b25d02dab04ce23fab918d6176814877ffba65e410bab2ae256d4f5f937458d24a144f3c45f6fb27e9f95490e95eac4575d49d7dec6f72ebdf3efd9dc6c83ead51652223b18963651b8d957b7aa050b022e4beac68f928de0d1094dc756d8e1d2b89a1bcac0d3d40f0f71e67b166a6a56d8ea91df5c930566640be524f187be2065127cd15b2417f7d80b6a8cf781e0e90c6ef61cbc902e935ffd2dc9e84c4170fadb6f76b15d77c72b49b8aa30ad1efabef37d55b4bb
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (23 mod 64).
# DIGEST: dd6cea270655225cb4f4231f54c19eaaa146eac5
KEY: 477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b5
NONCE: 4ed4fad0be905d41203f5dce998f8fb2
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed8293
AD: 3f62be8dc55b436965aabe
CT: df01c1a140da0e422919c0d34b231fa3cd767766fb35f8d78d715c44b9003e42cca112fa1543d74ac05e00da9b5740c03b5c4d1e558ceb8629adf3adb1771e6edd5b986094f724e675682e65af15bb3c0feeed8cb3407a
TAG: 25a40fa2eda366cc951e8965249500a657316c33538f874f861753eb038dc5cce0425824f138abde55bade8b0500af1f61b8ea69d4bd68de3fc403021c2224635535bc83dcbb429a8ea6c0ca2687a34e02d1dc45e7bebafd26b4814c0766e7fce5238767280ce0424a3f16a30b943622b8c1abe4eb6c279333e9d8f7bc32afb915bc5b0328147b57d02d68584afd85107302e3c84983cff39256313c4462b693c256edbbedadc50a52cd2a3c8255c1c34ba87a70cb652d74d8375ede59a57514bf5bc50532acc8be4b438daaa2d7d2caae6c291ea2c78e27766b6e2afa2551f3287a6a2a4bf747a1706cd66fd724fbe0e7e81197b1ac612c05cde5a62fa0d5c43d01e6300c7066057e
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (24 mod 64).
# DIGEST: 34dd9bf0ce19eff890ecad474388779f63b0af70
KEY: 7e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54e
NONCE: d4fad0be905d41203f5dce998f8fb2ea
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f
AD: 62be8dc55b436965aabe47
CT: 889ed4c7bd5455821c5b95a67a277a197140816784e820ad8e126b3d3f0ddaca73e3eede78c1c1d3ff5c2a98c0cadd644393b7e3c2273aea2be1c6fd20374b71edbed5658237d819b5e4e206698c8cc8c12e017196776bbd
TAG: 57da1b6d2a9717b7f6f37f21dd9c686414ecd07bc24619b9d35c62c3548586bf726bdd33fcbbf64686556d1ece930f37c6f4c8bc1931a10c50269cc1dcd95bed9d9edb0463a266e6e51d2d90fa9c1a1a4dec6d21663df4f4b99060b37441cdc09386eb785b7cb0183df692d7846483998269e36d06bc7e3a010ebc798c83a5de0c4d6201f2b5b7187a7d99d109741a19e267cbe458063aa1ee66c7c2e0449549d03a9cac20d356c393de63d466ac3e04d63b88c26768f0b3fb18564acb1515ce4be0829aa99cb293adb9a0d3dde529827abeae270611c35277a4b373fb099cfc86a99483063014ec189429a243438447c9cd47a333b22e2c1c84845b79e23a661d411570c510f42c
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (25 mod 64).
# DIGEST: 7db8cfbd3b29f96d752346eeda3c2bb0bd070099
KEY: 0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4
NONCE: fad0be905d41203f5dce998f8fb2eaad
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62
AD: be8dc55b436965aabe477e
CT: 13833f78c9383bb4455972d6e7d8f22597e65de7dd01afa28fd99f9734366c522bcaef59c41487d84b3f84c1e0b7e5ff6de84206f54d5ae80ce80fe3cb68ea4edcd15897fd6fabe2a19904010538005668f2b05245e28bc0eb
TAG: a76458445b8ba4572e8aed335eeb6ef8126ccaebe8b4be3f799e1def09f8a81fddc2ddde86e2d011c4b61eb16bb74cc5a2c7e1b6d0107f6b749b93fe9f6589bf4ea2444cb63f5bdd3b65827fff3adf32044621aa164160ac4662506b42b0b13ac148e09abc016102ccc988362f5cf64b969fc056e3f302a830f9a0b7f3789bac1c940d5cd7e2dd61aa3c6b970c3d066504093d658fb5f9ac7fb22ce306f5a9d495ca7e29d02bb39123b5387c43ed9fa1b8a061a339ced5a9393b7dc6401921d0fe424c1f168451286961f8ac199c3f8f8d4b154c89d290a27cc53695e082bbec8a338ee09826555a3fba8fa4bdb663ba932db800df0a1b570450f33f936cb71622854b84b260c9
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (26 mod 64).
# DIGEST: 4abaa8453e8cfdefd918571a961d8351754ad5b4
KEY: dd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fa
NONCE: d0be905d41203f5dce998f8fb2eaad40
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be
AD: 8dc55b436965aabe477e0c
CT: 03065bb245ba12ab90903bc081198fdfe45d7d3c6fa3b1f76bde831917376ec2a5b2ac2cf629de6bd3f23025b678ea9cc3bd7801f5510b58432a8bc17999304fec4de7ab9ac22d75897cac67ed57e30d4745588b36695dd005c5
TAG: 92877bfb09987df366759a1776b758dd9943472b933d5720e4d199002d4f3ffdd527c2cdb16993da7aec2ee53a24f6681c22fdb9f9f69a89704b6356441c6e87930b2ddc47bdc1fa0df00f7490c16e18a095b53288042525f60f0f37be0036f9a7dfa37ed3977456b3d8c4c4b2c47879a4495bbfd6a512fb59a40b20bce316ecc559aa825b4be8dbbc5dbe06fdd074c1f2132e954fb74fc97075e9c5052a0f86bb431f7fd99d62080140e0457f8b5deadb9b2528e61731488f25f0574283a1b30c80b2bfafcf0e4343ceb83dd20d2179a38866780025516e5f8216ab70c158ddfd0ad7a446969cc9f6eaf5c984ce8e9c38fd3b8a007a1c154bb4330fbee4329b8335f4ec4b23
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (27 mod 64).
# DIGEST: 0fb9d7ffcc7c9b84f34661d472ae2d4fa25d3d99
KEY: 46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0
NONCE: be905d41203f5dce998f8fb2eaad409a
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8d
AD: c55b436965aabe477e0cdd
CT: 04c76011b9c4cc8ff18038d36a8c8b91debc8d0929ec173cfa5450f434308234e6a368f17a04ec0556dcf5ace0efb5ab51956d0daec5c530129aaa78309c3d0a04af17d02b0f91f70a82b2ea03522659f76d1919731ca52747da3d
TAG: bb70d9741043c7d3d9a3c5f7d2dc1517a91729b54dc8f49291e2201331a24fb24ad212398617237c77de3d6266fd32341893a9c8bb42e60123bf3bd4fd70a065d6f3d0ae98434d8cda789be46a5e5ad05033d18cdadb36e33fca58181909dbd3cc1733dfb4b6dba689a66f19bbadd35f830d6af1edcbedca45b2810cc82ce83d39ef9d6d17aefec9b7199575e8d08df3ecb9a407b41a9c1d851e923072c96c5ffc60d3987ad10f27aab7792a198a17c8bf88c586ab11cee5008ee7ea769c56ff8d644b51059b9b2ddcfaa92d3b3055a4b3921bf95c5c131c2485d869f642cd14cd4eb9b73740534f6c48c63f76c6f1e4dfcdd9dc3c07593ee6032a98aa10e1b7f095c505d2
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (28 mod 64).
# DIGEST: c68fec315401703e49722fe4b39cf28b14e9f50c
KEY: be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be
NONCE: 905d41203f5dce998f8fb2eaad409ae0
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc5
AD: 5b436965aabe477e0cdd46
CT: 5d9af50991ea21f041a766d8d9036073eeb0ac083b8069619ee50c64c661bad73a9e2ca7f8b49ad9df79e47b49ca3c8ea9dc254854f116a49959c91481ba96463521bfdb74902a4b454d2c6af72d130175c33e8764b64bc93955f9f3
TAG: c3ccb45d8e69eccdb1f058a490d8de92f255953c16f27e21b49e4f29639452ff846aa45394972d895a0fcde901fee45211e835f6e4152de7475075e1e7ed832d45e0407eac1c6a0c88de4a9fb44d961b3be197e45af38a88d1070416c419046f6e43496e6fc1750de734c7773bba9b402dc96683d624117249f3d3f3d87f83a140018afde34dd5980e86e157d632acb7fa5400dd272fe74abe46652eab999b9ac1cb65a4a609f3bf9cf3c8434f9eca0bd440d665e772629c0cc76e0d9009e47f5667c0a0846ebbb1c1b23523262d3225bc23e3513ebed8f67c721cc0886efb251b374ee4e79f60c6fc7bfb81ad9ac88c0a782d3c4bb918cd21ca1f3b8e311f5e48b9e6d738ade59dafd07ca721aed0f6f7f98f1b
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (29 mod 64).
# DIGEST: 15e1aa5285beab679aaedbf51a86b4aebbe3d7df
KEY: 99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be90
NONCE: 5d41203f5dce998f8fb2eaad409ae021
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b
AD: 436965aabe477e0cdd46be
CT: 182dc2f9f412f305a8fa4813e8c8eb7a41f9708efb516fe3feaa6ae94c89b4437cbdba7c738fb97ef9739ed94d988bd60af5359194d2b5f8a48e3f5482c3be294ae65ce803e21acdee157d436188980be8e58c95a7a5a33e427473d4ba
TAG: 2751722d2433b908076080c82895c633135bed9c7486d2fec286ea11b279b5029784972d39c8732cb1631841a60e86ad8b17c41e9c0b54ea3dba7b15121532b7d7a7fe8f92e2280481c73590cc38bbec7888932be3d10ab251157ed0335ea1b06a379c4d19d7d860bba5164da684c9d0eeb20e65c0c63a60bf94f65fa4e0f61bb94786271d5ca588093446fd563a6d513d81d590244807ce399f4bbee2f09cd8145634c1ebf06bb408489fa362b06af21a934b1114dd8233c8cb629df7fc5ac619fe2701de7daf7d7295049e1909fda9864fd7cd088316be8dc7770237748de45c3dde6d476d233983392e1a3a96f9c6550d5a7df61e3818492806db44121c277df71b9e1e176e335a68f2811637a9ce17919d
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (30 mod 64).
# DIGEST: 8cc0b1164fc844e958e055b7ae43f2f95c29e8c3
KEY: 371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d
NONCE: 41203f5dce998f8fb2eaad409ae02116
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b43
AD: 6965aabe477e0cdd46be99
CT: 0990f57d9a7e9b64bcee741e158eb5749e9d7b34d43c6429754689d87fc45daaa618fc62d3dc111e5a1a7a06b2b14c5b0f3e2e463085e80da6ce4a6f7815cbf871376c8c87a36555b8a74e0a14421e1e4d74f7531546369ca81e4585f86b
TAG: 4e2e000dd4c6c0eac8aeb581fd352c8c8d4033ea944594afdaa87f05ae6be756e46cf27b7ee6eb01e9f4eb50918d2b438fc0d1eaaf7c6add8078a6a9d45be1e813c18b20eef740c85df67de7765974544f5482f9a0012192f3d84b2cf6c01141f6a8040158cf9ba03c5a1b580cfddf0a682955713a4cac6e0d3b6e273db3a91a1b8096f85fbc3c7a67e893885bae3b4c65d03d111da7e199780de379c6ee07a3657ecee397ce0c9d34ee5d39e8fc4a64c86a0d68182ea48b91c76f63011d0f0cdeaba4e1ff6a19686c5223a25a10af0fce79437322c0cab4786fdb4b93e687a1c7154bd294d784169b1bc7cc5c9f3b8bc3e1d8b808b448f926ce8731ab30a33cef85f57053ef081a8948178030a50c247e53
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (31 mod 64).
# DIGEST: b51001b6ff9d27bccf3103a4961280e0a1406257
KEY: 1eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41
NONCE: 203f5dce998f8fb2eaad409ae0211641
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b4369
AD: 65aabe477e0cdd46be9937
CT: 8d7999ec7a80e528bd6a8d2a9724930c93ee5cbb0c888d9b7c79d2449e638c03f3143f1927a1b261d66ff55bdeb7ff6616da99a2155f465d7c91f54963e7cbda7b61529381204ba43c9681260799ce66fec9b0e9882fc0ab474fd9134adb66
TAG: e9012cda52183ec3e658c42f819dd986216e84e14eb38a462e3db010070a3056db6b148863afa9af5849e3ae963730f02bcc2b419f9cb37659609dc730008a43c41e87312b546d3b67e1f092001bd8a1b81ea304126801f149b0a37d826e0fac21045be4087f76e3c44a796bb55b6e4565d44cba7a8a48d4ffad797982256e87b95f6599b53f2ad34299d90204acc139d115b66c78a2072c741c43c81bab9dace2c0088b2a5dacd917e75ff0de07ab5febad79eb5e0d03012503110bc0f62e2aedda35c9bed4b7c2131f96a4d0c9ca4d133ee032a787e499c92cd46b33e5bfb7f1d3de52db0c7e2a15232a7c3c064c90bcd23366bf982bfbd9694e92b709a86afa4c4a6eb8d5e9b48a20ef409acec78a8c
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (32 mod 64).
# DIGEST: aceed075f31ab159f6610f43ff0a6ed3a359bee1
KEY: b8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d4120
NONCE: 3f5dce998f8fb2eaad409ae02116417d
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965
AD: aabe477e0cdd46be99371e
CT: c3e61ff897b490847e6539236d2e3b208baca2e83347b7ea2ac714f65a409638e59a5dce5c3a4109e6d6cdb8a232f5f8a2577101f9fb53aa50918f924c1a5361ef98d6672258b4adb37ca5f30d22893dbde262fa9cf72d2913c1901d70a0b7c1
TAG: a49c692364eda34c22ad3745a4339244b687f596bda16d4ff61c6697996214bffc78fe54bb30321d37f17a7ee146dd33771b9b922b475ed41e55de39f1573683e4c8147a9bc370d6f75882c991073181d3f5eaf31a9cfe0dd205540cf6a2b6c0898b3d1ebe351c7e036e136088fe88a07e2c512fd488dd5dfbaebe10e6627bebb2cccf1e9c985ec9f1924abd91d29f0862403c24496ba6c0535358de379a60adb764fe00f5e09f3487b075713a85452ebc21205279815653b39af6c7d84cb1a10178006c1b4ee3e53028c09ef59817abc2335fa2ee7a56ea18e2cbe533b7d30c80609151b58b3c711314b35d3be3df1cb6d5cddffc316a940cc78ba1734da1c09d1d05c2650ce3a0fbd60bedfef7a83f
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (33 mod 64).
# DIGEST: 976ca4c9819e25a204a024d05fbe7420f717bc58
KEY: da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f
NONCE: 5dce998f8fb2eaad409ae02116417dae
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aa
AD: be477e0cdd46be99371eb8
CT: 1944f256989b6acd7dc7c334d10ce71d9f2980cdb6adb03784061096955a3e10efe7cbf1c0aa1caab97cdeee4d08a8ff34d68e1b53a0df58e79a4c1d5d9b7eadb2430c0b8049b6c43a848fbc5e5feaf16c5ae08da38f973b18e33fde747702b882
TAG: 6e0c7a079e170b669fd211bd54c2cd2c51bdd5dc84c84e0da6104dd1d5f6e8b27847a4def48c030c515b680a5db67439f300d184d2c8fe18681c7fa25840b80f53ff494fab5e1694a604c1c12b3b113aeff88bc2c5bd31e84cf5474d6429b4cd08241e94a7f4276054fed2f2a0d863eac2671c9af96045447d6422b8789c4674feb8fb27098b5ef613f08573184271899f735af845e6b7ed9dafd4524247178415479fd60da081ae076331df7ea141df29a086b76bbe35dfd4f983e45b2f1316cc27d88c48b87d2934833eeb5bde5df0866e4a9d8894fc275d6677eda6ac6b41a0475aeb9a55ce7d7a04820b581e8565c9d9919685bdf0f163d77ac45a15e4717e2e716e49ddd079f18295bc7a05e7
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (34 mod 64).
# DIGEST: ad8cfe7556704bb1974e94f70d8743d147c5c3b4
KEY: 7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5d
NONCE: ce998f8fb2eaad409ae02116417dae0c
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe
AD: 477e0cdd46be99371eb8da
CT: a850ddac6117f7b13e15c17621fc7c99f2276ed7337cde87ada287814150f8b3f3e8ba7108a1237fa6a9ddcebb07c234660ec93b8279bb4614be85c5973603568e885f5f8ea102d0621b5ba77fc58af4285c15996d6868c520f3e09ec5b6a468cc82
TAG: bce897e6a5dfbd940ec2c477af3411901f0f2fa9436ff3b4da7354189f097d231b95741788b45e9a56e7ca7a41b265489578bfe8667b1cd64a2ddd765144e770ae13fc2e9ad24575bfb97e0e012869ebfb52a9c7e181e79bc260442d166550435dd5c08b131ed3850f78a2e1df8a1ed026d9310a83f0b8449cf2baec42d7d7e31c4ec56d9d25246b34a479ecf8ab850c65fe8b2a6361fd185c25d6f253f556aa46825c535a4a54b855148e032d3e1ecb8d501802db1eac194a4bf7f3c70f8b8c33cd88d3362476e2080cbb4482fd9453ead6dc62a0dbc0649e41a699c53427ea8ff93fc9f2353356f695642ce7db49fffca401e9c275365dd0a339e3970d5810c5667c234986a65e1ce01e827e27
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (35 mod 64).
# DIGEST: 1dfd9608adabb5a55e12949f1c4bfcd5a77cb703
KEY: ac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce
NONCE: 998f8fb2eaad409ae02116417dae0cef
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe47
AD: 7e0cdd46be99371eb8da7d
CT: 0cc80c78b73b1bd898c6af38846d32837ed0712ab7cc48b01c6dd831f37237ca7634c90aba35b35da59b60aff8e6b9a622f5a481c98c03fc76c1375e4602e96c08a465f3085ec86b0a8e1ce8757df761400be6510f1cdff60b05bd46271650b9e5d5e4
TAG: 34a24675223b1e1d363b941da5d1566dc42a61c7c239a6684a497e7ef90a78d29c1aba0a9be91a8cc8a7cd578c77e62db1234da2b913e9500cf81df22cf481ee43f0818be959ec7fe49aeb7be270d227f633f65a003b19060ffe8bdfaaacd2c20ac65b43254252fb2fa8d2264f5664f3fdfaaefe7216c3f8bc6957656d218d5f98f5b377fd675a21d16769c499b82d4fa54be52ef8c96222b83fbe5bd3b456c9d181cfb5ce23639749e9e22dbc3979f07910b83c200c82a3dd449e5ae47486bd7f2cdc26c3beea2d3c490a801bf587e323725be1a76c32396e5c5ea24a9933706260d5aa16c847e00bdc5d96b0b96652a2c73e6141367debc228af6f944bcfd65a9269a7fb8c912c25ae2a6e8c
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (36 mod 64).
# DIGEST: ad2b43eee27e6267d8c5c1c3d558a07dcd6b1f5f
KEY: 997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce99
NONCE: 8f8fb2eaad409ae02116417dae0cef45
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e
AD: 0cdd46be99371eb8da7dac
CT: ad918e7428ca106cf043d6626772cd45ce998f32fea28c3253fd58f0fcc191bb4cd250b5dc6a7b352bb2aaa66601e280576fa60ad8c3aa58742462955fd7f33ddbbb5036128617c1fc3bfdf83100dfdd069042ad1887c2821afbcf822756226c69779d88
TAG: edae83839ae4bcbcf7da661a302815b024d7576e65ecb70c183411003b1d6c769a13de3444f82c7783ff5593d9983b369833cab8dfc80120e35bc86d3b00c307338163bd5de5863a1f2daee49b4f535ce455b131eba334b7c995dc25640833c6c0a7bac710ce37ae2b85e58179b57218e801c4a7e5dc19cb3c841c11c299a72efd9cdf249e9c4423cfff588895e38e5b2d166344ba53b083da555ae4a1e0278f5b7a557e9aec08ac70da44858306df69ad968c017f8b4c24a0b562be19e1f6416841387ee3cd9c8f7c8b3dd1fecff0609fc77c4d86fb1e387cd1932775e58b928f4022821c0b9dfc43912fe0d0755b2bc2f88682f6b11eaffb6caaab1e295755d1256810ce16d70b306ffd6e
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (37 mod 64).
# DIGEST: 3dcddb1e4f49633e7b7bd36f4056d16c53be7f5e
KEY: 7deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f
NONCE: 8fb2eaad409ae02116417dae0cef457b
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0c
AD: dd46be99371eb8da7dac99
CT: 8ef4db8a8444ddd056428a25b718aec0258fe05b5fe8d6d972ca6762875c030fa2b4822cf03e797a53046749e39646c8c6b373a1d77287f4124c19ef758eef75db8e4e03309b3d14e918bfd9499ae5c9e2f3079ab7da8ca7f00ab69d14ad96fdba1c58b813
TAG: b78d95ae68ef1121b27bf93eb67605bbcbfce1e0293fa37e0de4a959cc0a1a47a374f6727edfa9aa5a330e5c3df90a30d371304258624e8015a2fe7583e362f045087ac9ff6bfdb5371d9fc9d55f7dd91bf0310450c36d33538ad5f6057d0c8a0896217643c4f95ed6c93ec95dc6df838cd43d6f60dc3d48d489922dcb1fadc586dbbef4200a6b1d67d2024493fb4dfdaae7563edb5ae93fa2065d750a10919484fbb1389f93d2f28b62c8c6708122e0abe0ed22ddba815da8bd80393fe274f545e463dfc5f26bdc207f3f056263e799b3c89f9c740748a37b7f28cdfdbd9bc89155e466e9a1830dd6d0a206d27a588c56c3b6dc92d5202dd30ec0a2e1e31a0da1a5ddd9d905204f47cc25
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (38 mod 64).
# DIGEST: 25b982a242f669c013cab1c18da425330090e3cd
KEY: eafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8f
NONCE: b2eaad409ae02116417dae0cef457b9e
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd
AD: 46be99371eb8da7dac997d
CT: c107710a85a49250f3a4401fdf07a44f96560ca5e71d6021075b7b6e3ff8fd6f36c652f186dc82c8a21a8a743dcc007e6710214320cb5c5e788f8c5b020e4d0d89ec2fb780c9ea915966b9f9b1e2cb0f26fb6bf1aba6e6501f2571ef1299918d4d2e6b367e22
TAG: 3e7739cc9f98881f03a99d95250d460497e445cb24b4f8783c0010070484f8f379d74903d9a99f6a621791763af4e8e94ea305642643103b2dc0a0c1342f66154a0b4c4cac63e79d7121a2a44991273a9e1111208b3d9a5b6d11a6a28c83d16c9099d0a0247bf4670717ef0e8e6bd4e48c893ae189cab4f916862a8ebdfc0cb26cc545a9a08f01f8b4ce545914a35924f728c4e914b8cea6588116e9ebf592d4709e0c4efc8f0f8379fb30e35e36bfd68946ada030e35af5ed510a6061471659dd6780c1356c3dee7f69ab449a402456b63abd7e7763b4020db5216f099ef78a2125b42fe508cf94976b8e4e9ed65b38c254818e6aed084c037efabad7bd348e4e16099c7709cfd9116b
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (39 mod 64).
# DIGEST: 9d7958e23777ff2472f5a24dea5fc19c151dd921
KEY: fd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2
NONCE: eaad409ae02116417dae0cef457b9e5e
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46
AD: be99371eb8da7dac997dea
CT: f90604401a507574dcfe5d7c5e0c36c5fa65d9a8f0a25daaa9fe5c50ffb3758f52c9c883c2f85d879f26845a130044d395b58497979cf24a9e18ee1f27d1eac4d0cd994a6338c5755c74419111b2bebed645c3d8b8071a7b5304eab2c33777eda01ce489f4a6d2
TAG: 8a94c9c05afa552672247d156dfc8d60e9e3e1e9eaee6e58c8fd6c1f9d41bff32571526cf035ef595cb5c5b2d64b2a98bfcadebe5ff66a6a2299af8e00fa27e621217c5ee1542a86ddaf93e293d01f20ba5f9093c1fb7a1b911e659027beceb9518f59d20cc54f958945dd44ec38f73fd475647a008de974e50facab9e6e878e3968249a91b4f71f4f86486d5e3bc2abd6dcc67989f58521ee78214dbd29bb7aca0f601842b1d36833748069e409c58de54f7f6e6f17b9e05127568a1566e70254589675f2802c153bd5106afa59e00ac753fb9c3f67508deb5bcb4e25d47e52852acceabb8e5e955e16c0b4448cd313c73ee2195f185f8869165de7f30a68efcfba1adab85e2eb975
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (40 mod 64).
# DIGEST: 09e9eab51bcb9faaa3bc3e473ff66b06e39653fa
KEY: 64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2ea
NONCE: ad409ae02116417dae0cef457b9e5e16
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be
AD: 99371eb8da7dac997deafd
CT: ff258ef9f318036586c5ec9e956c10c9423ad3a8a5468527c02bda6878c45398b0c78f3fba4eba3785282b3aa4586d31b238fb941546bdd6e3d918444d45f79b2a5ce3df0e8769a952243cce1f17f736d21e44d8d49449e017e9aa5ea20863a2f6b2f7025de029e1
TAG: c113b619c1829f799e045047dc1587c35eea2e9b5735e9acffb8d5250acb5340d7e48f261c58f6e1dfa213980d35df3f14938a5d6c20908290444308c31cfc08d07cc3258a5221e3c8d72031ab52ed92cca76a189eef780048623f82af821d521b0489068af4ff2954bd73dbccc6d6d4124760a5c71fbf88435af2ef8eb24197c8d7b23358baa411d87dd4439249fa80b6f00c4a4c500b0b7113151bc4f385233318ccb3bdaf779d41c433b2424bb3651db990f9fa72649d657bb823f0e73fbdf08e6f81aae0552aaf37370f139e85da70fa52422fabd155d567988d1d2b930f89f72725d97c1b1aaa67217c552ba1b6a51cd97bf2ac7017a2a97298c6d86bab809b9b4a7e1776a8
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (41 mod 64).
# DIGEST: 7b17b7cb19107af8fc4671420e461060e2ef3e61
KEY: b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad
NONCE: 409ae02116417dae0cef457b9e5e16dc
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99
AD: 371eb8da7dac997deafd64
CT: 5e654ee6344f96fa117a2e1f9cdc08bfaca9c83b1c4d61891e49077c8ae7a8aa604e1b19995b32872087e04a59ed367e42f0ad3998cc2112035b33104164403a948ecf73c516f74adaa57688cee9417456f996847e0c637120478f7d88288b5403f0697c4834e4ea7f
TAG: 363ea1d1325e86bb389f4c97a844b76e43d76fd4750954352aa52f5cd174c3d902a71a8265fba870b1b0e3a1add011914df362dfbc8f075cb45d2cca5498b48c49f0872f8371bf37e334c33dba4170d101dfebf14a519d37647748d92ccbb24774caf56204c1e7efb4b765b63d5ccedc308ccf06bf614e7695bfbf9e416df526ad21c4fda82cdce18ea647b6f99fd2bfebeafa94e8b9e83fb2d85fcd5f8456ed2e374ac383230dd39c528408e3b53a92a3950883f6eed412c1a5875a5db61b98c089daf3419522fbabcaa33479d4f0140963f1bb788a2471aa0384b44c0c69a4fc46a892f9ec8cca4cf0d048e30eefb1a74f8fecf77a4d61f97e4835a85594d1df3a345f720fca
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (42 mod 64).
# DIGEST: 48586ad2eac603c136911b28e2c69f101a8ef371
KEY: fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad40
NONCE: 9ae02116417dae0cef457b9e5e16dcc5
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be9937
AD: 1eb8da7dac997deafd64b1
CT: 59201549a3446dcbdf5c3fa8db930606f6e9bd374d8405e15d55493a82035491811f784fd4f0e3bdb6bdd2e01558783a00b32c53d7be31525343a5a2d72921222e32891149f8dd38303ffb584485df15dd4c6917d4d8ce80e1dd5192f30770873895a0219cafbe8dfaaf
TAG: 30b74b701e2777b537a16fa9b2d3bc9a86d718a4440ac3a0475eb675b352f215a847a286f042285b50764d14ddd3b3088189d7e26b96cdc33856347f3173c7cf4c9696ad560773e65878c4f8db001bf66a9e27e7f42593e9dc3f206e64502b4a11a235d5ff29cfeba3fcff20afac264c691a847a0b6c599bd9f7e4a57179f46b3880fac1b6cdc10444ee5875470d25c8a7bc20196aec1f028aea628092b5ecc973a058f083f4157dd9202d1f6b09c72374ea668041ab18045a383242b5e96ac127f6ff263c15d0a4999f61153ffc5d53bb77ed11b5b8bb3f2071b8ab14d92d161f7e39470913043b316ed3bf9baee35f8594785ff0f99a39b72e918bab81c49ec6c4c4ca459c
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (43 mod 64).
# DIGEST: c37456cfc543ba6e5848b9b8f4ac5a58a104b521
KEY: 65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409a
NONCE: e02116417dae0cef457b9e5e16dcc5b6
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371e
AD: b8da7dac997deafd64b1fc
CT: 54a2f87f11c6597b3013a0de46b61a8fcc28ab021465178138cdd76ef01c2701b3a48ca4d3cc885173bdeb33b7b27f9064d2f09ec187d0c9c482522fb29bb421595589aa69ec2ca4155f503bdb8f0f8d4d2f08531c0deaa386b9adad07e8aaa351e76ab938e435c7eee05b
TAG: 2b4f8a42097dfe879397a6fdd13c8e2611399c3c53d5cb5c0e41a4a49b99522b127dff5bbcdf4a5c6fa79440e8fecfbe1df30d34df7c3a399cd79164cd39ca50a3bb6ce2b95a46a3f50e47c9041dbf8f39aba1e807f66984619c62499bb5f0bed727c5214efe67ae9863b99daad6b2814484f9e96c3f6aa5a31417624052c69252de37d7f913e5a2715459f945958adef369e59fc7f704ba9d9646870561efd3c1bea0ba785a8a39698d7ccca3e0b6a6dc3b2570650ebaee1e133488b3a227fa97a8580737cb4852ae3e04c11df82816ec4d6bba8f9e63c9c48383466d9d145d27d18358e822af696a8d7c7aa65e2bc7ac32204a8271684e3803347423608666e23e90345c
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (44 mod 64).
# DIGEST: fc113d192686652653a15887974eb1f9b8e32248
KEY: de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae0
NONCE: 2116417dae0cef457b9e5e16dcc5b6f2
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8
AD: da7dac997deafd64b1fc65
CT: 0f0483dd1e9ef91f215f7f9817b7f82e0b96c0d3b2996b2a1d878d0be3a70c07a4bbbba3721e646405a8a7f44347557d482d7899044af37f6df054070eb4debf7471072af1e4c98dfb3c192e956b2931967d7fdf200b464be1ff1955a658bf86faa659db9fea5c63d26c13af
TAG: 176eae7a290cdf30272c219178d7a011400870bfb2ff611142d4e16fff9278cc5778770605f8914f09c3509fb6ec23bf5cdca390cf8dc0390502b3ac3026c47c167079f12302b6ea7eae668b6dac95a5541124aba8ecb8de4cac6c21ba17a2423ed4aac69e3292f3f4f031e9f54702c432d514726cf02ed646e0f60ed672b5f212e62aec4e51c8b8fbad3f1689f1b7dd775111695a342a279f7725da6ffa0e5a2ff5550159208bd30d28267c600e6b183dc1f72fbb4fd8013c5b4ec93f19dee5864bd854df3cabd5c813d4e3ec083d55ccdad4a0178e5d6cd262843d6309059033b987e366e66c67a3fcbba86730b5fcb4786989f86ff9b8a7318302123e0d53152a2a82a7cae76a81b017fc0b883ef6f8cca921
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (45 mod 64).
# DIGEST: bb6e5b5be84ee383caac0378cb6f541726ecf61f
KEY: 39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae021
NONCE: 16417dae0cef457b9e5e16dcc5b6f256
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da
AD: 7dac997deafd64b1fc65de
CT: 978a10e04037ba7f0dec2576efaff6e5e4de5ab80b4b0c0b8a6209e22da05b8be0f832883e371c61c23b5bef969c004bf2a0f0fc8fbf1313078e12af2b3569a98ae5ee76a9bbb6da6806be3356c02dfa607c26094fd876d8f9dcc0395f3fe356b0a51d1f59582a7bdc7da9971e
TAG: 9b37a729911834f666621a052c9d776f126e500cab45ddae7ad020874d77976af6ec581efd91dbf46ccf346a9dbb3a42d08d23de1cc074788f6887c0b15d98610b19fd2c00752136af3faa32e933518093d667617ae1dfa4e4527779bef7ccc9a1b82d8ddc0eb1d7d9247d0382c6d98ab29f60bc897d28483f1c69fe9b0d37113d237f7b3c3509411058e1c0f36fac6014b6c5937ef005a7fc2e3352da4866384d63c6aac2fdf74cdd16acf782022e4c5f1fa528cd6c977425ab19d800664577b5e5cf0a82e7ba75716c75bdf87eb8c7bdf7346c89d453bcff89ed0b93d9eb1452b72390a799498e31ae691460e5daa8ae3506aab4877cb82e3378874c6c97064b33f969786ed84e81cd1c2e2925b56266ca72
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (46 mod 64).
# DIGEST: a27799fc2e00e7abec4c5939451a834c4606cf7a
KEY: f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116
NONCE: 417dae0cef457b9e5e16dcc5b6f25607
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7d
AD: ac997deafd64b1fc65de39
CT: eded0eef58434338153caefd914cb98ff516157445bfbd25c3c5cbcc0ad68ed1bf049ac292da027acab0310ef08d66040341721524982165cfe7f6dc495f7f5f36cc410470e3b42045b718f580713dac8074b0e76a0345d11c94a9800bb5e5eef1cb8d9ba5818799cd1ef69c4ed1
TAG: d7459df78edeb89e01ea8d685b5780b94ac339c36750f2d5bc09009c12a22893348bb74f8c38f96451e5204e0d940b9b84c6a89eea61d6a78eff111b806ad4a50c8456d13f79288cd3f3bdde755083dd64d13e1c887d8df5102deb5a23055a02b6cab1021efe6add18d00be8c3afd6f8e80bc539c76003caad47c1cf95085bf48bf9ab6d487ff4cbf5bbbe0f2a2972e6a165a2e5ad230f58fff76fb8ed563b810684daf4b5902ec8cdf2442c323e7c7630129a89432a1795380a949f1113facd9ee148e2d38d4457b508155dba0d8d4812aec13d67050e70e2ff98a1fc1dffa01dcc7eca4349a0b14f2507687314c49b3fe7cdbde2ac840bd8ff7fb7c36a037e7b7de485183fdcfda49a2281645ec1b153ba
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (47 mod 64).
# DIGEST: f30eaff92a640a397f98e6803623e8d1f0c1fea6
KEY: f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae0211641
NONCE: 7dae0cef457b9e5e16dcc5b6f25607f0
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac
AD: 997deafd64b1fc65de39f4
CT: 7c433fc5255dd1e11f67c499c6a89c16b4b09355818cf304f11167bef253dc60c95486a840c3a8f77440f63a5c6a855931a90eea66a281d51d4198679e1420c824ae5c8bc0231444b65b69832b84c7b5ee2fb8484ac08727eb0cba0c14e7e0a9071cb0cdcf73d5d83ce53bba361ee4
TAG: 2e73871e9d71defb381e4e7d49d5d45880fa3effcb0cfe673ab52805e6273723cdf99557ed9ca838aa2229fe8eeadf7c6d94c91e867ca023fbb2d2835e420a3b026fb5e3915e38a7ac02d43a8c6ba8a149e99abec42967106bff6c80adf9be5c76503c95053c21472b9a338ed4c9c11b161ce83e2d6190f87e4dcf169e945335cc5acd699b983629d0bdc452f678232be0d31b9f231aaf4c3c3df79b1b8b2fd8802df0b71cc5e26b2a5c5c5ff0616bdff6cc7b1f09aff68d5e15dc9d61c1cb6a2c9602eab7794eb77af8bed198fadd854e8f8a47bf6bc11a8f75eec584f1901fbf012d1fafc03604ae49f9585272845677a1cbc27261d5d7fbe9bf1f1c9ea42c61b110cde99a3a602fc9eb6c825656d804
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (48 mod 64).
# DIGEST: 7227537c0113a9f46f7d332a0b37ee5303483d00
KEY: 3541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417d
NONCE: ae0cef457b9e5e16dcc5b6f25607f00d
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac99
AD: 7deafd64b1fc65de39f4f0
CT: bcdda7eecf3331f4e7605cfd33789ab585318bbd35047755402372403a4df125e7f5bdf857e49a3f74cb8e824576a226c1942fa86de07bbf564cfb384d8420a367963020613dd2f6bd4f371ca1b53532a7015dfdabd07497367aea8db92981418eff6b51eaafe2b6d5b3b4d1b8b95659
TAG: bea683141d42033e86b38d5e0614716ed53b7db5df93b0aa48b15e0111a46ee93c2971df88fa885f8f32e81222d9bb4b605640395e37e1ba474a17f0df48c488dd5a6051be2323f462cd94f81261289f076d60cf5907cac601e2709dc191a9ac5ef784733140ba8d45edded7e58d7316f92a9bd5aa86d6f8441604261a38359a8cbe57bd95522db7029db058a8b175eddaf8f258f2f479b348451b0786f15336e18077ba23eac377ea367d7e1afc08607ff63be2e613fea2e6097192ab41e40342e36688bad628ec273897c86e75e0b83d0d85fd13e850f29cfbe171a8d1b33b72a344a9e2bf292f0dad2ca754d45651a2067d9fb18c7a1845a9c145d4273ee2197dd0b4da66e88a7425a72fd541a78b
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (49 mod 64).
# DIGEST: d76570385cb65d30c3d636ff25c5efeb8d1ea08e
KEY: 41a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae
NONCE: 0cef457b9e5e16dcc5b6f25607f00d03
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997d
AD: eafd64b1fc65de39f4f035
CT: ccecdb03830e84c5267a5b6f68dc909cafe94a1c872602961e8467b4b2723af537d79d723fc4e8f0397fe169186c23f50cf9e78af3156f507bfd38181dffcc05695583863d8a167df062cd16aeec0cc548a7b5e16b148ced8bc2a60a33a583779fef6d7160e0f6c31a03b8a0f1ed8e18e9
TAG: 5175c37f295f196bcfcaffb35c4cfecd88d1b9c773d3162c96eb74a23722e599ac728ad68e2ac70369e0c6d212826afe93cbbc61abfc309d3f4a6f0d22421e02d711a6c97b6592b561b49ef5f6516367cbd966414d9842eb963c79bd4a8e1550199fc9cbd58b5fa5b898db2244769a950ee62bf915a074d5196732ae69cdaff05266bbc049903f5d7c702633741471bc3f8e44a426d201c5ad5987db33687db05a42778617c253576361fcbeee62707d9119cc76fa0627fcd65df7bdfd26469bd4e0265355cf885e2e515d56307adb91be258befc45ce8b238f6177d24f38ec56f0d64a46124161992a30f8a64355823397012af08f1df378effd1f67fb30796956fcf28b0ff35f618060a955b6311
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (50 mod 64).
# DIGEST: 170369666d1f2337b29b5f14af68d47910388e7b
KEY: a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0c
NONCE: ef457b9e5e16dcc5b6f25607f00d033f
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997dea
AD: fd64b1fc65de39f4f03541
CT: 2828ec3db18423dc583c7ac7dc5231da07af1756d7c032a866c64155626be3b3a686a93699023f6e421da24596baf99b45244d07d86a8973450afdb87ff2e9dbab6fcef52cd476f1f25f27f6bb3abf9b406704a14ce9682613125139b238d985ab8f68c17f7b824f279c01d820fb70502dab
TAG: 6af6f94f0ef92665d286e08fad2845c4c43f985b0cd0f09c6c6b4899c350a1a342f024c3ced7e54bb00b96d0e04c6d484e95b585a687258f4bdd1c00eb1d3f44e959b2dbb1444a292c81c92e3b1a01622fa377a583117bc2e170ea8c033864fe7dc09b7a9b1b5826ac8e38fd5849ac9024bcfb1c587be93b3da485adf297a77ecbec2a88fcd82e7eb952b6d012ec439310f624fd07de7bad33a5a59b72d88cb454d5da32d52012258c8754cc61dae82b26f8d6df7a4ca384ea88a30e12d4b07bc413791cded177d325c03a5a6c532641ca46ba2560cb3072733282305266985bc4afac41b171b28aae50266a00afb5a778e1c481a7799f29ba588ed3ebc65183517a31944921ae3a040731666daf
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (51 mod 64).
# DIGEST: 7c52593d1d37b0dc380297231c6cb7b64e04c493
KEY: 1be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef
NONCE: 457b9e5e16dcc5b6f25607f00d033fb9
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd
AD: 64b1fc65de39f4f03541a1
CT: b463f7f24871b617a1001d2f73f9eb8fe39b5fe0b382d420af876defd68a893add2eb6cac45e56d669f4ac67a943a3b32daf0932072bd701f9291b5020bfa9133d2875d8f6ee78ce8c49d45b80329831799f1eee8c712683300e49c57dc8c1ad0b07465184483d669b04c183976289e3ad6070
TAG: 2e8b0999a7792a9cfe5148a8730e28ef92557e1b5d9c318d27d12fb1356fa0dff3467e865c530d4f20fdb765f7ec7e56b7ba28fb49309bdddb413182b07670cba711d6e5e3c086b4e4211f0f19666590bdc9a121e1430f6b0c64c07eff2d81e47a02d375fa46bf8d6fb8708f3a247287b595be7aa19414e3d2d39785a0bc8ef46b547bd4805a8460fdab65d81866dbc496581ec548c51f601e13289fcf3e45f1bb4a7777f9a9243282681aa1c746fac4a8433e1f477950eea76c24d318e95f0586eb5d21a16f8b2b58a14c4780eea922b97de4b1ea292f842c662534bea84213924e837cb546c26f3bc9951eca7593f4f01e3e6360cb14248d127a08d5e0b77f438479035769e0e12c856bf3bb
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (52 mod 64).
# DIGEST: 09a1659100052d13bebb4defd7f54f975a58ae2b
KEY: e112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef45
NONCE: 7b9e5e16dcc5b6f25607f00d033fb95f
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64
AD: b1fc65de39f4f03541a11b
CT: adfffd8a654da994aa8adb618cf69b25ad5dff201cd3a84314796e0228ae3e01be77cd8052e950fd74e3d8fb0066705874a7319dda8bee7bf7748ad844a70b1ee0d774a6156fef109dba8346a68b48458728ebde458e5bd777a26291f98cafb175864fee2d335fe5a38f1738df9a5aeb13f25442
TAG: 0562ed87899d06eef5f3a7680c110360e5338af0b78416497e18291d4e8a75a219942acedc7d1493a15f6d35d1d8cd27b2bb26bcfd58dab2c747b4498ce1e56568226987124448509a7852588acf2dae587f0d13ca2ba54c50ea37c10e6c525b04caf0aa519662f258dee7fdbf17568ecb924c0f26701dad0952d3a57a8188d046439d7e35d73adbb39559adef95017029a9f6392d7282a1c84eae663d840184da4bbcbcf9c262d69ed2a7743aee175150e03bd3e6c38a8a1a762614ba2fbbb631ef56ffe3746dc95d9a15eae1f4f88e3180569e73b25b8eeb8474ec8dee041cdfcca5219514c5125395d83de633bf5bb05e4771e7a583f4e6a6d20af36235090454f8acab43984fda3f5740
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (53 mod 64).
# DIGEST: 230c3353ccbd95e4f0acbbb0073053a0186f833d
KEY: 12a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b
NONCE: 9e5e16dcc5b6f25607f00d033fb95fb0
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1
AD: fc65de39f4f03541a11be1
CT: 985481677ae867b2427182edf3de86d7b9956a4970b107ca7e01e90ee7cb02c6b9a46212e1b8ce67e7aca5e2d96272c2f412b5f16a7c1d00fe597f1390c3a686724c4846c78ae66b26ded18adb40f0d74c33a68032b97d440104cb7acc755ad7383c16013ec7fc519b293e4c624b132f91c44202c7
TAG: 62eaabaa53e386ce7d064c718e4761d14092263af3027efcf5c343ab46e1133d3131dc3cd7dd6b8b8d9ae6ca172fc10f5887dafb169aab9f0e7eda4a5b3436750ccf47f2e3e9965b46f3dfedcf38d61dff3cea927bb3ee8509d6a4288f2879d04095eab6b9e154d0e22da31cb51638ae978a0c5cfdac346ab551d359fdbe9aa34e9ceb15051d7e04e9788240a030c0ab7c19d00f32da1df539f08d158f34a1e3fa6ee8d10ec0d99675a3465c889fe2b6631ff2765a6b83f594315768fdb30c27d2747a6e9d4c5724a5e93704a1851d606dfe97150667309b27503b09c85d86ecd83caf1ec456ac19b7fa273af74714611b3e9a3359354c7b983d700775930bd90a629d88a3cf7cf17f5058
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (54 mod 64).
# DIGEST: 701e141608e71005d32dd1e29cd068aea736c9dd
KEY: a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e
NONCE: 5e16dcc5b6f25607f00d033fb95fb09e
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc
AD: 65de39f4f03541a11be112
CT: a06030a844e38f9e049bcf318b10e1cd2db6b60a2611cf9788f0c1fb31a366d2038b3a1692865b926196594850807895523a851a993b77e49c911f840f28aaa42b4f427eead4e2a578d57b101bb4795aedcffc58212e0eaecadf503e3b208eeb72d53072caa44677d6667a0d22639db7aebc2f70ebb6
TAG: fabbfe986fa42c58408b2f008c7fed482ae568cb39c938aa531e49a85ee71fced2cdd2ebe97a35295977ccef50433b41c511d424a47274599f3f2a28678a4936c1382d6a9f5d41b4266ded97a2fb11ce4e4df03f9e976675b9b35eafbbb399eb86a79a8023de822f8c0d83da5516766f141f83d8075a77e7c55e987cd181f02d8d6f7c90775bace579d25fa1a969e4dec07a5ddbef63c67b6d76bff54dbc7fb87f8af639c392a8a32bee35255e24cc63cea90445ddbbb75e4c594d6d1441e198720c2fb7674822e52d0298fe24c6e1602fec34038e62a55cdfb5d3fe6479fe6b02b5fe648792636e03213e402f02e2a3cad928996e4b1d2fecbd97ec5ebac5ea2f9c4989599648b0577a
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (55 mod 64).
# DIGEST: 9aaf96b472ea76fd9ff4adf56dab5fe0400d18d6
KEY: 2933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e
NONCE: 16dcc5b6f25607f00d033fb95fb09e4d
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65
AD: de39f4f03541a11be112a7
CT: d934f61f94d2b0aef2b63668352d2af2db2e225d0c8dd86b8d7c901de7425dca2a0d2f3bae9dbaef4946d18ebc2d9f4cff5c268cfc80b89c35f7b1a3de12173f9377a7ad9b33751fc89390cea9b44e80423702a9848c6d2562d24838e3b0511b81a737a4b65fac394da45f62f1f3b2bfaf0b4f3f0c5ca5
TAG: da6ed936480fd159c32347d94a17ae7bf9344d4bdb1bc0921d85456e9b48a2e2c24769bdda1cd6bed0b44e980873ec3c79b4346849366ca6d6a77e8b1091c6657a009691733da37706c0f480244ec0c7839648cd0eb63a28eaacdc8b60b1ab59f7d83bd142419a5a548df23f019e560c0c9a307b4c2498f69386eb13d4dcc64ca77c8f5f7c4b6e0c18a058eac72426ed4d541477e3a036b9a450af234670c94a4ceb7cd19c9ae113477431fc2ea30738a95c5753a4b8de9e0e4e1a0f7d52f67b2957a39ff1c6eef88bac3b927ab004d64f3522e0db7e80d27309b864996aa2bafe615139732cd492608cc128295132a4f40a70f8bfbb5b18b2fa45c55c87db39872bc5c1e3300f446f
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (56 mod 64).
# DIGEST: ac6871d354eac507556770d8b6bf10b5240273ed
KEY: 33c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16
NONCE: dcc5b6f25607f00d033fb95fb09e4d00
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de
AD: 39f4f03541a11be112a729
CT: 413d2c3fbc77845409ad66cc13432824ae4ae109379a9617e8b93d4f9b17fe0d0450476c3f98c229bf35e86fa792dceb4b3864761dd442c294e43b1cafe1fe086cd1ca5e1572fe2b3753c20a74b663b536f6e686d9765bafb10566f2b5cf02ee24e3dc69cb2be9392c991848b840418835603bdd83b2cf0f
TAG: 5df250368694b1d3b11119d8c787df534fe4526eb31af32c9289b0eaa4e9455b5cd4a44c13a335857f67fd2662317e086c1a299d794830ca08ca99df1aa79c8f49589dab551cc6269129b731e4d560c7e330fea2aeb5f06eab87738bccaae53b9661a78f3f08986f454519097a6c43837931a56caafd581ae52343dcb71b98ee0b36cb7037a1eac81f308f292eca92ff2c13c3b807aadaffc832f43ed98c0cab6174639b1ec48f3e8e3736f7a20069aaddc2414f1edffba78bbbc04babfe6d6f1a5ae8f77931f78974edb257d2ea6d5440bd7c8f8283ac0e362e1959bc35bca6f257da511f456466be60ff7451887e5ff221f30547e586cc76e7bf76dade793565d733e5705bfcf5
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (57 mod 64).
# DIGEST: 050258d6ad6bec54f8bc48c7ba2d669d6416c11e
KEY: c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dc
NONCE: c5b6f25607f00d033fb95fb09e4d00d6
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39
AD: f4f03541a11be112a72933
CT: fca448fd13c6877aa9fc299953dc631df8024cebe774bb14839821b05485c4a8f1345697b072342343f6a5479d99d5ba0ab29db7760b1e21b37969333473e6fd16bcc5b52e1d6472fee31034d515f66439f092341036a48d637ec84d22af8d1848843aa33e3b2059f7f90a0db47dc41d8af3b5cd76f4b36ec3
TAG: 3071b853c877cc72cbec5c249fe76736e87793118f0890200b64cc9b91e26448b327dd87eb314c4c074af49091051b69122a2d13b8a7fc0b15a87e7e26b791ab3a74e399d429ef4e6ed69f2036e91909b11075ef19c6554f21b5b9b90fe20c9c633f71c666519774baaa12d8f819ddddbb592a99689ba34c44e59792da3d7750f4cfbfdad6e295a73ada8957eb9a7f7bbb4e8f82d4647bd41d5ca2a51cee58be3fcaf307382efec054d880b5866a38aa0dcc72911c9e9ff902ca3743873618b2b35c45cb32e496ac7c8c69c1818583ea5016a57f6e912859b1b1a22bd701113e6cbaac2a935a94cc3fa0b9d4c23ee573b0054eebaa3414c936aee6bd9782385d690c1eb570c5ed
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (58 mod 64).
# DIGEST: 70060f86c76e53512933c09deb5872eb23efad67
KEY: b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5
NONCE: b6f25607f00d033fb95fb09e4d00d617
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4
AD: f03541a11be112a72933c7
CT: 8c5849a917c328d68cdf4fc279b29efb0c3c1921621276ca19206c9941a5789b0aba7283e743f94a6e4142f7febc9ad35df30daffeaa5cd0cffe0fa2e4cd5ceb687def585b2634774a01a3f00ce2ca9951fb910b4386bd0d61d1e292b2b225ac55000fdce10131ba163c97f810a2b350fc8a59348253549e0cbd
TAG: 5beab8f1449d50a6e4a1a747fc2b9864cad962480673db6451ef7aa42b42e7f0edc3748a71df8ddb33d6f9bcc9024c7170bd7a5b81577f9594a87d90fe96a50a62d31c01368173aadd7dda6f7d4c413773649fa7e5aa0c3cbd0fc760666ce5d5ec5e4209c4eda0a8ba0d66e83ed3337067d8ecfb81d3d1c1bed7eceea2582f276c43fc15d5c2bf9d2558d3c3f4d8cdb8953d28b0221c70330c346640f1ea1acccba27466cc0ec3c14729a78f62c7537b1ca5e9f9bc74c4571be9b67f04533b1f8fa2f9232c216ecd81bd120197b558b2733d3d9bab706f67670327465722b2be2c6e3f2ee507620dce326f28400857cc28c697c9b10df0d093965c21ebc42f34d71963ca85db
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (59 mod 64).
# DIGEST: 58286fe273bf572a76a2725933dd969777c303c1
KEY: 4ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6
NONCE: f25607f00d033fb95fb09e4d00d6172e
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f0
AD: 3541a11be112a72933c7b5
CT: d0076d9cc2f829a33a0b1972f6c0d8c67718a7593975798e0667135db3ce31b4d9bea98710909313a4a2af88bae720963ee738f26bde44b54dd5820992569e5d2eea000baf5de9e0f76dc8e0b93244a8474beb7e922a5f30a5b5977611594af25ed35aab12a61de68f215d73173fd38f586b8c509459a5f7587d43
TAG: d8ffaeef22eb2181a48da72bbf57ba4562e3a1ebf9cd2a872f155fbadeb78c47e64ac6419fa1a9b1ce5a8e78e60ed1f8dcf02535613b959448f754b70d7159d2dd4814122b35418d4e554992b4789e04f018234c91de44b9de80f7ab406fb6fda6f086fc6b91ace53dffe012d703e71861d0b3ecab86a287a76857781254de544985ac5b11bedf29138500598f757ae295d8577ae7e597e9cd915d15124c7f1d9786f9666bc4b69eaa18e28227d87bdc8935e537d12360b53746ad0d7834ad830aa5307f69c3e4ff6e37ee6ba8937f75723ae4f64c2a04949b0db60c979fec6f485dd0cf14cacf5e8d0e624d9a8578e4028b8076a9cee1e5a0ba5b96e9f0f6e6ef98ae84a0
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (60 mod 64).
# DIGEST: ae701e5c8672dfaf728bf0f43f5e5247ea9ac13a
KEY: d4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f2
NONCE: 5607f00d033fb95fb09e4d00d6172e78
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f035
AD: 41a11be112a72933c7b54e
CT: 298f670117678bd139c60399dcab68bb0414829b458c747b0dda5dbd67f95fa393bfd2719f815a12a2b7c6b3e769b61ddb4651970b30451cee6166545d8e4c4554c8217898186dc02684c5025ee692e12130ab41ce75d79a4ba1a4dd02e0af581a645979c1a3c8c12f5b13e9c1113316eb31b8096b4eff1bf3f7ca10
TAG: ee9c1cae63b819ff804cc5a34d59d17a76539b7850d5164ae8ab252633acc10145c2c71b1a10b0a87cf2db361c6aeeae533201457c5952feb347f739b3c236845a887fd0974b052a4e71cffaaddd1f00c64c47251ae446a5875e1e1854ca2c032b4e01dc995f35d901b60d042aabcaad3c08cbfd12567cc789408b6710d81b6b7c6067e02f263763d74bc039e0430bc1f3b4c01f95f54492a9c5b81b8d279266b378bccc9073bf1f1db1ddd964f9b6b7ac8771ffbb55d1ff9d973cff3d4eeffa277427e0cc41a4457ad6c2f035b1c0f93880aca55888cadabcccfc9dcf53dc3924a4c03a5a7bf8416bba76d8a362893193811ddcb02b0a9ccf2ffb6902d7e0c434cc489d720487f4664d60f210433b8f71d98666
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (61 mod 64).
# DIGEST: 4f498d0aa9205160827626ef80c163275eca1f78
KEY: fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f256
NONCE: 07f00d033fb95fb09e4d00d6172e780a
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541
AD: a11be112a72933c7b54ed4
CT: f72c519566632f89513f3f278407845ff8096a5b63929f0ea6009c3cae0dbd853662c4017ee5729eab92f2c475f0a45533de67d4b941d4b16c1964986d8f4a16cc12f02c28442ddf5790f321b3942cb65964587f3fe55ab28064c52ce3d3598d3431788ed2c26fe1b196abfd35afa0f7c8206a6bc71d61cc4e1a086c4c
TAG: f8c75274342950e4893ca3b0e9fe95fa51343c628e1f04d9dd19ed928ef7af0a106b6bc6b70d0ebf552c0acc51b5af94dbb9f4fca444ed4eefff63e4746af9852d727d4465695b1113eda1becabbc56e2860b55b986d6122b93bb822865ab8bbf1409aef68cbe720befe0ebc6dbb639b3be391a161c2d9ed65a2898b3ea7cd993827aa8f2c60dd0d9e926cbffd8bbf6ac43fdbb61ff0024cdb9e668bd9980a39530a526c3c9cbbe1e4f46ae3e8229bc5e7c8b91855eae7a2aaa1b827d8b99ed19843aafb76cd361259c29dba7a02dfb40d9bd2d580aa12a6951f0f53ad5b283443c5bb8b4c9fcf569b30830d1844860256c18d753a8d80d1d0e8656623b1a06700fc513a7099590aa566d48eb6c078c4472d4f
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (62 mod 64).
# DIGEST: 8c043825b2a3764e8a0cc35a011696fb3ed03c2b
KEY: d0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607
NONCE: f00d033fb95fb09e4d00d6172e780ab8
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a1
AD: 1be112a72933c7b54ed4fa
CT: bc6acdf0943ba34efbf9eb27fe9e968f23bc1d4f1eff7f86e836621422e7ad8e1adc03249475b6be8ec5d3e96e167af7e6b85ac87b5da2364b1e0d87d5c49d43ddea8e9b796580fc4fea7774f8210e4ec424aa029717937bf76b148e8af72e8badcc3f12dd259fd4dd9a325d81cfc7a193fb756b5d140fb703aaa6d71496
TAG: cdbcd83191a554bf922180902fd060fcc63a8dc39a90ccbca9fbfeefe9a09a9da72c8782f6d3ccd9e2b5a80816eb5bb6919580a8ec186b8b1e388a561b6c931b22dfe62544456f7344f4c18c4823f167b2ebb8a93e3edb8181f358e66db5a3966eae5e893e76b16e8bd5da922720f754bdb6edf3496b62d79b14f00f24c1b30ec6ea16d88cac2b336f2bd057e68d6075907de3c9e7434da017d8bc5348ad79ec14182e07fc70f4e33ca2aaa2216d29aaf4dffb583c1b5159eedd66a2515127c3db358c1ccd89da4cefaf75a6eb5a8a80396ffcef783973f552645885e20b91dc0cf4485e94d943ea4bff3704a4bd2e23388090fb7ff707cf80b0c71f6d4560b3be71edab2e0b8d5ded1998f3b1df51225495
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (63 mod 64).
# DIGEST: f3a432271c9be858725fd024071c4f479ca9a971
KEY: be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f0
NONCE: 0d033fb95fb09e4d00d6172e780ab8b7
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11b
AD: e112a72933c7b54ed4fad0
CT: 0e87c57c18fdc439c968a9dab086c88271be6dd00843879ae1563e4ed03d69f9fa09a29c1bf99b1c859323eb8452acb2f808f051669bb5e097e23b947369b5a0577157995d729a75ae7a65e293acace3124a8aec53328439e5f2103fc3a236728682fc129a5b0e203bd730303fdd23962d6ea7a35aae3691f6721dafdf18fa
TAG: d7453e8aea805b4c95ed51f1033b386cfd74fef1c205d51fe351ec3b1a3bb2e2b7debd8b20c688f4c516a61fbaa690eb635fe2974a71f45d1b4e2fdf3be4724c3eacadbc6d295ea9b6f53c249783f35898ee4818a67ce5b002f17a48199c779b17482ddf5448b6186cd979dea3d9c7b0ae3f106c4b90c960dd8899a67e9f18767b49497519c86c0b391098192299e4f85862d150bb3e439f05fc9f937c888c4f40684c25018fae0c6fedee92fc0035d073f3704f61d93e7e321a19512561676a216127e6a716d1f5ea43b67dcfaa1ffde7380c066efdc8acba10f2e790d4839419dbed3d89634ae785f7aa3ace1fa1720757066f4b75b883c0ed592b8cba79a400d5e442e23716a7a13c252a7ce156e219
TAG_LEN: 20
NO_SEAL: 01
@@ -42,14 +42,707 @@ TAG_LEN: 32
NO_SEAL: 01
FAILS: 01
# Test with maximal padding.
# DIGEST: 3519ab2b2943d2a50996628f6c26bea29f84c95af4c128cc3af012bb358ee9f7
KEY: 481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8d
NONCE: c55b436965aabe477e0cdd46be99371e
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8
AD: afa22993a340b9b3c589c7
CT: 7265eea4b391d880c6bc72d3282f663e5551c0a71ca35898047362694ee8f271
TAG: 713c1f8817ca022f454f0c6c7d6efea46b86d79baaa4341843404a416f301640d175a628c7a80fdf1b37d1958b76888c69e42404a406005a31f52a59c308729063c6512864cf59608e45639630c5711ced56adf09840c4aa1d1c195b5f9fca08e6631ee9817a4792012dde00b4fb3bed7bfdd6dbdf6bfe82fab5f8406f783874b2a56607bffa361d773c9a7e5c0dc945e7a2dbfaaa5797551685a4700f6ab397c906630ac018704ad0e8697498fb9c1d5b843d808a5cf3c28015e5021dbea15f548745ed8c38ac250632efc66d0fe0f619b942fa90a41fefc779c8710c83ba586ed6ecbdb5b281003c93846299c86d09c7cf88bcfe76c5ffb1512ae5db71c1cc42bfbc03e6f3dd17b160e4b5696b2741786d5ae3f934e9d6ce0a4c372bf876cb
# Test with maximal padding (0 mod 64).
# DIGEST: 6d9cc64eaa0b3c7482d8431bff6d24c9bec634ef6459d873af4ff97756c9fe46
KEY: 37446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f0
NONCE: 3541a11be112a72933c7b54ed4fad0be
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba
AD: 2fd6773e0d0c302a5f47e0
CT: 694868cf990a1b8ef42fcb2b45cabf1bd78eee4b429c11b27a827762b9c319bc54a2b2c8eb2ac85063ef8ac7da8bc35b16c0a98822981dc9b246381780da7833
TAG: 47a2e2e74bed25960a83686013e0e10c057acc81e21d44bbc7abdb4e4dce746127f3e700bf3dc7183e6e9c2ab3a205b00ddbb0404fde852f7c0525e17c036dc56c7646344100e379a765bdf5bf776b957982befdfbf21276841df2c4dff60858e495f63b7760166c9a6da21092b58eb9eefdcae0332e291003a5d21b4ea897d0fc61d4e4eb6d2182a05a0d6aaf1ac924dff58d9618cf3dec05283788796c5126850db94de1625c6081da29969720a9fddb7186e6e1dc7ab1ad0e684118847762c25f820585720138651e08468229533a3ff3f1ddfd15fdc301318c603f49946548eed95d29d38c82fffd73f0c9df69116c056d959ce9198788ceba78cf4ee0fd890f6d72b59b9702c0ffbcab82674b688afe0348d58d700a83ad10704d004bc7
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (1 mod 64).
# DIGEST: bb57bd76fe5f29b96ee3f2d62d8f3c4d1c8c986c0991382834046dc907fe1ea7
KEY: 446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f035
NONCE: 41a11be112a72933c7b54ed4fad0be90
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2f
AD: d6773e0d0c302a5f47e037
CT: f2e78e183884c99ad7f199a02d87a1026c832b9a953919a98c2487bd0d724be407994fcce9e19b5a69f15ceef5d3b95c79d5fffede18a143cdfade5c0f80254c99
TAG: 24e9ae181761a00bf1d1af920bdde00d9e1ef046fd7f5b8af753a3c9da8fc14b00a5fe6bed0baa8e378f49d1874619e01567d914656397ac8c4e3c098211e08c6551183515a2c2c08d485a9387737568a22d5209de3084020da27f64abdac4451536baf006228325093a5d92210f9134bf2600bd6349b152504a2b2fa69a2ce1dd25852e4f57d0c7319862f5c4b663503aa3465c4b8696dbf853178f64b1f8f348e7fb7c423c05038a49bd0ca5363a5db1ae7dcc144a13edfba63a6ebe2a7df15eb313bc7e8b5372bd1a309ec41cdb78023c383a98c903ec28816cbe95b1a0696897b9d4afc9d4f22eece3094e473c94aad55f7041a499dcb0f7d99dfc101c313dd5c651ae01968899f152e77f8aead394faad8c545dc77ff89bcfe11bf32e
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (2 mod 64).
# DIGEST: b09802c727f0f85cb590791372c52bfdc2e69de36b9695daaf7a93d2fcf56fda
KEY: 6f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541
NONCE: a11be112a72933c7b54ed4fad0be905d
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6
AD: 773e0d0c302a5f47e03744
CT: c7de96bb45663dfe6da2a64ffc9ddfa7c3dc63077079bd4bc2ce52fea89924a75664782a5026fb5a099ec460eb9c6d7c3d5ea383092c8f4c67a70fc499a7689bf10f
TAG: 8ce29a56849f32a829c3e62c81f74a4e2c37206dca2fa9f736f65a2fb378849d181c06874de6db0158e629661ff7ec5b157cf8bcaf5dfe015c0c4168f9b3acb55388eb2a5d5bb7503ce5b8a03320f4799522669bfdfea3d97b9c960dbe3bff25d58b660785eb0ac73f5b2a18b7fba4b7369824ec18f7c79482a5ae6ee52f563dbe1637664a3081dc7e682408f473413c87d58cf384bf569fb41b6172b7d85f43ac06709d77f270659267561a0f15f7486dd61ee840195132997846c4614d0c2a9a03ef0f4a8de1d7ab6417180f184510452539270ebbfd4b13627734a183d8f5480db12077f6044066d4cb321d67caf4da996704b2ca40411222b541c84241ad7bc0c5835345e29c70b881ff77a8a20c3cfedc30df1b913c9fb722665de4
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (3 mod 64).
# DIGEST: 13588ebf114df38b7b59f890dffab8b1a4c85f090c3f4a0e508603ecd34f78f4
KEY: 5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a1
NONCE: 1be112a72933c7b54ed4fad0be905d41
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd677
AD: 3e0d0c302a5f47e037446f
CT: 3a77c0f70f9044fb3817d57be4f4e5ee4b27ffa586327f77c18346f9fef2608a552b551ac549f9e8d47c4959196162862fe2a35e44581971c2974d4a65a47ae7b8900e
TAG: 3f71cd59844c0498f849d2c2bda9945a2b33db723ea572de20a8e6df9b2721f4c065f00d66a6c69621cf6131a4fd5d712f14bdb226e66e494c97e096aa7d5f4c9e8e83f87a7a5f997b33cc3b6527d9a441375c859fb3ef82ddc78f86eb28cc883c528698ef592919e702b3a290d1137d995a91d0eb1e1da9688eb168ff7dfcb443d655b8336de2286b9fecd446d05398f1e25834968ed5d00cb3f3e3bb8612a17bbf958d516cd18b637f9b8b3082acdd32e87950539f08565e7db8321d6d84ac2d990cd183210a2c6309b30e944bcdbe9b17002b60c4fefb6047cceb6d89a1ed947c549addb0e528c3d525f85d3ef43f0abdb2d5d2043b7ff2457392460f28c1cad181b76c9ec6f4aa9c5843e792f4e9597ea0cdda36da0ff3e2090b8d
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (4 mod 64).
# DIGEST: 25c98c13e308408c882677b48f3a49a53b500146eadf5bbc0f5a240ab6ccbfb8
KEY: 91d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11b
NONCE: e112a72933c7b54ed4fad0be905d4120
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e
AD: 0d0c302a5f47e037446f58
CT: f2f3a3d985eb38c406bb0db0d141188c680656db8a4484abad2c8973267e14458e2be7cb52f06ee2a0f68eaced13db714296319b2b3557454f5e9cb47e8943ea91e0de64
TAG: d54b96ed058f5c69779994d8e841d4fd61470531e8fb5e7a6a85eb99d4676a8b2be1c11b27657f4fb0555b32c96c34d7f76212d8304029616998b4aba7b56dc29630a8e7602580c078966a56ad0dc188e347e37d819eab39cdbb2c44edec032eda568e87eb8851f6a6bb3275527430fd6b56ae80ee20be664cb8e11a7ac66365c48a06c2cbc7524f39f3e5931af206e412a39fe9acd7e6a938c26d71916b0f5d9c9c4ed3179eeb581a8ccedc626b60cf04b7e04d4ed61c009b29c839c66bf3edf7becf8403bf032190644030b93f559ef11316747d0ba898473977e377789a161c9b0682aba91120065d250bec31113f21cab32b0e4b0d1ad4295fe650728322453e4279eec0c7830b8e4acc92f3fb1916e069c69d37794ea3017235
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (5 mod 64).
# DIGEST: 3fb8ba4df90f52332bc7a20df805fe903351279e0424c232365cfc4e62982296
KEY: d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be1
NONCE: 12a72933c7b54ed4fad0be905d41203f
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d
AD: 0c302a5f47e037446f5891
CT: 02fd26e7b51a1bc6ab6735045d2e42fdd1f31adba98ed5f8b3e89450853104633abf6cbb70ecfba2f5b39dc06f419746abae4a51d33829bb04140275021d183bfc990d727c
TAG: 6e129a3a1de6045a9ffe8faed80494aed9d21635c29cd38c7d410a8ee0b690be4d7ece4de27862281e26b7a7f2660ddc18b33bdbbaeedcf68e068cae4a4cc9be126c66dfa14059adfcf4215e9316bba088ebee16a1532277b90dba74eb853c5ff5e844ffded2fd2f8b243496172cd1247618239fceb1432e6e2a8188145753b4e66275bc00d418d6782167b943b78a40816365ac7d49b5d8833046f032732e0a134202c5555f5b43434aced634b6e7fd0dc3b3bef955800822be1802392a424e8ec250dc1a223cb58393b49270f1b97f3021f9aa9d9f4980c3512e1fc297fb963d41d242000867c2873792b0211750688d6047e599ce1a390bf039a6061740d735fbdfa0e3b5905e1b24e9e4336a3f91433c0ee3dedade34c05285
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (6 mod 64).
# DIGEST: 23f13497afad98ac65bd2a1642935ff7185a839a672fd94b18279ff92202a3b7
KEY: 7df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112
NONCE: a72933c7b54ed4fad0be905d41203f5d
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c
AD: 302a5f47e037446f5891d7
CT: b2fe392acc286bdc73cac1aee34ecb3a3e3ae2ccdb065618e3c4a17f2b2668a2c11108b0bf8a8ffe20800a698e73c9b6ed4b0da61bf6fc22c33c75439445061ebc8b6fccb4ec
TAG: 738a07f02a376df628555d3755a9a76ca66cb12c6899bd77f49af1cc8b266b8a19ebf74d4b31c73ddcaab06e43eddbc931e35fece138f112e3c1eaf94d0eb568988fddb8b0c34f067d72bf6748b5f929cfb06b793df87a5fe17924df4841f98024e9b0ec1563244265a13896cd60cd1ca8c6818098d06470db3d9f7c873f33e3ca913a9238b7344a6eaaaf4c152ced9f5c9d20de930aeea453381ce7bda0f89804799e439dab022934742d0f36a61538973e98006d5f576900e0429a7ca68c0388895e05672949e5e4d1978381a9486002b7c3bcc39c4b07a8a4c6bcc502ff2afdaf29a77099c520a1a8517824dc724683e3866841de80030af402ab282cf27c1c749256ed40451bc91bd2be4d768df1718fc1ec481761000a4b
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (7 mod 64).
# DIGEST: fc71e48cdc62c15988a84f32ad60aa760b5766c892e559fa1ebd882a587ce590
KEY: f660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a7
NONCE: 2933c7b54ed4fad0be905d41203f5dce
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c30
AD: 2a5f47e037446f5891d77d
CT: 8780167385b8856be346b71b042332368067d5d9420b3793fe94bc1ba92991756523c7a8e0114af8fa7296ffef8fae01796b47edea43bdcaa8832a08e823c45c3608580249eb9d
TAG: 049a09e2d5e6ba8673f1963aa2d64759b4cc8d4b3583b103dfbb7595289478f13762fbcb464bc64b1b7704e3f72390ec2c9644496616c4b119b880e4a04a47b15a9c490df71c27c4dd47b3f2f46cd1cdbd2afdb87c33ec9af66a50f4757c0b9d0ed4776af0acae1951393c1ef95597f32057ceb35fb61ab2f34ccda4cf9fe81c7aa8ee4b5b01609460b2fe156478d1585d2a118acfae5f401761310f7d8b48973b5b8f3abd0b2b512aafc8e5251133054d8e0a197ba95f5900307a7f9c23e1a859e0e11091499030d7b51b410f4602239a278bd363185e6c7a1a31bf6aac78e2687a5aa4151a636bf7ac6bd89c668ef466d1cc4aae653736d296e4b6d9fc4c9f9e5f9ab51699317af018a009fa5718fa288c3618fec1e0fa63
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (8 mod 64).
# DIGEST: ff4f42d72ae561abda38963a2713bb743038589bc2d7efa0f3fab298630b9c02
KEY: 60ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a729
NONCE: 33c7b54ed4fad0be905d41203f5dce99
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a
AD: 5f47e037446f5891d77df6
CT: 2cd2031084f8742da110ab5d8f7290828857c867b38427c3f53be0dbe2cc94527d2f0aee90a38dee77c0ce115ef650b2ae65094e99ac9bf6da89e5440c1bb4f8021520429171362a
TAG: f3966d82808723b2398186d45098794ab366631d753a69f949c63dfec5c8d5222dc8765088fd387fea234286771a2228c05dbbfb73ce4a403c5e90a790e34fc677d685c9a7dcb6d8173956865e6c48394e4d95284d2e02c162de3ba4cd09516a321be8e07c8836408a76abf8edcbe767053488d6b07974b92d84934ec5b82856a65e6938620f4a6f346d654e3bd5255f3ca3fc5ee91dcc851b62d7dbe4f050e1fd65c6350ddb07314b7b05c00416f4a4787c82bc1dc6c7b25b4407c5bb67f32f5fb39c77c47782694e7c6086bfe6a6e873d7ba9c4c93a9e192b3e9c9ab47a91ef652021434ec1dafe189d5b427602c5694698d64549b7f734bcb0482c25267c2dbb985110e40834d536feb2491828b748feca9907d687ec9
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (9 mod 64).
# DIGEST: f4f7f147b43ea50a1f5a4f19c093ef917d3b92b46e5798e18b5294b0a0fef814
KEY: ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933
NONCE: c7b54ed4fad0be905d41203f5dce998f
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f
AD: 47e037446f5891d77df660
CT: cea9c7528706d506d75cf085c8475c081ee8c6145ca11610b73eb3e103a706faa66062f8edc10abaa7c3edb3fcaf43c202c4812e768fececaa04564414f45816a4138e4d35d7768b07
TAG: a61a67eb499525e4456b9853222c9612b7663dc3cd83aa9d78e680963fe2e1e23e69cacfba013e03c50b477b20df9ade41621e48c7ced451b4acc5d002f325bc19a237c327dd5d0f0af14e8cc60dcb8001d6d40c9b49d760e6135bd7a3a8ff9e313814ffadc6a5e6c285ee470fd05599465950c5887f9d7b4a1d1a7e80f8c5c76b41f51f403fa10b5140bbb68b2d7f3d2e19035357118ab72f327927ab75b369db9b426c176b937fc3fc92cb02f383aa069e07a223522fb7118a8440aef9ffa44da7a7c880b8513135e4b54f8fcd53ea1e6be7fdc2e7924ce529c846e67ad9460acb86ddfa938cd482d4216315806d45f658586006aca019fe6e2dd3453df00ae296beeb96a751dd29ef350e6da085059a8d70a5793abc
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (10 mod 64).
# DIGEST: c48f43e4386dbf727ca93d57b5b2a4ccd8e1f27b201db03000660078b773faf7
KEY: 82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7
NONCE: b54ed4fad0be905d41203f5dce998f8f
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47
AD: e037446f5891d77df660ed
CT: e967973079db00d2257d84817ff4c5faaf98024ac7eb71d22af3cbb92a001a558f5cce2e8c293d6dc2a968f69cb2731bf65954affbfdef4085123aa06baf0d80d7c80645d2d0f528a374
TAG: 00a4282530b0993737f2b1b3464cd5545fe2ada974f00d11f5737f9a165229c23b8f5cd13a9bb1d7d909b78b8101ba0d7903a427c076282f9fab0ad68598779d22bb0f9001c2a108d43bc4fef5e75147f7195cf4ad831d27d6e54adad6031985af12a41de780a1661764d87aacac5a94489c6639a655dc9682646e32d93dd2c0a8bf0a525908760a715cbc3aa5596bb641bc6cd8cb16b4195f66046ae3f19dfebd1a3e2bda23e00ac4055b0176be89ae987badb83291c4acf781855946c1b445efa542ec97fd4c9aea02a474e3d8eae50893fc827e4c44b4f5f18e773013b37e66dd7f4874b399f765f6f41a81e0407169ee1fb93b15a43a5d3b9538a9acbed534628bb961f2d02a2b55570bfa4fa98bc69298acafee
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (11 mod 64).
# DIGEST: 4fb8d7ccd762998c343aef821e49cf91783d15669105b725eb1123ddc16ea445
KEY: 933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b5
NONCE: 4ed4fad0be905d41203f5dce998f8fb2
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e0
AD: 37446f5891d77df660ed82
CT: df01c1a140da0e422919c0d34b231fa3cd767766fb35f8d78d715c44b9003e42cca112fa1543d74ac05e00da9b5740c03b5c4d1e558ceb8629adf3adb1771e6e8cfde8edcdcd8de584ef28
TAG: 520d6becaa190f3c1fbf6165ff2c4e7b62b8281cc4e77c542a88354baaf8d75b6d1f15ee26340a58c9e2fdbbc5864c307d35f7866a67b3db37998fc20eebb5c83270f7eb7d53c9352ab4c6f59cecb74d53e5751c6da3dc2a09dd90e3c55a0651ce4bf433da143527cb751a6c5fd97c7cd8dc4eb7d90f2f1919e975933468573924c9d1f0cb36d5da802cbb3916aa6f7264a22883792bbdd24e480e8d9adf44486efbde47afb91dc1131bbf2b0568ae91c92022f72185244b9fcf545449e5c197cc77a8dc4485e46daf3d9f84d3dd3facd793f0a2a9cb0f03395b8a23537efc0f922e51e5a43ecd0d3d4256851271f77c235718e4b444e12cf7bfb10a7a4354de62d1c62a2e3dcc687d40ab4ee6f0dd7a20fb32ebd7
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (12 mod 64).
# DIGEST: 756ef874fe4546df371e012dc34660cebd6321b67dac201988cc72e48917d7b0
KEY: 3f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54e
NONCE: d4fad0be905d41203f5dce998f8fb2ea
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037
AD: 446f5891d77df660ed8293
CT: 889ed4c7bd5455821c5b95a67a277a197140816784e820ad8e126b3d3f0ddaca73e3eede78c1c1d3ff5c2a98c0cadd644393b7e3c2273aea2be1c6fd20374b710b88bf2700f8b4c556698aea
TAG: 7dc1a08e3e948acb236f2dd5644ba6d8646ce8bbfb98b658807f6fdfd4e406be67b7a0ff9fe9868e013b7e3eee72aeef4ed6954047521046354c5e665fbaaad517d35fd7e633c1fae894aa36033dd2825506a3be826172b79ba6c1adc63533edd7e8b21ea9178e7ae9e191dd597ebf83a760862718200d4a23235c7460e48d415faa2426f0ec7edcbb0cbbb9ad15ce8580aad6d1934cf1549876d2bfd10710bf367796473fcd5b36189a32950a5fdbe582975860f289ad1da75c3bf72ff8e7627a736b7e0e123009dc47ca15dfa4eabb590825b2e584fc78262822758246549e3f7d436a2df974f0ec5a00eae4d9a5bdda4a9f815ae980d70befe63962b14870d1e72088fb410edb5f2b2dbe137e03702be94233
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (13 mod 64).
# DIGEST: 01fbec0db232a15b4f3e02a14f412e296a0f2c7bbc539ea1e5e835206e197929
KEY: 62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4
NONCE: fad0be905d41203f5dce998f8fb2eaad
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e03744
AD: 6f5891d77df660ed82933f
CT: 13833f78c9383bb4455972d6e7d8f22597e65de7dd01afa28fd99f9734366c522bcaef59c41487d84b3f84c1e0b7e5ff6de84206f54d5ae80ce80fe3cb68ea4eb40914e915f36730b911427c6b
TAG: da212acc6ab53e49e8e5d773c0f7911de1d9ff05c2cce077c77690af36bdb44c936d3ebaca584f7b4e08c43be26bc0adb9765fa984e8da7ba51a4b88a3da3fd8077ed5adba4b12da076d97c3016c05441baa10e28120aa1f023e52c558d6f4197be54313706f890d036b6dd3837c86a70ec9a8f035a0d339df73a50374c3530740b4d158efa875b57295366f21c81a3d8403d278cd04d0c74df93f01655d1e223f0151f098dd30f72a8b8cfe1fca085d482232633e23a813a796ddff3c314c706ccfc6ca9aae43d83cbbbd8fab795e98475fd2c818e74a1bb8436d190d45307d2e7909ce8fc2d94a6cb91fd13cff020e561e89661416c19ec958de8f8db7a32a5117c37af975b3023562a5d7e768aa7aa306e3
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (14 mod 64).
# DIGEST: c49af18a935082656e153daa62270e736e336727424bf48be78da0b7dced9de0
KEY: be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fa
NONCE: d0be905d41203f5dce998f8fb2eaad40
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f
AD: 5891d77df660ed82933f62
CT: 03065bb245ba12ab90903bc081198fdfe45d7d3c6fa3b1f76bde831917376ec2a5b2ac2cf629de6bd3f23025b678ea9cc3bd7801f5510b58432a8bc17999304f7b183e9404a235f1e0db578d53e4
TAG: 5f62471a66673b5967f2ee748d4f8c0e50c1a7bae064fabfaae832a53d4b18eebeb1eaa8cdaed0967900f46ba0f66ae9e8492a4cdc4feedc7d6c1176404d4d9eebb4d0c474ae07d008ef2e8e4dce39dddac3f4b759a34ce37d8908ff16825e3ccbcc84b6fd6276fd72ca4d4479f6c586253e4f8997cb76c66bc3e5b3151be6914454f176c3386a029b2e254dc73b9d5237f5a9abd1aea0cae50fb9c87f6493f5fb8e02d12bdbbd2709690ee6bc8466ae98fec44d8f39082a1d2187647ece97fc95816121e0152677cde571f678a594c18de4dd8b4bbf0dbf4faf5da7c00b81451d728e87bf4607866b342808bf0130a3e516e87cca43a6f4737da23261d5382fde1b2c2e011380177c47ba4101a8503dfcf8
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (15 mod 64).
# DIGEST: 8d6f1fdc3d60175573775cc289d7436b88d10dfa029e90e10e513c8e739666c4
KEY: 8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0
NONCE: be905d41203f5dce998f8fb2eaad409a
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f58
AD: 91d77df660ed82933f62be
CT: 04c76011b9c4cc8ff18038d36a8c8b91debc8d0929ec173cfa5450f434308234e6a368f17a04ec0556dcf5ace0efb5ab51956d0daec5c530129aaa78309c3d0a2a48687f6dd146c94ef9bd1b755db8
TAG: bf249369d0e07ecf93c9d4bbf7564d81140741bc564ace2852b680e2504bacaf181e1379810b5283a7aa4f24e2c70f956658d0e02e4199e78da1dccf480e3f8095ce3e273985c31de6f14f57b5a934a1a9eeb443164d176ca4fc0e9eaf09fad485a380a6d654073d08c17f26883b1d5e02fdca8406dca07a97cda68b400e5c0fce90ebd82ad9fe285769da0492ef30dfb13110c5c9146cd530ef0d757bc2b14e97ff983c931fb1cf2d64bbe5f9feceb7baf68bd13f8de5b4dda756acf7c9922809927df5ddf53f46288387d38afdb803a86fdf86e0f0f431cbeaa626aca0b942ed46fca72d7710cf7e0b466f88c913d04cd140037767cd7d1fb0a8dcc943ac5eb10c8d65d1bf00c6ccdd5db219db74f3bf
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (16 mod 64).
# DIGEST: 11a40304bc276c51e2e7d8e3fa16f905bf050f3861586be68ca4257b1e6cc566
KEY: c55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be
NONCE: 905d41203f5dce998f8fb2eaad409ae0
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891
AD: d77df660ed82933f62be8d
CT: 5d9af50991ea21f041a766d8d9036073eeb0ac083b8069619ee50c64c661bad73a9e2ca7f8b49ad9df79e47b49ca3c8ea9dc254854f116a49959c91481ba96463521bfdb74902a4b454d2c6af72d1301
TAG: 19c6ef896aa751a22b3504609e8f4497a4987ec3469fa6578e271d77e8d15a2eda3e8db8b6b00b40def47a16dfcd41c95ef6e2a650aac71031b4b2733ffef47d1d68c79b2f6962874727ef36613f0461f4b1a4db9f30121d7656b53c2e31285b0e4049b5ec8db3d813e9c1b66c7143813a65ad18618dbb0dbab39e12fbafc6b26a0f034311fdfdb1181117ecdd42cc2964f759b224c455fb5b69ccc25ec0831ee24a84c51985bebe23c238b48ab7cde07b3fc79f70fce2e514ccd2a5c91227824a58ff0e9f15226ef30b55510f870e6f75de34ac0deabbde13536075cf72c5c09d51264f29145f47163069edc421c9b818ce727283a09d7bd415bdc6201e632781b58eb8a9a519520b9ad994cc6524b464a6d719917a6691f6b1537a6b363aca
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (17 mod 64).
# DIGEST: da3fd1aaca630fe609395b45a44384c57f779505188c8b12391b9f34de17dbf5
KEY: 5b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be90
NONCE: 5d41203f5dce998f8fb2eaad409ae021
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d7
AD: 7df660ed82933f62be8dc5
CT: 182dc2f9f412f305a8fa4813e8c8eb7a41f9708efb516fe3feaa6ae94c89b4437cbdba7c738fb97ef9739ed94d988bd60af5359194d2b5f8a48e3f5482c3be294ae65ce803e21acdee157d436188980bcc
TAG: 35fa57f8dc3b68320462a41feb88654d838d684efa009c9cf0e68c79991045ab69baa6d662824d50fb589690b54edd144466b8d7332430da1bb53ccc0d3a640ff8eef6cb0d46c6faaaf81e9479fc2199ef1bb2256754c392aad96a5d702a269ab2e07cab5a2ec93d4c29cc64aa269c4d68dd7c54b1bb20aa4fb0475193e97a7ba0acfa719eb00a8651b64f57924e24af34cd9b369d062ec327dcaaf1cedddf11c3bfa578215cf8e9f958e63f0ae8e59ee783cd11d0c3637b91bcfa083a60551987fd6b225dbb502a700a94e01888b871b274e1b73f2b9db05a504cf420f47c51e5b235aa4d9a2c180db3687b021d506c96f4697b4ab510f3fe54d5c07f0b30f5eeda6dc542114f2d16be454b1a186ee6ee6aed6f8a07043527475b7df6cf5d
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (18 mod 64).
# DIGEST: 2ea803a4525d24849aeda1b0adb81676b32d99c42bcd0011932085424a0a8078
KEY: 436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d
NONCE: 41203f5dce998f8fb2eaad409ae02116
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77d
AD: f660ed82933f62be8dc55b
CT: 0990f57d9a7e9b64bcee741e158eb5749e9d7b34d43c6429754689d87fc45daaa618fc62d3dc111e5a1a7a06b2b14c5b0f3e2e463085e80da6ce4a6f7815cbf871376c8c87a36555b8a74e0a14421e1eed77
TAG: 52730d53e2849fa94025fecd80e64e2a9a0a5f88a6a88890754dccbaa84c2b4ae10825a15f389490cc8f87de08cf0f4f82ae824b4fbd9f016dee50b5d586b7e03cef258754a6a82550cb26177a83f9e7bbe0b3b17d60a7a89929b2451a79032f6a200f645c6c53838a2debb81f756a2a37ced064c673291591e29ea62bea505cd612e3ec55f0db630a2e7ac545b68e64cac59b639e1b80df1d3cd98a0e00865958b64a9bc1dbd0897fc5d6187989ceb766e71cdaa0de7df0ca36100b2541b5faf97092d6309ff4dbcc896dd5e08102fabb76042b8329a0691e571ced8da3cff1a6aeea3faf00197c4e0bfc57bebb1e2f8896fe71dfefff6032bb7459686e2d4828c19b8105ad6622328c5bbe8da11cf0087aca05686e53b432fec4d4c065
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (19 mod 64).
# DIGEST: 6802d4c044d85fe270b3761ec10ae5cb4b912a565e00cafc8eab935935523126
KEY: 6965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41
NONCE: 203f5dce998f8fb2eaad409ae0211641
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df6
AD: 60ed82933f62be8dc55b43
CT: 8d7999ec7a80e528bd6a8d2a9724930c93ee5cbb0c888d9b7c79d2449e638c03f3143f1927a1b261d66ff55bdeb7ff6616da99a2155f465d7c91f54963e7cbda7b61529381204ba43c9681260799ce66f7b8e9
TAG: e3d5c0e2427d0f24ce9199efae32408cf0a22b62e59aee3bae992b397aeff675d4e723c7ca2f0671f95cec68a21be86389508910ceceb13f6b6004e965656783fd2ffa6881a96bce6e3cdd80adfd6eaf7c57c836743a1b486979046c9c7d8ece2b871ad5c9c4c3401a467d7c0ea30fc90bb8be5cc35a1566120ac14eaad9a5c99f944be06eca9d473ce82125dbf4f7e3b0add283ae31098e26c94a6daa6f406c273ce3d91b801cbbe09731a8eac4ba38c6bb571f103a3557094a2a3b3477c4c3538e04957fc3afdb3cf7cb649bd6b6134c138da9e33c4677236244951898daa22fbd07f94b9b7091672ac0f6dca513de86186e102a51f59d6b96c80d64844e160b34c4f98248196130ec0965e6fa02d988f83f016b35e8681b4f8dfe39
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (20 mod 64).
# DIGEST: d159516557052899ecffe8072d2cdb753939d812db2f8861e3ba7a837f0fe29e
KEY: 65aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d4120
NONCE: 3f5dce998f8fb2eaad409ae02116417d
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660
AD: ed82933f62be8dc55b4369
CT: c3e61ff897b490847e6539236d2e3b208baca2e83347b7ea2ac714f65a409638e59a5dce5c3a4109e6d6cdb8a232f5f8a2577101f9fb53aa50918f924c1a5361ef98d6672258b4adb37ca5f30d22893dcf6d0349
TAG: d81126eaf7e4e4d12f66810696ea8a7b26806b688ad1f8863427879fc31407a2d8ddaccd00bf3351c267e14263d0c138716277e47eb31d93204bf1020db38af84802b1f17110073ed04748b367d06fee5336a98866d3e1bfbd259bbedea78129beb3e446e9c451ae9b905eb1f19517c4d15e9ba3e9fade980131899178a0b29e6c35a81ce9701a59880b3cd925738302bb1495c0ddda69ee1aba582ed158df2ea84b75abf60d389050a25e7eed1b3cf36e0b04756f67819d21776c33ccd802ce04aeb57881f92ce940303971a2d02a800b8557b08805f055a299c2870789f5a2a1f38f9187be63d7e3e3a7af804d334319a79d9fea40684d9b03059800502c5e92dd0cce30de11d89e8d2c816589d440fa1fdb0e4cccc57c1511ef60
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (21 mod 64).
# DIGEST: 8b4c76888085f1030618cca2b0ef708b79b68fbe879c266adab2211c35baebae
KEY: aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f
NONCE: 5dce998f8fb2eaad409ae02116417dae
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed
AD: 82933f62be8dc55b436965
CT: 1944f256989b6acd7dc7c334d10ce71d9f2980cdb6adb03784061096955a3e10efe7cbf1c0aa1caab97cdeee4d08a8ff34d68e1b53a0df58e79a4c1d5d9b7eadb2430c0b8049b6c43a848fbc5e5feaf18e45691b7c
TAG: 7d89642640d19b0427d5d948adada9000755d3703a092201740a80074c1c4489d2edc363654e721de3c3d5a5ec5ae16bbc8534c23dd037989fa7d816e3c0030adeb88f4a36b8257732f33f2d58391b88a06e2d50055ccd71080922524c02c371713a755cf0636f7c6d5a9fa2edb366773e519125a3ae46ec1369416c028fc00570d5bb80882fba31792d42d3247d669c8b704f765125246f38d1dc1504b22d361055bc79a3195ce4cdff14a16008c1c6e7a5ee1a67f95dbe7ca08fded965ede2a0367eb13670c877685aefcbd7d7a9162b3c69f5d59ce3ff9dea4db78a0abc6eafa1c45666564d8fe1648b20b3a5ca8c19acae4ca514b79554c4c3eab74fb18ed41e061e6b4e83395f54eeb0863db3ed0b6509f7c9920d110d23aa
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (22 mod 64).
# DIGEST: c93f922285c3abf65fd70f22abd7ef859a392a9db0a979acbc99563829e3fd77
KEY: be477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5d
NONCE: ce998f8fb2eaad409ae02116417dae0c
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82
AD: 933f62be8dc55b436965aa
CT: a850ddac6117f7b13e15c17621fc7c99f2276ed7337cde87ada287814150f8b3f3e8ba7108a1237fa6a9ddcebb07c234660ec93b8279bb4614be85c5973603568e885f5f8ea102d0621b5ba77fc58af4d6df034ac59f
TAG: ca216ce4ab900dc62f66dd21c314cbfb3a6512cc74ae3f46f3e8209bb2753d7559ea3ebb553eb57215fdeabe9fd10b001893ba2c92d3a9f7171c0b86427a416d137b239bb2d8ecfda6d6ce01bd8862079c32eef3c932bdb49fcb1b9940a9d4399630865834050f1d81635f894547420421d606729105123c49d6d34e267a7e8e9e27c85b048a1f83b5c0257cc4c111851457b431c5cbfc5302fb1c459f7f7e339f9e11a91c36df1ae2faa0d5528b80eb38adcf7de3bc1cb5e0cd066a67d2184950531a36331117f94166ead4c630425d22fdfd94abe4e7170f17c7247aa8d2f4872d7fc74cecd40ad4d5f3ae8895874d15cc7bf203196c6e9e8a515d8e4c70073eadeff727e57514d85e1b914c12229afbfd69f450aec61247f5
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (23 mod 64).
# DIGEST: fecc2d68e7e0874de9d063a889b18ca83d3d5908aae064db20d723a8da1b3978
KEY: 477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce
NONCE: 998f8fb2eaad409ae02116417dae0cef
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed8293
AD: 3f62be8dc55b436965aabe
CT: 0cc80c78b73b1bd898c6af38846d32837ed0712ab7cc48b01c6dd831f37237ca7634c90aba35b35da59b60aff8e6b9a622f5a481c98c03fc76c1375e4602e96c08a465f3085ec86b0a8e1ce8757df76193de2a06ccbc63
TAG: 9e4eb28cbb60fefd301f975e22d687098d06727b3b730599f3824abb3965911cd2ad9bd4fc70be6b62147b968aec7f591646066edde324140591632130cd71d7555c0fe87dded42808a41460cc45b27012d0d8e16ef8704102be8d788db90e1cf260a7a774192a850979a25ebdbc723a3af5c13aa7c5c86ff91412307e0755240f82fadefc1f23dc57c5f703346b5d8bb2d2811eb07dbaac1abd456b2864ab652059c54a5bc74643509ba0dc0778a946f5e40e5fb955468ad4f30365bc2ba0e42f6af17bb562fef2ce63a881077762c722c840bc7ac7faac11984c0a77283bb2b2984042456873e6e368f9139b5c50b424c97cb8b6dee50881be33b96decad3c2b5aa9298f334b85c0de683c037447a5036dc282f8b42aa214
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (24 mod 64).
# DIGEST: a182bceec087418714d31fdad208a5d5c578fa8917a754e0b0527364378afa81
KEY: 7e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce99
NONCE: 8f8fb2eaad409ae02116417dae0cef45
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f
AD: 62be8dc55b436965aabe47
CT: ad918e7428ca106cf043d6626772cd45ce998f32fea28c3253fd58f0fcc191bb4cd250b5dc6a7b352bb2aaa66601e280576fa60ad8c3aa58742462955fd7f33ddbbb5036128617c1fc3bfdf83100dfddcbde1814d15ffe81
TAG: 946a6de726a9f45f40fae17258b38b3f16fb8d288b876bd59255ed61091e270f16d6cb7f140fdd72fa1c45991180c1be805db33e7ddf3db5f928d533d182e49a178ffcd6f119bdc6400343697c2e6da7221fe849ef9ba1e2b68343965526c889377be4e60d3c46b6a997497c85c9cdf2931babc76b0da50fcc7e49bab9fc1dc42eb27ff4d09cd7c5d2ef558b5e5d2a0c0ba8a31bc7b25f32f08aa27542c59c1d7593f6db75dd12c7d3e12e45d76345337af9168ef03d8eb86581b651e61889fe3fcbaac6e925a99b17e4d414bd2401695c562b0229d168c65f52c3f11fbc6d817a3b691217090dd9f1bddc6017c87bb41f683de94d0ec564d2440c19e42797ee6deaa13479afc7872a0c7edf4c3b988806f7d2cf0811f946
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (25 mod 64).
# DIGEST: 81dd23016c18f838fcfdaa8afa9c52009af9d93092e250bde67ac11e8588a238
KEY: 0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f
NONCE: 8fb2eaad409ae02116417dae0cef457b
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62
AD: be8dc55b436965aabe477e
CT: 8ef4db8a8444ddd056428a25b718aec0258fe05b5fe8d6d972ca6762875c030fa2b4822cf03e797a53046749e39646c8c6b373a1d77287f4124c19ef758eef75db8e4e03309b3d14e918bfd9499ae5c96bf10b513ae9b38511
TAG: 50c96ccda0e56e203860ee8bf4d6e7092ff1bfc02470e291b1e6debdd71353745cad7887d47ecdfeec6996bc1f44754515a82c4aba9ca7758b609d7bb6e0be19170428afd8017478233f2582cb0ea1c52d1396395b6c83b0694786f4bea423167293e479fde3fb906a213411684d65e889a3dc9ece6a188b86421eedf6f2ef14da596800a8eefbae2461395f960d9ee05c3f1b1d05fb94a4b14d214d1aa8fc3612a7b7267e7272fd7330d85e66969c0a1202cd2843da7c01981e7565bd98f3e8fb5a55d17454d7d1c43d9faf130022d85428213251c20700e1bc069243fb408f69e39a11dda7ef2647cc78d040b1ed4c7b95c965fbec6b32fa0c7d51cd192f12f93a02df3e03afae0fc5a517d2b6f1a807718f8a31b8d5
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (26 mod 64).
# DIGEST: 20f01a20150588ee1067e30a2ab84904a34ac56cb9e327756a700b1af24c6200
KEY: dd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8f
NONCE: b2eaad409ae02116417dae0cef457b9e
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be
AD: 8dc55b436965aabe477e0c
CT: c107710a85a49250f3a4401fdf07a44f96560ca5e71d6021075b7b6e3ff8fd6f36c652f186dc82c8a21a8a743dcc007e6710214320cb5c5e788f8c5b020e4d0d89ec2fb780c9ea915966b9f9b1e2cb0f48800ab75f986e8d2c52
TAG: 4e7360dc7f6630f04c8f1d2f7839ea3f2389d40b2a0b50ac5e54be15b451b0c17e1f48e0d642dede861bf6ad751de565ff0d56d5595941fb6978084d5fd92ec0b26d1357ff33ad08811825acfc0f4370f3845af494d9851c202a5a3af65c1f96b6252a8c850c8ff4e14ed9ebbdaec69322ac90d060f0d1cd9591f0a8eaf9009c3d1835343d0fc1bf53616831ddad08c4852110333b31b733d5f8c30df3de0cc5b6201cc4fb086d3a4cbd6f5b09b7d2bafd20ca24af45e066c86d417481c984ab5c2aef71d11d1c1ebf714e96dfb4c0eea9510086d457529238cccb946e17f0e378725c230e15a0403f05f48df45ca3a1b5f7848bc49faa52aca2c5cffab9b59a0d91a192f89e3a50fb7b5a22dbe88c63daf4a5e4eb72
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (27 mod 64).
# DIGEST: 83a45f4fafff7e1ec40a34e75a49a431478bbe8c9234da4c1b3129aeaf453d5a
KEY: 46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2
NONCE: eaad409ae02116417dae0cef457b9e5e
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8d
AD: c55b436965aabe477e0cdd
CT: f90604401a507574dcfe5d7c5e0c36c5fa65d9a8f0a25daaa9fe5c50ffb3758f52c9c883c2f85d879f26845a130044d395b58497979cf24a9e18ee1f27d1eac4d0cd994a6338c5755c74419111b2bebec0dc90e28faccdb1a000e4
TAG: f4b3d162e2284dec1a2dd88163b4f319604d87a6d4eb576a021119146a8f0dd74773f3c2c82ac1413c1a66683743c413c68dd3368dd7d855b6ba54a45705b9cca49e920427b0917d2efb2df8f05705d7a4fc02e019c56da52bd3e9de2f10b150d06c70c7d365b7bb0241db500879dc2a441e003d3b534f13153eed94c2b822ca12fd728f04131e96b21770d1455c01ed9e5da2662f4b270b47c2ea8d7d0bd82533dd42a94ddba06f076d01d0a2003a38db14ac31d01dacc0b28254cfc451a5479f569a68ca21c5babc4b47a6f8d3fc33b9ca8a91d6b49523c2d1fb490030b0bf2dcd3f621c2934af7f9e920573fd8ea86380c15785c1699eb93737b5e9748e07ae3579fa73283e5c0aa1294e53fb5b71224634aa63
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (28 mod 64).
# DIGEST: ec9b1b48a2e7600c92e69277c9e55d1cf7a9135ec73cb736fd26718c5531fb7b
KEY: be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2ea
NONCE: ad409ae02116417dae0cef457b9e5e16
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc5
AD: 5b436965aabe477e0cdd46
CT: ff258ef9f318036586c5ec9e956c10c9423ad3a8a5468527c02bda6878c45398b0c78f3fba4eba3785282b3aa4586d31b238fb941546bdd6e3d918444d45f79b2a5ce3df0e8769a952243cce1f17f736bf39c070d9eaf57633315791
TAG: 87eb4bcb34d8d52975e556030cd976f4a63b074e466a55996d09bba1441279f4784279e587c30548d4584dbaf30291b01df4a212aa83cb217b9423841f39e9806c5e9e32bcd9a6cf65771b47264b9c41544645c020cf132cde08ed38eb335fa01f54e6b43b646b30b34fe2fb14e38a916fb328d7c82de7961d38a88377454bd9b89d1be1563f8edf9d0779a3733b59ac1218c4d94d1dad1373c242114f20c359c37ab2786e7525ed4bd96312de1078f0343fb18b6f703273febe9c6a3be7ebfc4d9eb82b796f3fa86fbb3bed56d31cf0613fb03bdf4cd6b24fb5e8678d6c817998fa71ee8a839418faf9ac578d7f360e30cb5b592634b86e064b78641445bfe29883b444ee32ab3a2d25ba6249560c2b56f57ed2
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (29 mod 64).
# DIGEST: 7b0d19af32e867b61fe57398a3ed863a56666fbb67100e6a5ff01971ab693fc8
KEY: 99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad
NONCE: 409ae02116417dae0cef457b9e5e16dc
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b
AD: 436965aabe477e0cdd46be
CT: 5e654ee6344f96fa117a2e1f9cdc08bfaca9c83b1c4d61891e49077c8ae7a8aa604e1b19995b32872087e04a59ed367e42f0ad3998cc2112035b33104164403a948ecf73c516f74adaa57688cee94174ccd5f9c7a9dfe10dd843d763c6
TAG: 1463adfb0bb32cd1573ce92e65dbef1c6fa62943172705d5df92b654d50fef6ca92786a55c3e5d28b70739cc3be99980c67f646cbcb840f69aa8bab199aed6d77d070dfa605aa81df92d211c31af752ce517bea945c95fe5953e14c129eeb3e51f9f58fa56808c247f0154624724bc98f0fad295963906b4a186b6b759f3129ca39a5658bdd5dad91f73befdc71e8c21d9cf1517a9bbc69c065a1574f4d84997e4e1a21d69f2822afa3109482a6e0049aa34a1a0aa1778adec7f58ccea95678667743f30a15fb4875ad3195b6fb0b9d9cad0eb36a6e736280c7e3ecdbefa69c41cf5f97bd27c3b6ff11df050c51d90df67e12c03afeac273099dffaf0870176232df3965df87be3f53d41dc53f56120a31e74c
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (30 mod 64).
# DIGEST: e3b7a347d9bdc63bb1c689eb823076d5ab24c3f502c328f70d71a1b3f00111d2
KEY: 371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad40
NONCE: 9ae02116417dae0cef457b9e5e16dcc5
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b43
AD: 6965aabe477e0cdd46be99
CT: 59201549a3446dcbdf5c3fa8db930606f6e9bd374d8405e15d55493a82035491811f784fd4f0e3bdb6bdd2e01558783a00b32c53d7be31525343a5a2d72921222e32891149f8dd38303ffb584485df1578e10a3aa048972303c2e7a2b630
TAG: df451bc64666a07ff2647e41aea895a4794217cf995b36a5e71b0df002f0aa44dcddfa01dccf8eacc1aa729262c1e70e91181e2f2ab353a856dd8157ba12e300f20be0d828b91b04f67e7a3e54f4443e9f43d32dc64985b73a9b687c3acf82e495d9ed0565f63c355045e991c9af8e93e2b912519022487009632adb94e42be70c1268ca3abd10e1acc02a7283c938133b68b58c063c2da00dbea6407e5751ea03c5899a615a18a26ea95be5b82818acf11f51ef8fb49e5a0e742bc7da8e2669cb2833143d7b8fc990010a5885808ecb294246301be69479d21106982bf906b020441a88899cd6096e1afbca056bf66339a02bb22993c10cd0c6320419bd8f61d5dfca05d543076eab65af5ceda36c2872f7
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (31 mod 64).
# DIGEST: 9ee27167f084f493a4e6e5b80c1cd07babdac057ed98dc28cea1f107ebc68787
KEY: 1eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409a
NONCE: e02116417dae0cef457b9e5e16dcc5b6
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b4369
AD: 65aabe477e0cdd46be9937
CT: 54a2f87f11c6597b3013a0de46b61a8fcc28ab021465178138cdd76ef01c2701b3a48ca4d3cc885173bdeb33b7b27f9064d2f09ec187d0c9c482522fb29bb421595589aa69ec2ca4155f503bdb8f0f8d79a5870e0d0be26ac239c56803ea81
TAG: 7975b116a955bd24273dd59c90130d59dd7d4344c2480064fd8947609ad90b6fdf2ece45a4c9bca094922af9c092336ecbb14e54737dc911218af7d385490a7ebf8e5e742924b332246d1c65ffa36a4d5d92f8549e1d67a7f7ee09d7a782cb8cc10c0d90222144aafa82b40e5347f42e937779515683062b6ce1841ea3eed2bc0af7b02567c2cec30d34ff6c7001a94c4e8cc28d4ae4f208b4e5cbd630909435e49edef7a63d036aaecd7a4e3aad81d8a9738bb627092e925ccb75440a05e0ae8773f7ebc11d61a49f4eecd74bc7d5512ddc3fd930a40637fc9f444634b09a9de52e35fd950c064dd7858d8ec0ec6cfdd62366aaefe6789e1b70e596e821352cdfef5942e280a3a02c7346f51d0f3f63f5
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (32 mod 64).
# DIGEST: f6b15333af80c49e8ea591c2272618074822d453d85ed3a96c29f249873acfc1
KEY: b8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae0
NONCE: 2116417dae0cef457b9e5e16dcc5b6f2
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965
AD: aabe477e0cdd46be99371e
CT: 0f0483dd1e9ef91f215f7f9817b7f82e0b96c0d3b2996b2a1d878d0be3a70c07a4bbbba3721e646405a8a7f44347557d482d7899044af37f6df054070eb4debf7471072af1e4c98dfb3c192e956b2931967d7fdf200b464be1ff1955a658bf86
TAG: 180e408dc7f0eba0dfd78cfabb6268c9f22c3d01895476a0b5e6b4f49af416fdfc2c6b5fa770db01bf14911c3287fc63279d67670966851d61488416a7cf636b0c4379cd07d0af5ac12a5fa73deb5f5b917307137761a2dc419c78519c207b66e04e018e650f202ed21751acd5ae72b42a66de3e93055b3bb4f69d57cbd18db29d6dedd2275c87e303725c8d7472dd3196aaba3d4182f72e48f3b46d2179e401a4dba81b87ee95c013da967901c0ffdc244f2b4c1645cce4731ef62a68ff1c5bda808d18331d64694801b6d668f6cc4be147ecf4c260f2ac53b6dcf65683ae430ce6ac77be9f9892af33d02eb928b4bf14c98088988b5dd2f2a9d21bfc4b745b4b701eed508b7f0352c84d8bb6ea5262717cffccbc4b8ad5f52c20c8dd122107
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (33 mod 64).
# DIGEST: 02dd1eae128cbeb47dbbbf90e2f5cd63293bb0091815c93bc1153d46f176374f
KEY: da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae021
NONCE: 16417dae0cef457b9e5e16dcc5b6f256
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aa
AD: be477e0cdd46be99371eb8
CT: 978a10e04037ba7f0dec2576efaff6e5e4de5ab80b4b0c0b8a6209e22da05b8be0f832883e371c61c23b5bef969c004bf2a0f0fc8fbf1313078e12af2b3569a98ae5ee76a9bbb6da6806be3356c02dfa607c26094fd876d8f9dcc0395f3fe35630
TAG: 963465dcde83c1f5833ec41c413660923c5ff60805f640a727f551d8349bbe0a90f41d97cdc07883aa06de8237b96a6d6118753745e4955855e056280106775ced9a7fe692e85aa99e5c7af4d0d619fec553ce1cc4f121b42bb7343968059b8ac5d95ef3c28fb672294dfb2cd58fba75aea06dfe70a90e40971551ad11929359d720f4c7da32373f57d85bd31b6cb95e2f0182c244c589ad4f9121cb717c1fd9298bdb4ae240dc9d144c2279924b2aa956a9a62c19b1816a88cdf83d169ba06849a012c83285daaac7560d1d59e2d24dea97a5b5e84fb1372dcbdafb746c4ba8b6ec786b9c21699bfd6cfe05c8be97731162b8eb62cd305ee5e275bc0371fe1a1ad0e74c0e518386270096dca101eb77ea0f9d23cb55d9bdfa3dc8352786f5
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (34 mod 64).
# DIGEST: 137fc408ae1b3684a802229d78368f9fc2202311cd6f5da091b2eb998ceb048e
KEY: 7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116
NONCE: 417dae0cef457b9e5e16dcc5b6f25607
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe
AD: 477e0cdd46be99371eb8da
CT: eded0eef58434338153caefd914cb98ff516157445bfbd25c3c5cbcc0ad68ed1bf049ac292da027acab0310ef08d66040341721524982165cfe7f6dc495f7f5f36cc410470e3b42045b718f580713dac8074b0e76a0345d11c94a9800bb5e5eeeaa1
TAG: 96f23023f81e6df33fbd6bb66f5d902bea2e91725f5ee0eda35fdc528d9adfc180a9faf9d5b49e015aa88384fa9fe9c22607292577079bb11bf074d5dbe0bcd683137449c15cce948e8faf560fe8e24fa764c03a8b5a8629e9c650cbe57c8e01da88659b6836ec59f362175df032a80ac4fa0a6d6f2110faec6067ad26b1182bf871982ce077b79736f29760cdf91c13939d8bca21b6c85cc1fbaa18ebb98dc350f1bb0ab4275f4a0325208a29b5f90895ea1552cdd9a1e05342b5be18bc5971252a1ae75cfce449c7b5d2eb0bbde05886a68e772e24689828c86c6f6d2717b8a9e035afbaab6c93789b015118ae6418b4e8388ee6692ee34c2baf02e45440088c67248c8e1803ddd0f94834bb3820fab5ed1a05336e99081290168c3fcd
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (35 mod 64).
# DIGEST: ac9d4fe33627d4e9868c57a42aab21659ccc7efe18df8b57819b7d25e665454c
KEY: ac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae0211641
NONCE: 7dae0cef457b9e5e16dcc5b6f25607f0
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe47
AD: 7e0cdd46be99371eb8da7d
CT: 7c433fc5255dd1e11f67c499c6a89c16b4b09355818cf304f11167bef253dc60c95486a840c3a8f77440f63a5c6a855931a90eea66a281d51d4198679e1420c824ae5c8bc0231444b65b69832b84c7b5ee2fb8484ac08727eb0cba0c14e7e0a93c4eb0
TAG: ca78160fd3dac00b2bd95406775dd73b99866fe209f372768f80c7c4f72ca9ae6f78808ac65fedfd62ea880f451ccad75dab2c692c0e0f4656bbccb89dfaac23cfd967a5a7fce24f7b872b417122cee869ce593c6025354abea20d5fbcb86d0d81af4314347b25e2d6f4cafb33f192fe1095b24285700c879403aa90e9096dfcc7060661fb32376c8674c68bd2b6bd801794b3e9a9c66818e2c6ea41db10f4b890bac070d29a08a199efd6c0c40ac555b419588ac084818aa194f014afc4de9d447ce09c02eeadbf6e706fa9eb46ad6934af479e51be512dfe6af009c855f822afa11c4c3689dadf989d662101404b8eec479e191df14604ff1b1346747078280fb41998bcd901842090b3ee068da1097f908fbceffcca6f81554142de
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (36 mod 64).
# DIGEST: e59c699ea2887f6c829b7a0e895c45710aef6911fa3c930de3da61fc988e955b
KEY: 997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417d
NONCE: ae0cef457b9e5e16dcc5b6f25607f00d
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e
AD: 0cdd46be99371eb8da7dac
CT: bcdda7eecf3331f4e7605cfd33789ab585318bbd35047755402372403a4df125e7f5bdf857e49a3f74cb8e824576a226c1942fa86de07bbf564cfb384d8420a367963020613dd2f6bd4f371ca1b53532a7015dfdabd07497367aea8db9298141229325ef
TAG: 13440914c85b7e154828290e09ac244fe4cae2f9f3019ce37d2b34c8b04ef7be063990524798b64646f5bce918de25b19ca5ce8826fcbc26dce412f97d1a78dc121e0cccc20821a153b65b8d40d8ad8a5aafe9537521fffd26de9380feca57cff1151b2519a2b72468ae1c85e66cc567b5c828488e35f45cc95defbcb7b08cd440484d110a6cc8afe2de4a77cd19df6aef85547a082de228a8d4ac8a0862078e07ce324cbddd2fc233dc11c4e6e076ac1e5b4a7c85dee0e0a0250b8ce4be19604623e8346d5e0da8a95e85d12c8e911b1d8a0f93a2ebb68bcd5465d1c4798ac2e76fa65d7063d6bea3b32881c8523d127eb6fe74450cca213c9d29d7f6dbf80ffbb5395b20fed6ae0608a159a853745e4f842d3c4c3bbdd8762d2810
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (37 mod 64).
# DIGEST: b0ffb7b78f23593d738e845daeb3ed175ee48ed5ed2d827565030b047dd0ed17
KEY: 7deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae
NONCE: 0cef457b9e5e16dcc5b6f25607f00d03
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0c
AD: dd46be99371eb8da7dac99
CT: ccecdb03830e84c5267a5b6f68dc909cafe94a1c872602961e8467b4b2723af537d79d723fc4e8f0397fe169186c23f50cf9e78af3156f507bfd38181dffcc05695583863d8a167df062cd16aeec0cc548a7b5e16b148ced8bc2a60a33a58377b987a53b95
TAG: e27f5bb5d85a43237ff065bdf963bd8ccfcb59793dc01c52f8a839d7e018222cba303b6a02f05004e8216496e36415efa80025b00e0be713698f95fda502ebefa8369f5d99c080dc851dd7f1967f1977136e8698ce304dfebc2e023ebb61313d1b0b2b169c0e6e3f1d6fbff3b5aeeda703c16af90bdde0783b2776d94ffed024296a0c8f4141af04e5ba5dcbffe8680b4f5af848306e4e6974acd173556f735c954397a4871de74a12a88f3bda3fb590fbbcf3d14e1201d401ee658fa80b3a2e81f55783582fc1022aeee5f7e7bb8af36ed63c82fec6ffd875a01c9626d52cf91c6b7ceab2e195e2dc248769cf829250b4300cc23cdbbad6a8146314838ede7b7e1ef9ca802d110414f6e5664b91b801060b6a16329c4b8d9b555e
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (38 mod 64).
# DIGEST: e8928848fef7e0556377fbf3ed36b4105f334fa17bd5c5fbe2117ef82051903f
KEY: eafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0c
NONCE: ef457b9e5e16dcc5b6f25607f00d033f
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd
AD: 46be99371eb8da7dac997d
CT: 2828ec3db18423dc583c7ac7dc5231da07af1756d7c032a866c64155626be3b3a686a93699023f6e421da24596baf99b45244d07d86a8973450afdb87ff2e9dbab6fcef52cd476f1f25f27f6bb3abf9b406704a14ce9682613125139b238d9853c3fe5e948d2
TAG: 7305f0e1fb25d024bc5d6d9026d1149ac535629c76f3c230a06398af0a1e1477aa6128eccd4714ad23b0008a32569a8fa3ed76a00c05abd5d4be887f97d8808eb9a25471e8328a1641bbc30e7aaf110b7e7aa2c81ec733c7be97be03140376ed808f00a710943ec9a5eed3bb62404d2267688dcc5570a21e56885338f12503edb7d1817586963fac14d4fd0b44336656e68b6bc1af82cb6211b9cd2ed0b5c2fc7832e759bfafd123f7812ebca13e000e80c0761d63807ee04f5a866a507ec2fa95b4ac5bd15502f8b3aa3cc906e41ee2268342a824850d17507405e7029c2ce61a3331bd0168f40ed99bb09d05b9bf8d906630e6b17426e83699ce9ea48ec0e0567fea02b62f83e14976444bdb80de1559df6c7b16c1f4639b58
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (39 mod 64).
# DIGEST: cfc1420c24eff01a9e6acebe2a96090e25738c3e1c14da2c6f36f9e20a857165
KEY: fd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef
NONCE: 457b9e5e16dcc5b6f25607f00d033fb9
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46
AD: be99371eb8da7dac997dea
CT: b463f7f24871b617a1001d2f73f9eb8fe39b5fe0b382d420af876defd68a893add2eb6cac45e56d669f4ac67a943a3b32daf0932072bd701f9291b5020bfa9133d2875d8f6ee78ce8c49d45b80329831799f1eee8c712683300e49c57dc8c1ad83f7716753e7a5
TAG: 5f037d241e016785b18877a82a891ff34b22caf1ce927a47a694a72d2ebb927b23ba264dd2bfc0b5929ffc66a18d1efec9dd91fb7b103e7f734269ba07382f320beb19bab4c6669bcc99c1306b1bd5f26ca8c98a520bb0c12bfdd4bf1b4336c550cbc6a3586f51702aec5c3c2d1923960a589ced9069b2a8aec7879ad627541e611842c8e6ef09e9f6ca61067a1fcc1947c1a3cb437a347206e9cccf6817e01f958e6de776d7e60100e6b8d7d350e59918522f96adf211430b32e8692688445c99204ef9d59c6d35e15834be6ec1623fe89c048251e8f38436197c21c65edeb0ee1334a4ac262bed07236c5b46b09e9c2dbf91772c4a9619b98b054037af1e0a5c1354c9f0f704521e310617b806f317ccb3809ee58d91d049
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (40 mod 64).
# DIGEST: bdb122b808f40da0ae98fe9ace91fef7f2b39bc734f4f735f7cbccb2c00e4666
KEY: 64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef45
NONCE: 7b9e5e16dcc5b6f25607f00d033fb95f
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be
AD: 99371eb8da7dac997deafd
CT: adfffd8a654da994aa8adb618cf69b25ad5dff201cd3a84314796e0228ae3e01be77cd8052e950fd74e3d8fb0066705874a7319dda8bee7bf7748ad844a70b1ee0d774a6156fef109dba8346a68b48458728ebde458e5bd777a26291f98cafb1684b200f84b13743
TAG: afd3d8b88f6846623af7588123e57743a37939244e723b69a20568123485645d1c714c937aa5974666470fb040ae1106d6fc2b48f5a58e44aaa6ef8cd4b7704c9a424558a25dbd6986fc695001680505e03603f4237cef08ccc81e6319f4586cef9e3accdc88f297d1913418bfc75ce2bfc102cfe85d71c422c951ec83bb041a0e740f220badafb9ec3742f4752d45f0e949eb2e63b2d6409eca3b4ce438381fe551545684ebd78cf066262963564275a3486d6f48dda57656c2132f3ee874d11ce5dedb90ee58ce23da7ef7c126957736735a8c8762c1d5aa03542454f7ae6db0f13408f01950961680d7ca85b4d3f7f02d5f0e8f85ec613afacf90910d0bcb550b321b3ebc47170fe082e5e41675a4cd33bb5b11a5a4b4
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (41 mod 64).
# DIGEST: a1c40dc7a17b3ef6c9170eeaa9500014ef9ada833615b6d40af3fb2e14d7ddb7
KEY: b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b
NONCE: 9e5e16dcc5b6f25607f00d033fb95fb0
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99
AD: 371eb8da7dac997deafd64
CT: 985481677ae867b2427182edf3de86d7b9956a4970b107ca7e01e90ee7cb02c6b9a46212e1b8ce67e7aca5e2d96272c2f412b5f16a7c1d00fe597f1390c3a686724c4846c78ae66b26ded18adb40f0d74c33a68032b97d440104cb7acc755ad759ef9b371d04e4394a
TAG: 02dc6b8ba61937d3e551c3207759d54de21b85ecd47c2c22160c6b7af023ede884eb7962d1238780e64fceba414ab543cb0177fd3223a7ad67f6bc74932de90aa195078805925df61081a72b96fbd7f68d2f26996f787ba7226528d2c26cc512347c1a639f01d361b5e1b41c359ea8b832408ccb0adee18f8ce9cf1dbc939029de54ff7748c9cf5a0c6c3b37c5fb0f39c8b73c3d2fbe5e20b393e00ff38b7d8ea4f5dfd8e276c2172b113cfc6cda46b930ea99c2c9716475368b69e0af8b2976c585bfa1cffb301f8b321abd1f2363227a9f2d195bdd772354e2355e9b027043d299f2a96721d9c0657f4e4f0820953173af30b832a8a90ca2f1bc0365207da62e857dab5abe31be5c6ed4d1bc01db223cdbca7c1c4d68
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (42 mod 64).
# DIGEST: 677f053b9f421414ba91c060ec7ed66d27982e992da0372e5264898c9edd2bab
KEY: fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e
NONCE: 5e16dcc5b6f25607f00d033fb95fb09e
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be9937
AD: 1eb8da7dac997deafd64b1
CT: a06030a844e38f9e049bcf318b10e1cd2db6b60a2611cf9788f0c1fb31a366d2038b3a1692865b926196594850807895523a851a993b77e49c911f840f28aaa42b4f427eead4e2a578d57b101bb4795aedcffc58212e0eaecadf503e3b208eeb36c6511dbf87f8fcd695
TAG: 3c5dab36f4690dbdcdb16d6cbe1ebaad64f8ba09bc9b7b112ff64fb7a21ba22706d8fd26318ccbfdf0ad944a8e67caeb3a939bc5384ae29524ba853ada968303db3f56d3c482a37bd8f1bb4d78235c1eb7e9eab833953def9bbe913767b871b626677f0b9420204a7d62b6825a647bec84c0da4c406e1a891586681e1699d4e5c348b6582746178ed5e1d8985bf265d2bf55cb553d76f68d2b3ad81dd9ad1fe409a604c3bcff45746b8c426e73d424d6bf3d6075db622c7a5866892805e4d4d653bf98a8f512766ad5a27aeb8f6badc00c49901c13d8eaa01628c667c4b48fa437c7bcc088036b44e0a195d1da95fb9952c0aeeb1060fe8a21c8eb911247e65a48802e9e6a55a3a4c8ba9ef90fbfd4bbf22afa803673
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (43 mod 64).
# DIGEST: 9c1c2b1853244d015dde7f4068220d7640501b1aca325b82c1be8c015b61e59d
KEY: 65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e
NONCE: 16dcc5b6f25607f00d033fb95fb09e4d
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371e
AD: b8da7dac997deafd64b1fc
CT: d934f61f94d2b0aef2b63668352d2af2db2e225d0c8dd86b8d7c901de7425dca2a0d2f3bae9dbaef4946d18ebc2d9f4cff5c268cfc80b89c35f7b1a3de12173f9377a7ad9b33751fc89390cea9b44e80423702a9848c6d2562d24838e3b0511bad71f4015da53ec8c435dd
TAG: 1ebd06a10660cef77361e20c5ffc08b077df3b79a4bf3333573469e4a42585771daf5a85eebd7753c8a305b81c32ffebef51a9827419c7b0f1d1ba5bf5aa3c947ba2db788747256a5e8e8644a66ba7c04a54884670aa7ac30f14ede3f38686e0b482b248dbc3ab8e3e39b939b22c21db990c59ed728a2f11eff3508330f29dee7d314df8304af2609739419eacce7d06c9e3073581e91a811b2f96710f791baece65a19fad9f94999158dd1261f1ccf7881c0752488a6817a373a7d25d83e9a13c2241ee0ce9355a2fa908974dd552514de09fcde23a5f744437f38d740ea8d950e061c6e19d6cf58a8f032b24a9ab7b496478fece8e273f1aac381af28679996eae33b01daa3393890d93e27d7c6cfbb9c7e25ea3
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (44 mod 64).
# DIGEST: 6bfc1f2aeae329867e5d7f268979743cf267d0dd73b7882abc0240ea586b21fd
KEY: de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16
NONCE: dcc5b6f25607f00d033fb95fb09e4d00
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8
AD: da7dac997deafd64b1fc65
CT: 413d2c3fbc77845409ad66cc13432824ae4ae109379a9617e8b93d4f9b17fe0d0450476c3f98c229bf35e86fa792dceb4b3864761dd442c294e43b1cafe1fe086cd1ca5e1572fe2b3753c20a74b663b536f6e686d9765bafb10566f2b5cf02ee77bcb753c13186c4d091927f
TAG: 40f0ab390d64582df98890aa0edc3e6b920bf856ebbe65c87539980aa95518ae9feb5353a6881454f86ce986a8d5a8dd2c65c9baf91b9f0adc103983ca7346574d909399e4a3ea228211e06fa4ff8c716351482199c71a53d08c908ad0443d39d6c57c86efc1cefab52e701ba474b370e60f694ed871ecc06ed6f6f931fa277d00f94bc0b19fa2dac026126f745547c28e5eccc60557087d6ca78e83def0d27594c82ee365859fdd50261aa2d8f93f8a3925cb689bcd051bf45f001cbae68f91f294628cd8ddcf54d72570e15238336ba002c0595580410562d428a00ff88a80686ea256a3510bf70cf5028cb43d84c363bd3d463fd6231e708b9c13e01aedba7b703899bdfc5696616f8f3f0a85ca2e092b3458
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (45 mod 64).
# DIGEST: c1702d4f70a18932e2f4d3951603ed904588a990123e0a02d29d7259afeedf69
KEY: 39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dc
NONCE: c5b6f25607f00d033fb95fb09e4d00d6
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da
AD: 7dac997deafd64b1fc65de
CT: fca448fd13c6877aa9fc299953dc631df8024cebe774bb14839821b05485c4a8f1345697b072342343f6a5479d99d5ba0ab29db7760b1e21b37969333473e6fd16bcc5b52e1d6472fee31034d515f66439f092341036a48d637ec84d22af8d182850bfd4140616471d3b5b41da
TAG: 8dab3658a601045d948222390159aef603aa6dd7a44ee2c0c5a688a6d87ae21cdc7e3a16521c41e1a4c4b46465484d32306b9cd01f92058e837bc0abbe328604bd46608ff38e225bcc898f5e4478d04f9a671a7993076a8ba39112f34d110c699a524fa4e7b1d6202641dbd0b401c17569bb207f61613064bee24c1dae9c3a67e7774682eaf2846c11bd849e33fb6c6fc2ea4ada8d115208914cbd6523a74ebf1364d38bec9dd913f01cd15c7e1e96001942cedd7f756194d0df3b095140d1d85bcbbb8c6810446b96c18c6ab728073bc89a0f6e13befec438f008ed5e13d4c4468436045773b173aff7096387d25bf6bd2a6d3555881f1b69b99750974b332c187583d0751720d554219124e6ba8944a33a35
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (46 mod 64).
# DIGEST: 09ec84331099e1d602d0998d99c199a6037255a5a4d96bb3af54cfba357bbbf1
KEY: f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5
NONCE: b6f25607f00d033fb95fb09e4d00d617
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7d
AD: ac997deafd64b1fc65de39
CT: 8c5849a917c328d68cdf4fc279b29efb0c3c1921621276ca19206c9941a5789b0aba7283e743f94a6e4142f7febc9ad35df30daffeaa5cd0cffe0fa2e4cd5ceb687def585b2634774a01a3f00ce2ca9951fb910b4386bd0d61d1e292b2b225ac68617962b28bee0d40f195ff45a5
TAG: 7efa8ddd692c0285de19d483dc17b89babd2143390b72e06375d88fa3f37ae611638c82ba20627ff311e8d29d2b4bf850e01fad1fc2150cba93d9fb52a21a1ca6c434783b66d5858eada584e4c8227dbfd329ef24eb1fc75de04aeaf811b09d67e5675ba0649fb784ed92c0a8893b77ba894d6799c4c2ec60a02dba67958927a22f5094c5620f89aa78544270d65213411c2382b4586e197ea45ba5d3425c2f4975a15e073370b358511155d222250148ceeab807684818324e48fe989eb12234d8023370de80a6fd942872d176f93f576514b1382a7ec12108d654bf0029196abcffb70c703df2157dc1c5f74f191bbf5892a5a6192bb0f1f1903ed08ac36a5060563405d150d0082ba646fca777e765f33
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (47 mod 64).
# DIGEST: 7d506a5c0299a82f5f93dd69526156e0de9aa5cf94f9fcaa12064ef920a1c5b6
KEY: f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6
NONCE: f25607f00d033fb95fb09e4d00d6172e
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac
AD: 997deafd64b1fc65de39f4
CT: d0076d9cc2f829a33a0b1972f6c0d8c67718a7593975798e0667135db3ce31b4d9bea98710909313a4a2af88bae720963ee738f26bde44b54dd5820992569e5d2eea000baf5de9e0f76dc8e0b93244a8474beb7e922a5f30a5b5977611594af258e26fdfe001e0e3573eaf8f8cbbb3
TAG: 3443426c166f9329de723222f80fab5c2c36855a9fb63ebefe6c7675f247328b84078869593bdae8b217859332817d88ed6227bb64e338a4ad03e881399702ed04b00aa223e57a620cc2330b19eb36bb7798083964e169f8593c8bcd076fb6ab923d443af0656e43ec069e12994f49b955e5fa42b800541233099d54b9b06b061145cfdfb6c67870b6ad5c6d5c7098753d063fe238a8a72184654087fe21133899a13dd3606ad7d61bbfd380284af41604ad9fb7486115170b9dbda77cd289374fa79d3e3811d87de3b645b55d976fdde37e93bee6e4552d55ff5ff85775e0682df3c108565639592228f722c9543df2951463377928f04ed65ecfa0c56262d19684ce2766e160f45b2b43cc2a70e88e5b
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (48 mod 64).
# DIGEST: 5e9c0270955ffa14e3383a79a1cfef00baec4e8be496c867cc14dbcaf609b61a
KEY: 3541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f2
NONCE: 5607f00d033fb95fb09e4d00d6172e78
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac99
AD: 7deafd64b1fc65de39f4f0
CT: 298f670117678bd139c60399dcab68bb0414829b458c747b0dda5dbd67f95fa393bfd2719f815a12a2b7c6b3e769b61ddb4651970b30451cee6166545d8e4c4554c8217898186dc02684c5025ee692e12130ab41ce75d79a4ba1a4dd02e0af581a645979c1a3c8c12f5b13e9c1113316
TAG: d0c431153a8757861b003602fd6d3ebb9e6724db6cfde4708b4838cc18c51b9bd17c2c84a66643b31768a745a221d8b4e7d2c8a8245b4c405ba37a8010e0517521b46458a49648b4bca3eea1f01b15e6c65c6434b6601dbff307111d2e77e440365272390524d527e043c5252471ae604b9637423cc9a4a0ee7a99859aadc26aff9676896d77bb8fd15d6834bee492ed85779b94f76c0c6aec2e10bedca5bc0a648fccc3bac478285fb85bbf0d9d43c03f7bba002bd0762ecbac2b10d42ab2ae9d3003a775628b329a282c55a27a17c9ecfd083c70c2633f2803e3ce7b7312186e50e48f1c48f42b8a3cffb4d94c14b86733fe374e12d0b68ffe864d04acb9295cc96d557b0634f44182c925f431e2168bceb72cae8ac3002434bc7951eb58cd
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (49 mod 64).
# DIGEST: 57739c0c5b8e1f0255bb93eb53822ce8688a4078d971c0a51e757a0269760bde
KEY: 41a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f256
NONCE: 07f00d033fb95fb09e4d00d6172e780a
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997d
AD: eafd64b1fc65de39f4f035
CT: f72c519566632f89513f3f278407845ff8096a5b63929f0ea6009c3cae0dbd853662c4017ee5729eab92f2c475f0a45533de67d4b941d4b16c1964986d8f4a16cc12f02c28442ddf5790f321b3942cb65964587f3fe55ab28064c52ce3d3598d3431788ed2c26fe1b196abfd35afa0f7a0
TAG: 272fe10ff7aa3a6e1e708647b30ea468b7676df14b88642bf6a45dfb07196147fcce3ec70cadf1a3c6e8308df7d1bcabfae38cc53e356d7a5a9205c3c4a4ba93330f234ea5d83163f4e0673f1b03414d7c4d56444b5772e574224229eae3b06c787d61931a5b67e148f57203739e16d4ed47a8a838179d2f2de404940d28dc348cfeacac92dfc099a809167422fc462ad433f1a7bd5d4f3398b1199492531c48975e4d8769f872393cfa05a821ab4cec2a173d187d59c8f5c26a3ff5b180bd6c02af9de6ff03639092fbf1eee9eedf505456eccc68327824898ac70d5f098ab8dde38511549e9520f41b578f715057b0ee505ef11ab177ed6c8bdd67627c8ddd5aba89fc9ab84fb748b02137f28f1aa59072929f067b8ca0fac0759d2c2317
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (50 mod 64).
# DIGEST: 0ec4072fc3c850d4ee958a0af170d5aabd223b024c617df36f4ad245d0304c0a
KEY: a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607
NONCE: f00d033fb95fb09e4d00d6172e780ab8
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997dea
AD: fd64b1fc65de39f4f03541
CT: bc6acdf0943ba34efbf9eb27fe9e968f23bc1d4f1eff7f86e836621422e7ad8e1adc03249475b6be8ec5d3e96e167af7e6b85ac87b5da2364b1e0d87d5c49d43ddea8e9b796580fc4fea7774f8210e4ec424aa029717937bf76b148e8af72e8badcc3f12dd259fd4dd9a325d81cfc7a188b3
TAG: a5343f428a33670552af3bbdb5b97ac5b52539ac60112fb6973224088e3089712b64f411d0288827180373d3989bf682c95a303700bb476887da936131fce26835b3a413bb24ffb6508d6b229b273954bda18670a04c65b2a30e4159f84bea5e60fb8df734c792bddfaee0599f19f62f54a37abd2a456aee65dac5f9bd946a244ade11308bcdcb14b4ca37fc1c7565077fea06465ddbc03b459fd19e69da017d1d45bcd427babfe31778ebe3629adce4c72264bb472762b6c4c9eacdc09584a05d375775e37be64bfdc5e0a4a3b63959188c1068afa05bdc12dba42311160c17c11e930855fcd0a7541b728f456866f577c57a979b4b9722658d237caf44b9fdd5ac55239b4e1328fbade275cb41a72cc4e08674c5f05223d8a5cd377d2b
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (51 mod 64).
# DIGEST: 640ba3888e6cc260a6022fb69dbe5c5267dc8604aa92216e11888394fe59d292
KEY: 1be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f0
NONCE: 0d033fb95fb09e4d00d6172e780ab8b7
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd
AD: 64b1fc65de39f4f03541a1
CT: 0e87c57c18fdc439c968a9dab086c88271be6dd00843879ae1563e4ed03d69f9fa09a29c1bf99b1c859323eb8452acb2f808f051669bb5e097e23b947369b5a0577157995d729a75ae7a65e293acace3124a8aec53328439e5f2103fc3a236728682fc129a5b0e203bd730303fdd2396270e00
TAG: 0f83d6bddf9d40d259dbaa002acac91b5e7623fdde5257b305581f67322abc2bd2c78f06196f106867c67eb23973e26df8abb47c47500eaccbe39292cd854a9c2376f928f53d124f6489b959f7a3b70c52cd5c01ee29a77698dfb3706ef2d600caee9707e8c18fcb9622ef34fa396ef4851498f9bfc7fd0160199607db896162cd7d9bcad5c47ddd8ecd4fee7c9028dc546094e7386ae9fe751ed5ebb5bcce4ba084922e5358b2e1e5a3e0ec2ab08fb33e6c2eb50d8bf8b106937a948ca0ca6ce538b08974647d305e2489ceebd8d77e8541fd1831a0f7203c420741f3bb8f2d894f890c04c6838e82a8aaa14b5f22314402890852b61a3e95b1811c9bebcdf65a9f358c0b607362a855c70715bc3cc38bc97c01064a843cbb9f9e1578
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (52 mod 64).
# DIGEST: 7c10e4553a91588e2c39060e9b438736721926cb7bf53858293ad763e9b70fe2
KEY: e112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d
NONCE: 033fb95fb09e4d00d6172e780ab8b700
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64
AD: b1fc65de39f4f03541a11b
CT: 688cd509094cd4bbc4084ae78885afbd16845ca8cd47077450408a85c8f3da0025623f3365a65f04d281ba5397fa74b6f90e01cf138e01ee22280fb3a7d4da5c1a3b0e0507bd46636984a0b91e11492ea47136b32c2f364cdfff19625878ba42a4fa736bb277740e58e4aef156616715f9ba2d84
TAG: fd1520aec4df666b38a77b5e8921addeec555fb803e5f56edd2d5822cfa8e422f5cf988860969cf7c9dd58bc80cdf8f5964b91182f6f45789d029c844e406c4fc4fdf313bee180947df1fa9f51e20706d746723baf917e23f110c7fbbfaa15b7bd8539b4c399d4212eab074e439249c30647085d305760dffa861786ec18e4d8b1b94c0338723fa2757d33ab9b2e8b3e26f94a5779270216c9801f7c330bdfe7de294cea505f4cbf9dfa4dca7638b4bfc31e6fc582aeb10f606e77c095ab7ff434e104a8a68f43408b1ba055a7d2fbf80e1dc84e0c1fc6ef754c6af823027c9cd63514b962e31b6932c1d9420fd0b510f845546700a048dc1549ae7877b25266d838b0a848349b3ac1fc3e64503e0a2c79eff9e16940681629b2a156
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (53 mod 64).
# DIGEST: 0e88468ae741a9ac1114e212499c092ba60869973f2cdaf456ceb336ad40cee9
KEY: 12a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d03
NONCE: 3fb95fb09e4d00d6172e780ab8b70043
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1
AD: fc65de39f4f03541a11be1
CT: 21be2dfd45845471a4356b8729da67d713a6aec1b72119e38626317384c349b06b04901a789f95bca41ca42e89549be13e29dfc322d3e88f9fc8c0129626c19ef5bd49c2ba8838c0fc3e04d48e3f5d69d99a07a9b69722f89cc896b1631f5e14458fdedbb6220da18328ab02ef8c72330c077b89c0
TAG: 0e832bdd33e00ebd16c9c3f6aebb3d9a89838462eb293bf94f83ea9d5e7b694330a143ccbf189e2a6acc6be8b4195d4a4c29c311e89c0f61e4e18ffdcf6100c69d837213c64f3b902314465231aeacebd86d3b8a1186e23abfacfb50819792020555ed206029ce5f18dc0aff8a8f7872f6a28c6a07999a485a706a670cfe3ee5dc307610c0e29656935ac41faae3b8f344cda2e06f46599ec4a338d23adf76b4dbb15963707cce130a6c35cc42ead1715dbd55eb26bb9e54203a9635afda43f2269a518b83041dd6f519f33d521f221d60cdc86be9c5d188afe2e80ff43051544cbafa9dd958e41a0b26df06698535ae3aa826241045bb980e0009132f972a291564eddb45bffe5d133c8cfbf013c1cfdb05ae13aca462c8c4eb1d
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (54 mod 64).
# DIGEST: 4bc1f00622d792e473151668845b2ffb30c43027972bf59ff86ce53a380f2aea
KEY: a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033f
NONCE: b95fb09e4d00d6172e780ab8b700433a
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc
AD: 65de39f4f03541a11be112
CT: 71fd9ada130acec7deffa6a53eab506bb5fc80ed7e98e656a5282cd88cdf9c253a87832ac42dae0e8a476011b11cd5c075c74b0f29c1c966983f3fa69e00df1ea93fad4942bde475e7ee08ea2c5f6676145c3dfb8d07521133468ce6e573b789a71e59d622587f8fb76e93af95b0c47e347764302bf5
TAG: 10e23776607c4b3980eb7ea6a3398defd2aad76439f34c2e360f60aefc52f030f969c761fde94aba35f80867065deb51773479233d91b1b11b52f84237dd3a20ebd8668f685d372ad884dd074cfb46e115aeb1e0d6de5001ac136bf7a0fd0bacf214c6f71a19709998fd23f9ecd1ef2cc4cd6cb8f91f03daf7d89098f47a2f29833fbabaf5b72b2ec17c5bf052ba3be3e6567431cd02be7b310b1c3fdd0c69cb0acf10660bfebde43ef5dfcb1717a878e024b027c07bbc6a809290ecfb99b8e2165ca10eac2d15846b6512cd1ad4065de5805dcaf8747dce9759c5e2b46b7e77b096f4da1601e0744a2c13d73b6c0962372628aac01c787be37605ee9910d4dbaf9259dbc28889fa5d405916ec57ac3a9c1e3d56257e4cefaaf1
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (55 mod 64).
# DIGEST: 7ddb9526ac0b917c3d63a2c0a4cd720d4814a25e29c34a5b203d8aa4d4e0eb00
KEY: 2933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb9
NONCE: 5fb09e4d00d6172e780ab8b700433a95
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65
AD: de39f4f03541a11be112a7
CT: 0efe6e536bd68a04db4c3d6a2d09bb7de3bd8422ac918573e9e769e5fe8496e4630763085ea5fb939ec972a16b0b01f4e39623d35eb2c514b653a4a716a2837964eaf232d5bdffac9111c4fa0136226b396928bf3df92ab7f04638f3f3cf090c05b14b086cb2883ba64c7680d3ea3e1a020451d259bf8e
TAG: d75d4338d0c73371bbc214d8f21d0a8ed40d3212ac4f91569f51b41cd2c5b9e1cfb67d4052a70a4d702538f58247be89d04038b27d7366fd5adb189764c1f54b6c2bcce81b0012d367a3efdd90ec9eb895432f1a95abc04669f93aad3283e4e56fffe95e0a8016514663d6e6f37df9c26c063bc7bcf23c2e9af26ad984c4769e994e6798dae965b0f288094ae179601d14a2b263db71993a0a6c81918aa38fd1302a82a7d830e1c36ddf40bea1817995c1520d493c874f54e7d441d288caed8434b6a790984ae81895c5088939f2428de79e3076abcc35d483f2601659e87e6d622d5e37104c9ced7012ec7122c849bfbf43354e7a559f01d526ef416748f366ae82c3c8b60f5364095e0382ae6c4e573b3fa119d49d2d7433
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (56 mod 64).
# DIGEST: cf85268a8412f6a450d7c8d48a2e744b508b00017da678e76cac09902ca6b0ad
KEY: 33c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95f
NONCE: b09e4d00d6172e780ab8b700433a957a
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de
AD: 39f4f03541a11be112a729
CT: d9832e63c2bc9936f33f10fbdb262711e715fb09ca209b46106c77e03b1bf7b062eebbb99185c684e9bfbceb083b5e459bceea895ce3fb7ec4eee3a5375c15066196b3cf24fc7b89a756184abb59ac80bc73116cd277e7ad4d9d02a9a9541cb4c71a644973b959b9405c9b109dc367c96ccf4c49a8cb942c
TAG: 9945a3c66ab56d5ba42914d0da1221752f381bb8929cdcfcc5df9a025c888273762ab6aeddb17b7e359923b1a4146a45692749b6751ab0f91df4678ea172de23a1b62a40921854513099a362c94cfe3be87bac38711b30df6748a21def3bf65e654d545b49ae975625975b27e789580a01c73c67f97fbff56d81d21f5d46cf32010090e2faa957e739902149511dec88a65d4dfd7e997db77879c7a3e53e5fd93a914300477ac5381ec213c8050dbbcc85273db55a5f3590b435669d956c5c54cc3bb95cde05791f8986c79138ca73883a65f22f58a8f6fd99b7ac8b81e6d8a7ca8cad64534e1d2a85641b3ca1c5b55e3fe41335f49b05b0a7cff05d1e788d37686cc5cbf97001fc0b5e509e7d99306a8e81e38bd94f54e8
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (57 mod 64).
# DIGEST: 0ecc677bf17604e63d1e4ac4a1d56702dfb16e205af1da5d105d553e87d14680
KEY: c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb0
NONCE: 9e4d00d6172e780ab8b700433a957a74
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39
AD: f4f03541a11be112a72933
CT: 90c83b333d6aa133026223c4966a43fb67f666db06d95f45cff479a626698bc2a73c64066e904ef04800aa8151adec851a51293b7bab1ce22d3e86cd3ba3924d8c0a1253f9714b7c1add9fba2be58b243e6f7ff4f0cf9ae6d4ccd2d4edbbc54d09abb8b9e3f0b269a2cf424a213f0dde799319e633b0fe1dc6
TAG: c2bd8abd58134322fdc45b2bc3bb19b1a7d1e374fb50ec18bd8b0a005e4fcd8a8fb89471e00b1c7c7d579582ffcd151a412b64f7eed5e2cef7ea6ebd5a8326c0723978f81dacd50cf79e363d0716a08512c051706d20b76f7752d9595629dfb99d53b3eb7b3c590aa05d061e35156aa5fc6552ab7858d78b875a120e14e5eafc06d336c683a6874f1759f8adb2159ad91c8240206f0f5093eed17532568c5262d4228d3285e7ffa17d38de7f50ee25ef25485e9692888b80f5ea64976fab5829920e6c9436b1f95e78de7b181fbcb6bde0ba50c18339cb59f942caca5647d8e40c58c0c17d9f4876e275bdaafbd1c73298fa0f79512e896ddb86d7f8234e9612dc624919aaa744ac5a3caa67cb8b809303854cf369fec2
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (58 mod 64).
# DIGEST: 75073f11e219dda101a54987959be5353c48af4af654fa6dd23e32639ca2ea1a
KEY: b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e
NONCE: 4d00d6172e780ab8b700433a957a741c
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4
AD: f03541a11be112a72933c7
CT: 7c9990e7f62cf12afa4e5a4eb3cce88da630a30c3a86a53ed009545de30a08f277e2b8202e138ddd380bb343b606fe7f9d8f53e924c74a21826b1240a76b8ca99ca1a73c8fe87c469793bcc03e84cbf98154b85123332327e0e8218cea0b9fefa3b92835ab96a369b90c7383667f0ba5e62e275c5f4870bcf1ad
TAG: 4b0023b660c25aee68d10550fb50140eb0c70dd881dfc8c9c99b7033eee7c72f6464368013845e2cd98fe6585ca56fcd8b09cce7ef29e88d97d719d5678189dcccf411a3a717b3985837f57641e74cda0bcc104f0058ff69c4b75a43a71e09e1ff6c9f26aaf940b34c7a4d29b645abeebe615e7b4c645b1622b866733f64cb2ceceb89183ea0bdb7b9fd13fc0fdc8c1379cbff97ea47828d265f73a140ffd454a68dbc03b0f43aa97bc3dbf326319004654d3f9085dacc461a45c0d334aa52eec9ede99435a8e4d6818c2c3ac263d6cd482f0b753ac2906827baa452360b120855f7f1ebdd35e30c104bcbf0dd76ea98584f15082b2418d18d9ea8fdd0cae0e6204a4421d3eaab6ed1eca6c49f411bd236b1fcb7629d
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (59 mod 64).
# DIGEST: 7390da1949a9ec86934b6f6c7af07d60fc37be21edd0ba9d937e888402731c54
KEY: 4ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d
NONCE: 00d6172e780ab8b700433a957a741c9e
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f0
AD: 3541a11be112a72933c7b5
CT: da1b99574d59c3998b39dc057d093134c9bb4d0f9a38758e95273694e405b55d8047bf119dbf29c346ea5318a13c8eac769230c085cc2b67e57800279fd47aee9f2ba8e572bebb9f231e954430bfa53bd193ed74b4dc59d6c6e3687451c95d996c86283f10bccde027b90be52f6e2003c061446ad646ef6794073e
TAG: c47a0239314493854571f92f50efbe318131d94c773d811848f642d29ee7ce1706c1ce3f55b7be4b57f4ef893fa9816b0cb3c1d74559f7f3d6119f7c7460eea64bdf660f13ca59723eca7401dc93c687172842b88e446b0aadecea68b924917d06e234098295b1345ae215c33474fbd1b010255fd233229998c21ec87024b1331288f6fc6ddbfc5cf0ef2587f216617d041df338e4ca14bd12c7e6c7d1625f46057755b2f9f18f5bf5cdba9eb0132f84b954fd6e0aa30d26c0a5937b2ffe982456326bd16c002ee0bdcf4a2a38000b1164b143b52fd69adc4855a7a5bad09a97fadc5b1d9b7bdbdb1d6cfc63ae44931019b61ed2573aa8912ebfc436e7e92a636d337bb0e2054ce2dbf30180ee7bac0bdc687e63cd
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (60 mod 64).
# DIGEST: 174d05b7079b80d455325eda1a010ec9bfec7110a14120c6cfe365d270099069
KEY: d4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00
NONCE: d6172e780ab8b700433a957a741c9eb8
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f035
AD: 41a11be112a72933c7b54e
CT: 003e3e54c1df8c46595d812418ee8157054b3191a3f73ec99a047f8c8d25499dcbd028b90caf67af13f72b1632a2e605047c784cfd47b533a947238bed948ab395f83dbc1e5e63e05d50f085aca5dc7ac958e0138e9dddb0883bf8214eb3c43474bc7476deec216841d5648e1db04a898d5dbcdf3d8a832063739aea
TAG: df1cacab73190492bfb49c18745fb0ebb0e2826941621d2ad4a7556a677e71865a25556d15f6c243ad98d65d7d48bf0926e86417256f6eddaf648b23e0bc877b1f4a144f5cb8025d68831f6440b6524fa61d701337764e887fe08073a0bf0a0a279c50ec8f799bf9fc6e9709a376fb1b1d52a1fb60d50657e56cc283fd36c0b07e7612a025d5fb17d407a85b8b0b7f70dced03d39f0958d0364df204b92cfc5b04189a741395d9bc288cad4bf12b6d7c590200f295598209c133ed9cef848b0f716db41f29db4d5ca48cc2b0cf536d89f6a8201738497bb1f04dd9df01e9623d09ebcea9f1587c93c44c5d1bd99ac021fd98142d9f02f8b4e52470b23588e3229c0f769f43abef626bfc91f32894cb406882d055
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (61 mod 64).
# DIGEST: 338800a96a5cf6db2ec5d06de2a53d0fb1b94918f1f8d5c0f222640d4c1bb96d
KEY: fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6
NONCE: 172e780ab8b700433a957a741c9eb80f
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541
AD: a11be112a72933c7b54ed4
CT: 088728abe87e0abc8f5991ed5b43811f4134b159111b0fe9a173122864baf70c5a904e46404399ad705084830860d7e78bf85bb166576117af665dd709ed380aa5de72a9d5819177fff5ca3b536f40f6518a21ccc50dc1cdd1a3d4dc89128de2ec6a6c64cdb50df0e11b55769dbc1e3cc18c9e57c06f5ee705590654bd
TAG: 092370b96f4351ecdf553259224c8b6e90e656c00886aee0bc6a8c2e54ead2e35b7c68cf9ec40e01a2fdbd796a1fd018c92b8872eb56b9a4ca371d72b56f3e57feb77187510200b154fedc6b139a36a49bb2060d1567c167935c31941dd80fbef0d296a8256f144ef3cab87983c9e4e2bbcd3fb339217021c93c6662feb87821efcddebe9e2a106c5b724bfdc9b00cfe533615b8c97bd90c7c825709ad1619dec1d4f914a1b4c7b2776d69e4d51b905806a6edb67d4b926ba299af119a520227f5c409bf247c35b4b2b8fbeb2a4ee2f2192455883db9bf2dce2bb62506a6eb1f00e6223502aa1af04eb6d1250e3aa9aa193e9468b96a5788f88ee2524b55064d94c7d5b9227c9d988e1b19474342932d3f8e4c
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (62 mod 64).
# DIGEST: 6dc3a2d32318422ad20e9c7b09a9a73d8608a326eb14efd6eb52b87ffe4bad09
KEY: d0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d617
NONCE: 2e780ab8b700433a957a741c9eb80f2b
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a1
AD: 1be112a72933c7b54ed4fa
CT: 2e844cc46c1eb905c90fa857be56d4bf947ffe31238ecd92f62c3fdbb1df4c65b14acce9aedbcf6e0d6b0099023fb89084d0658af9d148c00798ba511cfe93ca2604109939a2ed5c8be6a6557f270c14ec9dcf1953014c5324bddbd19c5de88cdfd90c17b06161dc3faac0b551ea15fb1ef49b20d5ba92ff185e0f2a1342
TAG: fdc906b90e526f25e414d44f8ef584c232bc97634e4b4af65ebf6ab6c3adcee9a7b6cc010e33f9181a83e6c8482e28b299f7495631df8068b454e952ea2467093ded7c93da6ea3a7faa91fb507789fccfcd8c0cbb115602c269e94900fe34daf36862b068376f1aa0d11a175ea2a47166891fc08d86d99b0cdc36134f2cb0c48a1dc5e7009348c9788ef122c92e82028de1e2ab27596cf9ce5bcc18115859084db6cd598341c60aa6189080e1d27014f442dc98d6ad3074bf357134209337eafd57c9e71b9fb505f7f442729f16cc2ebcadf3b1b521d22731a417c0ac06f7dcc3719ad8612ff1dfd9fdaea8b626b172be78a8fef4dd5e681282c108c925adafa5bb03b372b623d0e1aff82038cf70c72f481
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (63 mod 64).
# DIGEST: e2c5b8d5e6f07c136223bdb8a1c0197cd99132dd8320a3f1dd1a393a90e575ad
KEY: be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e
NONCE: 780ab8b700433a957a741c9eb80f2b02
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11b
AD: e112a72933c7b54ed4fad0
CT: c0d206171605ceaa8cf507e9c5b785162dc985f8e6d02c9b78d1ee7a50ffe0f2f9eaa80444445da0f42f08cfec019f2aec8b0dc7e9e49eb63180811b092cd737191d8a4b9b2a4f802f484f5b3e7144899b29878c9e7173f24b732eecdcb6bfc88b3a87cbda306c296176d18d794c1f1382c7df66b9c97666ebde165ed92869
TAG: f33071d221e0e38375c6e17bfe1edfcc9628e765995441ec3f3535501ef80c66b03f7c9127e59464aae5a9c62a6cc80e5b9ba164ca644171e309aa408757e5a4ac5956ac9f47a9d2c1b01a5e4fba3870422803efb2ce809954f1dda2a64a5ed16b98bf911ed1a505d6c5837d16e79587219cf47211de415de99fcee110f11a3bac9b2a234cac4172afbc404ecdc471dd5a756ff8936fc481b0bdd876501dab51174710b920f75ae0d2ab1605b11cdac009aeb26fac1ec2ed4627f05e5f8507e38765cb9bc886bf15b37278ac25b9230838900e17e31ce1d4f15fe7767db19e6405f6cb85db43cbb6b764a9506eff8efb80a706cabcd4beb646aa7bd5f62e2edfd6191bab4ecc948527902307ccc4479b67
TAG_LEN: 32
NO_SEAL: 01
@@ -0,0 +1,105 @@
# From the Bluetooth Mesh Profile Specification v1.0.
#
# The relevant AES-CCM calls are:
#
# KEY: EncryptionKey
# NONCE: Network Nonce
# IN: DST || TransportPDU
# AD: (none)
# CT: EncTransportPDU
# TAG: NetMIC
#
# KEY: DevKey if present, otherwise AppKey
# NONCE: Application Nonce
# IN: Access Payload
# AD: Label UUID, if present
# CT: EncAccessPayload
# TAG: TransMIC
# Section 8.3.1.
KEY: 0953fa93e7caac9638f58820220a398e
NONCE: 00800000011201000012345678
IN: fffd034b50057e400000010000
AD:
CT: b5e5bfdacbaf6cb7fb6bff871f
TAG: 035444ce83a670df
# Section 8.3.2
KEY: 0953fa93e7caac9638f58820220a398e
NONCE: 00800148202345000012345678
IN: 120104320308ba072f
AD:
CT: 79d7dbc0c9b4d43eeb
TAG: ec129d20a620d01e
# Section 8.3.3.
KEY: 0953fa93e7caac9638f58820220a398e
NONCE: 00802b38322fe3000012345678
IN: 120104fa0205a6000a
AD:
CT: 53273086b8c5ee00bd
TAG: d9cfcc62a2ddf572
# Section 8.3.4.
KEY: be635105434859f484fc798e043ce40e
NONCE: 00800000021201000012345678
IN: 23450100
AD:
CT: b0e5d0ad
TAG: 970d579a4e88051c
# Section 8.3.5.
KEY: be635105434859f484fc798e043ce40e
NONCE: 00800148342345000012345678
IN: 120102001234567800
AD:
CT: 5c39da1792b1fee9ec
TAG: 74b786c56d3a9dee
# Section 8.3.7.
KEY: 0953fa93e7caac9638f58820220a398e
NONCE: 008b0148352345000012345678
IN: 000300a6ac00000002
AD:
CT: 0d0d730f94d7f3509d
TAG: f987bb417eb7c05f
# Section 8.3.9.
KEY: 0953fa93e7caac9638f58820220a398e
NONCE: 008b0148362345000012345678
IN: 000300a6ac00000003
AD:
CT: d85d806bbed248614f
TAG: 938067b0d983bb7b
# Section 8.3.10.
KEY: be635105434859f484fc798e043ce40e
NONCE: 00800000031201000012345678
IN: 23450101
AD:
CT: 7777ed35
TAG: 5afaf66d899c1e3d
# Section 8.3.12.
KEY: be635105434859f484fc798e043ce40e
NONCE: 00800000041201000012345678
IN: 23450101
AD:
CT: ae214660
TAG: 87599c2426ce9a35
# Section 8.3.14.
KEY: be635105434859f484fc798e043ce40e
NONCE: 00800000051201000012345678
IN: 23450100
AD:
CT: 7d3ae62a
TAG: 3c75dff683dce24e
# Section 8.3.24.
KEY: 63964771734fbd76e3b40519d1d94a48
NONCE: 010007080d1234973612345677
IN: ea0a00576f726c64
AD: f4a002c7fb1e4ca0a469a021de0db875
CT: de1547118463123e
TAG: 5f6a17b99dbca387
@@ -0,0 +1,208 @@
KEY: 404142434445464748494a4b4c4d4e4f
NONCE: 101112131415161718191a1b1c
IN: 20212223
AD: 0001020304050607
CT: 69915dad
TAG: 064617ca
KEY: 404142434445464748494a4b4c4d4e4f
NONCE: 101112131415161718191a1b1c
IN: 202122232425262728292a2b2c2d2e2f
AD: 0001020304050607
CT: 69915dad1e84c6376a68c2967e4dab61
TAG: 99763ebb
KEY: 404142434445464748494a4b4c4d4e4f
NONCE: 101112131415161718191a1b1c
IN: 202122232425262728292a2b2c2d2e2f
AD:
CT: 69915dad1e84c6376a68c2967e4dab61
TAG: c4630026
# From the Bluetooth Mesh Profile Specification v1.0.
#
# The relevant AES-CCM calls are:
#
# KEY: EncryptionKey
# NONCE: Network Nonce
# IN: DST || TransportPDU
# AD: (none)
# CT: EncTransportPDU
# TAG: NetMIC
#
# KEY: DevKey if present, otherwise AppKey
# NONCE: Application Nonce
# IN: Access Payload
# AD: Label UUID, if present
# CT: EncAccessPayload
# TAG: TransMIC
# Section 8.3.6.
KEY: 9d6dd0e96eb25dc19a40ed9914f8f03f
NONCE: 02003129ab0003120112345678
IN: 0056341263964771734fbd76e3b40519d1d94a48
AD:
CT: ee9dddfd2169326d23f3afdfcfdc18c52fdef772
TAG: e0e17308
KEY: 0953fa93e7caac9638f58820220a398e
NONCE: 00043129ab0003000012345678
IN: 12018026ac01ee9dddfd2169326d23f3afdf
AD:
CT: 0afba8c63d4e686364979deaf4fd40961145
TAG: 939cda0e
KEY: 0953fa93e7caac9638f58820220a398e
NONCE: 00043129ac0003000012345678
IN: 12018026ac21cfdc18c52fdef772e0e17308
AD:
CT: 6cae0c032bf0746f44f1b8cc8ce5edc57e55
TAG: beed49c0
# Section 8.3.8.
KEY: 0953fa93e7caac9638f58820220a398e
NONCE: 00043129ad0003000012345678
IN: 12018026ac01ee9dddfd2169326d23f3afdf
AD:
CT: 0e2f91add6f06e66006844cec97f973105ae
TAG: 2534f958
# Section 8.3.11.
KEY: be635105434859f484fc798e043ce40e
NONCE: 00033129ad0003000012345678
IN: 1201c026ac01ee9dddfd2169326d23f3afdf
AD:
CT: d5e748a20ecfd98ddfd32de80befb400213d
TAG: 113813b5
# Section 8.3.13's test vector is identical to 8.3.11.
# Section 8.3.15.
KEY: be635105434859f484fc798e043ce40e
NONCE: 00033129ac0003000012345678
IN: 12018026ac21cfdc18c52fdef772e0e17308
AD:
CT: f1d29805664d235eacd707217dedfe78497f
TAG: efec7391
# Section 8.3.16.
KEY: 9d6dd0e96eb25dc19a40ed9914f8f03f
NONCE: 02000000061201000312345678
IN: 800300563412
AD:
CT: 89511bf1d1a8
TAG: 1c11dcef
KEY: 0953fa93e7caac9638f58820220a398e
NONCE: 000b0000061201000012345678
IN: 00030089511bf1d1a81c11dcef
AD:
CT: 6b9be7f5a642f2f98680e61c3a
TAG: 8b47f228
# Section 8.3.17's test vector is identical to 8.3.16.
# Section 8.3.18.
KEY: 63964771734fbd76e3b40519d1d94a48
NONCE: 01000000071201ffff12345678
IN: 0400000000
AD:
CT: 5a8bde6d91
TAG: 06ea078a
KEY: 0953fa93e7caac9638f58820220a398e
NONCE: 00030000071201000012345678
IN: ffff665a8bde6d9106ea078a
AD:
CT: 5673728a627fb938535508e2
TAG: 1a6baf57
# Section 8.3.19.
KEY: 63964771734fbd76e3b40519d1d94a48
NONCE: 01000000091201ffff12345678
IN: 04000000010703
AD:
CT: ca6cd88e698d12
TAG: 65f43fc5
KEY: 0953fa93e7caac9638f58820220a398e
NONCE: 00030000091201000012345678
IN: ffff66ca6cd88e698d1265f43fc5
AD:
CT: 3010a05e1b23a926023da75d25ba
TAG: 91793736
# Section 8.3.20.
KEY: 63964771734fbd76e3b40519d1d94a48
NONCE: 01000708091234ffff12345677
IN: 04000000010703
AD:
CT: 9c9803e110fea9
TAG: 29e9542d
KEY: 0953fa93e7caac9638f58820220a398e
NONCE: 00030708091234000012345677
IN: ffff669c9803e110fea929e9542d
AD:
CT: 8c3dc87344a16c787f6b08cc897c
TAG: 941a5368
# Section 8.3.21.
KEY: 63964771734fbd76e3b40519d1d94a48
NONCE: 010007080a1234810512345677
IN: d50a0048656c6c6f
AD:
CT: 2fa730fd98f6e4bd
TAG: 120ea9d6
KEY: 0953fa93e7caac9638f58820220a398e
NONCE: 000307080a1234000012345677
IN: 8105662fa730fd98f6e4bd120ea9d6
AD:
CT: e4d611358eaf17796a6c98977f69e5
TAG: 872c4620
# Section 8.3.22.
KEY: 63964771734fbd76e3b40519d1d94a48
NONCE: 010007080b1234b52912345677
IN: d50a0048656c6c6f
AD: 0073e7e4d8b9440faf8415df4c56c0e1
CT: 3871b904d4315263
TAG: 16ca48a0
KEY: 0953fa93e7caac9638f58820220a398e
NONCE: 000307080b1234000012345677
IN: b529663871b904d431526316ca48a0
AD:
CT: ed31f3fdcf88a411135fea55df730b
TAG: 6b28e255
# Section 8.3.23.
KEY: 63964771734fbd76e3b40519d1d94a48
NONCE: 010007080c1234973612345677
IN: d50a0048656c6c6f
AD: f4a002c7fb1e4ca0a469a021de0db875
CT: 2456db5e3100eef6
TAG: 5daa7a38
KEY: 0953fa93e7caac9638f58820220a398e
NONCE: 000307080c1234000012345677
IN: 9736662456db5e3100eef65daa7a38
AD:
CT: 7a9d696d3dd16a75489696f0b70c71
TAG: 1b881385
# Section 8.3.24.
KEY: 0953fa93e7caac9638f58820220a398e
NONCE: 000307080d1234000012345677
IN: 9736e6a03401de1547118463123e5f6a17b9
AD:
CT: 94e998b4081f5a7308ce3edbb3b06cdecd02
TAG: 8e307f1c
KEY: 0953fa93e7caac9638f58820220a398e
NONCE: 000307080e1234000012345677
IN: 9736e6a034219dbca387
AD:
CT: dc2f4dd6fb4d32870129
TAG: 1be4aafe
@@ -0,0 +1,43 @@
# Test vectors from NIST: http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/gcm/gcm-spec.pdf
KEY: 000000000000000000000000000000000000000000000000
NONCE: 000000000000000000000000
AD:
TAG: cd33b28ac773f74ba00ed1f312572435
IN:
CT:
KEY: 000000000000000000000000000000000000000000000000
NONCE: 000000000000000000000000
AD:
TAG: 2ff58d80033927ab8ef4d4587514f0fb
IN: 00000000000000000000000000000000
CT: 98e7247c07f0fe411c267e4384b0f600
KEY: feffe9928665731c6d6a8f9467308308feffe9928665731c
NONCE: cafebabefacedbaddecaf888
AD:
TAG: 9924a7c8587336bfb118024db8674a14
IN: d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b391aafd255
CT: 3980ca0b3c00e841eb06fac4872a2757859e1ceaa6efd984628593b40ca1e19c7d773d00c144c525ac619d18c84a3f4718e2448b2fe324d9ccda2710acade256
KEY: feffe9928665731c6d6a8f9467308308feffe9928665731c
NONCE: cafebabefacedbaddecaf888
AD: feedfacedeadbeeffeedfacedeadbeefabaddad2
TAG: 2519498e80f1478f37ba55bd6d27618c
IN: d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39
CT: 3980ca0b3c00e841eb06fac4872a2757859e1ceaa6efd984628593b40ca1e19c7d773d00c144c525ac619d18c84a3f4718e2448b2fe324d9ccda2710
KEY: feffe9928665731c6d6a8f9467308308feffe9928665731c
NONCE: cafebabefacedbad
AD: feedfacedeadbeeffeedfacedeadbeefabaddad2
TAG: 65dcc57fcf623a24094fcca40d3533f8
IN: d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39
CT: 0f10f599ae14a154ed24b36e25324db8c566632ef2bbb34f8347280fc4507057fddc29df9a471f75c66541d4d4dad1c9e93a19a58e8b473fa0f062f7
KEY: feffe9928665731c6d6a8f9467308308feffe9928665731c
NONCE: 9313225df88406e555909c5aff5269aa6a7a9538534f7da1e4c303d2a318a728c3c0c95156809539fcf0e2429a6b525416aedbf5a0de6a57a637b39b
AD: feedfacedeadbeeffeedfacedeadbeefabaddad2
TAG: dcf566ff291c25bbb8568fc3d376a6d9
IN: d9313225f88406e5a55909c5aff5269a86a7a9531534f7da2e4c303d8a318a721c3c0c95956809532fcf0e2449a6b525b16aedf5aa0de657ba637b39
CT: d27e88681ce3243c4830165a8fdcf9ff1de9a1d8e6b447ef6ef7b79828666e4581e79012af34ddd9e2f037589b292db3e67c036745fa22e7e9b7373b
File diff suppressed because it is too large Load Diff
@@ -42,14 +42,707 @@ TAG_LEN: 20
NO_SEAL: 01
FAILS: 01
# Test with maximal padding.
# DIGEST: c6105cc86e18eb8376c16ea37693db5c07b77137
KEY: 8503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f0
# Test with maximal padding (0 mod 64).
# DIGEST: ceb2d295bd0efd37c6c34dab1854c80e986174fc
KEY: 37446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d4120
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c748
AD: 1df3f4183aa23fd8d7efd8
CT: c90e0c2567341ea7e9d968dbde46ecb46ad78dc8be7d47672068de66d6e7eae14b500b94927f24ff6a4f7b07
TAG: ec90d128ef465f4a3645fd0b2601fbe2b0bceae2f890f0700c7a15c82fcbee6ab492908ba5f2df0f04dd0635c047cbe52069d85fcfabe53ceb43dc71c46e51c0e3a9ff435840d62bdcb93341a1624b69397fa1bbd9229814a2788b91a107534b41ed488f4ce95fd2ab46963e4f1a3096c74acc8466d034eeaa7c0f1fe46a4eee7abb740367266cd36fba96dc74e520f64b9605c067bef516f517f99ec73c1104b43bf3e94eadd7dd6b9b7db847d6ff4c03dc454d8edbf8f694f09754f249fd1dc0bb4b130b2e43ddc1d24a0cc14edc8e7328515cc8498ae89beec66127508676fb04db92055abf2be22e0c2a7a3d9664e17d919f655ffaaaa7246a0ea29f9c42f72b6edd0dfb4867802d6992ce25efd8fe0dd0cb
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba
AD: 2fd6773e0d0c302a5f47e0
CT: 000893d3434c5be7cbf9daffd81f03545f735cb70d1bd16eab26e07da7ee29b4c607d9a57077d74437e5b01a89c808c7ceca0d3838e5c6ee9947f1d4ee1d5e5e
TAG: 6d8dc4edeeea81cb503d7389da209ae335876393fdab048965c7eb1a1403d05f8ef059788d08c2e906444388fd416a87bf8706f78d35797453b242618f4a99f47c3756116ec0318d96435032225ff82b902b9b6985189ca438e466154ded91676676c645926e2cf8a5d6f3bfafbb713d646cfd35b091f68e5ac2e7ec10badf1fd80767e6953abeecdc89beb2180dc92be21631164ef801147917e0c8d7841bdcdb52ea03344ab5f2bf3d5157794f5be79f51eb1efdacc0b77b27b72e2ce03d05473203522e3c2c196390d77dc28a35951f3aebd72ee58021d55e521dd029719a7660408ed0da5ab41830102bceb514b0b172d0ee10937111edba82b47e719c3beb3ce49a665accdc1c5bf028d465b5e1
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (1 mod 64).
# DIGEST: a07054c760cc66fc704edf950201005031f3faac
KEY: 446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2f
AD: d6773e0d0c302a5f47e037
CT: a1e92776d0ffcfed03d1be956169f606733755d5a7011620c7ced6a825d8e59627e75692a41a1f2a86e62fc6052873b5458616414584e36bad698cf4c44909e0a2
TAG: 6e0b32528feac2d7f69abb480efc7aae6cd1c5f8a654bcd10ec5be08b58f5a2198bddd83439d69ba9f55408cdf087e8a7f33fca6859638c5a4e8bc6961afee7534d8ffd95249d554b02e5beb81100be5e10abf679300f4ba514c03f4fbbba3cc62bd13dc8c8b9a726a9f217446c6e3b89cadb40488b177926c88c9d22a6c4ad9deca67f0d976fe62cd24c3cbb2e51dd16ee2e7bfe91d867b77c77a9a65c387e2682d946e617d0128034f5fe436eb7fa88aca82526d71dfefbdeeeb5a2c15d57fce0cf12e6ce0b101ef92d9ca540447e0bb65bc04b6a02e4e6d9378c6eebcd6d530c4ae14243beebb18403e8bcd434c2d88cc121e2df182edc3e1f52b060b1aecc48490c6cf3260299449945c803891
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (2 mod 64).
# DIGEST: d059c266cf6233af730b7a229b19356a4c6fcf06
KEY: 6f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5d
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6
AD: 773e0d0c302a5f47e03744
CT: f414f0321370af1490839677747893befa438051fef5f02fef488d7b84dc03140b3a5dc3a57041be4c8b688633110fc07251d877de0d6242928e4d937e3cc58ed611
TAG: 4ee98ac6f10e179314a251a9db190037c47b9fdfc66321d83a995f6dccc5259801b18c3f466f7f4939b7d2d7196e0b161aaa013721e81bb9707b974b904f670e4aa495357b562a254908417b65fa69e86c42b3efdd423838575db08465a7f4889c85201629f6350c0865b5b0cfbac4f51ea1eacc8f9768014975d780438c3bd77f7f18612080abdeac9331e1a068c8f3a345d0026c5723bdbc48643c1a733a5b7ca9078424522db9491bc38d2644dab2d75499715707cd83ed655343ca73672d480f1420754fbbfeae0fba05be3b5235a5fa48bda9f39df0b298351d8f4da3fb8a2feab8b1aca9335eb31ab03f40ab19f668bb864c798ae08de37bf848fe2e898172d26fa23f383787d7199a6990
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (3 mod 64).
# DIGEST: 8aac0687e33041fcc18da154b41f20a6af2bfb28
KEY: 5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd677
AD: 3e0d0c302a5f47e037446f
CT: b51ab2f8c4ba3e8638d454ea72da5e3cb15336c347c442b8e1ade85c5cbd0dde790dc707d60d452d5b88d72e718f13cd0e0f4c9149b72e8d6be869d817a3232513c958
TAG: dc8feba112517f6a820ca12de43c5d64c51cca713d3702a2b4a5cdbe86a90946a7369ec26ea8b5b35df329bfc6e29ef50c2774649134bd6e3f3fb38ef13d9c7fbe066e9cac4fb88dd0c02b677472ebbb2d0679dffedcaf13fccef6a25aed3a272ec01e7680becf80a624518e1333d28c97487b06e0581cc80c94989db4e93489f3dece9eab6dbbee73aeab572d1ee7705d18b899d9c62d7a370311e64131a801400b580d3c8f7af88be485b84fbdd89f7f7dacb29afeb56658f3d8e49f27adc542e412b0fd652b9f60575bf61622d7306c54bed50b43d89cdaecf1981ede09f9ea36fd174118ac178ade5f26ba04fcbd2eb035f030e2139506456ff8d342a4e59bd55dfafebda23a66cacfe6d1
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (4 mod 64).
# DIGEST: 53658226c112b86438dd27b58a71f9e36fc73c1e
KEY: 91d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce99
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e
AD: 0d0c302a5f47e037446f58
CT: 87bf1af7e4987cdab35bfe32adc6b1be286751426cf926217f2c699bc095bde7b6ff3d6cc96b79328ab776547c2cb756d9de8c1245d21619a51dba8364ef6914590f15f8
TAG: 55b9a1ee198080846389dd088016acab73622b1e2f902b0776846c74d99c27e67c7bbb55b2ac0efff91af0f6cb2ddcc0b5b8bab768048bb1662bb343d2f3a164bd4ca4850fbf8111b29e9be7bb836e2a8ac50ec2cb0b1c4529e50904007372284ec9187ea27d8faa03fc9535ba744155d06c06a0a97d96c03de71c13c95f185f426615f1368be346aa5ebf80049ac6771763235f2ee44dc910a01035c53caf8f9fa6f51fe3ad094513a8db177b6a66e24d21e1e40a23aa3629fffad45f84a58a29ef9237fac5eb6f5deb3825de6f399e46b2b2b91faf64ce45d164155e4dc757f6005c7c3e7fb3d8829623fd7c6ca48b923be90c38f5209c6d94696d2b2b7ebc5dfbf2cfa1a37e8ed038e830
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (5 mod 64).
# DIGEST: 6b7d5268b0b5037afb5be5af6a0ceb34e7656ac4
KEY: d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d
AD: 0c302a5f47e037446f5891
CT: 44237c388c3d017300db0fc9827f9b575e59bd971a0fd89cde4aeb1763912b49d50e92ba19d7594ef6da27320ac2bd1db3bcfe56b68a9ea8e2347d69890fa1fdc8bed782ad
TAG: c1068d84aa962e7b89090993378806194ffbf677e7a66524d2ebfa7bdc52d76d09b914168eec4a5fde0953d4567affd3a4e0e48190e7a84471efe8ad1ce577c21df93b9d641c865d90ea1e6069bd703c4ee372379a4ec94f7e99867179561d41e9053977cc985b98f7a9fbc675d77052809b89b8f23f993e191ed1a07f97b89d05de948107f94245f216c413288eb4e40f3cee9c00c15926657d9ef9187ab405ee8000b4bd84d5771464401d59156a97eea7b23b4a6e9f1587cd3b75826a621b699515829dfc57740ad5719c43e88d835e13ebf703a0966779d31dc26866e0e9d27e3376137c92c97af49a876eed425d3980f1904f013143faeccb4fc920185ec2325361e5b318434487f9
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (6 mod 64).
# DIGEST: 63efe7af502231420ed5aecce9a28446b257828d
KEY: 7df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8f
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c
AD: 302a5f47e037446f5891d7
CT: 2f25b5a3b01af5411466c8aa5d8ece037434d5e12b62306f2732cb063d0dcdfc2725e67118a242a5576d470fcaf9be6d811bf2789cc66f5561d0542438b5432fe713187a879f
TAG: d80e1f4edc2137f430d36a5ac93680c973fd7c64a03f7c2ce1b7e33085fe94da70ee26f47998947310508448cc70daa595687eaa540e48f048132de108a045da6d71170e39bb45160a344a2fdb5cb56ab020b9c0842ef2a1a5c83b4d63359fb8d71506d1e611fafa29e77d0669474d135e37bd8aefc3e17f024093186ff80fef73889e887b8d6672256dd592946ea84becc08c29445c8d978e896b1dad5e2608e347e54a97f3f757d7362f95f4cedebed07ab45b05713f7119c38d15a0f22d4259893f5e2401267543b3f78b52d54dd2d608173119e2dc7fe01f66589628e95fd7528958e993b21e4db664b8cba2f776d5cc305c42553da936d580c17d6f5090ff04e106c6488b5b18dd
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (7 mod 64).
# DIGEST: 1a555c300a1d1bd5b03cdd6bf2a678621624eb05
KEY: f660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c30
AD: 2a5f47e037446f5891d77d
CT: bbf934979c5d9da5c8b27d0341a164d640f12956a392303b0f1665935b5c39de458f53e0a6f824cc56081db1615fc67ffff0d300d1564666b81bb37da59e4da30de9d6a19df74e
TAG: 9c18b0f9ee6a167a23566325eb330660997193385214abaf945dc18fb8252fbab8330b9809a6f1b300ae5a0c9d841fdd6f77e8d65f1cd0b221fb9b94b5e5d7215e6f501f490a7fa0a754efa7f2d9f5b927a5da2bea736e73af067e5d988901032d503ef3ab89894d03e48a096e7c31fe64bbc2c13f02d878590659ee7606d9212898d4d246e52b03c5646b1c3fbd43baaeda6548156987fc8f490f5763da18198bf0754d20f16dcf7df6bd35ca4bd95cd5c95a60427fc541aaf1f6923ff150de825cff9900ac9492350770bdd13fc4d0ac858ccdf36efbaeeb572aa45ca5470a04a7fa1ce5954d58771730b7202def47b303e560e81ebba2080d044a0851043c5af1a05c30a5a448eb
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (8 mod 64).
# DIGEST: de9156349b578f2f44945ec6a676a67a829daea1
KEY: 60ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2ea
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a
AD: 5f47e037446f5891d77df6
CT: 9b9bb61ca4d5aab8d0342d2b174e8f39b8e21db0fb7146025fb298016df3bab4363bb47f5b1fa038587df98851d09d473a68c959ead8062c52b9d6de86bd6a0fc9a2daab4667c621
TAG: 897472da6d837ec173c2ae738721306e8d3c9e5353b65d1ecb3be3d0039739de379c9b06f42af8e952aa9acb4780a6de888dc8c54fe9a2eec19ae4a864b3b9696d712153bb66c49825ec5c891e30915c4b7b66b190525195429426ad694467dab09e8c2f9f21ffae4d54b74c0c5ed9a05963651dfcb9560677693429c63f3024043385ab0a31066243d42b80d2aa9854005504d6c8b9b7f736a8731c5dea0f3fc9007aae0c6edcd0a91dd1bbc5750de12ee13d4a77379cd3b2c2bbac885fa17338011b7b81cec6711fd5d65178f20a06f5475e09c202deef57939161ca8ed3e4aa9b010277acddc4478d1afb64138b276e265182ef2dea321b4f136c5c439ef6d099621813209a43
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (9 mod 64).
# DIGEST: 12812df3aa7f3bbc899f6f248f5590e02570c292
KEY: ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f
AD: 47e037446f5891d77df660
CT: 33ac574b7962d03b7816c0199a7f661a485832b9023867a749fc4bfe8ff0485571744f801139afd8215863b23e2d68ee7a254c60d8029e0f1ee10a1b947a4984f37f98a6767f52661e
TAG: 3ee493d8cc764880f4ae7fc3c189b95bfe11d89640e3c9ddb55b230ba0d142d53fe18be8b955cf0d0d237c3b295459fc4c723b27ba8a29ed8dd5c80fb9839e30bc92e6afbf28ef6f72d1c28e5452460f986444678e7ea982d8bae63b69788012bd43aa66e5a521840c79831ae74426fb16f0917c5d2747b9c31fe43ecee604f26afddb093a9f1f1205a4451d50080ed0a9208a88ed6dbde37a674932bca837c46dd8725982c2ef6ac54511151c4cd59e511ca3835ea9bdbbd2e0842dc9674a854b8d4b063d0685086cdf917a7b7983dcc28af2addf3bc302034e365da1a87334a68477aa34a3a878d926d4c17f50316749d917e172e47597d060403a0279ee68dcd864652f37c6
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (10 mod 64).
# DIGEST: f3c89f21c327fca4aa400fabea9e39780378e901
KEY: 82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad40
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47
AD: e037446f5891d77df660ed
CT: 8517e13ca00214ebfc748efd3a233e8b64801dcce99f9fee3d271357220dff7b1678c1cd6392a6ade62146c0e783248918a7cb69dd26dea525bd9060f380dba75e502bdc19581ebc3295
TAG: d1f1280699f5514e4a56b08a5c3146142ef8e44c18ccac74577ec0feffbc29884da82212cba95b31d8464954498340f35e9a3d84256e8628368edd166d4b429fcb76e0072d2f5276ed8dc7bd5f34e754f6577ba00ee7ad74e9c89c4f82af0a7716d6ac77c39643909dedcc9356ba42f07874031878229a076da9ac7b0e49b2d170239089ceaf84392e889e7bceb3e383d0f744e229c53e8654ef0099a11773885efc456883e4a973557852f70c0e35668f3f212260e131962087416e668c9f995f226152251f5873fb89047a9dfa65b9fd0116486092b1092c4ee33e7625772944c06a2969b162986cd46d2b4185af2658c25c69a7a599d17f37be0fe1c8250cd7df5e6cf304
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (11 mod 64).
# DIGEST: e8e41988fad6c8b44c56544964cfe0a347b35b1e
KEY: 933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409a
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e0
AD: 37446f5891d77df660ed82
CT: b1cf0005c93547664e09031d923c4ef9ad663a808189cd8aaa68fbada340d8bb13330499131ef3788cd91e9527702a2388802fdd2e91998a53ffbb466bb7e362d06677edd673cae71418a6
TAG: 7cad97328236aee512598d1a4c7d51b2154218fddf0ef21724921c1afe61fed1b7a1d1b56b8099dafff77362c4154e4bd7089fb0908ab1de49244a053997a0d04229250e52bc1ecf4550da5753a35108b6752f907ddf7a77fefbdb5d7290b02ae231d019d04ad9a5295336639e7e6c81ea46863d2bc3c4fca7d0f3b05237306759b156ac1fd10b044730987d04a943f0f598704f2191f6c627299b92a2c01a4004111c21f650376c3f28fc9793eddaefd74a2bb3cc5dea73685c954c63b71f2924ebcf9853ff084117cc84a0785d96d8d55d02723a2082ecd8c4b49b8d4068071593aff50c2e08fe7c49f6de1d7586e299b42ec723063f2341fd9b3445cf40893cf8c2bfa5
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (12 mod 64).
# DIGEST: d1c7b2c04dc25fe7b742a1d659aec20e1475ee4f
KEY: 3f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae0
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037
AD: 446f5891d77df660ed8293
CT: 7195b9643e0f7a4293c865db36442d4fe2cf3ea2c648dc88cd5636fe5e6bcea3d1197966e800da8c78bcb8830f3fa97671aebce98549e62827adf612e70f946673b07e2f953c8fe5e0b97aa1
TAG: 3a909a9fa57e720bea6251ebbc1a71bbae1fd894f6bbd16e11abe51bbd1293abc0ad4c152a08b4acfac7a65b723fc6bd6923db66bbf202e184e8dbba150e6021ad1310ab4752cd4ae874409688996fdf88636084db7762b9578bb0c98d77c5156a82a97a3f6989db2359d252ff7c6405bd4834708c88d4481b35eabe2f7069bf8bac374fa382f4225659b41dd2a8006c0ff8d7c77c8d157e0373f45fcc0abc804a9f8a6b816f2b729befd606dc61e7f763f18121f56255662e36d120b27adfc8e1b528bd8ced5386cdb62cc73e58cc7918d27253297e9cbb9c740c7765cb014cf7bf160cbf09e00d32d31d462f356791bcf1286bb9023254afa6c41fe3d165f1bf7e6c002ef64ecdf3b5e073fb569028032e6713
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (13 mod 64).
# DIGEST: 116e20ff1e79e0af464d473b1e7c187f4dd66007
KEY: 62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae021
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e03744
AD: 6f5891d77df660ed82933f
CT: 1d50f3eb1cd76d8e08a9f386db0cdc3eddfc694e8502ccae47ab431c2935fc461254b80386c87690b01c22f38ea9bd118d2e0ed316ac249437a3e9c30f6c1f767c150216ec90e6c8913ff3d469
TAG: e44bfe162cbba654362d1c86088564b14120815f181932e9f111d6da5efb5f4caad61f1161d1d148cc429ad34fcad9128bab101c7cc004fb8f0b516216a809a6599b5144b4c5828cf159fcecac46a86ba0698a6e5267610bad10cd7ce9079b6c691c2ecd522dbe3563074f2ac85712e58cca41761aa94449199a8b440016e68eb8bc9db3ff2c2bd9c64d9d3c71566bfb5d234af1a144859431f16ce6d65b4cc604e9cbf4e5539c192f07a2981b55582376bedc07aa20f5a841c9f500915fef353c37446511da3affd743fc551d5c22454797b3eb957770f1ca16da138c71bf5c00ab7893ae83b3f499a2c42f55551a986555925337e0604227ebf1c65312f0b1a8cdf2d06b5daf3e5ea97ceeb2f33421d0b44b
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (14 mod 64).
# DIGEST: c081d0d09b2c9eb39a372ef4a7b0246a0956b0f9
KEY: be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f
AD: 5891d77df660ed82933f62
CT: 4d754c684658bcc89208bcd75f24dc8e18b70a28b8a2201535e60ab755fb20e1ddfa98742d257eadd02d96c6a65f880d058312311efdf67f9a106beff9f5ace0ac6af586aefbb5e8b4850e584bb7
TAG: a9bc9bdf2c16ace8cd471c2bcfbc2cf933fc1886faeec62d4809ed5cc4dd4fcb6ca6c42f31bab300264b278dc0b10fe8a54005b590160b410dcdfa3db413dd04a72c897b262ed0fe4ad6683fc5229010f1d2bc939e61a2c9e0480ef3e03e90f74a3edd8bb523271adc45d097b197ca9034bff48677efa763e1ae7528d3f775f827b9c56ba7f042d7f9413b4c5d01972e86976ab3a398afae27faf3cd19ef1b24b5342f9d067e7702bf1ae9679540a72f7a12cdbfbac234d596856b3bfdc2190dff0b50f45b4355cfa25ebf8d1d16528fe6c4baf9b0e5a50f95c4091704e939c8ffe69183c2695ecb1f12f24fdf288a8e8bdf3fe510bae70c46d0214303d5503d21366c4eec24cc2808542a203d81789efbb6
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (15 mod 64).
# DIGEST: 6f7bb1f9e2772eb909c315e653e4737cfed78a18
KEY: 8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae0211641
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f58
AD: 91d77df660ed82933f62be
CT: 25bc47e58e7d4f3a417c95768699c92240a2be0e86232a41fe02d64f66716023996772e1118be48e685042f989dcd9cdc574614c9c3989f1885b4b71dfd5b1c32c1321ca41ca1e6ff1828e677e30fe
TAG: c96a78b9ca68054bc1ed2a150dff9f9585174f343d3df80350982002b4c95106b72813a90028f2855faef235909686607f39655ec48f4024e170c9f9574b0c81b63c8df7af6b4d0f0633853a09c334379952bbaead7415125f541a01e320c5f5d9806b71c3ba71890e3229e751f25ac82c245596b5fa688f1b13844d91169354bf0cc03cccf576c2216aeb9eeab33e2a9f8bad2145d36cf0e7585a02296a7a3b434f4efeeaa4d7ed65befda32b287d9d0946e25dbc0edc22de871184ae8c76777528b917585be784d5e0674b1e5693d0b8cbe8253f8db67c879e1d2b7ddd5df4777a15509f813eb4d0f5a935aa011daaf0cc1ba2ebba9a20a74847e9c53b648f6fce4c08b6e7babc1919e6de22210a6f05
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (16 mod 64).
# DIGEST: 172f4992e692a88f49628e5d3937959be01aed2e
KEY: c55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417d
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891
AD: d77df660ed82933f62be8d
CT: f1ab85a35a17541efb4f906e7fc85e64efec6ab40d59d3da920c4ec09797c3ad47820e9d934e51e3f4d097c4a555575939bfaeb8cfea062b64816a160d6e4d1ff02a5fded435ab9aa2daf22fa7d676fa
TAG: 14684ce099f4f0e11e785320debb89c79c03e8bb8751860d3779b4b553f6dedabdb23119d2866ad63fc974a6c6442b734394cb6705309a4d3889e90c4a222bbd14624cd89a9c3f904367c418140375dd592107f839ca94d43d09495a8dc8273201bd8f5a447bdf57506421a975ff4db3aab7878ff18e5b73c8f072a8d092461257d0182710ee9df9f86ac5ad321eac7ee96dddb27ecf561db222ed1c7c183c2ecdf4c7f57cf295638de3c4176ea244100d51c006282e98af1a8fd540daf0ca6f2fc0b88c550b4ab638760d95f2f9d09612da198616cd13fbfa1ad12a3fd30ac9956491cb11539a1be43175fb1452393f13f8d03501c89cf5962730125a7e185dc089b41124fc1e7f69b1fad46bd661c1
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (17 mod 64).
# DIGEST: 00133da1f7c63fd5f0eec364e9a359be02c1d3da
KEY: 5b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d7
AD: 7df660ed82933f62be8dc5
CT: 5d6bfe91cd2273a9b986397a38e81be5fbbcd0403ef51873c2c467a9fbadc7bf540e83c538a43dc0e0ab780a4c4b1f5b77ced74f65b61f8b8b58b26fa3e8cba568bb717dc7071bf82dd8c68b068e739706
TAG: 2ab9e654859c35e065f763d949d43c65dc85dc5d918850809ad8efaed6569d4b3ad064bef3427ae4c3be571fb914cefe2362169bed5b4c0cb17d2106fd6993d20ab8a8b70edb5f5d59b3357c8499c36e2b0b67edf7f334ff02d599031f43252b8d30d39affbd2093a6687c771b672329e14901ad9128f063267d3ab332ea31a79d37cb24ad0fd2d07f23b13d4643d1d9c529e1dd0490c851b0009fc1192f2438a48aba5a39be2ee925b1a38647197ead5cdea3499daa5abf9f4503d3581115a6847363348d5e7933948dce867752cde69ecc401012674ad75e12245dee86d775989275a5fc635c66d42c01b7646e180d28798905a3beb210c049be35b522ad580e1ca29f81b9469448749fce961ba6
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (18 mod 64).
# DIGEST: 60a6821269be6c5b985576b245f106128eb0b325
KEY: 436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0c
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77d
AD: f660ed82933f62be8dc55b
CT: 16e3c681ba1ece3bdbfb1da491f877e806ddac5f1ae96bc406bd195c9d48bcd4a9b700a8ced21d824bfb99eb057e401c3529818725b51e96c576e8009bfe4866e98f550a23ef4748ff761a4d1c44ccb5eba0
TAG: a30286b3d06306818a268db0e5116abc2c7361c5a32d334d8ce5f4007aaeab750980018b435c79391151fdd33df2a97dc2cf62c4426ce45be43f7e4949be735bcd33f0e81cc6b5a3c2255fbac9ff5a8fd7e7b57554d7ef00640d92b605c9afb0c19dd5ca4c79c409d85c197e8f21d79e91df01a817bf68e8718bc771028c945471ae003c0a210c572b79d772560031b5d3e5495aa8d9bd6fa3f8ae9976ed7e7f8d7275030d2f12ed5ab05276ebebafcac7d0ca41f9d860583f800e4f1b9658b12fab31fd63f6a5e4b80463918f8295ae11d7b97f9b5f89b8166861aec8f1b1417163a6a8adce23ce66c9a4306acae7ca75435cbaece814d6010a3e335bd7db9783812052179d5337d1c353be6e0b
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (19 mod 64).
# DIGEST: e2593f3b6741a9ed9fa188fc06efd057556ee624
KEY: 6965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df6
AD: 60ed82933f62be8dc55b43
CT: 9b51ba0eebf72bbcd7a1b8452a49f30bf2d96bf0cde4d9e5efe7f1903eb4e09f53aec649c5a8ad7e7fc6c28a0dcf4bd3556f4377bbf8b3f9c79dffa5978692559f732c109a7a02390746f5975d5a0aac4d04ce
TAG: 636f7bcc9b0b5320643f4b6acbecd60a0a89d2511621ab47fa4c9af610fa1ff9c6cc5cb8fb64493d6a4dca0e94a90794f31698cb1c5bb5658e8b6a63a2cc9b2f1f297240d3d6c62087e32f5d5e9f9d608eccf4b41253933c7391983db1138012a5f5caa5abde25c8a16fc33cccb0604421d985f198c48552650f5dd299bf9163c136c042c9a35cdf7120a702bf460d739ab264fe1f58453ff4990f7315379ff074e01730e7cace8d45a5d0355c0acc409db8fbc759516ad56818b37700548aca769719937103787311b6dbc8488d9e68ee439cec3075bafb725f44734326df9b10d6a4f7133ba84489a9985febc96200276a1fb513f8a3c062466cbe63e7ad668cade7ea70c3b8cd040a6162be
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (20 mod 64).
# DIGEST: 17450a437efe239e1858ac4062f34024305372be
KEY: 65aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef45
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660
AD: ed82933f62be8dc55b4369
CT: 5e4df84379f9736d784d9166047003e3ce3375a8e7add80c8687e94f68595aaa52e3bd39a45a7f67d35b4df0c5d62abc81680ebea78d1ec02153833b4dc4bc51b4d1725f5a830a064e33cd5052e90735477c069d
TAG: ddefe8bc965ff097f22b8978296cb5eac25732862def3ce5a7d2ee9f7b7d6a6cfe5778b9d6901e7540d8c62f3d97f68b43224e00f8536bd7df50f3ccd1e0917eeff5c32d196cc2b594d23347f4bc1db22ede4f2ffa7f0774c1a073b5e91fbec2b634d0d60458f215309be0c2d1b553f22a87cdd75cb64cfaaa0a15ce876bad26f48b2d6464488f97e35899c7aa80957491823239173843dd88a617839e5bbcf78d51dee3418defcea0a72e5ba7a1e8d652139955570510a9c8e6b6902a5c74133c641fe3950db1b7123406eb4cd86e17bf4efda4128e83172ae78e8c2b632c0cef066ef311f38fa1a210a7802a39b95cb699962daf41e5d436d474753997ac3c826ad39980aacc954adbb12c
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (21 mod 64).
# DIGEST: a35fc7d25f90dd9cbd35910d5532aca8aba88b29
KEY: aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed
AD: 82933f62be8dc55b436965
CT: 1ddce9b3f674dfc1b94a6cb34418e6b75c93f14941a6dbe028ed59667404b93afead95ec50b9393a8e0e5f469fc1cbc5136f4dc54f3a005af6c88cf70ff39487cdc730dc131538279704a67492f5241faf00aa8c46
TAG: d43074349115775a6db0a999c8b492d65bf1c10f046b7c7fa6335d54854a202748ed412c82088bac5d07db529fd2358c66e48a1a40083d9911834522091a61d25013bee70e3d9bed1c1a63ff50c2f0c1ec80bbba5bbb25fd8b2c787e9e6c90fe73a8e476743050c06c8f72344842507a75e6514fdb760f1c733242fd447a8c0658e3045324da0dd132841d0ca758429c6fc0355434a6ae86cc1c798cc9a558e767730437f66f08bc8fd0301d3447f5f5f5ae483ddbbf61f1c8de15bb2421f500ab10ed643d4bb54367946206d5d5cfa6a4a2bd16527a7cfc619d1d7df22fecabdb0541201825e2af362adb3033ccc4eac11db0b563d5bfd65ef1a95a28d5798a33230a78af0b38bed6d429
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (22 mod 64).
# DIGEST: 73eff0f03358879f900b6ebd515f0f4e5a6929e4
KEY: be477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82
AD: 933f62be8dc55b436965aa
CT: 6736ca287cf31ea3ec92c68697bfd1f88642e67d9dcab11c5dc8ecfc61611ecffc54a04119f53f9e5476196f220486ab53e2b21e1135bc6745731f0bd32eee9777a1b3d208c21d86048a4cc945389d60ec8954aaec13
TAG: 53f11651de2a737a0117aef6790d2683681561ca2b26586c5564d5fe06565e17200115d2a473aab781b9f8d4002fb4060f1eb43e77e31f270c143ae08a1cb5a2887c2ba393e050473894f62c6a7ec438eaa575d631b0736c3fcce58b9e81c28701a6d4c1dfd19a5d2de366d7b1c2433997dc826b48222fccf919ae872e42332b74d24027dbdd487014adae3813d52bd20271ab8da425e641701f78312026f117423f90145181d9af2696cfa08059a2f3b1f7f63e48c7ca8f63396620b4046210cc431a1b1311834659338f957141da2cba2d499ce121223f45078668652c9b699209bd1a33832e8a53c7bcd5fad62acbedbcfc1cf839b6d1444a991c573e8c2ecafbe33a23701291a8cb
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (23 mod 64).
# DIGEST: dd6cea270655225cb4f4231f54c19eaaa146eac5
KEY: 477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed8293
AD: 3f62be8dc55b436965aabe
CT: 95b9375058667abde693e7e3a598dd4c326ae4db29f54667c54453e6191c52f86d2fb4fe324e9a02b94f094f1dc272b1e6ad85529206a511468879d31ab9e74f7666691dcd7365ce52fd6df951c20e7a71ba740901f797
TAG: 533eaf7ba2c963ee7357a118f8306660f786ef35206612b3bb8a87748c76c6bd67c15aca895927b6a92c1fda33dc4c330e8fca65d6b82343247d070a5bc0d0d632f7ec3060546cf2fa4f3bb7f144356bb2371cd19100e7d7066f2c304039836d62a647300bba5b7501241b8126a8f39bf8ac2946aee674d0a64644b8aa0e261f4049c9ab56b16e717d162d9a43936852047d4adeb17bda109d3aea0a46acb70e7fc9351978b4bfea20cfa0f437fe8c1308e45a390e40ca17739c4edc6a0bf6e0c14d84ea315e36ad0e80d22011b02675ae09e814c08ce607d4e3fe18a4bb9380966c174ca8a1c397966dccddbbaf85f47bbd97c5d99936c26917df99b6356de065ac0ddee7dfede113
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (24 mod 64).
# DIGEST: 34dd9bf0ce19eff890ecad474388779f63b0af70
KEY: 7e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f
AD: 62be8dc55b436965aabe47
CT: eded2db8c302b3b5b5b0c0d556f8d34408fdb2af75d38231049b5f91e02a4086e6ffcfabcba5e3ec68173dfde382a41523d3c8ea1f7944351baad1588516c548125b1005d3375b03a4ff4bb19937068e0efea0abbeac4f8f
TAG: 379af744a549ee2fc70f6fd955d68da610b9e28178af1e7d6034c5e583f838a84882937060dee0838a6d0e008c51d312956cbc233af4e94ee992a3a9fc427f98283ffa000fe22e62e6181754cd434b066e685a514bc6ec82444c3d722fd37b305e1c514541208c4cc8298acfbc9f41762f50c87a9b95ca7a4d47ef412f0079cff9affdad66dec43d8fa706ef5bfa7deb9826c28ba66a7395e6491bd45ce3750864e3b0d466d236d1d5a5a6dfa8f531c2ae985515d367eca43505de759ad476ca08a6ad5265e8550a4d1fcdb0f8c3ef1a4567ae3262d5d5a78e7ef6c8097ca22815e35ac82ff78fb39b029edf5521311d0904b2e10822ffdf3f93118412181f8679363766430beedf
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (25 mod 64).
# DIGEST: 7db8cfbd3b29f96d752346eeda3c2bb0bd070099
KEY: 0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dc
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62
AD: be8dc55b436965aabe477e
CT: a56c9d8579b78c9ef40c4a230e8bd42750510340fbd0cf55393bd13d93b105fd2cd1d701b6882bacc661e8da81b7c9eed6b5dd4da12353298150819c748f464f5c60b86f92a9e89e483055b8dd3f42605a3065f08189f74021
TAG: 2704ec8335c00380797ebe4100b3ce3fceb38704eeb5db223e4256f4b2a5353ec0a89676e0542ccbcf3ccf131832f2d4af2fa86de6fb456ccc6add9e453c16e303755dc4e841344efb5251cd266a88f4f0efa3155db9bb475e9e97904a2efaabd8b2e836d54babc9fe4a5a0805d113ad28843994e83694fef3172ef45abfb037b3c78205fe9e6042fe4c2db156b78fcc52b0f43eb3b2ca0f40ddd0077be8880c29c9cf5d3a5b68eac071874a7c96fc531cac7c0245dfd87febabc641b081a7de6693cc85d7851238f239914d96e8281e6c44b1576d0e2a3ea02079762e05923cd53134db1524c28c02474bd539d0ffd8bea24cc743a35267ccfd405a834bbbeb3819a3060ae254
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (26 mod 64).
# DIGEST: 4abaa8453e8cfdefd918571a961d8351754ad5b4
KEY: dd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be
AD: 8dc55b436965aabe477e0c
CT: bf13550fa32201ffc699cbf22de17ca268652f8ba2693dde72b626d01855eea7c21f0afae3fa03dc757491e8efb9091a4c100f8dccfd15a9b4dd94e4fe1f5e90cec62768d0a91e132acb1fbec1052878706359cab3445d38b1a7
TAG: 87370bba8adc7957b9f4b468f584e1483306cbfa87738a2a047d9e5b0af76efafe46dd1028aba3d3677967124f2adfa8d88922bbad39c82f9272e4734a12c9a82201024147b14c50f110371ca57d3cadba332d46efd5a936feea2f74609ee8b39e22d4e49f608229b9963417661e47610547970d017d1afba6c5d653eeb9d6b596ee2560f1879437c81dd7b7ff64737f68e295cb558c3833fb481b582817bad184290f7b731b611aa09c63272a14f4471ec654e460fe7e2061de628bca07cb52682d4d46a3e29abd90faa42e9cda1118c92ba698ea985bfa4dae1e5a5edc2eff590d609b37786d1d577b55b0cc671d237e338cf46269451be059e44a2e6b40664d060919e7bd
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (27 mod 64).
# DIGEST: 0fb9d7ffcc7c9b84f34661d472ae2d4fa25d3d99
KEY: 46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8d
AD: c55b436965aabe477e0cdd
CT: 9f9a3ab733e50c1584c4f0c2a2dc0ff71bb3a9b32dbe92da2fcff8fe46a4bf16d4f30ec8efb1319891b7d2586839fffe5012a6dc3d5f0ad21e1572a1ffb48fbb59ee4b8e0234e543786e775dd4c54cb1ed006b4e8f5195610e267f
TAG: e3e1b44b7aa92166a01da7ba9c7dd6ed9245dfe296ee16fc20addd7a6c15462ca1c0bf1b90a136dba0749837bcf133377d6ff21fd3cb7c1f7fc50df8ada45e671e1bfdd4f711462c9655c8159f2dda37bcc96df425ef3fcba2056973d39378fd2189375bcb96ca84d023f45f880166ba262c3f089e58888b8a67ce85048c5628061e04a7f09d8a6eda422d424482dc4dd4d361fde54b3c659b273ee9a04faa389befbe2816e164d9bcd9fb6ec7aecf51e9288cbeca4d3e0dd776a3c122eb4524196dd7e4b8420a08a3276173c282dc1463ce6e6b17fb419c1bdb47882e6685c877119fb6348bd0f80b867d60fc8ffc4e89768eb33ada5f32a81eca38965b28bac74f5dcaa1
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (28 mod 64).
# DIGEST: c68fec315401703e49722fe4b39cf28b14e9f50c
KEY: be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f2
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc5
AD: 5b436965aabe477e0cdd46
CT: b4d33c5131701c960eda4c50fc0a918acbe28cd47fbcaa328c6a9eb08e3c36b697928c6981992ab155c30984c6b8e9340cb00decef7086f589ed2d730cfafd5ccfb95373b8c55044fa1c95927d02278a48f986a6b8301426bbdd504e
TAG: c327263a3dc33abbbb6985406703ecee6ddb0d9b236ff2366c65effb2c936e5961d99de3bab4eb9c5aba4f65a55bf768a369181b191545f4421be3bc5bd2155257374ba8ac8e70823421da77aa1e2001a4e2f4942a40dc586e1c9e3d0e8dba136bcd823eb644d8d152182fb0c88ba540ba3a71ff1b147e4e072298023ae0c8d37cff859108b02d586d5357076e6e649e2a8ad3d4a9de1ffdea88b4dacb2d2c7fe12c8739e0d50d91e3fb57d54e22e6c4ca3c8e47b2b9c7de9220a1588c631dd6ac85d04f58559b796b8adf5559365f8009181a75e1f7f1a3c1097d81065be9b30bdcd0c5572db64f633561e426f1a6023fd7b7e1c4f66919e9ee67c5ac4026cb11aac92e445d90ba020153333c8db152113c5cbe
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (29 mod 64).
# DIGEST: 15e1aa5285beab679aaedbf51a86b4aebbe3d7df
KEY: 99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f256
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b
AD: 436965aabe477e0cdd46be
CT: fe6540372ad1c40ec1dd644e935c480b9e34aed05a7f21e2e37dd46db52ebc5352cbc3be2aa289cc2e9712aa7d393f4454c9fa3a4acc30db41ada1257693d3469b0a1d5680dc8dbfea8cbb4768161f829a4f853c1c48d08825aa2b44f1
TAG: 53f79cf7b8f4380a1d1f1def457d4ad78c5819e0654d4052186213880228c482e2a54bbffb71483d32a8eb97ea8e9057a99a52fc3381820bd5c8fa43b846257380c07075592d6a445075a0df4e48f20dac7e2df8967a1cda41bbd4b0411a54b3ab9e79354a59aef5291599176599db82c0f6ee8a05e012067e2961b147a7baa73a818c64b52dbefd767b285fad111972528e3865b78c3c8aed658b1e84ecfd6ba292bca83ef66968e1bbdc05f616ae79d1d7932a0e8d5fdd7f98159b199bf933ada7670bfd4992bc2ec95daac00f10b7cf2bb68755edeb646395efccbfe322c9f381d39ec36d92c914fabb74d4df8dd506d9a8e233c591a503e92943e9437b10268bc9fd1a512b31a3aa62034ebb2dfc2ee3ae
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (30 mod 64).
# DIGEST: 8cc0b1164fc844e958e055b7ae43f2f95c29e8c3
KEY: 371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b43
AD: 6965aabe477e0cdd46be99
CT: 22e6c691ae1ba796667ceeaba4dcf85582e398e529d938da63c8221a58c2fbe242f6da82eae8c896dd31b45b3e8b72ff3dd7906130954f7b68d4c8729d3ff66ffad72104047209a56f1d6cdd927b57e8f29108140f903d03da3f4d210219
TAG: 6c22c87e07027df3721970ac8ebb881edad4c00566f7b53dff9189ba9844543d4c5894ff1579a353db455a1597370c9d8f2c16a191d6e0eacf6c0cb3bc30b979ba40244a12dcdbf806e609fee1cb9531813ab90854c5eef9527b0e546193df1d3b2e52c5c01cb67db0f4fae9e1557e89b130fde7ae3f7b493d1b0296ef965538ddb7519ec972ddd1926ca29e3a9ff5c9f55414f07a1c1785908975ed43b16bb7c96b2820fa3c317582dacaec45c71b3ed841a41358c87340f5fbac68dcd4590d9aa4cdae3374d7c332c6ace45644a8805ac792c4ae5bbd09ca06581fcb46e71381031d5ad54b117005c2924a538501c944c416e19480d48e792a741e863043be0cf0cc12c700c3238a77ca4dbd168da1618a
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (31 mod 64).
# DIGEST: b51001b6ff9d27bccf3103a4961280e0a1406257
KEY: 1eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f0
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b4369
AD: 65aabe477e0cdd46be9937
CT: 4772e647d03817c0f9deb39ff4f4f27fb0fed33e0630eb453883c707336f0e74ef206e92e31fb2935a466105dbdfd42c180ef63cf5cdd3c281337895e399df6078c22762eba5d84b8845ea00bd88bf5e4f0da518cae42502e8531b14d979bd
TAG: a6a89cb7f4f54501b3fc90129f28198a9c3ebebcd6fbf6513ae3b136ab79b5cdf4df4563910a498137864bf3a63b6dc731a29e2ce7768a8216ee39bb67f73b16f73fcf6bfb934ef67dbd964d016d876ed884e5c3357a5238dd7ad6f979e81952d9e2c2c6c5bbcb1ef860c67aa977b8b0e0288bb37c94b48ca7f8f5df733e1bc522c9b06292ae4340710d15079b8d4e9e7dc95b653844a7a5f795d71bd7611900698a21335e0736418cc31a6c29409f501e0d88be63b54d6ab8ab5c7f07f7375860f949168f9555ee49f7fcc41900bbe1b769a65ec344e172e0de68d74c94d261fd9785b6516ff425c6669adeb426c2deef874dd6b510791baa8778601c134dc5e05e0b414836303f21bcc7c300958a0200
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (32 mod 64).
# DIGEST: aceed075f31ab159f6610f43ff0a6ed3a359bee1
KEY: b8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965
AD: aabe477e0cdd46be99371e
CT: 6dadacb58a7b88e2daba277f66e5757042c142115871c9813d1a72a79e5a71366801a757a5f9982e99c355fe7d742fe3f047b711dbe340bf2ffd00cea6dc6ed7a4a416c17138404854ab8a5420960d60cd1b86424b2668740910a922865e4c13
TAG: 98e4dbc80aff1a2c04156dec77deab9850b5b951f501d58f265f2c75344f7e6d0aba191b077877ed269e75ec40c84d8644070e68e18583be6e13788ff2c7f9a923f84eec8642ffb6eb40ca773a45c003df69c80de0ba199354f231f9091d1b4078ac218835e2df3e76e77d657099bef5a6a1367e6c39b23a0b7cd345bb8f5a97b9dc86300132e95853fc3635da842ed214fd00bac3b46f002f3c26cfd36c575a56af06e74032cec9451837db3542aa717aebf6e3ab3037dfab7cf0aa0177eba2dc3a56c3e3011d4c940b124b565c4450b08ce2f900d400e01a9b469d327cd9bda24af77f60e8ec6f5da196ad850c38d5cec0fba6bbab584c8b486bbac87a7f559be463e5929985ce710243260fb9258e
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (33 mod 64).
# DIGEST: 976ca4c9819e25a204a024d05fbe7420f717bc58
KEY: da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d03
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aa
AD: be477e0cdd46be99371eb8
CT: 4307f039e09bbc51fa0477941e321dec14e5f562d3a5ba25d71c3c8afa23f44e1ca619d130890b7476e5227442c27995cd292ed9d0a649773b752b3bc7abf171244624bc55784adc9282f1776789fdbcca048313a1e6c8a23119db185ea4ec1925
TAG: 87187cd5d301d869cd1b4bb721475f6dd5b64be330781e20a24c1784dcd74cbec221914ad4ae88d4c9a1a9eaae7b13052d2c6ded662507a07594feae4de66b72c7fc1143c4e7100293f842ac0022d8a916a687e436ab7bbb56b2a4fc18677a813b38ab1e1d48a474322d44f581a8d007ffc6f7f4a132212e7bef5d5c9b13889dd2009c6398fa2dba18eecfcc5f41c5ed56be7f451f9b7b7a908f0838d3d8e2696512c6ec159a6dd94a1628be9911a3d827105d8cee209b6ec4cee3a488ef5eae355826d9a474f55bc736605c6c24444330fe5eff18a735736b66ea5d0c5b3278e373b57d86dc7815603993814ecb0dbdbd330c69dc46d7e6fc8555a18cc0ba5b5da89e5075c7ad835fef0fa46ea426
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (34 mod 64).
# DIGEST: ad8cfe7556704bb1974e94f70d8743d147c5c3b4
KEY: 7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033f
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe
AD: 477e0cdd46be99371eb8da
CT: ee9fa11a7d6f965e7d65d8f48810754770b9d237ba0111978b97e24f223817d0c6ce4dbde85c4e0979bea607a36c66f908c25384184fc334d8d985b78c2e9872d82c4cb1aad49d7dc21d6484b80f9192bd724ca57cdced2fdf142283126721c1c2f2
TAG: ba76fb9c71f51c92d4602572883846812cc94a83e86dd16136d65c3ab932f89b28ecf49ce22335f0c643e3d979401bad3ca97673f062cf69855b23b6a1b14927594d92f689b4204ddb32d95d577ef4379890d804ce26e0e4565dfce891c992a29b9b1fa57f633b0c231e4e9c4939679bd52205988cffc989e34ae744e49a7ada77c6fda5537c5b031208acca0628913fd8a2ecd9f2b5d50254da5f7f00189dfa6d553300d805807141ef0b75557a693f1f90698a8ac912931b7a1a3a889295046219394a0884f823d204d0a3bc4cd4e3fa6adbddab80d123368d2f29ce5e8a992ab9c1c5d2c8cbc99e99647410abb5c73d8e00a0482834f97a576e99311d747088e9e65b8546265f71a237c1f74b
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (35 mod 64).
# DIGEST: 1dfd9608adabb5a55e12949f1c4bfcd5a77cb703
KEY: ac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb9
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe47
AD: 7e0cdd46be99371eb8da7d
CT: 1a95f47f7bdb2d91358f683b7bf803254d88b59e2d3c1d873a09794e1c18f1c924d480727599a1a6890bb664335e690e4e52c385b634bed45e08410448ffda3ea2593a02a11a03d994617b9f7ac85317bf09c41b08b416863cd90f0244d22c795a34b0
TAG: 4537e27f1bd4b1b873ef4b3eb83cfc860c44921195a0250a96e553280b15e9ed379d4eac959a2809ce808e40dda881cf8a08cd50302f7dd5e67659613932ffdc086db4de634000cdda80fc576294c265f49a48c79ece6d42423a4f86c25c0a168d5eca502e87c419ec09134c27e4db1f2255de7e10f0102b44f30c67c8e07aa23aecd3f62ac8a24f9e8f82be61b539e288d22f8e05e914c191877c5ad1a546415df68427f97576adcb8d428ce7ce2c96acc98fe0d6dcb42049206ee1679f037955cbc12be9ae020774bea675b7c17d0033a60927f75e87d9c7ca263a5e0ed38450af657a81434afc9b4f4a14f02f82e33e17e7f61c276cc1e630dd773547b6cd78231de0895e447235cbac4b3a
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (36 mod 64).
# DIGEST: ad2b43eee27e6267d8c5c1c3d558a07dcd6b1f5f
KEY: 997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95f
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e
AD: 0cdd46be99371eb8da7dac
CT: 67466a0bda0815f726cd09d159e06088b2530b73775a8c18eab2d09ed7bd12b743b0a10345cb3126dc14d8f5c503b65a45467ef9b56ec7c5b24e5548e734d3f0fc90fd9c8019fc782882ea6e72f4df5fc6e8105e79d12fc588c9137c758995666f480dcf
TAG: 24b828c3e60182873556d7aa85480180d7cc42ba81732058a109b5ecf21f66f1ab580d18f70604ff31dab5a1bbee007d213d2fc7070e3377aed31399291cfad53a334bad7c1c61ddac5015d19cca020dec137fb76472b1a595e0fd5dbdd127b3267521aee32fd12c1f54493d23c27671750776f8937032b9164ed78bee6b8234972634fc7cb32cc0b7f6fdae850110d1979e380b4578b8747de6f3d89bb66d546949ac94e49b0a460c192f98373e2359fdea2cf2a6ad4d09199cc145fc537459d73f48d265a1cdd458f306e3596b2088f233630ee0a37a5c2c21a76bcd47871a7954cd9bf911ab942ff7221623cc7539344e23dba7b0aea370a7d2e2383a4ec9db06a8123016d73b4323d19a
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (37 mod 64).
# DIGEST: 3dcddb1e4f49633e7b7bd36f4056d16c53be7f5e
KEY: 7deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb0
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0c
AD: dd46be99371eb8da7dac99
CT: 34f8a83c831f374e77c5601317b658e47091d811285791eac2fc59fb06658c115dc875c80b1089a62fc7d072534617dc81dc3adffbbba4b9db2e7272eb0b8aea73eb9de6480c43190e239fc300377f186e4659b1f239906614865f10444ee64ae77ccf8e3f
TAG: 4c975e14b038359ddc06d23ea5a5119eeef3708347d7de47875cc88138b79d5c644507363c0a951623f3c26f8dffd51a2a282641d96ff107fc69684add9e93c56a7d29c8e097dbeac0a56d7afc522b7f5c921cff17c6ae4c7bd456bdbf95c052b18751e1c3ad9a26517c29071361aadf06740e43afb13762b4bc2a80aeb5e042259a36cf03a208b8f6162515fdd3623343b127655de069d5eb8c7b6c00fabec02186cd39bac62768303dbfed24cb20105c7d8b2a6b2c34d5f4472c6f372a841672c1f7b405d70d05c632f7a53997e3e4e0aedbb05813a8712dfcd3c8df4fcd83971cdb81538d2516a3a4a9372dbca6bdee43a2ed77309076fdb367fec85e5db2f01e59d3cc188b67f5edcf
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (38 mod 64).
# DIGEST: 25b982a242f669c013cab1c18da425330090e3cd
KEY: eafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd
AD: 46be99371eb8da7dac997d
CT: 2ec0aab31fbb036bd2af5ce39025ee2d5591fd525a199f2233384f52a8746f4fb547843c92d1e4c9fa92bc268174d4a59134142f14e8e1e277f1f1844c64f76dcd20f3b73dfec8e9fc59a639616fe4075a4732dcd3e1de806086239d2e09deca0ffc081f2ef2
TAG: 3049393a7f477630782378966f7ed4d33451da6b00ba751aee542cfe5aba67748a46953b578d0fad0e37b5627b4295a4f44b0c28d16e300888c0c8db965c14c23310279cdc9834d2ff9ec85932b7e341393fa3b6661bb8d3ab0cff6c6b646d927626b8710d3243ad7a971efbe3f6ede39d8b9f77585e4565a8b07917a712d85b846469807e94f3073097a69c30dfc5f92fd88cc36d3a5f670155aa98ebc80112db1fd1db0685261c1e7711d9c82a73dece8629a4025d7837852749fb8ee1489bacfb0bd8fada1389fc31ece84558d5732c9b559db32d8a498aafdc0aad020240e00f3fe22c2932924305fc1b3d648c53b9fcad835189b41a150ccf234988f26eda2655054c395924fe50
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (39 mod 64).
# DIGEST: 9d7958e23777ff2472f5a24dea5fc19c151dd921
KEY: fd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46
AD: be99371eb8da7dac997dea
CT: 90712d5e3edeed5000c62ce80212d41773a393792a3a8fc62a1cfbff38b3555aadd88f0e36f93c8a12897d7779972b3e42978cdf85da7a3ba2e4b261f0a0cf4e1edaf259849e87133a9c057e5d3e693a2a181eff1f5d6f84e0679c625ad9a0f72c47d607ffa453
TAG: 90b31128a2f6673d25ec56c9431584416b2e8c62fdadf580db2d5dd2ef8fcff5da4edfc09685b16db527abf1258b82c13761e41e41646479c833c8606b438a53fbc3718bb5e2ab3d9e25ee8862ff2d088aa5b37877ce5bcedf184713b2d5acb8408bf2f50b3041a0e582230a1f4034b6eee294808ca78e605b0461c1fa383b8194a30b3e66ed58c1b30331a97b3b87e12d2239f8f34e632caee944450e99165b9a317029c9f658c7182cfaadbb6f52da0f8c4f3fd73959c58559404ff80ea3af53c4430ebf2e41197ddde0e3d380668b4e72f72022e3b1ead76284506cfb3a20b9bf6e8425eeb89fc5582f4f1c6736e1185452e87133cb1e8ec045d2e40315fcdceb02da252a5cbd3a
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (40 mod 64).
# DIGEST: 09e9eab51bcb9faaa3bc3e473ff66b06e39653fa
KEY: 64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be
AD: 99371eb8da7dac997deafd
CT: ea1b542c224788ae66ded1b3ed9f9e35708252a1cd1d4725b0a187b669c51d282776471be5a07f256faa9ff16fa4248c629a4bcd31a9dfb7f260d9b1cb62dbae424624fd816bd81f781b93ca9dab437b5e0cb64a37874b0117cf7b96adba2cb7d75b834adf572d99
TAG: 1e6a782f455ebe54ce2dbac88683437494c4433ddef95e45bae93bfbf4b1d5d0d2a459e9db88be408428c47c256f73d42778e42b936dad9ed773a02d0e7298c22b60280cf1b7191eb7c8fa307076f5129720bad5961206dea4ea1a05645827b30ff3bfb6066db13a2f9f1bde975c80ea902e9e51e64086ea4641150c531df51b328de057d850502fdbf50b4a1295d170c0dada86a0209d2026501f111247b75826953366ecfee0e4c3479040cf27370de1711a73d0ccde18e218b9f6f6aa20e0a8cb0fa4aa75ee585e96a0a0968423c86b35c899b5409e577e093c36d18149199b59caf99f19d1163c31a0d3da31b8c5cd372372e2bacdb2b03ed28605e346cf794872e096ae048b
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (41 mod 64).
# DIGEST: 7b17b7cb19107af8fc4671420e461060e2ef3e61
KEY: b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99
AD: 371eb8da7dac997deafd64
CT: b1025c9eb02f72e5526ef641778aebe786c2f85961997f1eaa090a33caae3a9df34da7088352a2df7a61eaaa026dadbcd604f5baa3a0de4fcbb3812816408d61384984141d9c78f47e725e99cea9d52f73cdd5e2c3961b035589db1d2283476006a1e10a992d499762
TAG: 3f441554acad8b8f9565a0a69a17d231684a6293aa032e140eb41ea302b45d0e2e36e62ca23e981f98721a97ec02ea946282e23fd4838dd07b9a8cfbc069d913226cf543235541dc1a8881394e9cc0999c63b543e5ab74c35436637578148ff48bca333734d768b15a6e9535a69705248f28961e50facf4e8bc0825b7d2152cb2b85ac2e767b6650376a677f4c7e76521c790d59d9588e54deb9cda034551544ba80cf9d11a9f589b7e8980e6ab95ab77848e2bba36ed85afd9774f32bc9ab9173db20fb97a53d23091add97f16d8ced6bac6399aa089718d8bcc94c13b6e0d08e805b7fa252e787958d4780d24d812e0ea0df1652c04ac325355be7b21aaa97c2749f274a31c6
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (42 mod 64).
# DIGEST: 48586ad2eac603c136911b28e2c69f101a8ef371
KEY: fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d617
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be9937
AD: 1eb8da7dac997deafd64b1
CT: 10623f3b3c8888a31cbf51eae0989eb3caad5f5b786c13b41c04e0b6cb2641f850df4ebea610a4d521557c8f987ded40e9702503fc4ae62d1830a0f04d168888062f5b147e858a134a4022bf2790d81a89133aee08a34a704f152cc3cc763c21207d2231109e0b71a801
TAG: dab4bcc473354bdea1e31b926a19fb97ce2c8b47e76082bcc93a1db2707b67e4f72b18cfb728232ca334bfe9a4a55c347777a25b1a13ada600adfdc4fd57275414b3bfdc9613f300b4b29fefa8820b5c8989bc79db1bcafb69b0d89f7624a510d3a1597f953564a29367aefdaf36d238b957460f50b71adb5f85e9275aa511b7118d2310f5e3cc2bf0c21b0be6e6adcbbb24064a760b74679de7fc146a00014f36d39f59df902925710de6397bf32f5d108902159755feea57fb58a7bcce680babfb90e05a8d15c1b42a3b7d779af99e3cab04eb59e5ef45128195ca17bdc25dcaefee874e919bc8edbc8e28e3997aa396768ccfcd25e59dfe27e46de35dd101c38f7e48bd8d
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (43 mod 64).
# DIGEST: c37456cfc543ba6e5848b9b8f4ac5a58a104b521
KEY: 65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371e
AD: b8da7dac997deafd64b1fc
CT: 60d4a0ba2caff08ac046349b511017a7c5f5537eff0bda94bf838d50c14d59426424e4a8f531103773aa0eb9d242a9e6f2ba5002ef04aef8144c8a88f05788fa5fa1ab1cb5cad84da0d31b280ff8a55c2e8f32f39549736bb055169ad5ae93c02561006a3f13e65094f7d4
TAG: 140431d7b2bcf5139b7c9436fdfb3b44834ca810fb478eb0aaf7b0e2c68ce434f05c1f825b245d9fb4af48056925a50315b9f1b7d340e5f797dde4f460ad3c526853049976c0f680b691b28fb79d61cc9f7d8a4b28ddab1f610ac6cc44b91d64275ff1d26aa2b5ef314b1f280181cf72cd8b8fbc939a8751538d85f7fe03617a9cabd79dea5e64832d0b4aeb4893ac35c0d9f1475d928e3ed40292687926ccf5f9f76f78e00f217c013a12e38686423dcee930366e79950955c07399183d775c7030a50addaa42c7aabe5d8ebb95611f3c2f68be067e179e3de60d45b828d54bd6be07948508ff8a9b68abd944da07a484a8b9bfd4be1a22ff006e578b0c43c2bb1359d012
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (44 mod 64).
# DIGEST: fc113d192686652653a15887974eb1f9b8e32248
KEY: de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e78
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8
AD: da7dac997deafd64b1fc65
CT: e59fdb3d1413cd6a1098b5daf1662c698076996e2581e11a286e5acd6f29d41ff9d04da8308ce7f5defc52be0b4d1ee96d8e5f4eddbdd5fa9894e7d1b0a1bed483b7e7549e1c10cf5b8ebd1e7f1177972ff061cdecdad8d97bb0308b19bbc2c84d32a41f4c2b7e58721349e9
TAG: 6cfe1e101e9b8fd2b209a30c0c1127e1bc8a51b8826c64258b573711f4af7c7e4ede036de4a94d70e17695481424907475180c7899a982d7eb94536a30a57be43d5c6b5e9c34972e61b9356a9338af6e8dbf27c920edc9bd02ed5535018d3b3e3df45664f4c0bc01f1876f36338e85b4a127181b42f7cdfa7a4da5a6c249f1bcee2959e25d0fe17717b0181c026ca814cf21d6af3b548435df052ffa0a0e8f74b8c3f7bb37a6b5bcd2b3f2c0e4b24daad586f7b59996072f82c123aa0ae66d3f6bd9980e8ea0312ab9fe0052e1fb3911e35d880f1df50612799033c384f4899f69714efe5df2727528f7b3af6d69e525a04375391643febed777fe3fa3807a73aae666c137dff28eb3b2ccc1d07bc665094d33c4
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (45 mod 64).
# DIGEST: bb6e5b5be84ee383caac0378cb6f541726ecf61f
KEY: 39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780a
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da
AD: 7dac997deafd64b1fc65de
CT: 9764272fe16e12bb42a8f2a6620e44d4f202c21d51692e2948e2f4e4a18acf58a12d399310f15e78bac1f5f2a48416e5f4262ab9a8480d9f1429e5e9d15d81df0719f8db8d7ac08da696048e8a048255071ba8926be1dfbbcf53e7430862f64c891edaf772a830fd525aa8796c
TAG: 2cdb47ae25d087c752c007dc8b83cc050b53376aa92e9bc2c46d05ac7137dce0f70ac601b76fe40efd84be464015b5397031ec3e394f880713ad10727d270730e469ca30ea5897a84fd204bb14a920c4c1bba0d27fb154cd1f8277fa6aab1f4c743b52b51d09657b80398aac269f57196fdfb219d745f53a72ca08cfaebd736e7d016806d68e5deba428b484d958335bf03c0ab713b9a54b9a5bb4f3b82b76c45d04b5b6141aeb7271d0a71ebf90ba74b27dff1ece371f6353b8ce8615475a1b82c3276569b99de52b7ae5f27cb1cf9ceca291c1922382ad5260ebbb32cf995772eab6d6213d2e4c438909f691a81825c2adad290839c08566e5cfb3c13de4ebb016529de5549a9ac57d2e76086db82a3ad881
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (46 mod 64).
# DIGEST: a27799fc2e00e7abec4c5939451a834c4606cf7a
KEY: f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7d
AD: ac997deafd64b1fc65de39
CT: 9b6a8359acfc5d15067e2e6d812727d768f44b3edf4272f57fb54db41d95153fb03d7a7b3371e91c4be80326f4d70a8f2ac1e867ad3772901c513895e694214d6c0fa1f431aeb016ccc93faacb4950082f0cf00d3a5879c9a4f3fdb281e911b40d6d0a84b05f4ce32f85b1657d75
TAG: a3c72b69369cbf0d435790c97438a38109f36b147943b0629b1c2e4926e831d27155f5617f1f884af2799774b69bf0e092d29158fa51495e132b206cf51156c2116b23848ea51d684808d5a291b68f57250626d2190a7c0779512bca6ed44e619d0f7f8bc28e1c9b729514e12e7cc08e8e8d72bd1ae30229e56fa7e3246dab29e75bfc866a2b83c48036ea0296dfad04357ed990aecf6b28a0a3fe7eaed48f5fa59202f109ad0cfe6aa5cbedfcd62eeeb15df7be0645e161ee6f7f9dd811c98158de6534739268757a1813e1aa6c331586867acc75ae410c371a81cab835fcd928519d9468ed61fb5d7c191807e613d40fe174c8b33a400baea2e96d9d7f1734dd11092481e71d0b0c0c86419d5c50cf6e18
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (47 mod 64).
# DIGEST: f30eaff92a640a397f98e6803623e8d1f0c1fea6
KEY: f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b7
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac
AD: 997deafd64b1fc65de39f4
CT: 5818d2a656fce95d7a24bcb216f4d6b91d45d58d6ca2df5c9d6412d917951a9f61ff07fcb6b078fad69862aace436194f86f309373452e813c461fdb36a95f575fdf0f784ffa0914f0c0ee0c57ed1e604ca7a7a4b3d20c272b3b7f2e65b18c1abdf8c88e1e7e7dbbe9569eddfb226a
TAG: f6bfe8a461cc83a7bc7c5a39b6c521ed3e0ff050a6b01999b2710e0997e1a36a72c11363307aab1e4d921e9364ce826419d15b3a14e251e82bca615281c19bd243a294365492b11567341f13f14764e2b30ebc8ac4d313047694a884598daae76a45797f583a8279529e9352c8c13a06510ece3057c0936de84e6c292e3266424eb9aa4b7e5891fe7180f0a31580a700a4e24d7f1e53e1b69bf36a7c0db63473566920565cb9a22a47aad6afc8910a6b6019a67a092ae814c0260f2fada1a6dc44c5447217b6831457f66d7a2ecdc9187986edbdc1c68e573da33daee7fa2ef3adf4b6179b9a02d31c36e4505d5829ef30058ce5d09ae42fadfe4f66e894c36d7db467ec5ef508e26cf0724b261235579c
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (48 mod 64).
# DIGEST: 7227537c0113a9f46f7d332a0b37ee5303483d00
KEY: 3541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b700
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac99
AD: 7deafd64b1fc65de39f4f0
CT: ad0dff8adc54b5f02f428915bfa9f7277e4743e72e1789dcf552b91cda03bf52c757a9cca0655550c944fd264d287bc97d15dab3b986ed34637f45ffc1eb71b764cf5d5c1444033975829f1e59cb65ce40d787adc630e1f3155b2dc32733a75452efc755b6acd2160fddb9a26e0c4587
TAG: bb5273d6920ea95b43efeffc99da0dd48a556e357726fe34dad94f0257276f3ac759c16d9b34dd86f09a37bf48227d67765efb83d001eb8dd87636ec32860226db118427a7c7367d53cf085ff86d05a8f35f893a044e99ae5ef14fe490eb03aaf0b97581184956211bd19ad09c9aa9a064e305abff0c654006b8db861c7956ad6cbf46aeac4e5f5d54539a9dede2ac61d8f133c1a9fd2b8e23ef5d2d3068b42baff87faccfd8499cafa30bce2f30e2c1fb203acf1378d0c776f9476ca83e4973ffdd66f2fa86105ed83701fdce6ad64a824d2317f51443c9dd3c520327c7f3bd99413d832bb1b6b70655d31c90b7bb23a1957a146f6e0dd1a272a04e833e0b1c84ba2b09b0c1963ac17350292646566f
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (49 mod 64).
# DIGEST: d76570385cb65d30c3d636ff25c5efeb8d1ea08e
KEY: 41a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b70043
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997d
AD: eafd64b1fc65de39f4f035
CT: 8a1448acbd769e42bfdf00ddd801153db3202daf5ba7997890f5f42a183d3a66faf66d899c7099fa99bbcf5b62b6adcb6ee87fafdd0275a8f625f3f959b0ea9acca88070aa9c61141787435cd60f63e262a80b6aaf931ba554ade7e0fb46b03a318347f1ca84e9fa1786d721b6c222b1b3
TAG: 7bb49e9f481b45b543195956ddfe975cb63203f4b68b50a05c855d128d311c339676c1b6b38ae280d0731f613f9ae4cfd1945e302451f26eeb379a1b610773750e3e841d50e16da759a603897de6e84aa6733252cb0b6f6539e1a5258751ee7c0a45aa9296c32322d6a465a42e4017f44814fc58402cf561deaffa43d61396d53077cf089cfcd42b182694d286a97f99b65e5c43ecf69898c036381c6dd9657f2cc08144b28e9ad9a00ff10fb0ad3b26e92d8d65cd6879b11ae50f592407188e46a3342308ff9316c898b09648f71513e09367aa2ad5d93f87e4b2430ccc8fba9825c0407135fbf65a0db46d491059f71a989629dbfb1adb10e98d02935fa846628e8b0f8dd01991761945c5e84f9b
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (50 mod 64).
# DIGEST: 170369666d1f2337b29b5f14af68d47910388e7b
KEY: a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b700433a
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997dea
AD: fd64b1fc65de39f4f03541
CT: 0fca069ff1b260179dd5ff1124e557e97a4cc41e069d124cded05275d37913efa220e1ed4768bd04d8e65797040856b686cfcd5b772278bcf5fa64cd8183ba8b7724359804d609b31fc31514a4ed43d84de929d99e63f12306bb497e8ee77648be578ee74f1cb2a09ab32b3ecb913c7b36ae
TAG: 19b492f83b9458b356020d7c6343b6967f1ab0328801042379e7d8e98dc3f3cf646a96d7842c83bbd210dd8dbc38cfe5fda9d879285aeabe19dec677fcd389651cd284ac650287f13a461ec23f7dc1cb5511dc529e99a078c2c80ebaf0fdc6704bdc35a2c89c728a061095448e6dbee102f4793932a580a826382a244a9f11c665015675322d514be8b1453ed6be846613312a1bf9e4f2c126d2b15dd8e6ae759f5151528361d10d657543767b05e8c1b79df65aac381738e2f43f95cdc77383f22e36e3b26d0c65f695c75f7ab422864e63c230df313fd8e41b265b5a704b7e5f7c96306bffc1a95cd09584519e2726edf93a9d2871b9fddfd7983c81812653152c3775df228a542f06f359bf26
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (51 mod 64).
# DIGEST: 7c52593d1d37b0dc380297231c6cb7b64e04c493
KEY: 1be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b700433a95
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd
AD: 64b1fc65de39f4f03541a1
CT: 8cacbae377d038fe27b37fdb253f3b136aa38660743dc6b4778ab16940a9710c8f08970164316e26c3b603140f2f43f62a88d021426b841baec29fb11a3d8735d0b8c14d133a825e1044be5523932ebd65b34433c083c2d77af313a240b1eeb52391728dcd04852fdcbf9b6f89502dddc317c4
TAG: 85c893ad99aff613e6f95cf9c6e9045cc22fc8fe421716bb135269202ac57803e67682d09f88ae5970fb4f52e97a28efcdfe0a359df79a0576179a04830becb0551d93d862842c4b5f33c23fc0988f96d6deb37288f96507e432190853aca788d55114946833b6c7c7c10c34a5d5852d6fdb287b9dd97fa6b7991efef4ce66b0dd9f0ed6d112713c314aee9c172675d86c8f52097362f3ed4356ef4309da510a6708f32f24549dd80c9ef72018d7fd90134fa2d1ac1b9858ceb9b382b263cd3dbf697aa40f875eb502d4f128845bdaa9a8b4fd07a31b687bf4a1a1bb4843e205a9ab2b33a3ace650f96935b5f6de6d7577deb9ab68c4295cee108b2f4aed1f2d2fd167085d2173e2e854559222
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (52 mod 64).
# DIGEST: 09a1659100052d13bebb4defd7f54f975a58ae2b
KEY: e112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b700433a957a
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64
AD: b1fc65de39f4f03541a11b
CT: 06b44584c9ddd267bf03aa311730fd0c4d3461678d94b4a794eb3e90b9cf3113ecf0ce0da8789d59bec50a1fd1e08ceea4cf9e00b2e0423706c126af7a3031df6cd82a7bcef877b413662e731b5a74ebf68f781eeeb79cf760cebda2c5070dfb992007716993b0213e822829e23f448a7a5ed880
TAG: fd65c8c7f6b7795ab5792332f6329c1d606b305f3de89d9e154ff7232947d8581b6666faa823b9ff8bbab2cea14c2526b0fceb5ebaabb79ab4cea0bce96e9d1a3f556d7d2d83b4ce2c1ebdaeceedac3fae6fb8f9869f7c136d47a1ac93c7b5b5ef01f8e56602d808a39b40f069403eab03498959b53b8ac0bfb72f0c5b5063c063183b43d60a616325439b0491e2f3be59f9948c939f533c3fc0923028babbaaee977cbb05fc44f8cf8ea37016141d464716a875ce4ad096e247ee9081a1ae3448183f5412d84a6223daf432dedd679bc3f167ca5dade21fb2cd9057189049e730df47b409a07a8b2c727e2ce04da8e3f02ebc6c2bd528b7726ab803c5fc5dd602496f78b28474ac87911bd4
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (53 mod 64).
# DIGEST: 230c3353ccbd95e4f0acbbb0073053a0186f833d
KEY: 12a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b700433a957a74
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1
AD: fc65de39f4f03541a11be1
CT: 85da88e13f3ca14fc4440ffca7bc837818daf1dc52a4c505583edd070c7cbcdb4642d8ee1ca687037b08e1737a2f49039621823222f9f02deef2c340289af5184a86af8429747ef2f7d98d6aec2af060fc8e6895c2182bd1c479fc6a2e7ecc0390995bafad5b3356e2a795131b0aa7d4ded344e50b
TAG: f1a1b3f3fcb4cb89587bea4284449bcdb16785c277835bff9083a65ae77ff7543492a1d2710a79b720060ee37954c9719f8dc0f6fb4a75a27bc2a761017ebdc0c81f9e8ea5809a816ee67e731871c476f1ccd6b690b054984a4e74c060fbcdf5dbae743ebe2f72fd865dc1eb96e4e62fca3561a245be1749ace472b312cb1b28a0b2c2d38d089eab44f51ceb88af097627638a3556005952e28212d5c9bbe85c86f89879e55358ed06f28402f40285b97a8046b5479202f28218c71f98a4020ca5d53e16e91ff8387b16cfe6bc4e81c96c44e7691c10ebb0d37686e608773cbda993b816ee3b15c4ccca2a22468b186f8d29d853b945bd27ca0fe3e9ec55bdb9bb4e5477e6f89914e3084c
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (54 mod 64).
# DIGEST: 701e141608e71005d32dd1e29cd068aea736c9dd
KEY: a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b700433a957a741c
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc
AD: 65de39f4f03541a11be112
CT: 10ee64784345c076e3f9aaeacc87cd51d6ee0b0facc9f40b4e6a1b4bec669ac3c5252c948b0c0a4d8e798248e6b10ee247e51c81793c2be91aa8c9666e0d8774439ea159e4745014bdd2e9f379ba461a7e638cab9ba2aba1498397044edd3f271e2b4dbb5990c383167c9191ceeaa8239aa6391c4b27
TAG: ac2d199535c4d2eba150702b88740058f1e834f89031c3851571dd9122291dc3e35b764eddc5856850c8c59b3caa211feb1ac256b749127bbf4ef56ffab65e3d9eaf438b778e5342a67ee4d876fd3e53aa29a532fab39d0c57e24593374e2adfb22cdf0def5d9cbc8701c9d6a2cf23d835cf75236069ab2874b7264e0e0ea9dd785b463ed8a6cc3cefc3a4c076e5f0d047c7d60be677b7716bd123bbf3daddc0cd5eed4d5c4f0f6d1c19c66e0b5bee5d58d295c2fbe6a164d464b173cda057094b983b2ff974783084a6cc4ebd9644f3b4426a3c157352b70ee37a2f1ddcb85936b0c38be4eadb33bb9cda7108c192597421bce5e36cc2bce7b65868f28adde738fd3bfbeb15608b4dca
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (55 mod 64).
# DIGEST: 9aaf96b472ea76fd9ff4adf56dab5fe0400d18d6
KEY: 2933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b700433a957a741c9e
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65
AD: de39f4f03541a11be112a7
CT: b90220b919dd02b216aa2eb7863372a645b09df88645dcaf138fb73d8896e39aac5a1c2f0535385e15cb850a6febd5d6ea9f3fb573944cdd5b30cb80aff6b73a173ffd7c85673248fab94e3b9544930cff59f52515dcc8ba39b6f51dfd0487bcc9d28773e91c718afe8399d652acb97552b1909335dad8
TAG: 4db032df3ebf850528a308017477a21da23178403432b4714c1da01a253a635cd2caa77467597e9b8c589ef3e9c6f5b991329b97bcd1bf1332e03638fe1b157763bc41e4f6e78c05a5ec5f83306e3b5e8bd96c9a04aa83291ca90355a3b96a8688cb93ed9bba3b8688834538d1e8bb95a0cf431eb7b849d87199657a402a0e1e5ef79da8c1895cd454c440c57cd424977f6bf9e2fa133d916c8772e447e066ec2cbe3d0de2a7e19f06c74ad5794e5eaf9119fdb70665c07ab81e7d72371d23a4c96290d2da60bc7819af4d60ff4ba832daf3369c6198c45f0ca4c974dd9b4a81c0249706a25b23fcc0fa13271d0f00c6672a06898b2b833ba3b8cbd519e53939f0da6c09f288bff969
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (56 mod 64).
# DIGEST: ac6871d354eac507556770d8b6bf10b5240273ed
KEY: 33c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b700433a957a741c9eb8
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de
AD: 39f4f03541a11be112a729
CT: 9807d89925c67a45c8ba18cfdb817f5bbc21e58c10f7dc8c15b70acd97e8b97e0393d5948d51a65f6f092590b38c845164e6d2b49288bd0f73c4f4b551b362470638f51422dcfdaaff5e8aaf80ff715f3f597fb9385ca18355b8e98d1de17a303d019f7d4b9a3acd07d257c049fc16134c53e1350cfb8c28
TAG: 7cd3491b8e157876b8091d2742f673196a25077410036ed62855b5440eabb10a01362a8e7c06658ab767be26c43a6eea3e354ec867de2b7b6ce96a4a951696051fe1a76a694d330eb56c1752bb2f866dbf6c1e85b3361316631c7a4a277023fe1d793ec4e4416c8db3b7e8a157e33438eba857e2b54db84e06006f83d93284714dc76cdf33da3d5adee64de2ee9feb689b9d64ecb857588c60c6e8b2eaa3999dd2f1cc2a6727cc5a50fc3902124055705eb726f0e57830732c85bd598519ace6cc86105cd36cdc7ad7f6868babe314b69d33021cf9931720aaf765d5f61e41155c7572ba298d52f3d61b28e3b5080c124821e1a97d1ec78eb5decd34a69d054fecb1209d86ee7779
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (57 mod 64).
# DIGEST: 050258d6ad6bec54f8bc48c7ba2d669d6416c11e
KEY: c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b700433a957a741c9eb80f
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39
AD: f4f03541a11be112a72933
CT: 8d69a3691570f0d175aad5fb77a0e9abd3f882b10355a08f0160c113096acfecdbc4ac32f037d16c2c4dda4bd3325c8690bade6bf39b14435cc11ff575a3d7e9f7b09b5b40f9645d9a5dfb44f42304d82298cdd866e957d4ab64374ffb86879a9339ea892986ac706bd2310927aa2bf27dce3bd6012591cfce
TAG: d754d4d2dcae21dc4a69c8e56ba3925f9f3ccc53278cc621a0ec4d4ea7b099a289eff5599f8bb1555aa9fddae50f04b5567ca7ae4498e1716f4243932934e2cec1434d4780184f0af1d0d194cf848671e5b0d6982a07b5679826f124c8f69f26cfa37a0105cdf15585697c75504bf8c9c04d583db189cf2dc2dd345aa926d440997a8d76f6ed12a19f2d95a2727fc4c0f8786ac3c50896a6cad6d948712e4d72a44cfb2fc9dc753dbed91f4fe412db6fa5e6b548eb1abed87e3b4e5d808ab4ce11f265efbd4af8e0516bc412fb9ecc3d69ee68bff6b12f3987a585670439ced09a038c526bf226299b0628f6db003a21eb5d943ef84e90f133dbb4c8468f555721c76da689e8d6
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (58 mod 64).
# DIGEST: 70060f86c76e53512933c09deb5872eb23efad67
KEY: b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b700433a957a741c9eb80f2b
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4
AD: f03541a11be112a72933c7
CT: 26d675c591f287b26eb35f87231624e454c4aca1f25491b74a252e971c48ca523b353b4f6c0106c1b3b40182eddbaf7ba47263790c3b22d23b09458d48868bb18b2fb01bdfa965f7c1b211fe02f9b78959b71e872ee05ff3baf548a85797270fd43c9db1f9f97d3b60c62c06bccca0ece2b7249f3c0dc6b04aa7
TAG: 864b50299da796a664edb8e1d0bd0120ad31405c47919c288884dfba933326b03eb399c634fa77d611e613e958369aa3d9a563f421cce3ea87d5bf2e179c20e5218378cca347fc18b87248a66810ea08806f571f1e86bfde99d089b06c3156cb6f2427503cf03e39bf3a60b1d9542a3789b657956ad925754ca4a369b05d269d481d4cacd35ede8684623ec9fde9ee860ab12975bb1386470e1221d2b2d1091c7a41754b8440740b4878fb19c65ffeb2a120d84661179e07672953243a09085f0d21265a5476c8574bc49e30ba364fd9d7f2035ba1222ef9c6bab7d1e68211c1a9425a13473f692b700c242fb56fe77fded75312bfdbb7fd44a88ab37d85d640e883ed1936ef
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (59 mod 64).
# DIGEST: 58286fe273bf572a76a2725933dd969777c303c1
KEY: 4ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b700433a957a741c9eb80f2b02
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f0
AD: 3541a11be112a72933c7b5
CT: 9c61bfbbd3e8395be166b30a56b3e192748ba3bbbdc334dc3720206ac10c90dd777aa4957695bddaea0b7e554951c94f2f74a2bb7547ac20a7e357fe249614204401144fef61394c140553d5566c18ded15e0fa50fd5836cb725d277fa46210eb588a96d7baec9e2c947fee1b85cbe6556cf23655132ea72dfe4a2
TAG: e66769c0cd9a2448afe99faea0b64137f4a902158d6b11a58f4bff98df8545e0ea23a7f7127b6dd76e3a3ed43490b44bbcd6a7321e5edb819e6b2e163318ead19f5a306c7b0b137f3b9aca44c4ea070ffa5712102b3f1dcec5c660b494e8f3d809b3722fee1e7dd29cf771613b68e45733a9e66ebda992930d32829d31e61f2217e41620ea4e621840f0fa7f7b8762e0ca509f0eeeded7fd55727462b045e4adff507f3dc4389d9397f0429bd17c2408ed60e0d94efad4936fb55c359052a6a88c056e7ec1e4085f4a48b125bf9340e57be98b5cfddc3f9d07cd036b0b78aa205fdbdc8e9c511ce32b6e4c9dcfe5722fa13f9d8b59821c61ca6f8ef75eb367f4a37453642c
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (60 mod 64).
# DIGEST: ae701e5c8672dfaf728bf0f43f5e5247ea9ac13a
KEY: d4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b700433a957a741c9eb80f2b021b
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f035
AD: 41a11be112a72933c7b54e
CT: 174bb28ef8ee033bf0f39cf6a5d3c2157ec773078860232827fdb1c875e9622e198a00a50fcc03b2cbf1e4a747efcdecda8b612ec3ebac650a7401b4b204185e4b42306d544e3f6512b87bf36b5f55ec0bb4da01c36aad92a16865cb852e1a5d1a86d3d57e6336d4376e8988f00162de8b238cfe36916d5545fa9460
TAG: 726c9d0511e81f69edf9bbd0397f4c3c49365418afadcca36de0aef99afbacad6dcf042fa62d405c9672e5409a7d28baefb467b7c153a3ed97bfd2b8be9b96e42b33703951bcbf04dec12d9bee63f5f30d2e57ecdcb3818479a163bd2a1caff3a327a911bcbb50bf213b77cdff340c858472223a71d4f15e029fbb800b81ff375d84d4c30ceda7a2c42267e1cf43dfd565c8a4a842556d577633857204af99ca35ca3c28bb02a7dd9ab224ae58938461af1e2bf64492fa2a18b4224ac3ef671c7abd9b6e266a0469cf3b0283b3ad6934240994f1b2d43b35d77e0055e0377c43922527d93426be34191dfd4b0a4296a078d128ea416be209b15c557f5da675c705ef8d1a30ebe78535434d2ff8bd29346abb9bfa
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (61 mod 64).
# DIGEST: 4f498d0aa9205160827626ef80c163275eca1f78
KEY: fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b700433a957a741c9eb80f2b021b14
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541
AD: a11be112a72933c7b54ed4
CT: 9b01cfa97c72b5ae8befd0d357283a52f6b8c5d9292d28f61373334280f815d6b69f878936738cebaf6fc84d20baf51868eb4d2ae08d64e724beea1887a76316acc955a00b5d1230fb120bf7d51f74fdc5f332521c59406bbd3161987c6ec49ad946a6a51755796de19830631daf69c78a847d2e515d409a7b77ffe75e
TAG: e785184106419b8c7f38061f49cfe3a265e9d4557b9b2d91ecb8f21ef3f52e387643b8ac35aae45594e70e4ad4457b852834718a1456136c5690aa164a152b0cacf020e33bfb33e2f1b79dd23d2fba5adcf22d4288308bc1d055be378eb77b67dad654658906aa3cebca8eadce6127ffe972803bed110a5e301bca0f2c06dfcb7af44275628831bff33807048996115d496f4f13b479f4fc1e8f2ff0991ad73293e789cd909fc0471a484ca11be8383fbb4d9590570c275354cc89a872306f4d285561dbc068c98d2989dc4453b97cea004a73fe238924c321d3a77063c1f20890324ae59860bdd3f7a70a7c21f1c51a790f37305719527a20b879e56b65d38799b899cd9fdd7edafbf456618452eb4fa37cfb
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (62 mod 64).
# DIGEST: 8c043825b2a3764e8a0cc35a011696fb3ed03c2b
KEY: d0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b700433a957a741c9eb80f2b021b1444
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a1
AD: 1be112a72933c7b54ed4fa
CT: 0b0133ac614de667eafb516e1fb33b016a8b49e558f335eed239d50ddd13a4152f1570269615a243502fe1c6db0667a2de7975120ef65186f5af83821598ff45494e943acae24a6095ad46a498971f7b185d7784d451b1260ea478c03babf0e582a8a777cec20905821267eb85aec1a20c0e3b94d78d425a12f2efc4d60c
TAG: 1d832d65c91d458bf343260419ad0ab95c1ffc09b137d1ad1805cdd648c8ecdaeeaa0ea27075d4e6753538d831577642c92317aeb5525724023beb923c2626bd9536757ab73d1739ed0a850afbaa5914fe94ed606e245274d4d3071201a3d73ea1fbbfb4032e8404c12dd02e0b6cdc38324f4684049e2707f249c9dce0e6df9386b787154ecc3974d041cd6bc5e6d031851247703347bf8324f077ce63ce0393fcbafb4396bbfc9260628f4f82244b77b8ea0ff14e26c2058e0d8b662fcb9d9ef747cacc42ece4777114cd2062e20b8c6d198fd5628b198511274f54964c40f1052d41f68b5d90256e894da5e5ff3dee493f5eb2a7d2a9a88e32b774afe2e0e643d606185c34796b40716a46fb8ba911552a
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (63 mod 64).
# DIGEST: f3a432271c9be858725fd024071c4f479ca9a971
KEY: be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b700433a957a741c9eb80f2b021b144476
NONCE:
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11b
AD: e112a72933c7b54ed4fad0
CT: 8d5b92c78a48ca6049da6a036735ca23b99f9c3cfb97122312e5bf0279d094cfca0b976e24f6b65d81f85eff669da35486809cbfdfd1fd615a5347947156148e6b71a11f7bec611e7c29e19f6f62f94bd7f8b89e54b6945dcc1a7e380e51456a31f1d511bb92443deab5987c3bba266329b3f27e24d155ce685f67c34dd18f
TAG: 295c8072940df20a1ce3a27f32622fd6cdec5f5aaebee91e6654ce96f013cefc348f1425a6fbd6f42cb4e1e866c0fa602afdb503eda59801d8a791fa7de63d22c080369c6a3389034ff92ffd347ebfccb0dc9cc972f6654eb102f5b12baf864b3514f22d55f28df8d51955a1d338b4e5ee9145a4a85ec87655ce41255a6e91435a1d9e4af613d35bc6b4554c2594baca964d2a58c75deccd36d3efb50986f844ca6cf79dae24edbe75ca6008457ec23e69db9e19c6c039feceda6e1672bdcccf0a8c864e957b7efb1b468b4976a97600e3d03ba9341876e6439117d2ec364d479e0743ea9ddfce7effc0a64b73fa55fb1f57c18ea97dbd03b6391963734dfc459d4efe2e0f609bd51ee0a09faa81065ec8
TAG_LEN: 20
NO_SEAL: 01
@@ -42,14 +42,707 @@ TAG_LEN: 20
NO_SEAL: 01
FAILS: 01
# Test with maximal padding.
# DIGEST: c6105cc86e18eb8376c16ea37693db5c07b77137
KEY: 8503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371e
NONCE: b8da7dac997deafd64b1fc65de39f4f0
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c748
AD: 1df3f4183aa23fd8d7efd8
CT: c90e0c2567341ea7e9d968dbde46ecb46ad78dc8be7d47672068de66d6e7eae14b500b94927f24ff6a4f7b07
TAG: ec90d128ef465f4a3645fd0b2601fbe2b0bceae2f890f0700c7a15c82fcbee6ab492908ba5f2df0f04dd0635c047cbe52069d85fcfabe53ceb43dc71c46e51c0e3a9ff435840d62bdcb93341a1624b69397fa1bbd9229814a2788b91a107534b41ed488f4ce95fd2ab46963e4f1a3096c74acc8466d034eeaa7c0f1fe46a4eee7abb740367266cd36fba96dc74e520f64b9605c067bef516f517f99ec73c1104b43bf3e94eadd7dd6b9b7db847d6ff4c03dc454d8edbf8f694f09754f249fd1dc0bb4b130b2e43ddc1d24a0cc14edc8e7328515cc8498ae89beec66127508676fb04db92055abf2be22e0c2a7a3d9664e17d919f655ffaaaa7246a0ea29f9c42f72b6edd0dfb4867802d6992ce25efd8fe0dd0cb
# Test with maximal padding (0 mod 64).
# DIGEST: ceb2d295bd0efd37c6c34dab1854c80e986174fc
KEY: 37446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11b
NONCE: e112a72933c7b54ed4fad0be905d4120
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba
AD: 2fd6773e0d0c302a5f47e0
CT: 000893d3434c5be7cbf9daffd81f03545f735cb70d1bd16eab26e07da7ee29b4c607d9a57077d74437e5b01a89c808c7ceca0d3838e5c6ee9947f1d4ee1d5e5e
TAG: 6d8dc4edeeea81cb503d7389da209ae335876393fdab048965c7eb1a1403d05f8ef059788d08c2e906444388fd416a87bf8706f78d35797453b242618f4a99f47c3756116ec0318d96435032225ff82b902b9b6985189ca438e466154ded91676676c645926e2cf8a5d6f3bfafbb713d646cfd35b091f68e5ac2e7ec10badf1fd80767e6953abeecdc89beb2180dc92be21631164ef801147917e0c8d7841bdcdb52ea03344ab5f2bf3d5157794f5be79f51eb1efdacc0b77b27b72e2ce03d05473203522e3c2c196390d77dc28a35951f3aebd72ee58021d55e521dd029719a7660408ed0da5ab41830102bceb514b0b172d0ee10937111edba82b47e719c3beb3ce49a665accdc1c5bf028d465b5e1
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (1 mod 64).
# DIGEST: a07054c760cc66fc704edf950201005031f3faac
KEY: 446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be1
NONCE: 12a72933c7b54ed4fad0be905d41203f
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2f
AD: d6773e0d0c302a5f47e037
CT: a1e92776d0ffcfed03d1be956169f606733755d5a7011620c7ced6a825d8e59627e75692a41a1f2a86e62fc6052873b5458616414584e36bad698cf4c44909e0a2
TAG: 6e0b32528feac2d7f69abb480efc7aae6cd1c5f8a654bcd10ec5be08b58f5a2198bddd83439d69ba9f55408cdf087e8a7f33fca6859638c5a4e8bc6961afee7534d8ffd95249d554b02e5beb81100be5e10abf679300f4ba514c03f4fbbba3cc62bd13dc8c8b9a726a9f217446c6e3b89cadb40488b177926c88c9d22a6c4ad9deca67f0d976fe62cd24c3cbb2e51dd16ee2e7bfe91d867b77c77a9a65c387e2682d946e617d0128034f5fe436eb7fa88aca82526d71dfefbdeeeb5a2c15d57fce0cf12e6ce0b101ef92d9ca540447e0bb65bc04b6a02e4e6d9378c6eebcd6d530c4ae14243beebb18403e8bcd434c2d88cc121e2df182edc3e1f52b060b1aecc48490c6cf3260299449945c803891
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (2 mod 64).
# DIGEST: d059c266cf6233af730b7a229b19356a4c6fcf06
KEY: 6f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112
NONCE: a72933c7b54ed4fad0be905d41203f5d
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6
AD: 773e0d0c302a5f47e03744
CT: f414f0321370af1490839677747893befa438051fef5f02fef488d7b84dc03140b3a5dc3a57041be4c8b688633110fc07251d877de0d6242928e4d937e3cc58ed611
TAG: 4ee98ac6f10e179314a251a9db190037c47b9fdfc66321d83a995f6dccc5259801b18c3f466f7f4939b7d2d7196e0b161aaa013721e81bb9707b974b904f670e4aa495357b562a254908417b65fa69e86c42b3efdd423838575db08465a7f4889c85201629f6350c0865b5b0cfbac4f51ea1eacc8f9768014975d780438c3bd77f7f18612080abdeac9331e1a068c8f3a345d0026c5723bdbc48643c1a733a5b7ca9078424522db9491bc38d2644dab2d75499715707cd83ed655343ca73672d480f1420754fbbfeae0fba05be3b5235a5fa48bda9f39df0b298351d8f4da3fb8a2feab8b1aca9335eb31ab03f40ab19f668bb864c798ae08de37bf848fe2e898172d26fa23f383787d7199a6990
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (3 mod 64).
# DIGEST: 8aac0687e33041fcc18da154b41f20a6af2bfb28
KEY: 5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a7
NONCE: 2933c7b54ed4fad0be905d41203f5dce
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd677
AD: 3e0d0c302a5f47e037446f
CT: b51ab2f8c4ba3e8638d454ea72da5e3cb15336c347c442b8e1ade85c5cbd0dde790dc707d60d452d5b88d72e718f13cd0e0f4c9149b72e8d6be869d817a3232513c958
TAG: dc8feba112517f6a820ca12de43c5d64c51cca713d3702a2b4a5cdbe86a90946a7369ec26ea8b5b35df329bfc6e29ef50c2774649134bd6e3f3fb38ef13d9c7fbe066e9cac4fb88dd0c02b677472ebbb2d0679dffedcaf13fccef6a25aed3a272ec01e7680becf80a624518e1333d28c97487b06e0581cc80c94989db4e93489f3dece9eab6dbbee73aeab572d1ee7705d18b899d9c62d7a370311e64131a801400b580d3c8f7af88be485b84fbdd89f7f7dacb29afeb56658f3d8e49f27adc542e412b0fd652b9f60575bf61622d7306c54bed50b43d89cdaecf1981ede09f9ea36fd174118ac178ade5f26ba04fcbd2eb035f030e2139506456ff8d342a4e59bd55dfafebda23a66cacfe6d1
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (4 mod 64).
# DIGEST: 53658226c112b86438dd27b58a71f9e36fc73c1e
KEY: 91d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a729
NONCE: 33c7b54ed4fad0be905d41203f5dce99
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e
AD: 0d0c302a5f47e037446f58
CT: 87bf1af7e4987cdab35bfe32adc6b1be286751426cf926217f2c699bc095bde7b6ff3d6cc96b79328ab776547c2cb756d9de8c1245d21619a51dba8364ef6914590f15f8
TAG: 55b9a1ee198080846389dd088016acab73622b1e2f902b0776846c74d99c27e67c7bbb55b2ac0efff91af0f6cb2ddcc0b5b8bab768048bb1662bb343d2f3a164bd4ca4850fbf8111b29e9be7bb836e2a8ac50ec2cb0b1c4529e50904007372284ec9187ea27d8faa03fc9535ba744155d06c06a0a97d96c03de71c13c95f185f426615f1368be346aa5ebf80049ac6771763235f2ee44dc910a01035c53caf8f9fa6f51fe3ad094513a8db177b6a66e24d21e1e40a23aa3629fffad45f84a58a29ef9237fac5eb6f5deb3825de6f399e46b2b2b91faf64ce45d164155e4dc757f6005c7c3e7fb3d8829623fd7c6ca48b923be90c38f5209c6d94696d2b2b7ebc5dfbf2cfa1a37e8ed038e830
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (5 mod 64).
# DIGEST: 6b7d5268b0b5037afb5be5af6a0ceb34e7656ac4
KEY: d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933
NONCE: c7b54ed4fad0be905d41203f5dce998f
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d
AD: 0c302a5f47e037446f5891
CT: 44237c388c3d017300db0fc9827f9b575e59bd971a0fd89cde4aeb1763912b49d50e92ba19d7594ef6da27320ac2bd1db3bcfe56b68a9ea8e2347d69890fa1fdc8bed782ad
TAG: c1068d84aa962e7b89090993378806194ffbf677e7a66524d2ebfa7bdc52d76d09b914168eec4a5fde0953d4567affd3a4e0e48190e7a84471efe8ad1ce577c21df93b9d641c865d90ea1e6069bd703c4ee372379a4ec94f7e99867179561d41e9053977cc985b98f7a9fbc675d77052809b89b8f23f993e191ed1a07f97b89d05de948107f94245f216c413288eb4e40f3cee9c00c15926657d9ef9187ab405ee8000b4bd84d5771464401d59156a97eea7b23b4a6e9f1587cd3b75826a621b699515829dfc57740ad5719c43e88d835e13ebf703a0966779d31dc26866e0e9d27e3376137c92c97af49a876eed425d3980f1904f013143faeccb4fc920185ec2325361e5b318434487f9
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (6 mod 64).
# DIGEST: 63efe7af502231420ed5aecce9a28446b257828d
KEY: 7df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7
NONCE: b54ed4fad0be905d41203f5dce998f8f
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c
AD: 302a5f47e037446f5891d7
CT: 2f25b5a3b01af5411466c8aa5d8ece037434d5e12b62306f2732cb063d0dcdfc2725e67118a242a5576d470fcaf9be6d811bf2789cc66f5561d0542438b5432fe713187a879f
TAG: d80e1f4edc2137f430d36a5ac93680c973fd7c64a03f7c2ce1b7e33085fe94da70ee26f47998947310508448cc70daa595687eaa540e48f048132de108a045da6d71170e39bb45160a344a2fdb5cb56ab020b9c0842ef2a1a5c83b4d63359fb8d71506d1e611fafa29e77d0669474d135e37bd8aefc3e17f024093186ff80fef73889e887b8d6672256dd592946ea84becc08c29445c8d978e896b1dad5e2608e347e54a97f3f757d7362f95f4cedebed07ab45b05713f7119c38d15a0f22d4259893f5e2401267543b3f78b52d54dd2d608173119e2dc7fe01f66589628e95fd7528958e993b21e4db664b8cba2f776d5cc305c42553da936d580c17d6f5090ff04e106c6488b5b18dd
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (7 mod 64).
# DIGEST: 1a555c300a1d1bd5b03cdd6bf2a678621624eb05
KEY: f660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b5
NONCE: 4ed4fad0be905d41203f5dce998f8fb2
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c30
AD: 2a5f47e037446f5891d77d
CT: bbf934979c5d9da5c8b27d0341a164d640f12956a392303b0f1665935b5c39de458f53e0a6f824cc56081db1615fc67ffff0d300d1564666b81bb37da59e4da30de9d6a19df74e
TAG: 9c18b0f9ee6a167a23566325eb330660997193385214abaf945dc18fb8252fbab8330b9809a6f1b300ae5a0c9d841fdd6f77e8d65f1cd0b221fb9b94b5e5d7215e6f501f490a7fa0a754efa7f2d9f5b927a5da2bea736e73af067e5d988901032d503ef3ab89894d03e48a096e7c31fe64bbc2c13f02d878590659ee7606d9212898d4d246e52b03c5646b1c3fbd43baaeda6548156987fc8f490f5763da18198bf0754d20f16dcf7df6bd35ca4bd95cd5c95a60427fc541aaf1f6923ff150de825cff9900ac9492350770bdd13fc4d0ac858ccdf36efbaeeb572aa45ca5470a04a7fa1ce5954d58771730b7202def47b303e560e81ebba2080d044a0851043c5af1a05c30a5a448eb
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (8 mod 64).
# DIGEST: de9156349b578f2f44945ec6a676a67a829daea1
KEY: 60ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54e
NONCE: d4fad0be905d41203f5dce998f8fb2ea
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a
AD: 5f47e037446f5891d77df6
CT: 9b9bb61ca4d5aab8d0342d2b174e8f39b8e21db0fb7146025fb298016df3bab4363bb47f5b1fa038587df98851d09d473a68c959ead8062c52b9d6de86bd6a0fc9a2daab4667c621
TAG: 897472da6d837ec173c2ae738721306e8d3c9e5353b65d1ecb3be3d0039739de379c9b06f42af8e952aa9acb4780a6de888dc8c54fe9a2eec19ae4a864b3b9696d712153bb66c49825ec5c891e30915c4b7b66b190525195429426ad694467dab09e8c2f9f21ffae4d54b74c0c5ed9a05963651dfcb9560677693429c63f3024043385ab0a31066243d42b80d2aa9854005504d6c8b9b7f736a8731c5dea0f3fc9007aae0c6edcd0a91dd1bbc5750de12ee13d4a77379cd3b2c2bbac885fa17338011b7b81cec6711fd5d65178f20a06f5475e09c202deef57939161ca8ed3e4aa9b010277acddc4478d1afb64138b276e265182ef2dea321b4f136c5c439ef6d099621813209a43
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (9 mod 64).
# DIGEST: 12812df3aa7f3bbc899f6f248f5590e02570c292
KEY: ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4
NONCE: fad0be905d41203f5dce998f8fb2eaad
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f
AD: 47e037446f5891d77df660
CT: 33ac574b7962d03b7816c0199a7f661a485832b9023867a749fc4bfe8ff0485571744f801139afd8215863b23e2d68ee7a254c60d8029e0f1ee10a1b947a4984f37f98a6767f52661e
TAG: 3ee493d8cc764880f4ae7fc3c189b95bfe11d89640e3c9ddb55b230ba0d142d53fe18be8b955cf0d0d237c3b295459fc4c723b27ba8a29ed8dd5c80fb9839e30bc92e6afbf28ef6f72d1c28e5452460f986444678e7ea982d8bae63b69788012bd43aa66e5a521840c79831ae74426fb16f0917c5d2747b9c31fe43ecee604f26afddb093a9f1f1205a4451d50080ed0a9208a88ed6dbde37a674932bca837c46dd8725982c2ef6ac54511151c4cd59e511ca3835ea9bdbbd2e0842dc9674a854b8d4b063d0685086cdf917a7b7983dcc28af2addf3bc302034e365da1a87334a68477aa34a3a878d926d4c17f50316749d917e172e47597d060403a0279ee68dcd864652f37c6
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (10 mod 64).
# DIGEST: f3c89f21c327fca4aa400fabea9e39780378e901
KEY: 82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fa
NONCE: d0be905d41203f5dce998f8fb2eaad40
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47
AD: e037446f5891d77df660ed
CT: 8517e13ca00214ebfc748efd3a233e8b64801dcce99f9fee3d271357220dff7b1678c1cd6392a6ade62146c0e783248918a7cb69dd26dea525bd9060f380dba75e502bdc19581ebc3295
TAG: d1f1280699f5514e4a56b08a5c3146142ef8e44c18ccac74577ec0feffbc29884da82212cba95b31d8464954498340f35e9a3d84256e8628368edd166d4b429fcb76e0072d2f5276ed8dc7bd5f34e754f6577ba00ee7ad74e9c89c4f82af0a7716d6ac77c39643909dedcc9356ba42f07874031878229a076da9ac7b0e49b2d170239089ceaf84392e889e7bceb3e383d0f744e229c53e8654ef0099a11773885efc456883e4a973557852f70c0e35668f3f212260e131962087416e668c9f995f226152251f5873fb89047a9dfa65b9fd0116486092b1092c4ee33e7625772944c06a2969b162986cd46d2b4185af2658c25c69a7a599d17f37be0fe1c8250cd7df5e6cf304
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (11 mod 64).
# DIGEST: e8e41988fad6c8b44c56544964cfe0a347b35b1e
KEY: 933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0
NONCE: be905d41203f5dce998f8fb2eaad409a
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e0
AD: 37446f5891d77df660ed82
CT: b1cf0005c93547664e09031d923c4ef9ad663a808189cd8aaa68fbada340d8bb13330499131ef3788cd91e9527702a2388802fdd2e91998a53ffbb466bb7e362d06677edd673cae71418a6
TAG: 7cad97328236aee512598d1a4c7d51b2154218fddf0ef21724921c1afe61fed1b7a1d1b56b8099dafff77362c4154e4bd7089fb0908ab1de49244a053997a0d04229250e52bc1ecf4550da5753a35108b6752f907ddf7a77fefbdb5d7290b02ae231d019d04ad9a5295336639e7e6c81ea46863d2bc3c4fca7d0f3b05237306759b156ac1fd10b044730987d04a943f0f598704f2191f6c627299b92a2c01a4004111c21f650376c3f28fc9793eddaefd74a2bb3cc5dea73685c954c63b71f2924ebcf9853ff084117cc84a0785d96d8d55d02723a2082ecd8c4b49b8d4068071593aff50c2e08fe7c49f6de1d7586e299b42ec723063f2341fd9b3445cf40893cf8c2bfa5
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (12 mod 64).
# DIGEST: d1c7b2c04dc25fe7b742a1d659aec20e1475ee4f
KEY: 3f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be
NONCE: 905d41203f5dce998f8fb2eaad409ae0
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037
AD: 446f5891d77df660ed8293
CT: 7195b9643e0f7a4293c865db36442d4fe2cf3ea2c648dc88cd5636fe5e6bcea3d1197966e800da8c78bcb8830f3fa97671aebce98549e62827adf612e70f946673b07e2f953c8fe5e0b97aa1
TAG: 3a909a9fa57e720bea6251ebbc1a71bbae1fd894f6bbd16e11abe51bbd1293abc0ad4c152a08b4acfac7a65b723fc6bd6923db66bbf202e184e8dbba150e6021ad1310ab4752cd4ae874409688996fdf88636084db7762b9578bb0c98d77c5156a82a97a3f6989db2359d252ff7c6405bd4834708c88d4481b35eabe2f7069bf8bac374fa382f4225659b41dd2a8006c0ff8d7c77c8d157e0373f45fcc0abc804a9f8a6b816f2b729befd606dc61e7f763f18121f56255662e36d120b27adfc8e1b528bd8ced5386cdb62cc73e58cc7918d27253297e9cbb9c740c7765cb014cf7bf160cbf09e00d32d31d462f356791bcf1286bb9023254afa6c41fe3d165f1bf7e6c002ef64ecdf3b5e073fb569028032e6713
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (13 mod 64).
# DIGEST: 116e20ff1e79e0af464d473b1e7c187f4dd66007
KEY: 62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be90
NONCE: 5d41203f5dce998f8fb2eaad409ae021
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e03744
AD: 6f5891d77df660ed82933f
CT: 1d50f3eb1cd76d8e08a9f386db0cdc3eddfc694e8502ccae47ab431c2935fc461254b80386c87690b01c22f38ea9bd118d2e0ed316ac249437a3e9c30f6c1f767c150216ec90e6c8913ff3d469
TAG: e44bfe162cbba654362d1c86088564b14120815f181932e9f111d6da5efb5f4caad61f1161d1d148cc429ad34fcad9128bab101c7cc004fb8f0b516216a809a6599b5144b4c5828cf159fcecac46a86ba0698a6e5267610bad10cd7ce9079b6c691c2ecd522dbe3563074f2ac85712e58cca41761aa94449199a8b440016e68eb8bc9db3ff2c2bd9c64d9d3c71566bfb5d234af1a144859431f16ce6d65b4cc604e9cbf4e5539c192f07a2981b55582376bedc07aa20f5a841c9f500915fef353c37446511da3affd743fc551d5c22454797b3eb957770f1ca16da138c71bf5c00ab7893ae83b3f499a2c42f55551a986555925337e0604227ebf1c65312f0b1a8cdf2d06b5daf3e5ea97ceeb2f33421d0b44b
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (14 mod 64).
# DIGEST: c081d0d09b2c9eb39a372ef4a7b0246a0956b0f9
KEY: be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d
NONCE: 41203f5dce998f8fb2eaad409ae02116
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f
AD: 5891d77df660ed82933f62
CT: 4d754c684658bcc89208bcd75f24dc8e18b70a28b8a2201535e60ab755fb20e1ddfa98742d257eadd02d96c6a65f880d058312311efdf67f9a106beff9f5ace0ac6af586aefbb5e8b4850e584bb7
TAG: a9bc9bdf2c16ace8cd471c2bcfbc2cf933fc1886faeec62d4809ed5cc4dd4fcb6ca6c42f31bab300264b278dc0b10fe8a54005b590160b410dcdfa3db413dd04a72c897b262ed0fe4ad6683fc5229010f1d2bc939e61a2c9e0480ef3e03e90f74a3edd8bb523271adc45d097b197ca9034bff48677efa763e1ae7528d3f775f827b9c56ba7f042d7f9413b4c5d01972e86976ab3a398afae27faf3cd19ef1b24b5342f9d067e7702bf1ae9679540a72f7a12cdbfbac234d596856b3bfdc2190dff0b50f45b4355cfa25ebf8d1d16528fe6c4baf9b0e5a50f95c4091704e939c8ffe69183c2695ecb1f12f24fdf288a8e8bdf3fe510bae70c46d0214303d5503d21366c4eec24cc2808542a203d81789efbb6
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (15 mod 64).
# DIGEST: 6f7bb1f9e2772eb909c315e653e4737cfed78a18
KEY: 8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41
NONCE: 203f5dce998f8fb2eaad409ae0211641
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f58
AD: 91d77df660ed82933f62be
CT: 25bc47e58e7d4f3a417c95768699c92240a2be0e86232a41fe02d64f66716023996772e1118be48e685042f989dcd9cdc574614c9c3989f1885b4b71dfd5b1c32c1321ca41ca1e6ff1828e677e30fe
TAG: c96a78b9ca68054bc1ed2a150dff9f9585174f343d3df80350982002b4c95106b72813a90028f2855faef235909686607f39655ec48f4024e170c9f9574b0c81b63c8df7af6b4d0f0633853a09c334379952bbaead7415125f541a01e320c5f5d9806b71c3ba71890e3229e751f25ac82c245596b5fa688f1b13844d91169354bf0cc03cccf576c2216aeb9eeab33e2a9f8bad2145d36cf0e7585a02296a7a3b434f4efeeaa4d7ed65befda32b287d9d0946e25dbc0edc22de871184ae8c76777528b917585be784d5e0674b1e5693d0b8cbe8253f8db67c879e1d2b7ddd5df4777a15509f813eb4d0f5a935aa011daaf0cc1ba2ebba9a20a74847e9c53b648f6fce4c08b6e7babc1919e6de22210a6f05
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (16 mod 64).
# DIGEST: 172f4992e692a88f49628e5d3937959be01aed2e
KEY: c55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d4120
NONCE: 3f5dce998f8fb2eaad409ae02116417d
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891
AD: d77df660ed82933f62be8d
CT: f1ab85a35a17541efb4f906e7fc85e64efec6ab40d59d3da920c4ec09797c3ad47820e9d934e51e3f4d097c4a555575939bfaeb8cfea062b64816a160d6e4d1ff02a5fded435ab9aa2daf22fa7d676fa
TAG: 14684ce099f4f0e11e785320debb89c79c03e8bb8751860d3779b4b553f6dedabdb23119d2866ad63fc974a6c6442b734394cb6705309a4d3889e90c4a222bbd14624cd89a9c3f904367c418140375dd592107f839ca94d43d09495a8dc8273201bd8f5a447bdf57506421a975ff4db3aab7878ff18e5b73c8f072a8d092461257d0182710ee9df9f86ac5ad321eac7ee96dddb27ecf561db222ed1c7c183c2ecdf4c7f57cf295638de3c4176ea244100d51c006282e98af1a8fd540daf0ca6f2fc0b88c550b4ab638760d95f2f9d09612da198616cd13fbfa1ad12a3fd30ac9956491cb11539a1be43175fb1452393f13f8d03501c89cf5962730125a7e185dc089b41124fc1e7f69b1fad46bd661c1
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (17 mod 64).
# DIGEST: 00133da1f7c63fd5f0eec364e9a359be02c1d3da
KEY: 5b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f
NONCE: 5dce998f8fb2eaad409ae02116417dae
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d7
AD: 7df660ed82933f62be8dc5
CT: 5d6bfe91cd2273a9b986397a38e81be5fbbcd0403ef51873c2c467a9fbadc7bf540e83c538a43dc0e0ab780a4c4b1f5b77ced74f65b61f8b8b58b26fa3e8cba568bb717dc7071bf82dd8c68b068e739706
TAG: 2ab9e654859c35e065f763d949d43c65dc85dc5d918850809ad8efaed6569d4b3ad064bef3427ae4c3be571fb914cefe2362169bed5b4c0cb17d2106fd6993d20ab8a8b70edb5f5d59b3357c8499c36e2b0b67edf7f334ff02d599031f43252b8d30d39affbd2093a6687c771b672329e14901ad9128f063267d3ab332ea31a79d37cb24ad0fd2d07f23b13d4643d1d9c529e1dd0490c851b0009fc1192f2438a48aba5a39be2ee925b1a38647197ead5cdea3499daa5abf9f4503d3581115a6847363348d5e7933948dce867752cde69ecc401012674ad75e12245dee86d775989275a5fc635c66d42c01b7646e180d28798905a3beb210c049be35b522ad580e1ca29f81b9469448749fce961ba6
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (18 mod 64).
# DIGEST: 60a6821269be6c5b985576b245f106128eb0b325
KEY: 436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5d
NONCE: ce998f8fb2eaad409ae02116417dae0c
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77d
AD: f660ed82933f62be8dc55b
CT: 16e3c681ba1ece3bdbfb1da491f877e806ddac5f1ae96bc406bd195c9d48bcd4a9b700a8ced21d824bfb99eb057e401c3529818725b51e96c576e8009bfe4866e98f550a23ef4748ff761a4d1c44ccb5eba0
TAG: a30286b3d06306818a268db0e5116abc2c7361c5a32d334d8ce5f4007aaeab750980018b435c79391151fdd33df2a97dc2cf62c4426ce45be43f7e4949be735bcd33f0e81cc6b5a3c2255fbac9ff5a8fd7e7b57554d7ef00640d92b605c9afb0c19dd5ca4c79c409d85c197e8f21d79e91df01a817bf68e8718bc771028c945471ae003c0a210c572b79d772560031b5d3e5495aa8d9bd6fa3f8ae9976ed7e7f8d7275030d2f12ed5ab05276ebebafcac7d0ca41f9d860583f800e4f1b9658b12fab31fd63f6a5e4b80463918f8295ae11d7b97f9b5f89b8166861aec8f1b1417163a6a8adce23ce66c9a4306acae7ca75435cbaece814d6010a3e335bd7db9783812052179d5337d1c353be6e0b
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (19 mod 64).
# DIGEST: e2593f3b6741a9ed9fa188fc06efd057556ee624
KEY: 6965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce
NONCE: 998f8fb2eaad409ae02116417dae0cef
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df6
AD: 60ed82933f62be8dc55b43
CT: 9b51ba0eebf72bbcd7a1b8452a49f30bf2d96bf0cde4d9e5efe7f1903eb4e09f53aec649c5a8ad7e7fc6c28a0dcf4bd3556f4377bbf8b3f9c79dffa5978692559f732c109a7a02390746f5975d5a0aac4d04ce
TAG: 636f7bcc9b0b5320643f4b6acbecd60a0a89d2511621ab47fa4c9af610fa1ff9c6cc5cb8fb64493d6a4dca0e94a90794f31698cb1c5bb5658e8b6a63a2cc9b2f1f297240d3d6c62087e32f5d5e9f9d608eccf4b41253933c7391983db1138012a5f5caa5abde25c8a16fc33cccb0604421d985f198c48552650f5dd299bf9163c136c042c9a35cdf7120a702bf460d739ab264fe1f58453ff4990f7315379ff074e01730e7cace8d45a5d0355c0acc409db8fbc759516ad56818b37700548aca769719937103787311b6dbc8488d9e68ee439cec3075bafb725f44734326df9b10d6a4f7133ba84489a9985febc96200276a1fb513f8a3c062466cbe63e7ad668cade7ea70c3b8cd040a6162be
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (20 mod 64).
# DIGEST: 17450a437efe239e1858ac4062f34024305372be
KEY: 65aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce99
NONCE: 8f8fb2eaad409ae02116417dae0cef45
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660
AD: ed82933f62be8dc55b4369
CT: 5e4df84379f9736d784d9166047003e3ce3375a8e7add80c8687e94f68595aaa52e3bd39a45a7f67d35b4df0c5d62abc81680ebea78d1ec02153833b4dc4bc51b4d1725f5a830a064e33cd5052e90735477c069d
TAG: ddefe8bc965ff097f22b8978296cb5eac25732862def3ce5a7d2ee9f7b7d6a6cfe5778b9d6901e7540d8c62f3d97f68b43224e00f8536bd7df50f3ccd1e0917eeff5c32d196cc2b594d23347f4bc1db22ede4f2ffa7f0774c1a073b5e91fbec2b634d0d60458f215309be0c2d1b553f22a87cdd75cb64cfaaa0a15ce876bad26f48b2d6464488f97e35899c7aa80957491823239173843dd88a617839e5bbcf78d51dee3418defcea0a72e5ba7a1e8d652139955570510a9c8e6b6902a5c74133c641fe3950db1b7123406eb4cd86e17bf4efda4128e83172ae78e8c2b632c0cef066ef311f38fa1a210a7802a39b95cb699962daf41e5d436d474753997ac3c826ad39980aacc954adbb12c
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (21 mod 64).
# DIGEST: a35fc7d25f90dd9cbd35910d5532aca8aba88b29
KEY: aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f
NONCE: 8fb2eaad409ae02116417dae0cef457b
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed
AD: 82933f62be8dc55b436965
CT: 1ddce9b3f674dfc1b94a6cb34418e6b75c93f14941a6dbe028ed59667404b93afead95ec50b9393a8e0e5f469fc1cbc5136f4dc54f3a005af6c88cf70ff39487cdc730dc131538279704a67492f5241faf00aa8c46
TAG: d43074349115775a6db0a999c8b492d65bf1c10f046b7c7fa6335d54854a202748ed412c82088bac5d07db529fd2358c66e48a1a40083d9911834522091a61d25013bee70e3d9bed1c1a63ff50c2f0c1ec80bbba5bbb25fd8b2c787e9e6c90fe73a8e476743050c06c8f72344842507a75e6514fdb760f1c733242fd447a8c0658e3045324da0dd132841d0ca758429c6fc0355434a6ae86cc1c798cc9a558e767730437f66f08bc8fd0301d3447f5f5f5ae483ddbbf61f1c8de15bb2421f500ab10ed643d4bb54367946206d5d5cfa6a4a2bd16527a7cfc619d1d7df22fecabdb0541201825e2af362adb3033ccc4eac11db0b563d5bfd65ef1a95a28d5798a33230a78af0b38bed6d429
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (22 mod 64).
# DIGEST: 73eff0f03358879f900b6ebd515f0f4e5a6929e4
KEY: be477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8f
NONCE: b2eaad409ae02116417dae0cef457b9e
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82
AD: 933f62be8dc55b436965aa
CT: 6736ca287cf31ea3ec92c68697bfd1f88642e67d9dcab11c5dc8ecfc61611ecffc54a04119f53f9e5476196f220486ab53e2b21e1135bc6745731f0bd32eee9777a1b3d208c21d86048a4cc945389d60ec8954aaec13
TAG: 53f11651de2a737a0117aef6790d2683681561ca2b26586c5564d5fe06565e17200115d2a473aab781b9f8d4002fb4060f1eb43e77e31f270c143ae08a1cb5a2887c2ba393e050473894f62c6a7ec438eaa575d631b0736c3fcce58b9e81c28701a6d4c1dfd19a5d2de366d7b1c2433997dc826b48222fccf919ae872e42332b74d24027dbdd487014adae3813d52bd20271ab8da425e641701f78312026f117423f90145181d9af2696cfa08059a2f3b1f7f63e48c7ca8f63396620b4046210cc431a1b1311834659338f957141da2cba2d499ce121223f45078668652c9b699209bd1a33832e8a53c7bcd5fad62acbedbcfc1cf839b6d1444a991c573e8c2ecafbe33a23701291a8cb
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (23 mod 64).
# DIGEST: dd6cea270655225cb4f4231f54c19eaaa146eac5
KEY: 477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2
NONCE: eaad409ae02116417dae0cef457b9e5e
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed8293
AD: 3f62be8dc55b436965aabe
CT: 95b9375058667abde693e7e3a598dd4c326ae4db29f54667c54453e6191c52f86d2fb4fe324e9a02b94f094f1dc272b1e6ad85529206a511468879d31ab9e74f7666691dcd7365ce52fd6df951c20e7a71ba740901f797
TAG: 533eaf7ba2c963ee7357a118f8306660f786ef35206612b3bb8a87748c76c6bd67c15aca895927b6a92c1fda33dc4c330e8fca65d6b82343247d070a5bc0d0d632f7ec3060546cf2fa4f3bb7f144356bb2371cd19100e7d7066f2c304039836d62a647300bba5b7501241b8126a8f39bf8ac2946aee674d0a64644b8aa0e261f4049c9ab56b16e717d162d9a43936852047d4adeb17bda109d3aea0a46acb70e7fc9351978b4bfea20cfa0f437fe8c1308e45a390e40ca17739c4edc6a0bf6e0c14d84ea315e36ad0e80d22011b02675ae09e814c08ce607d4e3fe18a4bb9380966c174ca8a1c397966dccddbbaf85f47bbd97c5d99936c26917df99b6356de065ac0ddee7dfede113
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (24 mod 64).
# DIGEST: 34dd9bf0ce19eff890ecad474388779f63b0af70
KEY: 7e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2ea
NONCE: ad409ae02116417dae0cef457b9e5e16
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f
AD: 62be8dc55b436965aabe47
CT: eded2db8c302b3b5b5b0c0d556f8d34408fdb2af75d38231049b5f91e02a4086e6ffcfabcba5e3ec68173dfde382a41523d3c8ea1f7944351baad1588516c548125b1005d3375b03a4ff4bb19937068e0efea0abbeac4f8f
TAG: 379af744a549ee2fc70f6fd955d68da610b9e28178af1e7d6034c5e583f838a84882937060dee0838a6d0e008c51d312956cbc233af4e94ee992a3a9fc427f98283ffa000fe22e62e6181754cd434b066e685a514bc6ec82444c3d722fd37b305e1c514541208c4cc8298acfbc9f41762f50c87a9b95ca7a4d47ef412f0079cff9affdad66dec43d8fa706ef5bfa7deb9826c28ba66a7395e6491bd45ce3750864e3b0d466d236d1d5a5a6dfa8f531c2ae985515d367eca43505de759ad476ca08a6ad5265e8550a4d1fcdb0f8c3ef1a4567ae3262d5d5a78e7ef6c8097ca22815e35ac82ff78fb39b029edf5521311d0904b2e10822ffdf3f93118412181f8679363766430beedf
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (25 mod 64).
# DIGEST: 7db8cfbd3b29f96d752346eeda3c2bb0bd070099
KEY: 0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad
NONCE: 409ae02116417dae0cef457b9e5e16dc
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62
AD: be8dc55b436965aabe477e
CT: a56c9d8579b78c9ef40c4a230e8bd42750510340fbd0cf55393bd13d93b105fd2cd1d701b6882bacc661e8da81b7c9eed6b5dd4da12353298150819c748f464f5c60b86f92a9e89e483055b8dd3f42605a3065f08189f74021
TAG: 2704ec8335c00380797ebe4100b3ce3fceb38704eeb5db223e4256f4b2a5353ec0a89676e0542ccbcf3ccf131832f2d4af2fa86de6fb456ccc6add9e453c16e303755dc4e841344efb5251cd266a88f4f0efa3155db9bb475e9e97904a2efaabd8b2e836d54babc9fe4a5a0805d113ad28843994e83694fef3172ef45abfb037b3c78205fe9e6042fe4c2db156b78fcc52b0f43eb3b2ca0f40ddd0077be8880c29c9cf5d3a5b68eac071874a7c96fc531cac7c0245dfd87febabc641b081a7de6693cc85d7851238f239914d96e8281e6c44b1576d0e2a3ea02079762e05923cd53134db1524c28c02474bd539d0ffd8bea24cc743a35267ccfd405a834bbbeb3819a3060ae254
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (26 mod 64).
# DIGEST: 4abaa8453e8cfdefd918571a961d8351754ad5b4
KEY: dd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad40
NONCE: 9ae02116417dae0cef457b9e5e16dcc5
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be
AD: 8dc55b436965aabe477e0c
CT: bf13550fa32201ffc699cbf22de17ca268652f8ba2693dde72b626d01855eea7c21f0afae3fa03dc757491e8efb9091a4c100f8dccfd15a9b4dd94e4fe1f5e90cec62768d0a91e132acb1fbec1052878706359cab3445d38b1a7
TAG: 87370bba8adc7957b9f4b468f584e1483306cbfa87738a2a047d9e5b0af76efafe46dd1028aba3d3677967124f2adfa8d88922bbad39c82f9272e4734a12c9a82201024147b14c50f110371ca57d3cadba332d46efd5a936feea2f74609ee8b39e22d4e49f608229b9963417661e47610547970d017d1afba6c5d653eeb9d6b596ee2560f1879437c81dd7b7ff64737f68e295cb558c3833fb481b582817bad184290f7b731b611aa09c63272a14f4471ec654e460fe7e2061de628bca07cb52682d4d46a3e29abd90faa42e9cda1118c92ba698ea985bfa4dae1e5a5edc2eff590d609b37786d1d577b55b0cc671d237e338cf46269451be059e44a2e6b40664d060919e7bd
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (27 mod 64).
# DIGEST: 0fb9d7ffcc7c9b84f34661d472ae2d4fa25d3d99
KEY: 46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409a
NONCE: e02116417dae0cef457b9e5e16dcc5b6
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8d
AD: c55b436965aabe477e0cdd
CT: 9f9a3ab733e50c1584c4f0c2a2dc0ff71bb3a9b32dbe92da2fcff8fe46a4bf16d4f30ec8efb1319891b7d2586839fffe5012a6dc3d5f0ad21e1572a1ffb48fbb59ee4b8e0234e543786e775dd4c54cb1ed006b4e8f5195610e267f
TAG: e3e1b44b7aa92166a01da7ba9c7dd6ed9245dfe296ee16fc20addd7a6c15462ca1c0bf1b90a136dba0749837bcf133377d6ff21fd3cb7c1f7fc50df8ada45e671e1bfdd4f711462c9655c8159f2dda37bcc96df425ef3fcba2056973d39378fd2189375bcb96ca84d023f45f880166ba262c3f089e58888b8a67ce85048c5628061e04a7f09d8a6eda422d424482dc4dd4d361fde54b3c659b273ee9a04faa389befbe2816e164d9bcd9fb6ec7aecf51e9288cbeca4d3e0dd776a3c122eb4524196dd7e4b8420a08a3276173c282dc1463ce6e6b17fb419c1bdb47882e6685c877119fb6348bd0f80b867d60fc8ffc4e89768eb33ada5f32a81eca38965b28bac74f5dcaa1
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (28 mod 64).
# DIGEST: c68fec315401703e49722fe4b39cf28b14e9f50c
KEY: be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae0
NONCE: 2116417dae0cef457b9e5e16dcc5b6f2
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc5
AD: 5b436965aabe477e0cdd46
CT: b4d33c5131701c960eda4c50fc0a918acbe28cd47fbcaa328c6a9eb08e3c36b697928c6981992ab155c30984c6b8e9340cb00decef7086f589ed2d730cfafd5ccfb95373b8c55044fa1c95927d02278a48f986a6b8301426bbdd504e
TAG: c327263a3dc33abbbb6985406703ecee6ddb0d9b236ff2366c65effb2c936e5961d99de3bab4eb9c5aba4f65a55bf768a369181b191545f4421be3bc5bd2155257374ba8ac8e70823421da77aa1e2001a4e2f4942a40dc586e1c9e3d0e8dba136bcd823eb644d8d152182fb0c88ba540ba3a71ff1b147e4e072298023ae0c8d37cff859108b02d586d5357076e6e649e2a8ad3d4a9de1ffdea88b4dacb2d2c7fe12c8739e0d50d91e3fb57d54e22e6c4ca3c8e47b2b9c7de9220a1588c631dd6ac85d04f58559b796b8adf5559365f8009181a75e1f7f1a3c1097d81065be9b30bdcd0c5572db64f633561e426f1a6023fd7b7e1c4f66919e9ee67c5ac4026cb11aac92e445d90ba020153333c8db152113c5cbe
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (29 mod 64).
# DIGEST: 15e1aa5285beab679aaedbf51a86b4aebbe3d7df
KEY: 99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae021
NONCE: 16417dae0cef457b9e5e16dcc5b6f256
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b
AD: 436965aabe477e0cdd46be
CT: fe6540372ad1c40ec1dd644e935c480b9e34aed05a7f21e2e37dd46db52ebc5352cbc3be2aa289cc2e9712aa7d393f4454c9fa3a4acc30db41ada1257693d3469b0a1d5680dc8dbfea8cbb4768161f829a4f853c1c48d08825aa2b44f1
TAG: 53f79cf7b8f4380a1d1f1def457d4ad78c5819e0654d4052186213880228c482e2a54bbffb71483d32a8eb97ea8e9057a99a52fc3381820bd5c8fa43b846257380c07075592d6a445075a0df4e48f20dac7e2df8967a1cda41bbd4b0411a54b3ab9e79354a59aef5291599176599db82c0f6ee8a05e012067e2961b147a7baa73a818c64b52dbefd767b285fad111972528e3865b78c3c8aed658b1e84ecfd6ba292bca83ef66968e1bbdc05f616ae79d1d7932a0e8d5fdd7f98159b199bf933ada7670bfd4992bc2ec95daac00f10b7cf2bb68755edeb646395efccbfe322c9f381d39ec36d92c914fabb74d4df8dd506d9a8e233c591a503e92943e9437b10268bc9fd1a512b31a3aa62034ebb2dfc2ee3ae
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (30 mod 64).
# DIGEST: 8cc0b1164fc844e958e055b7ae43f2f95c29e8c3
KEY: 371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116
NONCE: 417dae0cef457b9e5e16dcc5b6f25607
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b43
AD: 6965aabe477e0cdd46be99
CT: 22e6c691ae1ba796667ceeaba4dcf85582e398e529d938da63c8221a58c2fbe242f6da82eae8c896dd31b45b3e8b72ff3dd7906130954f7b68d4c8729d3ff66ffad72104047209a56f1d6cdd927b57e8f29108140f903d03da3f4d210219
TAG: 6c22c87e07027df3721970ac8ebb881edad4c00566f7b53dff9189ba9844543d4c5894ff1579a353db455a1597370c9d8f2c16a191d6e0eacf6c0cb3bc30b979ba40244a12dcdbf806e609fee1cb9531813ab90854c5eef9527b0e546193df1d3b2e52c5c01cb67db0f4fae9e1557e89b130fde7ae3f7b493d1b0296ef965538ddb7519ec972ddd1926ca29e3a9ff5c9f55414f07a1c1785908975ed43b16bb7c96b2820fa3c317582dacaec45c71b3ed841a41358c87340f5fbac68dcd4590d9aa4cdae3374d7c332c6ace45644a8805ac792c4ae5bbd09ca06581fcb46e71381031d5ad54b117005c2924a538501c944c416e19480d48e792a741e863043be0cf0cc12c700c3238a77ca4dbd168da1618a
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (31 mod 64).
# DIGEST: b51001b6ff9d27bccf3103a4961280e0a1406257
KEY: 1eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae0211641
NONCE: 7dae0cef457b9e5e16dcc5b6f25607f0
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b4369
AD: 65aabe477e0cdd46be9937
CT: 4772e647d03817c0f9deb39ff4f4f27fb0fed33e0630eb453883c707336f0e74ef206e92e31fb2935a466105dbdfd42c180ef63cf5cdd3c281337895e399df6078c22762eba5d84b8845ea00bd88bf5e4f0da518cae42502e8531b14d979bd
TAG: a6a89cb7f4f54501b3fc90129f28198a9c3ebebcd6fbf6513ae3b136ab79b5cdf4df4563910a498137864bf3a63b6dc731a29e2ce7768a8216ee39bb67f73b16f73fcf6bfb934ef67dbd964d016d876ed884e5c3357a5238dd7ad6f979e81952d9e2c2c6c5bbcb1ef860c67aa977b8b0e0288bb37c94b48ca7f8f5df733e1bc522c9b06292ae4340710d15079b8d4e9e7dc95b653844a7a5f795d71bd7611900698a21335e0736418cc31a6c29409f501e0d88be63b54d6ab8ab5c7f07f7375860f949168f9555ee49f7fcc41900bbe1b769a65ec344e172e0de68d74c94d261fd9785b6516ff425c6669adeb426c2deef874dd6b510791baa8778601c134dc5e05e0b414836303f21bcc7c300958a0200
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (32 mod 64).
# DIGEST: aceed075f31ab159f6610f43ff0a6ed3a359bee1
KEY: b8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417d
NONCE: ae0cef457b9e5e16dcc5b6f25607f00d
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965
AD: aabe477e0cdd46be99371e
CT: 6dadacb58a7b88e2daba277f66e5757042c142115871c9813d1a72a79e5a71366801a757a5f9982e99c355fe7d742fe3f047b711dbe340bf2ffd00cea6dc6ed7a4a416c17138404854ab8a5420960d60cd1b86424b2668740910a922865e4c13
TAG: 98e4dbc80aff1a2c04156dec77deab9850b5b951f501d58f265f2c75344f7e6d0aba191b077877ed269e75ec40c84d8644070e68e18583be6e13788ff2c7f9a923f84eec8642ffb6eb40ca773a45c003df69c80de0ba199354f231f9091d1b4078ac218835e2df3e76e77d657099bef5a6a1367e6c39b23a0b7cd345bb8f5a97b9dc86300132e95853fc3635da842ed214fd00bac3b46f002f3c26cfd36c575a56af06e74032cec9451837db3542aa717aebf6e3ab3037dfab7cf0aa0177eba2dc3a56c3e3011d4c940b124b565c4450b08ce2f900d400e01a9b469d327cd9bda24af77f60e8ec6f5da196ad850c38d5cec0fba6bbab584c8b486bbac87a7f559be463e5929985ce710243260fb9258e
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (33 mod 64).
# DIGEST: 976ca4c9819e25a204a024d05fbe7420f717bc58
KEY: da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae
NONCE: 0cef457b9e5e16dcc5b6f25607f00d03
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aa
AD: be477e0cdd46be99371eb8
CT: 4307f039e09bbc51fa0477941e321dec14e5f562d3a5ba25d71c3c8afa23f44e1ca619d130890b7476e5227442c27995cd292ed9d0a649773b752b3bc7abf171244624bc55784adc9282f1776789fdbcca048313a1e6c8a23119db185ea4ec1925
TAG: 87187cd5d301d869cd1b4bb721475f6dd5b64be330781e20a24c1784dcd74cbec221914ad4ae88d4c9a1a9eaae7b13052d2c6ded662507a07594feae4de66b72c7fc1143c4e7100293f842ac0022d8a916a687e436ab7bbb56b2a4fc18677a813b38ab1e1d48a474322d44f581a8d007ffc6f7f4a132212e7bef5d5c9b13889dd2009c6398fa2dba18eecfcc5f41c5ed56be7f451f9b7b7a908f0838d3d8e2696512c6ec159a6dd94a1628be9911a3d827105d8cee209b6ec4cee3a488ef5eae355826d9a474f55bc736605c6c24444330fe5eff18a735736b66ea5d0c5b3278e373b57d86dc7815603993814ecb0dbdbd330c69dc46d7e6fc8555a18cc0ba5b5da89e5075c7ad835fef0fa46ea426
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (34 mod 64).
# DIGEST: ad8cfe7556704bb1974e94f70d8743d147c5c3b4
KEY: 7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0c
NONCE: ef457b9e5e16dcc5b6f25607f00d033f
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe
AD: 477e0cdd46be99371eb8da
CT: ee9fa11a7d6f965e7d65d8f48810754770b9d237ba0111978b97e24f223817d0c6ce4dbde85c4e0979bea607a36c66f908c25384184fc334d8d985b78c2e9872d82c4cb1aad49d7dc21d6484b80f9192bd724ca57cdced2fdf142283126721c1c2f2
TAG: ba76fb9c71f51c92d4602572883846812cc94a83e86dd16136d65c3ab932f89b28ecf49ce22335f0c643e3d979401bad3ca97673f062cf69855b23b6a1b14927594d92f689b4204ddb32d95d577ef4379890d804ce26e0e4565dfce891c992a29b9b1fa57f633b0c231e4e9c4939679bd52205988cffc989e34ae744e49a7ada77c6fda5537c5b031208acca0628913fd8a2ecd9f2b5d50254da5f7f00189dfa6d553300d805807141ef0b75557a693f1f90698a8ac912931b7a1a3a889295046219394a0884f823d204d0a3bc4cd4e3fa6adbddab80d123368d2f29ce5e8a992ab9c1c5d2c8cbc99e99647410abb5c73d8e00a0482834f97a576e99311d747088e9e65b8546265f71a237c1f74b
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (35 mod 64).
# DIGEST: 1dfd9608adabb5a55e12949f1c4bfcd5a77cb703
KEY: ac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef
NONCE: 457b9e5e16dcc5b6f25607f00d033fb9
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe47
AD: 7e0cdd46be99371eb8da7d
CT: 1a95f47f7bdb2d91358f683b7bf803254d88b59e2d3c1d873a09794e1c18f1c924d480727599a1a6890bb664335e690e4e52c385b634bed45e08410448ffda3ea2593a02a11a03d994617b9f7ac85317bf09c41b08b416863cd90f0244d22c795a34b0
TAG: 4537e27f1bd4b1b873ef4b3eb83cfc860c44921195a0250a96e553280b15e9ed379d4eac959a2809ce808e40dda881cf8a08cd50302f7dd5e67659613932ffdc086db4de634000cdda80fc576294c265f49a48c79ece6d42423a4f86c25c0a168d5eca502e87c419ec09134c27e4db1f2255de7e10f0102b44f30c67c8e07aa23aecd3f62ac8a24f9e8f82be61b539e288d22f8e05e914c191877c5ad1a546415df68427f97576adcb8d428ce7ce2c96acc98fe0d6dcb42049206ee1679f037955cbc12be9ae020774bea675b7c17d0033a60927f75e87d9c7ca263a5e0ed38450af657a81434afc9b4f4a14f02f82e33e17e7f61c276cc1e630dd773547b6cd78231de0895e447235cbac4b3a
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (36 mod 64).
# DIGEST: ad2b43eee27e6267d8c5c1c3d558a07dcd6b1f5f
KEY: 997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef45
NONCE: 7b9e5e16dcc5b6f25607f00d033fb95f
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e
AD: 0cdd46be99371eb8da7dac
CT: 67466a0bda0815f726cd09d159e06088b2530b73775a8c18eab2d09ed7bd12b743b0a10345cb3126dc14d8f5c503b65a45467ef9b56ec7c5b24e5548e734d3f0fc90fd9c8019fc782882ea6e72f4df5fc6e8105e79d12fc588c9137c758995666f480dcf
TAG: 24b828c3e60182873556d7aa85480180d7cc42ba81732058a109b5ecf21f66f1ab580d18f70604ff31dab5a1bbee007d213d2fc7070e3377aed31399291cfad53a334bad7c1c61ddac5015d19cca020dec137fb76472b1a595e0fd5dbdd127b3267521aee32fd12c1f54493d23c27671750776f8937032b9164ed78bee6b8234972634fc7cb32cc0b7f6fdae850110d1979e380b4578b8747de6f3d89bb66d546949ac94e49b0a460c192f98373e2359fdea2cf2a6ad4d09199cc145fc537459d73f48d265a1cdd458f306e3596b2088f233630ee0a37a5c2c21a76bcd47871a7954cd9bf911ab942ff7221623cc7539344e23dba7b0aea370a7d2e2383a4ec9db06a8123016d73b4323d19a
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (37 mod 64).
# DIGEST: 3dcddb1e4f49633e7b7bd36f4056d16c53be7f5e
KEY: 7deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b
NONCE: 9e5e16dcc5b6f25607f00d033fb95fb0
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0c
AD: dd46be99371eb8da7dac99
CT: 34f8a83c831f374e77c5601317b658e47091d811285791eac2fc59fb06658c115dc875c80b1089a62fc7d072534617dc81dc3adffbbba4b9db2e7272eb0b8aea73eb9de6480c43190e239fc300377f186e4659b1f239906614865f10444ee64ae77ccf8e3f
TAG: 4c975e14b038359ddc06d23ea5a5119eeef3708347d7de47875cc88138b79d5c644507363c0a951623f3c26f8dffd51a2a282641d96ff107fc69684add9e93c56a7d29c8e097dbeac0a56d7afc522b7f5c921cff17c6ae4c7bd456bdbf95c052b18751e1c3ad9a26517c29071361aadf06740e43afb13762b4bc2a80aeb5e042259a36cf03a208b8f6162515fdd3623343b127655de069d5eb8c7b6c00fabec02186cd39bac62768303dbfed24cb20105c7d8b2a6b2c34d5f4472c6f372a841672c1f7b405d70d05c632f7a53997e3e4e0aedbb05813a8712dfcd3c8df4fcd83971cdb81538d2516a3a4a9372dbca6bdee43a2ed77309076fdb367fec85e5db2f01e59d3cc188b67f5edcf
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (38 mod 64).
# DIGEST: 25b982a242f669c013cab1c18da425330090e3cd
KEY: eafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e
NONCE: 5e16dcc5b6f25607f00d033fb95fb09e
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd
AD: 46be99371eb8da7dac997d
CT: 2ec0aab31fbb036bd2af5ce39025ee2d5591fd525a199f2233384f52a8746f4fb547843c92d1e4c9fa92bc268174d4a59134142f14e8e1e277f1f1844c64f76dcd20f3b73dfec8e9fc59a639616fe4075a4732dcd3e1de806086239d2e09deca0ffc081f2ef2
TAG: 3049393a7f477630782378966f7ed4d33451da6b00ba751aee542cfe5aba67748a46953b578d0fad0e37b5627b4295a4f44b0c28d16e300888c0c8db965c14c23310279cdc9834d2ff9ec85932b7e341393fa3b6661bb8d3ab0cff6c6b646d927626b8710d3243ad7a971efbe3f6ede39d8b9f77585e4565a8b07917a712d85b846469807e94f3073097a69c30dfc5f92fd88cc36d3a5f670155aa98ebc80112db1fd1db0685261c1e7711d9c82a73dece8629a4025d7837852749fb8ee1489bacfb0bd8fada1389fc31ece84558d5732c9b559db32d8a498aafdc0aad020240e00f3fe22c2932924305fc1b3d648c53b9fcad835189b41a150ccf234988f26eda2655054c395924fe50
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (39 mod 64).
# DIGEST: 9d7958e23777ff2472f5a24dea5fc19c151dd921
KEY: fd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e
NONCE: 16dcc5b6f25607f00d033fb95fb09e4d
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46
AD: be99371eb8da7dac997dea
CT: 90712d5e3edeed5000c62ce80212d41773a393792a3a8fc62a1cfbff38b3555aadd88f0e36f93c8a12897d7779972b3e42978cdf85da7a3ba2e4b261f0a0cf4e1edaf259849e87133a9c057e5d3e693a2a181eff1f5d6f84e0679c625ad9a0f72c47d607ffa453
TAG: 90b31128a2f6673d25ec56c9431584416b2e8c62fdadf580db2d5dd2ef8fcff5da4edfc09685b16db527abf1258b82c13761e41e41646479c833c8606b438a53fbc3718bb5e2ab3d9e25ee8862ff2d088aa5b37877ce5bcedf184713b2d5acb8408bf2f50b3041a0e582230a1f4034b6eee294808ca78e605b0461c1fa383b8194a30b3e66ed58c1b30331a97b3b87e12d2239f8f34e632caee944450e99165b9a317029c9f658c7182cfaadbb6f52da0f8c4f3fd73959c58559404ff80ea3af53c4430ebf2e41197ddde0e3d380668b4e72f72022e3b1ead76284506cfb3a20b9bf6e8425eeb89fc5582f4f1c6736e1185452e87133cb1e8ec045d2e40315fcdceb02da252a5cbd3a
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (40 mod 64).
# DIGEST: 09e9eab51bcb9faaa3bc3e473ff66b06e39653fa
KEY: 64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16
NONCE: dcc5b6f25607f00d033fb95fb09e4d00
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be
AD: 99371eb8da7dac997deafd
CT: ea1b542c224788ae66ded1b3ed9f9e35708252a1cd1d4725b0a187b669c51d282776471be5a07f256faa9ff16fa4248c629a4bcd31a9dfb7f260d9b1cb62dbae424624fd816bd81f781b93ca9dab437b5e0cb64a37874b0117cf7b96adba2cb7d75b834adf572d99
TAG: 1e6a782f455ebe54ce2dbac88683437494c4433ddef95e45bae93bfbf4b1d5d0d2a459e9db88be408428c47c256f73d42778e42b936dad9ed773a02d0e7298c22b60280cf1b7191eb7c8fa307076f5129720bad5961206dea4ea1a05645827b30ff3bfb6066db13a2f9f1bde975c80ea902e9e51e64086ea4641150c531df51b328de057d850502fdbf50b4a1295d170c0dada86a0209d2026501f111247b75826953366ecfee0e4c3479040cf27370de1711a73d0ccde18e218b9f6f6aa20e0a8cb0fa4aa75ee585e96a0a0968423c86b35c899b5409e577e093c36d18149199b59caf99f19d1163c31a0d3da31b8c5cd372372e2bacdb2b03ed28605e346cf794872e096ae048b
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (41 mod 64).
# DIGEST: 7b17b7cb19107af8fc4671420e461060e2ef3e61
KEY: b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dc
NONCE: c5b6f25607f00d033fb95fb09e4d00d6
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99
AD: 371eb8da7dac997deafd64
CT: b1025c9eb02f72e5526ef641778aebe786c2f85961997f1eaa090a33caae3a9df34da7088352a2df7a61eaaa026dadbcd604f5baa3a0de4fcbb3812816408d61384984141d9c78f47e725e99cea9d52f73cdd5e2c3961b035589db1d2283476006a1e10a992d499762
TAG: 3f441554acad8b8f9565a0a69a17d231684a6293aa032e140eb41ea302b45d0e2e36e62ca23e981f98721a97ec02ea946282e23fd4838dd07b9a8cfbc069d913226cf543235541dc1a8881394e9cc0999c63b543e5ab74c35436637578148ff48bca333734d768b15a6e9535a69705248f28961e50facf4e8bc0825b7d2152cb2b85ac2e767b6650376a677f4c7e76521c790d59d9588e54deb9cda034551544ba80cf9d11a9f589b7e8980e6ab95ab77848e2bba36ed85afd9774f32bc9ab9173db20fb97a53d23091add97f16d8ced6bac6399aa089718d8bcc94c13b6e0d08e805b7fa252e787958d4780d24d812e0ea0df1652c04ac325355be7b21aaa97c2749f274a31c6
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (42 mod 64).
# DIGEST: 48586ad2eac603c136911b28e2c69f101a8ef371
KEY: fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5
NONCE: b6f25607f00d033fb95fb09e4d00d617
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be9937
AD: 1eb8da7dac997deafd64b1
CT: 10623f3b3c8888a31cbf51eae0989eb3caad5f5b786c13b41c04e0b6cb2641f850df4ebea610a4d521557c8f987ded40e9702503fc4ae62d1830a0f04d168888062f5b147e858a134a4022bf2790d81a89133aee08a34a704f152cc3cc763c21207d2231109e0b71a801
TAG: dab4bcc473354bdea1e31b926a19fb97ce2c8b47e76082bcc93a1db2707b67e4f72b18cfb728232ca334bfe9a4a55c347777a25b1a13ada600adfdc4fd57275414b3bfdc9613f300b4b29fefa8820b5c8989bc79db1bcafb69b0d89f7624a510d3a1597f953564a29367aefdaf36d238b957460f50b71adb5f85e9275aa511b7118d2310f5e3cc2bf0c21b0be6e6adcbbb24064a760b74679de7fc146a00014f36d39f59df902925710de6397bf32f5d108902159755feea57fb58a7bcce680babfb90e05a8d15c1b42a3b7d779af99e3cab04eb59e5ef45128195ca17bdc25dcaefee874e919bc8edbc8e28e3997aa396768ccfcd25e59dfe27e46de35dd101c38f7e48bd8d
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (43 mod 64).
# DIGEST: c37456cfc543ba6e5848b9b8f4ac5a58a104b521
KEY: 65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6
NONCE: f25607f00d033fb95fb09e4d00d6172e
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371e
AD: b8da7dac997deafd64b1fc
CT: 60d4a0ba2caff08ac046349b511017a7c5f5537eff0bda94bf838d50c14d59426424e4a8f531103773aa0eb9d242a9e6f2ba5002ef04aef8144c8a88f05788fa5fa1ab1cb5cad84da0d31b280ff8a55c2e8f32f39549736bb055169ad5ae93c02561006a3f13e65094f7d4
TAG: 140431d7b2bcf5139b7c9436fdfb3b44834ca810fb478eb0aaf7b0e2c68ce434f05c1f825b245d9fb4af48056925a50315b9f1b7d340e5f797dde4f460ad3c526853049976c0f680b691b28fb79d61cc9f7d8a4b28ddab1f610ac6cc44b91d64275ff1d26aa2b5ef314b1f280181cf72cd8b8fbc939a8751538d85f7fe03617a9cabd79dea5e64832d0b4aeb4893ac35c0d9f1475d928e3ed40292687926ccf5f9f76f78e00f217c013a12e38686423dcee930366e79950955c07399183d775c7030a50addaa42c7aabe5d8ebb95611f3c2f68be067e179e3de60d45b828d54bd6be07948508ff8a9b68abd944da07a484a8b9bfd4be1a22ff006e578b0c43c2bb1359d012
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (44 mod 64).
# DIGEST: fc113d192686652653a15887974eb1f9b8e32248
KEY: de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f2
NONCE: 5607f00d033fb95fb09e4d00d6172e78
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8
AD: da7dac997deafd64b1fc65
CT: e59fdb3d1413cd6a1098b5daf1662c698076996e2581e11a286e5acd6f29d41ff9d04da8308ce7f5defc52be0b4d1ee96d8e5f4eddbdd5fa9894e7d1b0a1bed483b7e7549e1c10cf5b8ebd1e7f1177972ff061cdecdad8d97bb0308b19bbc2c84d32a41f4c2b7e58721349e9
TAG: 6cfe1e101e9b8fd2b209a30c0c1127e1bc8a51b8826c64258b573711f4af7c7e4ede036de4a94d70e17695481424907475180c7899a982d7eb94536a30a57be43d5c6b5e9c34972e61b9356a9338af6e8dbf27c920edc9bd02ed5535018d3b3e3df45664f4c0bc01f1876f36338e85b4a127181b42f7cdfa7a4da5a6c249f1bcee2959e25d0fe17717b0181c026ca814cf21d6af3b548435df052ffa0a0e8f74b8c3f7bb37a6b5bcd2b3f2c0e4b24daad586f7b59996072f82c123aa0ae66d3f6bd9980e8ea0312ab9fe0052e1fb3911e35d880f1df50612799033c384f4899f69714efe5df2727528f7b3af6d69e525a04375391643febed777fe3fa3807a73aae666c137dff28eb3b2ccc1d07bc665094d33c4
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (45 mod 64).
# DIGEST: bb6e5b5be84ee383caac0378cb6f541726ecf61f
KEY: 39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f256
NONCE: 07f00d033fb95fb09e4d00d6172e780a
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da
AD: 7dac997deafd64b1fc65de
CT: 9764272fe16e12bb42a8f2a6620e44d4f202c21d51692e2948e2f4e4a18acf58a12d399310f15e78bac1f5f2a48416e5f4262ab9a8480d9f1429e5e9d15d81df0719f8db8d7ac08da696048e8a048255071ba8926be1dfbbcf53e7430862f64c891edaf772a830fd525aa8796c
TAG: 2cdb47ae25d087c752c007dc8b83cc050b53376aa92e9bc2c46d05ac7137dce0f70ac601b76fe40efd84be464015b5397031ec3e394f880713ad10727d270730e469ca30ea5897a84fd204bb14a920c4c1bba0d27fb154cd1f8277fa6aab1f4c743b52b51d09657b80398aac269f57196fdfb219d745f53a72ca08cfaebd736e7d016806d68e5deba428b484d958335bf03c0ab713b9a54b9a5bb4f3b82b76c45d04b5b6141aeb7271d0a71ebf90ba74b27dff1ece371f6353b8ce8615475a1b82c3276569b99de52b7ae5f27cb1cf9ceca291c1922382ad5260ebbb32cf995772eab6d6213d2e4c438909f691a81825c2adad290839c08566e5cfb3c13de4ebb016529de5549a9ac57d2e76086db82a3ad881
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (46 mod 64).
# DIGEST: a27799fc2e00e7abec4c5939451a834c4606cf7a
KEY: f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607
NONCE: f00d033fb95fb09e4d00d6172e780ab8
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7d
AD: ac997deafd64b1fc65de39
CT: 9b6a8359acfc5d15067e2e6d812727d768f44b3edf4272f57fb54db41d95153fb03d7a7b3371e91c4be80326f4d70a8f2ac1e867ad3772901c513895e694214d6c0fa1f431aeb016ccc93faacb4950082f0cf00d3a5879c9a4f3fdb281e911b40d6d0a84b05f4ce32f85b1657d75
TAG: a3c72b69369cbf0d435790c97438a38109f36b147943b0629b1c2e4926e831d27155f5617f1f884af2799774b69bf0e092d29158fa51495e132b206cf51156c2116b23848ea51d684808d5a291b68f57250626d2190a7c0779512bca6ed44e619d0f7f8bc28e1c9b729514e12e7cc08e8e8d72bd1ae30229e56fa7e3246dab29e75bfc866a2b83c48036ea0296dfad04357ed990aecf6b28a0a3fe7eaed48f5fa59202f109ad0cfe6aa5cbedfcd62eeeb15df7be0645e161ee6f7f9dd811c98158de6534739268757a1813e1aa6c331586867acc75ae410c371a81cab835fcd928519d9468ed61fb5d7c191807e613d40fe174c8b33a400baea2e96d9d7f1734dd11092481e71d0b0c0c86419d5c50cf6e18
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (47 mod 64).
# DIGEST: f30eaff92a640a397f98e6803623e8d1f0c1fea6
KEY: f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f0
NONCE: 0d033fb95fb09e4d00d6172e780ab8b7
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac
AD: 997deafd64b1fc65de39f4
CT: 5818d2a656fce95d7a24bcb216f4d6b91d45d58d6ca2df5c9d6412d917951a9f61ff07fcb6b078fad69862aace436194f86f309373452e813c461fdb36a95f575fdf0f784ffa0914f0c0ee0c57ed1e604ca7a7a4b3d20c272b3b7f2e65b18c1abdf8c88e1e7e7dbbe9569eddfb226a
TAG: f6bfe8a461cc83a7bc7c5a39b6c521ed3e0ff050a6b01999b2710e0997e1a36a72c11363307aab1e4d921e9364ce826419d15b3a14e251e82bca615281c19bd243a294365492b11567341f13f14764e2b30ebc8ac4d313047694a884598daae76a45797f583a8279529e9352c8c13a06510ece3057c0936de84e6c292e3266424eb9aa4b7e5891fe7180f0a31580a700a4e24d7f1e53e1b69bf36a7c0db63473566920565cb9a22a47aad6afc8910a6b6019a67a092ae814c0260f2fada1a6dc44c5447217b6831457f66d7a2ecdc9187986edbdc1c68e573da33daee7fa2ef3adf4b6179b9a02d31c36e4505d5829ef30058ce5d09ae42fadfe4f66e894c36d7db467ec5ef508e26cf0724b261235579c
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (48 mod 64).
# DIGEST: 7227537c0113a9f46f7d332a0b37ee5303483d00
KEY: 3541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d
NONCE: 033fb95fb09e4d00d6172e780ab8b700
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac99
AD: 7deafd64b1fc65de39f4f0
CT: ad0dff8adc54b5f02f428915bfa9f7277e4743e72e1789dcf552b91cda03bf52c757a9cca0655550c944fd264d287bc97d15dab3b986ed34637f45ffc1eb71b764cf5d5c1444033975829f1e59cb65ce40d787adc630e1f3155b2dc32733a75452efc755b6acd2160fddb9a26e0c4587
TAG: bb5273d6920ea95b43efeffc99da0dd48a556e357726fe34dad94f0257276f3ac759c16d9b34dd86f09a37bf48227d67765efb83d001eb8dd87636ec32860226db118427a7c7367d53cf085ff86d05a8f35f893a044e99ae5ef14fe490eb03aaf0b97581184956211bd19ad09c9aa9a064e305abff0c654006b8db861c7956ad6cbf46aeac4e5f5d54539a9dede2ac61d8f133c1a9fd2b8e23ef5d2d3068b42baff87faccfd8499cafa30bce2f30e2c1fb203acf1378d0c776f9476ca83e4973ffdd66f2fa86105ed83701fdce6ad64a824d2317f51443c9dd3c520327c7f3bd99413d832bb1b6b70655d31c90b7bb23a1957a146f6e0dd1a272a04e833e0b1c84ba2b09b0c1963ac17350292646566f
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (49 mod 64).
# DIGEST: d76570385cb65d30c3d636ff25c5efeb8d1ea08e
KEY: 41a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d03
NONCE: 3fb95fb09e4d00d6172e780ab8b70043
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997d
AD: eafd64b1fc65de39f4f035
CT: 8a1448acbd769e42bfdf00ddd801153db3202daf5ba7997890f5f42a183d3a66faf66d899c7099fa99bbcf5b62b6adcb6ee87fafdd0275a8f625f3f959b0ea9acca88070aa9c61141787435cd60f63e262a80b6aaf931ba554ade7e0fb46b03a318347f1ca84e9fa1786d721b6c222b1b3
TAG: 7bb49e9f481b45b543195956ddfe975cb63203f4b68b50a05c855d128d311c339676c1b6b38ae280d0731f613f9ae4cfd1945e302451f26eeb379a1b610773750e3e841d50e16da759a603897de6e84aa6733252cb0b6f6539e1a5258751ee7c0a45aa9296c32322d6a465a42e4017f44814fc58402cf561deaffa43d61396d53077cf089cfcd42b182694d286a97f99b65e5c43ecf69898c036381c6dd9657f2cc08144b28e9ad9a00ff10fb0ad3b26e92d8d65cd6879b11ae50f592407188e46a3342308ff9316c898b09648f71513e09367aa2ad5d93f87e4b2430ccc8fba9825c0407135fbf65a0db46d491059f71a989629dbfb1adb10e98d02935fa846628e8b0f8dd01991761945c5e84f9b
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (50 mod 64).
# DIGEST: 170369666d1f2337b29b5f14af68d47910388e7b
KEY: a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033f
NONCE: b95fb09e4d00d6172e780ab8b700433a
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997dea
AD: fd64b1fc65de39f4f03541
CT: 0fca069ff1b260179dd5ff1124e557e97a4cc41e069d124cded05275d37913efa220e1ed4768bd04d8e65797040856b686cfcd5b772278bcf5fa64cd8183ba8b7724359804d609b31fc31514a4ed43d84de929d99e63f12306bb497e8ee77648be578ee74f1cb2a09ab32b3ecb913c7b36ae
TAG: 19b492f83b9458b356020d7c6343b6967f1ab0328801042379e7d8e98dc3f3cf646a96d7842c83bbd210dd8dbc38cfe5fda9d879285aeabe19dec677fcd389651cd284ac650287f13a461ec23f7dc1cb5511dc529e99a078c2c80ebaf0fdc6704bdc35a2c89c728a061095448e6dbee102f4793932a580a826382a244a9f11c665015675322d514be8b1453ed6be846613312a1bf9e4f2c126d2b15dd8e6ae759f5151528361d10d657543767b05e8c1b79df65aac381738e2f43f95cdc77383f22e36e3b26d0c65f695c75f7ab422864e63c230df313fd8e41b265b5a704b7e5f7c96306bffc1a95cd09584519e2726edf93a9d2871b9fddfd7983c81812653152c3775df228a542f06f359bf26
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (51 mod 64).
# DIGEST: 7c52593d1d37b0dc380297231c6cb7b64e04c493
KEY: 1be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb9
NONCE: 5fb09e4d00d6172e780ab8b700433a95
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd
AD: 64b1fc65de39f4f03541a1
CT: 8cacbae377d038fe27b37fdb253f3b136aa38660743dc6b4778ab16940a9710c8f08970164316e26c3b603140f2f43f62a88d021426b841baec29fb11a3d8735d0b8c14d133a825e1044be5523932ebd65b34433c083c2d77af313a240b1eeb52391728dcd04852fdcbf9b6f89502dddc317c4
TAG: 85c893ad99aff613e6f95cf9c6e9045cc22fc8fe421716bb135269202ac57803e67682d09f88ae5970fb4f52e97a28efcdfe0a359df79a0576179a04830becb0551d93d862842c4b5f33c23fc0988f96d6deb37288f96507e432190853aca788d55114946833b6c7c7c10c34a5d5852d6fdb287b9dd97fa6b7991efef4ce66b0dd9f0ed6d112713c314aee9c172675d86c8f52097362f3ed4356ef4309da510a6708f32f24549dd80c9ef72018d7fd90134fa2d1ac1b9858ceb9b382b263cd3dbf697aa40f875eb502d4f128845bdaa9a8b4fd07a31b687bf4a1a1bb4843e205a9ab2b33a3ace650f96935b5f6de6d7577deb9ab68c4295cee108b2f4aed1f2d2fd167085d2173e2e854559222
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (52 mod 64).
# DIGEST: 09a1659100052d13bebb4defd7f54f975a58ae2b
KEY: e112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95f
NONCE: b09e4d00d6172e780ab8b700433a957a
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64
AD: b1fc65de39f4f03541a11b
CT: 06b44584c9ddd267bf03aa311730fd0c4d3461678d94b4a794eb3e90b9cf3113ecf0ce0da8789d59bec50a1fd1e08ceea4cf9e00b2e0423706c126af7a3031df6cd82a7bcef877b413662e731b5a74ebf68f781eeeb79cf760cebda2c5070dfb992007716993b0213e822829e23f448a7a5ed880
TAG: fd65c8c7f6b7795ab5792332f6329c1d606b305f3de89d9e154ff7232947d8581b6666faa823b9ff8bbab2cea14c2526b0fceb5ebaabb79ab4cea0bce96e9d1a3f556d7d2d83b4ce2c1ebdaeceedac3fae6fb8f9869f7c136d47a1ac93c7b5b5ef01f8e56602d808a39b40f069403eab03498959b53b8ac0bfb72f0c5b5063c063183b43d60a616325439b0491e2f3be59f9948c939f533c3fc0923028babbaaee977cbb05fc44f8cf8ea37016141d464716a875ce4ad096e247ee9081a1ae3448183f5412d84a6223daf432dedd679bc3f167ca5dade21fb2cd9057189049e730df47b409a07a8b2c727e2ce04da8e3f02ebc6c2bd528b7726ab803c5fc5dd602496f78b28474ac87911bd4
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (53 mod 64).
# DIGEST: 230c3353ccbd95e4f0acbbb0073053a0186f833d
KEY: 12a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb0
NONCE: 9e4d00d6172e780ab8b700433a957a74
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1
AD: fc65de39f4f03541a11be1
CT: 85da88e13f3ca14fc4440ffca7bc837818daf1dc52a4c505583edd070c7cbcdb4642d8ee1ca687037b08e1737a2f49039621823222f9f02deef2c340289af5184a86af8429747ef2f7d98d6aec2af060fc8e6895c2182bd1c479fc6a2e7ecc0390995bafad5b3356e2a795131b0aa7d4ded344e50b
TAG: f1a1b3f3fcb4cb89587bea4284449bcdb16785c277835bff9083a65ae77ff7543492a1d2710a79b720060ee37954c9719f8dc0f6fb4a75a27bc2a761017ebdc0c81f9e8ea5809a816ee67e731871c476f1ccd6b690b054984a4e74c060fbcdf5dbae743ebe2f72fd865dc1eb96e4e62fca3561a245be1749ace472b312cb1b28a0b2c2d38d089eab44f51ceb88af097627638a3556005952e28212d5c9bbe85c86f89879e55358ed06f28402f40285b97a8046b5479202f28218c71f98a4020ca5d53e16e91ff8387b16cfe6bc4e81c96c44e7691c10ebb0d37686e608773cbda993b816ee3b15c4ccca2a22468b186f8d29d853b945bd27ca0fe3e9ec55bdb9bb4e5477e6f89914e3084c
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (54 mod 64).
# DIGEST: 701e141608e71005d32dd1e29cd068aea736c9dd
KEY: a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e
NONCE: 4d00d6172e780ab8b700433a957a741c
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc
AD: 65de39f4f03541a11be112
CT: 10ee64784345c076e3f9aaeacc87cd51d6ee0b0facc9f40b4e6a1b4bec669ac3c5252c948b0c0a4d8e798248e6b10ee247e51c81793c2be91aa8c9666e0d8774439ea159e4745014bdd2e9f379ba461a7e638cab9ba2aba1498397044edd3f271e2b4dbb5990c383167c9191ceeaa8239aa6391c4b27
TAG: ac2d199535c4d2eba150702b88740058f1e834f89031c3851571dd9122291dc3e35b764eddc5856850c8c59b3caa211feb1ac256b749127bbf4ef56ffab65e3d9eaf438b778e5342a67ee4d876fd3e53aa29a532fab39d0c57e24593374e2adfb22cdf0def5d9cbc8701c9d6a2cf23d835cf75236069ab2874b7264e0e0ea9dd785b463ed8a6cc3cefc3a4c076e5f0d047c7d60be677b7716bd123bbf3daddc0cd5eed4d5c4f0f6d1c19c66e0b5bee5d58d295c2fbe6a164d464b173cda057094b983b2ff974783084a6cc4ebd9644f3b4426a3c157352b70ee37a2f1ddcb85936b0c38be4eadb33bb9cda7108c192597421bce5e36cc2bce7b65868f28adde738fd3bfbeb15608b4dca
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (55 mod 64).
# DIGEST: 9aaf96b472ea76fd9ff4adf56dab5fe0400d18d6
KEY: 2933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d
NONCE: 00d6172e780ab8b700433a957a741c9e
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65
AD: de39f4f03541a11be112a7
CT: b90220b919dd02b216aa2eb7863372a645b09df88645dcaf138fb73d8896e39aac5a1c2f0535385e15cb850a6febd5d6ea9f3fb573944cdd5b30cb80aff6b73a173ffd7c85673248fab94e3b9544930cff59f52515dcc8ba39b6f51dfd0487bcc9d28773e91c718afe8399d652acb97552b1909335dad8
TAG: 4db032df3ebf850528a308017477a21da23178403432b4714c1da01a253a635cd2caa77467597e9b8c589ef3e9c6f5b991329b97bcd1bf1332e03638fe1b157763bc41e4f6e78c05a5ec5f83306e3b5e8bd96c9a04aa83291ca90355a3b96a8688cb93ed9bba3b8688834538d1e8bb95a0cf431eb7b849d87199657a402a0e1e5ef79da8c1895cd454c440c57cd424977f6bf9e2fa133d916c8772e447e066ec2cbe3d0de2a7e19f06c74ad5794e5eaf9119fdb70665c07ab81e7d72371d23a4c96290d2da60bc7819af4d60ff4ba832daf3369c6198c45f0ca4c974dd9b4a81c0249706a25b23fcc0fa13271d0f00c6672a06898b2b833ba3b8cbd519e53939f0da6c09f288bff969
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (56 mod 64).
# DIGEST: ac6871d354eac507556770d8b6bf10b5240273ed
KEY: 33c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00
NONCE: d6172e780ab8b700433a957a741c9eb8
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de
AD: 39f4f03541a11be112a729
CT: 9807d89925c67a45c8ba18cfdb817f5bbc21e58c10f7dc8c15b70acd97e8b97e0393d5948d51a65f6f092590b38c845164e6d2b49288bd0f73c4f4b551b362470638f51422dcfdaaff5e8aaf80ff715f3f597fb9385ca18355b8e98d1de17a303d019f7d4b9a3acd07d257c049fc16134c53e1350cfb8c28
TAG: 7cd3491b8e157876b8091d2742f673196a25077410036ed62855b5440eabb10a01362a8e7c06658ab767be26c43a6eea3e354ec867de2b7b6ce96a4a951696051fe1a76a694d330eb56c1752bb2f866dbf6c1e85b3361316631c7a4a277023fe1d793ec4e4416c8db3b7e8a157e33438eba857e2b54db84e06006f83d93284714dc76cdf33da3d5adee64de2ee9feb689b9d64ecb857588c60c6e8b2eaa3999dd2f1cc2a6727cc5a50fc3902124055705eb726f0e57830732c85bd598519ace6cc86105cd36cdc7ad7f6868babe314b69d33021cf9931720aaf765d5f61e41155c7572ba298d52f3d61b28e3b5080c124821e1a97d1ec78eb5decd34a69d054fecb1209d86ee7779
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (57 mod 64).
# DIGEST: 050258d6ad6bec54f8bc48c7ba2d669d6416c11e
KEY: c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6
NONCE: 172e780ab8b700433a957a741c9eb80f
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39
AD: f4f03541a11be112a72933
CT: 8d69a3691570f0d175aad5fb77a0e9abd3f882b10355a08f0160c113096acfecdbc4ac32f037d16c2c4dda4bd3325c8690bade6bf39b14435cc11ff575a3d7e9f7b09b5b40f9645d9a5dfb44f42304d82298cdd866e957d4ab64374ffb86879a9339ea892986ac706bd2310927aa2bf27dce3bd6012591cfce
TAG: d754d4d2dcae21dc4a69c8e56ba3925f9f3ccc53278cc621a0ec4d4ea7b099a289eff5599f8bb1555aa9fddae50f04b5567ca7ae4498e1716f4243932934e2cec1434d4780184f0af1d0d194cf848671e5b0d6982a07b5679826f124c8f69f26cfa37a0105cdf15585697c75504bf8c9c04d583db189cf2dc2dd345aa926d440997a8d76f6ed12a19f2d95a2727fc4c0f8786ac3c50896a6cad6d948712e4d72a44cfb2fc9dc753dbed91f4fe412db6fa5e6b548eb1abed87e3b4e5d808ab4ce11f265efbd4af8e0516bc412fb9ecc3d69ee68bff6b12f3987a585670439ced09a038c526bf226299b0628f6db003a21eb5d943ef84e90f133dbb4c8468f555721c76da689e8d6
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (58 mod 64).
# DIGEST: 70060f86c76e53512933c09deb5872eb23efad67
KEY: b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d617
NONCE: 2e780ab8b700433a957a741c9eb80f2b
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4
AD: f03541a11be112a72933c7
CT: 26d675c591f287b26eb35f87231624e454c4aca1f25491b74a252e971c48ca523b353b4f6c0106c1b3b40182eddbaf7ba47263790c3b22d23b09458d48868bb18b2fb01bdfa965f7c1b211fe02f9b78959b71e872ee05ff3baf548a85797270fd43c9db1f9f97d3b60c62c06bccca0ece2b7249f3c0dc6b04aa7
TAG: 864b50299da796a664edb8e1d0bd0120ad31405c47919c288884dfba933326b03eb399c634fa77d611e613e958369aa3d9a563f421cce3ea87d5bf2e179c20e5218378cca347fc18b87248a66810ea08806f571f1e86bfde99d089b06c3156cb6f2427503cf03e39bf3a60b1d9542a3789b657956ad925754ca4a369b05d269d481d4cacd35ede8684623ec9fde9ee860ab12975bb1386470e1221d2b2d1091c7a41754b8440740b4878fb19c65ffeb2a120d84661179e07672953243a09085f0d21265a5476c8574bc49e30ba364fd9d7f2035ba1222ef9c6bab7d1e68211c1a9425a13473f692b700c242fb56fe77fded75312bfdbb7fd44a88ab37d85d640e883ed1936ef
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (59 mod 64).
# DIGEST: 58286fe273bf572a76a2725933dd969777c303c1
KEY: 4ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e
NONCE: 780ab8b700433a957a741c9eb80f2b02
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f0
AD: 3541a11be112a72933c7b5
CT: 9c61bfbbd3e8395be166b30a56b3e192748ba3bbbdc334dc3720206ac10c90dd777aa4957695bddaea0b7e554951c94f2f74a2bb7547ac20a7e357fe249614204401144fef61394c140553d5566c18ded15e0fa50fd5836cb725d277fa46210eb588a96d7baec9e2c947fee1b85cbe6556cf23655132ea72dfe4a2
TAG: e66769c0cd9a2448afe99faea0b64137f4a902158d6b11a58f4bff98df8545e0ea23a7f7127b6dd76e3a3ed43490b44bbcd6a7321e5edb819e6b2e163318ead19f5a306c7b0b137f3b9aca44c4ea070ffa5712102b3f1dcec5c660b494e8f3d809b3722fee1e7dd29cf771613b68e45733a9e66ebda992930d32829d31e61f2217e41620ea4e621840f0fa7f7b8762e0ca509f0eeeded7fd55727462b045e4adff507f3dc4389d9397f0429bd17c2408ed60e0d94efad4936fb55c359052a6a88c056e7ec1e4085f4a48b125bf9340e57be98b5cfddc3f9d07cd036b0b78aa205fdbdc8e9c511ce32b6e4c9dcfe5722fa13f9d8b59821c61ca6f8ef75eb367f4a37453642c
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (60 mod 64).
# DIGEST: ae701e5c8672dfaf728bf0f43f5e5247ea9ac13a
KEY: d4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e78
NONCE: 0ab8b700433a957a741c9eb80f2b021b
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f035
AD: 41a11be112a72933c7b54e
CT: 174bb28ef8ee033bf0f39cf6a5d3c2157ec773078860232827fdb1c875e9622e198a00a50fcc03b2cbf1e4a747efcdecda8b612ec3ebac650a7401b4b204185e4b42306d544e3f6512b87bf36b5f55ec0bb4da01c36aad92a16865cb852e1a5d1a86d3d57e6336d4376e8988f00162de8b238cfe36916d5545fa9460
TAG: 726c9d0511e81f69edf9bbd0397f4c3c49365418afadcca36de0aef99afbacad6dcf042fa62d405c9672e5409a7d28baefb467b7c153a3ed97bfd2b8be9b96e42b33703951bcbf04dec12d9bee63f5f30d2e57ecdcb3818479a163bd2a1caff3a327a911bcbb50bf213b77cdff340c858472223a71d4f15e029fbb800b81ff375d84d4c30ceda7a2c42267e1cf43dfd565c8a4a842556d577633857204af99ca35ca3c28bb02a7dd9ab224ae58938461af1e2bf64492fa2a18b4224ac3ef671c7abd9b6e266a0469cf3b0283b3ad6934240994f1b2d43b35d77e0055e0377c43922527d93426be34191dfd4b0a4296a078d128ea416be209b15c557f5da675c705ef8d1a30ebe78535434d2ff8bd29346abb9bfa
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (61 mod 64).
# DIGEST: 4f498d0aa9205160827626ef80c163275eca1f78
KEY: fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780a
NONCE: b8b700433a957a741c9eb80f2b021b14
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541
AD: a11be112a72933c7b54ed4
CT: 9b01cfa97c72b5ae8befd0d357283a52f6b8c5d9292d28f61373334280f815d6b69f878936738cebaf6fc84d20baf51868eb4d2ae08d64e724beea1887a76316acc955a00b5d1230fb120bf7d51f74fdc5f332521c59406bbd3161987c6ec49ad946a6a51755796de19830631daf69c78a847d2e515d409a7b77ffe75e
TAG: e785184106419b8c7f38061f49cfe3a265e9d4557b9b2d91ecb8f21ef3f52e387643b8ac35aae45594e70e4ad4457b852834718a1456136c5690aa164a152b0cacf020e33bfb33e2f1b79dd23d2fba5adcf22d4288308bc1d055be378eb77b67dad654658906aa3cebca8eadce6127ffe972803bed110a5e301bca0f2c06dfcb7af44275628831bff33807048996115d496f4f13b479f4fc1e8f2ff0991ad73293e789cd909fc0471a484ca11be8383fbb4d9590570c275354cc89a872306f4d285561dbc068c98d2989dc4453b97cea004a73fe238924c321d3a77063c1f20890324ae59860bdd3f7a70a7c21f1c51a790f37305719527a20b879e56b65d38799b899cd9fdd7edafbf456618452eb4fa37cfb
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (62 mod 64).
# DIGEST: 8c043825b2a3764e8a0cc35a011696fb3ed03c2b
KEY: d0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8
NONCE: b700433a957a741c9eb80f2b021b1444
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a1
AD: 1be112a72933c7b54ed4fa
CT: 0b0133ac614de667eafb516e1fb33b016a8b49e558f335eed239d50ddd13a4152f1570269615a243502fe1c6db0667a2de7975120ef65186f5af83821598ff45494e943acae24a6095ad46a498971f7b185d7784d451b1260ea478c03babf0e582a8a777cec20905821267eb85aec1a20c0e3b94d78d425a12f2efc4d60c
TAG: 1d832d65c91d458bf343260419ad0ab95c1ffc09b137d1ad1805cdd648c8ecdaeeaa0ea27075d4e6753538d831577642c92317aeb5525724023beb923c2626bd9536757ab73d1739ed0a850afbaa5914fe94ed606e245274d4d3071201a3d73ea1fbbfb4032e8404c12dd02e0b6cdc38324f4684049e2707f249c9dce0e6df9386b787154ecc3974d041cd6bc5e6d031851247703347bf8324f077ce63ce0393fcbafb4396bbfc9260628f4f82244b77b8ea0ff14e26c2058e0d8b662fcb9d9ef747cacc42ece4777114cd2062e20b8c6d198fd5628b198511274f54964c40f1052d41f68b5d90256e894da5e5ff3dee493f5eb2a7d2a9a88e32b774afe2e0e643d606185c34796b40716a46fb8ba911552a
TAG_LEN: 20
NO_SEAL: 01
# Test with maximal padding (63 mod 64).
# DIGEST: f3a432271c9be858725fd024071c4f479ca9a971
KEY: be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b7
NONCE: 00433a957a741c9eb80f2b021b144476
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11b
AD: e112a72933c7b54ed4fad0
CT: 8d5b92c78a48ca6049da6a036735ca23b99f9c3cfb97122312e5bf0279d094cfca0b976e24f6b65d81f85eff669da35486809cbfdfd1fd615a5347947156148e6b71a11f7bec611e7c29e19f6f62f94bd7f8b89e54b6945dcc1a7e380e51456a31f1d511bb92443deab5987c3bba266329b3f27e24d155ce685f67c34dd18f
TAG: 295c8072940df20a1ce3a27f32622fd6cdec5f5aaebee91e6654ce96f013cefc348f1425a6fbd6f42cb4e1e866c0fa602afdb503eda59801d8a791fa7de63d22c080369c6a3389034ff92ffd347ebfccb0dc9cc972f6654eb102f5b12baf864b3514f22d55f28df8d51955a1d338b4e5ee9145a4a85ec87655ce41255a6e91435a1d9e4af613d35bc6b4554c2594baca964d2a58c75deccd36d3efb50986f844ca6cf79dae24edbe75ca6008457ec23e69db9e19c6c039feceda6e1672bdcccf0a8c864e957b7efb1b468b4976a97600e3d03ba9341876e6439117d2ec364d479e0743ea9ddfce7effc0a64b73fa55fb1f57c18ea97dbd03b6391963734dfc459d4efe2e0f609bd51ee0a09faa81065ec8
TAG_LEN: 20
NO_SEAL: 01
@@ -42,14 +42,707 @@ TAG_LEN: 32
NO_SEAL: 01
FAILS: 01
# Test with maximal padding.
# DIGEST: 3519ab2b2943d2a50996628f6c26bea29f84c95af4c128cc3af012bb358ee9f7
KEY: 481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371e
NONCE: b8da7dac997deafd64b1fc65de39f4f0
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8
AD: afa22993a340b9b3c589c7
CT: c90e0c2567341ea7e9d968dbde46ecb46ad78dc8be7d47672068de66d6e7eae1
TAG: bc33ca235ae35aad13e540cc9f0714dab00678652cc476d57c543967c39dddc9eb9045fddd9fab64fd564959daf731fd95181a79f4e1d5e98ad446d8a625b68a1185d14f4d17a90a23e9f63e3470c37a367efe6765da9174fcdef198cc90d4acfe1ea34b2a38776fba7dfaca92b99ec5be216e7c196f1a615c787f8a11dac7259b3b6982d1415fe53c5e37c428099f6aef8a13b20d77e482c0900528b10b0a008e5ecd673762de36b1ad38fc33fc5ec70cfb963c62a8f3d8e471e2cc863fc65ce54dccdd3d95fa449378784f4e39a24c3cdfbe74fd352b74fccfde6dc777fafd3dca970e63f5b07e8c53d7ea0f77c26f80c9a62b7d1ab8a5f2b6707ea4efbefd2bd04e535587a7e13ae0005e1e3401935f424c2eb7e27e4137135997e26957d6
# Test with maximal padding (0 mod 64).
# DIGEST: 6d9cc64eaa0b3c7482d8431bff6d24c9bec634ef6459d873af4ff97756c9fe46
KEY: 37446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be
NONCE: 905d41203f5dce998f8fb2eaad409ae0
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba
AD: 2fd6773e0d0c302a5f47e0
CT: 7195b9643e0f7a4293c865db36442d4fe2cf3ea2c648dc88cd5636fe5e6bcea3d1197966e800da8c78bcb8830f3fa97671aebce98549e62827adf612e70f9466
TAG: aecfefa9e983ae857f033408f04a2f4dc9069ce275e00f9c35649716c3c65e9bebbcbf75ea3445ffde4dea79bf5c3d1dc4cd15a351972492445d1fdca03f7834b18e556e7e37e1ee1fe9a3c9d99010fee3a7506677e3ac5cbd5448549ee3a5e7bdd5a7b584767e76f1964a864ad2dad467e35702a5771d960b47f0cc4654a09a5cb4b7336fd43cd4fe5290b15ff50ca286f654b215c3bdbf3b918ae042fc17626ebdae135302ab9553416224cfee1203f804d99804d9653ec2a99a7fbf5d2a54bccbac2ef38e6d58b22ed53804cd5851e07f7cefc52df184a3c9acce574ec14c99a3abfda4f21ad119dec4a7743b384490136e77b1216d0df8b58607cc1cb4dcdbf25682dcdee237b773fe9714d24f2b3531037614585df4f56c855fda9949cd
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (1 mod 64).
# DIGEST: bb57bd76fe5f29b96ee3f2d62d8f3c4d1c8c986c0991382834046dc907fe1ea7
KEY: 446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be90
NONCE: 5d41203f5dce998f8fb2eaad409ae021
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2f
AD: d6773e0d0c302a5f47e037
CT: 1d50f3eb1cd76d8e08a9f386db0cdc3eddfc694e8502ccae47ab431c2935fc461254b80386c87690b01c22f38ea9bd118d2e0ed316ac249437a3e9c30f6c1f7636
TAG: 4b376f558ddf76137f0690dd8eb88720c506760c182e4cbb2fddb2f64e269bbf9e4bd20d1f2e1b8203f10df5a92a5950a7394525c2c36006716d741e686473de9895bbbf47849ad3a340dd262c095263be3d7678734ca7edeebd4eee8d3375c8f552436e3a90c7305aa0bafed0bd42f8f651a38666e28455e335ed58d86ed265da1e9cb77c780d4be9a5674e3bf7b624ec862aa9f5201793cc1cfbad7d0f700ce44d3894ed8e19884277bb1e58fe2ff4d4439163c6642f11f13be03c62d5a13182edc3e62bb72cdd7d0e157fb20fe4815a6803425781c1701d0601153811ef79ecf6ed3852eb87f886abee0e4ff13622b32dd040691810a80f3e21cb1d24fd2dd2b74cdeca38c49a7a1d68d72aad5484c6907a4e6440743a56cb8b6394d2a9
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (2 mod 64).
# DIGEST: b09802c727f0f85cb590791372c52bfdc2e69de36b9695daaf7a93d2fcf56fda
KEY: 6f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d
NONCE: 41203f5dce998f8fb2eaad409ae02116
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6
AD: 773e0d0c302a5f47e03744
CT: 4d754c684658bcc89208bcd75f24dc8e18b70a28b8a2201535e60ab755fb20e1ddfa98742d257eadd02d96c6a65f880d058312311efdf67f9a106beff9f5ace06577
TAG: 261eb376dbb9e82baf29687e823a93bd63961414b1bc396d5fd21e70afa47aafee1103248a9be160a0cc35a7cf05e6a07984ccfc354d37903f9a199698485d5e136648b1fe6adee40b0dfb589979df3b158fd8b3d35c8ab4c387f61782242e23e5698e5f7ebb4e733a63f3282ecd0c565f9c9535df36f6156aabd988e06e754fb3082afa90800af3e564a8d275d9afe184a72d538bd26ca1b4b8c12dc0ed449e643c1a1aeb8b943bd74abda7dc19b2e303a778d348fbbfe221df38d538c921030ce6485ea2bf899284e5bc8329432b16e4562d1609af0fdc616d3bd91688c2655dc0d5b436c0db8e0b434d897687e91a60f749a7e5a6e88e43a16b5f7a4c68d5c8325c260915139d901988ab924f7e9b72bb16020f0cc0c6b3f97ce4380f
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (3 mod 64).
# DIGEST: 13588ebf114df38b7b59f890dffab8b1a4c85f090c3f4a0e508603ecd34f78f4
KEY: 5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41
NONCE: 203f5dce998f8fb2eaad409ae0211641
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd677
AD: 3e0d0c302a5f47e037446f
CT: 25bc47e58e7d4f3a417c95768699c92240a2be0e86232a41fe02d64f66716023996772e1118be48e685042f989dcd9cdc574614c9c3989f1885b4b71dfd5b1c323db52
TAG: 9e72a44693493371870022657655991223f9a9570caa8d43b20b7e567cacc129dcbf03e2a7583b5b494bd6c52cc66ff1d1b3ecb7c39e26efb5fe025ea5bbef7dc579c58c9cc8f272d36b3b596910477d4af7e7105055f7769ee01dbdfc684956d44d583748085de4d2d4f5a9aea177e1f59f4b851c2794e1ee26ef2462b77f1ffb6d41fa793cac4aaac3aa88bcafc60066cbfba2af3a006bf929621350aa66aeffcd8fd7928e50df5dd27ca0831119107aeb0a2e7af5531da7b4033a049180a477ba24b8bd8042c4d30385ca098f9a8f16be6c286811bc036b827576da12beabf69c481a2633f6bcc7cc9255d5c2ffbaf5fc5813c6350f45b8cc664ad18304cf895907ac6c1c1fa5f9485f8d87e0a61f702334db886fa0aedc353fe50f
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (4 mod 64).
# DIGEST: 25c98c13e308408c882677b48f3a49a53b500146eadf5bbc0f5a240ab6ccbfb8
KEY: 91d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d4120
NONCE: 3f5dce998f8fb2eaad409ae02116417d
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e
AD: 0d0c302a5f47e037446f58
CT: f1ab85a35a17541efb4f906e7fc85e64efec6ab40d59d3da920c4ec09797c3ad47820e9d934e51e3f4d097c4a555575939bfaeb8cfea062b64816a160d6e4d1f282dbe90
TAG: 2e3eea7d54f2a95572c0dc382ef826f9fa138637df323adf2f64e42a4be6d493ee3d087704d9a1ddadfa34b0cc2c35f4d7802a87fe3e14be035b269c8135e822771faf57a21ee9f892f26e2231a0e4e03b32f2a809d560ce72c7e910ba4c1b524b171bd50a7a150ed327e791e2f76551d4eaac1e53091f5d701caa50edb892c6e1e2c2f8ac0413b864847fc10875d6f702c03fe366ee4971ee4602d078ce648f54b8e71bcd383bc4c3a14342ebfae042fa52f59bc5ad73a51cd1c561ae615fbfe24eda7301794349431ae59fa6a791dbd0691a83dfe1f8cb0fbe9e385708a9dc9449186cd6026f962552903753372934e220c7d5eadc2ea75356a73cd086f850f40a9b83f1e9331009d23785bb5468feee97f6e9e21d2a17a9eb2b5d
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (5 mod 64).
# DIGEST: 3fb8ba4df90f52332bc7a20df805fe903351279e0424c232365cfc4e62982296
KEY: d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f
NONCE: 5dce998f8fb2eaad409ae02116417dae
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d
AD: 0c302a5f47e037446f5891
CT: 5d6bfe91cd2273a9b986397a38e81be5fbbcd0403ef51873c2c467a9fbadc7bf540e83c538a43dc0e0ab780a4c4b1f5b77ced74f65b61f8b8b58b26fa3e8cba574bb9527e4
TAG: 8f360ea3d348aa4a950019f720333de020f23bb86eb11ab2bad10665f2294b914eace65dd890642fe33979f0ab04de5fd00b98757e734cc1becc43830eaabd48d415ca58dedad92d4c71f0b7744b74326b9d1dcc7b9afa134c097fd563bb001d8e91dd71a41d5f906080097d811355c268581ddc1c7698d9a65179526eb8c96bfc03aca614f84aa2c871958e71fcef12efe601309efdd7084c7c02aec5a6649dd7fde231de46b4b0b4c52676edc19edb740b33f8c90885147137011c921336b52b3597a30334319d69d71498b11feb841c09577c2167b58430784a056310d1b264e52af8ae737d7f8dc6431b305afe2ad43640cb90c2eb6fb4d5cb8540ebeed729416c04d2260a6b923ad698541a3315f938ed6a1b1626b1e73ea0
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (6 mod 64).
# DIGEST: 23f13497afad98ac65bd2a1642935ff7185a839a672fd94b18279ff92202a3b7
KEY: 7df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5d
NONCE: ce998f8fb2eaad409ae02116417dae0c
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c
AD: 302a5f47e037446f5891d7
CT: 16e3c681ba1ece3bdbfb1da491f877e806ddac5f1ae96bc406bd195c9d48bcd4a9b700a8ced21d824bfb99eb057e401c3529818725b51e96c576e8009bfe486610501aa3068c
TAG: 52e952e88946079d0e7e443f24f113c0c13ee17438fb7c302d82abec8e24524ddb4121bd1f2f1ba18389ea5aaa2ff43b9978425f1795cf3b2b5245f13d74afbce0e6f4107c9478c9e76a803be141320ed0ebd81ad6133d0ba901cfc4ef9802c29dafb2fa0d4b6ec49bde0ad8e359265b9fcdb9caed5c2c3772f2777c8dc59190d554a76d6ddeb67f12a3cb382015a36a93ea747a808feee5cf9abb7dd413acadd6519125a68071f7f490209f2de8049724a87dedfe208322cc01ebafac59d1d7bcc8c2896074908b40c23094a878a0b33592ecb8d407a9c68016a112ff1b5226a0ca7ffc9fcebc4f674b4f13711ee64dafd5bfa757f3820366a26b12f74fc30297a1209c16ea6299841713d46b72d03a12a51c5309317939d556
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (7 mod 64).
# DIGEST: fc71e48cdc62c15988a84f32ad60aa760b5766c892e559fa1ebd882a587ce590
KEY: f660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce
NONCE: 998f8fb2eaad409ae02116417dae0cef
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c30
AD: 2a5f47e037446f5891d77d
CT: 9b51ba0eebf72bbcd7a1b8452a49f30bf2d96bf0cde4d9e5efe7f1903eb4e09f53aec649c5a8ad7e7fc6c28a0dcf4bd3556f4377bbf8b3f9c79dffa597869255f783cf0c89206f
TAG: d94d45b132507172de566b7fafe7ff2f6b50387ba1cb27c2f2d566eeb644490a01e89745aeec464c3aae3fcb240dacea5c13f8fab5e3db55a415052a01e0ea77d0ce06a75cdcbe0b7c83433b33022de91034a18188f7ddb699c55957611f0d1f2fccbf1e8e325d33e50ffde6b62cb153c43547f7faa3934eadc45b5bb18a88dc25470dbe6456ccc99ad306e664226630a761e9673f673262690af6e2922f2376ee9dd486872314d2afa8be11db1baa876a9c0c8d4f2050d65bcebf39a11656760142d0d4d505e2a80a0ae3533608c161cf6f9ed4de850a9fe77a0212bbab0c82b9fec6fd151bf391bc794229736b1a51bdb2b012393ee405f8ac64db7471aa63077d9aca9ab11da3d078947dbb7e8c3935c0dbce060df66655
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (8 mod 64).
# DIGEST: ff4f42d72ae561abda38963a2713bb743038589bc2d7efa0f3fab298630b9c02
KEY: 60ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce99
NONCE: 8f8fb2eaad409ae02116417dae0cef45
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a
AD: 5f47e037446f5891d77df6
CT: 5e4df84379f9736d784d9166047003e3ce3375a8e7add80c8687e94f68595aaa52e3bd39a45a7f67d35b4df0c5d62abc81680ebea78d1ec02153833b4dc4bc5112f4dc2b3f14deeb
TAG: 9772a910db4e6582b98dbcd4ddcf7833fd0e20fb8044161467d80288acdc76685c62394023653d4942a5d1d27e63c12b44dcca72217d43555728199bf2e751a1e17bfddbc0ff8c6b618715fbcd27990a7f94fa7009466dcf570508fcce46e0a807c6892e805aed7141fb4cd151642dffce62f8d9e677a6a5b3f3506c4aab3cf3cac29bf4bc04d8a2379b8ae4d55a3f7b1414cfa7f576f8345457a87f257a75cbe7862829a5b0f9f779aa50bdeaf36ac6411a1fa7ddbba9519fa933a0729f02a404eaeb2c35ba4ee424bab056ee3a8ad0cc5b5199e6eafa0795dab533d062410f775277907f36375ec1cda175ab1b8f8032899298557bab8f3eb67190175b710854f0338418cd46da7e1d4d0ef8fb8881df16f781df7f47b7
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (9 mod 64).
# DIGEST: f4f7f147b43ea50a1f5a4f19c093ef917d3b92b46e5798e18b5294b0a0fef814
KEY: ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f
NONCE: 8fb2eaad409ae02116417dae0cef457b
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f
AD: 47e037446f5891d77df660
CT: 1ddce9b3f674dfc1b94a6cb34418e6b75c93f14941a6dbe028ed59667404b93afead95ec50b9393a8e0e5f469fc1cbc5136f4dc54f3a005af6c88cf70ff39487dec8dec0a9e6ad33c0
TAG: 6875fe08d6aec1a18c56b4f446562a523b95c8434fcea5942abbc10f6e10ff7c455db0e80f945f81462a0e689df450630a34a8c9c3379c4494821e762c16a73b029df8e3e5775e78ac2a4106d539a5aa2522dd0a586a974b84bc09e86ffb21f3fc6a0d1c9e1d75179bada55085a3d9f9779c2461f2ccc990765da2450815da4cff73913b224bb946204ba50acf5884f71da7a487b743bfa20a09175a4dc11e9ee6a0b12bba1a7330fb482f925f36532c52a3ead78a8924cd30a1e3053faa174d5acf16fc3e02e0867b921d382c842afe2b69556bb89c853338f6f32434e2b9da81bcf7a237e709fd55ede388b51b2ae62e10b1ca69b4fcbdfa3ac73114713c66eb51fb36678137aa4516530a92e03b9454ca6b8ef35263
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (10 mod 64).
# DIGEST: c48f43e4386dbf727ca93d57b5b2a4ccd8e1f27b201db03000660078b773faf7
KEY: 82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8f
NONCE: b2eaad409ae02116417dae0cef457b9e
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47
AD: e037446f5891d77df660ed
CT: 6736ca287cf31ea3ec92c68697bfd1f88642e67d9dcab11c5dc8ecfc61611ecffc54a04119f53f9e5476196f220486ab53e2b21e1135bc6745731f0bd32eee9752fe18aa410159805977
TAG: 5e40a60a3661940d928cc1818e0f0277390296d5a20f1d020452845b5ecf83dabb95153285213d50438bfd32980c294aefd1d302517cf2aad8bdefc63d87d2995523db2f2380cbec94cf5f5a7af4f605d7c9cb2c2c5fc67b567c5c219de53c39e92ce4e597ff10c929d7e66f7a156f3bb8fcf5c05df504924dc282bb94fbc7045e5c758239b70c3f171bc9c34e95f8821738b02b1049c8e1b21d66e8ce2ad606c8492749b78592ddb0df4a51de74514a1f25fc4278b22dfd5aa0761e1afc5e4d622e9088879df40964ba02503e876ebc70ab5e75c33d7ba0d3879e32255ac7a884a723a673fcf7007c8105e7dedcfa91832ebecf6a929033da1069839a1ad5ea9f659e2f2d295b06d5d6c5e685732f8d9c4b95eca515
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (11 mod 64).
# DIGEST: 4fb8d7ccd762998c343aef821e49cf91783d15669105b725eb1123ddc16ea445
KEY: 933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2
NONCE: eaad409ae02116417dae0cef457b9e5e
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e0
AD: 37446f5891d77df660ed82
CT: 95b9375058667abde693e7e3a598dd4c326ae4db29f54667c54453e6191c52f86d2fb4fe324e9a02b94f094f1dc272b1e6ad85529206a511468879d31ab9e74f44d9f388b72cd2461fb67f
TAG: 7d5b0073be50f1aa588d60ff430da154c9793c30646b9d98ff8581febbf8541698a3a14e8dcd317d3f5102a828923b4a060843e4f813cc0198d19bc7b8c7c3fb00bbeadde45d84393bcbf90e4caa0b4fb7e8ce97584d639aaedca28b685083417c996ea73686a504e58ce170d5e59dd1e75cc2527c9a9976ab552533fd3e9c22603c5b4b25456d833182821116d7f80fbfeb9b0a840c127a755b4ac4121cd82f12508b0eabcf1255d5ed866b11366f9a2a59becf0aa3944ed0b1531c92342cb89dc819fa342d19db29556a98a6f1d7f166406257c4fc2019f5cfb8e1a2f02a161e2e6e91bd717c3c0b7429e9eb9d50f873ccdf0b487ee1996e38b248b0bc29ff17d713b810907bacca6f4dcc0633757d84bc065497
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (12 mod 64).
# DIGEST: 756ef874fe4546df371e012dc34660cebd6321b67dac201988cc72e48917d7b0
KEY: 3f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2ea
NONCE: ad409ae02116417dae0cef457b9e5e16
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037
AD: 446f5891d77df660ed8293
CT: eded2db8c302b3b5b5b0c0d556f8d34408fdb2af75d38231049b5f91e02a4086e6ffcfabcba5e3ec68173dfde382a41523d3c8ea1f7944351baad1588516c548942da82684d52639453ffdca
TAG: 518bf4d7ce510d2d8b41b8948c72f652efcc6973337da9e53d8daafd49a8fadebd391c0867ffe253dc07d26c12985933288fc617b9f1e0b74ba51b4a85e11d14de331f9af1c3ec66f4c85e0db13e2669a0429b3be48cb3e8a59f3fae779aba1ae3cf8a9c7d3c7c3d7046b3e7592c67da2779af921b2fe68801d739ebc0fe61ff52724a034f8d6ab916cfac58e9530a541148da1bcd17957a9fd9481571d054e6e38f6f13460fc1bfcc51052a7ae75f514a4d6525dd85d067698197322e61212d58c3fdd3f08e0a06189d8773f87f18c0156eda94657acf5659c6bd687188fe8e3f09b7cceb63d6c78e0198cfb985bfea1e6ef70f2e1727b50c45b123d189607c3dbe0e06f1b359ac5f8dfe1766580afe966c8f68
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (13 mod 64).
# DIGEST: 01fbec0db232a15b4f3e02a14f412e296a0f2c7bbc539ea1e5e835206e197929
KEY: 62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad
NONCE: 409ae02116417dae0cef457b9e5e16dc
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e03744
AD: 6f5891d77df660ed82933f
CT: a56c9d8579b78c9ef40c4a230e8bd42750510340fbd0cf55393bd13d93b105fd2cd1d701b6882bacc661e8da81b7c9eed6b5dd4da12353298150819c748f464fa35936dbdb39149ed790f58777
TAG: ec23664bb72e227a2d60f8e04aa12b33b78d59f1237f2305c1041793344510993f4dee5081f28a969c122c414a4218d4a73e4e8ba26ad8f6a8c3f73bfde7b0412f8fd6941f26ab73eca7110a4873cceccd43a917d5ea6418c85788512fbd262c72e594d2defd5a0a136ee74e9d1e76f335965a7679b3a059fdd6b72eab855763e4af5e028e9239418197e00088c7e2f661142d63babe769de4df2bb36f2fbb39b3723516d0c85b1214e82f12367582e9c707097cbd91650f2b0ae6f13a006cdaf65f9384496055bed36622b4b495335850b10fc6376112b99c4ca121228814539a2024bd4e839bb020efb32f858322b4474bf5317fced4ba64817e022bd53eb839793c59e673d4a50aea352db65143bc0a1d14
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (14 mod 64).
# DIGEST: c49af18a935082656e153daa62270e736e336727424bf48be78da0b7dced9de0
KEY: be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad40
NONCE: 9ae02116417dae0cef457b9e5e16dcc5
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f
AD: 5891d77df660ed82933f62
CT: bf13550fa32201ffc699cbf22de17ca268652f8ba2693dde72b626d01855eea7c21f0afae3fa03dc757491e8efb9091a4c100f8dccfd15a9b4dd94e4fe1f5e90a96a8ee973df3f67b1b87adde382
TAG: 45c6bd5afe30cb502e43d1b3b2440faaa2908d171c8e7f53480efb6d74fecc454a6dbe10ca0ea6368b4afc200632c1b078250369c85a463c63c8c79a95a8d5c3b2ed6ea220b8f624e381022f78cb94d401bc384c5c6be68e8f56f353524d93b68dbb590ca9afefe04e642fb8d8650c8e94a873985c14c1fc7f7e114b2dadf9c9cd89e504636329f476fce6fec894337704b6406c634aed0330cc20030543261a628efd49bbd4c52e7d70fe4b32415359135e2328027b388e3dd4edc43977e8eeecc04919087ec0935f3b7482defceac851adad46db682cb19d407a2615164e2930278c26f942572b64ff9ade93d2debb185309fc2c526a80aa57ce225ca7cfbddd4ae17cea86afaf38b1544a8efcef6df761
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (15 mod 64).
# DIGEST: 8d6f1fdc3d60175573775cc289d7436b88d10dfa029e90e10e513c8e739666c4
KEY: 8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409a
NONCE: e02116417dae0cef457b9e5e16dcc5b6
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f58
AD: 91d77df660ed82933f62be
CT: 9f9a3ab733e50c1584c4f0c2a2dc0ff71bb3a9b32dbe92da2fcff8fe46a4bf16d4f30ec8efb1319891b7d2586839fffe5012a6dc3d5f0ad21e1572a1ffb48fbb82daa5c2de27d8d64515d8b50556ac
TAG: d59e25e24c745028ce4239294565972873c4debbf863e3a3b5d69c5a32127916516037aff509bacc58b89e041ef8d2c56b7a3898aad9426f6c26c7d61adf61790362e299c73eda72314b6429d9f64985d91820bcfa806cf4b99d45d60369f52c369970c8162499f6c39948bea9a7ccb7ded6b4f69f13a98cb1665a9be4ad2f8e3e584157a7cf74009f504622b4529e55d36e92cc45df30bfea3d3687437ade9ae87e16f64da2960d30d6660faea9c890d4110e18c20576b729bf0157c151397aec86b563c1234f2deedfea18b2ed2a780b3fba34ddf21edef8bacc5155834e2ad144b39eacde01196a70e309122eeada9c1c589ecb7cd22a954a8025edd31383b2e36f453f9bc1fd8779e7a23653cfbea7
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (16 mod 64).
# DIGEST: 11a40304bc276c51e2e7d8e3fa16f905bf050f3861586be68ca4257b1e6cc566
KEY: c55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae0
NONCE: 2116417dae0cef457b9e5e16dcc5b6f2
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891
AD: d77df660ed82933f62be8d
CT: b4d33c5131701c960eda4c50fc0a918acbe28cd47fbcaa328c6a9eb08e3c36b697928c6981992ab155c30984c6b8e9340cb00decef7086f589ed2d730cfafd5ccfb95373b8c55044fa1c95927d02278a
TAG: 713f2e3e88f54fa870bb429940553f8a55526f219f062dadacd69284718a21914f86d905517eb301bb5693610d69a32becab289041fb962d940eb0a37da57724b4d07c3b968700dec4d019f6672cfc45be30e4ea80a33dfa7d88abc6733a1cc7a788c6dd12f2e18f001a9d8f0deea3411c00e9234d9484fd030375bb6c3519e8068694019cd8e7eda59760cbb775a01d68626f88ccb026604fb260c0e3eeecd3482619d1108c3ed9ee2f992c0d221f8a0b3964a6ac23bdab18f2a825a2bd8893551686224eaab405e027bcf3cf6cfd840479be33ebd22479b72d61e1d26c0d62ec8e378982a61e85da137019fdb017338fb245ed0f82c531be137dcd56af636c69197228ed2be7ae7dfb0097c4f7e5144577a2cb0cff362c52e28bb1d2b284c0
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (17 mod 64).
# DIGEST: da3fd1aaca630fe609395b45a44384c57f779505188c8b12391b9f34de17dbf5
KEY: 5b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae021
NONCE: 16417dae0cef457b9e5e16dcc5b6f256
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d7
AD: 7df660ed82933f62be8dc5
CT: fe6540372ad1c40ec1dd644e935c480b9e34aed05a7f21e2e37dd46db52ebc5352cbc3be2aa289cc2e9712aa7d393f4454c9fa3a4acc30db41ada1257693d3469b0a1d5680dc8dbfea8cbb4768161f8291
TAG: fb0e5d817e59ba33aad224a3d75b490058e8d743e6db43e920b30fff5e931aa17ebdd9f33ffd1eb9d73a2b9301fec0981bd29d85edd9804def4edcc9d25c04e7bb4f092b71322dbfb1c54fb71de189c88b0c63a4fc615a389b7d67758732f2356924813539ba0248d47fe0a536d141210b4e01d3a3cd1a846933c45abf7441eba3de98bf42c217ba29eab4dd52bdb44bc8ba97c7cdf10106f0e5ed04df11835e1ed86290c2b4b79e5b9a3597dfce92a71958957ceed5bab67ca5b00eb19c0897ea081929a9fa4c45db9dceb70875cf9773cb5dc543885f62bede29135a5e637c078029b09b290347f1e39b6ce35c43294fbee0cf3d9359c25d2a55083eb7d3d13486e851b1b60e1f51ef7fc48d16fa427d7440aa890d300d7a2876ab371686
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (18 mod 64).
# DIGEST: 2ea803a4525d24849aeda1b0adb81676b32d99c42bcd0011932085424a0a8078
KEY: 436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116
NONCE: 417dae0cef457b9e5e16dcc5b6f25607
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77d
AD: f660ed82933f62be8dc55b
CT: 22e6c691ae1ba796667ceeaba4dcf85582e398e529d938da63c8221a58c2fbe242f6da82eae8c896dd31b45b3e8b72ff3dd7906130954f7b68d4c8729d3ff66ffad72104047209a56f1d6cdd927b57e8d08e
TAG: 0325aa247e8c830cb0fbe906d495777fb41894e5721f07b1aadd8b0a2419dd28c973681d131ad8866e938ceb84e65762930d3961ec13c2ca461e927a8aa79cab8508709520b1dee01e81ab4c6f5ee93eb610d6185469d88b32f8acd04f6e8e138aab41456c9ecbe0ebc1d6f9edbcf8e4d543515f9cde2610b1a1454072d5d66b7948ababc0c99cf55e2ae3e9a1f0b141bdd8df4a1647f98becceb6229d190341072594cc3c2c61070c88b0513045aabd07d2261df9dfceee46c5f353dccd3c1b2fe4a2ebbaf8ab7b2939761aa86f88a19b84e611a957ba9fbae9009ab565279de6f972f82b42f324fbf7e9668b4f17415bfd796e4886566ee0febeb27397bf971795a7f49d8d302e13d7e8cc4b20fe89999665d03f83245b807fbdeb43cb
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (19 mod 64).
# DIGEST: 6802d4c044d85fe270b3761ec10ae5cb4b912a565e00cafc8eab935935523126
KEY: 6965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae0211641
NONCE: 7dae0cef457b9e5e16dcc5b6f25607f0
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df6
AD: 60ed82933f62be8dc55b43
CT: 4772e647d03817c0f9deb39ff4f4f27fb0fed33e0630eb453883c707336f0e74ef206e92e31fb2935a466105dbdfd42c180ef63cf5cdd3c281337895e399df6078c22762eba5d84b8845ea00bd88bf5e1439a8
TAG: 294f0bd94a45371cd6205187e9f8357817072cbb1940abd8c54418f1835616f05a75c38117165c43c0bbeaee69f8e20875121564bc383cd435e1e2fe4a36a6db906918c606edd336dd2dd7617c19a3d701756682d46e04609bc2e983b557cab0c8e3facf110be1f18baf31a69d09ff01fb8f51842e38fe3c38e42990c1bf68838cba82a82c4d77d796a59ba70abad4e0d6bb2f989e52622328458d5809ecbec33764dc77df403cc574c9535512c10446147077f8f05aa63fbc0f73195692ae69fcacc30253054064241ea28263b52feaae58d0b07c990308809a86327ff6b031f010c05720779ba1332ac1f93ef398491a438f4f823e45a4f2c5420c91447815e88fcb5f80717141516d8a1974db7a21fba576d77f929f52c84af22ad6
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (20 mod 64).
# DIGEST: d159516557052899ecffe8072d2cdb753939d812db2f8861e3ba7a837f0fe29e
KEY: 65aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417d
NONCE: ae0cef457b9e5e16dcc5b6f25607f00d
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660
AD: ed82933f62be8dc55b4369
CT: 6dadacb58a7b88e2daba277f66e5757042c142115871c9813d1a72a79e5a71366801a757a5f9982e99c355fe7d742fe3f047b711dbe340bf2ffd00cea6dc6ed7a4a416c17138404854ab8a5420960d6021e2deb4
TAG: aedd593c686dc75c7bee2e9e90c2ee010801d48e40d62b6d64cf8371d478a9319dc95d959937396c8e2a887865478cecb1d3e9dff34adb0aa0642ddb5b29693c2d9a3e78a7d71f60d6150f53dac8ec04b3832b7af35ae5244f5e49a97308d5dc1dad0254af32fa1848249e00d4dd547eaf98ec112db7d519c338d698e9633c64f47f9471843c2482e647878c5fc32b5bcc092f4580a39489d7ab61bd211fe4af348fcc18ed48389d670eb903313c79a5bd2bcc250f1ea5cf639e965c30c3b3aad31972c4cb451829d05448d5e12b76b03dd22ad2b7e906ed80d72bb13e6f60cbac269c605a47aa8b676fca372b7969fbb608c04b8d105b5e8323ab9b1e442248fd894e263d2cdad5e3a34fadeaf478c5512206980d0f4113c6bc3898
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (21 mod 64).
# DIGEST: 8b4c76888085f1030618cca2b0ef708b79b68fbe879c266adab2211c35baebae
KEY: aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae
NONCE: 0cef457b9e5e16dcc5b6f25607f00d03
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed
AD: 82933f62be8dc55b436965
CT: 4307f039e09bbc51fa0477941e321dec14e5f562d3a5ba25d71c3c8afa23f44e1ca619d130890b7476e5227442c27995cd292ed9d0a649773b752b3bc7abf171244624bc55784adc9282f1776789fdbcc5c043dadf
TAG: 10d9216fcf6eb71ad30348d591c025c364715c73d46bdd26f04cece2b14ba8f5183b7250750c75017bccf9b394579be5fd2c83e77a30eb11c9b2fba8355390a3bc19c98d0cd5f65144701f3f08fadebc29150ce3ecaf4bff75e9db3043228d037861656c2c462668e25a2a6b9d1da7929a44dccbfe3758501ff0952c064508025ca73687ecc1a89f825eb09a762c1d7a63edbbded5ac0ed6baea7ed19677c8844a063254a9a0f464da61ea782ff5ce62462009c64d9ebe9597c467e1d2f5a2ff39c18eeac0ab03cd771dc0c75bb826167703855b96a9ea6acf8f5a1c95f59582a56addbbb8ddefa5c73405b212c8945a60920dd18e3dd4c3571003f227f1a1cab2b41b67d133d0d20708ff44598440f8c5b2f438a6c0c14113d075
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (22 mod 64).
# DIGEST: c93f922285c3abf65fd70f22abd7ef859a392a9db0a979acbc99563829e3fd77
KEY: be477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0c
NONCE: ef457b9e5e16dcc5b6f25607f00d033f
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82
AD: 933f62be8dc55b436965aa
CT: ee9fa11a7d6f965e7d65d8f48810754770b9d237ba0111978b97e24f223817d0c6ce4dbde85c4e0979bea607a36c66f908c25384184fc334d8d985b78c2e9872d82c4cb1aad49d7dc21d6484b80f9192092da38282bb
TAG: 4ba52b012bc5146d24c5cd7101ffc935c90fddb5c25d4939422b08a9f36afb92a71ed5cf86418748b8268e236cde7ea7bf8e757079d3b5e74044939d104f48d8df2cf17880f08f9eb7da709132fa7fe6bc1ca3cf9308625e15595a56ba4b2bd12eb3a4fcb06cac3a7f8d5e046e464d5eab6f502e5a9a7542938e95a8e6e0f4106b5b77f100c1b39db7de14e6f777a0cfd8bf205a6d70a76c1820b48bf8e2f1d473f82b71dd5440251473e5878ee858d60a60afe9b9f07f201d208d0e60660cf6ba2440cd0cb2ce4ca1ff0b6085a864fdc8a70fb760747208a72f9108c7d3234ccd69c1218be9d3d59351827500244d0e1eb39d08c82be77ed837d29b8650fda3abf8e8e922f754119433bb1c27769cf7e042c49a6e87f75de521
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (23 mod 64).
# DIGEST: fecc2d68e7e0874de9d063a889b18ca83d3d5908aae064db20d723a8da1b3978
KEY: 477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef
NONCE: 457b9e5e16dcc5b6f25607f00d033fb9
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed8293
AD: 3f62be8dc55b436965aabe
CT: 1a95f47f7bdb2d91358f683b7bf803254d88b59e2d3c1d873a09794e1c18f1c924d480727599a1a6890bb664335e690e4e52c385b634bed45e08410448ffda3ea2593a02a11a03d994617b9f7ac85317689cff682990c7
TAG: cf55f1531360cf0dba29ca8baeba795e3ae57ae1c8d233e5d771be0a7b5e483b1871057aeb254958d0353264bd6c61834295431d1e624f194559d3e476216b295f81ba3a7ce67edad2c998d4d5f2cb4ebf6a83d3d40bf36eb0cfe75652752a4f8aa295663fc4577270c2b49ccb411c0f6e3a2978d77df2bad8db2e7252472562a6622a0c21570beff15ab6d21df869bb7b1f351035b7462753c36bbb0ac6e3b750591cb02c7ecd9b03819fdc47ca0106ba37c21cfd5123479629b57839cfaa4ec72382ac3fd6f1a8f24809921cef7e0474a6372cd4beaf7481b554da8cab83dd4de5767c3c7d0194ce7117100c07161889b01f4deb05ab1fd9de79f7b634009c5e40f2ba9ae916ea70e622ae14c915efd902758953ed3c63f9
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (24 mod 64).
# DIGEST: a182bceec087418714d31fdad208a5d5c578fa8917a754e0b0527364378afa81
KEY: 7e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef45
NONCE: 7b9e5e16dcc5b6f25607f00d033fb95f
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f
AD: 62be8dc55b436965aabe47
CT: 67466a0bda0815f726cd09d159e06088b2530b73775a8c18eab2d09ed7bd12b743b0a10345cb3126dc14d8f5c503b65a45467ef9b56ec7c5b24e5548e734d3f0fc90fd9c8019fc782882ea6e72f4df5f5f827d6e8c60c86a
TAG: f6c2c4b7de380be8cbfcd90f06ba067ae2e3e23286dc1079ceee60c2cb7384c229639917d38d6d50c24224981c7ad657c0b4672b2e3e0cb75a2745801195902c4ecaf772ab99592ab86682aa2f0b46607f5e0422b159a8d06bbf243728d0711dd3e68277b9a6f29a66a6cee41dee43a7121ac2d8e9c0d02d2cfa397515fde2161e5484679200c7be71015f0f73b88724adcb6ba772997119a6e17446c9872df0b8b50c571d5ea5ad71a14e9f4a81ad6437c1eccff6a93d1385115f55b7131225b5b49550cf9dad67fe8c9992f8482de6380b64abd01357fe46f98fd28dd2a3dc11f43b9c2306b5dd6f6fa02ec5bf3d9d495f0ec432c9f527f55680d64916bdb2a4088a72985c1ec03f418ef2a49870e1d8f77da41c227ac8
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (25 mod 64).
# DIGEST: 81dd23016c18f838fcfdaa8afa9c52009af9d93092e250bde67ac11e8588a238
KEY: 0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b
NONCE: 9e5e16dcc5b6f25607f00d033fb95fb0
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62
AD: be8dc55b436965aabe477e
CT: 34f8a83c831f374e77c5601317b658e47091d811285791eac2fc59fb06658c115dc875c80b1089a62fc7d072534617dc81dc3adffbbba4b9db2e7272eb0b8aea73eb9de6480c43190e239fc300377f1839a750fb5a915c63f4
TAG: f201dd303f2be93385e189f963a1b038564f9648cc09ee82bebd9d471564156e14933ed0ceb36f768064a038f1c86e936d05bd32fe132c068f635a41f5e6c0c9c1bc579b9e218e5b1e0e95e2f95a05171a4670ce0028aa7aeb78229f6b3ddca48e35c5948443bfb0234b083fef65ccd11d3d8894918289dcf13586868c3cfb535dd9d4d79cdc391a59c8a7d5917e47202108fc8ab98f8be0cdacf80582843ddbbf7f158841bc02f01d402b5b8c004b33a1d20d85590d37ca0704e58c3071b0da1f64ecc52532e76736cef4967641ede072cdd0b61a02b5078c310a7091beb07c1184ff74a65db5e71f42fd9ff622040c331687f72f6daa6f7752e21d0d844d4f646202eb18677308ad8747823c524d516398531c356f3b
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (26 mod 64).
# DIGEST: 20f01a20150588ee1067e30a2ab84904a34ac56cb9e327756a700b1af24c6200
KEY: dd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e
NONCE: 5e16dcc5b6f25607f00d033fb95fb09e
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be
AD: 8dc55b436965aabe477e0c
CT: 2ec0aab31fbb036bd2af5ce39025ee2d5591fd525a199f2233384f52a8746f4fb547843c92d1e4c9fa92bc268174d4a59134142f14e8e1e277f1f1844c64f76dcd20f3b73dfec8e9fc59a639616fe4076fabc5d3fc116a8db5b2
TAG: 58aa84e06a34424ee932af39466c3309363d93e3af6a37473f54788f7c1564549660ff8e96cbd74ea459c318d52566475062f7b6ef434a4bff703f831c4c5ef574d7cbfab0eb130bff93f7b7121f3bbfd56574f6bb89fc227257ced565ad4d73ae3c72b25f36be22ef5bd0cb5750cb23c52743bcc1306d63acb3f7ef73117a352a95418e8fc12696e99ca1f44c055c227eaf0a116c0847d49a32d1ea611e88f6d2500dc0d2c4cfc84978a31c43f30e2d5028602d7cfa4a48efe16b18d46f078502c5976a63ae91a63266bd068175bf842646264da36df63c134df8171f160fcaa144b78fdb81534ef248ed1c7bc234d045aee646aa6eac6d770f4487e1bb4bfe9e103bf83b1f8fb3a12bd56ecf0c8eb1c5a0d0f35cd7
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (27 mod 64).
# DIGEST: 83a45f4fafff7e1ec40a34e75a49a431478bbe8c9234da4c1b3129aeaf453d5a
KEY: 46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e
NONCE: 16dcc5b6f25607f00d033fb95fb09e4d
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8d
AD: c55b436965aabe477e0cdd
CT: 90712d5e3edeed5000c62ce80212d41773a393792a3a8fc62a1cfbff38b3555aadd88f0e36f93c8a12897d7779972b3e42978cdf85da7a3ba2e4b261f0a0cf4e1edaf259849e87133a9c057e5d3e693a420b7861b96e3f10b34f7b
TAG: ea3b1f0a196af1f2df325a7a1f4fe1799ff35df267da4a912cf0cac8ad6472428fd08ecf4356cacd67de7eaa0e92498afa1f8d01c9230d6dff346752970758ab979e62d3012356e83924e2f9cff28e485cb96c5d87c1882ab472a4dc6dbd79b68ec3e64990a389e864a4a2fe9e8fb4fc66ea5b1f07893864e1d6c38e73fa60ed109bf75d6b96d8512574e0afa2f6114d1acffcfa23433eacc0f021e05b6c4eb3148836449c72485e69635243a8aeae09fea475b361271acc9dba14ab957ecbb4b0a03edc3460d63eae1aaef92341456b395011321fcb7a85be0fdb812259397f8b52ff8653aa27040c17ea4fad7c6f6c9c941d1c83ae08d52c1719bd2c66fcb79c0179e3c1827785cc7880607de862e8c2bc8b4ddf
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (28 mod 64).
# DIGEST: ec9b1b48a2e7600c92e69277c9e55d1cf7a9135ec73cb736fd26718c5531fb7b
KEY: be99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16
NONCE: dcc5b6f25607f00d033fb95fb09e4d00
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc5
AD: 5b436965aabe477e0cdd46
CT: ea1b542c224788ae66ded1b3ed9f9e35708252a1cd1d4725b0a187b669c51d282776471be5a07f256faa9ff16fa4248c629a4bcd31a9dfb7f260d9b1cb62dbae424624fd816bd81f781b93ca9dab437bee7e80bb7baeac902deeecff
TAG: 650eb292cbefb80b7401e38e9803fd2b8dbb13ff21f0f0986eb42280ddf019458c06aca80c4784da1930a92427f96531e97f89e62ee5b945f07a8c7fd2b1dc6710f0a97096036d22493c2ea2592fea8e4b2cc93111959d33838e4919068385645f898736a0bcb391a30124694d7421f6cfe486047a95f55546c80a75fb7473ecb4a751db0c1dfab931081167e80a5116977c296d0b9e818dcd72d3404546589038d51f08ae71db0721c64e9ce9449aaec77fd362c41b6b9822c91f267e3cf0ceebffcfd55c7e16abca6ece0de8fd0b58919359aea7062af61e48a6185bb186db113a39be60fbf00d7f3664d3cc64e9f9eed70e01240e4d7f51587b846787c82723195a307c6144b3a1db94a10743df47c86386a7
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (29 mod 64).
# DIGEST: 7b0d19af32e867b61fe57398a3ed863a56666fbb67100e6a5ff01971ab693fc8
KEY: 99371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dc
NONCE: c5b6f25607f00d033fb95fb09e4d00d6
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b
AD: 436965aabe477e0cdd46be
CT: b1025c9eb02f72e5526ef641778aebe786c2f85961997f1eaa090a33caae3a9df34da7088352a2df7a61eaaa026dadbcd604f5baa3a0de4fcbb3812816408d61384984141d9c78f47e725e99cea9d52fc16797a3ee4dcd80b6e5ac836c
TAG: b1a3af10a3a38373bb7043194d9f0acc257f231ae324faa30c0457ed219deef787c85dce075c04e448ad2039d84718b9dbe23965df0b253986123e8f4427b833ef7679b4c6951d555c98ac8e151c3bcac077b8ffab30b8e6623809c39b7ffbf6c247f8be4993e91841a204b9af2ed9104749d573b01259646e8711d9a8b0959d4e9ba5ced78ccaf37a83035a096dbdca802070baf44c9d97b009c9c6eeefae4f1348ffe11bd512070636627d0defccb8dd737d6aac08116654cad9b36d3f183b3392a020d25f8e03142302415d3d0575ae203caa7581c754c36343bfbc37627320e9e7c0e66cf277e738346bff15b8277c5675827a25e0ee68482849df97d135df15e544159ded6d7eba4fe11c74f01051bd9f
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (30 mod 64).
# DIGEST: e3b7a347d9bdc63bb1c689eb823076d5ab24c3f502c328f70d71a1b3f00111d2
KEY: 371eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5
NONCE: b6f25607f00d033fb95fb09e4d00d617
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b43
AD: 6965aabe477e0cdd46be99
CT: 10623f3b3c8888a31cbf51eae0989eb3caad5f5b786c13b41c04e0b6cb2641f850df4ebea610a4d521557c8f987ded40e9702503fc4ae62d1830a0f04d168888062f5b147e858a134a4022bf2790d81a20976e2b98e407e7cb7ee4355bc5
TAG: d1ffa2b9b4db22b1de1eb8d9926e651ce34a85560c2e75605d9448c508e3030ce78f3a5973bd87d99be66603310d19d4e4a94a2cfc4ca9fd480dbf4315a814702d507d8699ed17e89dfa8c3b7c0491e4c22d63daf87bdf3e1ea54b759e2969ef392a659d9a8237bf4545b78d268cced5d4c6ee177ae96f77e555b27cfd6ccac215aef995c383e84419293d32401aa7d98634e99fd5124334aeb505f1b389d6b80b78eb57fd85f8c020c17789696078178dbc1e328ce213a623b6650a4d914037e4bec86ec6e1cf12881b4c71a204058970a1e607846421b8ca0fb346c19ea40a2b6be17fc0cdaff9d3c30868889b4e8664f2b586620ea74960c04e5dc3f9304dd78e8cd2fdc5c10d5b9cb640ff911e4ab323
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (31 mod 64).
# DIGEST: 9ee27167f084f493a4e6e5b80c1cd07babdac057ed98dc28cea1f107ebc68787
KEY: 1eb8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6
NONCE: f25607f00d033fb95fb09e4d00d6172e
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b4369
AD: 65aabe477e0cdd46be9937
CT: 60d4a0ba2caff08ac046349b511017a7c5f5537eff0bda94bf838d50c14d59426424e4a8f531103773aa0eb9d242a9e6f2ba5002ef04aef8144c8a88f05788fa5fa1ab1cb5cad84da0d31b280ff8a55cbd75f2327f726d6dcbcebbbf490012
TAG: 26ce951279729891effbc740a3e38a8eec1d8fd4bfcce6180a117931b1f3ac5a423772156307853624240be289aa9bd4868d9c8b3b93d332a2bdb679bd14eb8f91034468fb1771d679321b067ff9dedb04cafae3cf43c046350c23b97bc3791821d3b4fe50a5ca66057432994e75d53365fbabef04a3b6c4af9f2429dc478145c6e67f3dc1990d0c21fc5d816b25ffe4be41a7b465d8485b2e4c22d597a1419b021714faec3c2d2ce1546b73145a2bfe44ce6a4d6ff162c6904977388cb01e8495aa05a448a157cb986b59d74e3abaac98c024d4658ad842e9e10195b69a244aa42cdc5c073f08313cc9b2036f830a1aed7e70117c91a8fabbabc556d9fe8aed1ea047a83963f985c1914d524e058ef04a
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (32 mod 64).
# DIGEST: f6b15333af80c49e8ea591c2272618074822d453d85ed3a96c29f249873acfc1
KEY: b8da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f2
NONCE: 5607f00d033fb95fb09e4d00d6172e78
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965
AD: aabe477e0cdd46be99371e
CT: e59fdb3d1413cd6a1098b5daf1662c698076996e2581e11a286e5acd6f29d41ff9d04da8308ce7f5defc52be0b4d1ee96d8e5f4eddbdd5fa9894e7d1b0a1bed483b7e7549e1c10cf5b8ebd1e7f1177972ff061cdecdad8d97bb0308b19bbc2c8
TAG: 511574a8be372a8f1f9d856e674d266dffbee195e3f7e710f3ea76bc1c83e449fea70886b5cf0917543e45f8cc968502e873e362f1bb376a529cd4301b8e5427342869118fc7d2346aa78a4b3071024c5ae51a73af441ed02bbba31d0c106b720da7d9dd3cb9902048bdfe1e7ab6df1c2cbc78bec0c37333abc14b0725fca3278d54cd188140e35afbc743eaff515db5b740f97ce8062a20ac53b2a5cf527999529726f79cbf4220e0fcfe51863c2251f23a2a139182250e1ba6a9e889d998cc429dc503d5c3c4604346e2ca0adca12699b4ee8f0694609c3816ad161612c9710f6333e5c48e3c07f5a644714554869417dc31dbb5ddbc2de6518b683e6a7bc9355c0332ae155be0b126234b7c7a53c1852e7bcbedcd86e8bca69986dc5512f3
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (33 mod 64).
# DIGEST: 02dd1eae128cbeb47dbbbf90e2f5cd63293bb0091815c93bc1153d46f176374f
KEY: da7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f256
NONCE: 07f00d033fb95fb09e4d00d6172e780a
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aa
AD: be477e0cdd46be99371eb8
CT: 9764272fe16e12bb42a8f2a6620e44d4f202c21d51692e2948e2f4e4a18acf58a12d399310f15e78bac1f5f2a48416e5f4262ab9a8480d9f1429e5e9d15d81df0719f8db8d7ac08da696048e8a048255071ba8926be1dfbbcf53e7430862f64c04
TAG: 3859f6154fee0d5bb25811575cf137d0005e997ceaaf7def4d374e778bb2cc0b956159543f797667c24c28a2a0bbc352356054e532c663947e8a0b6e949ed9c93fc2897682142c43a60f8927bf2d37cb25c4faf709066465cb2df7765d97d7ceca95391b28e37dfa87e66d8e9dc1715524d22ac9cf618b2427e3099e2574990760c7f729c7859399965abd3cf7dba2c0ad3962bac36b443d318babd6107a11285c79bd897d5145ae0cf3f6aefa7f36e5d28f386c9ed1606d6e61808e79417a38d9a79b03e42c3fa9de1adda9d592a1c1314721c9d24b73d437a94a03668fb9fe43c15d48c0096254a95194928a78843b03d341df7d547d60dc1c93472c31c521f6433595231dbf6cadd58ecfb51df0245b4ffb4c022a86ae2ad502d851eaea
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (34 mod 64).
# DIGEST: 137fc408ae1b3684a802229d78368f9fc2202311cd6f5da091b2eb998ceb048e
KEY: 7dac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607
NONCE: f00d033fb95fb09e4d00d6172e780ab8
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe
AD: 477e0cdd46be99371eb8da
CT: 9b6a8359acfc5d15067e2e6d812727d768f44b3edf4272f57fb54db41d95153fb03d7a7b3371e91c4be80326f4d70a8f2ac1e867ad3772901c513895e694214d6c0fa1f431aeb016ccc93faacb4950082f0cf00d3a5879c9a4f3fdb281e911b4e46d
TAG: 60872631a4f0e7e07e7ababf7c02aec42c1696e836bb12ee942e3cc5833f3b48366bc15e90cbedb280b01aad3239bdfd49faddc5d1b580995e53b6ed934a57252f498c199149307d63d0785de5cdd501c864cce15cb7b04b0187ef35b3495a164121f6c6773052990733f62842a6a011586182487394bc36abeed63663d0acd8a9c5b3dfd9ad1e944d179723800c1a04566b804b38b4e2dfe81d04d1f4ccc262a65033d83cf299e8e39184576c60c410285ffb46930812f6d4fa4e2f5043d3eee385dd473277300d1feb6e29f81f051f5fb6c28de99bb8445f2a389aa71c1fbeb3d91aa66596fcfd46b3ca0e74c71694a5eb7da4b5abc8cb115a1bc65b8faeee4e96392a9bf2a15914405cf563e35428b69b15afbc9878b47f803b8b479a
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (35 mod 64).
# DIGEST: ac9d4fe33627d4e9868c57a42aab21659ccc7efe18df8b57819b7d25e665454c
KEY: ac997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f0
NONCE: 0d033fb95fb09e4d00d6172e780ab8b7
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe47
AD: 7e0cdd46be99371eb8da7d
CT: 5818d2a656fce95d7a24bcb216f4d6b91d45d58d6ca2df5c9d6412d917951a9f61ff07fcb6b078fad69862aace436194f86f309373452e813c461fdb36a95f575fdf0f784ffa0914f0c0ee0c57ed1e604ca7a7a4b3d20c272b3b7f2e65b18c1a3fd191
TAG: 93435a8da7fbb8fc3baae118d82bea0df990cf1018ca14993d2ab594117bdf1a6b9ee715af7d64353d1afe398734f5d88d97fc9cec550e6bda06c31ef12f21ba6e891cf9c24accb264a771570f3773129a5fa2d78e5a4a1299bf7eb6e0fc4fcc9d4ea7f4bef1ff089cbb840a04e4fd81775a72278cfdb757c2b041c190a830206a45ab4b5e261bd65bb206f60c7290b6c15c3f04b5fb0bdc64f775d7b88ad77617da94228b649ad948eb84915970fce864f776541d740fb6491843e27088de5e7ad51b9e80c4f55760ca996631be10cd005146356b7754ec34b62a2e19ff2ccd8e4526664f4bbb6c84ae5595515a5c8ed312a63b983d241eee86511736edee964c12d8f5b2eb775fecbcca740c7c3b2024fd5a6652990b5e1a3f3cd7ab
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (36 mod 64).
# DIGEST: e59c699ea2887f6c829b7a0e895c45710aef6911fa3c930de3da61fc988e955b
KEY: 997deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d
NONCE: 033fb95fb09e4d00d6172e780ab8b700
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e
AD: 0cdd46be99371eb8da7dac
CT: ad0dff8adc54b5f02f428915bfa9f7277e4743e72e1789dcf552b91cda03bf52c757a9cca0655550c944fd264d287bc97d15dab3b986ed34637f45ffc1eb71b764cf5d5c1444033975829f1e59cb65ce40d787adc630e1f3155b2dc32733a754360ec1e1
TAG: 6a74ea2b3f209b6f81b27fc58b28585c7b378a9b11b346aa0f155a495e1bca762cc9c73a00796ef7fb398aa1229119d7cbba739c3daffb0f460c0c6bbfe4c6e99164d0b88d262a1ac5c050533db32f61c2e06da092e1e019e1e01dd79a92b9433b2938f89917846f7b04bfd7ee42bdab140e1854db8312f28af64c979360d89b1583896c0c592508106adee7144867c8300d36ddd7bb87482a990141cc0a793dd2e490305feb1b1c7eb9cd3e76bf7b8c767cf17a614d9c816abc8b6c8ddcab95f1dc0f78404704d77403a97f4547742c33bbadd1944e34b20f2e3293418cfd8faf2ac19f0800f6aef3ec0babe1d2a5b721bf3da4c23d80f74c0e157689320d8c1b517f3dc9619874e8b3ecafdad75250e631cff0d5be6e553120cec5
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (37 mod 64).
# DIGEST: b0ffb7b78f23593d738e845daeb3ed175ee48ed5ed2d827565030b047dd0ed17
KEY: 7deafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d03
NONCE: 3fb95fb09e4d00d6172e780ab8b70043
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0c
AD: dd46be99371eb8da7dac99
CT: 8a1448acbd769e42bfdf00ddd801153db3202daf5ba7997890f5f42a183d3a66faf66d899c7099fa99bbcf5b62b6adcb6ee87fafdd0275a8f625f3f959b0ea9acca88070aa9c61141787435cd60f63e262a80b6aaf931ba554ade7e0fb46b03a06a57db627
TAG: 3fd3782dfec59549a1f357785c8056274d24d4a9fe64a7fd66f48dc76f831901ae3b39825c1bf24b1990cdb264db072005f5c55c5543a65467ced4291297af0607420f4254947fcc514ed2512e0c678e4d51721b5d6c3536a3f7b57327440c94cd24ad71cdd2d7209a24a8e9402c7c07de667d72854b232f6ab97a44b736322fc9512ae432f5e55d4d1176b985ea0e6204ab2b9f94cdd63db5b0e3e0e7b79f2c1687a055e9345813c718da09a233ab50e054812aca10cf18de8023fd6f28d029b4f38a5c3122e539748c60b12075c0faee5209b346055dc8c5ccca9093fcf4d87a7a9917a34e39fbea94a8f8456c6ec2a1b4a733b562563c79f4bf944068188e099ccffd60c75b87ddf211d55e182f8821b5918654afea2fb66090
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (38 mod 64).
# DIGEST: e8928848fef7e0556377fbf3ed36b4105f334fa17bd5c5fbe2117ef82051903f
KEY: eafd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033f
NONCE: b95fb09e4d00d6172e780ab8b700433a
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd
AD: 46be99371eb8da7dac997d
CT: 0fca069ff1b260179dd5ff1124e557e97a4cc41e069d124cded05275d37913efa220e1ed4768bd04d8e65797040856b686cfcd5b772278bcf5fa64cd8183ba8b7724359804d609b31fc31514a4ed43d84de929d99e63f12306bb497e8ee776485dc822c1ea53
TAG: 447babe3275b7d8f53437e527fecbb6106e50e8831b2f5df5ee8067d4e3e3f9b320ca4b72a7ed1785a94f24d4c92916fd6ca8fb1f4322abe0152b377a5161ac5c3d2c0bb5912378184c1b19582d979d6ab88681eebef4ce6836137f03195b0b19e3d632009ed05cde65f6996686820632ef4c0845d282b504974ca5eb3232ad95fdbfff4229b8385184fc87d7190d17f68c274f4aeb3d07745f52d4a92a02c776a0b256546104a827cf92047138e641ad188e65649ea1c4bec3c61411d5f931831bd5b5ac45982baacece549255d1c102c80dcca28878b789cf76146ec44f68d8fecc7e5c4b7780ffd5b93bddd40185f63977299381833957757f837a297c207d93d84ca9c0776b1dd87c952bee715acfb350c3f435700caf824
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (39 mod 64).
# DIGEST: cfc1420c24eff01a9e6acebe2a96090e25738c3e1c14da2c6f36f9e20a857165
KEY: fd64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb9
NONCE: 5fb09e4d00d6172e780ab8b700433a95
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46
AD: be99371eb8da7dac997dea
CT: 8cacbae377d038fe27b37fdb253f3b136aa38660743dc6b4778ab16940a9710c8f08970164316e26c3b603140f2f43f62a88d021426b841baec29fb11a3d8735d0b8c14d133a825e1044be5523932ebd65b34433c083c2d77af313a240b1eeb59a73a2b7e05a56
TAG: a497c1ca95443d00804466d23f2e960a3ca86bc9688581f6f78734a7f90376fbd81d074b5618b6e4e19b091549f91d7acc16147d9ee30a7e51d528d8aac4f3f49d0afc542d2c652727fe8ead274c3178a83795aedcb8019a4fb9726c3f53718338bd279368e6bafbb4ff9bc5ff57662f16bfd03875770ca633f66c6def6cdff3070ea34e77ca487d68b4a5443e1ed81a80dd0a58c1c7f1313f6dd976c9fca2d378e894ccfc233eb99c0dfba33d95a3c29742038067089ed97c737e3137f28b06847e4147b0c2eb01320feba305c39f3d55747a74d76fb300c11bab7d216729be4f2b1a3a4afce0b3d2475ac26a2ea086a1b681cf1b6444239bd991aee39cb5e45fad5395ab17ad95c37f590dd49d8dfe19768aa86ef271fb81
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (40 mod 64).
# DIGEST: bdb122b808f40da0ae98fe9ace91fef7f2b39bc734f4f735f7cbccb2c00e4666
KEY: 64b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95f
NONCE: b09e4d00d6172e780ab8b700433a957a
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be
AD: 99371eb8da7dac997deafd
CT: 06b44584c9ddd267bf03aa311730fd0c4d3461678d94b4a794eb3e90b9cf3113ecf0ce0da8789d59bec50a1fd1e08ceea4cf9e00b2e0423706c126af7a3031df6cd82a7bcef877b413662e731b5a74ebf68f781eeeb79cf760cebda2c5070dfbb7c6d1ae6fa2a177
TAG: c897a50e7bb28f06a5d1848ef4ad3688639503d7a832199155e61da6784097c06d178711af2bf868096d23772256707fd05d4c43963f885e5037dff18172b0a89fd04392ef01504ac2a664b6a74c120ed6e50e1309ae47171b6eb9912e85e3f812cecd79b55d2ad7759043c5995acdbac92b0090c9503508febbfa8116cfcbff92a80618cfb0223819548b04acca6da9dbd690da34368faa4cc9058c177f16fdacef52183ccabc3139509620243baedc601758240f26fe58b1632cb21440d905cd3f6ce3c17efc82e2e167132100dc18eb4c92b62810aa8651288c0ab882815b18f75175d61ef47393913f125e37b9126d5d8dcbdfa6221a28683f6c4aa7628ee28d95e0a3815ef3e601ed44bea3be0bee95a0ca5fd15f28
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (41 mod 64).
# DIGEST: a1c40dc7a17b3ef6c9170eeaa9500014ef9ada833615b6d40af3fb2e14d7ddb7
KEY: b1fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb0
NONCE: 9e4d00d6172e780ab8b700433a957a74
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99
AD: 371eb8da7dac997deafd64
CT: 85da88e13f3ca14fc4440ffca7bc837818daf1dc52a4c505583edd070c7cbcdb4642d8ee1ca687037b08e1737a2f49039621823222f9f02deef2c340289af5184a86af8429747ef2f7d98d6aec2af060fc8e6895c2182bd1c479fc6a2e7ecc03eb4b03204db79e18b5
TAG: bfb333acf9be1bb3abd081f67f54bb1a198e007b1152a081c13cd0279770cd9314999ae438b54d9b5e516ac648fc0c83f3788a4a4f396a4a65517bf8499e74528ec72fc640f26dba748606e16f566017ccb911caa94a814235c1f08c080934dcaace98ec6220ddf784c2c281776bf1aa758608466561cb62867a1d165f3d46de65d7d3a8bbb36e3ba645b5049ec1760e80d114374a0a6c1628c99f5352cfcf397df3dbdab10a44379ad1ef93727191d076bbaf70de831e14721162e8173531efe43a2a739bc3c76359bbead3d5032006efff46ac2c7fcd48a8071c3211496a61f2a6de0d690de8338c628fb0e3983bfef09738c1bc2bbd6dd9c51613d15fe0c85c02f2f9560809894974ff005b083d5abdc56f5106ef04
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (42 mod 64).
# DIGEST: 677f053b9f421414ba91c060ec7ed66d27982e992da0372e5264898c9edd2bab
KEY: fc65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e
NONCE: 4d00d6172e780ab8b700433a957a741c
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be9937
AD: 1eb8da7dac997deafd64b1
CT: 10ee64784345c076e3f9aaeacc87cd51d6ee0b0facc9f40b4e6a1b4bec669ac3c5252c948b0c0a4d8e798248e6b10ee247e51c81793c2be91aa8c9666e0d8774439ea159e4745014bdd2e9f379ba461a7e638cab9ba2aba1498397044edd3f2759dfa56f488a0118e6c5
TAG: 3db7a5fdcdc460c6454407a23ea3d0a8b10439d34f66016049a07d33d7598f5debab758abfd5140243a129c0de5dcd36172bcff878216959047099c4675effc9f8faec3c5749afef3624adaf4aaeac2bf6b8c39119d10689de6b734e8fde8461da3f3e71030ac2dc83c662b646169cd492f7fc426088025f5812b73ce182fa9bd7f024c056a7ba3778b5b369c2ef437c9cfc8b25e9ee868ff17d64a814a8cbaacf9079ad75dc055bd3afc491331bfffb8a61c058012879be54680e44d01cef9a35c796dfa3cc450a6f69d239d1b4609917abec22d969b7e3da0a400f359b93c78ca4134effbef8c3fc63e94264aa67b4e98548d14c5cb3817f59de84dd54d8120b317f07a96115fb0d75ac600491ef781475e2adb6ee
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (43 mod 64).
# DIGEST: 9c1c2b1853244d015dde7f4068220d7640501b1aca325b82c1be8c015b61e59d
KEY: 65de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d
NONCE: 00d6172e780ab8b700433a957a741c9e
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371e
AD: b8da7dac997deafd64b1fc
CT: b90220b919dd02b216aa2eb7863372a645b09df88645dcaf138fb73d8896e39aac5a1c2f0535385e15cb850a6febd5d6ea9f3fb573944cdd5b30cb80aff6b73a173ffd7c85673248fab94e3b9544930cff59f52515dcc8ba39b6f51dfd0487bc9f8eb23b031c3f6d70b763
TAG: c9d421b4b147c4392238c3c6e3bb6421e47773160722749bb244efc4a9ffe3a55b2952aafce9bf5e46d29f9d916c582e9ab426f60258bcd75c96fb4493fe0923356d7647382e103ea4ef363ca1a063ac89ec2e1ed9c45e84aa8d4e279af1bf40ecc0e5aa8a4af86b7e7390ec15852515e28bd8ee956709bd90172d8d03624c5a81dcfce21b573e1063d416ed59afb316a4a7fd1d22dfab206473567ac0b94aab64b2c201b84f8e89a575c5d1510cde801dc4a24b7537e062d1caf08f6008f2f14424edf16bfbe3960a857a2784ea033fad0ecedc84a917405458dccb12a107fc7f603565eeacc7573571d05483ea8dda7519bf10903b9ef9feef4ac6682956b193e2201dea4150b5aeb6c122cf4e0a854673736837
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (44 mod 64).
# DIGEST: 6bfc1f2aeae329867e5d7f268979743cf267d0dd73b7882abc0240ea586b21fd
KEY: de39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00
NONCE: d6172e780ab8b700433a957a741c9eb8
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8
AD: da7dac997deafd64b1fc65
CT: 9807d89925c67a45c8ba18cfdb817f5bbc21e58c10f7dc8c15b70acd97e8b97e0393d5948d51a65f6f092590b38c845164e6d2b49288bd0f73c4f4b551b362470638f51422dcfdaaff5e8aaf80ff715f3f597fb9385ca18355b8e98d1de17a302b81470c8e64a2443883cb88
TAG: b90eda5e4260d45f777533784bb41a3f580fecdd1c088958d001c2a34b3f19ff6edb5176fc369816ce5a3dc30bebcf6c727a64acad6e390588789aee7ec9371fa86589d89306ecd74b90ff8811b6c79a9319bda6fac4317e10a756044e97b68c47a63af7b20984d58d9e982ba135b620eea8b84fa0e4837f935e847a85b81167766f9bcba496f54d47652076e48c96aa2c723f52f1efe6b8188bec0c53c71c4a27a39a25d13b7fc94f44babaca1676d8140509f65983911a2aa09547b5db116d77c734ba30e766101b5efea44b1b425b6af818c1583c5e3d24d517b4693d819a1eb7f85c890b1cc560722faa2170ca6f7d426ead202e9c3186864bb4fd21db770a972bade06e4968caf0f06348dd00608d074646
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (45 mod 64).
# DIGEST: c1702d4f70a18932e2f4d3951603ed904588a990123e0a02d29d7259afeedf69
KEY: 39f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6
NONCE: 172e780ab8b700433a957a741c9eb80f
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da
AD: 7dac997deafd64b1fc65de
CT: 8d69a3691570f0d175aad5fb77a0e9abd3f882b10355a08f0160c113096acfecdbc4ac32f037d16c2c4dda4bd3325c8690bade6bf39b14435cc11ff575a3d7e9f7b09b5b40f9645d9a5dfb44f42304d82298cdd866e957d4ab64374ffb86879ada9fc8d6a17a7ff1b06cf33529
TAG: 1355e78bcb4dab39264351b32e7007598508d90f012029967337855deed8787fb8907de3958efefe76d5373c1834d53e506d18ed9a60578955c019a04fbbbb9ef011e6c284734f28e4d228f5901c163145257073d12dcbbad11055192c4d4781e7385f892e4d712e5e265e846d19712159bbd7c7bbee86f2a5201569018c7a4bee87a9f12e78472183f748f72c53046529394b5793598ca555d00efe86f582c6baea187cd47216cb02c6452429dc70f0926dbff7d6cfc830134da8073f2a4fe97ea612cbfaff430d64f7e111291c6abc02f6443230b492c7acc794c22376be011b1a71b9665657632e1354f49faa097e381a3fff3b1c355aff053dc7c2fdbdfd8279b300b1e06d6f6cb6170429f25090c78ac1
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (46 mod 64).
# DIGEST: 09ec84331099e1d602d0998d99c199a6037255a5a4d96bb3af54cfba357bbbf1
KEY: f4f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d617
NONCE: 2e780ab8b700433a957a741c9eb80f2b
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7d
AD: ac997deafd64b1fc65de39
CT: 26d675c591f287b26eb35f87231624e454c4aca1f25491b74a252e971c48ca523b353b4f6c0106c1b3b40182eddbaf7ba47263790c3b22d23b09458d48868bb18b2fb01bdfa965f7c1b211fe02f9b78959b71e872ee05ff3baf548a85797270f456c24459e019d00f06b8a73aaf1
TAG: 11cb33f42c68fed775b06e02f9dcb709d62614f7f3b74d8b6c429b10d0f3763d2036a18e502fcf000e9f831d01588656c5be6298f8d6b757818edde84acbcedd0608a6a36c1d827f750d7a4ef5f6df6193a620ea2f101d2b9aac4ce02a4bdde76d195cc3641bf1c0a3242e95ce5fe82c653696cb753e0cbc22bed985a860615b036ddb30a4c8c0f0ec22cb94ce3b792c9126d283eccc7d42a92c57ac389eef5020b1c1f0ca880137d21fbbe99ff07ce2317bf608ea29df9ee4179fd84dec1f9285a1e601186af282030a68a4477b59c9153d8a91c08d6e94c0746d641f9b108cec371c32d9c6068fb3f05131089787a0cc113c32403cb196dc4f98bda7460403a7f6ab6d8162ac4679b531dc266297c7a132
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (47 mod 64).
# DIGEST: 7d506a5c0299a82f5f93dd69526156e0de9aa5cf94f9fcaa12064ef920a1c5b6
KEY: f03541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e
NONCE: 780ab8b700433a957a741c9eb80f2b02
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac
AD: 997deafd64b1fc65de39f4
CT: 9c61bfbbd3e8395be166b30a56b3e192748ba3bbbdc334dc3720206ac10c90dd777aa4957695bddaea0b7e554951c94f2f74a2bb7547ac20a7e357fe249614204401144fef61394c140553d5566c18ded15e0fa50fd5836cb725d277fa46210e57fe3c24d3641fef78c33a009fcfe0
TAG: e39c89ecfffe2aab2a48fbd01a8b58895abf2bd66029bd5ce1b539c46e5878cca37f1c8031c8a820cf0e2500aa2a2c65a4974bc260c949d91180d660d21c918415c5cad09f1c5561bfb21f9f765c5c7f60e2c4352c0d90cf1266fca704562d003132e3b1690ae9bd9ba969c469f8d43c821f92e3a622f25d03967127a9ac4c3b2a62956216d525216ab6082fac62c80eeb993eeea3f966952065cd2b1ad1e9bbf4d27d07a377d363d1955ff2e8bad69db97c1fe49e1dcf405b73eedffb9c5992015b56073530d68503aae7b6b4ed8df988253429e900ad63f7e925e415174b24f724c9df43e95ff5b96a365beeecf08fded61eb6c2219bf4102351111231ec0c4fdbae472892eca04c91646521bd2ada50
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (48 mod 64).
# DIGEST: 5e9c0270955ffa14e3383a79a1cfef00baec4e8be496c867cc14dbcaf609b61a
KEY: 3541a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e78
NONCE: 0ab8b700433a957a741c9eb80f2b021b
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac99
AD: 7deafd64b1fc65de39f4f0
CT: 174bb28ef8ee033bf0f39cf6a5d3c2157ec773078860232827fdb1c875e9622e198a00a50fcc03b2cbf1e4a747efcdecda8b612ec3ebac650a7401b4b204185e4b42306d544e3f6512b87bf36b5f55ec0bb4da01c36aad92a16865cb852e1a5d1a86d3d57e6336d4376e8988f00162de
TAG: 0e7f9138058d2a9141ce79d896edb6f752349a730e9b9de2edbe431d9e3cca2b617e3611e84edf9c87917806ec955ee0bacc7474224d8bb364164127bbdb1b1560130ff08004ccafab3af0902d937dab57a572f08179771b00b214ad684b9b939d959b9b1e980c5164cbc56a4432c9837b154d2ca86b0c7882cf1c631602e8054bb07665230f10259ea41f812454eb01ae06f5f923a01764f29fb130e93ac4156317659d07e5fdade989a8e1d86dbc7033c7898d34932d6165e12ee01110aa86031812df4d79e6abd101709c42aed2b8eb722507f0d282469e6bb1db4dcd23ae4c9fdc96fa8c3382150a4798cfa9900f4a515d858f82ce1471723b4a289904143e34b892f4c8d761de9c0c0ed11f276ba964a734f60a1cf0a5415a0318473d2c
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (49 mod 64).
# DIGEST: 57739c0c5b8e1f0255bb93eb53822ce8688a4078d971c0a51e757a0269760bde
KEY: 41a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780a
NONCE: b8b700433a957a741c9eb80f2b021b14
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997d
AD: eafd64b1fc65de39f4f035
CT: 9b01cfa97c72b5ae8befd0d357283a52f6b8c5d9292d28f61373334280f815d6b69f878936738cebaf6fc84d20baf51868eb4d2ae08d64e724beea1887a76316acc955a00b5d1230fb120bf7d51f74fdc5f332521c59406bbd3161987c6ec49ad946a6a51755796de19830631daf69c7d9
TAG: 37cbf6f77fc5e964017bfc5582ba07d6b111668bd2db6aa7273b6cb35e6c440397401307fb7f979b6cb39cffdc26c3ef3ca83a11c0fcad66423677bc0c459c4448d87130c23e949561dfbc097b947832104e38dca519416e9ab9d98922188eb9fafb20a771f05e0713a56e47dfe1fab667c2bdc23c6287ef14c9ca985082ebf601bd18128702c54b5fe221040306a40314c9be88b86fce8887e465e9d2e062a5236bfe6ca2914a9f0aa5c43a88a7353761e10516c27dea9cd619a69b05e6287c0e8e28e2f5572c1a48884e9f8a890e11f4bae1be67beea5efd34cd69ca5e17ab7eee5ee4bc3af28a6e49bb47a0bf4a9a967bdf14054e54e9e8788e3ecaf5c4e8d5ee3e3844e560f5056503788810ba1aa91f51d47fea9ba1b276d83b0ad78c
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (50 mod 64).
# DIGEST: 0ec4072fc3c850d4ee958a0af170d5aabd223b024c617df36f4ad245d0304c0a
KEY: a11be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8
NONCE: b700433a957a741c9eb80f2b021b1444
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997dea
AD: fd64b1fc65de39f4f03541
CT: 0b0133ac614de667eafb516e1fb33b016a8b49e558f335eed239d50ddd13a4152f1570269615a243502fe1c6db0667a2de7975120ef65186f5af83821598ff45494e943acae24a6095ad46a498971f7b185d7784d451b1260ea478c03babf0e582a8a777cec20905821267eb85aec1a2ff29
TAG: e275096ae20d00bc4a15e380c877226c0b2ca24ffe959b13bac702c8eb499c2668abac60eb58c7a87c3f8d6af3e659784b87ab549ea4a1b069dfd5307a46aca1617019e262967c9e92affb78af2dbf7e8734a736263def3b210e3cc1cbafe1f652d427aca9220fecd8cbd5be52c711bf5a8cc9434ac1ff4b9c54965e477af9366830dac8b6573f969d21d989ba454b3a1439ba7186e4793473df702bcb9f191de383cc4447c07204d680649712502d1122b4fa4c7f980c453dd3b7478695a8cc555db1f8c7cdf1e41c9ad40a67c35f753a0318127e9be4225e957d3b34c625f5e5bd475d0d8dbb9bdd8c22336b5a70509ee2383e4142eba73748e1d9cbc1d361ba8e27e2cc33bbf6f455b876813aeea97ccc8c2d51ba96f3fb2c6b77fc4d
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (51 mod 64).
# DIGEST: 640ba3888e6cc260a6022fb69dbe5c5267dc8604aa92216e11888394fe59d292
KEY: 1be112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b7
NONCE: 00433a957a741c9eb80f2b021b144476
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd
AD: 64b1fc65de39f4f03541a1
CT: 8d5b92c78a48ca6049da6a036735ca23b99f9c3cfb97122312e5bf0279d094cfca0b976e24f6b65d81f85eff669da35486809cbfdfd1fd615a5347947156148e6b71a11f7bec611e7c29e19f6f62f94bd7f8b89e54b6945dcc1a7e380e51456a31f1d511bb92443deab5987c3bba2663e44640
TAG: 7acf0a75baf749f03853423ce40ae4561a255e37361b6c1d7112ece841573d869f21625490196ee94935af6cc3cf789cae11eb8d4e4919796eb984510bace170f192626127324a5defe85e0a226c8376f952528151bc78f33d093453fda77dfda1e6364cbcce001c22b3018689cdf769580642616eaeebd22345191c0c30b6e7a07a83d333aed065b0fab2c9c40e2cc08537afbf8682d434f5f9538292d7094519bfad7842b0c708af475b43770067b5b86a9178ab148e5d8c0815cf4403f6336d66079763f4923b12a53ec020967df5f1a416bcbe2f851af26f7eb79a26946fed4fb3586f6f5219e1a995a5e11ea22dcd9b78867c373d04d17241f19cf705df9cf57bd58e38952d8dc30d262948dfbf00f8b4b4ff9f7d7dd3f5fde29f
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (52 mod 64).
# DIGEST: 7c10e4553a91588e2c39060e9b438736721926cb7bf53858293ad763e9b70fe2
KEY: e112a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b700
NONCE: 433a957a741c9eb80f2b021b1444769d
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64
AD: b1fc65de39f4f03541a11b
CT: 997bd62c118718ee23b9d75f5ad15bea914cace8858ccf9534ffc79a626768802f7e86930243b3dae80d38782a6a61429cf0278d37bdb60a0ce3ea74163ab77eb299285efafa2895fac6d7f2ea65b35e579e07a7a6395e2488db288c415b402a913d727cbf3df623ae4a205d9867c59658d48c7a
TAG: 6cea3ef5940f79c341e22ca98771e1f4a27dea38724916ed5027d2747056a192e72ed7bf35cd1e3d9a724935bd778866a7454ee24a7d9ae6781aaf221ea99ee6e61d72a8918caf36d30d5a190494f0ba02ec3d96b4e9b12ff747e0f1c98ee1483ca32cdb68fe1312ff5f0f49f2e8e89eba814807cc8e44abae69cdab9d7ea9ca0b1a785b743f9fa4444c23e29fb77fa5c329941ac842b47c8b052a26e59eff599d1007f9c2a037c035c475134d272abff2a4fdff42e561afc2a589686be3eced7ab14ec72400dde1bca8738605794cdd80688b8caf366f08c0be0f200fc6fca9bdbc8e5ca54d75c1d02832d8eda711e4a4db319b622cb1af0ee8ef22d88d16e4552fd6a38d4f8517db6cd9ea6420c6d89b99ef60f87e43a0f6b3c63a
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (53 mod 64).
# DIGEST: 0e88468ae741a9ac1114e212499c092ba60869973f2cdaf456ceb336ad40cee9
KEY: 12a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b70043
NONCE: 3a957a741c9eb80f2b021b1444769da0
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1
AD: fc65de39f4f03541a11be1
CT: 6ddfb308153a27c84009486ba4794d3ae0367fe3f75e289a28e2bd79af4ac294827e034a8957cf3727463c10ebb82542a1a84d89214905da11bbf882b702168e670725717f360b255b6b1c4035c0192b743e62c20545f6f8706010fe2fc8ff25c7ecbb2184460d0944c1e29f66484c450b2b06fec4
TAG: d15b520c601564fce30151843ef4a8bce43516f2ff8acc27920dadccaf244a659d6ae5fe5568439d8af51273fac3982e690127a424b82ea2c5accc995c3002d70b6ccf3d46d86e4a231092b0c2a2b3fd2e9d199f8fbff1c4a2cdaa03ad6be6def2378c8991edaaee10c27347cce20ad1576f664b8cdcb3815416c89b62a3bb8477041bf3d070f2b862295c6fcfa2066894bc573858ea750607e0cdbd2a41771664b0d35c7b7cf9144e5802252b26cc2090e46887c2836f2d1a8bd4d82cf00915be9af229081d9766b95215c275271b2ee52b16fc6dba1ce627556d4749d058de8bb849021579c462f918cae2f4eed68ee4447100dbf246287022fdeacfc9599296b9ea3adee378f0743a78650abf652a78fbdf1ac7c64c844e115c
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (54 mod 64).
# DIGEST: 4bc1f00622d792e473151668845b2ffb30c43027972bf59ff86ce53a380f2aea
KEY: a72933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b700433a
NONCE: 957a741c9eb80f2b021b1444769da00f
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc
AD: 65de39f4f03541a11be112
CT: 452c39f1ed638a315dd21cfbfa383115d3345ae07f9968f2c30e47a05891ceacdc0f3b4669c929765f51f69c0db940b6ed5d0266894292e57d04c2fbb3b1fe2bc3acb98f87974341ed985a151f82673c237d101161ec73bdfa6144198a83a6e7ce8866b5fbb7bfdaa908dfc2fb15b9175ae8d6cb87f7
TAG: f7a43f52963dcf384be1ab05d5c76c82b0c56ad9cc7b75e28f08422429f128acc6768d744d05668eae006037f8f7e868a3489d746f5c756c130c910b48cb2572e351b38f89b9ef2d2b4b2a8890b5e3084cc630519519f3e767f284f060e04445562d201b94b5c07938ced76cb43ea1f6497fb86751f3cf76d58af9d9b32e367e012202f94c0bacdacf632c28c3f5d1623031e3695b7e4d82799ba9378415713cf3837e6dc815895ecfb6712207042ab4ad7afab51677b4132e5ec548346b062ae85eb0fb0e1a181022cf06edf4181aed1c28e3c615a11c825f70c182689dd401eeba16f021efb28505d570cf461237710533e101991196db42b2c82d4063377c3013cc2e2be6d8e544d44678eb80a137c7ff63377027f71d1a20
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (55 mod 64).
# DIGEST: 7ddb9526ac0b917c3d63a2c0a4cd720d4814a25e29c34a5b203d8aa4d4e0eb00
KEY: 2933c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b700433a95
NONCE: 7a741c9eb80f2b021b1444769da00fcf
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65
AD: de39f4f03541a11be112a7
CT: 8aacfaa8f3562d65f4ef8490db090ba2c6a4e80b99fdf707317a66b871dbfdc3a99d04229410d3e7e69325c62aab79ee16e898c32f56d3fe6edcd636291f195f60deaa0deb05b233f25530dce9ffc8e7a75de992afc6929e90e53093758b94038584acc9f235cc463722a18d0de99069c086062de66b39
TAG: 6031ef2bc636aa219307178d4e56307079c664416b5abf00149aa8040229322a006f6c621628e371d85d733037069df7356b8800a694d5c964f8321f250088f1d10d8a967b8290c9495c75c26d81ebde01469f46bb4b39934200b3da55f26847ed74dd5c26f641b9f48331dcedaaba9216bf4a9329022294e2c79b770ae73ef355b98ce6fc755c38e24d1782a74764e3720c01342cc07283d8925789c42a7f29704437476c1d510fb04c16e9e5f89d824fa861b05c9a18e52a8435e8b6aa8abb22a9a8ef48ab8cdee50636130a63a05dbab01908d12f30ec71d8475f54af9936c00d1ed3d69be870f6dfd10542473b472fae1171e8dc2f66643ac3720b8931a06b6f460b76f63fb12bc2d82acd6180d8f7a3340ab84c125b9f
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (56 mod 64).
# DIGEST: cf85268a8412f6a450d7c8d48a2e744b508b00017da678e76cac09902ca6b0ad
KEY: 33c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b700433a957a
NONCE: 741c9eb80f2b021b1444769da00fcfab
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de
AD: 39f4f03541a11be112a729
CT: 1425f735d28f545c7ab1627588b21089cfd0641b2746bae57d36f0286c43e9f9476f47da0ed156600455ac14c65c5f2999e8aac4d99f69a0deaf7ea1653dde591fe26139e30f64ba29d0b11c7853938d86d801e721ce7ec81be6fa8b5f281d31b14fe3388a028319f0fb12ab50438a3ecc32ee959cb5d393
TAG: 03ba0e494d4f1f602f3554bf4888706d6f686c9e04a1189d755a8b43f41abad6f5abac893019a9c3fc38f17a34b5b257107206d04a7a3d2afbd3cb03e5f10f2c79c5e2b18ba925a2eb112eea5477d9b862bd7323d0275a24b63675ffa375692b4a9237bca54478ee86981acd437ed1e4e2d71508b39c35b3ad3633ec617ef2d35ee174d52946a3018674eacc4dd64e705df60203cbfadc3b1f21c80a562cf2f6c42287e5df030da4553fc450b89e908ba0a6beca9c228729055d875f65c1313f5356b63a986233d10b5a00308ccfd8b7e1524e1b96a07afb980e8607d9586bfd0c50098a399fa12ee706b26eb1df88181103c2828710990c311ab321ccdabe2406c6acce5ebde7c10c612fbf6397a3da38ae1b016208eb9d
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (57 mod 64).
# DIGEST: 0ecc677bf17604e63d1e4ac4a1d56702dfb16e205af1da5d105d553e87d14680
KEY: c7b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b700433a957a74
NONCE: 1c9eb80f2b021b1444769da00fcfab0f
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39
AD: f4f03541a11be112a72933
CT: 368ce97b3b9c28678363cbcee49ac8474b6a12ff63d783060a8cb33ad951edd059260c4927d5bc2ce252b4deabfd902ec1025a8847bd6fa57324d1d8cdad0f23aacd338c8162f77024291f106dd73b1dba3746e7a8dc3c3132c6edf1367aa576046a7d537df7827059b25e469dbb6aec50f33836bd166761fa
TAG: b69fa0f760a7bd618bfd2225597444ba67a29e91a8bf110dd8cba1cbe05d335b40a51b1626c389046bdd3cd6f4211e127c58fd8b2fcdfc8d137652a8e3bbb7e3fc6ffab78b6b3b95ed52cc9884a5362339928db7e8d85a83dcc6634d92ed8df610885a3ba813ce831eebf22358d1c46b24cb89ccddf41ae4a4166eb9d48a62a6e3da218fc992a87154280093c178c3fb86133cd0427e8a23338536a7c6fe2614002e5a7765c49ea08ef1cb816d74dd7f6460a674f82e779ecc4d1346e6367b8e06586a1219cabb6e73de95c6546f7472bda8f17a2fa3462e1356d64affde34dd51c2fde2877ec1479030f38418c23c429189c16d38b2be3726a46f96d0013378b7a6418c9a29ce256fb50f991f3e32810c69e34fd73d9b
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (58 mod 64).
# DIGEST: 75073f11e219dda101a54987959be5353c48af4af654fa6dd23e32639ca2ea1a
KEY: b54ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b700433a957a741c
NONCE: 9eb80f2b021b1444769da00fcfab0f5f
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4
AD: f03541a11be112a72933c7
CT: f48fa6c6c0ba5d8904335d29ba3c5ec00b90041b67806c726a4f3b88c105db3b373499eb79f0ab9e348da562828ffd75369c90fb026cbd76cec6666bbd61b74548fdbf7f44c45c127e82dbb690641bdc7e9271fe154f6e148c0831d08ad7fbd38a4e3a9cf47e0d4803b4bb045e6808b228d1a8605661c54ed964
TAG: b4e59c14bf8f6fef19c49bc43295dcac4a43bafbb931ea101cb4a5fd7b3d14ff22ca54c5e0c3ef3317314f7676e327452bc5e46216f1337fca84e93de5afbf3d50fc3466e5aa3a23772fe9fc05da1fdb3c5520740b372733ad60dd874f592fb48aa9a2583ac61ad50bfa680f029b0b31cab014791e9374076e015995dc64b403d0307999cac380237e2063730356767323bbd11e8363876bef0c390091cd2c5a4102f08d15f4aea5761a8576b059ba59f6403b5f286d370f987a54db50b464af74df3c53a9e90f1503313cddada7719c2e5a43db5b94ac79f51bdd0747bb38db9dc38261b1212128b7acbafdf4172402b64fa9cb9fad382dbe28d14d0b40957c045565cacfdbbaaf0b0332ce1f67ee60aae09e29832c
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (59 mod 64).
# DIGEST: 7390da1949a9ec86934b6f6c7af07d60fc37be21edd0ba9d937e888402731c54
KEY: 4ed4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b700433a957a741c9e
NONCE: b80f2b021b1444769da00fcfab0f5f93
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f0
AD: 3541a11be112a72933c7b5
CT: e4879e4b80eac7bf4b235ee71db7af4a9b68cd4151d92ec1d33476595c714d4c6d97810f5c88c7ce2f45b181cb0a20b1969c88039248f7fce86f7f9458f51b726faf05610b76cef8afd0855a658feea188abdd705a3de0a655ce2e9a54617d8b646853210dc47dcb094c1db4c198cb1bc55147837b1c0bba9822ba
TAG: b82121c2929f5c4caf4220dd99bf0836b91dd5db0c753d8c6c88dd63a4964b60896712d926229acd3ebfd86d40aac7b8045739a6800284a57e4cfdb9f1d58782aa709b89f529a4b148e2ef9f4772bd57567a0b6f331b800e8fa71052eb99aa64efacf5f7060dd42b7cc653df1d3b784befcb1069bd2450f6b683c91ed7bb892a3f637587140aeece58cbc1500a8b93e86292062545308af906ede1f999bf1ac3f99ba5384fcef40967cb2a50270171cbf45cb5aa3b04fcb33ec022d82254a8852bde63db56730a64c163a017c9cac043ecbe2847ff740d768c72894311c210c0959a737abe70c1e20353c0db83dad2c4bd2d407fb389351381381c3bb3ccabb5d571f550c148ce940c0c401dd21230467dcc06fe44
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (60 mod 64).
# DIGEST: 174d05b7079b80d455325eda1a010ec9bfec7110a14120c6cfe365d270099069
KEY: d4fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b700433a957a741c9eb8
NONCE: 0f2b021b1444769da00fcfab0f5f93b5
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f035
AD: 41a11be112a72933c7b54e
CT: e067519b3b6b3271ec55bfd3b68ee9c762887b3eb80cd4f65d3267fe3c6baf3b83620aefab953b7406b7b8cc6fd5e8f8180af789d3c57c55d580b00ea780cff26f5758edba93b7a08b2292104ff11e4743e404f04055e136bac3300170b0731c35bee9de79de13da8e24635b882b9f7c85fcd6f94e310fad8d27cef5
TAG: ecd6d54ea9ef0297664a6f0c3ee972e2752233d0fe4381474bd846d99174f15e7312bd2f58547a9e8f301c8ba706d7bd0bb8b8a3bf16821d72895af7787acdb345c9d0f58171564995e53783343e782eefc468858321350c6c8f0ab1918eed7b01eb0265749226a19221f57818af356a3909ff17daf229510acf26b07273e21713d0ecb8f8f19c6c1679377409c4dbe2bd04de8c6546a6e6b00bdb72613b210412fe79998955e0de4e04a6a113243051b1e2d3ecb0a8beecb32f0374f78c804b0818410a12a12db227d49fd7107c02ccbd6dee62856cdcb49354e96cc434cab526b0cc4f215dc4c8e2262bc44e3c1a7fdef268d03803d1766c039d576c5799c4ebb148ee655daf7fd8e9632f90dd88b5cb6f4145
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (61 mod 64).
# DIGEST: 338800a96a5cf6db2ec5d06de2a53d0fb1b94918f1f8d5c0f222640d4c1bb96d
KEY: fad0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b700433a957a741c9eb80f
NONCE: 2b021b1444769da00fcfab0f5f93b511
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541
AD: a11be112a72933c7b54ed4
CT: 9b5f06ef7caa30028667c9d88efe9069c214d2244ab9b30443691c7298ba292241099693d831c5bc50dcf8a7eb983df8bd7d91497d8e6892e3c6ed49aae987bc5f047ea53b3a44960b469142662b1d0aa726b99170cf0c0edbbd2223efa7fd3c97afeeb9c50ca0a8074d2d339e8b4ebc0def814188cd87dee400b23ba1
TAG: c512d19b8c661985b1bddf12672f3ce85664c911566da59c3d0f4f8f044fa5fe6200371b1bbcdef5a5771cc7ee919e36c6b0d035e9a8b518be4aa8464ed8eecaf4e49d3270080d0b29589309fabc79fb533efdd869e42b2f3fea9d78756c266b245b4a37310eb1cbc24a878441b7701a813cdf7692a1fd2172001a90346c7a80b80ee21249e45e1eee7b19472987efcf4335f8b0c59c2ec21fa6d52624e7ebdf5a2a5d595a098eb56a6ec24636b021b5a899c27868f6ea549cce01a64af21e36525ae16e54700e9b9f57fa61caf0fd49a2c948b0059b315592cf52d5976d2022e6425ba227c9d9cf1d477517b5d25fdf33f6f719c2a6f91a032c5745477f53072c373f5507757417f26126b156ca91500325ae
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (62 mod 64).
# DIGEST: 6dc3a2d32318422ad20e9c7b09a9a73d8608a326eb14efd6eb52b87ffe4bad09
KEY: d0be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b700433a957a741c9eb80f2b
NONCE: 021b1444769da00fcfab0f5f93b51106
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a1
AD: 1be112a72933c7b54ed4fa
CT: a7a27ff44599a6263753294a057c527552f4659590b97b9135c74da778a88607d0781df713f4e0d72d044f0c2c7daab6fdcbf162cd700d236999e29c25be1c599b5b5941c774432494b848f6d862da9f95d28d132c7333a4ab436d5488466ff8304415494bac0a922c8aadf885ac23dbdfc19a0311857d4d58d69f714939
TAG: f18f948248b93ce700f586b0d146f3156b4135696992754f1b8d15fb1066b23b63006e15e5545e7072a8d7701b259692e6651dbf00692201d981bc0bcfbd7896ae69fc0219f089ec44cb737d07c25dea40c029a1146c062496765b002128a8b0fc1d11795e908aa0cfd095e96dd84c3a205db31bc1547aee7b31fe35eb388e15f8742e9c6aba30f7fab80fbb794e31f8801ed5aeb125826b545ece1440c33b3cd5f7fb4a422f456ed501248844da374ca8a033b541904c430ec09f0f72a53d458519eb55142156c823425ed89a64a5b0e5d20a1bec8d7146e62877daa08d4164fdedc5c85d93c4b1cd914055c6a80ba366f8f8739fe377be0afe56d198e96970d952d694cff07c9d83d9ef13e0e135d4ae86
TAG_LEN: 32
NO_SEAL: 01
# Test with maximal padding (63 mod 64).
# DIGEST: e2c5b8d5e6f07c136223bdb8a1c0197cd99132dd8320a3f1dd1a393a90e575ad
KEY: be905d41203f5dce998f8fb2eaad409ae02116417dae0cef457b9e5e16dcc5b6f25607f00d033fb95fb09e4d00d6172e780ab8b700433a957a741c9eb80f2b02
NONCE: 1b1444769da00fcfab0f5f93b511060c
IN: 936a91d0b5d2c0267218cb7090c6171386d641b87797b684e0fb56f97c3961d8afa22993a340b9b3c589c7481df3f4183aa23fd8d7efd88503f78b8ed1c8e9ba2fd6773e0d0c302a5f47e037446f5891d77df660ed82933f62be8dc55b436965aabe477e0cdd46be99371eb8da7dac997deafd64b1fc65de39f4f03541a11b
AD: e112a72933c7b54ed4fad0
CT: bef9d1b0ca29860a27227b7d32af256a09503a9febf9c1124054533c15117d846447e74f8963fe6eece8507f168adcce0664448a4c499b1db6d0d0a57eb9b4f86f797f2defefc7d9f3b5883758ffe189b6f9fd921eaf4a4d6b7f445e5c871c7fad06031e5a5efe9ad995b5e0887765a8966f27680ac925884d4850192214e5
TAG: e23947c16b562a55cf3b68611ca4d729dfd0b33405313299329e4eeacb6a8edbc64ddb87711bcbcf11c72fe70121557f1a0ef0512f606ce8e3221afa9fdd6b23b8f7bcbd9c296bb48821104f2701c6cbde78615c1a90adb1653f9f559d4291a339c385f9c26a29d37d923987226522cc939053fe951ab61cccb61846f89f0a4791f30166d5d9a04821b453917614a36766fd78fa099ae22ce788c44c0980df3a73d6ea2306dee86866143f8203357db580c00d4e4dbdbe9b53c37f08fad9736fca2819b52728849d9e36a0e7d75dbc48a7347b70cdadfcf8a81bf5734faaf01c795adbcc0340201402950b072359db8fcc5d7b68d84d59ad34bd20c3a9b529e397937700fbe5817a8f1c997cb0fb7c1d02
TAG_LEN: 32
NO_SEAL: 01

Some files were not shown because too many files have changed in this diff Show More