mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-23 12:52:07 +01:00
Rename EncryptionPurpose.STORAGE_AND_COMMUNICATION -> ANY
This commit is contained in:
parent
cf1881a140
commit
bd67d9c0fa
11 changed files with 12 additions and 12 deletions
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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());
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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");
|
||||||
|
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue