Skip to content

Commit e0b2019

Browse files
authored
Merge pull request #136 from bigbrett/fix-for-ccb-ecc-protection-macros
fix for new ECC ccb protection macros
2 parents d84fcb0 + 34aac6a commit e0b2019

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

src/wh_client_cryptocb.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ int wh_Client_CryptoCb(int devId, wc_CryptoInfo* info, void* inCtx)
204204
#endif /* !NO_RSA */
205205

206206
#ifdef HAVE_ECC
207+
#ifdef HAVE_ECC_DHE
207208
case WC_PK_TYPE_EC_KEYGEN:
208209
{
209210
/* Extract info parameters */
@@ -235,7 +236,9 @@ int wh_Client_CryptoCb(int devId, wc_CryptoInfo* info, void* inCtx)
235236
*out_len = len;
236237
}
237238
} break;
239+
#endif /* HAVE_ECC_DHE */
238240

241+
#ifdef HAVE_ECC_SIGN
239242
case WC_PK_TYPE_ECDSA_SIGN:
240243
{
241244
/* Extract info parameters */
@@ -256,7 +259,9 @@ int wh_Client_CryptoCb(int devId, wc_CryptoInfo* info, void* inCtx)
256259
*out_sig_len = sig_len;
257260
}
258261
} break;
262+
#endif /* HAVE_ECC_SIGN */
259263

264+
#ifdef HAVE_ECC_VERIFY
260265
case WC_PK_TYPE_ECDSA_VERIFY:
261266
{
262267
/* Extract info parameters */
@@ -270,7 +275,9 @@ int wh_Client_CryptoCb(int devId, wc_CryptoInfo* info, void* inCtx)
270275
ret = wh_Client_EccVerify(ctx, key, sig, sig_len, hash, hash_len,
271276
out_res);
272277
} break;
278+
#endif /* HAVE_ECC_VERIFY */
273279

280+
#ifdef HAVE_ECC_CHECK_KEY
274281
case WC_PK_TYPE_EC_CHECK_PRIV_KEY:
275282
{
276283
#if 0
@@ -285,6 +292,7 @@ int wh_Client_CryptoCb(int devId, wc_CryptoInfo* info, void* inCtx)
285292
ret = CRYPTOCB_UNAVAILABLE;
286293
#endif
287294
} break;
295+
#endif /* HAVE_ECC_CHECK_KEY */
288296

289297
#endif /* HAVE_ECC */
290298

src/wh_server_crypto.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,23 +95,27 @@ static int _HandleAesGcm(whServerContext* ctx, uint16_t magic,
9595
static int _HandleEccKeyGen(whServerContext* ctx, uint16_t magic,
9696
const void* cryptoDataIn, uint16_t inSize,
9797
void* cryptoDataOut, uint16_t* outSize);
98-
98+
#ifdef HAVE_ECC_DHE
9999
static int _HandleEccSharedSecret(whServerContext* ctx, uint16_t magic,
100100
const void* cryptoDataIn, uint16_t inSize,
101101
void* cryptoDataOut, uint16_t* outSize);
102-
102+
#endif /* HAVE_ECC_DHE */
103+
#ifdef HAVE_ECC_SIGN
103104
static int _HandleEccSign(whServerContext* ctx, uint16_t magic,
104105
const void* cryptoDataIn, uint16_t inSize,
105106
void* cryptoDataOut, uint16_t* outSize);
106-
107+
#endif /* HAVE_ECC_SIGN */
108+
#ifdef HAVE_ECC_VERIFY
107109
static int _HandleEccVerify(whServerContext* ctx, uint16_t magic,
108110
const void* cryptoDataIn, uint16_t inSize,
109111
void* cryptoDataOut, uint16_t* outSize);
112+
#endif /* HAVE_ECC_VERIFY */
110113
#if 0
114+
#ifdef HAVE_ECC_CHECK_KEY
111115
static int _HandleEccCheckPrivKey(whServerContext* server, whPacket* packet,
112116
uint16_t* size)
117+
#endif /* HAVE_ECC_CHECK_KEY */
113118
#endif
114-
115119
#endif /* HAVE_ECC */
116120

117121
#ifdef HAVE_CURVE25519
@@ -745,6 +749,7 @@ static int _HandleEccKeyGen(whServerContext* ctx, uint16_t magic,
745749
return ret;
746750
}
747751

752+
#ifdef HAVE_ECC_DHE
748753
static int _HandleEccSharedSecret(whServerContext* ctx, uint16_t magic,
749754
const void* cryptoDataIn, uint16_t inSize,
750755
void* cryptoDataOut, uint16_t* outSize)
@@ -818,7 +823,9 @@ static int _HandleEccSharedSecret(whServerContext* ctx, uint16_t magic,
818823
}
819824
return ret;
820825
}
826+
#endif /* HAVE_ECC_DHE */
821827

828+
#ifdef HAVE_ECC_SIGN
822829
static int _HandleEccSign(whServerContext* ctx, uint16_t magic,
823830
const void* cryptoDataIn, uint16_t inSize,
824831
void* cryptoDataOut, uint16_t* outSize)
@@ -885,7 +892,9 @@ static int _HandleEccSign(whServerContext* ctx, uint16_t magic,
885892
}
886893
return ret;
887894
}
895+
#endif /* HAVE_ECC_SIGN */
888896

897+
#ifdef HAVE_ECC_VERIFY
889898
static int _HandleEccVerify(whServerContext* ctx, uint16_t magic,
890899
const void* cryptoDataIn, uint16_t inSize,
891900
void* cryptoDataOut, uint16_t* outSize)
@@ -971,8 +980,10 @@ static int _HandleEccVerify(whServerContext* ctx, uint16_t magic,
971980
}
972981
return ret;
973982
}
983+
#endif /* HAVE_ECC_VERIFY */
974984

975985
#if 0
986+
#ifdef HAVE_ECC_CHECK_KEY
976987
/* TODO: Implement check key */
977988
static int _HandleEccCheckPrivKey(whServerContext* server, whPacket* packet,
978989
uint16_t* size)
@@ -1007,6 +1018,7 @@ static int _HandleEccCheckPrivKey(whServerContext* server, whPacket* packet,
10071018
}
10081019
return ret;
10091020
}
1021+
#endif /* HAVE_ECC_CHECK_KEY */
10101022
#endif
10111023
#endif /* HAVE_ECC */
10121024

@@ -2177,19 +2189,25 @@ int wh_Server_HandleCryptoRequest(whServerContext* ctx, uint16_t magic,
21772189
_HandleEccKeyGen(ctx, magic, cryptoDataIn, cryptoInSize,
21782190
cryptoDataOut, &cryptoOutSize);
21792191
break;
2192+
#ifdef HAVE_ECC_DHE
21802193
case WC_PK_TYPE_ECDH:
21812194
ret = _HandleEccSharedSecret(ctx, magic, cryptoDataIn,
21822195
cryptoInSize, cryptoDataOut,
21832196
&cryptoOutSize);
21842197
break;
2198+
#endif /* HAVE_ECC_DHE */
2199+
#ifdef HAVE_ECC_SIGN
21852200
case WC_PK_TYPE_ECDSA_SIGN:
21862201
ret = _HandleEccSign(ctx, magic, cryptoDataIn, cryptoInSize,
21872202
cryptoDataOut, &cryptoOutSize);
21882203
break;
2204+
#endif /* HAVE_ECC_SIGN */
2205+
#ifdef HAVE_ECC_VERIFY
21892206
case WC_PK_TYPE_ECDSA_VERIFY:
21902207
ret = _HandleEccVerify(ctx, magic, cryptoDataIn, cryptoInSize,
21912208
cryptoDataOut, &cryptoOutSize);
21922209
break;
2210+
#endif /* HAVE_ECC_VERIFY */
21932211
#if 0
21942212
case WC_PK_TYPE_EC_CHECK_PRIV_KEY:
21952213
ret = _HandleEccCheckPrivKey(ctx, magic, cryptoDataIn, cryptoInSize,

0 commit comments

Comments
 (0)