]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-dcrypt: Add dcrypt_key_get_curve_public
authorAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 21 Aug 2019 10:25:33 +0000 (13:25 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Mon, 23 Sep 2019 05:47:46 +0000 (08:47 +0300)
Returns name of the curve of public key

src/lib-dcrypt/dcrypt-private.h
src/lib-dcrypt/dcrypt.c
src/lib-dcrypt/dcrypt.h

index c13bc84eb581880c3037608f9628443e19b7d4de..13bfadbec7ee704371231c508d61b10c97714252 100644 (file)
@@ -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);
index 2db30c19ac2db503bb89da886ee19c54debe5043..77a3bd0ae86b9f1c753609adfcfea1cd95ac4ffa 100644 (file)
@@ -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);
+}
index da20496bffe44fd7db5f34fb5f99a8673722472e..a8b4588b3504a18ddb182c82d21ca59196da0b46 100644 (file)
@@ -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,