Revision: 557
          http://vde.svn.sourceforge.net/vde/?rev=557&view=rev
Author:   danielel
Date:     2013-03-07 20:55:56 +0000 (Thu, 07 Mar 2013)
Log Message:
-----------
Fixed encryption/decryption lenght
Closed SourceForge #3603904

Modified Paths:
--------------
    trunk/vde-2/src/vde_cryptcab/cryptcab.c

Modified: trunk/vde-2/src/vde_cryptcab/cryptcab.c
===================================================================
--- trunk/vde-2/src/vde_cryptcab/cryptcab.c     2013-03-07 20:18:59 UTC (rev 
556)
+++ trunk/vde-2/src/vde_cryptcab/cryptcab.c     2013-03-07 20:55:56 UTC (rev 
557)
@@ -95,7 +95,9 @@
 
 int data_encrypt(unsigned char *src, unsigned char *dst, int len, struct peer 
*p)
 {
-       int tlen, olen;
+       int tlen, olen, ulen;
+
+  ulen = len - (len % 8);
        
        if (encryption_disabled){
                memcpy(dst,src,len);
@@ -115,7 +117,7 @@
                goto cleanup;
        }
 
-       if (EVP_EncryptFinal (&ctx, dst + olen, &tlen) != 1)
+       if (EVP_EncryptFinal (&ctx, dst + ulen, &tlen) != 1)
        {
                fprintf (stderr,"error in encrypt final\n");
                olen = -1;
@@ -130,8 +132,10 @@
 
 int data_decrypt(unsigned char *src, unsigned char *dst, int len, struct peer 
*p)
 {
-       int tlen, olen;
+       int tlen, olen, ulen;
 
+  ulen = len - (len % 8);
+
        if (encryption_disabled){
                memcpy(dst,src,len);
                return len;
@@ -143,16 +147,16 @@
        }
 
        EVP_DecryptInit (&ctx, EVP_bf_cbc (), p->key, p->iv);
-       if (EVP_DecryptUpdate (&ctx, dst, &olen, src, len) != 1)
+       if (EVP_DecryptUpdate (&ctx, dst, &olen, src, ulen) != 1)
        {
                fprintf (stderr,"error in decrypt update\n");
                olen = -1;
                goto cleanup;
        }
 
-       if (EVP_DecryptFinal (&ctx, dst + olen, &tlen) != 1)
+       if (EVP_DecryptFinal (&ctx, dst + ulen, &tlen) != 1)
        {
-               fprintf (stderr,"error in decrypt final\n");
+               fprintf (stderr,"error in decrypt final, ulen = %d, tlen = 
%d\n", ulen, tlen);
                olen = -1;
                goto cleanup;
        }
@@ -193,6 +197,13 @@
        int olen;
        struct sockaddr_in *destination=&(p->in_a);
        unsigned char *crc;
+
+  if (len + 8 - 1 > MAXPKT) {
+    len = MAXPKT - 8 + 1;
+         vc_printlog(2,"Warning: Cropping down packet size to %d", len);
+  }
+
+
        if (encryption_disabled || (flags==CMD_CHALLENGE || flags==CMD_LOGIN || 
flags==CMD_DENY || flags==CMD_AUTH_OK || flags == CMD_KEEPALIVE)){
                memcpy(outbuf,data,len);
                olen=len;

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
vde-users mailing list
vde-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vde-users

Reply via email to