@@ -2281,6 +2281,7 @@ static INLINE enum wc_HashType HashForId(byte id)
22812281}
22822282
22832283
2284+ #if !defined(WOLFSSH_NO_ECDSA ) && !defined(WOLFSSH_NO_ECDH )
22842285static INLINE int wcPrimeForId (byte id )
22852286{
22862287 switch (id ) {
@@ -2313,7 +2314,6 @@ static INLINE int wcPrimeForId(byte id)
23132314 }
23142315}
23152316
2316- #ifndef WOLFSSH_NO_ECDSA
23172317static INLINE const char * PrimeNameForId (byte id )
23182318{
23192319 switch (id ) {
@@ -2333,7 +2333,7 @@ static INLINE const char *PrimeNameForId(byte id)
23332333 return "unknown" ;
23342334 }
23352335}
2336- #endif
2336+ #endif /* WOLFSSH_NO_ECDSA */
23372337
23382338
23392339static INLINE byte AeadModeForId (byte id )
@@ -2871,10 +2871,14 @@ static int DoKexDhReply(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
28712871 int ret = WS_SUCCESS ;
28722872 int tmpIdx = 0 ;
28732873 struct wolfSSH_sigKeyBlock * sigKeyBlock_ptr = NULL ;
2874+ #ifndef WOLFSSH_NO_ECDH
28742875 ecc_key * key_ptr = NULL ;
2876+ #ifndef WOLFSSH_SMALL_STACK
2877+ ecc_key key_s ;
2878+ #endif
2879+ #endif
28752880#ifndef WOLFSSH_SMALL_STACK
28762881 struct wolfSSH_sigKeyBlock s_sigKeyBlock ;
2877- ecc_key key_s ;
28782882#endif
28792883
28802884 WLOG (WS_LOG_DEBUG , "Entering DoKexDhReply()" );
@@ -5884,6 +5888,7 @@ static INLINE int VerifyMac(WOLFSSH* ssh, const byte* in, word32 inSz,
58845888}
58855889
58865890
5891+ #ifndef WOLFSSH_NO_AEAD
58875892static INLINE void AeadIncrementExpIv (byte * iv )
58885893{
58895894 int i ;
@@ -5896,7 +5901,6 @@ static INLINE void AeadIncrementExpIv(byte* iv)
58965901}
58975902
58985903
5899- #ifndef WOLFSSH_NO_AEAD
59005904static INLINE int EncryptAead (WOLFSSH * ssh , byte * cipher ,
59015905 const byte * input , word16 sz ,
59025906 byte * authTag , const byte * auth ,
@@ -5968,7 +5972,7 @@ static INLINE int DecryptAead(WOLFSSH* ssh, byte* plain,
59685972
59695973 return ret ;
59705974}
5971- #endif
5975+ #endif /* WOLFSSH_NO_AEAD */
59725976
59735977
59745978int DoReceive (WOLFSSH * ssh )
@@ -6432,9 +6436,11 @@ static const char cannedKeyAlgoClientNames[] =
64326436#endif
64336437
64346438static const char cannedKeyAlgoRsaNames [] = "ssh-rsa" ;
6439+ #if !defined(WOLFSSH_NO_ECDSA ) && !defined(WOLFSSH_NO_ECDH )
64356440static const char cannedKeyAlgoEcc256Names [] = "ecdsa-sha2-nistp256" ;
64366441static const char cannedKeyAlgoEcc384Names [] = "ecdsa-sha2-nistp384" ;
64376442static const char cannedKeyAlgoEcc521Names [] = "ecdsa-sha2-nistp521" ;
6443+ #endif
64386444
64396445static const char cannedKexAlgoNames [] =
64406446#if !defined (WOLFSSH_NO_ECDH_SHA2_NISTP521 )
@@ -6474,12 +6480,14 @@ static const word32 cannedMacAlgoNamesSz = sizeof(cannedMacAlgoNames) - 2;
64746480static const word32 cannedKeyAlgoClientNamesSz =
64756481 sizeof (cannedKeyAlgoClientNames ) - 2 ;
64766482static const word32 cannedKeyAlgoRsaNamesSz = sizeof (cannedKeyAlgoRsaNames ) - 1 ;
6483+ #if !defined(WOLFSSH_NO_ECDSA ) && !defined(WOLFSSH_NO_ECDH )
64776484static const word32 cannedKeyAlgoEcc256NamesSz =
64786485 sizeof (cannedKeyAlgoEcc256Names ) - 1 ;
64796486static const word32 cannedKeyAlgoEcc384NamesSz =
64806487 sizeof (cannedKeyAlgoEcc384Names ) - 1 ;
64816488static const word32 cannedKeyAlgoEcc521NamesSz =
64826489 sizeof (cannedKeyAlgoEcc521Names ) - 1 ;
6490+ #endif
64836491static const word32 cannedKexAlgoNamesSz = sizeof (cannedKexAlgoNames ) - 2 ;
64846492static const word32 cannedNoneNamesSz = sizeof (cannedNoneNames ) - 1 ;
64856493
@@ -6513,6 +6521,7 @@ int SendKexInit(WOLFSSH* ssh)
65136521 if (ret == WS_SUCCESS ) {
65146522 if (ssh -> ctx -> side == WOLFSSH_ENDPOINT_SERVER ) {
65156523 switch (ssh -> ctx -> useEcc ) {
6524+ #if !defined(WOLFSSH_NO_ECDSA ) && !defined(WOLFSSH_NO_ECDH )
65166525 case ECC_SECP256R1 :
65176526 cannedKeyAlgoNames = cannedKeyAlgoEcc256Names ;
65186527 cannedKeyAlgoNamesSz = cannedKeyAlgoEcc256NamesSz ;
@@ -6525,6 +6534,7 @@ int SendKexInit(WOLFSSH* ssh)
65256534 cannedKeyAlgoNames = cannedKeyAlgoEcc521Names ;
65266535 cannedKeyAlgoNamesSz = cannedKeyAlgoEcc521NamesSz ;
65276536 break ;
6537+ #endif
65286538 default :
65296539 cannedKeyAlgoNames = cannedKeyAlgoRsaNames ;
65306540 cannedKeyAlgoNamesSz = cannedKeyAlgoRsaNamesSz ;
@@ -6659,7 +6669,9 @@ int SendKexDhReply(WOLFSSH* ssh)
66596669{
66606670 int ret = WS_SUCCESS ;
66616671 byte * f_ptr = NULL , * sig_ptr = NULL ;
6672+ #ifndef WOLFSSH_NO_ECDH
66626673 byte * r_ptr = NULL , * s_ptr = NULL ;
6674+ #endif
66636675 byte scratchLen [LENGTH_SZ ];
66646676 word32 fSz = KEX_F_SIZE ;
66656677 word32 sigSz = KEX_SIG_SIZE ;
@@ -7057,6 +7069,7 @@ int SendKexDhReply(WOLFSSH* ssh)
70577069#endif /* ! WOLFSSH_NO_DH */
70587070 }
70597071 else {
7072+ #if !defined(WOLFSSH_NO_ECDH )
70607073 ecc_key pubKey ;
70617074 ecc_key privKey ;
70627075 int primeId ;
@@ -7092,6 +7105,7 @@ int SendKexDhReply(WOLFSSH* ssh)
70927105 ssh -> k , & ssh -> kSz );
70937106 wc_ecc_free (& privKey );
70947107 wc_ecc_free (& pubKey );
7108+ #endif /* !defined(WOLFSSH_NO_ECDH) */
70957109 }
70967110 }
70977111
@@ -7655,6 +7669,7 @@ int SendKexDhInit(WOLFSSH* ssh)
76557669#endif
76567670 }
76577671 else {
7672+ #if !defined(WOLFSSH_NO_ECDH )
76587673 ecc_key * privKey = & ssh -> handshake -> privKey .ecc ;
76597674 int primeId = wcPrimeForId (ssh -> handshake -> kexId );
76607675
@@ -7674,6 +7689,9 @@ int SendKexDhInit(WOLFSSH* ssh)
76747689 privKey , primeId );
76757690 if (ret == 0 )
76767691 ret = wc_ecc_export_x963 (privKey , e , & eSz );
7692+ #else
7693+ ret = WS_INVALID_ALGO_ID ;
7694+ #endif /* !defined(WOLFSSH_NO_ECDH) */
76777695 }
76787696
76797697 if (ret == 0 )
0 commit comments