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

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

Issue 275943004: Add support for RSA-OAEP when using NSS 3.16.2 or later (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Unit tests Created 6 years, 7 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 | Annotate | Revision Log
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 "jwk.h" 5 #include "jwk.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <map> 9 #include <map>
10 10
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 // | "HS384" | HMAC using SHA-384 hash algorithm | 104 // | "HS384" | HMAC using SHA-384 hash algorithm |
105 // | "HS512" | HMAC using SHA-512 hash algorithm | 105 // | "HS512" | HMAC using SHA-512 hash algorithm |
106 // | "RS1" | RSASSA using SHA-1 hash algorithm 106 // | "RS1" | RSASSA using SHA-1 hash algorithm
107 // | "RS256" | RSASSA using SHA-256 hash algorithm | 107 // | "RS256" | RSASSA using SHA-256 hash algorithm |
108 // | "RS384" | RSASSA using SHA-384 hash algorithm | 108 // | "RS384" | RSASSA using SHA-384 hash algorithm |
109 // | "RS512" | RSASSA using SHA-512 hash algorithm | 109 // | "RS512" | RSASSA using SHA-512 hash algorithm |
110 // +--------------+-------------------------------------------------------| 110 // +--------------+-------------------------------------------------------|
111 // | Key Management Algorithm | 111 // | Key Management Algorithm |
112 // +--------------+-------------------------------------------------------+ 112 // +--------------+-------------------------------------------------------+
113 // | "RSA1_5" | RSAES-PKCS1-V1_5 [RFC3447] | 113 // | "RSA1_5" | RSAES-PKCS1-V1_5 [RFC3447] |
114 // | "RSA-OAEP" | RSAES using Optimal Asymmetric Encryption Padding | 114 // | "RSA-OAEP" | RSAES using Optimal Asymmetric Encryption Padding |
eroman 2014/05/16 20:29:51 Update this comment.
115 // | | (OAEP) [RFC3447], with the default parameters | 115 // | | (OAEP) [RFC3447], with the default parameters |
116 // | | specified by RFC3447 in Section A.2.1 | 116 // | | specified by RFC3447 in Section A.2.1 |
117 // | "A128KW" | Advanced Encryption Standard (AES) Key Wrap Algorithm | 117 // | "A128KW" | Advanced Encryption Standard (AES) Key Wrap Algorithm |
118 // | | [RFC3394] using 128 bit keys | 118 // | | [RFC3394] using 128 bit keys |
119 // | "A192KW" | AES Key Wrap Algorithm using 192 bit keys | 119 // | "A192KW" | AES Key Wrap Algorithm using 192 bit keys |
120 // | "A256KW" | AES Key Wrap Algorithm using 256 bit keys | 120 // | "A256KW" | AES Key Wrap Algorithm using 256 bit keys |
121 // | "A128GCM" | AES in Galois/Counter Mode (GCM) [NIST.800-38D] using | 121 // | "A128GCM" | AES in Galois/Counter Mode (GCM) [NIST.800-38D] using |
122 // | | 128 bit keys | 122 // | | 128 bit keys |
123 // | "A192GCM" | AES GCM using 192 bit keys | 123 // | "A192GCM" | AES GCM using 192 bit keys |
124 // | "A256GCM" | AES GCM using 256 bit keys | 124 // | "A256GCM" | AES GCM using 256 bit keys |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 blink::WebCryptoAlgorithmIdSha384>); 277 blink::WebCryptoAlgorithmIdSha384>);
278 alg_to_info_["RS512"] = 278 alg_to_info_["RS512"] =
279 JwkAlgorithmInfo(&BindAlgorithmId<CreateRsaSsaImportAlgorithm, 279 JwkAlgorithmInfo(&BindAlgorithmId<CreateRsaSsaImportAlgorithm,
280 blink::WebCryptoAlgorithmIdSha512>); 280 blink::WebCryptoAlgorithmIdSha512>);
281 alg_to_info_["RSA1_5"] = JwkAlgorithmInfo( 281 alg_to_info_["RSA1_5"] = JwkAlgorithmInfo(
282 &BindAlgorithmId<CreateAlgorithm, 282 &BindAlgorithmId<CreateAlgorithm,
283 blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5>); 283 blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5>);
284 alg_to_info_["RSA-OAEP"] = 284 alg_to_info_["RSA-OAEP"] =
285 JwkAlgorithmInfo(&BindAlgorithmId<CreateRsaOaepImportAlgorithm, 285 JwkAlgorithmInfo(&BindAlgorithmId<CreateRsaOaepImportAlgorithm,
286 blink::WebCryptoAlgorithmIdSha1>); 286 blink::WebCryptoAlgorithmIdSha1>);
287 alg_to_info_["RSA-OAEP-256"] =
288 JwkAlgorithmInfo(&BindAlgorithmId<CreateRsaOaepImportAlgorithm,
289 blink::WebCryptoAlgorithmIdSha256>);
290 alg_to_info_["RSA-OAEP-384"] =
291 JwkAlgorithmInfo(&BindAlgorithmId<CreateRsaOaepImportAlgorithm,
292 blink::WebCryptoAlgorithmIdSha384>);
293 alg_to_info_["RSA-OAEP-512"] =
294 JwkAlgorithmInfo(&BindAlgorithmId<CreateRsaOaepImportAlgorithm,
295 blink::WebCryptoAlgorithmIdSha512>);
287 alg_to_info_["A128KW"] = JwkAlgorithmInfo( 296 alg_to_info_["A128KW"] = JwkAlgorithmInfo(
288 &BindAlgorithmId<CreateAlgorithm, blink::WebCryptoAlgorithmIdAesKw>, 297 &BindAlgorithmId<CreateAlgorithm, blink::WebCryptoAlgorithmIdAesKw>,
289 128); 298 128);
290 alg_to_info_["A192KW"] = JwkAlgorithmInfo( 299 alg_to_info_["A192KW"] = JwkAlgorithmInfo(
291 &BindAlgorithmId<CreateAlgorithm, blink::WebCryptoAlgorithmIdAesKw>, 300 &BindAlgorithmId<CreateAlgorithm, blink::WebCryptoAlgorithmIdAesKw>,
292 192); 301 192);
293 alg_to_info_["A256KW"] = JwkAlgorithmInfo( 302 alg_to_info_["A256KW"] = JwkAlgorithmInfo(
294 &BindAlgorithmId<CreateAlgorithm, blink::WebCryptoAlgorithmIdAesKw>, 303 &BindAlgorithmId<CreateAlgorithm, blink::WebCryptoAlgorithmIdAesKw>,
295 256); 304 256);
296 alg_to_info_["A128GCM"] = JwkAlgorithmInfo( 305 alg_to_info_["A128GCM"] = JwkAlgorithmInfo(
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 switch (algorithm.id()) { 567 switch (algorithm.id()) {
559 case blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5: 568 case blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5:
560 jwk_dict->SetString("alg", "RSA1_5"); 569 jwk_dict->SetString("alg", "RSA1_5");
561 break; 570 break;
562 default: 571 default:
563 NOTREACHED(); 572 NOTREACHED();
564 return Status::ErrorUnexpected(); 573 return Status::ErrorUnexpected();
565 } 574 }
566 break; 575 break;
567 case blink::WebCryptoKeyAlgorithmParamsTypeRsaHashed: 576 case blink::WebCryptoKeyAlgorithmParamsTypeRsaHashed:
568 switch (algorithm.rsaHashedParams()->hash().id()) { 577 switch (algorithm.id()) {
569 case blink::WebCryptoAlgorithmIdRsaOaep: 578 case blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5: {
570 jwk_dict->SetString("alg", "RSA-OAEP"); 579 switch (algorithm.rsaHashedParams()->hash().id()) {
Ryan Sleevi 2014/05/16 05:17:22 LULWUT
580 case blink::WebCryptoAlgorithmIdSha1:
581 jwk_dict->SetString("alg", "RS1");
582 break;
583 case blink::WebCryptoAlgorithmIdSha256:
584 jwk_dict->SetString("alg", "RS256");
585 break;
586 case blink::WebCryptoAlgorithmIdSha384:
587 jwk_dict->SetString("alg", "RS384");
588 break;
589 case blink::WebCryptoAlgorithmIdSha512:
590 jwk_dict->SetString("alg", "RS512");
591 break;
592 default:
593 NOTREACHED();
594 return Status::ErrorUnexpected();
595 }
571 break; 596 break;
572 case blink::WebCryptoAlgorithmIdSha1: 597 }
573 jwk_dict->SetString("alg", "RS1"); 598 case blink::WebCryptoAlgorithmIdRsaOaep: {
599 switch (algorithm.rsaHashedParams()->hash().id()) {
600 case blink::WebCryptoAlgorithmIdSha1:
601 jwk_dict->SetString("alg", "RSA-OAEP");
602 break;
603 case blink::WebCryptoAlgorithmIdSha256:
604 jwk_dict->SetString("alg", "RSA-OAEP-256");
605 break;
606 case blink::WebCryptoAlgorithmIdSha384:
607 jwk_dict->SetString("alg", "RSA-OAEP-384");
608 break;
609 case blink::WebCryptoAlgorithmIdSha512:
610 jwk_dict->SetString("alg", "RSA-OAEP-512");
611 break;
612 default:
613 NOTREACHED();
614 return Status::ErrorUnexpected();
615 }
574 break; 616 break;
575 case blink::WebCryptoAlgorithmIdSha256: 617 }
576 jwk_dict->SetString("alg", "RS256");
577 break;
578 case blink::WebCryptoAlgorithmIdSha384:
579 jwk_dict->SetString("alg", "RS384");
580 break;
581 case blink::WebCryptoAlgorithmIdSha512:
582 jwk_dict->SetString("alg", "RS512");
583 break;
584 default: 618 default:
585 NOTREACHED(); 619 NOTREACHED();
586 return Status::ErrorUnexpected(); 620 return Status::ErrorUnexpected();
587 } 621 }
588 break; 622 break;
589 default: 623 default:
590 return Status::ErrorUnsupported(); 624 return Status::ErrorUnsupported();
591 } 625 }
592 return Status::Success(); 626 return Status::Success();
593 } 627 }
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 860
827 std::string json; 861 std::string json;
828 base::JSONWriter::Write(&jwk_dict, &json); 862 base::JSONWriter::Write(&jwk_dict, &json);
829 buffer->assign(json.data(), json.data() + json.size()); 863 buffer->assign(json.data(), json.data() + json.size());
830 return Status::Success(); 864 return Status::Success();
831 } 865 }
832 866
833 } // namespace webcrypto 867 } // namespace webcrypto
834 868
835 } // namespace content 869 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/child/webcrypto/platform_crypto.h » ('j') | content/child/webcrypto/platform_crypto_nss.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698