diff options
author | Never <[email protected]> | 2016-12-09 13:51:55 +0100 |
---|---|---|
committer | Never <[email protected]> | 2016-12-09 14:00:07 +0100 |
commit | 2e37f7601380a09ac635941581387d4ac6b54f12 (patch) | |
tree | e1d16dee2c5df92b4197b2827bdddd9e4124a0ea /src/tests/test_pad.cpp | |
parent | 41e7cade5889d238ca695806451db227b9792cd9 (diff) |
Rewrote bc unpad functions as const time operations.
The unpad functions return the blocksize as padding position, if the padding is invalid.
.
Diffstat (limited to 'src/tests/test_pad.cpp')
-rw-r--r-- | src/tests/test_pad.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/tests/test_pad.cpp b/src/tests/test_pad.cpp index bf9e64c0d..c27e2607f 100644 --- a/src/tests/test_pad.cpp +++ b/src/tests/test_pad.cpp @@ -7,7 +7,7 @@ #include "tests.h" #if defined(BOTAN_HAS_CIPHER_MODE_PADDING) - #include <botan/mode_pad.h> + #include <botan/mode_pad.h> #endif namespace Botan_Tests { @@ -18,7 +18,7 @@ class Cipher_Mode_Padding_Tests : public Text_Based_Test { public: Cipher_Mode_Padding_Tests() : - Text_Based_Test("", "pad.vec", {"In", "Blocksize"},{"Out"}) + Text_Based_Test("", "pad.vec", {"In", "Blocksize"}, {"Out"}) {} Test::Result run_one_test(const std::string& header, const VarMap& vars) override @@ -50,12 +50,11 @@ class Cipher_Mode_Padding_Tests : public Text_Based_Test if(expected.empty()) { // This is an unpad an invalid input and ensure we reject - try + if(pad->unpad(input.data(), block_size) != block_size) { - pad->unpad(input.data(), block_size); result.test_failure("Did not reject invalid padding", Botan::hex_encode(input)); } - catch(Botan::Decoding_Error&) + else { result.test_success("Rejected invalid padding"); } @@ -69,7 +68,7 @@ class Cipher_Mode_Padding_Tests : public Text_Based_Test buf.assign(expected.begin(), expected.end()); - const size_t last_block = ( buf.size() < block_size ) ? 0 : buf.size() - block_size; + const size_t last_block = (buf.size() < block_size) ? 0 : buf.size() - block_size; const size_t pad_bytes = block_size - pad->unpad(&buf[last_block], block_size); buf.resize(buf.size() - pad_bytes); // remove padding result.test_eq("unpad", buf, input); |