tags:

views:

325

answers:

1

I have files which have either been encrypted with a public key and the Blowfish algorithm, or a public key and the AES-256 algorithm.

I'm looking to put together a Perl script that would be able to use the private keys (which I do have) to decrypt the files.

The public and private key files are all in PEM format, and while I can find ways of reading the PEM files, and ways of decrypting data with a key, I haven't yet found a way of going from PEM -> key.

Any suggestions?

A: 

Isn't PEM just a base64 encoding (wrapped in --- BEGIN/END CERTIFICATE --- lines)? Try the Mime::Base64 module, or have a look at the source to the Convert::PEM module.

mobrule
It does seem to be a Base64 encoding, and Convert::PEM is doing a decode_base64.If I try to use the decoded value though with Crypt::OpenSSL::AES, I'm getting "The key must be 128, 192 or 256 bits long". I guess my key is longer than that...So I need do something else to it... but I'm not currently just whether it's just a case of taking the first 256(?) bits or not.
Phil Cole