Commit d9b817f898 for strongswan.org
commit d9b817f8983dcb5fad7ed3426a209a1e0de303a9
Author: Tobias Brunner <tobias@strongswan.org>
Date: Wed Nov 25 09:04:22 2026 +0100
auth-cfg: Add support for composite key signature scheme constraints
Also matches strings case-insensitive.
diff --git a/src/libstrongswan/credentials/auth_cfg.c b/src/libstrongswan/credentials/auth_cfg.c
index a46cdb358e..b7def7c512 100644
--- a/src/libstrongswan/credentials/auth_cfg.c
+++ b/src/libstrongswan/credentials/auth_cfg.c
@@ -619,6 +619,26 @@ static struct {
{ "ecdsa", KEY_ECDSA, AUTH_RULE_ECDSA_STRENGTH, },
{ "ed25519", KEY_ED25519, AUTH_RULE_MAX, },
{ "ed448", KEY_ED448, AUTH_RULE_MAX, },
+ /* these are reordered slightly and have to precede the plain ML-DSA types
+ * for prefix matching */
+ { "mldsa44+rsa2048pss", KEY_MLDSA44_RSA2048_PSS, AUTH_RULE_MAX },
+ { "mldsa44+rsa2048pkcs15", KEY_MLDSA44_RSA2048_PKCS15, AUTH_RULE_MAX },
+ { "mldsa44+ed25519", KEY_MLDSA44_ED25519, AUTH_RULE_MAX },
+ { "mldsa44+ecdsa256", KEY_MLDSA44_ECDSA_P256, AUTH_RULE_MAX },
+ { "mldsa65+rsa3072pss", KEY_MLDSA65_RSA3072_PSS, AUTH_RULE_MAX },
+ { "mldsa65+rsa3072pkcs15", KEY_MLDSA65_RSA3072_PKCS15, AUTH_RULE_MAX },
+ { "mldsa65+rsa4096pss", KEY_MLDSA65_RSA4096_PSS, AUTH_RULE_MAX },
+ { "mldsa65+rsa4096pkcs15", KEY_MLDSA65_RSA4096_PKCS15, AUTH_RULE_MAX },
+ { "mldsa65+ecdsa256bp", KEY_MLDSA65_ECDSA_BPP256R1, AUTH_RULE_MAX },
+ { "mldsa65+ecdsa256", KEY_MLDSA65_ECDSA_P256, AUTH_RULE_MAX },
+ { "mldsa65+ecdsa384", KEY_MLDSA65_ECDSA_P384, AUTH_RULE_MAX },
+ { "mldsa65+ed25519", KEY_MLDSA65_ED25519, AUTH_RULE_MAX },
+ { "mldsa87+ecdsa384bp", KEY_MLDSA87_ECDSA_BPP384R1, AUTH_RULE_MAX },
+ { "mldsa87+ecdsa384", KEY_MLDSA87_ECDSA_P384, AUTH_RULE_MAX },
+ { "mldsa87+ed448", KEY_MLDSA87_ED448, AUTH_RULE_MAX },
+ { "mldsa87+rsa3072pss", KEY_MLDSA87_RSA3072_PSS, AUTH_RULE_MAX },
+ { "mldsa87+rsa4096pss", KEY_MLDSA87_RSA4096_PSS, AUTH_RULE_MAX },
+ { "mldsa87+ecdsa521", KEY_MLDSA87_ECDSA_P521, AUTH_RULE_MAX },
{ "mldsa44", KEY_ML_DSA_44, AUTH_RULE_MAX, },
{ "mldsa65", KEY_ML_DSA_65, AUTH_RULE_MAX, },
{ "mldsa87", KEY_ML_DSA_87, AUTH_RULE_MAX, },
@@ -633,14 +653,14 @@ static bool is_known_key_type(const char *str, bool prefix, key_type_t *type,
{
int i;
- if (strpfx(str, "ike:"))
+ if (strcasepfx(str, "ike:"))
{
str += 4;
}
for (i = 0; i < countof(known_key_types); i++)
{
- if ((prefix && strpfx(str, known_key_types[i].name)) ||
- (!prefix && streq(str, known_key_types[i].name)))
+ if ((prefix && strcasepfx(str, known_key_types[i].name)) ||
+ (!prefix && strcaseeq(str, known_key_types[i].name)))
{
if (type)
{
@@ -708,6 +728,24 @@ METHOD(auth_cfg_t, add_pubkey_constraints, void,
{ "identity", SIGN_ML_DSA_44, KEY_ML_DSA_44, },
{ "identity", SIGN_ML_DSA_65, KEY_ML_DSA_65, },
{ "identity", SIGN_ML_DSA_87, KEY_ML_DSA_87, },
+ { "identity", SIGN_MLDSA44_RSA2048_PSS, KEY_MLDSA44_RSA2048_PSS, },
+ { "identity", SIGN_MLDSA44_RSA2048_PKCS15, KEY_MLDSA44_RSA2048_PKCS15, },
+ { "identity", SIGN_MLDSA44_ED25519, KEY_MLDSA44_ED25519, },
+ { "identity", SIGN_MLDSA44_ECDSA_P256, KEY_MLDSA44_ECDSA_P256, },
+ { "identity", SIGN_MLDSA65_RSA3072_PSS, KEY_MLDSA65_RSA3072_PSS, },
+ { "identity", SIGN_MLDSA65_RSA3072_PKCS15, KEY_MLDSA65_RSA3072_PKCS15, },
+ { "identity", SIGN_MLDSA65_RSA4096_PSS, KEY_MLDSA65_RSA4096_PSS, },
+ { "identity", SIGN_MLDSA65_RSA4096_PKCS15, KEY_MLDSA65_RSA4096_PKCS15, },
+ { "identity", SIGN_MLDSA65_ECDSA_P256, KEY_MLDSA65_ECDSA_P256, },
+ { "identity", SIGN_MLDSA65_ECDSA_P384, KEY_MLDSA65_ECDSA_P384, },
+ { "identity", SIGN_MLDSA65_ECDSA_BPP256R1, KEY_MLDSA65_ECDSA_BPP256R1, },
+ { "identity", SIGN_MLDSA65_ED25519, KEY_MLDSA65_ED25519, },
+ { "identity", SIGN_MLDSA87_ECDSA_P384, KEY_MLDSA87_ECDSA_P384, },
+ { "identity", SIGN_MLDSA87_ECDSA_BPP384R1, KEY_MLDSA87_ECDSA_BPP384R1, },
+ { "identity", SIGN_MLDSA87_ED448, KEY_MLDSA87_ED448, },
+ { "identity", SIGN_MLDSA87_RSA3072_PSS, KEY_MLDSA87_RSA3072_PSS, },
+ { "identity", SIGN_MLDSA87_RSA4096_PSS, KEY_MLDSA87_RSA4096_PSS, },
+ { "identity", SIGN_MLDSA87_ECDSA_P521, KEY_MLDSA87_ECDSA_P521, },
};
if (expected_strength != AUTH_RULE_MAX)
@@ -729,7 +767,7 @@ METHOD(auth_cfg_t, add_pubkey_constraints, void,
key_token = token;
continue;
}
- if (key_token && strpfx(key_token, "ike:") && !ike)
+ if (key_token && strcasepfx(key_token, "ike:") && !ike)
{
continue;
}
@@ -746,7 +784,7 @@ METHOD(auth_cfg_t, add_pubkey_constraints, void,
chunk_free(&curve);
if (name)
{
- if (strpfx(key_token, "ike:"))
+ if (strcasepfx(key_token, "ike:"))
{
add(this, AUTH_RULE_IKE_ECDSA_CURVE, name);
ike_curve_added = TRUE;
@@ -760,12 +798,14 @@ METHOD(auth_cfg_t, add_pubkey_constraints, void,
}
}
- if (key_token && streq(key_token + strlen(key_token) - 3, "pss"))
+ if (key_token &&
+ strcaseeq(key_token + (strcasepfx(key_token, "ike:") ? 4 : 0),
+ "rsa/pss"))
{
params = create_rsa_pss_constraint(token);
if (params)
{
- if (strpfx(key_token, "ike:"))
+ if (strcasepfx(key_token, "ike:"))
{
add(this, AUTH_RULE_IKE_SIGNATURE_SCHEME, params);
ike_sig_added = TRUE;
@@ -787,7 +827,7 @@ METHOD(auth_cfg_t, add_pubkey_constraints, void,
params = create_rsa_pss_constraint(token);
if (params)
{
- if (strpfx(key_token, "ike:"))
+ if (strcasepfx(key_token, "ike:"))
{
add(this, AUTH_RULE_IKE_SIGNATURE_SCHEME, params);
ike_sig_added = TRUE;
@@ -802,7 +842,7 @@ METHOD(auth_cfg_t, add_pubkey_constraints, void,
}
for (i = 0; i < countof(schemes); i++)
{
- if (streq(schemes[i].name, token))
+ if (strcaseeq(schemes[i].name, token))
{
if (expected_type == KEY_ANY ||
expected_type == schemes[i].key)
@@ -810,7 +850,7 @@ METHOD(auth_cfg_t, add_pubkey_constraints, void,
INIT(params,
.scheme = schemes[i].scheme,
);
- if (strpfx(key_token, "ike:"))
+ if (strcasepfx(key_token, "ike:"))
{
add(this, AUTH_RULE_IKE_SIGNATURE_SCHEME, params);
ike_sig_added = TRUE;
diff --git a/src/libstrongswan/tests/suites/test_auth_cfg.c b/src/libstrongswan/tests/suites/test_auth_cfg.c
index 70c20cf081..c5d5069863 100644
--- a/src/libstrongswan/tests/suites/test_auth_cfg.c
+++ b/src/libstrongswan/tests/suites/test_auth_cfg.c
@@ -24,18 +24,32 @@ static struct {
signature_scheme_t ike[5];
} sig_constraints_tests[] = {
{ "rsa-sha256", { SIGN_RSA_EMSA_PKCS1_SHA2_256, 0 }, {0}},
+ { "RSA-sha256", { SIGN_RSA_EMSA_PKCS1_SHA2_256, 0 }, {0}},
+ { "rsa-SHA256", { SIGN_RSA_EMSA_PKCS1_SHA2_256, 0 }, {0}},
{ "rsa-sha256-sha512", { SIGN_RSA_EMSA_PKCS1_SHA2_256, SIGN_RSA_EMSA_PKCS1_SHA2_512, 0 }, {0}},
{ "ecdsa-sha256", { SIGN_ECDSA_WITH_SHA256_DER, SIGN_ECDSA_256, 0 }, {0}},
{ "rsa-sha256-ecdsa-sha256", { SIGN_RSA_EMSA_PKCS1_SHA2_256, SIGN_ECDSA_WITH_SHA256_DER, SIGN_ECDSA_256, 0 }, {0}},
{ "pubkey-sha256", { SIGN_RSA_EMSA_PKCS1_SHA2_256, SIGN_ECDSA_WITH_SHA256_DER, SIGN_ECDSA_256, 0 }, {0}},
{ "ike:rsa-sha256", {0}, { SIGN_RSA_EMSA_PKCS1_SHA2_256, 0 }},
+ { "IKE:rsa-sha256", {0}, { SIGN_RSA_EMSA_PKCS1_SHA2_256, 0 }},
{ "ike:rsa-sha256-rsa-sha256", { SIGN_RSA_EMSA_PKCS1_SHA2_256, 0 }, { SIGN_RSA_EMSA_PKCS1_SHA2_256, 0 }},
{ "rsa-sha256-ike:rsa-sha256", { SIGN_RSA_EMSA_PKCS1_SHA2_256, 0 }, { SIGN_RSA_EMSA_PKCS1_SHA2_256, 0 }},
+ { "rsa/pss-sha256", { SIGN_RSA_EMSA_PSS, 0 }, {0}},
+ { "rsa/PSS-sha256", { SIGN_RSA_EMSA_PSS, 0 }, {0}},
+ { "ike:rsa/pss-sha256", {0}, { SIGN_RSA_EMSA_PSS, 0 }},
{ "ike:pubkey-sha256", {0}, { SIGN_RSA_EMSA_PKCS1_SHA2_256, SIGN_ECDSA_WITH_SHA256_DER, SIGN_ECDSA_256, 0 }},
{ "rsa-ecdsa-sha256", { SIGN_ECDSA_WITH_SHA256_DER, SIGN_ECDSA_256, 0 }, {0}},
{ "rsa-4096-ecdsa-sha256", { SIGN_ECDSA_WITH_SHA256_DER, SIGN_ECDSA_256, 0 }, {0}},
{ "rsa-4096-ecdsa-256-sha256", { SIGN_ECDSA_WITH_SHA256_DER, SIGN_ECDSA_256, 0 }, {0}},
{ "rsa-ecdsa256-sha256", { SIGN_RSA_EMSA_PKCS1_SHA2_256, 0 }, {0}},
+ { "mldsa87-identity", { SIGN_ML_DSA_87, 0 }, {0}},
+ { "ike:mldsa87-identity", {0}, { SIGN_ML_DSA_87, 0 }},
+ { "mldsa87-identity-ike:mldsa87-identity", { SIGN_ML_DSA_87, 0 }, { SIGN_ML_DSA_87, 0 }},
+ { "mldsa87+ecdsa384-identity", { SIGN_MLDSA87_ECDSA_P384, 0 }, {0}},
+ { "ike:mldsa87+ecdsa384-identity", {0}, { SIGN_MLDSA87_ECDSA_P384, 0 }},
+ { "mldsa87+rsa4096pss-identity", { SIGN_MLDSA87_RSA4096_PSS, 0 }, {0}},
+ { "mldsa87+ecdsa384bp-identity", { SIGN_MLDSA87_ECDSA_BPP384R1, 0 }, {0}},
+ { "MLDSA87+ecdsa384BP-identity", { SIGN_MLDSA87_ECDSA_BPP384R1, 0 }, {0}},
{ "rsa4096-sha256", {0}, {0}},
{ "sha256", {0}, {0}},
{ "ike:sha256", {0}, {0}},
diff --git a/src/swanctl/swanctl.opt b/src/swanctl/swanctl.opt
index 6245c5c672..9053a23c32 100644
--- a/src/swanctl/swanctl.opt
+++ b/src/swanctl/swanctl.opt
@@ -692,21 +692,22 @@ connections.<conn>.remote<suffix>.auth = pubkey
To require specific signature schemes in the trustchain for the remote side,
specify the key type followed by one or more accepted hash algorithms (e.g.
- _pubkey-sha256-sha512_ or _ecdsa-sha384_). For EdDSA and ML-DSA use
- _identity_ as hash algorithm (e.g. _ed25519-identity_ or
- _mldsa87-identity_). 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
+ _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
+ 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
ECDSA was used in the trustchain). Multiple curves may be specified as
alternatives. Names are matched case-insensitive and support the aliases
- documented for _pki --gen_. However, hyphenated aliases like _p-256_ cannot
- be used here because dashes separate constraints.
+ documented for **pki --gen**(1). However, hyphenated aliases like _p-256_
+ cannot be used here because dashes separate constraints.
Unless disabled in **strongswan.conf**(5), or explicit IKEv2 signature
constraints are configured (refer to the description of the **local**