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,15 @@
package com.ionspin.kotlin.crypto.shortinputhash
/**
* Created by Ugljesa Jovanovic
* ugljesa.jovanovic@ionspin.com
* on 21-Aug-2020
*/
const val crypto_shorthash_KEYBYTES = 16
const val crypto_shorthash_BYTES = 8
expect object ShortHash {
fun shortHash(data : UByteArray, key: UByteArray) : UByteArray
fun shortHashKeygen() : UByteArray
}
@@ -1,10 +0,0 @@
package com.ionspin.kotlin.crypto.shortinputhash
/**
* Created by Ugljesa Jovanovic
* ugljesa.jovanovic@ionspin.com
* on 21-Aug-2020
*/
object ShortInputHashing {
}
@@ -0,0 +1,24 @@
package com.ionspin.kotlin.crypto.util
/**
* Created by Ugljesa Jovanovic
* ugljesa.jovanovic@ionspin.com
* on 28-Aug-2020
*/
fun String.hexStringToUByteArray() : UByteArray {
return this.chunked(2).map { it.toUByte(16) }.toUByteArray()
}
fun String.encodeToUByteArray() : UByteArray{
return encodeToByteArray().asUByteArray()
}
fun UByteArray.toHexString() : String {
return this.joinToString(separator = "") {
if (it <= 0x0FU) {
"0${it.toString(16)}"
} else {
it.toString(16)
}
}
}