pki: add security key identities to session options

Signed-off-by: Praneeth Sarode <praneethsarode@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Eshan Kelkar <eshankelkar@galorithm.com>
This commit is contained in:
Praneeth Sarode
2025-08-22 19:23:40 +05:30
parent 37f0e91814
commit d91630308d
3 changed files with 37 additions and 0 deletions

View File

@@ -392,6 +392,8 @@ int ssh_options_set_algo(ssh_session session,
* the identity list.\n
* \n
* By default id_rsa, id_ecdsa and id_ed25519 files are used.\n
* If libssh is built with FIDO2/U2F support, id_ecdsa_sk and\n
* id_ed25519_sk files are also used by default.\n
* \n
* The identity used to authenticate with public key will be
* prepended to the list.

View File

@@ -190,6 +190,29 @@ ssh_session ssh_new(void)
goto err;
}
#ifdef WITH_FIDO2
/* Add security key identities */
id = strdup("%d/id_ed25519_sk");
if (id == NULL) {
goto err;
}
rc = ssh_list_append(session->opts.identity_non_exp, id);
if (rc == SSH_ERROR) {
goto err;
}
#ifdef HAVE_ECC
id = strdup("%d/id_ecdsa_sk");
if (id == NULL) {
goto err;
}
rc = ssh_list_append(session->opts.identity_non_exp, id);
if (rc == SSH_ERROR) {
goto err;
}
#endif /* HAVE_ECC */
#endif /* WITH_FIDO2 */
/* Explicitly initialize states */
session->session_state = SSH_SESSION_STATE_NONE;
session->pending_call_state = SSH_PENDING_CALL_NONE;