mirror of
https://github.com/status-im/sqlcipher.git
synced 2025-02-23 17:28:17 +00:00
Adding get support to PRAGMA cipher_use_hmac
This commit is contained in:
parent
6eb69e384a
commit
9a9873b933
17
src/crypto.c
17
src/crypto.c
@ -130,12 +130,17 @@ int codec_pragma(sqlite3* db, int iDb, Parse *pParse, const char *zLeft, const c
|
||||
sqlcipher_set_default_use_hmac(sqlite3GetBoolean(zRight,1));
|
||||
}else
|
||||
if( sqlite3StrICmp(zLeft,"cipher_use_hmac")==0 ){
|
||||
if(ctx) {
|
||||
rc = sqlcipher_codec_ctx_set_use_hmac(ctx, sqlite3GetBoolean(zRight,1));
|
||||
if(rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, rc);
|
||||
/* since the use of hmac has changed, the page size may also change */
|
||||
rc = codec_set_btree_to_codec_pagesize(db, pDb, ctx);
|
||||
if(rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, rc);
|
||||
|
||||
if( zRight ) {
|
||||
if(ctx) {
|
||||
rc = sqlcipher_codec_ctx_set_use_hmac(ctx, sqlite3GetBoolean(zRight,1));
|
||||
if(rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, rc);
|
||||
/* since the use of hmac has changed, the page size may also change */
|
||||
rc = codec_set_btree_to_codec_pagesize(db, pDb, ctx);
|
||||
if(rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, rc);
|
||||
}
|
||||
} else {
|
||||
if(ctx) sqlcipher_codec_ctx_get_use_hmac(pParse, ctx, 2);
|
||||
}
|
||||
}else
|
||||
if( sqlite3StrICmp(zLeft,"cipher_hmac_pgno")==0 ){
|
||||
|
@ -422,6 +422,16 @@ int sqlcipher_codec_ctx_set_use_hmac(codec_ctx *ctx, int use) {
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
int sqlcipher_codec_ctx_get_use_hmac(Parse *pParse, codec_ctx *ctx, int for_ctx) {
|
||||
cipher_ctx * c_ctx = for_ctx ? ctx->write_ctx : ctx->read_ctx;
|
||||
int hmac_flag_set = c_ctx->flags & CIPHER_FLAG_HMAC > 0;
|
||||
char *hmac_flag = sqlite3_mprintf("%d", hmac_flag_set);
|
||||
codec_vdbe_return_static_string(pParse, "cipher_use_hmac", hmac_flag);
|
||||
sqlite3_free(hmac_flag);
|
||||
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
int sqlcipher_codec_ctx_set_flag(codec_ctx *ctx, unsigned int flag) {
|
||||
ctx->write_ctx->flags |= flag;
|
||||
ctx->read_ctx->flags |= flag;
|
||||
|
Loading…
x
Reference in New Issue
Block a user