bpak_verify — Verify API

The verify layer provides functions for verifying a BPAK package.


Source code: include/bpak/verify.h, lib/verify.c


BPAK - Bit Packer

Copyright (C) 2022 Jonas Blixt jonpe960@gmail.com

SPDX-License-Identifier: BSD-3-Clause

Functions

int bpak_verify_compute_header_hash(struct bpak_header *header, uint8_t *output_hash_buffer, size_t *output_hash_buffer_length)

Compute the hash of a bpak header

Parameters:
  • header[in] Pointer to a bpak header

  • output_hash_buffer[out] Output hash

  • size[in] In/out Available bytes in buffer as input and set to produced bytes output

Returns:

BPAK_OK on success

int bpak_verify_compute_payload_hash(struct bpak_header *header, bpak_io_t read_payload, off_t data_offset, void *user, uint8_t *output_hash_buffer, size_t *output_hash_buffer_length)

Compute the hash the payload

Parameters:
  • header[in] Pointer to a bpak header

  • read[in] Read callback for reading payload data

  • data_offset[in] Payload data offset

  • user[in] User pointer for io callback

  • output_hash_buffer[in] Output hash buffer

  • outpu_hash_buffer_length[in] Length of hash buffer / result bytes

Returns:

BPAK_OK on success

int bpak_verify_merkle_tree(bpak_io_t read_payload, off_t data_offset, size_t data_length, off_t tree_offset, bpak_merkle_hash_t expected_root_hash, bpak_merkle_hash_t salt, void *user)

Verify an existing merkle hash tree. This function will re-generate all hashes and compare the result with what’s accesible with the ‘read_payload’ function at offset ‘tree_offset’.

Parameters:
  • read_payload[in] i/o call back for reading payload data

  • data_offset[in] Offset where input data to merkle tree begins

  • data_length[in] Length of data block

  • tree_offset[in] Offset where merkle tree data begins

  • expected_root_hash[in] Expected root hash

  • salt[in] Salt to use during operation

Returns:

BPAK_OK if verification is OK

int bpak_verify_payload(struct bpak_header *header, bpak_io_t read_payload, off_t data_offset, void *user)

Verify the payload data. It will compute the payload hash for parts that should be hashed. It also verifies generated merkle hash trees and root hashes.

Parameters:
  • header[in] Pointer to a bpak header

  • read[in] I/O callback for reading payload data

  • data_offset[in] Payload data offset

  • user[in] User pointer for io callback

Returns:

BPAK_OK on success