Permalink
Browse files

-ansi -pedantic -std=c99 warning clean

  • Loading branch information...
1 parent f1ebbc0 commit d1af70233aab346b0d0463d67c00ec702de96baf @smparkes smparkes committed May 9, 2011
Showing with 8 additions and 5 deletions.
  1. +3 −3 src/crypto.c
  2. +1 −0 src/crypto.h
  3. +4 −2 src/crypto_impl.c
View
@@ -159,20 +159,20 @@ void* sqlite3Codec(void *iCtx, void *data, Pgno pgno, int mode) {
case 2:
case 3:
if(pgno == 1) memcpy(buffer, SQLITE_FILE_HEADER, FILE_HEADER_SZ); /* copy file header to the first 16 bytes of the page */
- rc = sqlcipher_page_cipher(ctx, CIPHER_READ_CTX, pgno, CIPHER_DECRYPT, page_sz - offset, pData + offset, buffer + offset);
+ rc = sqlcipher_page_cipher(ctx, CIPHER_READ_CTX, pgno, CIPHER_DECRYPT, page_sz - offset, pData + offset, (unsigned char*)buffer + offset);
if(rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, rc);
memcpy(pData, buffer, page_sz); /* copy buffer data back to pData and return */
return pData;
break;
case 6: /* encrypt */
if(pgno == 1) memcpy(buffer, kdf_salt, FILE_HEADER_SZ); /* copy salt to output buffer */
- rc = sqlcipher_page_cipher(ctx, CIPHER_WRITE_CTX, pgno, CIPHER_ENCRYPT, page_sz - offset, pData + offset, buffer + offset);
+ rc = sqlcipher_page_cipher(ctx, CIPHER_WRITE_CTX, pgno, CIPHER_ENCRYPT, page_sz - offset, pData + offset, (unsigned char*)buffer + offset);
if(rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, rc);
return buffer; /* return persistent buffer data, pData remains intact */
break;
case 7:
if(pgno == 1) memcpy(buffer, kdf_salt, FILE_HEADER_SZ); /* copy salt to output buffer */
- rc = sqlcipher_page_cipher(ctx, CIPHER_READ_CTX, pgno, CIPHER_ENCRYPT, page_sz - offset, pData + offset, buffer + offset);
+ rc = sqlcipher_page_cipher(ctx, CIPHER_READ_CTX, pgno, CIPHER_ENCRYPT, page_sz - offset, pData + offset, (unsigned char*)buffer + offset);
if(rc != SQLITE_OK) sqlcipher_codec_ctx_set_error(ctx, rc);
return buffer; /* return persistent buffer data, pData remains intact */
break;
View
@@ -131,6 +131,7 @@ void* sqlcipher_codec_ctx_get_data(codec_ctx *);
void sqlcipher_exportFunc(sqlite3_context *, int, sqlite3_value **);
+int sqlcipher_codec_ctx_set_use_hmac(codec_ctx *ctx, int use);
/* end extensions defined in crypto_impl.c */
#endif
View
@@ -130,7 +130,9 @@ int sqlcipher_cipher_ctx_cmp(cipher_ctx *c1, cipher_ctx *c2) {
&& c1->pass_sz == c2->pass_sz
&& (
c1->pass == c2->pass
- || !sqlcipher_memcmp(c1->pass, c2->pass, c1->pass_sz)
+ || !sqlcipher_memcmp((const unsigned char*)c1->pass,
+ (const unsigned char*)c2->pass,
+ c1->pass_sz)
)
) return 0;
return 1;
@@ -463,7 +465,7 @@ int sqlcipher_cipher_ctx_key_derive(codec_ctx *ctx, cipher_ctx *c_ctx) {
this KDF run. This ensures a distinct but predictable HMAC key. */
if(c_ctx->use_hmac) {
CODEC_TRACE(("codec_key_derive: deriving hmac key using PBKDF2\n"));
- PKCS5_PBKDF2_HMAC_SHA1( c_ctx->key, c_ctx->key_sz,
+ PKCS5_PBKDF2_HMAC_SHA1( (const char*)c_ctx->key, c_ctx->key_sz,
ctx->kdf_salt, ctx->kdf_salt_sz,
c_ctx->kdf_iter, c_ctx->key_sz, c_ctx->hmac_key);
}

0 comments on commit d1af702

Please sign in to comment.