aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libtests/qtest/rc4.test7
-rw-r--r--libtests/rc4.cc20
2 files changed, 26 insertions, 1 deletions
diff --git a/libtests/qtest/rc4.test b/libtests/qtest/rc4.test
index 0207317c..25a5ab45 100644
--- a/libtests/qtest/rc4.test
+++ b/libtests/qtest/rc4.test
@@ -35,9 +35,14 @@ foreach my $key (@tests)
{$td->FILE => "test$n.in"});
}
+$td->runtest("other tests",
+ {$td->COMMAND => "rc4 other"},
+ {$td->STRING => "passed\n", $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
+
cleanup();
-$td->report(4 * scalar(@tests));
+$td->report(1 + (4 * scalar(@tests)));
sub cleanup
{
diff --git a/libtests/rc4.cc b/libtests/rc4.cc
index f877666f..d3f1c7fa 100644
--- a/libtests/rc4.cc
+++ b/libtests/rc4.cc
@@ -7,9 +7,29 @@
#include <string.h>
#include <iostream>
#include <stdlib.h>
+#include <cassert>
+
+static void other_tests()
+{
+ // Test cases not covered by the pipeline: string as key, convert
+ // in place
+ RC4 r(reinterpret_cast<unsigned char const*>("quack"));
+ auto data = std::unique_ptr<unsigned char[]>(
+ new unsigned char[6], std::default_delete<unsigned char[]>());
+ memcpy(data.get(), "potato", 6);
+ r.process(data.get(), 6);
+ assert(memcmp(data.get(), "\xa5\x6f\xe7\x27\x2b\x5c", 6) == 0);
+ std::cout << "passed" << std::endl;
+}
int main(int argc, char* argv[])
{
+ if ((argc == 2) && (strcmp(argv[1], "other") == 0))
+ {
+ other_tests();
+ return 0;
+ }
+
if (argc != 4)
{
std::cerr << "Usage: rc4 hex-key infile outfile" << std::endl;