1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-08-08 19:02:06 +03:00

pki: Add pki_privatekey_type_from_string().

This commit is contained in:
Andreas Schneider
2011-08-07 14:00:25 +02:00
parent d8b41bcac3
commit 028888719a
2 changed files with 18 additions and 0 deletions

View File

@@ -37,6 +37,18 @@
#include "libssh/keys.h"
#include "libssh/buffer.h"
enum ssh_keytypes_e pki_privatekey_type_from_string(const char *privkey) {
if (strncmp(privkey, DSA_HEADER_BEGIN, strlen(DSA_HEADER_BEGIN)) == 0) {
return SSH_KEYTYPE_DSS;
}
if (strncmp(privkey, RSA_HEADER_BEGIN, strlen(RSA_HEADER_BEGIN)) == 0) {
return SSH_KEYTYPE_RSA;
}
return SSH_KEYTYPE_UNKNOWN;
}
/**
* @brief creates a new empty SSH key
* @returns an empty ssh_key handle, or NULL on error.