title: How can I decrypt Blowfish ciphertext with a salted header?
body: <p>I have some ciphertext that has been encrypted using Perl's <a href="http://search.cpan.org/~lds/Crypt-CBC-2.30/CBC.pm" rel="nofollow">Crypt::CBC</a> module that I wish to decrypt elsewhere.</p>
  
  <p>The ciphertext was generated using the 'simple' version of the <code>Crypt::CBC</code> constructor, that is:</p>
  
  <pre><code>use Crypt::CBC;
  $cipher = Crypt::CBC-&gt;new( -key    =&gt; 'my secret key',
                             -cipher =&gt; 'Blowfish'
                            );
  </code></pre>
  
  <p>From reading the MAN page, this method of construction will take the simple string key and random salt to generate an IV &amp; literal key to use for encryption, as well as embed a header with the salt.</p>
  
  <blockquote>
    <p>"salt" -- Combine the passphrase with
    an 8-byte random value to
               generate both the block cipher key and the IV from the
               provided passphrase. The salt will be appended to the
               beginning of the data stream allowing decryption to
               regenerate both the key and IV given the correct passphrase.
               This method is compatible with current versions of OpenSSL.</p>
  </blockquote>
  
  <p>I now need to decrypt the ciphertext on another platform that only supports CBC decryption given the ciphertext, a literal key &amp; IV.  To attempt to generate the literal key, IV &amp; salt, I used Crypt::CBC to generate the values like so:</p>
  
  <pre><code>my $crypt = new Crypt::CBC(-key =&gt; 'my secret key', -cipher =&gt; 'Blowfish');
  my $out = $crypt-&gt;decrypt($ciphertext);
  my $literal_key = $crypt-&gt;key();
  my $iv = $crypt-&gt;iv();
  my $salt = $crypt-&gt;salt();
  </code></pre>
  
  <p>The decryption here is correct, but I've been unable to use the generated literal key &amp; IV to decrypt the cipher; this produces rubbish:</p>
  
  <pre><code>my $crypt2 = new Crypt::CBC(
      -literal_key =&gt; 1,
      -key =&gt; $literal_key,
      -cipher =&gt; 'Blowfish',
      -iv =&gt; $iv,
      -header =&gt; 'none');
  my $rubbish - $crypt2-&gt;decrypt($ciphertext);
  </code></pre>
  
  <p>I can't provide a literal key and use a salted header so I'm lost as to the next move.  </p>
  
  <p>How can I decrypt this text?</p>
  
  <p><strong>EDIT</strong>: The target system is not running Perl, but I have been able to generate the identical value as in $rubbish above, so I'm sure it's using the same algorithm (CBC, Blowfish) to decipher.</p>