views:

222

answers:

1

I have a message coming from an external company which has been encrypted with our public key using Java.

Specifically the java code performing the encryption is -

  //get instance of cipher using BouncyCastle cryptography provider 
  Cipher cipher = Cipher.getInstance( "RSA/ECB/PKCS1Padding", "BC"); 

  //initialize the cipher with the public key pulled from the X509 certificate 
  cipher.init(Cipher.ENCRYPT_MODE, publicKey);

I need to be able to decrypt this message using our private key using C/C++ on Solaris. I have tried using the Crypto++ library and can successfully encode decode messages just using Crypto++, but am unable to work out how to decode the message encrypted from the java side.

Specifically I tried using a RSAES_PKCS1v15_Decryptor but this does not seem to work.

Does anyone have any suggestions as to how I can perform the decryption such as

  1. The required Crypto++ code (ideal)
  2. Alternatives to RSA/ECB/PKCS1Padding to use from the Java side
  3. Alternative open source C libraries I could try
  4. Anything else...
+1  A: 

I managed to get this working by changing the java code to use

Cipher cipher = Cipher.getInstance( "RSA/NONE/PKCS1Padding", "BC");

This then matches up with RSAES_PKCS1v15_Decryptor on the Crypto++ side.

Paul Dolphin