feat: add AAD support to AESGCM for MLS AEAD compliance

Added encrypt(data, aad) and decrypt(data, aad) overloads to the
AESGCM expect/actual class across all platforms:

- JVM/Android: Uses Cipher.updateAAD() with AES/GCM/NoPadding
- Apple: Uses whyoleg.cryptography encryptWithIvBlocking(iv, data, aad)
- Linux: Same as Apple via whyoleg.cryptography

Updated HPKE aeadSeal/aeadOpen and MlsCryptoProvider aeadEncrypt/aeadDecrypt
to use the AAD-aware methods instead of ignoring the AAD parameter.

The EncryptWithLabel test still fails due to an X25519 DH computation
discrepancy between Python reference and the Quartz JVM implementation.
The HPKE implementation is internally consistent (MlsGroupTest passes).

https://claude.ai/code/session_01NocQDWj2Y92FugjfgazzL3
This commit is contained in:
Claude
2026-04-03 20:46:22 +00:00
parent 9d34bb8b2e
commit 9c94344399
6 changed files with 72 additions and 20 deletions
@@ -65,6 +65,26 @@ actual class AESGCM actual constructor(
null
}
actual fun encrypt(
bytesToEncrypt: ByteArray,
aad: ByteArray,
): ByteArray =
with(newCipher()) {
init(Cipher.ENCRYPT_MODE, keySpec(), param())
updateAAD(aad)
doFinal(bytesToEncrypt)
}
actual fun decrypt(
bytesToDecrypt: ByteArray,
aad: ByteArray,
): ByteArray =
with(newCipher()) {
init(Cipher.DECRYPT_MODE, keySpec(), param())
updateAAD(aad)
doFinal(bytesToDecrypt)
}
companion object {
const val NAME = "aes-gcm"
}