Working single shot xchacha20poly1305 encryption and decryption in delegated flavour

This commit is contained in:
Ugljesa Jovanovic authored and Ugljesa Jovanovic committed 2020-06-27 18:20:53 +02:00
1 parent 6228263978
commit e6f560ba8e
13 files changed
+66 -48

No files matched your search

@@ -173,7 +173,6 @@ class XChaCha20Pure(key: UByteArray, nonce: UByteArray, initialCounter: UInt = 0
)
keystreamRemainingCounter = 64 - remainingBytes
processedBytesSoFar += data.size
state.overwriteWithZeroes()
return ciphertext
}
@@ -1,6 +1,7 @@
package com.ionspin.kotlin.crypto.symmetric
import com.ionspin.kotlin.crypto.hash.encodeToUByteArray
import com.ionspin.kotlin.crypto.util.hexColumsPrint
import kotlin.test.Test
import kotlin.test.assertTrue
@@ -239,9 +240,9 @@ class XChaCha20Test {
val firstChunk = xChaCha.xorWithKeystream(message.sliceArray(0 until 5))
val secondChunk = xChaCha.xorWithKeystream(message.sliceArray(5 until 90))
val thirdChunk = xChaCha.xorWithKeystream(message.sliceArray(90 until message.size))
val result = firstChunk + secondChunk + thirdChunk
assertTrue {
(firstChunk + secondChunk + thirdChunk).contentEquals(expected)
(result).contentEquals(expected)
}
}