Skip to content

Commit 85e07f5

Browse files
authored
Update kotlincrypto.core to latest SNAPSHOT (#93)
1 parent 18856e8 commit 85e07f5

File tree

6 files changed

+23
-15
lines changed

6 files changed

+23
-15
lines changed

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ POM_DEVELOPER_ID=KotlinCrypto
3030
POM_DEVELOPER_NAME=Kotlin Crypto
3131
POM_DEVELOPER_URL=https://github.com/KotlinCrypto/
3232

33-
VERSION_NAME=1.0.0-alpha01-SNAPSHOT
33+
VERSION_NAME=0.6.0-SNAPSHOT
3434
# 0.1.0-alpha01 = 00 01 00 11
3535
# 0.1.0-beta01 = 00 01 00 21
3636
# 0.1.0-rc01 = 00 01 00 31
3737
# 0.1.0 = 00 01 00 99
3838
# 1.1.0 = 01 01 00 99
39-
VERSION_CODE=01000011
39+
VERSION_CODE=00060011

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ gradle-kotlin = "1.9.24"
1313
gradle-publish-maven = "0.29.0"
1414

1515
kotlincrypto-bitops = "0.1.0-SNAPSHOT"
16-
kotlincrypto-core = "1.0.0-alpha01-SNAPSHOT"
16+
kotlincrypto-core = "0.6.0-SNAPSHOT"
1717
kotlincrypto-sponges = "0.3.4"
1818

1919
[libraries]

library/md/src/commonMain/kotlin/org/kotlincrypto/hash/md/MD5.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ public class MD5: Digest {
3131

3232
public constructor(): super(
3333
algorithm = "MD5",
34-
blockSize = 64,
34+
blockSize = BLOCK_SIZE_64,
3535
digestLength = 16,
3636
) {
3737
this.x = IntArray(16)
3838
this.state = H.copyOf()
39-
this.count = Counter.Bit32(incrementBy = blockSize())
39+
this.count = Counter.Bit32(incrementBy = BLOCK_SIZE_64)
4040
}
4141

4242
private constructor(other: MD5): super(other) {
@@ -131,6 +131,8 @@ public class MD5: Digest {
131131
}
132132

133133
private companion object {
134+
private const val BLOCK_SIZE_64 = 64
135+
134136
private val H = intArrayOf(1732584193, -271733879, -1732584194, 271733878)
135137

136138
private val S = intArrayOf(

library/sha1/src/commonMain/kotlin/org/kotlincrypto/hash/sha1/SHA1.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ public class SHA1: Digest {
3030

3131
public constructor(): super(
3232
algorithm = "SHA-1",
33-
blockSize = 64,
33+
blockSize = BLOCK_SIZE_64,
3434
digestLength = 20,
3535
) {
3636
this.x = IntArray(80)
3737
this.state = H.copyOf()
38-
this.count = Counter.Bit32(incrementBy = blockSize())
38+
this.count = Counter.Bit32(incrementBy = BLOCK_SIZE_64)
3939
}
4040

4141
private constructor(other: SHA1): super(other) {
@@ -49,7 +49,7 @@ public class SHA1: Digest {
4949
protected override fun compressProtected(input: ByteArray, offset: Int) {
5050
val x = x
5151

52-
input.bePackIntoUnsafe(x, destOffset = 0, sourceIndexStart = offset, sourceIndexEnd = offset + blockSize())
52+
input.bePackIntoUnsafe(x, destOffset = 0, sourceIndexStart = offset, sourceIndexEnd = offset + BLOCK_SIZE_64)
5353

5454
for (i in 16..<80) {
5555
x[i] = (x[i - 3] xor x[i - 8] xor x[i - 14] xor x[i - 16]).rotateLeft(1)
@@ -141,6 +141,8 @@ public class SHA1: Digest {
141141
}
142142

143143
private companion object {
144+
private const val BLOCK_SIZE_64 = 64
145+
144146
private val H = intArrayOf(1732584193, -271733879, -1732584194, 271733878, -1009589776)
145147
}
146148
}

library/sha2/src/commonMain/kotlin/org/kotlincrypto/hash/sha2/Bit32Digest.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ public sealed class Bit32Digest: Digest {
3434
@Throws(IllegalArgumentException::class)
3535
protected constructor(d: Int, h: IntArray): super(
3636
algorithm = "SHA-$d",
37-
blockSize = 64,
37+
blockSize = BLOCK_SIZE_64,
3838
digestLength = d / 8,
3939
) {
4040
this.h = h
41-
this.x = IntArray(64)
41+
this.x = IntArray(BLOCK_SIZE_64)
4242
this.state = h.copyOf()
43-
this.count = Counter.Bit32(incrementBy = blockSize())
43+
this.count = Counter.Bit32(incrementBy = BLOCK_SIZE_64)
4444
}
4545

4646
protected constructor(other: Bit32Digest): super(other) {
@@ -55,7 +55,7 @@ public sealed class Bit32Digest: Digest {
5555
protected final override fun compressProtected(input: ByteArray, offset: Int) {
5656
val x = x
5757

58-
input.bePackIntoUnsafe(x, destOffset = 0, sourceIndexStart = offset, sourceIndexEnd = offset + blockSize())
58+
input.bePackIntoUnsafe(x, destOffset = 0, sourceIndexStart = offset, sourceIndexEnd = offset + BLOCK_SIZE_64)
5959

6060
for (i in 16..<64) {
6161
val x15 = x[i - 15]
@@ -151,6 +151,8 @@ public sealed class Bit32Digest: Digest {
151151
}
152152

153153
private companion object {
154+
private const val BLOCK_SIZE_64 = 64
155+
154156
private val K = intArrayOf(
155157
1116352408, 1899447441, -1245643825, -373957723,
156158
961987163, 1508970993, -1841331548, -1424204075,

library/sha2/src/commonMain/kotlin/org/kotlincrypto/hash/sha2/Bit64Digest.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public sealed class Bit64Digest: Digest {
4141
h: LongArray,
4242
): super(
4343
algorithm = "SHA-$d" + (t?.let { "/$it" } ?: ""),
44-
blockSize = 128,
44+
blockSize = BLOCK_SIZE_128,
4545
digestLength = (t ?: d) / 8,
4646
) {
4747
this.isInitialized = if (t != null) {
@@ -58,7 +58,7 @@ public sealed class Bit64Digest: Digest {
5858
this.h = h
5959
this.x = LongArray(80)
6060
this.state = h.copyOf()
61-
this.count = Counter.Bit32(incrementBy = blockSize())
61+
this.count = Counter.Bit32(incrementBy = BLOCK_SIZE_128)
6262

6363
if (t == null) return
6464

@@ -95,7 +95,7 @@ public sealed class Bit64Digest: Digest {
9595
protected final override fun compressProtected(input: ByteArray, offset: Int) {
9696
val x = x
9797

98-
input.bePackIntoUnsafe(x, destOffset = 0, sourceIndexStart = offset, sourceIndexEnd = offset + blockSize())
98+
input.bePackIntoUnsafe(x, destOffset = 0, sourceIndexStart = offset, sourceIndexEnd = offset + BLOCK_SIZE_128)
9999

100100
for (i in 16..<80) {
101101
val x15 = x[i - 15]
@@ -201,6 +201,8 @@ public sealed class Bit64Digest: Digest {
201201
}
202202

203203
private companion object {
204+
private const val BLOCK_SIZE_128 = 128
205+
204206
private val K = longArrayOf(
205207
4794697086780616226L, 8158064640168781261L, -5349999486874862801L, -1606136188198331460L,
206208
4131703408338449720L, 6480981068601479193L, -7908458776815382629L, -6116909921290321640L,

0 commit comments

Comments
 (0)