diff options
Diffstat (limited to 'src/tests')
-rw-r--r-- | src/tests/data/pad.vec | 21 | ||||
-rw-r--r-- | src/tests/test_pad.cpp | 15 |
2 files changed, 36 insertions, 0 deletions
diff --git a/src/tests/data/pad.vec b/src/tests/data/pad.vec index 3c47959c9..edd0892fc 100644 --- a/src/tests/data/pad.vec +++ b/src/tests/data/pad.vec @@ -80,4 +80,25 @@ Blocksize = 8 In = FFFFFFFFFFFFFFFFFF Out = FFFFFFFFFFFFFFFFFF00000000000007 +Blocksize = 8 + +[ESP] +In = FFFFFF +Out = FFFFFF0102030405060708090A0B0C0D +Blocksize = 16 + +In = FFFFFFFF +Out = FFFFFFFF0102030405060708090A0B0C0D0E0F101112131415161718191A1B1C +Blocksize = 32 + +In = FFFFFFFFFFFF +Out = FFFFFFFFFFFF0102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A +Blocksize = 64 + +In = FFFFFFFFFFFFFFFF +Out = FFFFFFFFFFFFFFFF0102030405060708 +Blocksize = 8 + +In = FFFFFFFFFFFFFFFFFF +Out = FFFFFFFFFFFFFFFFFF01020304050607 Blocksize = 8
\ No newline at end of file diff --git a/src/tests/test_pad.cpp b/src/tests/test_pad.cpp index 6c9d1b85a..0eb14beb8 100644 --- a/src/tests/test_pad.cpp +++ b/src/tests/test_pad.cpp @@ -50,6 +50,21 @@ class Cipher_Mode_Padding_Tests : public Text_Based_Test return result; } + + std::vector<Test::Result> run_final_tests() + { + Test::Result result("ESP negative tests"); + + std::vector<uint8_t> invalid1 { 0xFF, 0x01, 0x02, 0x02 }; + result.test_throws("ESP invalid last pad", [&invalid1]() + { Botan::ESP_Padding().unpad(invalid1.data(), invalid1.size()); } ); + + std::vector<uint8_t> invalid2 { 0xFF, 0x01, 0x02, 0x04 }; + result.test_throws("ESP invalid pad", [&invalid2]() + { Botan::ESP_Padding().unpad(invalid2.data(), invalid2.size()); } ); + + return {result}; + } }; BOTAN_REGISTER_TEST("bc_pad", Cipher_Mode_Padding_Tests); |