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

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

Issue 205583003: [webcrypto] Remove ifdefs for whether hmac key algorithm has length. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix indentation 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_unittest.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/webcrypto_util.h" 5 #include "content/child/webcrypto/webcrypto_util.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" 10 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h"
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 } 377 }
378 378
379 bool CreateSecretKeyAlgorithm(const blink::WebCryptoAlgorithm& algorithm, 379 bool CreateSecretKeyAlgorithm(const blink::WebCryptoAlgorithm& algorithm,
380 unsigned int keylen_bytes, 380 unsigned int keylen_bytes,
381 blink::WebCryptoKeyAlgorithm* key_algorithm) { 381 blink::WebCryptoKeyAlgorithm* key_algorithm) {
382 switch (algorithm.id()) { 382 switch (algorithm.id()) {
383 case blink::WebCryptoAlgorithmIdHmac: { 383 case blink::WebCryptoAlgorithmIdHmac: {
384 blink::WebCryptoAlgorithm hash = GetInnerHashAlgorithm(algorithm); 384 blink::WebCryptoAlgorithm hash = GetInnerHashAlgorithm(algorithm);
385 if (hash.isNull()) 385 if (hash.isNull())
386 return false; 386 return false;
387 #if defined(WEBCRYPTO_HMAC_KEY_HAS_LENGTH)
388 if (keylen_bytes > UINT_MAX / 8) 387 if (keylen_bytes > UINT_MAX / 8)
389 return false; 388 return false;
390 #endif
391 *key_algorithm = blink::WebCryptoKeyAlgorithm::adoptParamsAndCreate( 389 *key_algorithm = blink::WebCryptoKeyAlgorithm::adoptParamsAndCreate(
392 algorithm.id(), 390 algorithm.id(),
393 #if defined(WEBCRYPTO_HMAC_KEY_HAS_LENGTH)
394 new blink::WebCryptoHmacKeyAlgorithmParams(hash, keylen_bytes * 8)); 391 new blink::WebCryptoHmacKeyAlgorithmParams(hash, keylen_bytes * 8));
395 #else
396 new blink::WebCryptoHmacKeyAlgorithmParams(hash));
397 #endif
398 return true; 392 return true;
399 } 393 }
400 case blink::WebCryptoAlgorithmIdAesKw: 394 case blink::WebCryptoAlgorithmIdAesKw:
401 case blink::WebCryptoAlgorithmIdAesCbc: 395 case blink::WebCryptoAlgorithmIdAesCbc:
402 case blink::WebCryptoAlgorithmIdAesCtr: 396 case blink::WebCryptoAlgorithmIdAesCtr:
403 case blink::WebCryptoAlgorithmIdAesGcm: 397 case blink::WebCryptoAlgorithmIdAesGcm:
404 *key_algorithm = blink::WebCryptoKeyAlgorithm::adoptParamsAndCreate( 398 *key_algorithm = blink::WebCryptoKeyAlgorithm::adoptParamsAndCreate(
405 algorithm.id(), 399 algorithm.id(),
406 new blink::WebCryptoAesKeyAlgorithmParams(keylen_bytes * 8)); 400 new blink::WebCryptoAesKeyAlgorithmParams(keylen_bytes * 8));
407 return true; 401 return true;
408 default: 402 default:
409 return false; 403 return false;
410 } 404 }
411 } 405 }
412 406
413 } // namespace webcrypto 407 } // namespace webcrypto
414 408
415 } // namespace content 409 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webcrypto/shared_crypto_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698