xipki / pkcs11wrapper

PKCS#11 Wrapper for Java. Deprecated. Please use xipki/ipkcs11wrapper (preferred) or xipki/jpkcs11wrapper instead.
Other
34 stars 13 forks source link

Decrypt with CKM_RSA_PKCS_OAEP mechanism return... Unsupported Parameters #15

Closed armando-basile closed 1 year ago

armando-basile commented 1 year ago

Hi, i trying to use CKM_RSA_PKCS_OAEP to decrypt using an RSA private key. I using this parameters:

Mechanism mech = new Mechanism(PKCS11Constants.CKM_RSA_PKCS_OAEP);

RSAPkcsOaepParameters params = new RSAPkcsOaepParameters(
    PKCS11Constants.CKM_SHA_1, 
    PKCS11Constants.CKG_MGF1_SHA1,
    PKCS11Constants.CKZ_SALT_SPECIFIED, 
    null);

mech.setParameters(params);

but when i try to

session.decryptInit(mech, keyToUse);

i receive always

Unsupported Parameters iaik.pkcs.pkcs11.parameters.RSAPkcsOaepParameters

i tested feature using the same parameters with a .Net PKCS11Interop and it work only using Net.Pkcs11Interop.HighLevelAPI80.MechanismParams.CkRsaPkcsOaepParams

could you help me ?

xipki commented 1 year ago

This exception can be explained by the code https://github.com/xipki/pkcs11wrapper/blob/sunpkcs11/src/java/src/iaik/pkcs/pkcs11/Session.java#L2003. OAEP is not supported yet by the JDK.

xipki commented 1 year ago

BTW, this project is deprecated and will not be supported anymore. To use OAEP, please use https://github.com/xipki/ipkcs11wrapper instead. You may use https://github.com/xipki/ipkcs11wrapper/blob/main/src/test/java/test/pkcs11/wrapper/encryption/RSAOaepDecrypt.java as an example.