ReactOS 0.4.15-dev-7942-gd23573b
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
 
static const BYTE encodedInt [] = { 0x02,0x01,0x01 }
 
static const WCHAR encodedIntStr [] = { '0','2',' ','0','1',' ','0','1',0 }
 
static const BYTE encodedBigInt []
 
static const WCHAR encodedBigIntStr []
 

Macro Definition Documentation

◆ ALG

#define ALG (   id)    id, #id

Function Documentation

◆ START_TEST()

START_TEST ( main  )

Definition at line 511 of file main.c.

512{
513 hCrypt = GetModuleHandleA("crypt32.dll");
514
525}
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
static void test_format_object(void)
Definition: main.c:408
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:380
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:306
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: %08x\n", GetLastError());
200 /* CryptMemRealloc(NULL, 0) fails pre-Vista */
201 buf = CryptMemAlloc(0);
202 buf = CryptMemRealloc(buf, 1);
203 ok(buf != NULL, "CryptMemRealloc failed: %08x\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 380 of file main.c.

381{
382 int (WINAPI *pI_CryptInstallOssGlobal)(DWORD,DWORD,DWORD);
383 int ret,i;
384
385 pI_CryptInstallOssGlobal = (void *)GetProcAddress(hCrypt,"I_CryptInstallOssGlobal");
386 /* passing in some random values to I_CryptInstallOssGlobal, it always returns 9 the first time, then 10, 11 etc.*/
387 for(i=0;i<30;i++)
388 {
389 ret = pI_CryptInstallOssGlobal(rand(),rand(),rand());
390 ok((9+i) == ret ||
391 ret == 0, /* Vista */
392 "Expected %d or 0, got %d\n",(9+i),ret);
393 }
394}
#define GetProcAddress(x, y)
Definition: compat.h:753
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
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
_Check_return_ int __cdecl rand(void)
Definition: rand.c:10
#define DWORD
Definition: nt_native.h:44
int ret
#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: %08x\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: %08x\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: %08x\n", GetLastError());
242 ret = pI_CryptFreeTls(index, 0);
243 ok(!ret, "I_CryptFreeTls succeeded\n");
245 "Expected E_INVALIDARG, got %08x\n", GetLastError());
246 }
247 /* Similar pass, check I_CryptDetachTls */
248 index = pI_CryptAllocTls();
249 ok(index, "I_CryptAllocTls failed: %08x\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: %08x\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 BOOL
Definition: nt_native.h:43
#define LPVOID
Definition: nt_native.h:45
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 %08x\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 %d (%08x)\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 %08x\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 %08x\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: %08x\n", GetLastError());
76}
#define ARRAY_SIZE(A)
Definition: main.h:33
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 %08x\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 %d (%08x)\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 %08x\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 %08x\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: %08x\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 %d (%08x)\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 %08x\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 %08x\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: %08x\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:2784

Referenced by START_TEST().

◆ test_format_object()

static void test_format_object ( void  )
static

Definition at line 408 of file main.c.

409{
410 BOOL (WINAPI *pCryptFormatObject)(DWORD dwEncoding, DWORD dwFormatType,
411 DWORD dwFormatStrType, void *pFormatStruct, LPCSTR lpszStructType,
412 const BYTE *pbEncoded, DWORD dwEncoded, void *pbFormat,
413 DWORD *pcbFormat);
414 BOOL ret;
415 DWORD size;
416 LPWSTR str;
417
418 pCryptFormatObject = (void *)GetProcAddress(hCrypt, "CryptFormatObject");
419 if (!pCryptFormatObject)
420 {
421 skip("No CryptFormatObject\n");
422 return;
423 }
424 /* Crash */
425 if (0)
426 {
427 pCryptFormatObject(0, 0, 0, NULL, NULL, NULL, 0, NULL, NULL);
428 }
429 /* When called with any but the default encoding, it fails to find a
430 * formatting function.
431 */
432 SetLastError(0xdeadbeef);
433 ret = pCryptFormatObject(0, 0, 0, NULL, NULL, NULL, 0, NULL, &size);
435 "expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
436 /* When called with the default encoding type for any undefined struct type
437 * (including none), it succeeds: the default encoding is a hex string
438 * encoding.
439 */
440 SetLastError(0xdeadbeef);
441 ret = pCryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, NULL, 0,
442 NULL, &size);
443 ok(ret, "CryptFormatObject failed: %d\n", GetLastError());
444 if (ret)
445 {
446 if (size == 0 && GetLastError() == ERROR_FILE_NOT_FOUND)
447 {
448 win_skip("CryptFormatObject has no default implementation\n");
449 return;
450 }
451 ok(size == sizeof(WCHAR), "unexpected size %d\n", size);
453 SetLastError(0xdeadbeef);
454 size = 0;
455 ret = pCryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, NULL, 0,
456 str, &size);
458 "expected ERROR_MORE_DATA, got %d\n", GetLastError());
459 size = sizeof(WCHAR);
460 ret = pCryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, NULL, 0,
461 str, &size);
462 ok(ret, "CryptFormatObject failed: %d\n", GetLastError());
463 ok(!str[0], "expected empty string\n");
465 }
466 ret = pCryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL, encodedInt,
467 sizeof(encodedInt), NULL, &size);
468 ok(ret, "CryptFormatObject failed: %d\n", GetLastError());
469 if (ret)
470 {
472 ret = pCryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL,
473 encodedInt, sizeof(encodedInt), str, &size);
474 ok(ret, "CryptFormatObject failed: %d\n", GetLastError());
475 ok(!lstrcmpW(str, encodedIntStr), "unexpected format string\n");
477 }
478 ret = pCryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL,
480 ok(ret, "CryptFormatObject failed: %d\n", GetLastError());
481 if (ret)
482 {
484 ret = pCryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL, NULL,
485 encodedBigInt, sizeof(encodedBigInt), str, &size);
486 ok(ret, "CryptFormatObject failed: %d\n", GetLastError());
487 ok(!lstrcmpiW(str, encodedBigIntStr), "unexpected format string\n");
489 }
490 /* When called with the default encoding type for any undefined struct
491 * type but CRYPT_FORMAT_STR_NO_HEX specified, it fails to find a
492 * formatting function.
493 */
494 SetLastError(0xdeadbeef);
495 ret = pCryptFormatObject(X509_ASN_ENCODING, 0, CRYPT_FORMAT_STR_NO_HEX,
496 NULL, NULL, NULL, 0, NULL, &size);
497 ok(!ret, "CryptFormatObject succeeded\n");
499 GetLastError() == 0xdeadbeef, /* Vista, W2K8 */
500 "expected ERROR_FILE_NOT_FOUND or no change, got %d\n", GetLastError());
501 /* When called to format an AUTHORITY_KEY_ID2_INFO, it fails when no
502 * data are given.
503 */
504 SetLastError(0xdeadbeef);
505 ret = pCryptFormatObject(X509_ASN_ENCODING, 0, 0, NULL,
508 "expected E_INVALIDARG, got %d\n", GetLastError());
509}
#define skip(...)
Definition: atltest.h:64
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
GLsizeiptr size
Definition: glext.h:5919
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
static const WCHAR encodedIntStr[]
Definition: main.c:397
static const WCHAR encodedBigIntStr[]
Definition: main.c:401
static LPCSTR DWORD void BYTE * pbEncoded
Definition: str.c:196
const WCHAR * str
#define win_skip
Definition: test.h:160
#define X509_ASN_ENCODING
Definition: wincrypt.h:2297
#define szOID_AUTHORITY_KEY_IDENTIFIER2
Definition: wincrypt.h:3200
#define CRYPT_FORMAT_STR_NO_HEX
Definition: wincrypt.h:3511
const char * LPCSTR
Definition: xmlstorage.h:183
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by START_TEST().

◆ test_getDefaultCryptProv()

static void test_getDefaultCryptProv ( void  )
static

Definition at line 306 of file main.c.

307{
308#define ALG(id) id, #id
309 static const struct
310 {
311 ALG_ID algid;
312 const char *name;
314 } test_prov[] =
315 {
316 { ALG(CALG_MD2), TRUE },
317 { ALG(CALG_MD4), TRUE },
318 { ALG(CALG_MD5), TRUE },
319 { ALG(CALG_SHA), TRUE },
320 { ALG(CALG_RSA_SIGN) },
321 { ALG(CALG_DSS_SIGN) },
322 { ALG(CALG_NO_SIGN) },
323 { ALG(CALG_ECDSA), TRUE },
324 { ALG(CALG_ECDH), TRUE },
325 { ALG(CALG_RSA_KEYX) },
326 { ALG(CALG_RSA_KEYX) },
327 };
328#undef ALG
329 HCRYPTPROV (WINAPI *pI_CryptGetDefaultCryptProv)(DWORD w);
330 HCRYPTPROV prov;
331 BOOL ret;
332 DWORD size, i;
333 LPSTR name;
334
335 pI_CryptGetDefaultCryptProv = (void *)GetProcAddress(hCrypt, "I_CryptGetDefaultCryptProv");
336 if (!pI_CryptGetDefaultCryptProv) return;
337
338 prov = pI_CryptGetDefaultCryptProv(0xdeadbeef);
339 ok(prov == 0 && GetLastError() == E_INVALIDARG,
340 "Expected E_INVALIDARG, got %08x\n", GetLastError());
341 prov = pI_CryptGetDefaultCryptProv(PROV_RSA_FULL);
342 ok(prov == 0 && GetLastError() == E_INVALIDARG,
343 "Expected E_INVALIDARG, got %08x\n", GetLastError());
344 prov = pI_CryptGetDefaultCryptProv(1);
345 ok(prov == 0 && GetLastError() == E_INVALIDARG,
346 "Expected E_INVALIDARG, got %08x\n", GetLastError());
347 prov = pI_CryptGetDefaultCryptProv(0);
348 ok(prov != 0, "I_CryptGetDefaultCryptProv failed: %08x\n", GetLastError());
349 CryptReleaseContext(prov, 0);
350
351 for (i = 0; i < ARRAY_SIZE(test_prov); i++)
352 {
353 if (winetest_debug > 1)
354 trace("%u: algid %#x (%s): class %u, type %u, sid %u\n", i, test_prov[i].algid, test_prov[i].name,
355 GET_ALG_CLASS(test_prov[i].algid) >> 13, GET_ALG_TYPE(test_prov[i].algid) >> 9, GET_ALG_SID(test_prov[i].algid));
356
357 prov = pI_CryptGetDefaultCryptProv(test_prov[i].algid);
358 if (!prov)
359 {
361 ok(test_prov[i].optional, "%u: I_CryptGetDefaultCryptProv(%#x) failed\n", i, test_prov[i].algid);
362 continue;
363 }
364
365 ret = CryptGetProvParam(prov, PP_NAME, NULL, &size, 0);
366 if (ret) /* some provders don't support PP_NAME */
367 {
369 ret = CryptGetProvParam(prov, PP_NAME, (BYTE *)name, &size, 0);
370 ok(ret, "%u: CryptGetProvParam failed %#x\n", i, GetLastError());
371 if (winetest_debug > 1)
372 trace("%u: algid %#x, name %s\n", i, test_prov[i].algid, name);
374 }
375
376 CryptReleaseContext(prov, 0);
377 }
378}
@ 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
#define ALG(id)
#define todo_wine_if(is_todo)
Definition: custom.c:76
static void test_prov(void)
Definition: rsaenh.c:250
int winetest_debug
Definition: name.c:39
#define PROV_RSA_FULL
Definition: wincrypt.h:2039
#define CALG_RSA_SIGN
Definition: wincrypt.h:1816
ULONG_PTR HCRYPTPROV
Definition: wincrypt.h:46
#define CALG_MD5
Definition: wincrypt.h:1805
#define GET_ALG_SID(x)
Definition: wincrypt.h:1711
#define CALG_MD2
Definition: wincrypt.h:1803
#define CALG_RSA_KEYX
Definition: wincrypt.h:1824
#define PP_NAME
Definition: wincrypt.h:2085
#define CALG_ECDSA
Definition: wincrypt.h:1850
#define GET_ALG_TYPE(x)
Definition: wincrypt.h:1710
#define CALG_MD4
Definition: wincrypt.h:1804
#define CALG_NO_SIGN
Definition: wincrypt.h:1818
#define CALG_SHA
Definition: wincrypt.h:1806
#define GET_ALG_CLASS(x)
Definition: wincrypt.h:1709
#define CALG_ECDH
Definition: wincrypt.h:1825
#define CALG_DSS_SIGN
Definition: wincrypt.h:1817
unsigned int ALG_ID
Definition: wincrypt.h:45
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 static const WCHAR safer[] = {
276 'S','o','f','t','w','a','r','e','\\',
277 'P','o','l','i','c','i','e','s','\\',
278 'M','i','c','r','o','s','o','f','t','\\','S','y','s','t','e','m',
279 'C','e','r','t','i','f','i','c','a','t','e','s','\\',
280 'T','r','u','s','t','e','d','P','u','b','l','i','s','h','e','r',
281 '\\','S','a','f','e','r',0 };
282 static const WCHAR authenticodeFlags[] = { 'A','u','t','h','e','n',
283 't','i','c','o','d','e','F','l','a','g','s',0 };
284 BOOL ret, exists = FALSE;
285 DWORD size, readFlags = 0, returnedFlags;
286 HKEY key;
287 LONG rc;
288
289 rc = RegOpenKeyW(HKEY_LOCAL_MACHINE, safer, &key);
290 if (rc == ERROR_SUCCESS)
291 {
292 size = sizeof(readFlags);
293 rc = RegQueryValueExW(key, authenticodeFlags, NULL, NULL,
294 (LPBYTE)&readFlags, &size);
295 if (rc == ERROR_SUCCESS)
296 exists = TRUE;
297 }
298 returnedFlags = 0xdeadbeef;
299 ret = pReadDWORD(authenticodeFlags, &returnedFlags);
300 ok(ret == exists, "Unexpected return value\n");
301 ok(readFlags == returnedFlags,
302 "Expected flags %08x, got %08x\n", readFlags, returnedFlags);
303 }
304}
#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 %d\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 %d\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 %d\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

◆ encodedBigInt

Initial value:
= { 0x02,0x1f,0x01,0x02,0x03,0x04,0x05,0x06,
0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x13,0x14,0x15,
0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f }

Definition at line 398 of file main.c.

◆ encodedBigIntStr

const WCHAR encodedBigIntStr[]
static
Initial value:
= { '0','2',' ','1','f',' ','0','1',' ',
'0','2',' ','0','3',' ','0','4',' ','0','5',' ','0','6',' ','0','7',' ','0',
'8',' ','0','9',' ','0','a',' ','0','b',' ','0','c',' ','0','d',' ','0','e',
' ','0','f',' ','1','0',' ','1','1',' ','1','2',' ','1','3',' ','1','4',' ',
'1','5',' ','1','6',' ','1','7',' ','1','8',' ','1','9',' ','1','a',' ','1',
'b',' ','1','c',' ','1','d',' ','1','e',' ','1','f',0 }

Definition at line 401 of file main.c.

Referenced by test_format_object().

◆ encodedInt

const BYTE encodedInt[] = { 0x02,0x01,0x01 }
static

Definition at line 396 of file main.c.

◆ encodedIntStr

const WCHAR encodedIntStr[] = { '0','2',' ','0','1',' ','0','1',0 }
static

Definition at line 397 of file main.c.

Referenced by test_format_object().

◆ hCrypt