aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/misc
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-11-09 14:18:11 -0500
committerJack Lloyd <[email protected]>2016-11-09 14:18:11 -0500
commit9fa352282f7550b1226e819c458005375d77f11b (patch)
tree7de79952215472876be420cb7bd37f7192db7bfa /src/lib/misc
parent719a5e3f319e423467a614ce1625a5ec43a82383 (diff)
Check missing Pipe::read return values
Diffstat (limited to 'src/lib/misc')
-rw-r--r--src/lib/misc/aont/package.cpp6
-rw-r--r--src/lib/misc/cryptobox/cryptobox.cpp12
2 files changed, 12 insertions, 6 deletions
diff --git a/src/lib/misc/aont/package.cpp b/src/lib/misc/aont/package.cpp
index a3be898d8..cec07d298 100644
--- a/src/lib/misc/aont/package.cpp
+++ b/src/lib/misc/aont/package.cpp
@@ -31,7 +31,8 @@ void aont_package(RandomNumberGenerator& rng,
Pipe pipe(new StreamCipher_Filter(new CTR_BE(cipher), package_key));
pipe.process_msg(input, input_len);
- pipe.read(output, pipe.remaining());
+ const size_t remaining = pipe.remaining();
+ BOTAN_ASSERT_EQUAL(remaining, pipe.read(output, remaining), "Expected read size");
// Set K0 (the all zero key)
cipher->set_key(SymmetricKey(all_zeros));
@@ -113,7 +114,8 @@ void aont_unpackage(BlockCipher* cipher,
pipe.process_msg(input, input_len - BLOCK_SIZE);
- pipe.read(output, pipe.remaining());
+ const size_t remaining = pipe.remaining();
+ BOTAN_ASSERT_EQUAL(remaining, pipe.read(output, remaining), "Expected read size");
}
}
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],