Compile wxSQLite with encryption and linkingSQLite3.dll sta  [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: 2092
Joined: Wed Jan 28, 2009 11:57 am
Location: Dar es Salaam, United Republic of Tanzania
Contact:

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Postby evstevemd » Thu Dec 01, 2011 4:35 pm

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?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

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

Postby silverstorm82 » Thu Dec 01, 2011 4:39 pm

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: 2092
Joined: Wed Jan 28, 2009 11:57 am
Location: Dar es Salaam, United Republic of Tanzania
Contact:

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Postby evstevemd » Thu Dec 01, 2011 4:49 pm

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?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

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

Postby silverstorm82 » Thu Dec 01, 2011 5:16 pm

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: 2092
Joined: Wed Jan 28, 2009 11:57 am
Location: Dar es Salaam, United Republic of Tanzania
Contact:

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Postby evstevemd » Thu Dec 01, 2011 5:39 pm

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?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2092
Joined: Wed Jan 28, 2009 11:57 am
Location: Dar es Salaam, United Republic of Tanzania
Contact:

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Postby evstevemd » Thu Dec 01, 2011 5:45 pm

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?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

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

Postby silverstorm82 » Thu Dec 01, 2011 6:02 pm

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: 2092
Joined: Wed Jan 28, 2009 11:57 am
Location: Dar es Salaam, United Republic of Tanzania
Contact:

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Postby evstevemd » Thu Dec 01, 2011 6:45 pm

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?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

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

Postby silverstorm82 » Thu Dec 01, 2011 6:52 pm

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: 2092
Joined: Wed Jan 28, 2009 11:57 am
Location: Dar es Salaam, United Republic of Tanzania
Contact:

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Postby evstevemd » Thu Dec 01, 2011 7:02 pm

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
viewtopic.php?f=30&t=27217#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?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

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

Postby silverstorm82 » Thu Dec 01, 2011 7:04 pm

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: 2092
Joined: Wed Jan 28, 2009 11:57 am
Location: Dar es Salaam, United Republic of Tanzania
Contact:

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Postby evstevemd » Thu Dec 01, 2011 7:21 pm

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?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

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

Postby silverstorm82 » Thu Dec 01, 2011 7:26 pm

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: 830
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: Compile wxSQLite with encryption and linkingSQLite3.dll

Postby utelle » Thu Dec 01, 2011 10:50 pm

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

Postby silverstorm82 » Thu Dec 01, 2011 11:13 pm

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


Return to “wxCode”

Who is online

Users browsing this forum: No registered users and 10 guests