@@ -159,18 +159,46 @@ public PGPSecretKeyRing classicKey(String userId, char[] passphrase)
159
159
.addEncryptionSubkey ()
160
160
.build (passphrase );
161
161
}
162
+
162
163
/**
163
- * Generate a sign -only OpenPGP key.
164
- * The key consists of a single, user-id-less Ed25519 key, which is capable of signing and certifying .
165
- * It carries a single direct-key signature with signing-related preferences .
164
+ * Generate an OpenPGP key consisting of an Ed25519 certify -only primary key,
165
+ * a dedicated Ed25519 sign-only subkey and dedicated X25519 encryption-only subkey .
166
+ * The key will carry the provided user-id and be protected using the provided passphrase .
166
167
*
167
- * @return sign-only (+certify) OpenPGP key
168
+ * @param userId user id
169
+ * @param passphrase nullable passphrase
170
+ * @return OpenPGP key
168
171
* @throws PGPException if the key cannot be generated
169
172
*/
170
- public PGPSecretKeyRing signOnlyKey ( )
173
+ public PGPSecretKeyRing ed25519x25519Key ( String userId , char [] passphrase )
171
174
throws PGPException
172
175
{
173
- return signOnlyKey (null );
176
+ return withPrimaryKey (PGPKeyPairGenerator ::generateEd25519KeyPair )
177
+ .addSigningSubkey (PGPKeyPairGenerator ::generateEd25519KeyPair )
178
+ .addEncryptionSubkey (PGPKeyPairGenerator ::generateX25519KeyPair )
179
+ .addUserId (userId )
180
+ .build (passphrase );
181
+ }
182
+
183
+
184
+ /**
185
+ * Generate an OpenPGP key consisting of an Ed448 certify-only primary key,
186
+ * a dedicated Ed448 sign-only subkey and dedicated X448 encryption-only subkey.
187
+ * The key will carry the provided user-id and be protected using the provided passphrase.
188
+ *
189
+ * @param userId user id
190
+ * @param passphrase nullable passphrase
191
+ * @return OpenPGP key
192
+ * @throws PGPException if the key cannot be generated
193
+ */
194
+ public PGPSecretKeyRing ed448x448Key (String userId , char [] passphrase )
195
+ throws PGPException
196
+ {
197
+ return withPrimaryKey (PGPKeyPairGenerator ::generateEd448KeyPair )
198
+ .addSigningSubkey (PGPKeyPairGenerator ::generateEd448KeyPair )
199
+ .addEncryptionSubkey (PGPKeyPairGenerator ::generateX448KeyPair )
200
+ .addUserId (userId )
201
+ .build (passphrase );
174
202
}
175
203
176
204
/**
@@ -257,7 +285,14 @@ public PGPSecretKeyRing signOnlyKey(
257
285
public WithPrimaryKey withPrimaryKey ()
258
286
throws PGPException
259
287
{
260
- return withPrimaryKey (null );
288
+ return withPrimaryKey ((SignatureSubpacketsFunction ) null );
289
+ }
290
+
291
+ public WithPrimaryKey withPrimaryKey (
292
+ KeyPairGeneratorCallback keyGenCallback )
293
+ throws PGPException
294
+ {
295
+ return withPrimaryKey (keyGenCallback , null );
261
296
}
262
297
263
298
/**
0 commit comments