summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2015-06-21 07:11:45 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2015-06-22 03:49:27 -0400
commit9aa867e46565d61491f884c793e4988678fbffa3 (patch)
treef6962434a15507a02cfdc7f14e6971bd3a2b5c72
parentd0497524658e37956737d7dbee73cc42120255dc (diff)
crypto: user - Add CRYPTO_MSG_DELRNG
This patch adds a new crypto_user command that allows the admin to delete the crypto system RNG. Note that this can only be done if the RNG is currently not in use. The next time it is used a new system RNG will be allocated. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--crypto/crypto_user.c12
-rw-r--r--include/uapi/linux/cryptouser.h1
2 files changed, 12 insertions, 1 deletions
diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c
index 11dbd5a81c72..08ea2867fc8a 100644
--- a/crypto/crypto_user.c
+++ b/crypto/crypto_user.c
@@ -27,6 +27,7 @@
27#include <net/net_namespace.h> 27#include <net/net_namespace.h>
28#include <crypto/internal/aead.h> 28#include <crypto/internal/aead.h>
29#include <crypto/internal/skcipher.h> 29#include <crypto/internal/skcipher.h>
30#include <crypto/internal/rng.h>
30#include <crypto/akcipher.h> 31#include <crypto/akcipher.h>
31 32
32#include "internal.h" 33#include "internal.h"
@@ -472,13 +473,21 @@ static int crypto_add_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
472 return 0; 473 return 0;
473} 474}
474 475
476static int crypto_del_rng(struct sk_buff *skb, struct nlmsghdr *nlh,
477 struct nlattr **attrs)
478{
479 if (!netlink_capable(skb, CAP_NET_ADMIN))
480 return -EPERM;
481 return crypto_del_default_rng();
482}
483
475#define MSGSIZE(type) sizeof(struct type) 484#define MSGSIZE(type) sizeof(struct type)
476 485
477static const int crypto_msg_min[CRYPTO_NR_MSGTYPES] = { 486static const int crypto_msg_min[CRYPTO_NR_MSGTYPES] = {
478 [CRYPTO_MSG_NEWALG - CRYPTO_MSG_BASE] = MSGSIZE(crypto_user_alg), 487 [CRYPTO_MSG_NEWALG - CRYPTO_MSG_BASE] = MSGSIZE(crypto_user_alg),
479 [CRYPTO_MSG_DELALG - CRYPTO_MSG_BASE] = MSGSIZE(crypto_user_alg), 488 [CRYPTO_MSG_DELALG - CRYPTO_MSG_BASE] = MSGSIZE(crypto_user_alg),
480 [CRYPTO_MSG_UPDATEALG - CRYPTO_MSG_BASE] = MSGSIZE(crypto_user_alg), 489 [CRYPTO_MSG_UPDATEALG - CRYPTO_MSG_BASE] = MSGSIZE(crypto_user_alg),
481 [CRYPTO_MSG_GETALG - CRYPTO_MSG_BASE] = MSGSIZE(crypto_user_alg), 490 [CRYPTO_MSG_DELRNG - CRYPTO_MSG_BASE] = 0,
482}; 491};
483 492
484static const struct nla_policy crypto_policy[CRYPTOCFGA_MAX+1] = { 493static const struct nla_policy crypto_policy[CRYPTOCFGA_MAX+1] = {
@@ -498,6 +507,7 @@ static const struct crypto_link {
498 [CRYPTO_MSG_GETALG - CRYPTO_MSG_BASE] = { .doit = crypto_report, 507 [CRYPTO_MSG_GETALG - CRYPTO_MSG_BASE] = { .doit = crypto_report,
499 .dump = crypto_dump_report, 508 .dump = crypto_dump_report,
500 .done = crypto_dump_report_done}, 509 .done = crypto_dump_report_done},
510 [CRYPTO_MSG_DELRNG - CRYPTO_MSG_BASE] = { .doit = crypto_del_rng },
501}; 511};
502 512
503static int crypto_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) 513static int crypto_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
diff --git a/include/uapi/linux/cryptouser.h b/include/uapi/linux/cryptouser.h
index 36efbbbf2f83..2e67bb64c1da 100644
--- a/include/uapi/linux/cryptouser.h
+++ b/include/uapi/linux/cryptouser.h
@@ -25,6 +25,7 @@ enum {
25 CRYPTO_MSG_DELALG, 25 CRYPTO_MSG_DELALG,
26 CRYPTO_MSG_UPDATEALG, 26 CRYPTO_MSG_UPDATEALG,
27 CRYPTO_MSG_GETALG, 27 CRYPTO_MSG_GETALG,
28 CRYPTO_MSG_DELRNG,
28 __CRYPTO_MSG_MAX 29 __CRYPTO_MSG_MAX
29}; 30};
30#define CRYPTO_MSG_MAX (__CRYPTO_MSG_MAX - 1) 31#define CRYPTO_MSG_MAX (__CRYPTO_MSG_MAX - 1)