Top Description Fields Constructors Methods
org.bouncycastle.openpgp

public Class PGPSignature

extends Object
Class Inheritance
Imports
java.io.ByteArrayOutputStream, .IOException, .OutputStream, java.util.ArrayList, .Date, .List, org.bouncycastle.asn1.ASN1EncodableVector, .ASN1Integer, .DERSequence, org.bouncycastle.bcpg.BCPGInputStream, .BCPGOutputStream, .MPInteger, .Packet, .PublicKeyAlgorithmTags, .SignaturePacket, .SignatureSubpacket, .TrustPacket, .UserAttributeSubpacket, org.bouncycastle.openpgp.operator.PGPContentVerifier, .PGPContentVerifierBuilder, .PGPContentVerifierBuilderProvider, org.bouncycastle.util.Arrays, .BigIntegers, .Strings

A PGP signature object.

Field Summary

Modifier and TypeField and Description
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
private byte
public static final int
public static final int
public static final int
private int
private OutputStream
private SignaturePacket
public static final int
public static final int
public static final int
public static final int
public static final int
private TrustPacket
private PGPContentVerifier

Constructor Summary

AccessConstructor and Description
public
pack-priv
pack-priv
PGPSignature(SignaturePacket sigPacket, TrustPacket trustPacket)

Method Summary

Modifier and TypeMethod and Description
private void
private void
blockUpdate(byte[] block, int off, int len)

private void
byteUpdate(byte b)

private static SignaturePacket
cast(Packet packet)

private PGPSignatureSubpacketVector
public void
encode(OutputStream outStream)

public void
encode(OutputStream
stream to write the key encoding to.
outStream
,
boolean
if the purpose of encoding is to send key to other users.
forTransfer
)

Encode the signature to outStream, with trust packets stripped out if forTransfer is true.

public Date

Returns:

the signature creation time.
getCreationTime
()

Return the creation time of the signature.

public byte[]

Returns:

digest prefix
getDigestPrefix
()

Return the digest prefix of the signature.

public byte[]
public byte[]

Returns:

a encoded byte array representing the key.
getEncoded
(boolean
if the purpose of encoding is to send key to other users.
forTransfer
)

Return an encoding of the signature, with trust packets stripped out if forTransfer is true.

private byte[]
public int

Returns:

signature hash algorithm.
getHashAlgorithm
()

Return the hash algorithm associated with this signature.

public PGPSignatureSubpacketVector
public int

Returns:

signature key algorithm.
getKeyAlgorithm
()

Return the key algorithm associated with this signature.

public long

Returns:

keyID of the signatures corresponding key.
getKeyID
()

Return the id of the key that created the signature.

public byte[]
public byte[]
public int
public PGPSignatureSubpacketVector
public int

Returns:

signature version number.
getVersion
()

Return the OpenPGP version number for this signature.

public boolean

Returns:

true if either hashed or unhashed subpackets are present, false otherwise.
hasSubpackets
()

Return true if the signature has either hashed or unhashed subpackets.

public void
init(PGPContentVerifierBuilderProvider verifierBuilderProvider, PGPPublicKey pubKey)

public boolean

Returns:

true if this signature represents a certification, false otherwise.
isCertification
()

Return true if this signature represents a certification.

public static boolean

Returns:

true if signatureType is a certification, false otherwise.
isCertification
(int signatureType)

Return true if the passed in signature type represents a certification, false if the signature type is not.

public static boolean
public static PGPSignature
public void
update(byte b)

public void
update(byte[] bytes)

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

private void
updateWithIdData(int header, byte[] idBytes)

private void
public boolean
public boolean

Returns:

true if the signature matches, false otherwise.
verifyCertification
(PGPUserAttributeSubpacketVector
user attributes the key was stored under
userAttributes
,
PGPPublicKey
the key to be verified.
key
)

Verify the signature as certifying the passed in public key as associated with the passed in user attributes.

public boolean

Returns:

true if the signature matches, false otherwise.
verifyCertification
(String
id the key was stored under
id
,
PGPPublicKey
the key to be verified.
key
)

Verify the signature as certifying the passed in public key as associated with the passed in id.

public boolean

Returns:

true if the signature matches, false otherwise.
verifyCertification
(byte[]
id the key was stored under in its raw byte form.
rawID
,
PGPPublicKey
the key to be verified.
key
)

Verify the signature as certifying the passed in public key as associated with the passed in rawID.

public boolean

Returns:

true if the certification is valid, false otherwise.
verifyCertification
(PGPPublicKey
the key we are verifying against.
masterKey
,
PGPPublicKey
the key we are verifying.
pubKey
)

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

public boolean

Returns:

true if the certification is valid, false otherwise.
verifyCertification
(PGPPublicKey
the key we are checking.
pubKey
)

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

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BINARY_DOCUMENTback to summary
public static final int BINARY_DOCUMENT
CANONICAL_TEXT_DOCUMENTback to summary
public static final int CANONICAL_TEXT_DOCUMENT
CASUAL_CERTIFICATIONback to summary
public static final int CASUAL_CERTIFICATION
CERTIFICATION_REVOCATIONback to summary
public static final int CERTIFICATION_REVOCATION
DEFAULT_CERTIFICATIONback to summary
public static final int DEFAULT_CERTIFICATION
DIRECT_KEYback to summary
public static final int DIRECT_KEY
KEY_REVOCATIONback to summary
public static final int KEY_REVOCATION
lastbback to summary
private byte lastb
NO_CERTIFICATIONback to summary
public static final int NO_CERTIFICATION
POSITIVE_CERTIFICATIONback to summary
public static final int POSITIVE_CERTIFICATION
PRIMARYKEY_BINDINGback to summary
public static final int PRIMARYKEY_BINDING
signatureTypeback to summary
private int signatureType
sigOutback to summary
private OutputStream sigOut
sigPckback to summary
private SignaturePacket sigPck
STAND_ALONEback to summary
public static final int STAND_ALONE
SUBKEY_BINDINGback to summary
public static final int SUBKEY_BINDING
SUBKEY_REVOCATIONback to summary
public static final int SUBKEY_REVOCATION
THIRD_PARTY_CONFIRMATIONback to summary
public static final int THIRD_PARTY_CONFIRMATION
TIMESTAMPback to summary
public static final int TIMESTAMP
trustPckback to summary
private TrustPacket trustPck
verifierback to summary
private PGPContentVerifier verifier

Constructor Detail

PGPSignatureback to summary
public PGPSignature(BCPGInputStream pIn) throws IOException, PGPException
PGPSignatureback to summary
pack-priv PGPSignature(SignaturePacket sigPacket)
PGPSignatureback to summary
pack-priv PGPSignature(SignaturePacket sigPacket, TrustPacket trustPacket)

Method Detail

addTrailerback to summary
private void addTrailer()
blockUpdateback to summary
private void blockUpdate(byte[] block, int off, int len)
byteUpdateback to summary
private void byteUpdate(byte b)
castback to summary
private static SignaturePacket cast(Packet packet) throws IOException
createSubpacketVectorback to summary
private PGPSignatureSubpacketVector createSubpacketVector(SignatureSubpacket[] pcks)
encodeback to summary
public void encode(OutputStream outStream) throws IOException
encodeback to summary
public void encode(OutputStream outStream, boolean forTransfer) throws IOException

Encode the signature to outStream, with trust packets stripped out if forTransfer is true.

Parameters
outStream:OutputStream

stream to write the key encoding to.

forTransfer:boolean

if the purpose of encoding is to send key to other users.

Exceptions
IOException:
in case of encoding error.
getCreationTimeback to summary
public Date getCreationTime()

Return the creation time of the signature.

Returns:Date

the signature creation time.

getDigestPrefixback to summary
public byte[] getDigestPrefix()

Return the digest prefix of the signature.

Returns:byte[]

digest prefix

getEncodedback to summary
public byte[] getEncoded() throws IOException
getEncodedback to summary
public byte[] getEncoded(boolean forTransfer) throws IOException

Return an encoding of the signature, with trust packets stripped out if forTransfer is true.

Parameters
forTransfer:boolean

if the purpose of encoding is to send key to other users.

Returns:byte[]

a encoded byte array representing the key.

Exceptions
IOException:
in case of encoding error.
getEncodedPublicKeyback to summary
private byte[] getEncodedPublicKey(PGPPublicKey pubKey) throws PGPException
getHashAlgorithmback to summary
public int getHashAlgorithm()

Return the hash algorithm associated with this signature.

Returns:int

signature hash algorithm.

getHashedSubPacketsback to summary
public PGPSignatureSubpacketVector getHashedSubPackets()
getKeyAlgorithmback to summary
public int getKeyAlgorithm()

Return the key algorithm associated with this signature.

Returns:int

signature key algorithm.

getKeyIDback to summary
public long getKeyID()

Return the id of the key that created the signature.

Returns:long

keyID of the signatures corresponding key.

getSignatureback to summary
public byte[] getSignature() throws PGPException
getSignatureTrailerback to summary
public byte[] getSignatureTrailer()
getSignatureTypeback to summary
public int getSignatureType()
getUnhashedSubPacketsback to summary
public PGPSignatureSubpacketVector getUnhashedSubPackets()
getVersionback to summary
public int getVersion()

Return the OpenPGP version number for this signature.

Returns:int

signature version number.

hasSubpacketsback to summary
public boolean hasSubpackets()

Return true if the signature has either hashed or unhashed subpackets.

Returns:boolean

true if either hashed or unhashed subpackets are present, false otherwise.

initback to summary
public void init(PGPContentVerifierBuilderProvider verifierBuilderProvider, PGPPublicKey pubKey) throws PGPException
isCertificationback to summary
public boolean isCertification()

Return true if this signature represents a certification.

Returns:boolean

true if this signature represents a certification, false otherwise.

isCertificationback to summary
public static boolean isCertification(int signatureType)

Return true if the passed in signature type represents a certification, false if the signature type is not.

Returns:boolean

true if signatureType is a certification, false otherwise.

isSignatureEncodingEqualback to summary
public static boolean isSignatureEncodingEqual(PGPSignature sig1, PGPSignature sig2)
joinback to summary
public static PGPSignature join(PGPSignature sig1, PGPSignature sig2) throws PGPException
updateback to summary
public void update(byte b)
updateback to summary
public void update(byte[] bytes)
updateback to summary
public void update(byte[] bytes, int off, int length)
updateWithIdDataback to summary
private void updateWithIdData(int header, byte[] idBytes)
updateWithPublicKeyback to summary
private void updateWithPublicKey(PGPPublicKey key) throws PGPException
verifyback to summary
public boolean verify() throws PGPException
verifyCertificationback to summary
public boolean verifyCertification(PGPUserAttributeSubpacketVector userAttributes, PGPPublicKey key) throws PGPException

Verify the signature as certifying the passed in public key as associated with the passed in user attributes.

Parameters
userAttributes:PGPUserAttributeSubpacketVector

user attributes the key was stored under

key:PGPPublicKey

the key to be verified.

Returns:boolean

true if the signature matches, false otherwise.

verifyCertificationback to summary
public boolean verifyCertification(String id, PGPPublicKey key) throws PGPException

Verify the signature as certifying the passed in public key as associated with the passed in id.

Parameters
id:String

id the key was stored under

key:PGPPublicKey

the key to be verified.

Returns:boolean

true if the signature matches, false otherwise.

verifyCertificationback to summary
public boolean verifyCertification(byte[] rawID, PGPPublicKey key) throws PGPException

Verify the signature as certifying the passed in public key as associated with the passed in rawID.

Parameters
rawID:byte[]

id the key was stored under in its raw byte form.

key:PGPPublicKey

the key to be verified.

Returns:boolean

true if the signature matches, false otherwise.

verifyCertificationback to summary
public boolean verifyCertification(PGPPublicKey masterKey, PGPPublicKey pubKey) throws PGPException

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

Parameters
masterKey:PGPPublicKey

the key we are verifying against.

pubKey:PGPPublicKey

the key we are verifying.

Returns:boolean

true if the certification is valid, false otherwise.

verifyCertificationback to summary
public boolean verifyCertification(PGPPublicKey pubKey) throws PGPException

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

Parameters
pubKey:PGPPublicKey

the key we are checking.

Returns:boolean

true if the certification is valid, false otherwise.