diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2015-03-11 17:53:08 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-03-13 08:32:28 +0100 |
commit | 2f3c3f512b2ff5023a4177e167eb6b55055fe883 (patch) | |
tree | 3df19abcf2a21b3909037825bed82f723901a37e /include/digest.h | |
parent | 3a436924121456c1347acedac31c9e19b2893565 (diff) | |
download | barebox-2f3c3f512b2ff5023a4177e167eb6b55055fe883.tar.gz barebox-2f3c3f512b2ff5023a4177e167eb6b55055fe883.tar.xz |
digest: add HMAC support for md5, sha1, sha224, sha256, sha384, sha512
the hmac algo will be registered as hmac(%s) such as hmac(sha256)
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/digest.h')
-rw-r--r-- | include/digest.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/include/digest.h b/include/digest.h index 2fd1135175..a26848c291 100644 --- a/include/digest.h +++ b/include/digest.h @@ -31,6 +31,7 @@ struct digest_algo { int (*init)(struct digest *d); int (*update)(struct digest *d, const void *data, unsigned long len); int (*final)(struct digest *d, unsigned char *md); + int (*set_key)(struct digest *d, unsigned char *key, unsigned int len); unsigned int length; unsigned int ctx_length; @@ -81,4 +82,11 @@ static inline int digest_length(struct digest *d) return d->algo->length; } +static inline int digest_set_key(struct digest *d, unsigned char *key, unsigned int len) +{ + if (!d->algo->set_key) + return -ENOTSUPP; + return d->algo->set_key(d, key, len); +} + #endif /* __SH_ST_DEVICES_H__ */ |