Bump to 1.4-M3

This commit is contained in:
Ugljesa Jovanovic authored and Ugljesa Jovanovic committed 2020-07-07 00:00:53 +02:00
1 parent 71ec5b7585
commit f5150557d6
9 files changed
+44 -17

No files matched your search

@@ -46,7 +46,7 @@ interface JsSodiumInterface {
//XChaCha20Poly1305
//encrypt
fun crypto_secretstream_xchacha20poly1305_init_push(header: Uint8Array) : dynamic
fun crypto_secretstream_xchacha20poly1305_push(state: dynamic, message: Uint8Array, additionalData: Uint8Array, tag: Char) : Uint8Array
fun crypto_secretstream_xchacha20poly1305_push(state: dynamic, message: Uint8Array, additionalData: Uint8Array, tag: UByte) : Uint8Array
//decrypt
fun crypto_secretstream_xchacha20poly1305_init_pull(header: Uint8Array, key: Uint8Array) : dynamic
@@ -54,15 +54,18 @@ actual class XChaCha20Poly1305Delegated internal actual constructor() {
var state : dynamic = null
actual fun initializeForEncryption(key: UByteArray) : UByteArray {
println("Initializaing for encryption")
val stateAndHeader = getSodium().crypto_secretstream_xchacha20poly1305_init_push(key.toUInt8Array())
val state = stateAndHeader.state
val header = stateAndHeader.header
console.log(state)
console.log(header)
println("Done initializaing for encryption")
return header
}
actual fun initializeForDecryption(key: UByteArray, header: UByteArray) {
}
internal actual constructor(
@@ -70,12 +73,14 @@ actual class XChaCha20Poly1305Delegated internal actual constructor() {
testState: UByteArray,
testHeader: UByteArray
) : this() {
state = getSodium().crypto_secretstream_xchacha20poly1305_init_pull(testHeader.toUInt8Array(), key.toUInt8Array())
console.log(state)
println("Done initializaing test state")
}
actual fun encrypt(data: UByteArray, additionalData: UByteArray): UByteArray {
// val encrypted
TODO()
val encrypted = getSodium().crypto_secretstream_xchacha20poly1305_push(state, data.toUInt8Array(), additionalData.toUInt8Array(), 0U)
return encrypted.toUByteArray()
}
actual fun decrypt(data: UByteArray, additionalData: UByteArray): UByteArray {