| Index: content/child/webcrypto/shared_crypto_unittest.cc
|
| diff --git a/content/child/webcrypto/shared_crypto_unittest.cc b/content/child/webcrypto/shared_crypto_unittest.cc
|
| index d5c7df89211f8d0ec49a5c802a0b55cd49dd9852..5fca92c20658eab24e514280776bc7efed20b31d 100644
|
| --- a/content/child/webcrypto/shared_crypto_unittest.cc
|
| +++ b/content/child/webcrypto/shared_crypto_unittest.cc
|
| @@ -910,19 +910,6 @@ TEST_F(SharedCryptoTest, MAYBE(GenerateKeyHmacNoLength)) {
|
| EXPECT_EQ(128U, raw_key.byteLength());
|
| }
|
|
|
| -TEST_F(SharedCryptoTest, MAYBE(ImportSecretKeyNoAlgorithm)) {
|
| - blink::WebCryptoKey key = blink::WebCryptoKey::createNull();
|
| -
|
| - // This fails because the algorithm is null.
|
| - EXPECT_STATUS(Status::ErrorMissingAlgorithmImportRawKey(),
|
| - ImportKey(blink::WebCryptoKeyFormatRaw,
|
| - CryptoData(HexStringToBytes("00000000000000000000")),
|
| - blink::WebCryptoAlgorithm::createNull(),
|
| - true,
|
| - blink::WebCryptoKeyUsageEncrypt,
|
| - &key));
|
| -}
|
| -
|
| TEST_F(SharedCryptoTest, ImportJwkFailures) {
|
|
|
| blink::WebCryptoKey key = blink::WebCryptoKey::createNull();
|
| @@ -962,16 +949,6 @@ TEST_F(SharedCryptoTest, ImportJwkFailures) {
|
| ImportKeyJwkFromDict(dict, algorithm, false, usage_mask, &key));
|
| RestoreJwkOctDictionary(&dict);
|
|
|
| - // Fail on both JWK and input algorithm missing.
|
| - dict.Remove("alg", NULL);
|
| - EXPECT_STATUS(Status::ErrorJwkAlgorithmMissing(),
|
| - ImportKeyJwkFromDict(dict,
|
| - blink::WebCryptoAlgorithm::createNull(),
|
| - false,
|
| - usage_mask,
|
| - &key));
|
| - RestoreJwkOctDictionary(&dict);
|
| -
|
| // Fail on invalid kty.
|
| dict.SetString("kty", "foo");
|
| EXPECT_STATUS(Status::ErrorJwkUnrecognizedKty(),
|
| @@ -1194,14 +1171,6 @@ TEST_F(SharedCryptoTest, MAYBE(ImportJwkInputConsistency)) {
|
| usage_mask,
|
| &key));
|
|
|
| - // Pass: JWK alg valid but input algorithm isNull: use JWK algorithm value.
|
| - EXPECT_STATUS_SUCCESS(ImportKeyJwk(CryptoData(json_vec),
|
| - blink::WebCryptoAlgorithm::createNull(),
|
| - extractable,
|
| - usage_mask,
|
| - &key));
|
| - EXPECT_EQ(blink::WebCryptoAlgorithmIdHmac, algorithm.id());
|
| -
|
| // Pass: JWK alg missing but input algorithm specified: use input value
|
| dict.Remove("alg", NULL);
|
| EXPECT_STATUS_SUCCESS(ImportKeyJwkFromDict(
|
| @@ -1304,24 +1273,14 @@ TEST_F(SharedCryptoTest, MAYBE(ImportExportSpki)) {
|
| "010001", CryptoData(key.algorithm().rsaParams()->publicExponent()));
|
|
|
| // Failing case: Empty SPKI data
|
| - EXPECT_STATUS(Status::ErrorImportEmptyKeyData(),
|
| - ImportKey(blink::WebCryptoKeyFormatSpki,
|
| - CryptoData(std::vector<uint8>()),
|
| - blink::WebCryptoAlgorithm::createNull(),
|
| - true,
|
| - blink::WebCryptoKeyUsageEncrypt,
|
| - &key));
|
| -
|
| - // 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(),
|
| - ImportKey(blink::WebCryptoKeyFormatSpki,
|
| - CryptoData(HexStringToBytes(kPublicKeySpkiDerHex)),
|
| - blink::WebCryptoAlgorithm::createNull(),
|
| - true,
|
| - blink::WebCryptoKeyUsageEncrypt,
|
| - &key));
|
| + EXPECT_STATUS(
|
| + Status::ErrorImportEmptyKeyData(),
|
| + ImportKey(blink::WebCryptoKeyFormatSpki,
|
| + CryptoData(std::vector<uint8>()),
|
| + CreateAlgorithm(blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5),
|
| + true,
|
| + blink::WebCryptoKeyUsageEncrypt,
|
| + &key));
|
|
|
| // Failing case: Bad DER encoding.
|
| EXPECT_STATUS(
|
| @@ -1394,18 +1353,9 @@ TEST_F(SharedCryptoTest, MAYBE(ImportPkcs8)) {
|
| EXPECT_STATUS(Status::ErrorImportEmptyKeyData(),
|
| ImportKey(blink::WebCryptoKeyFormatPkcs8,
|
| CryptoData(std::vector<uint8>()),
|
| - blink::WebCryptoAlgorithm::createNull(),
|
| - true,
|
| - blink::WebCryptoKeyUsageSign,
|
| - &key));
|
| -
|
| - // 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(),
|
| - ImportKey(blink::WebCryptoKeyFormatPkcs8,
|
| - CryptoData(HexStringToBytes(kPrivateKeyPkcs8DerHex)),
|
| - blink::WebCryptoAlgorithm::createNull(),
|
| + CreateRsaHashedImportAlgorithm(
|
| + blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5,
|
| + blink::WebCryptoAlgorithmIdSha1),
|
| true,
|
| blink::WebCryptoKeyUsageSign,
|
| &key));
|
| @@ -2113,21 +2063,10 @@ TEST_F(SharedCryptoTest, MAYBE(AesKwRawSymkeyWrapUnwrapErrors)) {
|
| webcrypto::CreateAlgorithm(blink::WebCryptoAlgorithmIdAesCbc),
|
| blink::WebCryptoKeyUsageEncrypt);
|
|
|
| - // Unwrap with null algorithm must fail.
|
| - blink::WebCryptoKey unwrapped_key = blink::WebCryptoKey::createNull();
|
| - EXPECT_STATUS(Status::ErrorMissingAlgorithmUnwrapRawKey(),
|
| - UnwrapKey(blink::WebCryptoKeyFormatRaw,
|
| - CryptoData(test_ciphertext),
|
| - wrapping_key,
|
| - wrapping_algorithm,
|
| - blink::WebCryptoAlgorithm::createNull(),
|
| - true,
|
| - blink::WebCryptoKeyUsageEncrypt,
|
| - &unwrapped_key));
|
| -
|
| // Unwrap with wrapped data too small must fail.
|
| const std::vector<uint8> small_data(test_ciphertext.begin(),
|
| test_ciphertext.begin() + 23);
|
| + blink::WebCryptoKey unwrapped_key = blink::WebCryptoKey::createNull();
|
| EXPECT_STATUS(Status::ErrorDataTooSmall(),
|
| UnwrapKey(blink::WebCryptoKeyFormatRaw,
|
| CryptoData(small_data),
|
|
|