Compile wxSQLite with encryption and linkingSQLite3.dll sta Topic is solved

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2409
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Post by evstevemd »

silverstorm82 wrote:I am sorry to ask again for help here.

I used the sqlite3.lib/.dll in the /sqlite3/secure subfolder and copied the files to sqlite3/lib subdirectory and compiled wxSQLite3. But HasEncryptionSupport() still returns false and when using ReKey() an exception is thrown ("Encryption support not available").

Any ideas here? If I understood correctly the preprocessor symbols

SQLITE_HAS_CODEC
CODEC_TYPE=CODEC_TYPE_AES128
SQLITE_CORE
THREADSAFE=1

have to be set when wxSQLite ist compiled, which I did. As the explanation in the readme is not very clear about where to set the symbols exactly, could you provide a detailled description please?

Greetings,
Jens
how do you check? I mean the code that does the check only!
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
silverstorm82
Knows some wx things
Knows some wx things
Posts: 32
Joined: Wed Aug 17, 2011 5:13 pm

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Post by silverstorm82 »

The check was performed after having opened the database file:

Code: Select all

try
{
  wxASSERT(HasEncryptionSupport());
  ReKey(wxT("TEST"));
  wxASSERT(HasEncryptionSupport());
}
catch (wxSQLite3Exception& err)
{
  wxMessageBox(err.GetMessage());
}
All included in a derived class of wxSQLite3Database. The reason why there are two check with HasEncryptionSupport() is that I thought that ReKey might change the status.
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2409
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Post by evstevemd »

Does demo that comes with wxSqlite3 work?
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
silverstorm82
Knows some wx things
Knows some wx things
Posts: 32
Joined: Wed Aug 17, 2011 5:13 pm

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Post by silverstorm82 »

Well, I can use wxSQLite3 and SQLite databases quite well without any problems. The only thing that does not work is the encryption support.
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2409
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Post by evstevemd »

silverstorm82 wrote:Well, I can use wxSQLite3 and SQLite databases quite well without any problems. The only thing that does not work is the encryption support.
If you link example with same library and run it, it will print messages including if encryption works ok. How did you compile wxSQLite3 anyway?
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2409
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Post by evstevemd »

silverstorm82 wrote:The check was performed after having opened the database file:

Code: Select all

try
{
  wxASSERT(HasEncryptionSupport());
  ReKey(wxT("TEST"));
  wxASSERT(HasEncryptionSupport());
}
catch (wxSQLite3Exception& err)
{
  wxMessageBox(err.GetMessage());
}
All included in a derived class of wxSQLite3Database. The reason why there are two check with HasEncryptionSupport() is that I thought that ReKey might change the status.
I can see from sample the code is

Code: Select all

if (wxSQLite3Database::HasEncryptionSupport())
    {
      db.Open(dbFile, wxString(wxT("password")));
    }
    else
    {
      db.Open(dbFile);
    }
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
silverstorm82
Knows some wx things
Knows some wx things
Posts: 32
Joined: Wed Aug 17, 2011 5:13 pm

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Post by silverstorm82 »

Well, the minimal example crashes at startup (unhandled exception). Update HERE: The minimal example works now but skips all tests regarding encryption.

I compiled the wxSqlite3 using the Visual Studio solution which was no problem.

Code: Select all

wxASSERT(wxSQLite3Database::HasEncryptionSupport());
returns false :-(

Just to make clear what I already did:
1.) Copied the sqlite3.lib from sqlite3/secure/aes128 to the sqlite3/lib directory. However, the last time I compiled wxSQLite3 I linked directly to the file in the aes128 directory instead of the file in the sqlite3/lib directory.
2.) Compiled wxSQLite3 using the standard settings.
3.) Linked my project against those compiled files.
4.) Copied the .dll files to the working directory of my project.
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2409
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Post by evstevemd »

silverstorm82 wrote:Well, the minimal example crashes at startup (unhandled exception). Update HERE: The minimal example works now but skips all tests regarding encryption.

I compiled the wxSqlite3 using the Visual Studio solution which was no problem.

Code: Select all

wxASSERT(wxSQLite3Database::HasEncryptionSupport());
returns false :-(

Just to make clear what I already did:
1.) Copied the sqlite3.lib from sqlite3/secure/aes128 to the sqlite3/lib directory. However, the last time I compiled wxSQLite3 I linked directly to the file in the aes128 directory instead of the file in the sqlite3/lib directory.
2.) Compiled wxSQLite3 using the standard settings.
3.) Linked my project against those compiled files.
4.) Copied the .dll files to the working directory of my project.
can you recompile/link the wxsqlite3?
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
silverstorm82
Knows some wx things
Knows some wx things
Posts: 32
Joined: Wed Aug 17, 2011 5:13 pm

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Post by silverstorm82 »

I already did to make sure that I linked against correct sqlite3.dll...

Perhaps I've got to compile the sqlite3.lib / .dll myself instead of using the one that is provided in the sqlite3/secure/aes128 directory. That's the last idea I have.
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2409
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Post by evstevemd »

silverstorm82 wrote:I already did to make sure that I linked against correct sqlite3.dll...

Perhaps I've got to compile the sqlite3.lib / .dll myself instead of using the one that is provided in the sqlite3/secure/aes128 directory. That's the last idea I have.
You should have done that in the first place and copy it to the dir you want. refere to
http://forums.wxwidgets.org/viewtopic.p ... 17#p116512
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
silverstorm82
Knows some wx things
Knows some wx things
Posts: 32
Joined: Wed Aug 17, 2011 5:13 pm

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Post by silverstorm82 »

Well, the readme states that for windows, precompiled .lib and .dll files are provided in the aes128 subdirectory... That's what I tried. However, recompiling did not work as well.
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2409
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Post by evstevemd »

silverstorm82 wrote:However, recompiling did not work as well.
How did you recompile?
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
silverstorm82
Knows some wx things
Knows some wx things
Posts: 32
Joined: Wed Aug 17, 2011 5:13 pm

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Post by silverstorm82 »

Like in the instructions:
1.) Created any empty project for a static linked library called sqlite3secure
2.) Copied all files from sqlite3/secure/src/codec-c to the projects directory.
3.) Downloaded the amalgamation sources from the mentioned website and extracted the contents to the projects directory, which is the step of copying the amalgamation souces to the codec-c directory.
4.) Set the preprocessor directives SQLITE_HAS_CODEC and CODEC_TYPE=CODEC_TYPE_AES128.
5.) Compiled the project, which worked fine and resulted in a sqlite3secure.lib file.
6.) Opened the wxSQLite3 project file and changed all references from sqlite3.lib to sqlite3secure.lib so that wxSQLite3 is linked against the just compiled library file.
7.) Compiled wxSQLite3 (worked fine).

Did I miss anything?
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Post by utelle »

silverstorm82 wrote:Like in the instructions:
1.) Created any empty project for a static linked library called sqlite3secure
2.) Copied all files from sqlite3/secure/src/codec-c to the projects directory.
3.) Downloaded the amalgamation sources from the mentioned website and extracted the contents to the projects directory, which is the step of copying the amalgamation souces to the codec-c directory.
4.) Set the preprocessor directives SQLITE_HAS_CODEC and CODEC_TYPE=CODEC_TYPE_AES128.
5.) Compiled the project, which worked fine and resulted in a sqlite3secure.lib file.
6.) Opened the wxSQLite3 project file and changed all references from sqlite3.lib to sqlite3secure.lib so that wxSQLite3 is linked against the just compiled library file.
7.) Compiled wxSQLite3 (worked fine).

Did I miss anything?
Yes. On compiling wxSQLite3 itself you have to specify the preprocessor symbol WXSQLITE3_HAVE_CODEC. This can be done from the preprocessor settings of your IDE (or from the command line of make) or by editing the header file wxsqlite3opt.h.

BTW the readme file coming with wxSQLite3 is very clear in this respect. Under the heading "Optional key based database encryption support" you find the following note:
Additionally the preprocessor symbol WXSQLITE3_HAVE_CODEC must be defined when compiling wxSQLite3.
Regards,

Ulrich
silverstorm82
Knows some wx things
Knows some wx things
Posts: 32
Joined: Wed Aug 17, 2011 5:13 pm

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Post by silverstorm82 »

Hello Ulrich,

thank you for the reply. It worked now. I must admit that I did not recognize that sentence in the readme.txt file as in my opinion the instructions in this thread were the same as in the readme. But the weren't. I am sorry for my mistake.

Anyway, thanks to you both for all your patience and your help on this problem.

Greetings,
Jens
Post Reply