HMAC SHA256 sign and check methods in `core`
Problem
The usecase is supporting token-based login in the future for something like some third party authentication flows that use shared secrets or inter-server player transfers or what have you. It would be a nice primitive to support since we already have a SHA256 implementation, and building HMAC-SHA256 on top of that is pretty straight forward.
Solutions
HMAC is somewhat annoying to implement in Lua, it would be nice if the engine implemented this either in builtin or in C++ (preferred). I'm a bit cautious about a Lua implementation too since the constant time comparison you need seems like something LuaJIT might decide to optimise away in the JIT compiler.
Implement core.hmac_sha256_sign(key, message) which returns the raw signature/digest bytes, as well as core.hmac_sha256_verify(key, message, signature) which returns a boolean
References that may be useful
https://datatracker.ietf.org/doc/rfc2104/ https://www.rfc-editor.org/info/rfc6234/#section-8.3 https://www.rfc-editor.org/info/rfc4231/
Alternatives
Don't implement it, let people roll their own version using core.sha256 and the bit32 library.
Additional context
Support for RSA would also be good, but that can be a different issue, ties into #17058 and possibly #5813
Source: luanti-org/luanti