Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: IMEI/IMEISV validation and test cases #30

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

williamlin0518
Copy link

@williamlin0518 williamlin0518 commented Jan 8, 2025

This fix is related to issue #624

  • Add proper IMEI checksum validation using Luhn algorithm
  • Add IMEI/IMEISV length validation
  • Add test cases for IMEI/IMEISV validation

nasConvert/MobileIdentity5GS_test.go Outdated Show resolved Hide resolved
nasConvert/MobileIdentity5GS.go Outdated Show resolved Hide resolved
@andy89923
Copy link
Contributor

Note

  • TS23.003 Numbering, addressing and identification -> IMEI/IMEISV/PEI
    • Annex B: IMEI Check Digit computation

Copy link
Contributor

@andy89923 andy89923 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @williamlin0518 ,

Overall, it's LGTM!
Try to replace NAS package in free5gc and test the functionalities.
Please report the result here, thanks.

} else {
if len(digitStr) != 16 {
return "", fmt.Errorf("invalid IMEISV length: expected 16 digits, got %d", len(digitStr))
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not validate IMEISV here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMEISV contains the first 14 digits of IMEI (TAC+SNR) and 2 digits of Software Version Number (SVN).

There is no Checksum or algorithm applied to IMEISV, so I think he only checks the length of the digits for now.

TS23.003

image

@williamlin0518
Copy link
Author

I have tested the NAS package integration by:

replace (
	github.com/free5gc/nas => #my nas repo
)

Running full test suite comparison:

  1. Ran tests with original NAS package
  2. Ran tests with my NAS implementation
  3. Compared test results (diff) between both versions

Results:
test.txt

  1. No direct NAS-related test failures
  2. Test outputs identical between original and new NAS implementation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants