I have an client/server architecture that periodically sends very small (10 or so bytes) UDP packets back and forth, which I'd like to authenticate without a large overhead in bandwidth or processing. Note that I don't care about an adversary seeing the plaintext, only I'd like to prevent them from modifying and re-transmitting the packets.
Here is the process I'm envisioning:
- User authenticates themselves with a username/password over HTTPS. Nothing out of the ordinary here.
- Server replies with a success message and N bytes (maybe around 32 bytes) of cryptographically generated random data. Both the client and server remember this string of data as their
common_secret
. - At this point the HTTPS connection is closed and all further communication will be via small UDP packets, using this scheme for authentication:
packet = plaintext + sha2(plaintext + common_secret)
- On receiving a packet, the server will calculate the same
sha2
from the plaintext and itscommon_secret
, and check that it matches the hash at the end of the packet.
An adversary will not be able to construct a valid packet without knowing common_secret
. Is this a valid authentication scheme?