Top Description Fields Constructors Methods
org.bouncycastle.openpgp

public Class PGPSignatureSubpacketGenerator

extends Object
Class Inheritance
Imports
java.io.IOException, java.util.ArrayList, .Date, .List, org.bouncycastle.bcpg.SignatureSubpacket, .SignatureSubpacketTags, org.bouncycastle.bcpg.sig.EmbeddedSignature, .Exportable, .Features, .IntendedRecipientFingerprint, .IssuerFingerprint, .IssuerKeyID, .KeyExpirationTime, .KeyFlags, .NotationData, .PolicyURI, .PreferredAlgorithms, .PrimaryUserID, .Revocable, .RevocationKey, .RevocationKeyTags, .RevocationReason, .SignatureCreationTime, .SignatureExpirationTime, .SignatureTarget, .SignerUserID, .TrustSignature

Generator for signature subpackets.

Field Summary

Modifier and TypeField and Description
pack-priv List<E>

Constructor Summary

AccessConstructor and Description
public
PGPSignatureSubpacketGenerator()

Base constructor, creates an empty generator.

public
PGPSignatureSubpacketGenerator(PGPSignatureSubpacketVector
an initial set of subpackets.
sigSubV
)

Constructor for pre-initialising the generator from an existing one.

Method Summary

Modifier and TypeMethod and Description
public void
addCustomSubpacket(SignatureSubpacket
subpacket
subpacket
)

Add a custom subpacket.

public void
addEmbeddedSignature(boolean
true if should be treated as critical, false otherwise.
isCritical
,
PGPSignature
embedded signature
pgpSignature
)

Add an embedded signature packet.

public void
addIntendedRecipientFingerprint(boolean
true if critical, false otherwise.
isCritical
,
PGPPublicKey
the public key the encrypted payload was encrypted against.
publicKey
)

Adds a intended recipient fingerprint for an encrypted payload the signature is associated with.

public void
addNotationData(boolean
true if should be treated as critical, false otherwise.
isCritical
,
boolean
true if the notation is human-readable.
isHumanReadable
,
String
name of the notation key.
notationName
,
String
value of the notation.
notationValue
)

Add a notation data packet to the signature.

public void
addPolicyURI(boolean isCritical, String policyUri)

public void
addRevocationKey(boolean
true if should be treated as critical, false otherwise.
isCritical
,
int
algorithm of the revocation key
keyAlgorithm
,
byte[]
fingerprint of the revocation key
fingerprint
)

Adds a revocation key sub packet.

public void
addSignerUserID(boolean
true if should be treated as critical, false otherwise.
isCritical
,
String
signer user-id
userID
)

Add a signer user-id to the signature.

public PGPSignatureSubpacketVector
public SignatureSubpacket[]

Returns:

an array of zero or more matching subpackets.
getSubpackets
(int
subpacket type code
type
)

Return all signature subpackets of the passed in type currently in the generator.

public boolean

Returns:

true if present, false otherwise.
hasSubpacket
(int
type to look for.
type
)

Return true if a particular subpacket type exists.

public boolean
removePacket(SignatureSubpacket
the signature subpacket to remove.
packet
)

Remove a previously set packet from the generator.

public void
setEmbeddedSignature(boolean
true if should be treated as critical, false otherwise.
isCritical
,
PGPSignature
embedded signature
pgpSignature
)

Add an embedded signature packet.
public void
setExportable(boolean
true if should be treated as critical, false otherwise.
isCritical
,
boolean
true if the signature should be exportable, false otherwise.
isExportable
)

Specify, whether or not the signature should be marked as exportable.

public void
setFeature(boolean
true if should be treated as critical, false otherwise.
isCritical
,
byte
features
feature
)

Specify the set of features of the key.

public void
setIntendedRecipientFingerprint(boolean
true if critical, false otherwise.
isCritical
,
PGPPublicKey
the public key the encrypted payload was encrypted against.
publicKey
)

Adds a intended recipient fingerprint for an encrypted payload the signature is associated with.
public void
setIssuerFingerprint(boolean
true if critical, false otherwise.
isCritical
,
PGPSecretKey
the secret key used to generate the associated signature.
secretKey
)

Sets the signature issuer fingerprint for the signing key.

public void
setIssuerFingerprint(boolean
true if critical, false otherwise.
isCritical
,
PGPPublicKey
the public key needed to verify the associated signature.
publicKey
)

Sets the signature issuer fingerprint for the signing key.

public void
setIssuerKeyID(boolean
true if should be treated as critical, false otherwise.
isCritical
,
long
id of the key that issued the signature
keyID
)

Sets issuer key-id subpacket.

public void
setKeyExpirationTime(boolean
true if should be treated as critical, false otherwise.
isCritical
,
long seconds)

Set the number of seconds a key is valid for after the time of its creation.

public void
setKeyFlags(boolean
true if should be treated as critical, false otherwise.
isCritical
,
int
flags
flags
)

Set this keys key flags.

public void
setNotationData(boolean
true if should be treated as critical, false otherwise.
isCritical
,
boolean
true if the notation is human-readable.
isHumanReadable
,
String
name of the notation key
notationName
,
String
value of the notation
notationValue
)

Add a notation data packet to the signature.
public void
setPreferredAEADAlgorithms(boolean
true if should be treated as critical, false otherwise.
isCritical
,
int[]
array of algorithms in descending preference
algorithms
)

Specify the preferred AEAD algorithms of this key.

public void
setPreferredCompressionAlgorithms(boolean
true if should be treated as critical, false otherwise.
isCritical
,
int[]
array of algorithms in descending preference
algorithms
)

Specify the preferred compression algorithms of this key.

public void
setPreferredHashAlgorithms(boolean
true if should be treated as critical, false otherwise.
isCritical
,
int[]
array of algorithms in descending preference
algorithms
)

Specify the preferred hash algorithms of the key.

public void
setPreferredSymmetricAlgorithms(boolean
true if should be treated as critical, false otherwise.
isCritical
,
int[]
array of algorithms in descending preference
algorithms
)

Specify the preferred symmetric encryption algorithms of the key.

public void
setPrimaryUserID(boolean isCritical, boolean isPrimaryUserID)

public void
setRevocable(boolean
true if should be treated as critical, false otherwise.
isCritical
,
boolean
true if the signature should be revocable, false otherwise.
isRevocable
)

Specify, whether or not the signature is revocable.

public void
setRevocationKey(boolean
true if should be treated as critical, false otherwise.
isCritical
,
int
algorithm of the revocation key
keyAlgorithm
,
byte[]
fingerprint of the revocation key
fingerprint
)

Deprecated use addRevocationKey(boolean, int, byte[]) instead.
Adds a revocation key sub packet.
public void
setRevocationReason(boolean
true if should be treated as critical, false otherwise.
isCritical
,
byte
reason code for the revocation
reason
,
String
human readable description of the revocation reason
description
)

Sets revocation reason sub packet.

public void
setSignatureCreationTime(boolean isCritical, Date date)

Set the creation time for the signature.

public void
setSignatureExpirationTime(boolean
true if should be treated as critical, false otherwise.
isCritical
,
long seconds)

Set the number of seconds a signature is valid for after the time of its creation.

public void
setSignatureTarget(boolean
true if should be treated as critical, false otherwise.
isCritical
,
int
algorithm of the key that issued the signature that is being referred to.
publicKeyAlgorithm
,
int
hash algorithm that was used to calculate the hash data.
hashAlgorithm
,
byte[]
hash of the signature that is being referred to.
hashData
)

Sets the signature target sub packet.

public void
setSignerUserID(boolean
true if should be treated as critical, false otherwise.
isCritical
,
String
signer user-id
userID
)

Deprecated use addSignerUserID(boolean, String) instead.
Add a signer user-id to the signature.
public void
setSignerUserID(boolean isCritical, byte[] rawUserID)

public void
setTrust(boolean
true if the packet is critical.
isCritical
,
int
depth level.
depth
,
int
trust amount.
trustAmount
)

Add a TrustSignature packet to the signature.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

packetsback to summary
pack-priv List<E> packets

Constructor Detail

PGPSignatureSubpacketGeneratorback to summary
public PGPSignatureSubpacketGenerator()

Base constructor, creates an empty generator.

PGPSignatureSubpacketGeneratorback to summary
public PGPSignatureSubpacketGenerator(PGPSignatureSubpacketVector sigSubV)

Constructor for pre-initialising the generator from an existing one.

Parameters
sigSubV:PGPSignatureSubpacketVector

an initial set of subpackets.

Method Detail

addCustomSubpacketback to summary
public void addCustomSubpacket(SignatureSubpacket subpacket)

Add a custom subpacket. Miscellaneous subpackets are subpackets that Bouncycastle does not recognize or doesn't have first class support for.

Parameters
subpacket:SignatureSubpacket

subpacket

addEmbeddedSignatureback to summary
public void addEmbeddedSignature(boolean isCritical, PGPSignature pgpSignature) throws IOException

Add an embedded signature packet.

Parameters
isCritical:boolean

true if should be treated as critical, false otherwise.

pgpSignature:PGPSignature

embedded signature

Exceptions
IOException:
in case of an error
addIntendedRecipientFingerprintback to summary
public void addIntendedRecipientFingerprint(boolean isCritical, PGPPublicKey publicKey)

Adds a intended recipient fingerprint for an encrypted payload the signature is associated with.

Parameters
isCritical:boolean

true if critical, false otherwise.

publicKey:PGPPublicKey

the public key the encrypted payload was encrypted against.

addNotationDataback to summary
public void addNotationData(boolean isCritical, boolean isHumanReadable, String notationName, String notationValue)

Add a notation data packet to the signature.

Parameters
isCritical:boolean

true if should be treated as critical, false otherwise.

isHumanReadable:boolean

true if the notation is human-readable.

notationName:String

name of the notation key.

notationValue:String

value of the notation.

addPolicyURIback to summary
public void addPolicyURI(boolean isCritical, String policyUri)
addRevocationKeyback to summary
public void addRevocationKey(boolean isCritical, int keyAlgorithm, byte[] fingerprint)

Adds a revocation key sub packet.

Parameters
isCritical:boolean

true if should be treated as critical, false otherwise.

keyAlgorithm:int

algorithm of the revocation key

fingerprint:byte[]

fingerprint of the revocation key

addSignerUserIDback to summary
public void addSignerUserID(boolean isCritical, String userID)

Add a signer user-id to the signature.

Parameters
isCritical:boolean

true if should be treated as critical, false otherwise.

userID:String

signer user-id

generateback to summary
public PGPSignatureSubpacketVector generate()
getSubpacketsback to summary
public SignatureSubpacket[] getSubpackets(int type)

Return all signature subpackets of the passed in type currently in the generator.

Parameters
type:int

subpacket type code

Returns:SignatureSubpacket[]

an array of zero or more matching subpackets.

hasSubpacketback to summary
public boolean hasSubpacket(int type)

Return true if a particular subpacket type exists.

Parameters
type:int

type to look for.

Returns:boolean

true if present, false otherwise.

removePacketback to summary
public boolean removePacket(SignatureSubpacket packet)

Remove a previously set packet from the generator.

Parameters
packet:SignatureSubpacket

the signature subpacket to remove.

setEmbeddedSignatureback to summary
public void setEmbeddedSignature(boolean isCritical, PGPSignature pgpSignature) throws IOException

Add an embedded signature packet.

Parameters
isCritical:boolean

true if should be treated as critical, false otherwise.

pgpSignature:PGPSignature

embedded signature

Exceptions
IOException:
in case of an error
setExportableback to summary
public void setExportable(boolean isCritical, boolean isExportable)

Specify, whether or not the signature should be marked as exportable. If this subpacket is missing, the signature is treated as being exportable.

Parameters
isCritical:boolean

true if should be treated as critical, false otherwise.

isExportable:boolean

true if the signature should be exportable, false otherwise.

setFeatureback to summary
public void setFeature(boolean isCritical, byte feature)

Specify the set of features of the key.

Parameters
isCritical:boolean

true if should be treated as critical, false otherwise.

feature:byte

features

setIntendedRecipientFingerprintback to summary
public void setIntendedRecipientFingerprint(boolean isCritical, PGPPublicKey publicKey)

Adds a intended recipient fingerprint for an encrypted payload the signature is associated with.

Parameters
isCritical:boolean

true if critical, false otherwise.

publicKey:PGPPublicKey

the public key the encrypted payload was encrypted against.

setIssuerFingerprintback to summary
public void setIssuerFingerprint(boolean isCritical, PGPSecretKey secretKey)

Sets the signature issuer fingerprint for the signing key.

Parameters
isCritical:boolean

true if critical, false otherwise.

secretKey:PGPSecretKey

the secret key used to generate the associated signature.

setIssuerFingerprintback to summary
public void setIssuerFingerprint(boolean isCritical, PGPPublicKey publicKey)

Sets the signature issuer fingerprint for the signing key.

Parameters
isCritical:boolean

true if critical, false otherwise.

publicKey:PGPPublicKey

the public key needed to verify the associated signature.

setIssuerKeyIDback to summary
public void setIssuerKeyID(boolean isCritical, long keyID)

Sets issuer key-id subpacket.

Parameters
isCritical:boolean

true if should be treated as critical, false otherwise.

keyID:long

id of the key that issued the signature

setKeyExpirationTimeback to summary
public void setKeyExpirationTime(boolean isCritical, long seconds)

Set the number of seconds a key is valid for after the time of its creation. A value of zero means the key never expires.

Parameters
isCritical:boolean

true if should be treated as critical, false otherwise.

setKeyFlagsback to summary
public void setKeyFlags(boolean isCritical, int flags)

Set this keys key flags. See PGPKeyFlags.

Parameters
isCritical:boolean

true if should be treated as critical, false otherwise.

flags:int

flags

setNotationDataback to summary
public void setNotationData(boolean isCritical, boolean isHumanReadable, String notationName, String notationValue)

Add a notation data packet to the signature.

Parameters
isCritical:boolean

true if should be treated as critical, false otherwise.

isHumanReadable:boolean

true if the notation is human-readable.

notationName:String

name of the notation key

notationValue:String

value of the notation

setPreferredAEADAlgorithmsback to summary
public void setPreferredAEADAlgorithms(boolean isCritical, int[] algorithms)

Specify the preferred AEAD algorithms of this key.

Parameters
isCritical:boolean

true if should be treated as critical, false otherwise.

algorithms:int[]

array of algorithms in descending preference

setPreferredCompressionAlgorithmsback to summary
public void setPreferredCompressionAlgorithms(boolean isCritical, int[] algorithms)

Specify the preferred compression algorithms of this key. See org.bouncycastle.bcpg.CompressionAlgorithmTags.

Parameters
isCritical:boolean

true if should be treated as critical, false otherwise.

algorithms:int[]

array of algorithms in descending preference

setPreferredHashAlgorithmsback to summary
public void setPreferredHashAlgorithms(boolean isCritical, int[] algorithms)

Specify the preferred hash algorithms of the key. See org.bouncycastle.bcpg.HashAlgorithmTags.

Parameters
isCritical:boolean

true if should be treated as critical, false otherwise.

algorithms:int[]

array of algorithms in descending preference

setPreferredSymmetricAlgorithmsback to summary
public void setPreferredSymmetricAlgorithms(boolean isCritical, int[] algorithms)

Specify the preferred symmetric encryption algorithms of the key. See org.bouncycastle.bcpg.SymmetricKeyAlgorithmTags.

Parameters
isCritical:boolean

true if should be treated as critical, false otherwise.

algorithms:int[]

array of algorithms in descending preference

setPrimaryUserIDback to summary
public void setPrimaryUserID(boolean isCritical, boolean isPrimaryUserID)
setRevocableback to summary
public void setRevocable(boolean isCritical, boolean isRevocable)

Specify, whether or not the signature is revocable.

Parameters
isCritical:boolean

true if should be treated as critical, false otherwise.

isRevocable:boolean

true if the signature should be revocable, false otherwise.

setRevocationKeyback to summary
public void setRevocationKey(boolean isCritical, int keyAlgorithm, byte[] fingerprint)

Adds a revocation key sub packet.

Parameters
isCritical:boolean

true if should be treated as critical, false otherwise.

keyAlgorithm:int

algorithm of the revocation key

fingerprint:byte[]

fingerprint of the revocation key

setRevocationReasonback to summary
public void setRevocationReason(boolean isCritical, byte reason, String description)

Sets revocation reason sub packet. See org.bouncycastle.bcpg.sig.RevocationReasonTags.

Parameters
isCritical:boolean

true if should be treated as critical, false otherwise.

reason:byte

reason code for the revocation

description:String

human readable description of the revocation reason

setSignatureCreationTimeback to summary
public void setSignatureCreationTime(boolean isCritical, Date date)

Set the creation time for the signature.

Note

this overrides the generation of a creation time when the signature is generated.

setSignatureExpirationTimeback to summary
public void setSignatureExpirationTime(boolean isCritical, long seconds)

Set the number of seconds a signature is valid for after the time of its creation. A value of zero means the signature never expires.

Parameters
isCritical:boolean

true if should be treated as critical, false otherwise.

setSignatureTargetback to summary
public void setSignatureTarget(boolean isCritical, int publicKeyAlgorithm, int hashAlgorithm, byte[] hashData)

Sets the signature target sub packet.

Parameters
isCritical:boolean

true if should be treated as critical, false otherwise.

publicKeyAlgorithm:int

algorithm of the key that issued the signature that is being referred to.

hashAlgorithm:int

hash algorithm that was used to calculate the hash data.

hashData:byte[]

hash of the signature that is being referred to.

setSignerUserIDback to summary
public void setSignerUserID(boolean isCritical, String userID)

Deprecated

use addSignerUserID(boolean, String) instead.

Add a signer user-id to the signature.

Parameters
isCritical:boolean

true if should be treated as critical, false otherwise.

userID:String

signer user-id

setSignerUserIDback to summary
public void setSignerUserID(boolean isCritical, byte[] rawUserID)
setTrustback to summary
public void setTrust(boolean isCritical, int depth, int trustAmount)

Add a TrustSignature packet to the signature. The values for depth and trust are largely installation dependent but there are some guidelines in RFC 4880 - 5.2.3.13.

Parameters
isCritical:boolean

true if the packet is critical.

depth:int

depth level.

trustAmount:int

trust amount.