Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
e672d8b6
Commit
e672d8b6
authored
Aug 12, 2004
by
James Hawkins
Committed by
Alexandre Julliard
Aug 12, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests for CryptEnumProviders.
parent
e1f5370f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
105 additions
and
0 deletions
+105
-0
crypt.c
dlls/advapi32/tests/crypt.c
+105
-0
No files found.
dlls/advapi32/tests/crypt.c
View file @
e672d8b6
...
...
@@ -25,6 +25,7 @@
#include "winbase.h"
#include "wincrypt.h"
#include "winerror.h"
#include "winreg.h"
static
const
char
szRsaBaseProv
[]
=
MS_DEF_PROV_A
;
static
const
char
szNonExistentProv
[]
=
"Wine Non Existent Cryptographic Provider v11.2"
;
...
...
@@ -119,9 +120,113 @@ static void test_acquire_context(void)
CryptReleaseContext
(
hProv
,
0
);
}
static
BOOL
FindProvRegVals
(
DWORD
dwIndex
,
DWORD
*
pdwProvType
,
LPSTR
*
pszProvName
,
DWORD
*
pcbProvName
,
DWORD
*
pdwProvCount
)
{
HKEY
hKey
;
HKEY
subkey
;
DWORD
size
=
sizeof
(
DWORD
);
if
(
RegOpenKey
(
HKEY_LOCAL_MACHINE
,
"Software
\\
Microsoft
\\
Cryptography
\\
Defaults
\\
Provider"
,
&
hKey
))
return
FALSE
;
RegQueryInfoKey
(
hKey
,
NULL
,
NULL
,
NULL
,
pdwProvCount
,
pcbProvName
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
if
(
!
(
*
pszProvName
=
((
LPSTR
)
LocalAlloc
(
LMEM_ZEROINIT
,
*
pcbProvName
))))
return
FALSE
;
RegEnumKeyEx
(
hKey
,
dwIndex
,
*
pszProvName
,
pcbProvName
,
NULL
,
NULL
,
NULL
,
NULL
);
(
*
pcbProvName
)
++
;
RegOpenKey
(
hKey
,
*
pszProvName
,
&
subkey
);
RegQueryValueEx
(
subkey
,
"Type"
,
NULL
,
NULL
,
(
BYTE
*
)
pdwProvType
,
&
size
);
RegCloseKey
(
subkey
);
RegCloseKey
(
hKey
);
return
TRUE
;
}
static
void
test_enum_providers
(
void
)
{
/* expected results */
CHAR
*
pszProvName
=
NULL
;
DWORD
cbName
;
DWORD
dwType
;
DWORD
provCount
;
DWORD
dwIndex
=
0
;
/* actual results */
CHAR
*
provider
=
NULL
;
DWORD
providerLen
;
DWORD
type
;
DWORD
count
;
BOOL
result
;
DWORD
notNull
=
5
;
DWORD
notZeroFlags
=
5
;
if
(
!
FindProvRegVals
(
dwIndex
,
&
dwType
,
&
pszProvName
,
&
cbName
,
&
provCount
))
return
;
/* check pdwReserved flag for NULL */
result
=
CryptEnumProviders
(
dwIndex
,
&
notNull
,
0
,
&
type
,
NULL
,
&
providerLen
);
ok
(
!
result
&&
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"%08x
\n
"
,
(
unsigned
int
)
GetLastError
());
/* check dwFlags == 0 */
result
=
CryptEnumProviders
(
dwIndex
,
NULL
,
notZeroFlags
,
&
type
,
NULL
,
&
providerLen
);
ok
(
!
result
&&
GetLastError
()
==
NTE_BAD_FLAGS
,
"%08x
\n
"
,
(
unsigned
int
)
GetLastError
());
/* alloc provider to half the size required
* cbName holds the size required */
todo_wine
{
providerLen
=
cbName
/
2
;
if
(
!
(
provider
=
((
LPSTR
)
LocalAlloc
(
LMEM_ZEROINIT
,
providerLen
))))
return
;
result
=
CryptEnumProviders
(
dwIndex
,
NULL
,
0
,
&
type
,
provider
,
&
providerLen
);
ok
(
!
result
&&
GetLastError
()
==
ERROR_MORE_DATA
,
"expected %08x, got %08x
\n
"
,
ERROR_MORE_DATA
,
(
unsigned
int
)
GetLastError
());
LocalFree
(
provider
);
}
/* loop through the providers to get the number of providers
* after loop ends, count should be provCount + 1 so subtract 1
* to get actual number of providers */
count
=
0
;
while
(
CryptEnumProviders
(
count
++
,
NULL
,
0
,
&
dwType
,
NULL
,
&
providerLen
))
;
count
--
;
ok
(
count
==
provCount
,
"expected %i, got %i
\n
"
,
(
int
)
provCount
,
(
int
)
count
);
/* loop past the actual number of providers to get the error
* ERROR_NO_MORE_ITEMS */
for
(
count
=
0
;
count
<
provCount
+
1
;
count
++
)
result
=
CryptEnumProviders
(
count
,
NULL
,
0
,
&
dwType
,
NULL
,
&
providerLen
);
ok
(
!
result
&&
GetLastError
()
==
ERROR_NO_MORE_ITEMS
,
"expected %08x, got %08x
\n
"
,
ERROR_NO_MORE_ITEMS
,
(
unsigned
int
)
GetLastError
());
/* check expected versus actual values returned */
result
=
CryptEnumProviders
(
dwIndex
,
NULL
,
0
,
&
type
,
NULL
,
&
providerLen
);
ok
(
result
&&
providerLen
==
cbName
,
"expected %i, got %i
\n
"
,
(
int
)
cbName
,
(
int
)
providerLen
);
if
(
!
(
provider
=
((
LPSTR
)
LocalAlloc
(
LMEM_ZEROINIT
,
providerLen
))))
return
;
result
=
CryptEnumProviders
(
dwIndex
,
NULL
,
0
,
&
type
,
provider
,
&
providerLen
);
ok
(
result
&&
type
==
dwType
,
"expected %i, got %i
\n
"
,
(
unsigned
int
)
dwType
,
(
unsigned
int
)
type
);
ok
(
result
&&
!
strcmp
(
pszProvName
,
provider
),
"expected %s, got %s
\n
"
,
pszProvName
,
provider
);
ok
(
result
&&
cbName
==
providerLen
,
"expected %i, got %i
\n
"
,
(
unsigned
int
)
cbName
,
(
unsigned
int
)
providerLen
);
}
START_TEST
(
crypt
)
{
init_environment
();
test_acquire_context
();
clean_up_environment
();
test_enum_providers
();
}
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