mirror of
https://github.com/status-im/sqlcipher.git
synced 2026-08-30 22:11:14 +00:00
Merge branch 'prerelease' of github.com:sqlcipher/sqlcipher into ditto
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -149,7 +149,7 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "./configure --enable-tempstore=yes --with-crypto-lib=openssl CFLAGS=\"-DSQLITE_HAS_CODEC -DSQLITE_TEMP_STORE=2 -DSQLCIPHER_CRYPTO_OPENSSL\"\nmake sqlite3.c\nexit 0";
|
||||
shellScript = "./configure --enable-tempstore=yes --with-crypto-lib=commoncrypto CFLAGS=\"-DSQLITE_HAS_CODEC -DSQLITE_TEMP_STORE=2 -DSQLCIPHER_CRYPTO_CC\"\nmake sqlite3.c\nexit 0";
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
@@ -236,7 +236,8 @@
|
||||
1DEB91F008733DB70010E9CD /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
"ARCHS[sdk=iphoneos*]" = "$(ARCHS_STANDARD)";
|
||||
"ARCHS[sdk=iphoneos*]" = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
|
||||
"ARCHS[sdk=iphonesimulator*]" = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
|
||||
"ARCHS[sdk=macosx*]" = (
|
||||
x86_64,
|
||||
i386,
|
||||
@@ -245,28 +246,34 @@
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
|
||||
"IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 6.0;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SKIP_INSTALL = YES;
|
||||
SUPPORTED_PLATFORMS = "iphonesimulator macosx iphoneos";
|
||||
VALID_ARCHS = "arm64 armv7 armv7s x86_64 i386";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
1DEB91F108733DB70010E9CD /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
||||
"ARCHS[sdk=iphoneos*]" = (
|
||||
armv7s,
|
||||
armv7,
|
||||
"ARCHS[sdk=iphoneos*]" = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
|
||||
"ARCHS[sdk=iphonesimulator*]" = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
|
||||
"ARCHS[sdk=macosx*]" = (
|
||||
i386,
|
||||
x86_64,
|
||||
);
|
||||
"ARCHS[sdk=macosx*]" = "$(ARCHS_STANDARD)";
|
||||
GCC_C_LANGUAGE_STANDARD = c99;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
|
||||
"IPHONEOS_DEPLOYMENT_TARGET[arch=arm64]" = 6.0;
|
||||
SDKROOT = iphoneos;
|
||||
SKIP_INSTALL = YES;
|
||||
SUPPORTED_PLATFORMS = "iphonesimulator macosx iphoneos";
|
||||
VALID_ARCHS = "arm64 armv7 armv7s x86_64 i386";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
||||
+7
-5
@@ -82,6 +82,7 @@ struct codec_ctx {
|
||||
Btree *pBt;
|
||||
cipher_ctx *read_ctx;
|
||||
cipher_ctx *write_ctx;
|
||||
unsigned int skip_read_hmac;
|
||||
};
|
||||
|
||||
int sqlcipher_register_provider(sqlcipher_provider *p) {
|
||||
@@ -756,7 +757,7 @@ int sqlcipher_page_cipher(codec_ctx *ctx, int for_ctx, Pgno pgno, int mode, int
|
||||
memcpy(iv_out, iv_in, c_ctx->iv_sz); /* copy the iv from the input to output buffer */
|
||||
}
|
||||
|
||||
if((c_ctx->flags & CIPHER_FLAG_HMAC) && (mode == CIPHER_DECRYPT)) {
|
||||
if((c_ctx->flags & CIPHER_FLAG_HMAC) && (mode == CIPHER_DECRYPT) && !ctx->skip_read_hmac) {
|
||||
if(sqlcipher_page_hmac(c_ctx, pgno, in, size + c_ctx->iv_sz, hmac_out) != SQLITE_OK) {
|
||||
sqlcipher_memset(out, 0, page_sz);
|
||||
CODEC_TRACE(("codec_cipher: hmac operations failed for pgno=%d\n", pgno));
|
||||
@@ -1048,7 +1049,7 @@ int sqlcipher_codec_ctx_migrate(codec_ctx *ctx) {
|
||||
CODEC_TRACE(("cannot migrate - SQL statements in progress"));
|
||||
goto handle_error;
|
||||
}
|
||||
|
||||
|
||||
/* Save the current value of the database flags so that it can be
|
||||
** restored before returning. Then set the writable-schema flag, and
|
||||
** disable CHECK and foreign key constraints. */
|
||||
@@ -1063,7 +1064,7 @@ int sqlcipher_codec_ctx_migrate(codec_ctx *ctx) {
|
||||
pDest = db->aDb[0].pBt;
|
||||
pDb = &(db->aDb[db->nDb-1]);
|
||||
pSrc = pDb->pBt;
|
||||
|
||||
|
||||
rc = sqlite3_exec(db, "BEGIN;", NULL, NULL, NULL);
|
||||
rc = sqlite3BtreeBeginTrans(pSrc, 2);
|
||||
rc = sqlite3BtreeBeginTrans(pDest, 2);
|
||||
@@ -1071,17 +1072,18 @@ int sqlcipher_codec_ctx_migrate(codec_ctx *ctx) {
|
||||
assert( 1==sqlite3BtreeIsInTrans(pDest) );
|
||||
assert( 1==sqlite3BtreeIsInTrans(pSrc) );
|
||||
|
||||
|
||||
sqlite3CodecGetKey(db, db->nDb - 1, (void**)&key, &password_sz);
|
||||
sqlite3CodecAttach(db, 0, key, password_sz);
|
||||
sqlite3pager_get_codec(pDest->pBt->pPager, (void**)&ctx);
|
||||
|
||||
ctx->skip_read_hmac = 1;
|
||||
for(i=0; i<ArraySize(aCopy); i+=2){
|
||||
sqlite3BtreeGetMeta(pSrc, aCopy[i], &meta);
|
||||
rc = sqlite3BtreeUpdateMeta(pDest, aCopy[i], meta+aCopy[i+1]);
|
||||
if( NEVER(rc!=SQLITE_OK) ) goto handle_error;
|
||||
}
|
||||
|
||||
rc = sqlite3BtreeCopyFile(pDest, pSrc);
|
||||
ctx->skip_read_hmac = 0;
|
||||
if( rc!=SQLITE_OK ) goto handle_error;
|
||||
rc = sqlite3BtreeCommit(pDest);
|
||||
|
||||
|
||||
+26
-23
@@ -42,6 +42,7 @@ file delete -force test4.db
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set old_pending_byte [sqlite3_test_control_pending_byte 0x40000000]
|
||||
|
||||
# If the library is not compiled with has_codec support then
|
||||
# skip all tests in this file.
|
||||
@@ -932,17 +933,18 @@ file delete -force test.db
|
||||
|
||||
# open a 1.1.8 database using the new code, HMAC disabled
|
||||
do_test open-1.1.8-database {
|
||||
sqlite_orig db sqlcipher-1.1.8-testkey.db
|
||||
file copy -force sqlcipher-1.1.8-testkey.db test.db
|
||||
sqlite_orig db test.db
|
||||
execsql {
|
||||
PRAGMA key = 'testkey';
|
||||
PRAGMA cipher_use_hmac = OFF;
|
||||
PRAGMA cipher_use_hmac = off;
|
||||
PRAGMA kdf_iter = 4000;
|
||||
SELECT count(*) FROM t1;
|
||||
SELECT * FROM t1;
|
||||
SELECT distinct * FROM t1;
|
||||
}
|
||||
} {4 1 1 one one 1 2 one two}
|
||||
} {75709 1 1 one one 1 2 one two 1 2}
|
||||
db close
|
||||
|
||||
file delete -force test.db
|
||||
|
||||
# open a 1.1.8 database without hmac, then copy the data
|
||||
do_test attach-and-copy-1.1.8 {
|
||||
@@ -963,9 +965,9 @@ do_test attach-and-copy-1.1.8 {
|
||||
execsql {
|
||||
PRAGMA key = 'testkey-hmac';
|
||||
SELECT count(*) FROM t1;
|
||||
SELECT * FROM t1;
|
||||
SELECT distinct * FROM t1;
|
||||
}
|
||||
} {4 1 1 one one 1 2 one two}
|
||||
} {75709 1 1 one one 1 2 one two 1 2}
|
||||
db close
|
||||
file delete -force test.db
|
||||
|
||||
@@ -1426,7 +1428,7 @@ do_test default-hmac-kdf-attach {
|
||||
PRAGMA cipher_default_use_hmac = ON;
|
||||
PRAGMA cipher_default_kdf_iter = 64000;
|
||||
}
|
||||
} {4 4}
|
||||
} {75709 75709}
|
||||
db close
|
||||
file delete -force test.db
|
||||
|
||||
@@ -1469,7 +1471,7 @@ do_test change-default-hmac-kdf-attach {
|
||||
PRAGMA cipher_default_use_hmac = ON;
|
||||
PRAGMA cipher_default_kdf_iter = 64000;
|
||||
}
|
||||
} {1 4}
|
||||
} {1 75709}
|
||||
db close
|
||||
file delete -force test.db
|
||||
|
||||
@@ -1643,16 +1645,16 @@ do_test multipage-schema-autovacuum-shortread-wal {
|
||||
db close
|
||||
file delete -force test.db
|
||||
|
||||
# open a 2.3 database with little endian hmac page numbers (default)
|
||||
# open a 3.0 database with little endian hmac page numbers (default)
|
||||
# verify it can be opened
|
||||
do_test open-2.3-le-database {
|
||||
sqlite_orig db sqlcipher-2.3-testkey.db
|
||||
do_test open-3.0-le-database {
|
||||
sqlite_orig db sqlcipher-3.0-testkey.db
|
||||
execsql {
|
||||
PRAGMA key = 'testkey';
|
||||
SELECT count(*) FROM t1;
|
||||
SELECT * FROM t1;
|
||||
SELECT distinct * FROM t1;
|
||||
}
|
||||
} {4 1 1 one one 1 2 one two}
|
||||
} {78536 1 1 one one 1 2 one two}
|
||||
db close
|
||||
|
||||
# open a 2.0 database with little endian hmac page numbers (default)
|
||||
@@ -1663,9 +1665,9 @@ do_test open-2.0-le-database {
|
||||
PRAGMA key = 'testkey';
|
||||
PRAGMA kdf_iter = 4000;
|
||||
SELECT count(*) FROM t1;
|
||||
SELECT * FROM t1;
|
||||
SELECT distinct * FROM t1;
|
||||
}
|
||||
} {4 1 1 one one 1 2 one two}
|
||||
} {78536 1 1 one one 1 2 one two}
|
||||
db close
|
||||
|
||||
# open a 2.0 database with big-endian hmac page numbers
|
||||
@@ -1677,9 +1679,9 @@ do_test open-2.0-be-database {
|
||||
PRAGMA cipher_hmac_pgno = be;
|
||||
PRAGMA kdf_iter = 4000;
|
||||
SELECT count(*) FROM t1;
|
||||
SELECT * FROM t1;
|
||||
SELECT distinct * FROM t1;
|
||||
}
|
||||
} {4 1 1 one one 1 2 one two}
|
||||
} {78536 1 1 one one 1 2 one two}
|
||||
db close
|
||||
|
||||
# open a 2.0 database with big-endian hmac page numbers
|
||||
@@ -1704,9 +1706,9 @@ do_test be-to-le-migration {
|
||||
execsql {
|
||||
PRAGMA key = 'testkey';
|
||||
SELECT count(*) FROM t1;
|
||||
SELECT * FROM t1;
|
||||
SELECT distinct * FROM t1;
|
||||
}
|
||||
} {4 1 1 one one 1 2 one two}
|
||||
} {78536 1 1 one one 1 2 one two}
|
||||
db close
|
||||
file delete -force test.db
|
||||
|
||||
@@ -1950,9 +1952,9 @@ do_test open-2.0-beta-database {
|
||||
PRAGMA fast_kdf_iter = 4000;
|
||||
PRAGMA cipher_hmac_salt_mask = "x'00'";
|
||||
SELECT count(*) FROM t1;
|
||||
SELECT * FROM t1;
|
||||
SELECT distinct * FROM t1;
|
||||
}
|
||||
} {2 test-0-0 test-0-1 test-1-0 test-1-1}
|
||||
} {38768 test-0-0 test-0-1 test-1-0 test-1-1}
|
||||
db close
|
||||
|
||||
# open a 2.0 beta database
|
||||
@@ -1981,7 +1983,7 @@ do_test 2.0-beta-to-2.0-migration {
|
||||
sqlite_orig db test.db
|
||||
execsql {
|
||||
PRAGMA key = 'testkey';
|
||||
SELECT * FROM t1;
|
||||
SELECT distinct * FROM t1;
|
||||
}
|
||||
} {test-0-0 test-0-1 test-1-0 test-1-1}
|
||||
db close
|
||||
@@ -2112,4 +2114,5 @@ db close
|
||||
file delete -force test.db
|
||||
file delete -force new.db
|
||||
|
||||
sqlite3_test_control_pending_byte $old_pending_byte
|
||||
finish_test
|
||||
|
||||
Reference in New Issue
Block a user