mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-30 08:12:06 +01:00
Add SigningOptions.add{Inline|Detached}Signatures(decryptor, pgpSecretKeyRingCollection, type)
This commit is contained in:
parent
8e6abe5d02
commit
e3749f5734
1 changed files with 40 additions and 0 deletions
|
@ -27,6 +27,7 @@ import org.bouncycastle.openpgp.PGPPrivateKey;
|
|||
import org.bouncycastle.openpgp.PGPPublicKey;
|
||||
import org.bouncycastle.openpgp.PGPSecretKey;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
|
||||
import org.bouncycastle.openpgp.PGPSignatureGenerator;
|
||||
import org.bouncycastle.openpgp.operator.PGPContentSignerBuilder;
|
||||
import org.pgpainless.PGPainless;
|
||||
|
@ -88,6 +89,26 @@ public final class SigningOptions {
|
|||
private final Map<SubkeyIdentifier, SigningMethod> signingMethods = new HashMap<>();
|
||||
private HashAlgorithm hashAlgorithmOverride;
|
||||
|
||||
/**
|
||||
* Add inline signatures with all secret key rings in the provided secret key ring collection.
|
||||
*
|
||||
* @param secrectKeyDecryptor decryptor to unlock the signing secret keys
|
||||
* @param signingKeys collection of signing keys
|
||||
* @param signatureType type of signature (binary, canonical text)
|
||||
* @return this
|
||||
* @throws KeyValidationException if something is wrong with any of the keys
|
||||
* @throws PGPException if any of the keys cannot be unlocked or a signing method cannot be created
|
||||
*/
|
||||
public SigningOptions addInlineSignatures(SecretKeyRingProtector secrectKeyDecryptor,
|
||||
PGPSecretKeyRingCollection signingKeys,
|
||||
DocumentSignatureType signatureType)
|
||||
throws KeyValidationException, PGPException {
|
||||
for (PGPSecretKeyRing signingKey : signingKeys) {
|
||||
addInlineSignature(secrectKeyDecryptor, signingKey, signatureType);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an inline-signature.
|
||||
* Inline signatures are being embedded into the message itself and can be processed in one pass, thanks to the use
|
||||
|
@ -150,6 +171,25 @@ public final class SigningOptions {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add detached signatures with all key rings from the provided secret key ring collection.
|
||||
*
|
||||
* @param secretKeyDecryptor decryptor to unlock the secret signing keys
|
||||
* @param signingKeys collection of signing key rings
|
||||
* @param signatureType type of the signature (binary, canonical text)
|
||||
* @return this
|
||||
* @throws PGPException if any of the keys cannot be validated or unlocked, or if any signing method cannot be created
|
||||
*/
|
||||
public SigningOptions addDetachedSignatures(SecretKeyRingProtector secretKeyDecryptor,
|
||||
PGPSecretKeyRingCollection signingKeys,
|
||||
DocumentSignatureType signatureType)
|
||||
throws PGPException {
|
||||
for (PGPSecretKeyRing signingKey : signingKeys) {
|
||||
addDetachedSignature(secretKeyDecryptor, signingKey, signatureType);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a detached signature.
|
||||
* Detached signatures are not being added into the PGP message itself.
|
||||
|
|
Loading…
Reference in a new issue