|
| 1 | +# 🛡️ DLMS Crypto Tool (C++ version) |
| 2 | + |
| 3 | +**DLMS Crypto Tool** is a cross-platform C++ command-line interface (CLI) utility for encrypting, decrypting, and authenticating DLMS APDU messages. |
| 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 | +- A C++17 compliant compiler (e.g. GCC 7+) |
| 18 | +- [OpenSSL](https://www.openssl.org/) development libraries |
| 19 | + - On Ubuntu `sudo apt-get install libss-dev` |
| 20 | +- GNU Make |
| 21 | + |
| 22 | +## 📦 Building the project |
| 23 | + |
| 24 | +### Using make |
| 25 | + |
| 26 | +1. **Clone the repository:** |
| 27 | + ```bash |
| 28 | + git clone https://github.com/YourUsername/dlms_crypto_tool.git |
| 29 | + cd dlms_crypto_tool |
| 30 | + ``` |
| 31 | + |
| 32 | +2. **Compile with make:** |
| 33 | + ```bash |
| 34 | + make |
| 35 | + ``` |
| 36 | + |
| 37 | +## How to use it |
| 38 | + |
| 39 | +🔑 Generate a Random Encryption Key |
| 40 | + |
| 41 | +```bash |
| 42 | +./dlmscli key |
| 43 | +``` |
| 44 | + |
| 45 | +🔐 Encrypt an APDU Message |
| 46 | + |
| 47 | +System Title = 5249435249435249\ |
| 48 | +Frame Counter = 80000001\ |
| 49 | +Encryption Key = 454E4352595054494F4E4B45594B4559\ |
| 50 | +Authentication Key = 41555448454E5449434154494F4E4B45\ |
| 51 | +APDU = c001810001000060010aff0200 |
| 52 | + |
| 53 | +```bash |
| 54 | +./dlmscli encrypt 5249435249435249 80000001 454E4352595054494F4E4B45594B4559 41555448454E5449434154494F4E4B45 c001810001000060010aff0200 |
| 55 | + |
| 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 | +```bash |
| 71 | +./dlmscli decrypt 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 | +```bash |
| 87 | +./dlmscli auth 5249435249435249 00000001 454E4352595054494F4E4B45594B4559 41555448454E5449434154494F4E4B45 0de63f2331a09aa85e8830f5f3 |
| 88 | +``` |
| 89 | +Result |
| 90 | +``` |
| 91 | +TAG: 62d423292e0fe5320370881d |
| 92 | +``` |
| 93 | + |
| 94 | +``` |
| 95 | +Contributions are welcome! To contribute: |
| 96 | +
|
| 97 | +1. Fork the repository. |
| 98 | +
|
| 99 | +2. Create a new branch for your changes. |
| 100 | +
|
| 101 | +3. Write tests for your modifications. |
| 102 | +
|
| 103 | +4. Submit a pull request with a detailed explanation of your changes. |
| 104 | +``` |
| 105 | + |
| 106 | +## 📜 License |
| 107 | + |
| 108 | +This project is licensed under the GNU General Public License v3.0 |
| 109 | + |
| 110 | +## 🙏 Acknowledgments |
| 111 | + |
| 112 | +Special thanks to the [OpenSSL](https://www.openssl.org/) team for providing an excellent library. |
| 113 | + |
| 114 | + |
| 115 | + |
| 116 | + |
0 commit comments