49#define CRYPT32_PROTECTDATA_PROV PROV_RSA_FULL
50#define CRYPT32_PROTECTDATA_HASH_CALG CALG_SHA1
51#define CRYPT32_PROTECTDATA_HASH_LEN 160
52#define CRYPT32_PROTECTDATA_KEY_CALG CALG_3DES
53#define CRYPT32_PROTECTDATA_KEY_LEN 168
54#define CRYPT32_PROTECTDATA_SALT_LEN 16
57 'I',
'\'',
'm',
' ',
'h',
'u',
'n',
't',
'i',
'n',
'g',
' ',
58 'w',
'a',
'b',
'b',
'i',
't',
's',0
135#define TRACE_DATA_BLOB(blob) do { \
136 TRACE("%s cbData: %u\n", #blob ,(unsigned int)((blob)->cbData)); \
137 TRACE("%s pbData @ %p:%s\n", #blob ,(blob)->pbData, \
138 hex_str((blob)->pbData, (blob)->cbData)); \
235 ERR(
"protect_data_t info0 not 16 bytes long\n");
240 ERR(
"protect_data_t info1 not 16 bytes long\n");
257 dwStruct = pSerial->
cbData;
333 ERR(
"struct size changed!? expected %u\n", dwStruct);
353 if (!pInfo || !pSerial || !pSerial->
pbData)
363 ERR(
"reading count0 failed!\n");
371 ERR(
"reading info0 failed!\n");
378 ERR(
"reading count1 failed!\n");
386 ERR(
"reading info1 failed!\n");
393 ERR(
"reading null0 failed!\n");
401 ERR(
"reading szDataDescr failed!\n");
408 ERR(
"reading cipher_alg failed!\n");
415 ERR(
"reading cipher_key_len failed!\n");
423 ERR(
"reading data0 failed!\n");
430 ERR(
"reading null1 failed!\n");
437 ERR(
"reading hash_alg failed!\n");
444 ERR(
"reading hash_len failed!\n");
452 ERR(
"reading salt failed!\n");
460 ERR(
"reading cipher failed!\n");
468 ERR(
"reading fingerprint failed!\n");
478 ERR(
"loaded corrupt structure! (used %u expected %u)\n",
index,
size);
493 if (pInfo->
count0 != 0x0001)
495 ERR(
"count0 != 0x0001 !\n");
498 if (pInfo->
count1 != 0x0001)
500 ERR(
"count0 != 0x0001 !\n");
503 if (pInfo->
null0 != 0x0000)
505 ERR(
"null0 != 0x0000 !\n");
508 if (pInfo->
null1 != 0x0000)
510 ERR(
"null1 != 0x0000 !\n");
521 ERR(
"info0 magic value not matched !\n");
527 ERR(
"unrecognized CryptProtectData block\n");
578 if (!pInfo)
return FALSE;
582 memset(pInfo,0,
sizeof(*pInfo));
614 ERR(
"CryptGenRandom\n");
636 ERR(
"could not allocate protect_data structures\n");
657 ERR(
"failed to get hash size\n");
663 ERR(
"failed to allocate blob memory\n");
670 ERR(
"failed to get hash value\n");
693 if (
one.cbData ==
two->cbData &&
710 char * szUsername =
NULL;
715 if (!salt || !phKey ||
718 ERR(
"CryptCreateHash\n");
746 pOptionalEntropy->
cbData,0)))
748 ERR(
"CryptHashData\n");
756 ERR(
"CryptDeriveKey\n");
772 TRACE(
"pPromptStruct: %p\n", pPromptStruct);
778 TRACE(
" szPrompt: %p %s\n",
785 if (pOptionalEntropy)
841 if (!pDataIn || !pDataOut)
860 ERR(
"CryptAcquireContextW failed\n");
867 ERR(
"fill_protect_data\n");
880 ERR(
"CryptCreateHash\n");
889 ERR(
"CryptEncrypt\n");
899 ERR(
"CryptMemAlloc\n");
920 ERR(
"convert_hash_to_blob\n");
956 TRACE(
"returning %s\n", rc ?
"ok" :
"FAIL");
1006 const char * announce_bad_opaque_data =
"CryptUnprotectData received a DATA_BLOB that seems to have NOT been generated by Wine. Please enable tracing ('export WINEDEBUG=crypt') to see details.";
1012 if (!pDataIn || !pDataOut)
1025 TRACE(
"\tppszDataDescr: %p\n", ppszDataDescr);
1031 FIXME(
"%s\n",announce_bad_opaque_data);
1039 FIXME(
"%s\n",announce_bad_opaque_data);
1046 ERR(
"CryptAcquireContextW failed\n");
1059 ERR(
"CryptCreateHash\n");
1067 ERR(
"CryptMemAlloc\n");
1094 ERR(
"LocalAlloc (ppszDataDescr)\n");
1130 TRACE(
"returning %s\n", rc ?
"ok" :
"FAIL");
int strcmp(const char *String1, const char *String2)
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
ACPI_SIZE strlen(const char *String)
char * strcpy(char *DstString, const char *SrcString)
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
static const TCHAR empty_str[]
#define ERROR_INSUFFICIENT_BUFFER
BOOL WINAPI GetUserNameA(LPSTR lpszName, LPDWORD lpSize)
BOOL WINAPI CryptCreateHash(HCRYPTPROV hProv, ALG_ID Algid, HCRYPTKEY hKey, DWORD dwFlags, HCRYPTHASH *phHash)
BOOL WINAPI CryptGenRandom(HCRYPTPROV hProv, DWORD dwLen, BYTE *pbBuffer)
BOOL WINAPI CryptGetHashParam(HCRYPTHASH hHash, DWORD dwParam, BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags)
BOOL WINAPI CryptDestroyKey(HCRYPTKEY hKey)
BOOL WINAPI CryptDestroyHash(HCRYPTHASH hHash)
BOOL WINAPI CryptReleaseContext(HCRYPTPROV hProv, DWORD dwFlags)
BOOL WINAPI CryptHashData(HCRYPTHASH hHash, const BYTE *pbData, DWORD dwDataLen, DWORD dwFlags)
BOOL WINAPI CryptDeriveKey(HCRYPTPROV hProv, ALG_ID Algid, HCRYPTHASH hBaseData, DWORD dwFlags, HCRYPTKEY *phKey)
BOOL WINAPI CryptDecrypt(HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final, DWORD dwFlags, BYTE *pbData, DWORD *pdwDataLen)
BOOL WINAPI CryptAcquireContextW(HCRYPTPROV *phProv, LPCWSTR pszContainer, LPCWSTR pszProvider, DWORD dwProvType, DWORD dwFlags)
BOOL WINAPI CryptEncrypt(HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final, DWORD dwFlags, BYTE *pbData, DWORD *pdwDataLen, DWORD dwBufLen)
LPVOID WINAPI CryptMemAlloc(ULONG cbSize)
VOID WINAPI CryptMemFree(LPVOID pv)
#define CRYPT32_PROTECTDATA_HASH_CALG
static void serialize_string(const BYTE *str, BYTE **ptr, DWORD len, DWORD width, BOOL prepend_len)
#define CRYPT32_PROTECTDATA_KEY_LEN
#define CRYPT32_PROTECTDATA_PROV
#define CRYPT32_PROTECTDATA_SALT_LEN
#define CRYPT32_PROTECTDATA_KEY_CALG
static BOOL fill_protect_data(struct protect_data_t *pInfo, LPCWSTR szDataDescr, HCRYPTPROV hProv)
static void serialize_dword(DWORD value, BYTE **ptr)
static void report(const DATA_BLOB *pDataIn, const DATA_BLOB *pOptionalEntropy, CRYPTPROTECT_PROMPTSTRUCT *pPromptStruct, DWORD dwFlags)
static const BYTE crypt32_protectdata_secret[]
BOOL WINAPI CryptUnprotectData(DATA_BLOB *pDataIn, LPWSTR *ppszDataDescr, DATA_BLOB *pOptionalEntropy, PVOID pvReserved, CRYPTPROTECT_PROMPTSTRUCT *pPromptStruct, DWORD dwFlags, DATA_BLOB *pDataOut)
#define CRYPT32_PROTECTDATA_HASH_LEN
static void free_protect_data(struct protect_data_t *pInfo)
static const char * hex_str(const unsigned char *p, int n)
static BOOL valid_protect_data(const struct protect_data_t *pInfo)
static BOOL convert_hash_to_blob(HCRYPTHASH hHash, DATA_BLOB *blob)
static BOOL unserialize_dword(const BYTE *ptr, DWORD *index, DWORD size, DWORD *value)
static BOOL serialize(const struct protect_data_t *pInfo, DATA_BLOB *pSerial)
static BOOL hash_matches_blob(HCRYPTHASH hHash, const DATA_BLOB *two)
static BOOL unserialize(const DATA_BLOB *pSerial, struct protect_data_t *pInfo)
static BOOL unserialize_string(const BYTE *ptr, DWORD *index, DWORD size, DWORD len, DWORD width, BOOL inline_len, BYTE **data, DWORD *stored)
static const char crypt_magic_str[]
BOOL WINAPI CryptProtectData(DATA_BLOB *pDataIn, LPCWSTR szDataDescr, DATA_BLOB *pOptionalEntropy, PVOID pvReserved, CRYPTPROTECT_PROMPTSTRUCT *pPromptStruct, DWORD dwFlags, DATA_BLOB *pDataOut)
static BOOL load_encryption_key(HCRYPTPROV hProv, DWORD key_len, const DATA_BLOB *salt, const DATA_BLOB *pOptionalEntropy, HCRYPTKEY *phKey)
#define TRACE_DATA_BLOB(blob)
static BYTE * convert_str_to_blob(LPCSTR str, DATA_BLOB *blob)
const char * wine_dbg_sprintf(const char *format,...)
#define ERROR_INVALID_PARAMETER
static __inline const char * debugstr_an(const char *s, int n)
static DWORD DWORD * dwLength
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLdouble GLdouble GLdouble r
GLint GLint GLsizei width
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
HLOCAL NTAPI LocalFree(HLOCAL hMem)
#define memcpy(s1, s2, n)
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
#define sprintf(buf, format,...)
static LPCSTR DWORD void * pvReserved
DWORD WINAPI GetLastError(void)
#define CRYPT_VERIFYCONTEXT
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
static const WCHAR MS_ENHANCED_PROV_W[]
#define ERROR_INVALID_DATA