Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed block sizes for hmac-sha2-256 and hmac-sha2-512 #156

Merged
merged 2 commits into from
Jan 9, 2015

Conversation

Boris-de
Copy link
Contributor

These MACs where added in fdb891b but they didn't work for me after disabling md5&sha1. The server simply didn't respond anymore eventually resulting in a timeout. I debugged this and found two issues with the current code:

  • both MACs have to use larger block/digest sizes, the previous values were the same that SHA1 had, but SHA2 needs 32 or 64 byte
  • Additionally the KeyExchanger would only generate a 20 byte key when using diffie-hellman with sha1 as a KEX. For SHA2 larger keys are used, so the first message with a mac resulted in a "Corrupted MAC on input" error on the server. So the keys had to be resized like its already done for the Ciphers.

Both MACs have to use larger block/digest sizes than SHA1.
Additionally the KEX must be changed so that it will resize
the keys "E" and "F" to get keys of the right size for those
MACs (according to section 7.2 of rfc4253)
@Boris-de
Copy link
Contributor Author

I tested this against an openssh-server with hmac-sha2-256 and hmac-sha2-512 and it now works for me.
Additionally I checked that hmac-md5, hmac-sha1 and hmac-sha1-96 still worked (using /usr/sbin/sshd -dd -o 'Port 2222' -o 'MACs ...')

@dkocher
Copy link
Contributor

dkocher commented Nov 12, 2014

Thanks for spotting these errors.

hierynomus added a commit that referenced this pull request Jan 9, 2015
fixed block sizes for hmac-sha2-256 and hmac-sha2-512
@hierynomus hierynomus merged commit 5b1f9f2 into hierynomus:master Jan 9, 2015
@hierynomus
Copy link
Owner

Thx indeed.. Just catching up on issues and PRs :)

@hierynomus
Copy link
Owner

It's merged already, but could you also provide some unit tests for this?

@Boris-de
Copy link
Contributor Author

Great, thanks for merging. I created a new PR with some tests for the MACs, see #164

@Boris-de Boris-de deleted the fix_hmac-sha2 branch January 11, 2015 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants