1
1
Граф коммитов

4746 Коммитов

Автор SHA1 Сообщение Дата
Andreas Schneider
3e8bdb122f knownhosts: Check if the hosts file exists
Fixes T135

Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-29 13:17:27 +02:00
David Wedderwille
cc536377f9 sftp server: Implementation of sftp_server_free() as counterpart to sftp_server_new()
Fixes T143

Signed-off-by: David Wedderwille <davidwe@posteo.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-29 13:17:24 +02:00
Andreas Schneider
643ca67f88 gssapi: Add missing malloc checks
Fixes T141

Reported-By: Ramin Farajpour Cami
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-29 13:17:21 +02:00
Andreas Schneider
8a885f0bd3 channels: Add check if we are authenticated before we create a channel
Fixes T139

Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-29 13:17:19 +02:00
Andreas Schneider
c4348c7b3c sftp: Check if the channel is still valid
Fixes T138

Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-29 13:17:16 +02:00
Enji Cooper
5ffc595d0d Document more @return values with doxygen for APIs
Summary:
* Note that SSH_ERROR can be returned on error in `ssh_channel_get_exit_status`
  and `ssh_channel_get_session`.
* Note the return codes for `channel_open` and `grow_window`; although these
  are internal APIs, it's best to document their behavior.
* Replace `@returns` use with `@return`. While Doxygen supports the
  former as a synonym for `@return`, it isn't documented in the manual
  (and might not be supported by other downstream documentation tools).

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>

Test Plan: n/a

Reviewers: #libssh, asn

Differential Revision: https://bugs.libssh.org/D15
2019-04-29 13:17:11 +02:00
Rosen Penev
815a53375e libcrypto: Fix compilation without deprecated OpenSSL APIs
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-29 13:17:09 +02:00
Till Wimmer
6cd506ea81 options: Update doc for SSH_OPTIONS_PORT
Signed-off-by: Till Wimmer <g4-lisz@tonarchiv.ch>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-29 13:17:06 +02:00
Till Wimmer
95ab5f0dce channel: Don't send EOF on channel more than once
Signed-off-by: Till Wimmer <g4-lisz@tonarchiv.ch>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-29 13:17:01 +02:00
Till Wimmer
9340a0af5e connector: Stop socket-to-channel EOF flooding
Signed-off-by: Till Wimmer <g4-lisz@tonarchiv.ch>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-29 13:16:54 +02:00
Ben Toews
08b3301e4f tests/pkd: connect to openssh using certificates
Signed-off-by: Ben Toews <mastahyeti@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-17 10:21:42 +02:00
Ben Toews
4a01496810 tests/unittests: test that signatures can be verified with certs
Signed-off-by: Ben Toews <mastahyeti@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-17 10:21:42 +02:00
Ben Toews
2f26b5d63c pki: allow certificates to be used in signature verification
A number of places checked that the signature type matched the key type. We
losen these checks to, for example, allow an RSA signature with an RSA-cert
key.

Signed-off-by: Ben Toews <mastahyeti@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-17 10:21:42 +02:00
Ben Toews
7c0719e53d pki: parse keys from certificates into ssh_key
Previously, we were just storing the raw certificate in ssh_key->cert. With
this change, we parse out the nonce string at the beginning of the certificate.
This leaves us with the certificate's public key at the start of the buffer.
The existing public key parsing code can then parse this out into the key fieds
of the ssh_key.

Signed-off-by: Ben Toews <mastahyeti@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-17 10:21:42 +02:00
Ben Toews
04b284dae0 tests/unittests: test ECDSA/ED25519 support
These tests are copied from the existing RSA/DSA certificate tests. They cover
importing certificates.

Signed-off-by: Ben Toews <mastahyeti@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-17 10:21:42 +02:00
Ben Toews
19cd909c8d pki: support ECDSA/ED25519 certificates
As with RSA/DSS, support is still quite limited. This is mostly about adding
new ssh_keytypes_e values and updating sites that check keys' types.

Signed-off-by: Ben Toews <mastahyeti@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-17 10:21:42 +02:00
Ben Toews
b1f3cfec34 libssh: deprecate SSH_KEYTYPE_ECDSA
This type is imprecise. We often need the ecdsa_nid in addition to the key type
in order to do anything. We replace this singluar ECDSA type with one type per
curve.

Signed-off-by: Ben Toews <mastahyeti@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-17 10:21:42 +02:00
Ben Toews
78f764b7c9 torture_pki: store test case attributes in struct instead of multiple arrays
Signed-off-by: Ben Toews <mastahyeti@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-17 10:21:42 +02:00
Ben Toews
e036c426f8 tests: add OpenSSL includes dir for torture tests
Tests were failing to build on macOS with OpenSS installed using homebrew.

Signed-off-by: Ben Toews <mastahyeti@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-17 10:21:35 +02:00
Andreas Schneider
77a6fe4a62 dh-gex: Add error check for ssh_packet_client_dhgex_group()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-15 19:58:58 +02:00
Simo Sorce
33ad6bc54e dh: Add compat function for openssl < 1.1.0
Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-04 08:00:31 +02:00
Simo Sorce
33399e52f0 dh: Add OpenSSL libcrypto specific DH implementation
Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-04 08:00:28 +02:00
Simo Sorce
7551857d08 dh: Move DH key handling into a separate file.
In preparation for adding crypto-libraries specific backends.

Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-04 08:00:23 +02:00
Simo Sorce
30d97979a2 dh: Confine DH KEX keys handling into fewer functions
In preparation for deferring computation on DH secret material to
crypto library specific backends

Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-04 08:00:19 +02:00
Simo Sorce
2f38af1559 dh: Rename variables for DH key exchange
Rename and refactor how some variables are held in ssh_crypto_struct.
Refactor allocation of dh exchange public keys.

This is in preparation for switching the code to use openssl native DH
handling and allowed to better reason about the code and the overall API.

Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-04 08:00:15 +02:00
Simo Sorce
997fe4d418 mbedcrypto: Make bignum_bin2bn behave like others
Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-04 07:59:58 +02:00
Anderson Toshiyuki Sasaki
fd30cf0676 tests: Add test cases for Match keyword in bind config
Adds test cases for the Match keyword for the bind options configuration
using a file.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-01 08:41:56 +02:00
Anderson Toshiyuki Sasaki
d9e6237a47 bind_config: Added minimal support for Match keyword
Only "Match All" is supported, if any other criterion is used, the block
is ignored and the options are not applied.

It is important to note that only a subset of the supported keywords are
allowed to be used inside a Match block, currently being "LogLevel" the
only supported keyword.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-01 08:41:53 +02:00
Anderson Toshiyuki Sasaki
25af8641b3 bind: Apply global configuration automatically
Apply the global bind configuration from the file pointed by
BIND_GLOBAL_CONFIG when a bind_new() is called.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-01 08:38:17 +02:00
Anderson Toshiyuki Sasaki
d6d9b56bb9 cmake,options: Allow to set global bind config file
This allows the global bind configuration file path to be set in
configuration time by defining the GLOBAL_BIND_CONFIG when calling
cmake.  If no value is defined, the default path is set as
"/etc/ssh/libssh_server_config".

usage example:

$ cmake -DGLOBAL_BIND_CONFIG=/etc/my/custom/path ..

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-01 08:38:17 +02:00
Anderson Toshiyuki Sasaki
68385a2e98 options: Add a bind option to set the config directory
This adds the SSH_BIND_OPTIONS_CONFIG_DIR which allows to set the
directory used to expand the escape character "%d" when passing a path
to ssh_bind_options_parse_file().

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-01 08:38:17 +02:00
Anderson Toshiyuki Sasaki
fd25beff68 options: Introduce ssh_bind_options_parse_config()
The added API allows setting the options of a given bind context through
a configuration file.  The default global configuration file
"/etc/ssh/libssh_server_config" is parsed before the provided
configuration file, if it hasn't been parsed yet.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-01 08:38:17 +02:00
Anderson Toshiyuki Sasaki
bab4d2b77b tests: Add tests for server side configuration
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-01 08:38:17 +02:00
Anderson Toshiyuki Sasaki
55a713cb04 bind_config: Support server side configuration
Introduced the support to set options for a given ssh_bind through a
configuration file.

For options set more than once in a single file (or by files included in it
recursively) the first value set will be kept.

Differently from the session options configuration,
if an option previously set in one configuration file is redefined in a
later processed file, the latest will be kept.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-01 08:38:15 +02:00
Anderson Toshiyuki Sasaki
79049981a5 config: Move common parser functions to config_parser.c
This will allow the moved functions to be used in the server side
configuration parser implementation.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-01 08:25:22 +02:00
Anderson Toshiyuki Sasaki
19e886d6b1 bind: Use calloc instead of malloc
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-01 08:25:22 +02:00
Anderson Toshiyuki Sasaki
0bde6b142c tests: Add missing unit tests for bind options
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-01 08:25:05 +02:00
Alberto Garcia Illera
45c7d07780 misc: Avoid printing full path in debug message
Signed-off-by: Alberto Garcia Illera <agarciaillera@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-29 14:42:40 +01:00
pmorris67
f05571841b channels: Added function to create channel to UNIX socket
[asn: Reformatting and added openssh version check]
Signed-off-by: Philip Morris <philip.morris67@ntlworld.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-29 08:10:43 +01:00
Andreas Schneider
55bcefbc56 config: Use size_t instead of u_int
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-25 19:16:28 +01:00
Jan Pazdziora
b0bd05a724 sftp_get_error returns int, not char *.
Signed-off-by: Jan Pazdziora <jpazdziora@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-25 18:51:15 +01:00
Jan Pazdziora
cd8f5ddbc2 Each ssh_channel_request_exec() needs to be run on fresh channel.
Signed-off-by: Jan Pazdziora <jpazdziora@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-25 18:50:52 +01:00
Jan Pazdziora
3ce9f78fb4 The ssh_channel_callbacks_struct member name is channel_data_function.
Addressing
client.c: In function ‘show_remote_uptime’:
client.c:107:6: error: ‘struct ssh_channel_callbacks_struct’ has no member named ‘channel_data’
     .channel_data = my_channel_data_function,
      ^~~~~~~~~~~~
client.c:107:21: warning: initialization of ‘long unsigned int’ from ‘int (*)(struct ssh_session_struct *, struct ssh_channel_struct *, void *, uint32_t,  int,  void *)’ {aka ‘int (*)(struct ssh_session_struct *, struct ssh_channel_struct *, void *, unsigned int,  int,  void *)’} makes integer from pointer without a cast [-Wint-conversion]
     .channel_data = my_channel_data_function,
                     ^~~~~~~~~~~~~~~~~~~~~~~~
client.c:107:21: note: (near initialization for ‘cb.size’)

Signed-off-by: Jan Pazdziora <jpazdziora@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-25 18:50:33 +01:00
Anderson Toshiyuki Sasaki
5104c86a2b auth: Set buffer used to store password as secure
This will make such buffer to be explicity overwritten with zeroes when
freed.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-25 18:47:55 +01:00
Andreas Schneider
144e551614 doc: Add a note about OpenSSL linking
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-13 10:36:32 +01:00
Andreas Schneider
65bc24d8a4 libcrypto: Add missing includes for modes.h
This defines block128_f.

Fixes T133.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-13 10:31:39 +01:00
Jan Pazdziora
d8fc65ad71 The SSH_LOG_ENTRY is not defined all, match the descriptions to SSH_BIND_OPTIONS_LOG_VERBOSITY*.
The documentation amends change in 801bc29494.

The SSH_LOG_ENTRY macro was removed during cleanup ab60d1d678.

Signed-off-by: Jan Pazdziora <jpazdziora@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-11 16:22:07 +01:00
Jan Pazdziora
81d0f6b6b7 From the context it seems that the function being defined is authenticate_none.
Signed-off-by: Jan Pazdziora <jpazdziora@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-11 16:19:47 +01:00
Jan Pazdziora
bed7dcb3ec ssh_userauth_publickey_auto requires three arguments.
Addressing
client.c: In function ‘authenticate_pubkey’:
client.c:70:8: error: too few arguments to function ‘ssh_userauth_publickey_auto’
   rc = ssh_userauth_publickey_auto(session, NULL);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from client.c:1:
/usr/include/libssh/libssh.h:745:16: note: declared here
 LIBSSH_API int ssh_userauth_publickey_auto(ssh_session session,
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jan Pazdziora <jpazdziora@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-11 16:19:26 +01:00
Simo Sorce
104c9dca3f Use a common KDF function
Cleanup the KDF function to use only one function per crypto backend.
Improve the KDF function to properly handle requested lenght and to
avoid unnecessarily reallocating buffers.

In OpenSSL use the new EVP_KDF API if available.

Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-07 12:03:32 +01:00