Tests are back up
This commit is contained in:
parent
bc1c50f268
commit
4ea04eb90d
Binary file not shown.
@ -34,6 +34,9 @@ class JvmTest {
|
||||
fun testNothing() {
|
||||
JvmSample.nothing()
|
||||
assertTrue { true }
|
||||
val arr = ubyteArrayOf(0U)
|
||||
val bla = ubyteArrayOf(1U)
|
||||
arr.copyInto(bla)
|
||||
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,6 @@ import com.ionspin.kotlin.crypto.keyderivation.argon2.Argon2Utils.argonBlake2bAr
|
||||
import com.ionspin.kotlin.crypto.keyderivation.argon2.Argon2Utils.compressionFunctionG
|
||||
import com.ionspin.kotlin.crypto.keyderivation.argon2.Argon2Utils.validateArgonParameters
|
||||
import com.ionspin.kotlin.crypto.util.fromLittleEndianArrayToUInt
|
||||
import com.ionspin.kotlin.crypto.util.toLittleEndianTypedUByteArray
|
||||
import com.ionspin.kotlin.crypto.util.toLittleEndianUByteArray
|
||||
|
||||
/**
|
||||
@ -300,16 +299,18 @@ class Argon2(
|
||||
}
|
||||
|
||||
override fun derive(): UByteArray {
|
||||
val blakeInput = parallelism.toUInt().toLittleEndianUByteArray() +
|
||||
tagLength.toLittleEndianUByteArray() +
|
||||
memorySize.toLittleEndianUByteArray() +
|
||||
numberOfIterations.toUInt().toLittleEndianUByteArray() +
|
||||
versionNumber.toLittleEndianUByteArray() +
|
||||
argonType.typeId.toUInt().toLittleEndianUByteArray() +
|
||||
password.size.toUInt().toLittleEndianUByteArray() + password +
|
||||
salt.size.toUInt().toLittleEndianUByteArray() + salt +
|
||||
key.size.toUInt().toLittleEndianUByteArray() + key +
|
||||
associatedData.size.toUInt().toLittleEndianUByteArray() + associatedData
|
||||
val h0 = Blake2b.digest(
|
||||
parallelism.toUInt()
|
||||
.toLittleEndianTypedUByteArray() + tagLength.toLittleEndianTypedUByteArray() + memorySize.toLittleEndianTypedUByteArray() +
|
||||
numberOfIterations.toUInt()
|
||||
.toLittleEndianTypedUByteArray() + versionNumber.toLittleEndianTypedUByteArray() + argonType.typeId.toUInt()
|
||||
.toLittleEndianTypedUByteArray() +
|
||||
password.size.toUInt().toLittleEndianTypedUByteArray() + password +
|
||||
salt.size.toUInt().toLittleEndianTypedUByteArray() + salt +
|
||||
key.size.toUInt().toLittleEndianTypedUByteArray() + key +
|
||||
associatedData.size.toUInt().toLittleEndianTypedUByteArray() + associatedData
|
||||
blakeInput.toTypedArray()
|
||||
).toUByteArray()
|
||||
|
||||
//Compute B[i][0]
|
||||
@ -318,7 +319,7 @@ class Argon2(
|
||||
argonBlake2bArbitraryLenghtHash(
|
||||
(h0 + 0.toUInt().toLittleEndianUByteArray() + i.toUInt().toLittleEndianUByteArray()).toUByteArray(),
|
||||
1024U
|
||||
).toUByteArray()
|
||||
)
|
||||
}
|
||||
|
||||
//Compute B[i][1]
|
||||
@ -327,7 +328,7 @@ class Argon2(
|
||||
argonBlake2bArbitraryLenghtHash(
|
||||
(h0 + 1.toUInt().toLittleEndianUByteArray() + i.toUInt().toLittleEndianUByteArray()).toUByteArray(),
|
||||
1024U
|
||||
).toUByteArray()
|
||||
)
|
||||
}
|
||||
executeArgonWithSingleThread()
|
||||
|
||||
|
@ -19,7 +19,12 @@
|
||||
package com.ionspin.kotlin.crypto.keyderivation.argon2
|
||||
|
||||
import com.ionspin.kotlin.crypto.hash.blake2b.Blake2b
|
||||
import com.ionspin.kotlin.crypto.util.*
|
||||
import com.ionspin.kotlin.crypto.util.arrayChunked
|
||||
import com.ionspin.kotlin.crypto.util.fromLittleEndianArrayToULong
|
||||
import com.ionspin.kotlin.crypto.util.plus
|
||||
import com.ionspin.kotlin.crypto.util.rotateRight
|
||||
import com.ionspin.kotlin.crypto.util.toLittleEndianUByteArray
|
||||
import com.ionspin.kotlin.crypto.util.xor
|
||||
|
||||
/**
|
||||
* Created by Ugljesa Jovanovic
|
||||
@ -95,6 +100,10 @@ object Argon2Utils {
|
||||
val endOfRow = startOfRow + (8 * 16)
|
||||
val rowToMix = r.copyOfRange(startOfRow, endOfRow)
|
||||
mixRound(rowToMix)
|
||||
.map { it.toLittleEndianUByteArray() }
|
||||
.flatMap { it.asIterable() }
|
||||
.toUByteArray()
|
||||
.copyInto(q, startOfRow)
|
||||
|
||||
}
|
||||
// Do the argon/blake2b mixing on columns
|
||||
@ -103,7 +112,7 @@ object Argon2Utils {
|
||||
z,
|
||||
i,
|
||||
mixRound(extractColumnFromGBlock(q, i))
|
||||
.map { it.toLittleEndianTypedUByteArray() }
|
||||
.map { it.toLittleEndianUByteArray() }
|
||||
.flatMap { it.asIterable() }
|
||||
.toUByteArray()
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user