mirror of
https://github.com/status-im/sqlcipher.git
synced 2025-02-24 01:38:09 +00:00
add flag for normalizing pgno in HMAC check
This commit is contained in:
parent
7a9b9e39a1
commit
70ef31ff5d
@ -57,10 +57,11 @@
|
||||
#endif
|
||||
|
||||
/* possible flags for cipher_ctx->flags */
|
||||
#define CIPHER_FLAG_HMAC 0x01
|
||||
#define CIPHER_FLAG_HMAC 0x01
|
||||
#define CIPHER_FLAG_LE_PGNO 0x02
|
||||
|
||||
#ifndef DEFAULT_CIPHER_FLAGS
|
||||
#define DEFAULT_CIPHER_FLAGS CIPHER_FLAG_HMAC
|
||||
#define DEFAULT_CIPHER_FLAGS CIPHER_FLAG_HMAC | CIPHER_FLAG_LE_PGNO
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -512,7 +512,11 @@ int sqlcipher_page_hmac(cipher_ctx *ctx, Pgno pgno, unsigned char *in, int in_sz
|
||||
valid pages out of order in a database */
|
||||
HMAC_Update(&ctx->hctx, in, in_sz);
|
||||
|
||||
HMAC_Update(&ctx->hctx, (const unsigned char*) pgno_le, sizeof(pgno_le));
|
||||
if(ctx->flags & CIPHER_FLAG_LE_PGNO) /* default compute hmac using little endian */
|
||||
HMAC_Update(&ctx->hctx, (const unsigned char*) pgno_le, sizeof(pgno_le));
|
||||
else /* legacy setting - compute using native byte ordering */
|
||||
HMAC_Update(&ctx->hctx, (const unsigned char*) &pgno, sizeof(pgno));
|
||||
|
||||
HMAC_Final(&ctx->hctx, out, NULL);
|
||||
HMAC_CTX_cleanup(&ctx->hctx);
|
||||
return SQLITE_OK;
|
||||
|
Loading…
x
Reference in New Issue
Block a user