SSH2: send KEXINIT packet and identification string first or last (for 1.0 branch) #1162
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This branch adds four new methods:
RFC4253 § 4.2 says "when the connection has been established, both sides MUST send an identification string" but it does not say which side should send it first.
RFC4253 § 7.1 says "key exchange begins by each side sending the [SSH_MSG_KEXINIT] packet" but again it does not say which side should send it first.
In theory, it shouldn't matter which side sends it first but in practice it sometimes does.
#1046 demonstrates that phpseclib sending the SSH_MSG_KEXINIT packet last can sometimes result in errors so, in lieu of any evidence that sending it first can result in errors, I've changed it so that it sends it first by default now. BUT if that does cause errors then phpseclib can be easily made to send it last.
https://stackoverflow.com/q/40430024/569976 demonstrates that phpseclib sending the identification packet last can result in errors but 535104c#commitcomment-23493058 demonstrates that sending it first can result in errors as well. This commit preserves the current behavior but makes it so that the current behavior can be overwritten.