59 lines
2.1 KiB
Kotlin
59 lines
2.1 KiB
Kotlin
package com.infendro.hash.blake
|
|
|
|
import kotlin.test.Test
|
|
import kotlin.test.assertContentEquals
|
|
import kotlin.test.assertEquals
|
|
|
|
class `Blake-384_Test` {
|
|
val function = `Blake-384`()
|
|
|
|
@Test
|
|
fun `bytes and block`() {
|
|
assertEquals(48, function.bytes)
|
|
assertEquals(384, function.bits)
|
|
assertEquals(128, function.block)
|
|
}
|
|
|
|
@Test
|
|
fun `empty bytearray`() {
|
|
val expected = byteArrayOf(
|
|
-0x3a, -0x35, -0x28, -0x64, -0x6e, +0x6a, -0x4b, +0x25,
|
|
-0x3e, +0x42, -0x1a, +0x62, +0x1f, +0x2f, +0x5f, -0x59,
|
|
+0x3a, -0x5c, -0x51, -0x1d, -0x27, -0x1e, +0x4a, -0x13,
|
|
+0x72, +0x7f, -0x56, -0x53, -0x2a, -0x51, +0x38, -0x4a,
|
|
+0x20, -0x43, -0x4a, +0x23, -0x23, +0x2b, +0x47, -0x78,
|
|
-0x4f, -0x38, +0x08, +0x69, -0x7c, -0x51, -0x79, +0x06,
|
|
)
|
|
val actual = function.hash(ByteArray(0))
|
|
assertContentEquals(expected, actual)
|
|
}
|
|
|
|
@Test
|
|
fun `one block`() {
|
|
val expected = byteArrayOf(
|
|
+0x10, +0x28, +0x1f, +0x67, -0x1f, +0x35, -0x17, +0x0a,
|
|
-0x18, -0x18, -0x7e, +0x25, +0x1a, +0x35, +0x55, +0x10,
|
|
-0x59, +0x19, +0x36, +0x7a, -0x29, +0x02, +0x27, -0x4f,
|
|
+0x37, +0x34, +0x3e, +0x1b, -0x3f, +0x22, +0x01, +0x5c,
|
|
+0x29, +0x39, +0x1e, -0x7b, +0x45, -0x4b, +0x27, +0x2d,
|
|
+0x13, -0x59, -0x3e, -0x79, -0x63, -0x5d, -0x28, +0x07,
|
|
)
|
|
val actual = function.hash(ByteArray(1))
|
|
assertContentEquals(expected, actual)
|
|
}
|
|
|
|
@Test
|
|
fun `two blocks`() {
|
|
val expected = byteArrayOf(
|
|
+0x0b, -0x68, +0x45, -0x23, +0x42, -0x6b, +0x66, -0x33,
|
|
-0x55, +0x77, +0x2b, -0x5f, -0x6b, -0x2e, +0x71, -0x11,
|
|
-0x02, +0x2d, +0x02, +0x11, -0x0f, +0x69, -0x6f, -0x29,
|
|
+0x66, -0x46, +0x74, -0x6c, +0x47, -0x3b, -0x33, -0x1b,
|
|
+0x69, +0x78, +0x0b, +0x2d, -0x56, +0x66, -0x3c, -0x4e,
|
|
+0x24, -0x5e, -0x14, +0x2e, +0x5d, +0x09, +0x17, +0x4c,
|
|
)
|
|
val actual = function.hash(ByteArray(144))
|
|
assertContentEquals(expected, actual)
|
|
}
|
|
}
|