aboutsummaryrefslogtreecommitdiffstats
path: root/libtests/qtest
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2009-10-18 01:58:59 +0200
committerJay Berkenbilt <ejb@ql.org>2009-10-18 01:58:59 +0200
commitaaeb71093d4ba3eafee0efece3b8bad7c18f0f00 (patch)
treeca715c95a5b614a292e6db0d95395397f0a81a5f /libtests/qtest
parente25910b59ab84c7aada0b651e7dbb47f6830ad3d (diff)
downloadqpdf-aaeb71093d4ba3eafee0efece3b8bad7c18f0f00.tar.zst
test aes
git-svn-id: svn+q:///qpdf/trunk@813 71b93d88-0707-0410-a8cf-f5a4172ac649
Diffstat (limited to 'libtests/qtest')
-rw-r--r--libtests/qtest/aes.test71
-rw-r--r--libtests/qtest/aes/data1bin0 -> 17041 bytes
-rw-r--r--libtests/qtest/aes/data2bin0 -> 16000 bytes
-rwxr-xr-xlibtests/qtest/aes/test-vector.cipher1
-rw-r--r--libtests/qtest/aes/test-vector.clearbin0 -> 16 bytes
5 files changed, 72 insertions, 0 deletions
diff --git a/libtests/qtest/aes.test b/libtests/qtest/aes.test
new file mode 100644
index 00000000..7e48840a
--- /dev/null
+++ b/libtests/qtest/aes.test
@@ -0,0 +1,71 @@
+#!/usr/bin/env perl
+require 5.008;
+BEGIN { $^W = 1; }
+use strict;
+use File::stat;
+
+chdir("aes") or die "chdir testdir failed: $!\n";
+
+require TestDriver;
+
+my $td = new TestDriver('AES');
+
+cleanup();
+
+my $key = '000102030405060708090a0b0c0d0e0f';
+$td->runtest("encrypt test vector",
+ {$td->COMMAND => "aes -cbc -encrypt $key test-vector.clear tmp1"},
+ {$td->STRING => "", $td->EXIT_STATUS => 0});
+$td->runtest("check output",
+ {$td->FILE => "tmp1"},
+ {$td->FILE => "test-vector.cipher"});
+$td->runtest("decrypt test vector",
+ {$td->COMMAND => "aes -cbc -decrypt $key tmp1 tmp2"},
+ {$td->STRING => "", $td->EXIT_STATUS => 0});
+$td->runtest("check output",
+ {$td->FILE => "tmp2"},
+ {$td->FILE => "test-vector.clear"});
+
+$key = '243f6a8885243f6a8885243f6a888524';
+foreach my $d (['data1', 17072], ['data2', 16032])
+{
+ my ($file, $size) = @$d;
+ $td->runtest("encrypt $file",
+ {$td->COMMAND => "aes +cbc -encrypt $key $file tmp1"},
+ {$td->STRING => "", $td->EXIT_STATUS => 0});
+ # sleep one second so random number will get a different seed
+ sleep(1);
+ $td->runtest("encrypt $file again",
+ {$td->COMMAND => "aes +cbc -encrypt $key $file tmp2"},
+ {$td->STRING => "", $td->EXIT_STATUS => 0});
+ foreach my $f (qw(tmp1 tmp2))
+ {
+ $td->runtest("check size",
+ {$td->STRING => sprintf("%d\n", stat($f)->size)},
+ {$td->STRING => "$size\n"});
+ }
+ $td->runtest("verify files are different",
+ {$td->COMMAND => "cmp tmp1 tmp2"},
+ {$td->REGEXP => '.*', $td->EXIT_STATUS => '!0'});
+ $td->runtest("decrypt $file",
+ {$td->COMMAND => "aes +cbc -decrypt $key tmp1 tmp3"},
+ {$td->STRING => "", $td->EXIT_STATUS => 0});
+ $td->runtest("decrypt $file again",
+ {$td->COMMAND => "aes +cbc -decrypt $key tmp2 tmp4"},
+ {$td->STRING => "", $td->EXIT_STATUS => 0});
+ $td->runtest("check output",
+ {$td->FILE => "tmp3"},
+ {$td->FILE => $file});
+ $td->runtest("check output",
+ {$td->FILE => "tmp4"},
+ {$td->FILE => $file});
+}
+
+cleanup();
+
+$td->report(22);
+
+sub cleanup
+{
+ system("rm -f tmp?");
+}
diff --git a/libtests/qtest/aes/data1 b/libtests/qtest/aes/data1
new file mode 100644
index 00000000..577a57d6
--- /dev/null
+++ b/libtests/qtest/aes/data1
Binary files differ
diff --git a/libtests/qtest/aes/data2 b/libtests/qtest/aes/data2
new file mode 100644
index 00000000..ab02cc99
--- /dev/null
+++ b/libtests/qtest/aes/data2
Binary files differ
diff --git a/libtests/qtest/aes/test-vector.cipher b/libtests/qtest/aes/test-vector.cipher
new file mode 100755
index 00000000..77cab1f1
--- /dev/null
+++ b/libtests/qtest/aes/test-vector.cipher
@@ -0,0 +1 @@
+iÄàØj{0ØÍ·€p´ÅZ•Odòäènžî‚ÒhH™ \ No newline at end of file
diff --git a/libtests/qtest/aes/test-vector.clear b/libtests/qtest/aes/test-vector.clear
new file mode 100644
index 00000000..2fdaa8e3
--- /dev/null
+++ b/libtests/qtest/aes/test-vector.clear
Binary files differ