aboutsummaryrefslogtreecommitdiffstats
path: root/src/wrap/perl-xs/t
diff options
context:
space:
mode:
authorlloyd <[email protected]>2009-10-09 18:11:14 +0000
committerlloyd <[email protected]>2009-10-09 18:11:14 +0000
commit621d5391649011aa63b5d3f706f6f2544a03fc21 (patch)
treeb3562b03fae45fb73f71cafbffcc00a60cfbce76 /src/wrap/perl-xs/t
parenta62f8baf340cdb977fdab8f29cfa71340c07c0e9 (diff)
Drop the SWIG wrappers; never worked. Move the XS wrappers to src/wrap/perl-xs
Diffstat (limited to 'src/wrap/perl-xs/t')
-rw-r--r--src/wrap/perl-xs/t/base64.t273
-rw-r--r--src/wrap/perl-xs/t/filt.t56
-rw-r--r--src/wrap/perl-xs/t/hex.t256
-rw-r--r--src/wrap/perl-xs/t/oid.t45
-rw-r--r--src/wrap/perl-xs/t/pipe.t98
-rw-r--r--src/wrap/perl-xs/t/testutl.pl26
-rw-r--r--src/wrap/perl-xs/t/x509cert.t42
7 files changed, 796 insertions, 0 deletions
diff --git a/src/wrap/perl-xs/t/base64.t b/src/wrap/perl-xs/t/base64.t
new file mode 100644
index 000000000..f0973e13e
--- /dev/null
+++ b/src/wrap/perl-xs/t/base64.t
@@ -0,0 +1,273 @@
+# vim: set ft=perl:
+# Before `make install' is performed this script should be runnable with
+# `make test'. After `make install' it should work as `perl test.pl'
+
+######################### We start with some black magic to print on failure.
+
+# Change 1..1 below to 1..last_test_to_print .
+# (It may become useful if the test is moved to ./t subdirectory.)
+
+BEGIN { $| = 1; print "1..24\n"; }
+END { print "not ok 1\n" unless $loaded; }
+
+require 't/testutl.pl';
+use Botan;
+
+$loaded = 1;
+print "ok 1\n";
+
+######################### End of black magic.
+
+# Insert your test code below (better if it prints "ok 13"
+# (correspondingly "not ok 13") depending on the success of chunk 13
+# of the test code):
+
+use strict;
+
+# Data prep
+
+my $botan_lic_b64_garbage = <<'EOF';
+Q29weXJpZ2h0IChDKSAxOTk5LTIwMDQgVGhlIEJvdGFuIFByb2plY3QuIEFsbCBy__�
+aWdodHMgcmVzZXJ2ZWQuCgpSZWRpc3RyaWJ1dGlvbiBhbmQgdXNlIGluIHNvdXJj$$*:
+ZSBhbmQgYmluYXJ5IGZvcm1zLCBmb3IgYW55IHVzZSwgd2l0aCBvciB3aXRob3V0!@#$%^&*(
+Cm1vZGlmaWNhdGlvbiwgaXMgcGVybWl0dGVkIHByb3ZpZGVkIHRoYXQgdGhlIGZv[\]
+bGxvd2luZyBjb25kaXRpb25zIGFyZSBtZXQ6CgoxLiBSZWRpc3RyaWJ1dGlvbnMg'~`
+b2Ygc291cmNlIGNvZGUgbXVzdCByZXRhaW4gdGhlIGFib3ZlIGNvcHlyaWdodCBu()
+b3RpY2UsIHRoaXMKbGlzdCBvZiBjb25kaXRpb25zLCBhbmQgdGhlIGZvbGxvd2lu
+ZyBkaXNjbGFpbWVyLgoKMi4gUmVkaXN0cmlidXRpb25zIGluIGJpbmFyeSBmb3Jt
+IG11c3QgcmVwcm9kdWNlIHRoZSBhYm92ZSBjb3B5cmlnaHQgbm90aWNlLAp0aGlz
+IGxpc3Qgb2YgY29uZGl0aW9ucywgYW5kIHRoZSBmb2xsb3dpbmcgZGlzY2xhaW1l
+ciBpbiB0aGUgZG9jdW1lbnRhdGlvbgphbmQvb3Igb3RoZXIgbWF0ZXJpYWxzIHBy_,^
+b3ZpZGVkIHdpdGggdGhlIGRpc3RyaWJ1dGlvbi4KClRISVMgU09GVFdBUkUgSVMg{|}~~~~~
+UFJPVklERUQgQlkgVEhFIEFVVEhPUihTKSAiQVMgSVMiIEFORCBBTlkgRVhQUkVT~~~~~~~~
+UyBPUiBJTVBMSUVECldBUlJBTlRJRVMsIElOQ0xVRElORywgQlVUIE5PVCBMSU1J__:;
+VEVEIFRPLCBUSEUgSU1QTElFRCBXQVJSQU5USUVTIE9GCk1FUkNIQU5UQUJJTElU
+WSBBTkQgRklUTkVTUyBGT1IgQSBQQVJUSUNVTEFSIFBVUlBPU0UsIEFSRSBESVND
+TEFJTUVELgoKSU4gTk8gRVZFTlQgU0hBTEwgVEhFIEFVVEhPUihTKSBPUiBDT05U
+UklCVVRPUihTKSBCRSBMSUFCTEUgRk9SIEFOWSBESVJFQ1QsCklORElSRUNULCBJ
+TkNJREVOVEFMLCBTUEVDSUFMLCBFWEVNUExBUlksIE9SIENPTlNFUVVFTlRJQUwg
+REFNQUdFUyAoSU5DTFVESU5HLApCVVQgTk9UIExJTUlURUQgVE8sIFBST0NVUkVN
+RU5UIE9GIFNVQlNUSVRVVEUgR09PRFMgT1IgU0VSVklDRVM7IExPU1MgT0YgVVNF
+LApEQVRBLCBPUiBQUk9GSVRTOyBPUiBCVVNJTkVTUyBJTlRFUlJVUFRJT04pIEhP
+V0VWRVIgQ0FVU0VEIEFORCBPTiBBTlkgVEhFT1JZIE9GCkxJQUJJTElUWSwgV0hF
+VEhFUiBJTiBDT05UUkFDVCwgU1RSSUNUIExJQUJJTElUWSwgT1IgVE9SVCAoSU5D
+TFVESU5HIE5FR0xJR0VOQ0UKT1IgT1RIRVJXSVNFKSBBUklTSU5HIElOIEFOWSBX
+QVkgT1VUIE9GIFRIRSBVU0UgT0YgVEhJUyBTT0ZUV0FSRSwgRVZFTiBJRgpBRFZJ
+U0VEIE9GIFRIRSBQT1NTSUJJTElUWSBPRiBTVUNIIERBTUFHRS4K
+EOF
+
+my $botan_lic_b64_ws = $botan_lic_b64_garbage;
+$botan_lic_b64_ws =~ s/[^A-Za-z0-9+\/= \n]//g;
+
+my $botan_lic_b64 = $botan_lic_b64_ws;
+$botan_lic_b64 =~ s/[ \n]//g;
+
+
+my $botan_lic = <<'EOF';
+Copyright (C) 1999-2004 The Botan Project. All rights reserved.
+
+Redistribution and use in source and binary forms, for any use, with or without
+modification, is permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+list of conditions, and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+this list of conditions, and the following disclaimer in the documentation
+and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
+
+IN NO EVENT SHALL THE AUTHOR(S) OR CONTRIBUTOR(S) BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+EOF
+
+
+# Decoder...
+
+my $f;
+
+eval { $f = Botan::Base64_Decoder->new(&Botan::NONE); };
+print "not " if $@ || !defined $f;
+print "ok 2\n";
+
+my $dec;
+eval { $dec = Botan::Pipe->new($f); };
+print "not " if $@ || !defined $dec;
+print "ok 3\n";
+
+eval { $f = Botan::Base64_Decoder->new(&Botan::IGNORE_WS); };
+print "not " if $@ || !defined $f;
+print "ok 4\n";
+
+my $dec_is;
+eval { $dec_is = Botan::Pipe->new($f); };
+print "not " if $@ || !defined $dec_is;
+print "ok 5\n";
+
+eval { $f = Botan::Base64_Decoder->new(&Botan::FULL_CHECK); };
+print "not " if $@ || !defined $f;
+print "ok 6\n";
+
+my $dec_fc;
+eval { $dec_fc = Botan::Pipe->new($f); };
+print "not " if $@ || !defined $dec_fc;
+print "ok 7\n";
+
+
+# Testing clean base64 input
+
+my $data;
+
+undef $data;
+eval {
+ $dec->process_msg($botan_lic_b64);
+ $data = $dec->read();
+};
+
+print "not " if $@ || $data ne $botan_lic;
+print "ok 8\n";
+
+undef $data;
+eval {
+ $dec_is->process_msg($botan_lic_b64);
+ $data = $dec_is->read();
+};
+
+print "not " if $@ || $data ne $botan_lic;
+print "ok 9\n";
+
+undef $data;
+eval {
+ $dec_fc->process_msg($botan_lic_b64);
+ $data = $dec_fc->read();
+};
+
+print "not " if $@ || $data ne $botan_lic;
+print "ok 10\n";
+
+
+# Testing base64 input with whitespaces
+
+undef $data;
+eval {
+ $dec->process_msg($botan_lic_b64_ws);
+ $dec->set_default_msg(1);
+ $data = $dec->read();
+};
+
+print "not " if $@ || $data ne $botan_lic;
+print "ok 11\n";
+
+undef $data;
+eval {
+ $dec_is->process_msg($botan_lic_b64_ws);
+ $dec_is->set_default_msg(1);
+ $data = $dec_is->read();
+};
+
+print "not " if $@ || $data ne $botan_lic;
+print "ok 12\n";
+
+undef $data;
+eval {
+ $dec_fc->process_msg($botan_lic_b64_ws);
+ $dec_fc->set_default_msg(1);
+ $data = $dec_fc->read();
+};
+
+print "not " unless $@ && !defined $data;
+print "ok 13\n";
+
+
+# Testing base64 input with garbage
+
+undef $data;
+eval {
+ $dec->process_msg($botan_lic_b64_garbage);
+ $dec->set_default_msg(2);
+ $data = $dec->read();
+};
+
+print "not " if $@ || $data ne $botan_lic;
+print "ok 14\n";
+
+undef $data;
+eval {
+ $dec_is->process_msg($botan_lic_b64_garbage);
+ $dec_is->set_default_msg(2);
+ $data = $dec_is->read();
+};
+
+print "not " unless $@ && !defined $data;
+print "ok 15\n";
+
+undef $data;
+eval {
+ $dec_fc->process_msg($botan_lic_b64_garbage);
+ $dec_fc->set_default_msg(2);
+ $data = $dec_fc->read();
+};
+
+print "not " unless $@ && !defined $data;
+print "ok 16\n";
+
+
+# Encoder...
+
+eval { $f = Botan::Base64_Encoder->new(); };
+print "not " if $@ || !defined $f;
+print "ok 17\n";
+
+my $enc;
+eval { $enc = Botan::Pipe->new($f); };
+print "not " if $@ || !defined $enc;
+print "ok 18\n";
+
+eval { $f = Botan::Base64_Encoder->new(1, 5); };
+print "not " if $@ || !defined $f;
+print "ok 19\n";
+
+my $enc2;
+eval { $enc2 = Botan::Pipe->new($f); };
+print "not " if $@ || !defined $enc2;
+print "ok 20\n";
+
+undef $data;
+eval {
+ $enc->process_msg("Hello\n");
+ $data = $enc->read();
+};
+print "not " if $@ || $data ne "SGVsbG8K";
+print "ok 21\n";
+
+undef $data;
+eval {
+ $enc2->process_msg("Hello\n");
+ $data = $enc2->read();
+};
+print "not " if $@ || $data ne "SGVsb\nG8K\n";
+print "ok 22\n";
+
+
+# Encoder with decoder...
+
+my $p;
+eval {
+ $p = Botan::Pipe->new(
+ Botan::Base64_Encoder->new(),
+ Botan::Base64_Decoder->new(),
+ );
+};
+print "not " if $@ || !defined $p;
+print "ok 23\n";
+
+print "not " unless random_message_ok($p);
+print "ok 24\n";
diff --git a/src/wrap/perl-xs/t/filt.t b/src/wrap/perl-xs/t/filt.t
new file mode 100644
index 000000000..2a7b4c8ba
--- /dev/null
+++ b/src/wrap/perl-xs/t/filt.t
@@ -0,0 +1,56 @@
+# vim: set ft=perl:
+# Before `make install' is performed this script should be runnable with
+# `make test'. After `make install' it should work as `perl test.pl'
+
+######################### We start with some black magic to print on failure.
+
+# Change 1..1 below to 1..last_test_to_print .
+# (It may become useful if the test is moved to ./t subdirectory.)
+
+BEGIN { $| = 1; print "1..5\n"; }
+END { print "not ok 1\n" unless $loaded; }
+
+use Botan;
+
+$loaded = 1;
+print "ok 1\n";
+
+######################### End of black magic.
+
+# Insert your test code below (better if it prints "ok 13"
+# (correspondingly "not ok 13") depending on the success of chunk 13
+# of the test code):
+
+use strict;
+
+my $pipe = Botan::Pipe->new(Botan::Hex_Encoder->new());
+
+print "not " unless $pipe;
+print "ok 2\n";
+
+$pipe->process_msg('FOO');
+
+print "not " if $pipe->read() ne '464F4F';
+print "ok 3\n";
+
+$pipe = Botan::Pipe->new(Botan::Hex_Encoder->new(0, 0, 1));
+
+print "not " unless $pipe;
+print "ok 4\n";
+
+$pipe->process_msg('FOO');
+
+print "not " if $pipe->read() ne '464f4f';
+print "ok 5\n";
+
+
+
+
+
+
+#my $pipe = Botan::Pipe->new(Botan::Base64_Encoder->new());
+#$pipe->process_msg('FOO');
+#
+#print "not " if $pipe->read() ne 'Rk9P';
+#print "ok 4\n";
+
diff --git a/src/wrap/perl-xs/t/hex.t b/src/wrap/perl-xs/t/hex.t
new file mode 100644
index 000000000..6f447b25c
--- /dev/null
+++ b/src/wrap/perl-xs/t/hex.t
@@ -0,0 +1,256 @@
+# vim: set ft=perl:
+# Before `make install' is performed this script should be runnable with
+# `make test'. After `make install' it should work as `perl test.pl'
+
+######################### We start with some black magic to print on failure.
+
+# Change 1..1 below to 1..last_test_to_print .
+# (It may become useful if the test is moved to ./t subdirectory.)
+
+BEGIN { $| = 1; print "1..24\n"; }
+END { print "not ok 1\n" unless $loaded; }
+
+require 't/testutl.pl';
+use Botan;
+
+$loaded = 1;
+print "ok 1\n";
+
+######################### End of black magic.
+
+# Insert your test code below (better if it prints "ok 13"
+# (correspondingly "not ok 13") depending on the success of chunk 13
+# of the test code):
+
+use strict;
+
+# Data prep
+
+my ($hex, $hex_ws, $hex_garbage);
+while ( $_ = <DATA> )
+{
+ $hex_garbage .= $_;
+ s/[^[:xdigit:][:space:]]//g;
+ $hex_ws .= $_;
+ s/[^[:xdigit:]]//g;
+ $hex .= $_;
+}
+my $data_test = pack("H*", $hex);
+
+# Decoder...
+
+my $f;
+
+eval { $f = Botan::Hex_Decoder->new(&Botan::NONE); };
+print "not " if $@ || !defined $f;
+print "ok 2\n";
+
+my $dec;
+eval { $dec = Botan::Pipe->new($f); };
+print "not " if $@ || !defined $dec;
+print "ok 3\n";
+
+eval { $f = Botan::Hex_Decoder->new(&Botan::IGNORE_WS); };
+print "not " if $@ || !defined $f;
+print "ok 4\n";
+
+my $dec_is;
+eval { $dec_is = Botan::Pipe->new($f); };
+print "not " if $@ || !defined $dec_is;
+print "ok 5\n";
+
+eval { $f = Botan::Hex_Decoder->new(&Botan::FULL_CHECK); };
+print "not " if $@ || !defined $f;
+print "ok 6\n";
+
+my $dec_fc;
+eval { $dec_fc = Botan::Pipe->new($f); };
+print "not " if $@ || !defined $dec_fc;
+print "ok 7\n";
+
+
+# Testing clean hexadecimal input
+
+my $data;
+
+undef $data;
+eval {
+ $dec->process_msg($hex);
+ $data = $dec->read();
+};
+
+print "not " if $@ || $data ne $data_test;
+print "ok 8\n";
+
+undef $data;
+eval {
+ $dec_is->process_msg($hex);
+ $data = $dec_is->read();
+};
+
+print "not " if $@ || $data ne $data_test;
+print "ok 9\n";
+
+undef $data;
+eval {
+ $dec_fc->process_msg($hex);
+ $data = $dec_fc->read();
+};
+
+print "not " if $@ || $data ne $data_test;
+print "ok 10\n";
+
+
+# Testing hexadecimal input with whitespaces
+
+undef $data;
+eval {
+ $dec->process_msg($hex_ws);
+ $dec->set_default_msg(1);
+ $data = $dec->read();
+};
+
+print "not " if $@ || $data ne $data_test;
+print "ok 11\n";
+
+undef $data;
+eval {
+ $dec_is->process_msg($hex_ws);
+ $dec_is->set_default_msg(1);
+ $data = $dec_is->read();
+};
+
+print "not " if $@ || $data ne $data_test;
+print "ok 12\n";
+
+undef $data;
+eval {
+ $dec_fc->process_msg($hex_ws);
+ $dec_fc->set_default_msg(1);
+ $data = $dec_fc->read();
+};
+
+print "not " unless $@ && !defined $data;
+print "ok 13\n";
+
+
+# Testing hexadecimal input with garbage
+
+undef $data;
+eval {
+ $dec->process_msg($hex_garbage);
+ $dec->set_default_msg(2);
+ $data = $dec->read();
+};
+
+print "not " if $@ || $data ne $data_test;
+print "ok 14\n";
+
+undef $data;
+eval {
+ $dec_is->process_msg($hex_garbage);
+ $dec_is->set_default_msg(2);
+ $data = $dec_is->read();
+};
+
+print "not " unless $@ && !defined $data;
+print "ok 15\n";
+
+undef $data;
+eval {
+ $dec_fc->process_msg($hex_garbage);
+ $dec_fc->set_default_msg(2);
+ $data = $dec_fc->read();
+};
+
+print "not " unless $@ && !defined $data;
+print "ok 16\n";
+
+
+# Encoder...
+
+eval { $f = Botan::Hex_Encoder->new(); };
+print "not " if $@ || !defined $f;
+print "ok 17\n";
+
+my $enc;
+eval { $enc = Botan::Pipe->new($f); };
+print "not " if $@ || !defined $enc;
+print "ok 18\n";
+
+eval { $f = Botan::Hex_Encoder->new(1, 5, 1); };
+print "not " if $@ || !defined $f;
+print "ok 19\n";
+
+my $enc2;
+eval { $enc2 = Botan::Pipe->new($f); };
+print "not " if $@ || !defined $enc2;
+print "ok 20\n";
+
+undef $data;
+eval {
+ $enc->process_msg("Hello\n");
+ $data = $enc->read();
+};
+print "not " if $@ || $data ne "48656C6C6F0A";
+print "ok 21\n";
+
+undef $data;
+eval {
+ $enc2->process_msg("Hello\n");
+ $data = $enc2->read();
+};
+print "not " if $@ || $data ne "48656\nc6c6f\n0a\n";
+print "ok 22\n";
+
+
+# Encoder with decoder...
+
+my $p;
+eval {
+ $p = Botan::Pipe->new(
+ Botan::Hex_Encoder->new(),
+ Botan::Hex_Decoder->new(),
+ );
+};
+print "not " if $@ || !defined $p;
+print "ok 23\n";
+
+print "not " unless random_message_ok($p);
+print "ok 24\n";
+
+
+
+__DATA__
+cb13 4a4d 7522 1fd3 c6f6 7786 d04b 3043 ..JMu"....w..K..
+4552 4bcf 4d2b 9d71 0cfe 4d6a 1caf bcfd .RK.M+.q..Mj....
+8f91 6151 ff85 e900 7e6a bafc 15e9 ae51 ...Q....~j.....Q
+b14b 7210 bb40 5958 2b82 d49e b808 68a5 .Kr..@YX+.....h.
+7945 9dec f686 9b98 989e 826d 8088 6ee7 y..........m..n.
+d066 1eac 8c34 c461 bb54 7726 87ab d681 .........Tw&....
+a0be 52e5 1128 0cf2 759e cb2d e690 4ed9 ..R..(..u..-..N.
+7e88 bda7 2523 4a0f 185a 02b1 f898 fc41 ~...%#J..Z......
+dd48 fa87 945d 7611 b8c9 a50a 2de2 b670 .H...]v.....-..p
+0056 c8be 2cbb e7d0 1e70 4a3d 79f0 dce9 .V..,....pJ=y...
+b57f 154b 2b3a db73 f086 de11 9f3e 1641 ...K+:.s.....>..
+3a28 8b9b bb0f 682b 80db b791 89e0 62c0 :(....h+........
+7204 db97 5432 2eb0 a04e f38e 809f 7223 r...T....N....r#
+912e e552 1452 6dd2 e09f dd06 c715 7c1a ...R.Rm.......|.
+fe3d d6cc b6d0 a17a 27d7 4327 4e43 8af3 .=.....z'..'N...
+6eb5 e9f8 bfe9 34c3 6636 8243 358f 966d n..............m
+7d87 d17b 5c37 6acb 4972 f4ec 6806 bbde }..{\.j.Ir..h...
+2689 a019 a9e2 4101 7fe2 de72 bc03 eb5e &..........r...^
+b699 2d6b f8cd a08e 6e01 edfc a81a 94b6 ..-k....n.......
+9073 15fb efb2 c8d9 9f85 6633 85f1 e9d0 .s..............
+20ce 578b ab9d 2e51 b947 69bf fba5 82c6 .W....Q.Gi.....
+2ed0 dd36 d679 a399 7db3 8a0d cdef 0eda .....y..}.......
+e761 e7f1 5b17 3f67 0c83 215a eddf 9d2a ....[.?g..!Z...*
+5e70 0a77 c92e 94e1 a82b fd7c f10a 894f ^p.w.....+.|...O
+2955 f0e8 7398 f409 2040 b797 da03 a5a6 )U..s... @......
+7ba4 c3c9 2659 b9f7 6a56 e17a b481 983f {...&Y..jV.z...?
+00ed 3cc8 5a22 ad5c b6e0 3566 d717 35a6 ..<.Z".\........
+1523 4104 de63 477e fd24 68e5 e816 98df .#....G~.$h.....
+1747 417e db72 a76a be5b b9dc 3dfb 2d05 .G.~.r.j.[..=.-.
+d27f e597 eafc 9a29 15c5 792d 9c88 9aea .......)..y-....
+485e e431 96c3 7723 da6d 28b2 477a fd12 H^....w#.m(.Gz..
+e645 5dcd 7d5a d8b4 7acc 10b2 b41a e11d ..].}Z..z.......
diff --git a/src/wrap/perl-xs/t/oid.t b/src/wrap/perl-xs/t/oid.t
new file mode 100644
index 000000000..66204541f
--- /dev/null
+++ b/src/wrap/perl-xs/t/oid.t
@@ -0,0 +1,45 @@
+# vim: set ft=perl:
+# Before `make install' is performed this script should be runnable with
+# `make test'. After `make install' it should work as `perl test.pl'
+
+######################### We start with some black magic to print on failure.
+
+# Change 1..1 below to 1..last_test_to_print .
+# (It may become useful if the test is moved to ./t subdirectory.)
+
+BEGIN { $| = 1; print "1..6\n"; }
+END { print "not ok 1\n" unless $loaded; }
+
+use Botan;
+
+$loaded = 1;
+print "ok 1\n";
+
+######################### End of black magic.
+
+# Insert your test code below (better if it prints "ok 13"
+# (correspondingly "not ok 13") depending on the success of chunk 13
+# of the test code):
+
+use strict;
+
+print "not " unless Botan::OIDS::have_oid('X520.CommonName');
+print "ok 2\n";
+
+my $oid_c = Botan::OID->new('2.5.4.3');
+print "not " if Botan::OIDS::lookup_by_oid($oid_c) ne 'X520.CommonName';
+print "ok 3\n";
+
+my $oid_x = Botan::OIDS::lookup_by_name('X520.CommonName');
+print "not " if $oid_x->as_string() ne '2.5.4.3';
+print "ok 4\n";
+
+my $oid_foo_num = '1.2.3.4.5.6.7.8.9.10.11.12.13.14.15';
+my $oid_foo = Botan::OID->new($oid_foo_num);
+print "not " if Botan::OIDS::lookup_by_oid($oid_foo) ne $oid_foo_num;
+print "ok 5\n";
+
+Botan::OIDS::add_oid($oid_foo, 'Zito.Foo');
+
+print "not " if Botan::OIDS::lookup_by_oid($oid_foo) ne 'Zito.Foo';
+print "ok 6\n";
diff --git a/src/wrap/perl-xs/t/pipe.t b/src/wrap/perl-xs/t/pipe.t
new file mode 100644
index 000000000..f850d8519
--- /dev/null
+++ b/src/wrap/perl-xs/t/pipe.t
@@ -0,0 +1,98 @@
+# vim: set ft=perl:
+# Before `make install' is performed this script should be runnable with
+# `make test'. After `make install' it should work as `perl test.pl'
+
+######################### We start with some black magic to print on failure.
+
+# Change 1..1 below to 1..last_test_to_print .
+# (It may become useful if the test is moved to ./t subdirectory.)
+
+BEGIN { $| = 1; print "1..20\n"; }
+END { print "not ok 1\n" unless $loaded; }
+
+use Botan;
+
+$loaded = 1;
+print "ok 1\n";
+
+######################### End of black magic.
+
+# Insert your test code below (better if it prints "ok 13"
+# (correspondingly "not ok 13") depending on the success of chunk 13
+# of the test code):
+
+use strict;
+
+my $pipe = Botan::Pipe->new();
+
+print "not " unless $pipe;
+print "ok 2\n";
+
+$pipe->start_msg();
+$pipe->write('Hello world');
+$pipe->end_msg();
+
+print "not " if $pipe->message_count() != 1;
+print "ok 3\n";
+
+print "not " if $pipe->remaining() != 11;
+print "ok 4\n";
+
+print "not " if $pipe->end_of_data();
+print "ok 5\n";
+
+print "not " if $pipe->read() ne 'Hello world';
+print "ok 6\n";
+
+print "not " if $pipe->remaining() != 0;
+print "ok 7\n";
+
+print "not " unless $pipe->end_of_data();
+print "ok 8\n";
+
+$pipe->process_msg('Hello world');
+
+print "not " if $pipe->message_count() != 2;
+print "ok 9\n";
+
+my $msg_num = $pipe->message_count() -1;
+
+print "not " if $pipe->read(5, $msg_num) ne 'Hello';
+print "ok 10\n";
+
+print "not " if $pipe->read(6, $msg_num) ne ' world';
+print "ok 11\n";
+
+print "not " if $pipe->remaining() != 0;
+print "ok 12\n";
+
+print "not " unless $pipe->end_of_data();
+print "ok 13\n";
+
+$pipe->process_msg("The\0string\0with\0null\0chars\0");
+$msg_num = $pipe->message_count() -1;
+
+print "not " if $pipe->read(80, $msg_num) ne "The\0string\0with\0null\0chars\0";
+print "ok 14\n";
+
+$pipe->process_msg('FOO BAR');
+$pipe->set_default_msg($pipe->message_count() -1);
+
+print "not " if $pipe->peek(3) ne 'FOO';
+print "ok 15\n";
+
+print "not " if $pipe->peek(3, 4) ne 'BAR';
+print "ok 16\n";
+
+print "not " if $pipe->peek() ne 'FOO BAR';
+print "ok 17\n";
+
+print "not " if $pipe->read() ne 'FOO BAR';
+print "ok 18\n";
+
+print "not " if $pipe->remaining() != 0;
+print "ok 19\n";
+
+print "not " unless $pipe->end_of_data();
+print "ok 20\n";
+
diff --git a/src/wrap/perl-xs/t/testutl.pl b/src/wrap/perl-xs/t/testutl.pl
new file mode 100644
index 000000000..add6f6a45
--- /dev/null
+++ b/src/wrap/perl-xs/t/testutl.pl
@@ -0,0 +1,26 @@
+#!/usr/bin/perl
+
+sub random_message_ok
+{
+ my ($pipe, $iter, $chunkmax) = @_;
+ $iter = 100 unless defined $iter;
+ $chunkmax = 300 unless defined $chunkmax;
+ eval {
+ my $input = '';
+ $pipe->start_msg();
+ for(my $i = 0; $i < $iter; $i++)
+ {
+ my $chunk = '';
+ my $chunklen = int(rand($chunkmax));
+ $chunk .= pack("C", int(rand(256))) while $chunklen--;
+ $input .= $chunk;
+ $pipe->write($chunk);
+ }
+ $pipe->end_msg();
+ my $msg_num = $pipe->message_count() -1;
+ my $output = $pipe->read(0xFFFFFFFF, $msg_num);
+ return $input eq $output;
+ };
+}
+
+1;
diff --git a/src/wrap/perl-xs/t/x509cert.t b/src/wrap/perl-xs/t/x509cert.t
new file mode 100644
index 000000000..2a943aeac
--- /dev/null
+++ b/src/wrap/perl-xs/t/x509cert.t
@@ -0,0 +1,42 @@
+# vim: set ft=perl:
+# Before `make install' is performed this script should be runnable with
+# `make test'. After `make install' it should work as `perl test.pl'
+
+######################### We start with some black magic to print on failure.
+
+# Change 1..1 below to 1..last_test_to_print .
+# (It may become useful if the test is moved to ./t subdirectory.)
+
+BEGIN { $| = 1; print "1..4\n"; }
+END { print "not ok 1\n" unless $loaded; }
+
+use Botan;
+
+$loaded = 1;
+print "ok 1\n";
+
+######################### End of black magic.
+
+# Insert your test code below (better if it prints "ok 13"
+# (correspondingly "not ok 13") depending on the success of chunk 13
+# of the test code):
+
+use strict;
+
+my $cert = Botan::X509_Certificate->new('data/ca.cert.der');
+
+print "not " if $cert->x509_version() != 3;
+print "ok 2\n";
+
+print "not " if $cert->start_time() ne '2000/8/20 21:48:00 UTC';
+print "ok 3\n";
+
+print "not " if $cert->end_time() ne '2002/8/10 21:48:00 UTC';
+print "ok 4\n";
+
+#my $subject = $cert->subject_dn()->get_attributes();
+#print STDERR "subject=", join(',', @{$subject}), "\n";
+#
+#my $issuer = $cert->issuer_dn()->get_attributes();
+#print STDERR "issuer=", join(',', @{$issuer}), "\n";
+#