#include <stdio.h>
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winerror.h>
#include <wincrypt.h>
#include "wine/test.h"
Go to the source code of this file.
◆ START_TEST()
| START_TEST |
( |
protectdata |
| ) |
|
Definition at line 216 of file protectdata.c.
217{
223
224
228}
HLOCAL NTAPI LocalFree(HLOCAL hMem)
static DATA_BLOB cipher_no_desc
static void test_simpleroundtrip(const char *plaintext)
static void test_cryptprotectdata(void)
static void test_cryptunprotectdata(void)
static DATA_BLOB cipher_entropy
◆ test_cryptprotectdata()
| static void test_cryptprotectdata |
( |
void |
| ) |
|
|
static |
Definition at line 38 of file protectdata.c.
39{
43
46
49
52 ok(!
protected,
"Encrypting without plain data source.\n");
55
58 ok(!
protected,
"Encrypting without cipher destination.\n");
61
64
65
68 ok(
protected,
"Encrypting without entropy.\n");
69 if (protected)
70 {
73 }
74
77
78
81 ok(
protected,
"Encrypting with entropy.\n");
82
85
86
91 ok(
protected,
"Encrypting with entropy.\n");
92}
BOOL WINAPI CryptProtectData(DATA_BLOB *pDataIn, LPCWSTR szDataDescr, DATA_BLOB *pOptionalEntropy, PVOID pvReserved, CRYPTPROTECT_PROMPTSTRUCT *pPromptStruct, DWORD dwFlags, DATA_BLOB *pDataOut)
#define ERROR_INVALID_PARAMETER
_ACRTIMP size_t __cdecl strlen(const char *)
GLdouble GLdouble GLdouble r
DWORD WINAPI GetLastError(void)
Referenced by START_TEST().
◆ test_cryptunprotectdata()
| static void test_cryptunprotectdata |
( |
void |
| ) |
|
|
static |
Definition at line 94 of file protectdata.c.
95{
101
104
107
110 ok(!okay,
"Decrypting without destination\n");
113
116 ok(!okay,
"Decrypting without source\n");
119
122
125 ok(!okay,
"Decrypting without needed entropy\n");
128
132
133
136 ok(okay,
"Decrypting without entropy\n");
137
138 ok(plain.
pbData!=
NULL,
"Plain DATA_BLOB missing data\n");
141 ok(data_desc!=
NULL,
"Description not allocated\n");
142 ok(!
lstrcmpW(data_desc,
L"Ultra secret test message"),
"Description does not match\n");
143
146
150
151
154 ok(!okay,
"Decrypting with wrong entropy\n");
157
158
161 ok(okay,
"Decrypting with entropy\n");
162
163 ok(plain.
pbData!=
NULL,
"Plain DATA_BLOB missing data\n");
166 ok(data_desc!=
NULL,
"Description not allocated\n");
167 ok(!
lstrcmpW(data_desc,
L"Ultra secret test message"),
"Description does not match\n");
168
171
175
176
179 ok(okay,
"Decrypting with entropy and no description\n");
180
181 ok(plain.
pbData!=
NULL,
"Plain DATA_BLOB missing data\n");
184 ok(data_desc!=
NULL,
"Description not allocated\n");
185 ok(data_desc[0]==
'\0',
"Description not empty\n");
186
189
192}
BOOL WINAPI CryptUnprotectData(DATA_BLOB *pDataIn, LPWSTR *ppszDataDescr, DATA_BLOB *pOptionalEntropy, PVOID pvReserved, CRYPTPROTECT_PROMPTSTRUCT *pPromptStruct, DWORD dwFlags, DATA_BLOB *pDataOut)
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
_ACRTIMP int __cdecl strcmp(const char *, const char *)
#define ERROR_INVALID_DATA
Referenced by START_TEST().
◆ test_simpleroundtrip()
Definition at line 194 of file protectdata.c.
195{
201
203 input.pbData = (
unsigned char *)plaintext;
206 ok(
res != 0,
"can't protect\n");
207
210 ok(output.
cbData ==
strlen(plaintext),
"output wrong length %ld for input '%s', wanted %d\n", output.
cbData, plaintext,
lstrlenA(plaintext));
211 ok(!
memcmp(plaintext, (
char *)output.
pbData, output.
cbData),
"output wrong contents for input '%s'\n", plaintext);
214}
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
GLenum GLenum GLenum input
static const WCHAR emptyW[]
int WINAPI lstrlenA(LPCSTR lpString)
Referenced by START_TEST().
◆ cipher
◆ cipher_entropy
◆ cipher_no_desc
◆ key
| char key[] = "Wibble wibble wibble" |
|
static |
◆ protected
◆ secret
◆ secret2