diff options
author | Jay Berkenbilt <ejb@ql.org> | 2019-11-06 00:44:16 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2019-11-09 15:53:42 +0100 |
commit | fb4c6c150345c76c73de7cdfcb48caab34c5cab6 (patch) | |
tree | cc8b59b6bcbc85d5fb3df19c5d3a604a7f0c4653 /libtests | |
parent | 6d1d244615154d02405d345ec46872976eb20881 (diff) | |
download | qpdf-fb4c6c150345c76c73de7cdfcb48caab34c5cab6.tar.zst |
Increase coverage for RC4 testing
Diffstat (limited to 'libtests')
-rw-r--r-- | libtests/qtest/rc4.test | 7 | ||||
-rw-r--r-- | libtests/rc4.cc | 20 |
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; |