[PATCH 7/8] digest: add HMAC support for md5, sha1, sha224, sha256, sha384, sha512

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Thu Mar 12 01:13:08 PDT 2015


On 08:17 Thu 12 Mar     , Sascha Hauer wrote:
> On Wed, Mar 11, 2015 at 05:53:08PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > the hmac algo will be registered as hmac(%s) such as hmac(sha256)
> > 
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> > ---
> > +static int digest_hmac_alloc(struct digest *d)
> > +{
> > +	struct digest_hmac_ctx *dh = d->ctx;
> > +	struct digest_hmac *hmac = to_digest_hmac(d->algo);
> > +
> > +	dh->d = digest_alloc(hmac->name);
> > +	if (!dh->d)
> > +		return -EINVAL;
> > +
> > +	dh->ipad = xmalloc(sizeof(unsigned char) * hmac->pad_length);
> > +	dh->opad = xmalloc(sizeof(unsigned char) * hmac->pad_length);
> 
> sizeof(unsigned char) is 1. Dropped while applying.
habit to always use sizeof but yes no diff

Best Regards,
J.



More information about the barebox mailing list