[PATCH 19/27] netlink: decode crypto_user_alg attributes of CRYPTOCFGA_REPORT_CIPHER

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


* configure.ac (AC_CHECK_TYPES): Add struct crypto_report_cipher.
* netlink_crypto.c (decode_crypto_report_cipher): New function.
(crypto_user_alg_nla_decoders): Add CRYPTOCFGA_REPORT_CIPHER.
---
 configure.ac     |  1 +
 netlink_crypto.c | 28 +++++++++++++++++++++++++++-
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 90cada5..005f2d8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -323,6 +323,7 @@ AC_CHECK_TYPES(m4_normalize([
 AC_CHECK_TYPES(m4_normalize([
 	struct crypto_report_aead,
 	struct crypto_report_blkcipher,
+	struct crypto_report_cipher,
 	struct crypto_report_comp,
 	struct crypto_report_hash,
 	struct crypto_report_larval,
diff --git a/netlink_crypto.c b/netlink_crypto.c
index 47c098c..8729f80 100644
--- a/netlink_crypto.c
+++ b/netlink_crypto.c
@@ -181,6 +181,31 @@ decode_crypto_report_rng(struct tcb *const tcp,
 	return true;
 }
 
+static bool
+decode_crypto_report_cipher(struct tcb *const tcp,
+			    const kernel_ulong_t addr,
+			    const unsigned int len,
+			    const void *const opaque_data)
+{
+# ifdef HAVE_STRUCT_CRYPTO_REPORT_CIPHER
+	struct crypto_report_cipher rcipher;
+
+	if (len < sizeof(rcipher))
+		printstrn(tcp, addr, len);
+	else if (!umove_or_printaddr(tcp, addr, &rcipher)) {
+		PRINT_FIELD_CSTRING("{", rcipher, type);
+		PRINT_FIELD_U(", ", rcipher, blocksize);
+		PRINT_FIELD_U(", ", rcipher, min_keysize);
+		PRINT_FIELD_U(", ", rcipher, max_keysize);
+		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,
@@ -188,7 +213,8 @@ static const nla_decoder_t crypto_user_alg_nla_decoders[] = {
 	[CRYPTOCFGA_REPORT_BLKCIPHER]	= decode_crypto_report_blkcipher,
 	[CRYPTOCFGA_REPORT_AEAD]	= decode_crypto_report_aead,
 	[CRYPTOCFGA_REPORT_COMPRESS]	= decode_crypto_report_comp,
-	[CRYPTOCFGA_REPORT_RNG]		= decode_crypto_report_rng
+	[CRYPTOCFGA_REPORT_RNG]		= decode_crypto_report_rng,
+	[CRYPTOCFGA_REPORT_CIPHER]	= decode_crypto_report_cipher
 };
 
 static void
-- 
2.7.4





More information about the Strace-devel mailing list