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

@@ -0,0 +1,25 @@
package com.ionspin.kotlin.crypto.shortinputhash
import com.ionspin.kotlin.crypto.LibsodiumInitializer.sodium
/**
* Created by Ugljesa Jovanovic
* ugljesa.jovanovic@ionspin.com
* on 21-Aug-2020
*/
actual object ShortHash {
actual fun shortHash(data: UByteArray, key: UByteArray): UByteArray {
val hashResult = UByteArray(crypto_shorthash_BYTES)
sodium.crypto_shorthash(hashResult.asByteArray(), data.asByteArray(), data.size.toLong(), key.asByteArray())
return hashResult
}
actual fun shortHashKeygen(): UByteArray {
val key = UByteArray(crypto_shorthash_KEYBYTES)
sodium.crypto_shorthash_keygen(key.asByteArray())
return key
}
}