Hi Jo,

Thanks again for all your input and continued assistance.

That's interesting about the padding as I note the following from the docs:

use_pkcs1_oaep_padding Use EME-OAEP padding as defined in PKCS #1 v2.0 with SHA-1, MGF1 a +nd an empty encoding parameter. This mode of padding is recommended f +or all new applications. It is the default mode used by Crypt::OpenSS +L::RSA.

I tried adding the padding option, as you suggested and was able to encrypt and decrypt text.

Perhaps something that I should have done earlier was to dig out the hex editor and see if the data that I was reading from the file was really what I was reading from the file. As it turned out, I wasn't quite on the mark and so wasn't reading the correct data, which meant that sometimes it was > modulus. After correcting the read(), the blocks all decrypted and the data looked as expected, the second block containing lots of 0x00 padding. The blocks contain a 56 byte blowfish key, which I had believe was 40 bytes in the first block and the remaining 16 bytes in the second block, padded out with zeros. I too had wondered how to fit the data into the first block if it needs to be less than the modulus. As it turns out the answer was rather obvious. There's 39 bytes of the key in the first block, with a leading 0x00 pad and the remaining 17 in the second block with lots of 0x00 padding.

Thanks again for your assistance with this, it's been eating far too much of my time recently!

BOfH

In reply to Re^2: Importing keys into Crypt::Openssl::RSA by BOfH
in thread Importing keys into Crypt::Openssl::RSA by BOfH

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.