From 64a947b1337b93061da7c7af1f6ce6b2431b70ae Mon Sep 17 00:00:00 2001 From: Steffen Klassert Date: Tue, 27 Sep 2011 07:21:26 +0200 Subject: crypto: Add a flag to identify crypto instances The upcomming crypto user configuration api needs to identify crypto instances. This patch adds a flag that is set if the algorithm is an instance that is build from templates. Signed-off-by: Steffen Klassert Signed-off-by: Herbert Xu --- include/linux/crypto.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include/linux') diff --git a/include/linux/crypto.h b/include/linux/crypto.h index e5e468e9133d..de9adec5693c 100644 --- a/include/linux/crypto.h +++ b/include/linux/crypto.h @@ -71,6 +71,11 @@ #define CRYPTO_ALG_TESTED 0x00000400 +/* + * Set if the algorithm is an instance that is build from templates. + */ +#define CRYPTO_ALG_INSTANCE 0x00000800 + /* * Transform masks and values (for crt_flags). */ -- cgit v1.2.3 From a38f7907b926e4c6c7d389ad96cc38cec2e5a9e9 Mon Sep 17 00:00:00 2001 From: Steffen Klassert Date: Tue, 27 Sep 2011 07:23:50 +0200 Subject: crypto: Add userspace configuration API This patch adds a basic userspace configuration API for the crypto layer. With this it is possible to instantiate, remove and to show crypto algorithms from userspace. Signed-off-by: Steffen Klassert Signed-off-by: Herbert Xu --- include/linux/cryptouser.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++ include/linux/netlink.h | 1 + 2 files changed, 53 insertions(+) create mode 100644 include/linux/cryptouser.h (limited to 'include/linux') diff --git a/include/linux/cryptouser.h b/include/linux/cryptouser.h new file mode 100644 index 000000000000..b874e3879d81 --- /dev/null +++ b/include/linux/cryptouser.h @@ -0,0 +1,52 @@ +/* + * Crypto user configuration API. + * + * Copyright (C) 2011 secunet Security Networks AG + * Copyright (C) 2011 Steffen Klassert + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/* Netlink configuration messages. */ +enum { + CRYPTO_MSG_BASE = 0x10, + CRYPTO_MSG_NEWALG = 0x10, + CRYPTO_MSG_DELALG, + CRYPTO_MSG_UPDATEALG, + CRYPTO_MSG_GETALG, + __CRYPTO_MSG_MAX +}; +#define CRYPTO_MSG_MAX (__CRYPTO_MSG_MAX - 1) +#define CRYPTO_NR_MSGTYPES (CRYPTO_MSG_MAX + 1 - CRYPTO_MSG_BASE) + +#define CRYPTO_MAX_NAME CRYPTO_MAX_ALG_NAME + +/* Netlink message attributes. */ +enum crypto_attr_type_t { + CRYPTOCFGA_UNSPEC, + CRYPTOCFGA_PRIORITY_VAL, /* __u32 */ + __CRYPTOCFGA_MAX + +#define CRYPTOCFGA_MAX (__CRYPTOCFGA_MAX - 1) +}; + +struct crypto_user_alg { + char cru_name[CRYPTO_MAX_ALG_NAME]; + char cru_driver_name[CRYPTO_MAX_ALG_NAME]; + char cru_module_name[CRYPTO_MAX_ALG_NAME]; + __u32 cru_type; + __u32 cru_mask; + __u32 cru_refcnt; + __u32 cru_flags; +}; diff --git a/include/linux/netlink.h b/include/linux/netlink.h index 2e17c5dbdcb8..464ace04283b 100644 --- a/include/linux/netlink.h +++ b/include/linux/netlink.h @@ -25,6 +25,7 @@ #define NETLINK_SCSITRANSPORT 18 /* SCSI Transports */ #define NETLINK_ECRYPTFS 19 #define NETLINK_RDMA 20 +#define NETLINK_CRYPTO 21 /* Crypto layer */ #define MAX_LINKS 32 -- cgit v1.2.3 From 6c5a86f529a9e9ca4c9aca5fa477e9557d4a3d3d Mon Sep 17 00:00:00 2001 From: Steffen Klassert Date: Tue, 27 Sep 2011 07:25:05 +0200 Subject: crypto: Add userspace report for larval type algorithms Signed-off-by: Steffen Klassert Signed-off-by: Herbert Xu --- include/linux/cryptouser.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include/linux') diff --git a/include/linux/cryptouser.h b/include/linux/cryptouser.h index b874e3879d81..7a849b4c3b82 100644 --- a/include/linux/cryptouser.h +++ b/include/linux/cryptouser.h @@ -36,6 +36,7 @@ enum { enum crypto_attr_type_t { CRYPTOCFGA_UNSPEC, CRYPTOCFGA_PRIORITY_VAL, /* __u32 */ + CRYPTOCFGA_REPORT_LARVAL, /* struct crypto_report_larval */ __CRYPTOCFGA_MAX #define CRYPTOCFGA_MAX (__CRYPTOCFGA_MAX - 1) @@ -50,3 +51,7 @@ struct crypto_user_alg { __u32 cru_refcnt; __u32 cru_flags; }; + +struct crypto_report_larval { + char type[CRYPTO_MAX_NAME]; +}; -- cgit v1.2.3 From f4d663ce6357e533f107ce3789bd8848c94bea81 Mon Sep 17 00:00:00 2001 From: Steffen Klassert Date: Tue, 27 Sep 2011 07:26:10 +0200 Subject: crypto: Add userspace report for shash type algorithms Signed-off-by: Steffen Klassert Signed-off-by: Herbert Xu --- include/linux/cryptouser.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include/linux') diff --git a/include/linux/cryptouser.h b/include/linux/cryptouser.h index 7a849b4c3b82..ee4688221975 100644 --- a/include/linux/cryptouser.h +++ b/include/linux/cryptouser.h @@ -37,6 +37,7 @@ enum crypto_attr_type_t { CRYPTOCFGA_UNSPEC, CRYPTOCFGA_PRIORITY_VAL, /* __u32 */ CRYPTOCFGA_REPORT_LARVAL, /* struct crypto_report_larval */ + CRYPTOCFGA_REPORT_HASH, /* struct crypto_report_hash */ __CRYPTOCFGA_MAX #define CRYPTOCFGA_MAX (__CRYPTOCFGA_MAX - 1) @@ -55,3 +56,9 @@ struct crypto_user_alg { struct crypto_report_larval { char type[CRYPTO_MAX_NAME]; }; + +struct crypto_report_hash { + char type[CRYPTO_MAX_NAME]; + unsigned int blocksize; + unsigned int digestsize; +}; -- cgit v1.2.3 From 50496a1fab6c6a90b77da4b247321a88e632bd46 Mon Sep 17 00:00:00 2001 From: Steffen Klassert Date: Tue, 27 Sep 2011 07:41:54 +0200 Subject: crypto: Add userspace report for blkcipher type algorithms Signed-off-by: Steffen Klassert Signed-off-by: Herbert Xu --- include/linux/cryptouser.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include/linux') diff --git a/include/linux/cryptouser.h b/include/linux/cryptouser.h index ee4688221975..a96a1a11ee66 100644 --- a/include/linux/cryptouser.h +++ b/include/linux/cryptouser.h @@ -38,6 +38,7 @@ enum crypto_attr_type_t { CRYPTOCFGA_PRIORITY_VAL, /* __u32 */ CRYPTOCFGA_REPORT_LARVAL, /* struct crypto_report_larval */ CRYPTOCFGA_REPORT_HASH, /* struct crypto_report_hash */ + CRYPTOCFGA_REPORT_BLKCIPHER, /* struct crypto_report_blkcipher */ __CRYPTOCFGA_MAX #define CRYPTOCFGA_MAX (__CRYPTOCFGA_MAX - 1) @@ -62,3 +63,12 @@ struct crypto_report_hash { unsigned int blocksize; unsigned int digestsize; }; + +struct crypto_report_blkcipher { + char type[CRYPTO_MAX_NAME]; + char geniv[CRYPTO_MAX_NAME]; + unsigned int blocksize; + unsigned int min_keysize; + unsigned int max_keysize; + unsigned int ivsize; +}; -- cgit v1.2.3 From 6ad414fe710d4fd3a8c8c6c2ad8fefcfcc207968 Mon Sep 17 00:00:00 2001 From: Steffen Klassert Date: Tue, 27 Sep 2011 07:44:27 +0200 Subject: crypto: Add userspace report for aead type algorithms Signed-off-by: Steffen Klassert Signed-off-by: Herbert Xu --- include/linux/cryptouser.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include/linux') diff --git a/include/linux/cryptouser.h b/include/linux/cryptouser.h index a96a1a11ee66..48030c7dfb51 100644 --- a/include/linux/cryptouser.h +++ b/include/linux/cryptouser.h @@ -39,6 +39,7 @@ enum crypto_attr_type_t { CRYPTOCFGA_REPORT_LARVAL, /* struct crypto_report_larval */ CRYPTOCFGA_REPORT_HASH, /* struct crypto_report_hash */ CRYPTOCFGA_REPORT_BLKCIPHER, /* struct crypto_report_blkcipher */ + CRYPTOCFGA_REPORT_AEAD, /* struct crypto_report_aead */ __CRYPTOCFGA_MAX #define CRYPTOCFGA_MAX (__CRYPTOCFGA_MAX - 1) @@ -72,3 +73,11 @@ struct crypto_report_blkcipher { unsigned int max_keysize; unsigned int ivsize; }; + +struct crypto_report_aead { + char type[CRYPTO_MAX_NAME]; + char geniv[CRYPTO_MAX_NAME]; + unsigned int blocksize; + unsigned int maxauthsize; + unsigned int ivsize; +}; -- cgit v1.2.3 From a55465dca7befd31f4ffa54508d4e2d1e701b8dc Mon Sep 17 00:00:00 2001 From: Steffen Klassert Date: Tue, 27 Sep 2011 07:46:32 +0200 Subject: crypto: Add userspace report for pcompress type algorithms Signed-off-by: Steffen Klassert Signed-off-by: Herbert Xu --- include/linux/cryptouser.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include/linux') diff --git a/include/linux/cryptouser.h b/include/linux/cryptouser.h index 48030c7dfb51..c8c1dfcb7cf2 100644 --- a/include/linux/cryptouser.h +++ b/include/linux/cryptouser.h @@ -40,6 +40,7 @@ enum crypto_attr_type_t { CRYPTOCFGA_REPORT_HASH, /* struct crypto_report_hash */ CRYPTOCFGA_REPORT_BLKCIPHER, /* struct crypto_report_blkcipher */ CRYPTOCFGA_REPORT_AEAD, /* struct crypto_report_aead */ + CRYPTOCFGA_REPORT_COMPRESS, /* struct crypto_report_comp */ __CRYPTOCFGA_MAX #define CRYPTOCFGA_MAX (__CRYPTOCFGA_MAX - 1) @@ -81,3 +82,7 @@ struct crypto_report_aead { unsigned int maxauthsize; unsigned int ivsize; }; + +struct crypto_report_comp { + char type[CRYPTO_MAX_NAME]; +}; -- cgit v1.2.3 From 792608e9c215141fa4b870b7b2a23767a1ef12f4 Mon Sep 17 00:00:00 2001 From: Steffen Klassert Date: Tue, 27 Sep 2011 07:47:11 +0200 Subject: crypto: Add userspace report for rng type algorithms Signed-off-by: Steffen Klassert Signed-off-by: Herbert Xu --- include/linux/cryptouser.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include/linux') diff --git a/include/linux/cryptouser.h b/include/linux/cryptouser.h index c8c1dfcb7cf2..ed8a40e8fb6b 100644 --- a/include/linux/cryptouser.h +++ b/include/linux/cryptouser.h @@ -41,6 +41,7 @@ enum crypto_attr_type_t { CRYPTOCFGA_REPORT_BLKCIPHER, /* struct crypto_report_blkcipher */ CRYPTOCFGA_REPORT_AEAD, /* struct crypto_report_aead */ CRYPTOCFGA_REPORT_COMPRESS, /* struct crypto_report_comp */ + CRYPTOCFGA_REPORT_RNG, /* struct crypto_report_rng */ __CRYPTOCFGA_MAX #define CRYPTOCFGA_MAX (__CRYPTOCFGA_MAX - 1) @@ -86,3 +87,8 @@ struct crypto_report_aead { struct crypto_report_comp { char type[CRYPTO_MAX_NAME]; }; + +struct crypto_report_rng { + char type[CRYPTO_MAX_NAME]; + unsigned int seedsize; +}; -- cgit v1.2.3 From 07a5fa4abd8b6965d4585d3b110f89bdf5612aff Mon Sep 17 00:00:00 2001 From: Steffen Klassert Date: Tue, 27 Sep 2011 07:48:01 +0200 Subject: crypto: Add userspace report for cipher type algorithms Signed-off-by: Steffen Klassert Signed-off-by: Herbert Xu --- include/linux/cryptouser.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include/linux') diff --git a/include/linux/cryptouser.h b/include/linux/cryptouser.h index ed8a40e8fb6b..532fb58f16bf 100644 --- a/include/linux/cryptouser.h +++ b/include/linux/cryptouser.h @@ -42,6 +42,7 @@ enum crypto_attr_type_t { CRYPTOCFGA_REPORT_AEAD, /* struct crypto_report_aead */ CRYPTOCFGA_REPORT_COMPRESS, /* struct crypto_report_comp */ CRYPTOCFGA_REPORT_RNG, /* struct crypto_report_rng */ + CRYPTOCFGA_REPORT_CIPHER, /* struct crypto_report_cipher */ __CRYPTOCFGA_MAX #define CRYPTOCFGA_MAX (__CRYPTOCFGA_MAX - 1) @@ -67,6 +68,13 @@ struct crypto_report_hash { unsigned int digestsize; }; +struct crypto_report_cipher { + char type[CRYPTO_MAX_ALG_NAME]; + unsigned int blocksize; + unsigned int min_keysize; + unsigned int max_keysize; +}; + struct crypto_report_blkcipher { char type[CRYPTO_MAX_NAME]; char geniv[CRYPTO_MAX_NAME]; -- cgit v1.2.3