From d1947b55ec8516b661b4ec92b0d4b6b12e23ea47 Mon Sep 17 00:00:00 2001 From: Norbert Pocs Date: Mon, 24 Oct 2022 12:50:46 +0200 Subject: [PATCH] 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 Reviewed-by: Jakub Jelen --- include/libssh/agent.h | 8 ++++++++ include/libssh/auth.h | 8 ++++++++ include/libssh/bignum.h | 7 +++++++ include/libssh/bind.h | 7 +++++++ include/libssh/bind_config.h | 8 ++++++++ include/libssh/blf.h | 9 +++++++++ include/libssh/buffer.h | 8 ++++++++ include/libssh/chacha.h | 8 ++++++++ include/libssh/channels.h | 8 ++++++++ include/libssh/config_parser.h | 8 ++++++++ include/libssh/crypto.h | 8 ++++++++ include/libssh/curve25519.h | 8 ++++++++ include/libssh/dh-gex.h | 8 ++++++++ include/libssh/dh.h | 8 ++++++++ include/libssh/ecdh.h | 8 ++++++++ include/libssh/ed25519.h | 8 ++++++++ include/libssh/fe25519.h | 8 ++++++++ include/libssh/ge25519.h | 8 ++++++++ include/libssh/gssapi.h | 8 ++++++++ include/libssh/kex.h | 8 ++++++++ include/libssh/keys.h | 8 ++++++++ include/libssh/knownhosts.h | 8 ++++++++ include/libssh/legacy.h | 8 ++++++++ include/libssh/libgcrypt.h | 8 ++++++++ include/libssh/libmbedcrypto.h | 8 ++++++++ include/libssh/messages.h | 8 ++++++++ include/libssh/misc.h | 8 ++++++++ include/libssh/options.h | 8 ++++++++ include/libssh/packet.h | 8 ++++++++ include/libssh/pcap.h | 8 ++++++++ include/libssh/pki.h | 8 ++++++++ include/libssh/pki_priv.h | 8 ++++++++ include/libssh/poll.h | 8 ++++++++ include/libssh/poly1305.h | 8 ++++++++ include/libssh/priv.h | 8 ++++++++ include/libssh/sc25519.h | 8 ++++++++ include/libssh/scp.h | 8 ++++++++ include/libssh/sftp_priv.h | 8 ++++++++ include/libssh/string.h | 8 ++++++++ include/libssh/threads.h | 8 ++++++++ include/libssh/token.h | 8 ++++++++ include/libssh/wrapper.h | 8 ++++++++ 42 files changed, 335 insertions(+) diff --git a/include/libssh/agent.h b/include/libssh/agent.h index 72052159..caf8d3e2 100644 --- a/include/libssh/agent.h +++ b/include/libssh/agent.h @@ -70,6 +70,10 @@ #define SSH_AGENT_RSA_SHA2_256 0x02 #define SSH_AGENT_RSA_SHA2_512 0x04 +#ifdef __cplusplus +extern "C" { +#endif + struct ssh_agent_struct { struct ssh_socket_struct *sock; ssh_buffer ident; @@ -115,4 +119,8 @@ ssh_string ssh_agent_sign_data(ssh_session session, const ssh_key pubkey, struct ssh_buffer_struct *data); +#ifdef __cplusplus +} +#endif + #endif /* __AGENT_H */ diff --git a/include/libssh/auth.h b/include/libssh/auth.h index 90b377d4..b358b7a2 100644 --- a/include/libssh/auth.h +++ b/include/libssh/auth.h @@ -23,6 +23,10 @@ #include "config.h" #include "libssh/callbacks.h" +#ifdef __cplusplus +extern "C" { +#endif + SSH_PACKET_CALLBACK(ssh_packet_userauth_banner); SSH_PACKET_CALLBACK(ssh_packet_userauth_failure); SSH_PACKET_CALLBACK(ssh_packet_userauth_success); @@ -100,4 +104,8 @@ enum ssh_auth_service_state_e { SSH_AUTH_SERVICE_DENIED, }; +#ifdef __cplusplus +} +#endif + #endif /* AUTH_H_ */ diff --git a/include/libssh/bignum.h b/include/libssh/bignum.h index 726ed7b9..6b5dc1a2 100644 --- a/include/libssh/bignum.h +++ b/include/libssh/bignum.h @@ -25,9 +25,16 @@ #include "libssh/libgcrypt.h" #include "libssh/libmbedcrypto.h" +#ifdef __cplusplus +extern "C" { +#endif + bignum ssh_make_string_bn(ssh_string string); ssh_string ssh_make_bignum_string(bignum num); void ssh_print_bignum(const char *which, const_bignum num); +#ifdef __cplusplus +} +#endif #endif /* BIGNUM_H_ */ diff --git a/include/libssh/bind.h b/include/libssh/bind.h index c0439d2c..56f97f27 100644 --- a/include/libssh/bind.h +++ b/include/libssh/bind.h @@ -25,6 +25,10 @@ #include "libssh/kex.h" #include "libssh/session.h" +#ifdef __cplusplus +extern "C" { +#endif + struct ssh_bind_struct { struct ssh_common_struct common; /* stuff common to ssh_bind and ssh_session */ 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 *sshbind); +#ifdef __cplusplus +} +#endif #endif /* BIND_H_ */ diff --git a/include/libssh/bind_config.h b/include/libssh/bind_config.h index 7ee19b87..5f2dccce 100644 --- a/include/libssh/bind_config.h +++ b/include/libssh/bind_config.h @@ -28,6 +28,10 @@ #include "libssh/server.h" +#ifdef __cplusplus +extern "C" { +#endif + enum ssh_bind_config_opcode_e { /* Known but not allowed in Match block */ 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); +#ifdef __cplusplus +} +#endif + #endif /* BIND_CONFIG_H_ */ diff --git a/include/libssh/blf.h b/include/libssh/blf.h index ce131e6b..201821a2 100644 --- a/include/libssh/blf.h +++ b/include/libssh/blf.h @@ -49,6 +49,10 @@ #define BLF_MAXKEYLEN ((BLF_N-2)*4) /* 448 bits */ #define BLF_MAXUTILIZED ((BLF_N+2)*4) /* 576 bits */ +#ifdef __cplusplus +extern "C" { +#endif + /* Blowfish context */ typedef struct BlowfishContext { 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 *); #endif /* !defined(HAVE_BCRYPT_PBKDF) && !defined(HAVE_BLH_H) */ + +#ifdef __cplusplus +} +#endif + #endif /* _BLF_H */ diff --git a/include/libssh/buffer.h b/include/libssh/buffer.h index a55a1b40..1fce7b76 100644 --- a/include/libssh/buffer.h +++ b/include/libssh/buffer.h @@ -27,6 +27,10 @@ #define SSH_BUFFER_PACK_END ((uint32_t) 0x4f65feb3) +#ifdef __cplusplus +extern "C" { +#endif + void ssh_buffer_set_secure(ssh_buffer buffer); int ssh_buffer_add_ssh_string(ssh_buffer buffer, ssh_string string); 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(ssh_buffer buffer, uint32_t len); +#ifdef __cplusplus +} +#endif + #endif /* BUFFER_H_ */ diff --git a/include/libssh/chacha.h b/include/libssh/chacha.h index 867f532d..ab3fe492 100644 --- a/include/libssh/chacha.h +++ b/include/libssh/chacha.h @@ -18,6 +18,10 @@ struct chacha_ctx { #define CHACHA_CTRLEN 8 #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) #ifdef HAVE_GCC_BOUNDED_ATTRIBUTE __attribute__((__bounded__(__minbytes__, 2, CHACHA_MINKEYLEN))) @@ -37,4 +41,8 @@ void chacha_encrypt_bytes(struct chacha_ctx *x, const uint8_t *m, #endif ; +#ifdef __cplusplus +} +#endif + #endif /* CHACHA_H */ diff --git a/include/libssh/channels.h b/include/libssh/channels.h index ef93441d..cb2bea43 100644 --- a/include/libssh/channels.h +++ b/include/libssh/channels.h @@ -22,6 +22,10 @@ #define CHANNELS_H_ #include "libssh/priv.h" +#ifdef __cplusplus +extern "C" { +#endif + /** @internal * Describes the different possible states in a * outgoing (client) channel request @@ -109,4 +113,8 @@ int ssh_global_request(ssh_session session, ssh_buffer buffer, int reply); +#ifdef __cplusplus +} +#endif + #endif /* CHANNELS_H_ */ diff --git a/include/libssh/config_parser.h b/include/libssh/config_parser.h index e974917c..a7dd42a2 100644 --- a/include/libssh/config_parser.h +++ b/include/libssh/config_parser.h @@ -26,6 +26,10 @@ #ifndef CONFIG_PARSER_H_ #define CONFIG_PARSER_H_ +#ifdef __cplusplus +extern "C" { +#endif + char *ssh_config_get_cmd(char **str); char *ssh_config_get_token(char **str); @@ -54,4 +58,8 @@ int ssh_config_parse_uri(const char *tok, char **hostname, char **port); +#ifdef __cplusplus +} +#endif + #endif /* LIBSSH_CONFIG_H_ */ diff --git a/include/libssh/crypto.h b/include/libssh/crypto.h index 1d73613b..3dba18d0 100644 --- a/include/libssh/crypto.h +++ b/include/libssh/crypto.h @@ -216,6 +216,10 @@ struct ssh_cipher_struct { void (*cleanup)(struct ssh_cipher_struct *cipher); }; +#ifdef __cplusplus +extern "C" { +#endif + const struct ssh_cipher_struct *ssh_get_chacha20poly1305_cipher(void); int sshkdf_derive_key(struct ssh_crypto_struct *crypto, 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); #endif /* HAVE_LIBCRYPTO */ +#ifdef __cplusplus +} +#endif + #endif /* _CRYPTO_H_ */ diff --git a/include/libssh/curve25519.h b/include/libssh/curve25519.h index f0cc6348..8c89267c 100644 --- a/include/libssh/curve25519.h +++ b/include/libssh/curve25519.h @@ -33,6 +33,10 @@ #define crypto_scalarmult crypto_scalarmult_curve25519 #else +#ifdef __cplusplus +extern "C" { +#endif + #define CURVE25519_PUBKEY_SIZE 32 #define CURVE25519_PRIVKEY_SIZE 32 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); #endif /* WITH_SERVER */ +#ifdef __cplusplus +} +#endif + #endif /* CURVE25519_H_ */ diff --git a/include/libssh/dh-gex.h b/include/libssh/dh-gex.h index 4fc23d82..d12f9b8f 100644 --- a/include/libssh/dh-gex.h +++ b/include/libssh/dh-gex.h @@ -23,10 +23,18 @@ #ifndef SRC_DH_GEX_H_ #define SRC_DH_GEX_H_ +#ifdef __cplusplus +extern "C" { +#endif + int ssh_client_dhgex_init(ssh_session session); #ifdef WITH_SERVER void ssh_server_dhgex_init(ssh_session session); #endif /* WITH_SERVER */ +#ifdef __cplusplus +} +#endif + #endif /* SRC_DH_GEX_H_ */ diff --git a/include/libssh/dh.h b/include/libssh/dh.h index 353dc233..4d6a0e37 100644 --- a/include/libssh/dh.h +++ b/include/libssh/dh.h @@ -30,6 +30,10 @@ struct dh_ctx; #define DH_CLIENT_KEYPAIR 0 #define DH_SERVER_KEYPAIR 1 +#ifdef __cplusplus +extern "C" { +#endif + /* functions implemented by crypto backends */ int ssh_dh_init_common(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); bool ssh_dh_is_known_group(bignum modulus, bignum generator); +#ifdef __cplusplus +} +#endif + #endif /* DH_H_ */ diff --git a/include/libssh/ecdh.h b/include/libssh/ecdh.h index 17fe02e7..e6907c0b 100644 --- a/include/libssh/ecdh.h +++ b/include/libssh/ecdh.h @@ -42,6 +42,10 @@ #define HAVE_ECDH 1 #endif +#ifdef __cplusplus +extern "C" { +#endif + extern struct ssh_packet_callbacks_struct ssh_ecdh_client_callbacks; /* Backend-specific functions. */ 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); #endif /* WITH_SERVER */ +#ifdef __cplusplus +} +#endif + #endif /* ECDH_H_ */ diff --git a/include/libssh/ed25519.h b/include/libssh/ed25519.h index 8a3263c8..de95b31b 100644 --- a/include/libssh/ed25519.h +++ b/include/libssh/ed25519.h @@ -37,6 +37,10 @@ typedef uint8_t ed25519_pubkey[ED25519_PK_LEN]; typedef uint8_t ed25519_privkey[ED25519_SK_LEN]; typedef uint8_t ed25519_signature[ED25519_SIG_LEN]; +#ifdef __cplusplus +extern "C" { +#endif + /** @internal * @brief generate an ed25519 key pair * @param[out] pk generated public key @@ -76,4 +80,8 @@ int crypto_sign_ed25519_open( const ed25519_pubkey pk); /** @} */ +#ifdef __cplusplus +} +#endif + #endif /* ED25519_H_ */ diff --git a/include/libssh/fe25519.h b/include/libssh/fe25519.h index 438d85db..0dfb0613 100644 --- a/include/libssh/fe25519.h +++ b/include/libssh/fe25519.h @@ -33,6 +33,10 @@ typedef struct { uint32_t v[32]; } fe25519; +#ifdef __cplusplus +extern "C" { +#endif + void fe25519_freeze(fe25519 *r); 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); +#ifdef __cplusplus +} +#endif + #endif diff --git a/include/libssh/ge25519.h b/include/libssh/ge25519.h index 329bd042..480f29dc 100644 --- a/include/libssh/ge25519.h +++ b/include/libssh/ge25519.h @@ -28,6 +28,10 @@ typedef struct fe25519 t; } ge25519; +#ifdef __cplusplus +extern "C" { +#endif + extern const ge25519 ge25519_base; 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); +#ifdef __cplusplus +} +#endif + #endif diff --git a/include/libssh/gssapi.h b/include/libssh/gssapi.h index ccd83664..b0c74c73 100644 --- a/include/libssh/gssapi.h +++ b/include/libssh/gssapi.h @@ -29,6 +29,10 @@ typedef struct ssh_gssapi_struct *ssh_gssapi; +#ifdef __cplusplus +extern "C" { +#endif + #ifdef WITH_SERVER 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); @@ -42,4 +46,8 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_response); int ssh_gssapi_auth_mic(ssh_session session); +#ifdef __cplusplus +} +#endif + #endif /* GSSAPI_H */ diff --git a/include/libssh/kex.h b/include/libssh/kex.h index 3a1f4a6f..6e0d886e 100644 --- a/include/libssh/kex.h +++ b/include/libssh/kex.h @@ -31,6 +31,10 @@ struct ssh_kex_struct { char *methods[SSH_KEX_METHODS]; }; +#ifdef __cplusplus +extern "C" { +#endif + SSH_PACKET_CALLBACK(ssh_packet_kexinit); 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_generate_session_keys(ssh_session session); +#ifdef __cplusplus +} +#endif + #endif /* KEX_H_ */ diff --git a/include/libssh/keys.h b/include/libssh/keys.h index 934189c2..615f1eae 100644 --- a/include/libssh/keys.h +++ b/include/libssh/keys.h @@ -62,9 +62,17 @@ struct ssh_private_key_struct { #endif }; +#ifdef __cplusplus +extern "C" { +#endif + const char *ssh_type_to_char(int type); int ssh_type_from_name(const char *name); ssh_public_key publickey_from_string(ssh_session session, ssh_string pubkey_s); +#ifdef __cplusplus +} +#endif + #endif /* KEYS_H_ */ diff --git a/include/libssh/knownhosts.h b/include/libssh/knownhosts.h index 44e434c0..b50018cd 100644 --- a/include/libssh/knownhosts.h +++ b/include/libssh/knownhosts.h @@ -22,6 +22,10 @@ #ifndef SSH_KNOWNHOSTS_H_ #define SSH_KNOWNHOSTS_H_ +#ifdef __cplusplus +extern "C" { +#endif + struct ssh_list *ssh_known_hosts_get_algorithms(ssh_session session); char *ssh_known_hosts_get_algorithms_names(ssh_session session); enum ssh_known_hosts_e @@ -29,4 +33,8 @@ ssh_session_get_known_hosts_entry_file(ssh_session session, const char *filename, struct ssh_knownhosts_entry **pentry); +#ifdef __cplusplus +} +#endif + #endif /* SSH_KNOWNHOSTS_H_ */ diff --git a/include/libssh/legacy.h b/include/libssh/legacy.h index c0b50e24..38bef4da 100644 --- a/include/libssh/legacy.h +++ b/include/libssh/legacy.h @@ -31,6 +31,10 @@ typedef struct ssh_private_key_struct* ssh_private_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_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); @@ -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 char *string_to_char(ssh_string str); +#ifdef __cplusplus +} +#endif + #endif /* LEGACY_H_ */ diff --git a/include/libssh/libgcrypt.h b/include/libssh/libgcrypt.h index 347d851b..e4087fd2 100644 --- a/include/libssh/libgcrypt.h +++ b/include/libssh/libgcrypt.h @@ -104,6 +104,10 @@ int ssh_gcry_rand_range(bignum rnd, bignum max); } while(0) /* Helper functions for data conversions. */ +#ifdef __cplusplus +extern "C" { +#endif + /* 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 OUTFORMAT. */ @@ -114,6 +118,10 @@ ssh_string ssh_sexp_extract_mpi(const gcry_sexp_t sexp, #define ssh_fips_mode() false +#ifdef __cplusplus +} +#endif + #endif /* HAVE_LIBGCRYPT */ #endif /* LIBGCRYPT_H_ */ diff --git a/include/libssh/libmbedcrypto.h b/include/libssh/libmbedcrypto.h index fe53019b..e6fc393c 100644 --- a/include/libssh/libmbedcrypto.h +++ b/include/libssh/libmbedcrypto.h @@ -73,6 +73,10 @@ struct mbedtls_ecdsa_sig { bignum s; }; +#ifdef __cplusplus +extern "C" { +#endif + bignum ssh_mbedcry_bn_new(void); void ssh_mbedcry_bn_free(bignum num); 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 +#ifdef __cplusplus +} +#endif + #endif /* HAVE_LIBMBEDCRYPTO */ #endif /* LIBMBEDCRYPTO_H_ */ diff --git a/include/libssh/messages.h b/include/libssh/messages.h index 1341d708..160306cc 100644 --- a/include/libssh/messages.h +++ b/include/libssh/messages.h @@ -92,6 +92,10 @@ struct ssh_message_struct { struct ssh_global_request global_request; }; +#ifdef __cplusplus +extern "C" { +#endif + SSH_PACKET_CALLBACK(ssh_packet_channel_open); 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); ssh_message ssh_message_pop_head(ssh_session session); +#ifdef __cplusplus +} +#endif + #endif /* MESSAGES_H_ */ diff --git a/include/libssh/misc.h b/include/libssh/misc.h index 569e2b7d..ee9e73c9 100644 --- a/include/libssh/misc.h +++ b/include/libssh/misc.h @@ -21,6 +21,10 @@ #ifndef MISC_H_ #define MISC_H_ +#ifdef __cplusplus +extern "C" { +#endif + /* in misc.c */ /* gets the user home dir. */ 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); char *ssh_strreplace(const char *src, const char *pattern, const char *repl); +#ifdef __cplusplus +} +#endif + #endif /* MISC_H_ */ diff --git a/include/libssh/options.h b/include/libssh/options.h index e8dc6c69..35b3ffba 100644 --- a/include/libssh/options.h +++ b/include/libssh/options.h @@ -21,6 +21,10 @@ #ifndef _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_string(ssh_session session, const char *input); int ssh_options_set_algo(ssh_session session, @@ -28,4 +32,8 @@ int ssh_options_set_algo(ssh_session session, const char *list); int ssh_options_apply(ssh_session session); +#ifdef __cplusplus +} +#endif + #endif /* _OPTIONS_H */ diff --git a/include/libssh/packet.h b/include/libssh/packet.h index dec3a439..7f10a709 100644 --- a/include/libssh/packet.h +++ b/include/libssh/packet.h @@ -51,6 +51,10 @@ enum ssh_packet_filter_result_e { int ssh_packet_send(ssh_session session); +#ifdef __cplusplus +extern "C" { +#endif + SSH_PACKET_CALLBACK(ssh_packet_unimplemented); SSH_PACKET_CALLBACK(ssh_packet_disconnect_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, enum ssh_crypto_direction_e direction); +#ifdef __cplusplus +} +#endif + #endif /* PACKET_H_ */ diff --git a/include/libssh/pcap.h b/include/libssh/pcap.h index 2e43ae87..2a6c3c27 100644 --- a/include/libssh/pcap.h +++ b/include/libssh/pcap.h @@ -27,6 +27,10 @@ #ifdef WITH_PCAP 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); 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); +#ifdef __cplusplus +} +#endif + #endif /* WITH_PCAP */ #endif /* PCAP_H_ */ diff --git a/include/libssh/pki.h b/include/libssh/pki.h index 27bcca71..50d18776 100644 --- a/include/libssh/pki.h +++ b/include/libssh/pki.h @@ -118,6 +118,10 @@ struct ssh_signature_struct { typedef struct ssh_signature_struct *ssh_signature; +#ifdef __cplusplus +extern "C" { +#endif + /* SSH Key Functions */ 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); char *ssh_pki_export_pub_uri_from_priv_uri(const char *priv_uri); +#ifdef __cplusplus +} +#endif + #endif /* PKI_H_ */ diff --git a/include/libssh/pki_priv.h b/include/libssh/pki_priv.h index c0edb851..854dbad3 100644 --- a/include/libssh/pki_priv.h +++ b/include/libssh/pki_priv.h @@ -23,6 +23,10 @@ #include "libssh/pki.h" +#ifdef __cplusplus +extern "C" { +#endif + /* defined in bcrypt_pbkdf.c */ int bcrypt_pbkdf(const char *pass, 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); bool ssh_key_size_allowed_rsa(int min_size, ssh_key key); +#ifdef __cplusplus +} +#endif + #endif /* PKI_PRIV_H_ */ diff --git a/include/libssh/poll.h b/include/libssh/poll.h index 3aa9a49b..8e30676e 100644 --- a/include/libssh/poll.h +++ b/include/libssh/poll.h @@ -114,6 +114,10 @@ typedef unsigned long int nfds_t; #endif /* WIN32 */ #endif /* HAVE_POLL */ +#ifdef __cplusplus +extern "C" { +#endif + void ssh_poll_init(void); void ssh_poll_cleanup(void); 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); void ssh_event_remove_poll(ssh_event event, ssh_poll_handle p); +#ifdef __cplusplus +} +#endif + #endif /* POLL_H_ */ diff --git a/include/libssh/poly1305.h b/include/libssh/poly1305.h index 513f1b99..a22fea87 100644 --- a/include/libssh/poly1305.h +++ b/include/libssh/poly1305.h @@ -7,6 +7,10 @@ #define POLY1305_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, const uint8_t key[POLY1305_KEYLEN]) #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 ; +#ifdef __cplusplus +} +#endif + #endif /* POLY1305_H */ diff --git a/include/libssh/priv.h b/include/libssh/priv.h index bab761b0..47af57f4 100644 --- a/include/libssh/priv.h +++ b/include/libssh/priv.h @@ -47,6 +47,10 @@ # endif #endif /* !defined(HAVE_STRTOULL) */ +#ifdef __cplusplus +extern "C" { +#endif + #if !defined(HAVE_STRNDUP) char *strndup(const char *s, size_t n); #endif /* ! HAVE_STRNDUP */ @@ -434,4 +438,8 @@ bool is_ssh_initialized(void); #define SSH_ERRNO_MSG_MAX 1024 char *ssh_strerror(int err_num, char *buf, size_t buflen); +#ifdef __cplusplus +} +#endif + #endif /* _LIBSSH_PRIV_H */ diff --git a/include/libssh/sc25519.h b/include/libssh/sc25519.h index 5a2c1b85..43b09a05 100644 --- a/include/libssh/sc25519.h +++ b/include/libssh/sc25519.h @@ -35,6 +35,10 @@ typedef struct { uint32_t v[16]; } shortsc25519; +#ifdef __cplusplus +extern "C" { +#endif + void sc25519_from32bytes(sc25519 *r, const unsigned char x[32]); 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); +#ifdef __cplusplus +} +#endif + #endif diff --git a/include/libssh/scp.h b/include/libssh/scp.h index d356d89b..089fcfc9 100644 --- a/include/libssh/scp.h +++ b/include/libssh/scp.h @@ -47,9 +47,17 @@ struct ssh_scp_struct { int request_mode; }; +#ifdef __cplusplus +extern "C" { +#endif + int ssh_scp_read_string(ssh_scp scp, char *buffer, size_t len); int ssh_scp_integer_mode(const char *mode); char *ssh_scp_string_mode(int mode); int ssh_scp_response(ssh_scp scp, char **response); +#ifdef __cplusplus +} +#endif + #endif diff --git a/include/libssh/sftp_priv.h b/include/libssh/sftp_priv.h index ccde008a..005bf85f 100644 --- a/include/libssh/sftp_priv.h +++ b/include/libssh/sftp_priv.h @@ -21,6 +21,10 @@ #ifndef SFTP_PRIV_H #define SFTP_PRIV_H +#ifdef __cplusplus +extern "C" { +#endif + sftp_packet sftp_packet_read(sftp_session sftp); int sftp_packet_write(sftp_session sftp, uint8_t type, ssh_buffer payload); void sftp_packet_free(sftp_packet packet); @@ -29,4 +33,8 @@ sftp_attributes sftp_parse_attr(sftp_session session, ssh_buffer buf, int expectname); +#ifdef __cplusplus +} +#endif + #endif /* SFTP_PRIV_H */ diff --git a/include/libssh/string.h b/include/libssh/string.h index 8c7db1df..35b2ea2e 100644 --- a/include/libssh/string.h +++ b/include/libssh/string.h @@ -22,6 +22,10 @@ #define STRING_H_ #include "libssh/priv.h" +#ifdef __cplusplus +extern "C" { +#endif + /* must be 32 bits number + immediately our data */ #ifdef _MSC_VER #pragma pack(1) @@ -38,4 +42,8 @@ __attribute__ ((packed)) #endif ; +#ifdef __cplusplus +} +#endif + #endif /* STRING_H_ */ diff --git a/include/libssh/threads.h b/include/libssh/threads.h index 522f91d5..47340d17 100644 --- a/include/libssh/threads.h +++ b/include/libssh/threads.h @@ -49,6 +49,10 @@ #endif +#ifdef __cplusplus +extern "C" { +#endif + int ssh_threads_init(void); void ssh_threads_finalize(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); void crypto_thread_finalize(void); +#ifdef __cplusplus +} +#endif + #endif /* THREADS_H_ */ diff --git a/include/libssh/token.h b/include/libssh/token.h index 9896fb06..2cd7b20f 100644 --- a/include/libssh/token.h +++ b/include/libssh/token.h @@ -31,6 +31,10 @@ struct ssh_tokens_st { char **tokens; }; +#ifdef __cplusplus +extern "C" { +#endif + struct ssh_tokens_st *ssh_tokenize(const char *chain, char separator); 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, const char *appended_list); +#ifdef __cplusplus +} +#endif + #endif /* TOKEN_H_ */ diff --git a/include/libssh/wrapper.h b/include/libssh/wrapper.h index f4a33d2d..9fef1d29 100644 --- a/include/libssh/wrapper.h +++ b/include/libssh/wrapper.h @@ -29,6 +29,10 @@ #include "libssh/libgcrypt.h" #include "libssh/libmbedcrypto.h" +#ifdef __cplusplus +extern "C" { +#endif + enum ssh_kdf_digest { SSH_KDF_SHA1=1, 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); #endif /* HAVE_LIBCRYPTO && OPENSSL_VERSION_NUMBER */ +#ifdef __cplusplus +} +#endif + #endif /* WRAPPER_H_ */