Skip to content

Commit

Permalink
Spec: Clarify file length handling for AES GCM streams (#9136)
Browse files Browse the repository at this point in the history
  • Loading branch information
ggershinsky authored Dec 19, 2023
1 parent 980733c commit a83bfe7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions format/gcm-stream-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,7 @@ AES GCM Stream encrypts all blocks by the GCM cipher, without padding. The AES G
The AES GCM cipher protects against byte replacement inside a ciphertext block - but, without an AAD, it can't prevent replacement of one ciphertext block with another (encrypted with the same key). AES GCM Stream leverages AADs to protect against swapping ciphertext blocks inside a file or between files. AES GCM Stream can also protect against swapping full files - for example, replacement of a metadata file with an old version. AADs are built to reflects the identity of a file and of the blocks inside the file.

AES GCM Stream constructs a block AAD from two components: an AAD prefix - a string provided by Iceberg for the file (with the file ID), and an AAD suffix - the block sequence number in the file, as an int in a 4-byte little-endian form. The block AAD is a direct concatenation of the prefix and suffix parts.

### File length

An attacker can delete a few last blocks in an encrypted file. To detect the attack, the reader implementations of the AES GCM Stream must use the file length value taken from a trusted source (such as a signed file metadata), and not from the file system.

0 comments on commit a83bfe7

Please sign in to comment.