-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from ReneeVandervelde/fix-chacha-result-equality
Fix Equality Check in `XChaCha20EncryptionResult`
- Loading branch information
Showing
2 changed files
with
30 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...src/commonTest/kotlin/com/iospin/kotlin/crypto/symmetric/XChaCha20EncryptionResultTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.iospin.kotlin.crypto.symmetric | ||
|
||
import com.ionspin.kotlin.crypto.symmetric.XChaCha20EncryptionResult | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertNotEquals | ||
|
||
class XChaCha20EncryptionResultTest { | ||
@Test | ||
fun testEquality() { | ||
val firstResult = XChaCha20EncryptionResult( | ||
nonce = ubyteArrayOf(0x12u, 0x34u, 0x56u), | ||
encryptionData = ubyteArrayOf(0x78u, 0x9Au), | ||
) | ||
val secondResult = XChaCha20EncryptionResult( | ||
nonce = ubyteArrayOf(0x12u, 0x34u, 0x56u), | ||
encryptionData = ubyteArrayOf(0x78u, 0x9Au), | ||
) | ||
val differingResult = XChaCha20EncryptionResult( | ||
nonce = ubyteArrayOf(0u), | ||
encryptionData = ubyteArrayOf(0u), | ||
) | ||
|
||
assertEquals(firstResult, secondResult) | ||
assertNotEquals(firstResult, differingResult) | ||
assertNotEquals(secondResult, differingResult) | ||
} | ||
} |