Skip to content

Commit d34c6ca

Browse files
authored
fix(core): SHA1Stream length carry overflow (#54)
1 parent e11c42a commit d34c6ca

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

  • acidify-core/src/commonMain/kotlin/org/ntqqrev/acidify/internal/crypto/hash

acidify-core/src/commonMain/kotlin/org/ntqqrev/acidify/internal/crypto/hash/SHA1Stream.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ internal class SHA1Stream {
8585

8686
fun update(data: ByteArray, len: Int = data.size) {
8787
var index = (count[0] ushr 3) and 0x3F
88+
val old0 = count[0]
8889
count[0] += len shl 3
89-
if (count[0] < (len shl 3)) count[1]++
90+
if (count[0].toUInt() < old0.toUInt()) count[1]++
9091
count[1] += len ushr 29
9192

9293
val partLen = Sha1BlockSize - index

0 commit comments

Comments
 (0)