Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1454)

Unified Diff: content/renderer/webcrypto/webcrypto_util.h

Issue 25906002: [webcrypto] Add JWK import for HMAC and AES-CBC key. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes for eroman plus more tests Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..3df692a995792cd2dd8f2bd109f3d278392c7eb0
--- /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(
+ const WebKit::WebCryptoAlgorithm& algorithm);
+
+WebKit::WebCryptoAlgorithm CreateAlgorithm(WebKit::WebCryptoAlgorithmId id);
+
+WebKit::WebCryptoAlgorithm CreateHmacAlgorithmByKeyLen(
+ unsigned short hash_key_length);
+
+WebKit::WebCryptoAlgorithm CreateHmacAlgorithmByHashId(
+ WebKit::WebCryptoAlgorithmId hash_id);
+
+WebKit::WebCryptoAlgorithm CreateHmacKeyGenAlgorithm(
+ WebKit::WebCryptoAlgorithmId hash_id,
+ unsigned hash_length);
+
+WebKit::WebCryptoAlgorithm CreateRsaEsAlgorithm();
+
+WebKit::WebCryptoAlgorithm CreateRsaSsaAlgorithmByKeyLen(
+ unsigned short hash_key_length);
+
+WebKit::WebCryptoAlgorithm CreateRsaOaepAlgorithmByKeyLen(
+ unsigned short hash_key_length);
+
+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);
+
+WebKit::WebCryptoAlgorithm CreateAesGcmKeyGenAlgorithm(unsigned short length);
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_UTIL_H_

Powered by Google App Engine
This is Rietveld 408576698