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

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

Issue 202863004: Fix "unreachable code" warnings (MSVC warning 4702) in content/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 | Annotate | Revision Log
« no previous file with comments | « content/child/npapi/webplugin_delegate_impl.cc ('k') | content/common/content_paths.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 5 #include <algorithm>
6 #include <functional> 6 #include <functional>
7 #include <map> 7 #include <map>
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 algorithm_info->IsInvalidKeyByteLength(jwk_k_value.size())) { 695 algorithm_info->IsInvalidKeyByteLength(jwk_k_value.size())) {
696 return Status::ErrorJwkIncorrectKeyLength(); 696 return Status::ErrorJwkIncorrectKeyLength();
697 } 697 }
698 698
699 return ImportKey(blink::WebCryptoKeyFormatRaw, 699 return ImportKey(blink::WebCryptoKeyFormatRaw,
700 CryptoData(jwk_k_value), 700 CryptoData(jwk_k_value),
701 algorithm, 701 algorithm,
702 extractable, 702 extractable,
703 usage_mask, 703 usage_mask,
704 key); 704 key);
705 } else if (jwk_kty_value == "RSA") { 705 }
706 if (jwk_kty_value == "RSA") {
706 // An RSA public key must have an "n" (modulus) and an "e" (exponent) entry 707 // An RSA public key must have an "n" (modulus) and an "e" (exponent) entry
707 // in the JWK, while an RSA private key must have those, plus at least a "d" 708 // in the JWK, while an RSA private key must have those, plus at least a "d"
708 // (private exponent) entry. 709 // (private exponent) entry.
709 // See http://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-18, 710 // See http://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-18,
710 // section 6.3. 711 // section 6.3.
711 712
712 // RSA private key import is not currently supported, so fail here if a "d" 713 // RSA private key import is not currently supported, so fail here if a "d"
713 // entry is found. 714 // entry is found.
714 // TODO(padolph): Support RSA private key import. 715 // TODO(padolph): Support RSA private key import.
715 if (dict_value->HasKey("d")) 716 if (dict_value->HasKey("d"))
716 return Status::ErrorJwkRsaPrivateKeyUnsupported(); 717 return Status::ErrorJwkRsaPrivateKeyUnsupported();
717 718
718 std::string jwk_n_value; 719 std::string jwk_n_value;
719 status = GetJwkBytes(dict_value, "n", &jwk_n_value); 720 status = GetJwkBytes(dict_value, "n", &jwk_n_value);
720 if (status.IsError()) 721 if (status.IsError())
721 return status; 722 return status;
722 std::string jwk_e_value; 723 std::string jwk_e_value;
723 status = GetJwkBytes(dict_value, "e", &jwk_e_value); 724 status = GetJwkBytes(dict_value, "e", &jwk_e_value);
724 if (status.IsError()) 725 if (status.IsError())
725 return status; 726 return status;
726 727
727 return platform::ImportRsaPublicKey(algorithm, 728 return platform::ImportRsaPublicKey(algorithm,
728 extractable, 729 extractable,
729 usage_mask, 730 usage_mask,
730 CryptoData(jwk_n_value), 731 CryptoData(jwk_n_value),
731 CryptoData(jwk_e_value), 732 CryptoData(jwk_e_value),
732 key); 733 key);
733 734
734 } else {
735 return Status::ErrorJwkUnrecognizedKty();
736 } 735 }
737 736
738 return Status::Success(); 737 return Status::ErrorJwkUnrecognizedKty();
739 } 738 }
740 739
741 Status ExportKeyJwk(const blink::WebCryptoKey& key, 740 Status ExportKeyJwk(const blink::WebCryptoKey& key,
742 blink::WebArrayBuffer* buffer) { 741 blink::WebArrayBuffer* buffer) {
743 base::DictionaryValue jwk_dict; 742 base::DictionaryValue jwk_dict;
744 Status status = Status::Error(); 743 Status status = Status::Error();
745 blink::WebArrayBuffer exported_key; 744 blink::WebArrayBuffer exported_key;
746 745
747 if (key.type() == blink::WebCryptoKeyTypeSecret) { 746 if (key.type() == blink::WebCryptoKeyTypeSecret) {
748 status = ExportKey(blink::WebCryptoKeyFormatRaw, key, &exported_key); 747 status = ExportKey(blink::WebCryptoKeyFormatRaw, key, &exported_key);
(...skipping 14 matching lines...) Expand all
763 std::string json; 762 std::string json;
764 base::JSONWriter::Write(&jwk_dict, &json); 763 base::JSONWriter::Write(&jwk_dict, &json);
765 *buffer = CreateArrayBuffer(reinterpret_cast<const uint8*>(json.data()), 764 *buffer = CreateArrayBuffer(reinterpret_cast<const uint8*>(json.data()),
766 json.size()); 765 json.size());
767 return Status::Success(); 766 return Status::Success();
768 } 767 }
769 768
770 } // namespace webcrypto 769 } // namespace webcrypto
771 770
772 } // namespace content 771 } // namespace content
OLDNEW
« no previous file with comments | « content/child/npapi/webplugin_delegate_impl.cc ('k') | content/common/content_paths.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698