aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-26 11:43:05 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-26 11:43:05 -0400
commitec3b67c11df42362ccda81261d62829042f223f0 (patch)
treeab66bc43d98e38eda7162f76208993b2280f88f3 /crypto
parente868171a94b637158a3930c9adfb448d0df163cd (diff)
parent4be2700fb7b95f2a7cef9324879cafccab8774fc (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
* 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6: (32 commits) [NetLabel]: correct usage of RCU locking [TCP]: fix D-SACK cwnd handling [NET] napi: use non-interruptible sleep in napi_disable [SCTP] net/sctp/auth.c: make 3 functions static [TCP]: Add missing I/O AT code to ipv6 side. [SCTP]: #if 0 sctp_update_copy_cksum() [INET]: Unexport icmpmsg_statistics [NET]: Unexport sock_enable_timestamp(). [TCP]: Make tcp_match_skb_to_sack() static. [IRDA]: Make ircomm_tty static. [NET] fs/proc/proc_net.c: make a struct static [NET] dev_change_name: ignore changes to same name [NET]: Document some simple rules for actions [NET_CLS_ACT]: Use skb_act_clone [NET_CLS_ACT]: Introduce skb_act_clone [TCP]: Fix scatterlist handling in MD5 signature support. [IPSEC]: Fix scatterlist handling in skb_icv_walk(). [IPSEC]: Add missing sg_init_table() calls to ESP. [CRYPTO]: Initialize TCRYPT on-stack scatterlist objects correctly. [CRYPTO]: HMAC needs some more scatterlist fixups. ...
Diffstat (limited to 'crypto')
-rw-r--r--crypto/hmac.c10
-rw-r--r--crypto/tcrypt.c24
2 files changed, 19 insertions, 15 deletions
diff --git a/crypto/hmac.c b/crypto/hmac.c
index 6691981bda..0f05be769c 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,9 +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, 0, 0); 165 sg_init_table(sg2, 1);
164 sg_set_buf(sg2, opad, bs + ds); 166 sg_set_buf(sg2, opad, bs + ds);
165 167
166 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 d741c63af4..c457bdb2a4 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;