Skip to content

Commit

Permalink
libguile-ssh/session-func: Handle SSH_OPTIONS_RSA_MIN_SIZE
Browse files Browse the repository at this point in the history
* libguile-ssh/session-func.c (set_option): Handle SSH_OPTIONS_RSA_MIN_SIZE.
* doc/api-sessions.texi: Update.
* tests/session.scm ("session-set!, rsa-min-size"): New test.
* NEWS: Update.
  • Loading branch information
artyom-poptsov committed May 1, 2024
1 parent 524649c commit 40b0e8a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ This patch fixes this error.

Reported by graywolf in
<https://github.com/artyom-poptsov/guile-ssh/issues/38>
** =session-set!= now allows to set =rsa-min-size=
Only available if Guile-SSH is compiled with libssh 0.10.
** Add new tests.
** Update the documentation.

* Changes in version 0.16.4 (2023-12-17)
** =private-key-from-file= now allows to read encrypted keys
Expand Down
16 changes: 14 additions & 2 deletions doc/api-sessions.texi
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,11 @@ replaced by the user home directory.

Expected type of @var{value}: string.
@item identity
Set the identity file name. By default identity, @file{id_dsa} and
@file{id_rsa} are checked.
Set the identity file name. In libssh prior version 0.10 @file{id_dsa} and
@file{id_rsa} are checked by default.

In libssh 0.10 or newer versions @file{id_rsa}, @file{id_ecdsa} and
@file{id_ed25519} are checked by default.

The identity file used authenticate with public key. It may include
@code{%s} which will be replaced by the user home directory.
Expand Down Expand Up @@ -245,6 +248,15 @@ Expected type of @var{value}: string.
Set the command to be executed in order to connect to server.

Expected type of @var{value}: string.
@item rsa-min-size
Set the minimum RSA key size in bits to be accepted by the client for both
authentication and hostkey verification. The values under 768 bits are not
accepted even with this configuration option as they are considered completely
broken. Setting 0 will revert the value to defaults. Default is 1024 bits or
2048 bits in FIPS mode.

Expected type of @var{value}: number.

@item stricthostkeycheck
Set the parameter @code{StrictHostKeyChecking} to avoid asking about a
fingerprint.
Expand Down
12 changes: 11 additions & 1 deletion libguile-ssh/session-func.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* session-func.c -- Functions for working with SSH session.
*
* Copyright (C) 2013-2023 Artyom V. Poptsov <poptsov.artyom@gmail.com>
* Copyright (C) 2013-2024 Artyom V. Poptsov <poptsov.artyom@gmail.com>
*
* This file is part of Guile-SSH.
*
Expand Down Expand Up @@ -81,6 +81,10 @@ static gssh_symbol_t session_options[] = {
{ "public-key-accepted-types", SSH_OPTIONS_PUBLICKEY_ACCEPTED_TYPES },
#endif

#if HAVE_LIBSSH_0_10
{"rsa-min-size", SSH_OPTIONS_RSA_MIN_SIZE },
#endif

{ "callbacks", GSSH_OPTIONS_CALLBACKS },
{ NULL, -1 }
};
Expand Down Expand Up @@ -399,6 +403,12 @@ set_option (SCM scm_session, gssh_session_t* sd, int type, SCM value)
break;
#endif

#if HAVE_LIBSSH_0_10
case SSH_OPTIONS_RSA_MIN_SIZE:
return set_int32_opt (session, type, value);
break;
#endif

default:
guile_ssh_error1 ("session-set!",
"Operation is not supported yet: %a~%",
Expand Down
6 changes: 6 additions & 0 deletions tests/session.scm
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@
options)
res))

(unless (>= %libssh-minor-version 10)
(test-skip "session-set!, rsa-min-size"))
(test-assert "session-set!, rsa-min-size"
(let ((session (%make-session)))
(session-set! session 'rsa-min-size 1024)))

(test-assert "session-set!, invalid values"
(let ((session (%make-session))
(options '((host 12345 #t)
Expand Down

0 comments on commit 40b0e8a

Please sign in to comment.