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
5df2626a
Commit
5df2626a
authored
Nov 02, 2009
by
Jeremy White
Committed by
Alexandre Julliard
Nov 04, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
advapi32/tests: Only release providers and free keys if we've had success creating them.
parent
39d8f137
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
99 additions
and
86 deletions
+99
-86
crypt.c
dlls/advapi32/tests/crypt.c
+99
-86
No files found.
dlls/advapi32/tests/crypt.c
View file @
5df2626a
...
...
@@ -956,70 +956,78 @@ static void test_rc2_keylen(void)
ret
=
pCryptAcquireContextA
(
&
provider
,
NULL
,
NULL
,
PROV_RSA_FULL
,
CRYPT_VERIFYCONTEXT
);
ok
(
ret
,
"CryptAcquireContext error %u
\n
"
,
GetLastError
());
key_blob
.
header
.
bType
=
PLAINTEXTKEYBLOB
;
key_blob
.
header
.
bVersion
=
CUR_BLOB_VERSION
;
key_blob
.
header
.
reserved
=
0
;
key_blob
.
header
.
aiKeyAlg
=
CALG_RC2
;
key_blob
.
key_size
=
sizeof
(
key
);
memcpy
(
key_blob
.
key_data
,
key
,
key_length
);
/* Importing a 16-byte key works with the default provider. */
SetLastError
(
0xdeadbeef
);
ret
=
pCryptImportKey
(
provider
,
(
BYTE
*
)
&
key_blob
,
sizeof
(
BLOBHEADER
)
+
sizeof
(
DWORD
)
+
key_blob
.
key_size
,
0
,
CRYPT_IPSEC_HMAC_KEY
,
&
hkey
);
/* CRYPT_IPSEC_HMAC_KEY is not supported on W2K and lower */
todo_wine
ok
(
ret
||
broken
(
!
ret
&&
GetLastError
()
==
NTE_BAD_FLAGS
),
"CryptImportKey error %08x
\n
"
,
GetLastError
());
pCryptDestroyKey
(
hkey
);
pCryptReleaseContext
(
provider
,
0
);
if
(
ret
)
{
key_blob
.
header
.
bType
=
PLAINTEXTKEYBLOB
;
key_blob
.
header
.
bVersion
=
CUR_BLOB_VERSION
;
key_blob
.
header
.
reserved
=
0
;
key_blob
.
header
.
aiKeyAlg
=
CALG_RC2
;
key_blob
.
key_size
=
sizeof
(
key
);
memcpy
(
key_blob
.
key_data
,
key
,
key_length
);
/* Importing a 16-byte key works with the default provider. */
SetLastError
(
0xdeadbeef
);
ret
=
pCryptImportKey
(
provider
,
(
BYTE
*
)
&
key_blob
,
sizeof
(
BLOBHEADER
)
+
sizeof
(
DWORD
)
+
key_blob
.
key_size
,
0
,
CRYPT_IPSEC_HMAC_KEY
,
&
hkey
);
/* CRYPT_IPSEC_HMAC_KEY is not supported on W2K and lower */
todo_wine
ok
(
ret
||
broken
(
!
ret
&&
GetLastError
()
==
NTE_BAD_FLAGS
),
"CryptImportKey error %08x
\n
"
,
GetLastError
());
if
(
ret
)
pCryptDestroyKey
(
hkey
);
pCryptReleaseContext
(
provider
,
0
);
}
SetLastError
(
0xdeadbeef
);
ret
=
pCryptAcquireContextA
(
&
provider
,
NULL
,
MS_DEF_PROV
,
PROV_RSA_FULL
,
CRYPT_VERIFYCONTEXT
);
ok
(
ret
,
"CryptAcquireContext error %08x
\n
"
,
GetLastError
());
/* Importing a 16-byte key doesn't work with the base provider.. */
SetLastError
(
0xdeadbeef
);
ret
=
pCryptImportKey
(
provider
,
(
BYTE
*
)
&
key_blob
,
sizeof
(
BLOBHEADER
)
+
sizeof
(
DWORD
)
+
key_blob
.
key_size
,
0
,
0
,
&
hkey
);
ok
(
!
ret
&&
(
GetLastError
()
==
NTE_BAD_DATA
||
GetLastError
()
==
NTE_BAD_LEN
||
/* Win7 */
GetLastError
()
==
NTE_BAD_TYPE
||
/* W2K */
GetLastError
()
==
NTE_PERM
),
/* Win9x, WinMe and NT4 */
"unexpected error %08x
\n
"
,
GetLastError
());
/* but importing an 56-bit (7-byte) key does.. */
key_blob
.
key_size
=
7
;
SetLastError
(
0xdeadbeef
);
ret
=
pCryptImportKey
(
provider
,
(
BYTE
*
)
&
key_blob
,
sizeof
(
BLOBHEADER
)
+
sizeof
(
DWORD
)
+
key_blob
.
key_size
,
0
,
0
,
&
hkey
);
ok
(
ret
||
broken
(
!
ret
&&
GetLastError
()
==
NTE_BAD_TYPE
)
||
/* W2K */
broken
(
!
ret
&&
GetLastError
()
==
NTE_PERM
),
/* Win9x, WinMe and NT4 */
"CryptAcquireContext error %08x
\n
"
,
GetLastError
());
pCryptDestroyKey
(
hkey
);
/* as does importing a 16-byte key with the base provider when
* CRYPT_IPSEC_HMAC_KEY is specified.
*/
key_blob
.
key_size
=
sizeof
(
key
);
SetLastError
(
0xdeadbeef
);
ret
=
pCryptImportKey
(
provider
,
(
BYTE
*
)
&
key_blob
,
sizeof
(
BLOBHEADER
)
+
sizeof
(
DWORD
)
+
key_blob
.
key_size
,
0
,
CRYPT_IPSEC_HMAC_KEY
,
&
hkey
);
/* CRYPT_IPSEC_HMAC_KEY is not supported on W2K and lower */
todo_wine
ok
(
ret
||
broken
(
!
ret
&&
GetLastError
()
==
NTE_BAD_FLAGS
),
"CryptImportKey error %08x
\n
"
,
GetLastError
());
pCryptDestroyKey
(
hkey
);
pCryptReleaseContext
(
provider
,
0
);
if
(
ret
)
{
/* Importing a 16-byte key doesn't work with the base provider.. */
SetLastError
(
0xdeadbeef
);
ret
=
pCryptImportKey
(
provider
,
(
BYTE
*
)
&
key_blob
,
sizeof
(
BLOBHEADER
)
+
sizeof
(
DWORD
)
+
key_blob
.
key_size
,
0
,
0
,
&
hkey
);
ok
(
!
ret
&&
(
GetLastError
()
==
NTE_BAD_DATA
||
GetLastError
()
==
NTE_BAD_LEN
||
/* Win7 */
GetLastError
()
==
NTE_BAD_TYPE
||
/* W2K */
GetLastError
()
==
NTE_PERM
),
/* Win9x, WinMe and NT4 */
"unexpected error %08x
\n
"
,
GetLastError
());
/* but importing an 56-bit (7-byte) key does.. */
key_blob
.
key_size
=
7
;
SetLastError
(
0xdeadbeef
);
ret
=
pCryptImportKey
(
provider
,
(
BYTE
*
)
&
key_blob
,
sizeof
(
BLOBHEADER
)
+
sizeof
(
DWORD
)
+
key_blob
.
key_size
,
0
,
0
,
&
hkey
);
ok
(
ret
||
broken
(
!
ret
&&
GetLastError
()
==
NTE_BAD_TYPE
)
||
/* W2K */
broken
(
!
ret
&&
GetLastError
()
==
NTE_PERM
),
/* Win9x, WinMe and NT4 */
"CryptAcquireContext error %08x
\n
"
,
GetLastError
());
if
(
ret
)
pCryptDestroyKey
(
hkey
);
/* as does importing a 16-byte key with the base provider when
* CRYPT_IPSEC_HMAC_KEY is specified.
*/
key_blob
.
key_size
=
sizeof
(
key
);
SetLastError
(
0xdeadbeef
);
ret
=
pCryptImportKey
(
provider
,
(
BYTE
*
)
&
key_blob
,
sizeof
(
BLOBHEADER
)
+
sizeof
(
DWORD
)
+
key_blob
.
key_size
,
0
,
CRYPT_IPSEC_HMAC_KEY
,
&
hkey
);
/* CRYPT_IPSEC_HMAC_KEY is not supported on W2K and lower */
todo_wine
ok
(
ret
||
broken
(
!
ret
&&
GetLastError
()
==
NTE_BAD_FLAGS
),
"CryptImportKey error %08x
\n
"
,
GetLastError
());
if
(
ret
)
pCryptDestroyKey
(
hkey
);
pCryptReleaseContext
(
provider
,
0
);
}
key_blob
.
key_size
=
sizeof
(
key
);
SetLastError
(
0xdeadbeef
);
...
...
@@ -1027,34 +1035,39 @@ static void test_rc2_keylen(void)
PROV_RSA_FULL
,
CRYPT_VERIFYCONTEXT
);
ok
(
ret
,
"CryptAcquireContext error %08x
\n
"
,
GetLastError
());
/* Importing a 16-byte key also works with the default provider when
* CRYPT_IPSEC_HMAC_KEY is specified.
*/
SetLastError
(
0xdeadbeef
);
ret
=
pCryptImportKey
(
provider
,
(
BYTE
*
)
&
key_blob
,
sizeof
(
BLOBHEADER
)
+
sizeof
(
DWORD
)
+
key_blob
.
key_size
,
0
,
CRYPT_IPSEC_HMAC_KEY
,
&
hkey
);
todo_wine
ok
(
ret
||
broken
(
!
ret
&&
GetLastError
()
==
NTE_BAD_FLAGS
),
"CryptImportKey error %08x
\n
"
,
GetLastError
());
pCryptDestroyKey
(
hkey
);
/* There is no apparent limit to the size of the input key when
* CRYPT_IPSEC_HMAC_KEY is specified.
*/
key_blob
.
key_size
=
sizeof
(
key_blob
.
key_data
);
SetLastError
(
0xdeadbeef
);
ret
=
pCryptImportKey
(
provider
,
(
BYTE
*
)
&
key_blob
,
sizeof
(
BLOBHEADER
)
+
sizeof
(
DWORD
)
+
key_blob
.
key_size
,
0
,
CRYPT_IPSEC_HMAC_KEY
,
&
hkey
);
todo_wine
ok
(
ret
||
broken
(
!
ret
&&
GetLastError
()
==
NTE_BAD_FLAGS
),
"CryptImportKey error %08x
\n
"
,
GetLastError
());
pCryptDestroyKey
(
hkey
);
pCryptReleaseContext
(
provider
,
0
);
if
(
ret
)
{
/* Importing a 16-byte key also works with the default provider when
* CRYPT_IPSEC_HMAC_KEY is specified.
*/
SetLastError
(
0xdeadbeef
);
ret
=
pCryptImportKey
(
provider
,
(
BYTE
*
)
&
key_blob
,
sizeof
(
BLOBHEADER
)
+
sizeof
(
DWORD
)
+
key_blob
.
key_size
,
0
,
CRYPT_IPSEC_HMAC_KEY
,
&
hkey
);
todo_wine
ok
(
ret
||
broken
(
!
ret
&&
GetLastError
()
==
NTE_BAD_FLAGS
),
"CryptImportKey error %08x
\n
"
,
GetLastError
());
if
(
ret
)
pCryptDestroyKey
(
hkey
);
/* There is no apparent limit to the size of the input key when
* CRYPT_IPSEC_HMAC_KEY is specified.
*/
key_blob
.
key_size
=
sizeof
(
key_blob
.
key_data
);
SetLastError
(
0xdeadbeef
);
ret
=
pCryptImportKey
(
provider
,
(
BYTE
*
)
&
key_blob
,
sizeof
(
BLOBHEADER
)
+
sizeof
(
DWORD
)
+
key_blob
.
key_size
,
0
,
CRYPT_IPSEC_HMAC_KEY
,
&
hkey
);
todo_wine
ok
(
ret
||
broken
(
!
ret
&&
GetLastError
()
==
NTE_BAD_FLAGS
),
"CryptImportKey error %08x
\n
"
,
GetLastError
());
if
(
ret
)
pCryptDestroyKey
(
hkey
);
pCryptReleaseContext
(
provider
,
0
);
}
}
START_TEST
(
crypt
)
...
...
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