|
1 |
| -# 🛡️ DLMS Crypto Tool |
2 |
| - |
3 |
| -**DLMS Crypto Tool** is a Node.js package and command-line interface (CLI) utility for encrypting, decrypting, generate encryption key, 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:** Interact with the tool via a command‑line utility (`dlmscli`). |
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 |
| -- **✅ Well-Tested:** Unit tests are provided with Mocha to ensure core functionality. |
14 |
| - |
15 |
| -## 🚀 Requirements |
16 |
| - |
17 |
| -- Node.js vs23.11.0 (tested only with this version) |
18 |
| -- [Commander](https://www.npmjs.com/package/commander) |
19 |
| -- [Mocha](https://mochajs.org/) if you want run Unit tests |
20 |
| -- npm (comes with Node.js) |
21 |
| - |
22 |
| -## 📦 Installation |
23 |
| - |
24 |
| -You can install the package globally from npm to get the CLI: |
25 |
| - |
26 |
| -``` |
27 |
| -npm install -g dlms_crypto_tool |
28 |
| -``` |
29 |
| - |
30 |
| -Or install it as a dependecy in your project: |
31 |
| - |
32 |
| -``` |
33 |
| -npm install dlms_crypto_tool |
34 |
| -``` |
35 |
| - |
36 |
| -## How to use it |
37 |
| - |
38 |
| -The package provide a CLI command called `dlmscli`. |
39 |
| - |
40 |
| -🔑 Generate a Random Encryption Key |
41 |
| - |
42 |
| -``` |
43 |
| -dlmscli key |
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 encrypt 5249435249435249 80000001 454E4352595054494F4E4B45594B4559 41555448454E5449434154494F4E4B45 c001810001000060010aff0200 |
56 |
| -``` |
57 |
| -*Tip:* Use --infile <path> to load input from a file and --outfile <path> to save the output |
58 |
| - |
59 |
| -🔓 Decrypt an APDU Message |
60 |
| - |
61 |
| -System Title = 5249435249435249\ |
62 |
| -Frame Counter = 80000001\ |
63 |
| -Encryption Key = 454E4352595054494F4E4B45594B4559\ |
64 |
| -Authentication Key = 41555448454E5449434154494F4E4B45\ |
65 |
| -APDU = 0de63f2331a09aa85e8830f5f3 |
66 |
| - |
67 |
| -``` |
68 |
| -dlmscli decrypt 5249435249435249 80000001 454E4352595054494F4E4B45594B4559 41555448454E5449434154494F4E4B45 0de63f2331a09aa85e8830f5f3 |
69 |
| -``` |
70 |
| -Result |
71 |
| -``` |
72 |
| -Encrypted/Decrypted APDU: c001810001000060010aff0200 |
73 |
| -``` |
74 |
| - |
75 |
| -🔎 Authenticate an APDU Message |
76 |
| - |
77 |
| -System Title = 5249435249435249\ |
78 |
| -Frame Counter = 00000001\ |
79 |
| -Encryption Key = 454E4352595054494F4E4B45594B4559\ |
80 |
| -Authentication Key = 41555448454E5449434154494F4E4B45\ |
81 |
| -APDU = 0de63f2331a09aa85e8830f5f3 |
82 |
| -``` |
83 |
| -dlmscli auth 5249435249435249 00000001 454E4352595054494F4E4B45594B4559 41555448454E5449434154494F4E4B45 0de63f2331a09aa85e8830f5f3 |
84 |
| -``` |
85 |
| -Result |
86 |
| -``` |
87 |
| -TAG: 62d423292e0fe5320370881d |
88 |
| -``` |
89 |
| - |
90 |
| -## 🧪 Running Tests |
91 |
| - |
92 |
| -To run unit test using Mocha, follow these steps: |
93 |
| - |
94 |
| -1. Clone the repository and install the development dependencies: |
95 |
| - |
96 |
| -``` |
97 |
| -git clone https://github.com/YourUsername/dlms-crypto-tool.git |
98 |
| -cd dlms-crypto-tool |
99 |
| -npm install |
100 |
| -``` |
101 |
| -2. Run tests: |
102 |
| - |
103 |
| -``` |
104 |
| -
|
105 |
| -npm test |
106 |
| -``` |
107 |
| - |
108 |
| -## 🤝 Contributing |
109 |
| - |
110 |
| -Contributions are welcome! To contribute: |
111 |
| - |
112 |
| -1. Fork the repository. |
113 |
| - |
114 |
| -2. Create a new branch for your changes. |
115 |
| - |
116 |
| -3. Write tests for your modifications. |
117 |
| - |
118 |
| -4. Submit a pull request with a detailed explanation of your changes. |
119 |
| - |
120 |
| -## 📜 License |
121 |
| - |
| 1 | +# 🛡️ DLMS Crypto Tool |
| 2 | + |
| 3 | +**DLMS Crypto Tool** is a Node.js package and command-line interface (CLI) utility for encrypting, decrypting, generate encryption key, 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:** Interact with the tool via a command‑line utility (`dlmscli`). |
| 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 | +- **✅ Well-Tested:** Unit tests are provided with Mocha to ensure core functionality. |
| 14 | + |
| 15 | +## 🚀 Requirements |
| 16 | + |
| 17 | +- Node.js vs23.11.0 (tested only with this version) |
| 18 | +- [Commander](https://www.npmjs.com/package/commander) |
| 19 | +- [Mocha](https://mochajs.org/) if you want run Unit tests |
| 20 | +- npm (comes with Node.js) |
| 21 | + |
| 22 | +## 📦 Installation |
| 23 | + |
| 24 | +You can install the package globally from npm to get the CLI: |
| 25 | + |
| 26 | +``` |
| 27 | +npm install -g dlms_crypto_tool |
| 28 | +``` |
| 29 | + |
| 30 | +Or install it as a dependecy in your project: |
| 31 | + |
| 32 | +``` |
| 33 | +npm install dlms_crypto_tool |
| 34 | +``` |
| 35 | + |
| 36 | +## How to use it |
| 37 | + |
| 38 | +The package provide a CLI command called `dlmscli`. |
| 39 | + |
| 40 | +🔑 Generate a Random Encryption Key |
| 41 | + |
| 42 | +``` |
| 43 | +dlmscli key |
| 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 encrypt 5249435249435249 80000001 454E4352595054494F4E4B45594B4559 41555448454E5449434154494F4E4B45 c001810001000060010aff0200 |
| 56 | +``` |
| 57 | +*Tip:* Use --infile <path> to load input from a file and --outfile <path> to save the output |
| 58 | + |
| 59 | +🔓 Decrypt an APDU Message |
| 60 | + |
| 61 | +System Title = 5249435249435249\ |
| 62 | +Frame Counter = 80000001\ |
| 63 | +Encryption Key = 454E4352595054494F4E4B45594B4559\ |
| 64 | +Authentication Key = 41555448454E5449434154494F4E4B45\ |
| 65 | +APDU = 0de63f2331a09aa85e8830f5f3 |
| 66 | + |
| 67 | +``` |
| 68 | +dlmscli decrypt 5249435249435249 80000001 454E4352595054494F4E4B45594B4559 41555448454E5449434154494F4E4B45 0de63f2331a09aa85e8830f5f3 |
| 69 | +``` |
| 70 | +Result |
| 71 | +``` |
| 72 | +Encrypted/Decrypted APDU: c001810001000060010aff0200 |
| 73 | +``` |
| 74 | + |
| 75 | +🔎 Authenticate an APDU Message |
| 76 | + |
| 77 | +System Title = 5249435249435249\ |
| 78 | +Frame Counter = 00000001\ |
| 79 | +Encryption Key = 454E4352595054494F4E4B45594B4559\ |
| 80 | +Authentication Key = 41555448454E5449434154494F4E4B45\ |
| 81 | +APDU = 0de63f2331a09aa85e8830f5f3 |
| 82 | +``` |
| 83 | +dlmscli auth 5249435249435249 00000001 454E4352595054494F4E4B45594B4559 41555448454E5449434154494F4E4B45 0de63f2331a09aa85e8830f5f3 |
| 84 | +``` |
| 85 | +Result |
| 86 | +``` |
| 87 | +TAG: 62d423292e0fe5320370881d |
| 88 | +``` |
| 89 | + |
| 90 | +## 🧪 Running Tests |
| 91 | + |
| 92 | +To run unit test using Mocha, follow these steps: |
| 93 | + |
| 94 | +1. Clone the repository and install the development dependencies: |
| 95 | + |
| 96 | +``` |
| 97 | +git clone https://github.com/YourUsername/dlms-crypto-tool.git |
| 98 | +cd dlms-crypto-tool |
| 99 | +npm install |
| 100 | +``` |
| 101 | +2. Run tests: |
| 102 | + |
| 103 | +``` |
| 104 | +
|
| 105 | +npm test |
| 106 | +``` |
| 107 | + |
| 108 | +## 🤝 Contributing |
| 109 | + |
| 110 | +Contributions are welcome! To contribute: |
| 111 | + |
| 112 | +1. Fork the repository. |
| 113 | + |
| 114 | +2. Create a new branch for your changes. |
| 115 | + |
| 116 | +3. Write tests for your modifications. |
| 117 | + |
| 118 | +4. Submit a pull request with a detailed explanation of your changes. |
| 119 | + |
| 120 | +## 📜 License |
| 121 | + |
122 | 122 | This project is licensed under the GNU General Public License v3.0
|
0 commit comments