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