external/boringssl: Sync to 387b07b78dac785a341eeb2ff86e29393ffe8627.

This includes the following changes:

https://boringssl.googlesource.com/boringssl/+log/df11bed9ee05141b54da7b88cc5b7960ca858164..387b07b78dac785a341eeb2ff86e29393ffe8627

Test: atest CtsLibcoreTestCases (TODO)
Change-Id: I815f6f838a77041a4b71abfa2a03d409f106e71a
diff --git a/BORINGSSL_REVISION b/BORINGSSL_REVISION
index 6b8d547..95b215e 100644
--- a/BORINGSSL_REVISION
+++ b/BORINGSSL_REVISION
@@ -1 +1 @@
-df11bed9ee05141b54da7b88cc5b7960ca858164
+387b07b78dac785a341eeb2ff86e29393ffe8627
diff --git a/src/crypto/fipsmodule/digest/md32_common.h b/src/crypto/fipsmodule/digest/md32_common.h
index a0c3665..07d39d9 100644
--- a/src/crypto/fipsmodule/digest/md32_common.h
+++ b/src/crypto/fipsmodule/digest/md32_common.h
@@ -223,12 +223,12 @@
 }
 
 
-void HASH_TRANSFORM(HASH_CTX *c, const uint8_t *data) {
+void HASH_TRANSFORM(HASH_CTX *c, const uint8_t data[HASH_CBLOCK]) {
   HASH_BLOCK_DATA_ORDER(c->h, data, 1);
 }
 
 
-int HASH_FINAL(uint8_t *md, HASH_CTX *c) {
+int HASH_FINAL(uint8_t out[HASH_DIGEST_LENGTH], HASH_CTX *c) {
   // |c->data| always has room for at least one byte. A full block would have
   // been consumed.
   size_t n = c->num;
@@ -258,7 +258,7 @@
   c->num = 0;
   OPENSSL_memset(c->data, 0, HASH_CBLOCK);
 
-  HASH_MAKE_STRING(c, md);
+  HASH_MAKE_STRING(c, out);
   return 1;
 }
 
diff --git a/src/crypto/fipsmodule/md4/md4.c b/src/crypto/fipsmodule/md4/md4.c
index f0c1dcd..cc2a631 100644
--- a/src/crypto/fipsmodule/md4/md4.c
+++ b/src/crypto/fipsmodule/md4/md4.c
@@ -62,7 +62,7 @@
 #include "../../internal.h"
 
 
-uint8_t *MD4(const uint8_t *data, size_t len, uint8_t *out) {
+uint8_t *MD4(const uint8_t *data, size_t len, uint8_t out[MD4_DIGEST_LENGTH]) {
   MD4_CTX ctx;
   MD4_Init(&ctx);
   MD4_Update(&ctx, data, len);
@@ -88,6 +88,7 @@
 
 #define HASH_CTX MD4_CTX
 #define HASH_CBLOCK 64
+#define HASH_DIGEST_LENGTH 16
 #define HASH_UPDATE MD4_Update
 #define HASH_TRANSFORM MD4_Transform
 #define HASH_FINAL MD4_Final
@@ -238,6 +239,7 @@
 #undef DATA_ORDER_IS_LITTLE_ENDIAN
 #undef HASH_CTX
 #undef HASH_CBLOCK
+#undef HASH_DIGEST_LENGTH
 #undef HASH_UPDATE
 #undef HASH_TRANSFORM
 #undef HASH_FINAL
diff --git a/src/crypto/fipsmodule/md5/md5.c b/src/crypto/fipsmodule/md5/md5.c
index 66c65a6..a48d704 100644
--- a/src/crypto/fipsmodule/md5/md5.c
+++ b/src/crypto/fipsmodule/md5/md5.c
@@ -64,7 +64,7 @@
 #include "../../internal.h"
 
 
-uint8_t *MD5(const uint8_t *data, size_t len, uint8_t *out) {
+uint8_t *MD5(const uint8_t *data, size_t len, uint8_t out[MD5_DIGEST_LENGTH]) {
   MD5_CTX ctx;
   MD5_Init(&ctx);
   MD5_Update(&ctx, data, len);
@@ -94,6 +94,7 @@
 
 #define HASH_CTX MD5_CTX
 #define HASH_CBLOCK 64
+#define HASH_DIGEST_LENGTH 16
 #define HASH_UPDATE MD5_Update
 #define HASH_TRANSFORM MD5_Transform
 #define HASH_FINAL MD5_Final
@@ -281,6 +282,7 @@
 #undef DATA_ORDER_IS_LITTLE_ENDIAN
 #undef HASH_CTX
 #undef HASH_CBLOCK
+#undef HASH_DIGEST_LENGTH
 #undef HASH_UPDATE
 #undef HASH_TRANSFORM
 #undef HASH_FINAL
diff --git a/src/crypto/fipsmodule/sha/sha1.c b/src/crypto/fipsmodule/sha/sha1.c
index a3b771a..cc1243b 100644
--- a/src/crypto/fipsmodule/sha/sha1.c
+++ b/src/crypto/fipsmodule/sha/sha1.c
@@ -74,7 +74,7 @@
   return 1;
 }
 
-uint8_t *SHA1(const uint8_t *data, size_t len, uint8_t *out) {
+uint8_t *SHA1(const uint8_t *data, size_t len, uint8_t out[SHA_DIGEST_LENGTH]) {
   SHA_CTX ctx;
   SHA1_Init(&ctx);
   SHA1_Update(&ctx, data, len);
@@ -87,6 +87,7 @@
 
 #define HASH_CTX                SHA_CTX
 #define HASH_CBLOCK             64
+#define HASH_DIGEST_LENGTH      20
 #define HASH_MAKE_STRING(c, s) \
   do {                         \
     uint32_t ll;               \
@@ -343,6 +344,7 @@
 #undef DATA_ORDER_IS_BIG_ENDIAN
 #undef HASH_CTX
 #undef HASH_CBLOCK
+#undef HASH_DIGEST_LENGTH
 #undef HASH_MAKE_STRING
 #undef HASH_UPDATE
 #undef HASH_TRANSFORM
diff --git a/src/crypto/fipsmodule/sha/sha256.c b/src/crypto/fipsmodule/sha/sha256.c
index 92a5295..0e42446 100644
--- a/src/crypto/fipsmodule/sha/sha256.c
+++ b/src/crypto/fipsmodule/sha/sha256.c
@@ -92,7 +92,8 @@
   return 1;
 }
 
-uint8_t *SHA224(const uint8_t *data, size_t len, uint8_t *out) {
+uint8_t *SHA224(const uint8_t *data, size_t len,
+                uint8_t out[SHA224_DIGEST_LENGTH]) {
   SHA256_CTX ctx;
   SHA224_Init(&ctx);
   SHA224_Update(&ctx, data, len);
@@ -101,7 +102,8 @@
   return out;
 }
 
-uint8_t *SHA256(const uint8_t *data, size_t len, uint8_t *out) {
+uint8_t *SHA256(const uint8_t *data, size_t len,
+                uint8_t out[SHA256_DIGEST_LENGTH]) {
   SHA256_CTX ctx;
   SHA256_Init(&ctx);
   SHA256_Update(&ctx, data, len);
@@ -114,14 +116,17 @@
   return SHA256_Update(ctx, data, len);
 }
 
-int SHA224_Final(uint8_t *md, SHA256_CTX *ctx) {
-  return SHA256_Final(md, ctx);
+int SHA224_Final(uint8_t out[SHA224_DIGEST_LENGTH], SHA256_CTX *ctx) {
+  // SHA224_Init sets |ctx->md_len| to |SHA224_DIGEST_LENGTH|, so this has a
+  // smaller output.
+  return SHA256_Final(out, ctx);
 }
 
 #define DATA_ORDER_IS_BIG_ENDIAN
 
 #define HASH_CTX SHA256_CTX
 #define HASH_CBLOCK 64
+#define HASH_DIGEST_LENGTH 32
 
 // Note that FIPS180-2 discusses "Truncation of the Hash Function Output."
 // default: case below covers for it. It's not clear however if it's permitted
@@ -319,6 +324,7 @@
 #undef DATA_ORDER_IS_BIG_ENDIAN
 #undef HASH_CTX
 #undef HASH_CBLOCK
+#undef HASH_DIGEST_LENGTH
 #undef HASH_MAKE_STRING
 #undef HASH_UPDATE
 #undef HASH_TRANSFORM
diff --git a/src/crypto/fipsmodule/sha/sha512.c b/src/crypto/fipsmodule/sha/sha512.c
index f96cfbd..848f3b6 100644
--- a/src/crypto/fipsmodule/sha/sha512.c
+++ b/src/crypto/fipsmodule/sha/sha512.c
@@ -105,7 +105,8 @@
   return 1;
 }
 
-uint8_t *SHA384(const uint8_t *data, size_t len, uint8_t *out) {
+uint8_t *SHA384(const uint8_t *data, size_t len,
+                uint8_t out[SHA384_DIGEST_LENGTH]) {
   SHA512_CTX ctx;
   SHA384_Init(&ctx);
   SHA384_Update(&ctx, data, len);
@@ -114,7 +115,8 @@
   return out;
 }
 
-uint8_t *SHA512(const uint8_t *data, size_t len, uint8_t *out) {
+uint8_t *SHA512(const uint8_t *data, size_t len,
+                uint8_t out[SHA512_DIGEST_LENGTH]) {
   SHA512_CTX ctx;
   SHA512_Init(&ctx);
   SHA512_Update(&ctx, data, len);
@@ -129,15 +131,17 @@
 #endif
 
 
-int SHA384_Final(uint8_t *md, SHA512_CTX *sha) {
-  return SHA512_Final(md, sha);
+int SHA384_Final(uint8_t out[SHA384_DIGEST_LENGTH], SHA512_CTX *sha) {
+  // |SHA384_Init| sets |sha->md_len| to |SHA384_DIGEST_LENGTH|, so this has a
+  // |smaller output.
+  return SHA512_Final(out, sha);
 }
 
 int SHA384_Update(SHA512_CTX *sha, const void *data, size_t len) {
   return SHA512_Update(sha, data, len);
 }
 
-void SHA512_Transform(SHA512_CTX *c, const uint8_t *block) {
+void SHA512_Transform(SHA512_CTX *c, const uint8_t block[SHA512_CBLOCK]) {
   sha512_block_data_order(c->h, block, 1);
 }
 
@@ -189,7 +193,7 @@
   return 1;
 }
 
-int SHA512_Final(uint8_t *md, SHA512_CTX *sha) {
+int SHA512_Final(uint8_t out[SHA512_DIGEST_LENGTH], SHA512_CTX *sha) {
   uint8_t *p = sha->p;
   size_t n = sha->num;
 
@@ -221,7 +225,7 @@
 
   sha512_block_data_order(sha->h, p, 1);
 
-  if (md == NULL) {
+  if (out == NULL) {
     // TODO(davidben): This NULL check is absent in other low-level hash 'final'
     // functions and is one of the few places one can fail.
     return 0;
@@ -233,28 +237,28 @@
       for (n = 0; n < SHA384_DIGEST_LENGTH / 8; n++) {
         uint64_t t = sha->h[n];
 
-        *(md++) = (uint8_t)(t >> 56);
-        *(md++) = (uint8_t)(t >> 48);
-        *(md++) = (uint8_t)(t >> 40);
-        *(md++) = (uint8_t)(t >> 32);
-        *(md++) = (uint8_t)(t >> 24);
-        *(md++) = (uint8_t)(t >> 16);
-        *(md++) = (uint8_t)(t >> 8);
-        *(md++) = (uint8_t)(t);
+        *(out++) = (uint8_t)(t >> 56);
+        *(out++) = (uint8_t)(t >> 48);
+        *(out++) = (uint8_t)(t >> 40);
+        *(out++) = (uint8_t)(t >> 32);
+        *(out++) = (uint8_t)(t >> 24);
+        *(out++) = (uint8_t)(t >> 16);
+        *(out++) = (uint8_t)(t >> 8);
+        *(out++) = (uint8_t)(t);
       }
       break;
     case SHA512_DIGEST_LENGTH:
       for (n = 0; n < SHA512_DIGEST_LENGTH / 8; n++) {
         uint64_t t = sha->h[n];
 
-        *(md++) = (uint8_t)(t >> 56);
-        *(md++) = (uint8_t)(t >> 48);
-        *(md++) = (uint8_t)(t >> 40);
-        *(md++) = (uint8_t)(t >> 32);
-        *(md++) = (uint8_t)(t >> 24);
-        *(md++) = (uint8_t)(t >> 16);
-        *(md++) = (uint8_t)(t >> 8);
-        *(md++) = (uint8_t)(t);
+        *(out++) = (uint8_t)(t >> 56);
+        *(out++) = (uint8_t)(t >> 48);
+        *(out++) = (uint8_t)(t >> 40);
+        *(out++) = (uint8_t)(t >> 32);
+        *(out++) = (uint8_t)(t >> 24);
+        *(out++) = (uint8_t)(t >> 16);
+        *(out++) = (uint8_t)(t >> 8);
+        *(out++) = (uint8_t)(t);
       }
       break;
     // ... as well as make sure md_len is not abused.
diff --git a/src/decrepit/ripemd/internal.h b/src/decrepit/ripemd/internal.h
index fe172ca..089be15 100644
--- a/src/decrepit/ripemd/internal.h
+++ b/src/decrepit/ripemd/internal.h
@@ -54,8 +54,8 @@
  * copied and put under another distribution licence
  * [including the GNU Public Licence.] */
 
-#ifndef OPENSSL_HEADER_BN_INTERNAL_H
-#define OPENSSL_HEADER_BN_INTERNAL_H
+#ifndef OPENSSL_HEADER_RIPEMD_INTERNAL_H
+#define OPENSSL_HEADER_RIPEMD_INTERNAL_H
 
 #include <openssl/base.h>
 
@@ -72,6 +72,7 @@
 #define HASH_LONG uint32_t
 #define HASH_CTX RIPEMD160_CTX
 #define HASH_CBLOCK RIPEMD160_CBLOCK
+#define HASH_DIGEST_LENGTH RIPEMD160_DIGEST_LENGTH
 #define HASH_UPDATE RIPEMD160_Update
 #define HASH_TRANSFORM RIPEMD160_Transform
 #define HASH_FINAL RIPEMD160_Final
@@ -490,4 +491,4 @@
 }  // extern C
 #endif
 
-#endif  // OPENSSL_HEADER_BN_INTERNAL_H
+#endif  // OPENSSL_HEADER_RIPEMD_INTERNAL_H
diff --git a/src/decrepit/ripemd/ripemd.c b/src/decrepit/ripemd/ripemd.c
index 275d439..17b3fdf 100644
--- a/src/decrepit/ripemd/ripemd.c
+++ b/src/decrepit/ripemd/ripemd.c
@@ -311,7 +311,8 @@
 #undef X
 }
 
-uint8_t *RIPEMD160(const uint8_t *data, size_t len, unsigned char *out) {
+uint8_t *RIPEMD160(const uint8_t *data, size_t len,
+                   uint8_t out[RIPEMD160_DIGEST_LENGTH]) {
   RIPEMD160_CTX ctx;
 
   if (!RIPEMD160_Init(&ctx)) {
diff --git a/src/include/openssl/md4.h b/src/include/openssl/md4.h
index 52b88ca..b213bc6 100644
--- a/src/include/openssl/md4.h
+++ b/src/include/openssl/md4.h
@@ -79,17 +79,19 @@
 OPENSSL_EXPORT int MD4_Update(MD4_CTX *md4, const void *data, size_t len);
 
 // MD4_Final adds the final padding to |md4| and writes the resulting digest to
-// |md|, which must have at least |MD4_DIGEST_LENGTH| bytes of space. It
+// |out|, which must have at least |MD4_DIGEST_LENGTH| bytes of space. It
 // returns one.
-OPENSSL_EXPORT int MD4_Final(uint8_t *md, MD4_CTX *md4);
+OPENSSL_EXPORT int MD4_Final(uint8_t out[MD4_DIGEST_LENGTH], MD4_CTX *md4);
 
 // MD4 writes the digest of |len| bytes from |data| to |out| and returns |out|.
 // There must be at least |MD4_DIGEST_LENGTH| bytes of space in |out|.
-OPENSSL_EXPORT uint8_t *MD4(const uint8_t *data, size_t len, uint8_t *out);
+OPENSSL_EXPORT uint8_t *MD4(const uint8_t *data, size_t len,
+                            uint8_t out[MD4_DIGEST_LENGTH]);
 
 // MD4_Transform is a low-level function that performs a single, MD4 block
 // transformation using the state from |md4| and 64 bytes from |block|.
-OPENSSL_EXPORT void MD4_Transform(MD4_CTX *md4, const uint8_t *block);
+OPENSSL_EXPORT void MD4_Transform(MD4_CTX *md4,
+                                  const uint8_t block[MD4_CBLOCK]);
 
 struct md4_state_st {
   uint32_t h[4];
diff --git a/src/include/openssl/md5.h b/src/include/openssl/md5.h
index de6027f..5486512 100644
--- a/src/include/openssl/md5.h
+++ b/src/include/openssl/md5.h
@@ -80,17 +80,19 @@
 OPENSSL_EXPORT int MD5_Update(MD5_CTX *md5, const void *data, size_t len);
 
 // MD5_Final adds the final padding to |md5| and writes the resulting digest to
-// |md|, which must have at least |MD5_DIGEST_LENGTH| bytes of space. It
+// |out|, which must have at least |MD5_DIGEST_LENGTH| bytes of space. It
 // returns one.
-OPENSSL_EXPORT int MD5_Final(uint8_t *md, MD5_CTX *md5);
+OPENSSL_EXPORT int MD5_Final(uint8_t out[MD5_DIGEST_LENGTH], MD5_CTX *md5);
 
 // MD5 writes the digest of |len| bytes from |data| to |out| and returns |out|.
 // There must be at least |MD5_DIGEST_LENGTH| bytes of space in |out|.
-OPENSSL_EXPORT uint8_t *MD5(const uint8_t *data, size_t len, uint8_t *out);
+OPENSSL_EXPORT uint8_t *MD5(const uint8_t *data, size_t len,
+                            uint8_t out[MD5_DIGEST_LENGTH]);
 
 // MD5_Transform is a low-level function that performs a single, MD5 block
 // transformation using the state from |md5| and 64 bytes from |block|.
-OPENSSL_EXPORT void MD5_Transform(MD5_CTX *md5, const uint8_t *block);
+OPENSSL_EXPORT void MD5_Transform(MD5_CTX *md5,
+                                  const uint8_t block[MD5_CBLOCK]);
 
 struct md5_state_st {
   uint32_t h[4];
diff --git a/src/include/openssl/ripemd.h b/src/include/openssl/ripemd.h
index fb0b50c..d859b1f 100644
--- a/src/include/openssl/ripemd.h
+++ b/src/include/openssl/ripemd.h
@@ -83,21 +83,22 @@
                                    size_t len);
 
 // RIPEMD160_Final adds the final padding to |ctx| and writes the resulting
-// digest to |md|, which must have at least |RIPEMD160_DIGEST_LENGTH| bytes of
+// digest to |out|, which must have at least |RIPEMD160_DIGEST_LENGTH| bytes of
 // space. It returns one.
-OPENSSL_EXPORT int RIPEMD160_Final(uint8_t *md, RIPEMD160_CTX *ctx);
+OPENSSL_EXPORT int RIPEMD160_Final(uint8_t out[RIPEMD160_DIGEST_LENGTH],
+                                   RIPEMD160_CTX *ctx);
 
 // RIPEMD160 writes the digest of |len| bytes from |data| to |out| and returns
 // |out|. There must be at least |RIPEMD160_DIGEST_LENGTH| bytes of space in
 // |out|.
 OPENSSL_EXPORT uint8_t *RIPEMD160(const uint8_t *data, size_t len,
-                                  uint8_t *out);
+                                  uint8_t out[RIPEMD160_DIGEST_LENGTH]);
 
 // RIPEMD160_Transform is a low-level function that performs a single,
 // RIPEMD160 block transformation using the state from |ctx| and 64 bytes from
 // |block|.
 OPENSSL_EXPORT void RIPEMD160_Transform(RIPEMD160_CTX *ctx,
-                                        const uint8_t *block);
+                                        const uint8_t block[RIPEMD160_CBLOCK]);
 
 
 #if defined(__cplusplus)
diff --git a/src/include/openssl/sha.h b/src/include/openssl/sha.h
index c9b327d..b163e6a 100644
--- a/src/include/openssl/sha.h
+++ b/src/include/openssl/sha.h
@@ -79,20 +79,22 @@
 // SHA1_Update adds |len| bytes from |data| to |sha| and returns one.
 OPENSSL_EXPORT int SHA1_Update(SHA_CTX *sha, const void *data, size_t len);
 
-// SHA1_Final adds the final padding to |sha| and writes the resulting digest
-// to |md|, which must have at least |SHA_DIGEST_LENGTH| bytes of space. It
+// SHA1_Final adds the final padding to |sha| and writes the resulting digest to
+// |out|, which must have at least |SHA_DIGEST_LENGTH| bytes of space. It
 // returns one.
-OPENSSL_EXPORT int SHA1_Final(uint8_t *md, SHA_CTX *sha);
+OPENSSL_EXPORT int SHA1_Final(uint8_t out[SHA_DIGEST_LENGTH], SHA_CTX *sha);
 
 // SHA1 writes the digest of |len| bytes from |data| to |out| and returns
 // |out|. There must be at least |SHA_DIGEST_LENGTH| bytes of space in
 // |out|.
-OPENSSL_EXPORT uint8_t *SHA1(const uint8_t *data, size_t len, uint8_t *out);
+OPENSSL_EXPORT uint8_t *SHA1(const uint8_t *data, size_t len,
+                             uint8_t out[SHA_DIGEST_LENGTH]);
 
 // SHA1_Transform is a low-level function that performs a single, SHA-1 block
 // transformation using the state from |sha| and |SHA_CBLOCK| bytes from
 // |block|.
-OPENSSL_EXPORT void SHA1_Transform(SHA_CTX *sha, const uint8_t *block);
+OPENSSL_EXPORT void SHA1_Transform(SHA_CTX *sha,
+                                   const uint8_t block[SHA_CBLOCK]);
 
 struct sha_state_st {
 #if defined(OPENSSL_WINDOWS)
@@ -132,14 +134,16 @@
 OPENSSL_EXPORT int SHA224_Update(SHA256_CTX *sha, const void *data, size_t len);
 
 // SHA224_Final adds the final padding to |sha| and writes the resulting digest
-// to |md|, which must have at least |SHA224_DIGEST_LENGTH| bytes of space. It
+// to |out|, which must have at least |SHA224_DIGEST_LENGTH| bytes of space. It
 // returns one on success and zero on programmer error.
-OPENSSL_EXPORT int SHA224_Final(uint8_t *md, SHA256_CTX *sha);
+OPENSSL_EXPORT int SHA224_Final(uint8_t out[SHA224_DIGEST_LENGTH],
+                                SHA256_CTX *sha);
 
 // SHA224 writes the digest of |len| bytes from |data| to |out| and returns
 // |out|. There must be at least |SHA224_DIGEST_LENGTH| bytes of space in
 // |out|.
-OPENSSL_EXPORT uint8_t *SHA224(const uint8_t *data, size_t len, uint8_t *out);
+OPENSSL_EXPORT uint8_t *SHA224(const uint8_t *data, size_t len,
+                               uint8_t out[SHA224_DIGEST_LENGTH]);
 
 
 // SHA-256.
@@ -157,19 +161,22 @@
 OPENSSL_EXPORT int SHA256_Update(SHA256_CTX *sha, const void *data, size_t len);
 
 // SHA256_Final adds the final padding to |sha| and writes the resulting digest
-// to |md|, which must have at least |SHA256_DIGEST_LENGTH| bytes of space. It
+// to |out|, which must have at least |SHA256_DIGEST_LENGTH| bytes of space. It
 // returns one on success and zero on programmer error.
-OPENSSL_EXPORT int SHA256_Final(uint8_t *md, SHA256_CTX *sha);
+OPENSSL_EXPORT int SHA256_Final(uint8_t out[SHA256_DIGEST_LENGTH],
+                                SHA256_CTX *sha);
 
 // SHA256 writes the digest of |len| bytes from |data| to |out| and returns
 // |out|. There must be at least |SHA256_DIGEST_LENGTH| bytes of space in
 // |out|.
-OPENSSL_EXPORT uint8_t *SHA256(const uint8_t *data, size_t len, uint8_t *out);
+OPENSSL_EXPORT uint8_t *SHA256(const uint8_t *data, size_t len,
+                               uint8_t out[SHA256_DIGEST_LENGTH]);
 
 // SHA256_Transform is a low-level function that performs a single, SHA-256
 // block transformation using the state from |sha| and |SHA256_CBLOCK| bytes
 // from |block|.
-OPENSSL_EXPORT void SHA256_Transform(SHA256_CTX *sha, const uint8_t *block);
+OPENSSL_EXPORT void SHA256_Transform(SHA256_CTX *sha,
+                                     const uint8_t block[SHA256_CBLOCK]);
 
 // SHA256_TransformBlocks is a low-level function that takes |num_blocks| *
 // |SHA256_CBLOCK| bytes of data and performs SHA-256 transforms on it to update
@@ -202,14 +209,16 @@
 OPENSSL_EXPORT int SHA384_Update(SHA512_CTX *sha, const void *data, size_t len);
 
 // SHA384_Final adds the final padding to |sha| and writes the resulting digest
-// to |md|, which must have at least |SHA384_DIGEST_LENGTH| bytes of space. It
+// to |out|, which must have at least |SHA384_DIGEST_LENGTH| bytes of space. It
 // returns one on success and zero on programmer error.
-OPENSSL_EXPORT int SHA384_Final(uint8_t *md, SHA512_CTX *sha);
+OPENSSL_EXPORT int SHA384_Final(uint8_t out[SHA384_DIGEST_LENGTH],
+                                SHA512_CTX *sha);
 
 // SHA384 writes the digest of |len| bytes from |data| to |out| and returns
 // |out|. There must be at least |SHA384_DIGEST_LENGTH| bytes of space in
 // |out|.
-OPENSSL_EXPORT uint8_t *SHA384(const uint8_t *data, size_t len, uint8_t *out);
+OPENSSL_EXPORT uint8_t *SHA384(const uint8_t *data, size_t len,
+                               uint8_t out[SHA384_DIGEST_LENGTH]);
 
 
 // SHA-512.
@@ -227,19 +236,22 @@
 OPENSSL_EXPORT int SHA512_Update(SHA512_CTX *sha, const void *data, size_t len);
 
 // SHA512_Final adds the final padding to |sha| and writes the resulting digest
-// to |md|, which must have at least |SHA512_DIGEST_LENGTH| bytes of space. It
+// to |out|, which must have at least |SHA512_DIGEST_LENGTH| bytes of space. It
 // returns one on success and zero on programmer error.
-OPENSSL_EXPORT int SHA512_Final(uint8_t *md, SHA512_CTX *sha);
+OPENSSL_EXPORT int SHA512_Final(uint8_t out[SHA512_DIGEST_LENGTH],
+                                SHA512_CTX *sha);
 
 // SHA512 writes the digest of |len| bytes from |data| to |out| and returns
 // |out|. There must be at least |SHA512_DIGEST_LENGTH| bytes of space in
 // |out|.
-OPENSSL_EXPORT uint8_t *SHA512(const uint8_t *data, size_t len, uint8_t *out);
+OPENSSL_EXPORT uint8_t *SHA512(const uint8_t *data, size_t len,
+                               uint8_t out[SHA512_DIGEST_LENGTH]);
 
 // SHA512_Transform is a low-level function that performs a single, SHA-512
 // block transformation using the state from |sha| and |SHA512_CBLOCK| bytes
 // from |block|.
-OPENSSL_EXPORT void SHA512_Transform(SHA512_CTX *sha, const uint8_t *block);
+OPENSSL_EXPORT void SHA512_Transform(SHA512_CTX *sha,
+                                     const uint8_t block[SHA512_CBLOCK]);
 
 struct sha512_state_st {
   uint64_t h[8];
diff --git a/src/include/openssl/ssl.h b/src/include/openssl/ssl.h
index a539b20..629f006 100644
--- a/src/include/openssl/ssl.h
+++ b/src/include/openssl/ssl.h
@@ -631,6 +631,12 @@
 OPENSSL_EXPORT int SSL_CTX_set_max_proto_version(SSL_CTX *ctx,
                                                  uint16_t version);
 
+// SSL_CTX_get_min_proto_version returns the minimum protocol version for |ctx|
+OPENSSL_EXPORT uint16_t SSL_CTX_get_min_proto_version(SSL_CTX *ctx);
+
+// SSL_CTX_get_max_proto_version returns the maximum protocol version for |ctx|
+OPENSSL_EXPORT uint16_t SSL_CTX_get_max_proto_version(SSL_CTX *ctx);
+
 // SSL_set_min_proto_version sets the minimum protocol version for |ssl| to
 // |version|. If |version| is zero, the default minimum version is used. It
 // returns one on success and zero if |version| is invalid.
diff --git a/src/ssl/internal.h b/src/ssl/internal.h
index 0df9a5f..16b2866 100644
--- a/src/ssl/internal.h
+++ b/src/ssl/internal.h
@@ -1392,7 +1392,7 @@
   static UniquePtr<DC> Parse(CRYPTO_BUFFER *in, uint8_t *out_alert);
 
   // raw is the delegated credential encoded as specified in draft-ietf-tls-
-  // subcerts-02.
+  // subcerts-03.
   UniquePtr<CRYPTO_BUFFER> raw;
 
   // expected_cert_verify_algorithm is the signature scheme of the DC public
@@ -2464,14 +2464,14 @@
   // ssl is a non-owning pointer to the parent |SSL| object.
   SSL *const ssl = nullptr;
 
-  // conf_max_version is the maximum acceptable protocol version configured by
-  // |SSL_set_max_proto_version|. Note this version is normalized in DTLS and is
-  // further constrainted by |SSL_OP_NO_*|.
+  // conf_max_version is the maximum acceptable version configured by
+  // |SSL_set_max_proto_version|. Note this version is not normalized in DTLS
+  // and is further constrained by |SSL_OP_NO_*|.
   uint16_t conf_max_version = 0;
 
-  // conf_min_version is the minimum acceptable protocol version configured by
-  // |SSL_set_min_proto_version|. Note this version is normalized in DTLS and is
-  // further constrainted by |SSL_OP_NO_*|.
+  // conf_min_version is the minimum acceptable version configured by
+  // |SSL_set_min_proto_version|. Note this version is not normalized in DTLS
+  // and is further constrained by |SSL_OP_NO_*|.
   uint16_t conf_min_version = 0;
 
   X509_VERIFY_PARAM *param = nullptr;
diff --git a/src/ssl/ssl_test.cc b/src/ssl/ssl_test.cc
index f3f7923..af5d795 100644
--- a/src/ssl/ssl_test.cc
+++ b/src/ssl/ssl_test.cc
@@ -840,8 +840,8 @@
                                  const SSL_METHOD *(*method)(void)) {
   bssl::UniquePtr<SSL_CTX> ctx(SSL_CTX_new(method()));
   ASSERT_TRUE(ctx);
-  EXPECT_EQ(min_version, ctx->conf_min_version);
-  EXPECT_EQ(max_version, ctx->conf_max_version);
+  EXPECT_EQ(min_version, SSL_CTX_get_min_proto_version(ctx.get()));
+  EXPECT_EQ(max_version, SSL_CTX_get_max_proto_version(ctx.get()));
 }
 
 TEST(SSLTest, DefaultVersion) {
@@ -850,9 +850,9 @@
   ExpectDefaultVersion(TLS1_VERSION, TLS1_VERSION, &TLSv1_method);
   ExpectDefaultVersion(TLS1_1_VERSION, TLS1_1_VERSION, &TLSv1_1_method);
   ExpectDefaultVersion(TLS1_2_VERSION, TLS1_2_VERSION, &TLSv1_2_method);
-  ExpectDefaultVersion(TLS1_1_VERSION, TLS1_2_VERSION, &DTLS_method);
-  ExpectDefaultVersion(TLS1_1_VERSION, TLS1_1_VERSION, &DTLSv1_method);
-  ExpectDefaultVersion(TLS1_2_VERSION, TLS1_2_VERSION, &DTLSv1_2_method);
+  ExpectDefaultVersion(DTLS1_VERSION, DTLS1_2_VERSION, &DTLS_method);
+  ExpectDefaultVersion(DTLS1_VERSION, DTLS1_VERSION, &DTLSv1_method);
+  ExpectDefaultVersion(DTLS1_2_VERSION, DTLS1_2_VERSION, &DTLSv1_2_method);
 }
 
 TEST(SSLTest, CipherProperties) {
@@ -2617,13 +2617,13 @@
 
   // Zero is the default version.
   EXPECT_TRUE(SSL_CTX_set_max_proto_version(ctx.get(), 0));
-  EXPECT_EQ(TLS1_2_VERSION, ctx->conf_max_version);
+  EXPECT_EQ(TLS1_2_VERSION, SSL_CTX_get_max_proto_version(ctx.get()));
   EXPECT_TRUE(SSL_CTX_set_min_proto_version(ctx.get(), 0));
-  EXPECT_EQ(TLS1_VERSION, ctx->conf_min_version);
+  EXPECT_EQ(TLS1_VERSION, SSL_CTX_get_min_proto_version(ctx.get()));
 
   // TLS 1.3 is available, but not by default.
   EXPECT_TRUE(SSL_CTX_set_max_proto_version(ctx.get(), TLS1_3_VERSION));
-  EXPECT_EQ(TLS1_3_VERSION, ctx->conf_max_version);
+  EXPECT_EQ(TLS1_3_VERSION, SSL_CTX_get_max_proto_version(ctx.get()));
 
   // SSL 3.0 is not available.
   EXPECT_FALSE(SSL_CTX_set_min_proto_version(ctx.get(), SSL3_VERSION));
@@ -2646,9 +2646,9 @@
   EXPECT_FALSE(SSL_CTX_set_min_proto_version(ctx.get(), 0x1234));
 
   EXPECT_TRUE(SSL_CTX_set_max_proto_version(ctx.get(), 0));
-  EXPECT_EQ(TLS1_2_VERSION, ctx->conf_max_version);
+  EXPECT_EQ(DTLS1_2_VERSION, SSL_CTX_get_max_proto_version(ctx.get()));
   EXPECT_TRUE(SSL_CTX_set_min_proto_version(ctx.get(), 0));
-  EXPECT_EQ(TLS1_1_VERSION, ctx->conf_min_version);
+  EXPECT_EQ(DTLS1_VERSION, SSL_CTX_get_min_proto_version(ctx.get()));
 }
 
 static const char *GetVersionName(uint16_t version) {
diff --git a/src/ssl/ssl_versions.cc b/src/ssl/ssl_versions.cc
index e6dbc8d..e25fce6 100644
--- a/src/ssl/ssl_versions.cc
+++ b/src/ssl/ssl_versions.cc
@@ -134,12 +134,12 @@
 static bool set_version_bound(const SSL_PROTOCOL_METHOD *method, uint16_t *out,
                               uint16_t version) {
   if (!api_version_to_wire(&version, version) ||
-      !ssl_method_supports_version(method, version) ||
-      !ssl_protocol_version_from_wire(out, version)) {
+      !ssl_method_supports_version(method, version)) {
     OPENSSL_PUT_ERROR(SSL, SSL_R_UNKNOWN_SSL_VERSION);
     return false;
   }
 
+  *out = version;
   return true;
 }
 
@@ -147,8 +147,7 @@
                             uint16_t version) {
   // Zero is interpreted as the default minimum version.
   if (version == 0) {
-    // TLS 1.0 does not exist in DTLS.
-    *out = method->is_dtls ? TLS1_1_VERSION : TLS1_VERSION;
+    *out = method->is_dtls ? DTLS1_VERSION : TLS1_VERSION;
     return true;
   }
 
@@ -159,7 +158,7 @@
                             uint16_t version) {
   // Zero is interpreted as the default maximum version.
   if (version == 0) {
-    *out = TLS1_2_VERSION;
+    *out = method->is_dtls ? DTLS1_2_VERSION : TLS1_2_VERSION;
     return true;
   }
 
@@ -188,8 +187,14 @@
     }
   }
 
-  uint16_t min_version = hs->config->conf_min_version;
-  uint16_t max_version = hs->config->conf_max_version;
+  uint16_t min_version, max_version;
+  if (!ssl_protocol_version_from_wire(&min_version,
+                                      hs->config->conf_min_version) ||
+      !ssl_protocol_version_from_wire(&max_version,
+                                      hs->config->conf_max_version)) {
+    OPENSSL_PUT_ERROR(SSL, ERR_R_INTERNAL_ERROR);
+    return false;
+  }
 
   // QUIC requires TLS 1.3.
   if (hs->ssl->quic_method && min_version < TLS1_3_VERSION) {
@@ -344,6 +349,14 @@
   return set_max_version(ctx->method, &ctx->conf_max_version, version);
 }
 
+uint16_t SSL_CTX_get_min_proto_version(SSL_CTX *ctx) {
+  return ctx->conf_min_version;
+}
+
+uint16_t SSL_CTX_get_max_proto_version(SSL_CTX *ctx) {
+  return ctx->conf_max_version;
+}
+
 int SSL_set_min_proto_version(SSL *ssl, uint16_t version) {
   if (!ssl->config) {
     return 0;
diff --git a/src/ssl/t1_lib.cc b/src/ssl/t1_lib.cc
index 3a08fe6..c0452dc 100644
--- a/src/ssl/t1_lib.cc
+++ b/src/ssl/t1_lib.cc
@@ -2717,7 +2717,7 @@
   assert(TLSEXT_TYPE_delegated_credential == 0xff02);
   // TODO: Check that the extension is empty.
   //
-  // As of draft-02, the client sends an empty extension in order indicate
+  // As of draft-03, the client sends an empty extension in order indicate
   // support for delegated credentials. This could change, however, since the
   // spec is not yet finalized. This assertion is here to remind us to enforce
   // this check once the extension ID is assigned.
diff --git a/src/util/bot/DEPS b/src/util/bot/DEPS
index 5d6e8cd..1eb563d 100644
--- a/src/util/bot/DEPS
+++ b/src/util/bot/DEPS
@@ -28,7 +28,7 @@
   },
 
   'boringssl/util/bot/android_tools': {
-    'url': Var('chromium_git') + '/android_tools.git' + '@' + 'e958d6ea74442d4e0849bb8a018d215a0e78981d',
+    'url': Var('chromium_git') + '/android_tools.git' + '@' + '347a7c8078a009e98995985b7ab6ec6b35696dea',
     'condition': 'checkout_android',
   },
 
@@ -36,18 +36,18 @@
     Var('chromium_git') + '/external/gyp.git' + '@' + 'd61a9397e668fa9843c4aa7da9e79460fe590bfb',
 
   'boringssl/util/bot/libFuzzer': {
-    'url': Var('chromium_git') + '/chromium/llvm-project/compiler-rt/lib/fuzzer.git' +'@' + '2a53098584c48af50aec3fb51febe5e651489774',
+    'url': Var('chromium_git') + '/chromium/llvm-project/compiler-rt/lib/fuzzer.git' +'@' + 'e847d8a9b47158695593d5693b0f69250472b229',
     'condition': 'checkout_fuzzer',
   },
 
   # Update the following revisions from
-  # https://chromium.googlesource.com/chromium/buildtools/+/master/DEPS
+  # https://chromium.googlesource.com/chromium/src/+/master/buildtools/DEPS
   'boringssl/util/bot/libcxx': {
-    'url': Var('chromium_git') + '/chromium/llvm-project/libcxx.git' + '@' + 'e713cc0acf1ae8b82f451bf58ebef67a46ceddfb',
+    'url': Var('chromium_git') + '/chromium/llvm-project/libcxx.git' + '@' + '955113db37563c8632e31ddcff2047845553d7ff',
     'condition': 'checkout_libcxx',
   },
   'boringssl/util/bot/libcxxabi': {
-    'url': Var('chromium_git') + '/chromium/llvm-project/libcxxabi.git' + '@' + '307bb62985575b2e3216a8cfd7e122e0574f33a9',
+    'url': Var('chromium_git') + '/chromium/llvm-project/libcxxabi.git' + '@' + '0d529660e32d77d9111912d73f2c74fc5fa2a858',
     'condition': 'checkout_libcxx',
   },
 }
diff --git a/src/util/bot/UPDATING b/src/util/bot/UPDATING
index 5a46cdf..0e4f493 100644
--- a/src/util/bot/UPDATING
+++ b/src/util/bot/UPDATING
@@ -79,6 +79,6 @@
 
     upload_to_google_storage.py -b chrome-boringssl-sde sde-linux64.tar.bz2 sde-win32.tar.bz2
 
-The current revision is sde-external-8.16.0-2018-01-30-*.tar.bz2.
+The current revision is sde-external-8.35.0-2019-03-11-*.tar.bz2.
 
 When adding new files, remember to update .gitignore.
diff --git a/src/util/bot/go/bootstrap.py b/src/util/bot/go/bootstrap.py
index 1a33c79..d295748 100755
--- a/src/util/bot/go/bootstrap.py
+++ b/src/util/bot/go/bootstrap.py
@@ -45,7 +45,7 @@
 EXE_SFX = '.exe' if sys.platform == 'win32' else ''
 
 # Pinned version of Go toolset to download.
-TOOLSET_VERSION = 'go1.11.4'
+TOOLSET_VERSION = 'go1.12.1'
 
 # Platform dependent portion of a download URL. See http://golang.org/dl/.
 TOOLSET_VARIANTS = {
diff --git a/src/util/bot/sde-linux64.tar.bz2.sha1 b/src/util/bot/sde-linux64.tar.bz2.sha1
index bd93323..6037df5 100644
--- a/src/util/bot/sde-linux64.tar.bz2.sha1
+++ b/src/util/bot/sde-linux64.tar.bz2.sha1
@@ -1 +1 @@
-fe5d01f13b82469ce3854307bba9565d1a02b921
\ No newline at end of file
+25581fcf3a14d4ca70149c6186111603f725fb26
\ No newline at end of file
diff --git a/src/util/bot/sde-win32.tar.bz2.sha1 b/src/util/bot/sde-win32.tar.bz2.sha1
index d17e78d..0837b08 100644
--- a/src/util/bot/sde-win32.tar.bz2.sha1
+++ b/src/util/bot/sde-win32.tar.bz2.sha1
@@ -1 +1 @@
-0f746c4c64e07794fd597ec950a24de571376732
\ No newline at end of file
+d08247e1b7d9837f75ffbfa3f44e9b8f44eb90ba
\ No newline at end of file
diff --git a/src/util/bot/update_clang.py b/src/util/bot/update_clang.py
index b1f7776..5151b13 100644
--- a/src/util/bot/update_clang.py
+++ b/src/util/bot/update_clang.py
@@ -19,8 +19,8 @@
 # CLANG_REVISION and CLANG_SUB_REVISION determine the build of clang
 # to use. These should be synced with tools/clang/scripts/update.py in
 # Chromium.
-CLANG_REVISION = '349417'
-CLANG_SUB_REVISION=2
+CLANG_REVISION = '357569'
+CLANG_SUB_REVISION = 1
 
 PACKAGE_VERSION = "%s-%s" % (CLANG_REVISION, CLANG_SUB_REVISION)
 
diff --git a/src/util/bot/vs_toolchain.py b/src/util/bot/vs_toolchain.py
index 2530662..feaaa7c 100644
--- a/src/util/bot/vs_toolchain.py
+++ b/src/util/bot/vs_toolchain.py
@@ -87,9 +87,9 @@
     # Update 3 final with 10.0.15063.468 SDK and no vctip.exe.
     return ['f53e4598951162bad6330f7a167486c7ae5db1e5']
   if env_version == '2017':
-    # VS 2017 Update 7.1 (15.7.1) with 10.0.17134.12 SDK, rebuilt with
-    # dbghelp.dll fix.
-    return ['3bc0ec615cf20ee342f3bc29bc991b5ad66d8d2c']
+    # VS 2017 Update 9 (15.9.3) with 10.0.17763.132 SDK, 10.0.17134 version of
+    # d3dcompiler_47.dll, with ARM64 libraries.
+    return ['818a152b3f1da991c1725d85be19a0f27af6bab4']
   raise Exception('Unsupported VS version %s' % env_version)