mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-07 23:41:59 +01:00
Introduced new AES-256 encryption method for new emails
Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
parent
613f25848d
commit
d2f3f018c0
@ -162,18 +162,29 @@ int retrieve_file_from_archive(char *filename, int mode, char **buffer, FILE *de
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The new encryption scheme uses piler id starting with 5000....
|
||||||
|
|
||||||
if(cfg->encrypt_messages == 1){
|
if(cfg->encrypt_messages == 1){
|
||||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||||
EVP_CIPHER_CTX_init(&ctx);
|
EVP_CIPHER_CTX_init(&ctx);
|
||||||
EVP_DecryptInit_ex(&ctx, EVP_bf_cbc(), NULL, cfg->key, cfg->iv);
|
if(strstr(filename, "/5000")){
|
||||||
|
EVP_DecryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, cfg->key, cfg->iv);
|
||||||
|
} else {
|
||||||
|
EVP_DecryptInit_ex(&ctx, EVP_bf_cbc(), NULL, cfg->key, cfg->iv);
|
||||||
|
}
|
||||||
|
|
||||||
blocklen = EVP_CIPHER_CTX_block_size(&ctx);
|
blocklen = EVP_CIPHER_CTX_block_size(&ctx);
|
||||||
#else
|
#else
|
||||||
ctx = EVP_CIPHER_CTX_new();
|
ctx = EVP_CIPHER_CTX_new();
|
||||||
if(!ctx) goto CLEANUP;
|
if(!ctx) goto CLEANUP;
|
||||||
|
|
||||||
EVP_CIPHER_CTX_init(ctx);
|
EVP_CIPHER_CTX_init(ctx);
|
||||||
EVP_DecryptInit_ex(ctx, EVP_bf_cbc(), NULL, cfg->key, cfg->iv);
|
if(strstr(filename, "/5000")){
|
||||||
|
EVP_DecryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, cfg->key, cfg->iv);
|
||||||
|
} else {
|
||||||
|
EVP_DecryptInit_ex(ctx, EVP_bf_cbc(), NULL, cfg->key, cfg->iv);
|
||||||
|
}
|
||||||
|
|
||||||
blocklen = EVP_CIPHER_CTX_block_size(ctx);
|
blocklen = EVP_CIPHER_CTX_block_size(ctx);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -265,11 +265,13 @@ void create_id(char *id, unsigned char server_id){
|
|||||||
|
|
||||||
get_random_bytes(buf, RND_STR_LEN/2, server_id);
|
get_random_bytes(buf, RND_STR_LEN/2, server_id);
|
||||||
|
|
||||||
|
// New encryption scheme using AES-256
|
||||||
|
buf[0] = 0x50;
|
||||||
|
|
||||||
for(i=0; i < RND_STR_LEN/2; i++){
|
for(i=0; i < RND_STR_LEN/2; i++){
|
||||||
sprintf(id, "%02x", buf[i]);
|
sprintf(id, "%02x", buf[i]);
|
||||||
id += 2;
|
id += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -109,14 +109,14 @@ int store_file(struct session_data *sdata, char *filename, int len, struct confi
|
|||||||
|
|
||||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||||
EVP_CIPHER_CTX_init(&ctx);
|
EVP_CIPHER_CTX_init(&ctx);
|
||||||
EVP_EncryptInit_ex(&ctx, EVP_bf_cbc(), NULL, cfg->key, cfg->iv);
|
EVP_EncryptInit_ex(&ctx, EVP_aes_256_cbc()(), NULL, cfg->key, cfg->iv);
|
||||||
blocklen = EVP_CIPHER_CTX_block_size(&ctx);
|
blocklen = EVP_CIPHER_CTX_block_size(&ctx);
|
||||||
#else
|
#else
|
||||||
ctx = EVP_CIPHER_CTX_new();
|
ctx = EVP_CIPHER_CTX_new();
|
||||||
if(!ctx) goto ENDE;
|
if(!ctx) goto ENDE;
|
||||||
|
|
||||||
EVP_CIPHER_CTX_init(ctx);
|
EVP_CIPHER_CTX_init(ctx);
|
||||||
EVP_EncryptInit_ex(ctx, EVP_bf_cbc(), NULL, cfg->key, cfg->iv);
|
EVP_EncryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, cfg->key, cfg->iv);
|
||||||
blocklen = EVP_CIPHER_CTX_block_size(ctx);
|
blocklen = EVP_CIPHER_CTX_block_size(ctx);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user