Hello Peter, I have an exception thrown using my modified DidiSoft_Examples directory code for Keystore.
Please find attached the modified DidiSoft_Examples directory (DidiSoft_Examples_dmbgroup.tar.gz)
Hopefully, this is adequate.
It may very well be the keystore is corrupted or damaged in some way but I would like to know the underlying cause before going back to our production code with any new changes or purging the existing keystore.
The line #s of interest to run Main.java are:
#22 change the value of args[0] as needed.
#150, 159 are the points of invocation of interest.
The keystore after line #159 is the one that throws the exception (please see posted below).
I'm still not sure about the consequences of an empty keystore though there are no issues with this example.
I cannot recreate here either the issue I see in our enterprise app:
- First our enterprise application executes this line of code: KeyStore ks = new KeyStore("pgp.ks", "nxoCs+2ZX33HOsHoS92k+A==");
- Next executed line is: ks.isInMemory() which then jumps to the attach source page for: ServletWrapper.loadServlet() line 1248 (Google doesn't help).
The following is the output from DidiSoft_Examples:
***************************************************************************************************************************************
***************************************************
*** OpenPGP Library for Java Demonstration
***************************************************
Encrypt file.
Nov 07, 2013 12:27:10 PM com.didisoft.pgp.bc.BaseLib <clinit>
INFO: BouncyCastle security provider was loaded
Decrypt file.
Sign and Encrypt file.
Decrypt and Verify file.
Signature is valid.
Sign and Encrypt file (old OpenPGP format version 3).
Decrypt and Verify file (old OpenPGP format version 3).
Signature is valid.
Sign file.
Verify file.
Signature is valid.
Sign file (old OpenPGP format version 3).
Verify file (old OpenPGP format version 3).
Signature is valid.
Clear sign file.
Verify clear signed file.
File OUTPUT.sig.txt has a valid signature.
Generate Key Pair.
UID: demo2 <
de...@didisoft.com> is trusted: true
Encrypt File with Keystore.
Decrypt File with Keystore.
Sign and Encrypt File with Keystore.
Decrypt and Verify File with Keystore.
Signature is valid.
Keystore is in memory: false
Keystore backup on save: true
Keystore auto save on: true
Keystore partial match id: true
Keystore skip Lucas Lehmer: false
Type Bits Key ID Date User ID
DH/DSS 1024 BD8B1479 2013-11-07 David Brown <
da...@davidwbrown.name>
(Signing key) (Trusted)
RSA 1024 E8B96342 2013-11-07 demo2 <
de...@didisoft.com>
(Encryption Key) (Signing key) (Trusted)
RSA 2048 29EF5D31 2013-11-07 David Brown (RSA test import) <
david...@dmbgroup.com>
(Encryption Key) (Signing key) (Trusted)
Import Private Key.
Import Public Key.
Imported key:
da...@davidwbrown.name is trusted: true
Sign Public Key as Trusted Introducer
Keystore is in memory: false
Keystore backup on save: true
Keystore auto save on: true
Keystore partial match id: true
Keystore skip Lucas Lehmer: false
Type Bits Key ID Date User ID
DH/DSS 1024 BD8B1479 2013-11-07 David Brown <
da...@davidwbrown.name>
(Signing key) (Trusted)
RSA 1024 E8B96342 2013-11-07 demo2 <
de...@didisoft.com>
(Encryption Key) (Signing key) (Trusted)
RSA 512 26BB9370 2010-02-15 Example Key
sup...@didisoft.com (Encryption Key) (Signing key) (Trusted)
RSA 2048 29EF5D31 2013-11-07 David Brown (RSA test import) <
david...@dmbgroup.com>
(Encryption Key) (Signing key) (Trusted)
DH/DSS 1024 F2BE4954 2013-10-03
da...@davidwbrown.name (Signing key) (Not Trusted)
Assign designated revoker and revoke the key
Before change revoker key UID: David Brown <
da...@davidwbrown.name>
Before change revoker key 2 UID: demo2 <
de...@didisoft.com>
Revoker 2 key Trust Level: TRUSTED
Revocation Lib threw an exception: No key found matching keyID: 3269088737648068948
Revoker key UID: dxadmin <
da...@davidwbrown.name> is changed: true
Revoked key UID:
da...@davidwbrown.nameRevoker 2 key UID: demo2 <
de...@didisoft.com> is changed: true
Revocation Lib threw an exception: Target key has no designated revoker signature with fingerprint: 22228e0282ca629e88ff9dbacba8e824bd8b1479
Keystore is in memory: false
Keystore backup on save: true
Keystore auto save on: true
Keystore partial match id: true
Keystore skip Lucas Lehmer: false
Type Bits Key ID Date User ID
DH/DSS 1024 BD8B1479 2013-11-07 dxadmin <
da...@davidwbrown.name>
(Signing key) (Trusted)
RSA 512 26BB9370 2010-02-15 Example Key
sup...@didisoft.com (Encryption Key) (Signing key) (Trusted)
RSA 1024 E8B96342 2013-11-07 dxadmin <
de...@didisoft.com (Encryption Key) (Signing key) (Trusted)
RSA 2048 29EF5D31 2013-11-07 David Brown (RSA test import) <
david...@dmbgroup.com>
(Encryption Key) (Signing key) (Trusted)
DH/DSS 1024 F2BE4954 2013-10-03
da...@davidwbrown.name (Signing key) (Not Trusted)
Delete: keypair, public and private keys...
INPUT.txt Tue Mar 06 12:33:06 CST 2012
INPUT.txt Tue Mar 06 12:33:06 CST 2012
Encrypted with Key ID : 26BB9370
Keystore is in memory: false
Keystore backup on save: true
Keystore auto save on: true
Keystore partial match id: true
Keystore skip Lucas Lehmer: false
Type Bits Key ID Date User ID
Exception in thread "main" com.didisoft.pgp.PGPException: Exception creating cipher : null : null
at com.didisoft.pgp.bc.IOUtil.newPGPException(Unknown Source)
at com.didisoft.pgp.KeyStore.a(Unknown Source)
at com.didisoft.pgp.KeyStore.<init>(Unknown Source)
at KeystoreListKeys.main(KeystoreListKeys.java:21)
at Main.main(Main.java:162)
Caused by: java.lang.NullPointerException
at org.bouncycastle.openpgp.PGPPBEEncryptedData.getDataStream(Unknown Source)
at org.bouncycastle.openpgp.PGPPBEEncryptedData.getDataStream(Unknown Source)
at org.bouncycastle.openpgp.PGPPBEEncryptedData.getDataStream(Unknown Source)
... 4 more
***************************************************************************************************************************************