version 1.11, 2007/01/27 23:59:29 |
version 1.13, 2007/01/28 18:13:28 |
|
|
# |
# |
# This started as Memo.pm, I just made it work for Keyring. |
# This started as Memo.pm, I just made it work for Keyring. |
# |
# |
# $Id$ |
# $RedRiver: Keyring.pm,v 1.12 2007/01/28 00:18:46 andrew Exp $ |
# $RedRiver: Keyring.pm,v 1.10 2006/12/06 18:45:42 andrew Exp $ |
|
|
|
use strict; |
use strict; |
package Palm::Keyring; |
package Palm::Keyring; |
|
|
|
|
=head1 SYNOPSIS |
=head1 SYNOPSIS |
|
|
|
use Palm::PDB; |
use Palm::Keyring; |
use Palm::Keyring; |
|
my $pdb = new Palm::PDB; |
$pdb->Load($file); |
$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 |
=head1 DESCRIPTION |
|
|
|
|
parses Keyring for Palm OS databases. See |
parses Keyring for Palm OS databases. See |
L<http://gnukeyring.sourceforge.net/>. |
L<http://gnukeyring.sourceforge.net/>. |
|
|
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. |
Decrypt and Encrypt. |
|
|
|
It currently supports the v4 Keyring databases. The v5 databases from the pre-release keyring-2.0 are not supported. |
|
|
=cut |
=cut |
|
|
=head2 new |
=head2 new |
|
|
$pdb = new Palm::Keyring($password); |
$pdb = new Palm::Keyring([$password]); |
|
|
Create a new PDB, initialized with the various Palm::Keyring fields |
Create a new PDB, initialized with the various Palm::Keyring fields |
and an empty record list. |
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 |
=cut |
|
|
|
|
|
|
$self->{digest} ||= _calc_keys($self->{password}); |
$self->{digest} ||= _calc_keys($self->{password}); |
|
|
|
my $recordcount = 0; |
foreach my $record (@{ $self->{records} }) { |
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; |
my ($name, $encrypted) = split /\000/, $record->{data}, 2; |
next unless $encrypted; |
next unless $encrypted; |
|
|
|
|
=head1 AUTHOR |
=head1 AUTHOR |
|
|
Andrew Fresh E<lt>andrew@mad-techies.org<gt> |
Andrew Fresh E<lt>andrew@mad-techies.orgE<gt> |
|
|
=head1 SEE ALSO |
=head1 SEE ALSO |
|
|