Example usage for org.bouncycastle.openpgp PGPSignature verifyCertification

List of usage examples for org.bouncycastle.openpgp PGPSignature verifyCertification

Introduction

In this page you can find the example usage for org.bouncycastle.openpgp PGPSignature verifyCertification.

Prototype

public boolean verifyCertification(PGPPublicKey pubKey) throws PGPException 

Source Link

Document

Verify a key certification, such as a revocation, for the passed in key.

Usage

From source file:com.google.e2e.bcdriver.KeyChecker.java

License:Apache License

private static final boolean isGoodDirectSignature(PGPSignature sig, PGPPublicKey signer, PGPPublicKey target,
        StringBuilder errors) throws PGPException, SignatureException, IOException {

    sig.init(new BcPGPContentVerifierBuilderProvider(), signer);

    boolean ok;/* w  w w  .  j  a  v a2s .c o m*/

    // There's a bug that prevents sig.verifyCertification(signer)
    // working for DIRECT_KEY signatures.
    //
    // So, re-implement the code again here.
    if (sig.getSignatureType() == PGPSignature.DIRECT_KEY) {
        byte[] bytes = target.getPublicKeyPacket().getEncodedContents();
        sig.update((byte) 0x99);
        sig.update((byte) (bytes.length >> 8));
        sig.update((byte) (bytes.length));
        sig.update(bytes);
        ok = sig.verify();
    } else {
        ok = sig.verifyCertification(target);
    }

    // If we have a good signature, also ensure the signature
    // hasn't expired.
    return ok && isSignatureCurrent(sig, errors);
}

From source file:org.kontalk.xmppserver.pgp.PGPUtils.java

License:Open Source License

private static boolean verifyKeySignature(PGPPublicKey publicKey, PGPSignature sig) throws PGPException {
    sig.init(new BcPGPContentVerifierBuilderProvider(), publicKey);
    return sig.verifyCertification(publicKey);
}