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

1162 Коммитов

Автор SHA1 Сообщение Дата
Paul Capron
b3a11e0185 priv.h: Fix typo in comment; “cound” → “count”
Signed-off-by: Paul Capron <paul@fragara.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-09-29 13:05:34 +02:00
Paul Capron
cbd48c497f priv.h: Fix “MAX_PACKAT_LEN” typo in #ifndef guard
The preprocessor guard was previously effectively inoperative;
it used to read “MAX_PACKAT_LEN” (note the ‘A’!), now is ‘E’.

Signed-off-by: Paul Capron <paul@fragara.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-09-29 13:05:34 +02:00
Jakub Jelen
88d4fa5352 sftp: Fix more typos
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-08-12 13:13:13 +02:00
Harald Sitter
c0b65ccc5a sftp: fix documentation typos
Signed-off-by: Harald Sitter <sitter@kde.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-08-12 13:09:16 +02:00
Heiko Thiery
bee8ed82ab cmake: Add autogenerated libssh_version.h
Set the cmake project verision to the autogenerated file to have a single
point to set the version. This will be included in the libssh.h file.

Pair-Programmed-With: Andreas Schneider <asn@cryptomilk.org>
Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com>
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-05-06 13:02:32 +02:00
Jakub Jelen
e6aee24a1e Add basic support for none cipher and MACs
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-05-05 14:23:06 +02:00
Anderson Toshiyuki Sasaki
dba2114ed7 init: Introduce internal is_ssh_initialized()
The introduced function returns whether the library is initialized or
not.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-04-09 11:25:49 +02:00
Anderson Toshiyuki Sasaki
9eb1ce88ae kex: Add support for diffie-hellman-group14-sha256
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-04-06 09:27:26 +02:00
Andreas Schneider
3e5dc99198 doc: Add SSH auth callback to libssh_auth doc group
Fixes T217

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-03-23 15:03:25 +01:00
Andreas Schneider
875b2a5b59 include: Remove PRIdS definitions
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-02-12 09:39:06 +01:00
Sebastian Kinne
17b518a677 pki: add support for sk-ecdsa and sk-ed25519
This adds server-side support for the newly introduced OpenSSH
keytypes sk-ecdsa-sha2-nistp256@openssh.com and sk-ed25519@openssh.com
(including their corresponding certificates), which are backed
by U2F/FIDO2 tokens.

Change-Id: Ib73425c572601c3002be45974e6ea051f1d7efdc
Signed-off-by: Sebastian Kinne <skinne@google.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-02-11 10:08:26 +01:00
Jakub Jelen
8670fb101b chacha: Create common file to avoid code duplication
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-01-23 09:48:11 +01:00
Andreas Schneider
8215753402 misc: Make the src pointer const in ssh_strreplace()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-01-23 09:20:43 +01:00
Jakub Jelen
3642224ee5 legacy,keys: Fix the macro conditions
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:45:24 +01:00
Sahana Prasad
4ea09256f6 src: Implements PKCS11 URI support
Imports private and public keys from the engine via PKCS11 URIs. Uses
the imported keys to authenticate to the ssh server.

Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-20 16:17:33 +01:00
Sahana Prasad
6bf4ada240 src: Helper funtions to detect PKCS #11 URIs
Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-20 14:41:02 +01:00
Andreas Schneider
35216e7254 misc: Add ssh_strreplace()
Pair-Programmed-With: Sahana Prasad <sahana@redhat.com>
Signed-Off-by: Sahana Prasad <sahana@redhat.com>
Signed-Off-By: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-20 14:35:18 +01:00
Andreas Schneider
5317ebf0fc misc: Add ssh_tmpname()
Signed-Off-By: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-20 14:35:04 +01:00
Andreas Schneider
742d81ec5d include: Rename __unused__ to __attr_unused__
This avoids a collision with valgrind.h

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-11 11:38:16 +01:00
Anderson Toshiyuki Sasaki
c9ce8fa40b misc: Add a function to encode newlines
Given a string, the added function encodes existing newline characters
('\n') as the string "\\n" and puts into a given output buffer.

The output buffer must have at least 2 times the length of the input
string plus 1 for the terminating '\0'. In the worst case, each
character can be replaced by 2 characters.

Fixes T189

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
d60640cd0e socket: Pass port as uint16_t to ssh_socket_connect()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
64cd7e7ce2 bignum: Fix integer types for ssh_make_bignum_string()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
f5bc5147b9 base64: Fix size types of bin_to_base64()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
5ef416fd35 include: Mark SSH_AUTH flags as unsigned
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
1be68139bb agent: Return uint32_t for ssh_agent_get_ident_count()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
6b105624bf sftp: Fix integer types in sftp_write() and sftp_packet_write()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
db4345fb36 sftp: Remove internal function from sftp.h
Those are not marked as LIBSSH_API so not part of the public API and the
symbols aren't exported!

Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
31b26934b0 fe25519: Fix integer types of fe25519_iszero()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
922a2aee99 include: Fix integer type of dh_pn and dh_pmax
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
dad2720355 channels: Fix integer and bool argument of channel_default_bufferize()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Anderson Toshiyuki Sasaki
c4ad1aba98 CVE-2019-14889: misc: Add function to quote file names
The added function quote file names strings to be used in a shell.
Special cases are treated for the charactes '\'' and '!'.

Fixes T181

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-09 16:08:03 +01:00
Jakub Jelen
c8a621c606 Use only one variable denoting the size of methods arrays
Previously, there was non-consistent usage of constans SSH_KEX_METHODS,
KEX_METHODS_SIZE and of magic number 10 to reference the arrays used
for algorithm negotiation by peers. This commit settles down to the single
constant and its usage throughout the whole codebase.

Fixes T195

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-11-18 11:59:01 +01:00
Anderson Toshiyuki Sasaki
77bd8ed4c0 session: Use ssh_packet_state_e instead of int
Use the enum type instead of int in the ssh_session_struct

Fixes T194

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-11-18 11:59:01 +01:00
Anderson Toshiyuki Sasaki
39f6ba2dc9 messages: Use ssh_publickey_state_e instead of char
Use the enum type instead of char in the ssh_auth_request struct

Fixes T194

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-11-18 11:59:01 +01:00
Jakub Jelen
1ebf506913 server: Use really the negotiated signature type
Generally, when the extension negotiation is enabled and client supports
SHA2 algorithms for RSA, they are supposed to be prioritized against the
old SHA1. If it is not (ssh-rsa is listed in front of rsa-sha2-* hostkey
algorithms during negotiation), the server wrongly tries to provide the
new typo of signature, ignoring the negotiated algirithm

This commit propagates the digest algorithm from negotiation to the actual
signature functions, which were previously responsible for decision
about the hash algorithm based just on the negotiated extensions.

Fixes T191

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-11-07 15:55:32 +01:00
Jakub Jelen
689f1b0a6b callbacks: Improve documentation about callbacks handling
Fixes T103

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-10-01 10:24:06 +02:00
Anderson Toshiyuki Sasaki
55cd04fbee pki: Remove unused function pki_signature_verify()
This removes unused function pki_signature_verify()
from pki_{crypto, mbedcrypto, gcrypt}.  The function was also removed
from include/libssh/pki_priv.h.  The function ssh_pki_signature_verify()
was changed to receive a const unsigned char *input.

All tests calling pki_signature_verify() were changed to call
ssh_pki_signature_verify() instead.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-09-24 16:49:35 +02:00
Anderson Toshiyuki Sasaki
2a2c1c98bf pki_crypto: Use OpenSSL for Ed25519 signatures
Use OpenSSL to generate and verify Ed25519 signatures, if supported.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-09-24 16:49:35 +02:00
Anderson Toshiyuki Sasaki
bdcaf55b90 pki: Move common Ed25519 functions to pki_ed25519_common.c
This is a preparation to use the Ed25519 implementation from OpenSSL.

The function pki_ed25519_sig_to_blob() was renamed to
pki_ed25519_signature_to_blob() and pki_ed25519_sig_from_blob() was
renamed to pki_signature_from_ed25519_blob() to follow the naming for
other algorithms.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-09-24 16:49:35 +02:00
Jakub Jelen
618b858e49 sftp: Improve the documentation of sftp_init() and sftp_new()
Fixes: T137

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-09-16 09:35:32 +02:00
Andreas Schneider
92d3efec81 dh: Add ssh_dh_debug_crypto()
We should call it where we have access to the crypto structure.

Pair-Programmed-With: Jakub Jelen <jjelen@redhat.com>
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-08-08 09:30:03 +02:00
Andreas Schneider
4e25ee6124 bignum: Pass const to ssh_print_bignum()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-08-07 09:49:00 +02:00
Anderson Toshiyuki Sasaki
742918cb1c misc: Introduce internal function ssh_mkdirs()
If the given path includes missing directories, ssh_mkdirs() tries to
create them recursively.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-08-06 16:53:22 +02:00
Anderson Toshiyuki Sasaki
7857cd1aa5 misc: Introduce internal function ssh_dir_writeable()
The introduced internal function checks if the provided path is for an
existing directory which is accessible for writing.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-08-06 16:52:24 +02:00
Anderson Toshiyuki Sasaki
33927f3ae8 misc: Introduce ssh_log_hexdump()
The introduced internal function is intended to be a replacement for the
deprecated function ssh_print_hexa().

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-07-30 13:26:29 +02:00
Andreas Schneider
1a26c57af2 include: Add define for SSH_CONNECTOR_STDINOUT
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-07-08 14:48:28 +02:00
Stefan Strogin
0d4658740b libcrypto: fix compilation with LibreSSL
LibreSSL does not support FIPS mode, check for FIPS_mode() in
ConfigureChecks.cmake.

Signed-off-by: Stefan Strogin <steils@gentoo.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-07-04 17:57:35 +02:00
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
Jakub Jelen
0833f07c53 options: Allow to configure cryptographic algorithms for server
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-02-07 10:30:05 +01:00
Andreas Schneider
b84949b32c include: Mark ssh_print_hexa as deprecated
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-02-07 09:46:13 +01:00
Baruch Siach
6c7eaa9e12 buffer: Convert argc to size_t in ssh_buffer_unpack() as well
Commit c306a693f3 ("buffer: Use size_t for argc argument in
ssh_buffer_(un)pack()") mentioned unpack in the commit log, but it only
touches the pack variants. Extend the conversion to unpack.

Pre-initialize the p pointer to avoid possible use before
initialization in case of early argc check failure.

This fixes build failure:

.../libssh-0.8.6/src/buffer.c: In function 'ssh_buffer_unpack_va':
.../libssh-0.8.6/src/buffer.c:1229:16: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
             if (argc == -1){
		^

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-24 17:48:08 +01:00