Hans Leidekker : bcrypt: Implement BCryptHashData.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Jan 6 14:50:56 CST 2016


Module: wine
Branch: master
Commit: b1e08b3928f00f36eefd1bcec17c83dbd58419ab
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b1e08b3928f00f36eefd1bcec17c83dbd58419ab

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Wed Jan  6 14:19:18 2016 +0100

bcrypt: Implement BCryptHashData.

Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/bcrypt/bcrypt.spec   |  2 +-
 dlls/bcrypt/bcrypt_main.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/dlls/bcrypt/bcrypt.spec b/dlls/bcrypt/bcrypt.spec
index 53db32a..5d67516 100644
--- a/dlls/bcrypt/bcrypt.spec
+++ b/dlls/bcrypt/bcrypt.spec
@@ -29,7 +29,7 @@
 @ stub BCryptGenerateSymmetricKey
 @ stdcall BCryptGetFipsAlgorithmMode(ptr)
 @ stdcall BCryptGetProperty(ptr wstr ptr long ptr long)
-@ stub BCryptHashData
+@ stdcall BCryptHashData(ptr ptr long long)
 @ stub BCryptImportKey
 @ stub BCryptImportKeyPair
 @ stdcall BCryptOpenAlgorithmProvider(ptr wstr wstr long)
diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
index 9ad3060..806fee8 100644
--- a/dlls/bcrypt/bcrypt_main.c
+++ b/dlls/bcrypt/bcrypt_main.c
@@ -202,6 +202,32 @@ static NTSTATUS hash_init( struct hash *hash )
     }
     return STATUS_SUCCESS;
 }
+
+static void hash_update( struct hash *hash, UCHAR *input, ULONG size )
+{
+    switch (hash->alg_id)
+    {
+    case ALG_ID_SHA1:
+        CC_SHA1_Update( &hash->u.sha1_ctx, input, size );
+        break;
+
+    case ALG_ID_SHA256:
+        CC_SHA256_Update( &hash->u.sha256_ctx, input, size );
+        break;
+
+    case ALG_ID_SHA384:
+        CC_SHA384_Update( &hash->u.sha512_ctx, input, size );
+        break;
+
+    case ALG_ID_SHA512:
+        CC_SHA512_Update( &hash->u.sha512_ctx, input, size );
+        break;
+
+    default:
+        ERR( "unhandled id %u\n", hash->alg_id );
+        break;
+    }
+}
 #else
 struct hash
 {
@@ -214,6 +240,11 @@ static NTSTATUS hash_init( struct hash *hash )
     ERR( "support for hashes not available at build time\n" );
     return STATUS_NOT_IMPLEMENTED;
 }
+
+static void hash_update( struct hash *hash, UCHAR *input, ULONG size )
+{
+    ERR( "support for hashes not available at build time\n" );
+}
 #endif
 
 #define OBJECT_LENGTH_SHA1      278
@@ -410,3 +441,16 @@ NTSTATUS WINAPI BCryptDestroyHash( BCRYPT_HASH_HANDLE handle )
     HeapFree( GetProcessHeap(), 0, hash );
     return STATUS_SUCCESS;
 }
+
+NTSTATUS WINAPI BCryptHashData( BCRYPT_HASH_HANDLE handle, UCHAR *input, ULONG size, ULONG flags )
+{
+    struct hash *hash = handle;
+
+    TRACE( "%p, %p, %u, %08x\n", handle, input, size, flags );
+
+    if (!hash || hash->hdr.magic != MAGIC_HASH) return STATUS_INVALID_HANDLE;
+    if (!input) return STATUS_INVALID_PARAMETER;
+
+    hash_update( hash, input, size );
+    return STATUS_SUCCESS;
+}




More information about the wine-cvs mailing list