OLD | NEW |
---|---|
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/renderer/webcrypto/shared_crypto.h" | 5 #include "content/renderer/webcrypto/shared_crypto.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/renderer/webcrypto/crypto_data.h" | 8 #include "content/renderer/webcrypto/crypto_data.h" |
9 #include "content/renderer/webcrypto/platform_crypto.h" | 9 #include "content/renderer/webcrypto/platform_crypto.h" |
10 #include "content/renderer/webcrypto/webcrypto_util.h" | 10 #include "content/renderer/webcrypto/webcrypto_util.h" |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 case blink::WebCryptoAlgorithmIdAesKw: { | 308 case blink::WebCryptoAlgorithmIdAesKw: { |
309 if (!IsValidAesKeyLengthBits(algorithm.aesKeyGenParams()->lengthBits())) | 309 if (!IsValidAesKeyLengthBits(algorithm.aesKeyGenParams()->lengthBits())) |
310 return Status::ErrorGenerateKeyLength(); | 310 return Status::ErrorGenerateKeyLength(); |
311 keylen_bytes = algorithm.aesKeyGenParams()->lengthBits() / 8; | 311 keylen_bytes = algorithm.aesKeyGenParams()->lengthBits() / 8; |
312 break; | 312 break; |
313 } | 313 } |
314 case blink::WebCryptoAlgorithmIdHmac: { | 314 case blink::WebCryptoAlgorithmIdHmac: { |
315 const blink::WebCryptoHmacKeyGenParams* params = | 315 const blink::WebCryptoHmacKeyGenParams* params = |
316 algorithm.hmacKeyGenParams(); | 316 algorithm.hmacKeyGenParams(); |
317 DCHECK(params); | 317 DCHECK(params); |
318 #ifdef WEBCRYPTO_HMAC_BITS | |
Ryan Sleevi
2014/03/06 21:51:37
if defined(...)
eroman
2014/03/06 21:54:18
Done.
| |
319 if (params->hasLengthBits()) { | |
320 if (params->optionalLengthBits() % 8) | |
321 return Status::ErrorGenerateKeyLength(); | |
322 keylen_bytes = params->optionalLengthBits() / 8; | |
323 #else | |
318 if (params->hasLengthBytes()) { | 324 if (params->hasLengthBytes()) { |
319 keylen_bytes = params->optionalLengthBytes(); | 325 keylen_bytes = params->optionalLengthBytes(); |
326 #endif | |
320 } else { | 327 } else { |
321 keylen_bytes = ShaBlockSizeBytes(params->hash().id()); | 328 keylen_bytes = ShaBlockSizeBytes(params->hash().id()); |
322 if (keylen_bytes == 0) | 329 if (keylen_bytes == 0) |
323 return Status::ErrorUnsupported(); | 330 return Status::ErrorUnsupported(); |
324 } | 331 } |
325 break; | 332 break; |
326 } | 333 } |
327 | 334 |
328 default: | 335 default: |
329 return Status::ErrorUnsupported(); | 336 return Status::ErrorUnsupported(); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
476 return VerifyRsaSsaPkcs1v1_5( | 483 return VerifyRsaSsaPkcs1v1_5( |
477 algorithm, key, signature, data, signature_match); | 484 algorithm, key, signature, data, signature_match); |
478 default: | 485 default: |
479 return Status::ErrorUnsupported(); | 486 return Status::ErrorUnsupported(); |
480 } | 487 } |
481 } | 488 } |
482 | 489 |
483 } // namespace webcrypto | 490 } // namespace webcrypto |
484 | 491 |
485 } // namespace content | 492 } // namespace content |
OLD | NEW |