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

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

Issue 274863003: [refactor] Remove IsHashAlgorithm() function. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | « no previous file | content/child/webcrypto/webcrypto_util.h » ('j') | 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 public_exponent.size())); 119 public_exponent.size()));
120 } 120 }
121 121
122 blink::WebCryptoAlgorithm CreateRsaHashedKeyGenAlgorithm( 122 blink::WebCryptoAlgorithm CreateRsaHashedKeyGenAlgorithm(
123 blink::WebCryptoAlgorithmId algorithm_id, 123 blink::WebCryptoAlgorithmId algorithm_id,
124 const blink::WebCryptoAlgorithmId hash_id, 124 const blink::WebCryptoAlgorithmId hash_id,
125 unsigned int modulus_length, 125 unsigned int modulus_length,
126 const std::vector<uint8>& public_exponent) { 126 const std::vector<uint8>& public_exponent) {
127 DCHECK(algorithm_id == blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5 || 127 DCHECK(algorithm_id == blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5 ||
128 algorithm_id == blink::WebCryptoAlgorithmIdRsaOaep); 128 algorithm_id == blink::WebCryptoAlgorithmIdRsaOaep);
129 DCHECK(IsHashAlgorithm(hash_id)); 129 DCHECK(blink::WebCryptoAlgorithm::isHash(hash_id));
130 return blink::WebCryptoAlgorithm::adoptParamsAndCreate( 130 return blink::WebCryptoAlgorithm::adoptParamsAndCreate(
131 algorithm_id, 131 algorithm_id,
132 new blink::WebCryptoRsaHashedKeyGenParams( 132 new blink::WebCryptoRsaHashedKeyGenParams(
133 CreateAlgorithm(hash_id), 133 CreateAlgorithm(hash_id),
134 modulus_length, 134 modulus_length,
135 webcrypto::Uint8VectorStart(public_exponent), 135 webcrypto::Uint8VectorStart(public_exponent),
136 public_exponent.size())); 136 public_exponent.size()));
137 } 137 }
138 138
139 // Creates an AES-CBC algorithm. 139 // Creates an AES-CBC algorithm.
(...skipping 19 matching lines...) Expand all
159 true, 159 true,
160 tag_length_bits)); 160 tag_length_bits));
161 } 161 }
162 162
163 // Creates an HMAC algorithm whose parameters struct is compatible with key 163 // Creates an HMAC algorithm whose parameters struct is compatible with key
164 // generation. It is an error to call this with a hash_id that is not a SHA*. 164 // generation. It is an error to call this with a hash_id that is not a SHA*.
165 // The key_length_bits parameter is optional, with zero meaning unspecified. 165 // The key_length_bits parameter is optional, with zero meaning unspecified.
166 blink::WebCryptoAlgorithm CreateHmacKeyGenAlgorithm( 166 blink::WebCryptoAlgorithm CreateHmacKeyGenAlgorithm(
167 blink::WebCryptoAlgorithmId hash_id, 167 blink::WebCryptoAlgorithmId hash_id,
168 unsigned int key_length_bits) { 168 unsigned int key_length_bits) {
169 DCHECK(IsHashAlgorithm(hash_id)); 169 DCHECK(blink::WebCryptoAlgorithm::isHash(hash_id));
170 // key_length_bytes == 0 means unspecified 170 // key_length_bytes == 0 means unspecified
171 return blink::WebCryptoAlgorithm::adoptParamsAndCreate( 171 return blink::WebCryptoAlgorithm::adoptParamsAndCreate(
172 blink::WebCryptoAlgorithmIdHmac, 172 blink::WebCryptoAlgorithmIdHmac,
173 new blink::WebCryptoHmacKeyGenParams( 173 new blink::WebCryptoHmacKeyGenParams(
174 CreateAlgorithm(hash_id), (key_length_bits != 0), key_length_bits)); 174 CreateAlgorithm(hash_id), (key_length_bits != 0), key_length_bits));
175 } 175 }
176 176
177 // Returns a slightly modified version of the input vector. 177 // Returns a slightly modified version of the input vector.
178 // 178 //
179 // - For non-empty inputs a single bit is inverted. 179 // - For non-empty inputs a single bit is inverted.
(...skipping 3239 matching lines...) Expand 10 before | Expand all | Expand 10 after
3419 algorithm, 3419 algorithm,
3420 CreateAesCbcAlgorithm(std::vector<uint8>(0, 16)), 3420 CreateAesCbcAlgorithm(std::vector<uint8>(0, 16)),
3421 true, 3421 true,
3422 blink::WebCryptoKeyUsageEncrypt, 3422 blink::WebCryptoKeyUsageEncrypt,
3423 &unwrapped_key)); 3423 &unwrapped_key));
3424 } 3424 }
3425 3425
3426 } // namespace webcrypto 3426 } // namespace webcrypto
3427 3427
3428 } // namespace content 3428 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/child/webcrypto/webcrypto_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698