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() {
|
fun testNothing() {
|
||||||
JvmSample.nothing()
|
JvmSample.nothing()
|
||||||
assertTrue { true }
|
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.compressionFunctionG
|
||||||
import com.ionspin.kotlin.crypto.keyderivation.argon2.Argon2Utils.validateArgonParameters
|
import com.ionspin.kotlin.crypto.keyderivation.argon2.Argon2Utils.validateArgonParameters
|
||||||
import com.ionspin.kotlin.crypto.util.fromLittleEndianArrayToUInt
|
import com.ionspin.kotlin.crypto.util.fromLittleEndianArrayToUInt
|
||||||
import com.ionspin.kotlin.crypto.util.toLittleEndianTypedUByteArray
|
|
||||||
import com.ionspin.kotlin.crypto.util.toLittleEndianUByteArray
|
import com.ionspin.kotlin.crypto.util.toLittleEndianUByteArray
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -300,16 +299,18 @@ class Argon2(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun derive(): UByteArray {
|
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(
|
val h0 = Blake2b.digest(
|
||||||
parallelism.toUInt()
|
blakeInput.toTypedArray()
|
||||||
.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
|
|
||||||
).toUByteArray()
|
).toUByteArray()
|
||||||
|
|
||||||
//Compute B[i][0]
|
//Compute B[i][0]
|
||||||
@ -318,7 +319,7 @@ class Argon2(
|
|||||||
argonBlake2bArbitraryLenghtHash(
|
argonBlake2bArbitraryLenghtHash(
|
||||||
(h0 + 0.toUInt().toLittleEndianUByteArray() + i.toUInt().toLittleEndianUByteArray()).toUByteArray(),
|
(h0 + 0.toUInt().toLittleEndianUByteArray() + i.toUInt().toLittleEndianUByteArray()).toUByteArray(),
|
||||||
1024U
|
1024U
|
||||||
).toUByteArray()
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Compute B[i][1]
|
//Compute B[i][1]
|
||||||
@ -327,7 +328,7 @@ class Argon2(
|
|||||||
argonBlake2bArbitraryLenghtHash(
|
argonBlake2bArbitraryLenghtHash(
|
||||||
(h0 + 1.toUInt().toLittleEndianUByteArray() + i.toUInt().toLittleEndianUByteArray()).toUByteArray(),
|
(h0 + 1.toUInt().toLittleEndianUByteArray() + i.toUInt().toLittleEndianUByteArray()).toUByteArray(),
|
||||||
1024U
|
1024U
|
||||||
).toUByteArray()
|
)
|
||||||
}
|
}
|
||||||
executeArgonWithSingleThread()
|
executeArgonWithSingleThread()
|
||||||
|
|
||||||
|
@ -19,7 +19,12 @@
|
|||||||
package com.ionspin.kotlin.crypto.keyderivation.argon2
|
package com.ionspin.kotlin.crypto.keyderivation.argon2
|
||||||
|
|
||||||
import com.ionspin.kotlin.crypto.hash.blake2b.Blake2b
|
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
|
* Created by Ugljesa Jovanovic
|
||||||
@ -95,6 +100,10 @@ object Argon2Utils {
|
|||||||
val endOfRow = startOfRow + (8 * 16)
|
val endOfRow = startOfRow + (8 * 16)
|
||||||
val rowToMix = r.copyOfRange(startOfRow, endOfRow)
|
val rowToMix = r.copyOfRange(startOfRow, endOfRow)
|
||||||
mixRound(rowToMix)
|
mixRound(rowToMix)
|
||||||
|
.map { it.toLittleEndianUByteArray() }
|
||||||
|
.flatMap { it.asIterable() }
|
||||||
|
.toUByteArray()
|
||||||
|
.copyInto(q, startOfRow)
|
||||||
|
|
||||||
}
|
}
|
||||||
// Do the argon/blake2b mixing on columns
|
// Do the argon/blake2b mixing on columns
|
||||||
@ -103,7 +112,7 @@ object Argon2Utils {
|
|||||||
z,
|
z,
|
||||||
i,
|
i,
|
||||||
mixRound(extractColumnFromGBlock(q, i))
|
mixRound(extractColumnFromGBlock(q, i))
|
||||||
.map { it.toLittleEndianTypedUByteArray() }
|
.map { it.toLittleEndianUByteArray() }
|
||||||
.flatMap { it.asIterable() }
|
.flatMap { it.asIterable() }
|
||||||
.toUByteArray()
|
.toUByteArray()
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user