Skip to content

feat: support AES-192/256-CBC and AES-192/256-GCM assertion decryption#90

Open
jacques-kigo wants to merge 3 commits intonjaremko:masterfrom
jacques-kigo:feat/aes-cbc-192-256-and-gcm-decryption
Open

feat: support AES-192/256-CBC and AES-192/256-GCM assertion decryption#90
jacques-kigo wants to merge 3 commits intonjaremko:masterfrom
jacques-kigo:feat/aes-cbc-192-256-and-gcm-decryption

Conversation

@jacques-kigo
Copy link
Copy Markdown
Contributor

What

Adds match arms in decrypt_assertion_value_info (src/crypto/xmlsec/mod.rs) for:

  • http://www.w3.org/2001/04/xmlenc#aes192-cbc
  • http://www.w3.org/2001/04/xmlenc#aes256-cbc
  • http://www.w3.org/2009/xmlenc11#aes192-gcm
  • http://www.w3.org/2009/xmlenc11#aes256-gcm

Each new arm mirrors the existing AES-128-CBC / AES-128-GCM arm, swapping the OpenSSL Cipher constructor.

Why

ServiceProvider::metadata() already advertises CBC-128/192/256 in the SP's <KeyDescriptor> EncryptionMethod block, but the decryption path only implemented AES-128-CBC and AES-128-GCM. Identity providers that pick the strongest advertised algorithm (e.g. AES-256-CBC) hit EncryptedAssertionValueMethodUnsupported even though the SP claimed support. This PR aligns the implementation with what the metadata advertises.

Test coverage

8 new tests in src/service_provider/tests.rs, mirroring the existing test_decrypt_assertion / test_decrypt_and_validate_assertion pattern (one decrypt-only and one full-validation test per new algorithm).

8 new fixtures in test_vectors/, generated with xmlsec1 --encrypt against the existing sp_cert.pem / sp_private.pem keypair (rsa-oaep-mgf1p key transport). Generation procedure documented in test_vectors/README.md, parallel to the existing signed-response generation docs.

README.md supported-algorithm list updated to reflect the four new arms.

Commits

Split into two for review:

  1. feat: support AES-192-CBC and AES-256-CBC assertion decryption — the metadata-implementation alignment that motivated the PR
  2. feat: support AES-192-GCM and AES-256-GCM assertion decryption — included for completeness alongside the existing AES-128-GCM arm

Either commit could land independently; they're separable.

Notes

  • No new dependencies — Cipher::aes_192_cbc(), Cipher::aes_256_cbc(), Cipher::aes_192_gcm(), Cipher::aes_256_gcm() already exist in the openssl crate the project uses.
  • The fixture-generation procedure had one gotcha worth flagging: xmlsec1 (correctly) strips redundant xmlns:dsig declarations on <dsig:KeyInfo> since the prefix is already in scope from the parent <xenc:EncryptedData>. samael's serde-based parser requires the explicit xmlns:dsig attribute on the <dsig:KeyInfo> element itself (EncryptedKeyInfo.ds in src/key_info.rs), so the post-processing step in test_vectors/README.md re-adds it.
  • All new tests pass on Apple Silicon (Darwin 25.4.0) against xmlsec1 1.3.10 with the openssl backend.

Add match arms in `decrypt_assertion_value_info` for AES-192-CBC and
AES-256-CBC, mirroring the existing AES-128-CBC arm. SP metadata
already advertised these algorithms, so this aligns the implementation
with what is published.

Add static test vectors and tests covering both algorithms (decrypt-
only and full validation), generated with `xmlsec1 --encrypt` against
the existing `sp_cert.pem` / `sp_private.pem` keypair. Document the
fixture-generation procedure in `test_vectors/README.md`, parallel to
the existing signed-response generation docs, and update the supported-
algorithm list in the top-level `README.md`.
Add match arms in `decrypt_assertion_value_info` for AES-192-GCM and
AES-256-GCM, mirroring the existing AES-128-GCM arm (rsa-oaep-mgf1p
key transport, 16-byte authentication tag).

Add static test vectors and tests covering both algorithms (decrypt-
only and full validation), generated with `xmlsec1 --encrypt`. Update
the supported-algorithm list in the top-level `README.md` and extend
the fixture-generation procedure in `test_vectors/README.md` to cover
the GCM variants.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant