aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/tcrypt.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@sunset.davemloft.net>2007-10-26 03:38:10 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-26 03:38:10 -0400
commitb733588559fc13547a59ccf81651c775b8f2719c (patch)
treeffcc43c310c5ca4350f0b74ea77ac16aeb4a00c0 /crypto/tcrypt.c
parenta6767721a563acb172c73f693fcf719b3b3d6716 (diff)
[CRYPTO]: Initialize TCRYPT on-stack scatterlist objects correctly.
Use sg_init_one() and sg_init_table() as needed. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'crypto/tcrypt.c')
-rw-r--r--crypto/tcrypt.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index d741c63af42c..c457bdb2a42b 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();
@@ -572,7 +574,7 @@ static int test_hash_jiffies_digest(struct hash_desc *desc, char *p, int blen,
572 574
573 for (start = jiffies, end = start + sec * HZ, bcount = 0; 575 for (start = jiffies, end = start + sec * HZ, bcount = 0;
574 time_before(jiffies, end); bcount++) { 576 time_before(jiffies, end); bcount++) {
575 sg_set_buf(sg, p, blen); 577 sg_init_one(sg, p, blen);
576 ret = crypto_hash_digest(desc, sg, blen, out); 578 ret = crypto_hash_digest(desc, sg, blen, out);
577 if (ret) 579 if (ret)
578 return ret; 580 return ret;
@@ -601,7 +603,7 @@ static int test_hash_jiffies(struct hash_desc *desc, char *p, int blen,
601 if (ret) 603 if (ret)
602 return ret; 604 return ret;
603 for (pcount = 0; pcount < blen; pcount += plen) { 605 for (pcount = 0; pcount < blen; pcount += plen) {
604 sg_set_buf(sg, p + pcount, plen); 606 sg_init_one(sg, p + pcount, plen);
605 ret = crypto_hash_update(desc, sg, plen); 607 ret = crypto_hash_update(desc, sg, plen);
606 if (ret) 608 if (ret)
607 return ret; 609 return ret;
@@ -631,7 +633,7 @@ static int test_hash_cycles_digest(struct hash_desc *desc, char *p, int blen,
631 633
632 /* Warm-up run. */ 634 /* Warm-up run. */
633 for (i = 0; i < 4; i++) { 635 for (i = 0; i < 4; i++) {
634 sg_set_buf(sg, p, blen); 636 sg_init_one(sg, p, blen);
635 ret = crypto_hash_digest(desc, sg, blen, out); 637 ret = crypto_hash_digest(desc, sg, blen, out);
636 if (ret) 638 if (ret)
637 goto out; 639 goto out;
@@ -643,7 +645,7 @@ static int test_hash_cycles_digest(struct hash_desc *desc, char *p, int blen,
643 645
644 start = get_cycles(); 646 start = get_cycles();
645 647
646 sg_set_buf(sg, p, blen); 648 sg_init_one(sg, p, blen);
647 ret = crypto_hash_digest(desc, sg, blen, out); 649 ret = crypto_hash_digest(desc, sg, blen, out);
648 if (ret) 650 if (ret)
649 goto out; 651 goto out;
@@ -686,7 +688,7 @@ static int test_hash_cycles(struct hash_desc *desc, char *p, int blen,
686 if (ret) 688 if (ret)
687 goto out; 689 goto out;
688 for (pcount = 0; pcount < blen; pcount += plen) { 690 for (pcount = 0; pcount < blen; pcount += plen) {
689 sg_set_buf(sg, p + pcount, plen); 691 sg_init_one(sg, p + pcount, plen);
690 ret = crypto_hash_update(desc, sg, plen); 692 ret = crypto_hash_update(desc, sg, plen);
691 if (ret) 693 if (ret)
692 goto out; 694 goto out;
@@ -706,7 +708,7 @@ static int test_hash_cycles(struct hash_desc *desc, char *p, int blen,
706 if (ret) 708 if (ret)
707 goto out; 709 goto out;
708 for (pcount = 0; pcount < blen; pcount += plen) { 710 for (pcount = 0; pcount < blen; pcount += plen) {
709 sg_set_buf(sg, p + pcount, plen); 711 sg_init_one(sg, p + pcount, plen);
710 ret = crypto_hash_update(desc, sg, plen); 712 ret = crypto_hash_update(desc, sg, plen);
711 if (ret) 713 if (ret)
712 goto out; 714 goto out;