mirror of
https://codeberg.org/scip/Crypt--PWSafe3.git
synced 2025-12-16 20:21:01 +01:00
fixed pack/unpack formats to use strictly little-endian values as required
by database format
This commit is contained in:
@@ -22,13 +22,15 @@ use Data::Dumper;
|
||||
use Exporter ();
|
||||
use vars qw(@ISA @EXPORT);
|
||||
|
||||
$Crypt::PWSafe3::VERSION = '1.07';
|
||||
$Crypt::PWSafe3::VERSION = '1.08';
|
||||
|
||||
use Crypt::PWSafe3::Field;
|
||||
use Crypt::PWSafe3::HeaderField;
|
||||
use Crypt::PWSafe3::Record;
|
||||
use Crypt::PWSafe3::SHA256;
|
||||
|
||||
require 5.10.0;
|
||||
|
||||
#
|
||||
# check, which random source to use.
|
||||
# install a wrapper closure around the
|
||||
@@ -204,7 +206,7 @@ sub read {
|
||||
}
|
||||
|
||||
$this->salt( $this->readbytes(32) );
|
||||
$this->iter( unpack("V", $this->readbytes(4) ) );
|
||||
$this->iter( unpack("L<", $this->readbytes(4) ) );
|
||||
|
||||
$this->strechedpw($this->stretchpw($this->password()));
|
||||
|
||||
@@ -324,7 +326,7 @@ sub save {
|
||||
$this->addheader($whosaved);
|
||||
|
||||
my $tmpfile = File::Spec->catfile(File::Spec->tmpdir(),
|
||||
".vault-" . unpack("H*", $this->random(16)));
|
||||
".vault-" . unpack("L<4", $this->random(16)));
|
||||
unlink $tmpfile;
|
||||
my $fd = new FileHandle($tmpfile, 'w') or croak "Could not open tmpfile $tmpfile: $!\n";
|
||||
$fd->binmode();
|
||||
@@ -332,7 +334,7 @@ sub save {
|
||||
|
||||
$this->writebytes($this->tag);
|
||||
$this->writebytes($this->salt);
|
||||
$this->writebytes(pack("V", $this->iter));
|
||||
$this->writebytes(pack("L<", $this->iter));
|
||||
|
||||
$this->strechedpw($this->stretchpw($passwd));
|
||||
|
||||
@@ -423,7 +425,7 @@ sub writefield {
|
||||
return;
|
||||
}
|
||||
|
||||
my $len = pack("V", $field->len);
|
||||
my $len = pack("L<", $field->len);
|
||||
my $type = pack("C", $field->type);
|
||||
my $raw = $field->raw;
|
||||
|
||||
@@ -585,7 +587,7 @@ sub readfield {
|
||||
|
||||
#print "clear: <" . unpack('H*', $data) . ">\n";
|
||||
|
||||
my $len = unpack("V", substr($data, 0, 4));
|
||||
my $len = unpack("L<", substr($data, 0, 4));
|
||||
my $type = unpack("C", substr($data, 4, 1));
|
||||
my $raw = substr($data, 5);
|
||||
|
||||
@@ -950,7 +952,7 @@ and/or modify it under the same terms as Perl itself.
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
Crypt::PWSafe3 Version 1.07.
|
||||
Crypt::PWSafe3 Version 1.08.
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
@@ -70,13 +70,13 @@ sub new {
|
||||
|
||||
if (exists $param{raw}) {
|
||||
if (grep { $_ eq $param{type} } @convtime) {
|
||||
$self->{value} = unpack("V", $param{raw});
|
||||
$self->{value} = unpack("L<", $param{raw});
|
||||
}
|
||||
elsif (grep { $_ eq $param{type} } @convhex) {
|
||||
$self->{value} = unpack('H*', $param{raw});
|
||||
$self->{value} = unpack('L<4', $param{raw});
|
||||
}
|
||||
elsif (grep { $_ eq $param{type} } @convbyte) {
|
||||
$self->{value} = unpack('W*', $param{raw});
|
||||
$self->{value} = unpack('W<*', $param{raw});
|
||||
}
|
||||
else {
|
||||
$self->{value} = $param{raw};
|
||||
@@ -87,13 +87,13 @@ sub new {
|
||||
else {
|
||||
if (exists $param{value}) {
|
||||
if (grep { $_ eq $param{type} } @convtime) {
|
||||
$self->{raw} = pack("V", $param{value});
|
||||
$self->{raw} = pack("L<", $param{value});
|
||||
}
|
||||
elsif (grep { $_ eq $param{type} } @convhex) {
|
||||
$self->{raw} = pack('H*', $param{value});
|
||||
$self->{raw} = pack('L<4', $param{value});
|
||||
}
|
||||
elsif (grep { $_ eq $param{type} } @convbyte) {
|
||||
$self->{raw} = pack('W*', $param{value});
|
||||
$self->{raw} = pack('W<*', $param{value});
|
||||
}
|
||||
else {
|
||||
$self->{raw} = $param{value};
|
||||
|
||||
@@ -65,13 +65,13 @@ sub new {
|
||||
|
||||
if (exists $param{raw}) {
|
||||
if ($param{type} == 0x00) {
|
||||
$self->{value} = unpack('H*', $param{raw});# maybe WW or CC ?
|
||||
$self->{value} = unpack('L<2', $param{raw});# maybe WW or CC ?
|
||||
}
|
||||
elsif ($param{type} == 0x01) {
|
||||
$self->{value} = unpack('H*', $param{raw});
|
||||
$self->{value} = unpack('L<4', $param{raw});
|
||||
}
|
||||
elsif ($param{type} == 0x04) {
|
||||
$self->{value} = unpack('V', $param{raw});
|
||||
$self->{value} = unpack('L<', $param{raw});
|
||||
}
|
||||
else {
|
||||
$self->{value} = $param{raw};
|
||||
@@ -81,13 +81,13 @@ sub new {
|
||||
else {
|
||||
if (exists $param{value}) {
|
||||
if ($param{type} == 0x00) {
|
||||
$self->{raw} = pack("H*", $param{value});
|
||||
$self->{raw} = pack("L<2", $param{value});
|
||||
}
|
||||
elsif ($param{type} == 0x01) {
|
||||
$self->{raw} = pack('H*', $param{value});
|
||||
$self->{raw} = pack('L<4', $param{value});
|
||||
}
|
||||
elsif ($param{type} == 0x04) {
|
||||
$self->{raw} = pack('V', $param{value});
|
||||
$self->{raw} = pack('L<', $param{value});
|
||||
}
|
||||
else {
|
||||
$self->{raw} = $param{value};
|
||||
|
||||
Reference in New Issue
Block a user