| Index: components/webcrypto/algorithms/ec.cc
|
| diff --git a/components/webcrypto/algorithms/ec.cc b/components/webcrypto/algorithms/ec.cc
|
| index 09b9ae408c9da802549e4ae5d9440732fc8bfb8a..9aa9bfeced7760270c3f88bf2479ccf0ee48043c 100644
|
| --- a/components/webcrypto/algorithms/ec.cc
|
| +++ b/components/webcrypto/algorithms/ec.cc
|
| @@ -290,11 +290,37 @@ Status EcAlgorithm::GenerateKey(const blink::WebCryptoAlgorithm& algorithm,
|
| return Status::Success();
|
| }
|
|
|
| -Status EcAlgorithm::VerifyKeyUsagesBeforeImportKey(
|
| - blink::WebCryptoKeyFormat format,
|
| - blink::WebCryptoKeyUsageMask usages) const {
|
| - return VerifyUsagesBeforeImportAsymmetricKey(format, all_public_key_usages_,
|
| - all_private_key_usages_, usages);
|
| +Status EcAlgorithm::ImportKey(blink::WebCryptoKeyFormat format,
|
| + const CryptoData& key_data,
|
| + const blink::WebCryptoAlgorithm& algorithm,
|
| + bool extractable,
|
| + blink::WebCryptoKeyUsageMask usages,
|
| + blink::WebCryptoKey* key) const {
|
| + switch (format) {
|
| + case blink::WebCryptoKeyFormatPkcs8:
|
| + return ImportKeyPkcs8(key_data, algorithm, extractable, usages, key);
|
| + case blink::WebCryptoKeyFormatSpki:
|
| + return ImportKeySpki(key_data, algorithm, extractable, usages, key);
|
| + case blink::WebCryptoKeyFormatJwk:
|
| + return ImportKeyJwk(key_data, algorithm, extractable, usages, key);
|
| + default:
|
| + return Status::ErrorUnsupportedImportKeyFormat();
|
| + }
|
| +}
|
| +
|
| +Status EcAlgorithm::ExportKey(blink::WebCryptoKeyFormat format,
|
| + const blink::WebCryptoKey& key,
|
| + std::vector<uint8_t>* buffer) const {
|
| + switch (format) {
|
| + case blink::WebCryptoKeyFormatPkcs8:
|
| + return ExportKeyPkcs8(key, buffer);
|
| + case blink::WebCryptoKeyFormatSpki:
|
| + return ExportKeySpki(key, buffer);
|
| + case blink::WebCryptoKeyFormatJwk:
|
| + return ExportKeyJwk(key, buffer);
|
| + default:
|
| + return Status::ErrorUnsupportedExportKeyFormat();
|
| + }
|
| }
|
|
|
| Status EcAlgorithm::ImportKeyPkcs8(const CryptoData& key_data,
|
| @@ -302,9 +328,12 @@ Status EcAlgorithm::ImportKeyPkcs8(const CryptoData& key_data,
|
| bool extractable,
|
| blink::WebCryptoKeyUsageMask usages,
|
| blink::WebCryptoKey* key) const {
|
| + Status status = CheckKeyCreationUsages(all_private_key_usages_, usages);
|
| + if (status.IsError())
|
| + return status;
|
| +
|
| crypto::ScopedEVP_PKEY private_key;
|
| - Status status =
|
| - ImportUnverifiedPkeyFromPkcs8(key_data, EVP_PKEY_EC, &private_key);
|
| + status = ImportUnverifiedPkeyFromPkcs8(key_data, EVP_PKEY_EC, &private_key);
|
| if (status.IsError())
|
| return status;
|
|
|
| @@ -327,9 +356,12 @@ Status EcAlgorithm::ImportKeySpki(const CryptoData& key_data,
|
| bool extractable,
|
| blink::WebCryptoKeyUsageMask usages,
|
| blink::WebCryptoKey* key) const {
|
| + Status status = CheckKeyCreationUsages(all_public_key_usages_, usages);
|
| + if (status.IsError())
|
| + return status;
|
| +
|
| crypto::ScopedEVP_PKEY public_key;
|
| - Status status =
|
| - ImportUnverifiedPkeyFromSpki(key_data, EVP_PKEY_EC, &public_key);
|
| + status = ImportUnverifiedPkeyFromSpki(key_data, EVP_PKEY_EC, &public_key);
|
| if (status.IsError())
|
| return status;
|
|
|
| @@ -388,9 +420,9 @@ Status EcAlgorithm::ImportKeyJwk(const CryptoData& key_data,
|
|
|
| // Now that the key type is known, verify the usages.
|
| if (is_private_key) {
|
| - status = CheckPrivateKeyCreationUsages(all_private_key_usages_, usages);
|
| + status = CheckKeyCreationUsages(all_private_key_usages_, usages);
|
| } else {
|
| - status = CheckPublicKeyCreationUsages(all_public_key_usages_, usages);
|
| + status = CheckKeyCreationUsages(all_public_key_usages_, usages);
|
| }
|
|
|
| if (status.IsError())
|
|
|