Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 673928 | Differences between
and this patch

Collapse All | Expand All

(-)a/src/vde_cryptcab/cryptcab.c (-12 / +19 lines)
Lines 22-28 static void Usage(char *programname) Link Here
22
	exit(1);
22
	exit(1);
23
}
23
}
24
	
24
	
25
static EVP_CIPHER_CTX ctx;
25
static EVP_CIPHER_CTX *ctx;
26
static int ctx_initialized = 0;
26
static int ctx_initialized = 0;
27
static int encryption_disabled = 0;
27
static int encryption_disabled = 0;
28
static int nfd;
28
static int nfd;
Lines 30-35 static unsigned long long mycounter=1; Link Here
30
static struct vde_open_args open_args={.port=0,.group=NULL,.mode=0700};
30
static struct vde_open_args open_args={.port=0,.group=NULL,.mode=0700};
31
static int verbose = 0;
31
static int verbose = 0;
32
32
33
#if OPENSSL_VERSION_NUMBER < 0x10100000
34
#define EVP_CIPHER_CTX_reset(x)	EVP_CIPHER_CTX_cleanup(x)
35
#endif
36
33
void vc_printlog(int priority, const char *format, ...)
37
void vc_printlog(int priority, const char *format, ...)
34
{
38
{
35
	va_list arg;
39
	va_list arg;
Lines 105-123 int data_encrypt(unsigned char *src, unsigned char *dst, int len, struct peer *p Link Here
105
	}
109
	}
106
110
107
	if (!ctx_initialized) {
111
	if (!ctx_initialized) {
108
		EVP_CIPHER_CTX_init (&ctx);
112
		ctx = EVP_CIPHER_CTX_new ();
113
		if (!ctx)
114
			return -1;
109
		ctx_initialized = 1;
115
		ctx_initialized = 1;
110
	}
116
	}
111
	
117
	
112
	EVP_EncryptInit (&ctx, EVP_bf_cbc (), p->key, p->iv);
118
	EVP_EncryptInit (ctx, EVP_bf_cbc (), p->key, p->iv);
113
	if (EVP_EncryptUpdate (&ctx, dst, &olen, src, len) != 1)
119
	if (EVP_EncryptUpdate (ctx, dst, &olen, src, len) != 1)
114
	{
120
	{
115
		fprintf (stderr,"error in encrypt update\n");
121
		fprintf (stderr,"error in encrypt update\n");
116
		olen = -1;
122
		olen = -1;
117
		goto cleanup;
123
		goto cleanup;
118
	}
124
	}
119
125
120
	if (EVP_EncryptFinal (&ctx, dst + ulen, &tlen) != 1)
126
	if (EVP_EncryptFinal (ctx, dst + ulen, &tlen) != 1)
121
	{
127
	{
122
		fprintf (stderr,"error in encrypt final\n");
128
		fprintf (stderr,"error in encrypt final\n");
123
		olen = -1;
129
		olen = -1;
Lines 126-132 int data_encrypt(unsigned char *src, unsigned char *dst, int len, struct peer *p Link Here
126
	olen += tlen;
132
	olen += tlen;
127
133
128
cleanup:
134
cleanup:
129
	EVP_CIPHER_CTX_cleanup(&ctx);	
135
	EVP_CIPHER_CTX_reset(ctx);
130
	return olen;
136
	return olen;
131
}
137
}
132
138
Lines 142-160 int data_decrypt(unsigned char *src, unsigned char *dst, int len, struct peer *p Link Here
142
	}
148
	}
143
	
149
	
144
	if (!ctx_initialized) {
150
	if (!ctx_initialized) {
145
		EVP_CIPHER_CTX_init (&ctx);
151
		ctx = EVP_CIPHER_CTX_new ();
152
		if (!ctx)
153
			return -1;
146
		ctx_initialized = 1;
154
		ctx_initialized = 1;
147
	}
155
	}
148
156
149
	EVP_DecryptInit (&ctx, EVP_bf_cbc (), p->key, p->iv);
157
	EVP_DecryptInit (ctx, EVP_bf_cbc (), p->key, p->iv);
150
	if (EVP_DecryptUpdate (&ctx, dst, &olen, src, ulen) != 1)
158
	if (EVP_DecryptUpdate (ctx, dst, &olen, src, ulen) != 1)
151
	{
159
	{
152
		fprintf (stderr,"error in decrypt update\n");
160
		fprintf (stderr,"error in decrypt update\n");
153
		olen = -1;
161
		olen = -1;
154
		goto cleanup;
162
		goto cleanup;
155
	}
163
	}
156
164
157
	if (EVP_DecryptFinal (&ctx, dst + ulen, &tlen) != 1)
165
	if (EVP_DecryptFinal (ctx, dst + ulen, &tlen) != 1)
158
	{
166
	{
159
		fprintf (stderr,"error in decrypt final, ulen = %d, tlen = %d\n", ulen, tlen);
167
		fprintf (stderr,"error in decrypt final, ulen = %d, tlen = %d\n", ulen, tlen);
160
		olen = -1;
168
		olen = -1;
Lines 163-169 int data_decrypt(unsigned char *src, unsigned char *dst, int len, struct peer *p Link Here
163
	olen += tlen;
171
	olen += tlen;
164
172
165
cleanup:
173
cleanup:
166
	EVP_CIPHER_CTX_cleanup(&ctx);	
174
	EVP_CIPHER_CTX_reset (ctx);
167
	return olen;
175
	return olen;
168
}
176
}
169
177
170
- 

Return to bug 673928