Skip to content

AES GCM spec vs implementation discrepancy #18219

Description

@xanderbailey

We're in the process of implementing the encryption spec in rust and python and have noticed something in the spec wording https://github.com/apache/iceberg/blob/1504ddd5d5119e934e7cbcaed82b9384caf35b82/format/gcm-stream-spec.md#cipher-block-structure The last block has a non-zero length <= BlockLength but Java AesGcmOutputStream will actually write an empty block and AesGcmInputFile will reject anything shorter than MIN_STREAM_LENGTH

public SeekableInputStream newStream() {
long ciphertextLength = encryptedLength();
Preconditions.checkState(
ciphertextLength >= Ciphers.MIN_STREAM_LENGTH,
"Invalid encrypted stream: %s is shorter than the minimum possible stream length",
ciphertextLength);
return new AesGcmInputStream(sourceFile.newStream(), ciphertextLength, dataKey, fileAADPrefix);

So java seems to disagree in both directions?

Link to python PR where this discussion came up apache/iceberg-python#3969

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions