-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decrypt data #21
Comments
Pseudo code to decrypt const crypto = require("crypto");
const alg = 'aes-128-gcm';
const key = 'xxxx'; // Get from energy company
const aad = '3000112233445566778899AABBCCDDEEFF`;
const keyBuffer = Buffer.from(key, 'hex');
const systemTitle = ''; // read from message (as hex)
const frameCounter = ''; // read from message (as hex)
const encryptedData = ''; // read from message (as hex)
const gcmTag = ''; // read from message (last 12 bytes, as hex)
const ivBuffer = Buffer.from(`${systemTitle}${frameCounter}`, 'hex');
const decipher = crypto.createDecipheriv(alg, keyBuffer, ivBuffer);
decipher.setAuthTag(gcmTag, 'hex');
let result = decipher.update(encryptedData, 'hex', 'utf8');
result += decipher.final('utf8'); // Not sure if this would be needed
smartmeter2mqtt/src/p1-reader.ts Lines 74 to 77 in 0221347
|
I need some help from someone who has access to a luxemburg smartmeter! Please execute the following script: # clone repo and open correct brance
git clone --branch feature/lux-encryption https://github.com/svrooij/smartmeter2mqtt.git
# go to folder
cd smartmeter2mqtt/example
# Execute script (replace the ip and port) and add you key if this doesn't give an error.
node decode-from-socket.js 192.168.1.15 23 The script above should start reading some output from the socket, if that works and it shows all the fields filled in. You add your key (in hexadecimal format) and it should start decrypting the data to DSMR telegram messages. Please share your output so I can actually start parsing this nice data. |
I'm working on a stream for you :) |
🎉 This issue has been resolved in version 1.7.0-beta.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Hi guys, Thank you for this great project. I purchased a P1 reader (ethernet) from Zuidwijk to follow my electric consumption in Home Assistant. I'm based in Luxembourg and have a Sagem 210 meter. Following the recommendation of Marcel Zuidwijk on https://www.zuidwijk.com/product/p1-reader-ethernet/#comment-31414 I gave a try to the project to read metrics, since the P1 with Ethernet does not cope with the decryption. I'm not using the docker version but standalone (or Bare metal as stated on your site). My config: P1 reader
Telegrams manager
The problem: when outputting in JSON, nothing happens. And when outputting in Raw-output, I get messages that look encrypted, example:
My bet is that the P1 output is not decrypted properly, even though I followed the instructions for LU P1 meter. By any chance, did I miss something obvious in the configuration / settings? If so, could you please kindly point it to me? Thank you and best regards. Alexandre |
Ouch, actually I have version 1.6.0 which does not deal with decryption I suppose. Gonna try with 1.7.x branch and let you know how it went. Sorry for the inconvenience. |
Hi guys, excellent news, after installing On the
And on the telnet console I get:
Even though sometimes I get error messages in the console:
Thank you and best regards. Alexandre |
Apparently the Luxemburg government thought that sending meter data in clear text isn't a good idea, so they are encrypting it with AES-128-GCM.
Every customer can request their own decryption key.
Needed data for decryption:
3000112233445566778899AABBCCDDEEFF
hexsystem-title (64 bits)
+frame counter (32 bits)
Sample frame: all these parts after each other
db
1
08
1
ffffffffffffffff
8
30
1
ffffffff
(max)4
...
(see length above)
ffffffffffffffffffffffff
(max)12
Once the data is decrypted it should just be a DSMR 5 telegram
For this to be implemented, please contact me if you live in Luxemburg, requested your key and have access to either the Slimme lezer or a P1 cable.
The text was updated successfully, but these errors were encountered: