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:
+20
@@ -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"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user