| 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 1733ae78e3a9ce92aef0d0e05bb9d6edd9f4399b..5067b469d0b2bf7d01b99afd2221796a03015881 100644
|
| --- a/content/child/webcrypto/test/rsa_ssa_unittest.cc
|
| +++ b/content/child/webcrypto/test/rsa_ssa_unittest.cc
|
| @@ -815,7 +815,7 @@ TEST(WebCryptoRsaSsaTest, GenerateKeyPairEmptyUsages) {
|
| blink::WebCryptoKey public_key;
|
| blink::WebCryptoKey private_key;
|
|
|
| - ASSERT_EQ(Status::ErrorCreateKeyEmptyUsages(),
|
| + ASSERT_EQ(Status::ErrorKeyEmptyUsages(),
|
| GenerateKeyPair(CreateRsaHashedKeyGenAlgorithm(
|
| blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5,
|
| blink::WebCryptoAlgorithmIdSha256,
|
| @@ -823,6 +823,62 @@ TEST(WebCryptoRsaSsaTest, GenerateKeyPairEmptyUsages) {
|
| true, 0, &public_key, &private_key));
|
| }
|
|
|
| +TEST(WebCryptoRsaSsaTest, ImportKeyEmptyUsages) {
|
| + blink::WebCryptoKey public_key;
|
| + blink::WebCryptoKey private_key;
|
| + blink::WebCryptoKey key;
|
| +
|
| + // Public without usage does not throw an error.
|
| + ASSERT_EQ(Status::Success(),
|
| + ImportKey(blink::WebCryptoKeyFormatSpki,
|
| + CryptoData(HexStringToBytes(kPublicKeySpkiDerHex)),
|
| + CreateRsaHashedImportAlgorithm(
|
| + blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5,
|
| + blink::WebCryptoAlgorithmIdSha256),
|
| + true, 0, &public_key));
|
| +
|
| + // Private empty usage will throw an error.
|
| + ASSERT_EQ(Status::ErrorKeyEmptyUsages(),
|
| + ImportKey(blink::WebCryptoKeyFormatPkcs8,
|
| + CryptoData(HexStringToBytes(kPrivateKeyPkcs8DerHex)),
|
| + CreateRsaHashedImportAlgorithm(
|
| + blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5,
|
| + blink::WebCryptoAlgorithmIdSha1),
|
| + true, 0, &private_key));
|
| +
|
| + std::vector<uint8_t> public_jwk;
|
| + ASSERT_EQ(Status::Success(),
|
| + ExportKey(blink::WebCryptoKeyFormatJwk, public_key, &public_jwk));
|
| +
|
| + ASSERT_EQ(Status::Success(),
|
| + ImportKey(blink::WebCryptoKeyFormatJwk,
|
| + CryptoData(public_jwk),
|
| + CreateRsaHashedImportAlgorithm(
|
| + blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5,
|
| + blink::WebCryptoAlgorithmIdSha256),
|
| + true, 0, &key));
|
| +
|
| + // With correct usage to get correct imported private_key
|
| + std::vector<uint8_t> private_jwk;
|
| + ImportKey(blink::WebCryptoKeyFormatPkcs8,
|
| + CryptoData(HexStringToBytes(kPrivateKeyPkcs8DerHex)),
|
| + CreateRsaHashedImportAlgorithm(
|
| + blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5,
|
| + blink::WebCryptoAlgorithmIdSha1),
|
| + true, blink::WebCryptoKeyUsageSign, &private_key);
|
| +
|
| + ASSERT_EQ(Status::Success(),
|
| + ExportKey(blink::WebCryptoKeyFormatJwk, private_key, &private_jwk));
|
| +
|
| + ASSERT_EQ(Status::ErrorKeyEmptyUsages(),
|
| + ImportKey(blink::WebCryptoKeyFormatJwk,
|
| + CryptoData(private_jwk),
|
| + CreateRsaHashedImportAlgorithm(
|
| + blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5,
|
| + blink::WebCryptoAlgorithmIdSha1),
|
| + true, 0, &key));
|
| +}
|
| +
|
| TEST(WebCryptoRsaSsaTest, ImportExportJwkRsaPublicKey) {
|
| struct TestCase {
|
| const blink::WebCryptoAlgorithmId hash;
|
|
|