| 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 "components/webcrypto/algorithms/rsa.h" | 5 #include "components/webcrypto/algorithms/rsa.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "components/webcrypto/algorithms/asymmetric_key_util.h" | 10 #include "components/webcrypto/algorithms/asymmetric_key_util.h" |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 } | 525 } |
| 526 | 526 |
| 527 // TODO(eroman): Defer import to the crypto thread. http://crbug.com/430763 | 527 // TODO(eroman): Defer import to the crypto thread. http://crbug.com/430763 |
| 528 Status RsaHashedAlgorithm::DeserializeKeyForClone( | 528 Status RsaHashedAlgorithm::DeserializeKeyForClone( |
| 529 const blink::WebCryptoKeyAlgorithm& algorithm, | 529 const blink::WebCryptoKeyAlgorithm& algorithm, |
| 530 blink::WebCryptoKeyType type, | 530 blink::WebCryptoKeyType type, |
| 531 bool extractable, | 531 bool extractable, |
| 532 blink::WebCryptoKeyUsageMask usages, | 532 blink::WebCryptoKeyUsageMask usages, |
| 533 const CryptoData& key_data, | 533 const CryptoData& key_data, |
| 534 blink::WebCryptoKey* key) const { | 534 blink::WebCryptoKey* key) const { |
| 535 if (algorithm.paramsType() != blink::WebCryptoKeyAlgorithmParamsTypeRsaHashed) |
| 536 return Status::ErrorUnexpected(); |
| 537 |
| 535 blink::WebCryptoAlgorithm import_algorithm = | 538 blink::WebCryptoAlgorithm import_algorithm = |
| 536 SynthesizeImportAlgorithmForClone(algorithm); | 539 SynthesizeImportAlgorithmForClone(algorithm); |
| 537 | 540 |
| 538 Status status; | 541 Status status; |
| 539 | 542 |
| 540 // The serialized data will be either SPKI or PKCS8 formatted. | 543 // The serialized data will be either SPKI or PKCS8 formatted. |
| 541 switch (type) { | 544 switch (type) { |
| 542 case blink::WebCryptoKeyTypePublic: | 545 case blink::WebCryptoKeyTypePublic: |
| 543 status = | 546 status = |
| 544 ImportKeySpki(key_data, import_algorithm, extractable, usages, key); | 547 ImportKeySpki(key_data, import_algorithm, extractable, usages, key); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 573 memcmp(algorithm.rsaHashedParams()->publicExponent().data(), | 576 memcmp(algorithm.rsaHashedParams()->publicExponent().data(), |
| 574 key->algorithm().rsaHashedParams()->publicExponent().data(), | 577 key->algorithm().rsaHashedParams()->publicExponent().data(), |
| 575 key->algorithm().rsaHashedParams()->publicExponent().size())) { | 578 key->algorithm().rsaHashedParams()->publicExponent().size())) { |
| 576 return Status::ErrorUnexpected(); | 579 return Status::ErrorUnexpected(); |
| 577 } | 580 } |
| 578 | 581 |
| 579 return Status::Success(); | 582 return Status::Success(); |
| 580 } | 583 } |
| 581 | 584 |
| 582 } // namespace webcrypto | 585 } // namespace webcrypto |
| OLD | NEW |