On Fri, 2016-03-18 at 09:26 -0700, Patrick Armstrong wrote:
+NTSTATUS WINAPI BCryptHash( BCRYPT_ALG_HANDLE algorithm, UCHAR *secret, ULONG secretlen,
UCHAR *input, ULONG inputlen, UCHAR *output, ULONG outputlen )
+{
- NTSTATUS status;
- BCRYPT_ALG_HANDLE handle;
This should be BCRYPT_HASH_HANDLE.
- TRACE( "%p, %p, %u, %p, %u, %p, %u\n", algorithm, secret, secretlen,
input, inputlen, output, outputlen );
- status = BCryptCreateHash( algorithm, &handle, NULL, 0, secret, secretlen, 0);
- if (status != STATUS_SUCCESS)
- {
goto cleanup_bcrypt_hash;
- }
There's no need for cleanup here.
- status = BCryptHashData( handle, input, inputlen, 0 );
- if (status != STATUS_SUCCESS)
- {
goto cleanup_bcrypt_hash;
- }
- status = BCryptFinishHash( handle, output, outputlen, 0 );
- if (status != STATUS_SUCCESS)
- {
goto cleanup_bcrypt_hash;
- }
- return BCryptDestroyHash( handle );
+cleanup_bcrypt_hash:
- BCryptDestroyHash( handle );
- return status;
+}
I don't think this goto is better than repeated BCryptDestroyHash calls.