version 1.29, 2007/02/19 00:22:42 |
version 1.30, 2007/02/19 01:37:10 |
|
|
package Palm::Keyring; |
package Palm::Keyring; |
# $RedRiver: Keyring.pm,v 1.28 2007/02/18 05:50:25 andrew Exp $ |
# $RedRiver: Keyring.pm,v 1.29 2007/02/19 00:22:42 andrew Exp $ |
######################################################################## |
######################################################################## |
# Keyring.pm *** Perl class for Keyring for Palm OS databases. |
# Keyring.pm *** Perl class for Keyring for Palm OS databases. |
# |
# |
|
|
} elsif ($self->{version} == 5) { |
} elsif ($self->{version} == 5) { |
my $blocksize = $CRYPTS[ $self->{appinfo}->{cipher} ]{blocksize}; |
my $blocksize = $CRYPTS[ $self->{appinfo}->{cipher} ]{blocksize}; |
my ($field, $extra) = _parse_field($rec->{data}); |
my ($field, $extra) = _parse_field($rec->{data}); |
my ($ivec, $encrypted) = unpack "A$blocksize A*", $extra; |
my $ivec = substr $extra, 0, $blocksize; |
|
my $encrypted = substr $extra, $blocksize; |
|
|
if ($self->{options}->{v4compatible}) { |
if ($self->{options}->{v4compatible}) { |
$rec->{name} = $field->{data}; |
$rec->{name} = $field->{data}; |
|
|
my $len = length $packed; |
my $len = length $packed; |
my $blocksize = $CRYPTS[ $self->{appinfo}->{cipher} ]{blocksize}; |
my $blocksize = $CRYPTS[ $self->{appinfo}->{cipher} ]{blocksize}; |
|
|
$rec->{data} = pack "A$len A$blocksize A*", |
$rec->{data} = join '', $packed, $rec->{ivec}, $rec->{encrypted}; |
$packed, $rec->{ivec}, $rec->{encrypted}; |
|
|
|
} else { |
} else { |
die 'Unsupported Version'; |
die 'Unsupported Version'; |
|
|
my $old = shift; |
my $old = shift; |
my $key = shift; |
my $key = shift; |
my $cipher = shift; |
my $cipher = shift; |
my $ivec = shift || pack("C*",map {rand(256)} 1..8); |
my $length = $CRYPTS[ $cipher ]{blocksize}; |
|
my $ivec = shift || pack("C*",map {rand(256)} 1..$length); |
|
|
my $keylen = $CRYPTS[ $cipher ]{keylen}; |
my $keylen = $CRYPTS[ $cipher ]{keylen}; |
my $cipher_name = $CRYPTS[ $cipher ]{name}; |
my $cipher_name = $CRYPTS[ $cipher ]{name}; |
|
|
croak("Needed parameter 'record' not passed!\n"); |
croak("Needed parameter 'record' not passed!\n"); |
} |
} |
|
|
if ( ! $self->Password($pass)) { |
if ( $pass && ! $self->Password($pass)) { |
croak("Invalid Password!\n"); |
croak("Invalid Password!\n"); |
} |
} |
|
|
|
|
|
|
if (! $pass) { |
if (! $pass) { |
delete $self->{password}; |
delete $self->{password}; |
delete $self->{key}; |
delete $self->{appinfo}->{key}; |
return 1; |
return 1; |
} |
} |
|
|
|
|
return undef, $field; |
return undef, $field; |
} |
} |
my $unpackstr = "S1 C1 C1 A$len"; |
my $unpackstr = "S1 C1 C1 A$len"; |
if ($len % 2) { |
if ($len % 2 && $len + 4 < length $field) { |
# trim the 0/1 byte padding for next even address. |
# trim the 0/1 byte padding for next even address. |
$unpackstr .= ' x' |
$unpackstr .= ' x' |
} |
} |