=================================================================== RCS file: /cvs/palm/Palm-Keyring/lib/Palm/Keyring.pm,v retrieving revision 1.11 retrieving revision 1.13 diff -u -r1.11 -r1.13 --- palm/Palm-Keyring/lib/Palm/Keyring.pm 2007/01/27 23:59:29 1.11 +++ palm/Palm-Keyring/lib/Palm/Keyring.pm 2007/01/28 18:13:28 1.13 @@ -8,8 +8,7 @@ # # This started as Memo.pm, I just made it work for Keyring. # -# $Id: Keyring.pm,v 1.11 2007/01/27 23:59:29 andrew Exp $ -# $RedRiver: Keyring.pm,v 1.10 2006/12/06 18:45:42 andrew Exp $ +# $RedRiver: Keyring.pm,v 1.12 2007/01/28 00:18:46 andrew Exp $ use strict; package Palm::Keyring; @@ -27,7 +26,7 @@ # One liner, to allow MakeMaker to work. -$VERSION = do { my @r = (q$Revision: 1.11 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +$VERSION = do { my @r = (q$Revision: 1.13 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; @ISA = qw( Palm::StdAppInfo Palm::Raw ); @@ -37,9 +36,15 @@ =head1 SYNOPSIS + use Palm::PDB; use Palm::Keyring; + my $pdb = new Palm::PDB; $pdb->Load($file); - $pdb->Decrypt($assword); + foreach my $record (@{ $pdb->{'records'} }) { + print "$record->{'plaintext'}->{'name'}\n"; + } + $pdb->Decrypt($password); + # do something with the decrypted parts =head1 DESCRIPTION @@ -47,19 +52,22 @@ parses Keyring for Palm OS databases. See L. -It has the standard Palm::Raw with 2 additional public methods. +It has the standard Palm::PDB methods with 2 additional public methods. Decrypt and Encrypt. +It currently supports the v4 Keyring databases. The v5 databases from the pre-release keyring-2.0 are not supported. + =cut =head2 new - $pdb = new Palm::Keyring($password); + $pdb = new Palm::Keyring([$password]); Create a new PDB, initialized with the various Palm::Keyring fields and an empty record list. -Use this method if you're creating a Keyring PDB from scratch. +Use this method if you're creating a Keyring PDB from scratch otherwise you +can just use Palm::PDB::new(). =cut @@ -252,8 +260,15 @@ $self->{digest} ||= _calc_keys($self->{password}); + my $recordcount = 0; foreach my $record (@{ $self->{records} }) { - next unless defined $record->{data}; + $recordcount++; + # always skip the first record that has the password in it. + next if $recordcount <= 1; + unless (defined $record->{data}) { + warn "Invalid record " . ($recordcount - 1) . "\n"; + next; + } my ($name, $encrypted) = split /\000/, $record->{data}, 2; next unless $encrypted; @@ -443,7 +458,7 @@ =head1 AUTHOR -Andrew Fresh Eandrew@mad-techies.org +Andrew Fresh Eandrew@mad-techies.orgE =head1 SEE ALSO