Package org.pgpainless.key.generation
Class KeyRingBuilder
- java.lang.Object
-
- org.pgpainless.key.generation.KeyRingBuilder
-
- All Implemented Interfaces:
KeyRingBuilderInterface<KeyRingBuilder>
public class KeyRingBuilder extends java.lang.Object implements KeyRingBuilderInterface<KeyRingBuilder>
-
-
Constructor Summary
Constructors Constructor Description KeyRingBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description KeyRingBuilderaddSubkey(KeySpec keySpec)KeyRingBuilderaddUserId(byte[] userId)KeyRingBuilderaddUserId(java.lang.String userId)org.bouncycastle.openpgp.PGPSecretKeyRingbuild()static org.bouncycastle.openpgp.PGPKeyPairgenerateKeyPair(KeySpec spec)org.bouncycastle.openpgp.PGPSecretKeyRingmodernKeyRing(java.lang.String userId, java.lang.String password)Generate a modern PGP key ring consisting of an ed25519 EdDSA primary key which is used to certify an X25519 XDH encryption subkey and an ed25519 EdDSA signing key.KeyRingBuildersetExpirationDate(java.util.Date expirationDate)KeyRingBuildersetPassphrase(Passphrase passphrase)KeyRingBuildersetPrimaryKey(KeySpec keySpec)org.bouncycastle.openpgp.PGPSecretKeyRingsimpleEcKeyRing(java.lang.String userId)Creates a key ring consisting of an ed25519 EdDSA primary key and a curve25519 XDH subkey.org.bouncycastle.openpgp.PGPSecretKeyRingsimpleEcKeyRing(java.lang.String userId, java.lang.String password)Creates a key ring consisting of an ed25519 EdDSA primary key and a X25519 XDH subkey.org.bouncycastle.openpgp.PGPSecretKeyRingsimpleEcKeyRing(UserId userId)Creates a key ring consisting of an ed25519 EdDSA primary key and a curve25519 XDH subkey.org.bouncycastle.openpgp.PGPSecretKeyRingsimpleEcKeyRing(UserId userId, java.lang.String password)Creates a key ring consisting of an ed25519 EdDSA primary key and a curve25519 XDH subkey.org.bouncycastle.openpgp.PGPSecretKeyRingsimpleRsaKeyRing(java.lang.String userId, RsaLength length)Creates a simple, unencrypted RSA KeyPair of lengthlengthwith user-iduserId.org.bouncycastle.openpgp.PGPSecretKeyRingsimpleRsaKeyRing(java.lang.String userId, RsaLength length, java.lang.String password)Creates a simple RSA KeyPair of lengthlengthwith user-iduserId.org.bouncycastle.openpgp.PGPSecretKeyRingsimpleRsaKeyRing(UserId userId, RsaLength length)Creates a simple, unencrypted RSA KeyPair of lengthlengthwith user-iduserId.org.bouncycastle.openpgp.PGPSecretKeyRingsimpleRsaKeyRing(UserId userId, RsaLength length, java.lang.String password)Creates a simple RSA KeyPair of lengthlengthwith user-iduserId.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.pgpainless.key.generation.KeyRingBuilderInterface
addSubkey, addUserId, setPrimaryKey
-
-
-
-
Method Detail
-
simpleRsaKeyRing
public org.bouncycastle.openpgp.PGPSecretKeyRing simpleRsaKeyRing(@Nonnull UserId userId, @Nonnull RsaLength length) throws java.security.InvalidAlgorithmParameterException, java.security.NoSuchAlgorithmException, org.bouncycastle.openpgp.PGPExceptionCreates a simple, unencrypted RSA KeyPair of lengthlengthwith user-iduserId. The KeyPair consists of a single RSA master key which is used for signing, encryption and certification.- Parameters:
userId- user id.length- length in bits.- Returns:
PGPSecretKeyRingcontaining the KeyPair.- Throws:
java.security.InvalidAlgorithmParameterExceptionjava.security.NoSuchAlgorithmExceptionorg.bouncycastle.openpgp.PGPException
-
simpleRsaKeyRing
public org.bouncycastle.openpgp.PGPSecretKeyRing simpleRsaKeyRing(@Nonnull java.lang.String userId, @Nonnull RsaLength length) throws java.security.InvalidAlgorithmParameterException, java.security.NoSuchAlgorithmException, org.bouncycastle.openpgp.PGPExceptionCreates a simple, unencrypted RSA KeyPair of lengthlengthwith user-iduserId. The KeyPair consists of a single RSA master key which is used for signing, encryption and certification.- Parameters:
userId- user id.length- length in bits.- Returns:
PGPSecretKeyRingcontaining the KeyPair.- Throws:
java.security.InvalidAlgorithmParameterExceptionjava.security.NoSuchAlgorithmExceptionorg.bouncycastle.openpgp.PGPException
-
simpleRsaKeyRing
public org.bouncycastle.openpgp.PGPSecretKeyRing simpleRsaKeyRing(@Nonnull UserId userId, @Nonnull RsaLength length, java.lang.String password) throws java.security.InvalidAlgorithmParameterException, java.security.NoSuchAlgorithmException, org.bouncycastle.openpgp.PGPExceptionCreates a simple RSA KeyPair of lengthlengthwith user-iduserId. The KeyPair consists of a single RSA master key which is used for signing, encryption and certification.- Parameters:
userId- user id.length- length in bits.password- Password of the key. Can be null for unencrypted keys.- Returns:
PGPSecretKeyRingcontaining the KeyPair.- Throws:
java.security.InvalidAlgorithmParameterExceptionjava.security.NoSuchAlgorithmExceptionorg.bouncycastle.openpgp.PGPException
-
simpleRsaKeyRing
public org.bouncycastle.openpgp.PGPSecretKeyRing simpleRsaKeyRing(@Nonnull java.lang.String userId, @Nonnull RsaLength length, java.lang.String password) throws org.bouncycastle.openpgp.PGPException, java.security.NoSuchAlgorithmException, java.security.InvalidAlgorithmParameterExceptionCreates a simple RSA KeyPair of lengthlengthwith user-iduserId. The KeyPair consists of a single RSA master key which is used for signing, encryption and certification.- Parameters:
userId- user id.length- length in bits.password- Password of the key. Can be null for unencrypted keys.- Returns:
PGPSecretKeyRingcontaining the KeyPair.- Throws:
org.bouncycastle.openpgp.PGPExceptionjava.security.NoSuchAlgorithmExceptionjava.security.InvalidAlgorithmParameterException
-
simpleEcKeyRing
public org.bouncycastle.openpgp.PGPSecretKeyRing simpleEcKeyRing(@Nonnull UserId userId) throws java.security.InvalidAlgorithmParameterException, java.security.NoSuchAlgorithmException, org.bouncycastle.openpgp.PGPExceptionCreates a key ring consisting of an ed25519 EdDSA primary key and a curve25519 XDH subkey. The EdDSA primary key is used for signing messages and certifying the sub key. The XDH subkey is used for encryption and decryption of messages.- Parameters:
userId- user-id- Returns:
PGPSecretKeyRingcontaining the key pairs.- Throws:
java.security.InvalidAlgorithmParameterExceptionjava.security.NoSuchAlgorithmExceptionorg.bouncycastle.openpgp.PGPException
-
simpleEcKeyRing
public org.bouncycastle.openpgp.PGPSecretKeyRing simpleEcKeyRing(@Nonnull java.lang.String userId) throws java.security.InvalidAlgorithmParameterException, java.security.NoSuchAlgorithmException, org.bouncycastle.openpgp.PGPExceptionCreates a key ring consisting of an ed25519 EdDSA primary key and a curve25519 XDH subkey. The EdDSA primary key is used for signing messages and certifying the sub key. The XDH subkey is used for encryption and decryption of messages.- Parameters:
userId- user-id- Returns:
PGPSecretKeyRingcontaining the key pairs.- Throws:
java.security.InvalidAlgorithmParameterExceptionjava.security.NoSuchAlgorithmExceptionorg.bouncycastle.openpgp.PGPException
-
simpleEcKeyRing
public org.bouncycastle.openpgp.PGPSecretKeyRing simpleEcKeyRing(@Nonnull UserId userId, java.lang.String password) throws java.security.InvalidAlgorithmParameterException, java.security.NoSuchAlgorithmException, org.bouncycastle.openpgp.PGPExceptionCreates a key ring consisting of an ed25519 EdDSA primary key and a curve25519 XDH subkey. The EdDSA primary key is used for signing messages and certifying the sub key. The XDH subkey is used for encryption and decryption of messages.- Parameters:
userId- user-idpassword- Password of the private key. Can be null for an unencrypted key.- Returns:
PGPSecretKeyRingcontaining the key pairs.- Throws:
java.security.InvalidAlgorithmParameterExceptionjava.security.NoSuchAlgorithmExceptionorg.bouncycastle.openpgp.PGPException
-
simpleEcKeyRing
public org.bouncycastle.openpgp.PGPSecretKeyRing simpleEcKeyRing(@Nonnull java.lang.String userId, java.lang.String password) throws org.bouncycastle.openpgp.PGPException, java.security.NoSuchAlgorithmException, java.security.InvalidAlgorithmParameterExceptionCreates a key ring consisting of an ed25519 EdDSA primary key and a X25519 XDH subkey. The EdDSA primary key is used for signing messages and certifying the sub key. The XDH subkey is used for encryption and decryption of messages.- Parameters:
userId- user-idpassword- Password of the private key. Can be null for an unencrypted key.- Returns:
PGPSecretKeyRingcontaining the key pairs.- Throws:
org.bouncycastle.openpgp.PGPExceptionjava.security.NoSuchAlgorithmExceptionjava.security.InvalidAlgorithmParameterException
-
modernKeyRing
public org.bouncycastle.openpgp.PGPSecretKeyRing modernKeyRing(java.lang.String userId, java.lang.String password) throws java.security.InvalidAlgorithmParameterException, java.security.NoSuchAlgorithmException, org.bouncycastle.openpgp.PGPExceptionGenerate a modern PGP key ring consisting of an ed25519 EdDSA primary key which is used to certify an X25519 XDH encryption subkey and an ed25519 EdDSA signing key.- Parameters:
userId- primary user idpassword- passphrase or null if the key should be unprotected.- Returns:
- key ring
- Throws:
java.security.InvalidAlgorithmParameterExceptionjava.security.NoSuchAlgorithmExceptionorg.bouncycastle.openpgp.PGPException
-
setPrimaryKey
public KeyRingBuilder setPrimaryKey(@Nonnull KeySpec keySpec)
- Specified by:
setPrimaryKeyin interfaceKeyRingBuilderInterface<KeyRingBuilder>
-
addSubkey
public KeyRingBuilder addSubkey(@Nonnull KeySpec keySpec)
- Specified by:
addSubkeyin interfaceKeyRingBuilderInterface<KeyRingBuilder>
-
addUserId
public KeyRingBuilder addUserId(@Nonnull java.lang.String userId)
- Specified by:
addUserIdin interfaceKeyRingBuilderInterface<KeyRingBuilder>
-
addUserId
public KeyRingBuilder addUserId(@Nonnull byte[] userId)
- Specified by:
addUserIdin interfaceKeyRingBuilderInterface<KeyRingBuilder>
-
setExpirationDate
public KeyRingBuilder setExpirationDate(@Nonnull java.util.Date expirationDate)
- Specified by:
setExpirationDatein interfaceKeyRingBuilderInterface<KeyRingBuilder>
-
setPassphrase
public KeyRingBuilder setPassphrase(@Nonnull Passphrase passphrase)
- Specified by:
setPassphrasein interfaceKeyRingBuilderInterface<KeyRingBuilder>
-
build
public org.bouncycastle.openpgp.PGPSecretKeyRing build() throws java.security.NoSuchAlgorithmException, org.bouncycastle.openpgp.PGPException, java.security.InvalidAlgorithmParameterException- Specified by:
buildin interfaceKeyRingBuilderInterface<KeyRingBuilder>- Throws:
java.security.NoSuchAlgorithmExceptionorg.bouncycastle.openpgp.PGPExceptionjava.security.InvalidAlgorithmParameterException
-
generateKeyPair
public static org.bouncycastle.openpgp.PGPKeyPair generateKeyPair(KeySpec spec) throws java.security.NoSuchAlgorithmException, org.bouncycastle.openpgp.PGPException, java.security.InvalidAlgorithmParameterException
- Throws:
java.security.NoSuchAlgorithmExceptionorg.bouncycastle.openpgp.PGPExceptionjava.security.InvalidAlgorithmParameterException
-
-