mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-12 03:00:26 +09:00
pki: Reformat pki_privatekey_type_from_string()
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
(cherry picked from commit 23c837f4d0)
This commit is contained in:
committed by
Andreas Schneider
parent
cafafe8f5a
commit
551188d99b
14
src/pki.c
14
src/pki.c
@@ -64,16 +64,22 @@
|
|||||||
#include "libssh/misc.h"
|
#include "libssh/misc.h"
|
||||||
#include "libssh/agent.h"
|
#include "libssh/agent.h"
|
||||||
|
|
||||||
enum ssh_keytypes_e pki_privatekey_type_from_string(const char *privkey) {
|
enum ssh_keytypes_e pki_privatekey_type_from_string(const char *privkey)
|
||||||
if (strncmp(privkey, DSA_HEADER_BEGIN, strlen(DSA_HEADER_BEGIN)) == 0) {
|
{
|
||||||
|
int cmp;
|
||||||
|
|
||||||
|
cmp = strncmp(privkey, DSA_HEADER_BEGIN, strlen(DSA_HEADER_BEGIN));
|
||||||
|
if (cmp == 0) {
|
||||||
return SSH_KEYTYPE_DSS;
|
return SSH_KEYTYPE_DSS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strncmp(privkey, RSA_HEADER_BEGIN, strlen(RSA_HEADER_BEGIN)) == 0) {
|
cmp = strncmp(privkey, RSA_HEADER_BEGIN, strlen(RSA_HEADER_BEGIN));
|
||||||
|
if (cmp == 0) {
|
||||||
return SSH_KEYTYPE_RSA;
|
return SSH_KEYTYPE_RSA;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strncmp(privkey, ECDSA_HEADER_BEGIN, strlen(ECDSA_HEADER_BEGIN)) == 0) {
|
cmp = strncmp(privkey, ECDSA_HEADER_BEGIN, strlen(ECDSA_HEADER_BEGIN));
|
||||||
|
if (cmp == 0) {
|
||||||
/* We don't know what the curve is at this point, so we don't actually
|
/* We don't know what the curve is at this point, so we don't actually
|
||||||
* know the type. We figure out the actual curve and fix things up in
|
* know the type. We figure out the actual curve and fix things up in
|
||||||
* pki_private_key_from_base64 */
|
* pki_private_key_from_base64 */
|
||||||
|
|||||||
Reference in New Issue
Block a user