Package org.bouncycastle.openpgp
Class PGPSignature
- java.lang.Object
-
- org.bouncycastle.openpgp.PGPSignature
-
public class PGPSignature extends java.lang.Object
A PGP signature object.
-
-
Field Summary
Fields Modifier and Type Field Description 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
PRIMARYKEY_BINDING
static int
STAND_ALONE
static int
SUBKEY_BINDING
static int
SUBKEY_REVOCATION
static int
TIMESTAMP
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
encode(java.io.OutputStream outStream)
void
encode(java.io.OutputStream outStream, boolean forTransfer)
Encode the signature to outStream, with trust packets stripped out if forTransfer is true.java.util.Date
getCreationTime()
Return the creation time of the signature.byte[]
getEncoded()
byte[]
getEncoded(boolean forTransfer)
Return an encoding of the signature, with trust packets stripped out if forTransfer is true.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.boolean
hasSubpackets()
Return true if the signature has either hashed or unhashed subpackets.void
init(PGPContentVerifierBuilderProvider verifierBuilderProvider, PGPPublicKey pubKey)
boolean
isCertification()
Return true if this signature represents a certification.static boolean
isCertification(int signatureType)
Return true if the passed in signature type represents a certification, false if the signature type is not.void
update(byte b)
void
update(byte[] bytes)
void
update(byte[] bytes, int off, int length)
boolean
verify()
boolean
verifyCertification(byte[] rawID, PGPPublicKey key)
Verify the signature as certifying the passed in public key as associated with the passed in rawID.boolean
verifyCertification(java.lang.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.boolean
verifyCertification(PGPUserAttributeSubpacketVector userAttributes, PGPPublicKey key)
Verify the signature as certifying the passed in public key as associated with the passed in user attributes.
-
-
-
Field Detail
-
BINARY_DOCUMENT
public static final int BINARY_DOCUMENT
- See Also:
- Constant Field Values
-
CANONICAL_TEXT_DOCUMENT
public static final int CANONICAL_TEXT_DOCUMENT
- See Also:
- Constant Field Values
-
STAND_ALONE
public static final int STAND_ALONE
- See Also:
- Constant Field Values
-
DEFAULT_CERTIFICATION
public static final int DEFAULT_CERTIFICATION
- See Also:
- Constant Field Values
-
NO_CERTIFICATION
public static final int NO_CERTIFICATION
- See Also:
- Constant Field Values
-
CASUAL_CERTIFICATION
public static final int CASUAL_CERTIFICATION
- See Also:
- Constant Field Values
-
POSITIVE_CERTIFICATION
public static final int POSITIVE_CERTIFICATION
- See Also:
- Constant Field Values
-
SUBKEY_BINDING
public static final int SUBKEY_BINDING
- See Also:
- Constant Field Values
-
PRIMARYKEY_BINDING
public static final int PRIMARYKEY_BINDING
- See Also:
- Constant Field Values
-
DIRECT_KEY
public static final int DIRECT_KEY
- See Also:
- Constant Field Values
-
KEY_REVOCATION
public static final int KEY_REVOCATION
- See Also:
- Constant Field Values
-
SUBKEY_REVOCATION
public static final int SUBKEY_REVOCATION
- See Also:
- Constant Field Values
-
CERTIFICATION_REVOCATION
public static final int CERTIFICATION_REVOCATION
- See Also:
- Constant Field Values
-
TIMESTAMP
public static final int TIMESTAMP
- See Also:
- Constant Field Values
-
-
Method Detail
-
getVersion
public int getVersion()
Return the OpenPGP version number for this signature.- Returns:
- signature version number.
-
getKeyAlgorithm
public int getKeyAlgorithm()
Return the key algorithm associated with this signature.- Returns:
- signature key algorithm.
-
getHashAlgorithm
public int getHashAlgorithm()
Return the hash algorithm associated with this signature.- Returns:
- signature hash algorithm.
-
isCertification
public boolean isCertification()
Return true if this signature represents a certification.- Returns:
- true if this signature represents a certification, false otherwise.
-
init
public void init(PGPContentVerifierBuilderProvider verifierBuilderProvider, PGPPublicKey pubKey) throws PGPException
- Throws:
PGPException
-
update
public void update(byte b)
-
update
public void update(byte[] bytes)
-
update
public void update(byte[] bytes, int off, int length)
-
verify
public boolean verify() throws PGPException
- Throws:
PGPException
-
verifyCertification
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
- user attributes the key was stored underkey
- the key to be verified.- Returns:
- true if the signature matches, false otherwise.
- Throws:
PGPException
-
verifyCertification
public boolean verifyCertification(java.lang.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
- id the key was stored underkey
- the key to be verified.- Returns:
- true if the signature matches, false otherwise.
- Throws:
PGPException
-
verifyCertification
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
- id the key was stored under in its raw byte form.key
- the key to be verified.- Returns:
- true if the signature matches, false otherwise.
- Throws:
PGPException
-
verifyCertification
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
- the key we are verifying against.pubKey
- the key we are verifying.- Returns:
- true if the certification is valid, false otherwise.
- Throws:
PGPException
-
verifyCertification
public boolean verifyCertification(PGPPublicKey pubKey) throws 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
-
getSignatureType
public int getSignatureType()
-
getKeyID
public long getKeyID()
Return the id of the key that created the signature.- Returns:
- keyID of the signatures corresponding key.
-
getCreationTime
public java.util.Date getCreationTime()
Return the creation time of the signature.- Returns:
- the signature creation time.
-
getSignatureTrailer
public byte[] getSignatureTrailer()
-
hasSubpackets
public boolean hasSubpackets()
Return true if the signature has either hashed or unhashed subpackets.- Returns:
- true if either hashed or unhashed subpackets are present, false otherwise.
-
getHashedSubPackets
public PGPSignatureSubpacketVector getHashedSubPackets()
-
getUnhashedSubPackets
public PGPSignatureSubpacketVector getUnhashedSubPackets()
-
getSignature
public byte[] getSignature() throws PGPException
- Throws:
PGPException
-
getEncoded
public byte[] getEncoded() throws java.io.IOException
- Throws:
java.io.IOException
-
getEncoded
public byte[] getEncoded(boolean forTransfer) throws java.io.IOException
Return an encoding of the signature, with trust packets stripped out if forTransfer is true.- Parameters:
forTransfer
- if the purpose of encoding is to send key to other users.- Returns:
- a encoded byte array representing the key.
- Throws:
java.io.IOException
- in case of encoding error.
-
encode
public void encode(java.io.OutputStream outStream) throws java.io.IOException
- Throws:
java.io.IOException
-
encode
public void encode(java.io.OutputStream outStream, boolean forTransfer) throws java.io.IOException
Encode the signature to outStream, with trust packets stripped out if forTransfer is true.- Parameters:
outStream
- stream to write the key encoding to.forTransfer
- if the purpose of encoding is to send key to other users.- Throws:
java.io.IOException
- in case of encoding error.
-
isCertification
public static boolean isCertification(int signatureType)
Return true if the passed in signature type represents a certification, false if the signature type is not.- Parameters:
signatureType
-- Returns:
- true if signatureType is a certification, false otherwise.
-
-