version 1.23, 2007/02/02 01:51:46 |
version 1.27, 2007/02/10 16:21:28 |
|
|
package Palm::Keyring; |
package Palm::Keyring; |
|
# $RedRiver: Keyring.pm,v 1.26 2007/02/06 02:58:50 andrew Exp $ |
# $RedRiver: Keyring.pm,v 1.22 2007/02/01 01:56:11 andrew Exp $ |
######################################################################## |
|
# Keyring.pm *** Perl class for Keyring for Palm OS databases. |
# |
# |
# Perl class for dealing with Keyring for Palm OS databases. |
|
# |
|
# This started as Memo.pm, I just made it work for Keyring. |
# This started as Memo.pm, I just made it work for Keyring. |
|
# |
|
# 2006.01.26 #*#*# andrew fresh <andrew@cpan.org> |
|
######################################################################## |
|
# Copyright (C) 2006, 2007 by Andrew Fresh |
|
# |
|
# This program is free software; you can redistribute it and/or modify |
|
# it under the same terms as Perl itself. |
|
######################################################################## |
use strict; |
use strict; |
use warnings; |
use warnings; |
|
|
use Carp; |
use Carp; |
|
|
use base qw/ Palm::StdAppInfo /; |
use base qw/ Palm::StdAppInfo /; |
|
|
use Digest::MD5 qw(md5); |
use Digest::MD5 qw(md5); |
use Crypt::DES; |
use Crypt::DES; |
use Readonly; |
|
|
|
Readonly my $ENCRYPT => 1; |
my $ENCRYPT = 1; |
Readonly my $DECRYPT => 0; |
my $DECRYPT = 0; |
Readonly my $MD5_CBLOCK => 64; |
my $MD5_CBLOCK = 64; |
Readonly my $kSalt_Size => 4; |
my $kSalt_Size = 4; |
Readonly my $EMPTY => q{}; |
my $EMPTY = q{}; |
Readonly my $SPACE => q{ }; |
my $SPACE = q{ }; |
Readonly my $NULL => chr 0; |
my $NULL = chr 0; |
|
|
# One liner, to allow MakeMaker to work. |
our $VERSION = 0.94; |
our $VERSION = 0.92; |
|
|
|
sub new { |
sub new { |
my $classname = shift; |
my $classname = shift; |
|
|
|
|
sub Password { |
sub Password { |
my $self = shift; |
my $self = shift; |
my $pass = shift || $self->{'password'}; |
my $pass = shift; |
my $new_pass = shift; |
my $new_pass = shift; |
|
|
|
if (! $pass) { |
|
delete $self->{password}; |
|
return 1; |
|
} |
|
|
if (! exists $self->{'records'}) { |
if (! exists $self->{'records'}) { |
# Give the PDB the first record that will hold the encrypted password |
# Give the PDB the first record that will hold the encrypted password |
$self->{'records'} = [ $self->new_Record ]; |
$self->{'records'} = [ $self->new_Record ]; |
|
|
Use this method if you're creating a Keyring PDB from scratch otherwise you |
Use this method if you're creating a Keyring PDB from scratch otherwise you |
can just use Palm::PDB::new() before calling Load(). |
can just use Palm::PDB::new() before calling Load(). |
|
|
|
If you pass in a password, it will initalize the first record with the encrypted |
|
password. |
|
|
=head2 Encrypt |
=head2 Encrypt |
|
|
$pdb->Encrypt($rec, $acct, [$password]); |
$pdb->Encrypt($rec, $acct[, $password]); |
|
|
Encrypts an account into a record, either with the password previously |
Encrypts an account into a record, either with the password previously |
used, or with a password that is passed. |
used, or with a password that is passed. |
|
|
$rec is a record from $pdb->{'records'} or a newly generated record. |
$rec is a record from $pdb->{'records'} or a new_Record(). |
$acct is a hashref in the format below. |
$acct is a hashref in the format below. |
|
|
my $acct = { |
my $acct = { |
|
|
}; |
}; |
|
|
If you have changed anything other than the lastchange, or don't pass in a |
If you have changed anything other than the lastchange, or don't pass in a |
lastchange record, Encrypt() will generate a new lastchange for you. |
lastchange key, Encrypt() will generate a new lastchange date for you. |
|
|
If you pass in a lastchange field that is different than the one in the |
If you pass in a lastchange field that is different than the one in the |
record, it will honor what you passed in. |
record, it will honor what you passed in. |
|
|
It also only uses the $acct->{'name'} if there is not already a $rec->{'name'}. |
Encrypt() only uses the $acct->{'name'} if there is not already a $rec->{'name'}. |
|
|
=head2 Decrypt |
=head2 Decrypt |
|
|
|
|
called new(), you only need to pass one password and it will set that as |
called new(), you only need to pass one password and it will set that as |
the password. |
the password. |
|
|
If nothing is passed, and there has been a password used before, |
If nothing is passed, it forgets the password that it was remembering. |
it just verifies that the password was correct. |
|
|
|
=head1 DEPENDENCIES |
=head1 DEPENDENCIES |
|
|
|
|
|
|
Readonly |
Readonly |
|
|
|
=head1 THANKS |
|
|
|
I would like to thank the helpful Perlmonk shigetsu who gave me some great advice |
|
and helped me get my first module posted. L<http://perlmonks.org/?node_id=596998> |
|
|
|
I would also like to thank |
|
Johan Vromans |
|
E<lt>jvromans@squirrel.nlE<gt> -- |
|
L<http://www.squirrel.nl/people/jvromans>. |
|
He had his own Palm::KeyRing module that he posted a couple of days before |
|
mine was ready and he was kind enough to let me have the namespace as well |
|
as giving me some very helpful hints about doing a few things that I was |
|
unsure of. He is really great. |
|
|
=head1 BUGS AND LIMITATIONS |
=head1 BUGS AND LIMITATIONS |
|
|
Once this module is uploaded, you can |
|
Please report any bugs or feature requests to |
Please report any bugs or feature requests to |
C<bug-palm-keyring at rt.cpan.org>, or through the web interface at |
C<bug-palm-keyring at rt.cpan.org>, or through the web interface at |
L<http://rt.cpan.org>. I will be notified, and then you'll automatically be |
L<http://rt.cpan.org>. I will be notified, and then you'll automatically be |
|
|
|
|
=head1 AUTHOR |
=head1 AUTHOR |
|
|
Andrew Fresh E<lt>andrew@mad-techies.orgE<gt> |
Andrew Fresh E<lt>andrew@cpan.orgE<gt> |
|
|
=head1 LICENSE AND COPYRIGHT |
=head1 LICENSE AND COPYRIGHT |
|
|
|
|
|
|
The Keyring for Palm OS website: |
The Keyring for Palm OS website: |
L<http://gnukeyring.sourceforge.net/> |
L<http://gnukeyring.sourceforge.net/> |
|
|
|
Johan Vromans also has a wxkeyring app that now uses this module, available |
|
from his website at L<http://www.vromans.org/johan/software/sw_palmkeyring.html> |