谷歌发布了针对ARM优化的新算法,但是如果要使用 salsa20 或 chacha20 或 chacha20-ietf 算法,还是需要先安装 libsodium 。
CentOS下:
yum install epel-release -y yum install libsodium -y
如果想自己编译,那么可以用以下的命令:
#CentOS yum -y groupinstall "Development Tools" wget https://github.com/jedisct1/libsodium/releases/download/1.0.12/libsodium-1.0.12.tar.gz tar xf libsodium-1.0.12.tar.gz && cd libsodium-1.0.12 ./configure && make -j2 && make install echo /usr/local/lib > /etc/ld.so.conf.d/usr_local_lib.conf ldconfig #Ubuntu/Debian: apt-get install build-essential -y wget https://github.com/jedisct1/libsodium/releases/download/1.0.12/libsodium-1.0.12.tar.gz tar xf libsodium-1.0.12.tar.gz && cd libsodium-1.0.12 ./configure && make -j2 && make install ldconfig
如果曾经安装过旧版本,亦可重复用以上步骤更新到最新版,仅1.0.4或以上版本支持chacha20-ietf。
假如我们遇到以下的错误时:
xxx: In function `crypto_derive_key':undefined reference to `crypto_pwhash' xxx: In function `cipher_aead_decrypt':undefined reference to `crypto_aead_xchacha20poly1305_ietf_decrypt' xxx: In function `cipher_aead_encrypt':undefined reference to `crypto_aead_xchacha20poly1305_ietf_encrypt' collect2: error: ld returned 1 exit status make[2]: *** [xxx] Error 1 make[2]: Leaving directory `xxx' make[1]: *** [xxx] Error 1 make[1]: Leaving directory `xxx' make: *** [all] Error 2
其实这原因有二:
1.系统存在旧libsodium的缘故,试试apt-get purge libsodium-dev再试试编译
2.尝试在编译时添加路径: ./configure --with-sodium=xxx