summaryrefslogtreecommitdiff
path: root/crypto/crc32c.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/crc32c.c
parent43600106e32809a4dead79fec67a63e9860e3d5d (diff)
downloadrenesas_kernel-6c2bb98bc33ae33c7a33a133a4cd5a06395fece5.tar.gz
renesas_kernel-6c2bb98bc33ae33c7a33a133a4cd5a06395fece5.tar.bz2
renesas_kernel-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/crc32c.c')
-rw-r--r--crypto/crc32c.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/crypto/crc32c.c b/crypto/crc32c.c
index 953362423a5..f2660123aeb 100644
--- a/crypto/crc32c.c
+++ b/crypto/crc32c.c
@@ -31,9 +31,9 @@ struct chksum_ctx {
* crc using table.
*/
-static void chksum_init(void *ctx)
+static void chksum_init(struct crypto_tfm *tfm)
{
- struct chksum_ctx *mctx = ctx;
+ struct chksum_ctx *mctx = crypto_tfm_ctx(tfm);
mctx->crc = ~(u32)0; /* common usage */
}
@@ -43,10 +43,10 @@ static void chksum_init(void *ctx)
* If your algorithm starts with ~0, then XOR with ~0 before you set
* the seed.
*/
-static int chksum_setkey(void *ctx, const u8 *key, unsigned int keylen,
- u32 *flags)
+static int chksum_setkey(struct crypto_tfm *tfm, const u8 *key,
+ unsigned int keylen, u32 *flags)
{
- struct chksum_ctx *mctx = ctx;
+ struct chksum_ctx *mctx = crypto_tfm_ctx(tfm);
if (keylen != sizeof(mctx->crc)) {
if (flags)
@@ -57,9 +57,10 @@ static int chksum_setkey(void *ctx, const u8 *key, unsigned int keylen,
return 0;
}
-static void chksum_update(void *ctx, const u8 *data, unsigned int length)
+static void chksum_update(struct crypto_tfm *tfm, const u8 *data,
+ unsigned int length)
{
- struct chksum_ctx *mctx = ctx;
+ struct chksum_ctx *mctx = crypto_tfm_ctx(tfm);
u32 mcrc;
mcrc = crc32c(mctx->crc, data, (size_t)length);
@@ -67,9 +68,9 @@ static void chksum_update(void *ctx, const u8 *data, unsigned int length)
mctx->crc = mcrc;
}
-static void chksum_final(void *ctx, u8 *out)
+static void chksum_final(struct crypto_tfm *tfm, u8 *out)
{
- struct chksum_ctx *mctx = ctx;
+ struct chksum_ctx *mctx = crypto_tfm_ctx(tfm);
u32 mcrc = (mctx->crc ^ ~(u32)0);
*(u32 *)out = __le32_to_cpu(mcrc);