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 #include "libssh/ed25519.h" 35 #define MAX_PUBKEY_SIZE 0x100000 36 #define MAX_PRIVKEY_SIZE 0x400000 38 #define SSH_KEY_FLAG_EMPTY 0x0 39 #define SSH_KEY_FLAG_PUBLIC 0x0001 40 #define SSH_KEY_FLAG_PRIVATE 0x0002 42 struct ssh_key_struct {
43 enum ssh_keytypes_e type;
54 #ifdef HAVE_OPENSSL_ECC 60 ed25519_pubkey *ed25519_pubkey;
61 ed25519_privkey *ed25519_privkey;
63 enum ssh_keytypes_e cert_type;
66 struct ssh_signature_struct {
67 enum ssh_keytypes_e type;
72 gcry_sexp_t ecdsa_sig;
73 #elif defined HAVE_LIBCRYPTO 76 # ifdef HAVE_OPENSSL_ECC 82 ed25519_signature *ed25519_sig;
85 typedef struct ssh_signature_struct *ssh_signature;
88 ssh_key ssh_key_dup(
const ssh_key key);
92 ssh_signature ssh_signature_new(
void);
93 void ssh_signature_free(ssh_signature sign);
95 int ssh_pki_export_signature_blob(
const ssh_signature sign,
96 ssh_string *sign_blob);
97 int ssh_pki_import_signature_blob(
const ssh_string sig_blob,
100 int ssh_pki_signature_verify_blob(ssh_session session,
103 unsigned char *digest,
107 int ssh_pki_export_pubkey_blob(
const ssh_key key,
109 int ssh_pki_import_pubkey_blob(
const ssh_string key_blob,
111 int ssh_pki_export_pubkey_rsa1(
const ssh_key key,
116 int ssh_pki_import_cert_blob(
const ssh_string cert_blob,
121 ssh_string ssh_pki_do_sign(ssh_session session, ssh_buffer sigbuf,
122 const ssh_key privatekey);
123 ssh_string ssh_pki_do_sign_agent(ssh_session session,
124 struct ssh_buffer_struct *buf,
125 const ssh_key pubkey);
126 ssh_string ssh_srv_pki_do_sign_sessionid(ssh_session session,
127 const ssh_key privkey);
130 ssh_public_key ssh_pki_convert_key_to_publickey(
const ssh_key key);
131 ssh_private_key ssh_pki_convert_key_to_privatekey(
const ssh_key key);
void ssh_key_clean(ssh_key key)
clean up the key and deallocate all existing keys
Definition: pki.c:128