Adding secret stream impl, completed generichash impl
This commit is contained in:
1 parent
6f38a01195
commit
39f0817308
9 files changed
+162
-63
No files matched your search
+3
-4
@@ -9,7 +9,6 @@ import kotlinx.cinterop.reinterpret
|
||||
import libsodium.crypto_generichash
|
||||
import libsodium.crypto_generichash_final
|
||||
import libsodium.crypto_generichash_init
|
||||
import libsodium.crypto_generichash_state
|
||||
import libsodium.crypto_generichash_update
|
||||
import platform.posix.malloc
|
||||
|
||||
@@ -21,7 +20,7 @@ import platform.posix.malloc
|
||||
|
||||
actual typealias GenericHashStateInternal = libsodium.crypto_generichash_blake2b_state
|
||||
|
||||
actual object GenericHashing {
|
||||
actual object GenericHash {
|
||||
val _emitByte: Byte = 0
|
||||
val _emitByteArray: ByteArray = ByteArray(0)
|
||||
|
||||
@@ -69,7 +68,7 @@ actual object GenericHashing {
|
||||
) {
|
||||
val pinnedMessage = messagePart.pin()
|
||||
crypto_generichash_update(
|
||||
state.state.ptr,
|
||||
state.internalState.ptr,
|
||||
pinnedMessage.addressOf(0),
|
||||
messagePart.size.convert()
|
||||
)
|
||||
@@ -80,7 +79,7 @@ actual object GenericHashing {
|
||||
val hashResult = UByteArray(state.hashLength)
|
||||
val hashResultPinned = hashResult.pin()
|
||||
crypto_generichash_final(
|
||||
state.state.ptr,
|
||||
state.internalState.ptr,
|
||||
hashResultPinned.addressOf(0),
|
||||
state.hashLength.convert()
|
||||
)
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.ionspin.kotlin.crypto.secretstream
|
||||
|
||||
actual typealias SecretStreamState = libsodium.crypto_secretstream_xchacha20poly1305_state
|
||||
|
||||
actual object SecretStream {
|
||||
actual fun xChaCha20Poly1305InitPush(key: UByteArray): SecretStreamStateAndHeader {
|
||||
TODO("not implemented yet")
|
||||
}
|
||||
|
||||
actual fun xChaCha20Poly1305Push(
|
||||
state: SecretStreamState,
|
||||
message: UByteArray,
|
||||
additionalData: UByteArray,
|
||||
tag: UByte
|
||||
): UByteArray {
|
||||
TODO("not implemented yet")
|
||||
}
|
||||
|
||||
actual fun xChaCha20Poly1305InitPull(
|
||||
key: UByteArray,
|
||||
header: UByteArray
|
||||
): SecretStreamStateAndHeader {
|
||||
TODO("not implemented yet")
|
||||
}
|
||||
|
||||
actual fun xChaCha20Poly1305Pull(
|
||||
state: SecretStreamState,
|
||||
ciphertext: UByteArray,
|
||||
additionalData: UByteArray
|
||||
): DecryptedDataAndTag {
|
||||
TODO("not implemented yet")
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user