Skip to content

Commit

Permalink
protocol/kex: fix preferred prime size calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
mscdex committed Jul 8, 2021
1 parent 27795a3 commit 6d8692d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/protocol/kex.js
Original file line number Diff line number Diff line change
Expand Up @@ -1776,16 +1776,18 @@ function onKEXPayload(state, payload) {
}

function dhEstimate(neg) {
const csCipher = CIPHER_INFO[neg.cs.cipher];
const scCipher = CIPHER_INFO[neg.sc.cipher];
// XXX: if OpenSSH's `umac-*` MACs are ever supported, their key lengths will
// also need to be considered when calculating `bits`
const bits = Math.max(
0,
(neg.cs.cipher.sslName === 'des-ede3-cbc' ? 14 : neg.cs.cipher.keyLen),
neg.cs.cipher.blockLen,
neg.cs.cipher.ivLen,
neg.cs.mac.actualLen,
(neg.sc.cipher.sslName === 'des-ede3-cbc' ? 14 : neg.sc.cipher.keyLen),
neg.sc.cipher.blockLen,
neg.sc.cipher.ivLen,
neg.sc.mac.actualLen
(csCipher.sslName === 'des-ede3-cbc' ? 14 : csCipher.keyLen),
csCipher.blockLen,
csCipher.ivLen,
(scCipher.sslName === 'des-ede3-cbc' ? 14 : scCipher.keyLen),
scCipher.blockLen,
scCipher.ivLen
) * 8;
if (bits <= 112)
return 2048;
Expand Down

0 comments on commit 6d8692d

Please sign in to comment.