@@ -68,19 +68,23 @@ struct coap_security_s {
68
68
69
69
};
70
70
71
+ #if !defined(MBEDTLS_SSL_CONF_SINGLE_CIPHERSUITE )
71
72
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED )
72
73
const int ECJPAKE_SUITES [] = {
73
74
MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 ,
74
75
0
75
76
};
76
77
#endif
77
78
79
+ #if defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED )
78
80
static const int PSK_SUITES [] = {
79
81
MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA256 ,
80
82
MBEDTLS_TLS_PSK_WITH_AES_256_CCM_8 ,
81
83
MBEDTLS_TLS_PSK_WITH_AES_128_CCM_8 ,
82
84
0
83
85
};
86
+ #endif /* defined(MBEDTLS_KEY_EXCHANGE__SOME__PSK_ENABLED) */
87
+ #endif /* !defined(MBEDTLS_SSL_CONF_SINGLE_CIPHERSUITE) */
84
88
85
89
#define TRACE_GROUP "CsSh"
86
90
@@ -332,7 +336,9 @@ static int coap_security_handler_configure_keys(coap_security_t *sec, coap_secur
332
336
if (0 != mbedtls_ssl_conf_psk (& sec -> _conf , keys ._priv_key , keys ._priv_key_len , keys ._cert , keys ._cert_len )) {
333
337
break ;
334
338
}
339
+ #if !defined(MBEDTLS_SSL_CONF_SINGLE_CIPHERSUITE )
335
340
mbedtls_ssl_conf_ciphersuites (& sec -> _conf , PSK_SUITES );
341
+ #endif /* !defined(MBEDTLS_SSL_CONF_SINGLE_CIPHERSUITE) */
336
342
ret = 0 ;
337
343
#endif
338
344
break ;
@@ -342,7 +348,9 @@ static int coap_security_handler_configure_keys(coap_security_t *sec, coap_secur
342
348
if (mbedtls_ssl_set_hs_ecjpake_password (& sec -> _ssl , keys ._key , keys ._key_len ) != 0 ) {
343
349
return -1 ;
344
350
}
351
+ #if !defined(MBEDTLS_SSL_CONF_SINGLE_CIPHERSUITE )
345
352
mbedtls_ssl_conf_ciphersuites (& sec -> _conf , ECJPAKE_SUITES );
353
+ #endif /* !defined(MBEDTLS_SSL_CONF_SINGLE_CIPHERSUITE) */
346
354
347
355
//NOTE: If thread starts supporting PSK in other modes, then this will be needed!
348
356
mbedtls_ssl_conf_export_keys_cb (& sec -> _conf ,
@@ -394,11 +402,23 @@ int coap_security_handler_connect_non_blocking(coap_security_t *sec, bool is_ser
394
402
return -1 ;
395
403
}
396
404
405
+ // Defines MBEDTLS_SSL_CONF_RECV/SEND/RECV_TIMEOUT define global functions which should be the same for all
406
+ // callers of mbedtls_ssl_set_bio_ctx and there should be only one ssl context. If these rules don't apply,
407
+ // these defines can't be used.
408
+ #if !defined(MBEDTLS_SSL_CONF_RECV ) && !defined(MBEDTLS_SSL_CONF_SEND ) && !defined(MBEDTLS_SSL_CONF_RECV_TIMEOUT )
397
409
mbedtls_ssl_set_bio (& sec -> _ssl , sec ,
398
410
f_send , f_recv , NULL );
411
+ #else
412
+ mbedtls_ssl_set_bio_ctx (& sec -> _ssl , sec );
413
+ #endif /* !defined(MBEDTLS_SSL_CONF_RECV) && !defined(MBEDTLS_SSL_CONF_SEND) && !defined(MBEDTLS_SSL_CONF_RECV_TIMEOUT) */
399
414
415
+ // Defines MBEDTLS_SSL_CONF_SET_TIMER/GET_TIMER define global functions which should be the same for all
416
+ // callers of mbedtls_ssl_set_timer_cb and there should be only one ssl context. If these rules don't apply,
417
+ // these defines can't be used.
418
+ #if !defined(MBEDTLS_SSL_CONF_SET_TIMER ) && !defined(MBEDTLS_SSL_CONF_GET_TIMER )
400
419
mbedtls_ssl_set_timer_cb (& sec -> _ssl , sec , set_timer ,
401
420
get_timer );
421
+ #endif /* !defined(MBEDTLS_SSL_CONF_SET_TIMER) && !defined(MBEDTLS_SSL_CONF_GET_TIMER) */
402
422
403
423
#if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED )
404
424
//TODO: Figure out better way!!!
@@ -420,8 +440,13 @@ int coap_security_handler_connect_non_blocking(coap_security_t *sec, bool is_ser
420
440
& sec -> _cookie );
421
441
#endif
422
442
443
+ #if !defined(MBEDTLS_SSL_CONF_MIN_MINOR_VER ) || !defined(MBEDTLS_SSL_CONF_MIN_MAJOR_VER )
423
444
mbedtls_ssl_conf_min_version (& sec -> _conf , MBEDTLS_SSL_MAJOR_VERSION_3 , MBEDTLS_SSL_MAJOR_VERSION_3 );
445
+ #endif /* !defined(MBEDTLS_SSL_CONF_MIN_MINOR_VER) || !defined(MBEDTLS_SSL_CONF_MIN_MAJOR_VER) */
446
+
447
+ #if !defined(MBEDTLS_SSL_CONF_MAX_MINOR_VER ) || !defined(MBEDTLS_SSL_CONF_MAX_MAJOR_VER )
424
448
mbedtls_ssl_conf_max_version (& sec -> _conf , MBEDTLS_SSL_MAJOR_VERSION_3 , MBEDTLS_SSL_MAJOR_VERSION_3 );
449
+ #endif /* !defined(MBEDTLS_SSL_CONF_MAX_MINOR_VER) || !defined(MBEDTLS_SSL_CONF_MAX_MAJOR_VER) */
425
450
426
451
sec -> _is_started = true;
427
452
0 commit comments