Package org.bouncycastle.openpgp.api
Class OpenPGPDetachedSignatureGenerator
java.lang.Object
org.bouncycastle.openpgp.api.AbstractOpenPGPDocumentSignatureGenerator<OpenPGPDetachedSignatureGenerator>
org.bouncycastle.openpgp.api.OpenPGPDetachedSignatureGenerator
public class OpenPGPDetachedSignatureGenerator
extends AbstractOpenPGPDocumentSignatureGenerator<OpenPGPDetachedSignatureGenerator>
High-Level OpenPGP Signature Generator for Detached Signatures.
Detached signatures can be stored and distributed as a distinct object alongside the signed data.
They are used for example to sign Release files of some Linux software distributions.
To use this class, instantiate it, optionally providing a concrete OpenPGPImplementation
and
OpenPGPPolicy
for algorithm policing.
Then, add the desired OpenPGPKey
you want to use for signing the data via one or more
calls to AbstractOpenPGPDocumentSignatureGenerator.addSigningKey(OpenPGPKey, KeyPassphraseProvider)
.
You have fine-grained control over the signature by using the method
AbstractOpenPGPDocumentSignatureGenerator.addSigningKey(OpenPGPKey.OpenPGPSecretKey, char[], SignatureParameters.Callback)
.
Lastly, retrieve a list of detached signatures
by calling
sign(InputStream)
, passing in an InputStream
containing the data you want to sign.
-
Field Summary
Fields inherited from class org.bouncycastle.openpgp.api.AbstractOpenPGPDocumentSignatureGenerator
defaultKeyPassphraseProvider, implementation, policy, signatureCallbacks, signatureGenerators, signingKeyPassphraseProviders, signingKeys, signingKeySelector
-
Constructor Summary
ConstructorsConstructorDescriptionInstantiate a signature generator using the defaultOpenPGPImplementation
and itsOpenPGPPolicy
.OpenPGPDetachedSignatureGenerator
(OpenPGPImplementation implementation) Instantiate a signature generator using the passed inOpenPGPImplementation
and itsOpenPGPPolicy
.OpenPGPDetachedSignatureGenerator
(OpenPGPImplementation implementation, OpenPGPPolicy policy) Instantiate a signature generator using a customOpenPGPImplementation
and customOpenPGPPolicy
. -
Method Summary
Modifier and TypeMethodDescriptionsign
(InputStream inputStream) Pass in anInputStream
containing the data that shall be signed and return a list of detached signatures.Methods inherited from class org.bouncycastle.openpgp.api.AbstractOpenPGPDocumentSignatureGenerator
addKeyPassphrase, addSigningKey, addSigningKey, addSigningKey, addSigningKey, addSigningKey, addSigningKey, addSignToGenerator, initSignatureGenerator, setMissingKeyPassphraseCallback, setSigningKeySelector
-
Constructor Details
-
OpenPGPDetachedSignatureGenerator
public OpenPGPDetachedSignatureGenerator()Instantiate a signature generator using the defaultOpenPGPImplementation
and itsOpenPGPPolicy
. -
OpenPGPDetachedSignatureGenerator
Instantiate a signature generator using the passed inOpenPGPImplementation
and itsOpenPGPPolicy
.- Parameters:
implementation
- custom OpenPGP implementation
-
OpenPGPDetachedSignatureGenerator
public OpenPGPDetachedSignatureGenerator(OpenPGPImplementation implementation, OpenPGPPolicy policy) Instantiate a signature generator using a customOpenPGPImplementation
and customOpenPGPPolicy
.- Parameters:
implementation
- custom OpenPGP implementationpolicy
- custom OpenPGP policy
-
-
Method Details
-
sign
public List<OpenPGPSignature.OpenPGPDocumentSignature> sign(InputStream inputStream) throws IOException, PGPException Pass in anInputStream
containing the data that shall be signed and return a list of detached signatures.- Parameters:
inputStream
- data to be signed- Returns:
- detached signatures
- Throws:
IOException
- if something goes wrong processing the dataPGPException
- if signing fails
-