summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
* session: fix comment typoLuka Perkov2014-03-271-1/+1
| | | | | | Signed-off-by: Luka Perkov <luka.perkov@sartura.hr> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> (cherry picked from commit 8ba94022824dadfec2b6650324a06106abaeac13)
* messages: use predefined macro for clearing sensitive dataLuka Perkov2014-03-271-2/+1
| | | | | | Signed-off-by: Luka Perkov <luka.perkov@sartura.hr> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> (cherry picked from commit a2fe341da558d27c348d55b1fbf9824f42ff2432)
* client: fix corner case when sockets are manually createdLuka Perkov2014-03-271-1/+4
| | | | | | | | | | | If the sockets are created manually and passed to libssh the internal session state is set to SSH_SESSION_STATE_SOCKET_CONNECTED. Result of this fix can be verified by running torture_connect test (torture_connect_socket) with -vvvv flags. Signed-off-by: Luka Perkov <luka.perkov@sartura.hr> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> (cherry picked from commit dbb2de272b57c7327204adb7b7bdef5c98bfbfd6)
* pki_crypto: Replace deprecated RSA_generate_key() with RSA_generate_key_ex()Petar Koretic2014-03-271-4/+14
| | | | | | | | | | | | | | | | | | On Mar 16, 09:41, Aris Adamantiadis wrote: > Hi Petar, > I agree with the principle, but I don't think this code can work... > RSA_generate_key takes an RSA* as parameter and in our code we probably > have key->rsa==NULL. (if we don't then the old code had a memory leak). > > Does the test case work ? > > Aris > Yes, you are right. This works, tested with tests/unittests/torture_pki Signed-off-by: Petar Koretic <petar.koretic@sartura.hr> (cherry picked from commit 0b8d24f800bae5f4f86c0eaca41c609f40d7baef)
* doc: Add ECDSA keys to docs, make key docs consistentAlan Dunn2014-03-271-1/+4
| | | | | | Signed-off-by: Alan Dunn <amdunn@gmail.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> (cherry picked from commit f6276fe73940dd35bbd4f95d3cf902bcf69f23f3)
* options: Allow use of host ECDSA keyAlan Dunn2014-03-271-23/+31
| | | | | | Signed-off-by: Alan Dunn <amdunn@gmail.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> (cherry picked from commit 2a1089d6079c14da8d24c996402e24a689a9f5d3)
* pki_crypto: Always copy ecdsa_nid into duplicated ECDSA keysAlan Dunn2014-03-121-2/+2
| | | | | | BUG: https://red.libssh.org/issues/147 Signed-off-by: Alan Dunn <amdunn@gmail.com>
* pki: Use SHA-2 for session ID signing with ECDSA keysAlan Dunn2014-03-121-12/+42
| | | | | | | | | Previously, SHA-1 was used always. BUG: https://red.libssh.org/issues/148 Signed-off-by: Alan Dunn <amdunn@gmail.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
* server: silence build warningLuka Perkov2014-03-121-0/+1
| | | | | | | | | | | | | | | The commit fixes this build warning: ==== src/server.c:223:8: warning: ‘privkey’ may be used uninitialized in this function [-Wmaybe-uninitialized] rc = ssh_pki_export_privkey_to_pubkey(*privkey, &pubkey); ^ src/server.c:243:11: note: ‘privkey’ was declared here ssh_key privkey; ==== Signed-off-by: Luka Perkov <luka.perkov@sartura.hr> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
* packet: log disconnect code in host byte orderJon Simons2014-03-121-13/+19
| | | | Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
* bind: only set bindfd after successful listenJon Simons2014-03-121-1/+2
| | | | | | | | In 'ssh_bind_listen', move setting of 'sshbind->bindfd' to only happen after the listen call: otherwise 'bindfd' can be set to a bogus descriptor for the case that listen fails. Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
* security: fix for vulnerability CVE-2014-0017Aris Adamantiadis2014-03-043-0/+14
| | | | | | | | | | When accepting a new connection, a forking server based on libssh forks and the child process handles the request. The RAND_bytes() function of openssl doesn't reset its state after the fork, but simply adds the current process id (getpid) to the PRNG state, which is not guaranteed to be unique. This can cause several children to end up with same PRNG state which is a security issue.
* pki: Fix the build on OpenSolaris.Andreas Schneider2014-02-121-1/+1
|
* pki: Fix memory leak with ecdsa signatures.Andreas Schneider2014-02-111-0/+4
|
* packet: Improve readablity of packet decrypt.Andreas Schneider2014-02-061-6/+7
| | | | | | | After discussion with Aris and it was not obvious enough to understand the issue we decided to refactor it. Reviewd-by: Aris Adamantiadis <aris@0xbadc0de.be>
* packet_crypt: Make packet_{en,de}crypt fail consistently on len == 0Alan Dunn2014-02-061-0/+6
| | | | | | | | | | Right now the behavior of packet_{en,de}crypt on len == 0 depends on the behavior of malloc. Instead, make these consistently fail based on what I assume the desired behavior is due to the first error message in each. Signed-off-by: Alan Dunn <amdunn@gmail.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
* packet: Do not decrypt zero length rest of bufferAlan Dunn2014-02-062-13/+25
| | | | | | | | | | | | | | | | | | | | | | | If we receive a packet of length exactly blocksize, then packet_decrypt gets called on a buffer of size 0. The check at the beginning of packet_decrypt indicates that the function should be called on buffers of at least one blocksize, though the check allows through zero length. As is packet_decrypt can return -1 when len is 0 because malloc can return NULL in this case: according to the ISO C standard, malloc is free to return NULL or a pointer that can be freed when size == 0, and uclibc by default will return NULL here (in "non-glibc-compatible" mode). The net result is that when using uclibc connections with libssh can anomalously fail. Alternatively, packet_decrypt (and probably packet_encrypt for consistency) could be made to always succeed on len == 0 without depending on the behavior of malloc. Thanks to Josh Berlin for bringing conneciton failures with uclibc to my attention. Signed-off-by: Alan Dunn <amdunn@gmail.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
* build: Use Threads_FOUND to decide whether to build ssh_threads.Raphael Kubo da Costa2014-02-061-2/+2
| | | | | | | | | | | | | | | | Follow-up to 4e04ec8, which caused a regression on OS X. Checking the value of CMAKE_THREAD_LIBS_INIT to decide whether any threading library is present on a system turns out to be wrong -- in OS X, for example, usage of pthreads does not depend on any additional linker or compiler flags, so CMAKE_THREAD_LIBS_INIT is empty and our check in src/CMakeLists.txt failed (it used to work before 4e04ec8 because CMAKE_HAVE_THREADS_LIBRARY is set). Instead, just look for Threads_FOUND, which FindThreads sets just like any other Find module when it has found what it was looking for. Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
* session: skip timestamp init for non-blocking caseJon Simons2014-02-061-1/+5
| | | | Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
* session: add getters for session cipher namesJon Simons2014-02-061-0/+32
| | | | Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
* Revert f2c2687ca6c6c7e25c9a547227027ab28eb4fc16Aris Adamantiadis2014-02-051-1/+1
| | | | | Fix bug #142 The mode does need to be an octal numeric string. Mode 0600 now gets sent on the wire as 0384, triggering a "scp: protocol error: bad mode" response, and an "scp status code 1d not valid" message from libssh.
* knownhosts: resolve leaks found by coverityAris Adamantiadis2014-02-052-9/+8
|
* knownhosts: detect variations of ecdsaAris Adamantiadis2014-02-052-32/+80
|
* Kex: fix coverity warning + edge caseAris Adamantiadis2014-02-041-4/+8
|
* server: use custom server bannersAudrius Butkevicius2014-02-041-2/+2
| | | | | | Value of session->serverbanner never gets used Signed-off-by: Audrius Butkevicius <audrius.butkevicius@gmail.com>
* server: allow custom server banners (bug #83)Aris Adamantiadis2014-02-042-2/+11
|
* Knownhosts: implement hostkey with knownhosts heuristicAris Adamantiadis2014-02-041-1/+24
|
* known_hosts: add ssh_knownhosts_algorithms()Aris Adamantiadis2014-02-041-0/+77
| | | | | | | | Goal of that function is to test the preferred key exchange methods based on what's available in the known_hosts file Conflicts: tests/client/torture_knownhosts.c
* threads: Be less strict when deciding whether to build libssh_threads.Raphael Kubo da Costa2014-02-031-2/+2
| | | | | | | | | | | | | | | | | As mentioned in the previous commit, there are cases where CMAKE_HAVE_THREADS_LIBRARY is not set and pthreads _is_ being used: one can pass -DTHREADS_HAVE_PTHREAD_ARG=1 to CMake directly so that it just passes -pthread to the compiler/linker and does not set CMAKE_HAVE_THREADS_LIBRARY. Since we are only interested in knowing whether any threading library has been found, we should use CMAKE_THREAD_LIBS_INIT instead (Threads_FOUND would also work). Note that, at the moment, there is only a pthreads backend available in threads/, so if it is not found configuration will fail because CMake will try to create a library from an empty set of source files. Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
* socket: fix read of non-connected socketJon Simons2014-02-021-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ensure to check whether the socket at hand is indeed still connected throughout POLLIN processing in ssh_socket_pollcallback. Before this change, the POLLIN block in ssh_socket_pollcallback is predicated against the condition (s->state == SSH_SOCKET_CONNECTED). Once entered, data from the socket is consumed through the data callback in this loop: do { r = s->callbacks->data(buffer_get_rest(s->in_buffer), buffer_get_rest_len(s->in_buffer), s->callbacks->userdata); buffer_pass_bytes(s->in_buffer,r); } while (r > 0); However, it is possible for the socket data callback to change the state of the socket (closing it, for example). Fix the loop to only continue so long as the socket remains connected: this also entails setting the ssh_socket state to SSH_SOCKET_CLOSED upon close. The bug can be observed before the change by sending a bogus banner to the server: 'echo -e "A\r\nB\r\n" | nc localhost 22'. Each of 'A' and 'B' will be processed by 'callback_receive_banner', even though the client socket is closed after rejection of 'A'. Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
* doc: correct ssh_channel_read_timeout unitsJon Simons2014-02-021-6/+6
| | | | Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
* src: Fix argument order in ssh_channel_pty_window_change_callbackAudrius Butkevicius2014-02-021-2/+2
| | | | | | | So that it would match ssh_channel_pty_request_callback as well as the documentation Signed-off-by: Audrius Butkevicius <audrius.butkevicius@gmail.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
* src: Define MAX_BUF_SIZE globally and use it.Joseph Southwell2014-02-024-5/+4
| | | | Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
* client: Fix EOF session error reporting.Joseph Southwell2014-02-022-3/+9
| | | | Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
* Make function ssh_channel_accept() nonblocking if timeout is 0.Oleksandr Shneyder2014-02-021-1/+5
| | | | Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
* pki_crypto: Fix memory leak with EC_KEY_set_public_key().Andreas Schneider2014-01-281-1/+3
| | | | BUG: https://red.libssh.org/issues/146
* doc: Document the unit for ssh_select() timeout.Andreas Schneider2014-01-231-1/+1
| | | | BUG: https://red.libssh.org/issues/143
* dh: Fix NULL check for p_group14.Rod Vagg2014-01-231-1/+1
| | | | Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
* pki_crypto: fix DSA signature extractionJon Simons2014-01-231-26/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | Fix the DSA portion of 'pki_signature_to_blob': before this change, it is possible to sometimes observe DSA signature validation failure when testing with OpenSSH clients. The problem ended up being the following snippet which did not account for the case when 'ssh_string_len(x)' may be less than 20: r = make_bignum_string(sig->dsa_sig->r); ... memcpy(buffer, ((char *) ssh_string_data(r)) + ssh_string_len(r) - 20, 20); Above consider the case that ssh_string_len(r) is 19; in that case the memcpy unintentionally starts in the wrong place. The same situation can happen for value 's' in this code. To fix, adjust the offsets used for the input and output pointers, taking into account that the lengths of 'r' and 's' can be less than 20. With the fix I am no longer able to reproduce the original failure mode. BUG: https://red.libssh.org/issues/144 Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
* doc: Fix description of error parameter for ssh_get_error*Alan Dunn2014-01-221-2/+2
| | | | | | | | | ssh_get_error can actually work on anything with an ssh_common_struct as its first member. It is already used in examples in the distribution with ssh_sessions and ssh_binds. Signed-off-by: Alan Dunn <amdunn@gmail.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
* pki_crypto: pad RSA signature blobsJon Simons2014-01-211-24/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Pad RSA signature blobs to the expected RSA signature length when processing via 'pki_signature_to_blob'. Some clients, notably PuTTY, may send unpadded RSA signatures during the public key exchange: before this change, one can sometimes observe failure in signature validation when using PuTTY's 'plink' client, along these lines: ssh_packet_process: ssh_packet_process: Dispatching handler for packet type 50 ssh_packet_userauth_request: ssh_packet_userauth_request: Auth request for service ssh-connection, method publickey for user 'foo' ssh_pki_signature_verify_blob: ssh_pki_signature_verify_blob: Going to verify a ssh-rsa type signature pki_signature_verify: pki_signature_verify: RSA error: error:04091077:rsa routines:INT_RSA_VERIFY:wrong signature length ssh_packet_userauth_request: ssh_packet_userauth_request: Received an invalid signature from peer For cross-reference this issue once also existed between PuTTY and OpenSSH: http://www.chiark.greenend.org.uk/~sgtatham/putty/wishlist/rsa-verify-failed.html http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/ssh-rsa.c?rev=1.19;content-type=text%2Fx-cvsweb-markup With the fix I am unable to reproduce the above failure mode when testing with 'plink'. Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
* Import keys during ssh_bind_accept_fdAlan Dunn2014-01-211-1/+11
| | | | | Signed-off-by: Alan Dunn <amdunn@gmail.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
* Separate out key import functionality from ssh_bind_listenAlan Dunn2014-01-211-12/+23
| | | | | Signed-off-by: Alan Dunn <amdunn@gmail.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
* doc: Fix channel documentation.Andreas Schneider2014-01-171-31/+49
|
* bind: fix possible double-frees in ssh_bind_freeJon Simons2014-01-161-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make sure to explicitly set key pointers to NULL following the use of 'ssh_key_free' throughout bind.c. Before this change, a double free can happen via 'ssh_bind_free' as in this example callpath: // create an ssh_bind ssh_bind b = ssh_bind_new(); // provide a path to a wrong key-type ssh_bind_options_set(b, SSH_BIND_OPTIONS_DSAKEY, path_to_rsa_key); // initialize set key-type ssh_bind_listen(b); -> error path "The DSA host key has the wrong type: %d", ssh_key_free(sshbind->dsa) -> ssh_key_clean(key) // OK -> SAFE_FREE(key) // OK, but, sshbind->dsa is *not* set to NULL // ssh_bind_listen failed, so clean up ssh_bind ssh_bind_free(b); -> ssh_key_free(sshbind->dsa) // double-free here To fix, set pointers to NULL that have been free'd with 'ssh_key_free'. Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
* channel: Add ssh_channel_accept_forward().Oleksandr Shneyder2014-01-161-3/+23
| | | | | | | | This works same way as ssh_forward_accept() but can return a destination port of the channel (useful if SSH connection forwarding several TCP/IP ports). Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
* threads: support libgcrypt 1.6 hackAris Adamantiadis2014-01-081-2/+23
| | | | | | | Not 100% satisfied of this patch, but the way libgcrypt handles threading in 1.6 is not compatible with custom handlers. The new code basicaly uses pthreads in every case. This will probably not work on windows.
* src: Update my mail address.Andreas Schneider2014-01-0711-11/+11
|
* update copyright informationAris Adamantiadis2014-01-0720-26/+26
|
* pki: fix gcrypt signature processAris Adamantiadis2014-01-071-1/+1
|