Use CRYPTO_store_u32_be in tls_cbc.cc It's a little shorter. Change-Id: Id4b35e5eabfb7cff6fc8d738ad9dd1d7e9f9dde4 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/85667 Reviewed-by: Rudolf Polzer <rpolzer@google.com> Commit-Queue: David Benjamin <davidben@google.com>
diff --git a/crypto/cipher/tls_cbc.cc b/crypto/cipher/tls_cbc.cc index 0918e23..747743d 100644 --- a/crypto/cipher/tls_cbc.cc +++ b/crypto/cipher/tls_cbc.cc
@@ -169,10 +169,7 @@ // The bounds above imply |total_bits| fits in four bytes. size_t total_bits = ctx->Nl + (len << 3); uint8_t length_bytes[4]; - length_bytes[0] = (uint8_t)(total_bits >> 24); - length_bytes[1] = (uint8_t)(total_bits >> 16); - length_bytes[2] = (uint8_t)(total_bits >> 8); - length_bytes[3] = (uint8_t)total_bits; + CRYPTO_store_u32_be(length_bytes, total_bits); // We now construct and process each expected block in constant-time. uint8_t block[SHA_CBLOCK] = {0}; @@ -264,10 +261,7 @@ // The bounds above imply |total_bits| fits in four bytes. size_t total_bits = ctx->Nl + (len << 3); uint8_t length_bytes[4]; - length_bytes[0] = (uint8_t)(total_bits >> 24); - length_bytes[1] = (uint8_t)(total_bits >> 16); - length_bytes[2] = (uint8_t)(total_bits >> 8); - length_bytes[3] = (uint8_t)total_bits; + CRYPTO_store_u32_be(length_bytes, total_bits); // We now construct and process each expected block in constant-time. uint8_t block[SHA256_CBLOCK] = {0};