Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Other Java > BOOK: Beginning Cryptography with Java
|
BOOK: Beginning Cryptography with Java
This is the forum to discuss the Wrox book Beginning Cryptography with Java by David Hook; ISBN: 9780764596339
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Cryptography with Java section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 20th, 2011, 09:38 PM
Registered User
 
Join Date: Dec 2011
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Smile Problem of running JCEKSStoreEntryExample.java

Hi David,

When I run the program JCEKSStoreEntryExample.java, I get the exception at
the line
"SecretKey secret = Utils.createKeyForAES(256, new SecureRandom());"

This is the excpetion:

at javax.crypto.KeyGenerator.getInstance(KeyGenerator .java:249)
at Utils.createKeyForAES
at JCEKStoreEntryExample.createKeyStore(JCEKSStoreEnt ryEXample.java.38)

I think the exception is thrown when "KeyGenerator generator = KeyGenerator.getInstance("AES", "BC")" is called.

How can I solve this problem?

Merry Christmas

Jacky
 
Old December 20th, 2011, 09:49 PM
dgh dgh is offline
Wrox Author
 
Join Date: Aug 2005
Posts: 206
Thanks: 0
Thanked 20 Times in 20 Posts
Default

The stack trace is incomplete so it's a little hard to say for sure, but it sounds like the BC provider is not installed in the JRE/JDK being used.

Regards,

David
 
Old December 20th, 2011, 10:18 PM
Registered User
 
Join Date: Dec 2011
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Question Complete Stack Trace

Hi David,

thanks for the quick reply. I think that the BC provider is installed in the JRE/JDK being used since this example need call generateRSAKeyPair(), which require BC provider. after I comment out the line "SecretKey secret = Utils.createKeyForAES(256, new SecureRandom());", the program can run properly.


In order for you to diagnose the problem, this is the complete stack track:

Exception in thread "main" java.lang.ExceptionInInitializerError
at javax.crypto.KeyGenerator.getInstance(KeyGenerator .java:249)
at Utils.createKeyForAES(Utils.java:45)
at JCEKSStoreEntryExample.createKyStore(JCEKStoreEntr yExample.java:38)
at JCEKSStoreEntryExample.createKyStore(JCEKStoreEntr yExample.java:52) caused by:java.lang.SecurityException: Can not initialize cryptographic mechanism
at javax.crptyo.JceSecurity.<clinit>(JceSecurity.java :86)... 4 more caused by java.lang.SecurityException: the jurisdiction policy files are not signed by a trusted signer!
at javax.crypto.JarVerifier.verifyPolicySigned(JarVer ifier.java:289)
at javax.crypto.JceSecurity.loadPolicies(JceSecurity. java:316)
at javax.crypto.JceSecurity.setupJurisdictionPolicies (JceSecurity.java:61)
at javax.crypto.JceSecruity.access$000(JceSecurity.ja va:48)
at javax.crypto.JceSecurity$1.run(JceSecurity.java:78 )
at java.security.AccessController.doPrivileged(Native Method)
at javax.crypto.JceSecurity.<clinit>(JceSecurity.java :76)
.. 4 more


Thanks again

Jack
 
Old December 20th, 2011, 10:26 PM
dgh dgh is offline
Wrox Author
 
Join Date: Aug 2005
Posts: 206
Thanks: 0
Thanked 20 Times in 20 Posts
Default

Exception gives the key - the JCE policy files are either for the wrong JVM or are not installed correctly.

Regards,

David





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem while running EJB Q4Java EJB 2 June 12th, 2011 11:42 AM
Java DB "Derby" is not running !! anammari Java Databases 0 March 15th, 2007 06:37 AM
Problem running a JSP arzamendip Pro JSP 0 September 11th, 2006 03:48 PM
Problem running Struts Eldo Zacharia Apache Tomcat 1 November 15th, 2004 11:50 PM
Php running problem Yee PHP How-To 5 October 26th, 2004 08:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.