Android TV Pin code rule

Continuing the discussion from [AndroidTV Binding 3.2.0;4.0.0):

I have question about the Pin Code which used for for the access the Android TV.
The Pin code process said, the pin code consist with “6 digit pin”, but when I see the source. It handled as a string, but when I tested with real device, The displayed 6digit pin always show “Hexadecimal” number.
Do you know what is the exact rule of the Pin Code? it’s “Hexadecimal” or “Number (0-9)+Characters (A-Z)”>

First, you probably want to move this off to the addons section, or just under the main thread, this isn’t the appropriate place for this thread to be.

To answer your question, we handle this as a string for a few reasons. The primary answer being, we almost immediately convert both the ShieldTV PIN (which is always digits) and the GoogleTV PIN (which is hexadecimal digits), into hex so that it can be sent over to the device. In the case of ShieldTV, we just send the PIN over inside of a command and it accepts it directly. In the case of GoogleTV, the PIN is far more complicated and is actually a piece of a seeded SHA256 hash of the modulus and public exponents of both the client and device. If you get a PIN of ABCDEF, CDEF is a seed appended to the end of the concatenated pieces, and AB is the first two hex digits of the overall SHA256 hash. When we reply to the device, we send the entire SHA256 hash, not the actual PIN. You can see this process here…

and here…

If you put the binding into trace you can see this process as well, there are several log messages spit out. I hope that answers your question.

1 Like

Thank you, this helps a lot.