lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1410552676.5187.211.camel@dhcp-9-2-203-236.watson.ibm.com>
Date:	Fri, 12 Sep 2014 16:11:16 -0400
From:	Mimi Zohar <zohar@...ux.vnet.ibm.com>
To:	David Howells <dhowells@...hat.com>
Cc:	vgoyal@...hat.com, keyrings@...ux-nfs.org,
	linux-kernel@...r.kernel.org
Subject: Re: [Keyrings] [PATCH 1/9] Provide a binary to hex conversion
 function

On Fri, 2014-09-12 at 20:05 +0100, David Howells wrote: 
> 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@...hat.com>
> ---
> 
>  include/linux/kernel.h |    1 +
>  lib/hexdump.c          |   18 ++++++++++++++++++
>  2 files changed, 19 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..6daf254dddfa 100644
> --- a/lib/hexdump.c
> +++ b/lib/hexdump.c
> @@ -59,6 +59,24 @@ 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)
> +{
> +	while (count--) {
> +		unsigned char ch = *(const unsigned char *)src;
> +		*dst++ = hex_asc[ch >> 4];
> +		*dst++ = hex_asc[ch & 0xf];
> +		src++;

How about using hex_byte_pack()?

Mimi

> +	}
> +	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
> 
> _______________________________________________
> Keyrings mailing list
> Keyrings@...ux-nfs.org
> To change your subscription to this list, please see http://linux-nfs.org/cgi-bin/mailman/listinfo/keyrings
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ