b8e0434
From 2d6ec9bc13a0994ba5a5911c1c210082ed4da09f Mon Sep 17 00:00:00 2001
b8e0434
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
b8e0434
Date: Fri, 5 Sep 2014 11:04:30 +0200
b8e0434
Subject: [PATCH] Do not test the reason for decryption failure on bad key
b8e0434
MIME-Version: 1.0
b8e0434
Content-Type: text/plain; charset=UTF-8
b8e0434
Content-Transfer-Encoding: 8bit
b8e0434
b8e0434
Tests checking error message after using bad decryption key fails
b8e0434
randomly.
b8e0434
b8e0434
Some bad keys can fool the "Bad key/passphrase" heuristic in the
b8e0434
Convert::PEM::CBC::decode() because it's a feature a stream cipher to
b8e0434
spit out bad output on bad key. So the heuristic is just a kind
b8e0434
service to point to the cause of the decoding failure (i.e. bad key).
b8e0434
By probabilistic nature of the heuristic, we cannot rely on the
b8e0434
/^Decryption failed/ error message.
b8e0434
b8e0434
This patch removes these tests.
b8e0434
b8e0434
CPAN RT#27574
b8e0434
b8e0434
Signed-off-by: Petr Písař <ppisar@redhat.com>
b8e0434
---
b8e0434
 t/01-readwrite.t | 3 +--
b8e0434
 t/02-encode.t    | 3 +--
b8e0434
 2 files changed, 2 insertions(+), 4 deletions(-)
b8e0434
b8e0434
diff --git a/t/01-readwrite.t b/t/01-readwrite.t
b8e0434
index 42a4416..208eba1 100644
b8e0434
--- a/t/01-readwrite.t
b8e0434
+++ b/t/01-readwrite.t
b8e0434
@@ -1,5 +1,5 @@
b8e0434
 use strict;
b8e0434
-use Test::More tests => 16;
b8e0434
+use Test::More tests => 15;
b8e0434
 use Test::Exception;
b8e0434
 
b8e0434
 use Convert::PEM;
b8e0434
@@ -29,7 +29,6 @@ lives_ok { $pem->write( Filename => $objfile, Content => $obj, Password => 'xx'
b8e0434
 ok -e $objfile, 'output file exists';
b8e0434
 lives_ok { $obj2 = $pem->read( Filename => $objfile ) } 'can read';
b8e0434
 ok !defined $obj2, 'cannot read encrypted file';
b8e0434
-like $pem->errstr, qr/^Decryption failed/, 'errstr matches decryption failed';
b8e0434
 lives_ok { $obj2 = $pem->read( Filename => $objfile, Password => 'xx') } 'can read';
b8e0434
 is $obj->{TestObject}{int}, $obj2->{TestObject}{int}, 'input matches output';
b8e0434
 unlink $objfile;
b8e0434
diff --git a/t/02-encode.t b/t/02-encode.t
b8e0434
index 37aa987..9c6ab4c 100644
b8e0434
--- a/t/02-encode.t
b8e0434
+++ b/t/02-encode.t
b8e0434
@@ -1,5 +1,5 @@
b8e0434
 use strict;
b8e0434
-use Test::More tests => 9;
b8e0434
+use Test::More tests => 8;
b8e0434
 
b8e0434
 use Convert::PEM;
b8e0434
 use Math::BigInt;
b8e0434
@@ -25,7 +25,6 @@ $blob = $pem->encode( Content => $obj, Password => 'xx' );
b8e0434
 ok $blob, 'encode gave us something';
b8e0434
 $obj2 = $pem->decode( Content => $blob );
b8e0434
 ok !defined $obj2, 'decode fails on encrypted input';
b8e0434
-like $pem->errstr, qr/^Decryption failed/, 'errstr matches decrypt failed';
b8e0434
 $obj2 = $pem->decode( Content => $blob, Password => 'xx' );
b8e0434
 is $obj->{TestObject}{int}, $obj2->{TestObject}{int}, 'input matches output';
b8e0434
 
b8e0434
-- 
b8e0434
1.9.3
b8e0434