|
From: Moshe S. <mo...@sp...> - 2003-05-26 21:37:36
|
I have written some code which reads a PGP keystore and then tries to
verify that a message was signed by someone in the keystore.
I initialize the class by passing it the name of the keystore file, then
I pass it the text of a supposedly signed message and it checks each
public key in the keystore to see if one of them recognizes the supplied
signature.
When I test this class standalone it works fine.
I've integrated the class into a JSP so that the input can come from a
form which a user fills out. I can't get the JSP to work - I get this
error when I try to read the keystore:
java.lang.RuntimeException: ElGamal algorithm not found.
java.security.NoSuchAlgorithmException: Algorithm ElGamal not available
at cryptix.openpgp.algorithm.PGPElGamal.(PGPElGamal.java:94)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorA
ccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingCons
tructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at java.lang.Class.newInstance0(Class.java:296)
at java.lang.Class.newInstance(Class.java:249)
at
cryptix.openpgp.algorithm.PGPAlgorithmFactory.getPublicKeyAlgorithm(PGPA
lgorithmFactory.java:445)
at
cryptix.openpgp.packet.PGPKeyPacket.decodePublicData(PGPKeyPacket.java:2
28)
at
cryptix.openpgp.packet.PGPPublicSubKeyPacket.decodeBody(PGPPublicSubKeyP
acket.java:92)
at
cryptix.openpgp.packet.PGPPacketFactory.readPacket(PGPPacketFactory.java
:253)
at
cryptix.openpgp.provider.PGPKeyBundleFactory.helper(PGPKeyBundleFactory.
java:84)
at
cryptix.openpgp.provider.PGPKeyRingKeyStore.engineLoad(PGPKeyRingKeyStor
e.java:366)
at java.security.KeyStore.load(KeyStore.java:652)
at mjs.blog.PGPUtils.readKeyStore(PGPUtils.java:90)
at org.apache.jsp.initialize_jsp._jspService(initialize_jsp.java:125)
Here's a relevant snippet of code, from initialize.jsp:
// some debugging information...
java.security.Provider prov[] =
java.security.Security.getProviders();
for (int i=0; i<prov.length; i++) {
out.println("provider #" + i + ": " + prov[i].getName() +
"<br> version: " + prov[i].getVersion() +
"<br> info: " + prov[i].getInfo() + "<p>");
}
PGPUtils pgpUtils = new PGPUtils();
// more debugging information
java.io.File f = new java.io.File("/home/mjs/myKeyStore.pkr");
if (f.exists() && f.canRead()) {
out.println("no problem reading that file.");
} else {
out.println("can't read the key store.");
}
pgpUtils.readKeyStore("/home/mjs/myKeyStore.pkr");
when I comment out the last line so that I can see what's going on I
get:
------------------------------------------------------------------------
------------------
provider #1: SunJSSE
version: 1.4
info: Sun JSSE provider(implements RSA Signatures, PKCS12, SunX509
key/trust factories, SSLv3, TLSv1)
provider #2: SunRsaSign
version: 1.0
info: SUN's provider for RSA signatures
provider #3: SunJCE
version: 1.4
info: SunJCE Provider (implements DES, Triple DES, Blowfish, PBE,
Diffie-Hellman, HMAC-MD5, HMAC-SHA1)
provider #4: SunJGSS
version: 1.0
info: Sun (Kerberos v5)
provider #5: CryptixCrypto
version: 1.3
info: Cryptix JCE Strong Crypto Provider
provider #6: CryptixOpenPGP
version: 0.20030205
info: Cryptix OpenPGP Provider
current working directory is /usr/local/jakarta/jakarta-tomcat-4.1.18/.
no problem reading that file.
------------------------------------------------------------------------
------------------
I have the following JAR files in my application's WEB-INF/lib
directory:
certpath-api-compat.jar
cryptix-jce-api.jar
cryptix-jce-provider.jar
cryptix-message-api.jar
cryptix-openpgp-provider.jar
cryptix-pki-api.jar
Can anyone offer any suggestion as to what I may be doing wrong?
Thanks.
|