Error while compiling botan sample example in Qt

531 Views Asked by At

I am trying to find out the error for two days but still haven't got this unknown reason figure out.

I have configured and compiled Botan library. Everything goes ok but when try to write this sample code to be run..

S2K* s2k = get_s2k("PBKDF2(SHA-256)");
s2k->set_iterations(4049);
SecureVector<byte> key_and_IV = s2k->derive_key(48, passphrase).bits_of();
SymmetricKey key(key_and_IV, 32);

it says error: 'class Botan::PBKDF' has no member named 'set_iterations'

How can I solve this problem ?

2

There are 2 best solutions below

1
On

The Botan docs for v1.11.1 report that the function get_s2k() has been deprecated, recommending that you use get_pbkdf() instead.

According to the docs, get_sdk(algospec) just returns the result of a call to get_pbkdf(algo_spec) which will give you a pointer to an instance of the class Botan::PBKDF.

First things first then, your code needs to be something more like:

PBKDF *s2k = getpbkdf("PBKDF2(SHA-256)");

Unfortunately without knowing what you want to do with s2k I can't help any further, as the docs have no reference to a public member function of PBKDF called set_iterations(). You're getting the error you mention because Botan::PBKDF really does have no member named set_iterations. You need to read the docs, work out what the purpose of set_iterations() was in your now deprecated example and hence how to achieve that purpose in the newer version of the library.

0
On

Possibly you missed your library header... as your error message says: 'has no member named...'