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" |
Ryan Sleevi
2014/07/18 23:02:55
stdint + linebreak
| |
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/WebCryptoAlgorithm.h" | 14 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" |
15 #include "third_party/WebKit/public/platform/WebCryptoKey.h" | 15 #include "third_party/WebKit/public/platform/WebCryptoKey.h" |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 | 18 |
19 namespace webcrypto { | 19 namespace webcrypto { |
20 | 20 |
21 class Status; | 21 class Status; |
22 | 22 |
23 // Returns a pointer to the start of |data|, or NULL if it is empty. This is a | 23 // 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 | 24 // convenience function for getting the pointer, and should not be used beyond |
25 // the expected lifetime of |data|. | 25 // the expected lifetime of |data|. |
26 CONTENT_EXPORT const uint8* Uint8VectorStart(const std::vector<uint8>& data); | 26 CONTENT_EXPORT const uint8_t* Uint8VectorStart( |
27 CONTENT_EXPORT uint8* Uint8VectorStart(std::vector<uint8>* data); | 27 const std::vector<uint8_t>& data); |
28 CONTENT_EXPORT uint8_t* Uint8VectorStart(std::vector<uint8_t>* data); | |
28 | 29 |
29 // This function decodes unpadded 'base64url' encoded data, as described in | 30 // This function decodes unpadded 'base64url' encoded data, as described in |
30 // RFC4648 (http://www.ietf.org/rfc/rfc4648.txt) Section 5. | 31 // RFC4648 (http://www.ietf.org/rfc/rfc4648.txt) Section 5. |
31 // In Web Crypto, this type of encoding is only used inside JWK. | 32 // In Web Crypto, this type of encoding is only used inside JWK. |
32 CONTENT_EXPORT bool Base64DecodeUrlSafe(const std::string& input, | 33 CONTENT_EXPORT bool Base64DecodeUrlSafe(const std::string& input, |
33 std::string* output); | 34 std::string* output); |
34 | 35 |
35 // Returns an unpadded 'base64url' encoding of the input data, the opposite of | 36 // Returns an unpadded 'base64url' encoding of the input data, the opposite of |
36 // Base64DecodeUrlSafe() above. | 37 // Base64DecodeUrlSafe() above. |
37 CONTENT_EXPORT std::string Base64EncodeUrlSafe(const base::StringPiece& input); | 38 CONTENT_EXPORT std::string Base64EncodeUrlSafe(const base::StringPiece& input); |
38 CONTENT_EXPORT std::string Base64EncodeUrlSafe(const std::vector<uint8>& input); | 39 CONTENT_EXPORT std::string Base64EncodeUrlSafe( |
40 const std::vector<uint8_t>& input); | |
39 | 41 |
40 // Composes a Web Crypto usage mask from an array of JWK key_ops values. | 42 // Composes a Web Crypto usage mask from an array of JWK key_ops values. |
41 CONTENT_EXPORT Status GetWebCryptoUsagesFromJwkKeyOps( | 43 CONTENT_EXPORT Status GetWebCryptoUsagesFromJwkKeyOps( |
42 const base::ListValue* jwk_key_ops_value, | 44 const base::ListValue* jwk_key_ops_value, |
43 blink::WebCryptoKeyUsageMask* jwk_key_ops_mask); | 45 blink::WebCryptoKeyUsageMask* jwk_key_ops_mask); |
44 | 46 |
45 // Composes a JWK key_ops array from a Web Crypto usage mask. | 47 // Composes a JWK key_ops array from a Web Crypto usage mask. |
46 base::ListValue* CreateJwkKeyOpsFromWebCryptoUsages( | 48 base::ListValue* CreateJwkKeyOpsFromWebCryptoUsages( |
47 blink::WebCryptoKeyUsageMask usage_mask); | 49 blink::WebCryptoKeyUsageMask usage_mask); |
48 | 50 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 Status VerifyAesKeyLengthForImport(unsigned int keylen_bytes); | 91 Status VerifyAesKeyLengthForImport(unsigned int keylen_bytes); |
90 | 92 |
91 Status CheckKeyCreationUsages(blink::WebCryptoKeyUsageMask all_possible_usages, | 93 Status CheckKeyCreationUsages(blink::WebCryptoKeyUsageMask all_possible_usages, |
92 blink::WebCryptoKeyUsageMask actual_usages); | 94 blink::WebCryptoKeyUsageMask actual_usages); |
93 | 95 |
94 } // namespace webcrypto | 96 } // namespace webcrypto |
95 | 97 |
96 } // namespace content | 98 } // namespace content |
97 | 99 |
98 #endif // CONTENT_CHILD_WEBCRYPTO_WEBCRYPTO_UTIL_H_ | 100 #endif // CONTENT_CHILD_WEBCRYPTO_WEBCRYPTO_UTIL_H_ |
OLD | NEW |