Index: content/renderer/webcrypto/shared_crypto_unittest.cc |
diff --git a/content/renderer/webcrypto/webcrypto_impl_unittest.cc b/content/renderer/webcrypto/shared_crypto_unittest.cc |
similarity index 70% |
rename from content/renderer/webcrypto/webcrypto_impl_unittest.cc |
rename to content/renderer/webcrypto/shared_crypto_unittest.cc |
index ba2e80a9dc10b9d6f3bd6ed3d3e08d54354f9b8c..465d3d1bb8fa90a045aa45a1e1eaf3c8416298da 100644 |
--- a/content/renderer/webcrypto/webcrypto_impl_unittest.cc |
+++ b/content/renderer/webcrypto/shared_crypto_unittest.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "content/renderer/webcrypto/webcrypto_impl.h" |
+#include "content/renderer/webcrypto/shared_crypto.h" |
#include <algorithm> |
#include <string> |
@@ -20,6 +20,7 @@ |
#include "content/public/common/content_paths.h" |
#include "content/public/renderer/content_renderer_client.h" |
#include "content/renderer/renderer_webkitplatformsupport_impl.h" |
+#include "content/renderer/webcrypto/crypto_data.h" |
#include "content/renderer/webcrypto/webcrypto_util.h" |
#include "testing/gtest/include/gtest/gtest.h" |
#include "third_party/WebKit/public/platform/WebArrayBuffer.h" |
@@ -47,7 +48,7 @@ |
namespace content { |
-using webcrypto::Status; |
+namespace webcrypto { |
namespace { |
@@ -69,25 +70,17 @@ std::vector<uint8> HexStringToBytes(const std::string& hex) { |
return bytes; |
} |
-void ExpectArrayBufferMatches(const std::vector<uint8>& expected, |
- const blink::WebArrayBuffer& actual) { |
- EXPECT_EQ( |
- base::HexEncode(webcrypto::Uint8VectorStart(expected), expected.size()), |
- base::HexEncode(actual.data(), actual.byteLength())); |
+void ExpectCryptoDataMatches(const CryptoData& expected, |
+ const CryptoData& actual) { |
+ EXPECT_EQ(base::HexEncode(expected.bytes(), expected.byte_length()), |
+ base::HexEncode(actual.bytes(), actual.byte_length())); |
} |
-void ExpectArrayBufferMatchesHex(const std::string& expected_hex, |
- const blink::WebArrayBuffer& array_buffer) { |
+void ExpectCryptoDataMatchesHex(const std::string& expected_hex, |
+ const CryptoData& actual) { |
EXPECT_STRCASEEQ( |
expected_hex.c_str(), |
- base::HexEncode(array_buffer.data(), array_buffer.byteLength()).c_str()); |
-} |
- |
-void ExpectVectorMatches(const std::vector<uint8>& expected, |
- const std::vector<uint8>& actual) { |
- EXPECT_EQ( |
- base::HexEncode(webcrypto::Uint8VectorStart(expected), expected.size()), |
- base::HexEncode(webcrypto::Uint8VectorStart(actual), actual.size())); |
+ base::HexEncode(actual.bytes(), actual.byte_length()).c_str()); |
} |
std::vector<uint8> MakeJsonVector(const std::string& json_string) { |
@@ -198,7 +191,7 @@ blink::WebCryptoAlgorithm GetDigestAlgorithm( |
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kDigestNameToId); ++i) { |
if (kDigestNameToId[i].name == algorithm_name) |
- return webcrypto::CreateAlgorithm(kDigestNameToId[i].id); |
+ return CreateAlgorithm(kDigestNameToId[i].id); |
} |
return blink::WebCryptoAlgorithm::createNull(); |
@@ -222,9 +215,9 @@ blink::WebCryptoAlgorithm CreateAesGcmAlgorithm( |
return blink::WebCryptoAlgorithm::adoptParamsAndCreate( |
blink::WebCryptoAlgorithmIdAesGcm, |
new blink::WebCryptoAesGcmParams( |
- webcrypto::Uint8VectorStart(iv), iv.size(), |
+ Uint8VectorStart(iv), iv.size(), |
true, |
- webcrypto::Uint8VectorStart(additional_data), |
+ Uint8VectorStart(additional_data), |
additional_data.size(), |
true, tag_length_bits)); |
} |
@@ -249,10 +242,10 @@ blink::WebCryptoAlgorithm CreateRsaAlgorithmWithInnerHash( |
blink::WebCryptoAlgorithmId hash_id) { |
DCHECK(algorithm_id == blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5 || |
algorithm_id == blink::WebCryptoAlgorithmIdRsaOaep); |
- DCHECK(webcrypto::IsHashAlgorithm(hash_id)); |
+ DCHECK(IsHashAlgorithm(hash_id)); |
return blink::WebCryptoAlgorithm::adoptParamsAndCreate( |
algorithm_id, |
- new blink::WebCryptoRsaSsaParams(webcrypto::CreateAlgorithm(hash_id))); |
+ new blink::WebCryptoRsaSsaParams(CreateAlgorithm(hash_id))); |
} |
// Determines if two ArrayBuffers have identical content. |
@@ -335,296 +328,150 @@ const char* const kPrivateKeyPkcs8DerHex = |
"584b8e22fdde1e5a2e3bd8aa5ba8d8584194eb2190acf832b847f13a3d24" |
"a79f4d"; |
-} // namespace |
- |
-class WebCryptoImplTest : public testing::Test { |
+class SharedCryptoTest : public testing::Test { |
protected: |
- blink::WebCryptoKey ImportSecretKeyFromRaw( |
- const std::vector<uint8>& key_raw, |
- const blink::WebCryptoAlgorithm& algorithm, |
- blink::WebCryptoKeyUsageMask usage) { |
- blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); |
- bool extractable = true; |
- EXPECT_STATUS_SUCCESS( |
- crypto_.ImportKeyInternal(blink::WebCryptoKeyFormatRaw, |
- webcrypto::Uint8VectorStart(key_raw), |
- key_raw.size(), |
- algorithm, |
- extractable, |
- usage, |
- &key)); |
- |
- EXPECT_FALSE(key.isNull()); |
- EXPECT_TRUE(key.handle()); |
- EXPECT_EQ(blink::WebCryptoKeyTypeSecret, key.type()); |
- EXPECT_EQ(algorithm.id(), key.algorithm().id()); |
- EXPECT_EQ(extractable, key.extractable()); |
- EXPECT_EQ(usage, key.usages()); |
- return key; |
- } |
- |
- void ImportRsaKeyPair( |
- const std::vector<uint8>& spki_der, |
- const std::vector<uint8>& pkcs8_der, |
- const blink::WebCryptoAlgorithm& algorithm, |
- bool extractable, |
- blink::WebCryptoKeyUsageMask usage_mask, |
- blink::WebCryptoKey* public_key, |
- blink::WebCryptoKey* private_key) { |
- EXPECT_STATUS_SUCCESS(ImportKeyInternal( |
- blink::WebCryptoKeyFormatSpki, |
- spki_der, |
- algorithm, |
- true, |
- usage_mask, |
- public_key)); |
- EXPECT_FALSE(public_key->isNull()); |
- EXPECT_TRUE(public_key->handle()); |
- EXPECT_EQ(blink::WebCryptoKeyTypePublic, public_key->type()); |
- EXPECT_EQ(algorithm.id(), public_key->algorithm().id()); |
- EXPECT_EQ(extractable, extractable); |
- EXPECT_EQ(usage_mask, public_key->usages()); |
- |
- EXPECT_STATUS_SUCCESS(ImportKeyInternal( |
- blink::WebCryptoKeyFormatPkcs8, |
- pkcs8_der, |
- algorithm, |
- extractable, |
- usage_mask, |
- private_key)); |
- EXPECT_FALSE(private_key->isNull()); |
- EXPECT_TRUE(private_key->handle()); |
- EXPECT_EQ(blink::WebCryptoKeyTypePrivate, private_key->type()); |
- EXPECT_EQ(algorithm.id(), private_key->algorithm().id()); |
- EXPECT_EQ(extractable, extractable); |
- EXPECT_EQ(usage_mask, private_key->usages()); |
- } |
- |
- // TODO(eroman): For Linux builds using system NSS, AES-GCM support is a |
- // runtime dependency. Test it by trying to import a key. |
- bool SupportsAesGcm() { |
- std::vector<uint8> key_raw(16, 0); |
- |
- blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); |
- Status status = crypto_.ImportKeyInternal( |
- blink::WebCryptoKeyFormatRaw, |
- webcrypto::Uint8VectorStart(key_raw), |
- key_raw.size(), |
- webcrypto::CreateAlgorithm(blink::WebCryptoAlgorithmIdAesGcm), |
- true, |
- blink::WebCryptoKeyUsageEncrypt, |
- &key); |
- |
- if (status.IsError()) |
- EXPECT_EQ(Status::ErrorUnsupported().ToString(), status.ToString()); |
- return status.IsSuccess(); |
- |
- } |
- |
- Status AesGcmEncrypt(const blink::WebCryptoKey& key, |
- const std::vector<uint8>& iv, |
- const std::vector<uint8>& additional_data, |
- unsigned int tag_length_bits, |
- const std::vector<uint8>& plain_text, |
- std::vector<uint8>* cipher_text, |
- std::vector<uint8>* authentication_tag) { |
- blink::WebCryptoAlgorithm algorithm = CreateAesGcmAlgorithm( |
- iv, additional_data, tag_length_bits); |
- |
- blink::WebArrayBuffer output; |
- Status status = EncryptInternal(algorithm, key, plain_text, &output); |
- if (status.IsError()) |
- return status; |
- |
- if (output.byteLength() * 8 < tag_length_bits) { |
- EXPECT_TRUE(false); |
- return Status::Error(); |
- } |
- |
- // The encryption result is cipher text with authentication tag appended. |
- cipher_text->assign( |
- static_cast<uint8*>(output.data()), |
- static_cast<uint8*>(output.data()) + |
- (output.byteLength() - tag_length_bits / 8)); |
- authentication_tag->assign( |
- static_cast<uint8*>(output.data()) + cipher_text->size(), |
- static_cast<uint8*>(output.data()) + output.byteLength()); |
- |
- return Status::Success(); |
- } |
- |
- Status AesGcmDecrypt(const blink::WebCryptoKey& key, |
- const std::vector<uint8>& iv, |
- const std::vector<uint8>& additional_data, |
- unsigned int tag_length_bits, |
- const std::vector<uint8>& cipher_text, |
- const std::vector<uint8>& authentication_tag, |
- blink::WebArrayBuffer* plain_text) { |
- blink::WebCryptoAlgorithm algorithm = CreateAesGcmAlgorithm( |
- iv, additional_data, tag_length_bits); |
- |
- // Join cipher text and authentication tag. |
- std::vector<uint8> cipher_text_with_tag; |
- cipher_text_with_tag.reserve( |
- cipher_text.size() + authentication_tag.size()); |
- cipher_text_with_tag.insert( |
- cipher_text_with_tag.end(), cipher_text.begin(), cipher_text.end()); |
- cipher_text_with_tag.insert( |
- cipher_text_with_tag.end(), authentication_tag.begin(), |
- authentication_tag.end()); |
- |
- return DecryptInternal(algorithm, key, cipher_text_with_tag, plain_text); |
- } |
- |
- // Forwarding methods to gain access to protected methods of |
- // WebCryptoImpl. |
- |
- Status DigestInternal( |
- const blink::WebCryptoAlgorithm& algorithm, |
- const std::vector<uint8>& data, |
- blink::WebArrayBuffer* buffer) { |
- return crypto_.DigestInternal( |
- algorithm, webcrypto::Uint8VectorStart(data), data.size(), buffer); |
+ virtual void SetUp() OVERRIDE { |
+ Init(); |
} |
+}; |
- Status GenerateKeyInternal( |
- const blink::WebCryptoAlgorithm& algorithm, |
- blink::WebCryptoKey* key) { |
- bool extractable = true; |
- blink::WebCryptoKeyUsageMask usage_mask = 0; |
- return crypto_.GenerateSecretKeyInternal( |
- algorithm, extractable, usage_mask, key); |
- } |
+blink::WebCryptoKey ImportSecretKeyFromRaw( |
+ const std::vector<uint8>& key_raw, |
+ const blink::WebCryptoAlgorithm& algorithm, |
+ blink::WebCryptoKeyUsageMask usage) { |
+ blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); |
+ bool extractable = true; |
+ EXPECT_STATUS_SUCCESS( |
+ ImportKey(blink::WebCryptoKeyFormatRaw, |
+ key_raw, |
+ algorithm, |
+ extractable, |
+ usage, |
+ &key)); |
- Status GenerateKeyPairInternal( |
- const blink::WebCryptoAlgorithm& algorithm, |
- bool extractable, |
- blink::WebCryptoKeyUsageMask usage_mask, |
- blink::WebCryptoKey* public_key, |
- blink::WebCryptoKey* private_key) { |
- return crypto_.GenerateKeyPairInternal( |
- algorithm, extractable, usage_mask, public_key, private_key); |
- } |
+ EXPECT_FALSE(key.isNull()); |
+ EXPECT_TRUE(key.handle()); |
+ EXPECT_EQ(blink::WebCryptoKeyTypeSecret, key.type()); |
+ EXPECT_EQ(algorithm.id(), key.algorithm().id()); |
+ EXPECT_EQ(extractable, key.extractable()); |
+ EXPECT_EQ(usage, key.usages()); |
+ return key; |
+} |
- Status ImportKeyInternal( |
- blink::WebCryptoKeyFormat format, |
- const std::vector<uint8>& key_data, |
- const blink::WebCryptoAlgorithm& algorithm, |
- bool extractable, |
- blink::WebCryptoKeyUsageMask usage_mask, |
- blink::WebCryptoKey* key) { |
- return crypto_.ImportKeyInternal(format, |
- webcrypto::Uint8VectorStart(key_data), |
- key_data.size(), |
- algorithm, |
- extractable, |
- usage_mask, |
- key); |
- } |
+void ImportRsaKeyPair( |
+ const std::vector<uint8>& spki_der, |
+ const std::vector<uint8>& pkcs8_der, |
+ const blink::WebCryptoAlgorithm& algorithm, |
+ bool extractable, |
+ blink::WebCryptoKeyUsageMask usage_mask, |
+ blink::WebCryptoKey* public_key, |
+ blink::WebCryptoKey* private_key) { |
+ EXPECT_STATUS_SUCCESS(ImportKey( |
+ blink::WebCryptoKeyFormatSpki, |
+ spki_der, |
+ algorithm, |
+ true, |
+ usage_mask, |
+ public_key)); |
+ EXPECT_FALSE(public_key->isNull()); |
+ EXPECT_TRUE(public_key->handle()); |
+ EXPECT_EQ(blink::WebCryptoKeyTypePublic, public_key->type()); |
+ EXPECT_EQ(algorithm.id(), public_key->algorithm().id()); |
+ EXPECT_EQ(extractable, extractable); |
+ EXPECT_EQ(usage_mask, public_key->usages()); |
+ |
+ EXPECT_STATUS_SUCCESS(ImportKey( |
+ blink::WebCryptoKeyFormatPkcs8, |
+ pkcs8_der, |
+ algorithm, |
+ extractable, |
+ usage_mask, |
+ private_key)); |
+ EXPECT_FALSE(private_key->isNull()); |
+ EXPECT_TRUE(private_key->handle()); |
+ EXPECT_EQ(blink::WebCryptoKeyTypePrivate, private_key->type()); |
+ EXPECT_EQ(algorithm.id(), private_key->algorithm().id()); |
+ EXPECT_EQ(extractable, extractable); |
+ EXPECT_EQ(usage_mask, private_key->usages()); |
+} |
- Status ExportKeyInternal( |
- blink::WebCryptoKeyFormat format, |
- const blink::WebCryptoKey& key, |
- blink::WebArrayBuffer* buffer) { |
- return crypto_.ExportKeyInternal(format, key, buffer); |
- } |
+// TODO(eroman): For Linux builds using system NSS, AES-GCM support is a |
+// runtime dependency. Test it by trying to import a key. |
+bool SupportsAesGcm() { |
+ std::vector<uint8> key_raw(16, 0); |
- Status SignInternal( |
- const blink::WebCryptoAlgorithm& algorithm, |
- const blink::WebCryptoKey& key, |
- const std::vector<uint8>& data, |
- blink::WebArrayBuffer* buffer) { |
- return crypto_.SignInternal( |
- algorithm, key, webcrypto::Uint8VectorStart(data), data.size(), buffer); |
- } |
+ blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); |
+ Status status = ImportKey( |
+ blink::WebCryptoKeyFormatRaw, |
+ key_raw, |
+ CreateAlgorithm(blink::WebCryptoAlgorithmIdAesGcm), |
+ true, |
+ blink::WebCryptoKeyUsageEncrypt, |
+ &key); |
- Status VerifySignatureInternal( |
- const blink::WebCryptoAlgorithm& algorithm, |
- const blink::WebCryptoKey& key, |
- const unsigned char* signature, |
- unsigned int signature_size, |
- const std::vector<uint8>& data, |
- bool* signature_match) { |
- return crypto_.VerifySignatureInternal(algorithm, |
- key, |
- signature, |
- signature_size, |
- webcrypto::Uint8VectorStart(data), |
- data.size(), |
- signature_match); |
- } |
+ if (status.IsError()) |
+ EXPECT_EQ(Status::ErrorUnsupported().ToString(), status.ToString()); |
+ return status.IsSuccess(); |
+} |
- Status VerifySignatureInternal( |
- const blink::WebCryptoAlgorithm& algorithm, |
- const blink::WebCryptoKey& key, |
- const std::vector<uint8>& signature, |
- const std::vector<uint8>& data, |
- bool* signature_match) { |
- return crypto_.VerifySignatureInternal( |
- algorithm, |
- key, |
- webcrypto::Uint8VectorStart(signature), |
- signature.size(), |
- webcrypto::Uint8VectorStart(data), |
- data.size(), |
- signature_match); |
- } |
+Status AesGcmEncrypt(const blink::WebCryptoKey& key, |
+ const std::vector<uint8>& iv, |
+ const std::vector<uint8>& additional_data, |
+ unsigned int tag_length_bits, |
+ const std::vector<uint8>& plain_text, |
+ std::vector<uint8>* cipher_text, |
+ std::vector<uint8>* authentication_tag) { |
+ blink::WebCryptoAlgorithm algorithm = CreateAesGcmAlgorithm( |
+ iv, additional_data, tag_length_bits); |
- Status EncryptInternal( |
- const blink::WebCryptoAlgorithm& algorithm, |
- const blink::WebCryptoKey& key, |
- const unsigned char* data, |
- unsigned int data_size, |
- blink::WebArrayBuffer* buffer) { |
- return crypto_.EncryptInternal(algorithm, key, data, data_size, buffer); |
- } |
+ blink::WebArrayBuffer output; |
+ Status status = Encrypt(algorithm, key, plain_text, &output); |
+ if (status.IsError()) |
+ return status; |
- Status EncryptInternal( |
- const blink::WebCryptoAlgorithm& algorithm, |
- const blink::WebCryptoKey& key, |
- const std::vector<uint8>& data, |
- blink::WebArrayBuffer* buffer) { |
- return crypto_.EncryptInternal( |
- algorithm, key, webcrypto::Uint8VectorStart(data), data.size(), buffer); |
+ if (output.byteLength() * 8 < tag_length_bits) { |
+ EXPECT_TRUE(false); |
+ return Status::Error(); |
} |
- Status DecryptInternal( |
- const blink::WebCryptoAlgorithm& algorithm, |
- const blink::WebCryptoKey& key, |
- const unsigned char* data, |
- unsigned int data_size, |
- blink::WebArrayBuffer* buffer) { |
- return crypto_.DecryptInternal(algorithm, key, data, data_size, buffer); |
- } |
+ // The encryption result is cipher text with authentication tag appended. |
+ cipher_text->assign( |
+ static_cast<uint8*>(output.data()), |
+ static_cast<uint8*>(output.data()) + |
+ (output.byteLength() - tag_length_bits / 8)); |
+ authentication_tag->assign( |
+ static_cast<uint8*>(output.data()) + cipher_text->size(), |
+ static_cast<uint8*>(output.data()) + output.byteLength()); |
- Status DecryptInternal( |
- const blink::WebCryptoAlgorithm& algorithm, |
- const blink::WebCryptoKey& key, |
- const std::vector<uint8>& data, |
- blink::WebArrayBuffer* buffer) { |
- return crypto_.DecryptInternal( |
- algorithm, key, webcrypto::Uint8VectorStart(data), data.size(), buffer); |
- } |
+ return Status::Success(); |
+} |
- Status ImportKeyJwk( |
- const std::vector<uint8>& key_data, |
- const blink::WebCryptoAlgorithm& algorithm, |
- bool extractable, |
- blink::WebCryptoKeyUsageMask usage_mask, |
- blink::WebCryptoKey* key) { |
- return crypto_.ImportKeyJwk(webcrypto::Uint8VectorStart(key_data), |
- key_data.size(), |
- algorithm, |
- extractable, |
- usage_mask, |
- key); |
- } |
+Status AesGcmDecrypt(const blink::WebCryptoKey& key, |
+ const std::vector<uint8>& iv, |
+ const std::vector<uint8>& additional_data, |
+ unsigned int tag_length_bits, |
+ const std::vector<uint8>& cipher_text, |
+ const std::vector<uint8>& authentication_tag, |
+ blink::WebArrayBuffer* plain_text) { |
+ blink::WebCryptoAlgorithm algorithm = CreateAesGcmAlgorithm( |
+ iv, additional_data, tag_length_bits); |
+ |
+ // Join cipher text and authentication tag. |
+ std::vector<uint8> cipher_text_with_tag; |
+ cipher_text_with_tag.reserve( |
+ cipher_text.size() + authentication_tag.size()); |
+ cipher_text_with_tag.insert( |
+ cipher_text_with_tag.end(), cipher_text.begin(), cipher_text.end()); |
+ cipher_text_with_tag.insert( |
+ cipher_text_with_tag.end(), authentication_tag.begin(), |
+ authentication_tag.end()); |
+ |
+ return Decrypt(algorithm, key, cipher_text_with_tag, plain_text); |
+} |
- private: |
- WebCryptoImpl crypto_; |
-}; |
+} // namespace |
-TEST_F(WebCryptoImplTest, StatusToString) { |
+TEST_F(SharedCryptoTest, StatusToString) { |
EXPECT_EQ("Success", Status::Success().ToString()); |
EXPECT_EQ("", Status::Error().ToString()); |
EXPECT_EQ("The requested operation is unsupported", |
@@ -637,7 +484,7 @@ TEST_F(WebCryptoImplTest, StatusToString) { |
Status::ErrorJwkBase64Decode("n").ToString()); |
} |
-TEST_F(WebCryptoImplTest, DigestSampleSets) { |
+TEST_F(SharedCryptoTest, DigestSampleSets) { |
scoped_ptr<base::ListValue> tests; |
ASSERT_TRUE(ReadJsonTestFileToList("digest.json", &tests)); |
@@ -652,12 +499,12 @@ TEST_F(WebCryptoImplTest, DigestSampleSets) { |
std::vector<uint8> test_output = GetBytesFromHexString(test, "output"); |
blink::WebArrayBuffer output; |
- ASSERT_STATUS_SUCCESS(DigestInternal(test_algorithm, test_input, &output)); |
- ExpectArrayBufferMatches(test_output, output); |
+ ASSERT_STATUS_SUCCESS(Digest(test_algorithm, test_input, &output)); |
+ ExpectCryptoDataMatches(test_output, output); |
} |
} |
-TEST_F(WebCryptoImplTest, HMACSampleSets) { |
+TEST_F(SharedCryptoTest, HMACSampleSets) { |
scoped_ptr<base::ListValue> tests; |
ASSERT_TRUE(ReadJsonTestFileToList("hmac.json", &tests)); |
@@ -673,78 +520,77 @@ TEST_F(WebCryptoImplTest, HMACSampleSets) { |
const std::vector<uint8> test_mac = GetBytesFromHexString(test, "mac"); |
blink::WebCryptoAlgorithm algorithm = |
- webcrypto::CreateHmacAlgorithmByHashId(test_hash.id()); |
+ CreateHmacAlgorithmByHashId(test_hash.id()); |
blink::WebCryptoKey key = ImportSecretKeyFromRaw( |
- test_key, algorithm, blink::WebCryptoKeyUsageSign); |
+ test_key, |
+ algorithm, |
+ blink::WebCryptoKeyUsageSign | blink::WebCryptoKeyUsageVerify); |
// Verify exported raw key is identical to the imported data |
blink::WebArrayBuffer raw_key; |
EXPECT_STATUS_SUCCESS( |
- ExportKeyInternal(blink::WebCryptoKeyFormatRaw, key, &raw_key)); |
- ExpectArrayBufferMatches(test_key, raw_key); |
+ ExportKey(blink::WebCryptoKeyFormatRaw, key, &raw_key)); |
+ ExpectCryptoDataMatches(test_key, raw_key); |
blink::WebArrayBuffer output; |
- ASSERT_STATUS_SUCCESS(SignInternal(algorithm, key, test_message, &output)); |
+ ASSERT_STATUS_SUCCESS(Sign(algorithm, key, test_message, &output)); |
- ExpectArrayBufferMatches(test_mac, output); |
+ ExpectCryptoDataMatches(test_mac, output); |
bool signature_match = false; |
- EXPECT_STATUS_SUCCESS(VerifySignatureInternal( |
+ EXPECT_STATUS_SUCCESS(VerifySignature( |
algorithm, |
key, |
- static_cast<const unsigned char*>(output.data()), |
- output.byteLength(), |
+ output, |
test_message, |
&signature_match)); |
EXPECT_TRUE(signature_match); |
// Ensure truncated signature does not verify by passing one less byte. |
- EXPECT_STATUS_SUCCESS(VerifySignatureInternal( |
+ EXPECT_STATUS_SUCCESS(VerifySignature( |
algorithm, |
key, |
- static_cast<const unsigned char*>(output.data()), |
- output.byteLength() - 1, |
+ CryptoData(static_cast<const unsigned char*>(output.data()), |
+ output.byteLength() - 1), |
test_message, |
&signature_match)); |
EXPECT_FALSE(signature_match); |
// Ensure truncated signature does not verify by passing no bytes. |
- EXPECT_STATUS_SUCCESS(VerifySignatureInternal( |
+ EXPECT_STATUS_SUCCESS(VerifySignature( |
algorithm, |
key, |
- NULL, |
- 0, |
+ CryptoData(), |
test_message, |
&signature_match)); |
EXPECT_FALSE(signature_match); |
// Ensure extra long signature does not cause issues and fails. |
const unsigned char kLongSignature[1024] = { 0 }; |
- EXPECT_STATUS_SUCCESS(VerifySignatureInternal( |
+ EXPECT_STATUS_SUCCESS(VerifySignature( |
algorithm, |
key, |
- kLongSignature, |
- sizeof(kLongSignature), |
+ CryptoData(kLongSignature, sizeof(kLongSignature)), |
test_message, |
&signature_match)); |
EXPECT_FALSE(signature_match); |
} |
} |
-TEST_F(WebCryptoImplTest, AesCbcFailures) { |
+TEST_F(SharedCryptoTest, AesCbcFailures) { |
const std::string key_hex = "2b7e151628aed2a6abf7158809cf4f3c"; |
blink::WebCryptoKey key = ImportSecretKeyFromRaw( |
HexStringToBytes(key_hex), |
- webcrypto::CreateAlgorithm(blink::WebCryptoAlgorithmIdAesCbc), |
+ CreateAlgorithm(blink::WebCryptoAlgorithmIdAesCbc), |
blink::WebCryptoKeyUsageEncrypt | blink::WebCryptoKeyUsageDecrypt); |
// Verify exported raw key is identical to the imported data |
blink::WebArrayBuffer raw_key; |
EXPECT_STATUS_SUCCESS( |
- ExportKeyInternal(blink::WebCryptoKeyFormatRaw, key, &raw_key)); |
- ExpectArrayBufferMatchesHex(key_hex, raw_key); |
+ ExportKey(blink::WebCryptoKeyFormatRaw, key, &raw_key)); |
+ ExpectCryptoDataMatchesHex(key_hex, raw_key); |
blink::WebArrayBuffer output; |
@@ -752,20 +598,20 @@ TEST_F(WebCryptoImplTest, AesCbcFailures) { |
{ |
std::vector<uint8> input(32); |
std::vector<uint8> iv; |
- EXPECT_STATUS(Status::ErrorIncorrectSizeAesCbcIv(), EncryptInternal( |
- webcrypto::CreateAesCbcAlgorithm(iv), key, input, &output)); |
- EXPECT_STATUS(Status::ErrorIncorrectSizeAesCbcIv(), DecryptInternal( |
- webcrypto::CreateAesCbcAlgorithm(iv), key, input, &output)); |
+ EXPECT_STATUS(Status::ErrorIncorrectSizeAesCbcIv(), Encrypt( |
+ CreateAesCbcAlgorithm(iv), key, input, &output)); |
+ EXPECT_STATUS(Status::ErrorIncorrectSizeAesCbcIv(), Decrypt( |
+ CreateAesCbcAlgorithm(iv), key, input, &output)); |
} |
// Use an invalid |iv| (more than 16 bytes) |
{ |
std::vector<uint8> input(32); |
std::vector<uint8> iv(17); |
- EXPECT_STATUS(Status::ErrorIncorrectSizeAesCbcIv(), EncryptInternal( |
- webcrypto::CreateAesCbcAlgorithm(iv), key, input, &output)); |
- EXPECT_STATUS(Status::ErrorIncorrectSizeAesCbcIv(), DecryptInternal( |
- webcrypto::CreateAesCbcAlgorithm(iv), key, input, &output)); |
+ EXPECT_STATUS(Status::ErrorIncorrectSizeAesCbcIv(), Encrypt( |
+ CreateAesCbcAlgorithm(iv), key, input, &output)); |
+ EXPECT_STATUS(Status::ErrorIncorrectSizeAesCbcIv(), Decrypt( |
+ CreateAesCbcAlgorithm(iv), key, input, &output)); |
} |
// Give an input that is too large (would cause integer overflow when |
@@ -776,13 +622,12 @@ TEST_F(WebCryptoImplTest, AesCbcFailures) { |
// Pretend the input is large. Don't pass data pointer as NULL in case that |
// is special cased; the implementation shouldn't actually dereference the |
// data. |
- const unsigned char* input = &iv[0]; |
- unsigned int input_len = INT_MAX - 3; |
+ CryptoData input(&iv[0], INT_MAX - 3); |
- EXPECT_STATUS(Status::ErrorDataTooLarge(), EncryptInternal( |
- webcrypto::CreateAesCbcAlgorithm(iv), key, input, input_len, &output)); |
- EXPECT_STATUS(Status::ErrorDataTooLarge(), DecryptInternal( |
- webcrypto::CreateAesCbcAlgorithm(iv), key, input, input_len, &output)); |
+ EXPECT_STATUS(Status::ErrorDataTooLarge(), Encrypt( |
+ CreateAesCbcAlgorithm(iv), key, input, &output)); |
+ EXPECT_STATUS(Status::ErrorDataTooLarge(), Decrypt( |
+ CreateAesCbcAlgorithm(iv), key, input, &output)); |
} |
// Fail importing the key (too few bytes specified) |
@@ -793,26 +638,23 @@ TEST_F(WebCryptoImplTest, AesCbcFailures) { |
blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); |
EXPECT_STATUS( |
Status::Error(), |
- ImportKeyInternal(blink::WebCryptoKeyFormatRaw, |
+ ImportKey(blink::WebCryptoKeyFormatRaw, |
key_raw, |
- webcrypto::CreateAesCbcAlgorithm(iv), |
+ CreateAesCbcAlgorithm(iv), |
true, |
blink::WebCryptoKeyUsageEncrypt, |
&key)); |
} |
- // TODO(eroman): Enable for OpenSSL once implemented. |
-#if !defined(USE_OPENSSL) |
// Fail exporting the key in SPKI and PKCS#8 formats (not allowed for secret |
// keys). |
EXPECT_STATUS(Status::ErrorUnexpectedKeyType(), |
- ExportKeyInternal(blink::WebCryptoKeyFormatSpki, key, &output)); |
+ ExportKey(blink::WebCryptoKeyFormatSpki, key, &output)); |
EXPECT_STATUS(Status::ErrorUnsupported(), |
- ExportKeyInternal(blink::WebCryptoKeyFormatPkcs8, key, &output)); |
-#endif |
+ ExportKey(blink::WebCryptoKeyFormatPkcs8, key, &output)); |
} |
-TEST_F(WebCryptoImplTest, MAYBE(AesCbcSampleSets)) { |
+TEST_F(SharedCryptoTest, MAYBE(AesCbcSampleSets)) { |
scoped_ptr<base::ListValue> tests; |
ASSERT_TRUE(ReadJsonTestFileToList("aes_cbc.json", &tests)); |
@@ -830,34 +672,34 @@ TEST_F(WebCryptoImplTest, MAYBE(AesCbcSampleSets)) { |
blink::WebCryptoKey key = ImportSecretKeyFromRaw( |
test_key, |
- webcrypto::CreateAlgorithm(blink::WebCryptoAlgorithmIdAesCbc), |
+ CreateAlgorithm(blink::WebCryptoAlgorithmIdAesCbc), |
blink::WebCryptoKeyUsageEncrypt | blink::WebCryptoKeyUsageDecrypt); |
// Verify exported raw key is identical to the imported data |
blink::WebArrayBuffer raw_key; |
- EXPECT_STATUS_SUCCESS(ExportKeyInternal( |
+ EXPECT_STATUS_SUCCESS(ExportKey( |
blink::WebCryptoKeyFormatRaw, key, &raw_key)); |
- ExpectArrayBufferMatches(test_key, raw_key); |
+ ExpectCryptoDataMatches(test_key, raw_key); |
blink::WebArrayBuffer output; |
// Test encryption. |
EXPECT_STATUS( |
Status::Success(), |
- EncryptInternal(webcrypto::CreateAesCbcAlgorithm(test_iv), |
+ Encrypt(CreateAesCbcAlgorithm(test_iv), |
key, |
test_plain_text, |
&output)); |
- ExpectArrayBufferMatches(test_cipher_text, output); |
+ ExpectCryptoDataMatches(test_cipher_text, output); |
// Test decryption. |
EXPECT_STATUS( |
Status::Success(), |
- DecryptInternal(webcrypto::CreateAesCbcAlgorithm(test_iv), |
+ Decrypt(CreateAesCbcAlgorithm(test_iv), |
key, |
test_cipher_text, |
&output)); |
- ExpectArrayBufferMatches(test_plain_text, output); |
+ ExpectCryptoDataMatches(test_plain_text, output); |
const unsigned int kAesCbcBlockSize = 16; |
@@ -866,11 +708,12 @@ TEST_F(WebCryptoImplTest, MAYBE(AesCbcSampleSets)) { |
if (test_cipher_text.size() >= kAesCbcBlockSize) { |
EXPECT_STATUS( |
Status::Error(), |
- DecryptInternal(webcrypto::CreateAesCbcAlgorithm(test_iv), |
+ Decrypt(CreateAesCbcAlgorithm(test_iv), |
key, |
- &test_cipher_text[0], |
- test_cipher_text.size() - kAesCbcBlockSize, |
- &output)); |
+ CryptoData( |
+ &test_cipher_text[0], |
+ test_cipher_text.size() - kAesCbcBlockSize), |
+ &output)); |
} |
// Decrypt cipher text which is not a multiple of block size by stripping |
@@ -878,16 +721,16 @@ TEST_F(WebCryptoImplTest, MAYBE(AesCbcSampleSets)) { |
if (test_cipher_text.size() > 3) { |
EXPECT_STATUS( |
Status::Error(), |
- DecryptInternal(webcrypto::CreateAesCbcAlgorithm(test_iv), |
+ Decrypt(CreateAesCbcAlgorithm(test_iv), |
key, |
- &test_cipher_text[0], |
- test_cipher_text.size() - 3, |
+ CryptoData(&test_cipher_text[0], |
+ test_cipher_text.size() - 3), |
&output)); |
} |
} |
} |
-TEST_F(WebCryptoImplTest, MAYBE(GenerateKeyAes)) { |
+TEST_F(SharedCryptoTest, MAYBE(GenerateKeyAes)) { |
// Check key generation for each of AES-CBC, AES-GCM, and AES-KW, and for each |
// allowed key length. |
std::vector<blink::WebCryptoAlgorithm> algorithm; |
@@ -905,11 +748,12 @@ TEST_F(WebCryptoImplTest, MAYBE(GenerateKeyAes)) { |
// Generate a small sample of keys. |
keys.clear(); |
for (int j = 0; j < 16; ++j) { |
- ASSERT_STATUS_SUCCESS(GenerateKeyInternal(algorithm[i], &key)); |
+ ASSERT_STATUS_SUCCESS(GenerateSecretKey( |
+ algorithm[i], true, 0, &key)); |
EXPECT_TRUE(key.handle()); |
EXPECT_EQ(blink::WebCryptoKeyTypeSecret, key.type()); |
ASSERT_STATUS_SUCCESS( |
- ExportKeyInternal(blink::WebCryptoKeyFormatRaw, key, &key_bytes)); |
+ ExportKey(blink::WebCryptoKeyFormatRaw, key, &key_bytes)); |
keys.push_back(key_bytes); |
} |
// Ensure all entries in the key sample set are unique. This is a simplistic |
@@ -918,29 +762,29 @@ TEST_F(WebCryptoImplTest, MAYBE(GenerateKeyAes)) { |
} |
} |
-TEST_F(WebCryptoImplTest, MAYBE(GenerateKeyAesBadLength)) { |
+TEST_F(SharedCryptoTest, MAYBE(GenerateKeyAesBadLength)) { |
const unsigned short kKeyLen[] = {0, 127, 257}; |
blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); |
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kKeyLen); ++i) { |
SCOPED_TRACE(i); |
- EXPECT_STATUS(Status::ErrorGenerateKeyLength(), GenerateKeyInternal( |
- CreateAesCbcKeyGenAlgorithm(kKeyLen[i]), &key)); |
- EXPECT_STATUS(Status::ErrorGenerateKeyLength(), GenerateKeyInternal( |
- CreateAesGcmKeyGenAlgorithm(kKeyLen[i]), &key)); |
- EXPECT_STATUS(Status::ErrorGenerateKeyLength(), GenerateKeyInternal( |
- CreateAesKwKeyGenAlgorithm(kKeyLen[i]), &key)); |
+ EXPECT_STATUS(Status::ErrorGenerateKeyLength(), GenerateSecretKey( |
+ CreateAesCbcKeyGenAlgorithm(kKeyLen[i]), true, 0, &key)); |
+ EXPECT_STATUS(Status::ErrorGenerateKeyLength(), GenerateSecretKey( |
+ CreateAesGcmKeyGenAlgorithm(kKeyLen[i]), true, 0, &key)); |
+ EXPECT_STATUS(Status::ErrorGenerateKeyLength(), GenerateSecretKey( |
+ CreateAesKwKeyGenAlgorithm(kKeyLen[i]), true, 0, &key)); |
} |
} |
-TEST_F(WebCryptoImplTest, MAYBE(GenerateKeyHmac)) { |
+TEST_F(SharedCryptoTest, MAYBE(GenerateKeyHmac)) { |
// Generate a small sample of HMAC keys. |
std::vector<blink::WebArrayBuffer> keys; |
for (int i = 0; i < 16; ++i) { |
blink::WebArrayBuffer key_bytes; |
blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); |
- blink::WebCryptoAlgorithm algorithm = webcrypto::CreateHmacKeyGenAlgorithm( |
+ blink::WebCryptoAlgorithm algorithm = CreateHmacKeyGenAlgorithm( |
blink::WebCryptoAlgorithmIdSha1, 64); |
- ASSERT_STATUS_SUCCESS(GenerateKeyInternal(algorithm, &key)); |
+ ASSERT_STATUS_SUCCESS(GenerateSecretKey(algorithm, true, 0, &key)); |
EXPECT_FALSE(key.isNull()); |
EXPECT_TRUE(key.handle()); |
EXPECT_EQ(blink::WebCryptoKeyTypeSecret, key.type()); |
@@ -948,7 +792,7 @@ TEST_F(WebCryptoImplTest, MAYBE(GenerateKeyHmac)) { |
blink::WebArrayBuffer raw_key; |
ASSERT_STATUS_SUCCESS( |
- ExportKeyInternal(blink::WebCryptoKeyFormatRaw, key, &raw_key)); |
+ ExportKey(blink::WebCryptoKeyFormatRaw, key, &raw_key)); |
EXPECT_EQ(64U, raw_key.byteLength()); |
keys.push_back(raw_key); |
} |
@@ -958,32 +802,32 @@ TEST_F(WebCryptoImplTest, MAYBE(GenerateKeyHmac)) { |
} |
// If the key length is not provided, then the block size is used. |
-TEST_F(WebCryptoImplTest, MAYBE(GenerateKeyHmacNoLength)) { |
+TEST_F(SharedCryptoTest, MAYBE(GenerateKeyHmacNoLength)) { |
blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); |
blink::WebCryptoAlgorithm algorithm = |
- webcrypto::CreateHmacKeyGenAlgorithm(blink::WebCryptoAlgorithmIdSha1, 0); |
- ASSERT_STATUS_SUCCESS(GenerateKeyInternal(algorithm, &key)); |
+ CreateHmacKeyGenAlgorithm(blink::WebCryptoAlgorithmIdSha1, 0); |
+ ASSERT_STATUS_SUCCESS(GenerateSecretKey(algorithm, true, 0, &key)); |
EXPECT_TRUE(key.handle()); |
EXPECT_EQ(blink::WebCryptoKeyTypeSecret, key.type()); |
blink::WebArrayBuffer raw_key; |
ASSERT_STATUS_SUCCESS( |
- ExportKeyInternal(blink::WebCryptoKeyFormatRaw, key, &raw_key)); |
+ ExportKey(blink::WebCryptoKeyFormatRaw, key, &raw_key)); |
EXPECT_EQ(64U, raw_key.byteLength()); |
// The block size for HMAC SHA-512 is larger. |
- algorithm = webcrypto::CreateHmacKeyGenAlgorithm( |
+ algorithm = CreateHmacKeyGenAlgorithm( |
blink::WebCryptoAlgorithmIdSha512, 0); |
- ASSERT_STATUS_SUCCESS(GenerateKeyInternal(algorithm, &key)); |
+ ASSERT_STATUS_SUCCESS(GenerateSecretKey(algorithm, true, 0, &key)); |
ASSERT_STATUS_SUCCESS( |
- ExportKeyInternal(blink::WebCryptoKeyFormatRaw, key, &raw_key)); |
+ ExportKey(blink::WebCryptoKeyFormatRaw, key, &raw_key)); |
EXPECT_EQ(128U, raw_key.byteLength()); |
} |
-TEST_F(WebCryptoImplTest, MAYBE(ImportSecretKeyNoAlgorithm)) { |
+TEST_F(SharedCryptoTest, MAYBE(ImportSecretKeyNoAlgorithm)) { |
blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); |
// This fails because the algorithm is null. |
- EXPECT_STATUS(Status::ErrorMissingAlgorithmImportRawKey(), ImportKeyInternal( |
+ EXPECT_STATUS(Status::ErrorMissingAlgorithmImportRawKey(), ImportKey( |
blink::WebCryptoKeyFormatRaw, |
HexStringToBytes("00000000000000000000"), |
blink::WebCryptoAlgorithm::createNull(), |
@@ -992,12 +836,11 @@ TEST_F(WebCryptoImplTest, MAYBE(ImportSecretKeyNoAlgorithm)) { |
&key)); |
} |
- |
-TEST_F(WebCryptoImplTest, ImportJwkFailures) { |
+TEST_F(SharedCryptoTest, ImportJwkFailures) { |
blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); |
blink::WebCryptoAlgorithm algorithm = |
- webcrypto::CreateAlgorithm(blink::WebCryptoAlgorithmIdAesCbc); |
+ CreateAlgorithm(blink::WebCryptoAlgorithmIdAesCbc); |
blink::WebCryptoKeyUsageMask usage_mask = blink::WebCryptoKeyUsageEncrypt; |
// Baseline pass: each test below breaks a single item, so we start with a |
@@ -1034,10 +877,10 @@ TEST_F(WebCryptoImplTest, ImportJwkFailures) { |
EXPECT_STATUS( |
Status::ErrorJwkAlgorithmMissing(), |
ImportKeyJwk(MakeJsonVector(dict), |
- blink::WebCryptoAlgorithm::createNull(), |
- false, |
- usage_mask, |
- &key)); |
+ blink::WebCryptoAlgorithm::createNull(), |
+ false, |
+ usage_mask, |
+ &key)); |
RestoreJwkOctDictionary(&dict); |
// Fail on invalid kty. |
@@ -1050,14 +893,16 @@ TEST_F(WebCryptoImplTest, ImportJwkFailures) { |
dict.Remove("kty", NULL); |
EXPECT_STATUS( |
Status::ErrorJwkPropertyMissing("kty"), |
- ImportKeyJwk(MakeJsonVector(dict), algorithm, false, usage_mask, &key)); |
+ ImportKeyJwk(MakeJsonVector(dict), algorithm, false, usage_mask, |
+ &key)); |
RestoreJwkOctDictionary(&dict); |
// Fail on kty wrong type. |
dict.SetDouble("kty", 0.1); |
EXPECT_STATUS( |
Status::ErrorJwkPropertyWrongType("kty", "string"), |
- ImportKeyJwk(MakeJsonVector(dict), algorithm, false, usage_mask, &key)); |
+ ImportKeyJwk( |
+ MakeJsonVector(dict), algorithm, false, usage_mask, &key)); |
RestoreJwkOctDictionary(&dict); |
// Fail on invalid use. |
@@ -1070,23 +915,25 @@ TEST_F(WebCryptoImplTest, ImportJwkFailures) { |
dict.SetBoolean("use", true); |
EXPECT_STATUS( |
Status::ErrorJwkPropertyWrongType("use", "string"), |
- ImportKeyJwk(MakeJsonVector(dict), algorithm, false, usage_mask, &key)); |
+ ImportKeyJwk( |
+ MakeJsonVector(dict), algorithm, false, usage_mask, &key)); |
RestoreJwkOctDictionary(&dict); |
// Fail on invalid extractable (wrong type). |
dict.SetInteger("extractable", 0); |
EXPECT_STATUS( |
Status::ErrorJwkPropertyWrongType("extractable", "boolean"), |
- ImportKeyJwk(MakeJsonVector(dict), algorithm, false, usage_mask, &key)); |
+ ImportKeyJwk( |
+ MakeJsonVector(dict), algorithm, false, usage_mask, &key)); |
RestoreJwkOctDictionary(&dict); |
} |
-TEST_F(WebCryptoImplTest, ImportJwkOctFailures) { |
+TEST_F(SharedCryptoTest, ImportJwkOctFailures) { |
base::DictionaryValue dict; |
RestoreJwkOctDictionary(&dict); |
blink::WebCryptoAlgorithm algorithm = |
- webcrypto::CreateAlgorithm(blink::WebCryptoAlgorithmIdAesCbc); |
+ CreateAlgorithm(blink::WebCryptoAlgorithmIdAesCbc); |
blink::WebCryptoKeyUsageMask usage_mask = blink::WebCryptoKeyUsageEncrypt; |
blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); |
@@ -1104,14 +951,16 @@ TEST_F(WebCryptoImplTest, ImportJwkOctFailures) { |
dict.Remove("k", NULL); |
EXPECT_STATUS( |
Status::ErrorJwkPropertyMissing("k"), |
- ImportKeyJwk(MakeJsonVector(dict), algorithm, false, usage_mask, &key)); |
+ ImportKeyJwk( |
+ MakeJsonVector(dict), algorithm, false, usage_mask, &key)); |
RestoreJwkOctDictionary(&dict); |
// Fail on bad b64 encoding for k. |
dict.SetString("k", "Qk3f0DsytU8lfza2au #$% Htaw2xpop9GYyTuH0p5GghxTI="); |
EXPECT_STATUS( |
Status::ErrorJwkBase64Decode("k"), |
- ImportKeyJwk(MakeJsonVector(dict), algorithm, false, usage_mask, &key)); |
+ ImportKeyJwk( |
+ MakeJsonVector(dict), algorithm, false, usage_mask, &key)); |
RestoreJwkOctDictionary(&dict); |
// Fail on empty k. |
@@ -1135,12 +984,12 @@ TEST_F(WebCryptoImplTest, ImportJwkOctFailures) { |
RestoreJwkOctDictionary(&dict); |
} |
-TEST_F(WebCryptoImplTest, MAYBE(ImportJwkRsaFailures)) { |
+TEST_F(SharedCryptoTest, MAYBE(ImportJwkRsaFailures)) { |
base::DictionaryValue dict; |
RestoreJwkRsaDictionary(&dict); |
blink::WebCryptoAlgorithm algorithm = |
- webcrypto::CreateAlgorithm(blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5); |
+ CreateAlgorithm(blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5); |
blink::WebCryptoKeyUsageMask usage_mask = blink::WebCryptoKeyUsageEncrypt; |
blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); |
@@ -1186,12 +1035,16 @@ TEST_F(WebCryptoImplTest, MAYBE(ImportJwkRsaFailures)) { |
// Fail if "d" parameter is present, implying the JWK is a private key, which |
// is not supported. |
dict.SetString("d", "Qk3f0Dsyt"); |
- EXPECT_STATUS(Status::ErrorJwkRsaPrivateKeyUnsupported(), ImportKeyJwk( |
- MakeJsonVector(dict), algorithm, false, usage_mask, &key)); |
+ EXPECT_STATUS(Status::ErrorJwkRsaPrivateKeyUnsupported(), |
+ ImportKeyJwk(MakeJsonVector(dict), |
+ algorithm, |
+ false, |
+ usage_mask, |
+ &key)); |
RestoreJwkRsaDictionary(&dict); |
} |
-TEST_F(WebCryptoImplTest, MAYBE(ImportJwkInputConsistency)) { |
+TEST_F(SharedCryptoTest, MAYBE(ImportJwkInputConsistency)) { |
// The Web Crypto spec says that if a JWK value is present, but is |
// inconsistent with the input value, the operation must fail. |
@@ -1199,7 +1052,7 @@ TEST_F(WebCryptoImplTest, MAYBE(ImportJwkInputConsistency)) { |
blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); |
bool extractable = false; |
blink::WebCryptoAlgorithm algorithm = |
- webcrypto::CreateHmacAlgorithmByHashId(blink::WebCryptoAlgorithmIdSha256); |
+ CreateHmacAlgorithmByHashId(blink::WebCryptoAlgorithmIdSha256); |
blink::WebCryptoKeyUsageMask usage_mask = blink::WebCryptoKeyUsageVerify; |
base::DictionaryValue dict; |
dict.SetString("kty", "oct"); |
@@ -1240,11 +1093,11 @@ TEST_F(WebCryptoImplTest, MAYBE(ImportJwkInputConsistency)) { |
ImportKeyJwk(json_vec, algorithm, false, usage_mask, &key)); |
EXPECT_FALSE(key.extractable()); |
dict.SetBoolean("extractable", true); |
- EXPECT_STATUS_SUCCESS( |
- ImportKeyJwk(MakeJsonVector(dict), algorithm, true, usage_mask, &key)); |
+ EXPECT_STATUS_SUCCESS(ImportKeyJwk( |
+ MakeJsonVector(dict), algorithm, true, usage_mask, &key)); |
EXPECT_TRUE(key.extractable()); |
- EXPECT_STATUS_SUCCESS( |
- ImportKeyJwk(MakeJsonVector(dict), algorithm, false, usage_mask, &key)); |
+ EXPECT_STATUS_SUCCESS(ImportKeyJwk( |
+ MakeJsonVector(dict), algorithm, false, usage_mask, &key)); |
EXPECT_FALSE(key.extractable()); |
dict.SetBoolean("extractable", true); // restore previous value |
@@ -1252,7 +1105,7 @@ TEST_F(WebCryptoImplTest, MAYBE(ImportJwkInputConsistency)) { |
// (HMAC SHA256). |
EXPECT_STATUS(Status::ErrorJwkAlgorithmInconsistent(), ImportKeyJwk( |
json_vec, |
- webcrypto::CreateAlgorithm(blink::WebCryptoAlgorithmIdAesCbc), |
+ CreateAlgorithm(blink::WebCryptoAlgorithmIdAesCbc), |
extractable, |
usage_mask, |
&key)); |
@@ -1261,7 +1114,8 @@ TEST_F(WebCryptoImplTest, MAYBE(ImportJwkInputConsistency)) { |
// (HMAC SHA256). |
EXPECT_STATUS(Status::ErrorJwkAlgorithmInconsistent(), ImportKeyJwk( |
json_vec, |
- webcrypto::CreateHmacAlgorithmByHashId(blink::WebCryptoAlgorithmIdSha1), |
+ CreateHmacAlgorithmByHashId( |
+ blink::WebCryptoAlgorithmIdSha1), |
extractable, |
usage_mask, |
&key)); |
@@ -1278,7 +1132,7 @@ TEST_F(WebCryptoImplTest, MAYBE(ImportJwkInputConsistency)) { |
dict.Remove("alg", NULL); |
EXPECT_STATUS_SUCCESS(ImportKeyJwk( |
MakeJsonVector(dict), |
- webcrypto::CreateHmacAlgorithmByHashId(blink::WebCryptoAlgorithmIdSha256), |
+ CreateHmacAlgorithmByHashId(blink::WebCryptoAlgorithmIdSha256), |
extractable, |
usage_mask, |
&key)); |
@@ -1304,7 +1158,7 @@ TEST_F(WebCryptoImplTest, MAYBE(ImportJwkInputConsistency)) { |
// algorithm. |
} |
-TEST_F(WebCryptoImplTest, MAYBE(ImportJwkHappy)) { |
+TEST_F(SharedCryptoTest, MAYBE(ImportJwkHappy)) { |
// This test verifies the happy path of JWK import, including the application |
// of the imported key material. |
@@ -1312,7 +1166,7 @@ TEST_F(WebCryptoImplTest, MAYBE(ImportJwkHappy)) { |
blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); |
bool extractable = false; |
blink::WebCryptoAlgorithm algorithm = |
- webcrypto::CreateHmacAlgorithmByHashId(blink::WebCryptoAlgorithmIdSha256); |
+ CreateHmacAlgorithmByHashId(blink::WebCryptoAlgorithmIdSha256); |
blink::WebCryptoKeyUsageMask usage_mask = blink::WebCryptoKeyUsageSign; |
// Import a symmetric key JWK and HMAC-SHA256 sign() |
@@ -1337,23 +1191,23 @@ TEST_F(WebCryptoImplTest, MAYBE(ImportJwkHappy)) { |
blink::WebArrayBuffer output; |
- ASSERT_STATUS_SUCCESS(SignInternal(algorithm, key, message_raw, &output)); |
+ ASSERT_STATUS_SUCCESS(Sign(algorithm, key, message_raw, &output)); |
const std::string mac_raw = |
"769f00d3e6a6cc1fb426a14a4f76c6462e6149726e0dee0ec0cf97a16605ac8b"; |
- ExpectArrayBufferMatchesHex(mac_raw, output); |
+ ExpectCryptoDataMatchesHex(mac_raw, output); |
// TODO(padolph): Import an RSA public key JWK and use it |
} |
-TEST_F(WebCryptoImplTest, MAYBE(ImportExportSpki)) { |
+TEST_F(SharedCryptoTest, MAYBE(ImportExportSpki)) { |
// Passing case: Import a valid RSA key in SPKI format. |
blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); |
- ASSERT_STATUS_SUCCESS(ImportKeyInternal( |
+ ASSERT_STATUS_SUCCESS(ImportKey( |
blink::WebCryptoKeyFormatSpki, |
HexStringToBytes(kPublicKeySpkiDerHex), |
- webcrypto::CreateAlgorithm(blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5), |
+ CreateAlgorithm(blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5), |
true, |
blink::WebCryptoKeyUsageEncrypt, |
&key)); |
@@ -1363,9 +1217,9 @@ TEST_F(WebCryptoImplTest, MAYBE(ImportExportSpki)) { |
EXPECT_EQ(blink::WebCryptoKeyUsageEncrypt, key.usages()); |
// Failing case: Empty SPKI data |
- EXPECT_STATUS(Status::ErrorImportEmptyKeyData(), ImportKeyInternal( |
+ EXPECT_STATUS(Status::ErrorImportEmptyKeyData(), ImportKey( |
blink::WebCryptoKeyFormatSpki, |
- std::vector<uint8>(), |
+ CryptoData(), |
blink::WebCryptoAlgorithm::createNull(), |
true, |
blink::WebCryptoKeyUsageEncrypt, |
@@ -1374,7 +1228,7 @@ TEST_F(WebCryptoImplTest, MAYBE(ImportExportSpki)) { |
// Failing case: Import RSA key with NULL input algorithm. This is not |
// allowed because the SPKI ASN.1 format for RSA keys is not specific enough |
// to map to a Web Crypto algorithm. |
- EXPECT_STATUS(Status::Error(), ImportKeyInternal( |
+ EXPECT_STATUS(Status::Error(), ImportKey( |
blink::WebCryptoKeyFormatSpki, |
HexStringToBytes(kPublicKeySpkiDerHex), |
blink::WebCryptoAlgorithm::createNull(), |
@@ -1383,19 +1237,19 @@ TEST_F(WebCryptoImplTest, MAYBE(ImportExportSpki)) { |
&key)); |
// Failing case: Bad DER encoding. |
- EXPECT_STATUS(Status::Error(), ImportKeyInternal( |
+ EXPECT_STATUS(Status::Error(), ImportKey( |
blink::WebCryptoKeyFormatSpki, |
HexStringToBytes("618333c4cb"), |
- webcrypto::CreateAlgorithm(blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5), |
+ CreateAlgorithm(blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5), |
true, |
blink::WebCryptoKeyUsageEncrypt, |
&key)); |
// Failing case: Import RSA key but provide an inconsistent input algorithm. |
- EXPECT_STATUS(Status::Error(), ImportKeyInternal( |
+ EXPECT_STATUS(Status::Error(), ImportKey( |
blink::WebCryptoKeyFormatSpki, |
HexStringToBytes(kPublicKeySpkiDerHex), |
- webcrypto::CreateAlgorithm(blink::WebCryptoAlgorithmIdAesCbc), |
+ CreateAlgorithm(blink::WebCryptoAlgorithmIdAesCbc), |
true, |
blink::WebCryptoKeyUsageEncrypt, |
&key)); |
@@ -1404,35 +1258,35 @@ TEST_F(WebCryptoImplTest, MAYBE(ImportExportSpki)) { |
// and compare to original data. |
blink::WebArrayBuffer output; |
ASSERT_STATUS_SUCCESS( |
- ExportKeyInternal(blink::WebCryptoKeyFormatSpki, key, &output)); |
- ExpectArrayBufferMatchesHex(kPublicKeySpkiDerHex, output); |
+ ExportKey(blink::WebCryptoKeyFormatSpki, key, &output)); |
+ ExpectCryptoDataMatchesHex(kPublicKeySpkiDerHex, output); |
// Failing case: Try to export a previously imported RSA public key in raw |
// format (not allowed for a public key). |
EXPECT_STATUS(Status::ErrorUnexpectedKeyType(), |
- ExportKeyInternal(blink::WebCryptoKeyFormatRaw, key, &output)); |
+ ExportKey(blink::WebCryptoKeyFormatRaw, key, &output)); |
// Failing case: Try to export a non-extractable key |
- ASSERT_STATUS_SUCCESS(ImportKeyInternal( |
+ ASSERT_STATUS_SUCCESS(ImportKey( |
blink::WebCryptoKeyFormatSpki, |
HexStringToBytes(kPublicKeySpkiDerHex), |
- webcrypto::CreateAlgorithm(blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5), |
+ CreateAlgorithm(blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5), |
false, |
blink::WebCryptoKeyUsageEncrypt, |
&key)); |
EXPECT_TRUE(key.handle()); |
EXPECT_FALSE(key.extractable()); |
EXPECT_STATUS(Status::ErrorKeyNotExtractable(), |
- ExportKeyInternal(blink::WebCryptoKeyFormatSpki, key, &output)); |
+ ExportKey(blink::WebCryptoKeyFormatSpki, key, &output)); |
} |
-TEST_F(WebCryptoImplTest, MAYBE(ImportPkcs8)) { |
+TEST_F(SharedCryptoTest, MAYBE(ImportPkcs8)) { |
// Passing case: Import a valid RSA key in PKCS#8 format. |
blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); |
- ASSERT_STATUS_SUCCESS(ImportKeyInternal( |
+ ASSERT_STATUS_SUCCESS(ImportKey( |
blink::WebCryptoKeyFormatPkcs8, |
HexStringToBytes(kPrivateKeyPkcs8DerHex), |
- webcrypto::CreateAlgorithm(blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5), |
+ CreateAlgorithm(blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5), |
true, |
blink::WebCryptoKeyUsageSign, |
&key)); |
@@ -1442,7 +1296,7 @@ TEST_F(WebCryptoImplTest, MAYBE(ImportPkcs8)) { |
EXPECT_EQ(blink::WebCryptoKeyUsageSign, key.usages()); |
// Failing case: Empty PKCS#8 data |
- EXPECT_STATUS(Status::ErrorImportEmptyKeyData(), ImportKeyInternal( |
+ EXPECT_STATUS(Status::ErrorImportEmptyKeyData(), ImportKey( |
blink::WebCryptoKeyFormatPkcs8, |
std::vector<uint8>(), |
blink::WebCryptoAlgorithm::createNull(), |
@@ -1453,7 +1307,7 @@ TEST_F(WebCryptoImplTest, MAYBE(ImportPkcs8)) { |
// Failing case: Import RSA key with NULL input algorithm. This is not |
// allowed because the PKCS#8 ASN.1 format for RSA keys is not specific enough |
// to map to a Web Crypto algorithm. |
- EXPECT_STATUS(Status::Error(), ImportKeyInternal( |
+ EXPECT_STATUS(Status::Error(), ImportKey( |
blink::WebCryptoKeyFormatPkcs8, |
HexStringToBytes(kPrivateKeyPkcs8DerHex), |
blink::WebCryptoAlgorithm::createNull(), |
@@ -1462,31 +1316,31 @@ TEST_F(WebCryptoImplTest, MAYBE(ImportPkcs8)) { |
&key)); |
// Failing case: Bad DER encoding. |
- EXPECT_STATUS(Status::Error(), ImportKeyInternal( |
+ EXPECT_STATUS(Status::Error(), ImportKey( |
blink::WebCryptoKeyFormatPkcs8, |
HexStringToBytes("618333c4cb"), |
- webcrypto::CreateAlgorithm(blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5), |
+ CreateAlgorithm(blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5), |
true, |
blink::WebCryptoKeyUsageSign, |
&key)); |
// Failing case: Import RSA key but provide an inconsistent input algorithm. |
- EXPECT_STATUS(Status::Error(), ImportKeyInternal( |
+ EXPECT_STATUS(Status::Error(), ImportKey( |
blink::WebCryptoKeyFormatPkcs8, |
HexStringToBytes(kPrivateKeyPkcs8DerHex), |
- webcrypto::CreateAlgorithm(blink::WebCryptoAlgorithmIdAesCbc), |
+ CreateAlgorithm(blink::WebCryptoAlgorithmIdAesCbc), |
true, |
blink::WebCryptoKeyUsageSign, |
&key)); |
} |
-TEST_F(WebCryptoImplTest, MAYBE(GenerateKeyPairRsa)) { |
+TEST_F(SharedCryptoTest, MAYBE(GenerateKeyPairRsa)) { |
// Note: using unrealistic short key lengths here to avoid bogging down tests. |
// Successful WebCryptoAlgorithmIdRsaEsPkcs1v1_5 key generation. |
const unsigned int modulus_length = 256; |
const std::vector<uint8> public_exponent = HexStringToBytes("010001"); |
- blink::WebCryptoAlgorithm algorithm = webcrypto::CreateRsaKeyGenAlgorithm( |
+ blink::WebCryptoAlgorithm algorithm = CreateRsaKeyGenAlgorithm( |
blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5, |
modulus_length, |
public_exponent); |
@@ -1494,7 +1348,7 @@ TEST_F(WebCryptoImplTest, MAYBE(GenerateKeyPairRsa)) { |
const blink::WebCryptoKeyUsageMask usage_mask = 0; |
blink::WebCryptoKey public_key = blink::WebCryptoKey::createNull(); |
blink::WebCryptoKey private_key = blink::WebCryptoKey::createNull(); |
- EXPECT_STATUS_SUCCESS(GenerateKeyPairInternal( |
+ EXPECT_STATUS_SUCCESS(GenerateKeyPair( |
algorithm, extractable, usage_mask, &public_key, &private_key)); |
EXPECT_FALSE(public_key.isNull()); |
EXPECT_FALSE(private_key.isNull()); |
@@ -1506,51 +1360,51 @@ TEST_F(WebCryptoImplTest, MAYBE(GenerateKeyPairRsa)) { |
EXPECT_EQ(usage_mask, private_key.usages()); |
// Fail with bad modulus. |
- algorithm = webcrypto::CreateRsaKeyGenAlgorithm( |
+ algorithm = CreateRsaKeyGenAlgorithm( |
blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5, 0, public_exponent); |
- EXPECT_STATUS(Status::ErrorGenerateRsaZeroModulus(), GenerateKeyPairInternal( |
+ EXPECT_STATUS(Status::ErrorGenerateRsaZeroModulus(), GenerateKeyPair( |
algorithm, extractable, usage_mask, &public_key, &private_key)); |
// Fail with bad exponent: larger than unsigned long. |
unsigned int exponent_length = sizeof(unsigned long) + 1; // NOLINT |
const std::vector<uint8> long_exponent(exponent_length, 0x01); |
- algorithm = webcrypto::CreateRsaKeyGenAlgorithm( |
+ algorithm = CreateRsaKeyGenAlgorithm( |
blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5, |
modulus_length, |
long_exponent); |
EXPECT_STATUS(Status::ErrorGenerateKeyPublicExponent(), |
- GenerateKeyPairInternal(algorithm, extractable, usage_mask, &public_key, |
+ GenerateKeyPair(algorithm, extractable, usage_mask, &public_key, |
&private_key)); |
// Fail with bad exponent: empty. |
const std::vector<uint8> empty_exponent; |
- algorithm = webcrypto::CreateRsaKeyGenAlgorithm( |
+ algorithm = CreateRsaKeyGenAlgorithm( |
blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5, |
modulus_length, |
empty_exponent); |
EXPECT_STATUS(Status::ErrorGenerateKeyPublicExponent(), |
- GenerateKeyPairInternal(algorithm, extractable, usage_mask, &public_key, |
+ GenerateKeyPair(algorithm, extractable, usage_mask, &public_key, |
&private_key)); |
// Fail with bad exponent: all zeros. |
std::vector<uint8> exponent_with_leading_zeros(15, 0x00); |
- algorithm = webcrypto::CreateRsaKeyGenAlgorithm( |
+ algorithm = CreateRsaKeyGenAlgorithm( |
blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5, |
modulus_length, |
exponent_with_leading_zeros); |
EXPECT_STATUS(Status::ErrorGenerateKeyPublicExponent(), |
- GenerateKeyPairInternal(algorithm, extractable, usage_mask, &public_key, |
+ GenerateKeyPair(algorithm, extractable, usage_mask, &public_key, |
&private_key)); |
// Key generation success using exponent with leading zeros. |
exponent_with_leading_zeros.insert(exponent_with_leading_zeros.end(), |
public_exponent.begin(), |
public_exponent.end()); |
- algorithm = webcrypto::CreateRsaKeyGenAlgorithm( |
+ algorithm = CreateRsaKeyGenAlgorithm( |
blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5, |
modulus_length, |
exponent_with_leading_zeros); |
- EXPECT_STATUS_SUCCESS(GenerateKeyPairInternal( |
+ EXPECT_STATUS_SUCCESS(GenerateKeyPair( |
algorithm, extractable, usage_mask, &public_key, &private_key)); |
EXPECT_FALSE(public_key.isNull()); |
EXPECT_FALSE(private_key.isNull()); |
@@ -1562,9 +1416,9 @@ TEST_F(WebCryptoImplTest, MAYBE(GenerateKeyPairRsa)) { |
EXPECT_EQ(usage_mask, private_key.usages()); |
// Successful WebCryptoAlgorithmIdRsaOaep key generation. |
- algorithm = webcrypto::CreateRsaKeyGenAlgorithm( |
+ algorithm = CreateRsaKeyGenAlgorithm( |
blink::WebCryptoAlgorithmIdRsaOaep, modulus_length, public_exponent); |
- EXPECT_STATUS_SUCCESS(GenerateKeyPairInternal( |
+ EXPECT_STATUS_SUCCESS(GenerateKeyPair( |
algorithm, extractable, usage_mask, &public_key, &private_key)); |
EXPECT_FALSE(public_key.isNull()); |
EXPECT_FALSE(private_key.isNull()); |
@@ -1576,11 +1430,11 @@ TEST_F(WebCryptoImplTest, MAYBE(GenerateKeyPairRsa)) { |
EXPECT_EQ(usage_mask, private_key.usages()); |
// Successful WebCryptoAlgorithmIdRsaSsaPkcs1v1_5 key generation. |
- algorithm = webcrypto::CreateRsaKeyGenAlgorithm( |
+ algorithm = CreateRsaKeyGenAlgorithm( |
blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, |
modulus_length, |
public_exponent); |
- EXPECT_STATUS_SUCCESS(GenerateKeyPairInternal( |
+ EXPECT_STATUS_SUCCESS(GenerateKeyPair( |
algorithm, false, usage_mask, &public_key, &private_key)); |
EXPECT_FALSE(public_key.isNull()); |
EXPECT_FALSE(private_key.isNull()); |
@@ -1596,21 +1450,21 @@ TEST_F(WebCryptoImplTest, MAYBE(GenerateKeyPairRsa)) { |
// Exporting a private key as SPKI format doesn't make sense. However this |
// will first fail because the key is not extractable. |
blink::WebArrayBuffer output; |
- EXPECT_STATUS(Status::ErrorKeyNotExtractable(), ExportKeyInternal( |
+ EXPECT_STATUS(Status::ErrorKeyNotExtractable(), ExportKey( |
blink::WebCryptoKeyFormatSpki, private_key, &output)); |
// Re-generate an extractable private_key and try to export it as SPKI format. |
// This should fail since spki is for public keys. |
- EXPECT_STATUS_SUCCESS(GenerateKeyPairInternal( |
+ EXPECT_STATUS_SUCCESS(GenerateKeyPair( |
algorithm, true, usage_mask, &public_key, &private_key)); |
- EXPECT_STATUS(Status::ErrorUnexpectedKeyType(), ExportKeyInternal( |
+ EXPECT_STATUS(Status::ErrorUnexpectedKeyType(), ExportKey( |
blink::WebCryptoKeyFormatSpki, private_key, &output)); |
} |
-TEST_F(WebCryptoImplTest, MAYBE(RsaEsRoundTrip)) { |
+TEST_F(SharedCryptoTest, MAYBE(RsaEsRoundTrip)) { |
// Import a key pair. |
blink::WebCryptoAlgorithm algorithm = |
- webcrypto::CreateAlgorithm(blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5); |
+ CreateAlgorithm(blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5); |
blink::WebCryptoKey public_key = blink::WebCryptoKey::createNull(); |
blink::WebCryptoKey private_key = blink::WebCryptoKey::createNull(); |
ImportRsaKeyPair( |
@@ -1634,7 +1488,7 @@ TEST_F(WebCryptoImplTest, MAYBE(RsaEsRoundTrip)) { |
// Verify encrypt / decrypt round trip on a few messages. Note that RSA |
// encryption does not support empty input. |
algorithm = |
- webcrypto::CreateAlgorithm(blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5); |
+ CreateAlgorithm(blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5); |
const char* const kTestDataHex[] = { |
"ff", |
"0102030405060708090a0b0c0d0e0f", |
@@ -1644,23 +1498,22 @@ TEST_F(WebCryptoImplTest, MAYBE(RsaEsRoundTrip)) { |
blink::WebArrayBuffer decrypted_data; |
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestDataHex); ++i) { |
SCOPED_TRACE(i); |
- EXPECT_STATUS_SUCCESS(EncryptInternal( |
+ EXPECT_STATUS_SUCCESS(Encrypt( |
algorithm, |
public_key, |
HexStringToBytes(kTestDataHex[i]), |
&encrypted_data)); |
EXPECT_EQ(kModulusLength / 8, encrypted_data.byteLength()); |
- ASSERT_STATUS_SUCCESS(DecryptInternal( |
+ ASSERT_STATUS_SUCCESS(Decrypt( |
algorithm, |
private_key, |
- reinterpret_cast<const unsigned char*>(encrypted_data.data()), |
- encrypted_data.byteLength(), |
+ encrypted_data, |
&decrypted_data)); |
- ExpectArrayBufferMatchesHex(kTestDataHex[i], decrypted_data); |
+ ExpectCryptoDataMatchesHex(kTestDataHex[i], decrypted_data); |
} |
} |
-TEST_F(WebCryptoImplTest, MAYBE(RsaEsKnownAnswer)) { |
+TEST_F(SharedCryptoTest, MAYBE(RsaEsKnownAnswer)) { |
scoped_ptr<base::Value> json; |
ASSERT_TRUE(ReadJsonTestFile("rsa_es.json", &json)); |
base::DictionaryValue* test = NULL; |
@@ -1684,7 +1537,7 @@ TEST_F(WebCryptoImplTest, MAYBE(RsaEsKnownAnswer)) { |
// Import the key pair. |
blink::WebCryptoAlgorithm algorithm = |
- webcrypto::CreateAlgorithm(blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5); |
+ CreateAlgorithm(blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5); |
blink::WebCryptoKey public_key = blink::WebCryptoKey::createNull(); |
blink::WebCryptoKey private_key = blink::WebCryptoKey::createNull(); |
ImportRsaKeyPair( |
@@ -1699,41 +1552,39 @@ TEST_F(WebCryptoImplTest, MAYBE(RsaEsKnownAnswer)) { |
// Decrypt the known-good ciphertext with the private key. As a check we must |
// get the known original cleartext. |
blink::WebArrayBuffer decrypted_data; |
- ASSERT_STATUS_SUCCESS(DecryptInternal( |
+ ASSERT_STATUS_SUCCESS(Decrypt( |
algorithm, |
private_key, |
ciphertext, |
&decrypted_data)); |
EXPECT_FALSE(decrypted_data.isNull()); |
- ExpectArrayBufferMatches(cleartext, decrypted_data); |
+ ExpectCryptoDataMatches(cleartext, decrypted_data); |
// Encrypt this decrypted data with the public key. |
blink::WebArrayBuffer encrypted_data; |
- ASSERT_STATUS_SUCCESS(EncryptInternal( |
+ ASSERT_STATUS_SUCCESS(Encrypt( |
algorithm, |
public_key, |
- reinterpret_cast<const unsigned char*>(decrypted_data.data()), |
- decrypted_data.byteLength(), |
+ decrypted_data, |
&encrypted_data)); |
EXPECT_EQ(128u, encrypted_data.byteLength()); |
// Finally, decrypt the newly encrypted result with the private key, and |
// compare to the known original cleartext. |
decrypted_data.reset(); |
- ASSERT_STATUS_SUCCESS(DecryptInternal( |
+ ASSERT_STATUS_SUCCESS(Decrypt( |
algorithm, |
private_key, |
- reinterpret_cast<const unsigned char*>(encrypted_data.data()), |
- encrypted_data.byteLength(), |
+ encrypted_data, |
&decrypted_data)); |
EXPECT_FALSE(decrypted_data.isNull()); |
- ExpectArrayBufferMatches(cleartext, decrypted_data); |
+ ExpectCryptoDataMatches(cleartext, decrypted_data); |
} |
-TEST_F(WebCryptoImplTest, MAYBE(RsaEsFailures)) { |
+TEST_F(SharedCryptoTest, MAYBE(RsaEsFailures)) { |
// Import a key pair. |
blink::WebCryptoAlgorithm algorithm = |
- webcrypto::CreateAlgorithm(blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5); |
+ CreateAlgorithm(blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5); |
blink::WebCryptoKey public_key = blink::WebCryptoKey::createNull(); |
blink::WebCryptoKey private_key = blink::WebCryptoKey::createNull(); |
ImportRsaKeyPair( |
@@ -1750,10 +1601,10 @@ TEST_F(WebCryptoImplTest, MAYBE(RsaEsFailures)) { |
const std::string message_hex_str("0102030405060708090a0b0c0d0e0f"); |
const std::vector<uint8> message_hex(HexStringToBytes(message_hex_str)); |
EXPECT_STATUS(Status::ErrorUnexpectedKeyType(), |
- EncryptInternal(algorithm, private_key, message_hex, &encrypted_data)); |
+ Encrypt(algorithm, private_key, message_hex, &encrypted_data)); |
// Fail encrypt with empty message. |
- EXPECT_STATUS(Status::Error(), EncryptInternal( |
+ EXPECT_STATUS(Status::Error(), Encrypt( |
algorithm, public_key, std::vector<uint8>(), &encrypted_data)); |
// Fail encrypt with message too large. RSAES can operate on messages up to |
@@ -1761,22 +1612,21 @@ TEST_F(WebCryptoImplTest, MAYBE(RsaEsFailures)) { |
const unsigned int kMaxMsgSizeBytes = kModulusLength / 8 - 11; |
EXPECT_STATUS( |
Status::ErrorDataTooLarge(), |
- EncryptInternal(algorithm, |
+ Encrypt(algorithm, |
public_key, |
std::vector<uint8>(kMaxMsgSizeBytes + 1, '0'), |
&encrypted_data)); |
// Generate encrypted data. |
EXPECT_STATUS(Status::Success(), |
- EncryptInternal(algorithm, public_key, message_hex, &encrypted_data)); |
+ Encrypt(algorithm, public_key, message_hex, &encrypted_data)); |
// Fail decrypt with a public key. |
blink::WebArrayBuffer decrypted_data; |
- EXPECT_STATUS(Status::ErrorUnexpectedKeyType(), DecryptInternal( |
+ EXPECT_STATUS(Status::ErrorUnexpectedKeyType(), Decrypt( |
algorithm, |
public_key, |
- reinterpret_cast<const unsigned char*>(encrypted_data.data()), |
- encrypted_data.byteLength(), |
+ encrypted_data, |
&decrypted_data)); |
// Corrupt encrypted data; ensure decrypt fails because padding was disrupted. |
@@ -1785,22 +1635,21 @@ TEST_F(WebCryptoImplTest, MAYBE(RsaEsFailures)) { |
static_cast<uint8*>(encrypted_data.data()) + encrypted_data.byteLength()); |
corrupted_data[corrupted_data.size() / 2] ^= 0x01; |
EXPECT_STATUS(Status::Error(), |
- DecryptInternal(algorithm, private_key, corrupted_data, &decrypted_data)); |
+ Decrypt(algorithm, private_key, corrupted_data, &decrypted_data)); |
// TODO(padolph): Are there other specific data corruption scenarios to |
// consider? |
// Do a successful decrypt with good data just for confirmation. |
- EXPECT_STATUS_SUCCESS(DecryptInternal( |
+ EXPECT_STATUS_SUCCESS(Decrypt( |
algorithm, |
private_key, |
- reinterpret_cast<const unsigned char*>(encrypted_data.data()), |
- encrypted_data.byteLength(), |
+ encrypted_data, |
&decrypted_data)); |
- ExpectArrayBufferMatchesHex(message_hex_str, decrypted_data); |
+ ExpectCryptoDataMatchesHex(message_hex_str, decrypted_data); |
} |
-TEST_F(WebCryptoImplTest, MAYBE(RsaSsaSignVerifyFailures)) { |
+TEST_F(SharedCryptoTest, MAYBE(RsaSsaSignVerifyFailures)) { |
// Import a key pair. |
blink::WebCryptoAlgorithm algorithm = CreateRsaAlgorithmWithInnerHash( |
blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, |
@@ -1821,24 +1670,23 @@ TEST_F(WebCryptoImplTest, MAYBE(RsaSsaSignVerifyFailures)) { |
// Compute a signature. |
const std::vector<uint8> data = HexStringToBytes("010203040506070809"); |
- ASSERT_STATUS_SUCCESS(SignInternal(algorithm, private_key, data, &signature)); |
+ ASSERT_STATUS_SUCCESS(Sign(algorithm, private_key, data, &signature)); |
// Ensure truncated signature does not verify by passing one less byte. |
- EXPECT_STATUS_SUCCESS(VerifySignatureInternal( |
+ EXPECT_STATUS_SUCCESS(VerifySignature( |
algorithm, |
public_key, |
- static_cast<const unsigned char*>(signature.data()), |
- signature.byteLength() - 1, |
+ CryptoData(reinterpret_cast<const unsigned char*>(signature.data()), |
+ signature.byteLength() - 1), |
data, |
&signature_match)); |
EXPECT_FALSE(signature_match); |
// Ensure truncated signature does not verify by passing no bytes. |
- EXPECT_STATUS_SUCCESS(VerifySignatureInternal( |
+ EXPECT_STATUS_SUCCESS(VerifySignature( |
algorithm, |
public_key, |
- NULL, |
- 0, |
+ CryptoData(), |
data, |
&signature_match)); |
EXPECT_FALSE(signature_match); |
@@ -1848,11 +1696,10 @@ TEST_F(WebCryptoImplTest, MAYBE(RsaSsaSignVerifyFailures)) { |
static_cast<uint8*>(signature.data()), |
static_cast<uint8*>(signature.data()) + signature.byteLength()); |
corrupt_sig[corrupt_sig.size() / 2] ^= 0x1; |
- EXPECT_STATUS_SUCCESS(VerifySignatureInternal( |
+ EXPECT_STATUS_SUCCESS(VerifySignature( |
algorithm, |
public_key, |
- webcrypto::Uint8VectorStart(corrupt_sig), |
- corrupt_sig.size(), |
+ corrupt_sig, |
data, |
&signature_match)); |
EXPECT_FALSE(signature_match); |
@@ -1861,40 +1708,32 @@ TEST_F(WebCryptoImplTest, MAYBE(RsaSsaSignVerifyFailures)) { |
const unsigned int long_message_size_bytes = 1024; |
DCHECK_GT(long_message_size_bytes, kModulusLength/8); |
const unsigned char kLongSignature[long_message_size_bytes] = { 0 }; |
- EXPECT_STATUS_SUCCESS(VerifySignatureInternal( |
+ EXPECT_STATUS_SUCCESS(VerifySignature( |
algorithm, |
public_key, |
- kLongSignature, |
- sizeof(kLongSignature), |
+ CryptoData(kLongSignature, sizeof(kLongSignature)), |
data, |
&signature_match)); |
EXPECT_FALSE(signature_match); |
// Ensure that verifying using a private key, rather than a public key, fails. |
- EXPECT_STATUS(Status::ErrorUnexpectedKeyType(), VerifySignatureInternal( |
+ EXPECT_STATUS(Status::ErrorUnexpectedKeyType(), VerifySignature( |
algorithm, |
private_key, |
- static_cast<const unsigned char*>(signature.data()), |
- signature.byteLength(), |
- data, |
+ signature, data, |
&signature_match)); |
// Ensure that signing using a public key, rather than a private key, fails. |
EXPECT_STATUS(Status::ErrorUnexpectedKeyType(), |
- SignInternal(algorithm, public_key, data, &signature)); |
+ Sign(algorithm, public_key, data, &signature)); |
// Ensure that signing and verifying with an incompatible algorithm fails. |
algorithm = |
- webcrypto::CreateAlgorithm(blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5); |
- EXPECT_STATUS(Status::ErrorUnsupported(), |
- SignInternal(algorithm, private_key, data, &signature)); |
- EXPECT_STATUS(Status::ErrorUnsupported(), VerifySignatureInternal( |
- algorithm, |
- public_key, |
- static_cast<const unsigned char*>(signature.data()), |
- signature.byteLength(), |
- data, |
- &signature_match)); |
+ CreateAlgorithm(blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5); |
+ EXPECT_STATUS(Status::ErrorKeyAlgorithmMismatch(), |
+ Sign(algorithm, private_key, data, &signature)); |
+ EXPECT_STATUS(Status::ErrorKeyAlgorithmMismatch(), VerifySignature( |
+ algorithm, public_key, signature, data, &signature_match)); |
// Some crypto libraries (NSS) can automatically select the RSA SSA inner hash |
// based solely on the contents of the input signature data. In the Web Crypto |
@@ -1906,7 +1745,7 @@ TEST_F(WebCryptoImplTest, MAYBE(RsaSsaSignVerifyFailures)) { |
// is specified by the input algorithm (desired), the verify will fail. |
// Compute a signature using SHA-1 as the inner hash. |
- EXPECT_STATUS_SUCCESS(SignInternal(CreateRsaAlgorithmWithInnerHash( |
+ EXPECT_STATUS_SUCCESS(Sign(CreateRsaAlgorithmWithInnerHash( |
blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, |
blink::WebCryptoAlgorithmIdSha1), |
private_key, |
@@ -1919,19 +1758,18 @@ TEST_F(WebCryptoImplTest, MAYBE(RsaSsaSignVerifyFailures)) { |
// algorithm has WebCryptoRsaKeyGenParams and not WebCryptoRsaSsaParams. Thus |
// it has no inner hash to conflict with the input algorithm. |
bool is_match; |
- EXPECT_STATUS_SUCCESS(VerifySignatureInternal( |
+ EXPECT_STATUS_SUCCESS(VerifySignature( |
CreateRsaAlgorithmWithInnerHash( |
blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, |
blink::WebCryptoAlgorithmIdSha256), |
public_key, |
- static_cast<const unsigned char*>(signature.data()), |
- signature.byteLength(), |
+ signature, |
data, |
&is_match)); |
EXPECT_FALSE(is_match); |
} |
-TEST_F(WebCryptoImplTest, MAYBE(RsaSignVerifyKnownAnswer)) { |
+TEST_F(SharedCryptoTest, MAYBE(RsaSignVerifyKnownAnswer)) { |
scoped_ptr<base::ListValue> tests; |
ASSERT_TRUE(ReadJsonTestFileToList("pkcs1v15_sign.json", &tests)); |
@@ -1965,11 +1803,11 @@ TEST_F(WebCryptoImplTest, MAYBE(RsaSignVerifyKnownAnswer)) { |
signature.reset(); |
ASSERT_STATUS_SUCCESS( |
- SignInternal(algorithm, private_key, test_message, &signature)); |
- ExpectArrayBufferMatches(test_signature, signature); |
+ Sign(algorithm, private_key, test_message, &signature)); |
+ ExpectCryptoDataMatches(test_signature, signature); |
bool is_match = false; |
- ASSERT_STATUS_SUCCESS(VerifySignatureInternal( |
+ ASSERT_STATUS_SUCCESS(VerifySignature( |
algorithm, |
public_key, |
test_signature, |
@@ -1979,55 +1817,55 @@ TEST_F(WebCryptoImplTest, MAYBE(RsaSignVerifyKnownAnswer)) { |
} |
} |
-TEST_F(WebCryptoImplTest, MAYBE(AesKwKeyImport)) { |
+TEST_F(SharedCryptoTest, MAYBE(AesKwKeyImport)) { |
blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); |
blink::WebCryptoAlgorithm algorithm = |
- webcrypto::CreateAlgorithm(blink::WebCryptoAlgorithmIdAesKw); |
+ CreateAlgorithm(blink::WebCryptoAlgorithmIdAesKw); |
// Import a 128-bit Key Encryption Key (KEK) |
std::string key_raw_hex_in = "025a8cf3f08b4f6c5f33bbc76a471939"; |
- ASSERT_STATUS_SUCCESS(ImportKeyInternal(blink::WebCryptoKeyFormatRaw, |
+ ASSERT_STATUS_SUCCESS(ImportKey(blink::WebCryptoKeyFormatRaw, |
HexStringToBytes(key_raw_hex_in), |
algorithm, |
true, |
blink::WebCryptoKeyUsageWrapKey, |
&key)); |
blink::WebArrayBuffer key_raw_out; |
- EXPECT_STATUS_SUCCESS(ExportKeyInternal(blink::WebCryptoKeyFormatRaw, |
+ EXPECT_STATUS_SUCCESS(ExportKey(blink::WebCryptoKeyFormatRaw, |
key, |
&key_raw_out)); |
- ExpectArrayBufferMatchesHex(key_raw_hex_in, key_raw_out); |
+ ExpectCryptoDataMatchesHex(key_raw_hex_in, key_raw_out); |
// Import a 192-bit KEK |
key_raw_hex_in = "c0192c6466b2370decbb62b2cfef4384544ffeb4d2fbc103"; |
- ASSERT_STATUS_SUCCESS(ImportKeyInternal(blink::WebCryptoKeyFormatRaw, |
+ ASSERT_STATUS_SUCCESS(ImportKey(blink::WebCryptoKeyFormatRaw, |
HexStringToBytes(key_raw_hex_in), |
algorithm, |
true, |
blink::WebCryptoKeyUsageWrapKey, |
&key)); |
- EXPECT_STATUS_SUCCESS(ExportKeyInternal(blink::WebCryptoKeyFormatRaw, |
+ EXPECT_STATUS_SUCCESS(ExportKey(blink::WebCryptoKeyFormatRaw, |
key, |
&key_raw_out)); |
- ExpectArrayBufferMatchesHex(key_raw_hex_in, key_raw_out); |
+ ExpectCryptoDataMatchesHex(key_raw_hex_in, key_raw_out); |
// Import a 256-bit Key Encryption Key (KEK) |
key_raw_hex_in = |
"e11fe66380d90fa9ebefb74e0478e78f95664d0c67ca20ce4a0b5842863ac46f"; |
- ASSERT_STATUS_SUCCESS(ImportKeyInternal(blink::WebCryptoKeyFormatRaw, |
+ ASSERT_STATUS_SUCCESS(ImportKey(blink::WebCryptoKeyFormatRaw, |
HexStringToBytes(key_raw_hex_in), |
algorithm, |
true, |
blink::WebCryptoKeyUsageWrapKey, |
&key)); |
- EXPECT_STATUS_SUCCESS(ExportKeyInternal(blink::WebCryptoKeyFormatRaw, |
+ EXPECT_STATUS_SUCCESS(ExportKey(blink::WebCryptoKeyFormatRaw, |
key, |
&key_raw_out)); |
- ExpectArrayBufferMatchesHex(key_raw_hex_in, key_raw_out); |
+ ExpectCryptoDataMatchesHex(key_raw_hex_in, key_raw_out); |
// Fail import of 0 length key |
EXPECT_STATUS(Status::Error(), |
- ImportKeyInternal(blink::WebCryptoKeyFormatRaw, |
+ ImportKey(blink::WebCryptoKeyFormatRaw, |
HexStringToBytes(""), |
algorithm, |
true, |
@@ -2037,7 +1875,7 @@ TEST_F(WebCryptoImplTest, MAYBE(AesKwKeyImport)) { |
// Fail import of 124-bit KEK |
key_raw_hex_in = "3e4566a2bdaa10cb68134fa66c15ddb"; |
EXPECT_STATUS(Status::Error(), |
- ImportKeyInternal(blink::WebCryptoKeyFormatRaw, |
+ ImportKey(blink::WebCryptoKeyFormatRaw, |
HexStringToBytes(key_raw_hex_in), |
algorithm, |
true, |
@@ -2047,7 +1885,7 @@ TEST_F(WebCryptoImplTest, MAYBE(AesKwKeyImport)) { |
// Fail import of 200-bit KEK |
key_raw_hex_in = "0a1d88608a5ad9fec64f1ada269ebab4baa2feeb8d95638c0e"; |
EXPECT_STATUS(Status::Error(), |
- ImportKeyInternal(blink::WebCryptoKeyFormatRaw, |
+ ImportKey(blink::WebCryptoKeyFormatRaw, |
HexStringToBytes(key_raw_hex_in), |
algorithm, |
true, |
@@ -2058,7 +1896,7 @@ TEST_F(WebCryptoImplTest, MAYBE(AesKwKeyImport)) { |
key_raw_hex_in = |
"72d4e475ff34215416c9ad9c8281247a4d730c5f275ac23f376e73e3bce8d7d5a"; |
EXPECT_STATUS(Status::Error(), |
- ImportKeyInternal(blink::WebCryptoKeyFormatRaw, |
+ ImportKey(blink::WebCryptoKeyFormatRaw, |
HexStringToBytes(key_raw_hex_in), |
algorithm, |
true, |
@@ -2070,7 +1908,7 @@ TEST_F(WebCryptoImplTest, MAYBE(AesKwKeyImport)) { |
// * Test decryption when the tag length exceeds input size |
// * Test decryption with empty input |
// * Test decryption with tag length of 0. |
-TEST_F(WebCryptoImplTest, MAYBE(AesGcmSampleSets)) { |
+TEST_F(SharedCryptoTest, MAYBE(AesGcmSampleSets)) { |
// Some Linux test runners may not have a new enough version of NSS. |
if (!SupportsAesGcm()) { |
LOG(WARNING) << "AES GCM not supported, skipping tests"; |
@@ -2100,15 +1938,15 @@ TEST_F(WebCryptoImplTest, MAYBE(AesGcmSampleSets)) { |
blink::WebCryptoKey key = ImportSecretKeyFromRaw( |
test_key, |
- webcrypto::CreateAlgorithm(blink::WebCryptoAlgorithmIdAesGcm), |
+ CreateAlgorithm(blink::WebCryptoAlgorithmIdAesGcm), |
blink::WebCryptoKeyUsageEncrypt | blink::WebCryptoKeyUsageDecrypt); |
// Verify exported raw key is identical to the imported data |
blink::WebArrayBuffer raw_key; |
- EXPECT_STATUS_SUCCESS(ExportKeyInternal( |
+ EXPECT_STATUS_SUCCESS(ExportKey( |
blink::WebCryptoKeyFormatRaw, key, &raw_key)); |
- ExpectArrayBufferMatches(test_key, raw_key); |
+ ExpectCryptoDataMatches(test_key, raw_key); |
// Test encryption. |
std::vector<uint8> cipher_text; |
@@ -2117,15 +1955,15 @@ TEST_F(WebCryptoImplTest, MAYBE(AesGcmSampleSets)) { |
test_tag_size_bits, test_plain_text, |
&cipher_text, &authentication_tag)); |
- ExpectVectorMatches(test_cipher_text, cipher_text); |
- ExpectVectorMatches(test_authentication_tag, authentication_tag); |
+ ExpectCryptoDataMatches(test_cipher_text, cipher_text); |
+ ExpectCryptoDataMatches(test_authentication_tag, authentication_tag); |
// Test decryption. |
blink::WebArrayBuffer plain_text; |
EXPECT_STATUS_SUCCESS(AesGcmDecrypt(key, test_iv, test_additional_data, |
test_tag_size_bits, test_cipher_text, |
test_authentication_tag, &plain_text)); |
- ExpectArrayBufferMatches(test_plain_text, plain_text); |
+ ExpectCryptoDataMatches(test_plain_text, plain_text); |
// Decryption should fail if any of the inputs are tampered with. |
EXPECT_STATUS(Status::Error(), |
@@ -2159,4 +1997,5 @@ TEST_F(WebCryptoImplTest, MAYBE(AesGcmSampleSets)) { |
} |
} |
+} // namespace webcrypto |
} // namespace content |