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/platform_crypto.h" | 5 #include "content/child/webcrypto/platform_crypto.h" |
| 6 | 6 |
| 7 #include <cryptohi.h> | 7 #include <cryptohi.h> |
| 8 #include <pk11pub.h> | 8 #include <pk11pub.h> |
| 9 #include <sechash.h> | 9 #include <sechash.h> |
| 10 | 10 |
| (...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 688 return Status::Error(); | 688 return Status::Error(); |
| 689 | 689 |
| 690 DCHECK(spki_der->data); | 690 DCHECK(spki_der->data); |
| 691 DCHECK(spki_der->len); | 691 DCHECK(spki_der->len); |
| 692 | 692 |
| 693 *buffer = CreateArrayBuffer(spki_der->data, spki_der->len); | 693 *buffer = CreateArrayBuffer(spki_der->data, spki_der->len); |
| 694 | 694 |
| 695 return Status::Success(); | 695 return Status::Success(); |
| 696 } | 696 } |
| 697 | 697 |
| 698 Status ExportRsaPublicKey(PublicKey* key, | |
| 699 std::vector<uint8>* modulus, | |
| 700 std::vector<uint8>* public_exponent) { | |
| 701 DCHECK(key); | |
| 702 DCHECK(key->key()); | |
| 703 | |
| 704 if (key->key()->keyType != rsaKey) | |
| 705 return Status::ErrorUnsupported(); | |
| 706 | |
| 707 SECItem modulus_item = key->key()->u.rsa.modulus; | |
| 708 if (!modulus_item.data || !modulus_item.len) | |
|
eroman
2014/03/24 22:05:51
Consider extracting this to a function:
CopySECIt
padolph
2014/03/25 01:10:28
Done.
| |
| 709 return Status::ErrorUnexpected(); | |
| 710 | |
| 711 SECItem public_exponent_item = key->key()->u.rsa.publicExponent; | |
| 712 if (!public_exponent_item.data || !public_exponent_item.len) | |
| 713 return Status::ErrorUnexpected(); | |
| 714 | |
| 715 modulus->assign(modulus_item.data, modulus_item.data + modulus_item.len); | |
| 716 public_exponent->assign(public_exponent_item.data, | |
| 717 public_exponent_item.data + public_exponent_item.len); | |
| 718 return Status::Success(); | |
| 719 } | |
| 720 | |
| 698 Status ImportKeyPkcs8(const blink::WebCryptoAlgorithm& algorithm, | 721 Status ImportKeyPkcs8(const blink::WebCryptoAlgorithm& algorithm, |
| 699 const CryptoData& key_data, | 722 const CryptoData& key_data, |
| 700 bool extractable, | 723 bool extractable, |
| 701 blink::WebCryptoKeyUsageMask usage_mask, | 724 blink::WebCryptoKeyUsageMask usage_mask, |
| 702 blink::WebCryptoKey* key) { | 725 blink::WebCryptoKey* key) { |
| 703 | 726 |
| 704 DCHECK(key); | 727 DCHECK(key); |
| 705 | 728 |
| 706 if (!key_data.byte_length()) | 729 if (!key_data.byte_length()) |
| 707 return Status::ErrorImportEmptyKeyData(); | 730 return Status::ErrorImportEmptyKeyData(); |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1323 key_algorithm, | 1346 key_algorithm, |
| 1324 usage_mask); | 1347 usage_mask); |
| 1325 return Status::Success(); | 1348 return Status::Success(); |
| 1326 } | 1349 } |
| 1327 | 1350 |
| 1328 } // namespace platform | 1351 } // namespace platform |
| 1329 | 1352 |
| 1330 } // namespace webcrypto | 1353 } // namespace webcrypto |
| 1331 | 1354 |
| 1332 } // namespace content | 1355 } // namespace content |
| OLD | NEW |