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

1065 Коммитов

Автор SHA1 Сообщение Дата
Andreas Schneider
24af712931 cmake: Use GNUInstallDirs for installation
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-07-04 16:08:34 +02:00
Anderson Toshiyuki Sasaki
65a38759ca knownhosts: Introduced ssh_known_hosts_get_algorithms_names()
The added internal function obtain a newly allocated string containing a
list of the signature types that can be generated by the keys present in
the known_hosts files, separated by commas.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-07-04 10:29:20 +02:00
Anderson Toshiyuki Sasaki
548753b338 token: Added function to remove duplicates
Added a function to remove duplicates from lists.  This function is used
in a new provided function to append lists removing duplicates.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-07-04 10:29:20 +02:00
Anderson Toshiyuki Sasaki
a82993b320 connect: Removed unused code
The internal function ssh_connect_host() is not used.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-27 10:31:46 +02:00
Andreas Schneider
2d2a4f3784 include: Make sure ssh_session_get_known_hosts_entry is added to the API
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-06-14 15:22:56 +02:00
David Wedderwille
70dd8b0348 callbacks: Add ssh_threads_get_default() to the callbacks.h
Fixes: T154

Signed-off-by: David Wedderwille <davidwe@posteo.de>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-14 15:22:56 +02:00
Anderson Toshiyuki Sasaki
91960409c3 ed25519: Replace unsigned long long with uint64_t
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-14 15:22:45 +02:00
Anderson Toshiyuki Sasaki
b775e316fa priv.h: Add macro definitions for PRIx32 and PRIx64
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-14 15:22:45 +02:00
David Wedderwille
658a150991 channels: Make ssh_message_channel_request_open_reply_accept_channel public
This also adds documentation for it.

Fixes T144

Signed-off-by: David Wedderwille <davidwe@posteo.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:49:20 +02:00
Anderson Toshiyuki Sasaki
7656911953 bignum: Define bignum_dup(bignum orig, bignum *dest)
The macro is defined for each crypto back end.  If (*dest) is NULL, a
new bignum is allocated.  Otherwise the value of orig is copied to
(*dest).

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-06-12 12:36:32 +02:00
Anderson Toshiyuki Sasaki
54d76098ed kex, pki, server, options: Filter algorithms in FIPS mode
When in FIPS mode, filter the algorithms to enable only the allowed
ones.  If any algorithm is explicitly set through options or
configuration file, they are kept.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-12 11:13:52 +02:00
Anderson Toshiyuki Sasaki
79f0c38fbd options: Allow avoiding system-wide configuration
The added option SSH_BIND_OPTIONS_PROCESS_CONFIG allows to skip
processing the system-wide configuration file.  The global configuration
file is processed automatically if this option is not set as false.

This option will only be effective if set before any call to
ssh_bind_options_parse_config().

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-12 10:17:54 +02:00
Anderson Toshiyuki Sasaki
07faf95a10 bind_config: Add support for HostKeyAlgorithms
Add support for setting the allowed HostKey algorithms through
configuration file.

Note that this does NOT add support for adding or removing values using
'+' or '-'. Only replacing the whole list is supported.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-12 10:17:54 +02:00
Anderson Toshiyuki Sasaki
250a0be0f9 options: Added an option to set server HostKey algorithms
The added option SSH_BIND_OPTIONS_HOSTKEY_ALGORITHMS allows restricting
the signature algorithms to offer to the client for host authentication.
The list set is used as a filter of allowed algorithms.

First a list of possible signature algorithms to offer is created from
the keys set and then such list is filtered against the allowed
algorithms.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-12 10:17:54 +02:00
Anderson Toshiyuki Sasaki
8f6e6f774e bind_config: Add support for PubkeyAcceptedKeyTypes
Add support for setting the accepted public key types through
configuration file.

Note that this does NOT add support for adding or removing values using
'+' or '-'. Only replacing the whole list is supported.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-12 10:17:54 +02:00
Anderson Toshiyuki Sasaki
f4363f5655 options: Add option to set server accepted pubkey types
The added option SSH_BIND_OPTIONS_PUBKEY_ACCEPTED_KEY_TYPES allows
restricting the allowed public key types accepted by the server for
authentication.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-12 10:17:54 +02:00
Anderson Toshiyuki Sasaki
2c4850cbbd token, kex: Add functions to handle tokens lists
The added functions allow splitting chains of tokens separated by a
given character (usually ','), and extracting matching parts between two
chains of tokens.

The previously existing functions in kex.c were replaced by the
introduced ones.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-12 10:17:54 +02:00
Anderson Toshiyuki Sasaki
248e5acd5c pki: Fail to sign when using wrong hash algorithm
Do not allow using SSH_DIGEST_AUTO for any algorithm other than
ed25519.

Do not allow using incompatible hash algorithms when signing or
verifying signatures.

Added negative tests for all combinations of signature and hash
algorithms.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Anderson Toshiyuki Sasaki
550a1a7667 pki: Remove unused code
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Anderson Toshiyuki Sasaki
fd9446553b pki_crypto: Added pki_sign_data() and pki_verify_data_signature()
pki_sign_data() uses the given private key and hash algorithm to sign
the data using the OpenSSL EVP interface.  The corresponding function
pki_verify_data_signature() receives the signature, the signed data, and
the public key to verify the signature.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Anderson Toshiyuki Sasaki
0ea9e39e81 pki: Add a common place to store raw signatures
This is a preparation to store the raw signature for all algorithms in
the same place in ssh_signature.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Anderson Toshiyuki Sasaki
76f9808eb2 auth, pki: Calculate hash internally when signing/verifying
This makes pki_do_sign() and pki_signature_verify() to receive the
original input instead of the pre-calculated hash.  The hash is then
calculated internally.

The hash to be used inside the signature is decided earlier, when all
the information about the signature to be generated/verified is
available.

Simplify ssh_pki_do_sign() and ssh_srv_pki_do_sign_sessionid().

The tests were modified to use pki_do_sign() instead of
pki_do_sign_hash().

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Anderson Toshiyuki Sasaki
01e98a6df7 pki: Remove duplicate and unused code
Remove duplicate code previously used only in server side to generate
signatures.  Currently the code used to generate the signature is the
same for both client and server.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Anderson Toshiyuki Sasaki
5f7a3c5c66 wrapper: Make sha{1, 256, 384, 512}() input const
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Anderson Toshiyuki Sasaki
848f59c37e wrapper.h: Add SSH_DIGEST_SHA384 to ssh_digest_e enum
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Jakub Jelen
104c696bca dh-gex: Verify received primes in FIPS mode to match one of the known groups
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-29 13:18:09 +02:00
Jakub Jelen
e446507352 Provide a function to query crypto backend for FIPS status
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-29 13:18:09 +02:00
Jakub Jelen
67beaf363f dh-gex: Fall back to known primes when the moduli file is not readable
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-29 13:18:09 +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
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
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
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
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
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
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
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
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
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
Andreas Schneider
7c444c09d7 sftp: Document how to free memory retruned by sftp_canonicalize_path()
Fixes T129

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-02-27 08:32:10 +01:00
Dirkjan Bussink
e4c7912b35 Add flag for tracking EtM HMACs
This adds a flag to the type structures to track if we use a
Encrypt-then-MAC cipher instead of Encrypt-and-MAC. EtM is a more secure
hashing mechanism.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-02-22 15:31:02 +01:00
Dirkjan Bussink
c6608c9211 Refactor ssh_packet_hmac_verify to allow for direct buffer
This will make it easier to do Encrypt-then-MAC checks as those will be
on the direct encrypted data received before decrypting which means they
are not allocated in an ssh buffer at that point yet.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-02-22 15:30:59 +01:00
Dirkjan Bussink
369051a5b4 Remove SHA384 HMAC
This is not supported by OpenSSH and not recommended to be implemented
either.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-02-22 15:30:52 +01:00
Tilo Eckert
7caf6d2ab6 buffer: Fix regression introduced by 6c7eaa and c306a6
Buffer (un)packing was broken on compilers that are not
gcc-compatible since the checks for an argument count of
-1 have been removed from ssh_buffer_(un)pack(). This
fix no longer uses GCC extensions for the __VA_NARG__
macro, but only plain C99.
Note: The macro can no longer count empty argument lists
(results in compile error) which was not needed anyway.

Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-02-21 10:51:17 +01:00
Jakub Jelen
fffa66698f Allow building without Group Exchange support
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-02-07 10:30:05 +01:00