Skip to content

Commit e1720c9

Browse files
committed
ssh: adjust private key length for DH key generation
- if calculated private key length is equal or exceeds number of bits in P (PBits) - use PBits - 1
1 parent 412bff5 commit e1720c9

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/ssh/src/ssh_transport.erl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2189,6 +2189,8 @@ parallell_gen_key(Ssh = #ssh{keyex_key = {x, {G, P}},
21892189
algorithms = Algs}) ->
21902190
Sz = dh_bits(Algs),
21912191
{Public, Private} = generate_key(dh, [P,G,2*Sz]),
2192+
BitSize = fun(N) -> bit_size(binary:encode_unsigned(N)) end,
2193+
{Public, Private} = generate_key(dh, [P,G,min(BitSize(P)-1, 2*Sz)]),
21922194
Ssh#ssh{keyex_key = {{Private, Public}, {G, P}}}.
21932195

21942196

0 commit comments

Comments
 (0)