Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,9 @@ WOLFSSH_CTX* CtxInit(WOLFSSH_CTX* ctx, byte side, void* heap)
ctx->algoListCipher = cannedEncAlgoNames;
ctx->algoListMac = cannedMacAlgoNames;
ctx->algoListKeyAccepted = cannedKeyAlgoNames;
#ifdef WOLFSSH_KEYBOARD_INTERACTIVE
ctx->keyboardAuthCb = NULL;
#endif

count = (word32)(sizeof(ctx->privateKey)
/ sizeof(ctx->privateKey[0]));
Expand Down Expand Up @@ -6421,11 +6424,16 @@ static int DoUserAuthInfoResponse(WOLFSSH* ssh,


if (ssh == NULL || buf == NULL || len == 0 || idx == NULL) {

ret = WS_BAD_ARGUMENT;
}

if ((ret == WS_SUCCESS) && (ssh->authId != ID_USERAUTH_KEYBOARD)) {
WLOG(WS_LOG_DEBUG, "DoUserAuthInfoResponse on non-keyboard auth");
ret = WS_FATAL_ERROR;
}

if (ret == WS_SUCCESS) {
WMEMSET(&authData, 0, sizeof(authData));
begin = *idx;
kb = &authData.sf.keyboard;
authData.type = WOLFSSH_USERAUTH_KEYBOARD;
Expand Down Expand Up @@ -7784,6 +7792,7 @@ static int DoUserAuthRequest(WOLFSSH* ssh,
authData.authName = buf + begin;
begin += authData.authNameSz;
authNameId = NameToId((char*)authData.authName, authData.authNameSz);
ssh->authId = authNameId;

if (authNameId == ID_USERAUTH_PASSWORD)
ret = DoUserAuthRequestPassword(ssh, &authData, buf, len, &begin);
Expand Down Expand Up @@ -8044,6 +8053,8 @@ static int DoUserAuthInfoRequest(WOLFSSH* ssh, byte* buf, word32 len,
ret = SendUserAuthKeyboardResponse(ssh);
}

ssh->authId = ID_USERAUTH_KEYBOARD;

WLOG(WS_LOG_DEBUG, "Leaving DoUserAuthInfoRequest(), ret = %d", ret);

return ret;
Expand Down Expand Up @@ -13348,6 +13359,11 @@ int SendUserAuthKeyboardRequest(WOLFSSH* ssh, WS_UserAuthData* authData)
ret = WS_BAD_ARGUMENT;
}

if (ssh->ctx->keyboardAuthCb == NULL) {
WLOG(WS_LOG_DEBUG, "SendUserAuthKeyboardRequest called with no Cb set");
ret = WS_BAD_USAGE;
}

if (ret == WS_SUCCESS) {
ret = ssh->ctx->keyboardAuthCb(&authData->sf.keyboard,
ssh->keyboardAuthCtx);
Expand Down
5 changes: 5 additions & 0 deletions tests/auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,11 @@ int wolfSSH_AuthTest(int argc, char** argv)
defined(NO_FILESYSTEM) || !defined(WOLFSSH_KEYBOARD_INTERACTIVE)
return 77;
#else

#if defined(DEBUG_WOLFSSH)
wolfSSH_Debugging_ON();
#endif

AssertIntEQ(wolfSSH_Init(), WS_SUCCESS);

#if defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(5,2)
Expand Down