Reduce chance that tamper change is same as original value in tests

This commit is contained in:
Ugljesa Jovanovic 2021-07-19 22:14:27 +02:00
parent 8b39e8a813
commit 38d3ac1b44
No known key found for this signature in database
GPG Key ID: 178E6DFCECCB0E0F

View File

@ -44,6 +44,8 @@ class BoxTest {
assertFailsWith<BoxCorruptedOrTamperedDataException>() {
val tampered = encrypted.copyOf()
tampered[1] = 0U
tampered[2] = 0U
tampered[3] = 0U
Box.openEasy(tampered, messageNonce, senderKeypair.publicKey, recipientKeypair.secretKey)
}
}
@ -71,6 +73,8 @@ class BoxTest {
assertFailsWith<BoxCorruptedOrTamperedDataException>() {
val tampered = encrypted.ciphertext.copyOf()
tampered[1] = 0U
tampered[2] = 0U
tampered[3] = 0U
Box.openDetached(
tampered,
encrypted.tag,
@ -104,6 +108,8 @@ class BoxTest {
assertFailsWith<BoxCorruptedOrTamperedDataException>() {
val tampered = encrypted.copyOf()
tampered[1] = 0U
tampered[2] = 0U
tampered[3] = 0U
Box.openEasyAfterNM(tampered, messageNonce, recipientComputedSessionKey)
}
}
@ -124,6 +130,8 @@ class BoxTest {
assertFailsWith<BoxCorruptedOrTamperedDataException>() {
val tampered = sealed.copyOf()
tampered[1] = 0U
tampered[2] = 0U
tampered[3] = 0U
Box.sealOpen(tampered, recipientKeypair.publicKey, recipientKeypair.secretKey)
}
}