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:
parent
6b0d6341d3
commit
ed2a009425
7 changed files with 233 additions and 68 deletions
|
|
@ -29,6 +29,7 @@ export module Imsd:Messages;
|
|||
import std;
|
||||
import :Util;
|
||||
import :Aka;
|
||||
import :Ipsec;
|
||||
import :Sip;
|
||||
|
||||
export namespace imsd::msg {
|
||||
|
|
@ -47,7 +48,9 @@ export namespace imsd::msg {
|
|||
// of every request we send over it. TCP unless the engine fell back
|
||||
// to, or was told to use, UDP.
|
||||
std::string transport = "TCP";
|
||||
std::string ealgOffer = "aes-cbc";
|
||||
// The ESP ciphers Security-Client offers, in order (canonical names:
|
||||
// imsd::ipsec::ParseEalgOffer).
|
||||
std::vector<std::string> ealgOffer = imsd::ipsec::DefaultEalgOffer();
|
||||
// RFC 7254 IMEI URN for +sip.instance (e.g. urn:gsma:imei:35999999-
|
||||
// 000000-1); empty omits the parameter.
|
||||
std::string instanceId;
|
||||
|
|
@ -101,12 +104,18 @@ export namespace imsd::msg {
|
|||
return std::format("Via: SIP/2.0/{} {};branch=z9hG4bK{};rport", transport, imsd::util::HostPort(c.local, port), branch);
|
||||
}
|
||||
|
||||
// Security-Client value: the SPIs and protected ports offered for the SA
|
||||
// pairs this REGISTER may set up — the in-use ones on an initial
|
||||
// registration, new SPIs and a new client port on a reregistration
|
||||
// (TS 24.229 5.1.1.4.2 d; TS 33.203 7.4.0: the server port stays).
|
||||
// Security-Client value: one mechanism per offered cipher, each with the
|
||||
// SPIs and protected ports offered for the SA pairs this REGISTER may
|
||||
// set up — the in-use ones on an initial registration, new SPIs and a
|
||||
// new client port on a reregistration (TS 24.229 5.1.1.4.2 d; TS 33.203
|
||||
// 7.4.0: the server port stays). One pair of SPIs and one of ports for
|
||||
// the whole list (TS 33.203 7.2 NOTE 1, NOTE 2), the mechanisms
|
||||
// comma-separated in one header field (Annex H).
|
||||
inline std::string SecurityClient(const Context& c, std::uint32_t spiUc, std::uint32_t spiUs, int portUc, int portUs) {
|
||||
return std::format("Security-Client: ipsec-3gpp; alg=hmac-sha-1-96; ealg={}; " "spi-c={}; spi-s={}; port-c={}; port-s={}", c.ealgOffer, spiUc, spiUs, portUc, portUs);
|
||||
std::string v;
|
||||
for (const std::string& ealg : c.ealgOffer)
|
||||
v += std::format("{}ipsec-3gpp; alg=hmac-sha-1-96; ealg={}; " "spi-c={}; spi-s={}; port-c={}; port-s={}", v.empty() ? "" : ", ", ealg, spiUc, spiUs, portUc, portUs);
|
||||
return std::format("Security-Client: {}", v);
|
||||
}
|
||||
inline std::string SecurityClient(const Context& c, std::uint32_t spiUc, std::uint32_t spiUs) {
|
||||
return SecurityClient(c, spiUc, spiUs, c.portUc, c.portUs);
|
||||
|
|
|
|||
Loading…
Reference in a new issue