System.Data.SQLite

Check-in [b5149d055f]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:1.0.39.0
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | sourceforge
Files: files | file ages | folders
SHA1: b5149d055ffa10cb82b2ae7a2894a170927a4f2b
User & Date: rmsimpson 2007-01-10 16:04:55.000
Context
2007-01-10
18:50
Temporary fix for CE check-in: cb13e676d0 user: rmsimpson tags: sourceforge
16:04
1.0.39.0 check-in: b5149d055f user: rmsimpson tags: sourceforge
15:50
no message check-in: 2f09f48056 user: rmsimpson tags: sourceforge
Changes
Unified Diff Ignore Whitespace Patch
Changes to SQLite.Interop/SQLite.Interop.rc.
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

/////////////////////////////////////////////////////////////////////////////
//
// Version
//

VS_VERSION_INFO VERSIONINFO
 FILEVERSION 1,0,38,0
 PRODUCTVERSION 1,0,0,0
 FILEFLAGSMASK 0x17L
#ifdef _DEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x4L
 FILETYPE 0x2L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904b0"
        BEGIN
            VALUE "Comments", "http://sqlite.phxsoftware.com"
            VALUE "FileDescription", "System.Data.SQLite Interop Library"
            VALUE "FileVersion", "1.0.38.0"
            VALUE "InternalName", "SQLite.Interop.DLL"
            VALUE "LegalCopyright", "Released to the public domain"
            VALUE "OriginalFilename", "SQLite3.DLL 3.3.8"
            VALUE "ProductName", "System.Data.SQLite"
            VALUE "ProductVersion", "1.0"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x409, 1200







|

















|


|







49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

/////////////////////////////////////////////////////////////////////////////
//
// Version
//

VS_VERSION_INFO VERSIONINFO
 FILEVERSION 1,0,39,0
 PRODUCTVERSION 1,0,0,0
 FILEFLAGSMASK 0x17L
#ifdef _DEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x4L
 FILETYPE 0x2L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904b0"
        BEGIN
            VALUE "Comments", "http://sqlite.phxsoftware.com"
            VALUE "FileDescription", "System.Data.SQLite Interop Library"
            VALUE "FileVersion", "1.0.39.0"
            VALUE "InternalName", "SQLite.Interop.DLL"
            VALUE "LegalCopyright", "Released to the public domain"
            VALUE "OriginalFilename", "SQLite3.DLL 3.3.10"
            VALUE "ProductName", "System.Data.SQLite"
            VALUE "ProductVersion", "1.0"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x409, 1200
Changes to SQLite.Interop/crypt.c.
1
2
3
4
5
6
7
8
9
10
11
#ifdef SQLITE_HAS_CODEC
  void sqlite3pager_free_codecarg(void *pArg);
#endif

#include "src/pager.c"

#ifndef SQLITE_OMIT_DISKIO
#ifdef SQLITE_HAS_CODEC

#include <windows.h>
#include <wincrypt.h>
<
<
<
<











1
2
3
4
5
6
7




#include "src/pager.c"

#ifndef SQLITE_OMIT_DISKIO
#ifdef SQLITE_HAS_CODEC

#include <windows.h>
#include <wincrypt.h>
259
260
261
262
263
264
265



266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
  }

  // Create a new encryption block and assign the codec to the new attached database
  if (hKey)
  {
    LPCRYPTBLOCK pBlock = CreateCryptBlock(hKey, sqlite3BtreePager(db->aDb[nDb].pBt), NULL);
    sqlite3pager_set_codec(sqlite3BtreePager(db->aDb[nDb].pBt), sqlite3Codec, pBlock);



    rc = SQLITE_OK;
  }
  return rc;
}

// Called by our code modification to pager.c to free the cryptblock associated with 
// a pager instance.
void sqlite3pager_free_codecarg(void *pArg)
{
  if (pArg)
    DestroyCryptBlock((LPCRYPTBLOCK)pArg);
}

// Once a password has been supplied and a key created, we don't keep the 
// original password for security purposes.  Therefore return NULL.
void sqlite3CodecGetKey(sqlite3 *db, int nDb, void **ppKey, int *pnKeyLen)
{
  *ppKey = NULL;
  *pnKeyLen = 0;
}







>
>
>





<
<
<
<
<
<
<
<







255
256
257
258
259
260
261
262
263
264
265
266
267
268
269








270
271
272
273
274
275
276
  }

  // Create a new encryption block and assign the codec to the new attached database
  if (hKey)
  {
    LPCRYPTBLOCK pBlock = CreateCryptBlock(hKey, sqlite3BtreePager(db->aDb[nDb].pBt), NULL);
    sqlite3pager_set_codec(sqlite3BtreePager(db->aDb[nDb].pBt), sqlite3Codec, pBlock);
    db->aDb[nDb].pAux = pBlock;
    db->aDb[nDb].xFreeAux = DestroyCryptBlock;

    rc = SQLITE_OK;
  }
  return rc;
}









// Once a password has been supplied and a key created, we don't keep the 
// original password for security purposes.  Therefore return NULL.
void sqlite3CodecGetKey(sqlite3 *db, int nDb, void **ppKey, int *pnKeyLen)
{
  *ppKey = NULL;
  *pnKeyLen = 0;
}
310
311
312
313
314
315
316


317
318
319
320
321
322
323
  // To rekey a database, we change the writekey for the pager.  The readkey remains
  // the same
  if (!pBlock) // Encrypt an unencrypted database
  {
    pBlock = CreateCryptBlock(hKey, p, NULL);
    pBlock->hReadKey = 0; // Original database is not encrypted
    sqlite3pager_set_codec(sqlite3BtreePager(pbt), sqlite3Codec, pBlock);


  }
  else // Change the writekey for an already-encrypted database
  {
    pBlock->hWriteKey = hKey;
  }

  // Start a transaction







>
>







301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
  // To rekey a database, we change the writekey for the pager.  The readkey remains
  // the same
  if (!pBlock) // Encrypt an unencrypted database
  {
    pBlock = CreateCryptBlock(hKey, p, NULL);
    pBlock->hReadKey = 0; // Original database is not encrypted
    sqlite3pager_set_codec(sqlite3BtreePager(pbt), sqlite3Codec, pBlock);
    db->aDb[0].pAux = pBlock;
    db->aDb[0].xFreeAux = DestroyCryptBlock;
  }
  else // Change the writekey for an already-encrypted database
  {
    pBlock->hWriteKey = hKey;
  }

  // Start a transaction
377
378
379
380
381
382
383


384
385
386
387
388
389
390
  }

  // If the readkey and writekey are both empty, there's no need for a codec on this
  // pager anymore.  Destroy the crypt block and remove the codec from the pager.
  if (!pBlock->hReadKey && !pBlock->hWriteKey)
  {
    sqlite3pager_set_codec(p, NULL, NULL);


    DestroyCryptBlock(pBlock);
  }

  return rc;
}

int sqlite3_key(sqlite3 *db, const void *pKey, int nKey)







>
>







370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
  }

  // If the readkey and writekey are both empty, there's no need for a codec on this
  // pager anymore.  Destroy the crypt block and remove the codec from the pager.
  if (!pBlock->hReadKey && !pBlock->hWriteKey)
  {
    sqlite3pager_set_codec(p, NULL, NULL);
    db->aDb[0].pAux = NULL;
    db->aDb[0].xFreeAux = NULL;
    DestroyCryptBlock(pBlock);
  }

  return rc;
}

int sqlite3_key(sqlite3 *db, const void *pKey, int nKey)