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