Commit Graph

1423 Commits

Author SHA1 Message Date
Rob Hague 18cf71bc07 Fix build break in Release (#1248) 2023-11-20 20:20:20 +01:00
se006 daa1accaf6 Fix avoidable exception when data length is too long (#823)
* Data lengths longer than stream position when data lengths are greater than int.maxvalue are ignored and do not throw an exception

* Removed unreachable test

* Do not try to load the data (just ignore it)

---------

Co-authored-by: Steve Evans <sevans1@oeconnection.com>
Co-authored-by: Rob Hague <rob.hague00@gmail.com>
2023-11-19 07:32:08 +01:00
Scott Xu f9f2b0e5f4 Expose SshIdentificationReceived event (#1195)
* Fix https://github.com/sshnet/SSH.NET/issues/1191

* Expose `SshIdentificationReceived` event so that lib consumer can adjust based on server identification

* revert unrelated code style change

* revert OpenSSH 6.6 related tests

* revert ConnectionBase

* Add unit tests

* Rename to `ServerIdentificationReceived`

* rename
2023-11-16 14:35:59 +01:00
Wojciech Nagórski 54d01621aa Enable trace logging for Integration tests (#1242) 2023-11-16 08:58:22 +01:00
Rob Hague 5021f6d4bb Use System.Security.Cryptography in AesCipher (#1235)
* Use System.Security.Cryptography in AesCipher

* don't set the IV - it is unused by ECB

* Dispose ciphers in Session if applicable

---------

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
2023-11-16 07:05:22 +01:00
Rob Hague b4c829105a Tweak diagnostics (#1241)
* Make it work (it needs the TRACE symbol defined - lots of head scratching without it)

* Expose publicly, but still in DEBUG (to allow programmatic configuration necessary in Core)

* Document how to use it

* Tweak usage (add some logs, remove key/iv information, override ToString on some Message types)

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
2023-11-16 06:39:42 +01:00
Rob Hague 58284d6019 Update global.json (#1240) 2023-11-16 06:05:37 +01:00
Pedro Fonseca 2eec748b18 Improve SFTP performance on medium/high latency connections (#866)
* Improve SFTP performance on medium-high latency connections
- Increases maxPendingReads from 10 to 100
- Increases socket send/receive buffer to 10 SSH packets (320K)

* Fix merge

* Adjust SFTP FileReader testcases to accept new MaxPendingReads values

* Fix CreateSftpFileReader testcase, make it dependant on MaxPendingReads constant

---------

Co-authored-by: Pedro Fonseca <pfonseca@qti.qualcomm.com>
2023-11-13 06:08:57 +01:00
Rob Hague 823bc1b67b Use CollectionAssert in ListDirectory tests (#1166)
* Use CollectionAssert in ListDirectory tests

* Indent the braces

---------

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
2023-11-13 06:07:26 +01:00
Gert Driesen 5ffcb94ec1 Merge pull request #1219 from Rob-Hague/testkeys
* Remove byte order mark, set eol=lf in key files
* Change the passphrase of Key.OPENSSH.ED25519.Encrypted to "12345"
* Normalize the OpenSSH files

Change the data to be in 64-wide columns instead of 70, and add a newline
at the end of the file. ssh-keygen does not like it otherwise.

puttygen Key.OPENSSH.ECDSA.Encrypted.txt -O private-openssh-new -C Key.OPENSSH.ECDSA.Encrypted
puttygen Key.OPENSSH.ECDSA.txt -O private-openssh-new -C Key.OPENSSH.ECDSA
puttygen Key.OPENSSH.ECDSA384.Encrypted.txt -O private-openssh-new -C Key.OPENSSH.ECDSA384.Encrypted
puttygen Key.OPENSSH.ECDSA384.txt -O private-openssh-new -C Key.OPENSSH.ECDSA384
puttygen Key.OPENSSH.ECDSA521.Encrypted.txt -O private-openssh-new -C Key.OPENSSH.ECDSA521.Encrypted
puttygen Key.OPENSSH.ECDSA521.txt -O private-openssh-new -C Key.OPENSSH.ECDSA521
puttygen Key.OPENSSH.ED25519.Encrypted.txt -O private-openssh-new -C Key.OPENSSH.ED25519.Encrypted
puttygen Key.OPENSSH.ED25519.txt -O private-openssh-new -C Key.OPENSSH.ED25519
puttygen Key.OPENSSH.RSA.Encrypted.txt -O private-openssh-new -C Key.OPENSSH.RSA.Encrypted
puttygen Key.OPENSSH.RSA.txt -O private-openssh-new -C Key.OPENSSH.RSA

(the -C flag changes the comment, otherwise puttygen refuses to do anything)

* Add OpenSSH public key files

Generated with

puttygen Key.OPENSSH.ECDSA.Encrypted.txt -o Key.OPENSSH.ECDSA.Encrypted.pub -O public-openssh
puttygen Key.OPENSSH.ECDSA.txt -o Key.OPENSSH.ECDSA.pub -O public-openssh
puttygen Key.OPENSSH.ECDSA384.Encrypted.txt -o Key.OPENSSH.ECDSA384.Encrypted.pub -O public-openssh
puttygen Key.OPENSSH.ECDSA384.txt -o Key.OPENSSH.ECDSA384.pub -O public-openssh
puttygen Key.OPENSSH.ECDSA521.Encrypted.txt -o Key.OPENSSH.ECDSA521.Encrypted.pub -O public-openssh
puttygen Key.OPENSSH.ECDSA521.txt -o Key.OPENSSH.ECDSA521.pub -O public-openssh
puttygen Key.OPENSSH.ED25519.Encrypted.txt -o Key.OPENSSH.ED25519.Encrypted.pub -O public-openssh
puttygen Key.OPENSSH.ED25519.txt -o Key.OPENSSH.ED25519.pub -O public-openssh
puttygen Key.OPENSSH.RSA.Encrypted.txt -o Key.OPENSSH.RSA.Encrypted.pub -O public-openssh
puttygen Key.OPENSSH.RSA.txt -o Key.OPENSSH.RSA.pub -O public-openssh

and so forth. Some whose ciphers are unsupported by puttygen were generated with e.g.

sudo ssh-keygen -f Key.RSA.Encrypted.Des.CBC.12345.txt -y > Key.RSA.Encrypted.Des.CBC.12345.pub

* Remove duplicate GetManifestResourceStream helpers

* Use shared Data folder for client keys in integration tests

* Remove unused symbols
2023-11-12 17:02:55 +01:00
Robert Hague 09ad44a823 Remove unused symbols 2023-11-11 18:47:46 +01:00
Robert Hague 0829fce6e4 Use shared Data folder for client keys in integration tests 2023-11-11 18:47:46 +01:00
Robert Hague 1fc6360cf8 Remove duplicate GetManifestResourceStream helpers 2023-11-11 17:39:34 +01:00
Robert Hague d36e7f552d Add OpenSSH public key files
Generated with

puttygen Key.OPENSSH.ECDSA.Encrypted.txt -o Key.OPENSSH.ECDSA.Encrypted.pub -O public-openssh
puttygen Key.OPENSSH.ECDSA.txt -o Key.OPENSSH.ECDSA.pub -O public-openssh
puttygen Key.OPENSSH.ECDSA384.Encrypted.txt -o Key.OPENSSH.ECDSA384.Encrypted.pub -O public-openssh
puttygen Key.OPENSSH.ECDSA384.txt -o Key.OPENSSH.ECDSA384.pub -O public-openssh
puttygen Key.OPENSSH.ECDSA521.Encrypted.txt -o Key.OPENSSH.ECDSA521.Encrypted.pub -O public-openssh
puttygen Key.OPENSSH.ECDSA521.txt -o Key.OPENSSH.ECDSA521.pub -O public-openssh
puttygen Key.OPENSSH.ED25519.Encrypted.txt -o Key.OPENSSH.ED25519.Encrypted.pub -O public-openssh
puttygen Key.OPENSSH.ED25519.txt -o Key.OPENSSH.ED25519.pub -O public-openssh
puttygen Key.OPENSSH.RSA.Encrypted.txt -o Key.OPENSSH.RSA.Encrypted.pub -O public-openssh
puttygen Key.OPENSSH.RSA.txt -o Key.OPENSSH.RSA.pub -O public-openssh

and so forth. Some whose ciphers are unsupported by puttygen were generated with e.g.

sudo ssh-keygen -f Key.RSA.Encrypted.Des.CBC.12345.txt -y > Key.RSA.Encrypted.Des.CBC.12345.pub
2023-11-11 17:39:34 +01:00
Robert Hague 9d6f3ef979 Normalize the OpenSSH files
Change the data to be in 64-wide columns instead of 70, and add a newline
at the end of the file. ssh-keygen does not like it otherwise.

puttygen Key.OPENSSH.ECDSA.Encrypted.txt -O private-openssh-new -C Key.OPENSSH.ECDSA.Encrypted
puttygen Key.OPENSSH.ECDSA.txt -O private-openssh-new -C Key.OPENSSH.ECDSA
puttygen Key.OPENSSH.ECDSA384.Encrypted.txt -O private-openssh-new -C Key.OPENSSH.ECDSA384.Encrypted
puttygen Key.OPENSSH.ECDSA384.txt -O private-openssh-new -C Key.OPENSSH.ECDSA384
puttygen Key.OPENSSH.ECDSA521.Encrypted.txt -O private-openssh-new -C Key.OPENSSH.ECDSA521.Encrypted
puttygen Key.OPENSSH.ECDSA521.txt -O private-openssh-new -C Key.OPENSSH.ECDSA521
puttygen Key.OPENSSH.ED25519.Encrypted.txt -O private-openssh-new -C Key.OPENSSH.ED25519.Encrypted
puttygen Key.OPENSSH.ED25519.txt -O private-openssh-new -C Key.OPENSSH.ED25519
puttygen Key.OPENSSH.RSA.Encrypted.txt -O private-openssh-new -C Key.OPENSSH.RSA.Encrypted
puttygen Key.OPENSSH.RSA.txt -O private-openssh-new -C Key.OPENSSH.RSA

(the -C flag changes the comment, otherwise puttygen refuses to do anything)
2023-11-11 17:39:34 +01:00
Robert Hague 60ba1dd090 Change the passphrase of Key.OPENSSH.ED25519.Encrypted to "12345" 2023-11-11 17:39:33 +01:00
Robert Hague 6ec6dc13fd Remove byte order mark, set eol=lf in key files 2023-11-11 17:39:33 +01:00
Rob Hague 826222f6fe Increase test coverage for AesCipher (#1232)
* Increase test coverage for AesCipher

The tests were generated by a script which is also added for posterity.
The script works by running "openssl enc [...]" (via WSL) to generate the
expected encrypted values, and also verifies those values against the .NET
BCL implementation as an extra validation (it uncovered a difference in
CFB mode between the two relating to the feedback size).

* Fix OfbCipherMode

It was an exact copy of CfbCipherMode
2023-11-05 09:45:30 +01:00
Gert Driesen 508fc87d2a Fix analyzer errors in Renci.SshNet and Renci.SshNet.TestTools.OpenSSH (#1229)
* Fix analyzer errors in Renci.SshNet and Renci.SshNet.TestTools.OpenSSH.
Suppress all errors in unit tests and integration tests.

* Update unit tests now that we pass 'mode' as argument name when we throw ArgumentException.

* Remove stale comment and add unit tests for SshData.ReadBytes(int length).

* Remove unnessary suppression.

* Remove Visual Studio magic.

* Removed duplicate source file.

* Clarified that suppression hides a false positive.

* Remove suppressions for S2372.

* Update ReadExtensionPair() to return concrete dictionary.
2023-11-01 11:33:42 +01:00
drieseng f745b3f803 Use <see langword="..."/> for language keywords. 2023-10-29 11:35:21 +01:00
Gert Driesen 42ff9206d2 Merge partial classes and complete IForwardedPort interface (#1223)
* Merge partial classes.
Complete IForwardedPort interface.
Expoe Closing event publicly on ForwardedPort.
Disable CA1030 (use events where appropriate).

* Merge partial classes.
Complete IForwardedPort interface.
Expoe Closing event publicly on ForwardedPort.
Disable CA1030 (use events where appropriate).

* Use local function and remove suppression.

* Compile regular expressions.

* Fix build, pfff.

---------

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
2023-10-25 22:14:56 +02:00
Gert Driesen 066f9982e3 Upgrade .NET SDK from 7.402 to 7.403. (#1222) 2023-10-25 08:35:44 +02:00
Wojciech Nagórski 8e2363360d Update Nugets 10/2023 (#1214)
* Update Nugets 10/2023

* Fix
2023-10-16 15:06:18 +02:00
Rob Hague 46796094f1 Delete more dummy tests (#1213) 2023-10-15 08:25:22 +02:00
Wojciech Nagórski f1297dec75 Move test projects (#1212)
* Move test projects to test folder.
Move global.json to root of repo.
Update solution items in solution.

* Move test projects to test folder.
Move global.json to root of repo.
Update solution items in solution.
Update appveyor configuration/

* Attempt to have appveyor use the correct .NET SDK.

* Update .NET SDK to version 7.0.402.

* Move Data folder below Renci.SshNet.Tests.

* Make csinst less chatty.

* Move Data folder directly below test folder as it's used by multiple test projects.

* Remove CS1591 nowarn from concrete test projects as this is already defined in the Directory.Build.props that is in the test folder.

* Fix integration test after moving test projects

---------

Co-authored-by: drieseng <gert.driesen@telenet.be>
2023-10-14 22:16:11 +02:00
Rob Hague 0e9b518492 Remove placeholder tests (#1183)
* Remove placeholder tests

* Move Reverse perf test to benchmarks project

---------

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
2023-10-14 21:41:04 +02:00
Patrick-3000 91d1ed2cbd Enable list directory async for net framework (#1206)
* Enable ListDirectoryAsync for .NET Framework
* Removed (now) unused constant.
2023-10-14 16:35:31 +02:00
Gert Driesen 1c7166a002 Update tests for SetLastAccessTime(Utc) to also verify the time component and the Kind of the DateTime value returned by GetLastAccessTime(Utc). (#1198) 2023.0.0 2023-10-09 05:45:16 +02:00
Rob Hague 70f58b7660 Add/migrate hmac+cipher integration tests (#1189)
* Add/migrate hmac+cipher integration tests

* fix integration tests

---------

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
2023-09-29 14:38:32 +02:00
Wojciech Nagórski 5803ada7cf Implement set last write and access time (#1194) 2023-09-29 10:07:18 +02:00
Wojciech Nagórski cd1151deca Update ISftpClient for #120 (#1193) 2023-09-29 09:05:45 +02:00
Patrick Yates f28c2c2dd0 Fix for channel session semaphore from thread blocking (#1071)
* Merging fix from @clivetong into our own SSH.NET fork
- The following article describes some of the issues with the double check lock that we have seen issues with: https://www.sudhanshutheone.com/posts/double-check-lock-csharp

* Merging fix from @clivetong into our own SSH.NET fork
- The following article describes some of the issues with the double check lock that we have seen issues with: https://www.sudhanshutheone.com/posts/double-check-lock-csharp

* Update Channel to fix AppVeyor failure (field should be readonly)
2023-09-28 21:01:18 +02:00
Dmitry Tsarevich dd2e55209b Use OS-agnostic socket error codes to allow tests run on different OSes (#1179)
SocketErrorCode is OS agnostic, ErrorCode is OS specific.

On Windows ErrorCode = (int) SocketErrorCode, but on Mac and Unix it is not.

For example ExitCode for HostNotFound (11001) on Windows is 11001, on Mac & Unix is -131073. So testing for ExitCode == 11001 fails on Mac & Unix.

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
2023-09-26 21:29:45 +02:00
Wojciech Nagórski 4ba591ee0b FingerPrints (#1186) 2023-09-26 21:00:20 +02:00
Rob Hague fdd113022b Enable DSA tests (#1181)
Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
2023-09-25 22:22:15 +02:00
Rob Hague 51e0c67f40 Try to "fix" the flaky test (#1185) 2023-09-25 21:35:14 +02:00
Rob Hague aade354748 Use ExceptionDispatchInfo in more places (#1182)
Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
2023-09-23 17:20:59 +02:00
Wojciech Nagórski 18e6673031 Improvements after #1177 (#1180) 2023-09-23 08:33:10 +02:00
Rob Hague 8732d3d7ef Add support for RSA SHA-2 public key algorithms (#1177)
* Abstract out the hash algorithm from RsaDigitalSignature

* Add integration tests

* Add DigitalSignature property to KeyHostAlgorithm

* Add IHostAlgorithmsProvider interface

* Verify the host signature

* Fix HostKeyEventArgsTest after merge

* Remove PubkeyAcceptedAlgorithms ssh-rsa

* Add test coverage for RSA keys in PrivateKeyFile

* Obsolete IPrivateKeySource

---------

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
2023-09-23 07:09:41 +02:00
Dāvis Mošenkovs 43329eef28 Support SHA256 fingerprints for host key validation (#1098)
* Add tests for HostKeyEventArgs

* Add SHA256 fingerprint support
2023-09-17 22:44:26 +02:00
Igor Milavec dcc596a774 Use ExceptionDispatchInfo to retain call stack in Session.WaitOnHandle() (#936)
* Use ExceptionDispatchInfo to retain call stack in Session.WaitOnHandle()

* merge

* Update src/Renci.SshNet/Session.cs

Co-authored-by: Rob Hague <rob.hague00@gmail.com>

---------

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
Co-authored-by: Rob Hague <rob.hague00@gmail.com>
2023-09-15 09:45:17 +02:00
Rob Hague 60de8a41a4 Add a benchmarks project (#1151)
* Add a benchmarks project

* Small improvements

---------

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
2023-09-15 05:32:13 +02:00
Wojciech Nagórski 9593e87e54 Move Integration tests (#1173)
* Renci.SshNet.IntegrationTests

* Renci.SshNet.TestTools.OpenSSH

* Move integration tests to main repo

* Move old tests to new integration tests

* Move old integration tests to new integration tests

* Move more tests

* Move authentication tests

* Move SshClientTests

* Fix some tests

* Remove duplicated test

* Poc of ProcessDisruptor

* Rename

* Some fixes

* Remove performance tests

* Small improvements
2023-09-12 13:34:43 +02:00
Rob Hague 9f1699b560 Delete performance/longrunning tests (#1143)
Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
2023-09-06 16:18:25 +02:00
Rob Hague 004b57ae9e Fix the assembly resolution build warning (#1165) 2023-08-30 14:56:49 +02:00
Wojciech Nagórski 7cd0487785 ListDirectoryAsync return IAsyncEnumerable (#1126)
* ListDirectoryAsync return IAsyncEnumerable

* Fix documentation

* Update README.md

* Fix

* Add Sftp ListDirectoryAsync test

* Revert

* Integration tests for ListDirectoryAsync with IAsyncEnumerable
2023-08-30 10:22:10 +02:00
Wojciech Nagórski 1b46264bd3 Merge pull request #1148 from WojciechNagorski/integration-tests-mstests
MSTest Integration tests
2023-08-30 07:14:02 +02:00
Wojciech Nagórski bfef6aa2a7 Merge branch 'develop' of https://github.com/sshnet/SSH.NET into integration-tests-mstests 2023-08-30 06:10:53 +02:00
Wojciech Nagórski 82dc77a2f8 Use correct SSH.NET 2023-08-30 06:10:28 +02:00
Wojciech Nagórski 77b27e570d Merge branch 'master' of https://github.com/sshnet/SSH.NET into integration-tests-mstests 2023-08-26 05:56:15 +02:00