mirror of https://github.com/wolfSSL/wolfssh.git
removed goto from processing the public key authentication
parent
e62b09520b
commit
bebe452d12
|
@ -1605,6 +1605,7 @@ static int DoUserAuthRequestPublicKey(WOLFSSH* ssh, WS_UserAuthData* authData,
|
||||||
uint32_t begin;
|
uint32_t begin;
|
||||||
WS_UserAuthData_PublicKey* pk;
|
WS_UserAuthData_PublicKey* pk;
|
||||||
int ret = WS_SUCCESS;
|
int ret = WS_SUCCESS;
|
||||||
|
int authFailure = 0;
|
||||||
|
|
||||||
WLOG(WS_LOG_DEBUG, "Entering DoUserAuthRequestPublicKey()");
|
WLOG(WS_LOG_DEBUG, "Entering DoUserAuthRequestPublicKey()");
|
||||||
|
|
||||||
|
@ -1640,36 +1641,36 @@ static int DoUserAuthRequestPublicKey(WOLFSSH* ssh, WS_UserAuthData* authData,
|
||||||
pk->signature = buf + begin;
|
pk->signature = buf + begin;
|
||||||
begin += pk->signatureSz;
|
begin += pk->signatureSz;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
goto onError;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pk->signature = NULL;
|
pk->signature = NULL;
|
||||||
pk->signatureSz = 0;
|
pk->signatureSz = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
*idx = begin;
|
if (ret == WS_SUCCESS) {
|
||||||
|
*idx = begin;
|
||||||
|
|
||||||
if (ssh->ctx->userAuthCb != NULL) {
|
if (ssh->ctx->userAuthCb != NULL) {
|
||||||
WLOG(WS_LOG_DEBUG, "DUARPK: Calling the userauth callback");
|
WLOG(WS_LOG_DEBUG, "DUARPK: Calling the userauth callback");
|
||||||
ret = ssh->ctx->userAuthCb(WOLFSSH_USERAUTH_PUBLICKEY,
|
ret = ssh->ctx->userAuthCb(WOLFSSH_USERAUTH_PUBLICKEY,
|
||||||
authData, ssh->userAuthCtx);
|
authData, ssh->userAuthCtx);
|
||||||
WLOG(WS_LOG_DEBUG, "DUARPK: callback result = %d", ret);
|
WLOG(WS_LOG_DEBUG, "DUARPK: callback result = %d", ret);
|
||||||
if (ret == WOLFSSH_USERAUTH_SUCCESS)
|
if (ret == WOLFSSH_USERAUTH_SUCCESS)
|
||||||
ret = WS_SUCCESS;
|
ret = WS_SUCCESS;
|
||||||
else {
|
else {
|
||||||
ret = SendUserAuthFailure(ssh, 0);
|
ret = SendUserAuthFailure(ssh, 0);
|
||||||
goto onError;
|
authFailure = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
WLOG(WS_LOG_DEBUG, "DUARPK: no userauth callback set");
|
||||||
|
ret = SendUserAuthFailure(ssh, 0);
|
||||||
|
authFailure = 1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
|
||||||
WLOG(WS_LOG_DEBUG, "DUARPK: no userauth callback set");
|
|
||||||
ret = SendUserAuthFailure(ssh, 0);
|
|
||||||
goto onError;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == WS_SUCCESS) {
|
if (ret == WS_SUCCESS && !authFailure) {
|
||||||
if (pk->signature == NULL) {
|
if (pk->signature == NULL) {
|
||||||
WLOG(WS_LOG_DEBUG, "DUARPK: Send the PK OK");
|
WLOG(WS_LOG_DEBUG, "DUARPK: Send the PK OK");
|
||||||
ret = SendUserAuthPkOk(ssh, pk->publicKeyType, pk->publicKeyTypeSz,
|
ret = SendUserAuthPkOk(ssh, pk->publicKeyType, pk->publicKeyTypeSz,
|
||||||
|
@ -1733,7 +1734,6 @@ static int DoUserAuthRequestPublicKey(WOLFSSH* ssh, WS_UserAuthData* authData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onError:
|
|
||||||
WLOG(WS_LOG_DEBUG, "Leaving DoUserAuthRequestPublicKey(), ret = %d", ret);
|
WLOG(WS_LOG_DEBUG, "Leaving DoUserAuthRequestPublicKey(), ret = %d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue