---
name: "File::KDBX::IO::HmacBlock"
section: "3pm"
platform: "linux"
package: "libfile-kdbx-perl"
version: "0.906-3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/File::KDBX::IO::HmacBlock"
---

# File::KDBX::IO::HmacBlock(3pm)

HMAC block stream IO handle

## NAME

File::KDBX::IO::HmacBlock - HMAC block stream IO handle

## VERSION

version 0.906

## DESCRIPTION

Writing to a HMAC-block stream handle will transform the data into a series of blocks. An HMAC is calculated for each block and is included in the output.

Reading from a handle, each block will be verified and authenticated as the blocks are disassembled back into a data stream.

This format helps ensure data integrity and authenticity of KDBX4 files.

Each block is encoded thusly:

- •

  HMAC - 32 bytes, calculated over \[block index (increments starting with 0), block size and data\]

- •

  Block size - Little-endian unsigned 32-bit (counting only the data)

- •

  Data - String of bytes

The terminating block is an empty block encoded as usual but block size is 0 and there is no data.

## ATTRIBUTES

### block\_size

Desired block size when writing (default: `$File::KDBX::IO::HmacBlock::BLOCK_SIZE` or 1,048,576 bytes)

### key

HMAC-SHA256 key for authenticating the data stream (required)

## METHODS

### new

```
    $fh = File::KDBX::IO::HmacBlock->new(%attributes);
    $fh = File::KDBX::IO::HmacBlock->new($fh, %attributes);
```

Construct a new HMAC-block stream IO handle.

## BUGS

Please report any bugs or feature requests on the bugtracker website \<https://github.com/chazmcgarvey/File-KDBX/issues\>

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

## AUTHOR

Charles McGarvey \<ccm@cpan.org\>

## COPYRIGHT AND LICENSE

This software is copyright (c) 2022 by Charles McGarvey.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
