22
22
* SOFTWARE.
23
23
*/
24
24
25
+ #include " ArduinoBearSSL.h"
26
+
27
+ #ifndef ARDUINO_DISABLE_ECCX08
25
28
#include < ArduinoECCX08.h>
29
+ #endif
26
30
27
- #include " ArduinoBearSSL.h"
28
31
#include " BearSSLTrustAnchors.h"
29
32
#include " utility/eccX08_asn1.h"
30
33
@@ -47,8 +50,13 @@ BearSSLClient::BearSSLClient(Client* client, const br_x509_trust_anchor* myTAs,
47
50
_noSNI(false ),
48
51
_ecChainLen(0 )
49
52
{
53
+ #ifndef ARDUINO_DISABLE_ECCX08
50
54
_ecVrfy = eccX08_vrfy_asn1;
51
55
_ecSign = eccX08_sign_asn1;
56
+ #else
57
+ _ecVrfy = br_ecdsa_vrfy_asn1_get_default ();
58
+ _ecSign = br_ecdsa_sign_asn1_get_default ();
59
+ #endif
52
60
53
61
_ecKey.curve = 0 ;
54
62
_ecKey.x = NULL ;
@@ -237,8 +245,13 @@ void BearSSLClient::setEccSlot(int ecc508KeySlot, const byte cert[], int certLen
237
245
_ecChainLen = 1 ;
238
246
_ecCertDynamic = false ;
239
247
248
+ #ifndef ARDUINO_DISABLE_ECCX08
240
249
_ecVrfy = eccX08_vrfy_asn1;
241
250
_ecSign = eccX08_sign_asn1;
251
+ #else
252
+ _ecVrfy = br_ecdsa_vrfy_asn1_get_default ();
253
+ _ecSign = br_ecdsa_sign_asn1_get_default ();
254
+ #endif
242
255
}
243
256
244
257
void BearSSLClient::setEccSlot (int ecc508KeySlot, const char cert[])
@@ -352,12 +365,16 @@ int BearSSLClient::connectSSL(const char* host)
352
365
// inject entropy in engine
353
366
unsigned char entropy[32 ];
354
367
368
+ #ifndef ARDUINO_DISABLE_ECCX08
355
369
if (!ECCX08.begin () || !ECCX08.locked () || !ECCX08.random (entropy, sizeof (entropy))) {
370
+ #endif
356
371
// no ECCX08 or random failed, fallback to pseudo random
357
372
for (size_t i = 0 ; i < sizeof (entropy); i++) {
358
373
entropy[i] = random (0 , 255 );
359
374
}
375
+ #ifndef ARDUINO_DISABLE_ECCX08
360
376
}
377
+ #endif
361
378
br_ssl_engine_inject_entropy (&_sc.eng , entropy, sizeof (entropy));
362
379
363
380
// add custom ECDSA vfry and EC sign
0 commit comments