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 <stdint.h> |
8 #include <string> | 9 #include <string> |
9 #include <vector> | 10 #include <vector> |
10 #include "base/basictypes.h" | 11 |
11 #include "base/strings/string_piece.h" | 12 #include "base/strings/string_piece.h" |
12 #include "base/values.h" | 13 #include "base/values.h" |
13 #include "content/common/content_export.h" | 14 #include "content/common/content_export.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_t* Uint8VectorStart( |
27 CONTENT_EXPORT uint8* Uint8VectorStart(std::vector<uint8>* data); | 28 const std::vector<uint8_t>& data); |
| 29 CONTENT_EXPORT uint8_t* Uint8VectorStart(std::vector<uint8_t>* data); |
28 | 30 |
29 // This function decodes unpadded 'base64url' encoded data, as described in | 31 // This function decodes unpadded 'base64url' encoded data, as described in |
30 // RFC4648 (http://www.ietf.org/rfc/rfc4648.txt) Section 5. | 32 // RFC4648 (http://www.ietf.org/rfc/rfc4648.txt) Section 5. |
31 // In Web Crypto, this type of encoding is only used inside JWK. | 33 // In Web Crypto, this type of encoding is only used inside JWK. |
32 CONTENT_EXPORT bool Base64DecodeUrlSafe(const std::string& input, | 34 CONTENT_EXPORT bool Base64DecodeUrlSafe(const std::string& input, |
33 std::string* output); | 35 std::string* output); |
34 | 36 |
35 // Returns an unpadded 'base64url' encoding of the input data, the opposite of | 37 // Returns an unpadded 'base64url' encoding of the input data, the opposite of |
36 // Base64DecodeUrlSafe() above. | 38 // Base64DecodeUrlSafe() above. |
37 CONTENT_EXPORT std::string Base64EncodeUrlSafe(const base::StringPiece& input); | 39 CONTENT_EXPORT std::string Base64EncodeUrlSafe(const base::StringPiece& input); |
38 CONTENT_EXPORT std::string Base64EncodeUrlSafe(const std::vector<uint8>& input); | 40 CONTENT_EXPORT std::string Base64EncodeUrlSafe( |
| 41 const std::vector<uint8_t>& input); |
39 | 42 |
40 // Composes a Web Crypto usage mask from an array of JWK key_ops values. | 43 // Composes a Web Crypto usage mask from an array of JWK key_ops values. |
41 CONTENT_EXPORT Status GetWebCryptoUsagesFromJwkKeyOps( | 44 CONTENT_EXPORT Status GetWebCryptoUsagesFromJwkKeyOps( |
42 const base::ListValue* jwk_key_ops_value, | 45 const base::ListValue* jwk_key_ops_value, |
43 blink::WebCryptoKeyUsageMask* jwk_key_ops_mask); | 46 blink::WebCryptoKeyUsageMask* jwk_key_ops_mask); |
44 | 47 |
45 // Composes a JWK key_ops array from a Web Crypto usage mask. | 48 // Composes a JWK key_ops array from a Web Crypto usage mask. |
46 base::ListValue* CreateJwkKeyOpsFromWebCryptoUsages( | 49 base::ListValue* CreateJwkKeyOpsFromWebCryptoUsages( |
47 blink::WebCryptoKeyUsageMask usage_mask); | 50 blink::WebCryptoKeyUsageMask usage_mask); |
48 | 51 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 Status VerifyAesKeyLengthForImport(unsigned int keylen_bytes); | 92 Status VerifyAesKeyLengthForImport(unsigned int keylen_bytes); |
90 | 93 |
91 Status CheckKeyCreationUsages(blink::WebCryptoKeyUsageMask all_possible_usages, | 94 Status CheckKeyCreationUsages(blink::WebCryptoKeyUsageMask all_possible_usages, |
92 blink::WebCryptoKeyUsageMask actual_usages); | 95 blink::WebCryptoKeyUsageMask actual_usages); |
93 | 96 |
94 } // namespace webcrypto | 97 } // namespace webcrypto |
95 | 98 |
96 } // namespace content | 99 } // namespace content |
97 | 100 |
98 #endif // CONTENT_CHILD_WEBCRYPTO_WEBCRYPTO_UTIL_H_ | 101 #endif // CONTENT_CHILD_WEBCRYPTO_WEBCRYPTO_UTIL_H_ |
OLD | NEW |