| Index: content/child/webcrypto/openssl/hmac_openssl.cc
|
| diff --git a/content/child/webcrypto/openssl/hmac_openssl.cc b/content/child/webcrypto/openssl/hmac_openssl.cc
|
| index 0872390d457a129fea36030889405ae4dbab9271..69b55bf0464979200a41f8bdb37be6aae8950e0a 100644
|
| --- a/content/child/webcrypto/openssl/hmac_openssl.cc
|
| +++ b/content/child/webcrypto/openssl/hmac_openssl.cc
|
| @@ -38,22 +38,14 @@ Status SignHmac(const std::vector<uint8_t>& raw_key,
|
| return Status::ErrorUnsupported();
|
| unsigned int hmac_expected_length = EVP_MD_size(digest_algorithm);
|
|
|
| - // OpenSSL wierdness here.
|
| - // First, HMAC() needs a void* for the key data, so make one up front as a
|
| - // cosmetic to avoid a cast. Second, OpenSSL does not like a NULL key,
|
| - // which will result if the raw_key vector is empty; an entirely valid
|
| - // case. Handle this specific case by pointing to a fresh array.
|
| - const unsigned char null_key[] = {0};
|
| - const void* const raw_key_voidp = raw_key.size() ? &raw_key[0] : null_key;
|
| -
|
| buffer->resize(hmac_expected_length);
|
| crypto::ScopedOpenSSLSafeSizeBuffer<EVP_MAX_MD_SIZE> hmac_result(
|
| vector_as_array(buffer), hmac_expected_length);
|
|
|
| unsigned int hmac_actual_length;
|
| - unsigned char* const success =
|
| - HMAC(digest_algorithm, raw_key_voidp, raw_key.size(), data.bytes(),
|
| - data.byte_length(), hmac_result.safe_buffer(), &hmac_actual_length);
|
| + unsigned char* const success = HMAC(
|
| + digest_algorithm, vector_as_array(&raw_key), raw_key.size(), data.bytes(),
|
| + data.byte_length(), hmac_result.safe_buffer(), &hmac_actual_length);
|
| if (!success || hmac_actual_length != hmac_expected_length)
|
| return Status::OperationError();
|
|
|
|
|