laforge has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/pysim/+/35682?usp=email )


Change subject: add contrib/eidtool.py: Tool for checking + computing EID 
checksum
......................................................................

add contrib/eidtool.py: Tool for checking + computing EID checksum

Change-Id: If6c560a2de51718948fb99b816e080f2aff4d0ed
---
A contrib/eidtool.py
1 file changed, 45 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/82/35682/1

diff --git a/contrib/eidtool.py b/contrib/eidtool.py
new file mode 100755
index 0000000..1e2f568
--- /dev/null
+++ b/contrib/eidtool.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python3
+
+import sys
+import argparse
+
+from pySim.euicc import compute_eid_checksum, verify_eid_checksum
+
+
+option_parser = argparse.ArgumentParser(description='EID tool')
+group = option_parser.add_mutually_exclusive_group(required=True)
+group.add_argument('--verify', help='Verify given EID csum')
+group.add_argument('--compute', help='Generate EID csum')
+option_parser.add_argument('--add', type=int, help='Add value to EID base 
before computing')
+
+
+if __name__ == '__main__':
+    opts = option_parser.parse_args()
+
+    if opts.verify:
+        res = verify_eid_checksum(opts.verify)
+        if res:
+            print("EID checksum verified successfully")
+            sys.exit(0)
+        else:
+            print("EID checksum invalid")
+            sys.exit(1)
+    elif opts.compute:
+        eid = opts.compute
+        if opts.add:
+            if len(eid) != 30:
+                print("EID base must be 30 digits when using --add")
+                sys.exit(2)
+            eid = str(int(eid) + int(opts.add))
+        res = compute_eid_checksum(eid)
+        print(res)
+

--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35682?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: If6c560a2de51718948fb99b816e080f2aff4d0ed
Gerrit-Change-Number: 35682
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <lafo...@osmocom.org>
Gerrit-MessageType: newchange

Reply via email to