=================================================================== RCS file: /cvs/palm/Palm-Keyring/lib/Palm/Keyring.pm,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- palm/Palm-Keyring/lib/Palm/Keyring.pm 2007/02/21 05:24:14 1.34 +++ palm/Palm-Keyring/lib/Palm/Keyring.pm 2007/02/22 04:11:35 1.35 @@ -1,5 +1,5 @@ package Palm::Keyring; -# $RedRiver: Keyring.pm,v 1.33 2007/02/21 01:26:07 andrew Exp $ +# $RedRiver: Keyring.pm,v 1.34 2007/02/21 05:24:14 andrew Exp $ ######################################################################## # Keyring.pm *** Perl class for Keyring for Palm OS databases. # @@ -16,6 +16,7 @@ use warnings; use Carp; +$Carp::Verbose = 1; use base qw/ Palm::StdAppInfo /; @@ -262,7 +263,7 @@ my $unpackstr = ("C1" x 8) # 8 uint8s in an array for the salt - . ("S1" x 2) # the iter (uint16) and the cipher (uint16) + . ("n1" x 2) # the iter (uint16) and the cipher (uint16) . ("C1" x 8); # and finally 8 more uint8s for the hash my (@salt, $iter, $cipher, @hash); @@ -303,7 +304,7 @@ my $packstr = ("C1" x 8) # 8 uint8s in an array for the salt - . ("S1" x 2) # the iter (uint16) and the cipher (uint16) + . ("n1" x 2) # the iter (uint16) and the cipher (uint16) . ("C1" x 8); # and finally 8 more uint8s for the hash my @salt = map { hex $_ } $appinfo->{salt} =~ /../gxm; @@ -407,8 +408,6 @@ sub _encrypt_v4 { - require Crypt::CBC; - my $new = shift; my $old = shift; my $digest = shift; @@ -559,9 +558,10 @@ $encrypted = $decrypted; } elsif ($cipher_name eq 'DES_EDE3' or $cipher_name eq 'Rijndael') { + require Crypt::CBC; my $c = Crypt::CBC->new( - -literal_key => 1, -key => $key, + -literal_key => 1, -iv => $ivec, -cipher => $cipher_name, -keysize => $keylen, @@ -659,7 +659,6 @@ sub _decrypt_v5 { - require Crypt::CBC; my $encrypted = shift; my $key = shift; @@ -677,9 +676,10 @@ $decrypted = $encrypted; } elsif ($cipher_name eq 'DES_EDE3' or $cipher_name eq 'Rijndael') { + require Crypt::CBC; my $c = Crypt::CBC->new( - -literal_key => 1, -key => $key, + -literal_key => 1, -iv => $ivec, -cipher => $cipher_name, -keysize => $keylen, @@ -791,7 +791,7 @@ } } } elsif ($self->{version} == 5) { - return _password_verify_v5($pass, $self->{appinfo}); + return _password_verify_v5($self->{appinfo}, $pass); } else { # XXX unsupported version } @@ -830,8 +830,8 @@ sub _password_verify_v5 { - my $pass = shift; my $appinfo = shift; + my $pass = shift; my $salt = pack("H*", $appinfo->{salt}); @@ -841,7 +841,9 @@ $CRYPTS[ $appinfo->{cipher} ]{DES_odd_parity}, ); + #print "Iter: '" . $appinfo->{iter} . "'\n"; #print "Key: '". unpack("H*", $key) . "'\n"; + #print "Salt: '". unpack("H*", $salt) . "'\n"; #print "Hash: '". $hash . "'\n"; #print "Hash: '". $appinfo->{masterhash} . "'\n"; @@ -1060,7 +1062,7 @@ $labels[3] = 'lastchange'; $labels[255] = 'notes'; - my ($len) = unpack "S1", $field; + my ($len) = unpack "n1", $field; if ($len + 4 > length $field) { return undef, $field; } @@ -1107,7 +1109,7 @@ $data = _pack_keyring_date($data); } my $len = length $data; - my $packstr = "S1 C1 C1 A*"; + my $packstr = "n1 C1 C1 A*"; my $packed = pack $packstr, ($len, $label, $font, $data);