in reply to Crypt::CBC, Blowfish and Salt problem

Please tell me that's not your real encryption key!

But to answer your question, you need to add an option to tell Crypt::CBC to use the old-style header, setting "randomiv" for the "-header" option. From the Crypt::CBC docs describing values for the "-header" option:

 
"randomiv" -- Generate the block cipher key from the passphrase, and
           choose a random 8-byte value to use as the IV. The IV will
           be prepended to the data stream. This method is compatible
           with ciphertext produced by versions of the library prior to
           2.17, but is incompatible with block ciphers that have non
           8-byte block sizes, such as Rijndael. Crypt::CBC will exit
           with a fatal error if you try to use this header mode with a
           non 8-byte cipher.

-sam

  • Comment on Re: Crypt::CBC, Blowfish and Salt problem

Replies are listed 'Best First'.
Re^2: Crypt::CBC, Blowfish and Salt problem
by Anonymous Monk on Feb 18, 2008 at 22:40 UTC
    Ok, I added that but was told by the system that salt was incompatible with randomiv, so I removed the salt entry and get this message now:

    "Ciphertext does not begin with a valid header for 'randomiv' header mode"

    Here is my new code at the bottom of the subroutine:
    my $cipher = Crypt::CBC->new( -key => $key, -cipher => 'Blowfish', -header => 'randomiv' );
    Any other ideas?

    Richard
    PS> Thank you for your assistance... and No those are not my real keys, I put some testing ones in... Mine are like 250 bytes long or so.
      Huh. Maybe you've got a mix of 'salt' and 'randomiv' data? Your encrypt routine has presumably been working since the change - only decryption has been bombing. You might try wrapping the first try in an eval - if it fails, try again with the alternate option.

      -sam