adding a hash to java script to provide security over a Bluetooth connection

Viewed 73

I am working on a project with a group of fellow students providing some apps for a company. These apps will have a Bluetooth connection to a device (one of the devices is a raspberry pi if that helps at all) We need help providing some kind of security to the data being transferred over the Bluetooth connection. We are thinking of doing a hash but we are unsure how that would look. We dont want a super strong hash as that would slow the connection, just anything to provide some kind of security to the data being transferred will work, thank you for your time.

P.S we will also be using Xcode too for another app too so if anyone has experience with xcode providing security on that would be great :)

2 Answers

Symmetric-key Encryption might solve your problem. Symmetric-key Encryption is a cryptographic algorithm that allows for shared secrets between two parties. In your case, if you wanted to send a secret message from an xcode app to a raspberry pi via bluetooth, you would first give both parties (the xcode app and the raspberry pi) a copy of a secret key. With this secret key, whenever one party wants to send a secret to the other, it encodes the data with the secret key, sends it to the other party, and the other party decodes it with the secret key.

Without the secret key, it would be virtually impossible to decode a message that has been encoded with a secret key. Therefore, you're fully protected against middleman attacks. Some secret key algorithms out there are Twofish (although I don't recommend it), Salsa20, and IDEA.

Symmetric Key Encryption is most likely avaliable on a standard crypto api.

For more information: https://en.wikipedia.org/wiki/Symmetric-key_algorithm

I assume with 'security' you mean 'confidentiality' and 'integrity' of the data in transfer. You said you wanted to have a hash, but hash (or rather an MAC/HMAC) can offer you only integrity checks. With encryption you could achieve both.

If using symmetric encryption isn't to much of a deal and you have no problems with sharing keys across the devices (or storing hardcoded secrets), I would go for symmetric encryption. I'm not the expert in JavaScript so I took a look on what is available out there... Man, I thought encryption in Java sucked.

Just find something people are using in JS now days and check the quality yourself.

Related