crypto: ahash - Fix EINPROGRESS notification callback
[pandora-kernel.git] / crypto / ablkcipher.c
index fdc67d3..3ad43ad 100644 (file)
@@ -23,6 +23,8 @@
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/seq_file.h>
+#include <linux/cryptouser.h>
+#include <net/netlink.h>
 
 #include <crypto/scatterwalk.h>
 
@@ -278,12 +280,12 @@ static int ablkcipher_walk_first(struct ablkcipher_request *req,
        if (WARN_ON_ONCE(in_irq()))
                return -EDEADLK;
 
+       walk->iv = req->info;
        walk->nbytes = walk->total;
        if (unlikely(!walk->total))
                return 0;
 
        walk->iv_buffer = NULL;
-       walk->iv = req->info;
        if (unlikely(((unsigned long)walk->iv & alignmask))) {
                int err = ablkcipher_copy_iv(walk, tfm, alignmask);
                if (err)
@@ -377,9 +379,39 @@ static int crypto_init_ablkcipher_ops(struct crypto_tfm *tfm, u32 type,
        }
        crt->base = __crypto_ablkcipher_cast(tfm);
        crt->ivsize = alg->ivsize;
+       crt->has_setkey = alg->max_keysize;
+
+       return 0;
+}
+
+#ifdef CONFIG_NET
+static int crypto_ablkcipher_report(struct sk_buff *skb, struct crypto_alg *alg)
+{
+       struct crypto_report_blkcipher rblkcipher;
+
+       strncpy(rblkcipher.type, "ablkcipher", sizeof(rblkcipher.type));
+       strncpy(rblkcipher.geniv, alg->cra_ablkcipher.geniv ?: "<default>",
+               sizeof(rblkcipher.geniv));
+
+       rblkcipher.blocksize = alg->cra_blocksize;
+       rblkcipher.min_keysize = alg->cra_ablkcipher.min_keysize;
+       rblkcipher.max_keysize = alg->cra_ablkcipher.max_keysize;
+       rblkcipher.ivsize = alg->cra_ablkcipher.ivsize;
+
+       NLA_PUT(skb, CRYPTOCFGA_REPORT_BLKCIPHER,
+               sizeof(struct crypto_report_blkcipher), &rblkcipher);
 
        return 0;
+
+nla_put_failure:
+       return -EMSGSIZE;
+}
+#else
+static int crypto_ablkcipher_report(struct sk_buff *skb, struct crypto_alg *alg)
+{
+       return -ENOSYS;
 }
+#endif
 
 static void crypto_ablkcipher_show(struct seq_file *m, struct crypto_alg *alg)
        __attribute__ ((unused));
@@ -403,6 +435,7 @@ const struct crypto_type crypto_ablkcipher_type = {
 #ifdef CONFIG_PROC_FS
        .show = crypto_ablkcipher_show,
 #endif
+       .report = crypto_ablkcipher_report,
 };
 EXPORT_SYMBOL_GPL(crypto_ablkcipher_type);
 
@@ -428,9 +461,39 @@ static int crypto_init_givcipher_ops(struct crypto_tfm *tfm, u32 type,
        crt->givdecrypt = alg->givdecrypt ?: no_givdecrypt;
        crt->base = __crypto_ablkcipher_cast(tfm);
        crt->ivsize = alg->ivsize;
+       crt->has_setkey = alg->max_keysize;
+
+       return 0;
+}
+
+#ifdef CONFIG_NET
+static int crypto_givcipher_report(struct sk_buff *skb, struct crypto_alg *alg)
+{
+       struct crypto_report_blkcipher rblkcipher;
+
+       strncpy(rblkcipher.type, "givcipher", sizeof(rblkcipher.type));
+       strncpy(rblkcipher.geniv, alg->cra_ablkcipher.geniv ?: "<built-in>",
+               sizeof(rblkcipher.geniv));
+
+       rblkcipher.blocksize = alg->cra_blocksize;
+       rblkcipher.min_keysize = alg->cra_ablkcipher.min_keysize;
+       rblkcipher.max_keysize = alg->cra_ablkcipher.max_keysize;
+       rblkcipher.ivsize = alg->cra_ablkcipher.ivsize;
+
+       NLA_PUT(skb, CRYPTOCFGA_REPORT_BLKCIPHER,
+               sizeof(struct crypto_report_blkcipher), &rblkcipher);
 
        return 0;
+
+nla_put_failure:
+       return -EMSGSIZE;
 }
+#else
+static int crypto_givcipher_report(struct sk_buff *skb, struct crypto_alg *alg)
+{
+       return -ENOSYS;
+}
+#endif
 
 static void crypto_givcipher_show(struct seq_file *m, struct crypto_alg *alg)
        __attribute__ ((unused));
@@ -454,6 +517,7 @@ const struct crypto_type crypto_givcipher_type = {
 #ifdef CONFIG_PROC_FS
        .show = crypto_givcipher_show,
 #endif
+       .report = crypto_givcipher_report,
 };
 EXPORT_SYMBOL_GPL(crypto_givcipher_type);
 
@@ -638,7 +702,7 @@ struct crypto_ablkcipher *crypto_alloc_ablkcipher(const char *alg_name,
 err:
                if (err != -EAGAIN)
                        break;
-               if (signal_pending(current)) {
+               if (fatal_signal_pending(current)) {
                        err = -EINTR;
                        break;
                }