diff --git a/pgpainless-core/src/main/kotlin/org/pgpainless/signature/builder/AbstractSignatureBuilder.kt b/pgpainless-core/src/main/kotlin/org/pgpainless/signature/builder/AbstractSignatureBuilder.kt index eb4c9f1f..26b50a6d 100644 --- a/pgpainless-core/src/main/kotlin/org/pgpainless/signature/builder/AbstractSignatureBuilder.kt +++ b/pgpainless-core/src/main/kotlin/org/pgpainless/signature/builder/AbstractSignatureBuilder.kt @@ -14,6 +14,7 @@ import org.bouncycastle.openpgp.PGPSignature import org.bouncycastle.openpgp.PGPSignatureGenerator import org.pgpainless.PGPainless import org.pgpainless.algorithm.HashAlgorithm +import org.pgpainless.algorithm.PublicKeyAlgorithm import org.pgpainless.algorithm.SignatureType import org.pgpainless.algorithm.negotiation.HashAlgorithmNegotiator import org.pgpainless.implementation.ImplementationFactory @@ -35,6 +36,9 @@ abstract class AbstractSignatureBuilder>( protected abstract val signatureTypePredicate: Predicate init { + val algorithm = + PublicKeyAlgorithm.requireFromId(privateSigningKey.publicKeyPacket.algorithm) + require(algorithm.isSigningCapable()) { "Key is not signing capable: $algorithm" } require(signatureTypePredicate.test(_signatureType)) { "Invalid signature type." } }