Index: content/child/webcrypto/test/rsa_ssa_unittest.cc |
diff --git a/content/child/webcrypto/test/rsa_ssa_unittest.cc b/content/child/webcrypto/test/rsa_ssa_unittest.cc |
index 34037309a77055c96aae6ee6eb76fb3b62a0dd26..b30700200c2ccf4e6789c046814336ebcc81f807 100644 |
--- a/content/child/webcrypto/test/rsa_ssa_unittest.cc |
+++ b/content/child/webcrypto/test/rsa_ssa_unittest.cc |
@@ -147,58 +147,6 @@ TEST(WebCryptoRsaSsaTest, ImportExportPkcs8) { |
&key)); |
} |
-// Tests importing of PKCS8 data that does not define a valid RSA key. |
-// TODO(eroman): Move to bad_rsa_keys.json |
-TEST(WebCryptoRsaSsaTest, ImportInvalidPkcs8) { |
- if (!SupportsRsaPrivateKeyImport()) |
- return; |
- |
- // kPrivateKeyPkcs8DerHex defines an RSA private key in PKCS8 format, whose |
- // parameters appear at the following offsets: |
- // |
- // n: (offset=36, len=129) |
- // e: (offset=167, len=3) |
- // d: (offset=173, len=128) |
- // p: (offset=303, len=65) |
- // q: (offset=370, len=65) |
- // dp: (offset=437, len=64) |
- // dq; (offset=503, len=64) |
- // qi: (offset=569, len=64) |
- |
- // Do several tests, each of which invert a single byte within the input. |
- const unsigned int kOffsetsToCorrupt[] = { |
- 50, // inside n |
- 168, // inside e |
- 175, // inside d |
- 333, // inside p |
- 373, // inside q |
- 450, // inside dp |
- 550, // inside dq |
- 600, // inside qi |
- }; |
- |
- for (size_t test_index = 0; test_index < arraysize(kOffsetsToCorrupt); |
- ++test_index) { |
- SCOPED_TRACE(test_index); |
- |
- unsigned int i = kOffsetsToCorrupt[test_index]; |
- std::vector<uint8_t> corrupted_data = |
- HexStringToBytes(kPrivateKeyPkcs8DerHex); |
- corrupted_data[i] = ~corrupted_data[i]; |
- |
- blink::WebCryptoKey key; |
- EXPECT_EQ(Status::DataError(), |
- ImportKey(blink::WebCryptoKeyFormatPkcs8, |
- CryptoData(corrupted_data), |
- CreateRsaHashedImportAlgorithm( |
- blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, |
- blink::WebCryptoAlgorithmIdSha1), |
- true, |
- blink::WebCryptoKeyUsageSign, |
- &key)); |
- } |
-} |
- |
// Tests JWK import and export by doing a roundtrip key conversion and ensuring |
// it was lossless: |
// |
@@ -384,112 +332,6 @@ TEST(WebCryptoRsaSsaTest, ImportJwkExistingModulusAndInvalid) { |
&key2)); |
} |
-// Import a JWK RSA private key with some optional parameters missing (q, dp, |
-// dq, qi). |
-// |
-// The only optional parameter included is "p". |
-// |
-// This fails because JWA says that producers must include either ALL optional |
-// parameters or NONE. |
-// TODO(eroman): Move to bad_rsa_keys.json |
-TEST(WebCryptoRsaSsaTest, ImportRsaPrivateKeyJwkMissingOptionalParams) { |
- blink::WebCryptoKey key; |
- |
- base::DictionaryValue dict; |
- dict.SetString("kty", "RSA"); |
- dict.SetString("alg", "RS1"); |
- |
- dict.SetString( |
- "n", |
- "pW5KDnAQF1iaUYfcfqhB0Vby7A42rVKkTf6x5h962ZHYxRBW_-2xYrTA8oOhKoijlN_" |
- "1JqtykcuzB86r_OCx39XNlQgJbVsri2311nHvY3fAkhyyPCcKcOJZjm_4nRnxBazC0_" |
- "DLNfKSgOE4a29kxO8i4eHyDQzoz_siSb2aITc"); |
- dict.SetString("e", "AQAB"); |
- dict.SetString( |
- "d", |
- "M6UEKpCyfU9UUcqbu9C0R3GhAa-IQ0Cu-YhfKku-" |
- "kuiUpySsPFaMj5eFOtB8AmbIxqPKCSnx6PESMYhEKfxNmuVf7olqEM5wfD7X5zTkRyejlXRQ" |
- "GlMmgxCcKrrKuig8MbS9L1PD7jfjUs7jT55QO9gMBiKtecbc7og1R8ajsyU"); |
- |
- dict.SetString("p", |
- "5-" |
- "iUJyCod1Fyc6NWBT6iobwMlKpy1VxuhilrLfyWeUjApyy8zKfqyzVwbgmh31W" |
- "hU1vZs8w0Fgs7bc0-2o5kQw"); |
- |
- ASSERT_EQ(Status::ErrorJwkPropertyMissing("q"), |
- ImportKeyJwkFromDict(dict, |
- CreateRsaHashedImportAlgorithm( |
- blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, |
- blink::WebCryptoAlgorithmIdSha1), |
- true, |
- blink::WebCryptoKeyUsageSign, |
- &key)); |
-} |
- |
-// Import a JWK RSA private key, without any of the optional parameters. |
-// |
-// According to JWA, such keys are valid, but applications SHOULD |
-// include all the parameters when sending, and recipients MAY |
-// accept them, but are not required to. Chromium's WebCrypto does |
-// not allow such degenerate keys. |
-// TODO(eroman): Move to bad_rsa_keys.json |
-TEST(WebCryptoRsaSsaTest, ImportRsaPrivateKeyJwkIncorrectOptionalEmpty) { |
- if (!SupportsRsaPrivateKeyImport()) |
- return; |
- |
- blink::WebCryptoKey key; |
- |
- base::DictionaryValue dict; |
- dict.SetString("kty", "RSA"); |
- dict.SetString("alg", "RS1"); |
- |
- dict.SetString( |
- "n", |
- "pW5KDnAQF1iaUYfcfqhB0Vby7A42rVKkTf6x5h962ZHYxRBW_-2xYrTA8oOhKoijlN_" |
- "1JqtykcuzB86r_OCx39XNlQgJbVsri2311nHvY3fAkhyyPCcKcOJZjm_4nRnxBazC0_" |
- "DLNfKSgOE4a29kxO8i4eHyDQzoz_siSb2aITc"); |
- dict.SetString("e", "AQAB"); |
- dict.SetString( |
- "d", |
- "M6UEKpCyfU9UUcqbu9C0R3GhAa-IQ0Cu-YhfKku-" |
- "kuiUpySsPFaMj5eFOtB8AmbIxqPKCSnx6PESMYhEKfxNmuVf7olqEM5wfD7X5zTkRyejlXRQ" |
- "GlMmgxCcKrrKuig8MbS9L1PD7jfjUs7jT55QO9gMBiKtecbc7og1R8ajsyU"); |
- |
- ASSERT_EQ(Status::ErrorJwkPropertyMissing("p"), |
- ImportKeyJwkFromDict(dict, |
- CreateRsaHashedImportAlgorithm( |
- blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, |
- blink::WebCryptoAlgorithmIdSha1), |
- true, |
- blink::WebCryptoKeyUsageSign, |
- &key)); |
-} |
- |
-// Tries importing a public RSA key whose exponent contains leading zeros. |
-// TODO(eroman): Move to bad_rsa_keys.json |
-TEST(WebCryptoRsaSsaTest, ImportJwkRsaNonMinimalExponent) { |
- base::DictionaryValue dict; |
- |
- dict.SetString("kty", "RSA"); |
- dict.SetString("e", "AAEAAQ"); // 00 01 00 01 |
- dict.SetString( |
- "n", |
- "qLOyhK-OtQs4cDSoYPFGxJGfMYdjzWxVmMiuSBGh4KvEx-CwgtaTpef87Wdc9GaFEncsDLxk" |
- "p0LGxjD1M8jMcvYq6DPEC_JYQumEu3i9v5fAEH1VvbZi9cTg-rmEXLUUjvc5LdOq_5OuHmtm" |
- "e7PUJHYW1PW6ENTP0ibeiNOfFvs"); |
- |
- blink::WebCryptoKey key; |
- |
- EXPECT_EQ(Status::ErrorJwkBigIntegerHasLeadingZero("e"), |
- ImportKeyJwkFromDict(dict, |
- CreateRsaHashedImportAlgorithm( |
- blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, |
- blink::WebCryptoAlgorithmIdSha256), |
- false, |
- blink::WebCryptoKeyUsageVerify, |
- &key)); |
-} |
- |
TEST(WebCryptoRsaSsaTest, GenerateKeyPairRsa) { |
// Note: using unrealistic short key lengths here to avoid bogging down tests. |