Line 0
Link Here
|
|
|
1 |
--- src/vde_cryptcab/cryptcab.c.orig 2011-11-23 16:41:17 UTC |
2 |
+++ src/vde_cryptcab/cryptcab.c |
3 |
@@ -22,7 +22,7 @@ static void Usage(char *programname) |
4 |
exit(1); |
5 |
} |
6 |
|
7 |
-static EVP_CIPHER_CTX ctx; |
8 |
+static EVP_CIPHER_CTX *ctx; |
9 |
static int ctx_initialized = 0; |
10 |
static int encryption_disabled = 0; |
11 |
static int nfd; |
12 |
@@ -30,6 +30,10 @@ static unsigned long long mycounter=1; |
13 |
static struct vde_open_args open_args={.port=0,.group=NULL,.mode=0700}; |
14 |
static int verbose = 0; |
15 |
|
16 |
+#if OPENSSL_VERSION_NUMBER < 0x10100000 |
17 |
+#define EVP_CIPHER_CTX_reset(x) EVP_CIPHER_CTX_cleanup(x) |
18 |
+#endif |
19 |
+ |
20 |
void vc_printlog(int priority, const char *format, ...) |
21 |
{ |
22 |
va_list arg; |
23 |
@@ -103,19 +107,21 @@ int data_encrypt(unsigned char *src, unsigned char *ds |
24 |
} |
25 |
|
26 |
if (!ctx_initialized) { |
27 |
- EVP_CIPHER_CTX_init (&ctx); |
28 |
+ ctx = EVP_CIPHER_CTX_new (); |
29 |
+ if (!ctx) |
30 |
+ return -1; |
31 |
ctx_initialized = 1; |
32 |
} |
33 |
|
34 |
- EVP_EncryptInit (&ctx, EVP_bf_cbc (), p->key, p->iv); |
35 |
- if (EVP_EncryptUpdate (&ctx, dst, &olen, src, len) != 1) |
36 |
+ EVP_EncryptInit (ctx, EVP_bf_cbc (), p->key, p->iv); |
37 |
+ if (EVP_EncryptUpdate (ctx, dst, &olen, src, len) != 1) |
38 |
{ |
39 |
fprintf (stderr,"error in encrypt update\n"); |
40 |
olen = -1; |
41 |
goto cleanup; |
42 |
} |
43 |
|
44 |
- if (EVP_EncryptFinal (&ctx, dst + olen, &tlen) != 1) |
45 |
+ if (EVP_EncryptFinal (ctx, dst + olen, &tlen) != 1) |
46 |
{ |
47 |
fprintf (stderr,"error in encrypt final\n"); |
48 |
olen = -1; |
49 |
@@ -124,7 +130,7 @@ int data_encrypt(unsigned char *src, unsigned char *ds |
50 |
olen += tlen; |
51 |
|
52 |
cleanup: |
53 |
- EVP_CIPHER_CTX_cleanup(&ctx); |
54 |
+ EVP_CIPHER_CTX_reset(ctx); |
55 |
return olen; |
56 |
} |
57 |
|
58 |
@@ -138,19 +144,21 @@ int data_decrypt(unsigned char *src, unsigned char *ds |
59 |
} |
60 |
|
61 |
if (!ctx_initialized) { |
62 |
- EVP_CIPHER_CTX_init (&ctx); |
63 |
+ ctx = EVP_CIPHER_CTX_new (); |
64 |
+ if (!ctx) |
65 |
+ return -1; |
66 |
ctx_initialized = 1; |
67 |
} |
68 |
|
69 |
- EVP_DecryptInit (&ctx, EVP_bf_cbc (), p->key, p->iv); |
70 |
- if (EVP_DecryptUpdate (&ctx, dst, &olen, src, len) != 1) |
71 |
+ EVP_DecryptInit (ctx, EVP_bf_cbc (), p->key, p->iv); |
72 |
+ if (EVP_DecryptUpdate (ctx, dst, &olen, src, len) != 1) |
73 |
{ |
74 |
fprintf (stderr,"error in decrypt update\n"); |
75 |
olen = -1; |
76 |
goto cleanup; |
77 |
} |
78 |
|
79 |
- if (EVP_DecryptFinal (&ctx, dst + olen, &tlen) != 1) |
80 |
+ if (EVP_DecryptFinal (ctx, dst + olen, &tlen) != 1) |
81 |
{ |
82 |
fprintf (stderr,"error in decrypt final\n"); |
83 |
olen = -1; |
84 |
@@ -159,7 +167,7 @@ int data_decrypt(unsigned char *src, unsigned char *ds |
85 |
olen += tlen; |
86 |
|
87 |
cleanup: |
88 |
- EVP_CIPHER_CTX_cleanup(&ctx); |
89 |
+ EVP_CIPHER_CTX_reset (ctx); |
90 |
return olen; |
91 |
} |
92 |
|