X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=crypto%2Fhmac.c;h=b60c3c7aa320ba08548c050f4fc05d231321de61;hb=e231c2ee64eb1c5cd3c63c31da9dac7d888dcf7f;hp=e4eb6ac53b5c0b68e01643ce0ec2be97bca35939;hpb=527da38d33f16da4c245da3a5a3858193f8a0261;p=firefly-linux-kernel-4.4.55.git diff --git a/crypto/hmac.c b/crypto/hmac.c index e4eb6ac53b5c..b60c3c7aa320 100644 --- a/crypto/hmac.c +++ b/crypto/hmac.c @@ -17,6 +17,7 @@ */ #include +#include #include #include #include @@ -61,7 +62,7 @@ static int hmac_setkey(struct crypto_hash *parent, desc.tfm = tfm; desc.flags = crypto_hash_get_flags(parent); desc.flags &= CRYPTO_TFM_REQ_MAY_SLEEP; - sg_set_buf(&tmp, inkey, keylen); + sg_init_one(&tmp, inkey, keylen); err = crypto_hash_digest(&desc, &tmp, keylen, digest); if (err) @@ -96,7 +97,7 @@ static int hmac_init(struct hash_desc *pdesc) desc.tfm = ctx->child; desc.flags = pdesc->flags & CRYPTO_TFM_REQ_MAY_SLEEP; - sg_set_buf(&tmp, ipad, bs); + sg_init_one(&tmp, ipad, bs); err = crypto_hash_init(&desc); if (unlikely(err)) @@ -131,7 +132,7 @@ static int hmac_final(struct hash_desc *pdesc, u8 *out) desc.tfm = ctx->child; desc.flags = pdesc->flags & CRYPTO_TFM_REQ_MAY_SLEEP; - sg_set_buf(&tmp, opad, bs + ds); + sg_init_one(&tmp, opad, bs + ds); err = crypto_hash_final(&desc, digest); if (unlikely(err)) @@ -158,10 +159,11 @@ static int hmac_digest(struct hash_desc *pdesc, struct scatterlist *sg, desc.tfm = ctx->child; desc.flags = pdesc->flags & CRYPTO_TFM_REQ_MAY_SLEEP; + sg_init_table(sg1, 2); sg_set_buf(sg1, ipad, bs); + scatterwalk_sg_chain(sg1, 2, sg); - sg_set_page(&sg[1], (void *) sg); - sg1[1].length = 0; + sg_init_table(sg2, 1); sg_set_buf(sg2, opad, bs + ds); err = crypto_hash_digest(&desc, sg1, nbytes + bs, digest); @@ -211,7 +213,7 @@ static struct crypto_instance *hmac_alloc(struct rtattr **tb) alg = crypto_get_attr_alg(tb, CRYPTO_ALG_TYPE_HASH, CRYPTO_ALG_TYPE_HASH_MASK); if (IS_ERR(alg)) - return ERR_PTR(PTR_ERR(alg)); + return ERR_CAST(alg); inst = crypto_alloc_instance("hmac", alg); if (IS_ERR(inst))