aboutsummaryrefslogtreecommitdiff
path: root/include
AgeCommit message (Collapse)AuthorFilesLines
2023-05-04CVE-2023-1667:kex: Add support for sending first_kex_packet_follows flagJakub Jelen2-3/+11
This is not completely straightforward as it requires us to do some state shuffling. We introduce internal flag that can turn this on in client side, so far for testing only as we do not want to universally enable this. We also repurpose the server flag indicating the guess was wrong also for the client to make desired decisions. If we found out our guess was wrong, we need to hope the server was able to figure out this much, we need to revert the DH FSM state, drop the callbacks from the "wrong" key exchange method and initiate the right one. The server side is already tested by the pkd_hello_i1, which is executing tests against dropbrear clients, which is using this flag by default out of the box. Tested manually also with the pkd_hello --rekey to make sure the server is able to handle the rekeying with all key exchange methods. Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2023-05-04CVE-2023-1667:kex: Correctly handle last fields of KEXINIT also in the ā†µJakub Jelen1-0/+5
client side Previously, the last two fields of KEXINIT were considered as always zero for the key exchange. This was true for the sending side, but might have not been true for the received KEXINIT from the peer. This moves the construction of these two fields closer to their reading or writing, instead of hardcoding them on the last possible moment before they go as input to the hashing function. This also allows accepting the first_kex_packet_follows on the client side, even though there is no kex algorithm now that would allow this. It also avoid memory leaks in case the server_set_kex() or ssh_set_client_kex() gets called multiple times, ensuring the algorithms will not change under our hands. It also makes use of a new flag to track if we sent KEXINIT. Previously, this was tracked only implicitly by the content of the session->next_crypto->{server,client}_kex (local kex). If it was not set, we considered it was not send. But given that we need to check the local kex even before sending it when we receive first_kex_packet_follows flag in the KEXINIT, this can no longer be used. Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2023-05-04CVE-2023-1667:dh: Expose the callback cleanup functionsJakub Jelen4-0/+4
These will be helpful when we already sent the first key exchange packet, but we found out that our guess was wrong and we need to initiate different key exchange method with different callbacks. Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2023-05-04CVE-2023-1667:kex: Remove needless function argumentJakub Jelen1-1/+1
The information if the session is client or server session is already part of the session structure so this argument only duplicated information. Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2023-05-04Reformat struct ssh_session_structJakub Jelen1-7/+7
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2023-04-28handle no-more-sessions in serverAhsen Kamal2-3/+7
Signed-off-by: Ahsen Kamal <itsahsenkamal@gmail.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-04-28add request no-more-sessions@openssh.com global requestAhsen Kamal1-0/+1
Signed-off-by: Ahsen Kamal <itsahsenkamal@gmail.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-04-24Add support for hardlink@openssh.comEshan Kelkar1-0/+16
sftp_hardlink() has been introduced which when called sends a SSH_FXP_EXTENDED request to server for creating a hardlink. Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-04-21Add callback to accept forwarded-tcpip requestsAdley Phu1-0/+25
Signed-off-by: Adley Phu <aphu@janestreet.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-03-15doc: Fix doxygen errors when QUIET=yes EXTRACT_ALL=yesNorbert Pocs3-4/+4
Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Sahana Prasad <sahana@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-03-06rename discon_msg to peer_discon_msgAhsen Kamal1-1/+1
Signed-off-by: Ahsen Kamal <itsahsenkamal@gmail.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-03-01Add support for PKCS#11 provider in OpenSSL 3.0Jakub Jelen1-1/+1
The engine API in OpenSSL 3.0 is deprecated so we are in the progress of working on a PKCS#11 provider for OpenSSL. This commit introduces a conditional build with the pkcs11-provider support (instead of engines) with all the changes required for the provider to work with existing code and tests. The CI modification is only temporary before we will have the real package in Fedora or somewhere to use. Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com> Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-02-02Remove support for DSA KeysMohammad Shehar Yaar Tausif8-34/+8
Solving issue #110. The original work is at !231 Some changes were needed because the newly added features in master through time Signed-off-by: Mohammad Shehar Yaar Tausif <sheharyaar48@gmail.com> Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-02-01server: Add documentation to some functionsNorbert Pocs1-3/+8
Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-02-01documentation: Fix Missing param doxygen warningsNorbert Pocs1-3/+20
Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-01-25Get rid of the deprecated OpenSSL APIJakub Jelen3-16/+7
It turns out there is a way to get the uncompressed format from the low-level API, which is not (yet?) deprecated so this removes all of the TODO's for ECDSA keys and moves the EC_KEY structure in the high-level EVP_PKEY. Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-25Remove needless ifdefs for Ed25519 support ...Jakub Jelen2-4/+5
... through bundled code with OpenSSL. These were needed with older OpenSSL versions before 1.1.1. After removal in 358ce465517eb494146d33b794cf7999f7430707 these were just static ifdef so this will simplify the code. Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-25Do not build the PKCS#11 when disabledJakub Jelen2-0/+4
This prevents building the pkcs11-related functions and printing pkcs11-related log messages when the libssh is built without PKCS#11 support. Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-09include: Document the need to free the returned bufferJakub Jelen1-0/+2
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Norbert Pocs <npocs@redhat.com>
2023-01-09Happy new year 2023!Andreas Schneider1-1/+1
And happy anniversary libssh (20 years). Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2023-01-02Add callbacks for channel open response, and channel request response.Tom Deseyn1-0/+31
Signed-off-by: Tom Deseyn <tom.deseyn@gmail.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-12-20Move old DSA and RSA structs into EVP_PKEYNorbert Pocs2-14/+0
For code simplification and less ifdefs removing DSA and RSA structures of the old openssl api and using the new EVP_PKEY api to store the legacy keys. Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-11-29Add flags for escape expand operationNorbert Pocs1-0/+7
Calling `ssh_options_apply` more times can result in an unwanted behaviour of expanding the escape characters more times. Adding flags to check if the expansion was already done on the current string variables. Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-11-29Add a placehohlder for non-expanded identitiesNorbert Pocs1-0/+1
Expanding a string twice could lead to unwanted behaviour. This solution creates a ssh_list (`opts.identites_non_exp`) to store the strings before expansion and by using ssh_apply it moves the string to the `opts.identities`. This way the expanded strings are separated. Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-11-29Fix memory leaks of bignums when openssl >= 3.0Norbert Pocs1-1/+1
The openssl 3.0 support has introduced some memory leaks at key build as OSSL_PARAM_BLD_push_BN duplicates the bignum and does not save the pointer itself. Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-11-18options.c: Add support for openssh config +,-,^Norbert Pocs1-1/+2
These features allow for options Ciphers, HostKeyAlgorithms, KexAlgorithms and MACs to append, remove and prepend to the default list of algorithms respectively Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-11-18kex: Add functions for openssh +,-,^ featuresNorbert Pocs1-0/+4
The funcions can: - add a list to the default list - remove a list from the default list - prepend a list to the default list Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-11-18tokens: Add low-level function to exlclude, prepend listsNorbert Pocs1-0/+5
These functions are needed for openssh -,^ features. Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-11-02libcrypto.c: Change function parameter nameNorbert Pocs1-3/+3
"new" is a c++ keyword which will make the build fail. Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-11-02pki_ed25519_common.c: Change function parameter nameNorbert Pocs1-1/+1
"new" is a c++ keyword which will make the build fail. Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-11-02misc.c/h: Change function parameter nameNorbert Pocs1-1/+1
"template" is a c++ keyword which will make the build fail. Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-11-02Add external c declaration for c++Norbert Pocs42-0/+335
To make sure c++ name mangling works correctly c code should be noted "extern" Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-11-02bind: Set socket connected after accepting connectionJakub Jelen1-0/+1
Also factor out the operation to the single place. Original patch drafted by Zekun Ni in the following issue: https://gitlab.com/libssh/libssh-mirror/-/issues/155 Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-10-31Remove HAVE_OPENSSL_ED25519 ifdefsNorbert Pocs1-3/+3
ED25519 is implicitly included in new (>1.1.1) openssl version, no need to check it explicitly. Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-10-12sftp: Add comment about limitation of sftp_setstatJakub Jelen1-0/+5
Fixes: #138 Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2022-10-12Fix various spelling issues reported by codespellJakub Jelen5-11/+11
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2022-10-12Support SSH_SUPPRESS_DEPRECATEDJeroen Ooms1-1/+1
Signed-off-by: Jeroen Ooms <jeroenooms@gmail.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-10-12fix printf format warningXiang Xiao1-7/+2
uint32_t should be formated by PRI?32 Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com> Change-Id: I811cfd764010f9e8bb599b370155ac065ee1905c
2022-10-07libssh.h: Update loglevel docNorbert Pocs1-5/+5
Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-09-22Implement IdentitiesOnlyLinus Kardell3-0/+3
Signed-off-by: Linus Kardell <linus.kardell@gmail.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-09-07kdf: Avoid endianess issuesAndreas Schneider2-2/+2
The key_type is only a letter, if we use and `int` and then cast it to (const char *) we will end up with a 0 value on big endian. Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2022-08-26misc: Fix format truncation in ssh_path_expand_escape()Andreas Schneider1-1/+1
error: ā€˜%uā€™ directive output may be truncated writing between 1 and 10 bytes into a region of size 6. Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-08-25misc: rename gettimeofday symbolTimo Rothenpieler1-1/+3
mingw does have this function, even though it appears to be deprecated. So the symbol has to have a different name, or linking becomes impossible. Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-08-25pki: Rework handling of EVP_PKEYs in OpenSSL backendJakub Jelen1-1/+3
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2022-08-25Initialize pkcs11 engine only onceJakub Jelen1-0/+3
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2022-08-25pki: Factor out the backend-specifics from cleaning the key structureJakub Jelen1-0/+2
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2022-07-08pki: Fix building pki_ed25519.c with libgcryptAndreas Schneider1-3/+3
Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-07-07Change const bignum to bignumNorbert Pocs1-0/+10
Openssl3.0 API retrieves bignum variables from a key. Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-07-07Use EVP_PKEY as a key type in key structsNorbert Pocs3-1/+23
Merge multiple key variables into one variable. Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-07-07Update HMAC function parameter typeNorbert Pocs2-4/+11
New openssl API, libmbedtls, libgcrypt use size_t for HMAC len pameter. New helper functions were added in libcrypto.c to avoid code duplication. (the header pki.h is needed for this reason) Signed-off-by: Norbert Pocs <npocs@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>