Hi,

I think I found a bug creating an encrypted backup.

 

The source database is encrypted using key:

aes256:A94A8FE5CCB19BA61C4C0873D391E987982FBBD3

 

The source database is readable, I can run select queries and insert data
with no problem.

 

When I use the following function to create a backup of the database, the
backup database becomes unreadable.

I used the same encryption key as the source database for the backup one,
but when I try to read something from the backed up database I get an error
that the database is encrypted.

 

Thanks

 

int backupDb(sqlite3 *pDb, const char *zFilename, const char *zKey)

{

  int rc;

  sqlite3 *pBackupDb;

 sqlite3_backup *pBackup;

 

  rc = sqlite3_open(zFilename, &pBackupDb);

  if( rc==SQLITE_OK )

  {

    if (zKey != NULL)

        sqlite3_key(pBackupDb, zKey, strlen(zKey));

        

    pBackup = sqlite3_backup_init(pBackupDb, "main", pDb, "main");

    if( pBackup )

    {

      do

      {

        rc = sqlite3_backup_step(pBackup, 100);

        if( rc==SQLITE_OK || rc==SQLITE_BUSY || rc==SQLITE_LOCKED ){

          sqlite3_sleep(10);

        }

      }

      while( rc==SQLITE_OK || rc==SQLITE_BUSY || rc==SQLITE_LOCKED );

 

      sqlite3_backup_finish(pBackup);

    }

    rc = sqlite3_errcode(pBackupDb);

  }

  

  sqlite3_close(pBackupDb);

  return rc;

}

 

Ulric Auger
--
Groupe Techna Inc.
 <mailto:ul...@gtechna.com> ul...@gtechna.com 

 

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to