Andreas Schneider
cff7882391
log: Add missing config.h include
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-06 12:39:45 +01:00
Andreas Schneider
5d1a8cd88b
cmake: Check for io.h on Windows
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-06 11:57:52 +01:00
Andreas Schneider
528b9c5323
cmake: Correctly check for sys/[u]time.h
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-06 11:52:12 +01:00
Andreas Schneider
293ab4bd40
doc: Improve documentation for ssh_set_auth_methods()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-06 11:29:02 +01:00
Andreas Schneider
a45db022e9
bcrypt: Fix type of shalen
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-06 11:18:55 +01:00
Andreas Schneider
02be4802d5
pki_ed25519: Do paranoia checks before we allocate memory
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-06 11:15:23 +01:00
Andreas Schneider
5437deed1b
callbacks: Add support for MSVC
...
__typeof__ is GCC specific
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-05 20:00:02 +01:00
Andreas Schneider
422271bd40
connector: Fix build with Visual Studio
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-05 18:03:34 +01:00
Andreas Schneider
801bc29494
options: Fix log level documentation
...
BUG: https://red.libssh.org/issues/210
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-05 17:15:31 +01:00
Stef Walter
857ce2376e
known_hosts: Add ssh_dump_knownhost() function
...
This works similarly to ssh_write_knownhost(), but allows the caller
to get a line with the known_hosts line.
BUG: https://red.libssh.org/issues/207
Signed-off-by: Stef Walter <stefw@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-05 17:12:07 +01:00
Andreas Schneider
2af88a679d
bignum: Use const in ssh_print_bignum()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-03 15:22:47 +01:00
Justus Winter
e3a866b8c1
ecdh: Implement ECDH using libgcrypt
...
* include/libssh/crypto.h (struct ssh_crypto_struct): Provide a
suitable 'ecdh_privkey'.
* include/libssh/ecdh.h: Also define 'HAVE_ECDH' if we do ECC using
libgcrypt.
(ecdh_build_k): New prototype.
* src/CMakeLists.txt (libssh_SRCS): Add backend-specific files.
* src/ecdh.c: Move backend-specific parts to...
* src/ecdh_crypto.c: ... this file.
* src/ecdh_gcrypt.c: New file.
* src/wrapper.c (crypto_free): Free 'ecdh_privkey'.
Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-03 15:20:36 +01:00
Justus Winter
f62cded9f0
pki_gcrypt: Handle ECDSA keys and signatures
...
* ConfigureChecks.cmake: Set 'HAVE_ECC' and 'HAVE_GCRYPT_ECC' if
applicable.
* include/libssh/pki.h (struct ssh_key_struct): Fix type of field
'ecdsa'.
(struct ssh_signature_struct): Likewise for 'ecdsa_sig'.
* src/pki.c (ssh_pki_key_ecdsa_name): Relax guard now that the used
function is also provided by the gcrypt backend.
(ssh_signature_free): Free ecdsa signature.
* src/pki_gcrypt.c (ECDSA_HEADER_{BEGIN,END}): New macros.
(privatekey_string_to_buffer): Handle ECDSA keys.
(pki_key_ecdsa_to_nid): New function.
(pki_key_ecdsa_nid_to_gcrypt_name): Likewise.
(pki_key_ecdsa_nid_to_name): Likewise.
(pki_key_ecdsa_nid_to_char): Likewise.
(pki_key_ecdsa_nid_from_name): Implement.
(asn1_oi_to_nid): New function.
(b64decode_ecdsa_privatekey): Likewise.
(pki_private_key_from_base64): Handle ECDSA keys.
(pki_pubkey_build_ecdsa): Implement.
(pki_key_dup): Handle ECDSA keys.
(pki_key_generate): Likewise.
(pki_key_generate_ecdsa): Implement.
(pki_key_compare): Handle ECDSA keys.
(pki_publickey_to_blob): Likewise.
(pki_signature_from_blob): Likewise.
(pki_signature_verify): Likewise.
(pki_do_sign): Likewise.
(pki_do_sign_sessionid): Likewise.
Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-03 15:20:30 +01:00
Justus Winter
7e315629b9
libgcrypt: Implement the 'evp' interface
...
* include/libssh/libgcrypt.h (EVPCTX): Fix type.
(NID_gcrypt_nistp{256,384,521}): New constants.
* src/libgcrypt.c (nid_to_md_algo): New function mapping curves to
digest algorithms.
(evp{,_init,_update,_final}): New functions.
Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-03 15:20:26 +01:00
Justus Winter
3c2ea78a09
pki_gcrypt: Add a little more ASN1 infrastructure
...
* src/pki_gcrypt.c (ASN1_OCTET_STRING): New macro.
(ASN1_OBJECT_IDENTIFIER): Likewise.
(asn1_check_tag): New function.
Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-03 15:19:34 +01:00
Justus Winter
85bcfab719
curve25519: Small libgcrypt bignum fix
...
* src/curve25519.c (ssh_client_curve25519_init): Make use of the
gcrypt-variant of 'bignum_bin2bn'.
Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-02 18:53:59 +01:00
Pino Toscano
67ffe26dea
Remove extra newlines from log/error messages
...
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-10-22 16:05:32 +02:00
Pino Toscano
bc78383fac
sftp: Fix memory leak in sftp_fstat
...
When parsing the result of a successful fstat call, make sure to free
the resulting reply message.
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-10-22 16:03:33 +02:00
Tilo Eckert
4f392ebc7e
session: Add missing ifdef that prevented Windows builds
...
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-10-08 10:54:36 +02:00
Tilo Eckert
1cc1a352fc
sftp: Add support for append in sftp_open()
...
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
2016-10-08 10:50:38 +02:00
Tilo Eckert
cfe7065ce1
sftp: Do not always set SSH_FXF_READ
...
Comparison ((flags & O_RDONLY) == O_RDONLY) is always true.
Also, O_RDWR, O_WRONLY and O_RDONLY are mutually exclusive => no need to check all of them
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
2016-10-08 10:45:30 +02:00
Andreas Schneider
f561e6bcb3
sftp: Correctly check for EOF else keep spinning if there is no data
...
This fixes an issue introduced with
dbf72ffba2ad5b5694cd55aa1a7ca99053d20386
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-10-07 13:36:58 +02:00
Andreas Schneider
83421c0e8c
gssapi: Use correct return code in ssh_gssapi_auth_mic()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-10-06 18:36:54 +02:00
Andreas Schneider
095733ed9c
gssapi: Print minor stat in error logging function
...
This also releases the memory allocated for the messages.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-10-06 18:22:26 +02:00
Andreas Schneider
155a155d1d
sftp: Add sftp_fsync() function
...
BUG: https://red.libssh.org/issues/141
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-10-06 16:26:52 +02:00
Jeremy Cross
dbf72ffba2
sftp: ensure sftp_packet_read recognizes channel EOF to avoid infinite loop
...
Signed-off-by: Jeremy Cross <jcross@bomgar.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-09-09 11:39:32 +02:00
Andreas Schneider
47d21b6420
sftpserver: Fix SSH_FXP_FSTAT arguments
...
Thanks to Игорь Коваленко <igor.a.kovalenko@gmail.com>
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-10 10:15:05 +02:00
Andreas Schneider
412c501442
sftp: Use calloc() instead of malloc()/memset()
...
This is calloc() is faster then calling memset().
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-04 14:56:22 +02:00
Andreas Schneider
5c70dd8b85
config: Fix build warnings
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-04 14:38:48 +02:00
Travers Carter
bc2db86d1c
Make "Host" pattern list handling consistent with OpenSSH
...
https://red.libssh.org/issues/187
Signed-off-by: Travers Carter <tcarter@noggin.com.au>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-03 17:57:12 +02:00
Andreas Schneider
1da5c94b44
client: If SSHv1 is disabled send the banner immediately
...
This saves a round-trip with SSHv2 connecting to the server. See RFC
4253 section 5.2 (New Client, Old Server).
Thanks to Yang Yubo <yang@yangyubo.com> for the suggestion.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-03 09:41:26 +02:00
Andreas Schneider
3d1edffe77
client: Fix ssh_send_banner() to confirm with RFC 4253
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-03 09:41:26 +02:00
Andreas Schneider
cb52ed7b12
client: Fix maximum banner length
...
According to RFC 4253 the max banner length is 255.
Thanks to Saju Panikulam <spanikulam@ipswitch.com> for the report.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-03 09:41:26 +02:00
Andreas Schneider
22799b107d
client: Reformat callback_receive_banner()
...
The function is hard to read as the indentation is not correctly
applied.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-03 09:41:26 +02:00
Ken Reister
c3ce3d5cc3
client: Receive the banner correctly
...
Comply with RFC 4253 compliance section 4.2.
Allow data other than "SSH-" to be sent across prior to the actual
version striong.
Signed-off-by: Ken Reister <reister.kenneth@CIMCOR.COM>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-03 09:41:26 +02:00
Aris Adamantiadis
32eea120af
sockets: Fix callback registration bug
...
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 17:34:09 +02:00
Aris Adamantiadis
8e42d3959c
packet: Improve logging output
...
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 17:27:16 +02:00
Aris Adamantiadis
9b3648ded0
connector: Implement ssh_connector_except()
...
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 16:58:47 +02:00
Aris Adamantiadis
0701745cbc
channels: Move ssh_channel_write_stderr out of server-only
...
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 16:57:13 +02:00
Aris Adamantiadis
bbe437dbb1
callbacks: Implement list of callbacks for channels
...
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 16:56:54 +02:00
Aris Adamantiadis
80d88dd3d9
packets: Handle flow control callbacks
...
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 16:55:46 +02:00
Aris Adamantiadis
5aaae4cb6b
events: Add functions for poll objects
...
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 16:40:43 +02:00
Kohei Suzuki
c092101e01
Add id_ed25519 to the default identity list
...
Signed-off-by: Kohei Suzuki <eagletmt@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 15:34:01 +02:00
David Kedves
d7df4429eb
channels: Bugfix for a possible invalid pointer usage (channel->session) in various places
...
BUG: https://red.libssh.org/issues/230
Signed-off-by: David Kedves <kedazo@severalnines.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 15:31:46 +02:00
Stef Walter
ffe8b98cc2
auth: Cleanup memory leak when using SSH agent
...
In Cockpit we've seen this memory leak:
at 0x4C2A9C7: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x5B76B03: ssh_userauth_agent (auth.c:778)
by 0x40DD5A: cockpit_ssh_authenticate (cockpitsshtransport.c:327)
BUG: https://red.libssh.org/issues/208
Signed-off-by: Stef Walter <stefw@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 15:28:24 +02:00
Andreas Schneider
33ecaaac01
auth1: Fix non-blocking SSHv1 auth
...
BUG: https://red.libssh.org/issues/232
Thanks to Fengyu Gao.
TODO: Add SSHv1 tests to our testsuite.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 12:19:00 +02:00
Justus Winter
3c69092cde
pki_gcrypt: Add primitive to read ASN.1 bit strings
...
* src/pki_gcrypt.c (ASN1_BIT_STRING): New macro.
(asn1_get_bit_string): New function.
Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 12:07:07 +02:00
Justus Winter
92fdf31d29
pki: Fix debug message
...
* src/pki.c (ssh_pki_signature_verify_blob): Fix debug message.
Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 11:55:39 +02:00
Justus Winter
878a650c7a
dh: Print hexadecimal data to stderr
...
* src/dh.c (ssh_print_hexa): Print to stderr.
Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 11:55:38 +02:00
Justus Winter
e518ec1cb7
pki_gcrypt: Rework 'pki_export_pubkey_rsa1'
...
* src/pki_gcrypt.c (pki_export_pubkey_rsa1): Rework to be more
idiomatic. Fix leaking MPIs.
Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 11:55:38 +02:00