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

Side by Side 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: removed JWK AES alg key length validation, replaced with TODO Created 7 years, 1 month 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 unified diff | Download patch
OLDNEW
(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(
eroman 2013/11/07 20:54:37 Can you add a comment similar to: // Returns the
padolph 2013/11/09 00:33:38 Done.
36 const WebKit::WebCryptoAlgorithm& algorithm);
37
38 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.
39
40 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.
41 unsigned short digest_length_bits);
42
43 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.
44 WebKit::WebCryptoAlgorithmId hash_id);
45
46 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.
47 WebKit::WebCryptoAlgorithmId hash_id,
48 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.
49
50 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.
51 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.
52
53 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.
54 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.
55
56 WebKit::WebCryptoAlgorithm CreateAesCbcAlgorithm(const std::vector<uint8>& iv);
57
58 WebKit::WebCryptoAlgorithm CreateAesGcmAlgorithm(
59 const std::vector<uint8>& iv,
60 const std::vector<uint8>& additional_data,
61 unsigned char tag_length);
62
63 WebKit::WebCryptoAlgorithm CreateAesCbcKeyGenAlgorithm(unsigned short length);
eroman 2013/11/07 20:54:37 would be good to name parameter length_bits or key
64
65 WebKit::WebCryptoAlgorithm CreateAesGcmKeyGenAlgorithm(unsigned short length);
eroman 2013/11/07 20:54:37 ditto.
66
67 } // namespace content
68
69 #endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698