Compare commits
2 Commits
c047b04d95
...
a1cf5f4202
| Author | SHA1 | Date | |
|---|---|---|---|
|
a1cf5f4202
|
|||
|
6020269957
|
@@ -1,5 +1,5 @@
|
|||||||
group = "com.infendro"
|
group = "com.infendro"
|
||||||
version = "1.0.0"
|
version = "1.0.1"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven("https://git.infendro.com/api/packages/Infendro/maven")
|
maven("https://git.infendro.com/api/packages/Infendro/maven")
|
||||||
@@ -22,6 +22,7 @@ kotlin {
|
|||||||
commonMain.dependencies {
|
commonMain.dependencies {
|
||||||
implementation(libs.mac)
|
implementation(libs.mac)
|
||||||
implementation(libs.hash)
|
implementation(libs.hash)
|
||||||
|
implementation(libs.bytearray)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
[versions]
|
[versions]
|
||||||
kotlin = "2.1.20"
|
kotlin = "2.1.20"
|
||||||
mac = "1.1.0"
|
mac = "1.1.2"
|
||||||
hash = "1.2.0"
|
hash = "1.2.2"
|
||||||
|
bytearray = "1.1.1"
|
||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
|
multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
|
||||||
@@ -9,3 +10,4 @@ multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotl
|
|||||||
[libraries]
|
[libraries]
|
||||||
mac = { module = "com.infendro:mac", version.ref = "mac" }
|
mac = { module = "com.infendro:mac", version.ref = "mac" }
|
||||||
hash = { module = "com.infendro:hash", version.ref = "hash" }
|
hash = { module = "com.infendro:hash", version.ref = "hash" }
|
||||||
|
bytearray = { module = "com.infendro:bytearray", version.ref = "bytearray" }
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package com.infendro.kdf
|
package com.infendro.kdf
|
||||||
|
|
||||||
|
import com.infendro.bytearray.addAll
|
||||||
|
import com.infendro.bytearray.toByteArray
|
||||||
|
import com.infendro.bytearray.xor
|
||||||
import com.infendro.hash.HashFunction
|
import com.infendro.hash.HashFunction
|
||||||
import com.infendro.kdf.util.addAll
|
|
||||||
import com.infendro.kdf.util.toByteArray
|
|
||||||
import com.infendro.kdf.util.xor
|
|
||||||
import com.infendro.mac.HMAC
|
import com.infendro.mac.HMAC
|
||||||
|
|
||||||
class PBKDF2(
|
class PBKDF2(
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
package com.infendro.kdf.util
|
|
||||||
|
|
||||||
import kotlin.experimental.xor
|
|
||||||
|
|
||||||
internal infix fun ByteArray.xor(
|
|
||||||
that: ByteArray,
|
|
||||||
): ByteArray {
|
|
||||||
if (this.size != that.size) throw Exception()
|
|
||||||
|
|
||||||
return ByteArray(size) { i ->
|
|
||||||
this[i] xor that[i]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal fun MutableCollection<Byte>.addAll(
|
|
||||||
bytes: ByteArray,
|
|
||||||
): Boolean {
|
|
||||||
return addAll(bytes.toList())
|
|
||||||
}
|
|
||||||
|
|
||||||
internal fun UInt.toByteArray(): ByteArray {
|
|
||||||
return ByteArray(4) { i ->
|
|
||||||
val offset = (3 - i) * 8
|
|
||||||
(this shr offset).toByte()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user