Skip to content

Commit d02e600

Browse files
embhornejohnstown
authored andcommitted
Fix for not HAVE_ECC
1 parent 5931aef commit d02e600

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

src/internal.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

64306434
static const char cannedKeyAlgoRsaNames[] = "ssh-rsa";
6435+
#if !defined(WOLFSSH_NO_ECDSA)
64316436
static const char cannedKeyAlgoEcc256Names[] = "ecdsa-sha2-nistp256";
64326437
static const char cannedKeyAlgoEcc384Names[] = "ecdsa-sha2-nistp384";
64336438
static const char cannedKeyAlgoEcc521Names[] = "ecdsa-sha2-nistp521";
6439+
#endif
64346440

64356441
static const char cannedKexAlgoNames[] =
64366442
#if !defined(WOLFSSH_NO_ECDH_SHA2_NISTP521)
@@ -6470,12 +6476,14 @@ static const word32 cannedMacAlgoNamesSz = sizeof(cannedMacAlgoNames) - 2;
64706476
static const word32 cannedKeyAlgoClientNamesSz =
64716477
sizeof(cannedKeyAlgoClientNames) - 2;
64726478
static const word32 cannedKeyAlgoRsaNamesSz = sizeof(cannedKeyAlgoRsaNames) - 1;
6479+
#if !defined(WOLFSSH_NO_ECDSA) && !defined(WOLFSSH_NO_ECDH)
64736480
static const word32 cannedKeyAlgoEcc256NamesSz =
64746481
sizeof(cannedKeyAlgoEcc256Names) - 1;
64756482
static const word32 cannedKeyAlgoEcc384NamesSz =
64766483
sizeof(cannedKeyAlgoEcc384Names) - 1;
64776484
static const word32 cannedKeyAlgoEcc521NamesSz =
64786485
sizeof(cannedKeyAlgoEcc521Names) - 1;
6486+
#endif
64796487
static const word32 cannedKexAlgoNamesSz = sizeof(cannedKexAlgoNames) - 2;
64806488
static 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)

tests/api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ static const char serverKeyEccDer[] =
471471
"45747a834c61f33fad26cf22cda9a3bca561b47ce662d4c2f755439a31fb8011"
472472
"20b5124b24f578d7fd22ef4635f005586b5f63c8da1bc4f569";
473473
static const int serverKeyEccCurveId = ECC_SECP256R1;
474-
#elif defined(WOLFSSH_NO_ECDSA_SHA2_NISTP384)
474+
#elif !defined(WOLFSSH_NO_ECDSA_SHA2_NISTP384)
475475
static const char serverKeyEccDer[] =
476476
"3081a402010104303eadd2bbbf05a7be3a3f7c28151289de5bb3644d7011761d"
477477
"b56f2a0362fba64f98e64ff986dc4fb8efdb2d6b8da57142a00706052b810400"
@@ -480,7 +480,7 @@ static const char serverKeyEccDer[] =
480480
"b4c6a4cf5e97bd7e51e975e3e9217261506eb9cf3c493d3eb88d467b5f27ebab"
481481
"2161c00066febd";
482482
static const int serverKeyEccCurveId = ECC_SECP384R1;
483-
#elif defined(WOLFSSH_NO_ECDSA_SHA2_NISTP521)
483+
#elif !defined(WOLFSSH_NO_ECDSA_SHA2_NISTP521)
484484
static const char serverKeyEccDer[] =
485485
"3081dc0201010442004ca4d86428d9400e7b2df3912eb996c195895043af92e8"
486486
"6de70ae4df46f22a291a6bb2748aae82580df6c39f49b3ed82f1789ece1b657d"

wolfssh/internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,9 @@ typedef struct HandshakeInfo {
463463
#ifndef WOLFSSH_NO_DH
464464
DhKey dh;
465465
#endif
466+
#if !defined(WOLFSSH_NO_ECDSA) && !defined(WOLFSSH_NO_ECDH)
466467
ecc_key ecc;
468+
#endif
467469
} privKey;
468470
} HandshakeInfo;
469471

0 commit comments

Comments
 (0)