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

4706 Коммитов

Автор SHA1 Сообщение Дата
Anderson Toshiyuki Sasaki
9ef0b0b029 tests/torture_pki: Skip some tests if in FIPS mode
Skip tests requiring algorithms not allowed in FIPS mode.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:29:32 +02:00
Anderson Toshiyuki Sasaki
39c69893c7 tests/torture_options: Use only allowed algorithms if in FIPS mode
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:29:32 +02:00
Anderson Toshiyuki Sasaki
ce888fd4c0 tests/torture_config: Use only allowed algorithms in FIPS mode
Use only allowed algorithms if running in FIPS mode.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:29:30 +02:00
Anderson Toshiyuki Sasaki
af031d8df6 tests/torture_bind_config: Use allowed algorithms in FIPS mode
Use only allowed algorithms if in FIPS mode.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:28:25 +02:00
Anderson Toshiyuki Sasaki
92a0d23eac tests/torture_hostkey: Skip some tests in FIPS mode
Skip tests using non allowed algorithms.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:28:25 +02:00
Anderson Toshiyuki Sasaki
1a6ac291a7 tests/torture_client_config: Adjust lists in FIPS mode
Use only allowed algorithms if in FIPS mode.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:28:25 +02:00
Anderson Toshiyuki Sasaki
bdb2ef4dcc tests/torture_algorithms: Skip some tests in FIPS mode
When running in FIPS mode, skip the tests using algorithms not allowed.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:28:25 +02:00
Anderson Toshiyuki Sasaki
41834f228b tests: Use different config if in FIPS mode
Use a different OpenSSH configuration if running in FIPS mode, which
contains only allowed algorithms.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:28:25 +02:00
Jakub Jelen
03ca994cc0 tests: Use the SHA2 extension by default to avoid issues in FIPS mode 2019-06-13 16:28:25 +02:00
Anderson Toshiyuki Sasaki
53ae2502f4 kex: Only advertise allowed signature types
Previously, if the client supported rsa-sha2-256 or rsa-sha2-512, the
server would advertise the extensions as supported without checking its
own list of allowed algorithms.  Now the server will only advertise
allowed signature algorithms.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:28:23 +02:00
Anderson Toshiyuki Sasaki
1b7146e28f server: Send only allowed algorithms in extension
Send only allowed algorithms in server-sig-algs extension if in FIPS
mode.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 14:37:39 +02:00
Jakub Jelen
a3ddc48cb0 pki: Derive correct algorithm identification for certificate authentication with SHA2 extension
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 11:00:56 +02:00
Jakub Jelen
132ed59d3f agent: Use SHA2 signatures also for RSA certificates
There is actually a bug in OpenSSH's ssh-agent of handling these
requests [1], but this change follows the way how OpenSSH clients
behave in regards to the communication with agent.

Without this change, the agent is asked to provide SHA1 signature
with certificates, which is not right if we negotiated SHA2 extensions.

[1] https://bugzilla.mindrot.org/show_bug.cgi?id=3016

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 11:00:56 +02:00
Jakub Jelen
f91a5fce6e tests: Use ed25519 keys explicitly
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 11:00:56 +02:00
Jakub Jelen
63f477181a tests: The DSA is not available in mbedtls
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 11:00:56 +02:00
Anderson Toshiyuki Sasaki
2c385c0e13 tests/client/torture_auth: Skip some tests if in FIPS mode
If in FIPS mode, skip tests which require algorithms not allowed.  Also
use allowed algorithms when possible to avoid skipping the test.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 11:00:56 +02:00
Jakub Jelen
66755c478c tests: Do not free pcap context while it is in use by the server session
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 11:00:56 +02:00
Jakub Jelen
9f178be1fa tests: Cover comparison of public keys, which was missing
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 11:00:56 +02:00
Jakub Jelen
1f66414805 pki_gcrypt: Do not compare private parts when comparing public keys
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 11:00:56 +02:00
Jakub Jelen
6d5ac15a51 config: Remove bogus trailing newlines in log messages
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 11:00:56 +02:00
Jakub Jelen
85241c19e9 kex: Reformat ssh_kex_get_supported_method() 2019-06-13 11:00:56 +02:00
Jakub Jelen
53cee7c9a3 kex: List also certificate types in list of allowed public key algorithms
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 11:00:56 +02:00
Anderson Toshiyuki Sasaki
f64c3dec74 tests: Add PKCS#8 PEM encrypted private keys
Copies of the DSA, RSA, and ECDSA keys were added encoded in PKCS#8
format.  For now, these keys are only used when testing with OpenSSL.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 11:00:56 +02:00
Anderson Toshiyuki Sasaki
0cfe4c7ab8 tests/torture_auth: Workaround OpenSSH agent bug
OpenSSH agent has a bug which makes it to not use SHA2 in signatures
when using certificates. It always uses SHA1.

See https://gitlab.com/libssh/libssh-mirror/merge_requests/34

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 11:00:56 +02:00
Anderson Toshiyuki Sasaki
01f4040218 dh: Avoid segmentation fault in GEX if fallback to known moduli
Make ssh_fallback_group() to duplicate the modulus and generator.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-12 12:37:43 +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
Jakub Jelen
9f7f5dee18 tests: Verify duplicate items are removed from knownhosts entries list
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-12 11:15:20 +02:00
Jakub Jelen
5f01ed0278 tests: Verify duplicate items are removed from knownhosts algorithms
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-12 11:15:20 +02:00
Jakub Jelen
196361c1f0 ssh_known_hosts_get_algorithms: Avoid returning duplicate key types from known hosts algorithms
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-12 11:15:20 +02:00
Jakub Jelen
79cd2618ec ssh_known_hosts_read_entries: Avoid returning duplicate knownhowst items
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-12 11:15:20 +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
Jakub Jelen
56041dc784 torture_hashes: Skip the MD5 tests in FIPS mode
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-12 10:41:24 +02:00
Jakub Jelen
167aa8bc6c pki_crypto: Use the new OpenSSL API to read PEM files
This allows the use of the new PKCS#8 PEM files and does not
limit libssh to using only the "traditional" PEM files, that
are not default in OpenSSL since 1.0.0 and which do not work
at all in FIPS mode.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-12 10:41:24 +02:00
Jakub Jelen
0ce1e84d90 pki_crypto: Use the new OpenSSL API to write new PKCS#8 PEM files
Since OpenSSL 1.0.0, the "traditional" PEM format was deprecated
in favor of the PKCS#8 PEM files which is more standardized,
more secure and does not depend on the MD5 hash, which is not
available for example in FIPS mode.

This requires using the new EVP_PKEY API for reading private key
blobs.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-12 10:41:24 +02:00
Anderson Toshiyuki Sasaki
ee456104f1 session: Do not use MD5 in FIPS mode
Do not use MD5 when generating fingerprints in FIPS mode.  The call will
fail in such case.  The test suite was updated with a negative test for
this case.

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 10:27:40 +02:00
Anderson Toshiyuki Sasaki
0fb7d9831a tests: Make sure unknown options are ignored in server config
Added a test to make sure unknown options in the configuration file are
ignored and don't make ssh_bind_options_parse_config() to fail.

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
55c637f2d3 bind_config: Fail if a known option couldn't be set
Make ssh_bind_options_parse_config() to fail if setting a known option
fails.  Previously the return value of ssh_bind_options_set() were
ignored when configuring the server through a configuration file.

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
d783aec96c kex: Remove unused code
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
dc35bbbeb1 server: Use default methods instead of all
Previously, when no methods were set, the server would enable all
supported methods.  This changes this behaviour by setting only the
default methods.

The server in pkd_daemon.c was changed to set explicitly all the
supported methods to keep the previous behaviour.

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
2db2a4e170 kex: Make order of preferred signature algorithms consistent
The default order of preference for signature algorithms were not
consistent. This makes the following order of preference to be the
default order:

* ssh-ed25519
* ecdsa-sha2-nistp521
* ecdsa-sha2-nistp384
* ecdsa-sha2-nistp256
* rsa-sha2-512
* rsa-sha2-256
* ssh-rsa
* ssh-dss

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
a8064cb0ca tests: Added tests for server config file
The added tests run the server with different combinations of algorithms
and try to connect using a client.

Note that few combinations are tested.

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
e7ef40c8f0 tests: Allow setting configuration file for test server
This allows testing the server with a configuration file.  This also
adds an option for the stand-alone test server to skip parsing the
system-wide configuration file.

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
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
bc95a51710 kex, known_hosts: Use new tokens functions
Replace the old tokens handling functions usage with the new implementation.

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
b0ff64bf1b pki: Check if the key is allowed against right list
Previously when generating the signature in server side the key was
checked against the wrong list, potentially making the server to select
the wrong algorithm to sign (e.g. rsa-sha2-512 instead of rsa-sha2-256).

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-12 10:17:54 +02:00