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 <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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 } // namespace | 381 } // namespace |
382 | 382 |
383 Status ImportKeyJwk(const CryptoData& key_data, | 383 Status ImportKeyJwk(const CryptoData& key_data, |
384 const blink::WebCryptoAlgorithm& algorithm_or_null, | 384 const blink::WebCryptoAlgorithm& algorithm_or_null, |
385 bool extractable, | 385 bool extractable, |
386 blink::WebCryptoKeyUsageMask usage_mask, | 386 blink::WebCryptoKeyUsageMask usage_mask, |
387 blink::WebCryptoKey* key) { | 387 blink::WebCryptoKey* key) { |
388 // TODO(padolph): Generalize this comment to include export, and move to top | 388 // TODO(padolph): Generalize this comment to include export, and move to top |
389 // of file. | 389 // of file. |
390 | 390 |
391 // TODO(padolph): Generalize this comment to include export, and move to top | |
392 // of file. | |
393 | |
394 // The goal of this method is to extract key material and meta data from the | 391 // The goal of this method is to extract key material and meta data from the |
395 // incoming JWK, combine them with the input parameters, and ultimately import | 392 // incoming JWK, combine them with the input parameters, and ultimately import |
396 // a Web Crypto Key. | 393 // a Web Crypto Key. |
397 // | 394 // |
398 // JSON Web Key Format (JWK) | 395 // JSON Web Key Format (JWK) |
399 // http://tools.ietf.org/html/draft-ietf-jose-json-web-key-21 | 396 // http://tools.ietf.org/html/draft-ietf-jose-json-web-key-21 |
400 // | 397 // |
401 // A JWK is a simple JSON dictionary with the following entries | 398 // A JWK is a simple JSON dictionary with the following entries |
402 // - "kty" (Key Type) Parameter, REQUIRED | 399 // - "kty" (Key Type) Parameter, REQUIRED |
403 // - <kty-specific parameters, see below>, REQUIRED | 400 // - <kty-specific parameters, see below>, REQUIRED |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 std::string json; | 760 std::string json; |
764 base::JSONWriter::Write(&jwk_dict, &json); | 761 base::JSONWriter::Write(&jwk_dict, &json); |
765 *buffer = CreateArrayBuffer(reinterpret_cast<const uint8*>(json.data()), | 762 *buffer = CreateArrayBuffer(reinterpret_cast<const uint8*>(json.data()), |
766 json.size()); | 763 json.size()); |
767 return Status::Success(); | 764 return Status::Success(); |
768 } | 765 } |
769 | 766 |
770 } // namespace webcrypto | 767 } // namespace webcrypto |
771 | 768 |
772 } // namespace content | 769 } // namespace content |
OLD | NEW |