Skip to content

Conversation

@rdblue
Copy link

@rdblue rdblue commented Sep 4, 2023

This implements the last few changes for the AES GCM encryption streams (apache#3231).

  • Use final variables for reused cipher and plain byte arrays
  • Validate that only one partial block can be written by the output stream (the last block)
  • Remove unnecessary tracking of streamPosition in the output stream
  • Remove some duplication in Ciphers
  • Add separate tests to check AAD and nonce validation: bad AAD prefix, corrupt AAD, corrupt nonce, corrupt ciphertext
  • Update empty file tests to validate the AAD

The main behavior change is that all files will write at least one cipher block. This is to ensure that the file AAD is validated even for empty files. Otherwise, an attacker could replace a metadata file with an empty file (with a valid header) and nothing would detect it.

@ggershinsky ggershinsky merged commit 792a7ce into ggershinsky:gcm_encryption_stream Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants