External Public-Key Authentication API (#72)

* Implemented dynamic loading of an external plug-in shared library to delegate public key authentication

* Moved conditional compilation of the plugin infrastructure into the configure.ac script to be able to add -ldl to dropbear build only when the flag is enabled

* Added tags file to the ignore list

* Updated API to have the constructor to return function pointers in the pliugin instance. Added support for passing user name to the checkpubkey function. Added options to the session returned by the plugin and have dropbear to parse and process them

* Added -rdynamic to the linker flags when EPKA is enabled

* Changed the API to pass a previously created session to the checkPubKey function (created during preauth)

* Added documentation to the API

* Added parameter addrstring to plugin creation function

* Modified the API to retrieve the auth options. Instead of having them as field of the EPKASession struct, they are stored internally (plugin-dependent) in the plugin/session and retrieved through a pointer to a function (in the session)

* Changed option string to be a simple char * instead of unsigned char *
This commit is contained in:
fabriziobertocci
2019-05-15 09:43:57 -04:00
committed by Matt Johnston
parent cae6e6af10
commit 8c6aaf8d36
12 changed files with 354 additions and 10 deletions

View File

@@ -91,6 +91,7 @@ void svr_auth_pubkey(int valid_user) {
sign_key * key = NULL;
char* fp = NULL;
enum signkey_type type = -1;
int auth_failure = 1;
TRACE(("enter pubkeyauth"))
@@ -110,9 +111,45 @@ void svr_auth_pubkey(int valid_user) {
send_msg_userauth_failure(0, 0);
goto out;
}
#if DROPBEAR_EPKA
if (svr_ses.epka_instance != NULL) {
char *options_buf;
if (svr_ses.epka_instance->checkpubkey(
svr_ses.epka_instance,
&ses.epka_session,
algo,
algolen,
keyblob,
keybloblen,
ses.authstate.username) == DROPBEAR_SUCCESS) {
/* Success */
auth_failure = 0;
/* Options provided? */
options_buf = ses.epka_session->get_options(ses.epka_session);
if (options_buf) {
struct buf temp_buf = {
.data = (unsigned char *)options_buf,
.len = strlen(options_buf),
.pos = 0,
.size = 0
};
int ret = svr_add_pubkey_options(&temp_buf, 0, "N/A");
if (ret == DROPBEAR_FAILURE) {
/* Fail immediately as the plugin provided wrong options */
send_msg_userauth_failure(0, 0);
goto out;
}
}
}
}
#endif
/* check if the key is valid */
if (checkpubkey(algo, algolen, keyblob, keybloblen) == DROPBEAR_FAILURE) {
if (auth_failure) {
auth_failure = checkpubkey(algo, algolen, keyblob, keybloblen) == DROPBEAR_FAILURE;
}
if (auth_failure) {
send_msg_userauth_failure(0, 0);
goto out;
}
@@ -156,6 +193,13 @@ void svr_auth_pubkey(int valid_user) {
"Pubkey auth succeeded for '%s' with key %s from %s",
ses.authstate.pw_name, fp, svr_ses.addrstring);
send_msg_userauth_success();
#if DROPBEAR_EPKA
if ((ses.epka_session != NULL) && (svr_ses.epka_instance->auth_success != NULL)) {
/* Was authenticated through the external plugin. tell plugin that signature verification was ok */
svr_ses.epka_instance->auth_success(ses.epka_session);
}
#endif
} else {
dropbear_log(LOG_WARNING,
"Pubkey auth bad signature for '%s' with key %s from %s",