Skip to content

Add OPENSSL_cleanse override to AES-GCM SAW proofs#186

Merged
justsmth merged 2 commits intomasterfrom
fix-aws-gcm
Mar 26, 2026
Merged

Add OPENSSL_cleanse override to AES-GCM SAW proofs#186
justsmth merged 2 commits intomasterfrom
fix-aws-gcm

Conversation

@justsmth
Copy link
Copy Markdown
Contributor

@justsmth justsmth commented Mar 25, 2026

Related

Description

Add OPENSSL_cleanse_ov to the evp_cipher_ovs override list in the AES-GCM SAW proofs.

This is needed to support aws/aws-lc#3121, which adds OPENSSL_cleanse calls to zeroize sensitive stack buffers in several cryptographic functions. Two of those calls land on the EVP_CipherInit_ex proof path:

  • CRYPTO_gcm128_init_key — cleansing the ghash_key (the raw GHASH subkey H = AES_K(0^128))
  • CRYPTO_ghash_init — cleansing the byte-swapped H[2] local copy of the same subkey

Without the override, SAW attempts to symbolically execute OPENSSL_cleanse, which contains an inline assembly barrier (__asm__ __volatile__) and cannot be interpreted, causing the fv-saw-x86_64-aes-gcm job to fail.

The OPENSSL_cleanse_ov override is already defined in proof/common/memory.saw (which AES-GCM.saw includes) and is already used by the ECDSA and ECDH proofs for the same reason.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@justsmth justsmth requested a review from a team as a code owner March 25, 2026 16:54
@justsmth justsmth merged commit 228593a into master Mar 26, 2026
12 checks passed
@justsmth justsmth deleted the fix-aws-gcm branch March 26, 2026 13:23
justsmth added a commit to aws/aws-lc that referenced this pull request Mar 26, 2026
#3121)

### Issues
Addresses: AWS-LC-1073

### Related
* awslabs/aws-lc-verification#186

### Description of changes:

Several functions were leaving sensitive intermediate values on the
stack after returning. This change adds `OPENSSL_cleanse` calls to
zeroize those buffers before they go out of scope:

- **CTR-DRBG** (`ctrdrbg.c`): Zeroize `seed_material`, `temp`,
`entropy_copy`, and partial keystream `block`.
- **ECDH** (`ecdh.c`): Zeroize the raw shared secret `buf` in
`ECDH_compute_key_fips`.
- **ECDSA** (`ecdsa.c`): Zeroize `tmp` after it holds k⁻¹ in
`ecdsa_sign_impl`.
- **X25519 / Ed25519 nohw** (`curve25519_nohw.c`): Zeroize clamped
private scalars, Montgomery ladder intermediates, and nonce-derived
values.
- **X25519 / Ed25519 s2n-bignum** (`curve25519_s2n_bignum_asm.c`): Same
treatment for the s2n-bignum code paths.
- **GCM** (`gcm.c`): Zeroize the GHASH hash key `H` (derived from
`AES_K(0^128)`) and `ghash_key`. The early `return` statements in
`CRYPTO_ghash_init` are refactored to `goto out` so all paths go through
a single cleanup site.

### Call-outs:

The GCM change is the only one with a structural refactor — the `return`
→ `goto out` conversion in `CRYPTO_ghash_init`. All other changes are
purely additive `OPENSSL_cleanse` calls at function exit points.

### Testing:

Existing tests cover the functional behavior of all affected code paths.
These changes should be transparent since they only zero memory that is
no longer used.


By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license and the ISC license.
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.

2 participants