java.lang.SecurityException: Signature classes have been tampered with

Hi folks,

Playing around with an nCipher HSM on Solaris 9 using Java 1.5 update 11.

- Configured java.security like this:

security.provider.1=com.ncipher.fixup.provider.nCipherRSAPrivateEncrypt

security.provider.2=com.ncipher.provider.km.nCipherKM

security.provider.3=sun.security.pkcs11.SunPKCS11 ${java.home}/lib/security/sunpkcs11-solaris.cfg

security.provider.4=etc.

- We ARE ABLE to use keytool successfully with the nCipher store type (ncipher.sworld), generating keys, CSRs, importing certificates, all works fine

- When we want to decrypt something using the nCipher security provider, we get the following error the first time in a session:

2007-02-16 11:42:46,590 [http-8080-Processor4] ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/CPDM].[PubDepubServlet] - Servlet.service() for servlet PubDepubServlet threw exception

java.lang.ExceptionInInitializerError

at javax.crypto.Cipher.getInstance(DashoA12275)

at javax.crypto.Cipher.getInstance(DashoA12275)

at org.bouncycastle.cms.KeyTransRecipientInformation.getContentStream(Unknown Source)

at org.bouncycastle.cms.RecipientInformation.getContent(Unknown Source)

at com.getronics.cpdm.bridge.components.smime.SMimeProcessorImpl.decryptSMimeEnvelope(SMimeProcessorImpl.java:88)

at com.getronics.cpdm.bridge.BridgeServicesImpl.decryptSMimeEnvelope(BridgeServicesImpl.java:175)

at com.getronics.cpdm.business.components.webhelper.WebHelperImpl.processPubDepubRequest(WebHelperImpl.java:65)

at com.getronics.cpdm.business.BusinessServicesImpl.processPubDepubRequest(BusinessServicesImpl.java:50)

at com.getronics.cpdm.servlets.PubDepubServlet.doPost(PubDepubServlet.java:48)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)

at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)

at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)

at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)

at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)

at java.lang.Thread.run(Unknown Source)

Caused by: java.lang.SecurityException: Cannot set up certs for trusted CAs

at javax.crypto.SunJCE_b.<clinit>(DashoA12275)

... 25 more

Caused by: java.lang.SecurityException: Signature classes have been tampered with

at javax.crypto.SunJCE_b.d(DashoA12275)

at javax.crypto.SunJCE_b.c(DashoA12275)

at javax.crypto.SunJCE_r.run(DashoA12275)

at java.security.AccessController.doPrivileged(Native Method)

... 26 more

- The second time we try in that same session, we get:

2007-02-16 12:50:27,924 [http-8080-Processor3] ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/CPDM].[PubDepubServlet] - Servlet.service() for servlet PubDepubServlet threw exception

java.lang.NoClassDefFoundError

at javax.crypto.Cipher.getInstance(DashoA12275)

at javax.crypto.Cipher.getInstance(DashoA12275)

at org.bouncycastle.cms.KeyTransRecipientInformation.getContentStream(Unknown Source)

at org.bouncycastle.cms.RecipientInformation.getContent(Unknown Source)

at com.getronics.cpdm.bridge.components.smime.SMimeProcessorImpl.decryptSMimeEnvelope(SMimeProcessorImpl.java:88)

at com.getronics.cpdm.bridge.BridgeServicesImpl.decryptSMimeEnvelope(BridgeServicesImpl.java:175)

at com.getronics.cpdm.business.components.webhelper.WebHelperImpl.processPubDepubRequest(WebHelperImpl.java:65)

at com.getronics.cpdm.business.BusinessServicesImpl.processPubDepubRequest(BusinessServicesImpl.java:50)

at com.getronics.cpdm.servlets.PubDepubServlet.doPost(PubDepubServlet.java:48)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)

at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)

at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)

at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)

at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)

at java.lang.Thread.run(Unknown Source)

Is there anyone out there that has seen this error before and knows what it means? The message "Signature classes have been tampered with" seems to be pretty exotic, only two hits on Google, without answers, SunSolve KB doesn't give any answers too.

Hope you can help, thanks a lot!

Cheers,

RVDL

[6544 byte] By [RVDLa] at [2007-11-26 18:48:45]
# 1
Why not invoke your nCipher support contract?
sabre150a at 2007-7-9 6:22:47 > top of Java-index,Security,Cryptography...
# 2

I did that as well, I'm just not totally sure yet if it's nCipher or something else.

Will do some more troubleshooting tomorrow, and hopefully nCipher has an answer tomorrow too.

Apart from that I'm very curious to whether more people came across this problem in other situations (without nCipher).

I just would like to know when this error occurs, what the error message exactly means, etc.

RVDLa at 2007-7-9 6:22:47 > top of Java-index,Security,Cryptography...
# 3
Well, still no solution, not on this forum, not from nCipher, not anywhere on the web.Can perhaps anyone tell me what "Signature classes" are in this context?
RVDLa at 2007-7-9 6:22:47 > top of Java-index,Security,Cryptography...
# 4
We had the same exception on Windows under JDK 1.4.2_13. We were adding nCipherKM provider at position 1. But when we moved nCipherKM to the end of the list, behind the default providers, we did not get this error any more.I hope you will post back your results.
rkollua at 2007-7-9 6:22:47 > top of Java-index,Security,Cryptography...
# 5
Thanks for the tip rkollu, I will try first thing in the morning and let you know!
RVDLa at 2007-7-9 6:22:47 > top of Java-index,Security,Cryptography...
# 6
By the way, rkollu, you DID select the nCipher security provider in your Java application, right? Otherwise it would just use the Sun security provider.(just checking ;-)
RVDLa at 2007-7-9 6:22:47 > top of Java-index,Security,Cryptography...
# 7

We can use this simple code to reproduce the error, while the nCipher Security Provider is the default of course (on top of the list means it's default):

import java.util.*;

public class CipherTest {

public static void main(String[] args) throws Exception {

System.out.println(new TreeMap(System.getProperties()));

System.out.println();

System.out.println(Arrays.asList(java.security.Security.getProviders()));

System.out.println();

System.out.println(Class.forName("javax.crypto.Cipher"));

System.out.println();

System.out.println(javax.crypto.Cipher.getInstance("RSA/ECB/PKCS1Padding"));

System.out.println("Test OK");

}

}

RVDLa at 2007-7-9 6:22:47 > top of Java-index,Security,Cryptography...
# 8
Rkollu, you're our hero, thanks a lot, it works !10 Duke Stars for you my friend ! ;-)
RVDLa at 2007-7-9 6:22:47 > top of Java-index,Security,Cryptography...
# 9

Good it worked for you too!

Actually we had to make this change (adding the ncipher at the end) only if we are using the FIPS compliant ncipher hardware. i.e, if the ncihpher is not FIPS compliant, the app will work even if the ncipher provider is first in list.

I thought I would just share this!

rkollua at 2007-7-9 6:22:47 > top of Java-index,Security,Cryptography...
# 10
Yep, we're using strictFIPS, introducing all kinds of other problems, nCipher warns to only use this when you REALLY REALLY REALLY need to, and we do ;-)
RVDLa at 2007-7-9 6:22:47 > top of Java-index,Security,Cryptography...