Skip to content

feat(reader): add support for reading encrypted uncompressed files and validate decryption - #14

Merged
zombocoder merged 1 commit into
mainfrom
bugfix/support--reading-encrypted-uncompressed
Aug 1, 2026
Merged

feat(reader): add support for reading encrypted uncompressed files and validate decryption#14
zombocoder merged 1 commit into
mainfrom
bugfix/support--reading-encrypted-uncompressed

Conversation

@zombocoder

Copy link
Copy Markdown
Owner

This pull request improves the handling of encrypted but uncompressed files in the bfc_read function and adds comprehensive regression tests to ensure correct decryption and error handling. It prevents raw ciphertext from being returned to callers and makes sure that decryption failures (including wrong keys or missing keys) are properly detected.

Encrypted file handling:

  • Added a new read_encrypted_file function to bfc_reader.c that fully decrypts the payload, validates its integrity using AEAD and CRC, and only returns plaintext if decryption is successful. This prevents raw ciphertext from being returned and ensures that a wrong decryption key is detected.
  • Updated bfc_read to use read_encrypted_file for encrypted, uncompressed objects, ensuring correct decryption and error handling for this case.

Testing and regression coverage:

  • Added a new regression test test_read_encrypted_uncompressed in test_reader.c to verify that:
    • No data is returned without a key,
    • A wrong key fails decryption,
    • The correct key yields the expected plaintext,
    • Partial reads operate on plaintext,
    • Reads past the end return nothing.
  • Integrated the new regression test into the main test suite, gated on the presence of libsodium (BFC_WITH_SODIUM).

@zombocoder
zombocoder merged commit b3777f3 into main Aug 1, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant