From ab5b2c35e143a87483700ca92d7fd50292a891d0 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Wed, 25 Mar 2015 12:56:14 +0100 Subject: crypto: prepare to allow multiple digest driver This will allow to have hw driver or asm optimised driver. Use a priority level to determine which one to use at runtime. The generic one will be 0. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD Signed-off-by: Sascha Hauer --- crypto/hmac.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'crypto/hmac.c') diff --git a/crypto/hmac.c b/crypto/hmac.c index 4c6a703e5e..77814a1643 100644 --- a/crypto/hmac.c +++ b/crypto/hmac.c @@ -7,8 +7,7 @@ #include #include #include - -#include "internal.h" +#include struct digest_hmac { char *name; @@ -145,7 +144,10 @@ err: } struct digest_algo hmac_algo = { - .flags = DIGEST_ALGO_NEED_KEY, + .base = { + .priority = 0, + .flags = DIGEST_ALGO_NEED_KEY, + }, .alloc = digest_hmac_alloc, .init = digest_hmac_init, .update = digest_hmac_update, @@ -160,16 +162,20 @@ struct digest_algo hmac_algo = { int digest_hmac_register(struct digest_algo *algo, unsigned int pad_length) { struct digest_hmac *dh; + char *name; if (!algo || !pad_length) return -EINVAL; + name = algo->base.name; dh = xzalloc(sizeof(*dh)); - dh->name = xstrdup(algo->name); + dh->name = xstrdup(name); dh->pad_length = pad_length; dh->algo = hmac_algo; dh->algo.length = algo->length; - dh->algo.name = asprintf("hmac(%s)", algo->name); + dh->algo.base.name = asprintf("hmac(%s)", name); + dh->algo.base.driver_name = asprintf("hmac(%s)-generic", name); + dh->algo.base.priority = algo->base.priority; return digest_algo_register(&dh->algo); } -- cgit v1.2.3