119119 Set when all DH algorithms are disabled. Set to disable use of all DH
120120 algorithms for key agreement. Setting this will force all DH key agreement
121121 algorithms off.
122+ WOLFSSH_NO_ECDH
123+ Set when all ECDH algorithms are disabled. Set to disable use of all ECDH
124+ algorithms for key agreement. Setting this will force all ECDH key agreement
125+ algorithms off.
122126*/
123127
124128
@@ -2234,29 +2238,19 @@ static INLINE int wcPrimeForId(byte id)
22342238 return ECC_CURVE_INVALID ;
22352239 }
22362240}
2241+
2242+ #ifndef WOLFSSH_NO_ECDSA
22372243static INLINE const char * PrimeNameForId (byte id )
22382244{
22392245 switch (id ) {
2240- #ifndef WOLFSSH_NO_ECDH_SHA2_NISTP256
2241- case ID_ECDH_SHA2_NISTP256 :
2242- return "nistp256" ;
2243- #endif
22442246#ifndef WOLFSSH_NO_ECDSA_SHA2_NISTP256
22452247 case ID_ECDSA_SHA2_NISTP256 :
22462248 return "nistp256" ;
22472249#endif
2248- #ifndef WOLFSSH_NO_ECDH_SHA2_NISTP384
2249- case ID_ECDH_SHA2_NISTP384 :
2250- return "nistp384" ;
2251- #endif
22522250#ifndef WOLFSSH_NO_ECDSA_SHA2_NISTP384
22532251 case ID_ECDSA_SHA2_NISTP384 :
22542252 return "nistp384" ;
22552253#endif
2256- #ifndef WOLFSSH_NO_ECDH_SHA2_NISTP521
2257- case ID_ECDH_SHA2_NISTP521 :
2258- return "nistp521" ;
2259- #endif
22602254#ifndef WOLFSSH_NO_ECDSA_SHA2_NISTP521
22612255 case ID_ECDSA_SHA2_NISTP521 :
22622256 return "nistp521" ;
@@ -2265,6 +2259,7 @@ static INLINE const char *PrimeNameForId(byte id)
22652259 return "unknown" ;
22662260 }
22672261}
2262+ #endif
22682263
22692264
22702265static INLINE byte AeadModeForId (byte id )
@@ -2785,7 +2780,7 @@ static int DoKexDhReply(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
27852780 RsaKey key ;
27862781 } rsa ;
27872782#endif
2788- #ifndef WOLFSSH_NO_ECC
2783+ #ifndef WOLFSSH_NO_ECDSA
27892784 struct {
27902785 ecc_key key ;
27912786 } ecc ;
@@ -3098,7 +3093,7 @@ static int DoKexDhReply(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
30983093#endif
30993094 }
31003095 else {
3101- #ifndef WOLFSSH_NO_ECDHE
3096+ #ifndef WOLFSSH_NO_ECDH
31023097 ecc_key key ;
31033098 ret = wc_ecc_init (& key );
31043099#ifdef HAVE_WC_ECC_SET_RNG
@@ -3254,7 +3249,7 @@ static int DoKexDhReply(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
32543249#endif
32553250 }
32563251 else {
3257- #ifdef WOLFSSH_NO_ECDSA
3252+ #ifndef WOLFSSH_NO_ECDSA
32583253 wc_ecc_free (& sigKeyBlock .sk .ecc .key );
32593254#endif
32603255 }
@@ -4120,7 +4115,7 @@ static int DoUserAuthRequestEcc(WOLFSSH* ssh, WS_UserAuthData_PublicKey* pk,
41204115#endif
41214116
41224117
4123- #if !defined(WOLFSSH_NO_RSA ) && !defined(WOLFSSH_NO_ECDSA )
4118+ #if !defined(WOLFSSH_NO_RSA ) || !defined(WOLFSSH_NO_ECDSA )
41244119/* Utility for DoUserAuthRequest() */
41254120static int DoUserAuthRequestPublicKey (WOLFSSH * ssh , WS_UserAuthData * authData ,
41264121 byte * buf , word32 len , word32 * idx )
@@ -4282,11 +4277,12 @@ static int DoUserAuthRequestPublicKey(WOLFSSH* ssh, WS_UserAuthData* authData,
42824277 }
42834278 else if (pkTypeId == ID_ECDSA_SHA2_NISTP256 ||
42844279 pkTypeId == ID_ECDSA_SHA2_NISTP384 ||
4285- pkTypeId == ID_ECDSA_SHA2_NISTP521 )
4280+ pkTypeId == ID_ECDSA_SHA2_NISTP521 ) {
42864281#ifndef WOLFSSH_NO_ECDSA
42874282 ret = DoUserAuthRequestEcc (ssh , pk ,
42884283 hashId , digest , digestSz );
42894284#endif
4285+ }
42904286 }
42914287
42924288 if (ret != WS_SUCCESS ) {
@@ -4364,7 +4360,7 @@ static int DoUserAuthRequest(WOLFSSH* ssh,
43644360
43654361 if (authNameId == ID_USERAUTH_PASSWORD )
43664362 ret = DoUserAuthRequestPassword (ssh , & authData , buf , len , & begin );
4367- #if !defined(WOLFSSH_NO_RSA ) && !defined(WOLFSSH_NO_ECDSA )
4363+ #if !defined(WOLFSSH_NO_RSA ) || !defined(WOLFSSH_NO_ECDSA )
43684364 else if (authNameId == ID_USERAUTH_PUBLICKEY ) {
43694365 authData .sf .publicKey .dataToSign = buf + * idx ;
43704366 ret = DoUserAuthRequestPublicKey (ssh , & authData , buf , len , & begin );
@@ -6449,7 +6445,7 @@ int SendKexDhReply(WOLFSSH* ssh)
64496445 byte nPad ;
64506446 } rsa ;
64516447#endif
6452- #ifndef WOLFSSH_NO_ECDH_SHA2_NISTP256
6448+ #ifndef WOLFSSH_NO_ECDSA
64536449 struct {
64546450 ecc_key key ;
64556451 word32 keyBlobSz ;
@@ -6638,6 +6634,7 @@ int SendKexDhReply(WOLFSSH* ssh)
66386634#endif /* WOLFSSH_NO_SSH_RSA_SHA1 */
66396635 }
66406636 else {
6637+ #ifndef WOLFSSH_NO_ECDSA
66416638 sigKeyBlock .sk .ecc .primeName =
66426639 PrimeNameForId (ssh -> handshake -> pubKeyId );
66436640 sigKeyBlock .sk .ecc .primeNameSz =
@@ -6707,6 +6704,7 @@ int SendKexDhReply(WOLFSSH* ssh)
67076704 enmhashId ,
67086705 sigKeyBlock .sk .ecc .q ,
67096706 sigKeyBlock .sk .ecc .qSz );
6707+ #endif
67106708 }
67116709#ifndef WOLFSSH_NO_DH_GEX_SHA256
67126710 /* If using DH-GEX include the GEX specific values. */
@@ -6950,6 +6948,7 @@ int SendKexDhReply(WOLFSSH* ssh)
69506948#endif
69516949 }
69526950 else {
6951+ #ifndef WOLFSSH_NO_ECDSA
69536952 WLOG (WS_LOG_INFO , "Signing hash with ECDSA." );
69546953 sigSz = sizeof (sig );
69556954 ret = wc_ecc_sign_hash (digest , wc_HashGetDigestSize (sigHashId ),
@@ -6987,6 +6986,7 @@ int SendKexDhReply(WOLFSSH* ssh)
69876986 WMEMCPY (sig + idx , s , sSz );
69886987 }
69896988 }
6989+ #endif
69906990 }
69916991 }
69926992 }
@@ -6997,7 +6997,9 @@ int SendKexDhReply(WOLFSSH* ssh)
69976997#endif
69986998 }
69996999 else {
7000+ #ifndef WOLFSSH_NO_ECDSA
70007001 wc_ecc_free (& sigKeyBlock .sk .ecc .key );
7002+ #endif
70017003 }
70027004
70037005 sigBlockSz = (LENGTH_SZ * 2 ) + sigKeyBlock .nameSz + sigSz ;
@@ -7043,6 +7045,7 @@ int SendKexDhReply(WOLFSSH* ssh)
70437045#endif
70447046 }
70457047 else {
7048+ #ifndef WOLFSSH_NO_ECDSA
70467049 c32toa (sigKeyBlock .sk .ecc .primeNameSz , output + idx );
70477050 idx += LENGTH_SZ ;
70487051 WMEMCPY (output + idx , sigKeyBlock .sk .ecc .primeName ,
@@ -7053,6 +7056,7 @@ int SendKexDhReply(WOLFSSH* ssh)
70537056 WMEMCPY (output + idx , sigKeyBlock .sk .ecc .q ,
70547057 sigKeyBlock .sk .ecc .qSz );
70557058 idx += sigKeyBlock .sk .ecc .qSz ;
7059+ #endif
70567060 }
70577061
70587062 /* Copy the server's public key. F for DE, or Q_S for ECDH. */
@@ -8168,7 +8172,7 @@ static int BuildUserAuthRequestEcc(WOLFSSH* ssh,
81688172#endif
81698173
81708174
8171- #if !defined(WOLFSSH_NO_RSA ) && !defined(WOLFSSH_NO_ECDSA )
8175+ #if !defined(WOLFSSH_NO_RSA ) || !defined(WOLFSSH_NO_ECDSA )
81728176static int PrepareUserAuthRequestPublicKey (WOLFSSH * ssh , word32 * payloadSz ,
81738177 const WS_UserAuthData * authData , WS_KeySignature * keySig )
81748178{
0 commit comments