Message ID | 20221118211624.19298-5-prestwoj@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Crypto operations by key ID | expand |
Context | Check | Description |
---|---|---|
tedd_an/pre-ci_am | success | Success |
Hi James, On 11/18/22 15:16, James Prestwood wrote: > Same as l_checksum_new_hmac but uses a key ID rather than a > key directly. > --- > ell/checksum.c | 17 +++++++++++++++++ > ell/checksum.h | 2 ++ > ell/ell.sym | 1 + > 3 files changed, 20 insertions(+) > <snip> > @@ -213,6 +217,19 @@ LIB_EXPORT struct l_checksum *l_checksum_new_hmac(enum l_checksum_type type, > &checksum_hmac_algs[type]); > } > > +struct l_checksum *l_checksum_new_hmac_from_key_id(enum l_checksum_type type, > + int32_t key_id) Missing LIB_EXPORT? > +{ > + if (!is_valid_index(checksum_hmac_algs, type) || > + !checksum_hmac_algs[type].name) > + return NULL; > + > + return checksum_new_common(checksum_hmac_algs[type].name, > + ALG_SET_KEY_BY_KEY_SERIAL, > + &key_id, sizeof(key_id), > + &checksum_hmac_algs[type]); > +} > + > /** > * l_checksum_clone: > * @checksum: parent checksum object Regards, -Denis
diff --git a/ell/checksum.c b/ell/checksum.c index e17f070..dc5e61a 100644 --- a/ell/checksum.c +++ b/ell/checksum.c @@ -68,6 +68,10 @@ struct sockaddr_alg { #define SOL_ALG 279 #endif +#ifndef ALG_SET_KEY_BY_KEY_SERIAL +#define ALG_SET_KEY_BY_KEY_SERIAL 7 +#endif + struct checksum_info { const char *name; uint8_t digest_len; @@ -213,6 +217,19 @@ LIB_EXPORT struct l_checksum *l_checksum_new_hmac(enum l_checksum_type type, &checksum_hmac_algs[type]); } +struct l_checksum *l_checksum_new_hmac_from_key_id(enum l_checksum_type type, + int32_t key_id) +{ + if (!is_valid_index(checksum_hmac_algs, type) || + !checksum_hmac_algs[type].name) + return NULL; + + return checksum_new_common(checksum_hmac_algs[type].name, + ALG_SET_KEY_BY_KEY_SERIAL, + &key_id, sizeof(key_id), + &checksum_hmac_algs[type]); +} + /** * l_checksum_clone: * @checksum: parent checksum object diff --git a/ell/checksum.h b/ell/checksum.h index 531fcb0..3dab13f 100644 --- a/ell/checksum.h +++ b/ell/checksum.h @@ -48,6 +48,8 @@ struct l_checksum *l_checksum_new(enum l_checksum_type type); struct l_checksum *l_checksum_new_cmac_aes(const void *key, size_t key_len); struct l_checksum *l_checksum_new_hmac(enum l_checksum_type type, const void *key, size_t key_len); +struct l_checksum *l_checksum_new_hmac_from_key_id(enum l_checksum_type type, + int32_t key_id); struct l_checksum *l_checksum_clone(struct l_checksum *checksum); void l_checksum_free(struct l_checksum *checksum); diff --git a/ell/ell.sym b/ell/ell.sym index 414b288..08252b8 100644 --- a/ell/ell.sym +++ b/ell/ell.sym @@ -115,6 +115,7 @@ global: l_checksum_new; l_checksum_new_cmac_aes; l_checksum_new_hmac; + l_checksum_new_hmac_from_key_id; l_checksum_clone; l_checksum_free; l_checksum_reset;