I use JcaContentSignerBuilder to sign a self-signed certificate but I don't know what the default padding is. My requirement is that I must NOT use PKCS#1.5 padding. The code I use is below - can someone tell me what padding this is going to generate?

KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA", "BC");

ContentSigner sigGen = new JcaContentSignerBuilder("SHA256WithRSAEncryption").setProvider("BC").build(keyPair.getPrivate());

X509Certificate certificate = new JcaX509CertificateConverter().setProvider("BC").getCertificate(builder.build(sigGen));

Best regards, Gianpaolo


It seems that SHA256WithRSA "implies the PKCS#1 v1.5 padding algorithm [RFC3447]"

See RFC4051, 2.3.2.

Sources : bouncycastle , crypto.stackexchange

  • Thanks, u r right. Any idea on what algorithms could I use? – Gianpaolo Rossi Oct 29 '15 at 16:17
  • After more research, I found a "SHA256withRSA/PSS", which, as its name says, uses PSS in place of PKCS#1 v1.5. I can't tell you much more about it. Good luck! – zr_ifrit Oct 29 '15 at 16:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.