mirror of
https://github.com/status-im/sqlcipher.git
synced 2025-02-24 01:38:09 +00:00
Checking for SQLITE_OK as return code for random
This commit is contained in:
parent
689b22ead7
commit
51f2855d36
@ -557,7 +557,7 @@ int sqlcipher_codec_ctx_init(codec_ctx **iCtx, Db *pDb, Pager *pPager, sqlite3_f
|
|||||||
|
|
||||||
if(fd == NULL || sqlite3OsRead(fd, ctx->kdf_salt, FILE_HEADER_SZ, 0) != SQLITE_OK) {
|
if(fd == NULL || sqlite3OsRead(fd, ctx->kdf_salt, FILE_HEADER_SZ, 0) != SQLITE_OK) {
|
||||||
/* if unable to read the bytes, generate random salt */
|
/* if unable to read the bytes, generate random salt */
|
||||||
if(ctx->read_ctx->provider->random(ctx->read_ctx->provider_ctx, ctx->kdf_salt, FILE_HEADER_SZ) != 1) return SQLITE_ERROR;
|
if(ctx->read_ctx->provider->random(ctx->read_ctx->provider_ctx, ctx->kdf_salt, FILE_HEADER_SZ) != SQLITE_OK) return SQLITE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((rc = sqlcipher_codec_ctx_set_cipher(ctx, CIPHER, 0)) != SQLITE_OK) return rc;
|
if((rc = sqlcipher_codec_ctx_set_cipher(ctx, CIPHER, 0)) != SQLITE_OK) return rc;
|
||||||
@ -662,7 +662,7 @@ int sqlcipher_page_cipher(codec_ctx *ctx, int for_ctx, Pgno pgno, int mode, int
|
|||||||
|
|
||||||
if(mode == CIPHER_ENCRYPT) {
|
if(mode == CIPHER_ENCRYPT) {
|
||||||
/* start at front of the reserve block, write random data to the end */
|
/* start at front of the reserve block, write random data to the end */
|
||||||
if(c_ctx->provider->random(c_ctx->provider_ctx, iv_out, c_ctx->reserve_sz) != 1) return SQLITE_ERROR;
|
if(c_ctx->provider->random(c_ctx->provider_ctx, iv_out, c_ctx->reserve_sz) != SQLITE_OK) return SQLITE_ERROR;
|
||||||
} else { /* CIPHER_DECRYPT */
|
} else { /* CIPHER_DECRYPT */
|
||||||
memcpy(iv_out, iv_in, c_ctx->iv_sz); /* copy the iv from the input to output buffer */
|
memcpy(iv_out, iv_in, c_ctx->iv_sz); /* copy the iv from the input to output buffer */
|
||||||
}
|
}
|
||||||
|
@ -53,8 +53,11 @@ static const char* sqlcipher_ltc_get_provider_name(void *ctx) {
|
|||||||
|
|
||||||
static int sqlcipher_ltc_random(void *ctx, void *buffer, int length) {
|
static int sqlcipher_ltc_random(void *ctx, void *buffer, int length) {
|
||||||
ltc_ctx *ltc = (ltc_ctx*)ctx;
|
ltc_ctx *ltc = (ltc_ctx*)ctx;
|
||||||
|
int rc;
|
||||||
|
|
||||||
fortuna_ready(&(ltc->prng));
|
if((rc = fortuna_ready(&(ltc->prng))) != CRYPT_OK) {
|
||||||
|
return SQLITE_ERROR;
|
||||||
|
}
|
||||||
fortuna_read(buffer, length, &(ltc->prng));
|
fortuna_read(buffer, length, &(ltc->prng));
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,8 @@ static const char* sqlcipher_openssl_get_provider_name(void *ctx) {
|
|||||||
|
|
||||||
/* generate a defined number of pseudorandom bytes */
|
/* generate a defined number of pseudorandom bytes */
|
||||||
static int sqlcipher_openssl_random (void *ctx, void *buffer, int length) {
|
static int sqlcipher_openssl_random (void *ctx, void *buffer, int length) {
|
||||||
return RAND_bytes((unsigned char *)buffer, length);
|
RAND_bytes((unsigned char *)buffer, length);
|
||||||
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sqlcipher_openssl_hmac(void *ctx, unsigned char *hmac_key, int key_sz, unsigned char *in, int in_sz, unsigned char *in2, int in2_sz, unsigned char *out) {
|
static int sqlcipher_openssl_hmac(void *ctx, unsigned char *hmac_key, int key_sz, unsigned char *in, int in_sz, unsigned char *in2, int in2_sz, unsigned char *out) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user