aboutsummaryrefslogtreecommitdiff
path: root/src/packet_cb.c
diff options
context:
space:
mode:
authorJakub Jelen <jjelen@redhat.com>2018-08-06 11:51:26 +0200
committerAndreas Schneider <asn@cryptomilk.org>2018-08-31 14:18:34 +0200
commit761225712a28d70adea7a2b872c265bc98a83511 (patch)
treee3b64f27742c357a1625e30407d12b7888c2e9cc /src/packet_cb.c
parentdf13d8c61f4fe0cc7d07260d59740eaf7f939d65 (diff)
downloadlibssh-761225712a28d70adea7a2b872c265bc98a83511.tar.gz
libssh-761225712a28d70adea7a2b872c265bc98a83511.tar.xz
libssh-761225712a28d70adea7a2b872c265bc98a83511.zip
client: Handle the MSG_EXT_INFO packet signalling supported extensions
RFC 8308: The extension negotiation in Secure Shell (SSH) Protocol RFC 8332: Use of RSA Keys with SHA-256 and SHA-512 in the Secure Shell (SSH) Protocol Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src/packet_cb.c')
-rw-r--r--src/packet_cb.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/packet_cb.c b/src/packet_cb.c
index ecf327ef..c3a1997f 100644
--- a/src/packet_cb.c
+++ b/src/packet_cb.c
@@ -270,3 +270,55 @@ SSH_PACKET_CALLBACK(ssh_packet_service_accept){
return SSH_PACKET_USED;
}
+
+/**
+ * @internal
+ * @brief handles a SSH2_MSG_EXT_INFO packet defined in RFC 8308
+ *
+ */
+SSH_PACKET_CALLBACK(ssh_packet_ext_info)
+{
+ int rc;
+ uint32_t nr_extensions = 0;
+ uint32_t i;
+ (void)type;
+ (void)user;
+
+ SSH_LOG(SSH_LOG_PACKET, "Received SSH_MSG_EXT_INFO");
+
+ rc = ssh_buffer_get_u32(packet, &nr_extensions);
+ if (rc == 0) {
+ SSH_LOG(SSH_LOG_PACKET, "Failed to read number of extensions");
+ return SSH_PACKET_USED;
+ }
+ nr_extensions = ntohl(nr_extensions);
+ SSH_LOG(SSH_LOG_PACKET, "Follows %u extensions", nr_extensions);
+
+ for (i = 0; i < nr_extensions; i++) {
+ char *name = NULL;
+ char *value = NULL;
+ int cmp;
+
+ rc = ssh_buffer_unpack(packet, "ss", &name, &value);
+ if (rc != SSH_OK) {
+ SSH_LOG(SSH_LOG_PACKET, "Error reading extension name-value pair");
+ return SSH_PACKET_USED;
+ }
+
+ cmp = strcmp(name, "server-sig-algs");
+ if (cmp == 0) {
+ /* TODO check for NULL bytes */
+ SSH_LOG(SSH_LOG_PACKET, "Extension: %s=<%s>", name, value);
+ if (ssh_match_group(value, "rsa-sha2-512")) {
+ session->extensions |= SSH_EXT_SIG_RSA_SHA512;
+ }
+ if (ssh_match_group(value, "rsa-sha2-256")) {
+ session->extensions |= SSH_EXT_SIG_RSA_SHA256;
+ }
+ }
+ free(name);
+ free(value);
+ }
+
+ return SSH_PACKET_USED;
+}