Added sha2 hashes in common and native and test
This commit is contained in:
1 parent
1878144b8f
commit
15be707114
7 files changed
+313
-4
No files matched your search
+19
-3
@@ -18,7 +18,7 @@ interface JsSodiumInterface {
|
||||
|
||||
fun crypto_hash_sha512(message: Uint8Array): Uint8Array
|
||||
|
||||
//Updateable
|
||||
// ---- Generic hash ---- // Updateable
|
||||
|
||||
fun crypto_generichash_init(key : Uint8Array, hashLength: Int) : dynamic
|
||||
|
||||
@@ -28,11 +28,27 @@ interface JsSodiumInterface {
|
||||
|
||||
fun crypto_generichash_keygen() : Uint8Array
|
||||
|
||||
//Short hash
|
||||
// ---- Generic hash end ---- // Updateable
|
||||
|
||||
// ---- Blake2b ----
|
||||
|
||||
fun crypto_generichash_blake2b(hashLength: Int, inputMessage: Uint8Array, key: Uint8Array): Uint8Array
|
||||
|
||||
fun crypto_generichash_blake2b_init(key : Uint8Array, hashLength: Int) : dynamic
|
||||
|
||||
fun crypto_generichash_blake2b_update(state: dynamic, inputMessage: Uint8Array)
|
||||
|
||||
fun crypto_generichash_blake2b_final(state: dynamic, hashLength: Int) : Uint8Array
|
||||
|
||||
fun crypto_generichash_blake2b_keygen() : Uint8Array
|
||||
|
||||
// ---- Blake2b end ----
|
||||
|
||||
// ---- Short hash ----
|
||||
fun crypto_shorthash(data : Uint8Array, key: Uint8Array) : Uint8Array
|
||||
|
||||
fun crypto_shorthash_keygen() : Uint8Array
|
||||
|
||||
// ---- Short hash end ----
|
||||
|
||||
fun crypto_hash_sha256_init() : dynamic
|
||||
|
||||
|
||||
+31
@@ -48,4 +48,35 @@ actual object GenericHash {
|
||||
actual fun genericHashKeygen(): UByteArray {
|
||||
return getSodium().crypto_generichash_keygen().toUByteArray()
|
||||
}
|
||||
// -- Not present in LazySodium nor libsodium.js
|
||||
// actual fun blake2b(message: UByteArray, requestedHashLength: Int, key: UByteArray?) : UByteArray {
|
||||
// return getSodium().crypto_generichash_blake2b(
|
||||
// requestedHashLength,
|
||||
// message.toUInt8Array(),
|
||||
// key?.toUInt8Array() ?: Uint8Array(0)
|
||||
// ).toUByteArray()
|
||||
// }
|
||||
//
|
||||
// actual fun blake2bInit(
|
||||
// requestedHashLength: Int,
|
||||
// key: UByteArray?
|
||||
// ): Blake2bState {
|
||||
// val state = getSodium().crypto_generichash_blake2b_init(key?.toUInt8Array() ?: Uint8Array(0), requestedHashLength)
|
||||
// return Blake2bState(requestedHashLength, state)
|
||||
// }
|
||||
//
|
||||
// actual fun blake2bUpdate(
|
||||
// state: GenericHashState,
|
||||
// messagePart: UByteArray
|
||||
// ) {
|
||||
// getSodium().crypto_generichash_blake2b_update(state.internalState, messagePart.toUInt8Array())
|
||||
// }
|
||||
//
|
||||
// actual fun blake2bFinal(state: GenericHashState): UByteArray {
|
||||
// return getSodium().crypto_generichash_blake2b_final(state.internalState, state.hashLength).toUByteArray()
|
||||
// }
|
||||
//
|
||||
// actual fun blake2bKeygen(): UByteArray {
|
||||
// return getSodium().crypto_generichash_blake2b_keygen().toUByteArray()
|
||||
// }
|
||||
}
|
||||
Reference in new issue
Block a user