From 2c04994443384224161d895d00255b5788e8376d Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Sun, 18 Sep 2011 22:04:03 +0200 Subject: pki: Add a ssh_key_cmp() function. --- include/libssh/libssh.h | 8 ++++++++ include/libssh/pki_priv.h | 3 +++ include/libssh/server.h | 1 + 3 files changed, 12 insertions(+) (limited to 'include') diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h index d09d9331..30e31de4 100644 --- a/include/libssh/libssh.h +++ b/include/libssh/libssh.h @@ -242,6 +242,11 @@ enum ssh_keytypes_e{ SSH_KEYTYPE_ECDSA }; +enum ssh_keycmp_e { + SSH_KEY_CMP_PUBLIC = 0, + SSH_KEY_CMP_PRIVATE +}; + /* Error return codes */ #define SSH_OK 0 /* No error */ #define SSH_ERROR -1 /* Error of some kind */ @@ -458,6 +463,9 @@ LIBSSH_API const char *ssh_key_type_to_char(enum ssh_keytypes_e type); LIBSSH_API enum ssh_keytypes_e ssh_key_type_from_name(const char *name); LIBSSH_API int ssh_key_is_public(const ssh_key k); LIBSSH_API int ssh_key_is_private(const ssh_key k); +LIBSSH_API int ssh_key_cmp(const ssh_key k1, + const ssh_key k2, + enum ssh_keycmp_e what); LIBSSH_API int ssh_pki_generate(enum ssh_keytypes_e type, int parameter, ssh_key *pkey); diff --git a/include/libssh/pki_priv.h b/include/libssh/pki_priv.h index 6be297ed..7a664cf1 100644 --- a/include/libssh/pki_priv.h +++ b/include/libssh/pki_priv.h @@ -36,6 +36,9 @@ void _ssh_pki_log(const char *function, ssh_key pki_key_dup(const ssh_key key, int demote); int pki_key_generate_rsa(ssh_key key, int parameter); int pki_key_generate_dss(ssh_key key, int parameter); +int pki_key_compare(const ssh_key k1, + const ssh_key k2, + enum ssh_keycmp_e what); /* SSH Private Key Functions */ enum ssh_keytypes_e pki_privatekey_type_from_string(const char *privkey); diff --git a/include/libssh/server.h b/include/libssh/server.h index 9ad53e42..f3e0bb53 100644 --- a/include/libssh/server.h +++ b/include/libssh/server.h @@ -307,6 +307,7 @@ LIBSSH_API const char *ssh_message_auth_password(ssh_message msg); * @return The public key or NULL. * * @see ssh_key_dup() + * @see ssh_key_cmp() * @see ssh_message_get() * @see ssh_message_type() */ -- cgit v1.2.3