Skip to content

[parquet] Allow more encryption algorithms - #9203

Merged
alamb merged 33 commits into
apache:mainfrom
hsiang-c:allow_more_enc_algo
May 20, 2026
Merged

[parquet] Allow more encryption algorithms#9203
alamb merged 33 commits into
apache:mainfrom
hsiang-c:allow_more_enc_algo

Conversation

@hsiang-c

@hsiang-chsiang-c commented Jan 16, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

  • Iceberg spec supports AES key sizes of 128, 192 and 256 bits. Iceberg Rust depends on arrow-rs for Parquet I/O, I'd like to start supporting AES 256 with this PR.

What changes are included in this PR?

  • RingGcmBlockEncryptor and RingGcmBlockDecryptor will pick AES-128 or AES-256 based on key size
  • Refactor encryption_async.rs and encryption.rs to test both AES-128 and AES-256 encrypted parquet files

Are these changes tested?

Yes, unit test and on AES-256 encrypted Parquet files defined in https://github.com/apache/parquet-testing/tree/master/data/aes256

Are there any user-facing changes?

No

@xanderbaileyxanderbailey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I exposed quote style here I exported the underlying QuoteStyle is that something we might want to do here also for Algorithm?

@hsiang-c
hsiang-c marked this pull request as ready for review January 23, 2026 07:27
@hsiang-c

Copy link
Copy Markdown
ContributorAuthor

@xanderbailey

Thank you for the review, I took a look at your PR. You made QuoteStyle part of Writer and expose as part of the API.

Do you mean you'd like to make Algorithm a field of RingGcmBlockDecryptor and RingGcmBlockEncryptor and expose them instead of importing it from ring::aead?

Comment threadparquet/src/encryption/ciphers.rs Outdated
Comment threadparquet/src/encryption/decrypt.rs Outdated
@alamb

alamb commented Feb 3, 2026

Copy link
Copy Markdown
Contributor

Thanks @hsiang-c and @mbutrovich -- looks like there are some CI failures on this PR.

Also, it seems like we should have some tests for the new features

@alambalamb changed the title Allow more encryption algorithms[parquet] Allow more encryption algorithmsFeb 11, 2026

@alambalamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @hsiang-c

FYI @adamreeve and @rok as the original authors of the parquet encryption feature

Perhaps you have some time to review this PR?

Comment threadparquet/src/encryption/ciphers.rs Outdated
}

impl RingGcmBlockDecryptor {
#[allow(dead_code)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to allow dead code? Maybe we should remove it instead?

Comment threadparquet/src/file/metadata/mod.rs Outdated

#[cfg(feature = "encryption")]
let expected_size_with_decryptor = 3080;
#[cfg(not(feature = "encryption"))]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? The whole test is gated by

#[cfg(feature = "encryption")]fn test_memory_size_with_decryptor(){

it seems like you just need to update the 3072 to 3080 to reflect the additional size?

Comment threadparquet/src/encryption/ciphers.rs Outdated
#[test]
fn test_round_trip_with_incorrect_key_length() {
let key = [0u8; 16];
assert!(RingGcmBlockEncryptor::new_with_algorithm(&CHACHA20_POLY1305, &key).is_err());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isn't clear to me that CHACHA is a valid Parquet encryption: https://github.com/apache/parquet-format/blob/master/Encryption.md :

Comment threadparquet/src/encryption/decrypt.rs Outdated
}

/// The AEAD decryption algorithm to be used.
pub fn with_algorithm(mut self, algorithm: &'static Algorithm) -> Self {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this effectively makes Algorithm a part of the public API I think -- this might be ok, but it also means we would not be able to change the underlying crypto library without breaking the API in the future

@adamreeveadamreeveFeb 11, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I don't like this and I don't think it's necessary, see my comment on new_with_algorithm. This also makes it possible for users to easily create Parquet files that aren't compliant with the spec by using a non-standard algorithm.

Changing the crypto library is something we might potentially want to do to be able to add AES_GCM_CTR support for example (#7258 (comment)).

I think if we want to support new algorithms like AES_GCM_CTR in the future the user should provide an enum value from a supported set of algorithms like is done in the C++ implementation, but we can infer the key length from the provided key so this isn't necessary for this change.

@adamreeveadamreeve left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing this @hsiang-c! I've left a few comments

Comment threadparquet/src/encryption/ciphers.rs Outdated
Comment on lines +49 to +52
pub(crate) fn new_with_algorithm(
algorithm: &'static Algorithm,
key_bytes: &[u8],
) -> Result<Self> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's any need to add this new constructor, we can reuse the existing new method above and change the algorithm based on the length of the key.

This is also a bit semantically confusing as you could create a new "RingGcmBlockDecryptor" with a non-GCM algorithm.

Comment threadparquet/src/encryption/ciphers.rs Outdated
Comment on lines +158 to +161
pub(crate) fn new_with_algorithm(
algorithm: &'static Algorithm,
key_bytes: &[u8],
) -> Result<Self> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, I think we should reuse the existing new method.

Comment threadparquet/src/encryption/decrypt.rs Outdated
}

/// The AEAD decryption algorithm to be used.
pub fn with_algorithm(mut self, algorithm: &'static Algorithm) -> Self {

@adamreeveadamreeveFeb 11, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I don't like this and I don't think it's necessary, see my comment on new_with_algorithm. This also makes it possible for users to easily create Parquet files that aren't compliant with the spec by using a non-standard algorithm.

Changing the crypto library is something we might potentially want to do to be able to add AES_GCM_CTR support for example (#7258 (comment)).

I think if we want to support new algorithms like AES_GCM_CTR in the future the user should provide an enum value from a supported set of algorithms like is done in the C++ implementation, but we can infer the key length from the provided key so this isn't necessary for this change.

Comment threadparquet/tests/encryption/encryption_async.rs
@hsiang-c
hsiang-c marked this pull request as draft February 14, 2026 00:58
@tom-s-powell

Copy link
Copy Markdown

Curious if there's a rough timeline on getting this change in?

@hsiang-c
hsiang-c marked this pull request as ready for review February 19, 2026 00:52

@tom-s-powelltom-s-powell left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance that this'll get reviewed?

Comment threadparquet/tests/encryption/encryption_util.rs Outdated
@adamreeve

Copy link
Copy Markdown
Contributor

Any chance that this'll get reviewed?

This isn't ready for another review yet. The tests are currently failing because they need apache/parquet-testing#102. I'm happy to review this again once @hsiang-c says it's ready.

@alamb

Copy link
Copy Markdown
Contributor

Marking as draft as I think this PR is no longer waiting on feedback and I am trying to make it easier to find PRs in need of review. Please mark it as ready for review when it is ready for another look

@hsiang-c
hsiang-cforce-pushed the allow_more_enc_algo branch from 2fe8a54 to 44caeccCompareMay 4, 2026 17:41
@hsiang-c
hsiang-c marked this pull request as ready for review May 4, 2026 18:28
@hsiang-c

Copy link
Copy Markdown
ContributorAuthor

@adamreeve I reverted some unnecessary tests and refactored the test data a bit, please take a look when you have time, thank you.

@adamreeveadamreeve left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @hsiang-c, the test changes look good to me. This is still a bit complicated by the int64_field.list.int64_field issue, but I think that's OK for now.

@hsiang-c

Copy link
Copy Markdown
ContributorAuthor

Thanks @adamreeve I'll fix the test data in parquet-testing and remove int64_field.list.int64_field in the tests.

@alamb

alamb commented May 7, 2026

Copy link
Copy Markdown
Contributor

Marking as draft as I think this PR is no longer waiting on feedback and I am trying to make it easier to find PRs in need of review. Please mark it as ready for review when it is ready for another look

Or if you prefer to merge it now, let me know and we can do that

@hsiang-c

Copy link
Copy Markdown
ContributorAuthor

@alamb This is ready for your review, thank you.

@alambalamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me -- thnks @adamreeve and @hsiang-c

@alamb
alamb merged commit accb1cf into apache:mainMay 20, 2026
17 checks passed
Rich-T-kid pushed a commit to Rich-T-kid/arrow-rs that referenced this pull request Jun 2, 2026
# Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax.
-->
- Closesapache#9202.
# Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly
in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand
your changes and offer better suggestions for fixes.
-->
- Iceberg
[spec](https://iceberg.apache.org/gcm-stream-spec/#encryption-algorithm)
supports AES key sizes of 128, 192 and 256 bits. Iceberg Rust depends on
`arrow-rs` for Parquet I/O, I'd like to start supporting AES 256 with
this PR.
# What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it
is sometimes worth providing a summary of the individual changes in this
PR.
-->
- `RingGcmBlockEncryptor` and `RingGcmBlockDecryptor` will pick AES-128
or AES-256 based on key size
- Refactor `encryption_async.rs` and `encryption.rs` to test both
AES-128 and AES-256 encrypted parquet files
# Are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->
Yes, unit test and on AES-256 encrypted Parquet files defined in
https://github.com/apache/parquet-testing/tree/master/data/aes256
# Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
If there are any breaking changes to public APIs, please call them out.
-->
No
alamb added a commit that referenced this pull request Jul 17, 2026
…10351)
- Part of #10349
- Fixes#9202 in 58.x releases
This PR:
- Backports #9203 from @hsiang-c
to the `58_maintenance` line
Co-authored-by: hsiang-c <137842490+hsiang-c@users.noreply.github.com>
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
blackmwk pushed a commit to apache/iceberg-rust that referenced this pull request Jul 23, 2026
…#2878)
## Which issue does this PR close?
- Closes #.
Depends on the arrow-rs 58.4.0 release tracked in apache/arrow-rs#10349.
## What changes are included in this PR?
- Bump `arrow`/`parquet` deps from `58` to `58.4`. arrow-rs 58.4.0 adds
AES-256 for Parquet modular encryption (58.3.0 was AES-128 only), landed
via apache/arrow-rs#9203.
- Add an AES-256 encrypted-Parquet read test. Refactored the existing
128-bit test into a shared `assert_encrypted_parquet_roundtrip(key)`
helper with `_aes_128` and `_aes_256` callers.
Note: 192-bit is not supported for data files. arrow-rs uses `ring`,
which has no AES-192-GCM. Can revisit later.
## Are these changes tested?
Yes. Unit test `test_read_encrypted_parquet_aes_256` writes and reads
back a 256-bit encrypted Parquet file. It fails on arrow-rs 58.3.0
(`ring` rejects the 32-byte key) and passes on 58.4.0.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parquetChanges to the parquet crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Parquet] Support other encryption/decryption key size

7 participants

@hsiang-c@alamb@tom-s-powell@adamreeve@xanderbailey@rok@mbutrovich