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

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
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/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 algorithm_info->IsInvalidKeyByteLength(jwk_k_value.size())) { 505 algorithm_info->IsInvalidKeyByteLength(jwk_k_value.size())) {
506 return Status::ErrorJwkIncorrectKeyLength(); 506 return Status::ErrorJwkIncorrectKeyLength();
507 } 507 }
508 508
509 return ImportKey(blink::WebCryptoKeyFormatRaw, 509 return ImportKey(blink::WebCryptoKeyFormatRaw,
510 CryptoData(jwk_k_value), 510 CryptoData(jwk_k_value),
511 algorithm, 511 algorithm,
512 extractable, 512 extractable,
513 usage_mask, 513 usage_mask,
514 key); 514 key);
515 } else if (jwk_kty_value == "RSA") { 515 }
516 516
517 if (jwk_kty_value == "RSA") {
517 // An RSA public key must have an "n" (modulus) and an "e" (exponent) entry 518 // An RSA public key must have an "n" (modulus) and an "e" (exponent) entry
518 // in the JWK, while an RSA private key must have those, plus at least a "d" 519 // in the JWK, while an RSA private key must have those, plus at least a "d"
519 // (private exponent) entry. 520 // (private exponent) entry.
520 // See http://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-18, 521 // See http://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-18,
521 // section 6.3. 522 // section 6.3.
522 523
523 // RSA private key import is not currently supported, so fail here if a "d" 524 // RSA private key import is not currently supported, so fail here if a "d"
524 // entry is found. 525 // entry is found.
525 // TODO(padolph): Support RSA private key import. 526 // TODO(padolph): Support RSA private key import.
526 if (dict_value->HasKey("d")) 527 if (dict_value->HasKey("d"))
527 return Status::ErrorJwkRsaPrivateKeyUnsupported(); 528 return Status::ErrorJwkRsaPrivateKeyUnsupported();
528 529
529 std::string jwk_n_value; 530 std::string jwk_n_value;
530 status = GetJwkBytes(dict_value, "n", &jwk_n_value); 531 status = GetJwkBytes(dict_value, "n", &jwk_n_value);
531 if (status.IsError()) 532 if (status.IsError())
532 return status; 533 return status;
533 std::string jwk_e_value; 534 std::string jwk_e_value;
534 status = GetJwkBytes(dict_value, "e", &jwk_e_value); 535 status = GetJwkBytes(dict_value, "e", &jwk_e_value);
535 if (status.IsError()) 536 if (status.IsError())
536 return status; 537 return status;
537 538
538 return platform::ImportRsaPublicKey(algorithm, 539 return platform::ImportRsaPublicKey(algorithm,
539 extractable, 540 extractable,
540 usage_mask, 541 usage_mask,
541 CryptoData(jwk_n_value), 542 CryptoData(jwk_n_value),
542 CryptoData(jwk_e_value), 543 CryptoData(jwk_e_value),
543 key); 544 key);
544 545
545 } else {
546 return Status::ErrorJwkUnrecognizedKty();
547 } 546 }
548 547
549 return Status::Success(); 548 return Status::ErrorJwkUnrecognizedKty();
550 } 549 }
551 550
552 } // namespace webcrypto 551 } // namespace webcrypto
553 552
554 } // namespace content 553 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698