diff options
author | eroman <eroman@chromium.org> | 2014-10-21 12:13:31 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-21 19:13:52 +0000 |
commit | 0e1d34edba6a5d8f7fe43c5b675880a36f4b3861 (patch) | |
tree | c3b200f97725a05623ca3fafe519019a1cd32a44 /content/child | |
parent | 1f125f14e0d2cb8980049baf43f1cb34d7307a4e (diff) | |
download | chromium_src-0e1d34edba6a5d8f7fe43c5b675880a36f4b3861.zip chromium_src-0e1d34edba6a5d8f7fe43c5b675880a36f4b3861.tar.gz chromium_src-0e1d34edba6a5d8f7fe43c5b675880a36f4b3861.tar.bz2 |
Cleanup: rename usage_mask --> usages.
This is a simple search and replace:
s/usage_mask/usages/g
There was some inconsistenty on when variables were called "usages" versus "usage_mask"; now they all read "usages".
Review URL: https://codereview.chromium.org/670773003
Cr-Commit-Position: refs/heads/master@{#300533}
Diffstat (limited to 'content/child')
33 files changed, 295 insertions, 309 deletions
diff --git a/content/child/webcrypto/algorithm_dispatch.cc b/content/child/webcrypto/algorithm_dispatch.cc index a7b53ba..f8d7933 100644 --- a/content/child/webcrypto/algorithm_dispatch.cc +++ b/content/child/webcrypto/algorithm_dispatch.cc @@ -104,14 +104,14 @@ Status Digest(const blink::WebCryptoAlgorithm& algorithm, Status GenerateKey(const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, GenerateKeyResult* result) { const AlgorithmImplementation* impl = NULL; Status status = GetAlgorithmImplementation(algorithm.id(), &impl); if (status.IsError()) return status; - return impl->GenerateKey(algorithm, extractable, usage_mask, result); + return impl->GenerateKey(algorithm, extractable, usages, result); } // Note that this function may be called from the target Blink thread. @@ -119,30 +119,27 @@ Status ImportKey(blink::WebCryptoKeyFormat format, const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) { const AlgorithmImplementation* impl = NULL; Status status = GetAlgorithmImplementation(algorithm.id(), &impl); if (status.IsError()) return status; - status = impl->VerifyKeyUsagesBeforeImportKey(format, usage_mask); + status = impl->VerifyKeyUsagesBeforeImportKey(format, usages); if (status.IsError()) return status; switch (format) { case blink::WebCryptoKeyFormatRaw: - return impl->ImportKeyRaw( - key_data, algorithm, extractable, usage_mask, key); + return impl->ImportKeyRaw(key_data, algorithm, extractable, usages, key); case blink::WebCryptoKeyFormatSpki: - return impl->ImportKeySpki( - key_data, algorithm, extractable, usage_mask, key); + return impl->ImportKeySpki(key_data, algorithm, extractable, usages, key); case blink::WebCryptoKeyFormatPkcs8: return impl->ImportKeyPkcs8( - key_data, algorithm, extractable, usage_mask, key); + key_data, algorithm, extractable, usages, key); case blink::WebCryptoKeyFormatJwk: - return impl->ImportKeyJwk( - key_data, algorithm, extractable, usage_mask, key); + return impl->ImportKeyJwk(key_data, algorithm, extractable, usages, key); default: return Status::ErrorUnsupported(); } @@ -213,7 +210,7 @@ Status UnwrapKey(blink::WebCryptoKeyFormat format, const blink::WebCryptoAlgorithm& wrapping_algorithm, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) { if (!KeyUsageAllows(wrapping_key, blink::WebCryptoKeyUsageUnwrapKey)) return Status::ErrorUnexpected(); @@ -226,7 +223,7 @@ Status UnwrapKey(blink::WebCryptoKeyFormat format, if (status.IsError()) return status; - status = import_impl->VerifyKeyUsagesBeforeImportKey(format, usage_mask); + status = import_impl->VerifyKeyUsagesBeforeImportKey(format, usages); if (status.IsError()) return status; @@ -242,7 +239,7 @@ Status UnwrapKey(blink::WebCryptoKeyFormat format, // key bytes however this should be OK. For more discussion see // http://crubg.com/372040 return ImportKey( - format, CryptoData(buffer), algorithm, extractable, usage_mask, key); + format, CryptoData(buffer), algorithm, extractable, usages, key); } scoped_ptr<blink::WebCryptoDigestor> CreateDigestor( diff --git a/content/child/webcrypto/algorithm_dispatch.h b/content/child/webcrypto/algorithm_dispatch.h index d13845b..3eefb46 100644 --- a/content/child/webcrypto/algorithm_dispatch.h +++ b/content/child/webcrypto/algorithm_dispatch.h @@ -45,14 +45,14 @@ CONTENT_EXPORT Status Digest(const blink::WebCryptoAlgorithm& algorithm, CONTENT_EXPORT Status GenerateKey(const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, GenerateKeyResult* result); CONTENT_EXPORT Status ImportKey(blink::WebCryptoKeyFormat format, const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key); CONTENT_EXPORT Status ExportKey(blink::WebCryptoKeyFormat format, @@ -84,7 +84,7 @@ CONTENT_EXPORT Status const blink::WebCryptoAlgorithm& wrapping_algorithm, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key); CONTENT_EXPORT scoped_ptr<blink::WebCryptoDigestor> CreateDigestor( diff --git a/content/child/webcrypto/algorithm_implementation.cc b/content/child/webcrypto/algorithm_implementation.cc index e54f292..b815a52 100644 --- a/content/child/webcrypto/algorithm_implementation.cc +++ b/content/child/webcrypto/algorithm_implementation.cc @@ -55,14 +55,14 @@ Status AlgorithmImplementation::Digest( Status AlgorithmImplementation::GenerateKey( const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, GenerateKeyResult* result) const { return Status::ErrorUnsupported(); } Status AlgorithmImplementation::VerifyKeyUsagesBeforeImportKey( blink::WebCryptoKeyFormat format, - blink::WebCryptoKeyUsageMask usage_mask) const { + blink::WebCryptoKeyUsageMask usages) const { return Status::ErrorUnsupportedImportKeyFormat(); } @@ -70,7 +70,7 @@ Status AlgorithmImplementation::ImportKeyRaw( const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const { return Status::ErrorUnsupportedImportKeyFormat(); } @@ -79,7 +79,7 @@ Status AlgorithmImplementation::ImportKeyPkcs8( const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const { return Status::ErrorUnsupportedImportKeyFormat(); } @@ -88,7 +88,7 @@ Status AlgorithmImplementation::ImportKeySpki( const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const { return Status::ErrorUnsupportedImportKeyFormat(); } @@ -97,7 +97,7 @@ Status AlgorithmImplementation::ImportKeyJwk( const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const { return Status::ErrorUnsupportedImportKeyFormat(); } diff --git a/content/child/webcrypto/algorithm_implementation.h b/content/child/webcrypto/algorithm_implementation.h index 1a240e2..e926ad0 100644 --- a/content/child/webcrypto/algorithm_implementation.h +++ b/content/child/webcrypto/algorithm_implementation.h @@ -74,11 +74,11 @@ class AlgorithmImplementation { // This method corresponds to Web Crypto's crypto.subtle.generateKey(). // - // Implementations MUST verify |usage_mask| and return an error if it is not + // Implementations MUST verify |usages| and return an error if it is not // appropriate. virtual Status GenerateKey(const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, GenerateKeyResult* result) const; // ----------------------------------------------- @@ -99,14 +99,14 @@ class AlgorithmImplementation { // ImportKeyJwk() must do the final usage check. virtual Status VerifyKeyUsagesBeforeImportKey( blink::WebCryptoKeyFormat format, - blink::WebCryptoKeyUsageMask usage_mask) const; + blink::WebCryptoKeyUsageMask usages) const; // This method corresponds to Web Crypto's // crypto.subtle.importKey(format='raw'). virtual Status ImportKeyRaw(const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const; // This method corresponds to Web Crypto's @@ -114,7 +114,7 @@ class AlgorithmImplementation { virtual Status ImportKeyPkcs8(const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const; // This method corresponds to Web Crypto's @@ -122,7 +122,7 @@ class AlgorithmImplementation { virtual Status ImportKeySpki(const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const; // This method corresponds to Web Crypto's @@ -130,7 +130,7 @@ class AlgorithmImplementation { virtual Status ImportKeyJwk(const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const; // ----------------------------------------------- diff --git a/content/child/webcrypto/jwk.cc b/content/child/webcrypto/jwk.cc index e1ac96f..eb6b392 100644 --- a/content/child/webcrypto/jwk.cc +++ b/content/child/webcrypto/jwk.cc @@ -46,7 +46,7 @@ // Web Crypto Key type <-- (deduced) // Web Crypto Key extractable <-- JWK ext + input extractable // Web Crypto Key algorithm <-- JWK alg + input algorithm -// Web Crypto Key keyUsage <-- JWK use, key_ops + input usage_mask +// Web Crypto Key keyUsage <-- JWK use, key_ops + input usages // Web Crypto Key keying material <-- kty-specific parameters // // Values for each JWK entry are case-sensitive and defined in @@ -183,7 +183,7 @@ // +-------+--------------------------------------------------------------+ // // Consistency and conflict resolution -// The 'algorithm', 'extractable', and 'usage_mask' input parameters +// The 'algorithm', 'extractable', and 'usages' input parameters // may be different than the corresponding values inside the JWK. The Web // Crypto spec says that if a JWK value is present but is inconsistent with // the input value, it is an error and the operation must fail. If no @@ -199,10 +199,10 @@ // false but the input parameter is true, it is an inconsistency. If both // are true or both are false, use that value. // -// usage_mask -// The input usage_mask must be a strict subset of the interpreted JWK use -// value, else it is judged inconsistent. In all cases the input usage_mask -// is used as the final usage_mask. +// usages +// The input usages must be a strict subset of the interpreted JWK use +// value, else it is judged inconsistent. In all cases the input usages +// is used as the final usages. // namespace content { @@ -224,10 +224,10 @@ class JwkWriter { public: JwkWriter(const std::string& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, const std::string& kty) { dict_.SetString("alg", algorithm); - dict_.Set("key_ops", CreateJwkKeyOpsFromWebCryptoUsages(usage_mask)); + dict_.Set("key_ops", CreateJwkKeyOpsFromWebCryptoUsages(usages)); dict_.SetBoolean("ext", extractable); dict_.SetString("kty", kty); } @@ -378,8 +378,8 @@ Status VerifyExt(base::DictionaryValue* dict, bool expected_extractable) { } Status VerifyUsages(base::DictionaryValue* dict, - blink::WebCryptoKeyUsageMask expected_usage_mask) { - // JWK "key_ops" (optional) --> usage_mask parameter + blink::WebCryptoKeyUsageMask expected_usages) { + // JWK "key_ops" (optional) --> usages parameter base::ListValue* jwk_key_ops_value = NULL; bool has_jwk_key_ops; Status status = @@ -392,12 +392,12 @@ Status VerifyUsages(base::DictionaryValue* dict, GetWebCryptoUsagesFromJwkKeyOps(jwk_key_ops_value, &jwk_key_ops_mask); if (status.IsError()) return status; - // The input usage_mask must be a subset of jwk_key_ops_mask. - if (!ContainsKeyUsages(jwk_key_ops_mask, expected_usage_mask)) + // The input usages must be a subset of jwk_key_ops_mask. + if (!ContainsKeyUsages(jwk_key_ops_mask, expected_usages)) return Status::ErrorJwkKeyopsInconsistent(); } - // JWK "use" (optional) --> usage_mask parameter + // JWK "use" (optional) --> usages parameter std::string jwk_use_value; bool has_jwk_use; status = GetOptionalJwkString(dict, "use", &jwk_use_value, &has_jwk_use); @@ -411,8 +411,8 @@ Status VerifyUsages(base::DictionaryValue* dict, jwk_use_mask = kJwkSigUsage; else return Status::ErrorJwkUnrecognizedUse(); - // The input usage_mask must be a subset of jwk_use_mask. - if (!ContainsKeyUsages(jwk_use_mask, expected_usage_mask)) + // The input usages must be a subset of jwk_use_mask. + if (!ContainsKeyUsages(jwk_use_mask, expected_usages)) return Status::ErrorJwkUseInconsistent(); } @@ -442,7 +442,7 @@ Status VerifyAlg(base::DictionaryValue* dict, Status ParseJwkCommon(const CryptoData& bytes, bool expected_extractable, - blink::WebCryptoKeyUsageMask expected_usage_mask, + blink::WebCryptoKeyUsageMask expected_usages, std::string* kty, scoped_ptr<base::DictionaryValue>* dict) { // Parse the incoming JWK JSON. @@ -469,25 +469,24 @@ Status ParseJwkCommon(const CryptoData& bytes, if (status.IsError()) return status; - status = VerifyUsages(dict_value, expected_usage_mask); + status = VerifyUsages(dict_value, expected_usages); if (status.IsError()) return status; return Status::Success(); } -Status ReadSecretKeyNoExpectedAlg( - const CryptoData& key_data, - bool expected_extractable, - blink::WebCryptoKeyUsageMask expected_usage_mask, - std::vector<uint8_t>* raw_key_data, - scoped_ptr<base::DictionaryValue>* dict) { +Status ReadSecretKeyNoExpectedAlg(const CryptoData& key_data, + bool expected_extractable, + blink::WebCryptoKeyUsageMask expected_usages, + std::vector<uint8_t>* raw_key_data, + scoped_ptr<base::DictionaryValue>* dict) { if (!key_data.byte_length()) return Status::ErrorImportEmptyKeyData(); std::string kty; Status status = ParseJwkCommon( - key_data, expected_extractable, expected_usage_mask, &kty, dict); + key_data, expected_extractable, expected_usages, &kty, dict); if (status.IsError()) return status; @@ -508,9 +507,9 @@ Status ReadSecretKeyNoExpectedAlg( void WriteSecretKeyJwk(const CryptoData& raw_key_data, const std::string& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, std::vector<uint8_t>* jwk_key_data) { - JwkWriter writer(algorithm, extractable, usage_mask, "oct"); + JwkWriter writer(algorithm, extractable, usages, "oct"); writer.SetBase64Encoded("k", raw_key_data); writer.ToBytes(jwk_key_data); } @@ -518,11 +517,11 @@ void WriteSecretKeyJwk(const CryptoData& raw_key_data, Status ReadSecretKeyJwk(const CryptoData& key_data, const std::string& expected_algorithm, bool expected_extractable, - blink::WebCryptoKeyUsageMask expected_usage_mask, + blink::WebCryptoKeyUsageMask expected_usages, std::vector<uint8_t>* raw_key_data) { scoped_ptr<base::DictionaryValue> dict; Status status = ReadSecretKeyNoExpectedAlg( - key_data, expected_extractable, expected_usage_mask, raw_key_data, &dict); + key_data, expected_extractable, expected_usages, raw_key_data, &dict); if (status.IsError()) return status; return VerifyAlg(dict.get(), expected_algorithm); @@ -542,11 +541,11 @@ std::string MakeJwkAesAlgorithmName(const std::string& suffix, Status ReadAesSecretKeyJwk(const CryptoData& key_data, const std::string& algorithm_name_suffix, bool expected_extractable, - blink::WebCryptoKeyUsageMask expected_usage_mask, + blink::WebCryptoKeyUsageMask expected_usages, std::vector<uint8_t>* raw_key_data) { scoped_ptr<base::DictionaryValue> dict; Status status = ReadSecretKeyNoExpectedAlg( - key_data, expected_extractable, expected_usage_mask, raw_key_data, &dict); + key_data, expected_extractable, expected_usages, raw_key_data, &dict); if (status.IsError()) return status; @@ -579,9 +578,9 @@ void WriteRsaPublicKeyJwk(const CryptoData& n, const CryptoData& e, const std::string& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, std::vector<uint8_t>* jwk_key_data) { - JwkWriter writer(algorithm, extractable, usage_mask, "RSA"); + JwkWriter writer(algorithm, extractable, usages, "RSA"); writer.SetBase64Encoded("n", n); writer.SetBase64Encoded("e", e); writer.ToBytes(jwk_key_data); @@ -598,9 +597,9 @@ void WriteRsaPrivateKeyJwk(const CryptoData& n, const CryptoData& qi, const std::string& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, std::vector<uint8_t>* jwk_key_data) { - JwkWriter writer(algorithm, extractable, usage_mask, "RSA"); + JwkWriter writer(algorithm, extractable, usages, "RSA"); writer.SetBase64Encoded("n", n); writer.SetBase64Encoded("e", e); @@ -624,7 +623,7 @@ JwkRsaInfo::~JwkRsaInfo() { Status ReadRsaKeyJwk(const CryptoData& key_data, const std::string& expected_algorithm, bool expected_extractable, - blink::WebCryptoKeyUsageMask expected_usage_mask, + blink::WebCryptoKeyUsageMask expected_usages, JwkRsaInfo* result) { if (!key_data.byte_length()) return Status::ErrorImportEmptyKeyData(); @@ -632,7 +631,7 @@ Status ReadRsaKeyJwk(const CryptoData& key_data, scoped_ptr<base::DictionaryValue> dict; std::string kty; Status status = ParseJwkCommon( - key_data, expected_extractable, expected_usage_mask, &kty, &dict); + key_data, expected_extractable, expected_usages, &kty, &dict); if (status.IsError()) return status; diff --git a/content/child/webcrypto/jwk.h b/content/child/webcrypto/jwk.h index 9c7a769..a587209 100644 --- a/content/child/webcrypto/jwk.h +++ b/content/child/webcrypto/jwk.h @@ -26,11 +26,11 @@ class Status; // * raw_key_data: The actual key data // * algorithm: The JWK algorithm name (i.e. "alg") // * extractable: The JWK extractability (i.e. "ext") -// * usage_mask: The JWK usages (i.e. "key_ops") +// * usages: The JWK usages (i.e. "key_ops") void WriteSecretKeyJwk(const CryptoData& raw_key_data, const std::string& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, std::vector<uint8_t>* jwk_key_data); // Parses a UTF-8 encoded JWK (key_data), and extracts the key material to @@ -39,11 +39,11 @@ void WriteSecretKeyJwk(const CryptoData& raw_key_data, // * expected_algorithm must match the JWK's "alg", if present. // * expected_extractable must be consistent with the JWK's "ext", if // present. -// * expected_usage_mask must be a subset of the JWK's "key_ops" if present. +// * expected_usages must be a subset of the JWK's "key_ops" if present. Status ReadSecretKeyJwk(const CryptoData& key_data, const std::string& expected_algorithm, bool expected_extractable, - blink::WebCryptoKeyUsageMask expected_usage_mask, + blink::WebCryptoKeyUsageMask expected_usages, std::vector<uint8_t>* raw_key_data); // Creates an AES algorithm name for the given key size (in bytes). For @@ -61,7 +61,7 @@ std::string MakeJwkAesAlgorithmName(const std::string& suffix, Status ReadAesSecretKeyJwk(const CryptoData& key_data, const std::string& algorithm_name_suffix, bool expected_extractable, - blink::WebCryptoKeyUsageMask expected_usage_mask, + blink::WebCryptoKeyUsageMask expected_usages, std::vector<uint8_t>* raw_key_data); // Writes a JWK-formated RSA public key and saves the result to @@ -70,7 +70,7 @@ void WriteRsaPublicKeyJwk(const CryptoData& n, const CryptoData& e, const std::string& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, std::vector<uint8_t>* jwk_key_data); // Writes a JWK-formated RSA private key and saves the result to @@ -85,7 +85,7 @@ void WriteRsaPrivateKeyJwk(const CryptoData& n, const CryptoData& qi, const std::string& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, std::vector<uint8_t>* jwk_key_data); // Describes the RSA components for a parsed key. The names of the properties @@ -113,11 +113,11 @@ struct JwkRsaInfo { // * expected_algorithm must match the JWK's "alg", if present. // * expected_extractable must be consistent with the JWK's "ext", if // present. -// * expected_usage_mask must be a subset of the JWK's "key_ops" if present. +// * expected_usages must be a subset of the JWK's "key_ops" if present. Status ReadRsaKeyJwk(const CryptoData& key_data, const std::string& expected_algorithm, bool expected_extractable, - blink::WebCryptoKeyUsageMask expected_usage_mask, + blink::WebCryptoKeyUsageMask expected_usages, JwkRsaInfo* result); const char* GetJwkHmacAlgorithmName(blink::WebCryptoAlgorithmId hash); diff --git a/content/child/webcrypto/nss/aes_gcm_nss.cc b/content/child/webcrypto/nss/aes_gcm_nss.cc index 586e307..0ff3e4a 100644 --- a/content/child/webcrypto/nss/aes_gcm_nss.cc +++ b/content/child/webcrypto/nss/aes_gcm_nss.cc @@ -145,25 +145,24 @@ class AesGcmImplementation : public AesAlgorithm { virtual Status VerifyKeyUsagesBeforeImportKey( blink::WebCryptoKeyFormat format, - blink::WebCryptoKeyUsageMask usage_mask) const override { + blink::WebCryptoKeyUsageMask usages) const override { // Prevent importing AES-GCM keys if it is unavailable. Status status = NssSupportsAesGcm(); if (status.IsError()) return status; - return AesAlgorithm::VerifyKeyUsagesBeforeImportKey(format, usage_mask); + return AesAlgorithm::VerifyKeyUsagesBeforeImportKey(format, usages); } virtual Status GenerateKey(const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, GenerateKeyResult* result) const override { // Prevent generating AES-GCM keys if it is unavailable. Status status = NssSupportsAesGcm(); if (status.IsError()) return status; - return AesAlgorithm::GenerateKey( - algorithm, extractable, usage_mask, result); + return AesAlgorithm::GenerateKey(algorithm, extractable, usages, result); } virtual Status Encrypt(const blink::WebCryptoAlgorithm& algorithm, diff --git a/content/child/webcrypto/nss/aes_key_nss.cc b/content/child/webcrypto/nss/aes_key_nss.cc index dda4d6b..2bd0c57 100644 --- a/content/child/webcrypto/nss/aes_key_nss.cc +++ b/content/child/webcrypto/nss/aes_key_nss.cc @@ -40,9 +40,9 @@ AesAlgorithm::AesAlgorithm(CK_MECHANISM_TYPE import_mechanism, Status AesAlgorithm::GenerateKey(const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, GenerateKeyResult* result) const { - Status status = CheckKeyCreationUsages(all_key_usages_, usage_mask); + Status status = CheckKeyCreationUsages(all_key_usages_, usages); if (status.IsError()) return status; @@ -54,7 +54,7 @@ Status AesAlgorithm::GenerateKey(const blink::WebCryptoAlgorithm& algorithm, return GenerateSecretKeyNss( blink::WebCryptoKeyAlgorithm::createAes(algorithm.id(), keylen_bits), extractable, - usage_mask, + usages, keylen_bits / 8, CKM_AES_KEY_GEN, result); @@ -62,11 +62,11 @@ Status AesAlgorithm::GenerateKey(const blink::WebCryptoAlgorithm& algorithm, Status AesAlgorithm::VerifyKeyUsagesBeforeImportKey( blink::WebCryptoKeyFormat format, - blink::WebCryptoKeyUsageMask usage_mask) const { + blink::WebCryptoKeyUsageMask usages) const { switch (format) { case blink::WebCryptoKeyFormatRaw: case blink::WebCryptoKeyFormatJwk: - return CheckKeyCreationUsages(all_key_usages_, usage_mask); + return CheckKeyCreationUsages(all_key_usages_, usages); default: return Status::ErrorUnsupportedImportKeyFormat(); } @@ -74,7 +74,7 @@ Status AesAlgorithm::VerifyKeyUsagesBeforeImportKey( Status AesAlgorithm::ImportKeyRaw(const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const { const unsigned int keylen_bytes = key_data.byte_length(); Status status = VerifyAesKeyLengthForImport(keylen_bytes); @@ -88,7 +88,7 @@ Status AesAlgorithm::ImportKeyRaw(const CryptoData& key_data, key_data, blink::WebCryptoKeyAlgorithm::createAes(algorithm.id(), keylen_bits), extractable, - usage_mask, + usages, import_mechanism_, import_flags_, key); @@ -97,16 +97,16 @@ Status AesAlgorithm::ImportKeyRaw(const CryptoData& key_data, Status AesAlgorithm::ImportKeyJwk(const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const { std::vector<uint8_t> raw_data; Status status = ReadAesSecretKeyJwk( - key_data, jwk_suffix_, extractable, usage_mask, &raw_data); + key_data, jwk_suffix_, extractable, usages, &raw_data); if (status.IsError()) return status; return ImportKeyRaw( - CryptoData(raw_data), algorithm, extractable, usage_mask, key); + CryptoData(raw_data), algorithm, extractable, usages, key); } Status AesAlgorithm::ExportKeyRaw(const blink::WebCryptoKey& key, diff --git a/content/child/webcrypto/nss/aes_key_nss.h b/content/child/webcrypto/nss/aes_key_nss.h index 6d80dd3..7f4c1b1 100644 --- a/content/child/webcrypto/nss/aes_key_nss.h +++ b/content/child/webcrypto/nss/aes_key_nss.h @@ -38,23 +38,23 @@ class AesAlgorithm : public AlgorithmImplementation { virtual Status GenerateKey(const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, GenerateKeyResult* result) const override; virtual Status VerifyKeyUsagesBeforeImportKey( blink::WebCryptoKeyFormat format, - blink::WebCryptoKeyUsageMask usage_mask) const override; + blink::WebCryptoKeyUsageMask usages) const override; virtual Status ImportKeyRaw(const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const override; virtual Status ImportKeyJwk(const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const override; virtual Status ExportKeyRaw(const blink::WebCryptoKey& key, diff --git a/content/child/webcrypto/nss/hmac_nss.cc b/content/child/webcrypto/nss/hmac_nss.cc index 74cdaef..82855f2 100644 --- a/content/child/webcrypto/nss/hmac_nss.cc +++ b/content/child/webcrypto/nss/hmac_nss.cc @@ -57,9 +57,9 @@ class HmacImplementation : public AlgorithmImplementation { virtual Status GenerateKey(const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, GenerateKeyResult* result) const override { - Status status = CheckKeyCreationUsages(kAllKeyUsages, usage_mask); + Status status = CheckKeyCreationUsages(kAllKeyUsages, usages); if (status.IsError()) return status; @@ -79,7 +79,7 @@ class HmacImplementation : public AlgorithmImplementation { return GenerateSecretKeyNss( blink::WebCryptoKeyAlgorithm::createHmac(hash.id(), keylen_bits), extractable, - usage_mask, + usages, keylen_bits / 8, mechanism, result); @@ -87,11 +87,11 @@ class HmacImplementation : public AlgorithmImplementation { virtual Status VerifyKeyUsagesBeforeImportKey( blink::WebCryptoKeyFormat format, - blink::WebCryptoKeyUsageMask usage_mask) const override { + blink::WebCryptoKeyUsageMask usages) const override { switch (format) { case blink::WebCryptoKeyFormatRaw: case blink::WebCryptoKeyFormatJwk: - return CheckKeyCreationUsages(kAllKeyUsages, usage_mask); + return CheckKeyCreationUsages(kAllKeyUsages, usages); default: return Status::ErrorUnsupportedImportKeyFormat(); } @@ -100,7 +100,7 @@ class HmacImplementation : public AlgorithmImplementation { virtual Status ImportKeyRaw(const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const override { const blink::WebCryptoAlgorithm& hash = algorithm.hmacImportParams()->hash(); @@ -119,7 +119,7 @@ class HmacImplementation : public AlgorithmImplementation { blink::WebCryptoKeyAlgorithm::createHmac( hash.id(), keylen_bits.ValueOrDie()), extractable, - usage_mask, + usages, mechanism, CKF_SIGN | CKF_VERIFY, key); @@ -128,7 +128,7 @@ class HmacImplementation : public AlgorithmImplementation { virtual Status ImportKeyJwk(const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const override { const char* algorithm_name = GetJwkHmacAlgorithmName(algorithm.hmacImportParams()->hash().id()); @@ -137,12 +137,12 @@ class HmacImplementation : public AlgorithmImplementation { std::vector<uint8_t> raw_data; Status status = ReadSecretKeyJwk( - key_data, algorithm_name, extractable, usage_mask, &raw_data); + key_data, algorithm_name, extractable, usages, &raw_data); if (status.IsError()) return status; return ImportKeyRaw( - CryptoData(raw_data), algorithm, extractable, usage_mask, key); + CryptoData(raw_data), algorithm, extractable, usages, key); } virtual Status ExportKeyRaw(const blink::WebCryptoKey& key, diff --git a/content/child/webcrypto/nss/rsa_key_nss.cc b/content/child/webcrypto/nss/rsa_key_nss.cc index 1ad4cb3..370bdb2 100644 --- a/content/child/webcrypto/nss/rsa_key_nss.cc +++ b/content/child/webcrypto/nss/rsa_key_nss.cc @@ -307,7 +307,7 @@ Status ExportKeyPkcs8Nss(SECKEYPrivateKey* key, std::vector<uint8_t>* buffer) { Status ImportRsaPrivateKey(const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, const JwkRsaInfo& params, blink::WebCryptoKey* key) { Status status = NssSupportsRsaPrivateKeyImport(); @@ -409,7 +409,7 @@ Status ImportRsaPrivateKey(const blink::WebCryptoAlgorithm& algorithm, blink::WebCryptoKeyTypePrivate, extractable, key_algorithm, - usage_mask); + usages); return Status::Success(); } @@ -425,7 +425,7 @@ Status ExportKeySpkiNss(SECKEYPublicKey* key, std::vector<uint8_t>* buffer) { Status ImportRsaPublicKey(const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, const CryptoData& modulus_data, const CryptoData& exponent_data, blink::WebCryptoKey* key) { @@ -500,7 +500,7 @@ Status ImportRsaPublicKey(const blink::WebCryptoAlgorithm& algorithm, blink::WebCryptoKeyTypePublic, extractable, key_algorithm, - usage_mask); + usages); return Status::Success(); } @@ -509,17 +509,17 @@ Status ImportRsaPublicKey(const blink::WebCryptoAlgorithm& algorithm, Status RsaHashedAlgorithm::GenerateKey( const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask combined_usage_mask, + blink::WebCryptoKeyUsageMask combined_usages, GenerateKeyResult* result) const { Status status = CheckKeyCreationUsages( - all_public_key_usages_ | all_private_key_usages_, combined_usage_mask); + all_public_key_usages_ | all_private_key_usages_, combined_usages); if (status.IsError()) return status; - const blink::WebCryptoKeyUsageMask public_usage_mask = - combined_usage_mask & all_public_key_usages_; - const blink::WebCryptoKeyUsageMask private_usage_mask = - combined_usage_mask & all_private_key_usages_; + const blink::WebCryptoKeyUsageMask public_usages = + combined_usages & all_public_key_usages_; + const blink::WebCryptoKeyUsageMask private_usages = + combined_usages & all_private_key_usages_; unsigned int public_exponent = 0; unsigned int modulus_length_bits = 0; @@ -590,14 +590,14 @@ Status RsaHashedAlgorithm::GenerateKey( blink::WebCryptoKeyTypePublic, true, key_algorithm, - public_usage_mask); + public_usages); blink::WebCryptoKey private_key = blink::WebCryptoKey::create(private_key_handle.release(), blink::WebCryptoKeyTypePrivate, extractable, key_algorithm, - private_usage_mask); + private_usages); result->AssignKeyPair(public_key, private_key); return Status::Success(); @@ -605,15 +605,15 @@ Status RsaHashedAlgorithm::GenerateKey( Status RsaHashedAlgorithm::VerifyKeyUsagesBeforeImportKey( blink::WebCryptoKeyFormat format, - blink::WebCryptoKeyUsageMask usage_mask) const { + blink::WebCryptoKeyUsageMask usages) const { switch (format) { case blink::WebCryptoKeyFormatSpki: - return CheckKeyCreationUsages(all_public_key_usages_, usage_mask); + return CheckKeyCreationUsages(all_public_key_usages_, usages); case blink::WebCryptoKeyFormatPkcs8: - return CheckKeyCreationUsages(all_private_key_usages_, usage_mask); + return CheckKeyCreationUsages(all_private_key_usages_, usages); case blink::WebCryptoKeyFormatJwk: return CheckKeyCreationUsages( - all_public_key_usages_ | all_private_key_usages_, usage_mask); + all_public_key_usages_ | all_private_key_usages_, usages); default: return Status::ErrorUnsupportedImportKeyFormat(); } @@ -623,7 +623,7 @@ Status RsaHashedAlgorithm::ImportKeyPkcs8( const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const { Status status = NssSupportsRsaPrivateKeyImport(); if (status.IsError()) @@ -678,7 +678,7 @@ Status RsaHashedAlgorithm::ImportKeyPkcs8( blink::WebCryptoKeyTypePrivate, extractable, key_algorithm, - usage_mask); + usages); return Status::Success(); } @@ -687,7 +687,7 @@ Status RsaHashedAlgorithm::ImportKeySpki( const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const { if (!key_data.byte_length()) return Status::ErrorImportEmptyKeyData(); @@ -731,7 +731,7 @@ Status RsaHashedAlgorithm::ImportKeySpki( blink::WebCryptoKeyTypePublic, extractable, key_algorithm, - usage_mask); + usages); return Status::Success(); } @@ -756,7 +756,7 @@ Status RsaHashedAlgorithm::ImportKeyJwk( const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const { const char* jwk_algorithm = GetJwkAlgorithm(algorithm.rsaHashedImportParams()->hash().id()); @@ -766,22 +766,22 @@ Status RsaHashedAlgorithm::ImportKeyJwk( JwkRsaInfo jwk; Status status = - ReadRsaKeyJwk(key_data, jwk_algorithm, extractable, usage_mask, &jwk); + ReadRsaKeyJwk(key_data, jwk_algorithm, extractable, usages, &jwk); if (status.IsError()) return status; // Once the key type is known, verify the usages. status = CheckKeyCreationUsages( jwk.is_private_key ? all_private_key_usages_ : all_public_key_usages_, - usage_mask); + usages); if (status.IsError()) return Status::ErrorCreateKeyBadUsages(); return jwk.is_private_key - ? ImportRsaPrivateKey(algorithm, extractable, usage_mask, jwk, key) + ? ImportRsaPrivateKey(algorithm, extractable, usages, jwk, key) : ImportRsaPublicKey(algorithm, extractable, - usage_mask, + usages, CryptoData(jwk.n), CryptoData(jwk.e), key); diff --git a/content/child/webcrypto/nss/rsa_key_nss.h b/content/child/webcrypto/nss/rsa_key_nss.h index 8004659..f11d919 100644 --- a/content/child/webcrypto/nss/rsa_key_nss.h +++ b/content/child/webcrypto/nss/rsa_key_nss.h @@ -45,23 +45,23 @@ class RsaHashedAlgorithm : public AlgorithmImplementation { virtual Status GenerateKey(const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, GenerateKeyResult* result) const override; virtual Status VerifyKeyUsagesBeforeImportKey( blink::WebCryptoKeyFormat format, - blink::WebCryptoKeyUsageMask usage_mask) const override; + blink::WebCryptoKeyUsageMask usages) const override; virtual Status ImportKeyPkcs8(const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const override; virtual Status ImportKeySpki(const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const override; virtual Status ExportKeyPkcs8(const blink::WebCryptoKey& key, @@ -73,7 +73,7 @@ class RsaHashedAlgorithm : public AlgorithmImplementation { virtual Status ImportKeyJwk(const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const override; virtual Status ExportKeyJwk(const blink::WebCryptoKey& key, diff --git a/content/child/webcrypto/nss/rsa_oaep_nss.cc b/content/child/webcrypto/nss/rsa_oaep_nss.cc index d129eac..55501b3 100644 --- a/content/child/webcrypto/nss/rsa_oaep_nss.cc +++ b/content/child/webcrypto/nss/rsa_oaep_nss.cc @@ -170,23 +170,22 @@ class RsaOaepImplementation : public RsaHashedAlgorithm { virtual Status GenerateKey(const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, GenerateKeyResult* result) const override { Status status = NssSupportsRsaOaep(); if (status.IsError()) return status; return RsaHashedAlgorithm::GenerateKey( - algorithm, extractable, usage_mask, result); + algorithm, extractable, usages, result); } virtual Status VerifyKeyUsagesBeforeImportKey( blink::WebCryptoKeyFormat format, - blink::WebCryptoKeyUsageMask usage_mask) const override { + blink::WebCryptoKeyUsageMask usages) const override { Status status = NssSupportsRsaOaep(); if (status.IsError()) return status; - return RsaHashedAlgorithm::VerifyKeyUsagesBeforeImportKey(format, - usage_mask); + return RsaHashedAlgorithm::VerifyKeyUsagesBeforeImportKey(format, usages); } virtual const char* GetJwkAlgorithm( diff --git a/content/child/webcrypto/nss/sym_key_nss.cc b/content/child/webcrypto/nss/sym_key_nss.cc index b779e92..5066d5d 100644 --- a/content/child/webcrypto/nss/sym_key_nss.cc +++ b/content/child/webcrypto/nss/sym_key_nss.cc @@ -20,7 +20,7 @@ namespace webcrypto { Status GenerateSecretKeyNss(const blink::WebCryptoKeyAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, unsigned keylen_bytes, CK_MECHANISM_TYPE mechanism, GenerateKeyResult* result) { @@ -51,7 +51,7 @@ Status GenerateSecretKeyNss(const blink::WebCryptoKeyAlgorithm& algorithm, blink::WebCryptoKeyTypeSecret, extractable, algorithm, - usage_mask)); + usages)); return Status::Success(); } @@ -59,7 +59,7 @@ Status GenerateSecretKeyNss(const blink::WebCryptoKeyAlgorithm& algorithm, Status ImportKeyRawNss(const CryptoData& key_data, const blink::WebCryptoKeyAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, CK_MECHANISM_TYPE mechanism, CK_FLAGS flags, blink::WebCryptoKey* key) { @@ -85,7 +85,7 @@ Status ImportKeyRawNss(const CryptoData& key_data, blink::WebCryptoKeyTypeSecret, extractable, algorithm, - usage_mask); + usages); return Status::Success(); } diff --git a/content/child/webcrypto/nss/sym_key_nss.h b/content/child/webcrypto/nss/sym_key_nss.h index 5d05508..7f1e067 100644 --- a/content/child/webcrypto/nss/sym_key_nss.h +++ b/content/child/webcrypto/nss/sym_key_nss.h @@ -19,7 +19,7 @@ class Status; Status GenerateSecretKeyNss(const blink::WebCryptoKeyAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, unsigned keylen_bytes, CK_MECHANISM_TYPE mechanism, GenerateKeyResult* result); @@ -27,7 +27,7 @@ Status GenerateSecretKeyNss(const blink::WebCryptoKeyAlgorithm& algorithm, Status ImportKeyRawNss(const CryptoData& key_data, const blink::WebCryptoKeyAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, CK_MECHANISM_TYPE mechanism, CK_FLAGS flags, blink::WebCryptoKey* key); diff --git a/content/child/webcrypto/openssl/aes_key_openssl.cc b/content/child/webcrypto/openssl/aes_key_openssl.cc index 738b87b..14fa24e 100644 --- a/content/child/webcrypto/openssl/aes_key_openssl.cc +++ b/content/child/webcrypto/openssl/aes_key_openssl.cc @@ -32,9 +32,9 @@ AesAlgorithm::AesAlgorithm(const std::string& jwk_suffix) Status AesAlgorithm::GenerateKey(const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, GenerateKeyResult* result) const { - Status status = CheckKeyCreationUsages(all_key_usages_, usage_mask); + Status status = CheckKeyCreationUsages(all_key_usages_, usages); if (status.IsError()) return status; @@ -46,18 +46,18 @@ Status AesAlgorithm::GenerateKey(const blink::WebCryptoAlgorithm& algorithm, return GenerateSecretKeyOpenSsl( blink::WebCryptoKeyAlgorithm::createAes(algorithm.id(), keylen_bits), extractable, - usage_mask, + usages, keylen_bits / 8, result); } Status AesAlgorithm::VerifyKeyUsagesBeforeImportKey( blink::WebCryptoKeyFormat format, - blink::WebCryptoKeyUsageMask usage_mask) const { + blink::WebCryptoKeyUsageMask usages) const { switch (format) { case blink::WebCryptoKeyFormatRaw: case blink::WebCryptoKeyFormatJwk: - return CheckKeyCreationUsages(all_key_usages_, usage_mask); + return CheckKeyCreationUsages(all_key_usages_, usages); default: return Status::ErrorUnsupportedImportKeyFormat(); } @@ -66,7 +66,7 @@ Status AesAlgorithm::VerifyKeyUsagesBeforeImportKey( Status AesAlgorithm::ImportKeyRaw(const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const { const unsigned int keylen_bytes = key_data.byte_length(); Status status = VerifyAesKeyLengthForImport(keylen_bytes); @@ -80,23 +80,23 @@ Status AesAlgorithm::ImportKeyRaw(const CryptoData& key_data, key_data, blink::WebCryptoKeyAlgorithm::createAes(algorithm.id(), keylen_bits), extractable, - usage_mask, + usages, key); } Status AesAlgorithm::ImportKeyJwk(const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const { std::vector<uint8_t> raw_data; Status status = ReadAesSecretKeyJwk( - key_data, jwk_suffix_, extractable, usage_mask, &raw_data); + key_data, jwk_suffix_, extractable, usages, &raw_data); if (status.IsError()) return status; return ImportKeyRaw( - CryptoData(raw_data), algorithm, extractable, usage_mask, key); + CryptoData(raw_data), algorithm, extractable, usages, key); } Status AesAlgorithm::ExportKeyRaw(const blink::WebCryptoKey& key, diff --git a/content/child/webcrypto/openssl/aes_key_openssl.h b/content/child/webcrypto/openssl/aes_key_openssl.h index a77673a912..206a1e2 100644 --- a/content/child/webcrypto/openssl/aes_key_openssl.h +++ b/content/child/webcrypto/openssl/aes_key_openssl.h @@ -30,23 +30,23 @@ class AesAlgorithm : public AlgorithmImplementation { Status GenerateKey(const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, GenerateKeyResult* result) const override; Status VerifyKeyUsagesBeforeImportKey( blink::WebCryptoKeyFormat format, - blink::WebCryptoKeyUsageMask usage_mask) const override; + blink::WebCryptoKeyUsageMask usages) const override; Status ImportKeyRaw(const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const override; Status ImportKeyJwk(const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const override; Status ExportKeyRaw(const blink::WebCryptoKey& key, diff --git a/content/child/webcrypto/openssl/hmac_openssl.cc b/content/child/webcrypto/openssl/hmac_openssl.cc index 946a2bc..46cca84 100644 --- a/content/child/webcrypto/openssl/hmac_openssl.cc +++ b/content/child/webcrypto/openssl/hmac_openssl.cc @@ -72,9 +72,9 @@ class HmacImplementation : public AlgorithmImplementation { Status GenerateKey(const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, GenerateKeyResult* result) const override { - Status status = CheckKeyCreationUsages(kAllKeyUsages, usage_mask); + Status status = CheckKeyCreationUsages(kAllKeyUsages, usages); if (status.IsError()) return status; @@ -89,18 +89,18 @@ class HmacImplementation : public AlgorithmImplementation { return GenerateSecretKeyOpenSsl(blink::WebCryptoKeyAlgorithm::createHmac( params->hash().id(), keylen_bits), extractable, - usage_mask, + usages, keylen_bits / 8, result); } Status VerifyKeyUsagesBeforeImportKey( blink::WebCryptoKeyFormat format, - blink::WebCryptoKeyUsageMask usage_mask) const override { + blink::WebCryptoKeyUsageMask usages) const override { switch (format) { case blink::WebCryptoKeyFormatRaw: case blink::WebCryptoKeyFormatJwk: - return CheckKeyCreationUsages(kAllKeyUsages, usage_mask); + return CheckKeyCreationUsages(kAllKeyUsages, usages); default: return Status::ErrorUnsupportedImportKeyFormat(); } @@ -109,7 +109,7 @@ class HmacImplementation : public AlgorithmImplementation { Status ImportKeyRaw(const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const override { const blink::WebCryptoAlgorithm& hash = algorithm.hmacImportParams()->hash(); @@ -124,14 +124,14 @@ class HmacImplementation : public AlgorithmImplementation { blink::WebCryptoKeyAlgorithm::createHmac( hash.id(), keylen_bits.ValueOrDie()), extractable, - usage_mask, + usages, key); } Status ImportKeyJwk(const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const override { const char* algorithm_name = GetJwkHmacAlgorithmName(algorithm.hmacImportParams()->hash().id()); @@ -140,12 +140,12 @@ class HmacImplementation : public AlgorithmImplementation { std::vector<uint8_t> raw_data; Status status = ReadSecretKeyJwk( - key_data, algorithm_name, extractable, usage_mask, &raw_data); + key_data, algorithm_name, extractable, usages, &raw_data); if (status.IsError()) return status; return ImportKeyRaw( - CryptoData(raw_data), algorithm, extractable, usage_mask, key); + CryptoData(raw_data), algorithm, extractable, usages, key); } Status ExportKeyRaw(const blink::WebCryptoKey& key, diff --git a/content/child/webcrypto/openssl/rsa_key_openssl.cc b/content/child/webcrypto/openssl/rsa_key_openssl.cc index 78a9c58..4d01c8e 100644 --- a/content/child/webcrypto/openssl/rsa_key_openssl.cc +++ b/content/child/webcrypto/openssl/rsa_key_openssl.cc @@ -95,7 +95,7 @@ Status CreateWebCryptoPrivateKey( const blink::WebCryptoAlgorithmId rsa_algorithm_id, const blink::WebCryptoAlgorithm& hash, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) { blink::WebCryptoKeyAlgorithm key_algorithm; Status status = CreateRsaHashedKeyAlgorithm( @@ -115,7 +115,7 @@ Status CreateWebCryptoPrivateKey( blink::WebCryptoKeyTypePrivate, extractable, key_algorithm, - usage_mask); + usages); return Status::Success(); } @@ -124,7 +124,7 @@ Status CreateWebCryptoPublicKey( const blink::WebCryptoAlgorithmId rsa_algorithm_id, const blink::WebCryptoAlgorithm& hash, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) { blink::WebCryptoKeyAlgorithm key_algorithm; Status status = CreateRsaHashedKeyAlgorithm( @@ -144,7 +144,7 @@ Status CreateWebCryptoPublicKey( blink::WebCryptoKeyTypePublic, extractable, key_algorithm, - usage_mask); + usages); return Status::Success(); } @@ -162,7 +162,7 @@ BIGNUM* CreateBIGNUM(const std::string& n) { Status ImportRsaPrivateKey(const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, const JwkRsaInfo& params, blink::WebCryptoKey* key) { crypto::ScopedRSA rsa(RSA_new()); @@ -195,13 +195,13 @@ Status ImportRsaPrivateKey(const blink::WebCryptoAlgorithm& algorithm, algorithm.id(), algorithm.rsaHashedImportParams()->hash(), extractable, - usage_mask, + usages, key); } Status ImportRsaPublicKey(const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, const CryptoData& n, const CryptoData& e, blink::WebCryptoKey* key) { @@ -222,7 +222,7 @@ Status ImportRsaPublicKey(const blink::WebCryptoAlgorithm& algorithm, algorithm.id(), algorithm.rsaHashedImportParams()->hash(), extractable, - usage_mask, + usages, key); } @@ -231,17 +231,17 @@ Status ImportRsaPublicKey(const blink::WebCryptoAlgorithm& algorithm, Status RsaHashedAlgorithm::GenerateKey( const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask combined_usage_mask, + blink::WebCryptoKeyUsageMask combined_usages, GenerateKeyResult* result) const { Status status = CheckKeyCreationUsages( - all_public_key_usages_ | all_private_key_usages_, combined_usage_mask); + all_public_key_usages_ | all_private_key_usages_, combined_usages); if (status.IsError()) return status; - const blink::WebCryptoKeyUsageMask public_usage_mask = - combined_usage_mask & all_public_key_usages_; - const blink::WebCryptoKeyUsageMask private_usage_mask = - combined_usage_mask & all_private_key_usages_; + const blink::WebCryptoKeyUsageMask public_usages = + combined_usages & all_public_key_usages_; + const blink::WebCryptoKeyUsageMask private_usages = + combined_usages & all_private_key_usages_; const blink::WebCryptoRsaHashedKeyGenParams* params = algorithm.rsaHashedKeyGenParams(); @@ -292,7 +292,7 @@ Status RsaHashedAlgorithm::GenerateKey( algorithm.id(), params->hash(), true, - public_usage_mask, + public_usages, &public_key); if (status.IsError()) return status; @@ -301,7 +301,7 @@ Status RsaHashedAlgorithm::GenerateKey( algorithm.id(), params->hash(), extractable, - private_usage_mask, + private_usages, &private_key); if (status.IsError()) return status; @@ -312,16 +312,16 @@ Status RsaHashedAlgorithm::GenerateKey( Status RsaHashedAlgorithm::VerifyKeyUsagesBeforeImportKey( blink::WebCryptoKeyFormat format, - blink::WebCryptoKeyUsageMask usage_mask) const { + blink::WebCryptoKeyUsageMask usages) const { switch (format) { case blink::WebCryptoKeyFormatSpki: - return CheckKeyCreationUsages(all_public_key_usages_, usage_mask); + return CheckKeyCreationUsages(all_public_key_usages_, usages); case blink::WebCryptoKeyFormatPkcs8: - return CheckKeyCreationUsages(all_private_key_usages_, usage_mask); + return CheckKeyCreationUsages(all_private_key_usages_, usages); case blink::WebCryptoKeyFormatJwk: // TODO(eroman): http://crbug.com/395904 return CheckKeyCreationUsages( - all_public_key_usages_ | all_private_key_usages_, usage_mask); + all_public_key_usages_ | all_private_key_usages_, usages); default: return Status::ErrorUnsupportedImportKeyFormat(); } @@ -331,7 +331,7 @@ Status RsaHashedAlgorithm::ImportKeyPkcs8( const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const { if (!key_data.byte_length()) return Status::ErrorImportEmptyKeyData(); @@ -370,7 +370,7 @@ Status RsaHashedAlgorithm::ImportKeyPkcs8( algorithm.id(), algorithm.rsaHashedImportParams()->hash(), extractable, - usage_mask, + usages, key); } @@ -378,7 +378,7 @@ Status RsaHashedAlgorithm::ImportKeySpki( const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const { if (!key_data.byte_length()) return Status::ErrorImportEmptyKeyData(); @@ -404,7 +404,7 @@ Status RsaHashedAlgorithm::ImportKeySpki( algorithm.id(), algorithm.rsaHashedImportParams()->hash(), extractable, - usage_mask, + usages, key); } @@ -412,7 +412,7 @@ Status RsaHashedAlgorithm::ImportKeyJwk( const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const { crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); @@ -424,22 +424,22 @@ Status RsaHashedAlgorithm::ImportKeyJwk( JwkRsaInfo jwk; Status status = - ReadRsaKeyJwk(key_data, jwk_algorithm, extractable, usage_mask, &jwk); + ReadRsaKeyJwk(key_data, jwk_algorithm, extractable, usages, &jwk); if (status.IsError()) return status; // Once the key type is known, verify the usages. status = CheckKeyCreationUsages( jwk.is_private_key ? all_private_key_usages_ : all_public_key_usages_, - usage_mask); + usages); if (status.IsError()) return status; return jwk.is_private_key - ? ImportRsaPrivateKey(algorithm, extractable, usage_mask, jwk, key) + ? ImportRsaPrivateKey(algorithm, extractable, usages, jwk, key) : ImportRsaPublicKey(algorithm, extractable, - usage_mask, + usages, CryptoData(jwk.n), CryptoData(jwk.e), key); diff --git a/content/child/webcrypto/openssl/rsa_key_openssl.h b/content/child/webcrypto/openssl/rsa_key_openssl.h index a93550d..48d7b4c 100644 --- a/content/child/webcrypto/openssl/rsa_key_openssl.h +++ b/content/child/webcrypto/openssl/rsa_key_openssl.h @@ -40,29 +40,29 @@ class RsaHashedAlgorithm : public AlgorithmImplementation { Status GenerateKey(const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, GenerateKeyResult* result) const override; Status VerifyKeyUsagesBeforeImportKey( blink::WebCryptoKeyFormat format, - blink::WebCryptoKeyUsageMask usage_mask) const override; + blink::WebCryptoKeyUsageMask usages) const override; Status ImportKeyPkcs8(const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const override; Status ImportKeySpki(const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const override; Status ImportKeyJwk(const CryptoData& key_data, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) const override; Status ExportKeyPkcs8(const blink::WebCryptoKey& key, diff --git a/content/child/webcrypto/openssl/sym_key_openssl.cc b/content/child/webcrypto/openssl/sym_key_openssl.cc index e03cc58..3923833 100644 --- a/content/child/webcrypto/openssl/sym_key_openssl.cc +++ b/content/child/webcrypto/openssl/sym_key_openssl.cc @@ -20,7 +20,7 @@ namespace webcrypto { Status GenerateSecretKeyOpenSsl(const blink::WebCryptoKeyAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, unsigned keylen_bytes, GenerateKeyResult* result) { crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); @@ -37,7 +37,7 @@ Status GenerateSecretKeyOpenSsl(const blink::WebCryptoKeyAlgorithm& algorithm, blink::WebCryptoKeyTypeSecret, extractable, algorithm, - usage_mask)); + usages)); return Status::Success(); } @@ -45,13 +45,13 @@ Status GenerateSecretKeyOpenSsl(const blink::WebCryptoKeyAlgorithm& algorithm, Status ImportKeyRawOpenSsl(const CryptoData& key_data, const blink::WebCryptoKeyAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) { *key = blink::WebCryptoKey::create(new SymKeyOpenSsl(key_data), blink::WebCryptoKeyTypeSecret, extractable, algorithm, - usage_mask); + usages); return Status::Success(); } diff --git a/content/child/webcrypto/openssl/sym_key_openssl.h b/content/child/webcrypto/openssl/sym_key_openssl.h index ac68f5e..bb5def4 100644 --- a/content/child/webcrypto/openssl/sym_key_openssl.h +++ b/content/child/webcrypto/openssl/sym_key_openssl.h @@ -17,14 +17,14 @@ class Status; Status GenerateSecretKeyOpenSsl(const blink::WebCryptoKeyAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, unsigned keylen_bytes, GenerateKeyResult* result); Status ImportKeyRawOpenSsl(const CryptoData& key_data, const blink::WebCryptoKeyAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key); } // namespace webcrypto diff --git a/content/child/webcrypto/structured_clone.cc b/content/child/webcrypto/structured_clone.cc index 6bbf6d3..68d449a 100644 --- a/content/child/webcrypto/structured_clone.cc +++ b/content/child/webcrypto/structured_clone.cc @@ -109,7 +109,7 @@ bool SerializeKeyForClone(const blink::WebCryptoKey& key, bool DeserializeKeyForClone(const blink::WebCryptoKeyAlgorithm& algorithm, blink::WebCryptoKeyType type, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, const CryptoData& key_data, blink::WebCryptoKey* key) { // TODO(eroman): This should not call into the platform crypto layer. @@ -124,7 +124,7 @@ bool DeserializeKeyForClone(const blink::WebCryptoKeyAlgorithm& algorithm, key_data, KeyAlgorithmToImportAlgorithm(algorithm), extractable, - usage_mask, + usages, key); if (status.IsError()) return false; diff --git a/content/child/webcrypto/structured_clone.h b/content/child/webcrypto/structured_clone.h index a72974c..3e218c8 100644 --- a/content/child/webcrypto/structured_clone.h +++ b/content/child/webcrypto/structured_clone.h @@ -23,7 +23,7 @@ bool SerializeKeyForClone(const blink::WebCryptoKey& key, bool DeserializeKeyForClone(const blink::WebCryptoKeyAlgorithm& algorithm, blink::WebCryptoKeyType type, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, const CryptoData& key_data, blink::WebCryptoKey* key); diff --git a/content/child/webcrypto/test/aes_cbc_unittest.cc b/content/child/webcrypto/test/aes_cbc_unittest.cc index 7ad0e27..b7f897c 100644 --- a/content/child/webcrypto/test/aes_cbc_unittest.cc +++ b/content/child/webcrypto/test/aes_cbc_unittest.cc @@ -639,7 +639,7 @@ TEST(WebCryptoAesCbcTest, ImportJwkUnrecognizedKeyOps) { blink::WebCryptoKey key; blink::WebCryptoAlgorithm algorithm = CreateAlgorithm(blink::WebCryptoAlgorithmIdAesCbc); - blink::WebCryptoKeyUsageMask usage_mask = blink::WebCryptoKeyUsageEncrypt; + blink::WebCryptoKeyUsageMask usages = blink::WebCryptoKeyUsageEncrypt; base::DictionaryValue dict; dict.SetString("kty", "oct"); @@ -655,7 +655,7 @@ TEST(WebCryptoAesCbcTest, ImportJwkUnrecognizedKeyOps) { key_ops->AppendString("baz"); key_ops->AppendString("encrypt"); EXPECT_EQ(Status::Success(), - ImportKeyJwkFromDict(dict, algorithm, false, usage_mask, &key)); + ImportKeyJwkFromDict(dict, algorithm, false, usages, &key)); } // Import a JWK with a value in key_ops array that is not a string. @@ -663,7 +663,7 @@ TEST(WebCryptoAesCbcTest, ImportJwkNonStringKeyOp) { blink::WebCryptoKey key; blink::WebCryptoAlgorithm algorithm = CreateAlgorithm(blink::WebCryptoAlgorithmIdAesCbc); - blink::WebCryptoKeyUsageMask usage_mask = blink::WebCryptoKeyUsageEncrypt; + blink::WebCryptoKeyUsageMask usages = blink::WebCryptoKeyUsageEncrypt; base::DictionaryValue dict; dict.SetString("kty", "oct"); @@ -677,7 +677,7 @@ TEST(WebCryptoAesCbcTest, ImportJwkNonStringKeyOp) { key_ops->AppendString("encrypt"); key_ops->AppendInteger(3); EXPECT_EQ(Status::ErrorJwkPropertyWrongType("key_ops[1]", "string"), - ImportKeyJwkFromDict(dict, algorithm, false, usage_mask, &key)); + ImportKeyJwkFromDict(dict, algorithm, false, usages, &key)); } // Fail on missing k. diff --git a/content/child/webcrypto/test/hmac_unittest.cc b/content/child/webcrypto/test/hmac_unittest.cc index 3ec123b..d57116c 100644 --- a/content/child/webcrypto/test/hmac_unittest.cc +++ b/content/child/webcrypto/test/hmac_unittest.cc @@ -260,7 +260,7 @@ TEST(WebCryptoHmacTest, ImportJwkInputConsistency) { bool extractable = false; blink::WebCryptoAlgorithm algorithm = CreateHmacImportAlgorithm(blink::WebCryptoAlgorithmIdSha256); - blink::WebCryptoKeyUsageMask usage_mask = blink::WebCryptoKeyUsageVerify; + blink::WebCryptoKeyUsageMask usages = blink::WebCryptoKeyUsageVerify; base::DictionaryValue dict; dict.SetString("kty", "oct"); dict.SetString("k", "l3nZEgZCeX8XRwJdWyK3rGB8qwjhdY8vOkbIvh4lxTuMao9Y_--hdg"); @@ -270,7 +270,7 @@ TEST(WebCryptoHmacTest, ImportJwkInputConsistency) { CryptoData(json_vec), algorithm, extractable, - usage_mask, + usages, &key)); EXPECT_TRUE(key.handle()); EXPECT_EQ(blink::WebCryptoKeyTypeSecret, key.type()); @@ -297,7 +297,7 @@ TEST(WebCryptoHmacTest, ImportJwkInputConsistency) { CryptoData(json_vec), algorithm, extractable, - usage_mask, + usages, &key)); // Extractable cases: @@ -310,22 +310,22 @@ TEST(WebCryptoHmacTest, ImportJwkInputConsistency) { CryptoData(json_vec), algorithm, true, - usage_mask, + usages, &key)); EXPECT_EQ(Status::Success(), ImportKey(blink::WebCryptoKeyFormatJwk, CryptoData(json_vec), algorithm, false, - usage_mask, + usages, &key)); EXPECT_FALSE(key.extractable()); dict.SetBoolean("ext", true); EXPECT_EQ(Status::Success(), - ImportKeyJwkFromDict(dict, algorithm, true, usage_mask, &key)); + ImportKeyJwkFromDict(dict, algorithm, true, usages, &key)); EXPECT_TRUE(key.extractable()); EXPECT_EQ(Status::Success(), - ImportKeyJwkFromDict(dict, algorithm, false, usage_mask, &key)); + ImportKeyJwkFromDict(dict, algorithm, false, usages, &key)); EXPECT_FALSE(key.extractable()); dict.SetBoolean("ext", true); // restore previous value @@ -359,7 +359,7 @@ TEST(WebCryptoHmacTest, ImportJwkInputConsistency) { CryptoData(json_vec), CreateHmacImportAlgorithm(blink::WebCryptoAlgorithmIdSha1), extractable, - usage_mask, + usages, &key)); // Pass: JWK alg missing but input algorithm specified: use input value @@ -369,12 +369,12 @@ TEST(WebCryptoHmacTest, ImportJwkInputConsistency) { dict, CreateHmacImportAlgorithm(blink::WebCryptoAlgorithmIdSha256), extractable, - usage_mask, + usages, &key)); EXPECT_EQ(blink::WebCryptoAlgorithmIdHmac, algorithm.id()); dict.SetString("alg", "HS256"); - // Fail: Input usage_mask (encrypt) is not a subset of the JWK value + // Fail: Input usages (encrypt) is not a subset of the JWK value // (sign|verify). Moreover "encrypt" is not a valid usage for HMAC. EXPECT_EQ(Status::ErrorCreateKeyBadUsages(), ImportKey(blink::WebCryptoKeyFormatJwk, @@ -384,16 +384,16 @@ TEST(WebCryptoHmacTest, ImportJwkInputConsistency) { blink::WebCryptoKeyUsageEncrypt, &key)); - // Fail: Input usage_mask (encrypt|sign|verify) is not a subset of the JWK + // Fail: Input usages (encrypt|sign|verify) is not a subset of the JWK // value (sign|verify). Moreover "encrypt" is not a valid usage for HMAC. - usage_mask = blink::WebCryptoKeyUsageEncrypt | blink::WebCryptoKeyUsageSign | - blink::WebCryptoKeyUsageVerify; + usages = blink::WebCryptoKeyUsageEncrypt | blink::WebCryptoKeyUsageSign | + blink::WebCryptoKeyUsageVerify; EXPECT_EQ(Status::ErrorCreateKeyBadUsages(), ImportKey(blink::WebCryptoKeyFormatJwk, CryptoData(json_vec), algorithm, extractable, - usage_mask, + usages, &key)); // TODO(padolph): kty vs alg consistency tests: Depending on the kty value, @@ -412,7 +412,7 @@ TEST(WebCryptoHmacTest, ImportJwkHappy) { bool extractable = false; blink::WebCryptoAlgorithm algorithm = CreateHmacImportAlgorithm(blink::WebCryptoAlgorithmIdSha256); - blink::WebCryptoKeyUsageMask usage_mask = blink::WebCryptoKeyUsageSign; + blink::WebCryptoKeyUsageMask usages = blink::WebCryptoKeyUsageSign; // Import a symmetric key JWK and HMAC-SHA256 sign() // Uses the first SHA256 test vector from the HMAC sample set above. @@ -424,9 +424,8 @@ TEST(WebCryptoHmacTest, ImportJwkHappy) { dict.SetBoolean("ext", false); dict.SetString("k", "l3nZEgZCeX8XRwJdWyK3rGB8qwjhdY8vOkbIvh4lxTuMao9Y_--hdg"); - ASSERT_EQ( - Status::Success(), - ImportKeyJwkFromDict(dict, algorithm, extractable, usage_mask, &key)); + ASSERT_EQ(Status::Success(), + ImportKeyJwkFromDict(dict, algorithm, extractable, usages, &key)); EXPECT_EQ(blink::WebCryptoAlgorithmIdSha256, key.algorithm().hmacParams()->hash().id()); diff --git a/content/child/webcrypto/test/rsa_ssa_unittest.cc b/content/child/webcrypto/test/rsa_ssa_unittest.cc index 3ce88b1..81f5101 100644 --- a/content/child/webcrypto/test/rsa_ssa_unittest.cc +++ b/content/child/webcrypto/test/rsa_ssa_unittest.cc @@ -539,13 +539,13 @@ TEST(WebCryptoRsaSsaTest, GenerateKeyPairRsa) { modulus_length, public_exponent); bool extractable = true; - const blink::WebCryptoKeyUsageMask usage_mask = 0; + const blink::WebCryptoKeyUsageMask usages = 0; blink::WebCryptoKey public_key; blink::WebCryptoKey private_key; EXPECT_EQ(Status::Success(), GenerateKeyPair( - algorithm, extractable, usage_mask, &public_key, &private_key)); + algorithm, extractable, usages, &public_key, &private_key)); EXPECT_FALSE(public_key.isNull()); EXPECT_FALSE(private_key.isNull()); EXPECT_EQ(blink::WebCryptoKeyTypePublic, public_key.type()); @@ -560,8 +560,8 @@ TEST(WebCryptoRsaSsaTest, GenerateKeyPairRsa) { private_key.algorithm().rsaHashedParams()->hash().id()); EXPECT_TRUE(public_key.extractable()); EXPECT_EQ(extractable, private_key.extractable()); - EXPECT_EQ(usage_mask, public_key.usages()); - EXPECT_EQ(usage_mask, private_key.usages()); + EXPECT_EQ(usages, public_key.usages()); + EXPECT_EQ(usages, private_key.usages()); // Try exporting the generated key pair, and then re-importing to verify that // the exported data was valid. @@ -579,7 +579,7 @@ TEST(WebCryptoRsaSsaTest, GenerateKeyPairRsa) { blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, blink::WebCryptoAlgorithmIdSha256), true, - usage_mask, + usages, &public_key)); EXPECT_EQ(modulus_length, public_key.algorithm().rsaHashedParams()->modulusLengthBits()); @@ -597,7 +597,7 @@ TEST(WebCryptoRsaSsaTest, GenerateKeyPairRsa) { blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, blink::WebCryptoAlgorithmIdSha256), true, - usage_mask, + usages, &private_key)); EXPECT_EQ(modulus_length, private_key.algorithm().rsaHashedParams()->modulusLengthBits()); @@ -611,7 +611,7 @@ TEST(WebCryptoRsaSsaTest, GenerateKeyPairRsa) { public_exponent); EXPECT_EQ(Status::ErrorGenerateRsaUnsupportedModulus(), GenerateKeyPair( - algorithm, extractable, usage_mask, &public_key, &private_key)); + algorithm, extractable, usages, &public_key, &private_key)); // Fail with bad exponent: larger than unsigned long. unsigned int exponent_length = sizeof(unsigned long) + 1; // NOLINT @@ -623,7 +623,7 @@ TEST(WebCryptoRsaSsaTest, GenerateKeyPairRsa) { long_exponent); EXPECT_EQ(Status::ErrorGenerateKeyPublicExponent(), GenerateKeyPair( - algorithm, extractable, usage_mask, &public_key, &private_key)); + algorithm, extractable, usages, &public_key, &private_key)); // Fail with bad exponent: empty. const std::vector<uint8_t> empty_exponent; @@ -634,7 +634,7 @@ TEST(WebCryptoRsaSsaTest, GenerateKeyPairRsa) { empty_exponent); EXPECT_EQ(Status::ErrorGenerateKeyPublicExponent(), GenerateKeyPair( - algorithm, extractable, usage_mask, &public_key, &private_key)); + algorithm, extractable, usages, &public_key, &private_key)); // Fail with bad exponent: all zeros. std::vector<uint8_t> exponent_with_leading_zeros(15, 0x00); @@ -645,7 +645,7 @@ TEST(WebCryptoRsaSsaTest, GenerateKeyPairRsa) { exponent_with_leading_zeros); EXPECT_EQ(Status::ErrorGenerateKeyPublicExponent(), GenerateKeyPair( - algorithm, extractable, usage_mask, &public_key, &private_key)); + algorithm, extractable, usages, &public_key, &private_key)); // Key generation success using exponent with leading zeros. exponent_with_leading_zeros.insert(exponent_with_leading_zeros.end(), @@ -658,15 +658,15 @@ TEST(WebCryptoRsaSsaTest, GenerateKeyPairRsa) { exponent_with_leading_zeros); EXPECT_EQ(Status::Success(), GenerateKeyPair( - algorithm, extractable, usage_mask, &public_key, &private_key)); + algorithm, extractable, usages, &public_key, &private_key)); EXPECT_FALSE(public_key.isNull()); EXPECT_FALSE(private_key.isNull()); EXPECT_EQ(blink::WebCryptoKeyTypePublic, public_key.type()); EXPECT_EQ(blink::WebCryptoKeyTypePrivate, private_key.type()); EXPECT_TRUE(public_key.extractable()); EXPECT_EQ(extractable, private_key.extractable()); - EXPECT_EQ(usage_mask, public_key.usages()); - EXPECT_EQ(usage_mask, private_key.usages()); + EXPECT_EQ(usages, public_key.usages()); + EXPECT_EQ(usages, private_key.usages()); // Successful WebCryptoAlgorithmIdRsaSsaPkcs1v1_5 key generation (sha1) algorithm = @@ -676,7 +676,7 @@ TEST(WebCryptoRsaSsaTest, GenerateKeyPairRsa) { public_exponent); EXPECT_EQ( Status::Success(), - GenerateKeyPair(algorithm, false, usage_mask, &public_key, &private_key)); + GenerateKeyPair(algorithm, false, usages, &public_key, &private_key)); EXPECT_FALSE(public_key.isNull()); EXPECT_FALSE(private_key.isNull()); EXPECT_EQ(blink::WebCryptoKeyTypePublic, public_key.type()); @@ -693,8 +693,8 @@ TEST(WebCryptoRsaSsaTest, GenerateKeyPairRsa) { // extractable. EXPECT_TRUE(public_key.extractable()); EXPECT_FALSE(private_key.extractable()); - EXPECT_EQ(usage_mask, public_key.usages()); - EXPECT_EQ(usage_mask, private_key.usages()); + EXPECT_EQ(usages, public_key.usages()); + EXPECT_EQ(usages, private_key.usages()); // Exporting a private key as SPKI format doesn't make sense. However this // will first fail because the key is not extractable. @@ -706,7 +706,7 @@ TEST(WebCryptoRsaSsaTest, GenerateKeyPairRsa) { // This should fail since spki is for public keys. EXPECT_EQ( Status::Success(), - GenerateKeyPair(algorithm, true, usage_mask, &public_key, &private_key)); + GenerateKeyPair(algorithm, true, usages, &public_key, &private_key)); EXPECT_EQ(Status::ErrorUnexpectedKeyType(), ExportKey(blink::WebCryptoKeyFormatSpki, private_key, &output)); } @@ -731,14 +731,13 @@ TEST(WebCryptoRsaSsaTest, GenerateKeyPairRsaBadModulusLength) { modulus_length_bits, public_exponent); bool extractable = true; - const blink::WebCryptoKeyUsageMask usage_mask = 0; + const blink::WebCryptoKeyUsageMask usages = 0; blink::WebCryptoKey public_key; blink::WebCryptoKey private_key; - EXPECT_EQ( - Status::ErrorGenerateRsaUnsupportedModulus(), - GenerateKeyPair( - algorithm, extractable, usage_mask, &public_key, &private_key)); + EXPECT_EQ(Status::ErrorGenerateRsaUnsupportedModulus(), + GenerateKeyPair( + algorithm, extractable, usages, &public_key, &private_key)); } } @@ -1159,7 +1158,7 @@ TEST(WebCryptoRsaSsaTest, ImportJwkRsaFailures) { blink::WebCryptoAlgorithm algorithm = CreateRsaHashedImportAlgorithm(blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, blink::WebCryptoAlgorithmIdSha256); - blink::WebCryptoKeyUsageMask usage_mask = blink::WebCryptoKeyUsageVerify; + blink::WebCryptoKeyUsageMask usages = blink::WebCryptoKeyUsageVerify; blink::WebCryptoKey key; // An RSA public key JWK _must_ have an "n" (modulus) and an "e" (exponent) @@ -1170,7 +1169,7 @@ TEST(WebCryptoRsaSsaTest, ImportJwkRsaFailures) { // Baseline pass. EXPECT_EQ(Status::Success(), - ImportKeyJwkFromDict(dict, algorithm, false, usage_mask, &key)); + ImportKeyJwkFromDict(dict, algorithm, false, usages, &key)); EXPECT_EQ(algorithm.id(), key.algorithm().id()); EXPECT_FALSE(key.extractable()); EXPECT_EQ(blink::WebCryptoKeyUsageVerify, key.usages()); @@ -1184,19 +1183,19 @@ TEST(WebCryptoRsaSsaTest, ImportJwkRsaFailures) { // Fail on missing parameter. dict.Remove(kKtyParmName[idx], NULL); EXPECT_NE(Status::Success(), - ImportKeyJwkFromDict(dict, algorithm, false, usage_mask, &key)); + ImportKeyJwkFromDict(dict, algorithm, false, usages, &key)); RestoreJwkRsaDictionary(&dict); // Fail on bad b64 parameter encoding. dict.SetString(kKtyParmName[idx], "Qk3f0DsytU8lfza2au #$% Htaw2xpop9yTuH0"); EXPECT_NE(Status::Success(), - ImportKeyJwkFromDict(dict, algorithm, false, usage_mask, &key)); + ImportKeyJwkFromDict(dict, algorithm, false, usages, &key)); RestoreJwkRsaDictionary(&dict); // Fail on empty parameter. dict.SetString(kKtyParmName[idx], ""); EXPECT_EQ(Status::ErrorJwkEmptyBigInteger(kKtyParmName[idx]), - ImportKeyJwkFromDict(dict, algorithm, false, usage_mask, &key)); + ImportKeyJwkFromDict(dict, algorithm, false, usages, &key)); RestoreJwkRsaDictionary(&dict); } } diff --git a/content/child/webcrypto/test/test_helpers.cc b/content/child/webcrypto/test/test_helpers.cc index f10538f..00af762 100644 --- a/content/child/webcrypto/test/test_helpers.cc +++ b/content/child/webcrypto/test/test_helpers.cc @@ -367,8 +367,8 @@ void ImportRsaKeyPair(const std::vector<uint8_t>& spki_der, const std::vector<uint8_t>& pkcs8_der, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask public_key_usage_mask, - blink::WebCryptoKeyUsageMask private_key_usage_mask, + blink::WebCryptoKeyUsageMask public_key_usages, + blink::WebCryptoKeyUsageMask private_key_usages, blink::WebCryptoKey* public_key, blink::WebCryptoKey* private_key) { ASSERT_EQ(Status::Success(), @@ -376,40 +376,40 @@ void ImportRsaKeyPair(const std::vector<uint8_t>& spki_der, CryptoData(spki_der), algorithm, true, - public_key_usage_mask, + public_key_usages, public_key)); EXPECT_FALSE(public_key->isNull()); EXPECT_TRUE(public_key->handle()); EXPECT_EQ(blink::WebCryptoKeyTypePublic, public_key->type()); EXPECT_EQ(algorithm.id(), public_key->algorithm().id()); EXPECT_TRUE(public_key->extractable()); - EXPECT_EQ(public_key_usage_mask, public_key->usages()); + EXPECT_EQ(public_key_usages, public_key->usages()); ASSERT_EQ(Status::Success(), ImportKey(blink::WebCryptoKeyFormatPkcs8, CryptoData(pkcs8_der), algorithm, extractable, - private_key_usage_mask, + private_key_usages, private_key)); EXPECT_FALSE(private_key->isNull()); EXPECT_TRUE(private_key->handle()); EXPECT_EQ(blink::WebCryptoKeyTypePrivate, private_key->type()); EXPECT_EQ(algorithm.id(), private_key->algorithm().id()); EXPECT_EQ(extractable, private_key->extractable()); - EXPECT_EQ(private_key_usage_mask, private_key->usages()); + EXPECT_EQ(private_key_usages, private_key->usages()); } Status ImportKeyJwkFromDict(const base::DictionaryValue& dict, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) { return ImportKey(blink::WebCryptoKeyFormatJwk, CryptoData(MakeJsonVector(dict)), algorithm, extractable, - usage_mask, + usages, key); } @@ -601,10 +601,10 @@ void ImportExportJwkSymmetricKey( Status GenerateSecretKey(const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key) { GenerateKeyResult result; - Status status = GenerateKey(algorithm, extractable, usage_mask, &result); + Status status = GenerateKey(algorithm, extractable, usages, &result); if (status.IsError()) return status; @@ -618,11 +618,11 @@ Status GenerateSecretKey(const blink::WebCryptoAlgorithm& algorithm, Status GenerateKeyPair(const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* public_key, blink::WebCryptoKey* private_key) { GenerateKeyResult result; - Status status = GenerateKey(algorithm, extractable, usage_mask, &result); + Status status = GenerateKey(algorithm, extractable, usages, &result); if (status.IsError()) return status; diff --git a/content/child/webcrypto/test/test_helpers.h b/content/child/webcrypto/test/test_helpers.h index 0605148..1505f09 100644 --- a/content/child/webcrypto/test/test_helpers.h +++ b/content/child/webcrypto/test/test_helpers.h @@ -129,15 +129,15 @@ void ImportRsaKeyPair(const std::vector<uint8_t>& spki_der, const std::vector<uint8_t>& pkcs8_der, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask public_key_usage_mask, - blink::WebCryptoKeyUsageMask private_key_usage_mask, + blink::WebCryptoKeyUsageMask public_key_usages, + blink::WebCryptoKeyUsageMask private_key_usages, blink::WebCryptoKey* public_key, blink::WebCryptoKey* private_key); Status ImportKeyJwkFromDict(const base::DictionaryValue& dict, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key); // Parses a vector of JSON into a dictionary. @@ -179,11 +179,11 @@ void ImportExportJwkSymmetricKey( // expectation, then it fails with Status::ErrorUnexpected(). Status GenerateSecretKey(const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* key); Status GenerateKeyPair(const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoKey* public_key, blink::WebCryptoKey* private_key); diff --git a/content/child/webcrypto/webcrypto_impl.cc b/content/child/webcrypto/webcrypto_impl.cc index 205d515..2099a90 100644 --- a/content/child/webcrypto/webcrypto_impl.cc +++ b/content/child/webcrypto/webcrypto_impl.cc @@ -211,16 +211,16 @@ typedef EncryptState DigestState; struct GenerateKeyState : public BaseState { GenerateKeyState(const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, const blink::WebCryptoResult& result) : BaseState(result), algorithm(algorithm), extractable(extractable), - usage_mask(usage_mask) {} + usages(usages) {} const blink::WebCryptoAlgorithm algorithm; const bool extractable; - const blink::WebCryptoKeyUsageMask usage_mask; + const blink::WebCryptoKeyUsageMask usages; webcrypto::GenerateKeyResult generate_key_result; }; @@ -231,20 +231,20 @@ struct ImportKeyState : public BaseState { unsigned int key_data_size, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, const blink::WebCryptoResult& result) : BaseState(result), format(format), key_data(key_data, key_data + key_data_size), algorithm(algorithm), extractable(extractable), - usage_mask(usage_mask) {} + usages(usages) {} const blink::WebCryptoKeyFormat format; const std::vector<uint8_t> key_data; const blink::WebCryptoAlgorithm algorithm; const bool extractable; - const blink::WebCryptoKeyUsageMask usage_mask; + const blink::WebCryptoKeyUsageMask usages; blink::WebCryptoKey key; }; @@ -403,7 +403,7 @@ void DoGenerateKey(scoped_ptr<GenerateKeyState> passed_state) { return; state->status = webcrypto::GenerateKey(state->algorithm, state->extractable, - state->usage_mask, + state->usages, &state->generate_key_result); state->origin_thread->PostTask( FROM_HERE, base::Bind(DoGenerateKeyReply, Passed(&passed_state))); @@ -421,7 +421,7 @@ void DoImportKey(scoped_ptr<ImportKeyState> passed_state) { webcrypto::CryptoData(state->key_data), state->algorithm, state->extractable, - state->usage_mask, + state->usages, &state->key); if (state->status.IsSuccess()) { DCHECK(state->key.handle()); @@ -591,12 +591,12 @@ void WebCryptoImpl::digest(const blink::WebCryptoAlgorithm& algorithm, void WebCryptoImpl::generateKey(const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoResult result) { DCHECK(!algorithm.isNull()); scoped_ptr<GenerateKeyState> state( - new GenerateKeyState(algorithm, extractable, usage_mask, result)); + new GenerateKeyState(algorithm, extractable, usages, result)); if (!CryptoThreadPool::PostTask(FROM_HERE, base::Bind(DoGenerateKey, Passed(&state)))) { CompleteWithThreadPoolError(&result); @@ -608,15 +608,10 @@ void WebCryptoImpl::importKey(blink::WebCryptoKeyFormat format, unsigned int key_data_size, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoResult result) { - scoped_ptr<ImportKeyState> state(new ImportKeyState(format, - key_data, - key_data_size, - algorithm, - extractable, - usage_mask, - result)); + scoped_ptr<ImportKeyState> state(new ImportKeyState( + format, key_data, key_data_size, algorithm, extractable, usages, result)); if (!CryptoThreadPool::PostTask(FROM_HERE, base::Bind(DoImportKey, Passed(&state)))) { CompleteWithThreadPoolError(&result); diff --git a/content/child/webcrypto/webcrypto_impl.h b/content/child/webcrypto/webcrypto_impl.h index 8d5af3d..ce2262b 100644 --- a/content/child/webcrypto/webcrypto_impl.h +++ b/content/child/webcrypto/webcrypto_impl.h @@ -41,14 +41,14 @@ class WebCryptoImpl : public blink::WebCrypto { blink::WebCryptoResult result); virtual void generateKey(const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoResult result); virtual void importKey(blink::WebCryptoKeyFormat format, const unsigned char* key_data, unsigned int key_data_size, const blink::WebCryptoAlgorithm& algorithm, bool extractable, - blink::WebCryptoKeyUsageMask usage_mask, + blink::WebCryptoKeyUsageMask usages, blink::WebCryptoResult result); virtual void exportKey(blink::WebCryptoKeyFormat format, const blink::WebCryptoKey& key, diff --git a/content/child/webcrypto/webcrypto_util.cc b/content/child/webcrypto/webcrypto_util.cc index b052bc9..27614d1 100644 --- a/content/child/webcrypto/webcrypto_util.cc +++ b/content/child/webcrypto/webcrypto_util.cc @@ -61,12 +61,12 @@ const JwkToWebCryptoUsage kJwkWebCryptoUsageMap[] = { {"wrapKey", blink::WebCryptoKeyUsageWrapKey}, {"unwrapKey", blink::WebCryptoKeyUsageUnwrapKey}}; -// Modifies the input usage_mask by according to the key_op value. +// Modifies the input usages by according to the key_op value. bool JwkKeyOpToWebCryptoUsage(const std::string& key_op, - blink::WebCryptoKeyUsageMask* usage_mask) { + blink::WebCryptoKeyUsageMask* usages) { for (size_t i = 0; i < arraysize(kJwkWebCryptoUsageMap); ++i) { if (kJwkWebCryptoUsageMap[i].jwk_key_op == key_op) { - *usage_mask |= kJwkWebCryptoUsageMap[i].webcrypto_usage; + *usages |= kJwkWebCryptoUsageMap[i].webcrypto_usage; return true; } } @@ -74,10 +74,9 @@ bool JwkKeyOpToWebCryptoUsage(const std::string& key_op, } // Composes a Web Crypto usage mask from an array of JWK key_ops values. -Status GetWebCryptoUsagesFromJwkKeyOps( - const base::ListValue* jwk_key_ops_value, - blink::WebCryptoKeyUsageMask* usage_mask) { - *usage_mask = 0; +Status GetWebCryptoUsagesFromJwkKeyOps(const base::ListValue* jwk_key_ops_value, + blink::WebCryptoKeyUsageMask* usages) { + *usages = 0; for (size_t i = 0; i < jwk_key_ops_value->GetSize(); ++i) { std::string key_op; if (!jwk_key_ops_value->GetString(i, &key_op)) { @@ -85,7 +84,7 @@ Status GetWebCryptoUsagesFromJwkKeyOps( base::StringPrintf("key_ops[%d]", static_cast<int>(i)), "string"); } // Unrecognized key_ops are silently skipped. - ignore_result(JwkKeyOpToWebCryptoUsage(key_op, usage_mask)); + ignore_result(JwkKeyOpToWebCryptoUsage(key_op, usages)); } return Status::Success(); } @@ -93,10 +92,10 @@ Status GetWebCryptoUsagesFromJwkKeyOps( // Composes a JWK key_ops List from a Web Crypto usage mask. // Note: Caller must assume ownership of returned instance. base::ListValue* CreateJwkKeyOpsFromWebCryptoUsages( - blink::WebCryptoKeyUsageMask usage_mask) { + blink::WebCryptoKeyUsageMask usages) { base::ListValue* jwk_key_ops = new base::ListValue(); for (size_t i = 0; i < arraysize(kJwkWebCryptoUsageMap); ++i) { - if (usage_mask & kJwkWebCryptoUsageMap[i].webcrypto_usage) + if (usages & kJwkWebCryptoUsageMap[i].webcrypto_usage) jwk_key_ops->AppendString(kJwkWebCryptoUsageMap[i].jwk_key_op); } return jwk_key_ops; diff --git a/content/child/webcrypto/webcrypto_util.h b/content/child/webcrypto/webcrypto_util.h index cffea715..af8c8e9 100644 --- a/content/child/webcrypto/webcrypto_util.h +++ b/content/child/webcrypto/webcrypto_util.h @@ -26,7 +26,7 @@ CONTENT_EXPORT Status GetWebCryptoUsagesFromJwkKeyOps( // Composes a JWK key_ops array from a Web Crypto usage mask. base::ListValue* CreateJwkKeyOpsFromWebCryptoUsages( - blink::WebCryptoKeyUsageMask usage_mask); + blink::WebCryptoKeyUsageMask usages); // Creates a WebCryptoAlgorithm without any parameters. CONTENT_EXPORT blink::WebCryptoAlgorithm CreateAlgorithm( |