mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-09-09 18:29:39 +02:00
Set relaxed PK policies for tests with weak DSA keys
This commit is contained in:
parent
85856567dd
commit
148af79794
2 changed files with 37 additions and 0 deletions
|
@ -9,6 +9,8 @@ import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.pgpainless.PGPainless;
|
||||||
|
import org.pgpainless.policy.Policy;
|
||||||
import sop.ByteArrayAndResult;
|
import sop.ByteArrayAndResult;
|
||||||
import sop.DecryptionResult;
|
import sop.DecryptionResult;
|
||||||
import sop.EncryptionResult;
|
import sop.EncryptionResult;
|
||||||
|
@ -275,6 +277,17 @@ public class CarolKeySignEncryptRoundtripTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void regressionTest() throws IOException {
|
public void regressionTest() throws IOException {
|
||||||
|
// PGPainless default API is strict
|
||||||
|
PGPainless strictAPI = PGPainless.getInstance();
|
||||||
|
PGPainless relaxedAPI = new PGPainless(
|
||||||
|
strictAPI.getImplementation(),
|
||||||
|
// BSI policy allows DSA
|
||||||
|
strictAPI.getAlgorithmPolicy().copy()
|
||||||
|
.withPublicKeyAlgorithmPolicy(Policy.PublicKeyAlgorithmPolicy.bsi2021PublicKeyAlgorithmPolicy())
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
PGPainless.setInstance(relaxedAPI);
|
||||||
|
|
||||||
SOPImpl sop = new SOPImpl();
|
SOPImpl sop = new SOPImpl();
|
||||||
byte[] msg = "Hello, World!\n".getBytes();
|
byte[] msg = "Hello, World!\n".getBytes();
|
||||||
ReadyWithResult<EncryptionResult> encryption = sop.encrypt()
|
ReadyWithResult<EncryptionResult> encryption = sop.encrypt()
|
||||||
|
@ -294,5 +307,7 @@ public class CarolKeySignEncryptRoundtripTest {
|
||||||
VerificationListAssert.assertThatVerificationList(decryption.getResult().getVerifications())
|
VerificationListAssert.assertThatVerificationList(decryption.getResult().getVerifications())
|
||||||
.hasSingleItem()
|
.hasSingleItem()
|
||||||
.issuedBy("71FFDA004409E5DDB0C3E8F19BA789DC76D6849A", "71FFDA004409E5DDB0C3E8F19BA789DC76D6849A");
|
.issuedBy("71FFDA004409E5DDB0C3E8F19BA789DC76D6849A", "71FFDA004409E5DDB0C3E8F19BA789DC76D6849A");
|
||||||
|
|
||||||
|
PGPainless.setInstance(strictAPI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,30 @@
|
||||||
|
|
||||||
package sop.testsuite.pgpainless.operation;
|
package sop.testsuite.pgpainless.operation;
|
||||||
|
|
||||||
|
import org.pgpainless.PGPainless;
|
||||||
|
import org.pgpainless.policy.Policy;
|
||||||
|
import sop.SOP;
|
||||||
import sop.testsuite.operation.EncryptDecryptTest;
|
import sop.testsuite.operation.EncryptDecryptTest;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class PGPainlessEncryptDecryptTest extends EncryptDecryptTest {
|
public class PGPainlessEncryptDecryptTest extends EncryptDecryptTest {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void encryptDecryptRoundTripCarolTest(SOP sop) throws IOException {
|
||||||
|
// Carols key is DSA, which is rejected by PGPainless default policy now.
|
||||||
|
// Therefore, we need to set a relaxed PGPainless API instance, allowing DSA keys.
|
||||||
|
PGPainless strictAPI = PGPainless.getInstance();
|
||||||
|
PGPainless relaxedAPI = new PGPainless(
|
||||||
|
strictAPI.getImplementation(),
|
||||||
|
strictAPI.getAlgorithmPolicy().copy()
|
||||||
|
.withPublicKeyAlgorithmPolicy(Policy.PublicKeyAlgorithmPolicy.bsi2021PublicKeyAlgorithmPolicy())
|
||||||
|
.build());
|
||||||
|
PGPainless.setInstance(relaxedAPI);
|
||||||
|
|
||||||
|
super.encryptDecryptRoundTripCarolTest(sop);
|
||||||
|
|
||||||
|
PGPainless.setInstance(strictAPI);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue