diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-05-09 08:07:21 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-05-09 08:07:21 -0700 |
commit | c20b4b69f774896623a8ad87d974982bc89af7ed (patch) | |
tree | d7b104c8bd079f67b0553a5d436651e05696bb1c | |
parent | d9a9a23ff2b00463f25e880d13364938b321ab8a (diff) | |
parent | 67412f0e78dfbbbcb36e631d9df70c6c559d60d4 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
[CRYPTO] hmac: Avoid calling virt_to_page on key
-rw-r--r-- | crypto/hmac.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/crypto/hmac.c b/crypto/hmac.c index b60c3c7aa32..14c6351e639 100644 --- a/crypto/hmac.c +++ b/crypto/hmac.c @@ -57,14 +57,35 @@ static int hmac_setkey(struct crypto_hash *parent, if (keylen > bs) { struct hash_desc desc; struct scatterlist tmp; + int tmplen; int err; desc.tfm = tfm; desc.flags = crypto_hash_get_flags(parent); desc.flags &= CRYPTO_TFM_REQ_MAY_SLEEP; - sg_init_one(&tmp, inkey, keylen); - err = crypto_hash_digest(&desc, &tmp, keylen, digest); + err = crypto_hash_init(&desc); + if (err) + return err; + + tmplen = bs * 2 + ds; + sg_init_one(&tmp, ipad, tmplen); + + for (; keylen > tmplen; inkey += tmplen, keylen -= tmplen) { + memcpy(ipad, inkey, tmplen); + err = crypto_hash_update(&desc, &tmp, tmplen); + if (err) + return err; + } + + if (keylen) { + memcpy(ipad, inkey, keylen); + err = crypto_hash_update(&desc, &tmp, keylen); + if (err) + return err; + } + + err = crypto_hash_final(&desc, digest); if (err) return err; |