Example usage for org.bouncycastle.openpgp PGPSignatureSubpacketGenerator setRevocationReason

List of usage examples for org.bouncycastle.openpgp PGPSignatureSubpacketGenerator setRevocationReason

Introduction

In this page you can find the example usage for org.bouncycastle.openpgp PGPSignatureSubpacketGenerator setRevocationReason.

Prototype

public void setRevocationReason(boolean isCritical, byte reason, String description) 

Source Link

Document

Sets revocation reason sub packet

Usage

From source file:org.sufficientlysecure.keychain.pgp.PgpKeyOperation.java

License:Open Source License

private static PGPSignature generateRevocationSignature(PGPSignatureGenerator sGen, Date creationTime,
        PGPPrivateKey masterPrivateKey, PGPPublicKey pKey, String userId)

        throws IOException, PGPException, SignatureException {
    PGPSignatureSubpacketGenerator subHashedPacketsGen = new PGPSignatureSubpacketGenerator();
    // we use the tag NO_REASON since gnupg does not care about the tag while verifying
    // signatures with a revoked key, the warning is the same
    subHashedPacketsGen.setRevocationReason(true, RevocationReasonTags.NO_REASON, "");
    subHashedPacketsGen.setSignatureCreationTime(true, creationTime);
    sGen.setHashedSubpackets(subHashedPacketsGen.generate());
    sGen.init(PGPSignature.CERTIFICATION_REVOCATION, masterPrivateKey);
    return sGen.generateCertification(userId, pKey);
}

From source file:org.sufficientlysecure.keychain.pgp.PgpKeyOperation.java

License:Open Source License

private static PGPSignature generateRevocationSignature(PGPSignatureGenerator sGen, Date creationTime,
        PGPPublicKey masterPublicKey, PGPPrivateKey masterPrivateKey, PGPPublicKey pKey)
        throws IOException, PGPException, SignatureException {

    PGPSignatureSubpacketGenerator subHashedPacketsGen = new PGPSignatureSubpacketGenerator();
    // we use the tag NO_REASON since gnupg does not care about the tag while verifying
    // signatures with a revoked key, the warning is the same
    subHashedPacketsGen.setRevocationReason(true, RevocationReasonTags.NO_REASON, "");
    subHashedPacketsGen.setSignatureCreationTime(true, creationTime);
    sGen.setHashedSubpackets(subHashedPacketsGen.generate());
    // Generate key revocation or subkey revocation, depending on master/subkey-ness
    if (masterPublicKey.getKeyID() == pKey.getKeyID()) {
        sGen.init(PGPSignature.KEY_REVOCATION, masterPrivateKey);
        return sGen.generateCertification(masterPublicKey);
    } else {//from   w ww .java  2 s .  c om
        sGen.init(PGPSignature.SUBKEY_REVOCATION, masterPrivateKey);
        return sGen.generateCertification(masterPublicKey, pKey);
    }
}