]> git.codecow.com Git - nano25519.git/commitdiff
Fix blake message byte counter in digest.
authorChris Duncan <chris@zoso.dev>
Sun, 6 Sep 2026 09:17:29 +0000 (02:17 -0700)
committerChris Duncan <chris@zoso.dev>
Sun, 6 Sep 2026 09:17:29 +0000 (02:17 -0700)
src/assembly/blake2b.ts

index ebece11c2f84f1ca85f9a782187a58420c389726..eb380cde45c0388b68bed2c9f960587fd7c8fbef 100644 (file)
@@ -115,7 +115,7 @@ export class Blake2b {
        digest (output: StaticArray<u8>): void {
 
                // add final message block size to total bytes
-               this.t = v128.add<u64>(this.t, i64x2(this.c, 0))
+               this.t = v128.add<u64>(this.t, i64x2(this.c, u64(v128.extract_lane<u64>(this.t, 0) + u64(this.c) < u64(this.c))))
 
                // pad final block with zeros
                this.b.fill(0, this.c)