Chromium Code Reviews| Index: content/child/webcrypto/platform_crypto_openssl.cc |
| diff --git a/content/child/webcrypto/platform_crypto_openssl.cc b/content/child/webcrypto/platform_crypto_openssl.cc |
| index 89212ea55b201472c878c2e6edfe1431ed913223..83140538d86cfc8a96ba3c36f418b300d2bcd10d 100644 |
| --- a/content/child/webcrypto/platform_crypto_openssl.cc |
| +++ b/content/child/webcrypto/platform_crypto_openssl.cc |
| @@ -53,12 +53,10 @@ class SymKey : public Key { |
| namespace { |
| const EVP_CIPHER* GetAESCipherByKeyLength(unsigned int key_length_bytes) { |
| - // OpenSSL supports AES CBC ciphers for only 3 key lengths: 128, 192, 256 bits |
| + // OpenSSL supports AES CBC ciphers for only 2 key lengths: 128, 256 bits |
|
eroman
2014/07/15 20:20:44
LGTM for webcrypto changes!
For the record, remov
|
| switch (key_length_bytes) { |
| case 16: |
| return EVP_aes_128_cbc(); |
| - case 24: |
| - return EVP_aes_192_cbc(); |
| case 32: |
| return EVP_aes_256_cbc(); |
| default: |
| @@ -439,7 +437,8 @@ Status EncryptDecryptAesGcm(EncryptOrDecrypt mode, |
| crypto::ScopedOpenSSL<EVP_AEAD_CTX, EVP_AEAD_CTX_cleanup>::Type ctx_cleanup( |
| &ctx); |
| - ssize_t len; |
| + size_t len; |
| + int ok; |
| if (mode == DECRYPT) { |
| if (data.byte_length() < tag_length_bytes) |
| @@ -447,32 +446,34 @@ Status EncryptDecryptAesGcm(EncryptOrDecrypt mode, |
| buffer->resize(data.byte_length() - tag_length_bytes); |
| - len = EVP_AEAD_CTX_open(&ctx, |
| - Uint8VectorStart(buffer), |
| - buffer->size(), |
| - iv.bytes(), |
| - iv.byte_length(), |
| - data.bytes(), |
| - data.byte_length(), |
| - additional_data.bytes(), |
| - additional_data.byte_length()); |
| + ok = EVP_AEAD_CTX_open(&ctx, |
| + Uint8VectorStart(buffer), |
| + &len, |
| + buffer->size(), |
| + iv.bytes(), |
| + iv.byte_length(), |
| + data.bytes(), |
| + data.byte_length(), |
| + additional_data.bytes(), |
| + additional_data.byte_length()); |
| } else { |
| // No need to check for unsigned integer overflow here (seal fails if |
| // the output buffer is too small). |
| buffer->resize(data.byte_length() + tag_length_bytes); |
| - len = EVP_AEAD_CTX_seal(&ctx, |
| - Uint8VectorStart(buffer), |
| - buffer->size(), |
| - iv.bytes(), |
| - iv.byte_length(), |
| - data.bytes(), |
| - data.byte_length(), |
| - additional_data.bytes(), |
| - additional_data.byte_length()); |
| + ok = EVP_AEAD_CTX_seal(&ctx, |
| + Uint8VectorStart(buffer), |
| + &len, |
| + buffer->size(), |
| + iv.bytes(), |
| + iv.byte_length(), |
| + data.bytes(), |
| + data.byte_length(), |
| + additional_data.bytes(), |
| + additional_data.byte_length()); |
| } |
| - if (len < 0) |
| + if (!ok) |
| return Status::OperationError(); |
| buffer->resize(len); |
| return Status::Success(); |