Skip to content

Commit 1001b72

Browse files
committed
use new API with libressl >2.7.0
1 parent 1bc379f commit 1001b72

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/crypto_openssl.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static unsigned int openssl_external_init = 0;
4747
static unsigned int openssl_init_count = 0;
4848
static sqlite3_mutex* openssl_rand_mutex = NULL;
4949

50-
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
50+
#if OPENSSL_VERSION_NUMBER < 0x10100000L || LIBRESSL_VERSION_NUMBER < 0x20700000L
5151
static HMAC_CTX *HMAC_CTX_new(void)
5252
{
5353
HMAC_CTX *ctx = OPENSSL_malloc(sizeof(*ctx));
@@ -57,10 +57,10 @@ static HMAC_CTX *HMAC_CTX_new(void)
5757
return ctx;
5858
}
5959

60-
// Per 1.1.0 (https://wiki.openssl.org/index.php/1.1_API_Changes)
61-
// HMAC_CTX_free should call HMAC_CTX_cleanup, then EVP_MD_CTX_Cleanup.
62-
// HMAC_CTX_cleanup internally calls EVP_MD_CTX_cleanup so these
63-
// calls are not needed.
60+
/* Per 1.1.0 (https://wiki.openssl.org/index.php/1.1_API_Changes)
61+
HMAC_CTX_free should call HMAC_CTX_cleanup, then EVP_MD_CTX_Cleanup.
62+
HMAC_CTX_cleanup internally calls EVP_MD_CTX_cleanup so these
63+
calls are not needed. */
6464
static void HMAC_CTX_free(HMAC_CTX *ctx)
6565
{
6666
if (ctx != NULL) {
@@ -117,7 +117,7 @@ static int sqlcipher_openssl_activate(void *ctx) {
117117

118118
if(openssl_init_count == 0 && openssl_external_init == 0) {
119119
/* if the library was not externally initialized, then should be now */
120-
#if OPENSSL_VERSION_NUMBER < 0x10100000L
120+
#if OPENSSL_VERSION_NUMBER < 0x10100000L || LIBRESSL_VERSION_NUMBER < 0x20700000L
121121
OpenSSL_add_all_algorithms();
122122
#endif
123123
}
@@ -154,7 +154,7 @@ static int sqlcipher_openssl_deactivate(void *ctx) {
154154
Note: this code will only be reached if OpensSSL_add_all_algorithms()
155155
is called by SQLCipher internally. This should prevent SQLCipher from
156156
"cleaning up" openssl when it was initialized externally by the program */
157-
#if OPENSSL_VERSION_NUMBER < 0x10100000L
157+
#if OPENSSL_VERSION_NUMBER < 0x10100000L || LIBRESSL_VERSION_NUMBER < 0x20700000L
158158
EVP_cleanup();
159159
#endif
160160
} else {
@@ -226,7 +226,7 @@ static int sqlcipher_openssl_cipher(void *ctx, int mode, unsigned char *key, int
226226
EVP_CIPHER_CTX* ectx = EVP_CIPHER_CTX_new();
227227
if(ectx == NULL) return SQLITE_ERROR;
228228
EVP_CipherInit_ex(ectx, ((openssl_ctx *)ctx)->evp_cipher, NULL, NULL, NULL, mode);
229-
EVP_CIPHER_CTX_set_padding(ectx, 0); // no padding
229+
EVP_CIPHER_CTX_set_padding(ectx, 0); /* no padding */
230230
EVP_CipherInit_ex(ectx, NULL, NULL, key, iv, mode);
231231
EVP_CipherUpdate(ectx, out, &tmp_csz, in, in_sz);
232232
csz = tmp_csz;

0 commit comments

Comments
 (0)