summaryrefslogtreecommitdiffstats
path: root/crypto/md5.c
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2015-03-11 17:53:04 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2015-03-12 07:58:24 +0100
commit27b2336029335ea3f02243ff170986cdab1f98ef (patch)
tree722083808d1ce9b3bb69d3cca3520ce61a09064d /crypto/md5.c
parent804fae5d16c8c48c6fca8d54f2878a2e382a0bc2 (diff)
downloadbarebox-27b2336029335ea3f02243ff170986cdab1f98ef.tar.gz
barebox-27b2336029335ea3f02243ff170986cdab1f98ef.tar.xz
digest: make it multi-instance
Now you need to call digest_alloc and when you finish to use it digest_free. We need this for upcomming aes encryption support and secure boot as we will need multiple instance of the same digest. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'crypto/md5.c')
-rw-r--r--crypto/md5.c34
1 files changed, 11 insertions, 23 deletions
diff --git a/crypto/md5.c b/crypto/md5.c
index 6c4ca1dd59..f70dd62131 100644
--- a/crypto/md5.c
+++ b/crypto/md5.c
@@ -265,16 +265,9 @@ MD5Transform(__u32 buf[4], __u32 const in[16])
buf[3] += d;
}
-struct md5 {
- struct MD5Context context;
- struct digest d;
-};
-
static int digest_md5_init(struct digest *d)
{
- struct md5 *m = container_of(d, struct md5, d);
-
- MD5Init(&m->context);
+ MD5Init(d->ctx);
return 0;
}
@@ -282,35 +275,30 @@ static int digest_md5_init(struct digest *d)
static int digest_md5_update(struct digest *d, const void *data,
unsigned long len)
{
- struct md5 *m = container_of(d, struct md5, d);
-
- MD5Update(&m->context, data, len);
+ MD5Update(d->ctx, data, len);
return 0;
}
static int digest_md5_final(struct digest *d, unsigned char *md)
{
- struct md5 *m = container_of(d, struct md5, d);
-
- MD5Final(md, &m->context);
+ MD5Final(md, d->ctx);
return 0;
}
-static struct md5 m = {
- .d = {
- .name = "md5",
- .init = digest_md5_init,
- .update = digest_md5_update,
- .final = digest_md5_final,
- .length = 16,
- }
+static struct digest_algo md5 = {
+ .name = "md5",
+ .init = digest_md5_init,
+ .update = digest_md5_update,
+ .final = digest_md5_final,
+ .length = 16,
+ .ctx_length = sizeof(struct MD5Context),
};
static int md5_digest_register(void)
{
- digest_register(&m.d);
+ digest_algo_register(&md5);
return 0;
}