| OLD | NEW |
| 1 // Copyright 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 // This function decodes unpadded 'base64url' encoded data, as described in | 30 // This function decodes unpadded 'base64url' encoded data, as described in |
| 31 // RFC4648 (http://www.ietf.org/rfc/rfc4648.txt) Section 5. To do this, first | 31 // RFC4648 (http://www.ietf.org/rfc/rfc4648.txt) Section 5. |
| 32 // change the incoming data to 'base64' encoding by applying the appropriate | |
| 33 // transformation including adding padding if required, and then call a base64 | |
| 34 // decoder. | |
| 35 // 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. |
| 36 bool Base64DecodeUrlSafe(const std::string& input, std::string* output); | 33 bool Base64DecodeUrlSafe(const std::string& input, std::string* output); |
| 37 | 34 |
| 38 // Returns the "hash" param for an algorithm if it exists, otherwise returns | 35 // Returns the "hash" param for an algorithm if it exists, otherwise returns |
| 39 // a null algorithm. | 36 // a null algorithm. |
| 40 blink::WebCryptoAlgorithm GetInnerHashAlgorithm( | 37 blink::WebCryptoAlgorithm GetInnerHashAlgorithm( |
| 41 const blink::WebCryptoAlgorithm& algorithm); | 38 const blink::WebCryptoAlgorithm& algorithm); |
| 42 | 39 |
| 43 // Creates a WebCryptoAlgorithm without any parameters. | 40 // Creates a WebCryptoAlgorithm without any parameters. |
| 44 CONTENT_EXPORT blink::WebCryptoAlgorithm CreateAlgorithm( | 41 CONTENT_EXPORT blink::WebCryptoAlgorithm CreateAlgorithm( |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // Creates an AES-GCM algorithm whose parameters struct is compatible with key | 95 // Creates an AES-GCM algorithm whose parameters struct is compatible with key |
| 99 // generation. | 96 // generation. |
| 100 blink::WebCryptoAlgorithm CreateAesGcmKeyGenAlgorithm( | 97 blink::WebCryptoAlgorithm CreateAesGcmKeyGenAlgorithm( |
| 101 unsigned short key_length_bits); | 98 unsigned short key_length_bits); |
| 102 | 99 |
| 103 } // namespace webcrypto | 100 } // namespace webcrypto |
| 104 | 101 |
| 105 } // namespace content | 102 } // namespace content |
| 106 | 103 |
| 107 #endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_UTIL_H_ | 104 #endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_UTIL_H_ |
| OLD | NEW |