Skip to content

[C++][Gandiva] Modernize AES functions: add authenticated encryption (CBC/GCM) via ENCRYPT/DECRYPT #53776

Open

Description

@dmitry-chirkov-dremio

Describe the enhancement requested

Gandiva's aes_encrypt / aes_decrypt (ARROW-14431) support only AES-ECB and operate on VARCHAR. ECB is deterministic and unauthenticated: identical plaintext blocks give identical ciphertext, there is no IV, and tampering goes undetected. VARCHAR is also a poor fit for ciphertext, which is arbitrary bytes.

This adds binary encrypt / decrypt functions with modern cipher modes:

encrypt(data, key, mode)
encrypt(data, key, mode, iv)
encrypt(data, key, mode, iv, aad)   -- decrypt has the same overloads

All arguments and results are binary.

  • Modes: AES-ECB, AES-CBC (PKCS#7 by default, -NONE variants), AES-GCM; 16/24/32-byte keys.
  • GCM: caller-supplied nonce and optional AAD. Output is ciphertext || 16-byte tag; decrypt verifies the tag and errors on any key, IV, AAD or ciphertext mismatch.
  • IV and AAD are caller-managed and not embedded in the output. A NULL argument yields NULL. Failures are reported as Gandiva function errors with the OpenSSL diagnostic.
  • The registry functions aes_encrypt / aes_decrypt are unchanged. They stay ECB-only and are not recommended for new use.

Testing: all modes and key sizes, invalid key/IV/padding, GCM tag and AAD mismatch, block-aligned inputs, and known-answer vectors from the GCM specification (McGrew and Viega, test cases 4-6; 12-, 8- and 60-byte IVs).

Related: #50522 (output sizing in the current aes_encrypt stub; the new implementation sizes buffers independently of key length), #45693, #29995.

A PR will follow.

Component(s)

C++, Gandiva

Activity

  1. dmitry-chirkov-dremio commented on Oct 14, 2026

    @dmitry-chirkov-dremio
    ContributorAuthor

    take

  2. added 6 commits that reference this issue on Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions