Question: AUTH RSA Public Key Format
ivanjx opened this issue · comments
Hi,
Thanks for the documentation. This clarify some important things about ADB protocol. However im still stuck at the adb auth type 3 (RSAPUBLICKEY) about the public key format to send to the device. Same question has been asked here for more details. Do you know what is the correct format of adb public key?
Thanks.
I don't know for sure, sorry. If I remember correctly installing the official ADB binary would generate keys on your computer. It might just be a standard RSA/SSH key.
Hello,
I have some issue too . i'm not sure about the RSA public key to send.
If i send a Certificate ( raw format ) , a pop up appears on the screen, but i'm not able to sign the token after that.
And if i send a freshly created public key RSA, no pop up appears.
In the protocol, it just say "Send Public key" , it doesnt describe the format of that key.
@ivanjx did you had any success using .NET for creating the public key and sign the token ?
I saw your post stackoverflow btw.
are you using the private key to sign the payload from AUTH 2 process? you have to pre-generate those with the actual adb.exe
since i dont want to implement their custom key format. to obtain those 2 files, just connect to a device via adb shell then quit. after that look into C:\Users\username\.android
. you should have something like this:
the first file content is what you use for SIGNING. the second one is the ones you send for AUTH 3. since i am using C#, here is how i sign the payload in AUTH 2:
using RSA rsa = RSA.Create();
rsa.ImportFromPem(PRIVATE_KEY);
return rsa.SignHash(
payload,
HashAlgorithmName.SHA1,
RSASignaturePadding.Pkcs1);
hope this helps.
note: i use dotnet 7.0
. rsa.ImportFromPem
is not available in earlier versions of dotnet. if you are stuck with old version, you have to use bouncy castle.
@ivanjx Thank you so much for your answer, after writing my message i've continue searching for the right certificate, and indeed, it must be an adb.pub certificate that i generate using "adb keygen adb" in a terminal, it will create 2 file, one for public key and one for private key, sending the public key, and Sign the token using the private key works now.
It was mentionned in this Link
( and i am using .NET Framework 4.7, so yes i had to use Bouncy Castle. )
Thank you again :)