* Refactor logging to allow a loggerfactory per session specified in the ConnectionInfo.
This commit introduces an `ILoggerFactory` to various classes, replacing the static logger factory with an instance-based approach for more flexible and session-specific logging. These changes improve the logging framework's flexibility and maintainability and allow unit testing of logging.
* Improvements bases on feedback. Fixed tests. Added documentation.
* Update src/Renci.SshNet/ConnectionInfo.cs
---------
Co-authored-by: Rob Hague <rob.hague00@gmail.com>
* Preparation to enforce formatting and style in CI
- enabled IDE0055 to enforce formatting on build
- disabled SA1137 and SA1025 because they are already
covered by IDE0055
- disabled SA1021 because it conflicts with csharp_space_after_cast
* Cleanup formatting and style on codebase
This commit has no manual changes, it is the result
of running "dotnet format whitespace" and "dotnet format style"
* new formatting fixes after merge
* appveyor: set git autocrlf
as suggested by sharwell to hopefully fix Windows CI.
* use autocrlf input
to hopefully fix Linux tests
* fix formatting
* use autocrlf input for Linux only
* set csharp_space_after_cast to false
* Revert SA1021 suppression
---------
Co-authored-by: Robert Hague <rh@johnstreetcapital.com>
* Implement OpenSSH strict key exchange extension
* The pseudo-algorithm
is only valid in the initial SSH2_MSG_KEXINIT and MUST be ignored
if they are present in subsequent SSH2_MSG_KEXINIT packets.
* Only send strict kex pseudo algorithm for the first kex.
Strictly disable non-kex massages in strict kex mode.
* Unit tests for strict kex
* More unit tests
* More unit tests
* Correct file name
* Update SessionTest_ConnectingBase.cs
* More unit tests
* Delete SessionTest_Connecting_ServerSendsMaxIgnoreMessagesBeforeKexInit.cs
* Add a comment about throwing exception when inbound sequence number is about to wrap during init kex.
* Delete SessionTest_Connecting_ServerSendsDebugMessageAfterKexInit_NoStrictKex.cs
* Fix build
* Update test/Renci.SshNet.Tests/Classes/SessionTest_Connected.cs
---------
Co-authored-by: Rob Hague <rob.hague00@gmail.com>
* Init AeadCipher
* Move AeadCipher to parent folder. Move EncryptBlock/DecryptBlock from SymmetricCipher to BlockCipher
* simplify parameter name
* Implement AesGcmCipher
* Update README
* Remove protected IV from AeadCipher; Set offset to outbound sequence just like other ciphers
* Rename associatedData to packetLengthField
* Use Span<byte> to avoid unnecessary allocations
* Use `Span` to improve performance when `IncrementCounter()`
* Add `IsAead` property to `CipherInfo`. Include packet length field and tag field in offset and length when call AesGcm's `Decrypt(...)` method. Do not determine HMAC if cipher is AesGcm during kex.
* Fix build
* Fix UT
* Check `AesGcm.IsSupported` before add to the `Encryptions` collection.
Guard AES-GCM with `NET6_0_OR_GREATER`.
Insert AES-GCM ciphers right after AES-CTR ciphers but before AES-CBC ciphers, which is similar with OpenSSH:
```
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
```
Although Dictionary's order is not defined, from observation, it is in the same order with add. Anyway that would be another topic.
* Suppress CA1859 "Use concrete types when possible for improved performance" for `ConnectionInfo.Encryptions`.
Test `Aes128Gcm` and `Aes256Gcm` only when `NET6_0_OR_GREATER`
* Update xml doc comments. Do not treat AesGcmCipher separately in Session.cs
* Fix build
* Fix build
* Update the comment as ChaCha20Poly1305 uses a separated key to encypt the packet length and the size it 4.
* Update src/Renci.SshNet/Security/Cryptography/Cipher.cs
Co-authored-by: Rob Hague <rob.hague00@gmail.com>
* Make `AesGcmCipher` internal.
Assert offset when decrypt.
* Fix nullable error in build
* typos
---------
Co-authored-by: Rob Hague <rob.hague00@gmail.com>
* Support ETM (Encrypt-then-MAC) variants for HMAC
* Support ETM (Encrypt-then-MAC) variants for HMAC
* Remove `ETM` property from `HashInfo`
* Add support for HmacMd5Etm, HmacMd5_96_Etm, HmacSha1Etm and HmacSha1_96_Etm
Explicitly specify etm even if false
* Add Encrypt-then-MAC variants to README.md
* Add back empty span to prevent auto link
* Store ETM in `HashInfo`;
Change `HMAC Create[...]Hash()` to `HashAlgorithm Create[...]Hash(out bool isEncryptThenMAC)`
* Exludes the test projects from code coverage reports
* Removes MessageAttribute in favor of properties on Message class
* Benchmark for removal of MessageAttribute
* 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
* 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>