Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
a7578c7a
Commit
a7578c7a
authored
Feb 10, 2014
by
Bruno Jesus
Committed by
Alexandre Julliard
Feb 11, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcrypt: Add semi-stub implementation of BCryptGenRandom.
parent
c47ba3a4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
3 deletions
+45
-3
Makefile.in
dlls/bcrypt/Makefile.in
+1
-0
bcrypt_main.c
dlls/bcrypt/bcrypt_main.c
+31
-1
bcrypt.c
dlls/bcrypt/tests/bcrypt.c
+13
-2
No files found.
dlls/bcrypt/Makefile.in
View file @
a7578c7a
MODULE
=
bcrypt.dll
IMPORTS
=
advapi32
C_SRCS
=
\
bcrypt_main.c
...
...
dlls/bcrypt/bcrypt_main.c
View file @
a7578c7a
...
...
@@ -25,6 +25,7 @@
#define WIN32_NO_STATUS
#include "windef.h"
#include "winbase.h"
#include "ntsecapi.h"
#include "bcrypt.h"
#include "wine/debug.h"
...
...
@@ -57,7 +58,36 @@ NTSTATUS WINAPI BCryptEnumAlgorithms(ULONG dwAlgOperations, ULONG *pAlgCount,
NTSTATUS
WINAPI
BCryptGenRandom
(
BCRYPT_ALG_HANDLE
algorithm
,
UCHAR
*
buffer
,
ULONG
count
,
ULONG
flags
)
{
FIXME
(
"%p, %p, %u, %08x - stub
\n
"
,
algorithm
,
buffer
,
count
,
flags
);
const
DWORD
supported_flags
=
BCRYPT_USE_SYSTEM_PREFERRED_RNG
;
TRACE
(
"%p, %p, %u, %08x - semi-stub
\n
"
,
algorithm
,
buffer
,
count
,
flags
);
if
(
!
algorithm
)
{
/* It's valid to call without an algorithm if BCRYPT_USE_SYSTEM_PREFERRED_RNG
* is set. In this case the preferred system RNG is used.
*/
if
(
!
(
flags
&
BCRYPT_USE_SYSTEM_PREFERRED_RNG
))
return
STATUS_INVALID_HANDLE
;
}
if
(
!
buffer
)
return
STATUS_INVALID_PARAMETER
;
if
(
flags
&
~
supported_flags
)
FIXME
(
"unsupported flags %08x
\n
"
,
flags
&
~
supported_flags
);
if
(
algorithm
)
FIXME
(
"ignoring selected algorithm
\n
"
);
/* When zero bytes are requested the function returns success too. */
if
(
!
count
)
return
STATUS_SUCCESS
;
if
(
flags
&
BCRYPT_USE_SYSTEM_PREFERRED_RNG
)
{
if
(
RtlGenRandom
(
buffer
,
count
))
return
STATUS_SUCCESS
;
}
FIXME
(
"called with unsupported parameters, returning error
\n
"
);
return
STATUS_NOT_IMPLEMENTED
;
}
dlls/bcrypt/tests/bcrypt.c
View file @
a7578c7a
...
...
@@ -53,7 +53,6 @@ static void test_BCryptGenRandom(void)
return
;
}
todo_wine
{
ret
=
pBCryptGenRandom
(
NULL
,
NULL
,
0
,
0
);
ok
(
ret
==
STATUS_INVALID_HANDLE
,
"Expected STATUS_INVALID_HANDLE, got 0x%x
\n
"
,
ret
);
ret
=
pBCryptGenRandom
(
NULL
,
buffer
,
0
,
0
);
...
...
@@ -62,9 +61,21 @@ static void test_BCryptGenRandom(void)
ok
(
ret
==
STATUS_INVALID_HANDLE
,
"Expected STATUS_INVALID_HANDLE, got 0x%x
\n
"
,
ret
);
ret
=
pBCryptGenRandom
(
NULL
,
buffer
,
sizeof
(
buffer
),
BCRYPT_USE_SYSTEM_PREFERRED_RNG
);
ok
(
ret
==
STATUS_SUCCESS
,
"Expected success, got 0x%x
\n
"
,
ret
);
ret
=
pBCryptGenRandom
(
NULL
,
buffer
,
sizeof
(
buffer
),
BCRYPT_USE_SYSTEM_PREFERRED_RNG
|
BCRYPT_RNG_USE_ENTROPY_IN_BUFFER
);
ok
(
ret
==
STATUS_SUCCESS
,
"Expected success, got 0x%x
\n
"
,
ret
);
ret
=
pBCryptGenRandom
(
NULL
,
NULL
,
sizeof
(
buffer
),
BCRYPT_USE_SYSTEM_PREFERRED_RNG
);
ok
(
ret
==
STATUS_INVALID_PARAMETER
,
"Expected STATUS_INVALID_PARAMETER, got 0x%x
\n
"
,
ret
);
}
/* Zero sized buffer should work too */
ret
=
pBCryptGenRandom
(
NULL
,
buffer
,
0
,
BCRYPT_USE_SYSTEM_PREFERRED_RNG
);
ok
(
ret
==
STATUS_SUCCESS
,
"Expected success, got 0x%x
\n
"
,
ret
);
/* Test random number generation - It's impossible for a sane RNG to return 8 zeros */
memset
(
buffer
,
0
,
16
);
ret
=
pBCryptGenRandom
(
NULL
,
buffer
,
8
,
BCRYPT_USE_SYSTEM_PREFERRED_RNG
);
ok
(
ret
==
STATUS_SUCCESS
,
"Expected success, got 0x%x
\n
"
,
ret
);
ok
(
memcmp
(
buffer
,
buffer
+
8
,
8
),
"Expected a random number, got 0
\n
"
);
}
START_TEST
(
bcrypt
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment