Is PKCS#1 V2.0 implemented for Java?

2019-03-21 05:08发布

问题:

I need encrypt data using exactly the PKCS#1 V2.0 encryption method (defined in item 7.2.1 of the PKCS#1V2 specification).

Is it already implemented for Java?

I'm thinking in something like just pass a parameter to javax.crypto.Cipher specifying "PKCS#1V2", I wonder if there is something like this?

回答1:

PKCS#1 v2.0 encryption is usually called OAEP encryption. So:

Cipher.getInstance("RSA/ECB/OAEPWithSHA1AndMGF1Padding");

The place to look is the Java Cryptography Architecture documents: Standard Algorithm Name Documentation or Sun Providers Documentation.

As you can see the SunJCE provider supports the following variations of OAEP:

  • OAEPWITHMD5ANDMGF1PADDING
  • OAEPWITHSHA1ANDMGF1PADDING
  • (OAEPWITHSHA-1ANDMGF1PADDING)
  • OAEPWITHSHA-256ANDMGF1PADDING
  • OAEPWITHSHA-384ANDMGF1PADDING
  • OAEPWITHSHA-512ANDMGF1PADDING