| 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> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
| 13 #include "third_party/WebKit/public/platform/WebArrayBuffer.h" | 13 #include "third_party/WebKit/public/platform/WebArrayBuffer.h" |
| 14 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" | 14 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 namespace webcrypto { | 18 namespace webcrypto { |
| 19 | 19 |
| 20 // Returns a pointer to the start of |data|, or NULL if it is empty. This is a | 20 // Returns a pointer to the start of |data|, or NULL if it is empty. This is a |
| 21 // convenience function for getting the pointer, and should not be used beyond | 21 // convenience function for getting the pointer, and should not be used beyond |
| 22 // the expected lifetime of |data|. | 22 // the expected lifetime of |data|. |
| 23 CONTENT_EXPORT const uint8* Uint8VectorStart(const std::vector<uint8>& data); | 23 CONTENT_EXPORT const uint8* Uint8VectorStart(const std::vector<uint8>& data); |
| 24 | 24 |
| 25 // Shrinks a WebArrayBuffer to a new size. | 25 // Shrinks a WebArrayBuffer to a new size. |
| 26 // TODO(eroman): This works by re-allocating a new buffer. It would be better if | 26 // TODO(eroman): This works by re-allocating a new buffer. It would be better if |
| 27 // the WebArrayBuffer could just be truncated instead. | 27 // the WebArrayBuffer could just be truncated instead. |
| 28 void ShrinkBuffer(blink::WebArrayBuffer* buffer, unsigned new_size); | 28 void ShrinkBuffer(blink::WebArrayBuffer* buffer, unsigned new_size); |
| 29 | 29 |
| 30 // Creates a WebArrayBuffer from a uint8 byte array |
| 31 blink::WebArrayBuffer CreateArrayBuffer(const uint8* data, unsigned data_size); |
| 32 |
| 30 // This function decodes unpadded 'base64url' encoded data, as described in | 33 // This function decodes unpadded 'base64url' encoded data, as described in |
| 31 // RFC4648 (http://www.ietf.org/rfc/rfc4648.txt) Section 5. | 34 // RFC4648 (http://www.ietf.org/rfc/rfc4648.txt) Section 5. |
| 32 // In Web Crypto, this type of encoding is only used inside JWK. | 35 // In Web Crypto, this type of encoding is only used inside JWK. |
| 33 bool Base64DecodeUrlSafe(const std::string& input, std::string* output); | 36 bool Base64DecodeUrlSafe(const std::string& input, std::string* output); |
| 34 | 37 |
| 35 // Returns the "hash" param for an algorithm if it exists, otherwise returns | 38 // Returns the "hash" param for an algorithm if it exists, otherwise returns |
| 36 // a null algorithm. | 39 // a null algorithm. |
| 37 blink::WebCryptoAlgorithm GetInnerHashAlgorithm( | 40 blink::WebCryptoAlgorithm GetInnerHashAlgorithm( |
| 38 const blink::WebCryptoAlgorithm& algorithm); | 41 const blink::WebCryptoAlgorithm& algorithm); |
| 39 | 42 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 // Creates an AES-GCM algorithm whose parameters struct is compatible with key | 98 // Creates an AES-GCM algorithm whose parameters struct is compatible with key |
| 96 // generation. | 99 // generation. |
| 97 blink::WebCryptoAlgorithm CreateAesGcmKeyGenAlgorithm( | 100 blink::WebCryptoAlgorithm CreateAesGcmKeyGenAlgorithm( |
| 98 unsigned short key_length_bits); | 101 unsigned short key_length_bits); |
| 99 | 102 |
| 100 } // namespace webcrypto | 103 } // namespace webcrypto |
| 101 | 104 |
| 102 } // namespace content | 105 } // namespace content |
| 103 | 106 |
| 104 #endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_UTIL_H_ | 107 #endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_UTIL_H_ |
| OLD | NEW |