mirror of
https://github.com/status-im/sqlcipher.git
synced 2026-08-30 22:11:14 +00:00
pragma to return fast_kdf_iter
This commit is contained in:
+15
-7
@@ -108,18 +108,26 @@ int codec_pragma(sqlite3* db, int iDb, Parse *pParse, const char *zLeft, const c
|
||||
if(ctx) sqlcipher_codec_ctx_set_cipher(ctx, zRight, 1); // change write cipher only
|
||||
}else
|
||||
if( sqlite3StrICmp(zLeft, "kdf_iter")==0 ){
|
||||
if( zRight ) {
|
||||
if(ctx) sqlcipher_codec_ctx_set_kdf_iter(ctx, atoi(zRight), 2); // change of RW PBKDF2 iteration
|
||||
} else {
|
||||
if(ctx) {
|
||||
if(ctx) {
|
||||
if( zRight ) {
|
||||
sqlcipher_codec_ctx_set_kdf_iter(ctx, atoi(zRight), 2); // change of RW PBKDF2 iteration
|
||||
} else {
|
||||
char *kdf_iter = sqlite3_mprintf("%d", sqlcipher_codec_ctx_get_kdf_iter(ctx, 2));
|
||||
codec_vdbe_return_static_string(pParse, "kdf_iter", kdf_iter);
|
||||
sqlite3_free(kdf_iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else
|
||||
if( sqlite3StrICmp(zLeft, "fast_kdf_iter")==0 && zRight ){
|
||||
if(ctx) sqlcipher_codec_ctx_set_fast_kdf_iter(ctx, atoi(zRight), 2); // change of RW PBKDF2 iteration
|
||||
if( sqlite3StrICmp(zLeft, "fast_kdf_iter")==0){
|
||||
if(ctx) {
|
||||
if( zRight ) {
|
||||
sqlcipher_codec_ctx_set_fast_kdf_iter(ctx, atoi(zRight), 2); // change of RW PBKDF2 iteration
|
||||
} else {
|
||||
char *fast_kdf_iter = sqlite3_mprintf("%d", sqlcipher_codec_ctx_get_fast_kdf_iter(ctx, 2));
|
||||
codec_vdbe_return_static_string(pParse, "fast_kdf_iter", fast_kdf_iter);
|
||||
sqlite3_free(fast_kdf_iter);
|
||||
}
|
||||
}
|
||||
}else
|
||||
if( sqlite3StrICmp(zLeft, "rekey_kdf_iter")==0 && zRight ){
|
||||
if(ctx) sqlcipher_codec_ctx_set_kdf_iter(ctx, atoi(zRight), 1); // write iterations only
|
||||
|
||||
@@ -171,6 +171,7 @@ int sqlcipher_codec_ctx_get_kdf_iter(codec_ctx *ctx, int);
|
||||
void* sqlcipher_codec_ctx_get_kdf_salt(codec_ctx *ctx);
|
||||
|
||||
int sqlcipher_codec_ctx_set_fast_kdf_iter(codec_ctx *, int, int);
|
||||
int sqlcipher_codec_ctx_get_fast_kdf_iter(codec_ctx *, int);
|
||||
|
||||
int sqlcipher_codec_ctx_set_cipher(codec_ctx *, const char *, int);
|
||||
const char* sqlcipher_codec_ctx_get_cipher(codec_ctx *ctx, int for_ctx);
|
||||
|
||||
@@ -385,6 +385,11 @@ int sqlcipher_codec_ctx_set_fast_kdf_iter(codec_ctx *ctx, int fast_kdf_iter, int
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
int sqlcipher_codec_ctx_get_fast_kdf_iter(codec_ctx *ctx, int for_ctx) {
|
||||
cipher_ctx *c_ctx = for_ctx ? ctx->write_ctx : ctx->read_ctx;
|
||||
return c_ctx->fast_kdf_iter;
|
||||
}
|
||||
|
||||
/* set the global default flag for HMAC */
|
||||
void sqlcipher_set_default_use_hmac(int use) {
|
||||
if(use) default_flags |= CIPHER_FLAG_HMAC;
|
||||
|
||||
@@ -1683,6 +1683,31 @@ do_test verify-pragma-kdf-iter-reports-value-changed {
|
||||
db close
|
||||
file delete -force test.db
|
||||
|
||||
# verify the pragma fast_kdf_iter
|
||||
# reports the default value
|
||||
do_test verify-pragma-fast-kdf-iter-reports-default {
|
||||
sqlite_orig db test.db
|
||||
execsql {
|
||||
PRAGMA key = 'test';
|
||||
PRAGMA fast_kdf_iter;
|
||||
}
|
||||
} {2}
|
||||
db close
|
||||
file delete -force test.db
|
||||
|
||||
# verify the pragma fast_kdf_iter
|
||||
# reports value changed
|
||||
do_test verify-pragma-kdf-iter-reports-value-changed {
|
||||
sqlite_orig db test.db
|
||||
execsql {
|
||||
PRAGMA key = 'test';
|
||||
PRAGMA fast_kdf_iter = 4000;
|
||||
PRAGMA fast_kdf_iter;
|
||||
}
|
||||
} {4000}
|
||||
db close
|
||||
file delete -force test.db
|
||||
|
||||
# verify the pragma cipher_page_size
|
||||
# reports default value
|
||||
do_test verify-pragma-cipher-page-size-default {
|
||||
|
||||
Reference in New Issue
Block a user