summaryrefslogtreecommitdiffstats
path: root/crypto/rmd320.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-12-28 11:43:22 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2008-12-28 11:43:22 -0800
commite14e61e967f2b3bdf23f05e4ae5b9aa830151a44 (patch)
tree9412c94cbe37bf6f0d0bd9ad2d8b907ce23eb1db /crypto/rmd320.c
parentcb10ea549fdc0ab2dd8988adab5bf40b4fa642f3 (diff)
parent0ee4a96902dd7858e65f378c86f428a0355bd841 (diff)
downloadlinux-e14e61e967f2b3bdf23f05e4ae5b9aa830151a44.tar.bz2
Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (57 commits) crypto: aes - Precompute tables crypto: talitos - Ack done interrupt in isr instead of tasklet crypto: testmgr - Correct comment about deflate parameters crypto: salsa20 - Remove private wrappers around various operations crypto: des3_ede - permit weak keys unless REQ_WEAK_KEY set crypto: sha512 - Switch to shash crypto: sha512 - Move message schedule W[80] to static percpu area crypto: michael_mic - Switch to shash crypto: wp512 - Switch to shash crypto: tgr192 - Switch to shash crypto: sha256 - Switch to shash crypto: md5 - Switch to shash crypto: md4 - Switch to shash crypto: sha1 - Switch to shash crypto: rmd320 - Switch to shash crypto: rmd256 - Switch to shash crypto: rmd160 - Switch to shash crypto: rmd128 - Switch to shash crypto: null - Switch to shash crypto: hash - Make setkey optional ...
Diffstat (limited to 'crypto/rmd320.c')
-rw-r--r--crypto/rmd320.c61
1 files changed, 32 insertions, 29 deletions
diff --git a/crypto/rmd320.c b/crypto/rmd320.c
index b143d66e42c8..86becaba2f05 100644
--- a/crypto/rmd320.c
+++ b/crypto/rmd320.c
@@ -13,11 +13,10 @@
* any later version.
*
*/
+#include <crypto/internal/hash.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/mm.h>
-#include <linux/crypto.h>
-#include <linux/cryptohash.h>
#include <linux/types.h>
#include <asm/byteorder.h>
@@ -280,9 +279,9 @@ static void rmd320_transform(u32 *state, const __le32 *in)
return;
}
-static void rmd320_init(struct crypto_tfm *tfm)
+static int rmd320_init(struct shash_desc *desc)
{
- struct rmd320_ctx *rctx = crypto_tfm_ctx(tfm);
+ struct rmd320_ctx *rctx = shash_desc_ctx(desc);
rctx->byte_count = 0;
@@ -298,12 +297,14 @@ static void rmd320_init(struct crypto_tfm *tfm)
rctx->state[9] = RMD_H9;
memset(rctx->buffer, 0, sizeof(rctx->buffer));
+
+ return 0;
}
-static void rmd320_update(struct crypto_tfm *tfm, const u8 *data,
- unsigned int len)
+static int rmd320_update(struct shash_desc *desc, const u8 *data,
+ unsigned int len)
{
- struct rmd320_ctx *rctx = crypto_tfm_ctx(tfm);
+ struct rmd320_ctx *rctx = shash_desc_ctx(desc);
const u32 avail = sizeof(rctx->buffer) - (rctx->byte_count & 0x3f);
rctx->byte_count += len;
@@ -312,7 +313,7 @@ static void rmd320_update(struct crypto_tfm *tfm, const u8 *data,
if (avail > len) {
memcpy((char *)rctx->buffer + (sizeof(rctx->buffer) - avail),
data, len);
- return;
+ goto out;
}
memcpy((char *)rctx->buffer + (sizeof(rctx->buffer) - avail),
@@ -330,12 +331,15 @@ static void rmd320_update(struct crypto_tfm *tfm, const u8 *data,
}
memcpy(rctx->buffer, data, len);
+
+out:
+ return 0;
}
/* Add padding and return the message digest. */
-static void rmd320_final(struct crypto_tfm *tfm, u8 *out)
+static int rmd320_final(struct shash_desc *desc, u8 *out)
{
- struct rmd320_ctx *rctx = crypto_tfm_ctx(tfm);
+ struct rmd320_ctx *rctx = shash_desc_ctx(desc);
u32 i, index, padlen;
__le64 bits;
__le32 *dst = (__le32 *)out;
@@ -346,10 +350,10 @@ static void rmd320_final(struct crypto_tfm *tfm, u8 *out)
/* Pad out to 56 mod 64 */
index = rctx->byte_count & 0x3f;
padlen = (index < 56) ? (56 - index) : ((64+56) - index);
- rmd320_update(tfm, padding, padlen);
+ rmd320_update(desc, padding, padlen);
/* Append length */
- rmd320_update(tfm, (const u8 *)&bits, sizeof(bits));
+ rmd320_update(desc, (const u8 *)&bits, sizeof(bits));
/* Store state in digest */
for (i = 0; i < 10; i++)
@@ -357,31 +361,32 @@ static void rmd320_final(struct crypto_tfm *tfm, u8 *out)
/* Wipe context */
memset(rctx, 0, sizeof(*rctx));
+
+ return 0;
}
-static struct crypto_alg alg = {
- .cra_name = "rmd320",
- .cra_driver_name = "rmd320",
- .cra_flags = CRYPTO_ALG_TYPE_DIGEST,
- .cra_blocksize = RMD320_BLOCK_SIZE,
- .cra_ctxsize = sizeof(struct rmd320_ctx),
- .cra_module = THIS_MODULE,
- .cra_list = LIST_HEAD_INIT(alg.cra_list),
- .cra_u = { .digest = {
- .dia_digestsize = RMD320_DIGEST_SIZE,
- .dia_init = rmd320_init,
- .dia_update = rmd320_update,
- .dia_final = rmd320_final } }
+static struct shash_alg alg = {
+ .digestsize = RMD320_DIGEST_SIZE,
+ .init = rmd320_init,
+ .update = rmd320_update,
+ .final = rmd320_final,
+ .descsize = sizeof(struct rmd320_ctx),
+ .base = {
+ .cra_name = "rmd320",
+ .cra_flags = CRYPTO_ALG_TYPE_SHASH,
+ .cra_blocksize = RMD320_BLOCK_SIZE,
+ .cra_module = THIS_MODULE,
+ }
};
static int __init rmd320_mod_init(void)
{
- return crypto_register_alg(&alg);
+ return crypto_register_shash(&alg);
}
static void __exit rmd320_mod_fini(void)
{
- crypto_unregister_alg(&alg);
+ crypto_unregister_shash(&alg);
}
module_init(rmd320_mod_init);
@@ -389,5 +394,3 @@ module_exit(rmd320_mod_fini);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("RIPEMD-320 Message Digest");
-
-MODULE_ALIAS("rmd320");