aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/hmac.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/hmac.c')
-rw-r--r--crypto/hmac.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/crypto/hmac.c b/crypto/hmac.c
index da0456b37109..46120dee5ada 100644
--- a/crypto/hmac.c
+++ b/crypto/hmac.c
@@ -18,18 +18,15 @@
18#include <linux/mm.h> 18#include <linux/mm.h>
19#include <linux/highmem.h> 19#include <linux/highmem.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <asm/scatterlist.h> 21#include <linux/scatterlist.h>
22#include "internal.h" 22#include "internal.h"
23 23
24static void hash_key(struct crypto_tfm *tfm, u8 *key, unsigned int keylen) 24static void hash_key(struct crypto_tfm *tfm, u8 *key, unsigned int keylen)
25{ 25{
26 struct scatterlist tmp; 26 struct scatterlist tmp;
27 27
28 tmp.page = virt_to_page(key); 28 sg_set_buf(&tmp, key, keylen);
29 tmp.offset = offset_in_page(key);
30 tmp.length = keylen;
31 crypto_digest_digest(tfm, &tmp, 1, key); 29 crypto_digest_digest(tfm, &tmp, 1, key);
32
33} 30}
34 31
35int crypto_alloc_hmac_block(struct crypto_tfm *tfm) 32int crypto_alloc_hmac_block(struct crypto_tfm *tfm)
@@ -69,9 +66,7 @@ void crypto_hmac_init(struct crypto_tfm *tfm, u8 *key, unsigned int *keylen)
69 for (i = 0; i < crypto_tfm_alg_blocksize(tfm); i++) 66 for (i = 0; i < crypto_tfm_alg_blocksize(tfm); i++)
70 ipad[i] ^= 0x36; 67 ipad[i] ^= 0x36;
71 68
72 tmp.page = virt_to_page(ipad); 69 sg_set_buf(&tmp, ipad, crypto_tfm_alg_blocksize(tfm));
73 tmp.offset = offset_in_page(ipad);
74 tmp.length = crypto_tfm_alg_blocksize(tfm);
75 70
76 crypto_digest_init(tfm); 71 crypto_digest_init(tfm);
77 crypto_digest_update(tfm, &tmp, 1); 72 crypto_digest_update(tfm, &tmp, 1);
@@ -103,16 +98,12 @@ void crypto_hmac_final(struct crypto_tfm *tfm, u8 *key,
103 for (i = 0; i < crypto_tfm_alg_blocksize(tfm); i++) 98 for (i = 0; i < crypto_tfm_alg_blocksize(tfm); i++)
104 opad[i] ^= 0x5c; 99 opad[i] ^= 0x5c;
105 100
106 tmp.page = virt_to_page(opad); 101 sg_set_buf(&tmp, opad, crypto_tfm_alg_blocksize(tfm));
107 tmp.offset = offset_in_page(opad);
108 tmp.length = crypto_tfm_alg_blocksize(tfm);
109 102
110 crypto_digest_init(tfm); 103 crypto_digest_init(tfm);
111 crypto_digest_update(tfm, &tmp, 1); 104 crypto_digest_update(tfm, &tmp, 1);
112 105
113 tmp.page = virt_to_page(out); 106 sg_set_buf(&tmp, out, crypto_tfm_alg_digestsize(tfm));
114 tmp.offset = offset_in_page(out);
115 tmp.length = crypto_tfm_alg_digestsize(tfm);
116 107
117 crypto_digest_update(tfm, &tmp, 1); 108 crypto_digest_update(tfm, &tmp, 1);
118 crypto_digest_final(tfm, out); 109 crypto_digest_final(tfm, out);