aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/md5.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2006-05-16 08:09:29 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2006-06-26 03:34:39 -0400
commit6c2bb98bc33ae33c7a33a133a4cd5a06395fece5 (patch)
tree96684cd2c473cd05d651ce1fa3dd72b1b4b19b09 /crypto/md5.c
parent43600106e32809a4dead79fec67a63e9860e3d5d (diff)
[CRYPTO] all: Pass tfm instead of ctx to algorithms
Up until now algorithms have been happy to get a context pointer since they know everything that's in the tfm already (e.g., alignment, block size). However, once we have parameterised algorithms, such information will be specific to each tfm. So the algorithm API needs to be changed to pass the tfm structure instead of the context pointer. This patch is basically a text substitution. The only tricky bit is the assembly routines that need to get the context pointer offset through asm-offsets.h. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/md5.c')
-rw-r--r--crypto/md5.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/crypto/md5.c b/crypto/md5.c
index 7f041aef5da2..93d18e8b3d53 100644
--- a/crypto/md5.c
+++ b/crypto/md5.c
@@ -147,9 +147,9 @@ static inline void md5_transform_helper(struct md5_ctx *ctx)
147 md5_transform(ctx->hash, ctx->block); 147 md5_transform(ctx->hash, ctx->block);
148} 148}
149 149
150static void md5_init(void *ctx) 150static void md5_init(struct crypto_tfm *tfm)
151{ 151{
152 struct md5_ctx *mctx = ctx; 152 struct md5_ctx *mctx = crypto_tfm_ctx(tfm);
153 153
154 mctx->hash[0] = 0x67452301; 154 mctx->hash[0] = 0x67452301;
155 mctx->hash[1] = 0xefcdab89; 155 mctx->hash[1] = 0xefcdab89;
@@ -158,9 +158,9 @@ static void md5_init(void *ctx)
158 mctx->byte_count = 0; 158 mctx->byte_count = 0;
159} 159}
160 160
161static void md5_update(void *ctx, const u8 *data, unsigned int len) 161static void md5_update(struct crypto_tfm *tfm, const u8 *data, unsigned int len)
162{ 162{
163 struct md5_ctx *mctx = ctx; 163 struct md5_ctx *mctx = crypto_tfm_ctx(tfm);
164 const u32 avail = sizeof(mctx->block) - (mctx->byte_count & 0x3f); 164 const u32 avail = sizeof(mctx->block) - (mctx->byte_count & 0x3f);
165 165
166 mctx->byte_count += len; 166 mctx->byte_count += len;
@@ -188,9 +188,9 @@ static void md5_update(void *ctx, const u8 *data, unsigned int len)
188 memcpy(mctx->block, data, len); 188 memcpy(mctx->block, data, len);
189} 189}
190 190
191static void md5_final(void *ctx, u8 *out) 191static void md5_final(struct crypto_tfm *tfm, u8 *out)
192{ 192{
193 struct md5_ctx *mctx = ctx; 193 struct md5_ctx *mctx = crypto_tfm_ctx(tfm);
194 const unsigned int offset = mctx->byte_count & 0x3f; 194 const unsigned int offset = mctx->byte_count & 0x3f;
195 char *p = (char *)mctx->block + offset; 195 char *p = (char *)mctx->block + offset;
196 int padding = 56 - (offset + 1); 196 int padding = 56 - (offset + 1);