Example usage for org.bouncycastle.openpgp PGPSignatureGenerator generateCertification

List of usage examples for org.bouncycastle.openpgp PGPSignatureGenerator generateCertification

Introduction

In this page you can find the example usage for org.bouncycastle.openpgp PGPSignatureGenerator generateCertification.

Prototype

public PGPSignature generateCertification(PGPPublicKey masterKey, PGPPublicKey pubKey) throws PGPException 

Source Link

Document

Generate a certification for the passed in key against the passed in master key.

Usage

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;
}