JDK-8163417 : Error during hash calculation
  • Type: Bug
  • Component: security-libs
  • Sub-Component: javax.crypto:pkcs11
  • Affected Version: 9
  • Priority: P3
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: solaris_10
  • Submitted: 2016-08-08
  • Updated: 2017-02-01
  • Resolved: 2016-08-10
Related Reports
Relates :  
Description
The attached application works with JDK 8, with JDK 9 latest build the following exception is seen:

Exception in thread "main" java.lang.Error: Error during hash calculation
	at sun.security.ssl.HandshakeHash.getFinishedHash(java.base@9-ea/HandshakeHash.java:358)
	at sun.security.ssl.HandshakeMessage$Finished.getFinished(java.base@9-ea/HandshakeMessage.java:2331)
	at sun.security.ssl.HandshakeMessage$Finished.<init>(java.base@9-ea/HandshakeMessage.java:2278)
	at sun.security.ssl.ClientHandshaker.sendChangeCipherAndFinish(java.base@9-ea/ClientHandshaker.java:1328)
	at sun.security.ssl.ClientHandshaker.serverHelloDone(java.base@9-ea/ClientHandshaker.java:1240)
	at sun.security.ssl.ClientHandshaker.processMessage(java.base@9-ea/ClientHandshaker.java:414)
	at sun.security.ssl.Handshaker.processLoop(java.base@9-ea/Handshaker.java:1061)
	at sun.security.ssl.Handshaker.processRecord(java.base@9-ea/Handshaker.java:995)
	at sun.security.ssl.SSLSocketImpl.processInputRecord(java.base@9-ea/SSLSocketImpl.java:1132)
	at sun.security.ssl.SSLSocketImpl.readRecord(java.base@9-ea/SSLSocketImpl.java:1069)
	at sun.security.ssl.SSLSocketImpl.readRecord(java.base@9-ea/SSLSocketImpl.java:968)
	at sun.security.ssl.SSLSocketImpl.performInitialHandshake(java.base@9-ea/SSLSocketImpl.java:1395)
	at sun.security.ssl.SSLSocketImpl.startHandshake(java.base@9-ea/SSLSocketImpl.java:1422)
	at sun.security.ssl.SSLSocketImpl.startHandshake(java.base@9-ea/SSLSocketImpl.java:1406)
	at sun.net.www.protocol.https.HttpsClient.afterConnect(java.base@9-ea/HttpsClient.java:558)
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(java.base@9-ea/AbstractDelegateHttpsURLConnection.java:185)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(java.base@9-ea/HttpURLConnection.java:1505)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(java.base@9-ea/HttpURLConnection.java:1433)
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(java.base@9-ea/HttpsURLConnectionImpl.java:235)
	at jdk9httpconnection.JDK9httpConnection.main(JDK9httpConnection.java:36)
Caused by: java.lang.RuntimeException: Could not clone digest
	at sun.security.ssl.HandshakeHash.cloneDigest(java.base@9-ea/HandshakeHash.java:303)
	at sun.security.ssl.HandshakeHash.getFinishedHash(java.base@9-ea/HandshakeHash.java:356)
	... 19 more
Caused by: java.lang.CloneNotSupportedException: SHA-256
	at sun.security.pkcs11.P11Digest.clone(jdk.crypto.pkcs11@9-ea/P11Digest.java:316)
	at java.security.MessageDigest$Delegate.clone(java.base@9-ea/MessageDigest.java:573)
	at sun.security.ssl.HandshakeHash.cloneDigest(java.base@9-ea/HandshakeHash.java:300)
	... 20 more
Caused by: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_STATE_UNSAVEABLE
	at sun.security.pkcs11.wrapper.PKCS11.C_GetOperationState(jdk.crypto.pkcs11@9-ea/Native Method)
	at sun.security.pkcs11.P11Digest.clone(jdk.crypto.pkcs11@9-ea/P11Digest.java:311)
	... 22 more
Comments
This is an issue of SHA-256 cloning on Solaris 10 ("PKCS11Exception: CKR_STATE_UNSAVEABLE"). There is an old Solaris bug about not supporting cloning. The issue has been fixed. I cannot reproduce this issue on a Solaris 10 platform. $ uname -a SunOS XXXX 5.10 Generic_150401-14 i86pc i386 i86pc Please upgrade Solaris to the latest patch.
10-08-2016

SHA256 was disabled in JDK 8 because of the Solaris bug. As the Solaris get fixed, SHA256 is enabled in JDK 9. See jre/lib/security/sunpkcs11-solaris.cfg in JDK 8 ----------- # the following mechanisms are disabled due to no cloning support # (Solaris bug 7050617) CKM_SHA256 CKM_SHA384 CKM_SHA512 ----------- Please upgrade Solaris to the latest patch.
10-08-2016