Permalink
Browse files

pad key correctly

  • Loading branch information...
1 parent f219667 commit 08ae02e443696694288fc14ddcf4517c39e3047a @datamuc committed Mar 10, 2014
Showing with 6 additions and 2 deletions.
  1. +3 −1 lib/Nagios/Passive/Gearman.pm
  2. +3 −1 t/13.gearman.t
@@ -57,8 +57,10 @@ EOT
sub encrypted_string {
my $self = shift;
my $payload = $self->to_string;
+ my $key = $self->key;
+ $key = substr($key,0,32) . chr(0) x ( 32 - length( $key ) );
my $crypt = Crypt::Rijndael->new(
- _null_padding($self->key,32,'e'),
+ $key,
Crypt::Rijndael::MODE_ECB() # :-(
);
$payload = _null_padding($payload,32,'e');
View
@@ -16,11 +16,13 @@ my $nw = Nagios::Passive->create(
my $ns = Nagios::Passive->create(
gearman => Gearman::Client->new,
service_description=>'x',
- key => 'X',
+ key => 'X' x 32,
check_name => 'x',
host_name => 'localhost',
);
+ok eval { $ns->encrypted_string; 1 }, "encryption doesn't die";
+
is($nw->to_string, << 'EOE', 'to_string ok');
type=passive
host_name=localhost

0 comments on commit 08ae02e

Please sign in to comment.