use Encode qw(decode);
use File::KDBX::Constants qw(:header :inner_header :variant_map :compression);
use File::KDBX::Error;
-use File::KDBX::Util qw(:io :load assert_64bit erase_scoped);
+use File::KDBX::Util qw(:class :int :io :load erase_scoped);
use File::KDBX::IO::Crypt;
use File::KDBX::IO::HmacBlock;
use boolean;
use namespace::clean;
-use parent 'File::KDBX::Loader';
+extends 'File::KDBX::Loader';
our $VERSION = '999.999'; # VERSION
$buf .= $val;
}
- $type = KDBX_HEADER($type);
+ $type = to_header_constant($type);
if ($type == HEADER_END) {
# done
}
($val) = unpack('L<', $val);
}
elsif ($type == VMAP_TYPE_UINT64) {
- assert_64bit;
- ($val) = unpack('Q<', $val);
+ ($val) = unpack_Ql($val);
}
elsif ($type == VMAP_TYPE_BOOL) {
($val) = unpack('C', $val);
($val) = unpack('l<', $val);
}
elsif ($type == VMAP_TYPE_INT64) {
- assert_64bit;
- ($val) = unpack('q<', $val);
+ ($val) = unpack_ql($val);
}
elsif ($type == VMAP_TYPE_STRING) {
$val = decode('UTF-8', $val);
my $fh = shift;
my $kdbx = $self->kdbx;
- read_all $fh, my $buf, 5 or throw 'Expected inner header type and size',
- compression_error => $IO::Uncompress::Gunzip::GunzipError,
- crypt_error => $File::KDBX::IO::Crypt::ERROR,
- hmac_error => $File::KDBX::IO::HmacBLock::ERROR;
+ read_all $fh, my $buf, 5 or throw 'Expected inner header type and size';
my ($type, $size) = unpack('C L<', $buf);
my $val;
read_all $fh, $val, $size or throw 'Expected inner header value', type => $type, size => $size;
}
- my $dualtype = KDBX_INNER_HEADER($type);
-
- if (!defined $dualtype) {
- alert "Ignoring unknown inner header type ($type)", type => $type, size => $size, value => $val;
- return wantarray ? ($type => $val) : $type;
- }
- elsif ($dualtype == INNER_HEADER_END) {
+ $type = to_inner_header_constant($type) // $type;
+ if ($type == INNER_HEADER_END) {
# nothing
}
- elsif ($dualtype == INNER_HEADER_INNER_RANDOM_STREAM_ID) {
+ elsif ($type == INNER_HEADER_INNER_RANDOM_STREAM_ID) {
$val = unpack('L<', $val);
- $kdbx->inner_headers->{$dualtype} = $val;
+ $kdbx->inner_headers->{$type} = $val;
}
- elsif ($dualtype == INNER_HEADER_INNER_RANDOM_STREAM_KEY) {
- $kdbx->inner_headers->{$dualtype} = $val;
+ elsif ($type == INNER_HEADER_INNER_RANDOM_STREAM_KEY) {
+ $kdbx->inner_headers->{$type} = $val;
}
- elsif ($dualtype == INNER_HEADER_BINARY) {
+ elsif ($type == INNER_HEADER_BINARY) {
my $msize = $size - 1;
my ($flags, $data) = unpack("C a$msize", $val);
my $id = scalar keys %{$kdbx->binaries};
$flags & INNER_HEADER_BINARY_FLAG_PROTECT ? (protect => true) : (),
};
}
+ else {
+ alert "Ignoring unknown inner header type ($type)", type => $type, size => $size, value => $val;
+ return wantarray ? ($type => $val) : $type;
+ }
- return wantarray ? ($dualtype => $val) : $dualtype;
+ return wantarray ? ($type => $val) : $type;
}
1;