ipsec, messages, imsd: the offered ESP ciphers are a list

imsd's Security-Client held one mechanism, its cipher the value of EALG,
aes-cbc when unset. TS 33.203 7.2 has the UE's first REGISTER carry "a
list of identifiers for the integrity and encryption algorithms, which
the UE supports", and imsd can install three ciphers: an offer of one
could not say so.

EALG is now a comma-separated list, offered in the order written: one
mechanism per cipher in a single Security-Client, each with the
REGISTER's SPIs and ports (7.2 NOTE 1, NOTE 2). The default stays
aes-cbc alone. A name imsd cannot install is ignored with a journal
line where it used to go out as written, `3des` is offered as
des-ede3-cbc, RFC 3329's name for it, a setting that names no cipher
gives the default, and the bring-up logs what is offered (`ESP ciphers
offered: …`).

An offer of more than one cipher needs a further rule for the 401's
list. O2 UK's P-CSCF lists six mechanisms and puts the SPIs on one: the
sha1 entry without a cipher for a null offer, the sha1 entry with
aes-cbc for an aes-cbc offer (2026-09-17, 2026-09-20). The second has
the higher q, so with both ciphers offered the highest-q offered entry
and the entry carrying the SPIs can be two entries. The entry carrying
the SPIs is therefore taken when it is the only such entry and one of
the offer; otherwise the highest-q offered entry, as before. With one
cipher offered the two name the same algorithms; they can differ in mod
or prot, and there the marked entry's are now taken, where 1.2.1 took
the highest-q entry's.

Tested: tests/Ipsec (the setting; the selection against two offered
ciphers) and tests/Messages (a Security-Client of two mechanisms); the
daemon of this commit against a stand-in P-CSCF on the workstation, with
one cipher offered and with two.
This commit is contained in:
Jorijn van der Graaf 2026-11-23 10:08:04 +01:00
commit ed2a009425
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
7 changed files with 233 additions and 68 deletions

View file

@ -212,6 +212,24 @@ int main() {
Check(r3same.contains("port-c=45061; port-s=45062\r\n"), "without a client port the in-use one is offered (the initial registration's second REGISTER)");
}
// ---- the offer: one mechanism per offered cipher, in the list's order,
// every one with the REGISTER's SPIs and ports
{
Check(c.ealgOffer == imsd::ipsec::DefaultEalgOffer(), "the default context offers the default list");
Context two = c;
two.ealgOffer = {"aes-cbc", "null"};
std::string r1 = BuildRegisterInitial(two, "REGCALLID@2001:db8::db43", "FTAG5678", "REGBRANCH123456", 7449812u, 176466735u);
Check(r1.contains("\r\nSecurity-Client: ipsec-3gpp; alg=hmac-sha-1-96; ealg=aes-cbc; spi-c=7449812; spi-s=176466735; port-c=45061; port-s=45062, ipsec-3gpp; alg=hmac-sha-1-96; ealg=null; spi-c=7449812; spi-s=176466735; port-c=45061; port-s=45062\r\n"), "two ciphers offered: two mechanisms in one Security-Client");
std::string auth = AuthAka(two, "NONCEXYZ", "CNONCE0123456789", "RESP0000");
std::string r2 = BuildRegisterProtected(two, "REGCALLID@2001:db8::db43", "FTAG5678", "REGBRANCH123456", 2, 7449812u, 176466735u, auth);
Check(r2.contains("\r\nSecurity-Client: ipsec-3gpp; alg=hmac-sha-1-96; ealg=aes-cbc; spi-c=7449812; spi-s=176466735; port-c=45061; port-s=45062, ipsec-3gpp; alg=hmac-sha-1-96; ealg=null; spi-c=7449812; spi-s=176466735; port-c=45061; port-s=45062\r\n"), "the protected REGISTER repeats the initial one's Security-Client (TS 33.203 Annex H)");
std::string r3 = BuildRegisterProtected(two, "REGCALLID@2001:db8::db43", "FTAG5678", "REGBRANCH123456", 3, 55555u, 66666u, auth, 45063);
Check(r3.contains("\r\nSecurity-Client: ipsec-3gpp; alg=hmac-sha-1-96; ealg=aes-cbc; spi-c=55555; spi-s=66666; port-c=45063; port-s=45062, ipsec-3gpp; alg=hmac-sha-1-96; ealg=null; spi-c=55555; spi-s=66666; port-c=45063; port-s=45062\r\n"), "a reregistration's new SPIs and client port in every mechanism");
two.ealgOffer = {"null", "des-ede3-cbc"};
std::string r4 = BuildRegisterInitial(two, "REGCALLID@2001:db8::db43", "FTAG5678", "REGBRANCH123456", 7449812u, 176466735u);
Check(r4.contains("\r\nSecurity-Client: ipsec-3gpp; alg=hmac-sha-1-96; ealg=null; spi-c=7449812; spi-s=176466735; port-c=45061; port-s=45062, ipsec-3gpp; alg=hmac-sha-1-96; ealg=des-ede3-cbc; spi-c=7449812; spi-s=176466735; port-c=45061; port-s=45062\r\n"), "the list's order is the header's order");
}
// ---- protected-leg transport follows Context.transport (SIP_TRANSPORT=udp,
// or the auto fallback): every protected request's Via says UDP, the
// challenge's Via stays UDP either way, and TCP is the untouched default.