All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] checksum: add l_checksum_digest_length
@ 2019-01-15 22:38 James Prestwood
  2019-01-16 16:33 ` Denis Kenzior
  0 siblings, 1 reply; 2+ messages in thread
From: James Prestwood @ 2019-01-15 22:38 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 1674 bytes --]

IWD needs the ability to get the digest length for a given checksum.
This was trivial to do in IWD, but since the we already have the
digest length in ELL its more fitting to add a proper ELL API.
---
 ell/checksum.c | 17 +++++++++++++++++
 ell/checksum.h |  2 ++
 ell/ell.sym    |  1 +
 3 files changed, 20 insertions(+)

diff --git a/ell/checksum.c b/ell/checksum.c
index 56b337c..0bb16fd 100644
--- a/ell/checksum.c
+++ b/ell/checksum.c
@@ -510,3 +510,20 @@ LIB_EXPORT bool l_checksum_cmac_aes_supported()
 
 	return is_supported("cmac(aes)");
 }
+
+LIB_EXPORT ssize_t l_checksum_digest_length(enum l_checksum_type type)
+{
+	const char *name;
+	int i;
+
+	name = checksum_type_to_name(type);
+	if (!name)
+		return -EINVAL;
+
+	for (i = 0; checksum_info_table[i].name; i++) {
+		if (!strcmp(checksum_info_table[i].name, name))
+			return checksum_info_table[i].digest_len;
+	}
+
+	return 0;
+}
diff --git a/ell/checksum.h b/ell/checksum.h
index 05927b6..08d74b7 100644
--- a/ell/checksum.h
+++ b/ell/checksum.h
@@ -66,6 +66,8 @@ char *l_checksum_get_string(struct l_checksum *checksum);
 bool l_checksum_is_supported(enum l_checksum_type type, bool check_hmac);
 bool l_checksum_cmac_aes_supported();
 
+ssize_t l_checksum_digest_length(enum l_checksum_type type);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/ell/ell.sym b/ell/ell.sym
index 4a806aa..203a291 100644
--- a/ell/ell.sym
+++ b/ell/ell.sym
@@ -115,6 +115,7 @@ global:
 	l_checksum_get_string;
 	l_checksum_is_supported;
 	l_checksum_cmac_aes_supported;
+	l_checksum_digest_length;
 	/* cipher */
 	l_cipher_new;
 	l_aead_cipher_new;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] checksum: add l_checksum_digest_length
  2019-01-15 22:38 [PATCH] checksum: add l_checksum_digest_length James Prestwood
@ 2019-01-16 16:33 ` Denis Kenzior
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2019-01-16 16:33 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 453 bytes --]

Hi James,

On 01/15/2019 04:38 PM, James Prestwood wrote:
> IWD needs the ability to get the digest length for a given checksum.
> This was trivial to do in IWD, but since the we already have the
> digest length in ELL its more fitting to add a proper ELL API.
> ---
>   ell/checksum.c | 17 +++++++++++++++++
>   ell/checksum.h |  2 ++
>   ell/ell.sym    |  1 +
>   3 files changed, 20 insertions(+)

Applied, thanks.

Regards,
-Denis


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-01-16 16:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-15 22:38 [PATCH] checksum: add l_checksum_digest_length James Prestwood
2019-01-16 16:33 ` Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.