mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-26 14:22:05 +01:00
Remove withDefaultKeyFlags method
This commit is contained in:
parent
f4bc9bdbcc
commit
2378162953
8 changed files with 17 additions and 20 deletions
|
@ -103,7 +103,7 @@ public class KeyRingBuilder implements KeyRingBuilderInterface {
|
||||||
WithAdditionalUserIdOrPassphrase builder = this
|
WithAdditionalUserIdOrPassphrase builder = this
|
||||||
.withMasterKey(
|
.withMasterKey(
|
||||||
KeySpec.getBuilder(KeyType.RSA(length))
|
KeySpec.getBuilder(KeyType.RSA(length))
|
||||||
.withDefaultKeyFlags()
|
.withKeyFlags(KeyFlag.CERTIFY_OTHER, KeyFlag.SIGN_DATA, KeyFlag.ENCRYPT_COMMS)
|
||||||
.withDefaultAlgorithms())
|
.withDefaultAlgorithms())
|
||||||
.withPrimaryUserId(userId);
|
.withPrimaryUserId(userId);
|
||||||
|
|
||||||
|
|
|
@ -42,16 +42,6 @@ public class KeySpecBuilder implements KeySpecBuilderInterface {
|
||||||
return new WithDetailedConfigurationImpl();
|
return new WithDetailedConfigurationImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public WithDetailedConfiguration withDefaultKeyFlags() {
|
|
||||||
return withKeyFlags(
|
|
||||||
KeyFlag.CERTIFY_OTHER,
|
|
||||||
KeyFlag.SIGN_DATA,
|
|
||||||
KeyFlag.ENCRYPT_COMMS,
|
|
||||||
KeyFlag.ENCRYPT_STORAGE,
|
|
||||||
KeyFlag.AUTHENTICATION);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KeySpec withInheritedSubPackets() {
|
public KeySpec withInheritedSubPackets() {
|
||||||
return new KeySpec(type, null, true);
|
return new KeySpec(type, null, true);
|
||||||
|
|
|
@ -27,8 +27,6 @@ public interface KeySpecBuilderInterface {
|
||||||
|
|
||||||
WithDetailedConfiguration withKeyFlags(@Nonnull KeyFlag... flags);
|
WithDetailedConfiguration withKeyFlags(@Nonnull KeyFlag... flags);
|
||||||
|
|
||||||
WithDetailedConfiguration withDefaultKeyFlags();
|
|
||||||
|
|
||||||
KeySpec withInheritedSubPackets();
|
KeySpec withInheritedSubPackets();
|
||||||
|
|
||||||
interface WithDetailedConfiguration {
|
interface WithDetailedConfiguration {
|
||||||
|
|
|
@ -19,6 +19,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.pgpainless.PGPainless;
|
import org.pgpainless.PGPainless;
|
||||||
|
import org.pgpainless.algorithm.KeyFlag;
|
||||||
import org.pgpainless.key.generation.type.KeyType;
|
import org.pgpainless.key.generation.type.KeyType;
|
||||||
import org.pgpainless.key.generation.type.ecc.EllipticCurve;
|
import org.pgpainless.key.generation.type.ecc.EllipticCurve;
|
||||||
import org.pgpainless.key.generation.type.xdh.XDHCurve;
|
import org.pgpainless.key.generation.type.xdh.XDHCurve;
|
||||||
|
@ -43,7 +44,7 @@ public class CertificationKeyMustBeAbleToCertifyTest {
|
||||||
.generateKeyRing()
|
.generateKeyRing()
|
||||||
.withMasterKey(KeySpec
|
.withMasterKey(KeySpec
|
||||||
.getBuilder(type)
|
.getBuilder(type)
|
||||||
.withDefaultKeyFlags()
|
.withKeyFlags(KeyFlag.CERTIFY_OTHER, KeyFlag.SIGN_DATA)
|
||||||
.withDefaultAlgorithms())
|
.withDefaultAlgorithms())
|
||||||
.withPrimaryUserId("should@throw.ex")
|
.withPrimaryUserId("should@throw.ex")
|
||||||
.withoutPassphrase().build());
|
.withoutPassphrase().build());
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.bouncycastle.openpgp.PGPException;
|
||||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.pgpainless.PGPainless;
|
import org.pgpainless.PGPainless;
|
||||||
|
import org.pgpainless.algorithm.KeyFlag;
|
||||||
import org.pgpainless.key.generation.type.KeyType;
|
import org.pgpainless.key.generation.type.KeyType;
|
||||||
import org.pgpainless.key.generation.type.eddsa.EdDSACurve;
|
import org.pgpainless.key.generation.type.eddsa.EdDSACurve;
|
||||||
import org.pgpainless.key.generation.type.xdh.XDHCurve;
|
import org.pgpainless.key.generation.type.xdh.XDHCurve;
|
||||||
|
@ -35,10 +36,10 @@ public class GenerateEllipticCurveKeyTest {
|
||||||
public void test() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException, IOException {
|
public void test() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException, IOException {
|
||||||
PGPSecretKeyRing keyRing = PGPainless.generateKeyRing()
|
PGPSecretKeyRing keyRing = PGPainless.generateKeyRing()
|
||||||
.withSubKey(KeySpec.getBuilder(KeyType.XDH(XDHCurve._X25519))
|
.withSubKey(KeySpec.getBuilder(KeyType.XDH(XDHCurve._X25519))
|
||||||
.withDefaultKeyFlags()
|
.withKeyFlags(KeyFlag.ENCRYPT_COMMS)
|
||||||
.withDefaultAlgorithms())
|
.withDefaultAlgorithms())
|
||||||
.withMasterKey(KeySpec.getBuilder(KeyType.EDDSA(EdDSACurve._Ed25519))
|
.withMasterKey(KeySpec.getBuilder(KeyType.EDDSA(EdDSACurve._Ed25519))
|
||||||
.withDefaultKeyFlags()
|
.withKeyFlags(KeyFlag.CERTIFY_OTHER, KeyFlag.SIGN_DATA)
|
||||||
.withDefaultAlgorithms())
|
.withDefaultAlgorithms())
|
||||||
.withPrimaryUserId(UserId.onlyEmail("alice@wonderland.lit").toString())
|
.withPrimaryUserId(UserId.onlyEmail("alice@wonderland.lit").toString())
|
||||||
.withoutPassphrase()
|
.withoutPassphrase()
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.pgpainless.PGPainless;
|
import org.pgpainless.PGPainless;
|
||||||
|
import org.pgpainless.algorithm.KeyFlag;
|
||||||
import org.pgpainless.key.generation.type.KeyType;
|
import org.pgpainless.key.generation.type.KeyType;
|
||||||
import org.pgpainless.key.generation.type.rsa.RsaLength;
|
import org.pgpainless.key.generation.type.rsa.RsaLength;
|
||||||
import org.pgpainless.key.util.KeyRingUtils;
|
import org.pgpainless.key.util.KeyRingUtils;
|
||||||
|
@ -40,7 +41,7 @@ public class GenerateKeyWithAdditionalUserIdTest {
|
||||||
public void test() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException, IOException {
|
public void test() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException, IOException {
|
||||||
PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing()
|
PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing()
|
||||||
.withMasterKey(KeySpec.getBuilder(KeyType.RSA(RsaLength._3072))
|
.withMasterKey(KeySpec.getBuilder(KeyType.RSA(RsaLength._3072))
|
||||||
.withDefaultKeyFlags()
|
.withKeyFlags(KeyFlag.CERTIFY_OTHER, KeyFlag.SIGN_DATA, KeyFlag.ENCRYPT_COMMS)
|
||||||
.withDefaultAlgorithms())
|
.withDefaultAlgorithms())
|
||||||
.withPrimaryUserId("primary@user.id")
|
.withPrimaryUserId("primary@user.id")
|
||||||
.withAdditionalUserId("additional@user.id")
|
.withAdditionalUserId("additional@user.id")
|
||||||
|
|
|
@ -24,6 +24,7 @@ import java.security.NoSuchAlgorithmException;
|
||||||
import org.bouncycastle.openpgp.PGPException;
|
import org.bouncycastle.openpgp.PGPException;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.pgpainless.PGPainless;
|
import org.pgpainless.PGPainless;
|
||||||
|
import org.pgpainless.algorithm.KeyFlag;
|
||||||
import org.pgpainless.key.generation.type.KeyType;
|
import org.pgpainless.key.generation.type.KeyType;
|
||||||
import org.pgpainless.key.generation.type.rsa.RsaLength;
|
import org.pgpainless.key.generation.type.rsa.RsaLength;
|
||||||
import org.pgpainless.util.Passphrase;
|
import org.pgpainless.util.Passphrase;
|
||||||
|
@ -41,7 +42,7 @@ public class GenerateWithEmptyPassphrase {
|
||||||
public void testGeneratingKeyWithEmptyPassphraseDoesNotThrow() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException, IOException {
|
public void testGeneratingKeyWithEmptyPassphraseDoesNotThrow() throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, PGPException, IOException {
|
||||||
assertNotNull(PGPainless.generateKeyRing()
|
assertNotNull(PGPainless.generateKeyRing()
|
||||||
.withMasterKey(KeySpec.getBuilder(KeyType.RSA(RsaLength._3072))
|
.withMasterKey(KeySpec.getBuilder(KeyType.RSA(RsaLength._3072))
|
||||||
.withDefaultKeyFlags()
|
.withKeyFlags(KeyFlag.CERTIFY_OTHER, KeyFlag.SIGN_DATA, KeyFlag.ENCRYPT_COMMS)
|
||||||
.withDefaultAlgorithms())
|
.withDefaultAlgorithms())
|
||||||
.withPrimaryUserId("primary@user.id")
|
.withPrimaryUserId("primary@user.id")
|
||||||
.withPassphrase(Passphrase.emptyPassphrase())
|
.withPassphrase(Passphrase.emptyPassphrase())
|
||||||
|
|
|
@ -35,6 +35,7 @@ import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||||
import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
|
import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.pgpainless.PGPainless;
|
import org.pgpainless.PGPainless;
|
||||||
|
import org.pgpainless.algorithm.KeyFlag;
|
||||||
import org.pgpainless.key.generation.KeySpec;
|
import org.pgpainless.key.generation.KeySpec;
|
||||||
import org.pgpainless.key.generation.type.KeyType;
|
import org.pgpainless.key.generation.type.KeyType;
|
||||||
import org.pgpainless.key.generation.type.rsa.RsaLength;
|
import org.pgpainless.key.generation.type.rsa.RsaLength;
|
||||||
|
@ -49,8 +50,12 @@ public class BCUtilTest {
|
||||||
throws PGPException, NoSuchAlgorithmException, InvalidAlgorithmParameterException,
|
throws PGPException, NoSuchAlgorithmException, InvalidAlgorithmParameterException,
|
||||||
IOException {
|
IOException {
|
||||||
PGPSecretKeyRing sec = PGPainless.generateKeyRing()
|
PGPSecretKeyRing sec = PGPainless.generateKeyRing()
|
||||||
.withSubKey(KeySpec.getBuilder(KeyType.RSA(RsaLength._3072)).withDefaultKeyFlags().withDefaultAlgorithms())
|
.withSubKey(KeySpec.getBuilder(KeyType.RSA(RsaLength._3072))
|
||||||
.withMasterKey(KeySpec.getBuilder(KeyType.RSA(RsaLength._3072)).withDefaultKeyFlags().withDefaultAlgorithms())
|
.withKeyFlags(KeyFlag.ENCRYPT_COMMS)
|
||||||
|
.withDefaultAlgorithms())
|
||||||
|
.withMasterKey(KeySpec.getBuilder(KeyType.RSA(RsaLength._3072))
|
||||||
|
.withKeyFlags(KeyFlag.CERTIFY_OTHER, KeyFlag.SIGN_DATA)
|
||||||
|
.withDefaultAlgorithms())
|
||||||
.withPrimaryUserId("donald@duck.tails").withoutPassphrase().build();
|
.withPrimaryUserId("donald@duck.tails").withoutPassphrase().build();
|
||||||
|
|
||||||
PGPPublicKeyRing pub = KeyRingUtils.publicKeyRingFrom(sec);
|
PGPPublicKeyRing pub = KeyRingUtils.publicKeyRingFrom(sec);
|
||||||
|
|
Loading…
Reference in a new issue