From b256522f5b68a7a0063fe33d1d078c7d68494f13 Mon Sep 17 00:00:00 2001 From: Hideki Miyazaki Date: Sat, 27 Jan 2024 13:03:10 +0900 Subject: [PATCH 1/2] fix WOLFSSH_NO_RSA --- examples/client/common.c | 4 ++-- examples/sftpclient/sftpclient.c | 3 ++- src/internal.c | 2 +- tests/api.c | 1 + wolfssh/internal.h | 2 ++ 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/examples/client/common.c b/examples/client/common.c index 671532a4d..5a2c2ba63 100644 --- a/examples/client/common.c +++ b/examples/client/common.c @@ -642,7 +642,7 @@ int ClientUseCert(const char* certName) * returns 0 on success */ int ClientSetPrivateKey(const char* privKeyName, int userEcc) { - int ret; + int ret = 0; if (privKeyName == NULL) { if (userEcc) { @@ -682,7 +682,7 @@ int ClientSetPrivateKey(const char* privKeyName, int userEcc) * returns 0 on success */ int ClientUsePubKey(const char* pubKeyName, int userEcc) { - int ret; + int ret = 0; if (pubKeyName == NULL) { byte* p = userPublicKey; diff --git a/examples/sftpclient/sftpclient.c b/examples/sftpclient/sftpclient.c index 38b079823..01a2308b6 100644 --- a/examples/sftpclient/sftpclient.c +++ b/examples/sftpclient/sftpclient.c @@ -1128,6 +1128,7 @@ THREAD_RETURN WOLFSSH_THREAD sftpclient_test(void* args) socklen_t clientAddrSz = sizeof(clientAddr); int ret; int ch; + int userEcc = 0; /* int peerEcc = 0; */ word16 port = wolfSshPort; char* host = (char*)wolfSshIp; @@ -1262,7 +1263,7 @@ THREAD_RETURN WOLFSSH_THREAD sftpclient_test(void* args) } #endif - ret = ClientSetPrivateKey(privKeyName, 0); + ret = ClientSetPrivateKey(privKeyName, userEcc); if (ret != 0) { err_sys("Error setting private key"); } diff --git a/src/internal.c b/src/internal.c index 4e69277fb..096bf9ddd 100644 --- a/src/internal.c +++ b/src/internal.c @@ -6829,7 +6829,7 @@ static int DoChannelOpen(WOLFSSH* ssh, word32 typeSz; char type[32]; byte typeId = ID_UNKNOWN; - word32 peerChannelId; + word32 peerChannelId = 0; word32 peerInitialWindowSz; word32 peerMaxPacketSz; #ifdef WOLFSSH_FWD diff --git a/tests/api.c b/tests/api.c index b7f26063a..9aaf12953 100644 --- a/tests/api.c +++ b/tests/api.c @@ -746,6 +746,7 @@ static void test_wolfSSH_ReadKey(void) #ifndef WOLFSSH_NO_ECDSA_SHA2_NISTP256 /* OpenSSH Format, ecdsa-sha2-nistp256, private, need alloc */ + (void)keyCheck; key = NULL; keySz = 0; keyType = NULL; diff --git a/wolfssh/internal.h b/wolfssh/internal.h index fe435b33e..001116cb0 100644 --- a/wolfssh/internal.h +++ b/wolfssh/internal.h @@ -1204,9 +1204,11 @@ WOLFSSH_LOCAL int wsScpSendCallback(WOLFSSH*, int, const char*, char*, word32, WOLFSSH_LOCAL int wolfSSH_CleanPath(WOLFSSH* ssh, char* in); +#ifndef WOLFSSH_NO_RSA WOLFSSH_LOCAL int wolfSSH_RsaVerify(byte *sig, word32 sigSz, const byte* digest, word32 digestSz, RsaKey* key, void* heap, const char* loc); +#endif WOLFSSH_LOCAL void DumpOctetString(const byte*, word32); WOLFSSH_LOCAL int wolfSSH_oct2dec(WOLFSSH* ssh, byte* oct, word32 octSz); WOLFSSH_LOCAL void AddAssign64(word32*, word32); From bb81ad0afc32b1bbef30494f6c871c9b2168fb8b Mon Sep 17 00:00:00 2001 From: Hideki Miyazaki Date: Wed, 31 Jan 2024 08:18:16 +0900 Subject: [PATCH 2/2] additional gate for RSA --- src/internal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/internal.c b/src/internal.c index 096bf9ddd..49b21da8a 100644 --- a/src/internal.c +++ b/src/internal.c @@ -1034,6 +1034,7 @@ int IdentifyAsn1Key(const byte* in, word32 inSz, int isPrivate, void* heap) } +#ifndef WOLFSSH_NO_RSA /* * Utility function to read an Mpint from the stream directly into a mp_int. */ @@ -1052,7 +1053,6 @@ static INLINE int GetMpintToMp(mp_int* mp, } -#ifndef WOLFSSH_NO_RSA /* * For the given RSA key, calculate p^-1 and q^-1. wolfCrypt's RSA * code expects them, but the OpenSSH format key doesn't store them.