21 #include <linux/module.h>
22 #include <linux/string.h>
23 #include <linux/types.h>
25 #include <asm/byteorder.h>
28 static inline void le32_to_cpu_array(
u32 *
buf,
unsigned int words)
36 static inline void cpu_to_le32_array(
u32 *buf,
unsigned int words)
44 static inline void md5_transform_helper(
struct md5_state *
ctx)
46 le32_to_cpu_array(ctx->
block,
sizeof(ctx->
block) /
sizeof(
u32));
52 struct md5_state *mctx = shash_desc_ctx(desc);
54 mctx->
hash[0] = 0x67452301;
55 mctx->
hash[1] = 0xefcdab89;
56 mctx->
hash[2] = 0x98badcfe;
57 mctx->
hash[3] = 0x10325476;
65 struct md5_state *mctx = shash_desc_ctx(desc);
79 md5_transform_helper(mctx);
83 while (len >=
sizeof(mctx->
block)) {
85 md5_transform_helper(mctx);
86 data +=
sizeof(mctx->
block);
87 len -=
sizeof(mctx->
block);
97 struct md5_state *mctx = shash_desc_ctx(desc);
99 char *
p = (
char *)mctx->
block + offset;
100 int padding = 56 - (offset + 1);
105 md5_transform_helper(mctx);
106 p = (
char *)mctx->
block;
113 le32_to_cpu_array(mctx->
block, (
sizeof(mctx->
block) -
114 sizeof(
u64)) /
sizeof(
u32));
116 cpu_to_le32_array(mctx->
hash,
sizeof(mctx->
hash) /
sizeof(
u32));
118 memset(mctx, 0,
sizeof(*mctx));
123 static int md5_export(
struct shash_desc *desc,
void *out)
127 memcpy(out, ctx,
sizeof(*ctx));
131 static int md5_import(
struct shash_desc *desc,
const void *
in)
133 struct md5_state *ctx = shash_desc_ctx(desc);
135 memcpy(ctx, in,
sizeof(*ctx));
142 .update = md5_update,
144 .export = md5_export,
145 .import = md5_import,
156 static int __init md5_mod_init(
void)
161 static void __exit md5_mod_fini(
void)