Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/child/webcrypto/nss/rsa_key_nss.h" | 5 #include "content/child/webcrypto/nss/rsa_key_nss.h" |
| 6 | 6 |
| 7 #include <secasn1.h> | 7 #include <secasn1.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "content/child/webcrypto/crypto_data.h" | 10 #include "content/child/webcrypto/crypto_data.h" |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 581 private_key_handle.release(), blink::WebCryptoKeyTypePrivate, extractable, | 581 private_key_handle.release(), blink::WebCryptoKeyTypePrivate, extractable, |
| 582 key_algorithm, private_usages); | 582 key_algorithm, private_usages); |
| 583 | 583 |
| 584 result->AssignKeyPair(public_key, private_key); | 584 result->AssignKeyPair(public_key, private_key); |
| 585 return Status::Success(); | 585 return Status::Success(); |
| 586 } | 586 } |
| 587 | 587 |
| 588 Status RsaHashedAlgorithm::VerifyKeyUsagesBeforeImportKey( | 588 Status RsaHashedAlgorithm::VerifyKeyUsagesBeforeImportKey( |
| 589 blink::WebCryptoKeyFormat format, | 589 blink::WebCryptoKeyFormat format, |
| 590 blink::WebCryptoKeyUsageMask usages) const { | 590 blink::WebCryptoKeyUsageMask usages) const { |
| 591 bool checkEmptyKeyUsage = true; | |
| 591 switch (format) { | 592 switch (format) { |
| 592 case blink::WebCryptoKeyFormatSpki: | 593 case blink::WebCryptoKeyFormatSpki: |
| 593 return CheckKeyCreationUsages(all_public_key_usages_, usages); | 594 return CheckKeyCreationUsages(all_public_key_usages_, usages, |
| 595 checkEmptyKeyUsage); | |
|
eroman
2014/12/09 17:42:55
This is incorrect.
I am losing confidence in your
| |
| 594 case blink::WebCryptoKeyFormatPkcs8: | 596 case blink::WebCryptoKeyFormatPkcs8: |
| 595 return CheckKeyCreationUsages(all_private_key_usages_, usages); | 597 return CheckKeyCreationUsages(all_private_key_usages_, usages, |
| 598 checkEmptyKeyUsage); | |
| 596 case blink::WebCryptoKeyFormatJwk: | 599 case blink::WebCryptoKeyFormatJwk: |
| 597 // The JWK could represent either a public key or private key. The usages | 600 // The JWK could represent either a public key or private key. The usages |
| 598 // must make sense for one of the two. The usages will be checked again by | 601 // must make sense for one of the two. The usages will be checked again by |
| 599 // ImportKeyJwk() once the key type has been determined. | 602 // ImportKeyJwk() once the key type has been determined. |
| 600 if (CheckKeyCreationUsages(all_private_key_usages_, usages).IsSuccess() || | 603 if (CheckKeyCreationUsages(all_private_key_usages_, usages, |
| 601 CheckKeyCreationUsages(all_public_key_usages_, usages).IsSuccess()) { | 604 checkEmptyKeyUsages).IsSuccess() || |
|
eroman
2014/12/09 17:42:55
Incorrect for the same reason as above.
| |
| 605 CheckKeyCreationUsages(all_public_key_usages_, usages, | |
| 606 checkEmptyKeyUsages).IsSuccess()) { | |
| 602 return Status::Success(); | 607 return Status::Success(); |
| 603 } | 608 } |
| 604 return Status::ErrorCreateKeyBadUsages(); | 609 return Status::ErrorCreateKeyBadUsages(); |
| 605 default: | 610 default: |
| 606 return Status::ErrorUnsupportedImportKeyFormat(); | 611 return Status::ErrorUnsupportedImportKeyFormat(); |
| 607 } | 612 } |
| 608 } | 613 } |
| 609 | 614 |
| 610 Status RsaHashedAlgorithm::ImportKeyPkcs8( | 615 Status RsaHashedAlgorithm::ImportKeyPkcs8( |
| 611 const CryptoData& key_data, | 616 const CryptoData& key_data, |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 878 key->algorithm().rsaHashedParams()->publicExponent().size())) { | 883 key->algorithm().rsaHashedParams()->publicExponent().size())) { |
| 879 return Status::ErrorUnexpected(); | 884 return Status::ErrorUnexpected(); |
| 880 } | 885 } |
| 881 | 886 |
| 882 return Status::Success(); | 887 return Status::Success(); |
| 883 } | 888 } |
| 884 | 889 |
| 885 } // namespace webcrypto | 890 } // namespace webcrypto |
| 886 | 891 |
| 887 } // namespace content | 892 } // namespace content |
| OLD | NEW |