Note that there are some explanatory texts on larger screens.

plurals
  1. POStore PGP (public) keys in java keystore - Bouncycastle
    primarykey
    data
    text
    <p>I am using bouncycastle (JAVA) for signing, encryption, decryption and signatures' verification in implementation of SSO. I have raw PGP public and private keys and I need to store them in Java keystore. These PGP public keys have no certificate.</p> <p>I understand that for public keys (according to javadoc of Keystore: <a href="http://docs.oracle.com/javase/6/docs/api/java/security/KeyStore.html">http://docs.oracle.com/javase/6/docs/api/java/security/KeyStore.html</a>) I have to create certificate. Once certificate is created I can import it to the keystore as KeyStore.TrustedCertificateEntry. However, I am not able to create certificate entry for type org.bouncycastle.openpgp.PGPPublicKey.</p> <p>I have searched through the web but could not find any valid example:</p> <ol> <li>Bouncycastle documentation: <a href="http://www.bouncycastle.org/wiki/display/JA1/X.509+Public+Key+Certificate+and+Certification+Request+Generation">http://www.bouncycastle.org/wiki/display/JA1/X.509+Public+Key+Certificate+and+Certification+Request+Generation</a> Generates certificate for X.509 keys - </li> <li><p>Bouncycastle examples - org.bouncycastle.openpgp.examples.DirectKeySignature: Add certificat (object of type PGPSignature) directly to the PGPPublicKey. To conclude - I have signed (certified) PGPPublicKey but I am not able to store this type of Key into the java keystore.</p> <pre><code>OutputStream out = new ByteArrayOutputStream(); if (armor) { out = new ArmoredOutputStream(out); } PGPPrivateKey pgpPrivKey = secretKey.extractPrivateKey(secretKeyPass.toCharArray(), "BC"); PGPSignatureGenerator sGen = new PGPSignatureGenerator(secretKey.getPublicKey().getAlgorithm(), PGPUtil.SHA1, "BC"); sGen.initSign(PGPSignature.DIRECT_KEY, pgpPrivKey); BCPGOutputStream bOut = new BCPGOutputStream(out); sGen.generateOnePassVersion(false).encode(bOut); PGPSignatureSubpacketGenerator spGen = new PGPSignatureSubpacketGenerator(); boolean isHumanReadable = true; spGen.setNotationData(true, isHumanReadable, notationName, notationValue); PGPSignatureSubpacketVector packetVector = spGen.generate(); sGen.setHashedSubpackets(packetVector); bOut.flush(); return PGPPublicKey.addCertification(keyToBeSigned, sGen.generate()).getEncoded(); </code></pre></li> </ol> <p>I am mainly interested in programatic solution (java source code) but examples that use some tools will be helpful too.</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload