Adding get support to the PRAGMA kdf_iter

This commit is contained in:
Nick Parker 2012-11-06 11:20:39 -06:00
parent 693a403f76
commit 6eb69e384a
2 changed files with 15 additions and 2 deletions

View File

@ -104,8 +104,12 @@ int codec_pragma(sqlite3* db, int iDb, Parse *pParse, const char *zLeft, const c
if( sqlite3StrICmp(zLeft, "rekey_cipher")==0 && zRight ){
if(ctx) sqlcipher_codec_ctx_set_cipher(ctx, zRight, 1); // change write cipher only
}else
if( sqlite3StrICmp(zLeft, "kdf_iter")==0 && zRight ){
if(ctx) sqlcipher_codec_ctx_set_kdf_iter(ctx, atoi(zRight), 2); // change of RW PBKDF2 iteration
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) sqlcipher_codec_ctx_get_kdf_iter(pParse, ctx, 2);
}
}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

View File

@ -367,6 +367,15 @@ int sqlcipher_codec_ctx_set_kdf_iter(codec_ctx *ctx, int kdf_iter, int for_ctx)
return SQLITE_OK;
}
int sqlcipher_codec_ctx_get_kdf_iter(Parse *pParse, codec_ctx *ctx, int for_ctx) {
cipher_ctx *c_ctx = for_ctx ? ctx->write_ctx : ctx->read_ctx;
char *kdf_iter = sqlite3_mprintf("%d", c_ctx->kdf_iter);
codec_vdbe_return_static_string(pParse, "kdf_iter", kdf_iter);
sqlite3_free(kdf_iter);
return SQLITE_OK;
}
int sqlcipher_codec_ctx_set_fast_kdf_iter(codec_ctx *ctx, int fast_kdf_iter, int for_ctx) {
cipher_ctx *c_ctx = for_ctx ? ctx->write_ctx : ctx->read_ctx;
int rc;