mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-06 16:43:55 +00:00
Increase coverage for RC4 testing
This commit is contained in:
parent
6d1d244615
commit
fb4c6c1503
@ -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
|
||||
{
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user