| 1 |
stefan |
1.1 |
|
| 2 |
|
|
use Test; |
| 3 |
|
|
BEGIN { plan tests => 1 }; |
| 4 |
|
|
$|=1; |
| 5 |
|
|
|
| 6 |
|
|
use OpenSSL::Cipher qw(enum_ciphers new_encrypt new_decrypt); |
| 7 |
|
|
use OpenSSL::Rand 'randbytes'; |
| 8 |
|
|
|
| 9 |
|
|
%cip = enum_ciphers(); |
| 10 |
|
|
my ($msg,$err) = ('hallo Du kleiner Gartenzwerg, Alice liebt Bob', 0); |
| 11 |
|
|
|
| 12 |
|
|
for my $c (keys %cip) { |
| 13 |
|
|
my $key = randbytes($cip{$c}); |
| 14 |
|
|
my ($dec, $enc); |
| 15 |
|
|
$ctx = new_encrypt $c, $key; |
| 16 |
|
|
$enc = $ctx->update($msg); |
| 17 |
|
|
$enc .= $ctx->final; |
| 18 |
|
|
print STDERR "E\10"; |
| 19 |
|
|
$ctx = new_decrypt $c, $key; |
| 20 |
|
|
$dec = $ctx->update($enc); |
| 21 |
|
|
$dec .= $ctx->final; |
| 22 |
|
|
print STDERR "D\10"; |
| 23 |
|
|
$err++ if($dec ne $msg) |
| 24 |
|
|
} |
| 25 |
|
|
ok($err ? 0 :1); |