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 43 enum ssh_keytypes_e type;
47 #if defined(HAVE_LIBGCRYPT) 51 #elif defined(HAVE_LIBMBEDCRYPTO) 52 mbedtls_pk_context *rsa;
53 mbedtls_ecdsa_context *ecdsa;
55 #elif defined(HAVE_LIBCRYPTO) 58 # if defined(HAVE_OPENSSL_ECC) 64 ed25519_pubkey *ed25519_pubkey;
65 ed25519_privkey *ed25519_privkey;
67 enum ssh_keytypes_e cert_type;
71 enum ssh_keytypes_e type;
72 enum ssh_digest_e hash_type;
74 #if defined(HAVE_LIBGCRYPT) 77 gcry_sexp_t ecdsa_sig;
78 #elif defined(HAVE_LIBMBEDCRYPTO) 80 struct mbedtls_ecdsa_sig ecdsa_sig;
82 ed25519_signature *ed25519_sig;
94 enum ssh_keytypes_e type);
98 enum ssh_keytypes_e type);
100 #define is_ecdsa_key_type(t) \ 101 ((t) >= SSH_KEYTYPE_ECDSA_P256 && (t) <= SSH_KEYTYPE_ECDSA_P521) 103 #define is_cert_type(kt)\ 104 ((kt) == SSH_KEYTYPE_DSS_CERT01 ||\ 105 (kt) == SSH_KEYTYPE_RSA_CERT01 ||\ 106 ((kt) >= SSH_KEYTYPE_ECDSA_P256_CERT01 &&\ 107 (kt) <= SSH_KEYTYPE_ED25519_CERT01)) 110 ssh_signature ssh_signature_new(
void);
111 void ssh_signature_free(ssh_signature sign);
113 int ssh_pki_export_signature_blob(
const ssh_signature sign,
115 int ssh_pki_import_signature_blob(
const ssh_string sig_blob,
117 ssh_signature *psig);
121 unsigned char *digest,
125 int ssh_pki_export_pubkey_blob(
const ssh_key key,
127 int ssh_pki_import_pubkey_blob(
const ssh_string key_blob,
130 int ssh_pki_import_cert_blob(
const ssh_string cert_blob,
136 const ssh_key privatekey,
enum ssh_digest_e hash_type);
enum ssh_keytypes_e ssh_key_type_from_signature_name(const char *name)
Convert a ssh key algorithm name to a ssh key algorithm type.
Definition: pki.c:484
enum ssh_digest_e ssh_key_type_to_hash(ssh_session session, enum ssh_keytypes_e type)
Convert a key type to a hash type. This is usually unambiguous for all the key types, unless the SHA2 extension (RFC 8332) is negotiated during key exchange.
Definition: pki.c:383
Definition: session.h:109
const char * ssh_key_get_signature_algorithm(ssh_session session, enum ssh_keytypes_e type)
Gets signature algorithm name to be used with the given key type.
Definition: pki.c:452
void ssh_key_clean(ssh_key key)
clean up the key and deallocate all existing keys
Definition: pki.c:140
int ssh_key_algorithm_allowed(ssh_session session, const char *type)
Checks the given key against the configured allowed public key algorithm types.
Definition: pki.c:340
enum ssh_keytypes_e ssh_key_type_plain(enum ssh_keytypes_e type)
Get the pubic key type corresponding to a certificate type.
Definition: pki.c:552