Skip to content

Commit 3fdaf72

Browse files
committed
avs_commons 5.4.6
Improvements * devconfig script now additionally sets `-Werror=implicit-function-declaration` flag to ensure that missing function declarations are treated as error Bugfixes * Fixed default implementation of avs_condvar_create for pthreads in case pthread_condattr APIs are not available * Fixed compilation warnings when building against Mbed TLS 3.6 * Added missing call to `psa_crypto_init()` if `MBEDTLS_USE_PSA_CRYPTO` is not defined, but `MBEDTLS_PSA_CRYPTO_C` is. * Fixed DANE implementation to be compatible with TLS 1.3 implementation in Mbed TLS which ignores the authmode setting. * Added a workaround to mimic `MBEDTLS_SSL_VERIFY_NONE` authmode when using TLS 1.3. * Fixed a corner case with uninitialized variable in mbedtls_socket layer.
1 parent 2885ea1 commit 3fdaf72

File tree

7 files changed

+135
-92
lines changed

7 files changed

+135
-92
lines changed

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
# Changelog
22

3+
## avs_commons 5.4.6 (Oct 24th, 2024)
4+
5+
### Improvements
6+
7+
* devconfig script now additionally sets `-Werror=implicit-function-declaration`
8+
flag to ensure that missing function declarations are treated as error
9+
10+
### Bugfixes
11+
12+
* Fixed default implementation of avs_condvar_create for pthreads
13+
in case pthread_condattr APIs are not available
14+
* Fixed compilation warnings when building against Mbed TLS 3.6
15+
* Added missing call to `psa_crypto_init()` if `MBEDTLS_USE_PSA_CRYPTO` is not
16+
defined, but `MBEDTLS_PSA_CRYPTO_C` is.
17+
* Fixed DANE implementation to be compatible with TLS 1.3 implementation in Mbed
18+
TLS which ignores the authmode setting.
19+
* Added a workaround to mimic `MBEDTLS_SSL_VERIFY_NONE` authmode when using
20+
TLS 1.3.
21+
* Fixed a corner case with uninitialized variable in mbedtls_socket layer.
22+
323
## avs_commons 5.4.5 (May 28th, 2024)
424

525
### Improvements

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
cmake_minimum_required(VERSION 3.6.0)
1818
project(avs_commons C)
1919

20-
set(AVS_COMMONS_VERSION "5.4.5")
20+
set(AVS_COMMONS_VERSION "5.4.6")
2121

2222
################# DISTRIBUTION #################################################
2323

devconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ cmake -D WITH_EXTRA_WARNINGS=ON \
3232
-D WITH_TEST=ON \
3333
-D WITH_AVS_CRYPTO_ADVANCED_FEATURES=ON \
3434
-D WITH_VALGRIND=ON \
35-
-D CMAKE_C_FLAGS=-g \
35+
-D CMAKE_C_FLAGS="-g -Werror=implicit-function-declaration" \
3636
-D CMAKE_INSTALL_PREFIX:PATH=/tmp \
3737
"${EXTRA_FLAGS[@]}" \
3838
"$@" -H"$(dirname "$0")" -B. &&

src/compat/threading/pthread/avs_pthread_condvar.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,11 @@ int avs_condvar_create(avs_condvar_t **out_condvar) {
6262
if (!result) {
6363
result = pthread_cond_init(&(*out_condvar)->pthread_cond, attr_ptr);
6464
}
65+
# ifdef USE_CLOCK_MONOTONIC
6566
if (attr_ptr) {
6667
pthread_condattr_destroy(attr_ptr);
6768
}
69+
# endif // USE_CLOCK_MONOTONIC
6870
if (result) {
6971
avs_free(*out_condvar);
7072
*out_condvar = NULL;

src/crypto/mbedtls/avs_mbedtls_global.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@
2929
# include "../avs_crypto_global.h"
3030

3131
# include <mbedtls/version.h>
32-
# if defined(MBEDTLS_USE_PSA_CRYPTO) \
32+
# if defined(MBEDTLS_USE_PSA_CRYPTO) || defined(MBEDTLS_PSA_CRYPTO_C) \
3333
|| defined(AVS_COMMONS_WITH_MBEDTLS_PSA_RNG)
3434
# include <psa/crypto.h>
35-
# endif // defined(MBEDTLS_USE_PSA_CRYPTO) ||
36-
// defined(AVS_COMMONS_WITH_MBEDTLS_PSA_RNG)
35+
# endif // defined(MBEDTLS_USE_PSA_CRYPTO) || defined(MBEDTLS_PSA_CRYPTO_C)
36+
// || defined(AVS_COMMONS_WITH_MBEDTLS_PSA_RNG)
3737

3838
# define MODULE_NAME avs_crypto_global
3939
# include <avs_x_log_config.h>
@@ -42,7 +42,7 @@ VISIBILITY_SOURCE_BEGIN
4242

4343
avs_error_t _avs_crypto_initialize_global_state() {
4444
avs_error_t err = AVS_OK;
45-
# if defined(MBEDTLS_USE_PSA_CRYPTO) \
45+
# if defined(MBEDTLS_USE_PSA_CRYPTO) || defined(MBEDTLS_PSA_CRYPTO_C) \
4646
|| defined(AVS_COMMONS_WITH_MBEDTLS_PSA_RNG)
4747
// NOTE: When MBEDTLS_USE_PSA_CRYPTO is enabled, psa_crypto_init() is
4848
// required even when only using the regular Mbed TLS API. Also, even when
@@ -53,8 +53,8 @@ avs_error_t _avs_crypto_initialize_global_state() {
5353
LOG(ERROR, _("psa_crypto_init() failed: ") "%" PRId32, status);
5454
return avs_errno(AVS_EPROTO);
5555
}
56-
# endif // defined(MBEDTLS_USE_PSA_CRYPTO) ||
57-
// defined(AVS_COMMONS_WITH_MBEDTLS_PSA_RNG)
56+
# endif // defined(MBEDTLS_USE_PSA_CRYPTO) || defined(MBEDTLS_PSA_CRYPTO_C)
57+
// || defined(AVS_COMMONS_WITH_MBEDTLS_PSA_RNG)
5858
# if defined(AVS_COMMONS_WITH_AVS_CRYPTO_PKI_ENGINE) \
5959
|| defined(AVS_COMMONS_WITH_AVS_CRYPTO_PSK_ENGINE)
6060
err = _avs_crypto_mbedtls_engine_initialize_global_state();

src/crypto/mbedtls/avs_mbedtls_private.h

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ _avs_crypto_mbedtls_cipher_info_from_ciphersuite(
151151

152152
static inline mbedtls_cipher_mode_t
153153
_avs_crypto_mbedtls_cipher_info_get_mode(const mbedtls_cipher_info_t *cipher) {
154-
return cipher->MBEDTLS_PRIVATE(mode);
154+
return (mbedtls_cipher_mode_t) cipher->MBEDTLS_PRIVATE(mode);
155155
}
156156

157157
static inline unsigned int
@@ -166,6 +166,44 @@ static inline int mbedtls_ssl_is_handshake_over(mbedtls_ssl_context *ssl) {
166166
}
167167
# endif // MBEDTLS_VERSION_NUMBER < 0x03020000
168168

169+
# if defined(AVS_COMMONS_WITH_AVS_NET) \
170+
&& MBEDTLS_VERSION_NUMBER >= 0x03060000
171+
// since Mbed TLS 3.6.0 mbedtls_ssl_ciphersuite_uses_psk and
172+
// mbedtls_ssl_ciphersuite_uses_srv_cert has been moved to internal functions
173+
174+
# if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)
175+
static inline int
176+
mbedtls_ssl_ciphersuite_uses_psk(const mbedtls_ssl_ciphersuite_t *ciphersuite) {
177+
switch (ciphersuite->MBEDTLS_PRIVATE(key_exchange)) {
178+
case MBEDTLS_KEY_EXCHANGE_PSK:
179+
case MBEDTLS_KEY_EXCHANGE_RSA_PSK:
180+
case MBEDTLS_KEY_EXCHANGE_DHE_PSK:
181+
case MBEDTLS_KEY_EXCHANGE_ECDHE_PSK:
182+
return 1;
183+
default:
184+
return 0;
185+
}
186+
}
187+
# endif // defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED)
188+
189+
static inline int mbedtls_ssl_ciphersuite_uses_srv_cert(
190+
const mbedtls_ssl_ciphersuite_t *ciphersuite) {
191+
switch (ciphersuite->MBEDTLS_PRIVATE(key_exchange)) {
192+
case MBEDTLS_KEY_EXCHANGE_RSA:
193+
case MBEDTLS_KEY_EXCHANGE_RSA_PSK:
194+
case MBEDTLS_KEY_EXCHANGE_DHE_RSA:
195+
case MBEDTLS_KEY_EXCHANGE_ECDH_RSA:
196+
case MBEDTLS_KEY_EXCHANGE_ECDHE_RSA:
197+
case MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA:
198+
case MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA:
199+
return 1;
200+
default:
201+
return 0;
202+
}
203+
}
204+
# endif // defined(AVS_COMMONS_WITH_AVS_NET) && MBEDTLS_VERSION_NUMBER >=
205+
// 0x03060000
206+
169207
# ifndef MBEDTLS_SSL_SRV_C
170208
// HACK: We (ab)use mbedtls_ssl_conf_session_cache() in avs_net to detect
171209
// whether a (D)TLS session has been resumed or a new one has been created.
@@ -205,7 +243,7 @@ mbedtls_ssl_conf_session_cache(mbedtls_ssl_config *conf,
205243
&& defined(MBEDTLS_SSL_CONTEXT_SERIALIZATION)
206244
static inline mbedtls_cipher_type_t
207245
_avs_crypto_mbedtls_cipher_info_get_type(const mbedtls_cipher_info_t *cipher) {
208-
return cipher->MBEDTLS_PRIVATE(type);
246+
return (mbedtls_cipher_type_t) cipher->MBEDTLS_PRIVATE(type);
209247
}
210248
#endif // defined(AVS_COMMONS_WITH_AVS_NET) &&
211249
// defined(MBEDTLS_SSL_DTLS_CONNECTION_ID) &&

0 commit comments

Comments
 (0)