I'm trying to use BCryptEncrypt
to authenticate some AAD but the function is failing with STATUS_INVALID_PARAMETER
. BCryptEncrypt
takes 10 parameters. One of the parameters is BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO
. BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO
takes another 13 parameters.
Running my test program results in:
>.\bcrypt-gmac.exe
BCryptEncrypt error, 0xc000000d (STATUS_INVALID_PARAMETER)
STATUS_INVALID_PARAMETER
is not very helpful in this case.
My question is, how do I determine which of the 23 parameters is causing the error when using Bcrypt?
Is there a way to get extended error information, like through BcryptPropertyGet
(maybe a LAST_ERROR_PARAMETER
or something similar)?
Or does Microsoft expect us to guess at the problem? In this case, I guess the answer is, "you can't".
The Microsoft docs don't provide examples of using Bcrypt. I also cannot find helpful examples on Stack Overflow or MSDN. Even Writing Secure Code for Windows Vista fails to provide examples.
Here is the treatment in Writing Secure Code for Windows Vista. It amounts to pseudo-code, which is very disappointing: