Andreas Schneider
e4711c469f
pki: Use strndup in ssh_pki_export_privkey_base64()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-20 16:35:13 +02:00
DavidWed
d0ce2d1ecd
pki: Add ssh_pki_export_privkey_base64()
...
Fixes T53
Signed-off-by: DavidWedderwille <davidwe@posteo.de>
Reviewed-by: Andreas Schneider <asn@samba.org>
2018-09-20 16:35:13 +02:00
Andreas Schneider
92aa2cf496
dh: Use ssh_get_fingerprint_hash() in ssh_print_hash()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-20 16:35:13 +02:00
Andreas Schneider
bbed139eca
dh: Add ssh_get_fingerprint_hash()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-20 16:35:13 +02:00
Anderson Toshiyuki Sasaki
0eab270754
dh: Removed duplicated code
...
The code for calculating SHA 512 in ssh_make_sessionid() had been
duplicated; the cases were unified.
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2018-09-20 15:37:23 +02:00
Anderson Toshiyuki Sasaki
71594f9d6c
dh: Add diffie-hellman-group18-sha512 support
...
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2018-09-20 15:37:23 +02:00
Andreas Schneider
2ae2baf9ca
buffer: Don't call va_end() twice
...
This is handled in the cleanup.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-20 15:37:23 +02:00
Andreas Schneider
a30d542207
sftp: Include stdint.h
...
Thanks to Apex Liu
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-19 12:25:03 +02:00
Anderson Toshiyuki Sasaki
d9d3b65df2
dh: Add diffie-hellman-group16-sha512 support
...
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-19 12:17:02 +02:00
Harald Sitter
97cb302c0e
sftp: fix buffer_unpack argument to be char** rather than char*
...
Summary:
buffer variable 's' gets unpacked as char**, the previous code was passing
a char* causing segfaults on all readlink calls inside the unpacking code
Test Plan:
- without patchy examples/samplesftp segfaults in readlink
- with patchy it doesn't
Reviewers: asn
Differential Revision: https://bugs.libssh.org/D14
Signed-off-by: Harald Sitter <sitter@kde.org>
2018-09-19 11:18:12 +02:00
Andreas Schneider
90373d8394
buffer: Do cleanup if ssh_buffer_unpack() fails in the first loop
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-19 11:18:12 +02:00
Andreas Schneider
07f7fa7806
buffer: Fix invalid memory access in ssh_buffer_unpack()
...
Found by oss-fuzz.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-19 11:18:02 +02:00
Andreas Schneider
cc83b463ce
sftp: Fix a possible null pointer dereference
...
CID 1395721
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-18 10:19:59 +02:00
Jakub Jelen
1226de875b
pki: Implement reading public key from OpenSSH private key container
...
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-18 09:53:49 +02:00
Jakub Jelen
39102224b2
pki: Allow reading keys in new OpenSSH format
...
This implements reading the OpenSSH key format accross the
cryptographic backends. Most of the code is shared and moved
to pki.c, just the building of the keys is implemented in
pki_privkey_build_*() functions.
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-18 09:53:49 +02:00
Jakub Jelen
d23bda8181
pki: Use unpack to simplify public key reading
...
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-18 09:53:49 +02:00
Jakub Jelen
86d521cbe7
buffer: Make sure unpack of secure buffers securely cleans up
...
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-18 09:53:49 +02:00
Andreas Schneider
856dc698a9
libmbedcrypto: Fix creating evp hash
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-18 09:51:41 +02:00
Jakub Jelen
4d09c6dc31
buffer: Reformat ssh_buffer_get_ssh_string
...
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 16:39:38 +02:00
Jakub Jelen
c04eac40f3
pki_crypto: Clarify that memory passed with set0 is managed by openssl objects
...
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 16:39:38 +02:00
Jakub Jelen
8cc0672c0c
pki_mbedcrypto: pki_pubkey_build_rsa: properly clean up on error
...
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 16:39:38 +02:00
Jakub Jelen
8f7214a584
pki: Initialize pointers to NULL
...
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 16:39:38 +02:00
Jakub Jelen
039c066da5
buffer: Fix typo
...
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 16:39:38 +02:00
Andreas Schneider
e5170107c9
auth: Fix ecdsa pubkey auth
...
Pair-Programmed-With: Jakub Jelen <jjelen@redhat.com>
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
2018-09-17 16:39:12 +02:00
Andreas Schneider
0762057eb9
sftp: Move the packet payload to the message
...
This reduces memory allocations and copying.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
57153f6481
sftp: Use SSH_BUFFER_FREE in sftp_message_free()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
4c32befd93
sftp: Reformat sftp_message_free()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
be8302e2f3
sftp: Allocate a new buffer in sftp_packet_read() if needed
...
We will move the buffer to the message instead of duplicating the
memory.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
97d2e1f4cb
sftp: Reformat sftp_read_and_dispatch()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
12fc0ea1bf
sftp: Validate the packet handle before we allocate memory
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
573eab0d51
sftp: Reformat sftp_get_message()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
0e317e612f
sftp: Use bool for is_eof in sftp_packet_read()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
01135703a3
sftp: Use 's' only in the scope it is needed
...
This revaled a bug when reading the packet type.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
c070414309
sftp: Use 16K for the transfer buffer size
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
d2cc4eccc7
sftp: Get the packet type directly from the buffer
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
38781f69b0
sftp: Limit packet size to 256 MB
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
dc4faf9952
sftp: Directly read and validate the packet size from the bufffer
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
cbbc6ddcb6
sftp: Use read_packet from sftp handle
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
a7456bf4d5
sftp: Simplify the code for reading data
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
afc14fe003
sftp: Reformat sftp_packet_read()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
79a3fcac72
sftp: Keep a ssh_packet for reading in the sftp handle
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
945afaa6b4
sftp: Remove ZERO_STRUCTP from sftp_free()
...
The structure doesn't hold any sensitive data and this would be
optimized away anyway.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
d840a05be3
sftp: Reformat sftp_free()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
662c30eb72
sftp: Reformat sftp_new()
...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
2e8f2f03e7
cmake: Correctly detect if glob has gl_flags member
...
Thanks to Baruch Siach.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
ceecd3fd6f
config: Fix size type
...
src/config.c:562:12: error: assuming signed overflow does not occur when
simplifying conditional to constant [-Werror=strict-overflow]
if (args < 1) {
^
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-06 08:28:24 +02:00
Jakub Jelen
e9b44d26b1
config: Parse Match keyword
...
Amends f818e63f8, which introduced the constants and matching of this
configuration option, but did not implement the handling of the values
which was causing the configuration parser failing for certain
configurations.
This commit exposes match_pattern_list() from match.c
Red Hat Bugzilla:
https://bugzilla.redhat.com/show_bug.cgi?id=1624425
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-05 11:43:05 +02:00
Jakub Jelen
9f5f10552b
config: Do not overwrite previously matched result in Host blocks
...
The match_hostname() expects comma separated list, while the Host
config keyword in openssh uses spaces separated list by default.
Therefore any subseqent match or negated match in space separated
list will overwrite the previous matches.
This also adjusts the tests to make sure both of the versions work.
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-05 11:43:05 +02:00
Andreas Schneider
ef06ef2c1b
channels: Allow infinite timeout for ssh_channel_read_timout()
...
This is also documented.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-05 11:43:05 +02:00
Andreas Schneider
e558827c4e
channels: Don't read from a closed channel
...
Fixes T76
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-04 20:34:52 +02:00