This is based off the upstream implementation in mbedTLS as well as an external pull request [1] for MSVC support (using intrinsics). 1: https://github.com/ARMmbed/mbedtls/pull/1355