Skip to content

Commit 40b0e8a

Browse files
libguile-ssh/session-func: Handle SSH_OPTIONS_RSA_MIN_SIZE
* 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.
1 parent 524649c commit 40b0e8a

File tree

4 files changed

+35
-3
lines changed

4 files changed

+35
-3
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ This patch fixes this error.
1717

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

2125
* Changes in version 0.16.4 (2023-12-17)
2226
** =private-key-from-file= now allows to read encrypted keys

doc/api-sessions.texi

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,11 @@ replaced by the user home directory.
176176

177177
Expected type of @var{value}: string.
178178
@item identity
179-
Set the identity file name. By default identity, @file{id_dsa} and
180-
@file{id_rsa} are checked.
179+
Set the identity file name. In libssh prior version 0.10 @file{id_dsa} and
180+
@file{id_rsa} are checked by default.
181+
182+
In libssh 0.10 or newer versions @file{id_rsa}, @file{id_ecdsa} and
183+
@file{id_ed25519} are checked by default.
181184

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

247250
Expected type of @var{value}: string.
251+
@item rsa-min-size
252+
Set the minimum RSA key size in bits to be accepted by the client for both
253+
authentication and hostkey verification. The values under 768 bits are not
254+
accepted even with this configuration option as they are considered completely
255+
broken. Setting 0 will revert the value to defaults. Default is 1024 bits or
256+
2048 bits in FIPS mode.
257+
258+
Expected type of @var{value}: number.
259+
248260
@item stricthostkeycheck
249261
Set the parameter @code{StrictHostKeyChecking} to avoid asking about a
250262
fingerprint.

libguile-ssh/session-func.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* session-func.c -- Functions for working with SSH session.
22
*
3-
* Copyright (C) 2013-2023 Artyom V. Poptsov <poptsov.artyom@gmail.com>
3+
* Copyright (C) 2013-2024 Artyom V. Poptsov <poptsov.artyom@gmail.com>
44
*
55
* This file is part of Guile-SSH.
66
*
@@ -81,6 +81,10 @@ static gssh_symbol_t session_options[] = {
8181
{ "public-key-accepted-types", SSH_OPTIONS_PUBLICKEY_ACCEPTED_TYPES },
8282
#endif
8383

84+
#if HAVE_LIBSSH_0_10
85+
{"rsa-min-size", SSH_OPTIONS_RSA_MIN_SIZE },
86+
#endif
87+
8488
{ "callbacks", GSSH_OPTIONS_CALLBACKS },
8589
{ NULL, -1 }
8690
};
@@ -399,6 +403,12 @@ set_option (SCM scm_session, gssh_session_t* sd, int type, SCM value)
399403
break;
400404
#endif
401405

406+
#if HAVE_LIBSSH_0_10
407+
case SSH_OPTIONS_RSA_MIN_SIZE:
408+
return set_int32_opt (session, type, value);
409+
break;
410+
#endif
411+
402412
default:
403413
guile_ssh_error1 ("session-set!",
404414
"Operation is not supported yet: %a~%",

tests/session.scm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@
116116
options)
117117
res))
118118

119+
(unless (>= %libssh-minor-version 10)
120+
(test-skip "session-set!, rsa-min-size"))
121+
(test-assert "session-set!, rsa-min-size"
122+
(let ((session (%make-session)))
123+
(session-set! session 'rsa-min-size 1024)))
124+
119125
(test-assert "session-set!, invalid values"
120126
(let ((session (%make-session))
121127
(options '((host 12345 #t)

0 commit comments

Comments
 (0)