Chromium Code Reviews| Index: content/renderer/webcrypto/webcrypto_util.h |
| diff --git a/content/renderer/webcrypto/webcrypto_util.h b/content/renderer/webcrypto/webcrypto_util.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7bb79db5586c26c2929567f1624adf355625c17e |
| --- /dev/null |
| +++ b/content/renderer/webcrypto/webcrypto_util.h |
| @@ -0,0 +1,69 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_UTIL_H_ |
| +#define CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_UTIL_H_ |
| + |
| +#include <map> |
| +#include <string> |
| +#include <vector> |
| +#include "base/basictypes.h" |
| +#include "third_party/WebKit/public/platform/WebArrayBuffer.h" |
| +#include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" |
| + |
| +namespace content { |
| + |
| +// Returns a pointer to the start of |data|, or NULL if it is empty. This is a |
| +// convenience function for getting the pointer, and should not be used beyond |
| +// the expected lifetime of |data|. |
| +const uint8* Start(const std::vector<uint8>& data); |
| + |
| +// Shrinks a WebArrayBuffer to a new size. |
| +// TODO(eroman): This works by re-allocating a new buffer. It would be better if |
| +// the WebArrayBuffer could just be truncated instead. |
| +void ShrinkBuffer(WebKit::WebArrayBuffer* buffer, unsigned new_size); |
| + |
| +// This function decodes unpadded 'base64url' encoded data, as described in |
| +// RFC4648 (http://www.ietf.org/rfc/rfc4648.txt) Section 5. To do this, first |
| +// change the incoming data to 'base64' encoding by applying the appropriate |
| +// transformation including adding padding if required, and then call a base64 |
| +// decoder. |
| +// In Web Crypto, this type of encoding is only used inside JWK. |
| +bool Base64DecodeUrlSafe(const std::string& input, std::string* output); |
| + |
| +WebKit::WebCryptoAlgorithm GetInnerHashAlgorithm( |
|
eroman
2013/11/07 20:54:37
Can you add a comment similar to:
// Returns the
padolph
2013/11/09 00:33:38
Done.
|
| + const WebKit::WebCryptoAlgorithm& algorithm); |
| + |
| +WebKit::WebCryptoAlgorithm CreateAlgorithm(WebKit::WebCryptoAlgorithmId id); |
|
eroman
2013/11/07 20:54:37
// Creates a WebCryptoAlgorithm without any parame
padolph
2013/11/09 00:33:38
Done.
|
| + |
| +WebKit::WebCryptoAlgorithm CreateHmacAlgorithmByDigestLen( |
|
eroman
2013/11/07 20:54:37
// It is an error to call this with an unsupported
padolph
2013/11/09 00:33:38
Done.
|
| + unsigned short digest_length_bits); |
| + |
| +WebKit::WebCryptoAlgorithm CreateHmacAlgorithmByHashId( |
|
eroman
2013/11/07 20:54:37
// It is an error to call this with a hash_id that
padolph
2013/11/09 00:33:38
Done.
|
| + WebKit::WebCryptoAlgorithmId hash_id); |
| + |
| +WebKit::WebCryptoAlgorithm CreateHmacKeyGenAlgorithm( |
|
eroman
2013/11/07 20:54:37
// It is an error to call this with a hash_id that
padolph
2013/11/09 00:33:38
Done.
|
| + WebKit::WebCryptoAlgorithmId hash_id, |
| + unsigned hash_length); |
|
eroman
2013/11/07 20:54:37
IMPORTANT: this parameter should be named key_leng
padolph
2013/11/09 00:33:38
Done.
|
| + |
| +WebKit::WebCryptoAlgorithm CreateRsaSsaAlgorithm( |
|
eroman
2013/11/07 20:54:37
// It is an error to call this with a hash_id that
padolph
2013/11/09 00:33:38
Done.
|
| + WebKit::WebCryptoAlgorithmId hash_algorithm_id); |
|
eroman
2013/11/07 20:54:37
nit: elsewhere this is called hash_id
padolph
2013/11/09 00:33:38
Done.
|
| + |
| +WebKit::WebCryptoAlgorithm CreateRsaOaepAlgorithm( |
|
eroman
2013/11/07 20:54:37
// It is an error to call this with a hash_id that
padolph
2013/11/09 00:33:38
Done.
|
| + WebKit::WebCryptoAlgorithmId hash_algorithm_id); |
|
eroman
2013/11/07 20:54:37
nit: elsewhere this is called hash_id
padolph
2013/11/09 00:33:38
Done.
|
| + |
| +WebKit::WebCryptoAlgorithm CreateAesCbcAlgorithm(const std::vector<uint8>& iv); |
| + |
| +WebKit::WebCryptoAlgorithm CreateAesGcmAlgorithm( |
| + const std::vector<uint8>& iv, |
| + const std::vector<uint8>& additional_data, |
| + unsigned char tag_length); |
| + |
| +WebKit::WebCryptoAlgorithm CreateAesCbcKeyGenAlgorithm(unsigned short length); |
|
eroman
2013/11/07 20:54:37
would be good to name parameter length_bits or key
|
| + |
| +WebKit::WebCryptoAlgorithm CreateAesGcmKeyGenAlgorithm(unsigned short length); |
|
eroman
2013/11/07 20:54:37
ditto.
|
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_UTIL_H_ |