Chromium Code Reviews| Index: content/child/webcrypto/nss/rsa_key_nss.cc |
| diff --git a/content/child/webcrypto/nss/rsa_key_nss.cc b/content/child/webcrypto/nss/rsa_key_nss.cc |
| index 7a35593c18bdd75b2bfd5d7cd6e29704aa5f069b..24ae9d3e89b3e37c4d0d0edd29929cb244b8238c 100644 |
| --- a/content/child/webcrypto/nss/rsa_key_nss.cc |
| +++ b/content/child/webcrypto/nss/rsa_key_nss.cc |
| @@ -504,7 +504,7 @@ Status RsaHashedAlgorithm::GenerateKey( |
| blink::WebCryptoKeyUsageMask combined_usages, |
| GenerateKeyResult* result) const { |
| Status status = CheckKeyCreationUsages( |
| - all_public_key_usages_ | all_private_key_usages_, combined_usages); |
| + all_public_key_usages_ | all_private_key_usages_, combined_usages, false); |
|
eroman
2014/12/09 21:04:46
I am proposing a refactor in:
https://codereview.
Habib Virji
2014/12/15 18:48:55
Adapted to your changes.
|
| if (status.IsError()) |
| return status; |
| @@ -590,15 +590,17 @@ Status RsaHashedAlgorithm::VerifyKeyUsagesBeforeImportKey( |
| blink::WebCryptoKeyUsageMask usages) const { |
| switch (format) { |
| case blink::WebCryptoKeyFormatSpki: |
| - return CheckKeyCreationUsages(all_public_key_usages_, usages); |
| + return CheckKeyCreationUsages(all_public_key_usages_, usages, false); |
| case blink::WebCryptoKeyFormatPkcs8: |
| - return CheckKeyCreationUsages(all_private_key_usages_, usages); |
| + return CheckKeyCreationUsages(all_private_key_usages_, usages, true); |
| case blink::WebCryptoKeyFormatJwk: |
| // The JWK could represent either a public key or private key. The usages |
| // must make sense for one of the two. The usages will be checked again by |
| // ImportKeyJwk() once the key type has been determined. |
| - if (CheckKeyCreationUsages(all_private_key_usages_, usages).IsSuccess() || |
| - CheckKeyCreationUsages(all_public_key_usages_, usages).IsSuccess()) { |
| + if (CheckKeyCreationUsages( |
| + all_private_key_usages_, usages, true).IsSuccess() || |
|
eroman
2014/12/09 21:04:46
I am proposing a refactor in https://codereview.ch
Habib Virji
2014/12/15 18:48:55
Adapted to your changes.
|
| + CheckKeyCreationUsages( |
| + all_public_key_usages_, usages, false).IsSuccess()) { |
| return Status::Success(); |
| } |
| return Status::ErrorCreateKeyBadUsages(); |
| @@ -763,7 +765,7 @@ Status RsaHashedAlgorithm::ImportKeyJwk( |
| // Once the key type is known, verify the usages. |
| status = CheckKeyCreationUsages( |
| jwk.is_private_key ? all_private_key_usages_ : all_public_key_usages_, |
| - usages); |
| + usages, jwk.is_private_key ? true : false); |
|
eroman
2014/12/09 21:04:46
This is already a bool no need for ternary operato
Habib Virji
2014/12/15 18:48:55
Corrected.
|
| if (status.IsError()) |
| return Status::ErrorCreateKeyBadUsages(); |
|
eroman
2014/12/09 21:04:46
On a side note, I wander whey this isn't just "ret
Habib Virji
2014/12/15 18:48:55
Adapted to just return status.
|