Zeroconf based Authentication by command line #615
Replies: 16 comments 2 replies
-
I'm looking to do something similar. My goal is to programmatically swap which account the librespot instance is associated with. The document you referenced above explains how the auth blob is decoded but I need to know how to encode a blob which I would then use for zeroconf auth. |
Beta Was this translation helpful? Give feedback.
-
I have a similar need. I've got a Spotify Connect device at http://192.168.1.118/spotify that I would like to programatically run "addUser" on from one of two accounts. Calls to kick the current user off: |
Beta Was this translation helpful? Give feedback.
-
I'm not super knowledgeable on encryption but I'm thinking you would need the private key to construct the blob and all we have is the public key for decrypting the blob. As far as I know, only the official Spotify clients are capable of initiating a zero config auth. If there is an open source project that can handle that side of the process then we could look at that for hints but I don't think one exists. |
Beta Was this translation helpful? Give feedback.
-
@plietar - I see you're the author of the zeroconf authentication page. Can you offer up any details on how to generate blobs? Whose private key do I need to do the DH exchange? |
Beta Was this translation helpful? Give feedback.
-
In the odd case you haven't already seen the docs on zeroconf.. |
Beta Was this translation helpful? Give feedback.
-
Those docs only explain how you decrypt a blob. We are trying to do the opposite. |
Beta Was this translation helpful? Give feedback.
-
Ah fair enough, sorry for the noise :-) |
Beta Was this translation helpful? Give feedback.
-
@idcmp with DH, both sides have a private and a public key. They exchange public keys to compute a shared secret.
To actually compute the blob, you'd have to implement this function, backwards. There seem to be a couple of fields in the unencrypted blob that aren't described. I'm not sure what these are. Running librespot and printing their values could help. |
Beta Was this translation helpful? Give feedback.
-
Got it. Sorry if this is a stupid question, is librespot/core/src/authentication.rs Lines 92 to 95 in 06f5aa9 As listed in:
|
Beta Was this translation helpful? Give feedback.
-
That piece of code corresponds to the The code is a naive manual translation from the disassembled binary to Rust. I’m no crypto expert, so I have a hard time identifying the “high level” algorithms. It is certainly not CTR, since it is XORing pieces of the plaintext together, rather than the plaintext with some AES stream. On the other hand, it doesn’t match any of the other common cipher modes. |
Beta Was this translation helpful? Give feedback.
-
You can have a look at the Java implementation too: https://github.com/librespot-org/librespot-java/blob/1c9537a2a21833d68491f8bda077606fe1120c75/lib/src/main/java/xyz/gianlu/librespot/core/Session.java#L867 |
Beta Was this translation helpful? Give feedback.
-
Hi @devgianlu @plietar @idcmp - I'm interested in this too and have been looking around, but found very few examples where this has been done or reverse engineered fully. Would https://github.com/badfortrains/spotcontrol/blob/master/blob.go#L97 be an example to start from (in Go, but should be portable)? |
Beta Was this translation helpful? Give feedback.
-
When I was looking into this, I got to the point where I felt like there was a private key of sorts that was missing from the equation that I didn't have access to. I could have been wrong - reversing protocols is definitely not more forte anymore. |
Beta Was this translation helpful? Give feedback.
-
For those still interested, I published today a tool to connect your I don't have official Spotify Connect hardware. I only tested it on librespot |
Beta Was this translation helpful? Give feedback.
-
hutspot seems to have this implemented in cpp, is doesn't look easy to port to java or javascript which is what I'm looking for. |
Beta Was this translation helpful? Give feedback.
-
If someone stumbles upon this topic, I created a simplified version of TimotheeGerber's Spotify Connect app in Python. |
Beta Was this translation helpful? Give feedback.
-
I want to mock (simulate) a connection to the lib by code, with the zeroconf authentication mode.
In other words, i want to run a librespot instance, and then connect to it as a "spotify connect" device, but using code or cli, not the spotify app.
is this possible?
Beta Was this translation helpful? Give feedback.
All reactions