diff --git a/src/crypto.c b/src/crypto.c index bb6e72ec..7981aeb4 100644 --- a/src/crypto.c +++ b/src/crypto.c @@ -94,8 +94,12 @@ int codec_pragma(sqlite3* db, int iDb, Parse *pParse, const char *zLeft, const c if( sqlite3StrICmp(zLeft, "cipher_version")==0 && !zRight ){ codec_vdbe_return_static_string(pParse, "cipher_version", codec_get_cipher_version()); }else - if( sqlite3StrICmp(zLeft, "cipher")==0 && zRight ){ - if(ctx) sqlcipher_codec_ctx_set_cipher(ctx, zRight, 2); // change cipher for both + if( sqlite3StrICmp(zLeft, "cipher")==0 ){ + if( zRight ) { + if(ctx) sqlcipher_codec_ctx_set_cipher(ctx, zRight, 2); // change cipher for both + }else { + if(ctx) sqlcipher_codec_ctx_get_cipher(pParse, ctx, 2); + } }else if( sqlite3StrICmp(zLeft, "rekey_cipher")==0 && zRight ){ if(ctx) sqlcipher_codec_ctx_set_cipher(ctx, zRight, 1); // change write cipher only diff --git a/src/crypto_impl.c b/src/crypto_impl.c index e5456fa9..69482fc7 100644 --- a/src/crypto_impl.c +++ b/src/crypto_impl.c @@ -344,6 +344,15 @@ int sqlcipher_codec_ctx_set_cipher(codec_ctx *ctx, const char *cipher_name, int return SQLITE_OK; } +int sqlcipher_codec_ctx_get_cipher(Parse *pParse, codec_ctx *ctx, int for_ctx) { + cipher_ctx *c_ctx = for_ctx ? ctx->write_ctx : ctx->read_ctx; + EVP_CIPHER *evp_cipher = c_ctx->evp_cipher; + char* name = EVP_CIPHER_name(evp_cipher); + codec_vdbe_return_static_string(pParse, "cipher", name); + + return SQLITE_OK; +} + int sqlcipher_codec_ctx_set_kdf_iter(codec_ctx *ctx, int kdf_iter, int for_ctx) { cipher_ctx *c_ctx = for_ctx ? ctx->write_ctx : ctx->read_ctx; int rc;