diff --git a/src/archive.c b/src/archive.c index 3160b6af..17196a3a 100644 --- a/src/archive.c +++ b/src/archive.c @@ -135,7 +135,11 @@ int retrieve_file_from_archive(char *filename, int mode, char **buffer, FILE *de int rc=0, n, olen, tlen, len, fd=-1; unsigned char *s=NULL, *addr=NULL, inbuf[REALLYBIGBUFSIZE]; struct stat st; +#if OPENSSL_VERSION_NUMBER < 0x10100000L EVP_CIPHER_CTX ctx; +#else + EVP_CIPHER_CTX *ctx; +#endif if(filename == NULL) return 1; @@ -156,8 +160,16 @@ int retrieve_file_from_archive(char *filename, int mode, char **buffer, FILE *de if(cfg->encrypt_messages == 1){ + #if OPENSSL_VERSION_NUMBER < 0x10100000L EVP_CIPHER_CTX_init(&ctx); EVP_DecryptInit_ex(&ctx, EVP_bf_cbc(), NULL, cfg->key, cfg->iv); + #else + ctx = EVP_CIPHER_CTX_new(); + if(!ctx) goto CLEANUP; + + EVP_CIPHER_CTX_init(ctx); + EVP_DecryptInit_ex(ctx, EVP_bf_cbc(), NULL, cfg->key, cfg->iv); + #endif len = st.st_size+EVP_MAX_BLOCK_LENGTH; @@ -172,7 +184,11 @@ int retrieve_file_from_archive(char *filename, int mode, char **buffer, FILE *de while((n = read(fd, inbuf, sizeof(inbuf)))){ + #if OPENSSL_VERSION_NUMBER < 0x10100000L if(!EVP_DecryptUpdate(&ctx, s+tlen, &olen, inbuf, n)){ + #else + if(!EVP_DecryptUpdate(ctx, s+tlen, &olen, inbuf, n)){ + #endif syslog(LOG_PRIORITY, "%s: EVP_DecryptUpdate()", filename); goto CLEANUP; } @@ -181,7 +197,11 @@ int retrieve_file_from_archive(char *filename, int mode, char **buffer, FILE *de } + #if OPENSSL_VERSION_NUMBER < 0x10100000L if(EVP_DecryptFinal(&ctx, s + tlen, &olen) != 1){ + #else + if(EVP_DecryptFinal(ctx, s + tlen, &olen) != 1){ + #endif syslog(LOG_PRIORITY, "%s: EVP_DecryptFinal()", filename); goto CLEANUP; } @@ -203,7 +223,12 @@ int retrieve_file_from_archive(char *filename, int mode, char **buffer, FILE *de CLEANUP: if(fd != -1) close(fd); if(s) free(s); - if(cfg->encrypt_messages == 1) EVP_CIPHER_CTX_cleanup(&ctx); + if(cfg->encrypt_messages == 1) + #if OPENSSL_VERSION_NUMBER < 0x10100000L + EVP_CIPHER_CTX_cleanup(&ctx); + #else + EVP_CIPHER_CTX_free(ctx); + #endif return 0; } diff --git a/src/config.h b/src/config.h index bf37cc0b..36974d01 100644 --- a/src/config.h +++ b/src/config.h @@ -12,7 +12,7 @@ #define PROGNAME "piler" #define VERSION "1.3.0" -#define BUILD 955 +#define BUILD 956 #define HOSTID "mailarchiver" diff --git a/src/imap.c b/src/imap.c index be903c00..3d56b769 100644 --- a/src/imap.c +++ b/src/imap.c @@ -323,7 +323,11 @@ int connect_to_imap_server(int sd, int *seq, char *username, char *password, str SSL_library_init(); SSL_load_error_strings(); + #if OPENSSL_VERSION_NUMBER < 0x10100000L data->ctx = SSL_CTX_new(TLSv1_client_method()); + #else + data->ctx = SSL_CTX_new(TLS_client_method()); + #endif CHK_NULL(data->ctx, "internal SSL error"); data->ssl = SSL_new(data->ctx); diff --git a/src/piler.c b/src/piler.c index e59d84f1..5e3e289c 100644 --- a/src/piler.c +++ b/src/piler.c @@ -265,7 +265,11 @@ int init_ssl(){ SSL_library_init(); SSL_load_error_strings(); +#if OPENSSL_VERSION_NUMBER < 0x10100000L data.ctx = SSL_CTX_new(TLSv1_server_method()); +#else + data.ctx = SSL_CTX_new(TLS_server_method()); +#endif if(data.ctx == NULL){ syslog(LOG_PRIORITY, "SSL_CTX_new() failed"); return ERR; } diff --git a/src/pop3.c b/src/pop3.c index 3e7eb377..7daf3425 100644 --- a/src/pop3.c +++ b/src/pop3.c @@ -48,7 +48,11 @@ int connect_to_pop3_server(int sd, char *username, char *password, struct __data SSL_library_init(); SSL_load_error_strings(); + #if OPENSSL_VERSION_NUMBER < 0x10100000L data->ctx = SSL_CTX_new(TLSv1_client_method()); + #else + data->ctx = SSL_CTX_new(TLS_client_method()); + #endif CHK_NULL(data->ctx, "internal SSL error"); data->ssl = SSL_new(data->ctx); diff --git a/src/store.c b/src/store.c index 1230a456..0e1d8219 100644 --- a/src/store.c +++ b/src/store.c @@ -46,7 +46,11 @@ int store_file(struct session_data *sdata, char *filename, int len, struct __con Bytef *z=NULL; uLongf dstlen; +#if OPENSSL_VERSION_NUMBER < 0x10100000L EVP_CIPHER_CTX ctx; +#else + EVP_CIPHER_CTX *ctx; +#endif unsigned char *outbuf=NULL; int outlen=0, writelen, tmplen; @@ -101,16 +105,34 @@ int store_file(struct session_data *sdata, char *filename, int len, struct __con if(cfg->encrypt_messages == 1){ gettimeofday(&tv1, &tz); + #if OPENSSL_VERSION_NUMBER < 0x10100000L EVP_CIPHER_CTX_init(&ctx); EVP_EncryptInit_ex(&ctx, EVP_bf_cbc(), NULL, cfg->key, cfg->iv); + #else + ctx = EVP_CIPHER_CTX_new(); + if(!ctx) goto ENDE; + + EVP_CIPHER_CTX_init(ctx); + EVP_EncryptInit_ex(ctx, EVP_bf_cbc(), NULL, cfg->key, cfg->iv); + #endif outbuf = malloc(dstlen + EVP_MAX_BLOCK_LENGTH); if(outbuf == NULL) goto ENDE; + #if OPENSSL_VERSION_NUMBER < 0x10100000L if(!EVP_EncryptUpdate(&ctx, outbuf, &outlen, z, dstlen)) goto ENDE; if(!EVP_EncryptFinal_ex(&ctx, outbuf + outlen, &tmplen)) goto ENDE; + #else + if(!EVP_EncryptUpdate(ctx, outbuf, &outlen, z, dstlen)) goto ENDE; + if(!EVP_EncryptFinal_ex(ctx, outbuf + outlen, &tmplen)) goto ENDE; + #endif + outlen += tmplen; + #if OPENSSL_VERSION_NUMBER < 0x10100000L EVP_CIPHER_CTX_cleanup(&ctx); + #else + EVP_CIPHER_CTX_free(ctx); + #endif gettimeofday(&tv2, &tz); sdata->__encrypt += tvdiff(tv2, tv1);