Commit ee170b850c for strongswan.org
commit ee170b850c8898ccfc7d16b70366b84237e4e78f
Author: Tobias Brunner <tobias@strongswan.org>
Date: Tue Mar 10 16:35:27 2026 +0100
pki: Add support to generate composite keys
diff --git a/src/pki/commands/gen.c b/src/pki/commands/gen.c
index f40df62379..28584850e4 100644
--- a/src/pki/commands/gen.c
+++ b/src/pki/commands/gen.c
@@ -38,35 +38,7 @@ static int gen()
case 'h':
return command_usage(NULL);
case 't':
- if (streq(arg, "rsa"))
- {
- type = KEY_RSA;
- }
- else if (streq(arg, "ecdsa"))
- {
- type = KEY_ECDSA;
- }
- else if (streq(arg, "ed25519"))
- {
- type = KEY_ED25519;
- }
- else if (streq(arg, "ed448"))
- {
- type = KEY_ED448;
- }
- else if (streq(arg, "mldsa44"))
- {
- type = KEY_ML_DSA_44;
- }
- else if (streq(arg, "mldsa65"))
- {
- type = KEY_ML_DSA_65;
- }
- else if (streq(arg, "mldsa87"))
- {
- type = KEY_ML_DSA_87;
- }
- else
+ if (!key_type_from_string(arg, FALSE, &type) || type == KEY_ANY)
{
return command_usage("invalid key type");
}
@@ -188,12 +160,11 @@ static void __attribute__ ((constructor))reg()
{
command_register((command_t) {
gen, 'g', "gen", "generate a new private key",
- {"[--type rsa|ecdsa|ed25519|ed448|mldsa44|mldsa65|mldsa87]",
- "[--size bits] [--curve <name|oid>] [--safe-primes]",
+ {"[--type <key type>] [--size bits] [--curve <name|oid>] [--safe-primes]",
"[--shares n] [--threshold l] [--outform der|pem]"},
{
{"help", 'h', 0, "show usage information"},
- {"type", 't', 1, "type of key, default: rsa"},
+ {"type", 't', 1, "type of key (see man page), default: rsa"},
{"size", 's', 1, "keylength in bits, default: rsa 2048, ecdsa 384"},
{"curve", 'c', 1, "curve for ecdsa key (name or oid, --size is ignored)"},
{"safe-primes", 'p', 0, "generate rsa safe primes"},
diff --git a/src/pki/man/pki---gen.1.in b/src/pki/man/pki---gen.1.in
index 96bc083d68..acd6fecaac 100644
--- a/src/pki/man/pki---gen.1.in
+++ b/src/pki/man/pki---gen.1.in
@@ -2,7 +2,7 @@
.
.SH "NAME"
.
-pki \-\-gen \- Generate a new RSA or ECDSA private key
+pki \-\-gen \- Generate a new private key
.
.SH "SYNOPSIS"
.
@@ -31,7 +31,7 @@ pki \-\-gen \- Generate a new RSA or ECDSA private key
.
This sub-command of
.BR pki (1)
-is used to generate a new RSA or ECDSA private key.
+is used to generate a new private key.
.
.SH "OPTIONS"
.
@@ -47,8 +47,8 @@ Read command line options from \fIfile\fR.
.TP
.BI "\-t, \-\-type " type
Type of key to generate. Either \fIrsa\fR, \fIecdsa\fR, \fIed25519\fR,
-\fIed448\fR, \fImldsa44\fR, \fImldsa65\fR or \fImldsa87\fR, defaults to
-\fIrsa\fR.
+\fIed448\fR, \fImldsa44\fR, \fImldsa65\fR, \fImldsa87\fR or one of the composite
+key types listed below, defaults to \fIrsa\fR.
.TP
.BI "\-s, \-\-size " bits
Key length in bits. Defaults to 2048 for \fIrsa\fR and 384 for \fIecdsa\fR.
@@ -99,6 +99,65 @@ keys. The names/aliases are matched case-insensitive.
.B "bp512, brainpoolP512r1"
512-bit Brainpool curve (1.3.36.3.3.2.8.1.1.13)
.
+.SH "COMPOSITE KEY TYPES"
+.
+The following composite key types, which combine ML-DSA with a traditional
+algorithm, are supported given the required plugins are loaded:
+.TP
+.B "mldsa44+rsa2048pss, MLDSA44_RSA2048_PSS"
+ML-DSA-44 with 2048-bit RSA using RSASSA-PSS
+.TP
+.B "mldsa44+rsa2048pkcs15, MLDSA44_RSA2048_PKCS15"
+ML-DSA-44 with 2048-bit RSA using RSASSA-PKCS1-v1_5
+.TP
+.B "mldsa44+ed25519, MLDSA44_ED25519"
+ML-DSA-44 with Ed25519
+.TP
+.B "mldsa44+ecdsa256, MLDSA44_ECDSA_P256"
+ML-DSA-44 with 256-bit ECDSA using curve P-256/secp256r1
+.TP
+.B "mldsa65+rsa3072pss, MLDSA65_RSA3072_PSS"
+ML-DSA-65 with 3072-bit RSA using RSASSA-PSS
+.TP
+.B "mldsa65+rsa3072pkcs15, MLDSA65_RSA3072_PKCS15"
+ML-DSA-65 with 3072-bit RSA using RSASSA-PKCS1-v1_5
+.TP
+.B "mldsa65+rsa4096pss, MLDSA65_RSA4096_PSS"
+ML-DSA-65 with 4096-bit RSA using RSASSA-PSS
+.TP
+.B "mldsa65+rsa4096pkcs15, MLDSA65_RSA4096_PKCS15"
+ML-DSA-65 with 4096-bit RSA using RSASSA-PKCS1-v1_5
+.TP
+.B "mldsa65+ecdsa256, MLDSA65_ECDSA_P256"
+ML-DSA-65 with 256-bit ECDSA using curve P-256/secp256r1
+.TP
+.B "mldsa65+ecdsa384, MLDSA65_ECDSA_P384"
+ML-DSA-65 with 384-bit ECDSA using curve P-384/secp384r1
+.TP
+.B "mldsa65+ecdsa256bp, MLDSA65_ECDSA_BPP256R1"
+ML-DSA-65 with 256-bit ECDSA using curve brainpoolP256r1
+.TP
+.B "mldsa65+ed25519, MLDSA65_ED25519"
+ML-DSA-65 with Ed25519
+.TP
+.B "mldsa87+ecdsa384, MLDSA87_ECDSA_P384"
+ML-DSA-87 with 384-bit ECDSA using curve P-384/secp384r1
+.TP
+.B "mldsa87+ecdsa384bp, MLDSA87_ECDSA_BPP384R1"
+ML-DSA-87 with 384-bit ECDSA using curve brainpoolP384r1
+.TP
+.B "mldsa87+ed448, MLDSA87_ED448"
+ML-DSA-87 with Ed448
+.TP
+.B "mldsa87+rsa3072pss, MLDSA87_RSA3072_PSS"
+ML-DSA-87 with 3072-bit RSA using RSASSA-PSS
+.TP
+.B "mldsa87+rsa4096pss, MLDSA87_RSA4096_PSS"
+ML-DSA-87 with 4096-bit RSA using RSASSA-PSS
+.TP
+.B "mldsa87+ecdsa521, MLDSA87_ECDSA_P521"
+ML-DSA-87 with 521-bit ECDSA using curve P-521/secp521r1
+.
.SH "PROBLEMS ON HOSTS WITH LOW ENTROPY"
.
If the
diff --git a/src/swanctl/swanctl.opt b/src/swanctl/swanctl.opt
index 9053a23c32..ced2e7b169 100644
--- a/src/swanctl/swanctl.opt
+++ b/src/swanctl/swanctl.opt
@@ -694,13 +694,14 @@ connections.<conn>.remote<suffix>.auth = pubkey
specify the key type followed by one or more accepted hash algorithms (e.g.
_pubkey-sha256-sha512_ or _ecdsa-sha384_). For EdDSA, ML-DSA and composite
keys use _identity_ as hash algorithm (e.g. _ed25519-identity_,
- _mldsa87-identity_ or _mldsa65+ed25519-identity_). See **pki --gen**(1) for
- a list of supported composite key types. To require a specific public key
- strength for RSA or ECDSA, specify the key type followed by the minimum
- strength in bits (e.g. _ecdsa-384_ or _rsa-3072-ecdsa-384_). Note that this
- does not enforce the key type/signature scheme if no hash is specified after
- the strength. To restrict the elliptic curves accepted for ECDSA public keys
- in the trustchain, append one or more curve names or OIDs to an _ecdsa_ key
+ _mldsa87-identity_, _mldsa65+ed25519-identity_ or
+ _MLDSA87_ED448-identity_). See **pki --gen**(1) for a list of supported
+ composite key types. To require a specific public key strength for RSA or
+ ECDSA, specify the key type followed by the minimum strength in bits (e.g.
+ _ecdsa-384_ or _rsa-3072-ecdsa-384_). Note that this does not enforce the
+ key type/signature scheme if no hash is specified after the strength. To
+ restrict the elliptic curves accepted for ECDSA public keys in the
+ trustchain, append one or more curve names or OIDs to an _ecdsa_ key
type (for example _ecdsa-p256-sha256_, _ecdsa-1.3.36.3.3.2.8.1.1.11-sha384_
or _ecdsa-p384-brainpoolP384r1-sha384_). Again, without hash algorithm, this
does not enforce the signature scheme (i.e. curves will only be enforced if