I am writing an application in Java that will be using SHA-1 HMAC message authen
ID: 648474 • Letter: I
Question
I am writing an application in Java that will be using SHA-1 HMAC message authentication. From what I understand, a connection over HTTPS is considered secure enough to share a secret key in plain text, and there is little added benefit to hashing the key before sending it from the client to the server.
So, my implementation would have to share a secret key when the first connection is made. After that, the client would send an API key along with the message that would identify the client and allow the server to look up the correct secret key.
For more information on the approach that I want to use, I am following this guide (Gary Rowe's Multibit Merchant).
The goal is to authenticate the client on subsequent connections.
Is my assumption correct that I can safely send the secret key over HTTPS on the initial connection?
Explanation / Answer
HTTPS itself does not do encryption, it simply relies on SSL/TLS in order to implement some level of security to your communications. The problem lies with the choice of underlying algorithm - SSL 2.0 is already considered insecure due to flaws. Similar (less critical) attacks have also been discovered for SSL 3.0/TLS 1.0 so you can only fully trust HTTPS if you know what the server AND client (browser) use behind the curtains.
Generally, the approach for communicating a secret key (read ANY secret key) assumes an effort of asymmetric cryptography (see RSA, for example). So your client would connect and send his (temporarily generated, if you must) public key and receive the secret key encrypted with this. The message can now only be decrypted by his private key which never appears in HTTPS traffic and is, mathematically, hard to figure out. This is, for the most part, the way HTTPS works.
Normally I would advise against reimplementing any sort of crypto but, if you have no control over the SSL/TLS versions the server advertises, I would go for an encrypted secret key exchange inside the session and leave the rest of the traffic as is. Just remember NOT to implement the primitives yourself - any language out there has a number of functions and libraries dedicated to this, including higher-level primitives for simply encrypting a message with little options.
It all depends on your skill and on the security you want to impose inside the system.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.