Line 0
Link Here
|
|
|
1 |
--- source/crypto.c.orig 2016-08-05 20:49:07 UTC |
2 |
+++ source/crypto.c |
3 |
@@ -282,9 +282,9 @@ static char * decipher_evp (const unsigned char *passw |
4 |
unsigned char *iv = NULL; |
5 |
unsigned long errcode; |
6 |
int outlen2; |
7 |
- EVP_CIPHER_CTX a; |
8 |
- EVP_CIPHER_CTX_init(&a); |
9 |
- EVP_CIPHER_CTX_set_padding(&a, 0); |
10 |
+ EVP_CIPHER_CTX *a = EVP_CIPHER_CTX_new(); |
11 |
+ EVP_CIPHER_CTX_init(a); |
12 |
+ EVP_CIPHER_CTX_set_padding(a, 0); |
13 |
|
14 |
if (ivsize > 0) |
15 |
iv = new_malloc(ivsize); |
16 |
@@ -292,18 +292,19 @@ static char * decipher_evp (const unsigned char *passw |
17 |
if (ivsize > 0) |
18 |
memcpy(iv, ciphertext, ivsize); |
19 |
|
20 |
- EVP_DecryptInit_ex(&a, type, NULL, NULL, iv); |
21 |
- EVP_CIPHER_CTX_set_key_length(&a, passwdlen); |
22 |
- EVP_CIPHER_CTX_set_padding(&a, 0); |
23 |
- EVP_DecryptInit_ex(&a, NULL, NULL, passwd, NULL); |
24 |
+ EVP_DecryptInit_ex(a, type, NULL, NULL, iv); |
25 |
+ EVP_CIPHER_CTX_set_key_length(a, passwdlen); |
26 |
+ EVP_CIPHER_CTX_set_padding(a, 0); |
27 |
+ EVP_DecryptInit_ex(a, NULL, NULL, passwd, NULL); |
28 |
|
29 |
- if (EVP_DecryptUpdate(&a, outbuf, outlen, ciphertext, cipherlen) != 1) |
30 |
+ if (EVP_DecryptUpdate(a, outbuf, outlen, ciphertext, cipherlen) != 1) |
31 |
yell("EVP_DecryptUpdate died."); |
32 |
- if (EVP_DecryptFinal_ex(&a, outbuf + (*outlen), &outlen2) != 1) |
33 |
+ if (EVP_DecryptFinal_ex(a, outbuf + (*outlen), &outlen2) != 1) |
34 |
yell("EVP_DecryptFinal_Ex died."); |
35 |
*outlen += outlen2; |
36 |
|
37 |
- EVP_CIPHER_CTX_cleanup(&a); |
38 |
+ EVP_CIPHER_CTX_cleanup(a); |
39 |
+ EVP_CIPHER_CTX_free(a); |
40 |
|
41 |
ERR_load_crypto_strings(); |
42 |
while ((errcode = ERR_get_error())) |
43 |
@@ -454,9 +455,9 @@ static char * cipher_evp (const unsigned char *passwd, |
44 |
unsigned long errcode; |
45 |
u_32int_t randomval; |
46 |
int iv_count; |
47 |
- EVP_CIPHER_CTX a; |
48 |
- EVP_CIPHER_CTX_init(&a); |
49 |
- EVP_CIPHER_CTX_set_padding(&a, 0); |
50 |
+ EVP_CIPHER_CTX *a = EVP_CIPHER_CTX_new(); |
51 |
+ EVP_CIPHER_CTX_init(a); |
52 |
+ EVP_CIPHER_CTX_set_padding(a, 0); |
53 |
|
54 |
if (ivsize < 0) |
55 |
ivsize = 0; /* Shenanigans! */ |
56 |
@@ -480,12 +481,13 @@ static char * cipher_evp (const unsigned char *passwd, |
57 |
if (iv) |
58 |
memcpy(outbuf, iv, ivsize); |
59 |
|
60 |
- EVP_EncryptInit_ex(&a, type, NULL, NULL, iv); |
61 |
- EVP_CIPHER_CTX_set_key_length(&a, passwdlen); |
62 |
- EVP_EncryptInit_ex(&a, NULL, NULL, passwd, NULL); |
63 |
- EVP_EncryptUpdate(&a, outbuf + ivsize, &outlen, plaintext, plaintextlen); |
64 |
- EVP_EncryptFinal_ex(&a, outbuf + ivsize + outlen, &extralen); |
65 |
- EVP_CIPHER_CTX_cleanup(&a); |
66 |
+ EVP_EncryptInit_ex(a, type, NULL, NULL, iv); |
67 |
+ EVP_CIPHER_CTX_set_key_length(a, passwdlen); |
68 |
+ EVP_EncryptInit_ex(a, NULL, NULL, passwd, NULL); |
69 |
+ EVP_EncryptUpdate(a, outbuf + ivsize, &outlen, plaintext, plaintextlen); |
70 |
+ EVP_EncryptFinal_ex(a, outbuf + ivsize + outlen, &extralen); |
71 |
+ EVP_CIPHER_CTX_cleanup(a); |
72 |
+ EVP_CIPHER_CTX_free(a); |
73 |
outlen += extralen; |
74 |
|
75 |
ERR_load_crypto_strings(); |