diff options
author | Neels Hofmeyr <neels@hofmeyr.de> | 2020-06-10 17:31:18 +0200 |
---|---|---|
committer | neels <nhofmeyr@sysmocom.de> | 2020-06-14 10:52:48 +0000 |
commit | 16617816114f31bc9560c9646b4f566259f3b4a3 (patch) | |
tree | 167f668e4ae0d8a7424259e2029b64253ae5ee8e | |
parent | 15a850123243701c538dd110719ce5789820029e (diff) |
fix f_enc_IMEI_L3() oddevenIndicator
f_gen_imei() calls f_enc_IMEI_L3() with a 14 digits argument, but the IMEI_L3
template used is hardcoded to 15 digits. So the oddevenIndicator must always
indicate odd, not depend on the digits argument.
f_gen_imei() should probably also compose a Luhn checksum, leaving that to
another patch.
Found by using the new osmo_mobile_identity API in osmo-msc, which is stricter
about odd/even and filler digits than our previous implementations.
See osmo-msc Idfc8e576e10756aeaacf5569f6178068313eb7ea .
Change-Id: Iaa9ba1214c4c15fd9620e68fe2e842fdf52912c0
-rw-r--r-- | library/L3_Templates.ttcn | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/library/L3_Templates.ttcn b/library/L3_Templates.ttcn index 3032503b..ba911803 100644 --- a/library/L3_Templates.ttcn +++ b/library/L3_Templates.ttcn @@ -184,11 +184,20 @@ private function f_enc_IMSI_L3(hexstring digits) return IMSI_L3 { private function f_enc_IMEI_L3(hexstring digits) return IMEI_L3 { var IMEI_L3 l3; var integer len := lengthof(digits); - if (len rem 2 == 1) { /* modulo remainder */ - l3.oddevenIndicator := '1'B; - } else { - l3.oddevenIndicator := '0'B; - } + /* IMEI_L3 is always 15 digits. That is actually a 14 digit IMEI + a Luhn checksum digit (see + * libosmocore/include/osmocom/gsm/protocol/gsm_23_003.h) + * + * Here, we must not make the oddevenIndicator depend on the 'digits' parameter, because: + * - The IMEI_L3 template assumes always 15 digits. + * - The 'digits' parameter, however, may also contain less digits, 14 in the case of + * f_gen_imei(). + * - The IMEI_L3 template will then fill up with zeros to make 15 digits. + * Hence oddevenIndicator must always indicate 'odd' == '1'B. + * + * FIXME: if the caller passes less than 15 digits, the Luhn checksum digit then ends up zero == most probably + * wrong. + */ + l3.oddevenIndicator := '1'B; l3.digits := digits; return l3; } |