Patrick Armstrong : bcrypt: Make BCryptHashData behave more like Windows with empty input.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Mar 9 08:05:56 CST 2016


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

Author: Patrick Armstrong <pat at triplefox.com>
Date:   Tue Mar  8 20:42:45 2016 -0800

bcrypt: Make BCryptHashData behave more like Windows with empty input.

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

---

 dlls/bcrypt/bcrypt_main.c  |  2 +-
 dlls/bcrypt/tests/bcrypt.c | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/dlls/bcrypt/bcrypt_main.c b/dlls/bcrypt/bcrypt_main.c
index 957efdd..c919c1d 100644
--- a/dlls/bcrypt/bcrypt_main.c
+++ b/dlls/bcrypt/bcrypt_main.c
@@ -632,7 +632,7 @@ NTSTATUS WINAPI BCryptHashData( BCRYPT_HASH_HANDLE handle, UCHAR *input, ULONG s
     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;
+    if (!input) return STATUS_SUCCESS;
 
     return hash_update( hash, input, size );
 }
diff --git a/dlls/bcrypt/tests/bcrypt.c b/dlls/bcrypt/tests/bcrypt.c
index bcb287b..f1f0002 100644
--- a/dlls/bcrypt/tests/bcrypt.c
+++ b/dlls/bcrypt/tests/bcrypt.c
@@ -165,6 +165,9 @@ static void test_sha1(void)
     ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
     ok(hash != NULL, "hash not set\n");
 
+    ret = BCryptHashData(hash, NULL, 0, 0);
+    ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+
     ret = BCryptHashData(hash, (UCHAR *)"test", sizeof("test"), 0);
     ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
 
@@ -238,6 +241,9 @@ static void test_sha256(void)
     ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
     ok(hash != NULL, "hash not set\n");
 
+    ret = BCryptHashData(hash, NULL, 0, 0);
+    ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+
     ret = BCryptHashData(hash, (UCHAR *)"test", sizeof("test"), 0);
     ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
 
@@ -311,6 +317,9 @@ static void test_sha384(void)
     ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
     ok(hash != NULL, "hash not set\n");
 
+    ret = BCryptHashData(hash, NULL, 0, 0);
+    ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+
     ret = BCryptHashData(hash, (UCHAR *)"test", sizeof("test"), 0);
     ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
 
@@ -385,6 +394,9 @@ static void test_sha512(void)
     ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
     ok(hash != NULL, "hash not set\n");
 
+    ret = BCryptHashData(hash, NULL, 0, 0);
+    ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+
     ret = BCryptHashData(hash, (UCHAR *)"test", sizeof("test"), 0);
     ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
 
@@ -458,6 +470,9 @@ static void test_md5(void)
     ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
     ok(hash != NULL, "hash not set\n");
 
+    ret = BCryptHashData(hash, NULL, 0, 0);
+    ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
+
     ret = BCryptHashData(hash, (UCHAR *)"test", sizeof("test"), 0);
     ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
 




More information about the wine-cvs mailing list