diff --git a/pgpainless-core/src/main/java/org/pgpainless/encryption_signing/SigningOptions.java b/pgpainless-core/src/main/java/org/pgpainless/encryption_signing/SigningOptions.java index 4f5b0d1f..1cec422b 100644 --- a/pgpainless-core/src/main/java/org/pgpainless/encryption_signing/SigningOptions.java +++ b/pgpainless-core/src/main/java/org/pgpainless/encryption_signing/SigningOptions.java @@ -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 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.