[PATCH 17/27] netlink: decode crypto_user_alg attributes of CRYPTOCFGA_REPORT_RNG

JingPiao Chen chenjingpiao at gmail.com
Sat Jul 22 12:43:47 UTC 2017


* configure.ac (AC_CHECK_TYPES): Add struct crypto_report_rng.
* netlink_crypto.c (decode_crypto_report_rng): New function.
(crypto_user_alg_nla_decoders): Add CRYPTOCFGA_REPORT_RNG.
---
 configure.ac     |  3 ++-
 netlink_crypto.c | 26 +++++++++++++++++++++++++-
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 03a3055..90cada5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -325,7 +325,8 @@ AC_CHECK_TYPES(m4_normalize([
 	struct crypto_report_blkcipher,
 	struct crypto_report_comp,
 	struct crypto_report_hash,
-	struct crypto_report_larval
+	struct crypto_report_larval,
+	struct crypto_report_rng
 ]),,, [#include <linux/cryptouser.h>])
 
 AC_CHECK_MEMBERS([struct timex.tai],,, [#include <sys/timex.h>])
diff --git a/netlink_crypto.c b/netlink_crypto.c
index 24b7f93..47c098c 100644
--- a/netlink_crypto.c
+++ b/netlink_crypto.c
@@ -158,13 +158,37 @@ decode_crypto_report_comp(struct tcb *const tcp,
 	return true;
 }
 
+static bool
+decode_crypto_report_rng(struct tcb *const tcp,
+			 const kernel_ulong_t addr,
+			 const unsigned int len,
+			 const void *const opaque_data)
+{
+# ifdef HAVE_STRUCT_CRYPTO_REPORT_RNG
+	struct crypto_report_rng rrng;
+
+	if (len < sizeof(rrng))
+		printstrn(tcp, addr, len);
+	else if (!umove_or_printaddr(tcp, addr, &rrng)) {
+		PRINT_FIELD_CSTRING("{", rrng, type);
+		PRINT_FIELD_U(", ", rrng, seedsize);
+		tprints("}");
+	}
+# else
+	printstrn(tcp, addr, len);
+# 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,
 	[CRYPTOCFGA_REPORT_HASH]	= decode_crypto_report_hash,
 	[CRYPTOCFGA_REPORT_BLKCIPHER]	= decode_crypto_report_blkcipher,
 	[CRYPTOCFGA_REPORT_AEAD]	= decode_crypto_report_aead,
-	[CRYPTOCFGA_REPORT_COMPRESS]	= decode_crypto_report_comp
+	[CRYPTOCFGA_REPORT_COMPRESS]	= decode_crypto_report_comp,
+	[CRYPTOCFGA_REPORT_RNG]		= decode_crypto_report_rng
 };
 
 static void
-- 
2.7.4





More information about the Strace-devel mailing list