From: Aki Tuomi Date: Wed, 21 Aug 2019 10:25:33 +0000 (+0300) Subject: lib-dcrypt: Add dcrypt_key_get_curve_public X-Git-Tag: 2.3.8~60 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=203dac8d90b0e2eece73a97eb71f3863b80c3cc2;p=thirdparty%2Fdovecot%2Fcore.git lib-dcrypt: Add dcrypt_key_get_curve_public Returns name of the curve of public key --- diff --git a/src/lib-dcrypt/dcrypt-private.h b/src/lib-dcrypt/dcrypt-private.h index c13bc84eb5..13bfadbec7 100644 --- a/src/lib-dcrypt/dcrypt-private.h +++ b/src/lib-dcrypt/dcrypt-private.h @@ -169,6 +169,8 @@ struct dcrypt_vfs { enum dcrypt_key_type key_type, const ARRAY_TYPE(dcrypt_raw_key) *keys, const char **error_r); + bool (*key_get_curve_public)(struct dcrypt_public_key *key, + const char **curve_r, const char **error_r); }; void dcrypt_set_vfs(struct dcrypt_vfs *vfs); diff --git a/src/lib-dcrypt/dcrypt.c b/src/lib-dcrypt/dcrypt.c index 2db30c19ac..77a3bd0ae8 100644 --- a/src/lib-dcrypt/dcrypt.c +++ b/src/lib-dcrypt/dcrypt.c @@ -490,3 +490,14 @@ bool dcrypt_key_load_public_raw(struct dcrypt_public_key **key_r, return dcrypt_vfs->key_load_public_raw(key_r, key_type, keys, error_r); } + +bool dcrypt_key_get_curve_public(struct dcrypt_public_key *key, + const char **curve_r, const char **error_r) +{ + i_assert(dcrypt_vfs != NULL); + if (dcrypt_vfs->key_get_curve_public == NULL) { + *error_r = "Not implemented"; + return FALSE; + } + return dcrypt_vfs->key_get_curve_public(key, curve_r, error_r); +} diff --git a/src/lib-dcrypt/dcrypt.h b/src/lib-dcrypt/dcrypt.h index da20496bff..a8b4588b35 100644 --- a/src/lib-dcrypt/dcrypt.h +++ b/src/lib-dcrypt/dcrypt.h @@ -304,6 +304,10 @@ bool dcrypt_key_load_public_raw(struct dcrypt_public_key **key_r, const ARRAY_TYPE(dcrypt_raw_key) *keys, const char **error_r); +/* for ECC only - return textual name or OID of used curve */ +bool dcrypt_key_get_curve_public(struct dcrypt_public_key *key, + const char **curve_r, const char **error_r); + bool dcrypt_key_string_get_info(const char *key_data, enum dcrypt_key_format *format_r, enum dcrypt_key_version *version_r,