# Check device authenticity by HASH

Hello I'm working in a school project and I'm trying to resolve an issue. I have a server, a BLE device and a computer. The BLE device is constantly advertising data, I'm using 7bytes of the data leaving 17 bytes left and I want to use the rest of the bytes to check the authenticity of the BLE device.

So, when a computer is capturing the packages, I need to confirm that that package is really from an authentic device. My idea is:

1. The BLE device will sign the data (7bytes) with his private key (RSA method).
2. As the signature is much more than the 18bytes, it will generate a Hash of the signature.
3. The payload broadcast will result in the data (7bytes) + the hash (16/18bytes)
4. The computer will catch the broadcast message
5. The computer will send to the server the entire payload.
6. The server will have the BLE device private key and will sign the data (7bytes)
7. The server will generate the hash and will compare it
8. If it matches the server will send a successful code otherwise an error code.

My concern is it is possible to get the private key by getting the hash of a signed message? I think it is, but I'm not sure, maybe the hash can help in the guess of the private key, I don’t know.

And, this is a good and secure solution? If not do you guys know one better? Thank you.

• Does the server has the private key or the public key to verify the signature? May 1 '20 at 17:23
• @kelalaka hi, the server has the private key May 1 '20 at 18:01

If an RSA signature is sizably truncated, as is the case here, it can not be verified with the public key. Hence here (necessarily: deterministic) RSA signature is used as a secret-key MAC, and could (and IMHO should) be replaced by HMAC.

That said, no, there is no risk of leak of the private key, or even the lesser risk of the ability to sign. If there was, that would demonstrably be a break of the RSA signature scheme used.

More generally, given access to a black box that performs the textbook RSA private key operation $$x\mapsto x^d\bmod n$$, there is no known way that $$d$$ (or an equivalent) leaks, unless the black box has a side-channel leak.

• I see, thank you. May 3 '20 at 11:11