Giulio Rizzo
2014-08-07 13:32:59 UTC
Dear all,
I need to implement Edifact DigitalSign with one of our partner, so I
choose to go with Bouncy Castle with bcprov-jdk15on-147.jar.
Making more research I found that maybe I should use
on how to do with ISO9796d2PSSSigner.
If someone have an example on how to sign, you are more then welcome to
point me to it.
Thank you.
Best regards.
Giulio Rizzo
I need to implement Edifact DigitalSign with one of our partner, so I
choose to go with Bouncy Castle with bcprov-jdk15on-147.jar.
Algorithm=RSA
hash=SHA1
padding=ISO 9796-2 (scheme 2)
Following some examples I found on internet, I make the following simplehash=SHA1
padding=ISO 9796-2 (scheme 2)
import java.security.Signature;
import java.security.KeyPair;
Signature signer = signature.getInstance("SHA1WithRSA/ISO9796-2", "BC");
File plainTextFile = new File(plainTextFilePath);
FileInputStream plainTextFileFIN = plainTextFileFIN = new
FileInputStream(plainTextFile);
byte[] stringToSignDataBytes =
plainTextFileFIN.read(stringToSignDataBytes);
signer.initSign(keyPair.getPrivate());
signer.update(stringToSignDataBytes);
byte[] digitalSignature = digitalSignature = signer.sign();
But our partner is claiming that the sign is not correct.import java.security.KeyPair;
Signature signer = signature.getInstance("SHA1WithRSA/ISO9796-2", "BC");
File plainTextFile = new File(plainTextFilePath);
FileInputStream plainTextFileFIN = plainTextFileFIN = new
FileInputStream(plainTextFile);
byte[] stringToSignDataBytes =
plainTextFileFIN.read(stringToSignDataBytes);
signer.initSign(keyPair.getPrivate());
signer.update(stringToSignDataBytes);
byte[] digitalSignature = digitalSignature = signer.sign();
Making more research I found that maybe I should use
org.bouncycastle.crypto.signers.ISO9796d2PSSSigner
but as I don't found any example on this I would like to know ifSignature signer = signature.getInstance("SHA1WithRSA/ISO9796-2", "BC");
gives a ISO 9796-2 (scheme 2) sign or only a ISO 9796-2 before checkingon how to do with ISO9796d2PSSSigner.
If someone have an example on how to sign, you are more then welcome to
point me to it.
Thank you.
Best regards.
Giulio Rizzo