use Crypt::Mac::HMAC qw(hmac);
use Errno;
use File::KDBX::Error;
-use File::KDBX::Util qw(:io assert_64bit);
+use File::KDBX::Util qw(:class :io assert_64bit);
use namespace::clean;
-use parent 'File::KDBX::IO';
+extends 'File::KDBX::IO';
our $VERSION = '999.999'; # VERSION
our $BLOCK_SIZE = 1048576; # 1MiB
our $ERROR;
-=method new
-
- $fh = File::KDBX::IO::HmacBlock->new(%attributes);
- $fh = File::KDBX::IO::HmacBlock->new($fh, %attributes);
-
-Construct a new HMAC-block stream IO handle.
-
-=cut
-
-sub new {
- assert_64bit;
-
- my $class = shift;
- my %args = @_ % 2 == 1 ? (fh => shift, @_) : @_;
- my $self = $class->SUPER::new;
- $self->_fh($args{fh}) or throw 'IO handle required';
- $self->key($args{key}) or throw 'Key required';
- $self->block_size($args{block_size});
- $self->_buffer;
- return $self;
-}
-
=attr block_size
Desired block size when writing (default: C<$File::KDBX::IO::HmacBlock::BLOCK_SIZE> or 1,048,576 bytes)
my %ATTRS = (
_block_index => 0,
- _buffer => \(my $buf = ''),
+ _buffer => sub { \(my $buf = '') },
_finished => 0,
block_size => sub { $BLOCK_SIZE },
key => undef,
};
}
+=method new
+
+ $fh = File::KDBX::IO::HmacBlock->new(%attributes);
+ $fh = File::KDBX::IO::HmacBlock->new($fh, %attributes);
+
+Construct a new HMAC-block stream IO handle.
+
+=cut
+
+sub new {
+ assert_64bit;
+
+ my $class = shift;
+ my %args = @_ % 2 == 1 ? (fh => shift, @_) : @_;
+ my $self = $class->SUPER::new;
+ $self->_fh($args{fh}) or throw 'IO handle required';
+ $self->key($args{key}) or throw 'Key required';
+ $self->block_size($args{block_size});
+ $self->_buffer;
+ return $self;
+}
+
sub _FILL {
my ($self, $fh) = @_;