@@ -2309,7 +2309,11 @@ static INLINE int wcPrimeForId(byte id)
23092309 return ECC_SECP521R1 ;
23102310#endif
23112311 default :
2312+ #if !defined(WOLFSSH_NO_ECDSA ) && !defined(WOLFSSH_NO_ECDH )
23122313 return ECC_CURVE_INVALID ;
2314+ #else
2315+ return -1 ;
2316+ #endif
23132317 }
23142318}
23152319
@@ -6428,9 +6432,11 @@ static const char cannedKeyAlgoClientNames[] =
64286432#endif
64296433
64306434static const char cannedKeyAlgoRsaNames [] = "ssh-rsa" ;
6435+ #if !defined(WOLFSSH_NO_ECDSA )
64316436static const char cannedKeyAlgoEcc256Names [] = "ecdsa-sha2-nistp256" ;
64326437static const char cannedKeyAlgoEcc384Names [] = "ecdsa-sha2-nistp384" ;
64336438static const char cannedKeyAlgoEcc521Names [] = "ecdsa-sha2-nistp521" ;
6439+ #endif
64346440
64356441static const char cannedKexAlgoNames [] =
64366442#if !defined (WOLFSSH_NO_ECDH_SHA2_NISTP521 )
@@ -6470,12 +6476,14 @@ static const word32 cannedMacAlgoNamesSz = sizeof(cannedMacAlgoNames) - 2;
64706476static const word32 cannedKeyAlgoClientNamesSz =
64716477 sizeof (cannedKeyAlgoClientNames ) - 2 ;
64726478static const word32 cannedKeyAlgoRsaNamesSz = sizeof (cannedKeyAlgoRsaNames ) - 1 ;
6479+ #if !defined(WOLFSSH_NO_ECDSA ) && !defined(WOLFSSH_NO_ECDH )
64736480static const word32 cannedKeyAlgoEcc256NamesSz =
64746481 sizeof (cannedKeyAlgoEcc256Names ) - 1 ;
64756482static const word32 cannedKeyAlgoEcc384NamesSz =
64766483 sizeof (cannedKeyAlgoEcc384Names ) - 1 ;
64776484static const word32 cannedKeyAlgoEcc521NamesSz =
64786485 sizeof (cannedKeyAlgoEcc521Names ) - 1 ;
6486+ #endif
64796487static const word32 cannedKexAlgoNamesSz = sizeof (cannedKexAlgoNames ) - 2 ;
64806488static const word32 cannedNoneNamesSz = sizeof (cannedNoneNames ) - 1 ;
64816489
@@ -6509,6 +6517,7 @@ int SendKexInit(WOLFSSH* ssh)
65096517 if (ret == WS_SUCCESS ) {
65106518 if (ssh -> ctx -> side == WOLFSSH_ENDPOINT_SERVER ) {
65116519 switch (ssh -> ctx -> useEcc ) {
6520+ #if !defined(WOLFSSH_NO_ECDSA ) && !defined(WOLFSSH_NO_ECDH )
65126521 case ECC_SECP256R1 :
65136522 cannedKeyAlgoNames = cannedKeyAlgoEcc256Names ;
65146523 cannedKeyAlgoNamesSz = cannedKeyAlgoEcc256NamesSz ;
@@ -6521,6 +6530,7 @@ int SendKexInit(WOLFSSH* ssh)
65216530 cannedKeyAlgoNames = cannedKeyAlgoEcc521Names ;
65226531 cannedKeyAlgoNamesSz = cannedKeyAlgoEcc521NamesSz ;
65236532 break ;
6533+ #endif
65246534 default :
65256535 cannedKeyAlgoNames = cannedKeyAlgoRsaNames ;
65266536 cannedKeyAlgoNamesSz = cannedKeyAlgoRsaNamesSz ;
@@ -7053,6 +7063,7 @@ int SendKexDhReply(WOLFSSH* ssh)
70537063#endif /* ! WOLFSSH_NO_DH */
70547064 }
70557065 else {
7066+ #if !defined(WOLFSSH_NO_ECDH )
70567067 ecc_key pubKey ;
70577068 ecc_key privKey ;
70587069 int primeId ;
@@ -7088,6 +7099,7 @@ int SendKexDhReply(WOLFSSH* ssh)
70887099 ssh -> k , & ssh -> kSz );
70897100 wc_ecc_free (& privKey );
70907101 wc_ecc_free (& pubKey );
7102+ #endif /* !defined(WOLFSSH_NO_ECDH) */
70917103 }
70927104 }
70937105
@@ -7651,6 +7663,7 @@ int SendKexDhInit(WOLFSSH* ssh)
76517663#endif
76527664 }
76537665 else {
7666+ #if !defined(WOLFSSH_NO_ECDH )
76547667 ecc_key * privKey = & ssh -> handshake -> privKey .ecc ;
76557668 int primeId = wcPrimeForId (ssh -> handshake -> kexId );
76567669
@@ -7670,6 +7683,7 @@ int SendKexDhInit(WOLFSSH* ssh)
76707683 privKey , primeId );
76717684 if (ret == 0 )
76727685 ret = wc_ecc_export_x963 (privKey , e , & eSz );
7686+ #endif /* !defined(WOLFSSH_NO_ECDH) */
76737687 }
76747688
76757689 if (ret == 0 )
0 commit comments