diff options
author | Jack Lloyd <[email protected]> | 2016-11-09 14:18:11 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2016-11-09 14:18:11 -0500 |
commit | 9fa352282f7550b1226e819c458005375d77f11b (patch) | |
tree | 7de79952215472876be420cb7bd37f7192db7bfa /src/lib/misc/cryptobox | |
parent | 719a5e3f319e423467a614ce1625a5ec43a82383 (diff) |
Check missing Pipe::read return values
Diffstat (limited to 'src/lib/misc/cryptobox')
-rw-r--r-- | src/lib/misc/cryptobox/cryptobox.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/lib/misc/cryptobox/cryptobox.cpp b/src/lib/misc/cryptobox/cryptobox.cpp index c0fc9b777..95cdda149 100644 --- a/src/lib/misc/cryptobox/cryptobox.cpp +++ b/src/lib/misc/cryptobox/cryptobox.cpp @@ -88,9 +88,13 @@ std::string encrypt(const byte input[], size_t input_len, copy_mem(&out_buf[VERSION_CODE_LEN], pbkdf_salt.data(), PBKDF_SALT_LEN); - pipe.read(&out_buf[VERSION_CODE_LEN + PBKDF_SALT_LEN], MAC_OUTPUT_LEN, 1); - pipe.read(&out_buf[VERSION_CODE_LEN + PBKDF_SALT_LEN + MAC_OUTPUT_LEN], - ciphertext_len, 0); + BOTAN_ASSERT_EQUAL( + pipe.read(&out_buf[VERSION_CODE_LEN + PBKDF_SALT_LEN], MAC_OUTPUT_LEN, 1), + MAC_OUTPUT_LEN, "MAC output"); + BOTAN_ASSERT_EQUAL( + pipe.read(&out_buf[VERSION_CODE_LEN + PBKDF_SALT_LEN + MAC_OUTPUT_LEN], + ciphertext_len, 0), + ciphertext_len, "Ciphertext size"); return PEM_Code::encode(out_buf, "BOTAN CRYPTOBOX MESSAGE"); } @@ -139,7 +143,7 @@ std::string decrypt(const byte input[], size_t input_len, ciphertext.size() - ciphertext_offset); byte computed_mac[MAC_OUTPUT_LEN]; - pipe.read(computed_mac, MAC_OUTPUT_LEN, 1); + BOTAN_ASSERT_EQUAL(MAC_OUTPUT_LEN, pipe.read(computed_mac, MAC_OUTPUT_LEN, 1), "MAC size"); if(!same_mem(computed_mac, &ciphertext[VERSION_CODE_LEN + PBKDF_SALT_LEN], |