org.bouncycastle.openpgp

Class PGPSignature


public class PGPSignature
extends java.lang.Object

A PGP signature object.

Field Summary

static int
BINARY_DOCUMENT
static int
CANONICAL_TEXT_DOCUMENT
static int
CASUAL_CERTIFICATION
static int
CERTIFICATION_REVOCATION
static int
DEFAULT_CERTIFICATION
static int
DIRECT_KEY
static int
KEY_REVOCATION
static int
NO_CERTIFICATION
static int
POSITIVE_CERTIFICATION
static int
STAND_ALONE
static int
SUBKEY_BINDING
static int
SUBKEY_REVOCATION
static int
TIMESTAMP

Method Summary

void
encode(OutputStream outStream)
Date
getCreationTime()
Return the creation time of the signature.
byte[]
getEncoded()
int
getHashAlgorithm()
Return the hash algorithm associated with this signature.
PGPSignatureSubpacketVector
getHashedSubPackets()
int
getKeyAlgorithm()
Return the key algorithm associated with this signature.
long
getKeyID()
Return the id of the key that created the signature.
byte[]
getSignature()
byte[]
getSignatureTrailer()
int
getSignatureType()
PGPSignatureSubpacketVector
getUnhashedSubPackets()
int
getVersion()
Return the OpenPGP version number for this signature.
void
initVerify(PGPPublicKey pubKey, String provider)
void
update(byte b)
void
update(byte[] bytes)
void
update(byte[] bytes, int off, int length)
boolean
verify()
boolean
verifyCertification(String id, PGPPublicKey key)
Verify the signature as certifying the passed in public key as associated with the passed in id.
boolean
verifyCertification(PGPPublicKey pubKey)
Verify a key certification, such as a revocation, for the passed in key.
boolean
verifyCertification(PGPPublicKey masterKey, PGPPublicKey pubKey)
Verify a certification for the passed in key against the passed in master key.

Field Details

BINARY_DOCUMENT

public static final int BINARY_DOCUMENT
Field Value:
0

CANONICAL_TEXT_DOCUMENT

public static final int CANONICAL_TEXT_DOCUMENT
Field Value:
1

CASUAL_CERTIFICATION

public static final int CASUAL_CERTIFICATION
Field Value:
18

CERTIFICATION_REVOCATION

public static final int CERTIFICATION_REVOCATION
Field Value:
48

DEFAULT_CERTIFICATION

public static final int DEFAULT_CERTIFICATION
Field Value:
16

DIRECT_KEY

public static final int DIRECT_KEY
Field Value:
31

KEY_REVOCATION

public static final int KEY_REVOCATION
Field Value:
32

NO_CERTIFICATION

public static final int NO_CERTIFICATION
Field Value:
17

POSITIVE_CERTIFICATION

public static final int POSITIVE_CERTIFICATION
Field Value:
19

STAND_ALONE

public static final int STAND_ALONE
Field Value:
2

SUBKEY_BINDING

public static final int SUBKEY_BINDING
Field Value:
24

SUBKEY_REVOCATION

public static final int SUBKEY_REVOCATION
Field Value:
40

TIMESTAMP

public static final int TIMESTAMP
Field Value:
64

Method Details

encode

public void encode(OutputStream outStream)
            throws IOException

getCreationTime

public Date getCreationTime()
Return the creation time of the signature.
Returns:
the signature creation time.

getEncoded

public byte[] getEncoded()
            throws IOException

getHashAlgorithm

public int getHashAlgorithm()
Return the hash algorithm associated with this signature.
Returns:
signature hash algorithm.

getHashedSubPackets

public PGPSignatureSubpacketVector getHashedSubPackets()

getKeyAlgorithm

public int getKeyAlgorithm()
Return the key algorithm associated with this signature.
Returns:
signature key algorithm.

getKeyID

public long getKeyID()
Return the id of the key that created the signature.
Returns:
keyID of the signatures corresponding key.

getSignature

public byte[] getSignature()
            throws PGPException

getSignatureTrailer

public byte[] getSignatureTrailer()

getSignatureType

public int getSignatureType()

getUnhashedSubPackets

public PGPSignatureSubpacketVector getUnhashedSubPackets()

getVersion

public int getVersion()
Return the OpenPGP version number for this signature.
Returns:
signature version number.

initVerify

public void initVerify(PGPPublicKey pubKey,
                       String provider)
            throws NoSuchProviderException,
                   PGPException

update

public void update(byte b)
            throws SignatureException

update

public void update(byte[] bytes)
            throws SignatureException

update

public void update(byte[] bytes,
                   int off,
                   int length)
            throws SignatureException

verify

public boolean verify()
            throws PGPException,
                   SignatureException

verifyCertification

public boolean verifyCertification(String id,
                                   PGPPublicKey key)
            throws PGPException,
                   SignatureException
Verify the signature as certifying the passed in public key as associated with the passed in id.
Parameters:
id - id the key was stored under
key - the key to be verified.
Returns:
true if the signature matches, false otherwise.
Throws:
PGPException -

verifyCertification

public boolean verifyCertification(PGPPublicKey pubKey)
            throws SignatureException,
                   PGPException
Verify a key certification, such as a revocation, for the passed in key.
Parameters:
pubKey - the key we are checking.
Returns:
true if the certification is valid, false otherwise.
Throws:
PGPException -

verifyCertification

public boolean verifyCertification(PGPPublicKey masterKey,
                                   PGPPublicKey pubKey)
            throws SignatureException,
                   PGPException
Verify a certification for the passed in key against the passed in master key.
Parameters:
masterKey - the key we are verifying against.
pubKey - the key we are verifying.
Returns:
true if the certification is valid, false otherwise.
Throws:
PGPException -