Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2896)

Unified Diff: content/renderer/webcrypto_impl_unittest.cc

Issue 24616003: Implement verify() for HMAC using NSS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix_build_sh
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/webcrypto_impl_unittest.cc
diff --git a/content/renderer/webcrypto_impl_unittest.cc b/content/renderer/webcrypto_impl_unittest.cc
index 8a9a1004b86027bb4f7bcb82d35a669ab4d92840..1fd49012c40476a839a8bf709d0621c8c663879f 100644
--- a/content/renderer/webcrypto_impl_unittest.cc
+++ b/content/renderer/webcrypto_impl_unittest.cc
@@ -271,6 +271,30 @@ TEST_F(WebCryptoImplTest, HMACSampleSets) {
input_set[index].mac,
base::HexEncode(
array_buffer.data(), array_buffer.byteLength()).c_str());
+
+ bool signature_match = false;
+ EXPECT_TRUE(
+ crypto.VerifySignatureInternal(
+ hmac_algorithm,
+ crypto_key,
+ static_cast<const unsigned char*>(array_buffer.data()),
+ array_buffer.byteLength(),
+ message_raw.data(),
+ message_raw.size(),
+ &signature_match));
+ EXPECT_TRUE(signature_match);
+
+ // Ensure truncated signature does not verify by passing one less byte.
+ EXPECT_TRUE(
+ crypto.VerifySignatureInternal(
+ hmac_algorithm,
+ crypto_key,
+ static_cast<const unsigned char*>(array_buffer.data()),
+ array_buffer.byteLength() - 1,
+ message_raw.data(),
+ message_raw.size(),
+ &signature_match));
+ EXPECT_FALSE(signature_match);
}
}
« content/renderer/webcrypto_impl_nss.cc ('K') | « content/renderer/webcrypto_impl_openssl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698