PDA

View Full Version : Using botan encryption



UKCitizen1423
4th July 2018, 21:54
Hi All,

I'm using Qt Creator 4.6.1 on Windows 10
Based on Qt 5.10.1 (MSVC 2015, 32 bit)
Built on May 2 2018 04:24:33
qmake with mingw491_32

There is a project from the web which makes use of a botanwrapper with the include Botan.pri

The full code is quite long so not possible to post here but it is available at http://www.voidrealms.com/index.php?r=source/view&id=1 as a zip file. That all works and encrypts files but when I bring the files into my my project I get a huge number of compile errors such as those below.


botan.h:9380: error: expected identifier before '(' token
X942_DH_PARAMETERS = ANSI_X9_42,
^

and error: expected '}' before '(' token which points to the line


enum Format {
ANSI_X9_42,
ANSI_X9_57,
PKCS_3,

DSA_PARAMETERS = ANSI_X9_57,
DH_PARAMETERS = ANSI_X9_42,
X942_DH_PARAMETERS = ANSI_X9_42, // Error points to here
PKCS3_DH_PARAMETERS = PKCS_3
};


Also lots of errors relating to the const such as error: non-member function 'bool Botan::verify_group(Botan::RandomNumberGenerator&, bool)' cannot have cv-qualifier
bool verify_group(RandomNumberGenerator& rng, bool strong) const;
Which points to the code below



bool verify_group(RandomNumberGenerator& rng, bool strong) const;


I have checked the .pro files for the includes and I have the same files setup as the project that compiles and runs on the same setup. I have the same botan.pri file included which contains


win32 {
DEFINES += BOTAN_TARGET_OS_IS_WINDOWS \
BOTAN_TARGET_OS_HAS_LOADLIBRARY BOTAN_TARGET_OS_HAS_WIN32_GET_SYSTEMTIME \
BOTAN_TARGET_OS_HAS_WIN32_VIRTUAL_LOCK BOTAN_HAS_DYNAMICALLY_LOADED_ENGINE \
BOTAN_HAS_DYNAMIC_LOADER BOTAN_HAS_ENTROPY_SRC_CAPI BOTAN_HAS_ENTROPY_SRC_WIN32 \
BOTAN_HAS_MUTEX_WIN32

win32-msvc* {
QMAKE_CXXFLAGS += -wd4251 -wd4290 -wd4250
DEFINES += BOTAN_BUILD_COMPILER_IS_MSVC BOTAN_TARGET_OS_HAS_GMTIME_S
} else {
QMAKE_CFLAGS += -fpermissive -finline-functions -Wno-long-long
QMAKE_CXXFLAGS += -fpermissive -finline-functions -Wno-long-long
}
LIBS += -ladvapi32 -luser32
}

I have read that removing the const will remove 1 or more errors but I don't understand why this is broken on the same setup that happily compiles the botan.h and runs the build and encrypts files. Could someone help with how to start to troubleshoot this. Help appreciated. Thanks in advance.

UKCitizen1423
5th July 2018, 22:27
Thanks to Jack at StackOverflow https://stackoverflow.com/questions/51181330/using-botan-c-in-qt-to-encrypt-files the solution is to use #undef X942_DH_PARAMETERS