use File::KDBX::Error;
use File::KDBX::IO::Crypt;
use File::KDBX::IO::HashBlock;
-use File::KDBX::Util qw(:empty assert_64bit erase_scoped);
+use File::KDBX::Util qw(:class :empty :int :load erase_scoped);
use IO::Handle;
use namespace::clean;
-use parent 'File::KDBX::Dumper';
+extends 'File::KDBX::Dumper';
our $VERSION = '999.999'; # VERSION
local $headers->{+HEADER_TRANSFORM_SEED} = $kdbx->transform_seed;
local $headers->{+HEADER_TRANSFORM_ROUNDS} = $kdbx->transform_rounds;
+ my $got_iv_size = length($headers->{+HEADER_ENCRYPTION_IV});
+ alert 'Encryption IV should be exactly 16 bytes long',
+ got => $got_iv_size,
+ expected => 16 if $got_iv_size != 16;
+
if (nonempty (my $comment = $headers->{+HEADER_COMMENT})) {
$buf .= $self->_write_header($fh, HEADER_COMMENT, $comment);
}
my $type = shift;
my $val = shift // '';
- $type = KDBX_HEADER($type);
+ $type = to_header_constant($type);
if ($type == HEADER_END) {
$val = "\r\n\r\n";
}
# nothing
}
elsif ($type == HEADER_TRANSFORM_ROUNDS) {
- assert_64bit;
- $val = pack('Q<', $val);
+ $val = pack_Ql($val);
}
elsif ($type == HEADER_ENCRYPTION_IV) {
# nothing
$fh->print($kdbx->headers->{+HEADER_STREAM_START_BYTES})
or throw 'Failed to write start bytes';
- $fh->flush;
$kdbx->key($key);
my $compress = $kdbx->headers->{+HEADER_COMPRESSION_FLAGS};
if ($compress == COMPRESSION_GZIP) {
- require IO::Compress::Gzip;
+ load_optional('IO::Compress::Gzip');
$fh = IO::Compress::Gzip->new($fh,
-Level => IO::Compress::Gzip::Z_BEST_COMPRESSION(),
-TextFlag => 1,