video: tegra: dsi: configure host_suspended correctly
[linux-2.6.git] / crypto / shash.c
index 98b7f46..21fc12e 100644 (file)
@@ -17,6 +17,8 @@
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/seq_file.h>
+#include <linux/cryptouser.h>
+#include <net/netlink.h>
 
 #include "internal.h"
 
@@ -37,7 +39,7 @@ static int shash_setkey_unaligned(struct crypto_shash *tfm, const u8 *key,
        u8 *buffer, *alignbuffer;
        int err;
 
-       absize = keylen + (alignmask & ~(CRYPTO_MINALIGN - 1));
+       absize = keylen + (alignmask & ~(crypto_tfm_ctx_alignment() - 1));
        buffer = kmalloc(absize, GFP_KERNEL);
        if (!buffer)
                return -ENOMEM;
@@ -279,10 +281,10 @@ int shash_ahash_digest(struct ahash_request *req, struct shash_desc *desc)
        if (nbytes < min(sg->length, ((unsigned int)(PAGE_SIZE)) - offset)) {
                void *data;
 
-               data = crypto_kmap(sg_page(sg), 0);
+               data = kmap_atomic(sg_page(sg));
                err = crypto_shash_digest(desc, data + offset, nbytes,
                                          req->result);
-               crypto_kunmap(data, 0);
+               kunmap_atomic(data);
                crypto_yield(desc->flags);
        } else
                err = crypto_shash_init(desc) ?:
@@ -310,7 +312,13 @@ static int shash_async_export(struct ahash_request *req, void *out)
 
 static int shash_async_import(struct ahash_request *req, const void *in)
 {
-       return crypto_shash_import(ahash_request_ctx(req), in);
+       struct crypto_shash **ctx = crypto_ahash_ctx(crypto_ahash_reqtfm(req));
+       struct shash_desc *desc = ahash_request_ctx(req);
+
+       desc->tfm = *ctx;
+       desc->flags = req->base.flags;
+
+       return crypto_shash_import(desc, in);
 }
 
 static void crypto_exit_shash_ops_async(struct crypto_tfm *tfm)
@@ -350,7 +358,7 @@ int crypto_init_shash_ops_async(struct crypto_tfm *tfm)
                crt->setkey = shash_async_setkey;
        if (alg->export)
                crt->export = shash_async_export;
-       if (alg->setkey)
+       if (alg->import)
                crt->import = shash_async_import;
 
        crt->reqsize = sizeof(struct shash_desc) + crypto_shash_descsize(shash);
@@ -412,9 +420,9 @@ static int shash_compat_digest(struct hash_desc *hdesc, struct scatterlist *sg,
 
                desc->flags = hdesc->flags;
 
-               data = crypto_kmap(sg_page(sg), 0);
+               data = kmap_atomic(sg_page(sg));
                err = crypto_shash_digest(desc, data + offset, nbytes, out);
-               crypto_kunmap(data, 0);
+               kunmap_atomic(data);
                crypto_yield(desc->flags);
                goto out;
        }
@@ -516,6 +524,31 @@ static unsigned int crypto_shash_extsize(struct crypto_alg *alg)
        return alg->cra_ctxsize;
 }
 
+#ifdef CONFIG_NET
+static int crypto_shash_report(struct sk_buff *skb, struct crypto_alg *alg)
+{
+       struct crypto_report_hash rhash;
+       struct shash_alg *salg = __crypto_shash_alg(alg);
+
+       snprintf(rhash.type, CRYPTO_MAX_ALG_NAME, "%s", "shash");
+       rhash.blocksize = alg->cra_blocksize;
+       rhash.digestsize = salg->digestsize;
+
+       NLA_PUT(skb, CRYPTOCFGA_REPORT_HASH,
+               sizeof(struct crypto_report_hash), &rhash);
+
+       return 0;
+
+nla_put_failure:
+       return -EMSGSIZE;
+}
+#else
+static int crypto_shash_report(struct sk_buff *skb, struct crypto_alg *alg)
+{
+       return -ENOSYS;
+}
+#endif
+
 static void crypto_shash_show(struct seq_file *m, struct crypto_alg *alg)
        __attribute__ ((unused));
 static void crypto_shash_show(struct seq_file *m, struct crypto_alg *alg)
@@ -535,6 +568,7 @@ static const struct crypto_type crypto_shash_type = {
 #ifdef CONFIG_PROC_FS
        .show = crypto_shash_show,
 #endif
+       .report = crypto_shash_report,
        .maskclear = ~CRYPTO_ALG_TYPE_MASK,
        .maskset = CRYPTO_ALG_TYPE_MASK,
        .type = CRYPTO_ALG_TYPE_SHASH,