summaryrefslogtreecommitdiffstats
path: root/crypto/hmac.c
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2015-03-25 12:56:14 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2015-03-27 07:49:45 +0100
commitab5b2c35e143a87483700ca92d7fd50292a891d0 (patch)
treef2aaba38fb2ff847ab1e19d0d611fb3aa0be0a01 /crypto/hmac.c
parente10cc0b3330d4dd72fef076a7f1b2b67cb271a12 (diff)
downloadbarebox-ab5b2c35e143a87483700ca92d7fd50292a891d0.tar.gz
barebox-ab5b2c35e143a87483700ca92d7fd50292a891d0.tar.xz
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 <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'crypto/hmac.c')
-rw-r--r--crypto/hmac.c16
1 files changed, 11 insertions, 5 deletions
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 <common.h>
#include <digest.h>
#include <malloc.h>
-
-#include "internal.h"
+#include <crypto/internal.h>
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);
}