File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -92,7 +92,9 @@ typedef struct {
9292#endif /* DTLS_PSK_MAX_CLIENT_IDENTITY_LEN */
9393
9494/* This is the maximal supported length of the pre-shared key. */
95+ #ifndef DTLS_PSK_MAX_KEY_LEN
9596#define DTLS_PSK_MAX_KEY_LEN DTLS_KEY_LENGTH
97+ #endif /* DTLS_PSK_MAX_KEY_LEN */
9698
9799typedef struct {
98100 uint16_t id_length ;
Original file line number Diff line number Diff line change @@ -952,7 +952,7 @@ calculate_key_block(dtls_context_t *ctx,
952952 dtls_peer_type role ) {
953953 (void ) ctx ;
954954 (void ) session ;
955- unsigned char * pre_master_secret ;
955+ unsigned char pre_master_secret [ 2 * ( sizeof ( uint16 ) + DTLS_PSK_MAX_KEY_LEN )] ;
956956 int pre_master_len = 0 ;
957957 dtls_security_parameters_t * security = dtls_security_params_next (peer );
958958 uint8 master_secret [DTLS_MASTER_SECRET_LENGTH ];
@@ -962,7 +962,6 @@ calculate_key_block(dtls_context_t *ctx,
962962 return dtls_alert_fatal_create (DTLS_ALERT_INTERNAL_ERROR );
963963 }
964964
965- pre_master_secret = security -> key_block ;
966965 switch (get_key_exchange_algorithm (handshake -> cipher_index )) {
967966 case DTLS_KEY_EXCHANGE_PSK :
968967#ifdef DTLS_PSK
@@ -978,10 +977,9 @@ calculate_key_block(dtls_context_t *ctx,
978977 dtls_crit ("no psk key for session available\n" );
979978 return len ;
980979 }
981- /* Temporarily use the key_block storage space for the pre master secret. */
982980 pre_master_len = dtls_psk_pre_master_secret (psk , len ,
983981 pre_master_secret ,
984- MAX_KEYBLOCK_LENGTH );
982+ sizeof ( pre_master_secret ) );
985983
986984 dtls_debug_hexdump ("psk" , psk , len );
987985
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ if(CONFIG_LIBTINYDTLS)
3939 set (DTLS_ECC Off )
4040 endif ()
4141 add_subdirectory (.. build )
42- target_compile_definitions (tinydtls PUBLIC WITH_ZEPHYR )
42+ target_compile_definitions (tinydtls PUBLIC WITH_ZEPHYR DTLS_PSK_MAX_KEY_LEN=32 DTLS_PSK_MAX_CLIENT_IDENTITY_LEN=48 )
4343 target_link_libraries (tinydtls PUBLIC zephyr_interface )
4444 set_property (GLOBAL APPEND PROPERTY ZEPHYR_INTERFACE_LIBS tinydtls)
4545endif ()
You can’t perform that action at this time.
0 commit comments