porting form: https://github.com/devcoons/stm32-lib-crypto/blob/main/hash