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