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

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

Issue 698363002: webcrypto: Add ECDSA algorithm (chromium-side) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@extract_more
Patch Set: sigh, more android pedantry Created 6 years, 1 month 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
« no previous file with comments | « content/child/webcrypto/jwk.h ('k') | content/child/webcrypto/nss/util_nss.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 "content/child/webcrypto/jwk.h" 5 #include "content/child/webcrypto/jwk.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
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/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 if (has_jwk_alg && jwk_alg_value != expected_alg) 441 if (has_jwk_alg && jwk_alg_value != expected_alg)
442 return Status::ErrorJwkAlgorithmInconsistent(); 442 return Status::ErrorJwkAlgorithmInconsistent();
443 443
444 return Status::Success(); 444 return Status::Success();
445 } 445 }
446 446
447 JwkWriter::JwkWriter(const std::string& algorithm, 447 JwkWriter::JwkWriter(const std::string& algorithm,
448 bool extractable, 448 bool extractable,
449 blink::WebCryptoKeyUsageMask usages, 449 blink::WebCryptoKeyUsageMask usages,
450 const std::string& kty) { 450 const std::string& kty) {
451 dict_.SetString("alg", algorithm); 451 if (!algorithm.empty())
452 dict_.SetString("alg", algorithm);
452 dict_.Set("key_ops", CreateJwkKeyOpsFromWebCryptoUsages(usages)); 453 dict_.Set("key_ops", CreateJwkKeyOpsFromWebCryptoUsages(usages));
453 dict_.SetBoolean("ext", extractable); 454 dict_.SetBoolean("ext", extractable);
454 dict_.SetString("kty", kty); 455 dict_.SetString("kty", kty);
455 } 456 }
456 457
457 void JwkWriter::SetString(const std::string& member_name, 458 void JwkWriter::SetString(const std::string& member_name,
458 const std::string& value) { 459 const std::string& value) {
459 dict_.SetString(member_name, value); 460 dict_.SetString(member_name, value);
460 } 461 }
461 462
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 703
703 std::string Base64EncodeUrlSafe(const std::vector<uint8_t>& input) { 704 std::string Base64EncodeUrlSafe(const std::vector<uint8_t>& input) {
704 const base::StringPiece string_piece( 705 const base::StringPiece string_piece(
705 reinterpret_cast<const char*>(vector_as_array(&input)), input.size()); 706 reinterpret_cast<const char*>(vector_as_array(&input)), input.size());
706 return Base64EncodeUrlSafe(string_piece); 707 return Base64EncodeUrlSafe(string_piece);
707 } 708 }
708 709
709 } // namespace webcrypto 710 } // namespace webcrypto
710 711
711 } // namespace content 712 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webcrypto/jwk.h ('k') | content/child/webcrypto/nss/util_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698