How to build wxSqlite dll with encryption support Topic is solved

In this forum you can discuss database related issues which can be wxWidgets related, but also generic in nature.
Post Reply
samsam598
Super wx Problem Solver
Super wx Problem Solver
Posts: 340
Joined: Mon Oct 06, 2008 12:55 pm

How to build wxSqlite dll with encryption support

Post by samsam598 »

Greetings!

I know there are previous threads mentioned about Encryption issues regarding wxSQLite3(1.9.9 the latest).I built my wxSqlite lib without Encryption support,when I try to build with the Encryption support,build can not pass.I also know that there is a secure folder in the wxSqlite3 package,there are two sub folders,codec and codec-c.Under codec folder there is codec.h file which include s "../sqliteInt.h".where is sqliteInt.h?I can't see it.So I was lost on how to use secure source.

So my question is,is there a known way which can easily make Encryption support in wxSqlite works?I need a step to step guide.:P

I use have both Xp and Ubuntu 10.04 installed in my pc.C::B+wx works on both platform.


Thanks a lot for your help.
Regards,
Sam
-------------------------------------------------------------------
Windows 10 64bit
VS Community 2019
msys2-mingw13.2.0 C::B character set: UTF-8/GBK(Chinese)
wxWidgets 3.3/3.2.4 Unicode Mono Static gcc static build
utelle
Moderator
Moderator
Posts: 1127
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: How to build wxSqlite dll with encryption support

Post by utelle »

samsam598 wrote:I know there are previous threads mentioned about Encryption issues regarding wxSQLite3(1.9.9 the latest). I built my wxSqlite lib without Encryption support, when I try to build with the Encryption support, build can not pass. I also know that there is a secure folder in the wxSqlite3 package,there are two sub folders, codec and codec-c.
The folder codec contains the C++ version of the encryption support. You would need all SQLite sources as separate files, i.e. not the amalgamation. The C++ version is no longer actively maintained.

The folder code-c vcontains the C version of the encryption extension which works seamlessly together with the SQLite amalgamation.
samsam598 wrote:So my question is,is there a known way which can easily make Encryption support in wxSqlite works?I need a step to step guide.:P
Although this forum thread describes the process on Windows, it should be a sufficiently good guide for other platforms, too.

Regards,

Ulrich
samsam598
Super wx Problem Solver
Super wx Problem Solver
Posts: 340
Joined: Mon Oct 06, 2008 12:55 pm

Re: How to build wxSqlite dll with encryption support

Post by samsam598 »

utelle wrote:
samsam598 wrote:I know there are previous threads mentioned about Encryption issues regarding wxSQLite3(1.9.9 the latest). I built my wxSqlite lib without Encryption support, when I try to build with the Encryption support, build can not pass. I also know that there is a secure folder in the wxSqlite3 package,there are two sub folders, codec and codec-c.
The folder codec contains the C++ version of the encryption support. You would need all SQLite sources as separate files, i.e. not the amalgamation. The C++ version is no longer actively maintained.

The folder code-c vcontains the C version of the encryption extension which works seamlessly together with the SQLite amalgamation.
samsam598 wrote:So my question is,is there a known way which can easily make Encryption support in wxSqlite works?I need a step to step guide.:P
Although this forum thread describes the process on Windows, it should be a sufficiently good guide for other platforms, too.

Regards,

Ulrich
Thanks.The link provided guideline is very clear and workable.I built sqlite3 static and dll libraries under windows successfully for AEC128.But failed on AEC 256,both static and dll.Attached error log fyi.I uses wxDev-cpp +MinGW3.4.5,xp sp3.

Moreover,the minimal sample runs differently compare to no encrypt support.The non-encryption version runs without a single problem,buth this one did not.

Code: Select all

 

cout << endl << "User Defined Collation Sequence Test" << endl;
    db.SetCollation(wxT("reversed"), &myCollation);
    db.ExecuteUpdate(wxT("create table testcol(textcol char(20) collate reversed);"));
    db.ExecuteUpdate(wxT("insert into testcol values ('anton');"));
    db.ExecuteUpdate(wxT("insert into testcol values ('berta');"));
    db.ExecuteUpdate(wxT("insert into testcol values ('cesar');"));

    wxSQLite3ResultSet q4 = db.ExecuteQuery("select textcol from testcol order by 1 desc;");

    while (q4.NextRow())
    {
      cout << (const char*)(q4.GetString(0).mb_str()) << endl;
    }

    if (wxSQLite3Database::HasBackupSupport())
    {
      cout << endl << "Backup and restore database" << endl;
      ...
     }
When runs into the last line of the above code.Exception caught:

Code: Select all

Backup and restore database
26:SQLITE_NOTADB[26]: file is encrypted or is not a database
Press q then enter to quit:
I noticed you have provided the password to backup & restore function.So what is the problem?

Thanks again.
Attachments
errlog.txt
(21.36 KiB) Downloaded 218 times
Regards,
Sam
-------------------------------------------------------------------
Windows 10 64bit
VS Community 2019
msys2-mingw13.2.0 C::B character set: UTF-8/GBK(Chinese)
wxWidgets 3.3/3.2.4 Unicode Mono Static gcc static build
utelle
Moderator
Moderator
Posts: 1127
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: How to build wxSqlite dll with encryption support

Post by utelle »

samsam598 wrote:I built sqlite3 static and dll libraries under windows successfully for AEC128.But failed on AEC 256,both static and dll. Attached error log fyi.I uses wxDev-cpp +MinGW3.4.5,xp sp3.
I'll take a look at the log and try comment later on this issue.
samsam598 wrote:Moreover,the minimal sample runs differently compare to no encrypt support.The non-encryption version runs without a single problem,buth this one did not.
[...]
When runs into the last line of the above code.Exception caught:

Code: Select all

Backup and restore database
26:SQLITE_NOTADB[26]: file is encrypted or is not a database
Press q then enter to quit:
I noticed you have provided the password to backup & restore function. So what is the problem?
At the moment I don't know the answer. The backup succeeds if the destination database is not encrypted, that is, if the key passed to method Backup is not used. But this results in an unencrypted backup database file. I have to investigate how SQLite's backup works internally and what's causing the problem and how to solve it. So I have to ask for your patience.

Regards,

Ulrich
utelle
Moderator
Moderator
Posts: 1127
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: How to build wxSqlite dll with encryption support

Post by utelle »

utelle wrote:
samsam598 wrote:I built sqlite3 static and dll libraries under windows successfully for AEC128.But failed on AEC 256,both static and dll. Attached error log fyi.I uses wxDev-cpp +MinGW3.4.5,xp sp3.
I'll take a look at the log and try comment later on this issue.
The problem seems to be that an invalid typedef for the definition of the uint64 type is selected when MinGW is used. For MinGW it should be

typedef unsigned long long uint64;

Probably sha2.h has to be adjusted for MinGW. It works with Visual C++ though.

Keep in mind that AES-256 support is still experimental.

Regards,

Ulrich
samsam598
Super wx Problem Solver
Super wx Problem Solver
Posts: 340
Joined: Mon Oct 06, 2008 12:55 pm

Re: How to build wxSqlite dll with encryption support

Post by samsam598 »

Hi Ulrich,

Thank you so much for your prompt reply and for your great support on wxSqlite always!

Regards,
Sam
Regards,
Sam
-------------------------------------------------------------------
Windows 10 64bit
VS Community 2019
msys2-mingw13.2.0 C::B character set: UTF-8/GBK(Chinese)
wxWidgets 3.3/3.2.4 Unicode Mono Static gcc static build
utelle
Moderator
Moderator
Posts: 1127
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: How to build wxSqlite dll with encryption support

Post by utelle »

samsam598 wrote:Moreover,the minimal sample runs differently compare to no encrypt support. The non-encryption version runs without a single problem,buth this one did not.
[...]
When runs into the last line of the above code.Exception caught:

Code: Select all

Backup and restore database
26:SQLITE_NOTADB[26]: file is encrypted or is not a database
Press q then enter to quit:
I noticed you have provided the password to backup & restore function. So what is the problem?
In the end the explanation is really simple: if the backup destination database already exists and is not encrypted (or is encrypted with a different encryption key) you get the exception you observed. I'm sure you tested the minimal sample first without encryption and that test left an unencrypted backup database behind. Solution: delete the existing backup database file and run the sample application again and it should work as expected.

Regards,

Ulrich
samsam598
Super wx Problem Solver
Super wx Problem Solver
Posts: 340
Joined: Mon Oct 06, 2008 12:55 pm

Re: How to build wxSqlite dll with encryption support

Post by samsam598 »

utelle wrote:
samsam598 wrote:Moreover,the minimal sample runs differently compare to no encrypt support. The non-encryption version runs without a single problem,buth this one did not.
[...]
When runs into the last line of the above code.Exception caught:

Code: Select all

Backup and restore database
26:SQLITE_NOTADB[26]: file is encrypted or is not a database
Press q then enter to quit:
I noticed you have provided the password to backup & restore function. So what is the problem?
In the end the explanation is really simple: if the backup destination database already exists and is not encrypted (or is encrypted with a different encryption key) you get the exception you observed. I'm sure you tested the minimal sample first without encryption and that test left an unencrypted backup database behind. Solution: delete the existing backup database file and run the sample application again and it should work as expected.

Regards,

Ulrich
Yes,exactly.It works pretty good.Thanks again.
Regards,
Sam
-------------------------------------------------------------------
Windows 10 64bit
VS Community 2019
msys2-mingw13.2.0 C::B character set: UTF-8/GBK(Chinese)
wxWidgets 3.3/3.2.4 Unicode Mono Static gcc static build
Post Reply