crypto: tcrypt - Switch to new AEAD interface
[linux-2.6-block.git] / crypto / tcrypt.c
index 1a2800107fc89d55d933f78e56edc0d7b4370d15..4b4a9313f308f4339dc676d9e3ae13bfa7548ace 100644 (file)
  *
  */
 
+#include <crypto/aead.h>
 #include <crypto/hash.h>
 #include <linux/err.h>
+#include <linux/fips.h>
 #include <linux/init.h>
 #include <linux/gfp.h>
 #include <linux/module.h>
@@ -34,7 +36,6 @@
 #include <linux/timex.h>
 #include <linux/interrupt.h>
 #include "tcrypt.h"
-#include "internal.h"
 
 /*
  * Need slab memory for testing (size in number of pages).
@@ -276,7 +277,6 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,
        const char *key;
        struct aead_request *req;
        struct scatterlist *sg;
-       struct scatterlist *asg;
        struct scatterlist *sgout;
        const char *e;
        void *assoc;
@@ -308,11 +308,10 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,
        if (testmgr_alloc_buf(xoutbuf))
                goto out_nooutbuf;
 
-       sg = kmalloc(sizeof(*sg) * 8 * 3, GFP_KERNEL);
+       sg = kmalloc(sizeof(*sg) * 9 * 2, GFP_KERNEL);
        if (!sg)
                goto out_nosg;
-       asg = &sg[8];
-       sgout = &asg[8];
+       sgout = &sg[9];
 
        tfm = crypto_alloc_aead(algo, 0, 0);
 
@@ -338,7 +337,8 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,
                do {
                        assoc = axbuf[0];
                        memset(assoc, 0xff, aad_size);
-                       sg_init_one(&asg[0], assoc, aad_size);
+                       sg_set_buf(&sg[0], assoc, aad_size);
+                       sg_set_buf(&sgout[0], assoc, aad_size);
 
                        if ((*keysize + *b_size) > TVMEMSIZE * PAGE_SIZE) {
                                pr_err("template (%u) too big for tvmem (%lu)\n",
@@ -374,14 +374,14 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,
                                goto out;
                        }
 
-                       sg_init_aead(&sg[0], xbuf,
+                       sg_init_aead(&sg[1], xbuf,
                                    *b_size + (enc ? authsize : 0));
 
-                       sg_init_aead(&sgout[0], xoutbuf,
+                       sg_init_aead(&sgout[1], xoutbuf,
                                    *b_size + (enc ? authsize : 0));
 
                        aead_request_set_crypt(req, sg, sgout, *b_size, iv);
-                       aead_request_set_assoc(req, asg, aad_size);
+                       aead_request_set_ad(req, aad_size);
 
                        if (secs)
                                ret = test_aead_jiffies(req, enc, *b_size,
@@ -808,7 +808,7 @@ static int test_ahash_jiffies(struct ahash_request *req, int blen,
 
        for (start = jiffies, end = start + secs * HZ, bcount = 0;
             time_before(jiffies, end); bcount++) {
-               ret = crypto_ahash_init(req);
+               ret = do_one_ahash_op(req, crypto_ahash_init(req));
                if (ret)
                        return ret;
                for (pcount = 0; pcount < blen; pcount += plen) {
@@ -877,7 +877,7 @@ static int test_ahash_cycles(struct ahash_request *req, int blen,
 
        /* Warm-up run. */
        for (i = 0; i < 4; i++) {
-               ret = crypto_ahash_init(req);
+               ret = do_one_ahash_op(req, crypto_ahash_init(req));
                if (ret)
                        goto out;
                for (pcount = 0; pcount < blen; pcount += plen) {
@@ -896,7 +896,7 @@ static int test_ahash_cycles(struct ahash_request *req, int blen,
 
                start = get_cycles();
 
-               ret = crypto_ahash_init(req);
+               ret = do_one_ahash_op(req, crypto_ahash_init(req));
                if (ret)
                        goto out;
                for (pcount = 0; pcount < blen; pcount += plen) {