Commit b199467
authored
Fix key material extension during key exchange (#1689)
When the key exchange produces less key material than is needed for the cipher or hmac
algorithms, there is an iterative procedure to produce more.
For example, a SHA-1 key exchange algorithm produces 20 bytes of key material.
A SHA-256 hmac uses a 32 byte key, so one iteration of the procedure produces another
20 bytes of key material for a total of 40 which is sufficient for the hmac key.
The library works correctly in such cases of one iteration, but the logic is wrong if
more than one iteration is needed. In #1660, the connection uses a SHA-1 kex algorithm
with a SHA-512 hmac (64 byte key), requiring 3 iterations of the extension procedure and
resulting in an error upon connection.
This change fixes the logic to use the output of the previous iteration per the spec.
closes #16601 parent 6cba1be commit b199467
File tree
2 files changed
+19
-6
lines changed- src/Renci.SshNet/Security
- test/Renci.SshNet.IntegrationTests
2 files changed
+19
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
| |||
530 | 529 | | |
531 | 530 | | |
532 | 531 | | |
533 | | - | |
534 | | - | |
535 | | - | |
| 532 | + | |
536 | 533 | | |
537 | 534 | | |
538 | 535 | | |
| |||
541 | 538 | | |
542 | 539 | | |
543 | 540 | | |
544 | | - | |
| 541 | + | |
545 | 542 | | |
546 | 543 | | |
547 | | - | |
| 544 | + | |
548 | 545 | | |
549 | 546 | | |
550 | 547 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
43 | 59 | | |
44 | 60 | | |
45 | 61 | | |
| |||
0 commit comments