ReactOS 0.4.16-dev-1946-g52006dd
main.c File Reference
#include <stdio.h>
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winerror.h>
#include <wincrypt.h>
#include <winreg.h>
#include "wine/test.h"
Include dependency graph for main.c:

Go to the source code of this file.

Macros

#define ALG(id)   id, #id
 

Functions

static void test_findAttribute (void)
 
static void test_findExtension (void)
 
static void test_findRDNAttr (void)
 
static void test_verifyTimeValidity (void)
 
static void test_cryptAllocate (void)
 
static void test_cryptTls (void)
 
static void test_readTrustedPublisherDWORD (void)
 
static void test_getDefaultCryptProv (void)
 
static void test_CryptInstallOssGlobal (void)
 
static void test_format_object (void)
 
 START_TEST (main)
 

Variables

static HMODULE hCrypt
 

Macro Definition Documentation

◆ ALG

#define ALG (   id)    id, #id

Function Documentation

◆ START_TEST()

START_TEST ( main  )

Definition at line 476 of file main.c.

477{
478 hCrypt = GetModuleHandleA("crypt32.dll");
479
490}
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
static void test_format_object(void)
Definition: main.c:388
static void test_findRDNAttr(void)
Definition: main.c:123
static void test_verifyTimeValidity(void)
Definition: main.c:166
static void test_CryptInstallOssGlobal(void)
Definition: main.c:372
static void test_findAttribute(void)
Definition: main.c:33
static HMODULE hCrypt
Definition: main.c:31
static void test_readTrustedPublisherDWORD(void)
Definition: main.c:267
static void test_getDefaultCryptProv(void)
Definition: main.c:298
static void test_cryptAllocate(void)
Definition: main.c:193
static void test_cryptTls(void)
Definition: main.c:208
static void test_findExtension(void)
Definition: main.c:78

◆ test_cryptAllocate()

static void test_cryptAllocate ( void  )
static

Definition at line 193 of file main.c.

194{
195 LPVOID buf;
196
197 buf = CryptMemAlloc(0);
198 ok(buf != NULL, "CryptMemAlloc failed: %08lx\n", GetLastError());
200 /* CryptMemRealloc(NULL, 0) fails pre-Vista */
201 buf = CryptMemAlloc(0);
202 buf = CryptMemRealloc(buf, 1);
203 ok(buf != NULL, "CryptMemRealloc failed: %08lx\n", GetLastError());
205}
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
Definition: main.c:131
LPVOID WINAPI CryptMemRealloc(LPVOID pv, ULONG cbSize)
Definition: main.c:136
VOID WINAPI CryptMemFree(LPVOID pv)
Definition: main.c:141
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by START_TEST().

◆ test_CryptInstallOssGlobal()

static void test_CryptInstallOssGlobal ( void  )
static

Definition at line 372 of file main.c.

373{
374 int (WINAPI *pI_CryptInstallOssGlobal)(DWORD,DWORD,DWORD);
375 int ret,i;
376
377 pI_CryptInstallOssGlobal = (void *)GetProcAddress(hCrypt,"I_CryptInstallOssGlobal");
378 /* passing in some random values to I_CryptInstallOssGlobal, it always returns 9 the first time, then 10, 11 etc.*/
379 for(i=0;i<30;i++)
380 {
381 ret = pI_CryptInstallOssGlobal(rand(),rand(),rand());
382 ok((9+i) == ret ||
383 ret == 0, /* Vista */
384 "Expected %d or 0, got %d\n",(9+i),ret);
385 }
386}
#define GetProcAddress(x, y)
Definition: compat.h:753
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
return ret
Definition: mutex.c:146
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define DWORD
Definition: nt_native.h:44
_Check_return_ int __cdecl rand(void)
Definition: rand.c:10
#define WINAPI
Definition: msvc.h:6

Referenced by START_TEST().

◆ test_cryptTls()

static void test_cryptTls ( void  )
static

Definition at line 208 of file main.c.

209{
210 DWORD (WINAPI *pI_CryptAllocTls)(void);
211 LPVOID (WINAPI *pI_CryptDetachTls)(DWORD dwTlsIndex);
212 LPVOID (WINAPI *pI_CryptGetTls)(DWORD dwTlsIndex);
213 BOOL (WINAPI *pI_CryptSetTls)(DWORD dwTlsIndex, LPVOID lpTlsValue);
214 BOOL (WINAPI *pI_CryptFreeTls)(DWORD dwTlsIndex, DWORD unknown);
215 DWORD index;
216 BOOL ret;
217
218 pI_CryptAllocTls = (void *)GetProcAddress(hCrypt, "I_CryptAllocTls");
219 pI_CryptDetachTls = (void *)GetProcAddress(hCrypt, "I_CryptDetachTls");
220 pI_CryptGetTls = (void *)GetProcAddress(hCrypt, "I_CryptGetTls");
221 pI_CryptSetTls = (void *)GetProcAddress(hCrypt, "I_CryptSetTls");
222 pI_CryptFreeTls = (void *)GetProcAddress(hCrypt, "I_CryptFreeTls");
223
224 /* One normal pass */
225 index = pI_CryptAllocTls();
226 ok(index, "I_CryptAllocTls failed: %08lx\n", GetLastError());
227 if (index)
228 {
229 LPVOID ptr;
230
231 ptr = pI_CryptGetTls(index);
232 ok(!ptr, "Expected NULL\n");
233 ret = pI_CryptSetTls(index, (LPVOID)0xdeadbeef);
234 ok(ret, "I_CryptSetTls failed: %08lx\n", GetLastError());
235 ptr = pI_CryptGetTls(index);
236 ok(ptr == (LPVOID)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", ptr);
237 /* This crashes
238 ret = pI_CryptFreeTls(index, 1);
239 */
240 ret = pI_CryptFreeTls(index, 0);
241 ok(ret, "I_CryptFreeTls failed: %08lx\n", GetLastError());
242 ret = pI_CryptFreeTls(index, 0);
243 ok(!ret, "I_CryptFreeTls succeeded\n");
245 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
246 }
247 /* Similar pass, check I_CryptDetachTls */
248 index = pI_CryptAllocTls();
249 ok(index, "I_CryptAllocTls failed: %08lx\n", GetLastError());
250 if (index)
251 {
252 LPVOID ptr;
253
254 ptr = pI_CryptGetTls(index);
255 ok(!ptr, "Expected NULL\n");
256 ret = pI_CryptSetTls(index, (LPVOID)0xdeadbeef);
257 ok(ret, "I_CryptSetTls failed: %08lx\n", GetLastError());
258 ptr = pI_CryptGetTls(index);
259 ok(ptr == (LPVOID)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", ptr);
260 ptr = pI_CryptDetachTls(index);
261 ok(ptr == (LPVOID)0xdeadbeef, "Expected 0xdeadbeef, got %p\n", ptr);
262 ptr = pI_CryptGetTls(index);
263 ok(!ptr, "Expected NULL\n");
264 }
265}
#define index(s, c)
Definition: various.h:29
#define E_INVALIDARG
Definition: ddrawi.h:101
static WCHAR unknown[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1605
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint index
Definition: glext.h:6031
static PVOID ptr
Definition: dispmode.c:27
#define LPVOID
Definition: nt_native.h:45
#define BOOL
Definition: nt_native.h:43
static DWORD dwTlsIndex
Definition: wintirpc.c:34

Referenced by START_TEST().

◆ test_findAttribute()

static void test_findAttribute ( void  )
static

Definition at line 33 of file main.c.

34{
36 BYTE blobbin[] = {0x02,0x01,0x01};
37 static CHAR oid[] = "1.2.3";
38 CRYPT_ATTR_BLOB blobs[] = { { sizeof blobbin, blobbin }, };
39 CRYPT_ATTRIBUTE attr = { oid, ARRAY_SIZE(blobs), blobs };
40
41 /* returns NULL, last error not set */
42 SetLastError(0xdeadbeef);
44 ok(ret == NULL, "Expected failure\n");
45 ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
46 GetLastError());
47 if (0)
48 {
49 /* crashes */
51 /* returns NULL, last error is ERROR_INVALID_PARAMETER
52 * crashes on Vista
53 */
54 SetLastError(0xdeadbeef);
57 "Expected ERROR_INVALID_PARAMETER, got %ld (%08lx)\n", GetLastError(),
58 GetLastError());
59 }
60 /* returns NULL, last error not set */
61 SetLastError(0xdeadbeef);
62 ret = CertFindAttribute("bogus", 1, &attr);
63 ok(ret == NULL, "Expected failure\n");
64 ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
65 GetLastError());
66 /* returns NULL, last error not set */
67 SetLastError(0xdeadbeef);
68 ret = CertFindAttribute("1.2.4", 1, &attr);
69 ok(ret == NULL, "Expected failure\n");
70 ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
71 GetLastError());
72 /* succeeds, last error not set */
73 SetLastError(0xdeadbeef);
74 ret = CertFindAttribute("1.2.3", 1, &attr);
75 ok(ret != NULL, "CertFindAttribute failed: %08lx\n", GetLastError());
76}
#define ARRAY_SIZE(A)
Definition: main.h:20
PCRYPT_ATTRIBUTE WINAPI CertFindAttribute(LPCSTR pszObjId, DWORD cAttr, CRYPT_ATTRIBUTE rgAttr[])
Definition: cert.c:2006
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
Definition: cookie.c:202
char CHAR
Definition: xmlstorage.h:175
unsigned char BYTE
Definition: xxhash.c:193

Referenced by START_TEST().

◆ test_findExtension()

static void test_findExtension ( void  )
static

Definition at line 78 of file main.c.

79{
81 static CHAR oid[] = "1.2.3";
82 BYTE blobbin[] = {0x02,0x01,0x01};
83 CERT_EXTENSION ext = { oid, TRUE, { sizeof blobbin, blobbin } };
84
85 /* returns NULL, last error not set */
86 SetLastError(0xdeadbeef);
88 ok(ret == NULL, "Expected failure\n");
89 ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
90 GetLastError());
91 if (0)
92 {
93 /* crashes */
94 SetLastError(0xdeadbeef);
96 /* returns NULL, last error is ERROR_INVALID_PARAMETER
97 * crashes on Vista
98 */
99 SetLastError(0xdeadbeef);
102 "Expected ERROR_INVALID_PARAMETER, got %ld (%08lx)\n", GetLastError(),
103 GetLastError());
104 }
105 /* returns NULL, last error not set */
106 SetLastError(0xdeadbeef);
107 ret = CertFindExtension("bogus", 1, &ext);
108 ok(ret == NULL, "Expected failure\n");
109 ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
110 GetLastError());
111 /* returns NULL, last error not set */
112 SetLastError(0xdeadbeef);
113 ret = CertFindExtension("1.2.4", 1, &ext);
114 ok(ret == NULL, "Expected failure\n");
115 ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
116 GetLastError());
117 /* succeeds, last error not set */
118 SetLastError(0xdeadbeef);
119 ret = CertFindExtension("1.2.3", 1, &ext);
120 ok(ret != NULL, "CertFindExtension failed: %08lx\n", GetLastError());
121}
#define TRUE
Definition: types.h:120
PCERT_EXTENSION WINAPI CertFindExtension(LPCSTR pszObjId, DWORD cExtensions, CERT_EXTENSION rgExtensions[])
Definition: cert.c:2028
static const WCHAR *const ext[]
Definition: module.c:53

Referenced by START_TEST().

◆ test_findRDNAttr()

static void test_findRDNAttr ( void  )
static

Definition at line 123 of file main.c.

124{
126 static CHAR oid[] = "1.2.3";
127 BYTE bin[] = { 0x16,0x09,'J','u','a','n',' ','L','a','n','g' };
128 CERT_RDN_ATTR attrs[] = {
129 { oid, CERT_RDN_IA5_STRING, { sizeof bin, bin } },
130 };
131 CERT_RDN rdns[] = { { ARRAY_SIZE(attrs), attrs } };
132 CERT_NAME_INFO nameInfo = { ARRAY_SIZE(rdns), rdns };
133
134 if (0)
135 {
136 /* crashes */
137 SetLastError(0xdeadbeef);
139 /* returns NULL, last error is ERROR_INVALID_PARAMETER
140 * crashes on Vista
141 */
142 SetLastError(0xdeadbeef);
143 ret = CertFindRDNAttr(NULL, &nameInfo);
145 "Expected ERROR_INVALID_PARAMETER, got %ld (%08lx)\n", GetLastError(),
146 GetLastError());
147 }
148 /* returns NULL, last error not set */
149 SetLastError(0xdeadbeef);
150 ret = CertFindRDNAttr("bogus", &nameInfo);
151 ok(ret == NULL, "Expected failure\n");
152 ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
153 GetLastError());
154 /* returns NULL, last error not set */
155 SetLastError(0xdeadbeef);
156 ret = CertFindRDNAttr("1.2.4", &nameInfo);
157 ok(ret == NULL, "Expected failure\n");
158 ok(GetLastError() == 0xdeadbeef, "Last error was set to %08lx\n",
159 GetLastError());
160 /* succeeds, last error not set */
161 SetLastError(0xdeadbeef);
162 ret = CertFindRDNAttr("1.2.3", &nameInfo);
163 ok(ret != NULL, "CertFindRDNAttr failed: %08lx\n", GetLastError());
164}
PCERT_RDN_ATTR WINAPI CertFindRDNAttr(LPCSTR pszObjId, PCERT_NAME_INFO pName)
Definition: cert.c:2051
static struct _PeImage bin
#define CERT_RDN_IA5_STRING
Definition: wincrypt.h:2931

Referenced by START_TEST().

◆ test_format_object()

static void test_format_object ( void  )
static

Definition at line 388 of file main.c.

389{
390 static const BYTE encodedInt[] = {0x02,0x01,0x01};
391 static const BYTE encodedBigInt[] = {0x02,0x1f,0x01,0x02,0x03,0x04,0x05,
392 0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,
393 0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f};
394 static const WCHAR encodedBigIntStr[] = L"02 1f 01 02 03 04 05 06 07 08 09 "
395 "0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f";
396
397 BOOL ret;
398 DWORD size;
399 WCHAR str[100];
400
401 /* Crash */
402 if (0)
403 {
404 CryptFormatObject(0, 0, 0, NULL, NULL, NULL, 0, NULL, NULL);
405 }
406 /* When called with any but the default encoding, it fails to find a
407 * formatting function.
408 */
409 SetLastError(0xdeadbeef);
410 ret = CryptFormatObject(0, 0, 0, NULL, NULL, NULL, 0, NULL, &size);
411 ok(!ret, "expected failure\n");
412 ok(GetLastError() == ERROR_FILE_NOT_FOUND, "wrong error %lu\n", GetLastError());
413
414 /* When called with the default encoding type for any undefined struct type
415 * (including none), it succeeds: the default encoding is a hex string
416 * encoding.
417 */
418 SetLastError(0xdeadbeef);
420 ok(ret, "CryptFormatObject failed: %ld\n", GetLastError());
421 ok(size == sizeof(WCHAR) || broken(!size) /* Win10 1709+ */, "wrong size %ld\n", size);
422
423 SetLastError(0xdeadbeef);
424 size = 0;
426 ok(!ret, "expected failure\n");
427 ok(GetLastError() == ERROR_MORE_DATA, "wrong error %lu\n", GetLastError());
428
429 size = sizeof(WCHAR);
431 ok(ret, "CryptFormatObject failed, error %lu\n", GetLastError());
432 ok(!str[0], "expected empty string\n");
433
435 sizeof(encodedInt), NULL, &size);
436 ok(ret, "CryptFormatObject failed, error %lu\n", GetLastError());
437 ok(size >= sizeof(L"02 01 01"), "wrong size %lu\n", size);
438
440 sizeof(encodedInt), str, &size);
441 ok(ret, "CryptFormatObject failed, error %lu\n", GetLastError());
442 ok(!wcscmp(str, L"02 01 01"), "wrong string %s\n", wine_dbgstr_w(str));
443
445 sizeof(encodedBigInt), NULL, &size);
446 ok(ret, "CryptFormatObject failed, error %lu\n", GetLastError());
447 ok(size >= sizeof(encodedBigIntStr), "wrong size %lu\n", size);
448
450 encodedBigInt, sizeof(encodedBigInt), str, &size);
451 ok(ret, "CryptFormatObject failed: %ld\n", GetLastError());
452 ok(!wcsicmp(str, encodedBigIntStr), "wrong string %s\n", wine_dbgstr_w(str));
453
454 /* When called with the default encoding type for any undefined struct
455 * type but CRYPT_FORMAT_STR_NO_HEX specified, it fails to find a
456 * formatting function.
457 */
458 SetLastError(0xdeadbeef);
460 NULL, NULL, NULL, 0, NULL, &size);
461 ok(!ret, "CryptFormatObject succeeded\n");
463 || GetLastError() == 0xdeadbeef, /* Vista, W2K8 */
464 "wrong error %lu\n", GetLastError());
465
466 /* When called to format an AUTHORITY_KEY_ID2_INFO, it fails when no
467 * data are given.
468 */
469 SetLastError(0xdeadbeef);
472 ok(!ret, "expected failure\n");
473 ok(GetLastError() == E_INVALIDARG, "wrong error %lu\n", GetLastError());
474}
#define broken(x)
Definition: atltest.h:178
#define ERROR_MORE_DATA
Definition: dderror.h:13
BOOL WINAPI CryptFormatObject(DWORD dwCertEncodingType, DWORD dwFormatType, DWORD dwFormatStrType, void *pFormatStruct, LPCSTR lpszStructType, const BYTE *pbEncoded, DWORD cbEncoded, void *pbFormat, DWORD *pcbFormat)
Definition: object.c:2549
#define wcsicmp
Definition: compat.h:15
#define L(x)
Definition: resources.c:13
GLsizeiptr size
Definition: glext.h:5919
#define wine_dbgstr_w
Definition: kernel32.h:34
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
const WCHAR * str
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define X509_ASN_ENCODING
Definition: wincrypt.h:2501
#define szOID_AUTHORITY_KEY_IDENTIFIER2
Definition: wincrypt.h:3356
#define CRYPT_FORMAT_STR_NO_HEX
Definition: wincrypt.h:3671
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ test_getDefaultCryptProv()

static void test_getDefaultCryptProv ( void  )
static

Definition at line 298 of file main.c.

299{
300#define ALG(id) id, #id
301 static const struct
302 {
303 ALG_ID algid;
304 const char *name;
306 } test_prov[] =
307 {
308 { ALG(CALG_MD2), TRUE },
309 { ALG(CALG_MD4), TRUE },
310 { ALG(CALG_MD5), TRUE },
311 { ALG(CALG_SHA), TRUE },
312 { ALG(CALG_RSA_SIGN) },
313 { ALG(CALG_DSS_SIGN) },
314 { ALG(CALG_NO_SIGN) },
315 { ALG(CALG_ECDSA), TRUE },
316 { ALG(CALG_ECDH), TRUE },
317 { ALG(CALG_RSA_KEYX) },
318 { ALG(CALG_RSA_KEYX) },
319 };
320#undef ALG
321 HCRYPTPROV (WINAPI *pI_CryptGetDefaultCryptProv)(DWORD w);
322 HCRYPTPROV prov;
323 BOOL ret;
324 DWORD size, i;
325 LPSTR name;
326
327 pI_CryptGetDefaultCryptProv = (void *)GetProcAddress(hCrypt, "I_CryptGetDefaultCryptProv");
328 if (!pI_CryptGetDefaultCryptProv) return;
329
330 prov = pI_CryptGetDefaultCryptProv(0xdeadbeef);
331 ok(prov == 0 && GetLastError() == E_INVALIDARG,
332 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
333 prov = pI_CryptGetDefaultCryptProv(PROV_RSA_FULL);
334 ok(prov == 0 && GetLastError() == E_INVALIDARG,
335 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
336 prov = pI_CryptGetDefaultCryptProv(1);
337 ok(prov == 0 && GetLastError() == E_INVALIDARG,
338 "Expected E_INVALIDARG, got %08lx\n", GetLastError());
339 prov = pI_CryptGetDefaultCryptProv(0);
340 ok(prov != 0, "I_CryptGetDefaultCryptProv failed: %08lx\n", GetLastError());
341 CryptReleaseContext(prov, 0);
342
343 for (i = 0; i < ARRAY_SIZE(test_prov); i++)
344 {
345 if (winetest_debug > 1)
346 trace("%lu: algid %#x (%s): class %u, type %u, sid %u\n", i, test_prov[i].algid, test_prov[i].name,
347 GET_ALG_CLASS(test_prov[i].algid) >> 13, GET_ALG_TYPE(test_prov[i].algid) >> 9, GET_ALG_SID(test_prov[i].algid));
348
349 prov = pI_CryptGetDefaultCryptProv(test_prov[i].algid);
350 if (!prov)
351 {
353 ok(test_prov[i].optional, "%lu: I_CryptGetDefaultCryptProv(%#x) failed\n", i, test_prov[i].algid);
354 continue;
355 }
356
357 ret = CryptGetProvParam(prov, PP_NAME, NULL, &size, 0);
358 if (ret) /* some provders don't support PP_NAME */
359 {
361 ret = CryptGetProvParam(prov, PP_NAME, (BYTE *)name, &size, 0);
362 ok(ret, "%lu: CryptGetProvParam failed %#lx\n", i, GetLastError());
363 if (winetest_debug > 1)
364 trace("%lu: algid %#x, name %s\n", i, test_prov[i].algid, name);
366 }
367
368 CryptReleaseContext(prov, 0);
369 }
370}
@ optional
Definition: SystemMenu.c:34
int trace
Definition: main.c:57
BOOL WINAPI CryptReleaseContext(HCRYPTPROV hProv, DWORD dwFlags)
Definition: crypt.c:648
BOOL WINAPI CryptGetProvParam(HCRYPTPROV hProv, DWORD dwParam, BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags)
Definition: crypt.c:1688
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
int winetest_debug
#define todo_wine_if(is_todo)
Definition: minitest.h:81
#define ALG(id)
static void test_prov(void)
Definition: rsaenh.c:250
Definition: name.c:39
#define PROV_RSA_FULL
Definition: wincrypt.h:2243
#define CALG_RSA_SIGN
Definition: wincrypt.h:2069
ULONG_PTR HCRYPTPROV
Definition: wincrypt.h:55
#define CALG_MD5
Definition: wincrypt.h:2058
#define GET_ALG_SID(x)
Definition: wincrypt.h:1964
#define CALG_MD2
Definition: wincrypt.h:2056
#define CALG_RSA_KEYX
Definition: wincrypt.h:2080
#define PP_NAME
Definition: wincrypt.h:2289
#define CALG_ECDSA
Definition: wincrypt.h:2072
#define GET_ALG_TYPE(x)
Definition: wincrypt.h:1963
#define CALG_MD4
Definition: wincrypt.h:2057
#define CALG_NO_SIGN
Definition: wincrypt.h:2071
#define CALG_SHA
Definition: wincrypt.h:2059
#define GET_ALG_CLASS(x)
Definition: wincrypt.h:1962
#define CALG_ECDH
Definition: wincrypt.h:2078
#define CALG_DSS_SIGN
Definition: wincrypt.h:2070
unsigned int ALG_ID
Definition: wincrypt.h:54
char * LPSTR
Definition: xmlstorage.h:182

Referenced by START_TEST().

◆ test_readTrustedPublisherDWORD()

static void test_readTrustedPublisherDWORD ( void  )
static

Definition at line 267 of file main.c.

268{
269
270 BOOL (WINAPI *pReadDWORD)(LPCWSTR, DWORD *);
271
272 pReadDWORD = (void *)GetProcAddress(hCrypt, "I_CryptReadTrustedPublisherDWORDValueFromRegistry");
273 if (pReadDWORD)
274 {
275 BOOL ret, exists = FALSE;
276 DWORD size, readFlags = 0, returnedFlags;
277 HKEY key;
278 LONG rc;
279
281 L"Software\\Policies\\Microsoft\\SystemCertificates\\TrustedPublisher\\Safer", &key);
282 if (rc == ERROR_SUCCESS)
283 {
284 size = sizeof(readFlags);
285 rc = RegQueryValueExW(key, L"AuthenticodeFlags", NULL, NULL,
286 (LPBYTE)&readFlags, &size);
287 if (rc == ERROR_SUCCESS)
288 exists = TRUE;
289 }
290 returnedFlags = 0xdeadbeef;
291 ret = pReadDWORD(L"AuthenticodeFlags", &returnedFlags);
292 ok(ret == exists, "Unexpected return value\n");
293 ok(readFlags == returnedFlags,
294 "Expected flags %08lx, got %08lx\n", readFlags, returnedFlags);
295 }
296}
#define ERROR_SUCCESS
Definition: deptool.c:10
#define FALSE
Definition: types.h:117
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3268
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
long LONG
Definition: pedump.c:60
Definition: copy.c:22
unsigned char * LPBYTE
Definition: typedefs.h:53
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by START_TEST().

◆ test_verifyTimeValidity()

static void test_verifyTimeValidity ( void  )
static

Definition at line 166 of file main.c.

167{
168 SYSTEMTIME sysTime;
169 FILETIME fileTime;
170 CERT_INFO info = { 0 };
171 LONG ret;
172
173 GetSystemTime(&sysTime);
174 SystemTimeToFileTime(&sysTime, &fileTime);
175 /* crashes
176 ret = CertVerifyTimeValidity(NULL, NULL);
177 ret = CertVerifyTimeValidity(&fileTime, NULL);
178 */
179 /* Check with 0 NotBefore and NotAfter */
180 ret = CertVerifyTimeValidity(&fileTime, &info);
181 ok(ret == 1, "Expected 1, got %ld\n", ret);
182 info.NotAfter = fileTime;
183 /* Check with NotAfter equal to comparison time */
184 ret = CertVerifyTimeValidity(&fileTime, &info);
185 ok(ret == 0, "Expected 0, got %ld\n", ret);
186 /* Check with NotBefore after comparison time */
187 info.NotBefore = fileTime;
188 info.NotBefore.dwLowDateTime += 5000;
189 ret = CertVerifyTimeValidity(&fileTime, &info);
190 ok(ret == -1, "Expected -1, got %ld\n", ret);
191}
LONG WINAPI CertVerifyTimeValidity(LPFILETIME pTimeToVerify, PCERT_INFO pCertInfo)
Definition: cert.c:2158
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:158
VOID WINAPI GetSystemTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:327

Referenced by START_TEST().

Variable Documentation

◆ hCrypt