Commit b7335885 authored by David S. Miller's avatar David S. Miller

[CRYPTO]: Initialize TCRYPT on-stack scatterlist objects correctly.

Use sg_init_one() and sg_init_table() as needed.
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a6767721
...@@ -139,7 +139,7 @@ static void test_hash(char *algo, struct hash_testvec *template, ...@@ -139,7 +139,7 @@ static void test_hash(char *algo, struct hash_testvec *template,
printk("test %u:\n", i + 1); printk("test %u:\n", i + 1);
memset(result, 0, 64); memset(result, 0, 64);
sg_set_buf(&sg[0], hash_tv[i].plaintext, hash_tv[i].psize); sg_init_one(&sg[0], hash_tv[i].plaintext, hash_tv[i].psize);
if (hash_tv[i].ksize) { if (hash_tv[i].ksize) {
ret = crypto_hash_setkey(tfm, hash_tv[i].key, ret = crypto_hash_setkey(tfm, hash_tv[i].key,
...@@ -176,6 +176,7 @@ static void test_hash(char *algo, struct hash_testvec *template, ...@@ -176,6 +176,7 @@ static void test_hash(char *algo, struct hash_testvec *template,
memset(result, 0, 64); memset(result, 0, 64);
temp = 0; temp = 0;
sg_init_table(sg, hash_tv[i].np);
for (k = 0; k < hash_tv[i].np; k++) { for (k = 0; k < hash_tv[i].np; k++) {
memcpy(&xbuf[IDX[k]], memcpy(&xbuf[IDX[k]],
hash_tv[i].plaintext + temp, hash_tv[i].plaintext + temp,
...@@ -289,8 +290,8 @@ static void test_cipher(char *algo, int enc, ...@@ -289,8 +290,8 @@ static void test_cipher(char *algo, int enc,
goto out; goto out;
} }
sg_set_buf(&sg[0], cipher_tv[i].input, sg_init_one(&sg[0], cipher_tv[i].input,
cipher_tv[i].ilen); cipher_tv[i].ilen);
ablkcipher_request_set_crypt(req, sg, sg, ablkcipher_request_set_crypt(req, sg, sg,
cipher_tv[i].ilen, cipher_tv[i].ilen,
...@@ -353,6 +354,7 @@ static void test_cipher(char *algo, int enc, ...@@ -353,6 +354,7 @@ static void test_cipher(char *algo, int enc,
} }
temp = 0; temp = 0;
sg_init_table(sg, cipher_tv[i].np);
for (k = 0; k < cipher_tv[i].np; k++) { for (k = 0; k < cipher_tv[i].np; k++) {
memcpy(&xbuf[IDX[k]], memcpy(&xbuf[IDX[k]],
cipher_tv[i].input + temp, cipher_tv[i].input + temp,
...@@ -414,7 +416,7 @@ static int test_cipher_jiffies(struct blkcipher_desc *desc, int enc, char *p, ...@@ -414,7 +416,7 @@ static int test_cipher_jiffies(struct blkcipher_desc *desc, int enc, char *p,
int bcount; int bcount;
int ret; int ret;
sg_set_buf(sg, p, blen); sg_init_one(sg, p, blen);
for (start = jiffies, end = start + sec * HZ, bcount = 0; for (start = jiffies, end = start + sec * HZ, bcount = 0;
time_before(jiffies, end); bcount++) { time_before(jiffies, end); bcount++) {
...@@ -440,7 +442,7 @@ static int test_cipher_cycles(struct blkcipher_desc *desc, int enc, char *p, ...@@ -440,7 +442,7 @@ static int test_cipher_cycles(struct blkcipher_desc *desc, int enc, char *p,
int ret = 0; int ret = 0;
int i; int i;
sg_set_buf(sg, p, blen); sg_init_one(sg, p, blen);
local_bh_disable(); local_bh_disable();
local_irq_disable(); local_irq_disable();
...@@ -572,7 +574,7 @@ static int test_hash_jiffies_digest(struct hash_desc *desc, char *p, int blen, ...@@ -572,7 +574,7 @@ static int test_hash_jiffies_digest(struct hash_desc *desc, char *p, int blen,
for (start = jiffies, end = start + sec * HZ, bcount = 0; for (start = jiffies, end = start + sec * HZ, bcount = 0;
time_before(jiffies, end); bcount++) { time_before(jiffies, end); bcount++) {
sg_set_buf(sg, p, blen); sg_init_one(sg, p, blen);
ret = crypto_hash_digest(desc, sg, blen, out); ret = crypto_hash_digest(desc, sg, blen, out);
if (ret) if (ret)
return ret; return ret;
...@@ -601,7 +603,7 @@ static int test_hash_jiffies(struct hash_desc *desc, char *p, int blen, ...@@ -601,7 +603,7 @@ static int test_hash_jiffies(struct hash_desc *desc, char *p, int blen,
if (ret) if (ret)
return ret; return ret;
for (pcount = 0; pcount < blen; pcount += plen) { for (pcount = 0; pcount < blen; pcount += plen) {
sg_set_buf(sg, p + pcount, plen); sg_init_one(sg, p + pcount, plen);
ret = crypto_hash_update(desc, sg, plen); ret = crypto_hash_update(desc, sg, plen);
if (ret) if (ret)
return ret; return ret;
...@@ -631,7 +633,7 @@ static int test_hash_cycles_digest(struct hash_desc *desc, char *p, int blen, ...@@ -631,7 +633,7 @@ static int test_hash_cycles_digest(struct hash_desc *desc, char *p, int blen,
/* Warm-up run. */ /* Warm-up run. */
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
sg_set_buf(sg, p, blen); sg_init_one(sg, p, blen);
ret = crypto_hash_digest(desc, sg, blen, out); ret = crypto_hash_digest(desc, sg, blen, out);
if (ret) if (ret)
goto out; goto out;
...@@ -643,7 +645,7 @@ static int test_hash_cycles_digest(struct hash_desc *desc, char *p, int blen, ...@@ -643,7 +645,7 @@ static int test_hash_cycles_digest(struct hash_desc *desc, char *p, int blen,
start = get_cycles(); start = get_cycles();
sg_set_buf(sg, p, blen); sg_init_one(sg, p, blen);
ret = crypto_hash_digest(desc, sg, blen, out); ret = crypto_hash_digest(desc, sg, blen, out);
if (ret) if (ret)
goto out; goto out;
...@@ -686,7 +688,7 @@ static int test_hash_cycles(struct hash_desc *desc, char *p, int blen, ...@@ -686,7 +688,7 @@ static int test_hash_cycles(struct hash_desc *desc, char *p, int blen,
if (ret) if (ret)
goto out; goto out;
for (pcount = 0; pcount < blen; pcount += plen) { for (pcount = 0; pcount < blen; pcount += plen) {
sg_set_buf(sg, p + pcount, plen); sg_init_one(sg, p + pcount, plen);
ret = crypto_hash_update(desc, sg, plen); ret = crypto_hash_update(desc, sg, plen);
if (ret) if (ret)
goto out; goto out;
...@@ -706,7 +708,7 @@ static int test_hash_cycles(struct hash_desc *desc, char *p, int blen, ...@@ -706,7 +708,7 @@ static int test_hash_cycles(struct hash_desc *desc, char *p, int blen,
if (ret) if (ret)
goto out; goto out;
for (pcount = 0; pcount < blen; pcount += plen) { for (pcount = 0; pcount < blen; pcount += plen) {
sg_set_buf(sg, p + pcount, plen); sg_init_one(sg, p + pcount, plen);
ret = crypto_hash_update(desc, sg, plen); ret = crypto_hash_update(desc, sg, plen);
if (ret) if (ret)
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment