mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: vgoyal@redhat.com
Cc: dhowells@redhat.com, keyrings@linux-nfs.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 01/10] Provide a binary to hex conversion function [ver #2]
Date: Mon, 15 Sep 2014 21:45:02 +0100	[thread overview]
Message-ID: <20140915204502.27499.41387.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <20140915204456.27499.40234.stgit@warthog.procyon.org.uk>

Provide a function to convert a buffer of binary data into an unterminated
ascii hex string representation of that data.

Signed-off-by: David Howells <dhowells@redhat.com>
---

 include/linux/kernel.h |    1 +
 lib/hexdump.c          |   16 ++++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 95624bed87ef..7c0ad8e38510 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -496,6 +496,7 @@ static inline char *hex_byte_pack_upper(char *buf, u8 byte)
 
 extern int hex_to_bin(char ch);
 extern int __must_check hex2bin(u8 *dst, const char *src, size_t count);
+extern char *bin2hex(char *dst, const void *src, size_t count);
 
 bool mac_pton(const char *s, u8 *mac);
 
diff --git a/lib/hexdump.c b/lib/hexdump.c
index 8499c810909a..270773b91923 100644
--- a/lib/hexdump.c
+++ b/lib/hexdump.c
@@ -59,6 +59,22 @@ int hex2bin(u8 *dst, const char *src, size_t count)
 EXPORT_SYMBOL(hex2bin);
 
 /**
+ * bin2hex - convert binary data to an ascii hexadecimal string
+ * @dst: ascii hexadecimal result
+ * @src: binary data
+ * @count: binary data length
+ */
+char *bin2hex(char *dst, const void *src, size_t count)
+{
+	const unsigned char *_src = src;
+
+	while (count--)
+		dst = hex_byte_pack(dst, *_src++);
+	return dst;
+}
+EXPORT_SYMBOL(bin2hex);
+
+/**
  * hex_dump_to_buffer - convert a blob of data to "hex ASCII" in memory
  * @buf: data blob to dump
  * @len: number of bytes in the @buf


  reply	other threads:[~2014-09-15 20:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-15 20:44 [PATCH 00/10] KEYS: Improve asymmetric key and PKCS#7 handling " David Howells
2014-09-15 20:45 ` David Howells [this message]
2014-09-15 20:45 ` [PATCH 02/10] KEYS: Preparse match data " David Howells
2014-09-15 20:45 ` [PATCH 03/10] KEYS: Remove key_type::def_lookup_type " David Howells
2014-09-15 20:45 ` [PATCH 04/10] KEYS: Remove key_type::match in favour of overriding default by match_preparse " David Howells
2014-09-15 20:45 ` [PATCH 05/10] KEYS: Make the key matching functions return bool " David Howells
2014-09-15 20:45 ` [PATCH 06/10] KEYS: Update the keyrings documentation for match changes " David Howells
2014-09-15 20:45 ` [PATCH 07/10] KEYS: Implement binary asymmetric key ID handling " David Howells
2014-09-15 20:45 ` [PATCH 08/10] KEYS: Overhaul key identification when searching for asymmetric keys " David Howells
2014-09-15 20:45 ` [PATCH 09/10] PKCS#7: Better handling of unsupported crypto " David Howells
2014-09-15 20:45 ` [PATCH 10/10] PKCS#7: Handle PKCS#7 messages that contain no X.509 certs " David Howells
2014-09-15 22:30 ` [PATCH 09/10] PKCS#7: Better handling of unsupported crypto " David Howells
2014-09-21 23:32 ` [PATCH 11/10] Check hex2bin()'s return when generating an asymmetric key ID David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140915204502.27499.41387.stgit@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=keyrings@linux-nfs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vgoyal@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®