Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs
[pandora-kernel.git] / crypto / crypto_user.c
index aa67c74..2abca78 100644 (file)
@@ -40,7 +40,6 @@ struct crypto_dump_info {
 
 static struct crypto_alg *crypto_alg_match(struct crypto_user_alg *p, int exact)
 {
-       int match;
        struct crypto_alg *q, *alg = NULL;
 
        down_read(&crypto_alg_sem);
@@ -49,6 +48,7 @@ static struct crypto_alg *crypto_alg_match(struct crypto_user_alg *p, int exact)
                return NULL;
 
        list_for_each_entry(q, &crypto_alg_list, cra_list) {
+               int match = 0;
 
                if ((q->cra_flags ^ p->cru_type) & p->cru_mask)
                        continue;
@@ -70,6 +70,40 @@ static struct crypto_alg *crypto_alg_match(struct crypto_user_alg *p, int exact)
        return alg;
 }
 
+static int crypto_report_cipher(struct sk_buff *skb, struct crypto_alg *alg)
+{
+       struct crypto_report_cipher rcipher;
+
+       snprintf(rcipher.type, CRYPTO_MAX_ALG_NAME, "%s", "cipher");
+
+       rcipher.blocksize = alg->cra_blocksize;
+       rcipher.min_keysize = alg->cra_cipher.cia_min_keysize;
+       rcipher.max_keysize = alg->cra_cipher.cia_max_keysize;
+
+       NLA_PUT(skb, CRYPTOCFGA_REPORT_CIPHER,
+               sizeof(struct crypto_report_cipher), &rcipher);
+
+       return 0;
+
+nla_put_failure:
+       return -EMSGSIZE;
+}
+
+static int crypto_report_comp(struct sk_buff *skb, struct crypto_alg *alg)
+{
+       struct crypto_report_comp rcomp;
+
+       snprintf(rcomp.type, CRYPTO_MAX_ALG_NAME, "%s", "compression");
+
+       NLA_PUT(skb, CRYPTOCFGA_REPORT_COMPRESS,
+               sizeof(struct crypto_report_comp), &rcomp);
+
+       return 0;
+
+nla_put_failure:
+       return -EMSGSIZE;
+}
+
 static int crypto_report_one(struct crypto_alg *alg,
                             struct crypto_user_alg *ualg, struct sk_buff *skb)
 {
@@ -84,11 +118,38 @@ static int crypto_report_one(struct crypto_alg *alg,
 
        NLA_PUT_U32(skb, CRYPTOCFGA_PRIORITY_VAL, alg->cra_priority);
 
+       if (alg->cra_flags & CRYPTO_ALG_LARVAL) {
+               struct crypto_report_larval rl;
+
+               snprintf(rl.type, CRYPTO_MAX_ALG_NAME, "%s", "larval");
+
+               NLA_PUT(skb, CRYPTOCFGA_REPORT_LARVAL,
+                       sizeof(struct crypto_report_larval), &rl);
+
+               goto out;
+       }
+
        if (alg->cra_type && alg->cra_type->report) {
                if (alg->cra_type->report(skb, alg))
                        goto nla_put_failure;
+
+               goto out;
        }
 
+       switch (alg->cra_flags & (CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_LARVAL)) {
+       case CRYPTO_ALG_TYPE_CIPHER:
+               if (crypto_report_cipher(skb, alg))
+                       goto nla_put_failure;
+
+               break;
+       case CRYPTO_ALG_TYPE_COMPRESS:
+               if (crypto_report_comp(skb, alg))
+                       goto nla_put_failure;
+
+               break;
+       }
+
+out:
        return 0;
 
 nla_put_failure: