McKael / smartcrypto

SmartView2 handshake Golang library for Samsung Smart TV H/J (2014/2015) models
MIT License
8 stars 2 forks source link

`Could not parse message: cannot decrypt response: invalid padding ` (with credentials sectroyers php/python implementation) #2

Open mStirner opened 9 months ago

mStirner commented 9 months ago

I have a question about the "samtvcli" where this package is used. Did you modify the handshake somehow, or is this a pure 1:1 port from https://github.com/sectroyer/SmartCrypto ?

I wanted to port this/sectroyer's smartcrypto handshake to javascript/node.js.

The issue im facing is, when i use secrtoyers impelmentation, no matter if the php or python, i cant use the session id & key with samtvcli, even when the pairing says successful.

While im facing this issue, i have no trouble while using samtvcli pair, which leads me to wonder if you implemented/fixed anything.

Any idea?, samtvcli output (pairing with sectroyers php/c implemtnation):

INFO[0000] Using config file: /home/marc/.config/samtvcli/samtvcli.yaml 
DEBU[0000] Fetch URL: http://192.168.2.100:8000/socket.io/1/?t=1707330078650 
DEBU[0000] Reading WS message...                        
DEBU[0000] Read message (type 1): `1::`                 
DEBU[0000] Got greetings from TV                        
DEBU[0000] Sending SmartView handshake...               
DEBU[0000] Sending WS message: `1::/com.samsung.companion` ... 
DEBU[0000] Reading WS message...                        
DEBU[0000] Read message (type 1): `1::/com.samsung.companion` 
DEBU[0000] SmartView handshake completed                
DEBU[0000] Reading WS message...                        
DEBU[0000] sendMessage('KEY_MUTE')                      
DEBU[0000] Sending WS message: `5::/com.samsung.companion:{"name":"callCommon","args":[{"Session_Id":2,"body":"[64, 195, 236, 252, 204, 98, 232, 235, 62, 167, 133, 251, 240, 61, 113, 151, 63, 252, 27, 93, 117, 22, 145, 225, 113, 113, 48, 82, 233, 46, 177, 213, 32, 133, 65, 212, 198, 2, 43, 242, 19, 108, 120, 65, 73, 51, 27, 140, 124, 37, 28, 86, 240, 221, 46, 97, 177, 232, 36, 124, 239, 167, 94, 141, 16, 234, 165, 211, 108, 249, 25, 217, 169, 70, 149, 85, 105, 244, 133, 144, 118, 163, 115, 8, 243, 178, 199, 161, 155, 49, 221, 159, 142, 140, 108, 56, 209, 227, 200, 238, 112, 204, 240, 136, 211, 89, 49, 224, 101, 54, 82, 156, 87, 173, 233, 109, 91, 206, 0, 239, 143, 24, 131, 90, 235, 212, 109, 39, 175, 106, 58, 69, 184, 85, 186, 25, 4, 87, 64, 255, 105, 236, 37, 63, 185, 226, 133, 27, 51, 153, 76, 251, 96, 155, 200, 10, 77, 28, 104, 147, 148, 17, 152, 36, 205, 239, 150, 138, 68, 148, 23, 248, 146, 63, 106, 152]"}]}` ... 
DEBU[0000] Read message (type 1): `5::/com.samsung.companion:{"name":"receiveCommon","args":"[138,236,222,172,138,17,113,65,75,30,153,51,130,19,35,241,175,31,16,185,28,105,209,7,96,36,49,144,63,29,186,167,18,149,190,209,125,182,159,1,49,53,79,171,153,239,248,77,38,185,38,14,169,7,17,251,210,154,81,6,123,224,39,54]"}` 
DEBU[0000] SmartView message received                   
DEBU[0000] data: f7bd4e40add808dd31db0a14282a1f2d       
DEBU[0000] padlen: 2d                                   
ERRO[0000] Could not parse message: cannot decrypt response: invalid padding 
DEBU[0000] Reading WS message...                        
ERRO[0005] Cannot send key 'KEY_MUTE': no reply from TV

What drives me crazy is, that i worked with my javascript port (which uses basicly secryoers c impelmentation/binary, gist) but it suddenly stopped working.

Removed all paired devices from TV, it works every time with samtvcli, but not with the other implementations.

Thanks for any hint/reply.