aka: the ISIM application of a card, its identity files and the identity they hold
An ISIM holds the parameters a registration starts from (TS 24.229 5.1.1.1A): the private identity in EF_IMPI, the home domain in EF_DOMAIN and public identities in EF_IMPU (TS 31.103 4.2.2 to 4.2.4), of which the first record's is the one to register (GSMA IR.92 2.2.1). TS 23.003 has a UE derive its home domain and a temporary public identity from the IMSI "if there is no ISIM application" (13.2, 13.4B); those derived names are the only ones imsd has. This is the part of reading an ISIM that has no I/O; the daemon does not use it yet. ParseIsimApp finds the ISIM application of one slot in qmicli's card status, in whatever state the modem lists it. On the two cards with an ISIM that a read-only probe read (a US card, 2026-11-23, and a Norwegian one, 2026-11-21) the Fairphone 6's modem lists the ISIM `detected` beside the `ready` USIM, and on both a logical channel opened on it and its identity files were read. The commands are the ones that probe sent: SELECT by file identifier, READ BINARY, READ RECORD (TS 102 221 11.1.1, 11.1.3, 11.1.5). ApduAnswer is a card's answer, '90 00', '91 XX' and '92 XX' its normal endings (10.2.1.1), and ApduFollowUp the command it asks for next when the answer brought no data: GET RESPONSE for '61 XX', a command without data again with the length named for '6C XX' (7.3.1.1.5); an answer with data is taken for the command's last. HoldsRead takes a read's data under the warning '62 82' as well (10.2.1.3). ParseIsimValue takes the value of the data object with tag '80' that a file begins with, cuts 'FF' bytes from the end of its length as the probe does, and gives none for a value with a blank or a byte that is not printable ASCII. IsimIdentity checks the three values before they replace the derived names: they are written into a quoted string and between the angle brackets of SIP header fields. It refuses a value with a quote, a backslash, an angle bracket, a blank, a line break or another byte outside printable ASCII, a private or a public identity of more than 255 characters, a private identity without an @ between two parts, a domain that is not labels of letters, digits and inner hyphens, 63 characters a label and 253 in all at most, and a public identity that does not begin sip: or is that alone. The two readers of the card status share how they read a line; ParseCardStatus gives what it gave. Tested: tests/Aka (the application out of a card status with the US card's two applications, in either order, and out of a second slot with the Norwegian card's AID; the commands, the answers and their follow-ups, the values, the identity and what is refused) and tests/Messages (the two REGISTERs of an ISIM's identity against the pinned ones).
This commit is contained in:
parent
460343e578
commit
3754687b0d
4 changed files with 653 additions and 46 deletions
|
|
@ -18,7 +18,9 @@
|
|||
// and left terminating access-domain selection routing incoming calls to
|
||||
// CS fallback (observed live 2026-07-20); and the REGISTERs' Security-Client
|
||||
// carries the default offer's two mechanisms, where the Python stack offered
|
||||
// one cipher. Then the SMS over IP shapes: the
|
||||
// one cipher. The two REGISTERs once more on an identity an ISIM holds: the
|
||||
// pinned ones with the card's names in place of the derived ones. Then the
|
||||
// SMS over IP shapes: the
|
||||
// +g.3gpp.smsip Contact tag behind Context::smsOverIp, the MESSAGE carrying
|
||||
// an RP-DATA to the service centre and the one carrying an RP-ACK to the
|
||||
// IP-SM-GW with In-Reply-To (TS 24.341 5.3.1.2, 5.3.2.4), and a final other
|
||||
|
|
@ -251,6 +253,42 @@ int main() {
|
|||
Check(BuildRegisterProtected(c, "REGCALLID@2001:db8::db43", "FTAG5678", "REGBRANCH123456", 2, 7449812u, 176466735u, auth).contains("\r\nVia: SIP/2.0/TCP [2001:db8::db43]:45062;"), "default transport stays TCP");
|
||||
}
|
||||
|
||||
// ---- the REGISTERs of an identity an ISIM holds (imsd::aka::IsimIdentity):
|
||||
// every name is the card's — the Request-URI the home domain's, From and
|
||||
// To the public identity, the digest's username the private identity,
|
||||
// its realm the home domain; the rest of the message is the one pinned
|
||||
// above.
|
||||
{
|
||||
Context ci = c;
|
||||
ci.id = *imsd::aka::IsimIdentity(c.id, "001010123456789@private.example.net", "one.example.net", "sip:001010123456789@one.example.net");
|
||||
std::string want1(Reg1);
|
||||
auto swap = [](std::string& s, std::string_view from, std::string_view to) {
|
||||
int n = 0;
|
||||
for (std::size_t at = s.find(from); at != std::string::npos; at = s.find(from, at + to.size())) { s.replace(at, from.size(), to); n++; }
|
||||
return n;
|
||||
};
|
||||
Check(swap(want1, "REGISTER sip:ims.mnc001.mcc001.3gppnetwork.org SIP/2.0", "REGISTER sip:one.example.net SIP/2.0") == 1, "the pinned REGISTER has one Request-URI");
|
||||
Check(swap(want1, "<sip:001010123456789@ims.mnc001.mcc001.3gppnetwork.org>", "<sip:001010123456789@one.example.net>") == 2, "the pinned REGISTER has the public identity in From and To");
|
||||
Check(swap(want1, "username=\"001010123456789@ims.mnc001.mcc001.3gppnetwork.org\", realm=\"ims.mnc001.mcc001.3gppnetwork.org\", uri=\"sip:ims.mnc001.mcc001.3gppnetwork.org\"",
|
||||
"username=\"001010123456789@private.example.net\", realm=\"one.example.net\", uri=\"sip:one.example.net\"") == 1, "the pinned REGISTER has one digest");
|
||||
Check(!want1.contains("3gppnetwork.org"), "no derived name is left in the expected REGISTER");
|
||||
Eq(BuildRegisterInitial(ci, "REGCALLID@2001:db8::db43", "FTAG5678", "REGBRANCH123456", 7449812u, 176466735u), want1, "unprotected REGISTER of an ISIM's identity");
|
||||
|
||||
std::string want2(Reg2);
|
||||
swap(want2, "REGISTER sip:ims.mnc001.mcc001.3gppnetwork.org SIP/2.0", "REGISTER sip:one.example.net SIP/2.0");
|
||||
swap(want2, "<sip:001010123456789@ims.mnc001.mcc001.3gppnetwork.org>", "<sip:001010123456789@one.example.net>");
|
||||
swap(want2, "username=\"001010123456789@ims.mnc001.mcc001.3gppnetwork.org\", realm=\"ims.mnc001.mcc001.3gppnetwork.org\", uri=\"sip:ims.mnc001.mcc001.3gppnetwork.org\"",
|
||||
"username=\"001010123456789@private.example.net\", realm=\"one.example.net\", uri=\"sip:one.example.net\"");
|
||||
Check(!want2.contains("3gppnetwork.org"), "no derived name is left in the expected protected REGISTER");
|
||||
std::string auth = AuthAka(ci, "NONCEXYZ", "CNONCE0123456789", "RESP0000");
|
||||
Eq(BuildRegisterProtected(ci, "REGCALLID@2001:db8::db43", "FTAG5678", "REGBRANCH123456", 2, 7449812u, 176466735u, auth), want2, "protected REGISTER of an ISIM's identity");
|
||||
// the Contact keeps the binding's own user-part: the IMSI here, as in
|
||||
// the pinned message (an old state file's shape)
|
||||
Check(BuildRegisterInitial(ci, "REGCALLID@2001:db8::db43", "FTAG5678", "REGBRANCH123456", 7449812u, 176466735u).contains("\r\nContact: <sip:001010123456789@[2001:db8::db43]:5060>"), "the Contact is not the public identity");
|
||||
// RuriFor with a home domain that is not a derived one
|
||||
Eq(RuriFor("+31612345678", ci.id.domain), "sip:+31612345678@one.example.net;user=phone", "RuriFor puts a number at the domain it is given, an ISIM's here");
|
||||
}
|
||||
|
||||
// ---- RuriFor variants
|
||||
Eq(RuriFor("1233", c.id.domain), "sip:1233;phone-context=ims.mnc001.mcc001.3gppnetwork.org@ims.mnc001.mcc001.3gppnetwork.org;user=phone", "ruri short code");
|
||||
Eq(RuriFor("+31612345678", c.id.domain), "sip:+31612345678@ims.mnc001.mcc001.3gppnetwork.org;user=phone", "ruri E.164");
|
||||
|
|
|
|||
Loading…
Reference in a new issue