I am using RaspberryPi and Crypto++6 is the only available version through apt, I can't include the hash function library blake2, and /usr/include/cryptopp/blake2.h doesnt exist, I tried also to install it manually through github, below how I installed it manually, but still doesn't work and blake.h does not exist in include folder too, what can I do ? thank you in advance !
I was using <crypto++/libname.h>
because I am using a Debian based distribution (stretch), but when I tried <cryptopp/blake.h>
it works and this is after I installed the library manually, now I got another errors, what should I use crypto++ or cryptopp
/tmp/ccTmS4UQ.o: In function `main':
test.cpp:(.text+0x24): undefined reference to `CryptoPP::BLAKE2b::BLAKE2b(bool, unsigned int)'
/tmp/ccTmS4UQ.o: In function `CryptoPP::BLAKE2b::~BLAKE2b()':
test.cpp:(.text._ZN8CryptoPP7BLAKE2bD2Ev[_ZN8CryptoPP7BLAKE2bD5Ev]+0x74): undefined reference to `vtable for CryptoPP::BLAKE2b'
test.cpp:(.text._ZN8CryptoPP7BLAKE2bD2Ev[_ZN8CryptoPP7BLAKE2bD5Ev]+0x78): undefined reference to `vtable for CryptoPP::BLAKE2b'
collect2: error: ld returned 1 exit status
And:
uname -a
Linux raspberrypi 4.19.42-v7+ #1219 SMP Tue May 14 21:20:58 BST 2019 armv7l GNU/Linux
ldconfig -p | grep crypto++
libcrypto++.so.6 (libc6,hard-float) => /usr/lib/arm-linux-gnueabihf/libcrypto++.so.6
libcrypto++.so (libc6,hard-float) => /usr/lib/arm-linux-gnueabihf/libcrypto++.so
And a program:
#include <crypto++/cryptlib.h>
#include <crypto++/blake2.h>
#include <iostream>
int main (int argc, char* argv[])
{
using namespace CryptoPP;
BLAKE2b hash;
std::cout << "Name: " << hash.AlgorithmName() << std::endl;
std::cout << "Digest size: " << hash.DigestSize() << std::endl;
std::cout << "Block size: " << hash.BlockSize() << std::endl;
return 0;
}
I have uninstalled the package, and reinstall it manually via github
sudo git clone https://github.com/weidai11/cryptopp
cd cryptopp
sudo make
sudo make install
I get rid of blake2.h missing error, but I got many undefined reference errors e.g (/tmp/cc9AY7g8.o:(.rodata._ZTIN8CryptoPP25MessageAuthenticationCodeE[_ZTIN8CryptoPP25MessageAuthenticationCodeE]+0x18): undefined reference to typeinfo for CryptoPP::HashTransformation)
I was complining the example with a shell script as follow :
g++ -lrt -lpthread -lstdc++ -lcrypto -lcryptopp "$1" \
"$LIBRARY_DIR/arduPiLoRa.o" \
"$ARDUPIAPI_DIR/arduPiUART.o" \
"$ARDUPIAPI_DIR/arduPiUtils.o" \
"$ARDUPIAPI_DIR/arduPiMultiprotocol.o" \
"$ARDUPI_DIR/arduPi.o" \
"$LIBRARY_DIR/ecdh.o" \
"$LIBRARY_DIR/aes.o" \
-I"$ARDUPI_DIR" \
-I"$ARDUPIAPI_DIR" \
-I"$LIBRARY_DIR" \
-o "$1_exe"
but when I compiled it directly using g++ -o blake2 blake2.cpp -lcryptopp
the undefined reference errors disappeared, and I succesfully compiled it,
I have changed the shell script, now it finally worked, but I didn't quite undrestand it,
g++ -DNDEBUG -g3 -O2 -Wall -Wextra -lrt -lpthread -lstdc++ -lcrypto -lcryptopp -l:libcryptopp.a "$1" \
"$LIBRARY_DIR/arduPiLoRa.o" \
"$ARDUPIAPI_DIR/arduPiUART.o" \
"$ARDUPIAPI_DIR/arduPiUtils.o" \
"$ARDUPIAPI_DIR/arduPiMultiprotocol.o" \
"$ARDUPI_DIR/arduPi.o" \
"$LIBRARY_DIR/ecdh.o" \
"$LIBRARY_DIR/aes.o" \
-I"$ARDUPI_DIR" \
-I"$ARDUPIAPI_DIR" \
-I"$LIBRARY_DIR" \
-o "$1_exe" \
-l:libcryptopp.a