Repository navigation
Conversation
Support for calculating MAC (message authentication code) on encrypted data instead of plain text data. This adds support for the following MACs: [email protected] [email protected] [email protected]
|
@palmin I do want to review this; I've been up against a deadline so my time is limited to this project. If you'd submit a resolved update I'll take a look. |
|
I've built my app against this PR and tried connecting to the SSH server with each of the following settings in It seemed to work fine with all of them! |
| p->payload, | ||
| session->fullpacket_payload_len, | ||
| &session->remote.mac_abstract); | ||
| int etm = session->remote.mac->etm; |
There was a problem hiding this comment.
My attempt at etm support was considerably less change in fullpacket(). Here's the changes I've made for comparison:
int compressed;
int required_full_packet = encrypted && session->remote.mac->etm == 1;
const LIBSSH2_MAC_METHOD *remote_mac = NULL;
if ( required_full_packet ) {
if ( session->remote.crypt->auth_len == 0 )
remote_mac = session->remote.mac;
} else if ( encrypted ) {
remote_mac = session->remote.mac;
}
if (session->fullpacket_state == libssh2_NB_state_idle) {
if (!required_full_packet || (required_full_packet && remote_mac == NULL) )
session->fullpacket_macstate = LIBSSH2_MAC_CONFIRMED;
session->fullpacket_payload_len = p->packet_length - 1;
if (encrypted) {
if (!required_full_packet && remote_mac) {
/* Calculate MAC hash */
remote_mac->hash(session, macbuf, /* store hash here */
session->remote.seqno,
p->init, 5,
p->payload,
session->fullpacket_payload_len,
&session->remote.mac_abstract);
/* Compare the calculated hash with the MAC we just read from
* the network. The read one is at the very end of the payload
* buffer. Note that 'payload_len' here is the packet_length
* field which includes the padding but not the MAC.
*/
if (memcmp(macbuf, p->payload + session->fullpacket_payload_len,
session->remote.mac->mac_len)) {
session->fullpacket_macstate = LIBSSH2_MAC_INVALID;
}
}
else {
//etm trim off padding byte from payload
memmove(p->payload, &p->payload[1], p->packet_length - 1);
}
}There was a problem hiding this comment.
Your change is indeed much nicer @willco007.
I merged in the latest commits from master and replaced my change with yours but it requires auth_len in _LIBSSH2_CRYPT_METHOD failing with:
[ 19%] Building C object src/CMakeFiles/libssh2.dir/transport.c.o
/Users/ander/opgaver/ShellFish/related/encrypt-then-mac/libssh2/src/transport.c:175:36: error: no member named 'auth_len' in 'struct _LIBSSH2_CRYPT_METHOD'
if (session->remote.crypt->auth_len == 0) {
~~~~~~~~~~~~~~~~~~~~~ ^
1 error generated.
_LIBSSH2_CRYPT_METHOD is currently:
Lines 926 to 948 in 821d50d
I presume auth_len is crucial for ciphers where encryption and authentication are not separate but I'm unsure how to proceed with this pull request.
Can I just assume that auth_len is always zero?
There was a problem hiding this comment.
Yes, auth_len is for chacha20 support; so assuming it's zero is correct.
There was a problem hiding this comment.
Great. Your suggestion has been applied and I'm hoping for the automated tests to settle on green.
| return NULL; | ||
| } | ||
|
|
||
| /* _libssh2_supported_key_sign_algorithms |
There was a problem hiding this comment.
This is currently on master; pull up should grab it.
|
@palmin could you pull this up one more time and hopefully we can get all green and get this merged. |
|
@willco007 Did a merge with master, crossing my fingers and awaiting approval for tests to run. |
|
@willco007 Do you have any idea what I'm doing wrong to cause this error? |
|
looks like the first error is this: |
|
Master has |
85038d2 to
7c43d58
Compare
c37ea54 to
a420005
Compare
Support for calculating MAC (message authentication code) on encrypted data instead of plain text data. This adds support for the following MACs: [email protected] [email protected] [email protected] Closes libssh2#655
Support for calculating MAC (message authentication code) on encrypted data instead of plain text data. This adds support for the following MACs: [email protected] [email protected] [email protected] Integration-patches-by: Viktor Szakats * rebase on master * fix checksrc warnings * fix compiler warnings * fix indent/whitespace/eol * merge with AES-GCM patch Closes libssh2#655 Closes libssh2#987
|
Rebase onto master is continued in #987. |
Support for calculating MAC (message authentication code) on encrypted data instead of plain text data. This adds support for the following MACs: - `[email protected]` - `[email protected]` - `[email protected]` Integration-patches-by: Viktor Szakats * rebase on master * fix checksec warnings * fix compiler warning * fix indent/whitespace/eol * rebase/manual merge onto AES-GCM patch #797 * more manual merge of `libssh2_transport_send()` based on dfandrich/shellfish Fixes #582 Closes #655 Closes #987
- `ctest` shows a the default timeout '10000000' (turns out to be in seconds), cause infinite waits e.g. in case the necessary server worker is not available. CMake CI tests take approx: - GitHub / Linux : 125 seconds - AppVeyor / Windows: 300 seconds New timeouts are: 450 and 900 seconds respectively. - set timeouts for style-check, fuzz, Linux and Windows GitHub CI jobs to avoid hanging forever. Also: - move `choco install` to before_test to make builds start faster in `appveyor.yml`. - fix some yamllint `ON`/`OFF`-confusion issue by quoting these values in `appveyor.yml`. - fix indentation in `appveyor.yml`. - convert to GitHub workflows to LF line-ending. Ref: libssh2#655 (comment) Closes libssh2#851
Support for calculating MAC (message authentication code) on encrypted data instead of plain text data. This adds support for the following MACs: - `[email protected]` - `[email protected]` - `[email protected]` Integration-patches-by: Viktor Szakats * rebase on master * fix checksec warnings * fix compiler warning * fix indent/whitespace/eol * rebase/manual merge onto AES-GCM patch libssh2#797 * more manual merge of `libssh2_transport_send()` based on dfandrich/shellfish Fixes libssh2#582 Closes libssh2#655 Closes libssh2#987
Support for calculating MAC (message authentication code) on encrypted data instead of plain text data.
This adds support for the following MACs:
[email protected]
[email protected]
[email protected]
Some hardened SSH servers only accept etm MACs.