Commit 11279bad authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

bcrypt: Support retrieving hash length from algorithm handles.

parent e3e2805b
...@@ -438,6 +438,11 @@ static NTSTATUS get_alg_property( enum alg_id id, const WCHAR *prop, UCHAR *buf, ...@@ -438,6 +438,11 @@ static NTSTATUS get_alg_property( enum alg_id id, const WCHAR *prop, UCHAR *buf,
value = OBJECT_LENGTH_SHA1; value = OBJECT_LENGTH_SHA1;
break; break;
} }
else if (!strcmpW( prop, BCRYPT_HASH_LENGTH ))
{
value = HASH_DIGEST_LENGTH_SHA1;
break;
}
FIXME( "unsupported sha1 algorithm property %s\n", debugstr_w(prop) ); FIXME( "unsupported sha1 algorithm property %s\n", debugstr_w(prop) );
return STATUS_NOT_IMPLEMENTED; return STATUS_NOT_IMPLEMENTED;
...@@ -447,6 +452,11 @@ static NTSTATUS get_alg_property( enum alg_id id, const WCHAR *prop, UCHAR *buf, ...@@ -447,6 +452,11 @@ static NTSTATUS get_alg_property( enum alg_id id, const WCHAR *prop, UCHAR *buf,
value = OBJECT_LENGTH_SHA256; value = OBJECT_LENGTH_SHA256;
break; break;
} }
else if (!strcmpW( prop, BCRYPT_HASH_LENGTH ))
{
value = HASH_DIGEST_LENGTH_SHA256;
break;
}
FIXME( "unsupported sha256 algorithm property %s\n", debugstr_w(prop) ); FIXME( "unsupported sha256 algorithm property %s\n", debugstr_w(prop) );
return STATUS_NOT_IMPLEMENTED; return STATUS_NOT_IMPLEMENTED;
...@@ -456,6 +466,11 @@ static NTSTATUS get_alg_property( enum alg_id id, const WCHAR *prop, UCHAR *buf, ...@@ -456,6 +466,11 @@ static NTSTATUS get_alg_property( enum alg_id id, const WCHAR *prop, UCHAR *buf,
value = OBJECT_LENGTH_SHA384; value = OBJECT_LENGTH_SHA384;
break; break;
} }
else if (!strcmpW( prop, BCRYPT_HASH_LENGTH ))
{
value = HASH_DIGEST_LENGTH_SHA384;
break;
}
FIXME( "unsupported sha384 algorithm property %s\n", debugstr_w(prop) ); FIXME( "unsupported sha384 algorithm property %s\n", debugstr_w(prop) );
return STATUS_NOT_IMPLEMENTED; return STATUS_NOT_IMPLEMENTED;
...@@ -465,6 +480,11 @@ static NTSTATUS get_alg_property( enum alg_id id, const WCHAR *prop, UCHAR *buf, ...@@ -465,6 +480,11 @@ static NTSTATUS get_alg_property( enum alg_id id, const WCHAR *prop, UCHAR *buf,
value = OBJECT_LENGTH_SHA512; value = OBJECT_LENGTH_SHA512;
break; break;
} }
else if (!strcmpW( prop, BCRYPT_HASH_LENGTH ))
{
value = HASH_DIGEST_LENGTH_SHA512;
break;
}
FIXME( "unsupported sha512 algorithm property %s\n", debugstr_w(prop) ); FIXME( "unsupported sha512 algorithm property %s\n", debugstr_w(prop) );
return STATUS_NOT_IMPLEMENTED; return STATUS_NOT_IMPLEMENTED;
......
...@@ -123,6 +123,12 @@ static void test_sha1(void) ...@@ -123,6 +123,12 @@ static void test_sha1(void)
ok(len != 0xdeadbeef, "len not set\n"); ok(len != 0xdeadbeef, "len not set\n");
ok(size == sizeof(len), "got %u\n", size); ok(size == sizeof(len), "got %u\n", size);
len = size = 0xdeadbeef;
ret = BCryptGetProperty(alg, BCRYPT_HASH_LENGTH, (UCHAR *)&len , sizeof(len), &size, 0);
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
ok(len == 20, "got %u\n", len);
ok(size == sizeof(len), "got %u\n", size);
hash = NULL; hash = NULL;
len = sizeof(buf); len = sizeof(buf);
ret = BCryptCreateHash(alg, &hash, buf, len, NULL, 0, 0); ret = BCryptCreateHash(alg, &hash, buf, len, NULL, 0, 0);
...@@ -196,6 +202,12 @@ static void test_sha256(void) ...@@ -196,6 +202,12 @@ static void test_sha256(void)
ok(len != 0xdeadbeef, "len not set\n"); ok(len != 0xdeadbeef, "len not set\n");
ok(size == sizeof(len), "got %u\n", size); ok(size == sizeof(len), "got %u\n", size);
len = size = 0xdeadbeef;
ret = BCryptGetProperty(alg, BCRYPT_HASH_LENGTH, (UCHAR *)&len , sizeof(len), &size, 0);
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
ok(len == 32, "got %u\n", len);
ok(size == sizeof(len), "got %u\n", size);
hash = NULL; hash = NULL;
len = sizeof(buf); len = sizeof(buf);
ret = BCryptCreateHash(alg, &hash, buf, len, NULL, 0, 0); ret = BCryptCreateHash(alg, &hash, buf, len, NULL, 0, 0);
...@@ -269,6 +281,12 @@ static void test_sha384(void) ...@@ -269,6 +281,12 @@ static void test_sha384(void)
ok(len != 0xdeadbeef, "len not set\n"); ok(len != 0xdeadbeef, "len not set\n");
ok(size == sizeof(len), "got %u\n", size); ok(size == sizeof(len), "got %u\n", size);
len = size = 0xdeadbeef;
ret = BCryptGetProperty(alg, BCRYPT_HASH_LENGTH, (UCHAR *)&len , sizeof(len), &size, 0);
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
ok(len == 48, "got %u\n", len);
ok(size == sizeof(len), "got %u\n", size);
hash = NULL; hash = NULL;
len = sizeof(buf); len = sizeof(buf);
ret = BCryptCreateHash(alg, &hash, buf, len, NULL, 0, 0); ret = BCryptCreateHash(alg, &hash, buf, len, NULL, 0, 0);
...@@ -343,6 +361,12 @@ static void test_sha512(void) ...@@ -343,6 +361,12 @@ static void test_sha512(void)
ok(len != 0xdeadbeef, "len not set\n"); ok(len != 0xdeadbeef, "len not set\n");
ok(size == sizeof(len), "got %u\n", size); ok(size == sizeof(len), "got %u\n", size);
len = size = 0xdeadbeef;
ret = BCryptGetProperty(alg, BCRYPT_HASH_LENGTH, (UCHAR *)&len , sizeof(len), &size, 0);
ok(ret == STATUS_SUCCESS, "got %08x\n", ret);
ok(len == 64, "got %u\n", len);
ok(size == sizeof(len), "got %u\n", size);
hash = NULL; hash = NULL;
len = sizeof(buf); len = sizeof(buf);
ret = BCryptCreateHash(alg, &hash, buf, len, NULL, 0, 0); ret = BCryptCreateHash(alg, &hash, buf, len, NULL, 0, 0);
......
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