These static output buffers are a legacy from a time before processes had threads. This change drops support and callers who were depending on this (of which there are hopefully none) will crash. Change-Id: I7b8eb3440def507f92543e55465f821dfa02c7da Reviewed-on: https://boringssl-review.googlesource.com/14528 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>kris/onging/CECPQ3_patch15
@@ -62,7 +62,7 @@ static size_t FromBoolS(bool b) { | |||||
return b ? CONSTTIME_TRUE_S : CONSTTIME_FALSE_S; | return b ? CONSTTIME_TRUE_S : CONSTTIME_FALSE_S; | ||||
} | } | ||||
static uint8_t test_values_8[] = {0, 1, 2, 20, 32, 127, 128, 129, 255}; | |||||
static const uint8_t test_values_8[] = {0, 1, 2, 20, 32, 127, 128, 129, 255}; | |||||
static size_t test_values_s[] = { | static size_t test_values_s[] = { | ||||
0, | 0, | ||||
@@ -225,13 +225,6 @@ static int TestDigest(const TestVector *test) { | |||||
if (!CompareDigest(test, digest.get(), EVP_MD_size(test->md.func()))) { | if (!CompareDigest(test, digest.get(), EVP_MD_size(test->md.func()))) { | ||||
return false; | return false; | ||||
} | } | ||||
// Test the deprecated static buffer variant, until it's removed. | |||||
out = test->md.one_shot_func((const uint8_t *)test->input, | |||||
strlen(test->input), NULL); | |||||
if (!CompareDigest(test, out, EVP_MD_size(test->md.func()))) { | |||||
return false; | |||||
} | |||||
} | } | ||||
return true; | return true; | ||||
@@ -69,15 +69,6 @@ uint8_t *HMAC(const EVP_MD *evp_md, const void *key, size_t key_len, | |||||
const uint8_t *data, size_t data_len, uint8_t *out, | const uint8_t *data, size_t data_len, uint8_t *out, | ||||
unsigned int *out_len) { | unsigned int *out_len) { | ||||
HMAC_CTX ctx; | HMAC_CTX ctx; | ||||
static uint8_t static_out_buffer[EVP_MAX_MD_SIZE]; | |||||
/* OpenSSL has traditionally supported using a static buffer if |out| is | |||||
* NULL. We maintain that but don't document it. This behaviour should be | |||||
* considered to be deprecated. */ | |||||
if (out == NULL) { | |||||
out = static_out_buffer; | |||||
} | |||||
HMAC_CTX_init(&ctx); | HMAC_CTX_init(&ctx); | ||||
if (!HMAC_Init_ex(&ctx, key, key_len, evp_md, NULL) || | if (!HMAC_Init_ex(&ctx, key, key_len, evp_md, NULL) || | ||||
!HMAC_Update(&ctx, data, data_len) || | !HMAC_Update(&ctx, data, data_len) || | ||||
@@ -65,13 +65,6 @@ | |||||
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_CTX ctx; | MD5_CTX ctx; | ||||
static uint8_t digest[MD5_DIGEST_LENGTH]; | |||||
/* TODO(fork): remove this static buffer. */ | |||||
if (out == NULL) { | |||||
out = digest; | |||||
} | |||||
MD5_Init(&ctx); | MD5_Init(&ctx); | ||||
MD5_Update(&ctx, data, len); | MD5_Update(&ctx, data, len); | ||||
MD5_Final(out, &ctx); | MD5_Final(out, &ctx); | ||||
@@ -82,12 +82,6 @@ int SHA1_Init(SHA_CTX *sha) { | |||||
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_CTX ctx; | SHA_CTX ctx; | ||||
static uint8_t buf[SHA_DIGEST_LENGTH]; | |||||
/* TODO(fork): remove this static buffer. */ | |||||
if (out == NULL) { | |||||
out = buf; | |||||
} | |||||
if (!SHA1_Init(&ctx)) { | if (!SHA1_Init(&ctx)) { | ||||
return NULL; | return NULL; | ||||
} | } | ||||
@@ -99,12 +99,6 @@ int SHA256_Init(SHA256_CTX *sha) { | |||||
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) { | ||||
SHA256_CTX ctx; | SHA256_CTX ctx; | ||||
static uint8_t buf[SHA224_DIGEST_LENGTH]; | |||||
/* TODO(fork): remove this static buffer. */ | |||||
if (out == NULL) { | |||||
out = buf; | |||||
} | |||||
SHA224_Init(&ctx); | SHA224_Init(&ctx); | ||||
SHA224_Update(&ctx, data, len); | SHA224_Update(&ctx, data, len); | ||||
SHA224_Final(out, &ctx); | SHA224_Final(out, &ctx); | ||||
@@ -114,12 +108,6 @@ uint8_t *SHA224(const uint8_t *data, size_t len, uint8_t *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_CTX ctx; | SHA256_CTX ctx; | ||||
static uint8_t buf[SHA256_DIGEST_LENGTH]; | |||||
/* TODO(fork): remove this static buffer. */ | |||||
if (out == NULL) { | |||||
out = buf; | |||||
} | |||||
SHA256_Init(&ctx); | SHA256_Init(&ctx); | ||||
SHA256_Update(&ctx, data, len); | SHA256_Update(&ctx, data, len); | ||||
SHA256_Final(out, &ctx); | SHA256_Final(out, &ctx); | ||||
@@ -123,13 +123,6 @@ int SHA512_Init(SHA512_CTX *sha) { | |||||
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) { | ||||
SHA512_CTX ctx; | SHA512_CTX ctx; | ||||
static uint8_t buf[SHA384_DIGEST_LENGTH]; | |||||
/* TODO(fork): remove this static buffer. */ | |||||
if (out == NULL) { | |||||
out = buf; | |||||
} | |||||
SHA384_Init(&ctx); | SHA384_Init(&ctx); | ||||
SHA384_Update(&ctx, data, len); | SHA384_Update(&ctx, data, len); | ||||
SHA384_Final(out, &ctx); | SHA384_Final(out, &ctx); | ||||
@@ -139,12 +132,6 @@ uint8_t *SHA384(const uint8_t *data, size_t len, uint8_t *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_CTX ctx; | SHA512_CTX ctx; | ||||
static uint8_t buf[SHA512_DIGEST_LENGTH]; | |||||
/* TODO(fork): remove this static buffer. */ | |||||
if (out == NULL) { | |||||
out = buf; | |||||
} | |||||
SHA512_Init(&ctx); | SHA512_Init(&ctx); | ||||
SHA512_Update(&ctx, data, len); | SHA512_Update(&ctx, data, len); | ||||
SHA512_Final(out, &ctx); | SHA512_Final(out, &ctx); | ||||