summaryrefslogtreecommitdiffhomepage
path: root/svr-authpubkey.c
diff options
context:
space:
mode:
authorfabriziobertocci <fabriziobertocci@gmail.com>2019-05-15 09:43:57 -0400
committerMatt Johnston <matt@ucc.asn.au>2019-05-15 21:43:57 +0800
commit8c6aaf8d361e95ba3d9b371b86abaae1fd0e436f (patch)
tree42854eeaf56ed1955b6a1ec8c8e1e2df23524db8 /svr-authpubkey.c
parentcae6e6af1006d6afa33e030e21aeabafd8721be7 (diff)
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 *
Diffstat (limited to 'svr-authpubkey.c')
-rw-r--r--svr-authpubkey.c48
1 files changed, 46 insertions, 2 deletions
diff --git a/svr-authpubkey.c b/svr-authpubkey.c
index 4f27986..9d70bfb 100644
--- a/svr-authpubkey.c
+++ b/svr-authpubkey.c
@@ -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",