mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-30 08:12:06 +01:00
Tests: Make use of KeyRingInfo to determine encryption subkeys
This commit is contained in:
parent
df22c2a102
commit
e7f685e63b
1 changed files with 5 additions and 8 deletions
|
@ -21,7 +21,7 @@ import java.io.ByteArrayInputStream;
|
|||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Set;
|
||||
import java.util.List;
|
||||
|
||||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.bouncycastle.openpgp.PGPPublicKey;
|
||||
|
@ -30,11 +30,10 @@ import org.bouncycastle.util.io.Streams;
|
|||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.algorithm.KeyFlag;
|
||||
import org.pgpainless.algorithm.EncryptionPurpose;
|
||||
import org.pgpainless.implementation.ImplementationFactory;
|
||||
import org.pgpainless.key.OpenPgpV4Fingerprint;
|
||||
import org.pgpainless.key.util.KeyRingUtils;
|
||||
import org.pgpainless.util.selection.key.impl.EncryptionKeySelectionStrategy;
|
||||
import org.pgpainless.key.info.KeyRingInfo;
|
||||
|
||||
public class DecryptHiddenRecipientMessage {
|
||||
|
||||
|
@ -155,10 +154,8 @@ public class DecryptHiddenRecipientMessage {
|
|||
OpenPgpMetadata metadata = decryptionStream.getResult();
|
||||
assertEquals(0, metadata.getRecipientKeyIds().size());
|
||||
|
||||
// Hacky way of getting the encryption subkey of the key ring
|
||||
// TODO: Create convenient method for this
|
||||
Set<PGPPublicKey> encryptionKeys = new EncryptionKeySelectionStrategy(KeyFlag.ENCRYPT_STORAGE, KeyFlag.ENCRYPT_COMMS)
|
||||
.selectKeysFromKeyRing(KeyRingUtils.publicKeyRingFrom(secretKeys));
|
||||
KeyRingInfo info = new KeyRingInfo(secretKeys);
|
||||
List<PGPPublicKey> encryptionKeys = info.getEncryptionSubkeys(EncryptionPurpose.STORAGE_AND_COMMUNICATIONS);
|
||||
assertEquals(1, encryptionKeys.size());
|
||||
|
||||
assertEquals(new OpenPgpV4Fingerprint(encryptionKeys.iterator().next()), metadata.getDecryptionFingerprint());
|
||||
|
|
Loading…
Reference in a new issue