{"id":13566999,"url":"https://github.com/iotconnectivity/kiopcgenerator","last_synced_at":"2025-04-04T01:30:55.219Z","repository":{"id":56067963,"uuid":"180999703","full_name":"iotconnectivity/kiopcgenerator","owner":"iotconnectivity","description":"Ki/OPc USIM card keys geneartion. This script will produce Ki/eKi/OPc triplets given the Op and Transport keys.","archived":false,"fork":false,"pushed_at":"2024-01-05T18:02:19.000Z","size":43,"stargazers_count":40,"open_issues_count":7,"forks_count":18,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-10-14T20:03:20.607Z","etag":null,"topics":["gsm","ki","opc","sim","simcard","sims","smartcard","telecoms","usims"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iotconnectivity.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-04-12T12:03:17.000Z","updated_at":"2024-09-20T13:34:02.000Z","dependencies_parsed_at":"2024-01-08T17:17:47.361Z","dependency_job_id":"d05d5d4f-45b1-4f9d-8777-2aec740bab6a","html_url":"https://github.com/iotconnectivity/kiopcgenerator","commit_stats":null,"previous_names":["iotconnectivity/kiopcgenerator"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iotconnectivity%2Fkiopcgenerator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iotconnectivity%2Fkiopcgenerator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iotconnectivity%2Fkiopcgenerator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iotconnectivity%2Fkiopcgenerator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iotconnectivity","download_url":"https://codeload.github.com/iotconnectivity/kiopcgenerator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247043339,"owners_count":20874086,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gsm","ki","opc","sim","simcard","sims","smartcard","telecoms","usims"],"created_at":"2024-08-01T13:02:21.277Z","updated_at":"2025-04-04T01:30:54.926Z","avatar_url":"https://github.com/iotconnectivity.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Ki/OPc Generator\n\nKi/OPc USIM card keys geneartion. This script will produce Ki/eKi/OPc triplets given the Op and Transport keys.\n\nOPc was the ultimate key that is generated from OP and Ki (secret Key). \nGenerate your Ki secret keys and grab the OP and Transport keys from your carrier.\n\n**NOTE**: This package has been tested with Python3.6.9 and Python3.8\n\n## Table of Contents\n\n- [Description](#description)\n- [Usage](#usage)\n- [Installation](#installation)\n- [Support](#support)\n- [Contributing](#contributing)\n\n## Description\n\nOP: Operator Code : It is allotted to an operator and used in key generation algorithms of 3G and 4G. It is not shown as a part of input, because it is not specific to a user/Subscriber/SIM. It remains fix for all Subscriber/SIM of an operator that is why it is not used as an input to key generation algorithms. This OP (a 128-bits Operator Variant Algorithm Configuration Field )value is passed to an encryption algorithm (\"RijndaelEncrypt\") to generate OPc and OPc is used in all f1,f2,f3,f4,f5 functions internally to generate various keys.\n\nAs OP value is single, same to all subscriber/SIM. If someone knows it then there can be a possibility of spoofing of all SIM, because all SIMs are using the same value of OP. So Operator come up with the solution that they shall provision OPc rather than OP in AuC or HLR/HSS. When f1,f2....f5 get the OPc they doesn't generate it from OP; received OPC is used in vector generation. There is no reverse engineering for OP from OPC.\n\nBasically OPc was the ultimate key that is generated from OP and KEy (secret Key) by using  (\"RijndaelEncrypt\") algorithm which is specific to SIM. if some one able to theft OPc then it can spoof only single SIM not all the SIMs.\n\nOPc=Encypt-Algo(OP,Key)\nOPc -[128 Bits]\n\nTransport Key (64-Bits) : This key is used as a Lock to KEY (secret key) and OPc. When authentication credentials are to be provisioned at AuC or HLR/HSS; then they are provisioned in encrypted form rather then plain and this encryption is done by Transport Key. \nWhen authentication credentials are to be used in Authentication Generation then; all fields are decrypted  to plain key by transport key; and now plain key is used f1,f2,f3,f4,f5 algorithms.\n\n## Usage\n\nUse from the command line with the **kiopcgen** tool:\n\n```\nUsage: kiopcgen [options]\n\nOptions:\n  -h, --help                  show this help message and exit\n  -o OP, --op=OP              32 char OP key\n  -t TRANS, --transport=TRANS 32 char Transport key\n  -k KI, --ki=KI              Optional 32 char Ki key (to avoid random generation)\n\n$ kiopcgen  -o D7DECB1F50404CC29ECBF989FE73AFC5 -t 2257CC6E9746434B89F346F0276CCAEC\n{'KI': '780E6AC95A2E43449C15BDCDD0450982',\n 'OPC': '2274B84B8043105A28AABBE53EF1D014',\n 'eKI': '4601138387FCF7D666ED24BBB3EE37B8'}\n\n$ kiopcgen -o D7DECB1F50404CC29ECBF989FE73AFC5 -t 2257CC6E9746434B89F346F0276CCAEC -k 8978B79E7C104F678FA5C336509DB188\n{'KI': '8978B79E7C104F678FA5C336509DB188',\n 'OPC': '6F2E82855DEE7C893CB1F7A72FD08B57',\n 'eKI': 'FBE8C170F6A5C6C257E5324719674818'}\n```\n\nOr import the kiopcgenerator module to use in your scripts\n\n```python\nimport pprint\nimport uuid\nimport kiopcgenerator\n \nop = \"D7DECB1F50404CC29ECBF989FE73AFC5\"\ntransport = \"2257CC6E9746434B89F346F0276CCAEC\"\nki = kiopcgenerator.gen_ki() # Generates random ki\n\nprint (ki)\n# EBD77DF6CFF949448ACF82B8FE4E59E3\nprint (kiopcgenerator.gen_opc(op, ki))\n# 33244F04A86408A53110D1FCAFD04288\nprint (kiopcgenerator.gen_eki(transport, ki))\n# 8FAC9FE22D306EA4CB86279B3473D8CB\nprint (kiopcgenerator.gen_opc_eki(op, transport, ki))\n# {'KI': 'EBD77DF6CFF949448ACF82B8FE4E59E3', 'eKI': '8FAC9FE22D306EA4CB86279B3473D8CB', 'OPC': '33244F04A86408A53110D1FCAFD04288'}\n```\n\n## Installation\n\nBefore install this you need to setup below dependency:\n\n```\nFor Python 3.x\n$ sudo apt-get install python3-dev\n\nFor Python 3.4\n$ sudo apt-get install python3.4-dev\n\nFor Python 3.6.x\n$ sudo apt-get install python3.6-dev\n\nFor Python 3.7\n$ sudo apt-get install python3.7-dev\n\nFor Python 3.8\n$ sudo apt-get install python3.8-dev\n```\n\nUsing PyPI repository\n\n```\n$ pip install git+https://github.com/PodgroupConnectivity/kiopcgenerator#egg=kiopcgenerator\n```\n\nFrom source code\n\n```\n$ python setup.py install\n```\n\nNOTE: You may want to install the dependencies in advance, if you haven't yet.\n```\n$ pip install -r requirements.txt\n```\n\n## Support\n\nPlease [open an issue](https://github.com/PodgroupConnectivity/kiopcgenerator/issues/new) for support.\n\n## Contributing\n\nPlease contribute using [Github Flow](https://guides.github.com/introduction/flow/). Create a branch, add commits, and open a pull request.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiotconnectivity%2Fkiopcgenerator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiotconnectivity%2Fkiopcgenerator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiotconnectivity%2Fkiopcgenerator/lists"}