Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(749)

Side by Side Diff: content/child/webcrypto/platform_crypto_nss.cc

Issue 205913002: [webcrypto] Add JWK RSA public key export for NSS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 blink::WebArrayBuffer* modulus,
700 blink::WebArrayBuffer* 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 DCHECK(modulus_item.data);
eroman 2014/03/21 02:30:51 Do these need to be proper returns?
padolph 2014/03/24 04:24:06 Yes.
709 DCHECK(modulus_item.len);
710
711 SECItem public_exponent_item = key->key()->u.rsa.publicExponent;
712 DCHECK(public_exponent_item.data);
713 DCHECK(public_exponent_item.len);
714
715 *modulus = CreateArrayBuffer(modulus_item.data, modulus_item.len);
716 *public_exponent =
717 CreateArrayBuffer(public_exponent_item.data, public_exponent_item.len);
718
719 return Status::Success();
720 }
721
698 Status ImportKeyPkcs8(const blink::WebCryptoAlgorithm& algorithm, 722 Status ImportKeyPkcs8(const blink::WebCryptoAlgorithm& algorithm,
699 const CryptoData& key_data, 723 const CryptoData& key_data,
700 bool extractable, 724 bool extractable,
701 blink::WebCryptoKeyUsageMask usage_mask, 725 blink::WebCryptoKeyUsageMask usage_mask,
702 blink::WebCryptoKey* key) { 726 blink::WebCryptoKey* key) {
703 727
704 DCHECK(key); 728 DCHECK(key);
705 729
706 if (!key_data.byte_length()) 730 if (!key_data.byte_length())
707 return Status::ErrorImportEmptyKeyData(); 731 return Status::ErrorImportEmptyKeyData();
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
1323 key_algorithm, 1347 key_algorithm,
1324 usage_mask); 1348 usage_mask);
1325 return Status::Success(); 1349 return Status::Success();
1326 } 1350 }
1327 1351
1328 } // namespace platform 1352 } // namespace platform
1329 1353
1330 } // namespace webcrypto 1354 } // namespace webcrypto
1331 1355
1332 } // namespace content 1356 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698