OSDN Git Service

crypto: talitos - HMAC SNOOP NO AFEU mode requires SW icv checking.
[android-x86/kernel.git] / crypto / tcrypt.c
index ae22f05..babbda2 100644 (file)
@@ -223,11 +223,13 @@ static void sg_init_aead(struct scatterlist *sg, char *xbuf[XBUFSIZE],
        }
 
        sg_init_table(sg, np + 1);
-       np--;
+       if (rem)
+               np--;
        for (k = 0; k < np; k++)
                sg_set_buf(&sg[k + 1], xbuf[k], PAGE_SIZE);
 
-       sg_set_buf(&sg[k + 1], xbuf[k], rem);
+       if (rem)
+               sg_set_buf(&sg[k + 1], xbuf[k], rem);
 }
 
 static void test_aead_speed(const char *algo, int enc, unsigned int secs,
@@ -342,7 +344,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,
                        }
 
                        sg_init_aead(sg, xbuf,
-                                   *b_size + (enc ? authsize : 0));
+                                   *b_size + (enc ? 0 : authsize));
 
                        sg_init_aead(sgout, xoutbuf,
                                    *b_size + (enc ? authsize : 0));
@@ -350,7 +352,9 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,
                        sg_set_buf(&sg[0], assoc, aad_size);
                        sg_set_buf(&sgout[0], assoc, aad_size);
 
-                       aead_request_set_crypt(req, sg, sgout, *b_size, iv);
+                       aead_request_set_crypt(req, sg, sgout,
+                                              *b_size + (enc ? 0 : authsize),
+                                              iv);
                        aead_request_set_ad(req, aad_size);
 
                        if (secs)
@@ -725,6 +729,9 @@ static void test_ahash_speed_common(const char *algo, unsigned int secs,
                        break;
                }
 
+               if (speed[i].klen)
+                       crypto_ahash_setkey(tfm, tvmem[0], speed[i].klen);
+
                pr_info("test%3u "
                        "(%5u byte blocks,%5u bytes per update,%4u updates): ",
                        i, speed[i].blen, speed[i].plen, speed[i].blen / speed[i].plen);