Chromium Code Reviews| Index: crypto/encryptor_mac.cc |
| =================================================================== |
| --- crypto/encryptor_mac.cc (revision 107404) |
| +++ crypto/encryptor_mac.cc (working copy) |
| @@ -49,17 +49,19 @@ |
| // length is never larger than the input length plus the block size." |
| size_t output_size = input.size() + iv_.size(); |
| + DCHECK_GT(output_size, 0u); |
| + DCHECK_GT(output_size + 1, input.size()); |
|
Ryan Sleevi
2011/11/01 23:08:59
Both of these can be changed to CHECK_GT
|
| CCCryptorStatus err = CCCrypt(op, |
| kCCAlgorithmAES128, |
| kCCOptionPKCS7Padding, |
| raw_key.Data, raw_key.Length, |
| iv_.data(), |
| input.data(), input.size(), |
| - WriteInto(output, output_size+1), |
| + WriteInto(output, output_size + 1), |
| output_size, |
| &output_size); |
| if (err) { |
| - output->resize(0); |
| + output->clear(); |
| LOG(ERROR) << "CCCrypt returned " << err; |
| return false; |
| } |
| @@ -69,11 +71,13 @@ |
| bool Encryptor::Encrypt(const base::StringPiece& plaintext, |
| std::string* ciphertext) { |
| + DCHECK(!plaintext.empty() || (mode_ == CBC)); |
| return Crypt(kCCEncrypt, plaintext, ciphertext); |
| } |
| bool Encryptor::Decrypt(const base::StringPiece& ciphertext, |
| std::string* plaintext) { |
| + DCHECK(!ciphertext.empty()); |
| return Crypt(kCCDecrypt, ciphertext, plaintext); |
| } |