1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-23 04:42:06 +01:00

Rename EncryptionPurpose.STORAGE_AND_COMMUNICATION -> ANY

This commit is contained in:
Paul Schaub 2021-11-02 11:30:44 +01:00
parent cf1881a140
commit bd67d9c0fa
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
11 changed files with 12 additions and 12 deletions

View file

@ -11,12 +11,12 @@ public enum EncryptionPurpose {
*/ */
COMMUNICATIONS, COMMUNICATIONS,
/** /**
* The stream will encrypt data that is stored on disk. * The stream will encrypt data at rest.
* Eg. Encrypted backup... * Eg. Encrypted backup...
*/ */
STORAGE, STORAGE,
/** /**
* The stream will use keys with either flags to encrypt the data. * The stream will use keys with either flags to encrypt the data.
*/ */
STORAGE_AND_COMMUNICATIONS ANY
} }

View file

@ -316,7 +316,7 @@ public final class DecryptionStreamFactory {
break; break;
} }
KeyRingInfo info = new KeyRingInfo(secretKeys); KeyRingInfo info = new KeyRingInfo(secretKeys);
List<PGPPublicKey> encryptionSubkeys = info.getEncryptionSubkeys(EncryptionPurpose.STORAGE_AND_COMMUNICATIONS); List<PGPPublicKey> encryptionSubkeys = info.getEncryptionSubkeys(EncryptionPurpose.ANY);
for (PGPPublicKey pubkey : encryptionSubkeys) { for (PGPPublicKey pubkey : encryptionSubkeys) {
PGPSecretKey secretKey = secretKeys.getSecretKey(pubkey.getKeyID()); PGPSecretKey secretKey = secretKeys.getSecretKey(pubkey.getKeyID());
// Skip missing secret key // Skip missing secret key

View file

@ -71,7 +71,7 @@ public class EncryptionOptions {
* or {@link org.pgpainless.algorithm.KeyFlag#ENCRYPT_STORAGE}. * or {@link org.pgpainless.algorithm.KeyFlag#ENCRYPT_STORAGE}.
*/ */
public EncryptionOptions() { public EncryptionOptions() {
this(EncryptionPurpose.STORAGE_AND_COMMUNICATIONS); this(EncryptionPurpose.ANY);
} }
public EncryptionOptions(EncryptionPurpose purpose) { public EncryptionOptions(EncryptionPurpose purpose) {

View file

@ -777,7 +777,7 @@ public class KeyRingInfo {
encryptionKeys.add(subKey); encryptionKeys.add(subKey);
} }
break; break;
case STORAGE_AND_COMMUNICATIONS: case ANY:
if (keyFlags.contains(KeyFlag.ENCRYPT_COMMS) || keyFlags.contains(KeyFlag.ENCRYPT_STORAGE)) { if (keyFlags.contains(KeyFlag.ENCRYPT_COMMS) || keyFlags.contains(KeyFlag.ENCRYPT_STORAGE)) {
encryptionKeys.add(subKey); encryptionKeys.add(subKey);
} }

View file

@ -122,7 +122,7 @@ public class InvestigateMultiSEIPMessageHandlingTest {
public void generateTestMessage() throws PGPException, IOException { public void generateTestMessage() throws PGPException, IOException {
PGPSecretKeyRing ring1 = PGPainless.readKeyRing().secretKeyRing(KEY1); PGPSecretKeyRing ring1 = PGPainless.readKeyRing().secretKeyRing(KEY1);
KeyRingInfo info1 = PGPainless.inspectKeyRing(ring1); KeyRingInfo info1 = PGPainless.inspectKeyRing(ring1);
PGPPublicKey cryptKey1 = info1.getEncryptionSubkeys(EncryptionPurpose.STORAGE_AND_COMMUNICATIONS).get(0); PGPPublicKey cryptKey1 = info1.getEncryptionSubkeys(EncryptionPurpose.ANY).get(0);
PGPSecretKey signKey1 = ring1.getSecretKey(info1.getSigningSubkeys().get(0).getKeyID()); PGPSecretKey signKey1 = ring1.getSecretKey(info1.getSigningSubkeys().get(0).getKeyID());
PGPSecretKeyRing ring2 = PGPainless.readKeyRing().secretKeyRing(KEY2); PGPSecretKeyRing ring2 = PGPainless.readKeyRing().secretKeyRing(KEY2);
KeyRingInfo info2 = PGPainless.inspectKeyRing(ring2); KeyRingInfo info2 = PGPainless.inspectKeyRing(ring2);

View file

@ -144,7 +144,7 @@ public class DecryptHiddenRecipientMessage {
assertEquals(0, metadata.getRecipientKeyIds().size()); assertEquals(0, metadata.getRecipientKeyIds().size());
KeyRingInfo info = new KeyRingInfo(secretKeys); KeyRingInfo info = new KeyRingInfo(secretKeys);
List<PGPPublicKey> encryptionKeys = info.getEncryptionSubkeys(EncryptionPurpose.STORAGE_AND_COMMUNICATIONS); List<PGPPublicKey> encryptionKeys = info.getEncryptionSubkeys(EncryptionPurpose.ANY);
assertEquals(1, encryptionKeys.size()); assertEquals(1, encryptionKeys.size());
assertEquals(new SubkeyIdentifier(secretKeys, encryptionKeys.get(0).getKeyID()), metadata.getDecryptionKey()); assertEquals(new SubkeyIdentifier(secretKeys, encryptionKeys.get(0).getKeyID()), metadata.getDecryptionKey());

View file

@ -118,7 +118,7 @@ public class MissingPassphraseForDecryptionTest {
@Test @Test
public void throwExceptionStrategy() throws PGPException, IOException { public void throwExceptionStrategy() throws PGPException, IOException {
KeyRingInfo info = PGPainless.inspectKeyRing(secretKeys); KeyRingInfo info = PGPainless.inspectKeyRing(secretKeys);
List<PGPPublicKey> encryptionKeys = info.getEncryptionSubkeys(EncryptionPurpose.STORAGE_AND_COMMUNICATIONS); List<PGPPublicKey> encryptionKeys = info.getEncryptionSubkeys(EncryptionPurpose.ANY);
SecretKeyPassphraseProvider callback = new SecretKeyPassphraseProvider() { SecretKeyPassphraseProvider callback = new SecretKeyPassphraseProvider() {
@Nullable @Nullable

View file

@ -83,7 +83,7 @@ public class GenerateKeys {
assertEquals(PublicKeyAlgorithm.EDDSA.getAlgorithmId(), assertEquals(PublicKeyAlgorithm.EDDSA.getAlgorithmId(),
keyInfo.getSigningSubkeys().get(0).getAlgorithm()); keyInfo.getSigningSubkeys().get(0).getAlgorithm());
assertEquals(PublicKeyAlgorithm.ECDH.getAlgorithmId(), assertEquals(PublicKeyAlgorithm.ECDH.getAlgorithmId(),
keyInfo.getEncryptionSubkeys(EncryptionPurpose.STORAGE_AND_COMMUNICATIONS).get(0).getAlgorithm()); keyInfo.getEncryptionSubkeys(EncryptionPurpose.ANY).get(0).getAlgorithm());
} }
/** /**

View file

@ -56,7 +56,7 @@ public class ModifyKeys {
KeyRingInfo info = PGPainless.inspectKeyRing(secretKey); KeyRingInfo info = PGPainless.inspectKeyRing(secretKey);
primaryKeyId = info.getKeyId(); primaryKeyId = info.getKeyId();
encryptionSubkeyId = info.getEncryptionSubkeys(EncryptionPurpose.STORAGE_AND_COMMUNICATIONS).get(0).getKeyID(); encryptionSubkeyId = info.getEncryptionSubkeys(EncryptionPurpose.ANY).get(0).getKeyID();
signingSubkeyId = info.getSigningSubkeys().get(0).getKeyID(); signingSubkeyId = info.getSigningSubkeys().get(0).getKeyID();
} }

View file

@ -698,7 +698,7 @@ public class KeyRingInfoTest {
assertFalse(info.isKeyValidlyBound(unboundKey.getKeyId())); assertFalse(info.isKeyValidlyBound(unboundKey.getKeyId()));
List<PGPPublicKey> encryptionSubkeys = info.getEncryptionSubkeys(EncryptionPurpose.STORAGE_AND_COMMUNICATIONS); List<PGPPublicKey> encryptionSubkeys = info.getEncryptionSubkeys(EncryptionPurpose.ANY);
assertTrue(encryptionSubkeys.stream().map(OpenPgpV4Fingerprint::new).noneMatch(f -> f.equals(unboundKey)), assertTrue(encryptionSubkeys.stream().map(OpenPgpV4Fingerprint::new).noneMatch(f -> f.equals(unboundKey)),
"Unbound subkey MUST NOT be considered a valid encryption subkey"); "Unbound subkey MUST NOT be considered a valid encryption subkey");

View file

@ -51,7 +51,7 @@ public class TestTwoSubkeysEncryption {
EncryptionStream encryptionStream = PGPainless.encryptAndOrSign() EncryptionStream encryptionStream = PGPainless.encryptAndOrSign()
.onOutputStream(out) .onOutputStream(out)
.withOptions( .withOptions(
ProducerOptions.encrypt(new EncryptionOptions(EncryptionPurpose.STORAGE_AND_COMMUNICATIONS) ProducerOptions.encrypt(new EncryptionOptions(EncryptionPurpose.ANY)
.addRecipient(publicKeys, EncryptionOptions.encryptToAllCapableSubkeys()) .addRecipient(publicKeys, EncryptionOptions.encryptToAllCapableSubkeys())
) )
.setAsciiArmor(false) .setAsciiArmor(false)