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

Side by Side Diff: content/renderer/webcrypto/webcrypto_util.h

Issue 178073007: [webcrypto] Update to use the KeyAlgorithm. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 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 <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "content/common/content_export.h" 11 #include "content/common/content_export.h"
12 #include "third_party/WebKit/public/platform/WebArrayBuffer.h" 12 #include "third_party/WebKit/public/platform/WebArrayBuffer.h"
13 #include "third_party/WebKit/public/platform/WebCrypto.h" // TODO(eroman):
Ryan Sleevi 2014/02/25 22:26:26 TODO?
13 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" 14 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h"
14 #include "third_party/WebKit/public/platform/WebCryptoKey.h" 15 #include "third_party/WebKit/public/platform/WebCryptoKey.h"
15 16
16 namespace content { 17 namespace content {
17 18
18 namespace webcrypto { 19 namespace webcrypto {
19 20
20 // TODO(eroman): Move Status class to a separate file 21 // TODO(eroman): Move Status class to a separate file
21 22
22 // Status indicates whether an operation completed successfully, or with an 23 // Status indicates whether an operation completed successfully, or with an
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 211
211 // Returns the "hash" param for an algorithm if it exists, otherwise returns 212 // Returns the "hash" param for an algorithm if it exists, otherwise returns
212 // a null algorithm. 213 // a null algorithm.
213 blink::WebCryptoAlgorithm GetInnerHashAlgorithm( 214 blink::WebCryptoAlgorithm GetInnerHashAlgorithm(
214 const blink::WebCryptoAlgorithm& algorithm); 215 const blink::WebCryptoAlgorithm& algorithm);
215 216
216 // Creates a WebCryptoAlgorithm without any parameters. 217 // Creates a WebCryptoAlgorithm without any parameters.
217 CONTENT_EXPORT blink::WebCryptoAlgorithm CreateAlgorithm( 218 CONTENT_EXPORT blink::WebCryptoAlgorithm CreateAlgorithm(
218 blink::WebCryptoAlgorithmId id); 219 blink::WebCryptoAlgorithmId id);
219 220
220 // Creates an HMAC algorithm whose inner hash algorithm is determined by the 221 // Creates an HMAC import algorithm whose inner hash algorithm is determined by
221 // specified algorithm ID. It is an error to call this method with a hash 222 // the specified algorithm ID. It is an error to call this method with a hash
222 // algorithm that is not SHA*. 223 // algorithm that is not SHA*.
223 CONTENT_EXPORT blink::WebCryptoAlgorithm CreateHmacAlgorithmByHashId( 224 CONTENT_EXPORT blink::WebCryptoAlgorithm CreateHmacImportAlgorithm(
224 blink::WebCryptoAlgorithmId hash_id); 225 blink::WebCryptoAlgorithmId hash_id);
225 226
226 // Creates an HMAC algorithm whose parameters struct is compatible with key
227 // generation. It is an error to call this with a hash_id that is not a SHA*.
228 // The key_length_bytes parameter is optional, with zero meaning unspecified.
229 CONTENT_EXPORT blink::WebCryptoAlgorithm CreateHmacKeyGenAlgorithm(
230 blink::WebCryptoAlgorithmId hash_id,
231 unsigned int key_length_bytes);
232
233 // Creates an RSASSA-PKCS1-v1_5 algorithm. It is an error to call this with a 227 // Creates an RSASSA-PKCS1-v1_5 algorithm. It is an error to call this with a
234 // hash_id that is not a SHA*. 228 // hash_id that is not a SHA*.
235 blink::WebCryptoAlgorithm CreateRsaSsaAlgorithm( 229 blink::WebCryptoAlgorithm CreateRsaSsaImportAlgorithm(
236 blink::WebCryptoAlgorithmId hash_id); 230 blink::WebCryptoAlgorithmId hash_id);
237 231
238 // Creates an RSA-OAEP algorithm. It is an error to call this with a hash_id 232 // Creates an RSA-OAEP algorithm. It is an error to call this with a hash_id
239 // that is not a SHA*. 233 // that is not a SHA*.
240 blink::WebCryptoAlgorithm CreateRsaOaepAlgorithm( 234 blink::WebCryptoAlgorithm CreateRsaOaepImportAlgorithm(
241 blink::WebCryptoAlgorithmId hash_id); 235 blink::WebCryptoAlgorithmId hash_id);
242 236
243 // Creates an RSA algorithm with ID algorithm_id, whose parameters struct is 237 // TODO(eroman): Move to shared_crypto.cc
244 // compatible with key generation.
245 CONTENT_EXPORT blink::WebCryptoAlgorithm CreateRsaKeyGenAlgorithm(
246 blink::WebCryptoAlgorithmId algorithm_id,
247 unsigned int modulus_length,
248 const std::vector<uint8>& public_exponent);
249
250 // Creates an AES-CBC algorithm.
251 CONTENT_EXPORT blink::WebCryptoAlgorithm CreateAesCbcAlgorithm(
252 const std::vector<uint8>& iv);
253
254 // Creates and AES-GCM algorithm.
255 blink::WebCryptoAlgorithm CreateAesGcmAlgorithm(
256 const std::vector<uint8>& iv,
257 const std::vector<uint8>& additional_data,
258 uint8 tag_length_bytes);
259
260 // Returns the internal block size for SHA-* 238 // Returns the internal block size for SHA-*
261 unsigned int ShaBlockSizeBytes(blink::WebCryptoAlgorithmId hash_id); 239 unsigned int ShaBlockSizeBytes(blink::WebCryptoAlgorithmId hash_id);
262 240
241 #ifdef WEBCRYPTO_HAS_KEY_ALGORITHM
242 bool CreateSecretKeyAlgorithm(const blink::WebCryptoAlgorithm& algorithm,
243 unsigned keylen_bytes,
244 blink::WebCryptoKeyAlgorithm* key_algorithm);
245 #else
246 bool CreateSecretKeyAlgorithm(const blink::WebCryptoAlgorithm& algorithm,
247 unsigned keylen_bytes,
248 blink::WebCryptoAlgorithm* key_algorithm);
249 #endif
250
263 } // namespace webcrypto 251 } // namespace webcrypto
264 252
265 } // namespace content 253 } // namespace content
266 254
267 #endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_UTIL_H_ 255 #endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698