SSO の実装では、署名、暗号化、復号化、および署名の検証に bouncycastle (JAVA) を使用しています。生の PGP 公開鍵と秘密鍵があり、それらを Java キーストアに保存する必要があります。これらの PGP 公開鍵には証明書がありません。
公開鍵の場合 (Keystore の javadoc によると: http://docs.oracle.com/javase/6/docs/api/java/security/KeyStore.html )、証明書を作成する必要があることを理解しています。証明書が作成されたら、それを KeyStore.TrustedCertificateEntry としてキーストアにインポートできます。ただし、タイプ org.bouncycastle.openpgp.PGPPublicKey の証明書エントリを作成できません。
Web を検索しましたが、有効な例が見つかりませんでした。
- Bouncycastle のドキュメント: http://www.bouncycastle.org/wiki/display/JA1/X.509+Public+Key+Certificate+and+Certification+Request+Generation X.509 キーの証明書を生成します -
Bouncycastle の例 - org.bouncycastle.openpgp.examples.DirectKeySignature: 証明書 (タイプ PGPSSignature のオブジェクト) を PGPPublicKey に直接追加します。結論として、私は PGPPublicKey に署名 (認定) しましたが、このタイプのキーを Java キーストアに保存することができません。
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();
私は主にプログラム ソリューション (Java ソース コード) に興味がありますが、いくつかのツールを使用した例も役立ちます。
ありがとう!