clone iv before blowfish en|decryption
authorAndreas Steffen <andreas.steffen@strongswan.org>
Thu, 14 May 2009 08:54:39 +0000 (10:54 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Thu, 14 May 2009 11:55:56 +0000 (13:55 +0200)
src/libstrongswan/plugins/blowfish/blowfish_crypter.c

index b70ea22..01e6cf5 100644 (file)
@@ -109,8 +109,11 @@ static void decrypt(private_blowfish_crypter_t *this, chunk_t data, chunk_t iv,
                out = data.ptr;
        }
        in = data.ptr;
+       iv = chunk_clone(iv);
 
-   BF_cbc_encrypt(in, out, data.len, &this->schedule, iv.ptr, 0);
+       BF_cbc_encrypt(in, out, data.len, &this->schedule, iv.ptr, 0);
+
+       free(iv.ptr);
 }
 
 /**
@@ -131,8 +134,11 @@ static void encrypt (private_blowfish_crypter_t *this, chunk_t data, chunk_t iv,
                out = data.ptr;
        }
        in = data.ptr;
+       iv = chunk_clone(iv);
+
+       BF_cbc_encrypt(in, out, data.len, &this->schedule, iv.ptr, 1);
 
-   BF_cbc_encrypt(in, out, data.len, &this->schedule, iv.ptr, 1);
+       free(iv.ptr);
 }
 
 /**