|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Strict allocation-free RBKC validation for media downloader artifacts. More...
#include <stddef.h>#include "book_chunked.h"#include "mdl_verify_rabook_internal.h"#include "miniz.h"Go to the source code of this file.
Data Structures | |
| struct | mdl_rabook_io_t |
| Positioned exact-read adapter state. More... | |
Enumerations | |
| enum | mdl_verify_rabook_limit_t : uint32_t { k_rabook_chunk_bytes = 4U * 1024U * 1024U , k_rabook_compressed_bytes = k_rabook_chunk_bytes + (64U * 1024U) , k_rabook_scratch_bytes = 4U * 1024U * 1024U , k_rabook_table_entries = 65537U , k_rabook_read_calls = 1000000U } |
| Bounded strict-reader workspace profile. More... | |
Functions | |
| static ra8_err_t | internal_rabook_read (void *opaque, uint64_t offset, uint8_t *destination, uint32_t length) |
| Serve one exact positioned RBKC read through the portable file facade. | |
| static ra8_err_t | internal_rabook_inflate (const void *source, size_t source_bytes, void *destination, size_t destination_bytes, size_t *out_bytes) |
| Inflate one complete RFC 1950 chunk into caller storage. | |
| ra8_err_t | priv_mdl_verify_rabook (fw_fs_file_t *file, uint64_t size_bytes, mdl_export_workspace_t *workspace, mdl_verify_report_t *report) |
| Strictly validate one borrowed RBKC .rabook file. | |
Strict allocation-free RBKC validation for media downloader artifacts.
Adapts positioned portable-file reads to the production chunked reader and validates every RFC 1950 stream plus the complete inner RABOOK1 structure and CRC using only bounded caller workspace.
Definition in file mdl_verify_rabook.c.
| enum mdl_verify_rabook_limit_t : uint32_t |
Bounded strict-reader workspace profile.
Definition at line 21 of file mdl_verify_rabook.c.
|
static |
Inflate one complete RFC 1950 chunk into caller storage.
Uses miniz's bounded memory inflater and reports the exact produced extent for the chunk reader's independent length check.
| [in] | source | Complete compressed stream. |
| [in] | source_bytes | Compressed stream extent. |
| [out] | destination | Inflated destination. |
| [in] | destination_bytes | Writable destination extent. |
| [out] | out_bytes | Exact inflated extent on success. |
| k_ra8_ok | The zlib stream inflated completely. |
| k_ra8_err_validation_failed | The stream was malformed or oversized. |
out_bytes and that many destination bytes. Definition at line 101 of file mdl_verify_rabook.c.
References k_ra8_err_validation_failed, and k_ra8_ok.
Referenced by priv_mdl_verify_rabook().
|
static |
Serve one exact positioned RBKC read through the portable file facade.
Bounds the range against the snapshotted extent, seeks once, then tolerates positive short reads under a fixed progress ceiling.
| [in,out] | opaque | Bound mdl_rabook_io_t. |
| [in] | offset | Absolute source byte offset. |
| [out] | destination | Destination spanning length bytes. |
| [in] | length | Exact requested byte count. |
| k_ra8_ok | Exactly length bytes were copied. |
| k_ra8_err_out_of_range | The requested range exceeds the snapshot. |
| k_ra8_err_invalid_state | The backend stopped making progress. |
destination spans length writable bytes. Definition at line 58 of file mdl_verify_rabook.c.
References fw_fs_read(), fw_fs_seek(), k_ra8_err_invalid_size, k_ra8_err_invalid_state, k_ra8_err_out_of_range, k_ra8_ok, and k_rabook_read_calls.
Referenced by priv_mdl_verify_rabook().
| ra8_err_t priv_mdl_verify_rabook | ( | fw_fs_file_t * | file, |
| uint64_t | size_bytes, | ||
| mdl_export_workspace_t * | workspace, | ||
| mdl_verify_report_t * | report ) |
Strictly validate one borrowed RBKC .rabook file.
Opens the callback-driven chunk reader, validates every compressed stream and the complete inner RABOOK1 structure/CRC, then reports bounded chapter and image counts.
| [in,out] | file | Borrowed readable and seekable file. |
| [in] | size_bytes | Immutable complete file extent. |
| [in,out] | workspace | Exclusive caller-owned validation arena. |
| [out] | report | Candidate report populated only on success. |
| k_ra8_ok | Every outer and inner byte passed strict validation. |
| k_ra8_err_invalid_size | A wire or caller-workspace bound was exceeded. |
| k_ra8_err_validation_failed | A zlib stream or RABOOK1 structure failed. |
file remains open for the call. workspace was reset by the owning verifier and is exclusively mutable. report. Definition at line 120 of file mdl_verify_rabook.c.
References book_header_t::author_off, book_chunked_open(), book_chunked_validate_strict(), book_header_t::chapter_count, book_header_t::identifier_off, book_header_t::image_count, internal_rabook_inflate(), internal_rabook_read(), k_ra8_err_invalid_arg, k_ra8_err_invalid_size, k_ra8_ok, k_rabook_chunk_bytes, k_rabook_compressed_bytes, k_rabook_scratch_bytes, k_rabook_table_entries, mdl_export_workspace_take(), RA8_PRIV, and book_header_t::title_off.
Referenced by internal_verify_borrowed().