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/webcrypto_util.h" | 10 #include "content/child/webcrypto/webcrypto_util.h" |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 return status; | 600 return status; |
601 return platform::ExportKeyRaw(sym_key, buffer); | 601 return platform::ExportKeyRaw(sym_key, buffer); |
602 } | 602 } |
603 case blink::WebCryptoKeyFormatSpki: { | 603 case blink::WebCryptoKeyFormatSpki: { |
604 platform::PublicKey* public_key; | 604 platform::PublicKey* public_key; |
605 Status status = ToPlatformPublicKey(key, &public_key); | 605 Status status = ToPlatformPublicKey(key, &public_key); |
606 if (status.IsError()) | 606 if (status.IsError()) |
607 return status; | 607 return status; |
608 return platform::ExportKeySpki(public_key, buffer); | 608 return platform::ExportKeySpki(public_key, buffer); |
609 } | 609 } |
| 610 case blink::WebCryptoKeyFormatPkcs8: { |
| 611 platform::PrivateKey* private_key; |
| 612 Status status = ToPlatformPrivateKey(key, &private_key); |
| 613 if (status.IsError()) |
| 614 return status; |
| 615 return platform::ExportKeyPkcs8(private_key, key.algorithm(), buffer); |
| 616 } |
610 case blink::WebCryptoKeyFormatJwk: | 617 case blink::WebCryptoKeyFormatJwk: |
611 return ExportKeyJwk(key, buffer); | 618 return ExportKeyJwk(key, buffer); |
612 case blink::WebCryptoKeyFormatPkcs8: | |
613 // TODO(eroman): | |
614 return Status::ErrorUnsupported(); | |
615 default: | 619 default: |
616 return Status::ErrorUnsupported(); | 620 return Status::ErrorUnsupported(); |
617 } | 621 } |
618 } | 622 } |
619 | 623 |
620 Status ExportKey(blink::WebCryptoKeyFormat format, | 624 Status ExportKey(blink::WebCryptoKeyFormat format, |
621 const blink::WebCryptoKey& key, | 625 const blink::WebCryptoKey& key, |
622 blink::WebArrayBuffer* buffer) { | 626 blink::WebArrayBuffer* buffer) { |
623 if (!key.extractable()) | 627 if (!key.extractable()) |
624 return Status::ErrorKeyNotExtractable(); | 628 return Status::ErrorKeyNotExtractable(); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 key); | 788 key); |
785 if (status.IsError()) | 789 if (status.IsError()) |
786 return status; | 790 return status; |
787 | 791 |
788 return ValidateDeserializedKey(*key, algorithm, type); | 792 return ValidateDeserializedKey(*key, algorithm, type); |
789 } | 793 } |
790 | 794 |
791 } // namespace webcrypto | 795 } // namespace webcrypto |
792 | 796 |
793 } // namespace content | 797 } // namespace content |
OLD | NEW |