Capture notification lifecycle events securely
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user