2
1

0001-libs-srtp-crypto-hash-hmac_ossl.c-fix-build-with-lib.patch 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. From c8cc6f1773ff370bb14bb963e2f632eef6d6a3c2 Mon Sep 17 00:00:00 2001
  2. From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  3. Date: Thu, 12 May 2022 23:22:42 +0200
  4. Subject: [PATCH] libs/srtp/crypto/hash/hmac_ossl.c: fix build with libressl >=
  5. 3.5.0
  6. Fix the following build failure with libressl >= 3.5.0:
  7. crypto/hash/hmac_ossl.c: In function 'srtp_hmac_alloc':
  8. crypto/hash/hmac_ossl.c:88:55: error: invalid application of 'sizeof' to incomplete type 'HMAC_CTX' {aka 'struct hmac_ctx_st'}
  9. 88 | pointer = (uint8_t *)srtp_crypto_alloc(sizeof(HMAC_CTX) +
  10. | ^~~~~~~~
  11. crypto/hash/hmac_ossl.c:97:9: warning: implicit declaration of function 'HMAC_CTX_init'; did you mean 'HMAC_CTX_new'? [-Wimplicit-function-declaration]
  12. 97 | HMAC_CTX_init(new_hmac_ctx);
  13. | ^~~~~~~~~~~~~
  14. | HMAC_CTX_new
  15. crypto/hash/hmac_ossl.c: In function 'srtp_hmac_dealloc':
  16. crypto/hash/hmac_ossl.c:130:5: warning: implicit declaration of function 'HMAC_CTX_cleanup' [-Wimplicit-function-declaration]
  17. 130 | HMAC_CTX_cleanup(hmac_ctx);
  18. | ^~~~~~~~~~~~~~~~
  19. crypto/hash/hmac_ossl.c:133:40: error: invalid application of 'sizeof' to incomplete type 'HMAC_CTX' {aka 'struct hmac_ctx_st'}
  20. 133 | octet_string_set_to_zero(a, sizeof(HMAC_CTX) + sizeof(srtp_auth_t));
  21. | ^~~~~~~~
  22. Fixes:
  23. - http://autobuild.buildroot.org/results/e696ead9ffffa5bb80928d75607bfbb9b263d3c6
  24. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  25. ---
  26. libs/srtp/crypto/hash/hmac_ossl.c | 6 ++++--
  27. 1 file changed, 4 insertions(+), 2 deletions(-)
  28. diff --git a/libs/srtp/crypto/hash/hmac_ossl.c b/libs/srtp/crypto/hash/hmac_ossl.c
  29. index 8146438b05..6730cbb35c 100644
  30. --- a/libs/srtp/crypto/hash/hmac_ossl.c
  31. +++ b/libs/srtp/crypto/hash/hmac_ossl.c
  32. @@ -79,7 +79,8 @@ static srtp_err_status_t srtp_hmac_alloc(srtp_auth_t **a,
  33. /* OpenSSL 1.1.0 made HMAC_CTX an opaque structure, which must be allocated
  34. using HMAC_CTX_new. But this function doesn't exist in OpenSSL 1.0.x. */
  35. -#if OPENSSL_VERSION_NUMBER < 0x10100000L || LIBRESSL_VERSION_NUMBER
  36. +#if OPENSSL_VERSION_NUMBER < 0x10100000L || \
  37. + (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x30500000L)
  38. {
  39. /* allocate memory for auth and HMAC_CTX structures */
  40. uint8_t *pointer;
  41. @@ -125,7 +126,8 @@ static srtp_err_status_t srtp_hmac_dealloc(srtp_auth_t *a)
  42. hmac_ctx = (HMAC_CTX *)a->state;
  43. -#if OPENSSL_VERSION_NUMBER < 0x10100000L || LIBRESSL_VERSION_NUMBER
  44. +#if OPENSSL_VERSION_NUMBER < 0x10100000L || \
  45. + (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x30500000L)
  46. HMAC_CTX_cleanup(hmac_ctx);
  47. /* zeroize entire state*/
  48. --
  49. 2.35.1