aws/aws-encryption-sdk-c

Unable to read a RSA public key by using libcrypto.so c library

Closed this issue · 1 comments

It's not the SDK issue, but I need help from you. AWS Support forwarded me to Github as they don't know the answer. If I'm opening this issue in the wrong repo, please forward me to the correct one.

We are trying to add FIPS support to our project. We downloaded the libcrypto.so from AL2 and working on using this library through JNA (Java Native Access). There is no documentation for this library, but we got a recommendation to use OpenSSL documentation for reference. We have already implemented the AES algorithm, but I'm facing an issue with RSA. Actually, I'm not able to read the key. I tried different scenarios like:

  1. use the key with line separators and the header and the footer
  2. remove the header, the footer, and the line separators
  3. remove the header, the footer, and line separators. Then decode the key by using base64 (also tried to leave the last byte as null)
    but every time I get error:0906D06C:PEM routines:PEM_read_bio:no start line. I used BIO_new_mem_buf - to create a buffer of the key and PEM_read_bio_RSA_PUBKEY.

the public key that I'm using for testing is:

-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzVXfu7H9d+vjpakELoTt
l3vH5+cvD2V5+inVoq7pWtqqItEt4mkUUUdow1iBYGhTFUGfX0VuqHWsEr1adWCj
stVOQaNuBOduC7CqMbrzHQDrkQKT3XRJjapZQN5f5juap/adftOVMk444eQF+sa+
IpUaFQJypC+ECtaYSyk3MjjUc9sUQQ06qFTkogpdZ9UC7mRUMJrDCGNgxk0oguxI
fWtC3P/ny9OZD0QLTozY7xmuBfcg5dDTAU11ebXduvmQDm6I42UrhU/XgGXQkiLh
doe39c1O6iqr5Sgch97fkVjrq88aP2oBWLU2VkScx+eNjWoxeZV83L2iT8xHql5j
HwIDAQAB
-----END PUBLIC KEY-----

I would appreciate any helpful information on this or an example of using the RSA algorithm for encryption and decryption.

Hi,

We do not own the libcrypto so might not be of much help there. But we do have an example of how to use RSA here. If the issue still persists and you need help with libcrypto, please reach out to Aws-Lc team, who are the right owners of libcrypto.