fixed 3DES encryption
authorMartin Willi <martin@strongswan.org>
Wed, 7 May 2008 11:54:30 +0000 (11:54 -0000)
committerMartin Willi <martin@strongswan.org>
Wed, 7 May 2008 11:54:30 +0000 (11:54 -0000)
src/libstrongswan/asn1/pem.c
src/libstrongswan/plugins/des/des_crypter.c

index 63b3072..c79e98b 100755 (executable)
@@ -303,7 +303,12 @@ err_t pem_to_bin(chunk_t *blob, chunk_t *passphrase, bool *pgp)
        if (state != PEM_POST)
                return "file coded in unknown format, discarded";
 
-       return (encrypted)? pem_decrypt(blob, alg, key_size, &iv, passphrase) : NULL;
+       if (!encrypted)
+       {
+               return NULL;
+       }
+       return pem_decrypt(blob, alg, key_size, &iv, passphrase);
+       
 }
 
 /* load a coded key or certificate file with autodetection
index 06d4979..17defda 100644 (file)
@@ -1370,6 +1370,7 @@ static void decrypt(private_des_crypter_t *this, chunk_t data, chunk_t iv,
        if (decrypted)
        {
                *decrypted = chunk_alloc(data.len);
+               out = decrypted->ptr;
        }
        memcpy(&ivb, iv.ptr, sizeof(des_cblock));
        des_cbc_encrypt((des_cblock*)(data.ptr), (des_cblock*)out,
@@ -1390,6 +1391,7 @@ static void encrypt(private_des_crypter_t *this, chunk_t data, chunk_t iv,
        if (encrypted)
        {
                *encrypted = chunk_alloc(data.len);
+               out = encrypted->ptr;
        }
        memcpy(&ivb, iv.ptr, sizeof(des_cblock));
        des_cbc_encrypt((des_cblock*)(data.ptr), (des_cblock*)out,
@@ -1409,6 +1411,7 @@ static void decrypt3(private_des_crypter_t *this, chunk_t data, chunk_t iv,
        if (decrypted)
        {
                *decrypted = chunk_alloc(data.len);
+               out = decrypted->ptr;
        }
        memcpy(&ivb, iv.ptr, sizeof(des_cblock));
        des_ede3_cbc_encrypt((des_cblock*)(data.ptr), (des_cblock*)out,
@@ -1429,6 +1432,7 @@ static void encrypt3(private_des_crypter_t *this, chunk_t data, chunk_t iv,
        if (encrypted)
        {
                *encrypted = chunk_alloc(data.len);
+               out = encrypted->ptr;
        }
        memcpy(&ivb, iv.ptr, sizeof(des_cblock));
        des_ede3_cbc_encrypt((des_cblock*)(data.ptr), (des_cblock*)out,