| 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/shared_crypto.h" | 5 #include "content/child/webcrypto/shared_crypto.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/child/webcrypto/crypto_data.h" | 8 #include "content/child/webcrypto/crypto_data.h" |
| 9 #include "content/child/webcrypto/platform_crypto.h" | 9 #include "content/child/webcrypto/platform_crypto.h" |
| 10 #include "content/child/webcrypto/status.h" | 10 #include "content/child/webcrypto/status.h" |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 return status; | 639 return status; |
| 640 return platform::ExportKeyRaw(sym_key, buffer); | 640 return platform::ExportKeyRaw(sym_key, buffer); |
| 641 } | 641 } |
| 642 case blink::WebCryptoKeyFormatSpki: { | 642 case blink::WebCryptoKeyFormatSpki: { |
| 643 platform::PublicKey* public_key; | 643 platform::PublicKey* public_key; |
| 644 Status status = ToPlatformPublicKey(key, &public_key); | 644 Status status = ToPlatformPublicKey(key, &public_key); |
| 645 if (status.IsError()) | 645 if (status.IsError()) |
| 646 return status; | 646 return status; |
| 647 return platform::ExportKeySpki(public_key, buffer); | 647 return platform::ExportKeySpki(public_key, buffer); |
| 648 } | 648 } |
| 649 case blink::WebCryptoKeyFormatPkcs8: { |
| 650 platform::PrivateKey* private_key; |
| 651 Status status = ToPlatformPrivateKey(key, &private_key); |
| 652 if (status.IsError()) |
| 653 return status; |
| 654 return platform::ExportKeyPkcs8(private_key, key.algorithm(), buffer); |
| 655 } |
| 649 case blink::WebCryptoKeyFormatJwk: | 656 case blink::WebCryptoKeyFormatJwk: |
| 650 return ExportKeyJwk(key, buffer); | 657 return ExportKeyJwk(key, buffer); |
| 651 case blink::WebCryptoKeyFormatPkcs8: | |
| 652 // TODO(eroman): | |
| 653 return Status::ErrorUnsupported(); | |
| 654 default: | 658 default: |
| 655 return Status::ErrorUnsupported(); | 659 return Status::ErrorUnsupported(); |
| 656 } | 660 } |
| 657 } | 661 } |
| 658 | 662 |
| 659 Status ExportKey(blink::WebCryptoKeyFormat format, | 663 Status ExportKey(blink::WebCryptoKeyFormat format, |
| 660 const blink::WebCryptoKey& key, | 664 const blink::WebCryptoKey& key, |
| 661 blink::WebArrayBuffer* buffer) { | 665 blink::WebArrayBuffer* buffer) { |
| 662 if (!key.extractable()) | 666 if (!key.extractable()) |
| 663 return Status::ErrorKeyNotExtractable(); | 667 return Status::ErrorKeyNotExtractable(); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 key); | 807 key); |
| 804 if (status.IsError()) | 808 if (status.IsError()) |
| 805 return status; | 809 return status; |
| 806 | 810 |
| 807 return ValidateDeserializedKey(*key, algorithm, type); | 811 return ValidateDeserializedKey(*key, algorithm, type); |
| 808 } | 812 } |
| 809 | 813 |
| 810 } // namespace webcrypto | 814 } // namespace webcrypto |
| 811 | 815 |
| 812 } // namespace content | 816 } // namespace content |
| OLD | NEW |