Capture notification lifecycle events securely

This commit is contained in:
ajp_anton
2026-07-23 08:08:11 +00:00
parent 7da14dd10f
commit 6d77a43c55
6 changed files with 176 additions and 7 deletions
@@ -3,7 +3,6 @@ package se.ajpanton.notificationlog.data
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
import java.security.SecureRandom
import javax.crypto.KeyGenerator
class AesGcmCipherTest {
@@ -21,7 +20,7 @@ class AesGcmCipherTest {
@Test(expected = javax.crypto.AEADBadTagException::class)
fun rejectsTamperedCipherText() {
val key = KeyGenerator.getInstance("AES").apply { init(256) }.generateKey()
val encrypted = AesGcmCipher(key, SecureRandom()).encrypt("message".encodeToByteArray())
val encrypted = AesGcmCipher(key).encrypt("message".encodeToByteArray())
encrypted.cipherText[0] = (encrypted.cipherText[0].toInt() xor 1).toByte()
AesGcmCipher(key).decrypt(encrypted)