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

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

Issue 147573002: [style] Consistently use "unsigned int" rather than just "unsigned". (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase 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 <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 }; 176 };
177 177
178 // Returns a pointer to the start of |data|, or NULL if it is empty. This is a 178 // Returns a pointer to the start of |data|, or NULL if it is empty. This is a
179 // convenience function for getting the pointer, and should not be used beyond 179 // convenience function for getting the pointer, and should not be used beyond
180 // the expected lifetime of |data|. 180 // the expected lifetime of |data|.
181 CONTENT_EXPORT const uint8* Uint8VectorStart(const std::vector<uint8>& data); 181 CONTENT_EXPORT const uint8* Uint8VectorStart(const std::vector<uint8>& data);
182 182
183 // Shrinks a WebArrayBuffer to a new size. 183 // Shrinks a WebArrayBuffer to a new size.
184 // TODO(eroman): This works by re-allocating a new buffer. It would be better if 184 // TODO(eroman): This works by re-allocating a new buffer. It would be better if
185 // the WebArrayBuffer could just be truncated instead. 185 // the WebArrayBuffer could just be truncated instead.
186 void ShrinkBuffer(blink::WebArrayBuffer* buffer, unsigned new_size); 186 void ShrinkBuffer(blink::WebArrayBuffer* buffer, unsigned int new_size);
187 187
188 // Creates a WebArrayBuffer from a uint8 byte array 188 // Creates a WebArrayBuffer from a uint8 byte array
189 blink::WebArrayBuffer CreateArrayBuffer(const uint8* data, unsigned data_size); 189 blink::WebArrayBuffer CreateArrayBuffer(const uint8* data,
190 unsigned int data_size);
190 191
191 // This function decodes unpadded 'base64url' encoded data, as described in 192 // This function decodes unpadded 'base64url' encoded data, as described in
192 // RFC4648 (http://www.ietf.org/rfc/rfc4648.txt) Section 5. 193 // RFC4648 (http://www.ietf.org/rfc/rfc4648.txt) Section 5.
193 // In Web Crypto, this type of encoding is only used inside JWK. 194 // In Web Crypto, this type of encoding is only used inside JWK.
194 bool Base64DecodeUrlSafe(const std::string& input, std::string* output); 195 bool Base64DecodeUrlSafe(const std::string& input, std::string* output);
195 196
196 CONTENT_EXPORT bool IsHashAlgorithm(blink::WebCryptoAlgorithmId alg_id); 197 CONTENT_EXPORT bool IsHashAlgorithm(blink::WebCryptoAlgorithmId alg_id);
197 198
198 // Returns the "hash" param for an algorithm if it exists, otherwise returns 199 // Returns the "hash" param for an algorithm if it exists, otherwise returns
199 // a null algorithm. 200 // a null algorithm.
200 blink::WebCryptoAlgorithm GetInnerHashAlgorithm( 201 blink::WebCryptoAlgorithm GetInnerHashAlgorithm(
201 const blink::WebCryptoAlgorithm& algorithm); 202 const blink::WebCryptoAlgorithm& algorithm);
202 203
203 // Creates a WebCryptoAlgorithm without any parameters. 204 // Creates a WebCryptoAlgorithm without any parameters.
204 CONTENT_EXPORT blink::WebCryptoAlgorithm CreateAlgorithm( 205 CONTENT_EXPORT blink::WebCryptoAlgorithm CreateAlgorithm(
205 blink::WebCryptoAlgorithmId id); 206 blink::WebCryptoAlgorithmId id);
206 207
207 // Creates an HMAC algorithm whose inner hash algorithm is determined by the 208 // Creates an HMAC algorithm whose inner hash algorithm is determined by the
208 // specified algorithm ID. It is an error to call this method with a hash 209 // specified algorithm ID. It is an error to call this method with a hash
209 // algorithm that is not SHA*. 210 // algorithm that is not SHA*.
210 CONTENT_EXPORT blink::WebCryptoAlgorithm CreateHmacAlgorithmByHashId( 211 CONTENT_EXPORT blink::WebCryptoAlgorithm CreateHmacAlgorithmByHashId(
211 blink::WebCryptoAlgorithmId hash_id); 212 blink::WebCryptoAlgorithmId hash_id);
212 213
213 // Creates an HMAC algorithm whose parameters struct is compatible with key 214 // Creates an HMAC algorithm whose parameters struct is compatible with key
214 // generation. It is an error to call this with a hash_id that is not a SHA*. 215 // generation. It is an error to call this with a hash_id that is not a SHA*.
215 // The key_length_bytes parameter is optional, with zero meaning unspecified. 216 // The key_length_bytes parameter is optional, with zero meaning unspecified.
216 CONTENT_EXPORT blink::WebCryptoAlgorithm CreateHmacKeyGenAlgorithm( 217 CONTENT_EXPORT blink::WebCryptoAlgorithm CreateHmacKeyGenAlgorithm(
217 blink::WebCryptoAlgorithmId hash_id, 218 blink::WebCryptoAlgorithmId hash_id,
218 unsigned key_length_bytes); 219 unsigned int key_length_bytes);
219 220
220 // Creates an RSASSA-PKCS1-v1_5 algorithm. It is an error to call this with a 221 // Creates an RSASSA-PKCS1-v1_5 algorithm. It is an error to call this with a
221 // hash_id that is not a SHA*. 222 // hash_id that is not a SHA*.
222 blink::WebCryptoAlgorithm CreateRsaSsaAlgorithm( 223 blink::WebCryptoAlgorithm CreateRsaSsaAlgorithm(
223 blink::WebCryptoAlgorithmId hash_id); 224 blink::WebCryptoAlgorithmId hash_id);
224 225
225 // Creates an RSA-OAEP algorithm. It is an error to call this with a hash_id 226 // Creates an RSA-OAEP algorithm. It is an error to call this with a hash_id
226 // that is not a SHA*. 227 // that is not a SHA*.
227 blink::WebCryptoAlgorithm CreateRsaOaepAlgorithm( 228 blink::WebCryptoAlgorithm CreateRsaOaepAlgorithm(
228 blink::WebCryptoAlgorithmId hash_id); 229 blink::WebCryptoAlgorithmId hash_id);
229 230
230 // Creates an RSA algorithm with ID algorithm_id, whose parameters struct is 231 // Creates an RSA algorithm with ID algorithm_id, whose parameters struct is
231 // compatible with key generation. 232 // compatible with key generation.
232 CONTENT_EXPORT blink::WebCryptoAlgorithm CreateRsaKeyGenAlgorithm( 233 CONTENT_EXPORT blink::WebCryptoAlgorithm CreateRsaKeyGenAlgorithm(
233 blink::WebCryptoAlgorithmId algorithm_id, 234 blink::WebCryptoAlgorithmId algorithm_id,
234 unsigned modulus_length, 235 unsigned int modulus_length,
235 const std::vector<uint8>& public_exponent); 236 const std::vector<uint8>& public_exponent);
236 237
237 // Creates an AES-CBC algorithm. 238 // Creates an AES-CBC algorithm.
238 CONTENT_EXPORT blink::WebCryptoAlgorithm CreateAesCbcAlgorithm( 239 CONTENT_EXPORT blink::WebCryptoAlgorithm CreateAesCbcAlgorithm(
239 const std::vector<uint8>& iv); 240 const std::vector<uint8>& iv);
240 241
241 // Creates and AES-GCM algorithm. 242 // Creates and AES-GCM algorithm.
242 blink::WebCryptoAlgorithm CreateAesGcmAlgorithm( 243 blink::WebCryptoAlgorithm CreateAesGcmAlgorithm(
243 const std::vector<uint8>& iv, 244 const std::vector<uint8>& iv,
244 const std::vector<uint8>& additional_data, 245 const std::vector<uint8>& additional_data,
245 uint8 tag_length_bytes); 246 uint8 tag_length_bytes);
246 247
247 // Returns the internal block size for SHA-* 248 // Returns the internal block size for SHA-*
248 unsigned int ShaBlockSizeBytes(blink::WebCryptoAlgorithmId hash_id); 249 unsigned int ShaBlockSizeBytes(blink::WebCryptoAlgorithmId hash_id);
249 250
250 } // namespace webcrypto 251 } // namespace webcrypto
251 252
252 } // namespace content 253 } // namespace content
253 254
254 #endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_UTIL_H_ 255 #endif // CONTENT_RENDERER_WEBCRYPTO_WEBCRYPTO_UTIL_H_
OLDNEW
« no previous file with comments | « content/renderer/webcrypto/webcrypto_impl_unittest.cc ('k') | content/renderer/webcrypto/webcrypto_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698