Supergiovane / node-red-contrib-sia-ultimate

Connect your SIA-DCS compatible alarm system to node-red. It works with Ajax System too.
MIT License
18 stars 4 forks source link

Abus Secvest encryption doesn't work #6

Open HackyPaddy opened 8 months ago

HackyPaddy commented 8 months ago

Hello :)

with my Abus Secvest, i have a problem with your code. Messages without AES-encryption work fine, but with the encryption, your adapter received the encrypted message and decrypts this. Everything is fine up to this point.

But, the acknowledge is not understood by the system and the Secvest issues a reporting fault. No matter whether 128, 192, 256 aes-encryption.

Do you have help for me?

Greetings

Patrick

Supergiovane commented 8 months ago

Hi Patrick i checked now, but i cannot help you, because i've never used the encryption and i don't have any alarm panel supporting it to do a test. You could ask in iobroker forum about that, because my node is partially based on SIA implementation of iobroker.

HackyPaddy commented 8 months ago

Thx, for your answer. I think, the buffer for the pad message in your script doesn't work.

I have included an output of "pad", "padlen" and "result" in the script. This is the output: 292 - debug: node-red.0 (3206272) 8 Mar 03:45:02 - [info] PAD: - - Padlen:10 - - RESULT:|]_02:45:02,03-08-2024

"- -" are separators.

The value "pad" is empty. Is it right so? Can i output the pad on a debug?

Sry, I haven't worked with buffers yet and I'm not familiar with them.

Supergiovane commented 8 months ago

Hi Sincerely, i don’t remember how it must be (the pad). If you’re able, you could do the changes and send me a PR.

HackyPaddy commented 8 months ago

Hey,

That's exactly it, I've never worked with buffers before, that's why I turned to you.

But I can tell you how it has to work.

The pad must always be a multiple of 16. That works! And here the description:

Pad data shall be pseudo-random bytes which vary from one message to the next. This data will consist of binary values 0-255, except that it shall not contain the ASCII values for the character "|" (124, x7C), "[" (91, x5B) or "]" (93, x5D).

How do I get it to generate binary data?

if (sia.id[0] == "*") { let msglen = ('|]' + ts).length; let padlen = 16 - (msglen % 16); // let pad = new Buffer(padlen); let pad = Buffer.alloc(padlen, padlen); // let pad = Buffer.alloc(padlen, 0x00); let msg = encrypt_hex(cfg.password, pad + '|]' + ts); let dmsg = decrypt_hex(cfg.password, msg); // only for deguging let dmsghex = new Buffer.from(dmsg).toString('hex');

The Buffer.alloc should generate the data.

let pad = Buffer.alloc(padlen, padlen);

But in the console.log the pad is empty...

I added the code: RED.log.info("PAD:" + pad + " - - " + "Padlen:" + padlen + " - - " + "RESULT:" + pad + '|]' + ts);

and the result is:

292 - debug: node-red.0 (3206272) 8 Mar 03:45:02 - [info] PAD: - - Padlen:10 - - RESULT:|]_02:45:02,03-08-2024

The buffer should have a size of 10. Thats right. But, the pad is empty and so it doesn't work...

Best regards,

Patrick

HackyPaddy commented 8 months ago

In my opinion, a random of characters that corresponds to the length of padlen would first have to be generated. Then this part must be converted to byte (decimal or hex).

The characters “[ ] |” cannot be used.

How do you implement this in code?

Supergiovane commented 8 months ago

Hi The node is based to iobroker sia implementation Monday l’ll take a look

HackyPaddy commented 8 months ago

Hey,

the iobroker-adapter has the same issue. But, the adapter doesn't work at all. Not even if the messages are unencrypted.

Your code supports the unencryption messages :)

HackyPaddy commented 7 months ago

Hey,

have you already taken a look at the code? I tried to do a little research. But I can't get any further with the "pad" because I don't know how to create binary arrays.

Maybe together we can get the script running.

Greetings

Patrick

Am 09.03.2024 um 13:58 schrieb Massimo Saccani @.***>:

Hi The node is based to iobroker sia implementation Monday l’ll take a look

— Reply to this email directly, view it on GitHub https://github.com/Supergiovane/node-red-contrib-sia-ultimate/issues/6#issuecomment-1986850485, or unsubscribe https://github.com/notifications/unsubscribe-auth/BE5MVKHJRA2QQFFCZFP6NELYXMBOXAVCNFSM6AAAAABEMTIQVWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBWHA2TANBYGU. You are receiving this because you authored the thread.

Supergiovane commented 7 months ago

Hi Patrick Sorry no, i’ve no time in these months. I’m barely able to maintain the other my nodes. To fix that, i must review the code and understand again how SIA protocol works!