summaryrefslogtreecommitdiffstats
path: root/crypto/sha1.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2006-05-16 22:09:29 +1000
committerHerbert Xu <herbert@gondor.apana.org.au>2006-06-26 17:34:39 +1000
commit6c2bb98bc33ae33c7a33a133a4cd5a06395fece5 (patch)
tree96684cd2c473cd05d651ce1fa3dd72b1b4b19b09 /crypto/sha1.c
parent43600106e32809a4dead79fec67a63e9860e3d5d (diff)
downloadlinux-6c2bb98bc33ae33c7a33a133a4cd5a06395fece5.tar.gz
linux-6c2bb98bc33ae33c7a33a133a4cd5a06395fece5.tar.bz2
linux-6c2bb98bc33ae33c7a33a133a4cd5a06395fece5.zip
[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/sha1.c')
-rw-r--r--crypto/sha1.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/crypto/sha1.c b/crypto/sha1.c
index b96f57d95a82..6c77b689f87e 100644
--- a/crypto/sha1.c
+++ b/crypto/sha1.c
@@ -34,9 +34,9 @@ struct sha1_ctx {
u8 buffer[64];
};
-static void sha1_init(void *ctx)
+static void sha1_init(struct crypto_tfm *tfm)
{
- struct sha1_ctx *sctx = ctx;
+ struct sha1_ctx *sctx = crypto_tfm_ctx(tfm);
static const struct sha1_ctx initstate = {
0,
{ 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0 },
@@ -46,9 +46,10 @@ static void sha1_init(void *ctx)
*sctx = initstate;
}
-static void sha1_update(void *ctx, const u8 *data, unsigned int len)
+static void sha1_update(struct crypto_tfm *tfm, const u8 *data,
+ unsigned int len)
{
- struct sha1_ctx *sctx = ctx;
+ struct sha1_ctx *sctx = crypto_tfm_ctx(tfm);
unsigned int partial, done;
const u8 *src;
@@ -80,9 +81,9 @@ static void sha1_update(void *ctx, const u8 *data, unsigned int len)
/* Add padding and return the message digest. */
-static void sha1_final(void* ctx, u8 *out)
+static void sha1_final(struct crypto_tfm *tfm, u8 *out)
{
- struct sha1_ctx *sctx = ctx;
+ struct sha1_ctx *sctx = crypto_tfm_ctx(tfm);
__be32 *dst = (__be32 *)out;
u32 i, index, padlen;
__be64 bits;
@@ -93,10 +94,10 @@ static void sha1_final(void* ctx, u8 *out)
/* Pad out to 56 mod 64 */
index = sctx->count & 0x3f;
padlen = (index < 56) ? (56 - index) : ((64+56) - index);
- sha1_update(sctx, padding, padlen);
+ sha1_update(tfm, padding, padlen);
/* Append length */
- sha1_update(sctx, (const u8 *)&bits, sizeof(bits));
+ sha1_update(tfm, (const u8 *)&bits, sizeof(bits));
/* Store state in digest */
for (i = 0; i < 5; i++)