Browse Source

Remove static output buffers for hash & HMAC functions.

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
Adam Langley 7 years ago
committed by CQ bot account: commit-bot@chromium.org
parent
commit
faa539f877
7 changed files with 1 additions and 55 deletions
  1. +1
    -1
      crypto/constant_time_test.cc
  2. +0
    -7
      crypto/digest/digest_test.cc
  3. +0
    -9
      crypto/hmac/hmac.c
  4. +0
    -7
      crypto/md5/md5.c
  5. +0
    -6
      crypto/sha/sha1.c
  6. +0
    -12
      crypto/sha/sha256.c
  7. +0
    -13
      crypto/sha/sha512.c

+ 1
- 1
crypto/constant_time_test.cc View File

@@ -62,7 +62,7 @@ static size_t FromBoolS(bool b) {
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[] = {
0,


+ 0
- 7
crypto/digest/digest_test.cc View File

@@ -225,13 +225,6 @@ static int TestDigest(const TestVector *test) {
if (!CompareDigest(test, digest.get(), EVP_MD_size(test->md.func()))) {
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;


+ 0
- 9
crypto/hmac/hmac.c View File

@@ -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,
unsigned int *out_len) {
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);
if (!HMAC_Init_ex(&ctx, key, key_len, evp_md, NULL) ||
!HMAC_Update(&ctx, data, data_len) ||


+ 0
- 7
crypto/md5/md5.c View File

@@ -65,13 +65,6 @@

uint8_t *MD5(const uint8_t *data, size_t len, uint8_t *out) {
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_Update(&ctx, data, len);
MD5_Final(out, &ctx);


+ 0
- 6
crypto/sha/sha1.c View File

@@ -82,12 +82,6 @@ int SHA1_Init(SHA_CTX *sha) {

uint8_t *SHA1(const uint8_t *data, size_t len, uint8_t *out) {
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)) {
return NULL;
}


+ 0
- 12
crypto/sha/sha256.c View File

@@ -99,12 +99,6 @@ int SHA256_Init(SHA256_CTX *sha) {

uint8_t *SHA224(const uint8_t *data, size_t len, uint8_t *out) {
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_Update(&ctx, data, len);
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) {
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_Update(&ctx, data, len);
SHA256_Final(out, &ctx);


+ 0
- 13
crypto/sha/sha512.c View File

@@ -123,13 +123,6 @@ int SHA512_Init(SHA512_CTX *sha) {

uint8_t *SHA384(const uint8_t *data, size_t len, uint8_t *out) {
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_Update(&ctx, data, len);
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) {
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_Update(&ctx, data, len);
SHA512_Final(out, &ctx);


Loading…
Cancel
Save