Remove unsigned support
All checks were successful
/ test (pull_request) Successful in 50s

This commit is contained in:
2026-02-15 00:11:45 +01:00
parent 41d37cb42e
commit 4f04f4ae02
6 changed files with 20 additions and 36 deletions

View File

@@ -22,11 +22,12 @@ class HMAC(
function.hashInto(outer, destination, destinationOffset)
}
private fun pad(key: ByteArray): ByteArray =
ByteArray(function.block).also {
private fun pad(key: ByteArray): ByteArray {
return ByteArray(function.block).also {
when {
key.size > function.block -> function.hashInto(key, it)
else -> key.copyInto(it)
}
}
}
}

View File

@@ -7,18 +7,9 @@ interface MAC {
fun hashInto(key: ByteArray, value: ByteArray, destination: ByteArray, destinationOffset: Int = 0)
fun hashInto(key: ByteArray, value: ByteArray, destination: UByteArray, destinationOffset: Int = 0) =
hashInto(key, value, destination.asByteArray(), destinationOffset)
fun hashInto(key: UByteArray, value: UByteArray, destination: ByteArray, destinationOffset: Int = 0) =
hashInto(key.asByteArray(), value.asByteArray(), destination, destinationOffset)
fun hashInto(key: UByteArray, value: UByteArray, destination: UByteArray, destinationOffset: Int = 0) =
hashInto(key.asByteArray(), value.asByteArray(), destination.asByteArray(), destinationOffset)
fun hash(key: ByteArray, value: ByteArray): ByteArray =
ByteArray(bytes).also { hashInto(key, value, it) }
fun hash(key: UByteArray, value: UByteArray): UByteArray =
UByteArray(bytes).also { hashInto(key, value, it) }
fun hash(key: ByteArray, value: ByteArray): ByteArray {
val result = ByteArray(bytes)
hashInto(key, value, result)
return result
}
}