[PATCH 23/27] netlink: decode crypto_user_alg attributes of CRYPTOCFGA_REPORT_KPP

JingPiao Chen chenjingpiao at gmail.com
Sat Jul 22 13:00:38 UTC 2017


* configure.ac (AC_CHECK_TYPES): Add struct crypto_report_kpp.
* netlink_crypto.c (decode_crypto_report_kpp): New function.
(crypto_user_alg_nla_decoders): Add CRYPTOCFGA_REPORT_KPP.
---
 configure.ac     |  1 +
 netlink_crypto.c | 25 ++++++++++++++++++++++++-
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 5190ff0..929f248 100644
--- a/configure.ac
+++ b/configure.ac
@@ -327,6 +327,7 @@ AC_CHECK_TYPES(m4_normalize([
 	struct crypto_report_cipher,
 	struct crypto_report_comp,
 	struct crypto_report_hash,
+	struct crypto_report_kpp,
 	struct crypto_report_larval,
 	struct crypto_report_rng
 ]),,, [#include <linux/cryptouser.h>])
diff --git a/netlink_crypto.c b/netlink_crypto.c
index 188a3c8..4cd75bd 100644
--- a/netlink_crypto.c
+++ b/netlink_crypto.c
@@ -228,6 +228,28 @@ decode_crypto_report_akcipher(struct tcb *const tcp,
 	return true;
 }
 
+static bool
+decode_crypto_report_kpp(struct tcb *const tcp,
+			 const kernel_ulong_t addr,
+			 const unsigned int len,
+			 const void *const opaque_data)
+{
+# ifdef HAVE_STRUCT_CRYPTO_REPORT_AKCIPHER
+	struct crypto_report_kpp rkpp;
+
+	if (len < sizeof(rkpp))
+		printstr_ex(tcp, addr, len, QUOTE_0_TERMINATED);
+	else if (!umove_or_printaddr(tcp, addr, &rkpp)) {
+		PRINT_FIELD_CSTRING("{", rkpp, type);
+		tprints("}");
+	}
+# else
+	printstr_ex(tcp, addr, len, QUOTE_0_TERMINATED);
+# endif
+
+	return true;
+}
+
 static const nla_decoder_t crypto_user_alg_nla_decoders[] = {
 	[CRYPTOCFGA_PRIORITY_VAL]	= decode_nla_u32,
 	[CRYPTOCFGA_REPORT_LARVAL]	= decode_crypto_report_larval,
@@ -237,7 +259,8 @@ static const nla_decoder_t crypto_user_alg_nla_decoders[] = {
 	[CRYPTOCFGA_REPORT_COMPRESS]	= decode_crypto_report_comp,
 	[CRYPTOCFGA_REPORT_RNG]		= decode_crypto_report_rng,
 	[CRYPTOCFGA_REPORT_CIPHER]	= decode_crypto_report_cipher,
-	[CRYPTOCFGA_REPORT_AKCIPHER]	= decode_crypto_report_akcipher
+	[CRYPTOCFGA_REPORT_AKCIPHER]	= decode_crypto_report_akcipher,
+	[CRYPTOCFGA_REPORT_KPP]		= decode_crypto_report_kpp
 };
 
 static void
-- 
2.7.4





More information about the Strace-devel mailing list