Update readme and changelog, as this is going into master so snapshots are available for experimenting

This commit is contained in:
Ugljesa Jovanovic authored and Ugljesa Jovanovic committed 2020-08-08 22:22:38 +02:00
1 parent e997c18d1d
commit e6e7a7664c
13 files changed
+265 -28

No files matched your search

@@ -21,7 +21,7 @@ class SmokeTest {
Initializer.initialize()
val crypto = Crypto()
//TODO seems to be a bug in JS compiler, if we have the same method name in crypto an in JsSodiumInterface, method tries to call wrong method name (unneeded suffix _0)
//I've workaround this by making state functions with 1 parameter execute call with js("") wrap, but still might sail somewhere else
//I've worked around this by making state functions with 1 parameter execute call with js("") wrap, but still might sail somewhere else
val state256 = crypto.crypto_hash_sha256_init()
crypto.crypto_hash_sha256_update(state256, "Hello".encodeToUByteArray())
val result = crypto.crypto_hash_sha256_final(state256)
@@ -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)
}
}
@@ -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
}
@@ -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())