bcrypt: Implement BCryptGetProperty.
Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
0c9b94eeb3
commit
46369d79e0
|
@ -216,11 +216,157 @@ static NTSTATUS hash_init( struct hash *hash )
|
|||
}
|
||||
#endif
|
||||
|
||||
NTSTATUS WINAPI BCryptGetProperty(BCRYPT_HANDLE obj, LPCWSTR prop, UCHAR *buffer, ULONG count, ULONG *res, ULONG flags)
|
||||
{
|
||||
FIXME("%p, %s, %p, %u, %p, %08x - stub\n", obj, wine_dbgstr_w(prop), buffer, count, res, flags);
|
||||
#define OBJECT_LENGTH_SHA1 278
|
||||
#define OBJECT_LENGTH_SHA256 286
|
||||
#define OBJECT_LENGTH_SHA384 382
|
||||
#define OBJECT_LENGTH_SHA512 382
|
||||
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
#define HASH_DIGEST_LENGTH_SHA1 20
|
||||
#define HASH_DIGEST_LENGTH_SHA256 32
|
||||
#define HASH_DIGEST_LENGTH_SHA384 48
|
||||
#define HASH_DIGEST_LENGTH_SHA512 64
|
||||
|
||||
static NTSTATUS get_alg_property( enum alg_id id, const WCHAR *prop, UCHAR *buf, ULONG size, ULONG *ret_size )
|
||||
{
|
||||
ULONG value;
|
||||
|
||||
switch (id)
|
||||
{
|
||||
case ALG_ID_SHA1:
|
||||
if (!strcmpW( prop, BCRYPT_OBJECT_LENGTH ))
|
||||
{
|
||||
value = OBJECT_LENGTH_SHA1;
|
||||
break;
|
||||
}
|
||||
FIXME( "unsupported sha1 algorithm property %s\n", debugstr_w(prop) );
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
|
||||
case ALG_ID_SHA256:
|
||||
if (!strcmpW( prop, BCRYPT_OBJECT_LENGTH ))
|
||||
{
|
||||
value = OBJECT_LENGTH_SHA256;
|
||||
break;
|
||||
}
|
||||
FIXME( "unsupported sha256 algorithm property %s\n", debugstr_w(prop) );
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
|
||||
case ALG_ID_SHA384:
|
||||
if (!strcmpW( prop, BCRYPT_OBJECT_LENGTH ))
|
||||
{
|
||||
value = OBJECT_LENGTH_SHA384;
|
||||
break;
|
||||
}
|
||||
FIXME( "unsupported sha384 algorithm property %s\n", debugstr_w(prop) );
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
|
||||
case ALG_ID_SHA512:
|
||||
if (!strcmpW( prop, BCRYPT_OBJECT_LENGTH ))
|
||||
{
|
||||
value = OBJECT_LENGTH_SHA512;
|
||||
break;
|
||||
}
|
||||
FIXME( "unsupported sha512 algorithm property %s\n", debugstr_w(prop) );
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
|
||||
default:
|
||||
FIXME( "unsupported algorithm %u\n", id );
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
if (size < sizeof(ULONG))
|
||||
{
|
||||
*ret_size = sizeof(ULONG);
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
if (buf) *(ULONG *)buf = value;
|
||||
*ret_size = sizeof(ULONG);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static NTSTATUS get_hash_property( enum alg_id id, const WCHAR *prop, UCHAR *buf, ULONG size, ULONG *ret_size )
|
||||
{
|
||||
ULONG value;
|
||||
|
||||
switch (id)
|
||||
{
|
||||
case ALG_ID_SHA1:
|
||||
if (!strcmpW( prop, BCRYPT_HASH_LENGTH ))
|
||||
{
|
||||
value = HASH_DIGEST_LENGTH_SHA1;
|
||||
break;
|
||||
}
|
||||
FIXME( "unsupported sha1 hash property %s\n", debugstr_w(prop) );
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
|
||||
case ALG_ID_SHA256:
|
||||
if (!strcmpW( prop, BCRYPT_HASH_LENGTH ))
|
||||
{
|
||||
value = HASH_DIGEST_LENGTH_SHA256;
|
||||
break;
|
||||
}
|
||||
FIXME( "unsupported sha256 hash property %s\n", debugstr_w(prop) );
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
|
||||
case ALG_ID_SHA384:
|
||||
if (!strcmpW( prop, BCRYPT_HASH_LENGTH ))
|
||||
{
|
||||
value = HASH_DIGEST_LENGTH_SHA384;
|
||||
break;
|
||||
}
|
||||
FIXME( "unsupported sha384 hash property %s\n", debugstr_w(prop) );
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
|
||||
case ALG_ID_SHA512:
|
||||
if (!strcmpW( prop, BCRYPT_HASH_LENGTH ))
|
||||
{
|
||||
value = HASH_DIGEST_LENGTH_SHA512;
|
||||
break;
|
||||
}
|
||||
FIXME( "unsupported sha512 hash property %s\n", debugstr_w(prop) );
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
|
||||
default:
|
||||
FIXME( "unsupported hash %u\n", id );
|
||||
return STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
if (size < sizeof(ULONG))
|
||||
{
|
||||
*ret_size = sizeof(ULONG);
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
if (buf) *(ULONG *)buf = value;
|
||||
*ret_size = sizeof(ULONG);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS WINAPI BCryptGetProperty( BCRYPT_HANDLE handle, LPCWSTR prop, UCHAR *buffer, ULONG count, ULONG *res, ULONG flags )
|
||||
{
|
||||
struct object *object = handle;
|
||||
|
||||
TRACE( "%p, %s, %p, %u, %p, %08x\n", handle, wine_dbgstr_w(prop), buffer, count, res, flags );
|
||||
|
||||
if (!object) return STATUS_INVALID_HANDLE;
|
||||
if (!prop || !res) return STATUS_INVALID_PARAMETER;
|
||||
|
||||
switch (object->magic)
|
||||
{
|
||||
case MAGIC_ALG:
|
||||
{
|
||||
const struct algorithm *alg = (const struct algorithm *)object;
|
||||
return get_alg_property( alg->id, prop, buffer, count, res );
|
||||
}
|
||||
case MAGIC_HASH:
|
||||
{
|
||||
const struct hash *hash = (const struct hash *)object;
|
||||
return get_hash_property( hash->alg_id, prop, buffer, count, res );
|
||||
}
|
||||
default:
|
||||
WARN( "unknown magic %08x", object->magic );
|
||||
return STATUS_INVALID_HANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
NTSTATUS WINAPI BCryptCreateHash( BCRYPT_ALG_HANDLE algorithm, BCRYPT_HASH_HANDLE *handle, UCHAR *object, ULONG objectlen,
|
||||
|
|
Loading…
Reference in New Issue