package/shairport-sync: fix build w/ mbedtls v3.6
PATCH 1/1 package/shairport-sync: fix build w/ mbedtls v3.6
Since [1] when trying to build this package with mbedtls v3.6 the following error is happening:
```
player.h:12:10: fatal error: mbedtls/havege.h: No such file or directory
12 | #include <mbedtls/havege.h>
| ^~~~~~~~~~~~~~~~~~
compilation terminated.
```This error can be reproduced with the following config:
``` cat <<EOF >.config BR2_arm=y BR2_cortex_a7=y BR2_TOOLCHAIN_EXTERNAL=y BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y BR2_PACKAGE_MBEDTLS=y BR2_PACKAGE_SHAIRPORT_SYNC=y EOF make olddefconfig make ```
This patch backport the upstream commit [2] that add support for mbedtls v3.
[1] 3481a9643f package/mbedtls: bump to version 3.6.3.1
[2] https://github.com/mikebrady/shairport-sync/commit/d73b585c6f6d9136ae7a04243a54d734fa57d779
--- ...0002-mbedtls-add-support-to-mbedtls3.patch | 105 ++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 package/shairport-sync/0002-mbedtls-add-support-to-mbedtls3.patch
package/shairport-sync/0002-mbedtls-add-support-to-mbedtls3.patch new file +105 -0
@@ -0,0 +1,105 @@ +From d73b585c6f6d9136ae7a04243a54d734fa57d779 Mon Sep 17 00:00:00 2001 +From: Seo Suchan <[email protected]> +Date: Thu, 9 May 2024 19:10:59 +0900 +Subject: [PATCH] mbedtls: add support to mbedtls3 + +Signed-off-by: Seo Suchan <[email protected]> +Upstream: https://github.com/mikebrady/shairport-sync/commit/d73b585c6f6d9136ae7a04243a54d734fa57d779 +[thomas: backport the line numbers] +Signed-off-by: Thomas Perale <[email protected]> +--- + common.c | 30 ++++++++++++++++++++++++++---- + player.c | 1 - + player.h | 1 - + 3 files changed, 26 insertions(+), 6 deletions(-) + +diff --git a/common.c b/common.c +index 4dc75bc7f..0e2a07243 100644 +--- a/common.c ++++ b/common.c +@@ -77,6 +77,12 @@ + #include <mbedtls/md.h> + #include <mbedtls/version.h> + #include <mbedtls/x509.h> ++ ++#if MBEDTLS_VERSION_MAJOR == 3 ++#define MBEDTLS_PRIVATE_V3_ONLY(_q) MBEDTLS_PRIVATE(_q) ++#else ++#define MBEDTLS_PRIVATE_V3_ONLY(_q) _q ++#endif + #endif + + #ifdef CONFIG_LIBDAEMON +@@ -691,8 +697,14 @@ uint8_t *rsa_apply(uint8_t *input, int inlen, int *outlen, int mode) { + + mbedtls_pk_init(&pkctx); + ++#if MBEDTLS_VERSION_MAJOR == 3 + rc = mbedtls_pk_parse_key(&pkctx, (unsigned char *)super_secret_key, sizeof(super_secret_key), ++ NULL, 0, mbedtls_ctr_drbg_random, &ctr_drbg); ++#else ++ rc = mbedtls_pk_parse_key(&pkctx, (unsigned char *)super_secret_key, sizeof(super_secret_key), + NULL, 0); ++ ++#endif + if (rc != 0) + debug(1, "Error %d reading the private key.", rc); + +@@ -701,19 +713,29 @@ uint8_t *rsa_apply(uint8_t *input, int inlen, int *outlen, int mode) { + + switch (mode) { + case RSA_MODE_AUTH: +- mbedtls_rsa_set_padding(trsa, MBEDTLS_RSA_PKCS_V15, MBEDTLS_MD_NONE); +- outbuf = malloc(trsa->len); ++ mbedtls_rsa_set_padding(trsa, MBEDTLS_RSA_PKCS_V15, MBEDTLS_MD_NONE); ++ outbuf = malloc(trsa->MBEDTLS_PRIVATE_V3_ONLY(len)); ++#if MBEDTLS_VERSION_MAJOR == 3 ++ rc = mbedtls_rsa_pkcs1_encrypt(trsa, mbedtls_ctr_drbg_random, &ctr_drbg, ++ inlen, input, outbuf); ++#else + rc = mbedtls_rsa_pkcs1_encrypt(trsa, mbedtls_ctr_drbg_random, &ctr_drbg, MBEDTLS_RSA_PRIVATE, + inlen, input, outbuf); ++#endif + if (rc != 0) + debug(1, "mbedtls_pk_encrypt error %d.", rc); +- *outlen = trsa->len; ++ *outlen = trsa->MBEDTLS_PRIVATE_V3_ONLY(len); + break; + case RSA_MODE_KEY: + mbedtls_rsa_set_padding(trsa, MBEDTLS_RSA_PKCS_V21, MBEDTLS_MD_SHA1); +- outbuf = malloc(trsa->len); ++ outbuf = malloc(trsa->MBEDTLS_PRIVATE_V3_ONLY(len)); ++#if MBEDTLS_VERSION_MAJOR == 3 ++ rc = mbedtls_rsa_pkcs1_decrypt(trsa, mbedtls_ctr_drbg_random, &ctr_drbg, ++ &olen, input, outbuf, trsa->MBEDTLS_PRIVATE_V3_ONLY(len)); ++#else + rc = mbedtls_rsa_pkcs1_decrypt(trsa, mbedtls_ctr_drbg_random, &ctr_drbg, MBEDTLS_RSA_PRIVATE, + &olen, input, outbuf, trsa->len); ++#endif + if (rc != 0) + debug(1, "mbedtls_pk_decrypt error %d.", rc); + *outlen = olen; +diff --git a/player.c b/player.c +index 8c1752722..d023d269c 100644 +--- a/player.c ++++ b/player.c +@@ -47,7 +47,6 @@ + + #ifdef CONFIG_MBEDTLS + #include <mbedtls/aes.h> +-#include <mbedtls/havege.h> + #endif + + #ifdef CONFIG_POLARSSL +diff --git a/player.h b/player.h +index 11435bf91..b35eb7652 100644 +--- a/player.h ++++ b/player.h +@@ -9,7 +9,6 @@ + + #ifdef CONFIG_MBEDTLS + #include <mbedtls/aes.h> +-#include <mbedtls/havege.h> + #endif + + #ifdef CONFIG_POLARSSL
Signature · 6 lines
2.50.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 25 lines · Thomas Perale via buildroot
Since [1] when trying to build this package with mbedtls v3.6 the following error is happening:
``` player.h:12:10: fatal error: mbedtls/havege.h: No such file or directory 12 | #include <mbedtls/havege.h> | ^~~~~~~~~~~~~~~~~~ compilation terminated. ```This error can be reproduced with the following config:
``` cat <<EOF >.config BR2_arm=y BR2_cortex_a7=y BR2_TOOLCHAIN_EXTERNAL=y BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y BR2_PACKAGE_MBEDTLS=y BR2_PACKAGE_SHAIRPORT_SYNC=y EOF make olddefconfig make ```
Quoted 7 lines
This patch backport the upstream commit [2] that add support for mbedtls v3.
[1]
3481a9643fpackage/mbedtls: bump to version 3.6.3.1
[2] https://github.com/mikebrady/shairport-sync/commit/d73b585c6f6d9136ae7a04243a54d734fa57d779Signed-off-by Thomas Perale <[email protected]>
Applied to master, thanks.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 25 lines · Thomas Perale via buildroot
Since [1] when trying to build this package with mbedtls v3.6 the following error is happening:
``` player.h:12:10: fatal error: mbedtls/havege.h: No such file or directory 12 | #include <mbedtls/havege.h> | ^~~~~~~~~~~~~~~~~~ compilation terminated. ```This error can be reproduced with the following config:
``` cat <<EOF >.config BR2_arm=y BR2_cortex_a7=y BR2_TOOLCHAIN_EXTERNAL=y BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y BR2_PACKAGE_MBEDTLS=y BR2_PACKAGE_SHAIRPORT_SYNC=y EOF make olddefconfig make ```
Quoted 7 lines
This patch backport the upstream commit [2] that add support for mbedtls v3.
[1]
3481a9643fpackage/mbedtls: bump to version 3.6.3.1
[2] https://github.com/mikebrady/shairport-sync/commit/d73b585c6f6d9136ae7a04243a54d734fa57d779Signed-off-by Thomas Perale <[email protected]>
Applied to 2025.02.x and 2025.05.x, thanks.
Regards,
Arnout
Quoted 106 lines
--- ...0002-mbedtls-add-support-to-mbedtls3.patch | 105 ++++++++++++++++++ 1 file changed, 105 insertions(+)create mode 100644
package/shairport-sync/0002-mbedtls-add-support-to-mbedtls3.patchpackage/shairport-sync/0002-mbedtls-add-support-to-mbedtls3.patch new file +95
-0@@ -0,0 +1,105 @@ +From d73b585c6f6d9136ae7a04243a54d734fa57d779 Mon Sep 17 00:00:00 2001 +From: Seo Suchan <[email protected]> +Date: Thu, 9 May 2024 19:10:59 +0900 +Subject: [PATCH] mbedtls: add support to mbedtls3 + +Signed-off-by: Seo Suchan <[email protected]> +Upstream: https://github.com/mikebrady/shairport-sync/commit/d73b585c6f6d9136ae7a04243a54d734fa57d779 +[thomas: backport the line numbers] +Signed-off-by: Thomas Perale <[email protected]> +--- + common.c | 30 ++++++++++++++++++++++++++---- + player.c | 1 - + player.h | 1 - + 3 files changed, 26 insertions(+), 6 deletions(-) + +diff --git a/common.c b/common.c +index 4dc75bc7f..0e2a07243 100644 +--- a/common.c ++++ b/common.c +@@ -77,6 +77,12 @@ + #include <mbedtls/md.h> + #include <mbedtls/version.h> + #include <mbedtls/x509.h> ++ ++#if MBEDTLS_VERSION_MAJOR == 3 ++#define MBEDTLS_PRIVATE_V3_ONLY(_q) MBEDTLS_PRIVATE(_q) ++#else ++#define MBEDTLS_PRIVATE_V3_ONLY(_q) _q ++#endif + #endif + + #ifdef CONFIG_LIBDAEMON +@@ -691,8 +697,14 @@ uint8_t *rsa_apply(uint8_t *input, int inlen, int *outlen, int mode) { + + mbedtls_pk_init(&pkctx); + ++#if MBEDTLS_VERSION_MAJOR == 3 + rc = mbedtls_pk_parse_key(&pkctx, (unsigned char *)super_secret_key, sizeof(super_secret_key), ++ NULL, 0, mbedtls_ctr_drbg_random, &ctr_drbg); ++#else ++ rc = mbedtls_pk_parse_key(&pkctx, (unsigned char *)super_secret_key, sizeof(super_secret_key), + NULL, 0); ++ ++#endif + if (rc != 0) + debug(1, "Error %d reading the private key.", rc); + +@@ -701,19 +713,29 @@ uint8_t *rsa_apply(uint8_t *input, int inlen, int *outlen, int mode) { + + switch (mode) { + case RSA_MODE_AUTH: +- mbedtls_rsa_set_padding(trsa, MBEDTLS_RSA_PKCS_V15, MBEDTLS_MD_NONE); +- outbuf = malloc(trsa->len); ++ mbedtls_rsa_set_padding(trsa, MBEDTLS_RSA_PKCS_V15, MBEDTLS_MD_NONE); ++ outbuf = malloc(trsa->MBEDTLS_PRIVATE_V3_ONLY(len)); ++#if MBEDTLS_VERSION_MAJOR == 3 ++ rc = mbedtls_rsa_pkcs1_encrypt(trsa, mbedtls_ctr_drbg_random, &ctr_drbg, ++ inlen, input, outbuf); ++#else + rc = mbedtls_rsa_pkcs1_encrypt(trsa, mbedtls_ctr_drbg_random, &ctr_drbg, MBEDTLS_RSA_PRIVATE, + inlen, input, outbuf); ++#endif + if (rc != 0) + debug(1, "mbedtls_pk_encrypt error %d.", rc); +- *outlen = trsa->len; ++ *outlen = trsa->MBEDTLS_PRIVATE_V3_ONLY(len); + break; + case RSA_MODE_KEY: + mbedtls_rsa_set_padding(trsa, MBEDTLS_RSA_PKCS_V21, MBEDTLS_MD_SHA1); +- outbuf = malloc(trsa->len); ++ outbuf = malloc(trsa->MBEDTLS_PRIVATE_V3_ONLY(len)); ++#if MBEDTLS_VERSION_MAJOR == 3 ++ rc = mbedtls_rsa_pkcs1_decrypt(trsa, mbedtls_ctr_drbg_random, &ctr_drbg, ++ &olen, input, outbuf, trsa->MBEDTLS_PRIVATE_V3_ONLY(len)); ++#else + rc = mbedtls_rsa_pkcs1_decrypt(trsa, mbedtls_ctr_drbg_random, &ctr_drbg, MBEDTLS_RSA_PRIVATE, + &olen, input, outbuf, trsa->len); ++#endif + if (rc != 0) + debug(1, "mbedtls_pk_decrypt error %d.", rc); + *outlen = olen; +diff --git a/player.c b/player.c +index 8c1752722..d023d269c 100644 +--- a/player.c ++++ b/player.c +@@ -47,7 +47,6 @@ + + #ifdef CONFIG_MBEDTLS + #include <mbedtls/aes.h> +-#include <mbedtls/havege.h> + #endif + + #ifdef CONFIG_POLARSSL +diff --git a/player.h b/player.h +index 11435bf91..b35eb7652 100644
package/shairport-sync/0002-mbedtls-add-support-to-mbedtls3.patch line 105
Quoted 10 lines
package/shairport-sync/0002-mbedtls-add-support-to-mbedtls3.patch new file +10
-0+--- a/player.h ++++ b/player.h +@@ -9,7 +9,6 @@ + + #ifdef CONFIG_MBEDTLS + #include <mbedtls/aes.h> +-#include <mbedtls/havege.h> + #endif + + #ifdef CONFIG_POLARSSL
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot