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/child/webcrypto/shared_crypto.h" | 5 #include "content/child/webcrypto/shared_crypto.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/child/webcrypto/crypto_data.h" | 8 #include "content/child/webcrypto/crypto_data.h" |
9 #include "content/child/webcrypto/platform_crypto.h" | 9 #include "content/child/webcrypto/platform_crypto.h" |
10 #include "content/child/webcrypto/webcrypto_util.h" | 10 #include "content/child/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 #if defined(WEBCRYPTO_HMAC_BITS) |
| 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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 key); | 566 key); |
560 } | 567 } |
561 default: | 568 default: |
562 return Status::ErrorUnsupported(); | 569 return Status::ErrorUnsupported(); |
563 } | 570 } |
564 } | 571 } |
565 | 572 |
566 } // namespace webcrypto | 573 } // namespace webcrypto |
567 | 574 |
568 } // namespace content | 575 } // namespace content |
OLD | NEW |