diff options
author | David Benjamin <davidben@google.com> | 2016-06-09 01:31:24 +0300 |
---|---|---|
committer | Adam Langley <agl@google.com> | 2016-06-09 22:47:44 +0300 |
commit | 1a01e1fc88968c4db023f38967f9e81a8c42a15d (patch) | |
tree | 3f959639178b1fc70317a5bce980df40692156a0 /crypto/internal.h | |
parent | 67cb49d045f04973ddba0f92fe8a8ad483c7da89 (diff) |
Remove in-place TLS record assembly for now.
Decrypting is very easy to do in-place, but encrypting in-place is a hassle.
The rules actually were wrong due to record-splitting. The aliasing prefix and
the alignment prefix actually differ by 1. Take it out for now in preparation
for tightening the aliasing rules.
If we decide to do in-place encrypt later, probably it'd be more useful to
return header + in-place ciphertext + trailer. (That, in turn, needs a
scatter/gather thing on the AEAD thanks to TLS 1.3's padding and record type
construction.) We may also wish to rethink how record-splitting works here.
Change-Id: I0187d39c541e76ef933b7c2c193323164fd8a156
Reviewed-on: https://boringssl-review.googlesource.com/8230
Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/internal.h')
-rw-r--r-- | crypto/internal.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/crypto/internal.h b/crypto/internal.h index 433072ce..54e78d52 100644 --- a/crypto/internal.h +++ b/crypto/internal.h @@ -152,6 +152,19 @@ typedef __uint128_t uint128_t; #endif +/* buffers_alias returns one if |a| and |b| alias and zero otherwise. */ +static inline int buffers_alias(const uint8_t *a, size_t a_len, + const uint8_t *b, size_t b_len) { + /* Cast |a| and |b| to integers. In C, pointer comparisons between unrelated + * objects are undefined whereas pointer to integer conversions are merely + * implementation-defined. We assume the implementation defined it in a sane + * way. */ + uintptr_t a_u = (uintptr_t)a; + uintptr_t b_u = (uintptr_t)b; + return a_u + a_len > b_u && b_u + b_len > a_u; +} + + /* Constant-time utility functions. * * The following methods return a bitmask of all ones (0xff...f) for true and 0 |