Added a bunch, also added xchacha20 ic and xor

This commit is contained in:
Ugljesa Jovanovic committed 2021-02-23 19:54:07 +01:00
1 parent 354c0c2fd6
commit 574377da3c
11 files changed
+473 -81

No files matched your search

@@ -232,6 +232,10 @@ interface JsSodiumInterface {
fun crypto_stream_chacha20_xor(message : Uint8Array, nonce: Uint8Array, key: Uint8Array) : Uint8Array
fun crypto_stream_chacha20_xor_ic(message : Uint8Array, nonce: Uint8Array, initialCounter: UInt, key: Uint8Array) : Uint8Array
fun crypto_stream_xchacha20_keygen() : Uint8Array
fun crypto_stream_xchacha20_xor(message : Uint8Array, nonce: Uint8Array, key: Uint8Array) : Uint8Array
fun crypto_stream_xchacha20_xor_ic(message : Uint8Array, nonce: Uint8Array, initialCounter: UInt, key: Uint8Array) : Uint8Array
// ---- Stream end ----
// ---- Scalar multiplication ----
@@ -79,4 +79,42 @@ actual object Stream {
return result.toUByteArray()
}
actual fun xChacha20Keygen(): UByteArray {
val result = getSodium().crypto_stream_xchacha20_keygen()
return result.toUByteArray()
}
actual fun xChacha20Xor(
message: UByteArray,
nonce: UByteArray,
key: UByteArray
): UByteArray {
val result = getSodium().crypto_stream_xchacha20_xor(
message.toUInt8Array(),
nonce.toUInt8Array(),
key.toUInt8Array()
)
return result.toUByteArray()
}
actual fun xChacha20XorIc(
message: UByteArray,
nonce: UByteArray,
initialCounter: ULong,
key: UByteArray
): UByteArray {
val result = getSodium().crypto_stream_xchacha20_xor_ic(
message.toUInt8Array(),
nonce.toUInt8Array(),
initialCounter.toUInt(),
key.toUInt8Array()
)
return result.toUByteArray()
}
}