fix macos and windows compilation issues
This commit is contained in:
1 parent
e6e7a7664c
commit
d1a910b965
5 files changed
+24
-43
No files matched your search
+7
-7
@@ -15,39 +15,39 @@ actual typealias GenericHashState = Any
|
||||
|
||||
actual class Crypto internal actual constructor() {
|
||||
actual fun crypto_hash_sha256_init(): dynamic {
|
||||
println("Debug")
|
||||
println("Debug crypto_hash_sha256_init")
|
||||
val result = js("getSodium().crypto_hash_sha256_init()")
|
||||
return result
|
||||
}
|
||||
|
||||
actual fun crypto_hash_sha256_update(state: Sha256State, input: UByteArray) {
|
||||
println("Debug")
|
||||
println("Debug crypto_hash_sha256_update")
|
||||
getSodium().crypto_hash_sha256_update(state, input.toUInt8Array(), )
|
||||
}
|
||||
|
||||
actual fun crypto_hash_sha256_final(state: Sha256State): UByteArray {
|
||||
println("Debug")
|
||||
println("Debug crypto_hash_sha256_final")
|
||||
return getSodium().crypto_hash_sha256_final(state).toUByteArray()
|
||||
}
|
||||
|
||||
actual fun crypto_hash_sha512_init(): dynamic {
|
||||
println("Debug")
|
||||
println("Debug crypto_hash_sha512_init")
|
||||
val result = js("getSodium().crypto_hash_sha512_init()")
|
||||
return result
|
||||
}
|
||||
|
||||
actual fun crypto_hash_sha512_update(state: Sha512State, input: UByteArray) {
|
||||
println("Debug")
|
||||
println("Debug crypto_hash_sha512_update")
|
||||
getSodium().crypto_hash_sha512_update(state, input.toUInt8Array(), )
|
||||
}
|
||||
|
||||
actual fun crypto_hash_sha512_final(state: Sha512State): UByteArray {
|
||||
println("Debug")
|
||||
println("Debug crypto_hash_sha512_final")
|
||||
return getSodium().crypto_hash_sha512_final(state).toUByteArray()
|
||||
}
|
||||
|
||||
actual fun crypto_generichash_init(key: UByteArray, outlen: Int): dynamic {
|
||||
println("Debug")
|
||||
println("Debug crypto_generichash_init")
|
||||
return getSodium().crypto_generichash_init(key.toUInt8Array(), outlen)
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -17,45 +17,45 @@ actual typealias GenericHashState = ByteArray
|
||||
actual class Crypto internal actual constructor() {
|
||||
actual fun crypto_hash_sha256_init(): Sha256State {
|
||||
val state = debug.test.Sha256State()
|
||||
println("Debug")
|
||||
println("Debug crypto_hash_sha256_init")
|
||||
sodium.crypto_hash_sha256_init(state)
|
||||
return state
|
||||
}
|
||||
|
||||
actual fun crypto_hash_sha256_update(state: Sha256State, input: UByteArray) {
|
||||
println("Debug")
|
||||
println("Debug crypto_hash_sha256_update")
|
||||
sodium.crypto_hash_sha256_update(state, input.asByteArray(), input.size.toLong())
|
||||
}
|
||||
|
||||
actual fun crypto_hash_sha256_final(state: Sha256State): UByteArray {
|
||||
val out = UByteArray(32)
|
||||
println("Debug")
|
||||
println("Debug crypto_hash_sha256_final")
|
||||
sodium.crypto_hash_sha256_final(state, out.asByteArray())
|
||||
return out
|
||||
}
|
||||
|
||||
actual fun crypto_hash_sha512_init(): Sha512State {
|
||||
val state = debug.test.Sha512State()
|
||||
println("Debug")
|
||||
println("Debug crypto_hash_sha512_init")
|
||||
sodium.crypto_hash_sha512_init(state)
|
||||
return state
|
||||
}
|
||||
|
||||
actual fun crypto_hash_sha512_update(state: Sha512State, input: UByteArray) {
|
||||
println("Debug")
|
||||
println("Debug crypto_hash_sha512_update")
|
||||
sodium.crypto_hash_sha512_update(state, input.asByteArray(), input.size.toLong())
|
||||
}
|
||||
|
||||
actual fun crypto_hash_sha512_final(state: Sha512State): UByteArray {
|
||||
val out = UByteArray(64)
|
||||
println("Debug")
|
||||
println("Debug crypto_hash_sha512_final")
|
||||
sodium.crypto_hash_sha512_final(state, out.asByteArray())
|
||||
return out
|
||||
}
|
||||
|
||||
actual fun crypto_generichash_init(key: UByteArray, outlen: Int): GenericHashState {
|
||||
val state = debug.test.GenericHashState(sodium.crypto_generichash_statebytes())
|
||||
println("Debug")
|
||||
println("Debug crypto_generichash_init")
|
||||
sodium.crypto_generichash_init(state, key.asByteArray(), key.size, outlen)
|
||||
return state
|
||||
}
|
||||
|
||||
+7
@@ -30,11 +30,13 @@ actual class Crypto internal actual constructor() {
|
||||
actual fun crypto_hash_sha256_init(): Sha256State {
|
||||
val allocated = sodium_malloc(debug.test.Sha256State.size.convert())!!
|
||||
val state = allocated.reinterpret<debug.test.Sha256State>().pointed
|
||||
println("Debug crypto_hash_sha256_init")
|
||||
libsodium.crypto_hash_sha256_init(state.ptr)
|
||||
return state
|
||||
}
|
||||
|
||||
actual fun crypto_hash_sha256_update(state: Sha256State, input: UByteArray) {
|
||||
println("Debug crypto_hash_sha256_update")
|
||||
val pinnedInput = input.pin()
|
||||
libsodium.crypto_hash_sha256_update(state.ptr, pinnedInput.addressOf(0), input.size.convert())
|
||||
pinnedInput.unpin()
|
||||
@@ -42,6 +44,7 @@ actual class Crypto internal actual constructor() {
|
||||
|
||||
actual fun crypto_hash_sha256_final(state: Sha256State): UByteArray {
|
||||
val out = UByteArray(32)
|
||||
println("Debug crypto_hash_sha256_final")
|
||||
val pinnedOut = out.pin()
|
||||
libsodium.crypto_hash_sha256_final(state.ptr, pinnedOut.addressOf(0))
|
||||
pinnedOut.unpin()
|
||||
@@ -51,11 +54,13 @@ actual class Crypto internal actual constructor() {
|
||||
actual fun crypto_hash_sha512_init(): Sha512State {
|
||||
val allocated = sodium_malloc(debug.test.Sha512State.size.convert())!!
|
||||
val state = allocated.reinterpret<debug.test.Sha512State>().pointed
|
||||
println("Debug crypto_hash_sha512_init")
|
||||
libsodium.crypto_hash_sha512_init(state.ptr)
|
||||
return state
|
||||
}
|
||||
|
||||
actual fun crypto_hash_sha512_update(state: Sha512State, input: UByteArray) {
|
||||
println("Debug crypto_hash_sha512_update")
|
||||
val pinnedInput = input.pin()
|
||||
libsodium.crypto_hash_sha512_update(state.ptr, pinnedInput.addressOf(0), input.size.convert())
|
||||
pinnedInput.unpin()
|
||||
@@ -63,6 +68,7 @@ actual class Crypto internal actual constructor() {
|
||||
|
||||
actual fun crypto_hash_sha512_final(state: Sha512State): UByteArray {
|
||||
val out = UByteArray(64)
|
||||
println("Debug crypto_hash_sha512_final")
|
||||
val pinnedOut = out.pin()
|
||||
libsodium.crypto_hash_sha512_final(state.ptr, pinnedOut.addressOf(0))
|
||||
pinnedOut.unpin()
|
||||
@@ -72,6 +78,7 @@ actual class Crypto internal actual constructor() {
|
||||
actual fun crypto_generichash_init(key: UByteArray, outlen: Int): GenericHashState {
|
||||
val allocated = sodium_malloc(debug.test.GenericHashState.size.convert())!!
|
||||
val state = allocated.reinterpret<debug.test.GenericHashState>().pointed
|
||||
println("Debug crypto_generichash_init")
|
||||
val pinnedKey = key.pin()
|
||||
libsodium.crypto_generichash_init(state.ptr, pinnedKey.addressOf(0), key.size.convert(),
|
||||
outlen.convert())
|
||||
|
||||
Reference in new issue
Block a user