OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_RENDERER_WEBCRYPTO_WEBCRYPTO_UTIL_H_ | 5 #ifndef CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_UTIL_H_ |
6 #define CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_UTIL_H_ | 6 #define CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_UTIL_H_ |
7 | 7 |
8 #include <map> | |
9 #include <string> | 8 #include <string> |
10 #include <vector> | 9 #include <vector> |
11 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
12 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
13 #include "third_party/WebKit/public/platform/WebArrayBuffer.h" | 12 #include "third_party/WebKit/public/platform/WebArrayBuffer.h" |
14 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" | 13 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" |
| 14 #include "third_party/WebKit/public/platform/WebCryptoKey.h" |
15 | 15 |
16 namespace content { | 16 namespace content { |
17 | 17 |
18 namespace webcrypto { | 18 namespace webcrypto { |
19 | 19 |
| 20 // TODO(eroman): Move Status class to a separate file |
| 21 |
20 // Status indicates whether an operation completed successfully, or with an | 22 // Status indicates whether an operation completed successfully, or with an |
21 // error. The error is used for verification in unit-tests, as well as for | 23 // error. The error is used for verification in unit-tests, as well as for |
22 // display to the user. | 24 // display to the user. |
23 // | 25 // |
24 // As such, it is important that errors DO NOT reveal any sensitive material | 26 // As such, it is important that errors DO NOT reveal any sensitive material |
25 // (like key bytes). | 27 // (like key bytes). |
26 // | 28 // |
27 // Care must be taken with what errors are reported back to blink when doing | 29 // Care must be taken with what errors are reported back to blink when doing |
28 // compound operations like unwrapping a JWK key. In this case, errors | 30 // compound operations like unwrapping a JWK key. In this case, errors |
29 // generated by the JWK import are not appropriate to report since the wrapped | 31 // generated by the JWK import are not appropriate to report since the wrapped |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 | 194 |
193 // Shrinks a WebArrayBuffer to a new size. | 195 // Shrinks a WebArrayBuffer to a new size. |
194 // TODO(eroman): This works by re-allocating a new buffer. It would be better if | 196 // TODO(eroman): This works by re-allocating a new buffer. It would be better if |
195 // the WebArrayBuffer could just be truncated instead. | 197 // the WebArrayBuffer could just be truncated instead. |
196 void ShrinkBuffer(blink::WebArrayBuffer* buffer, unsigned int new_size); | 198 void ShrinkBuffer(blink::WebArrayBuffer* buffer, unsigned int new_size); |
197 | 199 |
198 // Creates a WebArrayBuffer from a uint8 byte array | 200 // Creates a WebArrayBuffer from a uint8 byte array |
199 blink::WebArrayBuffer CreateArrayBuffer(const uint8* data, | 201 blink::WebArrayBuffer CreateArrayBuffer(const uint8* data, |
200 unsigned int data_size); | 202 unsigned int data_size); |
201 | 203 |
| 204 // TODO(eroman): Move this to JWK file. |
202 // This function decodes unpadded 'base64url' encoded data, as described in | 205 // This function decodes unpadded 'base64url' encoded data, as described in |
203 // RFC4648 (http://www.ietf.org/rfc/rfc4648.txt) Section 5. | 206 // RFC4648 (http://www.ietf.org/rfc/rfc4648.txt) Section 5. |
204 // In Web Crypto, this type of encoding is only used inside JWK. | 207 // In Web Crypto, this type of encoding is only used inside JWK. |
205 bool Base64DecodeUrlSafe(const std::string& input, std::string* output); | 208 bool Base64DecodeUrlSafe(const std::string& input, std::string* output); |
206 | 209 |
207 CONTENT_EXPORT bool IsHashAlgorithm(blink::WebCryptoAlgorithmId alg_id); | 210 CONTENT_EXPORT bool IsHashAlgorithm(blink::WebCryptoAlgorithmId alg_id); |
208 | 211 |
209 // Returns the "hash" param for an algorithm if it exists, otherwise returns | 212 // Returns the "hash" param for an algorithm if it exists, otherwise returns |
210 // a null algorithm. | 213 // a null algorithm. |
211 blink::WebCryptoAlgorithm GetInnerHashAlgorithm( | 214 blink::WebCryptoAlgorithm GetInnerHashAlgorithm( |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 uint8 tag_length_bytes); | 259 uint8 tag_length_bytes); |
257 | 260 |
258 // Returns the internal block size for SHA-* | 261 // Returns the internal block size for SHA-* |
259 unsigned int ShaBlockSizeBytes(blink::WebCryptoAlgorithmId hash_id); | 262 unsigned int ShaBlockSizeBytes(blink::WebCryptoAlgorithmId hash_id); |
260 | 263 |
261 } // namespace webcrypto | 264 } // namespace webcrypto |
262 | 265 |
263 } // namespace content | 266 } // namespace content |
264 | 267 |
265 #endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_UTIL_H_ | 268 #endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_UTIL_H_ |
OLD | NEW |