pySim.esim: Add class for parsing/encoding eSIM activation codes

Change-Id: I2256722c04b56e8d9c16a65e3cd94f6a46f4ed85
This commit is contained in:
Harald Welte
2024-01-30 21:15:39 +01:00
parent d7715043a3
commit 93bdf00967
2 changed files with 90 additions and 0 deletions

View File

@@ -22,9 +22,22 @@ import base64
from pySim.utils import b2h, h2b
from pySim.esim.bsp import *
import pySim.esim.rsp as rsp
from pySim.esim import ActivationCode
from cryptography.hazmat.primitives.asymmetric import ec
class TestActivationCode(unittest.TestCase):
def test_de_encode(self):
STRS = ['1$SMDP.GSMA.COM$04386-AGYFT-A74Y8-3F815',
'1$SMDP.GSMA.COM$04386-AGYFT-A74Y8-3F815$$1',
'1$SMDP.GSMA.COM$04386-AGYFT-A74Y8-3F815$1.3.6.1.4.1.31746$1',
'1$SMDP.GSMA.COM$04386-AGYFT-A74Y8-3F815$1.3.6.1.4.1.31746',
'1$SMDP.GSMA.COM$$1.3.6.1.4.1.31746']
for s in STRS:
ac = ActivationCode.from_string(s)
self.assertEqual(s, ac.to_string())
class TestECKA(unittest.TestCase):
def test_mode51(self):
curve = ec.SECP256R1()