Skip to content

Conversation

@timhurskidremio
Copy link

@timhurskidremio timhurskidremio commented Nov 14, 2025

This change adds support for AES CBC mode with the following signatures:

AES_ENCRYPT(BINARY, BINARY, UTF8, BINARY) → BINARY
Parameters: plaintext (binary), key (binary), mode (string), iv (binary)

AES_DECRYPT(BINARY, BINARY, UTF8, BINARY) → BINARY
Parameters: ciphertext (binary), key (binary), mode (string), iv (binary)

The mode can be either AES-CBC-NONE for a no-padding call or AES-CBC-PKCS7 for a call with padding

Additional changes:

  • Upgrade the macOS runner from 13 to 15-intel
  • Updates the expected mode for ECB to AES-ECB
  • Adds a dispatcher to handle optional parameters in AES_ENCRYPT and AES_DECRYPT

The functional mapping is as follows:

AES_ENCRYPT(<plain text>, <key>, <mode>) → <ciphertext> → 3-arg stub
AES_ENCRYPT(<plain text>, <key>, <mode>, <iv>) → <ciphertext> → 4-arg stub
AES_ENCRYPT(<plain text>, <key>, <mode>, <iv>, <5th argument>) → <ciphertext> → 5-arg stub

3-arg stub → 5-arg stub with the 4ᵗʰ and 5ᵗʰ arguments set to nullptr
4-arg stub → 5-arg stub with the 5ᵗʰ arguments set to nullptr
5-arg stub → dispatcher

Dispatcher:
AES-ECBaes_decrypt_ecb
AES-CBC-PKCS7aes_decrypt_cbc
AES-CBC-NONEaes_decrypt_cbc
AES-GCM → Runtime exception

@github-actions
Copy link

Thanks for opening a pull request!

If this is not a minor PR. Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose

Opening GitHub issues ahead of time contributes to the Openness of the Apache Arrow project.

Then could you also rename the pull request title in the following format?

GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}

or

MINOR: [${COMPONENT}] ${SUMMARY}

See also:

@timhurskidremio
Copy link
Author

@timhurskidremio timhurskidremio force-pushed the add-support-for-cbc-encryption-mode branch from 275bce1 to 0cb4be4 Compare November 15, 2025 18:14
@timhurskidremio timhurskidremio marked this pull request as ready for review November 19, 2025 17:53
…date macOS runner versions

- Create ensure_mode() helper that throws std::runtime_error for invalid modes
- Update all ECB and CBC AES functions (3 encrypt + 3 decrypt) to use ensure_mode()
- Wrap all function bodies in try-catch to handle exceptions from ensure_mode()
- Consistent error handling across ECB and CBC modes
- Update CBC function signatures to include mode parameter: (data, key, mode, iv, padding)
- Update function registry to reflect new CBC parameter order
- Update LLVM mappings comments for clarity
- Update test expectations to match new error messages
- Update macOS runner versions from macos-13 to macos-15-intel in CI workflows
- Excludes GCM mode changes from the original commits
@timhurskidremio timhurskidremio force-pushed the add-support-for-cbc-encryption-mode branch from b3041bc to 00f53d4 Compare November 20, 2025 03:22
@timhurskidremio timhurskidremio force-pushed the add-support-for-cbc-encryption-mode branch from 0f66741 to 88e87b3 Compare November 25, 2025 06:16
@timhurskidremio timhurskidremio marked this pull request as draft November 25, 2025 14:33
@timhurskidremio timhurskidremio force-pushed the add-support-for-cbc-encryption-mode branch 6 times, most recently from a9d5636 to 5bdb71e Compare November 25, 2025 20:42
@timhurskidremio timhurskidremio force-pushed the add-support-for-cbc-encryption-mode branch from 5bdb71e to 68e180d Compare November 25, 2025 21:43
@timhurskidremio timhurskidremio marked this pull request as ready for review November 26, 2025 00:03
@timhurskidremio
Copy link
Author

std::string mode_str =
arrow::internal::AsciiToUpper(std::string_view(mode, mode_len));

if (mode_str == "AES-ECB") {
Copy link

Choose a reason for hiding this comment

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

If any of these comments are used more than once it would be good to make them constants. That could be done in a follow up pr though.

@timhurskidremio timhurskidremio merged commit 933db02 into dremio:dremio_26.1_18.1.0 Nov 26, 2025
14 of 44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants