1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-26 01:03:15 +03:00

Add external c declaration for c++

To make sure c++ name mangling works correctly c code should be noted "extern"

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
Norbert Pocs
2022-10-24 12:50:46 +02:00
committed by Jakub Jelen
parent 5e81eec4ec
commit d1947b55ec
42 changed files with 335 additions and 0 deletions

View File

@@ -70,6 +70,10 @@
#define SSH_AGENT_RSA_SHA2_256 0x02 #define SSH_AGENT_RSA_SHA2_256 0x02
#define SSH_AGENT_RSA_SHA2_512 0x04 #define SSH_AGENT_RSA_SHA2_512 0x04
#ifdef __cplusplus
extern "C" {
#endif
struct ssh_agent_struct { struct ssh_agent_struct {
struct ssh_socket_struct *sock; struct ssh_socket_struct *sock;
ssh_buffer ident; ssh_buffer ident;
@@ -115,4 +119,8 @@ ssh_string ssh_agent_sign_data(ssh_session session,
const ssh_key pubkey, const ssh_key pubkey,
struct ssh_buffer_struct *data); struct ssh_buffer_struct *data);
#ifdef __cplusplus
}
#endif
#endif /* __AGENT_H */ #endif /* __AGENT_H */

View File

@@ -23,6 +23,10 @@
#include "config.h" #include "config.h"
#include "libssh/callbacks.h" #include "libssh/callbacks.h"
#ifdef __cplusplus
extern "C" {
#endif
SSH_PACKET_CALLBACK(ssh_packet_userauth_banner); SSH_PACKET_CALLBACK(ssh_packet_userauth_banner);
SSH_PACKET_CALLBACK(ssh_packet_userauth_failure); SSH_PACKET_CALLBACK(ssh_packet_userauth_failure);
SSH_PACKET_CALLBACK(ssh_packet_userauth_success); SSH_PACKET_CALLBACK(ssh_packet_userauth_success);
@@ -100,4 +104,8 @@ enum ssh_auth_service_state_e {
SSH_AUTH_SERVICE_DENIED, SSH_AUTH_SERVICE_DENIED,
}; };
#ifdef __cplusplus
}
#endif
#endif /* AUTH_H_ */ #endif /* AUTH_H_ */

View File

@@ -25,9 +25,16 @@
#include "libssh/libgcrypt.h" #include "libssh/libgcrypt.h"
#include "libssh/libmbedcrypto.h" #include "libssh/libmbedcrypto.h"
#ifdef __cplusplus
extern "C" {
#endif
bignum ssh_make_string_bn(ssh_string string); bignum ssh_make_string_bn(ssh_string string);
ssh_string ssh_make_bignum_string(bignum num); ssh_string ssh_make_bignum_string(bignum num);
void ssh_print_bignum(const char *which, const_bignum num); void ssh_print_bignum(const char *which, const_bignum num);
#ifdef __cplusplus
}
#endif
#endif /* BIGNUM_H_ */ #endif /* BIGNUM_H_ */

View File

@@ -25,6 +25,10 @@
#include "libssh/kex.h" #include "libssh/kex.h"
#include "libssh/session.h" #include "libssh/session.h"
#ifdef __cplusplus
extern "C" {
#endif
struct ssh_bind_struct { struct ssh_bind_struct {
struct ssh_common_struct common; /* stuff common to ssh_bind and ssh_session */ struct ssh_common_struct common; /* stuff common to ssh_bind and ssh_session */
struct ssh_bind_callbacks_struct *bind_callbacks; struct ssh_bind_callbacks_struct *bind_callbacks;
@@ -57,5 +61,8 @@ struct ssh_bind_struct {
struct ssh_poll_handle_struct *ssh_bind_get_poll(struct ssh_bind_struct struct ssh_poll_handle_struct *ssh_bind_get_poll(struct ssh_bind_struct
*sshbind); *sshbind);
#ifdef __cplusplus
}
#endif
#endif /* BIND_H_ */ #endif /* BIND_H_ */

View File

@@ -28,6 +28,10 @@
#include "libssh/server.h" #include "libssh/server.h"
#ifdef __cplusplus
extern "C" {
#endif
enum ssh_bind_config_opcode_e { enum ssh_bind_config_opcode_e {
/* Known but not allowed in Match block */ /* Known but not allowed in Match block */
BIND_CFG_NOT_ALLOWED_IN_MATCH = -4, BIND_CFG_NOT_ALLOWED_IN_MATCH = -4,
@@ -71,4 +75,8 @@ int ssh_bind_config_parse_file(ssh_bind sshbind, const char *filename);
*/ */
int ssh_bind_config_parse_string(ssh_bind bind, const char *input); int ssh_bind_config_parse_string(ssh_bind bind, const char *input);
#ifdef __cplusplus
}
#endif
#endif /* BIND_CONFIG_H_ */ #endif /* BIND_CONFIG_H_ */

View File

@@ -49,6 +49,10 @@
#define BLF_MAXKEYLEN ((BLF_N-2)*4) /* 448 bits */ #define BLF_MAXKEYLEN ((BLF_N-2)*4) /* 448 bits */
#define BLF_MAXUTILIZED ((BLF_N+2)*4) /* 576 bits */ #define BLF_MAXUTILIZED ((BLF_N+2)*4) /* 576 bits */
#ifdef __cplusplus
extern "C" {
#endif
/* Blowfish context */ /* Blowfish context */
typedef struct BlowfishContext { typedef struct BlowfishContext {
uint32_t S[4][256]; /* S-Boxes */ uint32_t S[4][256]; /* S-Boxes */
@@ -84,4 +88,9 @@ void ssh_blf_cbc_decrypt(ssh_blf_ctx *, uint8_t *, uint8_t *, uint32_t);
uint32_t Blowfish_stream2word(const uint8_t *, uint16_t , uint16_t *); uint32_t Blowfish_stream2word(const uint8_t *, uint16_t , uint16_t *);
#endif /* !defined(HAVE_BCRYPT_PBKDF) && !defined(HAVE_BLH_H) */ #endif /* !defined(HAVE_BCRYPT_PBKDF) && !defined(HAVE_BLH_H) */
#ifdef __cplusplus
}
#endif
#endif /* _BLF_H */ #endif /* _BLF_H */

View File

@@ -27,6 +27,10 @@
#define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3) #define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3)
#ifdef __cplusplus
extern "C" {
#endif
void ssh_buffer_set_secure(ssh_buffer buffer); void ssh_buffer_set_secure(ssh_buffer buffer);
int ssh_buffer_add_ssh_string(ssh_buffer buffer, ssh_string string); int ssh_buffer_add_ssh_string(ssh_buffer buffer, ssh_string string);
int ssh_buffer_add_u8(ssh_buffer buffer, uint8_t data); int ssh_buffer_add_u8(ssh_buffer buffer, uint8_t data);
@@ -74,4 +78,8 @@ ssh_string ssh_buffer_get_ssh_string(ssh_buffer buffer);
uint32_t ssh_buffer_pass_bytes_end(ssh_buffer buffer, uint32_t len); uint32_t ssh_buffer_pass_bytes_end(ssh_buffer buffer, uint32_t len);
uint32_t ssh_buffer_pass_bytes(ssh_buffer buffer, uint32_t len); uint32_t ssh_buffer_pass_bytes(ssh_buffer buffer, uint32_t len);
#ifdef __cplusplus
}
#endif
#endif /* BUFFER_H_ */ #endif /* BUFFER_H_ */

View File

@@ -18,6 +18,10 @@ struct chacha_ctx {
#define CHACHA_CTRLEN 8 #define CHACHA_CTRLEN 8
#define CHACHA_STATELEN (CHACHA_NONCELEN+CHACHA_CTRLEN) #define CHACHA_STATELEN (CHACHA_NONCELEN+CHACHA_CTRLEN)
#ifdef __cplusplus
extern "C" {
#endif
void chacha_keysetup(struct chacha_ctx *x, const uint8_t *k, uint32_t kbits) void chacha_keysetup(struct chacha_ctx *x, const uint8_t *k, uint32_t kbits)
#ifdef HAVE_GCC_BOUNDED_ATTRIBUTE #ifdef HAVE_GCC_BOUNDED_ATTRIBUTE
__attribute__((__bounded__(__minbytes__, 2, CHACHA_MINKEYLEN))) __attribute__((__bounded__(__minbytes__, 2, CHACHA_MINKEYLEN)))
@@ -37,4 +41,8 @@ void chacha_encrypt_bytes(struct chacha_ctx *x, const uint8_t *m,
#endif #endif
; ;
#ifdef __cplusplus
}
#endif
#endif /* CHACHA_H */ #endif /* CHACHA_H */

View File

@@ -22,6 +22,10 @@
#define CHANNELS_H_ #define CHANNELS_H_
#include "libssh/priv.h" #include "libssh/priv.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @internal /** @internal
* Describes the different possible states in a * Describes the different possible states in a
* outgoing (client) channel request * outgoing (client) channel request
@@ -109,4 +113,8 @@ int ssh_global_request(ssh_session session,
ssh_buffer buffer, ssh_buffer buffer,
int reply); int reply);
#ifdef __cplusplus
}
#endif
#endif /* CHANNELS_H_ */ #endif /* CHANNELS_H_ */

View File

@@ -26,6 +26,10 @@
#ifndef CONFIG_PARSER_H_ #ifndef CONFIG_PARSER_H_
#define CONFIG_PARSER_H_ #define CONFIG_PARSER_H_
#ifdef __cplusplus
extern "C" {
#endif
char *ssh_config_get_cmd(char **str); char *ssh_config_get_cmd(char **str);
char *ssh_config_get_token(char **str); char *ssh_config_get_token(char **str);
@@ -54,4 +58,8 @@ int ssh_config_parse_uri(const char *tok,
char **hostname, char **hostname,
char **port); char **port);
#ifdef __cplusplus
}
#endif
#endif /* LIBSSH_CONFIG_H_ */ #endif /* LIBSSH_CONFIG_H_ */

View File

@@ -216,6 +216,10 @@ struct ssh_cipher_struct {
void (*cleanup)(struct ssh_cipher_struct *cipher); void (*cleanup)(struct ssh_cipher_struct *cipher);
}; };
#ifdef __cplusplus
extern "C" {
#endif
const struct ssh_cipher_struct *ssh_get_chacha20poly1305_cipher(void); const struct ssh_cipher_struct *ssh_get_chacha20poly1305_cipher(void);
int sshkdf_derive_key(struct ssh_crypto_struct *crypto, int sshkdf_derive_key(struct ssh_crypto_struct *crypto,
unsigned char *key, size_t key_len, unsigned char *key, size_t key_len,
@@ -227,4 +231,8 @@ int secure_memcmp(const void *s1, const void *s2, size_t n);
ENGINE *pki_get_engine(void); ENGINE *pki_get_engine(void);
#endif /* HAVE_LIBCRYPTO */ #endif /* HAVE_LIBCRYPTO */
#ifdef __cplusplus
}
#endif
#endif /* _CRYPTO_H_ */ #endif /* _CRYPTO_H_ */

View File

@@ -33,6 +33,10 @@
#define crypto_scalarmult crypto_scalarmult_curve25519 #define crypto_scalarmult crypto_scalarmult_curve25519
#else #else
#ifdef __cplusplus
extern "C" {
#endif
#define CURVE25519_PUBKEY_SIZE 32 #define CURVE25519_PUBKEY_SIZE 32
#define CURVE25519_PRIVKEY_SIZE 32 #define CURVE25519_PRIVKEY_SIZE 32
int crypto_scalarmult_base(unsigned char *q, const unsigned char *n); int crypto_scalarmult_base(unsigned char *q, const unsigned char *n);
@@ -53,4 +57,8 @@ int ssh_client_curve25519_init(ssh_session session);
void ssh_server_curve25519_init(ssh_session session); void ssh_server_curve25519_init(ssh_session session);
#endif /* WITH_SERVER */ #endif /* WITH_SERVER */
#ifdef __cplusplus
}
#endif
#endif /* CURVE25519_H_ */ #endif /* CURVE25519_H_ */

View File

@@ -23,10 +23,18 @@
#ifndef SRC_DH_GEX_H_ #ifndef SRC_DH_GEX_H_
#define SRC_DH_GEX_H_ #define SRC_DH_GEX_H_
#ifdef __cplusplus
extern "C" {
#endif
int ssh_client_dhgex_init(ssh_session session); int ssh_client_dhgex_init(ssh_session session);
#ifdef WITH_SERVER #ifdef WITH_SERVER
void ssh_server_dhgex_init(ssh_session session); void ssh_server_dhgex_init(ssh_session session);
#endif /* WITH_SERVER */ #endif /* WITH_SERVER */
#ifdef __cplusplus
}
#endif
#endif /* SRC_DH_GEX_H_ */ #endif /* SRC_DH_GEX_H_ */

View File

@@ -30,6 +30,10 @@ struct dh_ctx;
#define DH_CLIENT_KEYPAIR 0 #define DH_CLIENT_KEYPAIR 0
#define DH_SERVER_KEYPAIR 1 #define DH_SERVER_KEYPAIR 1
#ifdef __cplusplus
extern "C" {
#endif
/* functions implemented by crypto backends */ /* functions implemented by crypto backends */
int ssh_dh_init_common(struct ssh_crypto_struct *crypto); int ssh_dh_init_common(struct ssh_crypto_struct *crypto);
void ssh_dh_cleanup(struct ssh_crypto_struct *crypto); void ssh_dh_cleanup(struct ssh_crypto_struct *crypto);
@@ -82,4 +86,8 @@ int ssh_server_dh_process_init(ssh_session session, ssh_buffer packet);
int ssh_fallback_group(uint32_t pmax, bignum *p, bignum *g); int ssh_fallback_group(uint32_t pmax, bignum *p, bignum *g);
bool ssh_dh_is_known_group(bignum modulus, bignum generator); bool ssh_dh_is_known_group(bignum modulus, bignum generator);
#ifdef __cplusplus
}
#endif
#endif /* DH_H_ */ #endif /* DH_H_ */

View File

@@ -42,6 +42,10 @@
#define HAVE_ECDH 1 #define HAVE_ECDH 1
#endif #endif
#ifdef __cplusplus
extern "C" {
#endif
extern struct ssh_packet_callbacks_struct ssh_ecdh_client_callbacks; extern struct ssh_packet_callbacks_struct ssh_ecdh_client_callbacks;
/* Backend-specific functions. */ /* Backend-specific functions. */
int ssh_client_ecdh_init(ssh_session session); int ssh_client_ecdh_init(ssh_session session);
@@ -53,4 +57,8 @@ void ssh_server_ecdh_init(ssh_session session);
SSH_PACKET_CALLBACK(ssh_packet_server_ecdh_init); SSH_PACKET_CALLBACK(ssh_packet_server_ecdh_init);
#endif /* WITH_SERVER */ #endif /* WITH_SERVER */
#ifdef __cplusplus
}
#endif
#endif /* ECDH_H_ */ #endif /* ECDH_H_ */

View File

@@ -37,6 +37,10 @@ typedef uint8_t ed25519_pubkey[ED25519_PK_LEN];
typedef uint8_t ed25519_privkey[ED25519_SK_LEN]; typedef uint8_t ed25519_privkey[ED25519_SK_LEN];
typedef uint8_t ed25519_signature[ED25519_SIG_LEN]; typedef uint8_t ed25519_signature[ED25519_SIG_LEN];
#ifdef __cplusplus
extern "C" {
#endif
/** @internal /** @internal
* @brief generate an ed25519 key pair * @brief generate an ed25519 key pair
* @param[out] pk generated public key * @param[out] pk generated public key
@@ -76,4 +80,8 @@ int crypto_sign_ed25519_open(
const ed25519_pubkey pk); const ed25519_pubkey pk);
/** @} */ /** @} */
#ifdef __cplusplus
}
#endif
#endif /* ED25519_H_ */ #endif /* ED25519_H_ */

View File

@@ -33,6 +33,10 @@ typedef struct {
uint32_t v[32]; uint32_t v[32];
} fe25519; } fe25519;
#ifdef __cplusplus
extern "C" {
#endif
void fe25519_freeze(fe25519 *r); void fe25519_freeze(fe25519 *r);
void fe25519_unpack(fe25519 *r, const unsigned char x[32]); void fe25519_unpack(fe25519 *r, const unsigned char x[32]);
@@ -65,4 +69,8 @@ void fe25519_invert(fe25519 *r, const fe25519 *x);
void fe25519_pow2523(fe25519 *r, const fe25519 *x); void fe25519_pow2523(fe25519 *r, const fe25519 *x);
#ifdef __cplusplus
}
#endif
#endif #endif

View File

@@ -28,6 +28,10 @@ typedef struct
fe25519 t; fe25519 t;
} ge25519; } ge25519;
#ifdef __cplusplus
extern "C" {
#endif
extern const ge25519 ge25519_base; extern const ge25519 ge25519_base;
int ge25519_unpackneg_vartime(ge25519 *r, const unsigned char p[32]); int ge25519_unpackneg_vartime(ge25519 *r, const unsigned char p[32]);
@@ -40,4 +44,8 @@ void ge25519_double_scalarmult_vartime(ge25519 *r, const ge25519 *p1, const sc25
void ge25519_scalarmult_base(ge25519 *r, const sc25519 *s); void ge25519_scalarmult_base(ge25519 *r, const sc25519 *s);
#ifdef __cplusplus
}
#endif
#endif #endif

View File

@@ -29,6 +29,10 @@
typedef struct ssh_gssapi_struct *ssh_gssapi; typedef struct ssh_gssapi_struct *ssh_gssapi;
#ifdef __cplusplus
extern "C" {
#endif
#ifdef WITH_SERVER #ifdef WITH_SERVER
int ssh_gssapi_handle_userauth(ssh_session session, const char *user, uint32_t n_oid, ssh_string *oids); int ssh_gssapi_handle_userauth(ssh_session session, const char *user, uint32_t n_oid, ssh_string *oids);
SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_server); SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_server);
@@ -42,4 +46,8 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_response);
int ssh_gssapi_auth_mic(ssh_session session); int ssh_gssapi_auth_mic(ssh_session session);
#ifdef __cplusplus
}
#endif
#endif /* GSSAPI_H */ #endif /* GSSAPI_H */

View File

@@ -31,6 +31,10 @@ struct ssh_kex_struct {
char *methods[SSH_KEX_METHODS]; char *methods[SSH_KEX_METHODS];
}; };
#ifdef __cplusplus
extern "C" {
#endif
SSH_PACKET_CALLBACK(ssh_packet_kexinit); SSH_PACKET_CALLBACK(ssh_packet_kexinit);
int ssh_send_kex(ssh_session session, int server_kex); int ssh_send_kex(ssh_session session, int server_kex);
@@ -56,4 +60,8 @@ int ssh_hashbufin_add_cookie(ssh_session session, unsigned char *cookie);
int ssh_hashbufout_add_cookie(ssh_session session); int ssh_hashbufout_add_cookie(ssh_session session);
int ssh_generate_session_keys(ssh_session session); int ssh_generate_session_keys(ssh_session session);
#ifdef __cplusplus
}
#endif
#endif /* KEX_H_ */ #endif /* KEX_H_ */

View File

@@ -62,9 +62,17 @@ struct ssh_private_key_struct {
#endif #endif
}; };
#ifdef __cplusplus
extern "C" {
#endif
const char *ssh_type_to_char(int type); const char *ssh_type_to_char(int type);
int ssh_type_from_name(const char *name); int ssh_type_from_name(const char *name);
ssh_public_key publickey_from_string(ssh_session session, ssh_string pubkey_s); ssh_public_key publickey_from_string(ssh_session session, ssh_string pubkey_s);
#ifdef __cplusplus
}
#endif
#endif /* KEYS_H_ */ #endif /* KEYS_H_ */

View File

@@ -22,6 +22,10 @@
#ifndef SSH_KNOWNHOSTS_H_ #ifndef SSH_KNOWNHOSTS_H_
#define SSH_KNOWNHOSTS_H_ #define SSH_KNOWNHOSTS_H_
#ifdef __cplusplus
extern "C" {
#endif
struct ssh_list *ssh_known_hosts_get_algorithms(ssh_session session); struct ssh_list *ssh_known_hosts_get_algorithms(ssh_session session);
char *ssh_known_hosts_get_algorithms_names(ssh_session session); char *ssh_known_hosts_get_algorithms_names(ssh_session session);
enum ssh_known_hosts_e enum ssh_known_hosts_e
@@ -29,4 +33,8 @@ ssh_session_get_known_hosts_entry_file(ssh_session session,
const char *filename, const char *filename,
struct ssh_knownhosts_entry **pentry); struct ssh_knownhosts_entry **pentry);
#ifdef __cplusplus
}
#endif
#endif /* SSH_KNOWNHOSTS_H_ */ #endif /* SSH_KNOWNHOSTS_H_ */

View File

@@ -31,6 +31,10 @@
typedef struct ssh_private_key_struct* ssh_private_key; typedef struct ssh_private_key_struct* ssh_private_key;
typedef struct ssh_public_key_struct* ssh_public_key; typedef struct ssh_public_key_struct* ssh_public_key;
#ifdef __cplusplus
extern "C" {
#endif
LIBSSH_API int ssh_auth_list(ssh_session session); LIBSSH_API int ssh_auth_list(ssh_session session);
LIBSSH_API int ssh_userauth_offer_pubkey(ssh_session session, const char *username, int type, ssh_string publickey); LIBSSH_API int ssh_userauth_offer_pubkey(ssh_session session, const char *username, int type, ssh_string publickey);
LIBSSH_API int ssh_userauth_pubkey(ssh_session session, const char *username, ssh_string publickey, ssh_private_key privatekey); LIBSSH_API int ssh_userauth_pubkey(ssh_session session, const char *username, ssh_string publickey, ssh_private_key privatekey);
@@ -117,4 +121,8 @@ SSH_DEPRECATED LIBSSH_API size_t string_len(ssh_string str);
SSH_DEPRECATED LIBSSH_API ssh_string string_new(size_t size); SSH_DEPRECATED LIBSSH_API ssh_string string_new(size_t size);
SSH_DEPRECATED LIBSSH_API char *string_to_char(ssh_string str); SSH_DEPRECATED LIBSSH_API char *string_to_char(ssh_string str);
#ifdef __cplusplus
}
#endif
#endif /* LEGACY_H_ */ #endif /* LEGACY_H_ */

View File

@@ -104,6 +104,10 @@ int ssh_gcry_rand_range(bignum rnd, bignum max);
} while(0) } while(0)
/* Helper functions for data conversions. */ /* Helper functions for data conversions. */
#ifdef __cplusplus
extern "C" {
#endif
/* Extract an MPI from the given s-expression SEXP named NAME which is /* Extract an MPI from the given s-expression SEXP named NAME which is
encoded using INFORMAT and store it in a newly allocated ssh_string encoded using INFORMAT and store it in a newly allocated ssh_string
encoded using OUTFORMAT. */ encoded using OUTFORMAT. */
@@ -114,6 +118,10 @@ ssh_string ssh_sexp_extract_mpi(const gcry_sexp_t sexp,
#define ssh_fips_mode() false #define ssh_fips_mode() false
#ifdef __cplusplus
}
#endif
#endif /* HAVE_LIBGCRYPT */ #endif /* HAVE_LIBGCRYPT */
#endif /* LIBGCRYPT_H_ */ #endif /* LIBGCRYPT_H_ */

View File

@@ -73,6 +73,10 @@ struct mbedtls_ecdsa_sig {
bignum s; bignum s;
}; };
#ifdef __cplusplus
extern "C" {
#endif
bignum ssh_mbedcry_bn_new(void); bignum ssh_mbedcry_bn_new(void);
void ssh_mbedcry_bn_free(bignum num); void ssh_mbedcry_bn_free(bignum num);
unsigned char *ssh_mbedcry_bn2num(const_bignum num, int radix); unsigned char *ssh_mbedcry_bn2num(const_bignum num, int radix);
@@ -136,5 +140,9 @@ ssh_string make_ecpoint_string(const mbedtls_ecp_group *g, const
#define ssh_fips_mode() false #define ssh_fips_mode() false
#ifdef __cplusplus
}
#endif
#endif /* HAVE_LIBMBEDCRYPTO */ #endif /* HAVE_LIBMBEDCRYPTO */
#endif /* LIBMBEDCRYPTO_H_ */ #endif /* LIBMBEDCRYPTO_H_ */

View File

@@ -92,6 +92,10 @@ struct ssh_message_struct {
struct ssh_global_request global_request; struct ssh_global_request global_request;
}; };
#ifdef __cplusplus
extern "C" {
#endif
SSH_PACKET_CALLBACK(ssh_packet_channel_open); SSH_PACKET_CALLBACK(ssh_packet_channel_open);
SSH_PACKET_CALLBACK(ssh_packet_global_request); SSH_PACKET_CALLBACK(ssh_packet_global_request);
@@ -104,4 +108,8 @@ int ssh_message_handle_channel_request(ssh_session session, ssh_channel channel,
const char *request, uint8_t want_reply); const char *request, uint8_t want_reply);
ssh_message ssh_message_pop_head(ssh_session session); ssh_message ssh_message_pop_head(ssh_session session);
#ifdef __cplusplus
}
#endif
#endif /* MESSAGES_H_ */ #endif /* MESSAGES_H_ */

View File

@@ -21,6 +21,10 @@
#ifndef MISC_H_ #ifndef MISC_H_
#define MISC_H_ #define MISC_H_
#ifdef __cplusplus
extern "C" {
#endif
/* in misc.c */ /* in misc.c */
/* gets the user home dir. */ /* gets the user home dir. */
char *ssh_get_user_home_dir(void); char *ssh_get_user_home_dir(void);
@@ -99,4 +103,8 @@ int ssh_newline_vis(const char *string, char *buf, size_t buf_len);
int ssh_tmpname(char *template); int ssh_tmpname(char *template);
char *ssh_strreplace(const char *src, const char *pattern, const char *repl); char *ssh_strreplace(const char *src, const char *pattern, const char *repl);
#ifdef __cplusplus
}
#endif
#endif /* MISC_H_ */ #endif /* MISC_H_ */

View File

@@ -21,6 +21,10 @@
#ifndef _OPTIONS_H #ifndef _OPTIONS_H
#define _OPTIONS_H #define _OPTIONS_H
#ifdef __cplusplus
extern "C" {
#endif
int ssh_config_parse_file(ssh_session session, const char *filename); int ssh_config_parse_file(ssh_session session, const char *filename);
int ssh_config_parse_string(ssh_session session, const char *input); int ssh_config_parse_string(ssh_session session, const char *input);
int ssh_options_set_algo(ssh_session session, int ssh_options_set_algo(ssh_session session,
@@ -28,4 +32,8 @@ int ssh_options_set_algo(ssh_session session,
const char *list); const char *list);
int ssh_options_apply(ssh_session session); int ssh_options_apply(ssh_session session);
#ifdef __cplusplus
}
#endif
#endif /* _OPTIONS_H */ #endif /* _OPTIONS_H */

View File

@@ -51,6 +51,10 @@ enum ssh_packet_filter_result_e {
int ssh_packet_send(ssh_session session); int ssh_packet_send(ssh_session session);
#ifdef __cplusplus
extern "C" {
#endif
SSH_PACKET_CALLBACK(ssh_packet_unimplemented); SSH_PACKET_CALLBACK(ssh_packet_unimplemented);
SSH_PACKET_CALLBACK(ssh_packet_disconnect_callback); SSH_PACKET_CALLBACK(ssh_packet_disconnect_callback);
SSH_PACKET_CALLBACK(ssh_packet_ignore_callback); SSH_PACKET_CALLBACK(ssh_packet_ignore_callback);
@@ -88,4 +92,8 @@ int ssh_packet_set_newkeys(ssh_session session,
struct ssh_crypto_struct *ssh_packet_get_current_crypto(ssh_session session, struct ssh_crypto_struct *ssh_packet_get_current_crypto(ssh_session session,
enum ssh_crypto_direction_e direction); enum ssh_crypto_direction_e direction);
#ifdef __cplusplus
}
#endif
#endif /* PACKET_H_ */ #endif /* PACKET_H_ */

View File

@@ -27,6 +27,10 @@
#ifdef WITH_PCAP #ifdef WITH_PCAP
typedef struct ssh_pcap_context_struct* ssh_pcap_context; typedef struct ssh_pcap_context_struct* ssh_pcap_context;
#ifdef __cplusplus
extern "C" {
#endif
int ssh_pcap_file_write_packet(ssh_pcap_file pcap, ssh_buffer packet, uint32_t original_len); int ssh_pcap_file_write_packet(ssh_pcap_file pcap, ssh_buffer packet, uint32_t original_len);
ssh_pcap_context ssh_pcap_context_new(ssh_session session); ssh_pcap_context ssh_pcap_context_new(ssh_session session);
@@ -41,5 +45,9 @@ int ssh_pcap_context_write(ssh_pcap_context,enum ssh_pcap_direction direction, v
uint32_t len, uint32_t origlen); uint32_t len, uint32_t origlen);
#ifdef __cplusplus
}
#endif
#endif /* WITH_PCAP */ #endif /* WITH_PCAP */
#endif /* PCAP_H_ */ #endif /* PCAP_H_ */

View File

@@ -118,6 +118,10 @@ struct ssh_signature_struct {
typedef struct ssh_signature_struct *ssh_signature; typedef struct ssh_signature_struct *ssh_signature;
#ifdef __cplusplus
extern "C" {
#endif
/* SSH Key Functions */ /* SSH Key Functions */
void ssh_key_clean (ssh_key key); void ssh_key_clean (ssh_key key);
@@ -192,4 +196,8 @@ int ssh_key_size(ssh_key key);
bool ssh_pki_is_uri(const char *filename); bool ssh_pki_is_uri(const char *filename);
char *ssh_pki_export_pub_uri_from_priv_uri(const char *priv_uri); char *ssh_pki_export_pub_uri_from_priv_uri(const char *priv_uri);
#ifdef __cplusplus
}
#endif
#endif /* PKI_H_ */ #endif /* PKI_H_ */

View File

@@ -23,6 +23,10 @@
#include "libssh/pki.h" #include "libssh/pki.h"
#ifdef __cplusplus
extern "C" {
#endif
/* defined in bcrypt_pbkdf.c */ /* defined in bcrypt_pbkdf.c */
int bcrypt_pbkdf(const char *pass, int bcrypt_pbkdf(const char *pass,
size_t passlen, size_t passlen,
@@ -168,4 +172,8 @@ ssh_string ssh_pki_openssh_privkey_export(const ssh_key privkey,
int pki_uri_import(const char *uri_name, ssh_key *key, enum ssh_key_e key_type); int pki_uri_import(const char *uri_name, ssh_key *key, enum ssh_key_e key_type);
bool ssh_key_size_allowed_rsa(int min_size, ssh_key key); bool ssh_key_size_allowed_rsa(int min_size, ssh_key key);
#ifdef __cplusplus
}
#endif
#endif /* PKI_PRIV_H_ */ #endif /* PKI_PRIV_H_ */

View File

@@ -114,6 +114,10 @@ typedef unsigned long int nfds_t;
#endif /* WIN32 */ #endif /* WIN32 */
#endif /* HAVE_POLL */ #endif /* HAVE_POLL */
#ifdef __cplusplus
extern "C" {
#endif
void ssh_poll_init(void); void ssh_poll_init(void);
void ssh_poll_cleanup(void); void ssh_poll_cleanup(void);
int ssh_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout); int ssh_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout);
@@ -158,4 +162,8 @@ ssh_poll_ctx ssh_poll_get_default_ctx(ssh_session session);
int ssh_event_add_poll(ssh_event event, ssh_poll_handle p); int ssh_event_add_poll(ssh_event event, ssh_poll_handle p);
void ssh_event_remove_poll(ssh_event event, ssh_poll_handle p); void ssh_event_remove_poll(ssh_event event, ssh_poll_handle p);
#ifdef __cplusplus
}
#endif
#endif /* POLL_H_ */ #endif /* POLL_H_ */

View File

@@ -7,6 +7,10 @@
#define POLY1305_H #define POLY1305_H
#include "libssh/chacha20-poly1305-common.h" #include "libssh/chacha20-poly1305-common.h"
#ifdef __cplusplus
extern "C" {
#endif
void poly1305_auth(uint8_t out[POLY1305_TAGLEN], const uint8_t *m, size_t inlen, void poly1305_auth(uint8_t out[POLY1305_TAGLEN], const uint8_t *m, size_t inlen,
const uint8_t key[POLY1305_KEYLEN]) const uint8_t key[POLY1305_KEYLEN])
#ifdef HAVE_GCC_BOUNDED_ATTRIBUTE #ifdef HAVE_GCC_BOUNDED_ATTRIBUTE
@@ -16,4 +20,8 @@ void poly1305_auth(uint8_t out[POLY1305_TAGLEN], const uint8_t *m, size_t inlen,
#endif #endif
; ;
#ifdef __cplusplus
}
#endif
#endif /* POLY1305_H */ #endif /* POLY1305_H */

View File

@@ -47,6 +47,10 @@
# endif # endif
#endif /* !defined(HAVE_STRTOULL) */ #endif /* !defined(HAVE_STRTOULL) */
#ifdef __cplusplus
extern "C" {
#endif
#if !defined(HAVE_STRNDUP) #if !defined(HAVE_STRNDUP)
char *strndup(const char *s, size_t n); char *strndup(const char *s, size_t n);
#endif /* ! HAVE_STRNDUP */ #endif /* ! HAVE_STRNDUP */
@@ -434,4 +438,8 @@ bool is_ssh_initialized(void);
#define SSH_ERRNO_MSG_MAX 1024 #define SSH_ERRNO_MSG_MAX 1024
char *ssh_strerror(int err_num, char *buf, size_t buflen); char *ssh_strerror(int err_num, char *buf, size_t buflen);
#ifdef __cplusplus
}
#endif
#endif /* _LIBSSH_PRIV_H */ #endif /* _LIBSSH_PRIV_H */

View File

@@ -35,6 +35,10 @@ typedef struct {
uint32_t v[16]; uint32_t v[16];
} shortsc25519; } shortsc25519;
#ifdef __cplusplus
extern "C" {
#endif
void sc25519_from32bytes(sc25519 *r, const unsigned char x[32]); void sc25519_from32bytes(sc25519 *r, const unsigned char x[32]);
void shortsc25519_from16bytes(shortsc25519 *r, const unsigned char x[16]); void shortsc25519_from16bytes(shortsc25519 *r, const unsigned char x[16]);
@@ -71,4 +75,8 @@ void sc25519_window5(signed char r[51], const sc25519 *s);
void sc25519_2interleave2(unsigned char r[127], const sc25519 *s1, const sc25519 *s2); void sc25519_2interleave2(unsigned char r[127], const sc25519 *s1, const sc25519 *s2);
#ifdef __cplusplus
}
#endif
#endif #endif

View File

@@ -47,9 +47,17 @@ struct ssh_scp_struct {
int request_mode; int request_mode;
}; };
#ifdef __cplusplus
extern "C" {
#endif
int ssh_scp_read_string(ssh_scp scp, char *buffer, size_t len); int ssh_scp_read_string(ssh_scp scp, char *buffer, size_t len);
int ssh_scp_integer_mode(const char *mode); int ssh_scp_integer_mode(const char *mode);
char *ssh_scp_string_mode(int mode); char *ssh_scp_string_mode(int mode);
int ssh_scp_response(ssh_scp scp, char **response); int ssh_scp_response(ssh_scp scp, char **response);
#ifdef __cplusplus
}
#endif
#endif #endif

View File

@@ -21,6 +21,10 @@
#ifndef SFTP_PRIV_H #ifndef SFTP_PRIV_H
#define SFTP_PRIV_H #define SFTP_PRIV_H
#ifdef __cplusplus
extern "C" {
#endif
sftp_packet sftp_packet_read(sftp_session sftp); sftp_packet sftp_packet_read(sftp_session sftp);
int sftp_packet_write(sftp_session sftp, uint8_t type, ssh_buffer payload); int sftp_packet_write(sftp_session sftp, uint8_t type, ssh_buffer payload);
void sftp_packet_free(sftp_packet packet); void sftp_packet_free(sftp_packet packet);
@@ -29,4 +33,8 @@ sftp_attributes sftp_parse_attr(sftp_session session,
ssh_buffer buf, ssh_buffer buf,
int expectname); int expectname);
#ifdef __cplusplus
}
#endif
#endif /* SFTP_PRIV_H */ #endif /* SFTP_PRIV_H */

View File

@@ -22,6 +22,10 @@
#define STRING_H_ #define STRING_H_
#include "libssh/priv.h" #include "libssh/priv.h"
#ifdef __cplusplus
extern "C" {
#endif
/* must be 32 bits number + immediately our data */ /* must be 32 bits number + immediately our data */
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma pack(1) #pragma pack(1)
@@ -38,4 +42,8 @@ __attribute__ ((packed))
#endif #endif
; ;
#ifdef __cplusplus
}
#endif
#endif /* STRING_H_ */ #endif /* STRING_H_ */

View File

@@ -49,6 +49,10 @@
#endif #endif
#ifdef __cplusplus
extern "C" {
#endif
int ssh_threads_init(void); int ssh_threads_init(void);
void ssh_threads_finalize(void); void ssh_threads_finalize(void);
const char *ssh_threads_get_type(void); const char *ssh_threads_get_type(void);
@@ -60,4 +64,8 @@ struct ssh_threads_callbacks_struct *ssh_threads_get_default(void);
int crypto_thread_init(struct ssh_threads_callbacks_struct *user_callbacks); int crypto_thread_init(struct ssh_threads_callbacks_struct *user_callbacks);
void crypto_thread_finalize(void); void crypto_thread_finalize(void);
#ifdef __cplusplus
}
#endif
#endif /* THREADS_H_ */ #endif /* THREADS_H_ */

View File

@@ -31,6 +31,10 @@ struct ssh_tokens_st {
char **tokens; char **tokens;
}; };
#ifdef __cplusplus
extern "C" {
#endif
struct ssh_tokens_st *ssh_tokenize(const char *chain, char separator); struct ssh_tokens_st *ssh_tokenize(const char *chain, char separator);
void ssh_tokens_free(struct ssh_tokens_st *tokens); void ssh_tokens_free(struct ssh_tokens_st *tokens);
@@ -45,4 +49,8 @@ char *ssh_remove_duplicates(const char *list);
char *ssh_append_without_duplicates(const char *list, char *ssh_append_without_duplicates(const char *list,
const char *appended_list); const char *appended_list);
#ifdef __cplusplus
}
#endif
#endif /* TOKEN_H_ */ #endif /* TOKEN_H_ */

View File

@@ -29,6 +29,10 @@
#include "libssh/libgcrypt.h" #include "libssh/libgcrypt.h"
#include "libssh/libmbedcrypto.h" #include "libssh/libmbedcrypto.h"
#ifdef __cplusplus
extern "C" {
#endif
enum ssh_kdf_digest { enum ssh_kdf_digest {
SSH_KDF_SHA1=1, SSH_KDF_SHA1=1,
SSH_KDF_SHA256, SSH_KDF_SHA256,
@@ -127,4 +131,8 @@ int evp_dup_rsa_pkey(const ssh_key key, ssh_key new, int demote);
int evp_dup_ecdsa_pkey(const ssh_key key, ssh_key new, int demote); int evp_dup_ecdsa_pkey(const ssh_key key, ssh_key new, int demote);
#endif /* HAVE_LIBCRYPTO && OPENSSL_VERSION_NUMBER */ #endif /* HAVE_LIBCRYPTO && OPENSSL_VERSION_NUMBER */
#ifdef __cplusplus
}
#endif
#endif /* WRAPPER_H_ */ #endif /* WRAPPER_H_ */