mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-18 19:21:26 +00:00
Merge of IET r341: New md5/sha1 code in ietd didn't handle the byte swap properly
for the digest counters on big endian systems. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@1835 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -179,13 +179,14 @@ void md5_final(struct md5_ctx *ctx, u8 *out)
|
||||
memset(p, 0, padding);
|
||||
|
||||
/* 64-bit bit counter stored in LSW/LSB format */
|
||||
ctx->block[14] = ctx->count << 3;
|
||||
ctx->block[15] = ctx->count >> 29;
|
||||
ctx->block[14] = cpu_to_le32(ctx->count << 3);
|
||||
ctx->block[15] = cpu_to_le32(ctx->count >> 29);
|
||||
|
||||
md5_transform(ctx->digest, ctx->block);
|
||||
|
||||
for (i = 0; i < MD5_DIGEST_WORDS; i++)
|
||||
ctx->digest[i] = le32_to_cpu(ctx->digest[i]);
|
||||
|
||||
memcpy(out, ctx->digest, MD5_DIGEST_BYTES);
|
||||
memset(ctx, 0, sizeof(*ctx));
|
||||
}
|
||||
|
||||
@@ -144,14 +144,15 @@ void sha1_final(struct sha1_ctx *ctx, u8 *out)
|
||||
|
||||
memset(p, 0, padding);
|
||||
|
||||
/* 64-bit bit counter stored in MSW/LSB format (RFC bug?) */
|
||||
ctx->block[14] = bswap_32(ctx->count >> 29);
|
||||
ctx->block[15] = bswap_32(ctx->count << 3);
|
||||
/* 64-bit bit counter stored in MSW/MSB format */
|
||||
ctx->block[14] = cpu_to_be32(ctx->count >> 29);
|
||||
ctx->block[15] = cpu_to_be32(ctx->count << 3);
|
||||
|
||||
sha1_transform(ctx->digest, ctx->block);
|
||||
|
||||
for (i = 0; i < SHA1_DIGEST_WORDS; i++)
|
||||
ctx->digest[i] = be32_to_cpu(ctx->digest[i]);
|
||||
|
||||
memcpy(out, ctx->digest, SHA1_DIGEST_BYTES);
|
||||
memset(ctx, 0, sizeof(*ctx));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user