Short hash implementation and test, updated cbc tests as they ignored padding

This commit is contained in:
Ugljesa Jovanovic authored and Ugljesa Jovanovic committed 2020-08-28 22:35:33 +02:00
1 parent 86611453ea
commit 91cd41c8c1
12 files changed
+570 -27

No files matched your search

@@ -26,6 +26,11 @@ interface JsSodiumInterface {
fun crypto_generichash_final(state: dynamic, hashLength: Int) : Uint8Array
//Short hash
fun crypto_shorthash(data : Uint8Array, key: Uint8Array) : Uint8Array
fun crypto_shorthash_keygen() : Uint8Array
fun crypto_hash_sha256_init() : dynamic
@@ -0,0 +1,21 @@
package com.ionspin.kotlin.crypto.shortinputhash
import com.ionspin.kotlin.crypto.getSodium
import ext.libsodium.com.ionspin.kotlin.crypto.toUByteArray
import ext.libsodium.com.ionspin.kotlin.crypto.toUInt8Array
/**
* Created by Ugljesa Jovanovic
* ugljesa.jovanovic@ionspin.com
* on 21-Aug-2020
*/
actual object ShortHash {
actual fun shortHash(data: UByteArray, key: UByteArray): UByteArray {
return getSodium().crypto_shorthash(data.toUInt8Array(), key.toUInt8Array()).toUByteArray()
}
actual fun shortHashKeygen(): UByteArray {
return getSodium().crypto_shorthash_keygen().toUByteArray()
}
}