Merge pull request #802 from LinuxJedi/kbi-fixes

Keyboard Interactive bug fixes
pull/806/head
Daniel Pouzzner 2025-05-16 15:23:45 -05:00 committed by GitHub
commit 597a71be60
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 1 deletions

View File

@ -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]));
@ -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;
@ -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);
@ -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;
@ -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);

View File

@ -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)