bcrypt: Support retrieving hash length from algorithm handles.
Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
e3e2805b25
commit
11279badf2
|
@ -438,6 +438,11 @@ static NTSTATUS get_alg_property( enum alg_id id, const WCHAR *prop, UCHAR *buf,
|
|||
value = OBJECT_LENGTH_SHA1;
|
||||
break;
|
||||
}
|
||||
else if (!strcmpW( prop, BCRYPT_HASH_LENGTH ))
|
||||
{
|
||||
value = HASH_DIGEST_LENGTH_SHA1;
|
||||
break;
|
||||
}
|
||||
FIXME( "unsupported sha1 algorithm property %s\n", debugstr_w(prop) );
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
|
||||
|
@ -447,6 +452,11 @@ static NTSTATUS get_alg_property( enum alg_id id, const WCHAR *prop, UCHAR *buf,
|
|||
value = OBJECT_LENGTH_SHA256;
|
||||
break;
|
||||
}
|
||||
else if (!strcmpW( prop, BCRYPT_HASH_LENGTH ))
|
||||
{
|
||||
value = HASH_DIGEST_LENGTH_SHA256;
|
||||
break;
|
||||
}
|
||||
FIXME( "unsupported sha256 algorithm property %s\n", debugstr_w(prop) );
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
|
||||
|
@ -456,6 +466,11 @@ static NTSTATUS get_alg_property( enum alg_id id, const WCHAR *prop, UCHAR *buf,
|
|||
value = OBJECT_LENGTH_SHA384;
|
||||
break;
|
||||
}
|
||||
else if (!strcmpW( prop, BCRYPT_HASH_LENGTH ))
|
||||
{
|
||||
value = HASH_DIGEST_LENGTH_SHA384;
|
||||
break;
|
||||
}
|
||||
FIXME( "unsupported sha384 algorithm property %s\n", debugstr_w(prop) );
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
|
||||
|
@ -465,6 +480,11 @@ static NTSTATUS get_alg_property( enum alg_id id, const WCHAR *prop, UCHAR *buf,
|
|||
value = OBJECT_LENGTH_SHA512;
|
||||
break;
|
||||
}
|
||||
else if (!strcmpW( prop, BCRYPT_HASH_LENGTH ))
|
||||
{
|
||||
value = HASH_DIGEST_LENGTH_SHA512;
|
||||
break;
|
||||
}
|
||||
FIXME( "unsupported sha512 algorithm property %s\n", debugstr_w(prop) );
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
|
||||
|
|
|
@ -123,6 +123,12 @@ static void test_sha1(void)
|
|||
ok(len != 0xdeadbeef, "len not set\n");
|
||||
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;
|
||||
len = sizeof(buf);
|
||||
ret = BCryptCreateHash(alg, &hash, buf, len, NULL, 0, 0);
|
||||
|
@ -196,6 +202,12 @@ static void test_sha256(void)
|
|||
ok(len != 0xdeadbeef, "len not set\n");
|
||||
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;
|
||||
len = sizeof(buf);
|
||||
ret = BCryptCreateHash(alg, &hash, buf, len, NULL, 0, 0);
|
||||
|
@ -269,6 +281,12 @@ static void test_sha384(void)
|
|||
ok(len != 0xdeadbeef, "len not set\n");
|
||||
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;
|
||||
len = sizeof(buf);
|
||||
ret = BCryptCreateHash(alg, &hash, buf, len, NULL, 0, 0);
|
||||
|
@ -343,6 +361,12 @@ static void test_sha512(void)
|
|||
ok(len != 0xdeadbeef, "len not set\n");
|
||||
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;
|
||||
len = sizeof(buf);
|
||||
ret = BCryptCreateHash(alg, &hash, buf, len, NULL, 0, 0);
|
||||
|
|
Loading…
Reference in New Issue