summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKali Kaneko (leap communications) <kali@leap.se>2017-01-18 19:50:57 +0100
committerKali Kaneko (leap communications) <kali@leap.se>2017-01-18 19:50:57 +0100
commitdf9f0aabe5140f114b8a667e77d3feb8d637002c (patch)
tree46e50032b197db089cf101b946513c58b5a0f43c
parent7d2faa4d5df2468d14c8bc8b9b0876824e1a2ac0 (diff)
fix segfault with openssl 1.1openssl1_1
-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;
}