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 "components/webcrypto/jwk.h" | 5 #include "components/webcrypto/jwk.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 | 362 |
363 void JwkWriter::SetBytes(const std::string& member_name, | 363 void JwkWriter::SetBytes(const std::string& member_name, |
364 const CryptoData& value) { | 364 const CryptoData& value) { |
365 dict_.SetString(member_name, Base64EncodeUrlSafe(base::StringPiece( | 365 dict_.SetString(member_name, Base64EncodeUrlSafe(base::StringPiece( |
366 reinterpret_cast<const char*>(value.bytes()), | 366 reinterpret_cast<const char*>(value.bytes()), |
367 value.byte_length()))); | 367 value.byte_length()))); |
368 } | 368 } |
369 | 369 |
370 void JwkWriter::ToJson(std::vector<uint8_t>* utf8_bytes) const { | 370 void JwkWriter::ToJson(std::vector<uint8_t>* utf8_bytes) const { |
371 std::string json; | 371 std::string json; |
372 base::JSONWriter::Write(&dict_, &json); | 372 base::JSONWriter::Write(dict_, &json); |
373 utf8_bytes->assign(json.begin(), json.end()); | 373 utf8_bytes->assign(json.begin(), json.end()); |
374 } | 374 } |
375 | 375 |
376 Status ReadSecretKeyNoExpectedAlg(const CryptoData& key_data, | 376 Status ReadSecretKeyNoExpectedAlg(const CryptoData& key_data, |
377 bool expected_extractable, | 377 bool expected_extractable, |
378 blink::WebCryptoKeyUsageMask expected_usages, | 378 blink::WebCryptoKeyUsageMask expected_usages, |
379 std::vector<uint8_t>* raw_key_data, | 379 std::vector<uint8_t>* raw_key_data, |
380 JwkReader* jwk) { | 380 JwkReader* jwk) { |
381 Status status = jwk->Init(key_data, expected_extractable, expected_usages, | 381 Status status = jwk->Init(key_data, expected_extractable, expected_usages, |
382 "oct", std::string()); | 382 "oct", std::string()); |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 return Base64EncodeUrlSafe(string_piece); | 609 return Base64EncodeUrlSafe(string_piece); |
610 } | 610 } |
611 | 611 |
612 Status GetWebCryptoUsagesFromJwkKeyOpsForTest( | 612 Status GetWebCryptoUsagesFromJwkKeyOpsForTest( |
613 const base::ListValue* key_ops, | 613 const base::ListValue* key_ops, |
614 blink::WebCryptoKeyUsageMask* usages) { | 614 blink::WebCryptoKeyUsageMask* usages) { |
615 return GetWebCryptoUsagesFromJwkKeyOps(key_ops, usages); | 615 return GetWebCryptoUsagesFromJwkKeyOps(key_ops, usages); |
616 } | 616 } |
617 | 617 |
618 } // namespace webcrypto | 618 } // namespace webcrypto |
OLD | NEW |