Progress on native generator

This commit is contained in:
Ugljesa Jovanovic authored and Ugljesa Jovanovic committed 2020-08-01 18:07:12 +02:00
1 parent c975bdb248
commit 97c631ecb7
10 files changed
+371 -49

No files matched your search

@@ -1,5 +1,6 @@
package debug.test
import ByteArray
import com.goterl.lazycode.lazysodium.SodiumJava
import com.goterl.lazycode.lazysodium.interfaces.Hash
import kotlin.Int
@@ -9,20 +10,47 @@ val sodium: SodiumJava = SodiumJava()
actual typealias Sha256State = Hash.State256
actual class Hashing {
actual typealias Sha512State = Hash.State512
actual typealias GenericHashState = ByteArray
actual class Crypto {
actual fun crypto_hash_sha256_init(state: Sha256State): Int {
println("Debug")
return sodium.crypto_hash_sha256_init(state)
}
}
actual class GenericHash {
actual fun crypto_hash_sha256_update(state: Sha256State, input: UByteArray) {
println("Debug")
sodium.crypto_hash_sha256_update(state, input.asByteArray(), input.size.toLong())
}
actual fun crypto_hash_sha256_final(state: Sha256State, out: UByteArray) {
println("Debug")
sodium.crypto_hash_sha256_final(state, out.asByteArray())
}
actual fun crypto_hash_sha512_init(state: Sha512State): Int {
println("Debug")
return sodium.crypto_hash_sha512_init(state)
}
actual fun crypto_hash_sha512_update(state: Sha512State, input: UByteArray) {
println("Debug")
sodium.crypto_hash_sha512_update(state, input.asByteArray(), input.size.toLong())
}
actual fun crypto_hash_sha512_final(state: Sha512State, out: UByteArray) {
println("Debug")
sodium.crypto_hash_sha512_final(state, out.asByteArray())
}
actual fun crypto_generichash_init(
state: UByteArray,
state: GenericHashState,
key: UByteArray,
outlen: Int
): Int {
println("Debug")
return sodium.crypto_generichash_init(state.asByteArray(), key.asByteArray(), key.size, outlen)
return sodium.crypto_generichash_init(state, key.asByteArray(), key.size, outlen)
}
}