core/crypto/md5: odinfmt (NFC)

This commit is contained in:
Yawning Angel
2023-11-17 16:53:29 +09:00
parent d6e0e5d3f6
commit 9d627e453a
+7 -6
View File
@@ -10,9 +10,9 @@ package md5
Implementation of the MD5 hashing algorithm, as defined in RFC 1321 <https://datatracker.ietf.org/doc/html/rfc1321> Implementation of the MD5 hashing algorithm, as defined in RFC 1321 <https://datatracker.ietf.org/doc/html/rfc1321>
*/ */
import "core:io"
import "core:mem" import "core:mem"
import "core:os" import "core:os"
import "core:io"
import "../util" import "../util"
@@ -113,7 +113,7 @@ update :: proc(ctx: ^Md5_Context, data: []byte) {
for i := 0; i < len(data); i += 1 { for i := 0; i < len(data); i += 1 {
ctx.data[ctx.datalen] = data[i] ctx.data[ctx.datalen] = data[i]
ctx.datalen += 1 ctx.datalen += 1
if(ctx.datalen == BLOCK_SIZE) { if (ctx.datalen == BLOCK_SIZE) {
transform(ctx, ctx.data[:]) transform(ctx, ctx.data[:])
ctx.bitlen += 512 ctx.bitlen += 512
ctx.datalen = 0 ctx.datalen = 0
@@ -121,8 +121,8 @@ update :: proc(ctx: ^Md5_Context, data: []byte) {
} }
} }
final :: proc(ctx: ^Md5_Context, hash: []byte){ final :: proc(ctx: ^Md5_Context, hash: []byte) {
i : u32 i: u32
i = ctx.datalen i = ctx.datalen
if ctx.datalen < 56 { if ctx.datalen < 56 {
@@ -200,8 +200,9 @@ transform :: proc(ctx: ^Md5_Context, data: []byte) {
i, j: u32 i, j: u32
m: [DIGEST_SIZE]u32 m: [DIGEST_SIZE]u32
for i, j = 0, 0; i < DIGEST_SIZE; i+=1 { for i, j = 0, 0; i < DIGEST_SIZE; i += 1 {
m[i] = u32(data[j]) + u32(data[j + 1]) << 8 + u32(data[j + 2]) << 16 + u32(data[j + 3]) << 24 m[i] =
u32(data[j]) + u32(data[j + 1]) << 8 + u32(data[j + 2]) << 16 + u32(data[j + 3]) << 24
j += 4 j += 4
} }