This commit is contained in:
@@ -2,7 +2,7 @@ package com.infendro.hash.sha2
|
||||
|
||||
import com.infendro.bytes.bytearray.copyInto
|
||||
import com.infendro.bytes.intarray.copyInto
|
||||
import com.infendro.bytes.ulong.copyInto
|
||||
import com.infendro.bytes.long.copyInto
|
||||
import com.infendro.hash.HashFunction
|
||||
import com.infendro.hash.util.align
|
||||
|
||||
@@ -43,12 +43,12 @@ object `SHA-256` : HashFunction {
|
||||
}
|
||||
|
||||
internal fun pad(value: ByteArray): ByteArray {
|
||||
val length = value.size.toULong() * 8UL
|
||||
val length = value.size * 8L
|
||||
|
||||
val size = (value.size + 9).align(block)
|
||||
return ByteArray(size).also {
|
||||
value.copyInto(it)
|
||||
it[value.size] = 0x80U.toByte()
|
||||
it[value.size] = -0x80
|
||||
length.copyInto(it, size - 8)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user