wok-next view vde2/stuff/patches/vde_cryptcab-compile-against-openssl-1.1.0.patch @ rev 20775

quodlibet: remove non-existent package from bdeps
author Aleksej Bobylev <al.bobylev@gmail.com>
date Wed Jun 06 20:44:57 2018 +0300 (2018-06-06)
parents
children
line source
1 --- a/src/vde_cryptcab/cryptcab.c 2011-11-23 16:41:17.000000000 +0000
2 +++ b/src/vde_cryptcab/cryptcab.c 2017-03-20 22:54:20.452975075 +0000
3 @@ -22,7 +22,7 @@
4 exit(1);
5 }
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 @@
13 static struct vde_open_args open_args={.port=0,.group=NULL,.mode=0700};
14 static int verbose = 0;
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 @@
24 }
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 }
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 }
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 @@
50 olen += tlen;
52 cleanup:
53 - EVP_CIPHER_CTX_cleanup(&ctx);
54 + EVP_CIPHER_CTX_reset(ctx);
55 return olen;
56 }
58 @@ -138,19 +144,21 @@
59 }
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 }
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 }
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 @@
85 olen += tlen;
87 cleanup:
88 - EVP_CIPHER_CTX_cleanup(&ctx);
89 + EVP_CIPHER_CTX_reset (ctx);
90 return olen;
91 }