diff options
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/hmac.c | 11 | ||||
-rw-r--r-- | crypto/tcrypt.c | 20 |
2 files changed, 21 insertions, 10 deletions
diff --git a/crypto/hmac.c b/crypto/hmac.c index e4eb6ac53b5c..0f05be769c34 100644 --- a/crypto/hmac.c +++ b/crypto/hmac.c | |||
@@ -61,7 +61,7 @@ static int hmac_setkey(struct crypto_hash *parent, | |||
61 | desc.tfm = tfm; | 61 | desc.tfm = tfm; |
62 | desc.flags = crypto_hash_get_flags(parent); | 62 | desc.flags = crypto_hash_get_flags(parent); |
63 | desc.flags &= CRYPTO_TFM_REQ_MAY_SLEEP; | 63 | desc.flags &= CRYPTO_TFM_REQ_MAY_SLEEP; |
64 | sg_set_buf(&tmp, inkey, keylen); | 64 | sg_init_one(&tmp, inkey, keylen); |
65 | 65 | ||
66 | err = crypto_hash_digest(&desc, &tmp, keylen, digest); | 66 | err = crypto_hash_digest(&desc, &tmp, keylen, digest); |
67 | if (err) | 67 | if (err) |
@@ -96,7 +96,7 @@ static int hmac_init(struct hash_desc *pdesc) | |||
96 | 96 | ||
97 | desc.tfm = ctx->child; | 97 | desc.tfm = ctx->child; |
98 | desc.flags = pdesc->flags & CRYPTO_TFM_REQ_MAY_SLEEP; | 98 | desc.flags = pdesc->flags & CRYPTO_TFM_REQ_MAY_SLEEP; |
99 | sg_set_buf(&tmp, ipad, bs); | 99 | sg_init_one(&tmp, ipad, bs); |
100 | 100 | ||
101 | err = crypto_hash_init(&desc); | 101 | err = crypto_hash_init(&desc); |
102 | if (unlikely(err)) | 102 | if (unlikely(err)) |
@@ -131,7 +131,7 @@ static int hmac_final(struct hash_desc *pdesc, u8 *out) | |||
131 | 131 | ||
132 | desc.tfm = ctx->child; | 132 | desc.tfm = ctx->child; |
133 | desc.flags = pdesc->flags & CRYPTO_TFM_REQ_MAY_SLEEP; | 133 | desc.flags = pdesc->flags & CRYPTO_TFM_REQ_MAY_SLEEP; |
134 | sg_set_buf(&tmp, opad, bs + ds); | 134 | sg_init_one(&tmp, opad, bs + ds); |
135 | 135 | ||
136 | err = crypto_hash_final(&desc, digest); | 136 | err = crypto_hash_final(&desc, digest); |
137 | if (unlikely(err)) | 137 | if (unlikely(err)) |
@@ -158,10 +158,11 @@ static int hmac_digest(struct hash_desc *pdesc, struct scatterlist *sg, | |||
158 | desc.tfm = ctx->child; | 158 | desc.tfm = ctx->child; |
159 | desc.flags = pdesc->flags & CRYPTO_TFM_REQ_MAY_SLEEP; | 159 | desc.flags = pdesc->flags & CRYPTO_TFM_REQ_MAY_SLEEP; |
160 | 160 | ||
161 | sg_init_table(sg1, 2); | ||
161 | sg_set_buf(sg1, ipad, bs); | 162 | sg_set_buf(sg1, ipad, bs); |
163 | sg_set_page(&sg1[1], (void *) sg, 0, 0); | ||
162 | 164 | ||
163 | sg_set_page(&sg[1], (void *) sg); | 165 | sg_init_table(sg2, 1); |
164 | sg1[1].length = 0; | ||
165 | sg_set_buf(sg2, opad, bs + ds); | 166 | sg_set_buf(sg2, opad, bs + ds); |
166 | 167 | ||
167 | err = crypto_hash_digest(&desc, sg1, nbytes + bs, digest); | 168 | err = crypto_hash_digest(&desc, sg1, nbytes + bs, digest); |
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index d741c63af42c..24141fb6f5cb 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c | |||
@@ -139,7 +139,7 @@ static void test_hash(char *algo, struct hash_testvec *template, | |||
139 | printk("test %u:\n", i + 1); | 139 | printk("test %u:\n", i + 1); |
140 | memset(result, 0, 64); | 140 | memset(result, 0, 64); |
141 | 141 | ||
142 | sg_set_buf(&sg[0], hash_tv[i].plaintext, hash_tv[i].psize); | 142 | sg_init_one(&sg[0], hash_tv[i].plaintext, hash_tv[i].psize); |
143 | 143 | ||
144 | if (hash_tv[i].ksize) { | 144 | if (hash_tv[i].ksize) { |
145 | ret = crypto_hash_setkey(tfm, hash_tv[i].key, | 145 | ret = crypto_hash_setkey(tfm, hash_tv[i].key, |
@@ -176,6 +176,7 @@ static void test_hash(char *algo, struct hash_testvec *template, | |||
176 | memset(result, 0, 64); | 176 | memset(result, 0, 64); |
177 | 177 | ||
178 | temp = 0; | 178 | temp = 0; |
179 | sg_init_table(sg, hash_tv[i].np); | ||
179 | for (k = 0; k < hash_tv[i].np; k++) { | 180 | for (k = 0; k < hash_tv[i].np; k++) { |
180 | memcpy(&xbuf[IDX[k]], | 181 | memcpy(&xbuf[IDX[k]], |
181 | hash_tv[i].plaintext + temp, | 182 | hash_tv[i].plaintext + temp, |
@@ -289,8 +290,8 @@ static void test_cipher(char *algo, int enc, | |||
289 | goto out; | 290 | goto out; |
290 | } | 291 | } |
291 | 292 | ||
292 | sg_set_buf(&sg[0], cipher_tv[i].input, | 293 | sg_init_one(&sg[0], cipher_tv[i].input, |
293 | cipher_tv[i].ilen); | 294 | cipher_tv[i].ilen); |
294 | 295 | ||
295 | ablkcipher_request_set_crypt(req, sg, sg, | 296 | ablkcipher_request_set_crypt(req, sg, sg, |
296 | cipher_tv[i].ilen, | 297 | cipher_tv[i].ilen, |
@@ -353,6 +354,7 @@ static void test_cipher(char *algo, int enc, | |||
353 | } | 354 | } |
354 | 355 | ||
355 | temp = 0; | 356 | temp = 0; |
357 | sg_init_table(sg, cipher_tv[i].np); | ||
356 | for (k = 0; k < cipher_tv[i].np; k++) { | 358 | for (k = 0; k < cipher_tv[i].np; k++) { |
357 | memcpy(&xbuf[IDX[k]], | 359 | memcpy(&xbuf[IDX[k]], |
358 | cipher_tv[i].input + temp, | 360 | cipher_tv[i].input + temp, |
@@ -414,7 +416,7 @@ static int test_cipher_jiffies(struct blkcipher_desc *desc, int enc, char *p, | |||
414 | int bcount; | 416 | int bcount; |
415 | int ret; | 417 | int ret; |
416 | 418 | ||
417 | sg_set_buf(sg, p, blen); | 419 | sg_init_one(sg, p, blen); |
418 | 420 | ||
419 | for (start = jiffies, end = start + sec * HZ, bcount = 0; | 421 | for (start = jiffies, end = start + sec * HZ, bcount = 0; |
420 | time_before(jiffies, end); bcount++) { | 422 | time_before(jiffies, end); bcount++) { |
@@ -440,7 +442,7 @@ static int test_cipher_cycles(struct blkcipher_desc *desc, int enc, char *p, | |||
440 | int ret = 0; | 442 | int ret = 0; |
441 | int i; | 443 | int i; |
442 | 444 | ||
443 | sg_set_buf(sg, p, blen); | 445 | sg_init_one(sg, p, blen); |
444 | 446 | ||
445 | local_bh_disable(); | 447 | local_bh_disable(); |
446 | local_irq_disable(); | 448 | local_irq_disable(); |
@@ -570,6 +572,8 @@ static int test_hash_jiffies_digest(struct hash_desc *desc, char *p, int blen, | |||
570 | int bcount; | 572 | int bcount; |
571 | int ret; | 573 | int ret; |
572 | 574 | ||
575 | sg_init_table(sg, 1); | ||
576 | |||
573 | for (start = jiffies, end = start + sec * HZ, bcount = 0; | 577 | for (start = jiffies, end = start + sec * HZ, bcount = 0; |
574 | time_before(jiffies, end); bcount++) { | 578 | time_before(jiffies, end); bcount++) { |
575 | sg_set_buf(sg, p, blen); | 579 | sg_set_buf(sg, p, blen); |
@@ -595,6 +599,8 @@ static int test_hash_jiffies(struct hash_desc *desc, char *p, int blen, | |||
595 | if (plen == blen) | 599 | if (plen == blen) |
596 | return test_hash_jiffies_digest(desc, p, blen, out, sec); | 600 | return test_hash_jiffies_digest(desc, p, blen, out, sec); |
597 | 601 | ||
602 | sg_init_table(sg, 1); | ||
603 | |||
598 | for (start = jiffies, end = start + sec * HZ, bcount = 0; | 604 | for (start = jiffies, end = start + sec * HZ, bcount = 0; |
599 | time_before(jiffies, end); bcount++) { | 605 | time_before(jiffies, end); bcount++) { |
600 | ret = crypto_hash_init(desc); | 606 | ret = crypto_hash_init(desc); |
@@ -626,6 +632,8 @@ static int test_hash_cycles_digest(struct hash_desc *desc, char *p, int blen, | |||
626 | int i; | 632 | int i; |
627 | int ret; | 633 | int ret; |
628 | 634 | ||
635 | sg_init_table(sg, 1); | ||
636 | |||
629 | local_bh_disable(); | 637 | local_bh_disable(); |
630 | local_irq_disable(); | 638 | local_irq_disable(); |
631 | 639 | ||
@@ -677,6 +685,8 @@ static int test_hash_cycles(struct hash_desc *desc, char *p, int blen, | |||
677 | if (plen == blen) | 685 | if (plen == blen) |
678 | return test_hash_cycles_digest(desc, p, blen, out); | 686 | return test_hash_cycles_digest(desc, p, blen, out); |
679 | 687 | ||
688 | sg_init_table(sg, 1); | ||
689 | |||
680 | local_bh_disable(); | 690 | local_bh_disable(); |
681 | local_irq_disable(); | 691 | local_irq_disable(); |
682 | 692 | ||