🔑Ubuntu系统下PBC库的安装

开学网络安全实验课程的老师要教椭圆曲线,首先就是配置PBC库,Ubuntu作为我的主系统,必须是要配上的。

Linux编译安装PBC

开学网络安全实验课程的老师要教椭圆曲线,首先就是配置PBC库,Linux作为我的主系统,必须是要配上的。

Ubuntu系统下PBC库的安装

0.编译前环境安装

bash
sudo apt-get install m4
sudo apt-get install flex
sudo apt-get install bison
sudo apt-get install make

1.下载gmp和pbc并解压源码

pbc是依赖于gmp的,所以需要先安装gmp

下载gmp源码

官网:https://gmplib.org/

image-20240904154749656

wget https://gmplib.org/download/gmp/gmp-6.3.0.tar.xz

下载gmp-6.3.0.tar.xz,并解压

tar -xf gmp-6.3.0.tar.xz

下载pbc源码wget https://crypto.stanford.edu/pbc/files/pbc-0.5.14.tar.gz

https://crypto.stanford.edu/pbc/download.html

image-20240904155436476

继续解压

tar -zxvf pbc-0.5.14.tar.gz

image-20240904155645649

2.编译安装gmp

!!!可能会遇到gmp编译失败的问题,如果实在无法编译可以使用 sudo apt install libgmp-dev 来安装gmp,然后直接跳过这一步去编译安装PBC

依次执行列面的命令,如果没有出现error代表安装成功

bash
cd gmp-6.3.0
./configure
make
sudo make install

image-20240904155727983

./configure最终结果如下

image-20240904234546013

make最终结果如下

image-20240904234722433

sudo make install最终结果如下

image-20240904234830296

3.编译安装PBC

bahs
cd ..
cd pbc-0.5.14
./configure
make
sudo make install

image-20240904160105585

./configure结果如下

image-20240904235131837

make结果如下

image-20240904235215875

sudo make install的结果

image-20240904235246785

4.gcc编译代码测试

写入下面的代码到test.c

测试代码由GPT4o提供。

在test.c同目录下使用gcc编译

gcc test.c -I/usr/local/include -L/usr/local/lib -lpbc -lgmp

运行a.out

如果显示下面内容则代表正常运行。

image-20241109193102430

5.额外问题

问题1:编译完之后运行程序报错

./a.out: error while loading shared libraries: libpbc.so.1: cannot open shared object file: No such file or directory

执行下面命令之后再运行

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

Python星号*的更多用法
CTF-MD5碰撞

评论区

评论加载中...