Skip to content

Commit c26f72c

Browse files
committed
Maintenance
1. If the public key user authentication fails, don't retry it. 2. Add some more specific logging about the type of a signature getting generated.
1 parent 88e7919 commit c26f72c

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/internal.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2721,6 +2721,7 @@ static int DoKexDhInit(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
27212721
&& ssh->handshake->kexIdGuess != ssh->handshake->kexId) {
27222722

27232723
/* skip this message. */
2724+
WLOG(WS_LOG_DEBUG, "Skipping the client's KEX init function.");
27242725
ssh->handshake->kexPacketFollows = 0;
27252726
*idx += len;
27262727
return WS_SUCCESS;
@@ -6936,7 +6937,8 @@ int SendKexDhReply(WOLFSSH* ssh)
69366937
ret = WS_CRYPTO_FAILED;
69376938
}
69386939
else {
6939-
WLOG(WS_LOG_INFO, "Signing hash with RSA.");
6940+
WLOG(WS_LOG_INFO, "Signing hash with %s.",
6941+
IdToName(ssh->handshake->pubKeyId));
69406942
sigSz = wc_RsaSSL_Sign(encSig, encSigSz, sig, sizeof(sig),
69416943
&sigKeyBlock.sk.rsa.key, ssh->rng);
69426944
if (sigSz <= 0) {
@@ -6948,7 +6950,8 @@ int SendKexDhReply(WOLFSSH* ssh)
69486950
}
69496951
else {
69506952
#ifndef WOLFSSH_NO_ECDSA
6951-
WLOG(WS_LOG_INFO, "Signing hash with ECDSA.");
6953+
WLOG(WS_LOG_INFO, "Signing hash with %s.",
6954+
IdToName(ssh->handshake->pubKeyId));
69526955
sigSz = sizeof(sig);
69536956
ret = wc_ecc_sign_hash(digest, wc_HashGetDigestSize(sigHashId),
69546957
sig, &sigSz,
@@ -8360,8 +8363,9 @@ int SendUserAuthRequest(WOLFSSH* ssh, byte authId, int addSig)
83608363

83618364
if (authId == ID_USERAUTH_PASSWORD)
83628365
ret = PrepareUserAuthRequestPassword(ssh, &payloadSz, &authData);
8363-
else if (authId == ID_USERAUTH_PUBLICKEY) {
8366+
else if (authId == ID_USERAUTH_PUBLICKEY && !ssh->userAuthPkDone) {
83648367
authData.sf.publicKey.hasSignature = 1;
8368+
ssh->userAuthPkDone = 1;
83658369
ret = PrepareUserAuthRequestPublicKey(ssh, &payloadSz, &authData,
83668370
&keySig);
83678371
}

wolfssh/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,7 @@ struct WOLFSSH {
610610
word32 peerProtoIdSz;
611611
void* publicKeyCheckCtx;
612612
byte sendTerminalRequest;
613+
byte userAuthPkDone;
613614

614615
#ifdef USE_WINDOWS_API
615616
word32 defaultAttr; /* default windows attributes */

0 commit comments

Comments
 (0)