=================================================================== RCS file: /cvs/palm/Palm-Keyring/lib/Palm/Keyring.pm,v retrieving revision 1.4 retrieving revision 1.6 diff -u -r1.4 -r1.6 --- palm/Palm-Keyring/lib/Palm/Keyring.pm 2006/11/10 04:21:17 1.4 +++ palm/Palm-Keyring/lib/Palm/Keyring.pm 2006/11/10 16:18:59 1.6 @@ -8,8 +8,8 @@ # # This started as Memo.pm, I just made it work for Keyring. # -# $Id: Keyring.pm,v 1.4 2006/11/10 04:21:17 andrew Exp $ -# $RedRiver: Keyring.pm,v 1.3 2006/02/02 00:59:08 andrew Exp $ +# $Id: Keyring.pm,v 1.6 2006/11/10 16:18:59 andrew Exp $ +# $RedRiver: Keyring.pm,v 1.5 2006/11/10 04:52:27 andrew Exp $ use strict; package Palm::Keyring; @@ -27,7 +27,7 @@ # One liner, to allow MakeMaker to work. -$VERSION = do { my @r = (q$Revision: 1.4 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; +$VERSION = do { my @r = (q$Revision: 1.6 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; @ISA = qw( Palm::StdAppInfo Palm::Raw ); @@ -65,17 +65,16 @@ my $classname = shift; my $pass = shift; + # Create a generic PDB. No need to rebless it, though. my $self = $classname->SUPER::new(@_); - # Create a generic PDB. No need to rebless it, - # though. $self->{name} = "Keys-Gtkr"; # Default $self->{creator} = "Gtkr"; $self->{type} = "Gkyr"; + # The PDB is not a resource database by + # default, but it's worth emphasizing, + # since MemoDB is explicitly not a PRC. $self->{attributes}{resource} = 0; - # The PDB is not a resource database by - # default, but it's worth emphasizing, - # since MemoDB is explicitly not a PRC. # Initialize the AppInfo block $self->{appinfo} = {}; @@ -87,17 +86,15 @@ $self->{version} = 4; # Give the PDB the first record that will hold the encrypted password - $self->{records} = [ - { - 'category' => 0, - 'attributes' => { - 'private' => 1, - 'Secret' => 1, - 'Dirty' => 1, - 'dirty' => 1 - }, + $self->{records} = [ { + 'category' => 0, + 'attributes' => { + 'private' => 1, + 'Secret' => 1, + 'Dirty' => 1, + 'dirty' => 1 }, - ]; + }, ]; if ($pass) { $self->Encrypt($pass); @@ -133,6 +130,13 @@ 1; } +sub Write +{ + my $self = shift; + $self->Encrypt() || return undef; + return $self->SUPER::Load(@_); +} + sub Encrypt { my $self = shift; @@ -342,9 +346,9 @@ # if not, then die die "record not 8 byte padded" if (length($plaintext) % 8) && ! $flag; - my %C; + my @C; for ( 0..2 ) { - $C{$_} = new Crypt::DES( pack( "H*", substr($passphrase, 16*$_, 16 ))); + $C[$_] = new Crypt::DES( pack( "H*", substr($passphrase, 16*$_, 16 ))); } for ( 0 .. (($size)/8) - 1) { @@ -358,9 +362,9 @@ print "Binary: '" . unpack("b*", $pt) . "'\n"; #print "PT: '$pt' - Length: " . length($pt) . "\n"; } - $pt = $C{0}->decrypt( $pt ); - $pt = $C{1}->encrypt( $pt ); - $pt = $C{2}->decrypt( $pt ); + $pt = $C[0]->decrypt( $pt ); + $pt = $C[1]->encrypt( $pt ); + $pt = $C[2]->decrypt( $pt ); #print "PT: '$pt' - Length: " . length($pt) . "\n"; $cyphertext .= $pt; }