Bug 2515 - Implement diffie-hellman-group{14,15,16)-sha256
Summary: Implement diffie-hellman-group{14,15,16)-sha256
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: ssh (show other bugs)
Version: -current
Hardware: All All
: P3 enhancement
Assignee: Darren Tucker
URL:
Keywords:
Depends on:
Blocks: V_7_3
  Show dependency treegraph
 
Reported: 2015-12-11 15:23 AEDT by Darren Tucker
Modified: 2023-01-13 13:40 AEDT (History)
3 users (show)

See Also:


Attachments
add diffie-hellman-group{14,15,16}-sha256 (8.31 KB, patch)
2015-12-11 15:29 AEDT, Darren Tucker
no flags Details | Diff
add diffie-hellman-group{14,15,16}-sha256 (8.81 KB, patch)
2015-12-11 17:24 AEDT, Darren Tucker
no flags Details | Diff
add diffie-hellman-group{14,15,16}-sha256 (10.69 KB, patch)
2015-12-12 19:14 AEDT, Darren Tucker
no flags Details | Diff
Fix first_kex_follows (389 bytes, patch)
2015-12-13 00:55 AEDT, Matt Johnston
no flags Details | Diff
update to draft-ietf-curdle-ssh-kex-sha2-03 prefer groups 14, 16, 18 (14.01 KB, patch)
2016-04-22 16:47 AEST, Damien Miller
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Darren Tucker 2015-12-11 15:23:11 AEDT
The IETF ssh working group has proposed adding MODP groups 15 and 16 with SHA256 and deprecating group14-sha1 (we're already doing the latter).

https://datatracker.ietf.org/doc/draft-baushke-ssh-dh-group-sha2/
Comment 1 Darren Tucker 2015-12-11 15:29:06 AEDT
Created attachment 2766 [details]
add diffie-hellman-group{14,15,16}-sha256
Comment 2 Darren Tucker 2015-12-11 17:24:49 AEDT
Created attachment 2767 [details]
add diffie-hellman-group{14,15,16}-sha256

Add missing change to ssh_api.c, from Mark D. Baushke.
Comment 3 Matt Johnston 2015-12-12 01:18:30 AEDT
This is still hashing with sha1, see kex_dh_hash() - it doesn't use hash_alg.

I've patched Dropbear for group14-sha256, https://secure.ucc.asn.au/hg/dropbear/rev/d2f9ef67af15
Comment 4 Darren Tucker 2015-12-12 19:14:05 AEDT
Created attachment 2768 [details]
add diffie-hellman-group{14,15,16}-sha256

> This is still hashing with sha1, see kex_dh_hash() - it doesn't use hash_alg.

Well, that's not cool :-)

djm implemented the code to fix this which is included in the updated patch.

With this change, openssh client interops with the dropbear server.  dbclient doesn't work (the openssh server kills the connection claiming a negative bignum) but it also worked with an unmodified openssh-current with group14-sha1 (dbclient claims "Bad hostkey signature").  I don't know where the problem is though.
Comment 5 Matt Johnston 2015-12-13 00:55:38 AEDT
Created attachment 2769 [details]
Fix first_kex_follows
Comment 6 Matt Johnston 2015-12-13 00:58:00 AEDT
The Dropbear client failure was because it's sending first_kex_follows so OpenSSH parsed the first (should be discarded) kexdhinit packet.

It looks like that broke in https://github.com/openssh/openssh-portable/commit/57d10cbe861a235dd269c74fb2fe248469ecee9d in January :-\ 

Patch attached.
Comment 7 Damien Miller 2015-12-14 09:42:53 AEDT
Bah, breaking first-kex-follows was my fault. Fix committed and will be in OpenSSH 7.2
Comment 8 Damien Miller 2016-02-26 14:44:26 AEDT
Retarget to openssh-7.3
Comment 9 Damien Miller 2016-02-26 14:47:17 AEDT
Retarget to openssh-7.3
Comment 10 Damien Miller 2016-04-22 16:47:32 AEST
Created attachment 2808 [details]
update to draft-ietf-curdle-ssh-kex-sha2-03 prefer groups 14, 16, 18

This updates Darren's diff to draft-ietf-curdle-ssh-kex-sha2-03, specifically changing the hash for the group16 KEX to SHA512. This diff also removes group 15 instead of group 18, so the groups supported are:

diffie-hellman-group14-sha256 - 2048 bit
diffie-hellman-group16-sha512 - 4096 bit
diffie-hellman-group18-sha512 - 8192 bit

IMO the powers of two are a bit cleaner than the intermediate ones. 

Finally, this tweaks the fallback group logic to choose the next larger group a bit sooner and to consider the 8192 bit fixed group.
Comment 11 Damien Miller 2016-05-02 21:01:48 AEST
Thanks Mark and Darren - patch applied. This will be in OpenSSH 7.3. 

commit 0e8eeec8e75f6d0eaf33317376f773160018a9c7
Author: djm@openbsd.org <djm@openbsd.org>
Date:   Mon May 2 10:26:04 2016 +0000

    upstream commit
    
    add support for additional fixed DH groups from
     draft-ietf-curdle-ssh-kex-sha2-03
    
    diffie-hellman-group14-sha256 (2K group)
    diffie-hellman-group16-sha512 (4K group)
    diffie-hellman-group18-sha512 (8K group)
    
    based on patch from Mark D. Baushke and Darren Tucker
    ok markus@
    
    Upstream-ID: ac00406ada4f0dfec41585ca0839f039545bc46f

commit 67f1459efd2e85bf03d032539283fa8107218936
Author: djm@openbsd.org <djm@openbsd.org>
Date:   Mon May 2 09:52:00 2016 +0000

    upstream commit
    
    unit and regress tests for SHA256/512; ok markus
    
    Upstream-Regress-ID: a0cd1a92dc824067076a5fcef83c18df9b0bf2c6
Comment 12 Damien Miller 2016-08-02 10:40:37 AEST
Close all resolved bugs after 7.3p1 release