Commit 085ed64d authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

bcrypt: Implement BCryptFinishHash.

parent b1e08b39
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
@ stub BCryptEnumRegisteredProviders @ stub BCryptEnumRegisteredProviders
@ stub BCryptExportKey @ stub BCryptExportKey
@ stub BCryptFinalizeKeyPair @ stub BCryptFinalizeKeyPair
@ stub BCryptFinishHash @ stdcall BCryptFinishHash(ptr ptr long long)
@ stub BCryptFreeBuffer @ stub BCryptFreeBuffer
@ stdcall BCryptGenRandom(ptr ptr long long) @ stdcall BCryptGenRandom(ptr ptr long long)
@ stub BCryptGenerateKeyPair @ stub BCryptGenerateKeyPair
......
...@@ -228,6 +228,33 @@ static void hash_update( struct hash *hash, UCHAR *input, ULONG size ) ...@@ -228,6 +228,33 @@ static void hash_update( struct hash *hash, UCHAR *input, ULONG size )
break; break;
} }
} }
static NTSTATUS hash_finish( struct hash *hash, UCHAR *output, ULONG size )
{
switch (hash->alg_id)
{
case ALG_ID_SHA1:
CC_SHA1_Final( output, &hash->u.sha1_ctx );
break;
case ALG_ID_SHA256:
CC_SHA256_Final( output, &hash->u.sha256_ctx );
break;
case ALG_ID_SHA384:
CC_SHA384_Final( output, &hash->u.sha512_ctx );
break;
case ALG_ID_SHA512:
CC_SHA512_Final( output, &hash->u.sha512_ctx );
break;
default:
ERR( "unhandled id %u\n", hash->alg_id );
break;
}
return STATUS_SUCCESS;
}
#else #else
struct hash struct hash
{ {
...@@ -245,6 +272,12 @@ static void hash_update( struct hash *hash, UCHAR *input, ULONG size ) ...@@ -245,6 +272,12 @@ static void hash_update( struct hash *hash, UCHAR *input, ULONG size )
{ {
ERR( "support for hashes not available at build time\n" ); ERR( "support for hashes not available at build time\n" );
} }
static NTSTATUS hash_finish( struct hash *hash, UCHAR *output, ULONG size )
{
ERR( "support for hashes not available at build time\n" );
return STATUS_NOT_IMPLEMENTED;
}
#endif #endif
#define OBJECT_LENGTH_SHA1 278 #define OBJECT_LENGTH_SHA1 278
...@@ -454,3 +487,15 @@ NTSTATUS WINAPI BCryptHashData( BCRYPT_HASH_HANDLE handle, UCHAR *input, ULONG s ...@@ -454,3 +487,15 @@ NTSTATUS WINAPI BCryptHashData( BCRYPT_HASH_HANDLE handle, UCHAR *input, ULONG s
hash_update( hash, input, size ); hash_update( hash, input, size );
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
NTSTATUS WINAPI BCryptFinishHash( BCRYPT_HASH_HANDLE handle, UCHAR *output, ULONG size, ULONG flags )
{
struct hash *hash = handle;
TRACE( "%p, %p, %u, %08x\n", handle, output, size, flags );
if (!hash || hash->hdr.magic != MAGIC_HASH) return STATUS_INVALID_HANDLE;
if (!output) return STATUS_INVALID_PARAMETER;
return hash_finish( hash, output, size );
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment