|
| 1 | +# 🛡️ DLMS Crypto Tool |
| 2 | + |
| 3 | +**DLMS Crypto Tool** is a Python package and command-line interface (CLI) utility for encrypting, decrypting, and authenticating DLMS APDU messages. It offers both a modular API for integration into your Python projects and a standalone CLI for quick operations. |
| 4 | + |
| 5 | +## ✨ Features |
| 6 | + |
| 7 | +- **🔒 Encryption:** Encrypts DLMS APDU messages. |
| 8 | +- **🔑 Decryption:** Decrypts APDU messages. |
| 9 | +- **🧾 Authentication:** Generates authentication tags. |
| 10 | +- **💻 CLI Interface:** Use command-line options to perform encryption, decryption, authentication, and key generation. |
| 11 | +- **📁 File I/O Support:** Optionally load input data from files and output results to files. |
| 12 | +- **📝 Verbose Mode:** Provides detailed logging for debugging and traceability. |
| 13 | +- **📚 Documentation:** Detailed docs generated using MkDocs to guide you through using the tool. |
| 14 | + |
| 15 | +## 🚀 Requirements |
| 16 | + |
| 17 | +- Python 3.6 or higher |
| 18 | +- [cryptography](https://pypi.org/project/cryptography/) |
| 19 | + |
| 20 | +## 📦 Installation |
| 21 | + |
| 22 | +Install **DLMS Crypto Tool** from PyPI using pip: |
| 23 | + |
| 24 | +``` |
| 25 | +pip install dlms_crypto_tool |
| 26 | +``` |
| 27 | + |
| 28 | +Alternatively, clone the repository and install locally: |
| 29 | + |
| 30 | +``` |
| 31 | +git clone https://github.com/ric-geek/dlms-encrypt-decrypt-tool.git |
| 32 | +cd dlmscrypto |
| 33 | +pip install . |
| 34 | +``` |
| 35 | + |
| 36 | +## How to use it |
| 37 | + |
| 38 | +The package exposes a CLI command called `dlmscli` for easy interaction. |
| 39 | + |
| 40 | +🔑 Generate a Random Encryption Key |
| 41 | + |
| 42 | +``` |
| 43 | +dlmscli -k |
| 44 | +``` |
| 45 | + |
| 46 | +🔐 Encrypt an APDU Message |
| 47 | + |
| 48 | +System Title = 5249435249435249\ |
| 49 | +Frame Counter = 80000001\ |
| 50 | +Encryption Key = 454E4352595054494F4E4B45594B4559\ |
| 51 | +Authentication Key = 41555448454E5449434154494F4E4B45\ |
| 52 | +APDU = c001810001000060010aff0200 |
| 53 | + |
| 54 | +``` |
| 55 | +dlmscli -e 5249435249435249 80000001 454E4352595054494F4E4B45594B4559 41555448454E5449434154494F4E4B45 c001810001000060010aff0200 |
| 56 | +``` |
| 57 | +Result |
| 58 | +``` |
| 59 | +Encrypted/Decrypted APDU: 0de63f2331a09aa85e8830f5f3 |
| 60 | +``` |
| 61 | + |
| 62 | +🔓 Decrypt an APDU Message |
| 63 | + |
| 64 | +System Title = 5249435249435249\ |
| 65 | +Frame Counter = 80000001\ |
| 66 | +Encryption Key = 454E4352595054494F4E4B45594B4559\ |
| 67 | +Authentication Key = 41555448454E5449434154494F4E4B45\ |
| 68 | +APDU = 0de63f2331a09aa85e8830f5f3 |
| 69 | + |
| 70 | +``` |
| 71 | +dlmscli -d 5249435249435249 80000001 454E4352595054494F4E4B45594B4559 41555448454E5449434154494F4E4B45 0de63f2331a09aa85e8830f5f3 |
| 72 | +``` |
| 73 | +Result |
| 74 | +``` |
| 75 | +Encrypted/Decrypted APDU: c001810001000060010aff0200 |
| 76 | +``` |
| 77 | + |
| 78 | +🔎 Authenticate an APDU Message |
| 79 | + |
| 80 | +System Title = 5249435249435249\ |
| 81 | +Frame Counter = 00000001\ |
| 82 | +Encryption Key = 454E4352595054494F4E4B45594B4559\ |
| 83 | +Authentication Key = 41555448454E5449434154494F4E4B45\ |
| 84 | +APDU = 0de63f2331a09aa85e8830f5f3 |
| 85 | +``` |
| 86 | +dlmscli -a 5249435249435249 00000001 454E4352595054494F4E4B45594B4559 41555448454E5449434154494F4E4B45 0de63f2331a09aa85e8830f5f3 |
| 87 | +``` |
| 88 | +Result |
| 89 | +``` |
| 90 | +TAG: 62d423292e0fe5320370881d |
| 91 | +``` |
| 92 | + |
| 93 | +## 📜 License |
| 94 | + |
| 95 | +This project is licensed under the ### GNU General Public License v3.0 |
| 96 | + |
| 97 | +## 🙏 Acknowledgments |
| 98 | + |
| 99 | +Special thanks to the [cryptography](https://github.com/pyca/cryptography) team for providing an excellent library. |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | + |
0 commit comments