summaryrefslogtreecommitdiff
path: root/amalgamation
diff options
context:
space:
mode:
Diffstat (limited to 'amalgamation')
-rw-r--r--amalgamation/sqlite3.c44
1 files changed, 29 insertions, 15 deletions
diff --git a/amalgamation/sqlite3.c b/amalgamation/sqlite3.c
index fd39ec6..aaf8d2f 100644
--- a/amalgamation/sqlite3.c
+++ b/amalgamation/sqlite3.c
@@ -18398,14 +18398,16 @@ static int sqlcipher_openssl_random (void *ctx, void *buffer, int length) {
}
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) {
- HMAC_CTX hctx;
+
unsigned int outlen;
- HMAC_CTX_init(&hctx);
- HMAC_Init_ex(&hctx, hmac_key, key_sz, EVP_sha1(), NULL);
- HMAC_Update(&hctx, in, in_sz);
- HMAC_Update(&hctx, in2, in2_sz);
- HMAC_Final(&hctx, out, &outlen);
- HMAC_CTX_cleanup(&hctx);
+
+ HMAC_CTX *hctx;
+ hctx = HMAC_CTX_new();
+ HMAC_Init_ex(hctx, hmac_key, key_sz, EVP_sha1(), NULL);
+ HMAC_Update(hctx, in, in_sz);
+ HMAC_Update(hctx, in2, in2_sz);
+ HMAC_Final(hctx, out, &outlen);
+ HMAC_CTX_free(hctx);
return SQLITE_OK;
}
@@ -18415,18 +18417,30 @@ static int sqlcipher_openssl_kdf(void *ctx, const unsigned char *pass, int pass_
}
static int sqlcipher_openssl_cipher(void *ctx, int mode, unsigned char *key, int key_sz, unsigned char *iv, unsigned char *in, int in_sz, unsigned char *out) {
- EVP_CIPHER_CTX ectx;
int tmp_csz, csz;
-
- EVP_CipherInit(&ectx, ((openssl_ctx *)ctx)->evp_cipher, NULL, NULL, mode);
- EVP_CIPHER_CTX_set_padding(&ectx, 0); // no padding
- EVP_CipherInit(&ectx, NULL, key, iv, mode);
- EVP_CipherUpdate(&ectx, out, &tmp_csz, in, in_sz);
+ EVP_CIPHER_CTX *ectx;
+
+ ectx = EVP_CIPHER_CTX_new();
+
+ // FIXME --------------------------------------
+ //EVP_CipherInit(ectx, ((openssl_ctx *)ctx)->evp_cipher, NULL, NULL, mode);
+ EVP_CipherInit_ex(ectx, ((openssl_ctx *)ctx)->evp_cipher, NULL, NULL, NULL, mode);
+
+ EVP_CIPHER_CTX_set_padding(ectx, 0); // no padding
+
+ // FIXME --------------------------------------
+ //EVP_CipherInit(ectx, NULL, key, iv, mode);
+ EVP_CipherInit_ex(ectx, NULL, NULL, key, iv, mode);
+
+ EVP_CipherUpdate(ectx, out, &tmp_csz, in, in_sz);
+
csz = tmp_csz;
out += tmp_csz;
- EVP_CipherFinal(&ectx, out, &tmp_csz);
+
+ EVP_CipherFinal(ectx, out, &tmp_csz);
csz += tmp_csz;
- EVP_CIPHER_CTX_cleanup(&ectx);
+
+ EVP_CIPHER_CTX_free(ectx);
assert(in_sz == csz);
return SQLITE_OK;
}