1
1

3305 Коммитов

Автор SHA1 Сообщение Дата
Andreas Schneider
e051135a05 connect: Check that errno is 0 to fix Windows build.
Thanks to Viktor Butskih.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2014-12-25 12:34:59 +01:00
Andreas Schneider
bb18442fe8 options: Fix setting the port.
Make sure we correctly read the port from the config file.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2014-12-25 12:32:16 +01:00
Jon Simons
c2aed4ca78 CVE-2014-8132: Fixup error path in ssh_packet_kexinit()
Before this change, dangling pointers can be unintentionally left in the
respective next_crypto kex methods slots.  Ensure to set all slots to
NULL in the error-out path.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-12-17 19:45:09 +01:00
Andreas Schneider
b7b535816d libcrypto: Fix Windows build with ssh_reseed().
gettimeofday() is not available on Windows and we need it only in case
of forking.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2014-12-17 19:39:18 +01:00
Andreas Schneider
d8e691b58a cmake: Fix config variable names.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2014-12-17 10:38:56 +01:00
William Orr
52968b1a11 config: Also tokenize on equal sign.
The ssh config specifies it as a valid separator.

BUG: https://red.libssh.org/issues/166

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-12-17 10:34:27 +01:00
Jon Simons
b35f1f488c pki_gcrypt: fix DSA signature extraction
Fix DSA signature extraction for the LIBGCRYPT build.  Here, the same fix
that was applied to the LIBCRYPTO build for https://red.libssh.org/issues/144
is now adapted for pki_gcrypt.  Additionally, ensure to set the resulting
output sig_blob buffer before returning.

Before this fix, one can observe the failure with the pkd test on a LIBGCRYPT
build as so:

  # ./pkd_hello -i 1 -t torture_pkd_openssh_dsa_dsa_default

After, runs of 10000 back-to-back iterations of the same test are passing.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-12-09 19:21:47 +01:00
Jon Simons
10f71c6769 pki_gcrypt: fix warnings for SSH_KEYTYPE_ED25519
Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-12-09 19:21:34 +01:00
Jon Simons
014fde0542 torture: fix warning for SSH_KEYTYPE_ED25519
Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-12-09 19:21:18 +01:00
Jon Simons
ca2acec34a bignum: no-op make_string_bn_inplace for LIBGCRYPT
Disable the 'make_string_bn_inplace' helper function for the LIBGCRYPT
build, rather than using '#error' to fail the build completely.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-12-09 19:20:46 +01:00
Davide \"FunkyAss\" Del Zompo
bb197de75d doc: clarify tutorial error section
Signed-off-by: Davide "FunkyAss" Del Zompo <davide.delzompo@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-12-05 11:09:00 +01:00
Hani Benhabiles
03095f1516 Set the correct error in ssh_options_set().
Signed-off-by: Hani Benhabiles <hani@linux.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-12-05 11:03:55 +01:00
Jon Simons
6895d0b727 session: add getter for kexalgo
Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-12-05 10:48:07 +01:00
Jon Simons
4745d652b5 pki_crypto.c: plug ecdsa_sig->[r,s] bignum leaks
Per ecdsa(3ssl), ECDSA_SIG_new does allocate its 'r' and 's' bignum fields.
Fix a bug where the initial 'r' and 's' bignums were being overwritten with
newly-allocated bignums, resulting in a memory leak.

BUG: https://red.libssh.org/issues/175

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-12-05 10:42:32 +01:00
Andreas Schneider
a48711ae7e connect: Do not fail if the connect is in progress.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2014-10-15 10:27:55 +02:00
Jon Simons
a25790d343 tests: fix pkd build breakages
Fix a build breakage when '-DWITH_SERVER=OFF' is set: skip building the
pkd test for that case.  Add some missing includes for the OpenIndiana
and FreeBSD builds.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-10-15 10:26:24 +02:00
Stef Walter
cd2dc3770a gssapi: ssh_gssapi_set_creds() is a client side function
It should not be guarded by the WITH_SERVER #ifdef

Signed-off-by: Stef Walter <stefw@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-10-12 15:41:15 +02:00
William Orr
250f506487 Check return code of connect(2).
Signed-off-by: William Orr <will@worrbase.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-10-12 15:39:58 +02:00
Jon Simons
9dc932c02b tests: introduce pkd_hello
Introduce a sample public-key testing daemon to the 'pkd' test directory,
and add support code for cycling through various combinations of different
key exchange, cipher, and MAC algorithms.

The goal of the 'pkd_hello' test is to make it easy to test interactions
between non-libssh clients and a libssh-server, and to provide a starting
point for testing new implementations for key types, ciphers, MACs, and
so on.  The thinking is that testing a new algorithm should be as simple
as adding a new line for it in the PKDTESTS_* lists.

Macros are used to generate the tests and helper functions for a couple of
clients -- here, OpenSSH and dropbear are included for the first cut.  If
binaries are found for these clients, their test lists will be enabled;
when binaries are not found for a given client, those tests are skipped.

Tests are run in one large batch by default, but can also be run individually
to help with tracking down things like signature bugs that may take many
iterations to reproduce.

Each test logs its stdout and stderr to its own file, which is cleaned up
when a test succeeds.  For failures, those logs can be combined with verbose
libssh output from pkd itself to start debugging things.

Some example usages:

  pkd_hello
    Run all tests with default number of iterations.

  pkd_hello --list
    List available individual test names.

  pkd_hello -i 1000 -t torture_pkd_openssh_ecdsa_256_ecdh_sha2_nistp256
    Run only the torture_pkd_openssh_ecdsa_256_ecdh_sha2_nistp256
    testcase 1000 times.

  pkd_hello -v -v -v -v -e -o
    Run all tests with maximum libssh and pkd logging.

Included in the tests are passes for all existing kex, cipher, and MAC
algorithms.

BUG: https://red.libssh.org/issues/144

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-10-12 15:01:02 +02:00
Artyom V. Poptsov
aaae6cd97d pki_gcrypt: Initialize 'type_c' in 'pki_do_sign_sessionid'
Add missing initialization of 'type_c' field of a SSH signature in
'pki_do_sign_sessionid' procedure.

If libssh is compiled with GCrypt, 'dh_handshake_server' fails with
"Could not sign the session id" error.  The change fixes that.

Signed-off-by: Artyom V. Poptsov <poptsov.artyom@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-10-02 08:30:17 +02:00
Jon Simons
509676e3a4 server: fix auth_interactive_request reply
Fix a missing 'buffer_pack' formatter in 'ssh_message_auth_interactive_request'.
With this fix the 'examples/samplesshd-kbdint' program is working again for me.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-10-02 08:29:22 +02:00
Jon Simons
a6d412f0d7 ed25519: fix leak in pki_ed25519_sign
Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-10-02 08:28:51 +02:00
Jon Simons
59da8dab50 pki: check ssh_buffer_pack return in ssh_pki_do_sign
Check the 'ssh_buffer_pack' return in ssh_pki_do_sign for the ED25519 case.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-10-02 08:28:05 +02:00
Jon Simons
7edbedf0dd pki: fail when pubkey buffer length is not ED25519_PK_LEN
Fail fast in 'pki_import_pubkey_buffer' for the ED25519 case if a buffer
sized ED25519_PK_LEN can not be retrieved.  Before, the 'memcpy' could
have read beyond the bounds of 'ssh_string_data(pubkey)'.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-10-02 08:27:05 +02:00
Jon Simons
af25c5e668 crypto: check malloc return in ssh_mac_ctx_init
Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-10-02 08:25:53 +02:00
Jon Simons
092fe0b727 wrapper: fix z_stream leak
Ensure to free the z_stream structures as allocated from
the gzip.c initcompress, initdecompress functions.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-10-02 08:25:10 +02:00
Andreas Schneider
1ddb99c46f string: Correctly burn the string buffer.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-09-15 20:45:47 +02:00
Aris
93c7b81b4e ed25519: Generate, sign and verify keys.
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-09-07 22:07:34 +02:00
Aris Adamantiadis
93e82fa0c0 crypto: Add ed25519 implementation from OpenSSH.
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-09-07 21:35:20 +02:00
Aris Adamantiadis
e9b2d164e0 base64: Use a secure buffer.
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-09-07 10:38:23 +02:00
Aris Adamantiadis
86ae6b2251 buffer: Add a secure buffer mechanism to avoid memory spills
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-09-07 10:36:32 +02:00
Aris Adamantiadis
2cb2587b55 buffer: Implement "t" for text in ssh_buffer_pack().
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-09-07 10:27:35 +02:00
Andreas Schneider
86294ad3ea dh: Fix packing a pointer into the buffer.
Thanks to Giovanni Panozzo <giovanni@panozzo.it>.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2014-08-25 12:23:17 +02:00
Andreas Schneider
173994786b tests: Fix writing the '\0'.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2014-08-18 21:41:36 +02:00
Andreas Schneider
81123d6a91 ec: Fix build on CentOS.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2014-08-18 10:08:00 +02:00
Andreas Schneider
25eb9c4914 tests: Use public testkey passphrase function in pki test.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-08-15 12:32:57 +02:00
Andreas Schneider
c6210f5aef torture: Add public testkey passphrase function.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-08-15 12:32:54 +02:00
Andreas Schneider
c673543e54 tests: Use public testkeys in pki test.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-08-15 12:32:51 +02:00
Andreas Schneider
edca9d6e96 torture: Add public testkey functions.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-08-15 12:32:47 +02:00
Andreas Schneider
83aed7610c tests: Make write file a public torture function.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-08-15 12:32:37 +02:00
Andreas Schneider
5fa4721c6e auth: Fix a memory leak in agent publickey auth.
CID: 1230358

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-08-15 12:29:26 +02:00
Andreas Schneider
8b7627efd5 tests: Make sure we null terminate the buffer.
CID: 1230359

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-08-15 12:29:23 +02:00
Andreas Schneider
662217f409 packet: Check return value of ssh_buffer_unpack().
CID: 1230357

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-08-15 12:29:20 +02:00
Andreas Schneider
19433dca00 messages: Check return value of ssh_buffer_unpack().
CID: 1230356

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-08-15 12:29:16 +02:00
Andreas Schneider
6961dd79ad tests: Fix memory leak in buffer test.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-08-15 12:29:13 +02:00
Andreas Schneider
1b6375ce89 buffer: Make sure rc is initialized.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-08-15 12:29:11 +02:00
Andreas Schneider
64f6abead7 libgcrypt: Fix initializer name.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-08-15 12:29:07 +02:00
Andreas Schneider
f20a6d0a82 bignum: Add missing include.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-08-15 12:29:00 +02:00
Andreas Schneider
97c6b76863 messages: Fix two ssh_buffer_unpack().
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-08-07 17:28:42 +02:00
Aris Adamantiadis
6019cf1bed Fix sftp endianess bugs
Reviewed-by: Andreas Schneider <asn@samba.org>
2014-08-06 10:08:25 +02:00