bcrypt: Implement BCryptFinishHash.
Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
b1e08b3928
commit
085ed64df6
|
@ -22,7 +22,7 @@
|
|||
@ stub BCryptEnumRegisteredProviders
|
||||
@ stub BCryptExportKey
|
||||
@ stub BCryptFinalizeKeyPair
|
||||
@ stub BCryptFinishHash
|
||||
@ stdcall BCryptFinishHash(ptr ptr long long)
|
||||
@ stub BCryptFreeBuffer
|
||||
@ stdcall BCryptGenRandom(ptr ptr long long)
|
||||
@ stub BCryptGenerateKeyPair
|
||||
|
|
|
@ -228,6 +228,33 @@ static void hash_update( struct hash *hash, UCHAR *input, ULONG size )
|
|||
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
|
||||
struct hash
|
||||
{
|
||||
|
@ -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" );
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
#define OBJECT_LENGTH_SHA1 278
|
||||
|
@ -454,3 +487,15 @@ NTSTATUS WINAPI BCryptHashData( BCRYPT_HASH_HANDLE handle, UCHAR *input, ULONG s
|
|||
hash_update( hash, input, size );
|
||||
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 );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue