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 "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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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()) { |
| 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 Loading... |
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 |
OLD | NEW |