Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions build-logic/src/main/kotlin/-KmpConfigurationExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import io.matthewnelson.kmp.configuration.extension.KmpConfigurationExtension
import io.matthewnelson.kmp.configuration.extension.container.target.KmpConfigurationContainerDsl
import org.gradle.api.Action
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

fun KmpConfigurationExtension.configureShared(
java9ModuleName: String? = null,
Expand Down Expand Up @@ -73,6 +74,15 @@ fun KmpConfigurationExtension.configureShared(

if (publish) kotlin { explicitApi() }

if (publish) kotlin {
@Suppress("DEPRECATION")
compilerOptions {
freeCompilerArgs.add("-Xsuppress-version-warnings")
apiVersion.set(KotlinVersion.KOTLIN_1_8)
languageVersion.set(KotlinVersion.KOTLIN_1_8)
}
}

action.execute(this)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public sealed class BLAKE2Digest: Digest {
// Cryptographic mixing
val s = SIGMA

for (i in 0..<ROUND_COUNT) {
for (i in 0 until ROUND_COUNT) {
G(v = v, a = 0, b = 4, c = 8, d = 12, x = m[s[i][ 0]], y = m[s[i][ 1]])
G(v = v, a = 1, b = 5, c = 9, d = 13, x = m[s[i][ 2]], y = m[s[i][ 3]])
G(v = v, a = 2, b = 6, c = 10, d = 14, x = m[s[i][ 4]], y = m[s[i][ 5]])
Expand All @@ -227,7 +227,7 @@ public sealed class BLAKE2Digest: Digest {
}

// xor the two halves
for (i in 0..<8) {
for (i in 0 until 8) {
h[i] = h[i] xor v[i] xor v[i + 8]
}
}
Expand Down Expand Up @@ -473,7 +473,7 @@ public sealed class BLAKE2Digest: Digest {
// Cryptographic mixing
val s = SIGMA

for (i in 0..<ROUND_COUNT) {
for (i in 0 until ROUND_COUNT) {
G(v = v, a = 0, b = 4, c = 8, d = 12, x = m[s[i][ 0]], y = m[s[i][ 1]])
G(v = v, a = 1, b = 5, c = 9, d = 13, x = m[s[i][ 2]], y = m[s[i][ 3]])
G(v = v, a = 2, b = 6, c = 10, d = 14, x = m[s[i][ 4]], y = m[s[i][ 5]])
Expand All @@ -486,7 +486,7 @@ public sealed class BLAKE2Digest: Digest {
}

// xor the two halves
for (i in 0..<8) {
for (i in 0 until 8) {
h[i] = h[i] xor v[i] xor v[i + 8]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,20 @@ private const val SIZE_MESSAGE_64B = LEN_MESSAGE * Long.SIZE_BYTES

@JvmInline
internal value class Bit32Message internal constructor(internal val m: IntArray) {
internal constructor(b: ByteArray, offset: Int): this(IntArray(LEN_MESSAGE)) { populate(b, offset) }
internal companion object {
internal operator fun invoke(b: ByteArray, offset: Int): Bit32Message {
return Bit32Message(IntArray(LEN_MESSAGE)).apply { populate(b, offset) }
}
}
}

@JvmInline
internal value class Bit64Message internal constructor(internal val m: LongArray) {
internal constructor(b: ByteArray, offset: Int): this(LongArray(LEN_MESSAGE)) { populate(b, offset) }
internal companion object {
internal operator fun invoke(b: ByteArray, offset: Int): Bit64Message {
return Bit64Message(LongArray(LEN_MESSAGE)).apply { populate(b, offset) }
}
}
}

internal inline operator fun Bit32Message.get(sigmaByte: Byte): Int = m[sigmaByte.toInt()]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class MD5: Digest {
var c = state[2]
var d = state[3]

for (i in 0..<16) {
for (i in 0 until 16) {
val xi = input.leIntAt(offset = (i * Int.SIZE_BYTES) + offset)
x[i] = xi
// val g = i + 0
Expand All @@ -72,7 +72,7 @@ public class MD5: Digest {
b += f.rotateLeft(s[i])
}

for (i in 16..<32) {
for (i in 16 until 32) {
val g = ((5 * i) + 1) % 16
val f = ((d and b) or (d.inv() and c)) + a + k[i] + x[g]
a = d
Expand All @@ -81,7 +81,7 @@ public class MD5: Digest {
b += f.rotateLeft(s[i])
}

for (i in 32..<48) {
for (i in 32 until 48) {
val g = ((3 * i) + 5) % 16
val f = (b xor c xor d) + a + k[i] + x[g]
a = d
Expand All @@ -90,7 +90,7 @@ public class MD5: Digest {
b += f.rotateLeft(s[i])
}

for (i in 48..<64) {
for (i in 48 until 64) {
val g = (7 * i) % 16
val f = (c xor (b or d.inv())) + a + k[i] + x[g]
a = d
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class SHA1: Digest {

input.bePackIntoUnsafe(x, destOffset = 0, sourceIndexStart = offset, sourceIndexEnd = offset + BLOCK_SIZE)

for (i in 16..<80) {
for (i in 16 until 80) {
x[i] = (x[i - 3] xor x[i - 8] xor x[i - 14] xor x[i - 16]).rotateLeft(1)
}

Expand All @@ -64,7 +64,7 @@ public class SHA1: Digest {
var d = state[3]
var e = state[4]

for (i in 0..<20) {
for (i in 0 until 20) {
val f = d xor (b and (c xor d))
val k = 1518500249
val a2 = (a.rotateLeft(5)) + f + e + k + x[i]
Expand All @@ -75,7 +75,7 @@ public class SHA1: Digest {
a = a2
}

for (i in 20..<40) {
for (i in 20 until 40) {
val f = b xor c xor d
val k = 1859775393
val a2 = (a.rotateLeft(5)) + f + e + k + x[i]
Expand All @@ -86,7 +86,7 @@ public class SHA1: Digest {
a = a2
}

for (i in 40..<60) {
for (i in 40 until 60) {
val f = (b and c) or (b and d) or (c and d)
val k = -1894007588
val a2 = (a.rotateLeft(5)) + f + e + k + x[i]
Expand All @@ -97,7 +97,7 @@ public class SHA1: Digest {
a = a2
}

for (i in 60..<80) {
for (i in 60 until 80) {
val f = b xor c xor d
val k = -899497514
val a2 = (a.rotateLeft(5)) + f + e + k + x[i]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public sealed class Bit32Digest: Digest {

input.bePackIntoUnsafe(x, destOffset = 0, sourceIndexStart = offset, sourceIndexEnd = offset + BLOCK_SIZE)

for (i in 16..<64) {
for (i in 16 until 64) {
val x15 = x[i - 15]
val s0 =
((x15 ushr 7) or (x15 shl 25)) xor
Expand Down Expand Up @@ -88,7 +88,7 @@ public sealed class Bit32Digest: Digest {
var g = state[6]
var h = state[7]

for (i in 0..<64) {
for (i in 0 until 64) {
val s0 =
((a ushr 2) or (a shl 30)) xor
((a ushr 13) or (a shl 19)) xor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public sealed class Bit64Digest: Digest {

input.bePackIntoUnsafe(x, destOffset = 0, sourceIndexStart = offset, sourceIndexEnd = offset + BLOCK_SIZE)

for (i in 16..<80) {
for (i in 16 until 80) {
val x15 = x[i - 15]
val s0 = (x15.rotateRight(1)) xor (x15.rotateRight(8)) xor (x15 ushr 7)
val x2 = x[i - 2]
Expand All @@ -123,7 +123,7 @@ public sealed class Bit64Digest: Digest {
var g = state[6]
var h = state[7]

for (i in 0..<80) {
for (i in 0 until 80) {
val s0 = (a.rotateRight(28)) xor (a.rotateRight(34)) xor (a.rotateRight(39))
val s1 = (e.rotateRight(14)) xor (e.rotateRight(18)) xor (e.rotateRight(41))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ abstract class DigestUnitTest: HashUnitTest() {
updateSmall(digest)
var into = ByteArray(digest.digestLength() + 16)
digest.digestInto(into, destOffset = 16)
for (i in 0..<16) {
for (i in 0 until 16) {
assertEquals(0, into[i])
}
into = into.copyInto(destination = ByteArray(digest.digestLength()), startIndex = 16)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ abstract class XofUnitTest: HashUnitTest(), Resettable {
val r = Array(50) { i -> ByteArray(i) }
read(*r)
var b = r.first()
for (i in 1..<r.size) {
for (i in 1 until r.size) {
b += r[i]
}

Expand All @@ -77,10 +77,10 @@ abstract class XofUnitTest: HashUnitTest(), Resettable {
updateSmall(xof)
val r = ByteArray(200)
partialRead(r, 10, r.size - 20)
for (i in 0..<10) {
for (i in 0 until 10) {
assertEquals(0, r[i])
}
for (i in (r.size - 10)..<r.size) {
for (i in (r.size - 10) until r.size) {
assertEquals(0, r[i])
}
val actual = r.encodeToString(base16)
Expand Down
Loading