Package org.bouncycastle.openpgp
Class PGPSignature
java.lang.Object
org.bouncycastle.openpgp.PGPSignature
A PGP signature object.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intprotected bytestatic final intstatic final intstatic final intprotected OutputStreamprotected intstatic final intstatic final intstatic final intstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidblockUpdate(byte[] block, int off, int len) voidencode(OutputStream outStream) voidencode(OutputStream outStream, boolean forTransfer) Encode the signature to outStream, with trust packets stripped out if forTransfer is true.protected voidgetAttriubtesHash(PGPUserAttributeSubpacketVector userAttributes) Return the creation time of the signature.byte[]Return the digest prefix of the signature.byte[]byte[]getEncoded(boolean forTransfer) Return an encoding of the signature, with trust packets stripped out if forTransfer is true.intReturn the hash algorithm associated with this signature.intReturn the key algorithm associated with this signature.longgetKeyID()Return the id of the key that created the signature.byte[]byte[]intintReturn the OpenPGP version number for this signature.booleanReturn true if the signature has either hashed or unhashed subpackets.voidinit(PGPContentVerifierBuilderProvider verifierBuilderProvider, PGPPublicKey pubKey) booleanReturn true if this signature represents a certification.static booleanisCertification(int signatureType) Return true if the passed in signature type represents a certification, false if the signature type is not.static booleanisSignatureEncodingEqual(PGPSignature sig1, PGPSignature sig2) static PGPSignaturejoin(PGPSignature sig1, PGPSignature sig2) voidupdate(byte b) voidupdate(byte[] b) voidupdate(byte[] b, int off, int len) protected voidupdateWithIdData(int header, byte[] idBytes) protected voidbooleanverify()booleanverifyCertification(byte[] rawID, PGPPublicKey key) Verify the signature as certifying the passed in public key as associated with the passed in rawID.booleanverifyCertification(String id, PGPPublicKey key) Verify the signature as certifying the passed in public key as associated with the passed in id.booleanverifyCertification(PGPPublicKey pubKey) Verify a key certification, such as a revocation, for the passed in key.booleanverifyCertification(PGPPublicKey masterKey, PGPPublicKey pubKey) Verify a certification for the passed in key against the passed in master key.booleanverifyCertification(PGPUserAttributeSubpacketVector userAttributes, PGPPublicKey key) Verify the signature as certifying the passed in public key as associated with the passed in user attributes.
-
Field Details
-
BINARY_DOCUMENT
public static final int BINARY_DOCUMENT- See Also:
-
CANONICAL_TEXT_DOCUMENT
public static final int CANONICAL_TEXT_DOCUMENT- See Also:
-
STAND_ALONE
public static final int STAND_ALONE- See Also:
-
DEFAULT_CERTIFICATION
public static final int DEFAULT_CERTIFICATION- See Also:
-
NO_CERTIFICATION
public static final int NO_CERTIFICATION- See Also:
-
CASUAL_CERTIFICATION
public static final int CASUAL_CERTIFICATION- See Also:
-
POSITIVE_CERTIFICATION
public static final int POSITIVE_CERTIFICATION- See Also:
-
SUBKEY_BINDING
public static final int SUBKEY_BINDING- See Also:
-
PRIMARYKEY_BINDING
public static final int PRIMARYKEY_BINDING- See Also:
-
DIRECT_KEY
public static final int DIRECT_KEY- See Also:
-
KEY_REVOCATION
public static final int KEY_REVOCATION- See Also:
-
SUBKEY_REVOCATION
public static final int SUBKEY_REVOCATION- See Also:
-
CERTIFICATION_REVOCATION
public static final int CERTIFICATION_REVOCATION- See Also:
-
TIMESTAMP
public static final int TIMESTAMP- See Also:
-
THIRD_PARTY_CONFIRMATION
public static final int THIRD_PARTY_CONFIRMATION- See Also:
-
lastb
protected byte lastb -
sigOut
-
sigType
protected int sigType
-
-
Constructor Details
-
PGPSignature
- Throws:
IOExceptionPGPException
-
-
Method Details
-
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.
-
getDigestPrefix
public byte[] getDigestPrefix()Return the digest prefix of the signature.- Returns:
- digest prefix
-
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
-
verify
- 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
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
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
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
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
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
-
getUnhashedSubPackets
-
getSignature
- Throws:
PGPException
-
getEncoded
- Throws:
IOException
-
getEncoded
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:
IOException- in case of encoding error.
-
encode
- Throws:
IOException
-
encode
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:
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.
-
isSignatureEncodingEqual
-
join
- Throws:
PGPException
-
update
public void update(byte b) -
update
public void update(byte[] b) -
update
public void update(byte[] b, int off, int len) -
blockUpdate
protected void blockUpdate(byte[] block, int off, int len) -
updateWithIdData
protected void updateWithIdData(int header, byte[] idBytes) -
updateWithPublicKey
- Throws:
PGPException
-
getAttriubtesHash
protected void getAttriubtesHash(PGPUserAttributeSubpacketVector userAttributes) throws PGPException - Throws:
PGPException
-