ec: Fix build on CentOS.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
tests: Fix writing the '\0'.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
dh: Fix packing a pointer into the buffer.

Thanks to Giovanni Panozzo <giovanni@panozzo.it>.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
buffer: Implement "t" for text in ssh_buffer_pack().

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
buffer: Add a secure buffer mechanism to avoid memory spills

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
base64: Use a secure buffer.

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
crypto: Add ed25519 implementation from OpenSSH.

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
ed25519: Generate, sign and verify keys.

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
string: Correctly burn the string buffer.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
wrapper: fix z_stream leak

Ensure to free the z_stream structures as allocated from
the gzip.c initcompress, initdecompress functions.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
crypto: check malloc return in ssh_mac_ctx_init

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
pki: fail when pubkey buffer length is not ED25519_PK_LEN

Fail fast in 'pki_import_pubkey_buffer' for the ED25519 case if a buffer
sized ED25519_PK_LEN can not be retrieved.  Before, the 'memcpy' could
have read beyond the bounds of 'ssh_string_data(pubkey)'.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
pki: check ssh_buffer_pack return in ssh_pki_do_sign

Check the 'ssh_buffer_pack' return in ssh_pki_do_sign for the ED25519 case.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
ed25519: fix leak in pki_ed25519_sign

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
server: fix auth_interactive_request reply

Fix a missing 'buffer_pack' formatter in 'ssh_message_auth_interactive_request'.
With this fix the 'examples/samplesshd-kbdint' program is working again for me.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
pki_gcrypt: Initialize 'type_c' in 'pki_do_sign_sessionid'

Add missing initialization of 'type_c' field of a SSH signature in
'pki_do_sign_sessionid' procedure.

If libssh is compiled with GCrypt, 'dh_handshake_server' fails with
"Could not sign the session id" error.  The change fixes that.

Signed-off-by: Artyom V. Poptsov <poptsov.artyom@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>