]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - crypto/crypto_user.c
Merge branch 'for-4.8/core' of git://git.kernel.dk/linux-block
[karo-tx-linux.git] / crypto / crypto_user.c
index 7097a3395b2529fd123b2c0b14bcce6992fdee49..1c5705481c6985ad58240ae7514dd5ef0b950582 100644 (file)
@@ -28,6 +28,7 @@
 #include <crypto/internal/skcipher.h>
 #include <crypto/internal/rng.h>
 #include <crypto/akcipher.h>
+#include <crypto/kpp.h>
 
 #include "internal.h"
 
@@ -126,6 +127,21 @@ nla_put_failure:
        return -EMSGSIZE;
 }
 
+static int crypto_report_kpp(struct sk_buff *skb, struct crypto_alg *alg)
+{
+       struct crypto_report_kpp rkpp;
+
+       strncpy(rkpp.type, "kpp", sizeof(rkpp.type));
+
+       if (nla_put(skb, CRYPTOCFGA_REPORT_KPP,
+                   sizeof(struct crypto_report_kpp), &rkpp))
+               goto nla_put_failure;
+       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)
 {
@@ -176,6 +192,10 @@ static int crypto_report_one(struct crypto_alg *alg,
                        goto nla_put_failure;
 
                break;
+       case CRYPTO_ALG_TYPE_KPP:
+               if (crypto_report_kpp(skb, alg))
+                       goto nla_put_failure;
+               break;
        }
 
 out:
@@ -358,32 +378,6 @@ drop_alg:
        return err;
 }
 
-static struct crypto_alg *crypto_user_skcipher_alg(const char *name, u32 type,
-                                                  u32 mask)
-{
-       int err;
-       struct crypto_alg *alg;
-
-       type = crypto_skcipher_type(type);
-       mask = crypto_skcipher_mask(mask);
-
-       for (;;) {
-               alg = crypto_lookup_skcipher(name,  type, mask);
-               if (!IS_ERR(alg))
-                       return alg;
-
-               err = PTR_ERR(alg);
-               if (err != -EAGAIN)
-                       break;
-               if (fatal_signal_pending(current)) {
-                       err = -EINTR;
-                       break;
-               }
-       }
-
-       return ERR_PTR(err);
-}
-
 static int crypto_add_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
                          struct nlattr **attrs)
 {
@@ -416,16 +410,7 @@ static int crypto_add_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
        else
                name = p->cru_name;
 
-       switch (p->cru_type & p->cru_mask & CRYPTO_ALG_TYPE_MASK) {
-       case CRYPTO_ALG_TYPE_GIVCIPHER:
-       case CRYPTO_ALG_TYPE_BLKCIPHER:
-       case CRYPTO_ALG_TYPE_ABLKCIPHER:
-               alg = crypto_user_skcipher_alg(name, p->cru_type, p->cru_mask);
-               break;
-       default:
-               alg = crypto_alg_mod_lookup(name, p->cru_type, p->cru_mask);
-       }
-
+       alg = crypto_alg_mod_lookup(name, p->cru_type, p->cru_mask);
        if (IS_ERR(alg))
                return PTR_ERR(alg);