diff options
author | Kenny Root <kroot@google.com> | 2015-09-25 02:29:14 +0000 |
---|---|---|
committer | Kenny Root <kroot@google.com> | 2015-09-25 02:29:14 +0000 |
commit | b8494591d1b1a143f3b192d845c238bbf3bc629d (patch) | |
tree | dd743d9d64af3145fe96b8d5fc2f3427544794bd /src/crypto/evp/evp_test.cc | |
parent | a04d78d392463df4e69a64360c952ffa5abd22f7 (diff) | |
download | external_boringssl-b8494591d1b1a143f3b192d845c238bbf3bc629d.zip external_boringssl-b8494591d1b1a143f3b192d845c238bbf3bc629d.tar.gz external_boringssl-b8494591d1b1a143f3b192d845c238bbf3bc629d.tar.bz2 |
Revert "Revert "external/boringssl: sync with upstream.""
This reverts commit a04d78d392463df4e69a64360c952ffa5abd22f7.
Underlying issue was fixed.
Change-Id: I49685b653d16e728eb38e79e02b2c33ddeefed88
Diffstat (limited to 'src/crypto/evp/evp_test.cc')
-rw-r--r-- | src/crypto/evp/evp_test.cc | 64 |
1 files changed, 14 insertions, 50 deletions
diff --git a/src/crypto/evp/evp_test.cc b/src/crypto/evp/evp_test.cc index 239f868..c7ac908 100644 --- a/src/crypto/evp/evp_test.cc +++ b/src/crypto/evp/evp_test.cc @@ -56,10 +56,19 @@ #include <stdlib.h> #include <string.h> +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable: 4702) +#endif + #include <map> #include <string> #include <vector> +#if defined(_MSC_VER) +#pragma warning(pop) +#endif + #include <openssl/bio.h> #include <openssl/crypto.h> #include <openssl/digest.h> @@ -72,11 +81,10 @@ #include "../test/stl_compat.h" -// evp_test dispatches between multiple test types. HMAC tests test the legacy -// EVP_PKEY_HMAC API. PrivateKey tests take a key name parameter and single -// block, decode it as a PEM private key, and save it under that key name. -// Decrypt, Sign, and Verify tests take a previously imported key name as -// parameter and test their respective operations. +// evp_test dispatches between multiple test types. PrivateKey tests take a key +// name parameter and single block, decode it as a PEM private key, and save it +// under that key name. Decrypt, Sign, and Verify tests take a previously +// imported key name as parameter and test their respective operations. static const EVP_MD *GetDigest(FileTest *t, const std::string &name) { if (name == "MD5") { @@ -120,54 +128,10 @@ static bool ImportPrivateKey(FileTest *t, KeyMap *key_map) { return true; } -static bool TestHMAC(FileTest *t) { - std::string digest_str; - if (!t->GetAttribute(&digest_str, "HMAC")) { - return false; - } - const EVP_MD *digest = GetDigest(t, digest_str); - if (digest == nullptr) { - return false; - } - - std::vector<uint8_t> key, input, output; - if (!t->GetBytes(&key, "Key") || - !t->GetBytes(&input, "Input") || - !t->GetBytes(&output, "Output")) { - return false; - } - - ScopedEVP_PKEY pkey(EVP_PKEY_new_mac_key(EVP_PKEY_HMAC, nullptr, - bssl::vector_data(&key), - key.size())); - ScopedEVP_MD_CTX mctx; - if (!pkey || - !EVP_DigestSignInit(mctx.get(), nullptr, digest, nullptr, pkey.get()) || - !EVP_DigestSignUpdate(mctx.get(), bssl::vector_data(&input), - input.size())) { - return false; - } - - size_t len; - std::vector<uint8_t> actual; - if (!EVP_DigestSignFinal(mctx.get(), nullptr, &len)) { - return false; - } - actual.resize(len); - if (!EVP_DigestSignFinal(mctx.get(), bssl::vector_data(&actual), &len)) { - return false; - } - actual.resize(len); - return t->ExpectBytesEqual(bssl::vector_data(&output), output.size(), - bssl::vector_data(&actual), actual.size()); -} - static bool TestEVP(FileTest *t, void *arg) { KeyMap *key_map = reinterpret_cast<KeyMap*>(arg); if (t->GetType() == "PrivateKey") { return ImportPrivateKey(t, key_map); - } else if (t->GetType() == "HMAC") { - return TestHMAC(t); } int (*key_op_init)(EVP_PKEY_CTX *ctx); @@ -219,7 +183,7 @@ static bool TestEVP(FileTest *t, void *arg) { bssl::vector_data(&input), input.size())) { // ECDSA sometimes doesn't push an error code. Push one on the error queue // so it's distinguishable from other errors. - ERR_put_error(ERR_LIB_USER, 0, ERR_R_EVP_LIB, __FILE__, __LINE__); + OPENSSL_PUT_ERROR(USER, ERR_R_EVP_LIB); return false; } return true; |