diff --git a/src/crypto.c b/src/crypto.c index 7981aeb4..787311bd 100644 --- a/src/crypto.c +++ b/src/crypto.c @@ -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 diff --git a/src/crypto_impl.c b/src/crypto_impl.c index 69482fc7..a3bb9542 100644 --- a/src/crypto_impl.c +++ b/src/crypto_impl.c @@ -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;