mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-09-09 18:29:39 +02:00
Fix some tests
This commit is contained in:
parent
3feaf9134b
commit
a6e7bb18e9
6 changed files with 16 additions and 11 deletions
|
@ -329,8 +329,8 @@ class ConsumerOptions {
|
|||
|
||||
fun isIgnoreMDCErrors(): Boolean = ignoreMDCErrors
|
||||
|
||||
fun setAllowDecryptionWithNonEncryptionKey(allow: Boolean): ConsumerOptions = apply {
|
||||
allowDecryptionWithNonEncryptionKey = allow
|
||||
fun setAllowDecryptionWithMissingKeyFlags(): ConsumerOptions = apply {
|
||||
allowDecryptionWithNonEncryptionKey = true
|
||||
}
|
||||
|
||||
fun getAllowDecryptionWithNonEncryptionKey(): Boolean {
|
||||
|
|
|
@ -310,7 +310,7 @@ class SecretKeyRingEditor(var key: OpenPGPKey, override val referenceTime: Date
|
|||
if (subkeyAlgorithm.isSigningCapable()) {
|
||||
val pkBindingBuilder =
|
||||
PrimaryKeyBindingSignatureBuilder(
|
||||
key.primarySecretKey, subkeyProtector, hashAlgorithm)
|
||||
key.primarySecretKey, primaryKeyProtector, hashAlgorithm)
|
||||
pkBindingBuilder.hashedSubpackets.setSignatureCreationTime(referenceTime)
|
||||
hashedSubpackets.addEmbeddedSignature(pkBindingBuilder.build(primaryKey.publicKey))
|
||||
}
|
||||
|
|
|
@ -195,7 +195,9 @@ public class PreventDecryptionUsingNonEncryptionKeyTest {
|
|||
ByteArrayInputStream msgIn = new ByteArrayInputStream(MSG.getBytes(StandardCharsets.UTF_8));
|
||||
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify()
|
||||
.onInputStream(msgIn)
|
||||
.withOptions(ConsumerOptions.get().addDecryptionKey(secretKeys));
|
||||
.withOptions(ConsumerOptions.get()
|
||||
.setAllowDecryptionWithMissingKeyFlags()
|
||||
.addDecryptionKey(secretKeys));
|
||||
|
||||
Streams.drain(decryptionStream);
|
||||
decryptionStream.close();
|
||||
|
@ -225,7 +227,7 @@ public class PreventDecryptionUsingNonEncryptionKeyTest {
|
|||
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify()
|
||||
.onInputStream(msgIn)
|
||||
.withOptions(ConsumerOptions.get()
|
||||
.setAllowDecryptionWithNonEncryptionKey(true)
|
||||
.setAllowDecryptionWithMissingKeyFlags()
|
||||
.addDecryptionKey(secretKeys));
|
||||
|
||||
byte[] decrypted = Streams.readAll(decryptionStream);
|
||||
|
|
|
@ -179,7 +179,9 @@ public class EncryptionWithMissingKeyFlagsTest {
|
|||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
DecryptionStream decryptionStream = PGPainless.decryptAndOrVerify()
|
||||
.onInputStream(in)
|
||||
.withOptions(ConsumerOptions.get().addDecryptionKey(secretKeys));
|
||||
.withOptions(ConsumerOptions.get()
|
||||
.setAllowDecryptionWithMissingKeyFlags()
|
||||
.addDecryptionKey(secretKeys));
|
||||
ByteArrayOutputStream plain = new ByteArrayOutputStream();
|
||||
|
||||
// Decrypt
|
||||
|
|
|
@ -43,6 +43,7 @@ public class AddSubkeyWithModifiedBindingSignatureSubpacketsTest {
|
|||
.modernKeyRing("Alice <alice@pgpainless.org>")
|
||||
.getPGPSecretKeyRing();
|
||||
KeyRingInfo before = PGPainless.inspectKeyRing(secretKeys);
|
||||
List<OpenPGPCertificate.OpenPGPComponentKey> signingKeysBefore = before.getSigningSubkeys();
|
||||
|
||||
PGPKeyPair secretSubkey = KeyRingBuilder.generateKeyPair(
|
||||
KeySpec.getBuilder(KeyType.EDDSA_LEGACY(EdDSALegacyCurve._Ed25519), KeyFlag.SIGN_DATA).build(),
|
||||
|
@ -60,11 +61,11 @@ public class AddSubkeyWithModifiedBindingSignatureSubpacketsTest {
|
|||
.done();
|
||||
|
||||
KeyRingInfo after = PGPainless.inspectKeyRing(secretKeys);
|
||||
List<OpenPGPCertificate.OpenPGPComponentKey> signingKeys = after.getSigningSubkeys();
|
||||
signingKeys.removeAll(before.getSigningSubkeys());
|
||||
assertFalse(signingKeys.isEmpty());
|
||||
List<OpenPGPCertificate.OpenPGPComponentKey> signingKeysAfter = after.getSigningSubkeys();
|
||||
signingKeysAfter.removeAll(signingKeysBefore);
|
||||
assertFalse(signingKeysAfter.isEmpty());
|
||||
|
||||
OpenPGPCertificate.OpenPGPComponentKey newKey = signingKeys.get(0);
|
||||
OpenPGPCertificate.OpenPGPComponentKey newKey = signingKeysAfter.get(0);
|
||||
Date newExpirationDate = after.getSubkeyExpirationDate(new OpenPgpV4Fingerprint(newKey.getPGPPublicKey()));
|
||||
assertNotNull(newExpirationDate);
|
||||
Date now = new Date();
|
||||
|
|
|
@ -66,7 +66,7 @@ public class ThirdPartyDirectKeySignatureBuilderTest {
|
|||
PGPSignature signature = info.getLatestDirectKeySelfSignature();
|
||||
|
||||
assertNotNull(signature);
|
||||
assertEquals(directKeySig, signature);
|
||||
assertEquals(directKeySig.getSignature(), signature);
|
||||
|
||||
assertEquals(SignatureType.DIRECT_KEY, SignatureType.valueOf(signature.getSignatureType()));
|
||||
assertEquals(Collections.singletonList(KeyFlag.CERTIFY_OTHER), SignatureSubpacketsUtil.parseKeyFlags(signature));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue