c++encryptioncrypto++stream-cipher

‘ChaCha’ has not been declared in this scope using Crypto++?


I am trying to create a program that run ChaCha encryption. However, I kept getting this problem

testingchacha.cpp:38:5: error: ‘ChaCha’ has not been declared ChaCha::Encryption enc;

I tried to change the code from

ChaCha::Encryption

to

ChaCha20::Encryption

but doing that gave me a long list of error.

I also tried using the example code from Crypto++ website, but I got the same problem regarding 'ChaCha' has not been declared.

using namespace CryptoPP;
...

// Encryption object
ChaCha::Encryption enc;    
enc.SetKeyWithIV(key, key.size(), iv, iv.size());

Why am I getting the compile error?


Solution

  • You are using an old version of the library.

    The name changed from ChaCha20 to ChaCha, see commit here.

    You need at least version 8.1, see also this issue on github.

    Update the library and if you are getting a long list of errors when using the correct name, then you should probably ask about that instead.