1 --- lessfs-1.7.0/lib_crypto.c.org 2011-09-30 20:13:08.000000000 +0200
2 +++ lessfs-1.7.0/lib_crypto.c 2018-09-26 13:16:08.995599693 +0200
3 @@ -78,7 +78,7 @@ unsigned char *safepassword()
4 DAT *lfsencrypt(unsigned char *unenc, unsigned long size)
6 unsigned char *safepasswd;
12 @@ -86,19 +86,24 @@ DAT *lfsencrypt(unsigned char *unenc, un
14 pthread_mutex_lock(&crypto_mutex);
15 safepasswd = safepassword();
16 - EVP_CIPHER_CTX_init(&ctx);
17 - EVP_EncryptInit(&ctx, EVP_bf_cbc(), safepasswd, config->iv);
18 + ctx = EVP_CIPHER_CTX_new();
20 + die_cryptoerr("can't allocate memory for new ctx");
22 + EVP_EncryptInit(ctx, EVP_bf_cbc(), safepasswd, config->iv);
23 encoded = s_malloc(sizeof(DAT));
24 encoded->data = s_malloc(8 + size); //Blowfish can grow 64 bits
26 - if (EVP_EncryptUpdate(&ctx, encoded->data, &olen, unenc, size) != 1) {
27 + if (EVP_EncryptUpdate(ctx, encoded->data, &olen, unenc, size) != 1) {
28 + EVP_CIPHER_CTX_free(ctx);
29 die_cryptoerr("error in encrypt update\n");
32 - if (EVP_EncryptFinal(&ctx, encoded->data + olen, &tlen) != 1) {
33 + if (EVP_EncryptFinal(ctx, encoded->data + olen, &tlen) != 1) {
34 + EVP_CIPHER_CTX_free(ctx);
35 die_cryptoerr("error in encrypt final\n");
37 - EVP_CIPHER_CTX_cleanup(&ctx);
38 + EVP_CIPHER_CTX_free(ctx);
39 encoded->size = olen + tlen;
40 if (encoded->size > 8 + size) {
42 @@ -123,20 +128,24 @@ DAT *lfsdecrypt(DAT * data)
43 decrypted->data = s_malloc(data->size);
44 safepasswd = safepassword();
47 - EVP_CIPHER_CTX_init(&ctx);
48 - EVP_DecryptInit(&ctx, EVP_bf_cbc(), safepasswd, config->iv);
49 + EVP_CIPHER_CTX *ctx;
50 + ctx = EVP_CIPHER_CTX_new();
52 + die_cryptoerr("can't allocate memory for new ctx");
53 + EVP_DecryptInit(ctx, EVP_bf_cbc(), safepasswd, config->iv);
56 - (&ctx, decrypted->data, &olen, data->data, data->size) != 1) {
57 + (ctx, decrypted->data, &olen, data->data, data->size) != 1) {
58 + EVP_CIPHER_CTX_free(ctx);
59 die_cryptoerr("Unexpected fatal error while decrypting.\n");
62 - if (EVP_DecryptFinal(&ctx, decrypted->data + olen, &tlen) != 1) {
63 + if (EVP_DecryptFinal(ctx, decrypted->data + olen, &tlen) != 1) {
64 + EVP_CIPHER_CTX_free(ctx);
65 die_cryptoerr("Unexpected fatal error in decrypt final.\n");
68 - EVP_CIPHER_CTX_cleanup(&ctx);
69 + EVP_CIPHER_CTX_free(ctx);
70 decrypted->size = olen;
72 pthread_mutex_unlock(&crypto_mutex);