From ff1fb7e07fd9532bf2ae59be8ab38b6325bfaac4 Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Fri, 29 Jan 2021 15:15:27 +0100 Subject: [PATCH] Respect Policy when negotiating hash algorithm --- .../src/main/java/org/pgpainless/key/util/SignatureUtils.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pgpainless-core/src/main/java/org/pgpainless/key/util/SignatureUtils.java b/pgpainless-core/src/main/java/org/pgpainless/key/util/SignatureUtils.java index 9f43b94f..d9934bf9 100644 --- a/pgpainless-core/src/main/java/org/pgpainless/key/util/SignatureUtils.java +++ b/pgpainless-core/src/main/java/org/pgpainless/key/util/SignatureUtils.java @@ -29,6 +29,7 @@ import org.bouncycastle.openpgp.PGPSecretKey; import org.bouncycastle.openpgp.PGPSignature; import org.bouncycastle.openpgp.PGPSignatureGenerator; import org.bouncycastle.openpgp.operator.bc.BcPGPContentSignerBuilder; +import org.pgpainless.PGPainless; import org.pgpainless.algorithm.HashAlgorithm; import org.pgpainless.algorithm.SignatureType; import org.pgpainless.implementation.ImplementationFactory; @@ -57,7 +58,7 @@ public class SignatureUtils { private static HashAlgorithm negotiateHashAlgorithm(List preferredHashAlgorithms) { if (preferredHashAlgorithms.isEmpty()) { - return HashAlgorithm.SHA512; + return PGPainless.getPolicy().getDefaultSignatureHashAlgorithm(); } return preferredHashAlgorithms.get(0); }