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
a63d7c06
Commit
a63d7c06
authored
Sep 07, 2022
by
Nikolay Sivov
Committed by
Alexandre Julliard
Sep 07, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32/tests: Use CRT allocation functions.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
parent
1c5bfc12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
77 additions
and
79 deletions
+77
-79
base64.c
dlls/crypt32/tests/base64.c
+29
-30
cert.c
dlls/crypt32/tests/cert.c
+0
-0
encode.c
dlls/crypt32/tests/encode.c
+20
-21
message.c
dlls/crypt32/tests/message.c
+8
-8
msg.c
dlls/crypt32/tests/msg.c
+2
-2
oid.c
dlls/crypt32/tests/oid.c
+2
-2
store.c
dlls/crypt32/tests/store.c
+16
-16
No files found.
dlls/crypt32/tests/base64.c
View file @
a63d7c06
...
...
@@ -23,7 +23,6 @@
#include <windows.h>
#include <wincrypt.h>
#include "wine/heap.h"
#include "wine/test.h"
#define CERT_HEADER "-----BEGIN CERTIFICATE-----\r\n"
...
...
@@ -93,7 +92,7 @@ static WCHAR *strdupAtoW(const char *str)
if
(
!
str
)
return
ret
;
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
str
,
-
1
,
NULL
,
0
);
ret
=
heap_
alloc
(
len
*
sizeof
(
WCHAR
));
ret
=
m
alloc
(
len
*
sizeof
(
WCHAR
));
if
(
ret
)
MultiByteToWideChar
(
CP_ACP
,
0
,
str
,
-
1
,
ret
,
len
);
return
ret
;
...
...
@@ -128,7 +127,7 @@ static void encodeAndCompareBase64_A(const BYTE *toEncode, DWORD toEncodeLen,
ok
(
ret
,
"CryptBinaryToStringA failed: %ld
\n
"
,
GetLastError
());
ok
(
strLen
==
strLen2
,
"Unexpected required length %lu, expected %lu.
\n
"
,
strLen2
,
strLen
);
str
=
heap_
alloc
(
strLen
);
str
=
m
alloc
(
strLen
);
/* Partially filled output buffer. */
strLen2
=
strLen
-
1
;
...
...
@@ -157,7 +156,7 @@ static void encodeAndCompareBase64_A(const BYTE *toEncode, DWORD toEncodeLen,
if
(
trailer
)
ok
(
!
strncmp
(
trailer
,
ptr
,
strlen
(
trailer
)),
"Expected trailer %s, got %s
\n
"
,
trailer
,
ptr
);
heap_
free
(
str
);
free
(
str
);
}
static
void
encode_compare_base64_W
(
const
BYTE
*
toEncode
,
DWORD
toEncodeLen
,
DWORD
format
,
...
...
@@ -196,7 +195,7 @@ static void encode_compare_base64_W(const BYTE *toEncode, DWORD toEncodeLen, DWO
ok
(
ret
,
"CryptBinaryToStringW failed: %ld
\n
"
,
GetLastError
());
ok
(
strLen
==
strLen2
,
"Unexpected required length.
\n
"
);
strW
=
heap_
alloc
(
strLen
*
sizeof
(
WCHAR
));
strW
=
m
alloc
(
strLen
*
sizeof
(
WCHAR
));
headerW
=
strdupAtoW
(
header
);
trailerW
=
strdupAtoW
(
trailer
);
...
...
@@ -231,9 +230,9 @@ static void encode_compare_base64_W(const BYTE *toEncode, DWORD toEncodeLen, DWO
ok
(
!
memcmp
(
trailerW
,
ptr
,
lstrlenW
(
trailerW
)),
"Expected trailer %s, got %s.
\n
"
,
wine_dbgstr_w
(
trailerW
),
wine_dbgstr_w
(
ptr
));
heap_
free
(
strW
);
heap_
free
(
headerW
);
heap_
free
(
trailerW
);
free
(
strW
);
free
(
headerW
);
free
(
trailerW
);
}
static
DWORD
binary_to_hex_len
(
DWORD
binary_len
,
DWORD
flags
)
...
...
@@ -299,12 +298,12 @@ static void test_CryptBinaryToString(void)
ok
(
strLen
==
tests
[
i
].
toEncodeLen
,
"Unexpected required length %lu.
\n
"
,
strLen
);
strLen2
=
strLen
;
str
=
heap_
alloc
(
strLen
);
str
=
m
alloc
(
strLen
);
ret
=
CryptBinaryToStringA
(
tests
[
i
].
toEncode
,
tests
[
i
].
toEncodeLen
,
CRYPT_STRING_BINARY
,
str
,
&
strLen2
);
ok
(
ret
,
"CryptBinaryToStringA failed: %ld
\n
"
,
GetLastError
());
ok
(
strLen
==
strLen2
,
"Expected length %lu, got %lu
\n
"
,
strLen
,
strLen2
);
ok
(
!
memcmp
(
str
,
tests
[
i
].
toEncode
,
tests
[
i
].
toEncodeLen
),
"Unexpected value
\n
"
);
heap_
free
(
str
);
free
(
str
);
strLen
=
0
;
ret
=
CryptBinaryToStringW
(
tests
[
i
].
toEncode
,
tests
[
i
].
toEncodeLen
,
CRYPT_STRING_BINARY
,
NULL
,
&
strLen
);
...
...
@@ -312,12 +311,12 @@ static void test_CryptBinaryToString(void)
ok
(
strLen
==
tests
[
i
].
toEncodeLen
,
"Unexpected required length %lu.
\n
"
,
strLen
);
strLen2
=
strLen
;
strW
=
heap_
alloc
(
strLen
);
strW
=
m
alloc
(
strLen
);
ret
=
CryptBinaryToStringW
(
tests
[
i
].
toEncode
,
tests
[
i
].
toEncodeLen
,
CRYPT_STRING_BINARY
,
strW
,
&
strLen2
);
ok
(
ret
,
"CryptBinaryToStringW failed: %ld
\n
"
,
GetLastError
());
ok
(
strLen
==
strLen2
,
"Expected length %lu, got %lu
\n
"
,
strLen
,
strLen2
);
ok
(
!
memcmp
(
strW
,
tests
[
i
].
toEncode
,
tests
[
i
].
toEncodeLen
),
"Unexpected value
\n
"
);
heap_
free
(
strW
);
free
(
strW
);
encodeAndCompareBase64_A
(
tests
[
i
].
toEncode
,
tests
[
i
].
toEncodeLen
,
CRYPT_STRING_BASE64
,
tests
[
i
].
base64
,
NULL
,
NULL
);
...
...
@@ -338,7 +337,7 @@ static void test_CryptBinaryToString(void)
encode_compare_base64_W
(
tests
[
i
].
toEncode
,
tests
[
i
].
toEncodeLen
,
CRYPT_STRING_BASE64X509CRLHEADER
,
encodedW
,
X509_HEADER
,
X509_TRAILER
);
heap_
free
(
encodedW
);
free
(
encodedW
);
}
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
testsNoCR
);
i
++
)
...
...
@@ -352,13 +351,13 @@ static void test_CryptBinaryToString(void)
ok
(
ret
,
"CryptBinaryToStringA failed: %ld
\n
"
,
GetLastError
());
strLen2
=
strLen
;
str
=
heap_
alloc
(
strLen
);
str
=
m
alloc
(
strLen
);
ret
=
CryptBinaryToStringA
(
testsNoCR
[
i
].
toEncode
,
testsNoCR
[
i
].
toEncodeLen
,
CRYPT_STRING_BINARY
|
CRYPT_STRING_NOCR
,
str
,
&
strLen2
);
ok
(
ret
,
"CryptBinaryToStringA failed: %ld
\n
"
,
GetLastError
());
ok
(
strLen
==
strLen2
,
"Expected length %ld, got %ld
\n
"
,
strLen
,
strLen2
);
ok
(
!
memcmp
(
str
,
testsNoCR
[
i
].
toEncode
,
testsNoCR
[
i
].
toEncodeLen
),
"Unexpected value
\n
"
);
heap_
free
(
str
);
free
(
str
);
encodeAndCompareBase64_A
(
testsNoCR
[
i
].
toEncode
,
testsNoCR
[
i
].
toEncodeLen
,
CRYPT_STRING_BASE64
|
CRYPT_STRING_NOCR
,
testsNoCR
[
i
].
base64
,
NULL
,
NULL
);
...
...
@@ -383,7 +382,7 @@ static void test_CryptBinaryToString(void)
CRYPT_STRING_BASE64X509CRLHEADER
|
CRYPT_STRING_NOCR
,
encodedW
,
X509_HEADER_NOCR
,
X509_TRAILER_NOCR
);
heap_
free
(
encodedW
);
free
(
encodedW
);
}
/* Systems that don't support HEXRAW format convert to BASE64 instead - 3 bytes in -> 4 chars + crlf + 1 null out. */
...
...
@@ -420,9 +419,9 @@ static void test_CryptBinaryToString(void)
strLen2
+=
sizeof
(
input
)
*
2
+
1
;
ok
(
strLen
==
strLen2
,
"Expected length %ld, got %ld
\n
"
,
strLen2
,
strLen
);
hex
=
heap_
alloc
(
strLen
*
sizeof
(
WCHAR
));
hex
=
m
alloc
(
strLen
*
sizeof
(
WCHAR
));
memset
(
hex
,
0xcc
,
strLen
*
sizeof
(
WCHAR
));
ptr
=
cmp
=
heap_
alloc
(
strLen
*
sizeof
(
WCHAR
));
ptr
=
cmp
=
m
alloc
(
strLen
*
sizeof
(
WCHAR
));
for
(
j
=
0
;
j
<
ARRAY_SIZE
(
input
);
j
++
)
{
*
ptr
++
=
hexdig
[(
input
[
j
]
>>
4
)
&
0xf
];
...
...
@@ -465,8 +464,8 @@ static void test_CryptBinaryToString(void)
ok
(
strLen
==
strLen2
,
"Expected length %ld, got %ld
\n
"
,
strLen
,
strLen2
);
ok
(
!
memcmp
(
hex
,
cmp
,
strLen
*
sizeof
(
WCHAR
)),
"Unexpected value
\n
"
);
heap_
free
(
hex
);
heap_
free
(
cmp
);
free
(
hex
);
free
(
cmp
);
}
for
(
k
=
0
;
k
<
ARRAY_SIZE
(
sizes
);
k
++
)
...
...
@@ -483,10 +482,10 @@ static void test_CryptBinaryToString(void)
strLen2
=
binary_to_hex_len
(
sizes
[
k
],
CRYPT_STRING_HEX
|
flags
[
i
]);
ok
(
strLen
==
strLen2
,
"%lu: Expected length %ld, got %ld
\n
"
,
i
,
strLen2
,
strLen
);
hex
=
heap_
alloc
(
strLen
*
sizeof
(
WCHAR
)
+
256
);
hex
=
m
alloc
(
strLen
*
sizeof
(
WCHAR
)
+
256
);
memset
(
hex
,
0xcc
,
strLen
*
sizeof
(
WCHAR
));
ptr
=
cmp
=
heap_
alloc
(
strLen
*
sizeof
(
WCHAR
)
+
256
);
ptr
=
cmp
=
m
alloc
(
strLen
*
sizeof
(
WCHAR
)
+
256
);
for
(
j
=
0
;
j
<
sizes
[
k
];
j
++
)
{
*
ptr
++
=
hexdig
[(
input
[
j
]
>>
4
)
&
0xf
];
...
...
@@ -552,8 +551,8 @@ static void test_CryptBinaryToString(void)
ok
(
strLen
==
strLen2
,
"%lu: Expected length %ld, got %ld
\n
"
,
i
,
strLen
,
strLen2
);
ok
(
!
memcmp
(
hex
,
cmp
,
strLen
*
sizeof
(
WCHAR
)),
"%lu: got %s
\n
"
,
i
,
wine_dbgstr_wn
(
hex
,
strLen
));
heap_
free
(
hex
);
heap_
free
(
cmp
);
free
(
hex
);
free
(
cmp
);
}
}
...
...
@@ -569,7 +568,7 @@ static void decodeAndCompareBase64_A(LPCSTR toDecode, LPCSTR header,
len
+=
strlen
(
header
);
if
(
trailer
)
len
+=
strlen
(
trailer
);
str
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
);
str
=
malloc
(
len
);
if
(
str
)
{
LPBYTE
buf
;
...
...
@@ -586,7 +585,7 @@ static void decodeAndCompareBase64_A(LPCSTR toDecode, LPCSTR header,
ret
=
CryptStringToBinaryA
(
str
,
0
,
useFormat
,
NULL
,
&
bufLen
,
NULL
,
NULL
);
ok
(
ret
,
"CryptStringToBinaryA failed: %ld
\n
"
,
GetLastError
());
buf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
bufLen
);
buf
=
malloc
(
bufLen
);
if
(
buf
)
{
DWORD
skipped
,
usedFormat
;
...
...
@@ -605,7 +604,7 @@ static void decodeAndCompareBase64_A(LPCSTR toDecode, LPCSTR header,
ok
(
skipped
==
0
,
"Expected skipped 0, got %ld
\n
"
,
skipped
);
ok
(
usedFormat
==
expectedFormat
,
"Expected format %ld, got %ld
\n
"
,
expectedFormat
,
usedFormat
);
HeapFree
(
GetProcessHeap
(),
0
,
buf
);
free
(
buf
);
}
/* Check again, but with garbage up front */
...
...
@@ -625,7 +624,7 @@ static void decodeAndCompareBase64_A(LPCSTR toDecode, LPCSTR header,
"Expected !ret and last error ERROR_INVALID_DATA, got ret=%d, error=%ld
\n
"
,
ret
,
GetLastError
());
if
(
ret
)
{
buf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
bufLen
);
buf
=
malloc
(
bufLen
);
if
(
buf
)
{
DWORD
skipped
,
usedFormat
;
...
...
@@ -636,10 +635,10 @@ static void decodeAndCompareBase64_A(LPCSTR toDecode, LPCSTR header,
ok
(
skipped
==
strlen
(
garbage
),
"Expected %d characters of
\"
%s
\"
skipped when trying format %08lx, got %ld (used format is %08lx)
\n
"
,
lstrlenA
(
garbage
),
str
,
useFormat
,
skipped
,
usedFormat
);
HeapFree
(
GetProcessHeap
(),
0
,
buf
);
free
(
buf
);
}
}
HeapFree
(
GetProcessHeap
(),
0
,
str
);
free
(
str
);
}
}
...
...
dlls/crypt32/tests/cert.c
View file @
a63d7c06
This diff is collapsed.
Click to expand it.
dlls/crypt32/tests/encode.c
View file @
a63d7c06
...
...
@@ -2592,7 +2592,7 @@ static void test_decodeRsaPublicKey_Bcrypt(DWORD dwEncoding)
ok
(
!
memcmp
(
pubexp
,
pubexp_expected
,
sizeof
(
pubexp_expected
)),
"Wrong exponent
\n
"
);
todo_wine
ok
(
pubexp
[
3
]
==
0xff
,
"Got %02x
\n
"
,
pubexp
[
3
]);
leModulus
=
HeapAlloc
(
GetProcessHeap
(),
0
,
hdr
->
cbModulus
);
leModulus
=
malloc
(
hdr
->
cbModulus
);
/*
* CNG_RSA_PUBLIC_KEY_BLOB stores the modulus in big-endian format,
* so we need to convert it to little-endian
...
...
@@ -2603,7 +2603,7 @@ static void test_decodeRsaPublicKey_Bcrypt(DWORD dwEncoding)
rsaPubKeys
[
i
].
modulus
,
rsaPubKeys
[
i
].
decodedModulusLen
),
"Unexpected modulus
\n
"
);
LocalFree
(
buf
);
HeapFree
(
GetProcessHeap
(),
0
,
leModulus
);
free
(
leModulus
);
}
}
}
...
...
@@ -2799,13 +2799,13 @@ static void test_decodeExtensions(DWORD dwEncoding)
ret
=
CryptDecodeObjectEx
(
dwEncoding
,
X509_EXTENSIONS
,
exts
[
i
].
encoded
,
exts
[
i
].
encoded
[
1
]
+
2
,
0
,
NULL
,
NULL
,
&
bufSize
);
ok
(
ret
,
"CryptDecodeObjectEx failed: %08lx
\n
"
,
GetLastError
());
buf
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
bufSize
);
buf
=
calloc
(
1
,
bufSize
);
if
(
buf
)
{
ret
=
CryptDecodeObjectEx
(
dwEncoding
,
X509_EXTENSIONS
,
exts
[
i
].
encoded
,
exts
[
i
].
encoded
[
1
]
+
2
,
0
,
NULL
,
buf
,
&
bufSize
);
ok
(
ret
,
"CryptDecodeObjectEx failed: %08lx
\n
"
,
GetLastError
());
HeapFree
(
GetProcessHeap
(),
0
,
buf
);
free
(
buf
);
}
}
}
...
...
@@ -3770,14 +3770,14 @@ static void test_decodeCRLDistPoints(DWORD dwEncoding)
distPointWithUrlAndIssuer
,
distPointWithUrlAndIssuer
[
1
]
+
2
,
0
,
NULL
,
NULL
,
&
size
);
ok
(
ret
,
"CryptDecodeObjectEx failed: %08lx
\n
"
,
GetLastError
());
buf
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
size
);
buf
=
calloc
(
1
,
size
);
if
(
buf
)
{
ret
=
CryptDecodeObjectEx
(
dwEncoding
,
X509_CRL_DIST_POINTS
,
distPointWithUrlAndIssuer
,
distPointWithUrlAndIssuer
[
1
]
+
2
,
0
,
NULL
,
buf
,
&
size
);
ok
(
ret
,
"CryptDecodeObjectEx failed: %08lx
\n
"
,
GetLastError
());
HeapFree
(
GetProcessHeap
(),
0
,
buf
);
free
(
buf
);
}
}
...
...
@@ -4906,13 +4906,13 @@ static void test_decodeEnhancedKeyUsage(DWORD dwEncoding)
ret
=
CryptDecodeObjectEx
(
dwEncoding
,
X509_ENHANCED_KEY_USAGE
,
encodedUsage
,
sizeof
(
encodedUsage
),
0
,
NULL
,
NULL
,
&
size
);
ok
(
ret
,
"CryptDecodeObjectEx failed: %08lx
\n
"
,
GetLastError
());
buf
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
size
);
buf
=
calloc
(
1
,
size
);
if
(
buf
)
{
ret
=
CryptDecodeObjectEx
(
dwEncoding
,
X509_ENHANCED_KEY_USAGE
,
encodedUsage
,
sizeof
(
encodedUsage
),
0
,
NULL
,
buf
,
&
size
);
ok
(
ret
,
"CryptDecodeObjectEx failed: %08lx
\n
"
,
GetLastError
());
HeapFree
(
GetProcessHeap
(),
0
,
buf
);
free
(
buf
);
}
}
...
...
@@ -5391,14 +5391,14 @@ static void test_decodeAuthorityInfoAccess(DWORD dwEncoding)
authorityInfoAccessWithUrlAndIPAddr
,
sizeof
(
authorityInfoAccessWithUrlAndIPAddr
),
0
,
NULL
,
NULL
,
&
size
);
ok
(
ret
,
"CryptDecodeObjectEx failed: %lx
\n
"
,
GetLastError
());
buf
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
size
);
buf
=
calloc
(
1
,
size
);
if
(
buf
)
{
ret
=
CryptDecodeObjectEx
(
dwEncoding
,
X509_AUTHORITY_INFO_ACCESS
,
authorityInfoAccessWithUrlAndIPAddr
,
sizeof
(
authorityInfoAccessWithUrlAndIPAddr
),
0
,
NULL
,
buf
,
&
size
);
ok
(
ret
,
"CryptDecodeObjectEx failed: %lx
\n
"
,
GetLastError
());
HeapFree
(
GetProcessHeap
(),
0
,
buf
);
free
(
buf
);
}
}
...
...
@@ -6354,13 +6354,13 @@ static void test_decodePKCSAttributes(DWORD dwEncoding)
ret
=
CryptDecodeObjectEx
(
dwEncoding
,
PKCS_ATTRIBUTES
,
doublePKCSAttributes
,
sizeof
(
doublePKCSAttributes
),
0
,
NULL
,
NULL
,
&
size
);
ok
(
ret
,
"CryptDecodeObjectEx failed: %lx
\n
"
,
GetLastError
());
buf
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
size
);
buf
=
calloc
(
1
,
size
);
if
(
buf
)
{
ret
=
CryptDecodeObjectEx
(
dwEncoding
,
PKCS_ATTRIBUTES
,
doublePKCSAttributes
,
sizeof
(
doublePKCSAttributes
),
0
,
NULL
,
buf
,
&
size
);
ok
(
ret
,
"CryptDecodeObjectEx failed: %lx
\n
"
,
GetLastError
());
HeapFree
(
GetProcessHeap
(),
0
,
buf
);
free
(
buf
);
}
}
...
...
@@ -6522,14 +6522,14 @@ static void test_decodePKCSSMimeCapabilities(DWORD dwEncoding)
ret
=
CryptDecodeObjectEx
(
dwEncoding
,
PKCS_SMIME_CAPABILITIES
,
twoCapabilities
,
sizeof
(
twoCapabilities
),
0
,
NULL
,
NULL
,
&
size
);
ok
(
ret
,
"CryptDecodeObjectEx failed: %08lx
\n
"
,
GetLastError
());
ptr
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
size
);
ptr
=
calloc
(
1
,
size
);
if
(
ptr
)
{
SetLastError
(
0xdeadbeef
);
ret
=
CryptDecodeObjectEx
(
dwEncoding
,
PKCS_SMIME_CAPABILITIES
,
twoCapabilities
,
sizeof
(
twoCapabilities
),
0
,
NULL
,
ptr
,
&
size
);
ok
(
ret
,
"CryptDecodeObjectEx failed: %08lx
\n
"
,
GetLastError
());
HeapFree
(
GetProcessHeap
(),
0
,
ptr
);
free
(
ptr
);
}
}
...
...
@@ -7645,13 +7645,13 @@ static void test_decodeCertPolicies(DWORD dwEncoding)
ret
=
CryptDecodeObjectEx
(
dwEncoding
,
X509_CERT_POLICIES
,
twoPolicies
,
sizeof
(
twoPolicies
),
0
,
NULL
,
NULL
,
&
size
);
ok
(
ret
,
"CryptDecodeObjectEx failed: %08lx
\n
"
,
GetLastError
());
info
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
size
);
info
=
calloc
(
1
,
size
);
if
(
info
)
{
ret
=
CryptDecodeObjectEx
(
dwEncoding
,
X509_CERT_POLICIES
,
twoPolicies
,
sizeof
(
twoPolicies
),
0
,
NULL
,
info
,
&
size
);
ok
(
ret
,
"CryptDecodeObjectEx failed: %08lx
\n
"
,
GetLastError
());
HeapFree
(
GetProcessHeap
(),
0
,
info
);
free
(
info
);
}
}
...
...
@@ -7788,14 +7788,14 @@ static void test_decodeCertPolicyMappings(DWORD dwEncoding)
policyMappingWithTwoMappings
,
sizeof
(
policyMappingWithTwoMappings
),
0
,
NULL
,
NULL
,
&
size
);
ok
(
ret
,
"CryptDecodeObjectEx failed: %08lx
\n
"
,
GetLastError
());
info
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
size
);
info
=
calloc
(
1
,
size
);
if
(
info
)
{
ret
=
CryptDecodeObjectEx
(
dwEncoding
,
mappingOids
[
i
],
policyMappingWithTwoMappings
,
sizeof
(
policyMappingWithTwoMappings
),
0
,
NULL
,
info
,
&
size
);
ok
(
ret
,
"CryptDecodeObjectEx failed: %08lx
\n
"
,
GetLastError
());
HeapFree
(
GetProcessHeap
(),
0
,
info
);
free
(
info
);
}
}
}
...
...
@@ -8225,7 +8225,6 @@ static void test_decodeRsaPrivateKey(DWORD dwEncoding)
}
}
/* Free *pInfo with HeapFree */
static
void
testExportPublicKey
(
HCRYPTPROV
csp
,
PCERT_PUBLIC_KEY_INFO
*
pInfo
)
{
BOOL
ret
;
...
...
@@ -8262,7 +8261,7 @@ static void testExportPublicKey(HCRYPTPROV csp, PCERT_PUBLIC_KEY_INFO *pInfo)
ret
=
CryptExportPublicKeyInfoEx
(
csp
,
AT_SIGNATURE
,
X509_ASN_ENCODING
,
NULL
,
0
,
NULL
,
NULL
,
&
size
);
ok
(
ret
,
"CryptExportPublicKeyInfoEx failed: %08lx
\n
"
,
GetLastError
());
*
pInfo
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
*
pInfo
=
malloc
(
size
);
if
(
*
pInfo
)
{
ret
=
CryptExportPublicKeyInfoEx
(
csp
,
AT_SIGNATURE
,
...
...
@@ -8411,7 +8410,7 @@ static void testPortPublicKeyInfo(void)
testExportPublicKey
(
csp
,
&
info
);
testImportPublicKey
(
csp
,
info
);
HeapFree
(
GetProcessHeap
(),
0
,
info
);
free
(
info
);
CryptReleaseContext
(
csp
,
0
);
ret
=
CryptAcquireContextA
(
&
csp
,
cspName
,
MS_DEF_PROV_A
,
PROV_RSA_FULL
,
CRYPT_DELETEKEYSET
);
...
...
dlls/crypt32/tests/message.c
View file @
a63d7c06
...
...
@@ -688,14 +688,14 @@ static void test_hash_message(void)
/* Actually attempting to get the hashed data fails, perhaps because
* detached is FALSE.
*/
hashedBlob
=
HeapAlloc
(
GetProcessHeap
(),
0
,
hashedBlobSize
);
hashedBlob
=
malloc
(
hashedBlobSize
);
SetLastError
(
0xdeadbeef
);
ret
=
CryptHashMessage
(
&
para
,
FALSE
,
2
,
toHash
,
hashSize
,
hashedBlob
,
&
hashedBlobSize
,
NULL
,
NULL
);
ok
(
!
ret
&&
GetLastError
()
==
CRYPT_E_MSG_ERROR
,
"expected CRYPT_E_MSG_ERROR, got 0x%08lx (%ld)
\n
"
,
GetLastError
(),
GetLastError
());
HeapFree
(
GetProcessHeap
(),
0
,
hashedBlob
);
free
(
hashedBlob
);
}
/* Repeating tests with fDetached = TRUE results in success */
SetLastError
(
0xdeadbeef
);
...
...
@@ -704,7 +704,7 @@ static void test_hash_message(void)
ok
(
ret
,
"CryptHashMessage failed: 0x%08lx
\n
"
,
GetLastError
());
if
(
ret
)
{
hashedBlob
=
HeapAlloc
(
GetProcessHeap
(),
0
,
hashedBlobSize
);
hashedBlob
=
malloc
(
hashedBlobSize
);
SetLastError
(
0xdeadbeef
);
ret
=
CryptHashMessage
(
&
para
,
TRUE
,
2
,
toHash
,
hashSize
,
hashedBlob
,
&
hashedBlobSize
,
NULL
,
NULL
);
...
...
@@ -713,7 +713,7 @@ static void test_hash_message(void)
"unexpected size of detached blob %ld
\n
"
,
hashedBlobSize
);
ok
(
!
memcmp
(
hashedBlob
,
detachedHashBlob
,
hashedBlobSize
),
"unexpected detached blob value
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
hashedBlob
);
free
(
hashedBlob
);
}
/* Hashing a single item with fDetached = FALSE also succeeds */
SetLastError
(
0xdeadbeef
);
...
...
@@ -722,7 +722,7 @@ static void test_hash_message(void)
ok
(
ret
,
"CryptHashMessage failed: 0x%08lx
\n
"
,
GetLastError
());
if
(
ret
)
{
hashedBlob
=
HeapAlloc
(
GetProcessHeap
(),
0
,
hashedBlobSize
);
hashedBlob
=
malloc
(
hashedBlobSize
);
ret
=
CryptHashMessage
(
&
para
,
FALSE
,
1
,
toHash
,
hashSize
,
hashedBlob
,
&
hashedBlobSize
,
NULL
,
NULL
);
ok
(
ret
,
"CryptHashMessage failed: 0x%08lx
\n
"
,
GetLastError
());
...
...
@@ -730,7 +730,7 @@ static void test_hash_message(void)
"unexpected size of detached blob %ld
\n
"
,
hashedBlobSize
);
ok
(
!
memcmp
(
hashedBlob
,
hashBlob
,
hashedBlobSize
),
"unexpected detached blob value
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
hashedBlob
);
free
(
hashedBlob
);
}
/* Check the computed hash value too. You don't need to get the encoded
* blob to get it.
...
...
@@ -743,7 +743,7 @@ static void test_hash_message(void)
computedHashSize
);
if
(
ret
)
{
computedHash
=
HeapAlloc
(
GetProcessHeap
(),
0
,
computedHashSize
);
computedHash
=
malloc
(
computedHashSize
);
SetLastError
(
0xdeadbeef
);
ret
=
CryptHashMessage
(
&
para
,
TRUE
,
2
,
toHash
,
hashSize
,
NULL
,
&
hashedBlobSize
,
computedHash
,
&
computedHashSize
);
...
...
@@ -752,7 +752,7 @@ static void test_hash_message(void)
"unexpected size of hash value %ld
\n
"
,
computedHashSize
);
ok
(
!
memcmp
(
computedHash
,
hashVal
,
computedHashSize
),
"unexpected value
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
computedHash
);
free
(
computedHash
);
}
}
...
...
dlls/crypt32/tests/msg.c
View file @
a63d7c06
...
...
@@ -274,14 +274,14 @@ static void check_param(LPCSTR test, HCRYPTMSG msg, DWORD param,
ret
=
CryptMsgGetParam
(
msg
,
param
,
0
,
NULL
,
&
size
);
ok
(
ret
,
"%s: CryptMsgGetParam failed: %08lx
\n
"
,
test
,
GetLastError
());
buf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
buf
=
malloc
(
size
);
ret
=
CryptMsgGetParam
(
msg
,
param
,
0
,
buf
,
&
size
);
ok
(
ret
,
"%s: CryptMsgGetParam failed: %08lx
\n
"
,
test
,
GetLastError
());
ok
(
size
==
expectedSize
,
"%s: expected size %ld, got %ld
\n
"
,
test
,
expectedSize
,
size
);
if
(
size
==
expectedSize
&&
size
)
ok
(
!
memcmp
(
buf
,
expected
,
size
),
"%s: unexpected data
\n
"
,
test
);
HeapFree
(
GetProcessHeap
(),
0
,
buf
);
free
(
buf
);
}
static
void
test_data_msg_open
(
void
)
...
...
dlls/crypt32/tests/oid.c
View file @
a63d7c06
...
...
@@ -152,14 +152,14 @@ static void test_oidFunctionSet(void)
ok
(
ret
,
"CryptGetDefaultOIDDllList failed: %08lx
\n
"
,
GetLastError
());
if
(
ret
)
{
buf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
*
sizeof
(
WCHAR
));
buf
=
malloc
(
size
*
sizeof
(
WCHAR
));
if
(
buf
)
{
ret
=
CryptGetDefaultOIDDllList
(
set1
,
0
,
buf
,
&
size
);
ok
(
ret
,
"CryptGetDefaultOIDDllList failed: %08lx
\n
"
,
GetLastError
());
ok
(
!*
buf
,
"Expected empty DLL list
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
buf
);
free
(
buf
);
}
}
}
...
...
dlls/crypt32/tests/store.c
View file @
a63d7c06
...
...
@@ -216,7 +216,7 @@ static void testMemStore(void)
ret
=
CertSerializeCertificateStoreElement
(
context
,
1
,
NULL
,
&
size
);
ok
(
ret
,
"CertSerializeCertificateStoreElement failed: %08lx
\n
"
,
GetLastError
());
buf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
buf
=
malloc
(
size
);
if
(
buf
)
{
ret
=
CertSerializeCertificateStoreElement
(
context
,
0
,
buf
,
&
size
);
...
...
@@ -224,7 +224,7 @@ static void testMemStore(void)
ok
(
size
==
sizeof
(
serializedCert
),
"Wrong size %ld
\n
"
,
size
);
ok
(
!
memcmp
(
serializedCert
,
buf
,
size
),
"Unexpected serialized cert
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
buf
);
free
(
buf
);
}
ret
=
CertFreeCertificateContext
(
context
);
...
...
@@ -311,7 +311,7 @@ static void compareStore(HCERTSTORE store, LPCSTR name, const BYTE *pb,
todo_wine_if
(
todo
)
ok
(
blob
.
cbData
==
cb
,
"%s: expected size %ld, got %ld
\n
"
,
name
,
cb
,
blob
.
cbData
);
blob
.
pbData
=
HeapAlloc
(
GetProcessHeap
(),
0
,
blob
.
cbData
);
blob
.
pbData
=
malloc
(
blob
.
cbData
);
if
(
blob
.
pbData
)
{
ret
=
CertSaveStore
(
store
,
X509_ASN_ENCODING
,
CERT_STORE_SAVE_AS_STORE
,
...
...
@@ -319,7 +319,7 @@ static void compareStore(HCERTSTORE store, LPCSTR name, const BYTE *pb,
ok
(
ret
,
"CertSaveStore failed: %08lx
\n
"
,
GetLastError
());
todo_wine_if
(
todo
)
ok
(
!
memcmp
(
pb
,
blob
.
pbData
,
cb
),
"%s: unexpected value
\n
"
,
name
);
HeapFree
(
GetProcessHeap
(),
0
,
blob
.
pbData
);
free
(
blob
.
pbData
);
}
}
...
...
@@ -1063,7 +1063,7 @@ static void testRegStore(void)
size
=
0
;
RegQueryValueExA
(
subKey
,
"Blob"
,
NULL
,
NULL
,
NULL
,
&
size
);
buf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
buf
=
malloc
(
size
);
if
(
buf
)
{
rc
=
RegQueryValueExA
(
subKey
,
"Blob"
,
NULL
,
NULL
,
buf
,
&
size
);
...
...
@@ -1092,7 +1092,7 @@ static void testRegStore(void)
hdr
->
cb
),
"Unexpected hash in cert property
\n
"
);
}
}
HeapFree
(
GetProcessHeap
(),
0
,
buf
);
free
(
buf
);
}
RegCloseKey
(
subKey
);
}
...
...
@@ -2465,7 +2465,7 @@ static void testAddCertificateLink(void)
ret
=
CertSerializeCertificateStoreElement
(
linked
,
0
,
NULL
,
&
size
);
ok
(
ret
,
"CertSerializeCertificateStoreElement failed: %08lx
\n
"
,
GetLastError
());
buf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
buf
=
malloc
(
size
);
if
(
buf
)
{
ret
=
CertSerializeCertificateStoreElement
(
linked
,
0
,
buf
,
&
size
);
...
...
@@ -2477,7 +2477,7 @@ static void testAddCertificateLink(void)
ok
(
size
==
sizeof
(
serializedCert
),
"Wrong size %ld
\n
"
,
size
);
ok
(
!
memcmp
(
serializedCert
,
buf
,
size
),
"Unexpected serialized cert
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
buf
);
free
(
buf
);
}
/* Set a friendly name on the source certificate... */
blob
.
pbData
=
(
LPBYTE
)
L"WineTest"
;
...
...
@@ -2491,7 +2491,7 @@ static void testAddCertificateLink(void)
CERT_FRIENDLY_NAME_PROP_ID
,
NULL
,
&
size
);
ok
(
ret
,
"CertGetCertificateContextProperty failed: %08lx
\n
"
,
GetLastError
());
buf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
buf
=
malloc
(
size
);
if
(
buf
)
{
ret
=
CertGetCertificateContextProperty
(
linked
,
...
...
@@ -2500,7 +2500,7 @@ static void testAddCertificateLink(void)
GetLastError
());
ok
(
!
lstrcmpW
((
LPCWSTR
)
buf
,
L"WineTest"
),
"unexpected friendly name
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
buf
);
free
(
buf
);
}
CertFreeCertificateContext
(
linked
);
}
...
...
@@ -2541,7 +2541,7 @@ static void testAddCertificateLink(void)
ret
=
CertSerializeCertificateStoreElement
(
linked
,
0
,
NULL
,
&
size
);
ok
(
ret
,
"CertSerializeCertificateStoreElement failed: %08lx
\n
"
,
GetLastError
());
buf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
buf
=
malloc
(
size
);
if
(
buf
)
{
ret
=
CertSerializeCertificateStoreElement
(
linked
,
0
,
buf
,
&
size
);
...
...
@@ -2552,7 +2552,7 @@ static void testAddCertificateLink(void)
ok
(
size
==
sizeof
(
serializedCert
),
"Wrong size %ld
\n
"
,
size
);
ok
(
!
memcmp
(
serializedCert
,
buf
,
size
),
"Unexpected serialized cert
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
buf
);
free
(
buf
);
}
/* Set a friendly name on the source certificate... */
blob
.
pbData
=
(
LPBYTE
)
L"WineTest"
;
...
...
@@ -2566,7 +2566,7 @@ static void testAddCertificateLink(void)
CERT_FRIENDLY_NAME_PROP_ID
,
NULL
,
&
size
);
ok
(
ret
,
"CertGetCertificateContextProperty failed: %08lx
\n
"
,
GetLastError
());
buf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
buf
=
malloc
(
size
);
if
(
buf
)
{
ret
=
CertGetCertificateContextProperty
(
linked
,
...
...
@@ -2574,7 +2574,7 @@ static void testAddCertificateLink(void)
ok
(
ret
,
"CertGetCertificateContextProperty failed: %08lx
\n
"
,
GetLastError
());
ok
(
!
lstrcmpW
((
LPCWSTR
)
buf
,
L"WineTest"
),
"unexpected friendly name
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
buf
);
free
(
buf
);
}
CertFreeCertificateContext
(
linked
);
}
...
...
@@ -2603,7 +2603,7 @@ static void testAddCertificateLink(void)
ret
=
CertSerializeCertificateStoreElement
(
linked
,
0
,
NULL
,
&
size
);
ok
(
ret
,
"CertSerializeCertificateStoreElement failed: %08lx
\n
"
,
GetLastError
());
buf
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
buf
=
malloc
(
size
);
if
(
buf
)
{
ret
=
CertSerializeCertificateStoreElement
(
linked
,
0
,
buf
,
&
size
);
...
...
@@ -2616,7 +2616,7 @@ static void testAddCertificateLink(void)
"Wrong size %ld
\n
"
,
size
);
ok
(
!
memcmp
(
serializedCertWithFriendlyName
,
buf
,
size
),
"Unexpected serialized cert
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
buf
);
free
(
buf
);
}
CertFreeCertificateContext
(
linked
);
compareStore
(
store2
,
"file store -> file store"
,
...
...
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