24 #include "libssh/priv.h"
25 #ifdef HAVE_OPENSSL_EC_H
26 #include <openssl/ec.h>
28 #ifdef HAVE_OPENSSL_ECDSA_H
29 #include <openssl/ecdsa.h>
32 #include "libssh/crypto.h"
33 #ifdef HAVE_OPENSSL_ED25519
36 #define ED25519_SIG_LEN 64
38 #include "libssh/ed25519.h"
41 #define ED25519_KEY_LEN 32
43 #define MAX_PUBKEY_SIZE 0x100000
44 #define MAX_PRIVKEY_SIZE 0x400000
46 #define SSH_KEY_FLAG_EMPTY 0x0
47 #define SSH_KEY_FLAG_PUBLIC 0x0001
48 #define SSH_KEY_FLAG_PRIVATE 0x0002
51 enum ssh_keytypes_e type;
55 #if defined(HAVE_LIBGCRYPT)
59 #elif defined(HAVE_LIBMBEDCRYPTO)
60 mbedtls_pk_context *rsa;
61 mbedtls_ecdsa_context *ecdsa;
63 #elif defined(HAVE_LIBCRYPTO)
66 # if defined(HAVE_OPENSSL_ECC)
72 #ifdef HAVE_OPENSSL_ED25519
73 uint8_t *ed25519_pubkey;
74 uint8_t *ed25519_privkey;
76 ed25519_pubkey *ed25519_pubkey;
77 ed25519_privkey *ed25519_privkey;
80 enum ssh_keytypes_e cert_type;
84 enum ssh_keytypes_e type;
85 enum ssh_digest_e hash_type;
87 #if defined(HAVE_LIBGCRYPT)
90 gcry_sexp_t ecdsa_sig;
91 #elif defined(HAVE_LIBMBEDCRYPTO)
93 struct mbedtls_ecdsa_sig ecdsa_sig;
95 #ifndef HAVE_OPENSSL_ED25519
96 ed25519_signature *ed25519_sig;
109 enum ssh_keytypes_e type);
113 enum ssh_keytypes_e type);
114 enum ssh_digest_e ssh_key_hash_from_name(
const char *name);
116 #define is_ecdsa_key_type(t) \
117 ((t) >= SSH_KEYTYPE_ECDSA_P256 && (t) <= SSH_KEYTYPE_ECDSA_P521)
119 #define is_cert_type(kt)\
120 ((kt) == SSH_KEYTYPE_DSS_CERT01 ||\
121 (kt) == SSH_KEYTYPE_RSA_CERT01 ||\
122 ((kt) >= SSH_KEYTYPE_ECDSA_P256_CERT01 &&\
123 (kt) <= SSH_KEYTYPE_ED25519_CERT01))
131 int ssh_pki_import_signature_blob(
const ssh_string sig_blob,
137 const unsigned char *digest,
141 int ssh_pki_export_pubkey_blob(
const ssh_key key,
143 int ssh_pki_import_pubkey_blob(
const ssh_string key_blob,
146 int ssh_pki_import_cert_blob(
const ssh_string cert_blob,
152 const ssh_key privatekey,
enum ssh_digest_e hash_type);
158 const enum ssh_digest_e digest);