1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2025-09-10 18:59:39 +02:00

Remove SignerUserId check, Policy setting only via constructor parameter

This commit is contained in:
Paul Schaub 2025-03-24 12:40:43 +01:00
parent 4c180bbd59
commit 221d329254
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
16 changed files with 125 additions and 348 deletions

View file

@ -28,6 +28,8 @@ class SOPImpl(
private val sopv: SOPV = SOPVImpl(api)
) : SOP {
constructor(api: PGPainless) : this(api, SOPVImpl(api))
override fun armor(): Armor = ArmorImpl(api)
override fun changeKeyPassword(): ChangeKeyPassword = ChangeKeyPasswordImpl(api)

View file

@ -123,7 +123,8 @@ public class VerifyLegacySignatureTest {
"=TtKx\n" +
"-----END PGP MESSAGE-----";
SOPImpl sop = new SOPImpl();
PGPainless api = PGPainless.getInstance();
SOPImpl sop = new SOPImpl(api);
byte[] cert = sop.extractCert().key(KEY.getBytes(StandardCharsets.UTF_8))
.getBytes();
ByteArrayAndResult<List<Verification>> result = sop.inlineVerify()
@ -134,12 +135,13 @@ public class VerifyLegacySignatureTest {
assertFalse(result.getResult().isEmpty());
// Adjust data signature hash policy to accept new SHA-1 sigs
Policy policy = PGPainless.getPolicy();
Policy policy = api.getAlgorithmPolicy();
Policy adjusted = policy.copy()
.withDataSignatureHashAlgorithmPolicy(
Policy.HashAlgorithmPolicy.static2022RevocationSignatureHashAlgorithmPolicy()
).build();
PGPainless.getInstance().setAlgorithmPolicy(adjusted);
api = new PGPainless(adjusted);
sop = new SOPImpl(api);
// Sig generated in 2024 using SHA1
String newSig = "-----BEGIN PGP MESSAGE-----\n" +
@ -164,8 +166,5 @@ public class VerifyLegacySignatureTest {
.toByteArrayAndResult();
assertFalse(result.getResult().isEmpty());
// Reset old policy
PGPainless.getInstance().setAlgorithmPolicy(policy);
}
}