List of usage examples for org.bouncycastle.openpgp PGPSignatureGenerator generateCertification
public PGPSignature generateCertification(PGPPublicKey masterKey, PGPPublicKey pubKey) throws PGPException
From source file:ubicrypt.core.crypto.PGPEC.java
License:Open Source License
public static PGPPublicKey signPK(final PGPPublicKey pk, final PGPPrivateKey priv) { final PGPSignatureGenerator sGen = new PGPSignatureGenerator( new JcaPGPContentSignerBuilder(PGPPublicKey.ECDSA, PGPUtil.SHA256).setProvider("BC")); try {// w ww . ja v a2 s .c o m sGen.init(PGPSignature.DIRECT_KEY, priv); } catch (final PGPException e) { Throwables.propagate(e); } final PGPSignatureSubpacketGenerator spGen = new PGPSignatureSubpacketGenerator(); final PGPSignatureSubpacketVector packetVector = spGen.generate(); sGen.setHashedSubpackets(packetVector); try { return PGPPublicKey.addCertification(pk, sGen.generateCertification("id", pk)); } catch (final PGPException e) { Throwables.propagate(e); } return null; }