ssh-agent: keygen: Fix negative numbers in RSA key

The private exponent d may be negative in which case an additional pad
byte is needed. Otherwise ssh-agent fails to load the key.

Signed-off-by: Konrad Gräfe <kgraefe@paktolos.net>
This commit is contained in:
Konrad Gräfe 2024-03-04 14:52:26 +01:00 committed by Jonathan White
parent 2086e4c7d1
commit d2a4ccbc16

View File

@ -65,7 +65,7 @@ namespace OpenSSHKeyGen
BinaryStream privateStream(&privateData);
bigIntToStream(rsaKey.get_n(), privateStream, 1);
bigIntToStream(rsaKey.get_e(), privateStream);
bigIntToStream(rsaKey.get_d(), privateStream);
bigIntToStream(rsaKey.get_d(), privateStream, 1);
bigIntToStream(rsaKey.get_c(), privateStream, 1);
bigIntToStream(rsaKey.get_p(), privateStream, 1);
bigIntToStream(rsaKey.get_q(), privateStream, 1);