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

Side by Side Diff: content/child/webcrypto/shared_crypto_unittest.cc

Issue 193393002: [webcrypto] Change HMAC key generation length from bytes to bits. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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
« no previous file with comments | « content/child/webcrypto/shared_crypto.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "content/child/webcrypto/shared_crypto.h" 5 #include "content/child/webcrypto/shared_crypto.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 true, 103 true,
104 tag_length_bits)); 104 tag_length_bits));
105 } 105 }
106 106
107 // Creates an HMAC algorithm whose parameters struct is compatible with key 107 // Creates an HMAC algorithm whose parameters struct is compatible with key
108 // generation. It is an error to call this with a hash_id that is not a SHA*. 108 // generation. It is an error to call this with a hash_id that is not a SHA*.
109 // The key_length_bits parameter is optional, with zero meaning unspecified. 109 // The key_length_bits parameter is optional, with zero meaning unspecified.
110 blink::WebCryptoAlgorithm CreateHmacKeyGenAlgorithm( 110 blink::WebCryptoAlgorithm CreateHmacKeyGenAlgorithm(
111 blink::WebCryptoAlgorithmId hash_id, 111 blink::WebCryptoAlgorithmId hash_id,
112 unsigned int key_length_bits) { 112 unsigned int key_length_bits) {
113 #if !defined(WEBCRYPTO_HMAC_BITS)
114 // TODO(eroman): Delete
115 key_length_bits /= 8;
116 #endif
117 DCHECK(IsHashAlgorithm(hash_id)); 113 DCHECK(IsHashAlgorithm(hash_id));
118 // key_length_bytes == 0 means unspecified 114 // key_length_bytes == 0 means unspecified
119 return blink::WebCryptoAlgorithm::adoptParamsAndCreate( 115 return blink::WebCryptoAlgorithm::adoptParamsAndCreate(
120 blink::WebCryptoAlgorithmIdHmac, 116 blink::WebCryptoAlgorithmIdHmac,
121 new blink::WebCryptoHmacKeyGenParams( 117 new blink::WebCryptoHmacKeyGenParams(
122 CreateAlgorithm(hash_id), (key_length_bits != 0), key_length_bits)); 118 CreateAlgorithm(hash_id), (key_length_bits != 0), key_length_bits));
123 } 119 }
124 120
125 // Returns a slightly modified version of the input vector. 121 // Returns a slightly modified version of the input vector.
126 // 122 //
(...skipping 2181 matching lines...) Expand 10 before | Expand all | Expand 10 after
2308 test_cipher_text, 2304 test_cipher_text,
2309 test_authentication_tag, 2305 test_authentication_tag,
2310 &plain_text)); 2306 &plain_text));
2311 } 2307 }
2312 } 2308 }
2313 } 2309 }
2314 2310
2315 } // namespace webcrypto 2311 } // namespace webcrypto
2316 2312
2317 } // namespace content 2313 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webcrypto/shared_crypto.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698