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 <stdint.h> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/strings/string_piece.h" | 12 #include "base/strings/string_piece.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
15 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" | 15 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" |
16 #include "third_party/WebKit/public/platform/WebCryptoKey.h" | 16 #include "third_party/WebKit/public/platform/WebCryptoKey.h" |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 | 19 |
20 namespace webcrypto { | 20 namespace webcrypto { |
21 | 21 |
22 class Status; | 22 class Status; |
23 | 23 |
24 // Returns a pointer to the start of |data|, or NULL if it is empty. This is a | |
25 // convenience function for getting the pointer, and should not be used beyond | |
26 // the expected lifetime of |data|. | |
27 CONTENT_EXPORT const uint8_t* Uint8VectorStart( | |
28 const std::vector<uint8_t>& data); | |
29 CONTENT_EXPORT uint8_t* Uint8VectorStart(std::vector<uint8_t>* data); | |
30 | |
31 // This function decodes unpadded 'base64url' encoded data, as described in | 24 // This function decodes unpadded 'base64url' encoded data, as described in |
32 // RFC4648 (http://www.ietf.org/rfc/rfc4648.txt) Section 5. | 25 // RFC4648 (http://www.ietf.org/rfc/rfc4648.txt) Section 5. |
33 // In Web Crypto, this type of encoding is only used inside JWK. | 26 // In Web Crypto, this type of encoding is only used inside JWK. |
34 CONTENT_EXPORT bool Base64DecodeUrlSafe(const std::string& input, | 27 CONTENT_EXPORT bool Base64DecodeUrlSafe(const std::string& input, |
35 std::string* output); | 28 std::string* output); |
36 | 29 |
37 // Returns an unpadded 'base64url' encoding of the input data, the opposite of | 30 // Returns an unpadded 'base64url' encoding of the input data, the opposite of |
38 // Base64DecodeUrlSafe() above. | 31 // Base64DecodeUrlSafe() above. |
39 CONTENT_EXPORT std::string Base64EncodeUrlSafe(const base::StringPiece& input); | 32 CONTENT_EXPORT std::string Base64EncodeUrlSafe(const base::StringPiece& input); |
40 CONTENT_EXPORT std::string Base64EncodeUrlSafe( | 33 CONTENT_EXPORT std::string Base64EncodeUrlSafe( |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 Status VerifyAesKeyLengthForImport(unsigned int keylen_bytes); | 85 Status VerifyAesKeyLengthForImport(unsigned int keylen_bytes); |
93 | 86 |
94 Status CheckKeyCreationUsages(blink::WebCryptoKeyUsageMask all_possible_usages, | 87 Status CheckKeyCreationUsages(blink::WebCryptoKeyUsageMask all_possible_usages, |
95 blink::WebCryptoKeyUsageMask actual_usages); | 88 blink::WebCryptoKeyUsageMask actual_usages); |
96 | 89 |
97 } // namespace webcrypto | 90 } // namespace webcrypto |
98 | 91 |
99 } // namespace content | 92 } // namespace content |
100 | 93 |
101 #endif // CONTENT_CHILD_WEBCRYPTO_WEBCRYPTO_UTIL_H_ | 94 #endif // CONTENT_CHILD_WEBCRYPTO_WEBCRYPTO_UTIL_H_ |
OLD | NEW |