0003-ibrcommon-ssl-gcm-fix-static-build-with-openssl.patch 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. From 8118c43a53271ba2dd31ce3913a3cd21bc7dcca7 Mon Sep 17 00:00:00 2001
  2. From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  3. Date: Sat, 16 Feb 2019 11:58:34 +0100
  4. Subject: [PATCH] ibrcommon/ssl/gcm: fix static build with openssl
  5. gf_mul is already defined in libcrypto (openssl) so rename it into
  6. ibrdtn_gf_mul to fix following build failure:
  7. /home/buildroot/autobuild/instance-3/output/host/bin/../arm-buildroot-uclinux-uclibcgnueabi/sysroot/usr/lib/libcrypto.a(f_impl.o): In function `gf_mul':
  8. f_impl.c:(.text+0x0): multiple definition of `gf_mul'
  9. /home/buildroot/autobuild/instance-3/output/host/arm-buildroot-uclinux-uclibcgnueabi/sysroot/usr/lib/libibrcommon.a(gf128mul.o):gf128mul.cpp:(.text+0x30): first defined here
  10. collect2: error: ld returned 1 exit status
  11. Makefile:560: recipe for target 'dtnd' failed
  12. Fixes:
  13. - http://autobuild.buildroot.org/results/1d3b4b6cf043a3e185ce758b617a0a18c3d36cdb
  14. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  15. [Upstream status: https://github.com/ibrdtn/ibrdtn/pull/269]
  16. ---
  17. ibrcommon/ibrcommon/ssl/gcm/gcm.cpp | 10 +++++-----
  18. ibrcommon/ibrcommon/ssl/gcm/gf128mul.cpp | 2 +-
  19. ibrcommon/ibrcommon/ssl/gcm/gf128mul.h | 2 +-
  20. 3 files changed, 7 insertions(+), 7 deletions(-)
  21. diff --git a/ibrcommon/ssl/gcm/gcm.cpp b/ibrcommon/ssl/gcm/gcm.cpp
  22. index 8a5745b4..6097b43e 100644
  23. --- a/ibrcommon/ssl/gcm/gcm.cpp
  24. +++ b/ibrcommon/ssl/gcm/gcm.cpp
  25. @@ -89,7 +89,7 @@ ret_type gcm_init_and_key( /* initialise mode and set key
  26. #elif defined( TABLES_256 )
  27. #define gf_mul_hh(a, ctx, scr) gf_mul_256(a, ctx->gf_t256, scr)
  28. #else
  29. -#define gf_mul_hh(a, ctx, scr) gf_mul(a, ui8_ptr(ctx->ghash_h))
  30. +#define gf_mul_hh(a, ctx, scr) ibrdtn_gf_mul(a, ui8_ptr(ctx->ghash_h))
  31. #endif
  32. ret_type gcm_init_message( /* initialise a new message */
  33. @@ -334,9 +334,9 @@ ret_type gcm_compute_tag( /* compute authentication tag
  34. memcpy(tbuf, ctx->ghash_h, BLOCK_SIZE);
  35. for( ; ; )
  36. {
  37. - if(ln & 1) gf_mul(ui8_ptr(ctx->hdr_ghv), tbuf);
  38. + if(ln & 1) ibrdtn_gf_mul(ui8_ptr(ctx->hdr_ghv), tbuf);
  39. if(!(ln >>= 1)) break;
  40. - gf_mul(tbuf, tbuf);
  41. + ibrdtn_gf_mul(tbuf, tbuf);
  42. }
  43. }
  44. #else /* this one seems slower on x86 and x86_64 :-( */
  45. @@ -348,12 +348,12 @@ ret_type gcm_compute_tag( /* compute authentication tag
  46. tbuf[0] = 0x80;
  47. while(i)
  48. {
  49. - gf_mul(tbuf, tbuf);
  50. + ibrdtn_gf_mul(tbuf, tbuf);
  51. if(i & ln)
  52. gf_mul_hh(tbuf, ctx, scratch);
  53. i >>= 1;
  54. }
  55. - gf_mul(ui8_ptr(ctx->hdr_ghv), tbuf);
  56. + ibrdtn_gf_mul(ui8_ptr(ctx->hdr_ghv), tbuf);
  57. }
  58. #endif
  59. i = BLOCK_SIZE; ln = (uint_32t)(ctx->txt_acnt << 3);
  60. diff --git a/ibrcommon/ssl/gcm/gf128mul.cpp b/ibrcommon/ssl/gcm/gf128mul.cpp
  61. index a553a044..d0c460c3 100644
  62. --- a/ibrcommon/ssl/gcm/gf128mul.cpp
  63. +++ b/ibrcommon/ssl/gcm/gf128mul.cpp
  64. @@ -103,7 +103,7 @@
  65. const unsigned short gf_tab[256] = gf_dat(xda);
  66. -void gf_mul(void *a, const void* b)
  67. +void ibrdtn_gf_mul(void *a, const void* b)
  68. { uint_32t r[GF_BYTE_LEN >> 2], p[8][GF_BYTE_LEN >> 2];
  69. int i;
  70. diff --git a/ibrcommon/ssl/gcm/gf128mul.h b/ibrcommon/ssl/gcm/gf128mul.h
  71. index 4645c7fe..65fba54b 100644
  72. --- a/ibrcommon/ssl/gcm/gf128mul.h
  73. +++ b/ibrcommon/ssl/gcm/gf128mul.h
  74. @@ -619,7 +619,7 @@ gf_inline void mul_x(void *r, const void *x)
  75. /* A slow generic version of gf_mul (a = a * b) */
  76. -void gf_mul(void *a, const void* b);
  77. +void ibrdtn_gf_mul(void *a, const void* b);
  78. /* This version uses 64k bytes of table space on the stack.
  79. A 16 byte buffer has to be multiplied by a 16 byte key
  80. --
  81. 2.14.1