aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/test_tls_cbc.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-09-29 10:04:06 -0400
committerJack Lloyd <[email protected]>2017-09-29 10:04:06 -0400
commit2860028d21d93bbbf33966e7e511a9e19da770ca (patch)
tree8b91259274e6df8c07afbde1e3e9ce381bd982d8 /src/tests/test_tls_cbc.cpp
parent3829cf5df7522c4812d4bc33cb593503459c76b9 (diff)
Add a test of TLS CBC padding verification
See also GH #1227
Diffstat (limited to 'src/tests/test_tls_cbc.cpp')
-rw-r--r--src/tests/test_tls_cbc.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/tests/test_tls_cbc.cpp b/src/tests/test_tls_cbc.cpp
new file mode 100644
index 000000000..5ff242806
--- /dev/null
+++ b/src/tests/test_tls_cbc.cpp
@@ -0,0 +1,40 @@
+/*
+* (C) 2017 Jack Lloyd
+*
+* Botan is released under the Simplified BSD License (see license.txt)
+*/
+
+#include "tests.h"
+
+#if defined(BOTAN_HAS_TLS_CBC)
+ #include <botan/internal/tls_cbc.h>
+#endif
+
+namespace Botan_Tests {
+
+#if defined(BOTAN_HAS_TLS_CBC)
+
+class TLS_CBC_Padding_Tests : public Text_Based_Test
+ {
+ public:
+ TLS_CBC_Padding_Tests() : Text_Based_Test("tls_cbc.vec", "Record,Output") {}
+
+ Test::Result run_one_test(const std::string& algo, const VarMap& vars) override
+ {
+ const std::vector<uint8_t> record = get_req_bin(vars, "Record");
+ const size_t output = get_req_sz(vars, "Output");
+
+ uint16_t res = Botan::TLS::check_tls_cbc_padding(record.data(), record.size());
+
+ Test::Result result("TLS CBC padding check");
+ result.test_eq("Expected", res, output);
+ return result;
+ }
+ };
+
+BOTAN_REGISTER_TEST("tls_cbc_padding", TLS_CBC_Padding_Tests);
+
+#endif
+
+}
+