etwmc/Personal-HomeKit-HAP

PHK not decrypting/verifiying data

Closed this issue · 8 comments

On 6S+ iOS9.0.2 (jailbroken, for the matter)
Raspberry Pi B2
Latest github commit.

After sending accessories info, the PHK daemon freezes and does not continue.

Ask for accessories info
Reply: HTTP/1.1 200 OK
Content-Type: application/hap+json
Content-Length: 743

{"accessories":[{"aid":1,"services":[{"iid":1,"type":"3E","characteristics":[{"value":"Light 1","perms":["pr"],"type":"23","iid":2,"format":"string"},{"value":"ET","perms":["pr"],"type":"20","iid":3,"format":"string"},{"value":"Light","perms":["pr"],"type":"21","iid":4,"format":"string"},{"value":"12345678","perms":["pr"],"type":"30","iid":5,"format":"string"},{"perms":["pw"],"type":"14","iid":6,"format":"bool"}]},{"iid":7,"type":"43","characteristics":[{"value":"Light","perms":["pr"],"type":"23","iid":8,"format":"string"},{"value":true,"perms":["pr","pw","ev"],"type":"25","iid":9,"format":"bool"},{"value":50,"minValue":0,"maxValue":100,"minStep":1,"perms":["pr","pw","ev"],"type":"8","iid":10,"unit":"percentage","format":"int"}]}]}]}
send: 1
send: 100000000000000
send: 2
I??|<QW???9??y?3?f??*bA4'0??Z)ߍ??9
Passed-in data is no-verified!

etwmc commented

I assume RPi is little endian?
Anyway, can you try the new push?

It is little endian, according to python -c "import sys; print(sys.byteorder)"
Latest commit not working, same thing. Still: Passed-in data is no-verified!

I'm having the same issue on OS X. I can pair but nothing beyond that.

etwmc commented

I'm still trying to figure it out. It works on my Ubuntu x86-64, but not on anything else.
So I will probably finish tracking and fix it this week after I finish handling all the school work.

etwmc commented

I track down the problem: My MacBook weirdly pushed an old version of code for a while, which make the anything I push doesn't changed
I'm going to push this alongside with multi characteristic operation this weekend, but I'm going to need some testing in big endian platform before I can say I got all changes merge on this side.

Any luck?

etwmc commented

I'm not sure if the the current commit would work on RPi, because mine still haven't arrived, and my friend's was being used as a course project till next week. And given from the output, and the description on RPi endian, the byte swap seems also problematic.
But if you still see the byte swap happening on little endian machine, go to line 90 of PHKNetworkIP.cpp, and change it into the following:
return !e.c[0];
This reverse the result on the big endian detection, until I figure a way to write the endian system

If you wondering if the byte swap is occur, check for the line like this
send: 1
send: 100000000000000
send: 2

P.S. Sorry for taking so long. Never through overloading credits on MS is such time consuming. I haven't slept normally for a long time.

Latest commit is working fine on my RPI (B2) !
And don't feel bad about it taking time, we are grateful that you chose to share your project with us.