OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_UTIL_H_ |
| 6 #define CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_UTIL_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <string> |
| 10 #include <vector> |
| 11 #include "base/basictypes.h" |
| 12 #include "third_party/WebKit/public/platform/WebArrayBuffer.h" |
| 13 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" |
| 14 |
| 15 namespace content { |
| 16 |
| 17 // Returns a pointer to the start of |data|, or NULL if it is empty. This is a |
| 18 // convenience function for getting the pointer, and should not be used beyond |
| 19 // the expected lifetime of |data|. |
| 20 const uint8* Start(const std::vector<uint8>& data); |
| 21 |
| 22 // Shrinks a WebArrayBuffer to a new size. |
| 23 // TODO(eroman): This works by re-allocating a new buffer. It would be better if |
| 24 // the WebArrayBuffer could just be truncated instead. |
| 25 void ShrinkBuffer(WebKit::WebArrayBuffer* buffer, unsigned new_size); |
| 26 |
| 27 // This function decodes unpadded 'base64url' encoded data, as described in |
| 28 // RFC4648 (http://www.ietf.org/rfc/rfc4648.txt) Section 5. To do this, first |
| 29 // change the incoming data to 'base64' encoding by applying the appropriate |
| 30 // transformation including adding padding if required, and then call a base64 |
| 31 // decoder. |
| 32 // In Web Crypto, this type of encoding is only used inside JWK. |
| 33 bool Base64DecodeUrlSafe(const std::string& input, std::string* output); |
| 34 |
| 35 WebKit::WebCryptoAlgorithm GetInnerHashAlgorithm( |
| 36 const WebKit::WebCryptoAlgorithm& algorithm); |
| 37 |
| 38 WebKit::WebCryptoAlgorithm CreateAlgorithm(WebKit::WebCryptoAlgorithmId id); |
| 39 |
| 40 WebKit::WebCryptoAlgorithm CreateHmacAlgorithmByKeyLen( |
| 41 unsigned short hash_key_length); |
| 42 |
| 43 WebKit::WebCryptoAlgorithm CreateHmacAlgorithmByHashId( |
| 44 WebKit::WebCryptoAlgorithmId hash_id); |
| 45 |
| 46 WebKit::WebCryptoAlgorithm CreateHmacKeyGenAlgorithm( |
| 47 WebKit::WebCryptoAlgorithmId hash_id, |
| 48 unsigned hash_length); |
| 49 |
| 50 WebKit::WebCryptoAlgorithm CreateRsaEsAlgorithm(); |
| 51 |
| 52 WebKit::WebCryptoAlgorithm CreateRsaSsaAlgorithmByKeyLen( |
| 53 unsigned short hash_key_length); |
| 54 |
| 55 WebKit::WebCryptoAlgorithm CreateRsaOaepAlgorithmByKeyLen( |
| 56 unsigned short hash_key_length); |
| 57 |
| 58 WebKit::WebCryptoAlgorithm CreateAesCbcAlgorithm(const std::vector<uint8>& iv); |
| 59 |
| 60 WebKit::WebCryptoAlgorithm CreateAesGcmAlgorithm(const std::vector<uint8>& iv, |
| 61 const std::vector<uint8>& additional_data, unsigned char tag_length); |
| 62 |
| 63 WebKit::WebCryptoAlgorithm CreateAesCbcKeyGenAlgorithm(unsigned short length); |
| 64 |
| 65 WebKit::WebCryptoAlgorithm CreateAesGcmKeyGenAlgorithm(unsigned short length); |
| 66 |
| 67 } // namespace content |
| 68 |
| 69 #endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_UTIL_H_ |
OLD | NEW |