1

I sign the Message using Java IBMFIPS compliant.
The code to sign the message is:

//Signs the hash of each chunk and adds it to the Message Header
//data is 256Kb length  
//Get private key function is created by me to read the DER key formated file
GetPrivateKey privkey = new GetPrivateKey();   
Signature genSign = Signature.getInstance("SHA1withRSA","IBMJCEFIPS");
genSign.initSign(privkey.get());
genSign.update(data.getBytes());
byte[] byteSignedData = genSign.sign();

Get Private Key function code

File privateKeyFile = new File("Certificates" + File.separator+"mykey.der");
byte[] encodedKey = new byte[(int)privateKeyFile.length()];
new FileInputStream(privateKeyFile).read(encodedKey);
PKCS8EncodedKeySpec privateKeySpec = new PKCS8EncodedKeySpec(encodedKey);
KeyFactory kf = KeyFactory.getInstance("RSA","IBMJCEFIPS");
RSAPrivateCrtKey privatekey = (RSAPrivateCrtKey).generatePrivate(privateKeySpec);
return privatekey;

I am verifying this signature using openssl 0.9.8g, RSA_Verify() function.

I got the Error as:

RSA_verify_PKCS1 failed with error
error:04077064:rsa routines:RSA_verify:algorithm mismatch

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
Balamurugan
  • 2,259
  • 8
  • 33
  • 48

0 Answers0