From 677bc2677475ecd6dafe478cb580005affab3394 Mon Sep 17 00:00:00 2001 From: Gianni Ceccarelli Date: Thu, 22 Jun 2023 13:03:52 +0100 Subject: fix padding --- lib/Config/ClawsMail/PasswordStore.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Config/ClawsMail/PasswordStore.pm b/lib/Config/ClawsMail/PasswordStore.pm index 52a0a67..3fbb68f 100644 --- a/lib/Config/ClawsMail/PasswordStore.pm +++ b/lib/Config/ClawsMail/PasswordStore.pm @@ -38,7 +38,7 @@ sub decrypt($self,$input) { $rounds, 'SHA1', 32, # 32 bytes = 256 bits,for AES-256 ); - my $cipher = Crypt::Mode::CBC->new('AES', 0); # 0 = no padding + my $cipher = Crypt::Mode::CBC->new('AES', 5); # 5 = zero padding $ciphertext = decode_b64($ciphertext); @@ -49,7 +49,10 @@ sub decrypt($self,$input) { # the first 16 bytes are generated from the IV, we don't care # about them - return substr($cleartext,16); + $cleartext = substr($cleartext,16); + $cleartext =~ s/\0+\z//; + + return $cleartext; } sub password_for($self,$section,$key) { -- cgit v1.2.3