2021-11-12

学习内容:

一、根据其中把.pl文件变成.so文件流程如下:
1、CC=“gcc” /usr/bin/perl ./openssl/crypto/bn/asm/mips.pl 64 crypto/bn/bn-mips.S 把pl文件变为.S文件

2、gcc -I. -Icrypto/include -Iinclude -Icrypto -I… -I…/crypto/include -I…/include -I…/crypto -fPIC -pthread -mabi=64 -Wa,–noexecstack -Wall -DL_ENDIAN -Wa,–noexecstack -g -O2 -fdebug-prefix-map=/home/loongson/openssl/openssl-1.1.1d=. -fstack-protector-strong -Wformat -Werror=format-security -DOPENSSL_USE_NODELETE -DOPENSSL_PIC -DOPENSSL_BN_ASM_MONT -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DAES_ASM -DPOLY1305_ASM -DOPENSSLDIR=""/usr/lib/ssl"" -DENGINESDIR=""/usr/lib/mips64el-linux-gnuabi64/engines-1.1"" -DNDEBUG -Wdate-time -D_FORTIFY_SOURCE=2 -c -o crypto/bn/bn-mips.o crypto/bn/bn-mips.S

上面两个就会生成bn-mips.o文件了,我们本地测试可以直接根据这个.o文件自己手动生成.so文件,然后写测试程序进行手动测试。我采用如下的方法:
gcc -shared -fPIC bn-mips.o -o libbn-mips.so
lgcc test.c -o test -L. -lbn-mips
~/test$ ./test
输出:0

二、使用默认C语言的crypto的库:
cat test.c

#include <stdio.h>
#define BN_ULONG unsigned int

extern BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);

extern BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);

int main()
{
BN_ULONG bp = 12;
BN_ULONG d = 20;
int num = 10;
BN_ULONG tp[10] = {1,2,3,4,5,6,7,8,9,10};
BN_ULONG ap[10] = {1,2,3,4,5,6,7,8,9,10};
d = bn_mul_add_words(tp, ap, num, bp);
//d = bn_mul_words(tp,ap,num,bp);
printf("%d\r\n",d);
}

终端shell:
gcc test.c -o test -L. -lcrypto -lpthread -ldl
ls libcrypto.a
我从那个openssl中拷贝过来的静态库。
libcrypto.a
./test
0 //为什么结果是0呢?还是本来就应该是0

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值