| 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 #ifndef CONTENT_CHILD_WEBCRYPTO_JWK_H_ | 5 #ifndef CONTENT_CHILD_WEBCRYPTO_JWK_H_ |
| 6 #define CONTENT_CHILD_WEBCRYPTO_JWK_H_ | 6 #define CONTENT_CHILD_WEBCRYPTO_JWK_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 Status VerifyAlg(const std::string& expected_alg) const; | 101 Status VerifyAlg(const std::string& expected_alg) const; |
| 102 | 102 |
| 103 private: | 103 private: |
| 104 scoped_ptr<base::DictionaryValue> dict_; | 104 scoped_ptr<base::DictionaryValue> dict_; |
| 105 }; | 105 }; |
| 106 | 106 |
| 107 // Helper class for building the JSON for a JWK. | 107 // Helper class for building the JSON for a JWK. |
| 108 class JwkWriter { | 108 class JwkWriter { |
| 109 public: | 109 public: |
| 110 // Initializes a writer, and sets the standard JWK members as indicated. | 110 // Initializes a writer, and sets the standard JWK members as indicated. |
| 111 // |algorithm| is optional, and is only written if the provided |algorithm| is |
| 112 // non-empty. |
| 111 JwkWriter(const std::string& algorithm, | 113 JwkWriter(const std::string& algorithm, |
| 112 bool extractable, | 114 bool extractable, |
| 113 blink::WebCryptoKeyUsageMask usages, | 115 blink::WebCryptoKeyUsageMask usages, |
| 114 const std::string& kty); | 116 const std::string& kty); |
| 115 | 117 |
| 116 // Sets a string member |member_name| to |value|. | 118 // Sets a string member |member_name| to |value|. |
| 117 void SetString(const std::string& member_name, const std::string& value); | 119 void SetString(const std::string& member_name, const std::string& value); |
| 118 | 120 |
| 119 // Sets a bytes member |value| to |value| by base64 url-safe encoding it. | 121 // Sets a bytes member |value| to |value| by base64 url-safe encoding it. |
| 120 void SetBytes(const std::string& member_name, const CryptoData& value); | 122 void SetBytes(const std::string& member_name, const CryptoData& value); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 // Base64DecodeUrlSafe() above. | 238 // Base64DecodeUrlSafe() above. |
| 237 CONTENT_EXPORT std::string Base64EncodeUrlSafe(const base::StringPiece& input); | 239 CONTENT_EXPORT std::string Base64EncodeUrlSafe(const base::StringPiece& input); |
| 238 CONTENT_EXPORT std::string Base64EncodeUrlSafe( | 240 CONTENT_EXPORT std::string Base64EncodeUrlSafe( |
| 239 const std::vector<uint8_t>& input); | 241 const std::vector<uint8_t>& input); |
| 240 | 242 |
| 241 } // namespace webcrypto | 243 } // namespace webcrypto |
| 242 | 244 |
| 243 } // namespace content | 245 } // namespace content |
| 244 | 246 |
| 245 #endif // CONTENT_CHILD_WEBCRYPTO_JWK_H_ | 247 #endif // CONTENT_CHILD_WEBCRYPTO_JWK_H_ |
| OLD | NEW |