crypto: Change the type of server_pubkey to ssh_key

Authored by asn on Nov 10 2017, 5:35 PM.

Description

crypto: Change the type of server_pubkey to ssh_key

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>

Details

Committed
asnMar 21 2018, 8:40 PM
Parents
rLIBSSH7e1e0e5098be: misc: Use SecureZeroMemory if available for explicit_bzero
Branches
Unknown
Tags
Unknown

This commit introduces a crash in dh_handshake_server of src/server.c

line 340 server.c

rc = ssh_buffer_pack(session->out_buffer,
   "bSSS",
   SSH2_MSG_KEXDH_REPLY,
   session->next_crypto->server_pubkey,
   f,
   sig_blob);

The original code expects the second pack parameter to be ssh_string due to the signature "bSSS".

A simple fix is to convert the key back to ssh_string when it is needed:

ssh_string s_pubkey;

...

ssh_pki_export_pubkey_blob( session->next_crypto->server_pubkey, &s_pubkey );

rc = ssh_buffer_pack(session->out_buffer,
   "bSSS",
   SSH2_MSG_KEXDH_REPLY,
   s_pubkey,
   f,
   sig_blob);

ssh_string_free(s_pubkey);

This crash currently prevents the creation of a server with libssh.