-
Notifications
You must be signed in to change notification settings - Fork 8
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
implement security protocols #2
Comments
+1, as even open-zwave hasn't yet implemented S2 security. The OZW developers don't really seem to care either, they just closed an open ticket asking for it, saying why bother when there aren't any S2 devices out there (obviously there are now but still they don't care). I started looking into what it would take to add S2 security to OZW in a fork, but my C++ skills probably aren't up to the task. I could probably get it done in Python and would volunteer to do that in PyZwaver, if the author doesn't have time to do it. The offer is open though. Not sure what that timetable would be but hopefully the author of this project is more open to it than the authors of openzwave. |
My plan is to add S2 support but no support for S0. I have an S2 capable device to play with and hope to get the initial key exchange |
I'd be happy to assist in testing if needed. I'm just starting out with Z-wave, at the moment I'm actually doing some web scraping of the z-wave alliance site of all the devices to get a more accurate idea of the differences between various devices based on supported classes and their supported versions of them. I'm pretty disappointed that openzwave doesn't support S2 so I'm willing to invest some time to get an implementation going, even if it's just on the support side, helping out where needed. From what I understand, the USB z-wave devices are pretty much just a pipe and all the encryption and security protocols must be handled by the top-level application. I'm assuming that as long as they've got a specification for it that it's enough to make a Python implementation from scratch. Good luck and feel free to reach out if there's anything I can help with. |
Implementation work has begun. This feature will drag in a fairly heavy dependency on "cryptography" By default the corresponding import is still disabled. Development/debugging is currently done using a real device an iterating via ./example_tool.py --verbosity=20 --serial_port=/dev/ttyUSB0 unpair |
Some progress towards the handling the initial key exchange. Biggest omissions are around Nonce generation for SPAN. The other missing part is unit tests confirming that these primitives actually work as intended. Any help is greatly appreciated |
Most of the crypto primitives are now in place but have not been fully debugged. |
Question for you, apologies if it's slightly off-topic for this issue. This USB stick advertizes full S2 security: https://www.thesmartesthouse.com/products/zooz-usb-z-wave-plus-s2-stick-zst10 However my understanding of all common Z-Wave USB sticks was that the serial protocol left all of the S2 security to the end-user application to implement (hence this issue being open). But this product says that S2 is implemented out of the box, and is otherwise transparent. How can that be? And would it be compatible with PyZwaver and/or OpenZwave? |
My understanding is that s2 is largely done in software at the application layer. BTW: I wont have much time to work on this till the of the quarter so feel free |
Did you manage to decrypt the first S2 encrypted packet (the 'echo')? I'm implementing the same thing for some closed source project and I'm having troubles with it... ECDH, PRNG and decryption are good as far as I can tell, but there is some mistake in there... it would be nice if they would provide some test vectors for nonce generation, for example... |
sorry, no progress here. I think the best thing would be to reach out to the z-wave alliances and ask |
In the meantime, I managed to decrypt it. It's quite cumbersome to implement it, one needs to patiently check each referred RFC for test vectors and check against those. Apparently it's doable, but it takes patience and time. |
By the way, I've seen this: "My plan is to add S2 support but no support for S0." FYI, S0 is much simpler than S2 to implement, plus you have open source projects that already implement it, so if you get stuck you can look into those to see what they do. There is no open source implementation of S2 as far as I can tell and it's much harder to implement. Besides the S2 class one has to implement for example the transport class which is quite a bit of work by itself. |
@aromanro if you can post a transcript of the message exchanged of the initial key exchange including Re S0 support, I actually got that to work in a predecessor of this library but I do not think it is worth it. There are too many message that need to be exchanged leading to poor latency/reliability. |
S0 is working nicely in the software I implemented. Indeed there is the overhead of requesting the nonce and getting it each time, but it's not that bad. The reliability does not seem worse than without S0, if implemented right. You can even send an encrypted packet specifying with it that you need another nonce for the next packet, which cuts from overhead a little. As for that log, I'm not sure I should provide it, since I'm working on a closed source project. |
Can you point me at the rfc with the test vectors. |
There are various RFCs, pointed out in the documentation. The starting point for S2 implementation is 'Z-Wave-Transport-Encapsulation-Command-Class-Specification' pdf. For DiffieHellman I did what is said in this page http://cr.yp.to/ecdh.html and used gcrypt. For CBC-MAC I used this https://tools.ietf.org/html/rfc3610 for the test vectors at the end and the description which appears to me not so clear, I had a little bit of fighting with it until I managed to decrypt and authenticate. For AES CMAC I used gcrypt, I implemented my own PRNG according to the specs from here: https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf Basically I combined using gcrypt, my code and some black magic :) in order to have it working. It's quite a bit of work involved... |
So I got reasonably far with this in this test: using a standard python crypt library. I am going to clean it up a little over xmas. |
Not really, I'm very sick of my own code about this :( Checking my own code to find where the problems were was nightmare enough, trying to figure that out in some other code is more than I can stand right now, sorry. |
No description provided.
The text was updated successfully, but these errors were encountered: