1. 软件准备
(1)gcc 版本
arm@ubuntu:~/test$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.6/lto-wrapper
Target: i686-linux-gnu
Configured with: …/src/configure -v --with-pkgversion=‘Ubuntu/Linaro 4.6.3-1ubuntu5’ --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
(2)系统版本
arm@ubuntu:~/test$ uname -a
Linux ubuntu 3.11.0-15-generic #25~precise1-Ubuntu SMP Thu Jan 30 17:42:40 UTC 2014 i686 i686 i386 GNU/Linux
arm@ubuntu:~/test$ cat /proc/version
Linux version 3.11.0-15-generic (buildd@akateko) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #25~precise1-Ubuntu SMP Thu Jan 30 17:42:40 UTC 2014
(3)make版本
arm@ubuntu:~/test$ make -v
GNU Make 3.81
Copyright © 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
(4)openssl版本
安装包文件名openssl-1.1.0g
arm@ubuntu:/usr/local/openssl/bin$ ./openssl version
OpenSSL 1.1.0g 2 Nov 2017
主要用编译得到的库文件libcrypto.a、 libssl.a。
(5)YAFUFlash版本
#define VERSION_NUMBER “4.90.0”
2.安装OpenSSL
# tar -xzf openssl-1.1.0f.tar.gz
# cd openssl-1.1.0f
# mkdir /usr/local/openssl
# ./config --prefix=/usr/local/openssl
# make
# make install
# which openssl
/usr/local/openssl/bin/openssl
创建软连接,如下:
# ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
# cd /usr/local/openssl
# ldd /usr/local/openssl/bin/openssl
linux-vdso.so.1 => (0x00007ffc63975000)
libssl.so.1.1 => not found
libcrypto.so.1.1 => not found
libdl.so.2 => /lib64/libdl.so.2 (0x00007f8d9da0f000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f8d9d7f3000)
libc.so.6 => /lib64/libc.so.6 (0x00007f8d9d431000)
/lib64/ld-linux-x86-64.so.2 (0x00007f8d9dc28000)
# vim /etc/ld.so.conf
在最后追加一行:
/usr/local/openssl/lib
# openssl version
OpenSSL 1.1.0f 25 May 2017
安装OK
3.修改源代码
(1) 修改libipmi_network_session.c
第①处
在函数AES_CBC_Encrypt
内(大约在第1072行),将EVP_CIPHER_CTX ctx;
注释掉,在其下面添加以下代码。
EVP_CIPHER_CTX *ctx;
ctx = EVP_CIPHER_CTX_new(); //分配内存
//在函数AES_CBC_Encrypt末尾,即return LIBIPMI_STATUS_SUCCESS;添加
EVP_CIPHER_CTX_free(ctx);
//释放内存
第②处
在函数AES_CBC_Decrypt
内(大约在第1226行),将EVP_CIPHER_CTX ctx;
注释掉,在其下面添加以下代码。
EVP_CIPHER_CTX *ctx;
ctx = EVP_CIPHER_CTX_new(); //分配内存
//在函数AES_CBC_Decrypt末尾,即return LIBIPMI_STATUS_SUCCESS;添加以下语句
EVP_CIPHER_CTX_free(ctx); //释放内存
第③处
将libipmi_network_session.c中所有的“&ctx
”替换为“ctx
”。(此处是否应该修改还在待验证中)。
(2) 修改Makefile文件
文件路径yafuflash\yafuflash-4.90.0-ANY\Linux\Linux_x86_32\ Makefile。
将INCDIR = ../../../../Build/include
(大约在第5行)改为INCDIR = ../../ Build/include
在LIBS += $(LIBPATH)/libipmi.a
(大约在第21行)下添加以下代码即可:
LIBS += $(LIBPATH)/libssl.a
LIBS += $(LIBPATH)/libcrypto.a
LIBS += -lpthread
4.文件拷贝
mkdir yafuflash/lib/libipmi/Linux_x86_32 -p
cp yafuflash/lib/libipmi.a yafuflash/lib/libipmi/Linux_x86_32
cp /usr/local/openssl/lib/libcrypto.a yafuflash/lib/libipmi/Linux_x86_32
cp /usr/local/openssl/lib/libssl.a yafuflash/lib/libipmi/Linux_x86_32
cp -rf /usr/local/openssl/include/openssl/ yafuflash/Build/include/
5.编译
cd yafuflash/libipmi-3.142.0-src/data/Linux_x86_32/
make clean
make
cd ../../../yafuflash-4.90.0-ANY/Linux/Linux_x86_32/
make clean
make
cd ../../obj/Linux_x86_32/