Same thing for JVM, forgot about tag length
This commit is contained in:
parent
89e5ae62e4
commit
86611453ea
@ -4,7 +4,6 @@ import com.ionspin.kotlin.bignum.integer.util.hexColumsPrint
|
||||
import com.ionspin.kotlin.crypto.LibsodiumInitializer
|
||||
import com.ionspin.kotlin.crypto.util.encodeToUByteArray
|
||||
import com.ionspin.kotlin.crypto.util.testBlocking
|
||||
import kotlin.test.BeforeTest
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
@ -15,13 +14,10 @@ import kotlin.test.assertTrue
|
||||
*/
|
||||
class SecretStreamTest {
|
||||
|
||||
@BeforeTest
|
||||
fun initialize() = testBlocking {
|
||||
LibsodiumInitializer.initialize()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSecretStream() = testBlocking {
|
||||
LibsodiumInitializer.initializeWithCallback {
|
||||
val message = ("Ladies and Gentlemen of the class of '99: If I could offer you " +
|
||||
"only one tip for the future, sunscreen would be it.").encodeToUByteArray()
|
||||
|
||||
@ -80,6 +76,7 @@ class SecretStreamTest {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ actual object SecretStream {
|
||||
additionalData: UByteArray,
|
||||
tag: UByte
|
||||
): UByteArray {
|
||||
val ciphertext = UByteArray(message.size)
|
||||
val ciphertext = UByteArray(message.size + 17)
|
||||
sodium.crypto_secretstream_xchacha20poly1305_push(
|
||||
state,
|
||||
ciphertext.asByteArray(),
|
||||
@ -47,7 +47,7 @@ actual object SecretStream {
|
||||
ciphertext: UByteArray,
|
||||
additionalData: UByteArray
|
||||
): DecryptedDataAndTag {
|
||||
val result = UByteArray(ciphertext.size)
|
||||
val result = UByteArray(ciphertext.size - 17)
|
||||
val tagArray = UByteArray(1) { 0U }
|
||||
sodium.crypto_secretstream_xchacha20poly1305_pull(
|
||||
state,
|
||||
|
Loading…
x
Reference in New Issue
Block a user