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_WEBCRYPTO_UTIL_H_ | 5 #ifndef CONTENT_CHILD_WEBCRYPTO_WEBCRYPTO_UTIL_H_ |
6 #define CONTENT_CHILD_WEBCRYPTO_WEBCRYPTO_UTIL_H_ | 6 #define CONTENT_CHILD_WEBCRYPTO_WEBCRYPTO_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/strings/string_piece.h" | 11 #include "base/strings/string_piece.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 14 #include "third_party/WebKit/public/platform/WebArrayBuffer.h" |
14 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" | 15 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" |
15 #include "third_party/WebKit/public/platform/WebCryptoKey.h" | 16 #include "third_party/WebKit/public/platform/WebCryptoKey.h" |
16 | 17 |
17 namespace content { | 18 namespace content { |
18 | 19 |
19 namespace webcrypto { | 20 namespace webcrypto { |
20 | 21 |
21 class Status; | 22 class Status; |
22 | 23 |
23 // Returns a pointer to the start of |data|, or NULL if it is empty. This is a | 24 // Returns a pointer to the start of |data|, or NULL if it is empty. This is a |
24 // convenience function for getting the pointer, and should not be used beyond | 25 // convenience function for getting the pointer, and should not be used beyond |
25 // the expected lifetime of |data|. | 26 // the expected lifetime of |data|. |
26 CONTENT_EXPORT const uint8* Uint8VectorStart(const std::vector<uint8>& data); | 27 CONTENT_EXPORT const uint8* Uint8VectorStart(const std::vector<uint8>& data); |
27 CONTENT_EXPORT uint8* Uint8VectorStart(std::vector<uint8>* data); | 28 |
| 29 // Shrinks a WebArrayBuffer to a new size. |
| 30 // TODO(eroman): This works by re-allocating a new buffer. It would be better if |
| 31 // the WebArrayBuffer could just be truncated instead. |
| 32 void ShrinkBuffer(blink::WebArrayBuffer* buffer, unsigned int new_size); |
| 33 |
| 34 // Creates a WebArrayBuffer from a uint8 byte array |
| 35 blink::WebArrayBuffer CreateArrayBuffer(const uint8* data, |
| 36 unsigned int data_size); |
28 | 37 |
29 // This function decodes unpadded 'base64url' encoded data, as described in | 38 // This function decodes unpadded 'base64url' encoded data, as described in |
30 // RFC4648 (http://www.ietf.org/rfc/rfc4648.txt) Section 5. | 39 // RFC4648 (http://www.ietf.org/rfc/rfc4648.txt) Section 5. |
31 // In Web Crypto, this type of encoding is only used inside JWK. | 40 // In Web Crypto, this type of encoding is only used inside JWK. |
32 CONTENT_EXPORT bool Base64DecodeUrlSafe(const std::string& input, | 41 CONTENT_EXPORT bool Base64DecodeUrlSafe(const std::string& input, |
33 std::string* output); | 42 std::string* output); |
34 | 43 |
35 // Returns an unpadded 'base64url' encoding of the input data, the opposite of | 44 // Returns an unpadded 'base64url' encoding of the input data, the opposite of |
36 // Base64DecodeUrlSafe() above. | 45 // Base64DecodeUrlSafe() above. |
37 std::string Base64EncodeUrlSafe(const base::StringPiece& input); | 46 std::string Base64EncodeUrlSafe(const base::StringPiece& input); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 80 |
72 bool CreateSecretKeyAlgorithm(const blink::WebCryptoAlgorithm& algorithm, | 81 bool CreateSecretKeyAlgorithm(const blink::WebCryptoAlgorithm& algorithm, |
73 unsigned int keylen_bytes, | 82 unsigned int keylen_bytes, |
74 blink::WebCryptoKeyAlgorithm* key_algorithm); | 83 blink::WebCryptoKeyAlgorithm* key_algorithm); |
75 | 84 |
76 } // namespace webcrypto | 85 } // namespace webcrypto |
77 | 86 |
78 } // namespace content | 87 } // namespace content |
79 | 88 |
80 #endif // CONTENT_CHILD_WEBCRYPTO_WEBCRYPTO_UTIL_H_ | 89 #endif // CONTENT_CHILD_WEBCRYPTO_WEBCRYPTO_UTIL_H_ |
OLD | NEW |