/lib/jvm/jdk-17.0.2/bin/java -Dpin=**** -Dkey.name=admin -Dkeystore.password=**** -javaagent:/home/ilya/idea-IC-231.8770.65/lib/idea_rt.jar=45183:/home/ilya/idea-IC-231.8770.65/bin -Dfile.encoding=UTF-8 -classpath /home/ilya/IdeaProjects/TestPkcs11/out/production/classes testPkcs11.TestPkcs11
WARNING: Getting tokens from fapi backend failed.
plainText.len=59 encryptedText.len=64
ERROR: Internal buffer too small extralen=48
ERROR: Nonsensical pad value, got: 0, expected 1-16
Exception in thread "main" java.security.ProviderException: update() failed
at jdk.crypto.cryptoki/sun.security.pkcs11.P11Cipher.implUpdate(P11Cipher.java:668)
at jdk.crypto.cryptoki/sun.security.pkcs11.P11Cipher.engineUpdate(P11Cipher.java:553)
at jdk.crypto.cryptoki/sun.security.pkcs11.P11Cipher.engineDoFinal(P11Cipher.java:582)
at jdk.crypto.cryptoki/sun.security.pkcs11.P11Cipher.engineDoFinal(P11Cipher.java:568)
at java.base/javax.crypto.Cipher.doFinal(Cipher.java:2205)
at testPkcs11.TestPkcs11.test(TestPkcs11.java:53)
at testPkcs11.TestPkcs11.main(TestPkcs11.java:67)
Caused by: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_GENERAL_ERROR
at jdk.crypto.cryptoki/sun.security.pkcs11.wrapper.PKCS11.C_DecryptUpdate(Native Method)
at jdk.crypto.cryptoki/sun.security.pkcs11.P11Cipher.implUpdate(P11Cipher.java:648)
... 6 more
Process finished with exit code 1
It seems to me there are error in tpm.c code function do_buffered_encdec in this part:
...
Hello! Trying to use this module for java:
package testPkcs11;
import javax.crypto.; import javax.crypto.spec.IvParameterSpec; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardOpenOption; import java.security.; import java.security.cert.CertificateException;
public class TestPkcs11 {
}
and received error:
/lib/jvm/jdk-17.0.2/bin/java -Dpin=**** -Dkey.name=admin -Dkeystore.password=**** -javaagent:/home/ilya/idea-IC-231.8770.65/lib/idea_rt.jar=45183:/home/ilya/idea-IC-231.8770.65/bin -Dfile.encoding=UTF-8 -classpath /home/ilya/IdeaProjects/TestPkcs11/out/production/classes testPkcs11.TestPkcs11 WARNING: Getting tokens from fapi backend failed. plainText.len=59 encryptedText.len=64 ERROR: Internal buffer too small extralen=48 ERROR: Nonsensical pad value, got: 0, expected 1-16 Exception in thread "main" java.security.ProviderException: update() failed at jdk.crypto.cryptoki/sun.security.pkcs11.P11Cipher.implUpdate(P11Cipher.java:668) at jdk.crypto.cryptoki/sun.security.pkcs11.P11Cipher.engineUpdate(P11Cipher.java:553) at jdk.crypto.cryptoki/sun.security.pkcs11.P11Cipher.engineDoFinal(P11Cipher.java:582) at jdk.crypto.cryptoki/sun.security.pkcs11.P11Cipher.engineDoFinal(P11Cipher.java:568) at java.base/javax.crypto.Cipher.doFinal(Cipher.java:2205) at testPkcs11.TestPkcs11.test(TestPkcs11.java:53) at testPkcs11.TestPkcs11.main(TestPkcs11.java:67) Caused by: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_GENERAL_ERROR at jdk.crypto.cryptoki/sun.security.pkcs11.wrapper.PKCS11.C_DecryptUpdate(Native Method) at jdk.crypto.cryptoki/sun.security.pkcs11.P11Cipher.implUpdate(P11Cipher.java:648) ... 6 more
Process finished with exit code 1
It seems to me there are error in tpm.c code function do_buffered_encdec in this part: ...
...
If I change string
to
it works.