| 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()) { | 318       if (params->hasLengthBits()) { | 
| 320         if (params->optionalLengthBits() % 8) | 319         if (params->optionalLengthBits() % 8) | 
| 321           return Status::ErrorGenerateKeyLength(); | 320           return Status::ErrorGenerateKeyLength(); | 
| 322         keylen_bytes = params->optionalLengthBits() / 8; | 321         keylen_bytes = params->optionalLengthBits() / 8; | 
| 323 #else |  | 
| 324       if (params->hasLengthBytes()) { |  | 
| 325         keylen_bytes = params->optionalLengthBytes(); |  | 
| 326 #endif |  | 
| 327       } else { | 322       } else { | 
| 328         keylen_bytes = ShaBlockSizeBytes(params->hash().id()); | 323         keylen_bytes = ShaBlockSizeBytes(params->hash().id()); | 
| 329         if (keylen_bytes == 0) | 324         if (keylen_bytes == 0) | 
| 330           return Status::ErrorUnsupported(); | 325           return Status::ErrorUnsupported(); | 
| 331       } | 326       } | 
| 332       break; | 327       break; | 
| 333     } | 328     } | 
| 334 | 329 | 
| 335     default: | 330     default: | 
| 336       return Status::ErrorUnsupported(); | 331       return Status::ErrorUnsupported(); | 
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 566                                          key); | 561                                          key); | 
| 567     } | 562     } | 
| 568     default: | 563     default: | 
| 569       return Status::ErrorUnsupported(); | 564       return Status::ErrorUnsupported(); | 
| 570   } | 565   } | 
| 571 } | 566 } | 
| 572 | 567 | 
| 573 }  // namespace webcrypto | 568 }  // namespace webcrypto | 
| 574 | 569 | 
| 575 }  // namespace content | 570 }  // namespace content | 
| OLD | NEW | 
|---|