Not quite sure what you are trying to do but here are some excerpts of our routines from an MBean:
X509EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(publicKeyBytes);
KeyFactory keyFactory = KeyFactory.getInstance("RSA", "BC");
publicKey = keyFactory.generatePublic(publicKeySpec);
log.error("The public key is badly formatted.");
So we're using the Bouncy Castle RSA routines for generating the public key - all through the JCE API. The JBoss security policies are fine (java.policy) - we don't touch them.
bcprov-jdk14-118.jar lives in JAVA_HOME/jre/lib/ext.
In JAVA_HOME/jre/lib/security/java.security add the line,
And then the routine works. So we're not doing anything too special or different from the JCE guidelines.
We're just speculating on things here as you'd need to detail further your code for a clear understanding.
Thank you for your response. Let me start by saying that I'm a fairly junior Java programmer (less than a year) and totally inexperiences with JCE, so I'm doing most of my coding by example and fighting my way through stack traces using Google searches and newsgroups. Painful at best.
I brought the code home last night and set everything up and it runs fine. Not sure what's up with the environment at work, but I'm sure I'll figure it out. Sorry to waste your time.