checksum: add l_checksum_digest_length
PATCH 1/1 checksum: add l_checksum_digest_length
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(+)
ell/checksum.c +17 -0
@@ -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 ; +}
ell/checksum.h +2 -0
@@ -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
ell/ell.sym +1 -0
@@ -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;
Signature · 1 line
2.17.1
Denis Kenzior
AppliedHi James,
Quoted 8 lines · James Prestwood
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