summaryrefslogtreecommitdiffstats
path: root/src/legacy.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2011-08-15 19:17:13 +0200
committerAndreas Schneider <asn@cryptomilk.org>2011-08-16 00:47:43 +0200
commit714fa8960d52c5154faa55f5bdd3784657636884 (patch)
tree93029f5af89b4179fdcf7aebb8e262e38efd7211 /src/legacy.c
parent54a2b8a303f5d16bd1f5e60b42acad07e1d8827f (diff)
downloadlibssh-714fa8960d52c5154faa55f5bdd3784657636884.tar.gz
libssh-714fa8960d52c5154faa55f5bdd3784657636884.tar.xz
libssh-714fa8960d52c5154faa55f5bdd3784657636884.zip
pki: Move ssh_privatekey_type and privatekey_free to legacy.
Diffstat (limited to 'src/legacy.c')
-rw-r--r--src/legacy.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/legacy.c b/src/legacy.c
index ee5f896..a17cb82 100644
--- a/src/legacy.c
+++ b/src/legacy.c
@@ -297,6 +297,28 @@ ssh_private_key _privatekey_from_file(void *session, const char *filename,
return privatekey_from_file(session, filename, type, NULL);
}
+enum ssh_keytypes_e ssh_privatekey_type(ssh_private_key privatekey){
+ if (privatekey==NULL)
+ return SSH_KEYTYPE_UNKNOWN;
+ return privatekey->type;
+}
+
+void privatekey_free(ssh_private_key prv) {
+ if (prv == NULL) {
+ return;
+ }
+
+#ifdef HAVE_LIBGCRYPT
+ gcry_sexp_release(prv->dsa_priv);
+ gcry_sexp_release(prv->rsa_priv);
+#elif defined HAVE_LIBCRYPTO
+ DSA_free(prv->dsa_priv);
+ RSA_free(prv->rsa_priv);
+#endif
+ memset(prv, 0, sizeof(struct ssh_private_key_struct));
+ SAFE_FREE(prv);
+}
+
/****************************************************************************
* SERVER SUPPORT
****************************************************************************/