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

Unified Diff: trunk/src/content/child/webcrypto/shared_crypto_unittest.cc

Issue 252213003: Revert 266798 "[webcrypto] Make operations run on a background t..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 8 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
« no previous file with comments | « trunk/src/content/child/webcrypto/shared_crypto.cc ('k') | trunk/src/content/child/webcrypto/status.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/content/child/webcrypto/shared_crypto_unittest.cc
===================================================================
--- trunk/src/content/child/webcrypto/shared_crypto_unittest.cc (revision 266902)
+++ trunk/src/content/child/webcrypto/shared_crypto_unittest.cc (working copy)
@@ -67,89 +67,6 @@
namespace {
-// -----------------------------------------------------------------------------
-// TODO(eroman): Remove these helpers and convert all of the tests to using the
-// std::vector<> flavor of functions directly.
-// -----------------------------------------------------------------------------
-
-blink::WebArrayBuffer CreateArrayBuffer(const uint8* data,
- unsigned int data_size) {
- blink::WebArrayBuffer buffer = blink::WebArrayBuffer::create(data_size, 1);
- DCHECK(!buffer.isNull());
- if (data_size) // data_size == 0 might mean the data pointer is invalid
- memcpy(buffer.data(), data, data_size);
- return buffer;
-}
-
-void AssignWebArrayBuffer(const std::vector<uint8>& in,
- blink::WebArrayBuffer* out) {
- *out = CreateArrayBuffer(Uint8VectorStart(in), in.size());
-}
-
-Status Encrypt(const blink::WebCryptoAlgorithm& algorithm,
- const blink::WebCryptoKey& key,
- const CryptoData& data,
- blink::WebArrayBuffer* web_buffer) {
- std::vector<uint8> buffer;
- Status status = Encrypt(algorithm, key, data, &buffer);
- AssignWebArrayBuffer(buffer, web_buffer);
- return status;
-}
-
-Status Decrypt(const blink::WebCryptoAlgorithm& algorithm,
- const blink::WebCryptoKey& key,
- const CryptoData& data,
- blink::WebArrayBuffer* web_buffer) {
- std::vector<uint8> buffer;
- Status status = Decrypt(algorithm, key, data, &buffer);
- AssignWebArrayBuffer(buffer, web_buffer);
- return status;
-}
-
-Status Digest(const blink::WebCryptoAlgorithm& algorithm,
- const CryptoData& data,
- blink::WebArrayBuffer* web_buffer) {
- std::vector<uint8> buffer;
- Status status = Digest(algorithm, data, &buffer);
- AssignWebArrayBuffer(buffer, web_buffer);
- return status;
-}
-
-Status ExportKey(blink::WebCryptoKeyFormat format,
- const blink::WebCryptoKey& key,
- blink::WebArrayBuffer* web_buffer) {
- std::vector<uint8> buffer;
- Status status = webcrypto::ExportKey(format, key, &buffer);
- AssignWebArrayBuffer(buffer, web_buffer);
- return status;
-}
-
-Status Sign(const blink::WebCryptoAlgorithm& algorithm,
- const blink::WebCryptoKey& key,
- const CryptoData& data,
- blink::WebArrayBuffer* web_buffer) {
- std::vector<uint8> buffer;
-
- Status status = Sign(algorithm, key, data, &buffer);
- AssignWebArrayBuffer(buffer, web_buffer);
- return status;
-}
-
-Status WrapKey(blink::WebCryptoKeyFormat format,
- const blink::WebCryptoKey& wrapping_key,
- const blink::WebCryptoKey& key_to_wrap,
- const blink::WebCryptoAlgorithm& wrapping_algorithm,
- blink::WebArrayBuffer* web_buffer) {
- std::vector<uint8> buffer;
-
- Status status = webcrypto::WrapKey(
- format, wrapping_key, key_to_wrap, wrapping_algorithm, &buffer);
- AssignWebArrayBuffer(buffer, web_buffer);
- return status;
-}
-
-// -----------------------------------------------------------------------------
-
// TODO(eroman): For Linux builds using system NSS, AES-GCM support is a
// runtime dependency. Test it by trying to import a key.
// TODO(padolph): Consider caching the result of the import key test.
@@ -1958,45 +1875,6 @@
}
}
-TEST_F(SharedCryptoTest, MAYBE(ExportJwkEmptySymmetricKey)) {
- const blink::WebCryptoAlgorithm import_algorithm =
- webcrypto::CreateHmacImportAlgorithm(blink::WebCryptoAlgorithmIdSha1);
-
- blink::WebCryptoKeyUsageMask usages = blink::WebCryptoKeyUsageSign;
- blink::WebCryptoKey key = blink::WebCryptoKey::createNull();
-
- // Import a zero-byte HMAC key.
- const char key_data_hex[] = "";
- key = ImportSecretKeyFromRaw(
- HexStringToBytes(key_data_hex), import_algorithm, usages);
- EXPECT_EQ(0u, key.algorithm().hmacParams()->lengthBits());
-
- // Export the key in JWK format and validate.
- blink::WebArrayBuffer json;
- ASSERT_EQ(Status::Success(),
- ExportKey(blink::WebCryptoKeyFormatJwk, key, &json));
- EXPECT_TRUE(VerifySecretJwk(json, "HS1", key_data_hex, usages));
-
- // Now try re-importing the JWK key.
- key = blink::WebCryptoKey::createNull();
- EXPECT_EQ(Status::Success(),
- ImportKey(blink::WebCryptoKeyFormatJwk,
- CryptoData(json),
- import_algorithm,
- true,
- usages,
- &key));
-
- EXPECT_EQ(blink::WebCryptoKeyTypeSecret, key.type());
- EXPECT_EQ(0u, key.algorithm().hmacParams()->lengthBits());
-
- blink::WebArrayBuffer exported_key_data;
- EXPECT_EQ(Status::Success(),
- ExportKey(blink::WebCryptoKeyFormatRaw, key, &exported_key_data));
-
- EXPECT_EQ(0u, exported_key_data.byteLength());
-}
-
TEST_F(SharedCryptoTest, MAYBE(ImportExportSpki)) {
// Passing case: Import a valid RSA key in SPKI format.
blink::WebCryptoKey key = blink::WebCryptoKey::createNull();
@@ -2250,12 +2128,11 @@
EXPECT_EQ(usage_mask, public_key.usages());
EXPECT_EQ(usage_mask, private_key.usages());
- // Successful WebCryptoAlgorithmIdRsaSsaPkcs1v1_5 key generation (sha256)
- algorithm =
- CreateRsaHashedKeyGenAlgorithm(blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5,
- blink::WebCryptoAlgorithmIdSha256,
- modulus_length,
- public_exponent);
+ // Successful WebCryptoAlgorithmIdRsaOaep key generation.
+ algorithm = CreateRsaHashedKeyGenAlgorithm(blink::WebCryptoAlgorithmIdRsaOaep,
+ blink::WebCryptoAlgorithmIdSha256,
+ modulus_length,
+ public_exponent);
EXPECT_EQ(Status::Success(),
GenerateKeyPair(
algorithm, extractable, usage_mask, &public_key, &private_key));
« no previous file with comments | « trunk/src/content/child/webcrypto/shared_crypto.cc ('k') | trunk/src/content/child/webcrypto/status.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698