ReactOS  0.4.13-dev-242-g611e6d7
crypt.c File Reference
#include "config.h"
#include "wine/port.h"
#include <limits.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <fcntl.h>
#include "ntstatus.h"
#include "crypt.h"
#include "winnls.h"
#include "winreg.h"
#include "rpc.h"
#include "wine/debug.h"
#include "wine/unicode.h"
#include "winternl.h"
Include dependency graph for crypt.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define CRYPT_Alloc(size)   (LocalAlloc(LMEM_ZEROINIT, size))
 
#define CRYPT_Free(buffer)   (LocalFree(buffer))
 
#define CRYPT_GetProvFunc(name)   if ( !(provider->pFuncs->p##name = (void*)GetProcAddress(provider->hModule, #name)) ) goto error
 
#define CRYPT_GetProvFuncOpt(name)   provider->pFuncs->p##name = (void*)GetProcAddress(provider->hModule, #name)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (crypt)
 
static PWSTR CRYPT_GetProvKeyName (PCWSTR pProvName)
 
static PWSTR CRYPT_GetTypeKeyName (DWORD dwType, BOOL user)
 
static BOOL CRYPT_UnicodeToANSI (LPCWSTR wstr, LPSTR *str, int strsize)
 
static BOOL CRYPT_ANSIToUnicode (LPCSTR str, LPWSTR *wstr, int wstrsize)
 
static BOOL CALLBACK CRYPT_VerifyImage (LPCSTR lpszImage, BYTE *pData)
 
static void CALLBACK CRYPT_ReturnhWnd (HWND *phWnd)
 
static PCRYPTPROV CRYPT_LoadProvider (PCWSTR pImage)
 
static void CRYPT_CreateMachineGuid (void)
 
void WINAPI CloseEncryptedFileRaw (PVOID context)
 
BOOL WINAPI CryptAcquireContextW (HCRYPTPROV *phProv, LPCWSTR pszContainer, LPCWSTR pszProvider, DWORD dwProvType, DWORD dwFlags)
 
BOOL WINAPI CryptAcquireContextA (HCRYPTPROV *phProv, LPCSTR pszContainer, LPCSTR pszProvider, DWORD dwProvType, DWORD dwFlags)
 
BOOL WINAPI CryptContextAddRef (HCRYPTPROV hProv, DWORD *pdwReserved, DWORD dwFlags)
 
BOOL WINAPI CryptReleaseContext (HCRYPTPROV hProv, ULONG_PTR dwFlags)
 
BOOL WINAPI CryptGenRandom (HCRYPTPROV hProv, DWORD dwLen, BYTE *pbBuffer)
 
BOOL WINAPI CryptCreateHash (HCRYPTPROV hProv, ALG_ID Algid, HCRYPTKEY hKey, DWORD dwFlags, HCRYPTHASH *phHash)
 
BOOL WINAPI CryptDecrypt (HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final, DWORD dwFlags, BYTE *pbData, DWORD *pdwDataLen)
 
BOOL WINAPI CryptDeriveKey (HCRYPTPROV hProv, ALG_ID Algid, HCRYPTHASH hBaseData, DWORD dwFlags, HCRYPTKEY *phKey)
 
BOOL WINAPI CryptDestroyHash (HCRYPTHASH hHash)
 
BOOL WINAPI CryptDestroyKey (HCRYPTKEY hKey)
 
BOOL WINAPI CryptDuplicateHash (HCRYPTHASH hHash, DWORD *pdwReserved, DWORD dwFlags, HCRYPTHASH *phHash)
 
BOOL WINAPI CryptDuplicateKey (HCRYPTKEY hKey, DWORD *pdwReserved, DWORD dwFlags, HCRYPTKEY *phKey)
 
BOOL WINAPI CryptEncrypt (HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final, DWORD dwFlags, BYTE *pbData, DWORD *pdwDataLen, DWORD dwBufLen)
 
BOOL WINAPI CryptEnumProvidersW (DWORD dwIndex, DWORD *pdwReserved, DWORD dwFlags, DWORD *pdwProvType, LPWSTR pszProvName, DWORD *pcbProvName)
 
BOOL WINAPI CryptEnumProvidersA (DWORD dwIndex, DWORD *pdwReserved, DWORD dwFlags, DWORD *pdwProvType, LPSTR pszProvName, DWORD *pcbProvName)
 
BOOL WINAPI CryptEnumProviderTypesW (DWORD dwIndex, DWORD *pdwReserved, DWORD dwFlags, DWORD *pdwProvType, LPWSTR pszTypeName, DWORD *pcbTypeName)
 
BOOL WINAPI CryptEnumProviderTypesA (DWORD dwIndex, DWORD *pdwReserved, DWORD dwFlags, DWORD *pdwProvType, LPSTR pszTypeName, DWORD *pcbTypeName)
 
BOOL WINAPI CryptExportKey (HCRYPTKEY hKey, HCRYPTKEY hExpKey, DWORD dwBlobType, DWORD dwFlags, BYTE *pbData, DWORD *pdwDataLen)
 
BOOL WINAPI CryptGenKey (HCRYPTPROV hProv, ALG_ID Algid, DWORD dwFlags, HCRYPTKEY *phKey)
 
BOOL WINAPI CryptGetDefaultProviderW (DWORD dwProvType, DWORD *pdwReserved, DWORD dwFlags, LPWSTR pszProvName, DWORD *pcbProvName)
 
BOOL WINAPI CryptGetDefaultProviderA (DWORD dwProvType, DWORD *pdwReserved, DWORD dwFlags, LPSTR pszProvName, DWORD *pcbProvName)
 
BOOL WINAPI CryptGetHashParam (HCRYPTHASH hHash, DWORD dwParam, BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags)
 
BOOL WINAPI CryptGetKeyParam (HCRYPTKEY hKey, DWORD dwParam, BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags)
 
BOOL WINAPI CryptGetProvParam (HCRYPTPROV hProv, DWORD dwParam, BYTE *pbData, DWORD *pdwDataLen, DWORD dwFlags)
 
BOOL WINAPI CryptGetUserKey (HCRYPTPROV hProv, DWORD dwKeySpec, HCRYPTKEY *phUserKey)
 
BOOL WINAPI CryptHashData (HCRYPTHASH hHash, const BYTE *pbData, DWORD dwDataLen, DWORD dwFlags)
 
BOOL WINAPI CryptHashSessionKey (HCRYPTHASH hHash, HCRYPTKEY hKey, DWORD dwFlags)
 
BOOL WINAPI CryptImportKey (HCRYPTPROV hProv, const BYTE *pbData, DWORD dwDataLen, HCRYPTKEY hPubKey, DWORD dwFlags, HCRYPTKEY *phKey)
 
BOOL WINAPI CryptSignHashW (HCRYPTHASH hHash, DWORD dwKeySpec, LPCWSTR sDescription, DWORD dwFlags, BYTE *pbSignature, DWORD *pdwSigLen)
 
BOOL WINAPI CryptSignHashA (HCRYPTHASH hHash, DWORD dwKeySpec, LPCSTR sDescription, DWORD dwFlags, BYTE *pbSignature, DWORD *pdwSigLen)
 
BOOL WINAPI CryptSetHashParam (HCRYPTHASH hHash, DWORD dwParam, const BYTE *pbData, DWORD dwFlags)
 
BOOL WINAPI CryptSetKeyParam (HCRYPTKEY hKey, DWORD dwParam, const BYTE *pbData, DWORD dwFlags)
 
BOOL WINAPI CryptSetProviderA (LPCSTR pszProvName, DWORD dwProvType)
 
BOOL WINAPI CryptSetProviderW (LPCWSTR pszProvName, DWORD dwProvType)
 
BOOL WINAPI CryptSetProviderExW (LPCWSTR pszProvName, DWORD dwProvType, DWORD *pdwReserved, DWORD dwFlags)
 
BOOL WINAPI CryptSetProviderExA (LPCSTR pszProvName, DWORD dwProvType, DWORD *pdwReserved, DWORD dwFlags)
 
BOOL WINAPI CryptSetProvParam (HCRYPTPROV hProv, DWORD dwParam, const BYTE *pbData, DWORD dwFlags)
 
BOOL WINAPI CryptVerifySignatureW (HCRYPTHASH hHash, const BYTE *pbSignature, DWORD dwSigLen, HCRYPTKEY hPubKey, LPCWSTR sDescription, DWORD dwFlags)
 
BOOL WINAPI CryptVerifySignatureA (HCRYPTHASH hHash, const BYTE *pbSignature, DWORD dwSigLen, HCRYPTKEY hPubKey, LPCSTR sDescription, DWORD dwFlags)
 
DWORD WINAPI OpenEncryptedFileRawA (LPCSTR filename, ULONG flags, PVOID *context)
 
DWORD WINAPI OpenEncryptedFileRawW (LPCWSTR filename, ULONG flags, PVOID *context)
 
DWORD WINAPI ReadEncryptedFileRaw (PFE_EXPORT_FUNC export, PVOID callback, PVOID context)
 
BOOL WINAPI SystemFunction030 (LPCVOID b1, LPCVOID b2)
 
BOOL WINAPI SystemFunction035 (LPCSTR lpszDllFilePath)
 
BOOLEAN WINAPI SystemFunction036 (PVOID pbBuffer, ULONG dwLen)
 
NTSTATUS WINAPI SystemFunction040 (PVOID memory, ULONG length, ULONG flags)
 
NTSTATUS WINAPI SystemFunction041 (PVOID memory, ULONG length, ULONG flags)
 
DWORD WINAPI WriteEncryptedFileRaw (PFE_IMPORT_FUNC import, PVOID callback, PVOID context)
 

Variables

static HWND crypt_hWindow
 

Macro Definition Documentation

◆ CRYPT_Alloc

#define CRYPT_Alloc (   size)    (LocalAlloc(LMEM_ZEROINIT, size))

Definition at line 61 of file crypt.c.

◆ CRYPT_Free

#define CRYPT_Free (   buffer)    (LocalFree(buffer))

Definition at line 62 of file crypt.c.

◆ CRYPT_GetProvFunc

#define CRYPT_GetProvFunc (   name)    if ( !(provider->pFuncs->p##name = (void*)GetProcAddress(provider->hModule, #name)) ) goto error

Definition at line 200 of file crypt.c.

◆ CRYPT_GetProvFuncOpt

#define CRYPT_GetProvFuncOpt (   name)    provider->pFuncs->p##name = (void*)GetProcAddress(provider->hModule, #name)

Definition at line 202 of file crypt.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 47 of file crypt.c.

Function Documentation

◆ CloseEncryptedFileRaw()

void WINAPI CloseEncryptedFileRaw ( PVOID  context)

Definition at line 338 of file crypt.c.

339 {
340  FIXME("(%p): stub\n", context);
341 }
Definition: http.c:6587
#define FIXME(fmt,...)
Definition: debug.h:110

◆ CRYPT_ANSIToUnicode()

static BOOL CRYPT_ANSIToUnicode ( LPCSTR  str,
LPWSTR wstr,
int  wstrsize 
)
inlinestatic

Definition at line 158 of file crypt.c.

159 {
160  unsigned int wcount;
161 
162  if (!str)
163  {
164  *wstr = NULL;
165  return TRUE;
166  }
167  wcount = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
168  if (wstrsize == -1)
169  *wstr = CRYPT_Alloc(wcount * sizeof(WCHAR));
170  else
171  wcount = min( wcount, wstrsize/sizeof(WCHAR) );
172  if (*wstr)
173  {
174  MultiByteToWideChar(CP_ACP, 0, str, -1, *wstr, wcount);
175  return TRUE;
176  }
178  return FALSE;
179 }
#define TRUE
Definition: types.h:120
#define CP_ACP
Definition: compat.h:99
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define CRYPT_Alloc(size)
Definition: crypt.c:61
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SetLastError(x)
Definition: compat.h:409
#define min(a, b)
Definition: monoChain.cc:55
#define MultiByteToWideChar
Definition: compat.h:100

Referenced by CryptAcquireContextA(), CryptSetProviderExA(), CryptSignHashA(), and CryptVerifySignatureA().

◆ CRYPT_CreateMachineGuid()

static void CRYPT_CreateMachineGuid ( void  )
static

Definition at line 277 of file crypt.c.

278 {
279  static const WCHAR cryptographyW[] = {
280  'S','o','f','t','w','a','r','e','\\',
281  'M','i','c','r','o','s','o','f','t','\\',
282  'C','r','y','p','t','o','g','r','a','p','h','y',0 };
283  static const WCHAR machineGuidW[] = {
284  'M','a','c','h','i','n','e','G','u','i','d',0 };
285  LONG r;
286  HKEY key;
287 
288  r = RegOpenKeyExW(HKEY_LOCAL_MACHINE, cryptographyW, 0, KEY_ALL_ACCESS,
289  &key);
290  if (!r)
291  {
292  DWORD size;
293 
294  r = RegQueryValueExW(key, machineGuidW, NULL, NULL, NULL, &size);
295  if (r == ERROR_FILE_NOT_FOUND)
296  {
297  UUID uuid;
298  WCHAR buf[37];
299  RPC_STATUS rs;
300  static const WCHAR uuidFmt[] = {
301  '%','0','8','x','-','%','0','4','x','-',
302  '%','0','4','x','-','%','0','2','x',
303  '%','0','2','x','-','%','0','2','x',
304  '%','0','2','x','%','0','2','x',
305  '%','0','2','x','%','0','2','x',
306  '%','0','2','x',0 };
307 
308  rs = UuidCreate(&uuid);
309  if (rs == S_OK)
310  {
311  sprintfW(buf, uuidFmt,
312  uuid.Data1, uuid.Data2, uuid.Data3,
313  uuid.Data4[0], uuid.Data4[1],
314  uuid.Data4[2], uuid.Data4[3],
315  uuid.Data4[4], uuid.Data4[5],
316  uuid.Data4[6], uuid.Data4[7] );
317  RegSetValueExW(key, machineGuidW, 0, REG_SZ,
318  (const BYTE *)buf,
319  (lstrlenW(buf)+1)*sizeof(WCHAR));
320  }
321  }
322  RegCloseKey(key);
323  }
324 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define lstrlenW
Definition: compat.h:407
long RPC_STATUS
Definition: rpc.h:52
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4917
GLsizeiptr size
Definition: glext.h:5919
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned char BYTE
Definition: mem.h:68
#define S_OK
Definition: intsafe.h:59
RPC_STATUS WINAPI UuidCreate(UUID *Uuid)
Definition: rpcrt4_main.c:306
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define sprintfW
Definition: unicode.h:58
Definition: msctf.idl:510
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
static const unsigned char key[key_length]
Definition: crypt.c:1004
Definition: path.c:42
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REG_SZ
Definition: layer.c:22

Referenced by CryptAcquireContextW().

◆ CRYPT_GetProvKeyName()

static PWSTR CRYPT_GetProvKeyName ( PCWSTR  pProvName)
inlinestatic

Definition at line 64 of file crypt.c.

65 {
66  static const WCHAR KEYSTR[] = {
67  'S','o','f','t','w','a','r','e','\\',
68  'M','i','c','r','o','s','o','f','t','\\',
69  'C','r','y','p','t','o','g','r','a','p','h','y','\\',
70  'D','e','f','a','u','l','t','s','\\',
71  'P','r','o','v','i','d','e','r','\\',0
72  };
73  PWSTR keyname;
74 
75  keyname = CRYPT_Alloc((strlenW(KEYSTR) + strlenW(pProvName) +1)*sizeof(WCHAR));
76  if (keyname)
77  {
78  strcpyW(keyname, KEYSTR);
79  strcpyW(keyname + strlenW(KEYSTR), pProvName);
80  } else
82  return keyname;
83 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
uint16_t * PWSTR
Definition: typedefs.h:54
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define CRYPT_Alloc(size)
Definition: crypt.c:61
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SetLastError(x)
Definition: compat.h:409
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219

Referenced by CryptAcquireContextW(), and CryptSetProviderExW().

◆ CRYPT_GetTypeKeyName()

static PWSTR CRYPT_GetTypeKeyName ( DWORD  dwType,
BOOL  user 
)
inlinestatic

Definition at line 85 of file crypt.c.

86 {
87  static const WCHAR MACHINESTR[] = {
88  'S','o','f','t','w','a','r','e','\\',
89  'M','i','c','r','o','s','o','f','t','\\',
90  'C','r','y','p','t','o','g','r','a','p','h','y','\\',
91  'D','e','f','a','u','l','t','s','\\',
92  'P','r','o','v','i','d','e','r',' ','T','y','p','e','s','\\',
93  'T','y','p','e',' ','X','X','X',0
94  };
95  static const WCHAR USERSTR[] = {
96  'S','o','f','t','w','a','r','e','\\',
97  'M','i','c','r','o','s','o','f','t','\\',
98  'C','r','y','p','t','o','g','r','a','p','h','y','\\',
99  'P','r','o','v','i','d','e','r',' ','T','y','p','e',' ','X','X','X',0
100  };
101  PWSTR keyname;
102  PWSTR ptr;
103 
104  keyname = CRYPT_Alloc( ((user ? strlenW(USERSTR) : strlenW(MACHINESTR)) +1)*sizeof(WCHAR));
105  if (keyname)
106  {
107  user ? strcpyW(keyname, USERSTR) : strcpyW(keyname, MACHINESTR);
108  ptr = keyname + strlenW(keyname);
109  *(--ptr) = (dwType % 10) + '0';
110  *(--ptr) = ((dwType / 10) % 10) + '0';
111  *(--ptr) = (dwType / 100) + '0';
112  } else
114  return keyname;
115 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
uint16_t * PWSTR
Definition: typedefs.h:54
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define CRYPT_Alloc(size)
Definition: crypt.c:61
static PVOID ptr
Definition: dispmode.c:27
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SetLastError(x)
Definition: compat.h:409
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
void user(int argc, const char *argv[])
Definition: cmds.c:1350

Referenced by CryptAcquireContextW(), CryptGetDefaultProviderW(), and CryptSetProviderExW().

◆ CRYPT_LoadProvider()

static PCRYPTPROV CRYPT_LoadProvider ( PCWSTR  pImage)
static

Definition at line 204 of file crypt.c.

205 {
206  PCRYPTPROV provider;
207  DWORD errorcode = ERROR_NOT_ENOUGH_MEMORY;
208 
209  if ( !(provider = CRYPT_Alloc(sizeof(CRYPTPROV))) ) goto error;
210  if ( !(provider->pFuncs = CRYPT_Alloc(sizeof(PROVFUNCS))) ) goto error;
211  if ( !(provider->pVTable = CRYPT_Alloc(sizeof(VTableProvStruc))) ) goto error;
212  if ( !(provider->hModule = LoadLibraryW(pImage)) )
213  {
215  FIXME("Failed to load dll %s\n", debugstr_w(pImage));
216  goto error;
217  }
218  provider->dwMagic = MAGIC_CRYPTPROV;
219  provider->refcount = 1;
220 
221  errorcode = NTE_PROVIDER_DLL_FAIL;
222  CRYPT_GetProvFunc(CPAcquireContext);
223  CRYPT_GetProvFunc(CPCreateHash);
224  CRYPT_GetProvFunc(CPDecrypt);
225  CRYPT_GetProvFunc(CPDeriveKey);
226  CRYPT_GetProvFunc(CPDestroyHash);
227  CRYPT_GetProvFunc(CPDestroyKey);
228  CRYPT_GetProvFuncOpt(CPDuplicateHash);
229  CRYPT_GetProvFuncOpt(CPDuplicateKey);
230  CRYPT_GetProvFunc(CPEncrypt);
231  CRYPT_GetProvFunc(CPExportKey);
232  CRYPT_GetProvFunc(CPGenKey);
233  CRYPT_GetProvFunc(CPGenRandom);
234  CRYPT_GetProvFunc(CPGetHashParam);
235  CRYPT_GetProvFunc(CPGetKeyParam);
236  CRYPT_GetProvFunc(CPGetProvParam);
237  CRYPT_GetProvFunc(CPGetUserKey);
238  CRYPT_GetProvFunc(CPHashData);
239  CRYPT_GetProvFunc(CPHashSessionKey);
240  CRYPT_GetProvFunc(CPImportKey);
241  CRYPT_GetProvFunc(CPReleaseContext);
242  CRYPT_GetProvFunc(CPSetHashParam);
243  CRYPT_GetProvFunc(CPSetKeyParam);
244  CRYPT_GetProvFunc(CPSetProvParam);
245  CRYPT_GetProvFunc(CPSignHash);
246  CRYPT_GetProvFunc(CPVerifySignature);
247 
248  /* FIXME: Not sure what the pbContextInfo field is for.
249  * Does it need memory allocation?
250  */
251  provider->pVTable->Version = 3;
254  provider->pVTable->dwProvType = 0;
255  provider->pVTable->pbContextInfo = NULL;
256  provider->pVTable->cbContextInfo = 0;
257  provider->pVTable->pszProvName = NULL;
258  return provider;
259 
260 error:
261  SetLastError(errorcode);
262  if (provider)
263  {
264  provider->dwMagic = 0;
265  if (provider->hModule)
266  FreeLibrary(provider->hModule);
267  CRYPT_Free(provider->pVTable);
268  CRYPT_Free(provider->pFuncs);
269  CRYPT_Free(provider);
270  }
271  return NULL;
272 }
FARPROC FuncReturnhWnd
Definition: wincrypt.h:703
#define CRYPT_Free(buffer)
Definition: crypt.c:62
#define error(str)
Definition: mkdosfs.c:1605
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define CRYPT_Alloc(size)
Definition: crypt.c:61
LPSTR pszProvName
Definition: wincrypt.h:708
#define NTE_PROVIDER_DLL_FAIL
Definition: winerror.h:2897
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
PPROVFUNCS pFuncs
Definition: crypt.h:68
#define LoadLibraryW(x)
Definition: compat.h:404
smooth NULL
Definition: ftsmooth.c:416
static void CALLBACK CRYPT_ReturnhWnd(HWND *phWnd)
Definition: crypt.c:195
#define MAGIC_CRYPTPROV
Definition: crypt.h:59
UINT refcount
Definition: crypt.h:66
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
PVTableProvStruc pVTable
Definition: crypt.h:70
HMODULE hModule
Definition: crypt.h:67
FARPROC FuncVerifyImage
Definition: wincrypt.h:702
#define FreeLibrary(x)
Definition: compat.h:405
#define CRYPT_GetProvFunc(name)
Definition: crypt.c:200
static BOOL CALLBACK CRYPT_VerifyImage(LPCSTR lpszImage, BYTE *pData)
Definition: crypt.c:182
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
DWORD cbContextInfo
Definition: wincrypt.h:707
DWORD dwMagic
Definition: crypt.h:65
#define CRYPT_GetProvFuncOpt(name)
Definition: crypt.c:202
#define NTE_PROV_DLL_NOT_FOUND
Definition: winerror.h:2898
DWORD dwProvType
Definition: wincrypt.h:705
BYTE * pbContextInfo
Definition: wincrypt.h:706

Referenced by CryptAcquireContextW().

◆ CRYPT_ReturnhWnd()

static void CALLBACK CRYPT_ReturnhWnd ( HWND phWnd)
static

Definition at line 195 of file crypt.c.

196 {
197  if (phWnd) *phWnd = crypt_hWindow;
198 }
static HWND crypt_hWindow
Definition: crypt.c:59

Referenced by CRYPT_LoadProvider().

◆ CRYPT_UnicodeToANSI()

static BOOL CRYPT_UnicodeToANSI ( LPCWSTR  wstr,
LPSTR str,
int  strsize 
)
inlinestatic

Definition at line 125 of file crypt.c.

126 {
127  if (!wstr)
128  {
129  *str = NULL;
130  return TRUE;
131  }
132 
133  if (!*str)
134  {
135  strsize = WideCharToMultiByte(CP_ACP, 0, wstr, -1, NULL, 0, NULL, NULL);
136  *str = CRYPT_Alloc(strsize * sizeof(CHAR));
137  }
138  else if (strsize < 0)
139  {
140  strsize = INT_MAX; /* windows will pretend that the buffer is infinitely long */
141  }
142 
143  if (*str)
144  {
145  WideCharToMultiByte(CP_ACP, 0, wstr, -1, *str, strsize, NULL, NULL);
146  return TRUE;
147  }
148 
150  return FALSE;
151 }
#define TRUE
Definition: types.h:120
#define WideCharToMultiByte
Definition: compat.h:101
#define INT_MAX
Definition: limits.h:40
#define CP_ACP
Definition: compat.h:99
char CHAR
Definition: xmlstorage.h:175
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define CRYPT_Alloc(size)
Definition: crypt.c:61
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:409

Referenced by CryptAcquireContextW(), CryptEnumProvidersA(), CryptEnumProviderTypesA(), and CryptGetDefaultProviderA().

◆ CRYPT_VerifyImage()

static BOOL CALLBACK CRYPT_VerifyImage ( LPCSTR  lpszImage,
BYTE pData 
)
static

Definition at line 182 of file crypt.c.

183 {
184  if (!lpszImage || !pData)
185  {
187  return FALSE;
188  }
189 
190  FIXME("(%s, %p): not verifying image\n", lpszImage, pData);
191 
192  return TRUE;
193 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define FIXME(fmt,...)
Definition: debug.h:110
#define SetLastError(x)
Definition: compat.h:409
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827

Referenced by CRYPT_LoadProvider().

◆ CryptAcquireContextA()

BOOL WINAPI CryptAcquireContextA ( HCRYPTPROV phProv,
LPCSTR  pszContainer,
LPCSTR  pszProvider,
DWORD  dwProvType,
DWORD  dwFlags 
)

Definition at line 569 of file crypt.c.

571 {
572  PWSTR pProvider = NULL, pContainer = NULL;
573  BOOL ret = FALSE;
574 
575  TRACE("(%p, %s, %s, %d, %08x)\n", phProv, debugstr_a(pszContainer),
576  debugstr_a(pszProvider), dwProvType, dwFlags);
577 
578  if ( !CRYPT_ANSIToUnicode(pszContainer, &pContainer, -1) )
579  {
581  return FALSE;
582  }
583  if ( !CRYPT_ANSIToUnicode(pszProvider, &pProvider, -1) )
584  {
585  CRYPT_Free(pContainer);
587  return FALSE;
588  }
589 
590  ret = CryptAcquireContextW(phProv, pContainer, pProvider, dwProvType, dwFlags);
591 
592  CRYPT_Free(pContainer);
593  CRYPT_Free(pProvider);
594 
595  return ret;
596 }
#define CRYPT_Free(buffer)
Definition: crypt.c:62
static BOOL CRYPT_ANSIToUnicode(LPCSTR str, LPWSTR *wstr, int wstrsize)
Definition: crypt.c:158
uint16_t * PWSTR
Definition: typedefs.h:54
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
BOOL WINAPI CryptAcquireContextW(HCRYPTPROV *phProv, LPCWSTR pszContainer, LPCWSTR pszProvider, DWORD dwProvType, DWORD dwFlags)
Definition: crypt.c:358
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
#define SetLastError(x)
Definition: compat.h:409
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175

Referenced by assembly_get_pubkey_token(), clean_up_aes_environment(), clean_up_base_environment(), CRYPT_CreateKeyProv(), init_aes_environment(), init_base_environment(), init_function_pointers(), test_container_sd(), test_hashes(), test_key_initialization(), test_null_provider(), test_rsa_round_trip(), test_schannel_provider(), and testPortPublicKeyInfo().

◆ CryptAcquireContextW()

BOOL WINAPI CryptAcquireContextW ( HCRYPTPROV phProv,
LPCWSTR  pszContainer,
LPCWSTR  pszProvider,
DWORD  dwProvType,
DWORD  dwFlags 
)

Definition at line 358 of file crypt.c.

360 {
361  PCRYPTPROV pProv = NULL;
362  HKEY key;
363  PWSTR imagepath = NULL, keyname = NULL, provname = NULL, temp = NULL;
364  PSTR provnameA = NULL, pszContainerA = NULL;
365  DWORD keytype, type, len;
366  ULONG r;
367  static const WCHAR nameW[] = {'N','a','m','e',0};
368  static const WCHAR typeW[] = {'T','y','p','e',0};
369  static const WCHAR imagepathW[] = {'I','m','a','g','e',' ','P','a','t','h',0};
370 
371  TRACE("(%p, %s, %s, %d, %08x)\n", phProv, debugstr_w(pszContainer),
372  debugstr_w(pszProvider), dwProvType, dwFlags);
373 
374  if (dwProvType < 1 || dwProvType > MAXPROVTYPES)
375  {
377  return FALSE;
378  }
379 
380  if (!phProv)
381  {
383  return FALSE;
384  }
385 
386  /* Make sure the MachineGuid value exists */
388 
389  if (!pszProvider || !*pszProvider)
390  {
391  /* No CSP name specified so try the user default CSP first
392  * then try the machine default CSP
393  */
394  if ( !(keyname = CRYPT_GetTypeKeyName(dwProvType, TRUE)) ) {
395  TRACE("No provider registered for crypto provider type %d.\n", dwProvType);
397  return FALSE;
398  }
399  if (RegOpenKeyW(HKEY_CURRENT_USER, keyname, &key))
400  {
401  CRYPT_Free(keyname);
402  if ( !(keyname = CRYPT_GetTypeKeyName(dwProvType, FALSE)) ) {
403  TRACE("No type registered for crypto provider type %d.\n", dwProvType);
404  RegCloseKey(key);
406  goto error;
407  }
408  if (RegOpenKeyW(HKEY_LOCAL_MACHINE, keyname, &key)) {
409  TRACE("Did not find registry entry of crypto provider for %s.\n", debugstr_w(keyname));
410  CRYPT_Free(keyname);
411  RegCloseKey(key);
413  goto error;
414  }
415  }
416  CRYPT_Free(keyname);
417  r = RegQueryValueExW(key, nameW, NULL, &keytype, NULL, &len);
418  if( r != ERROR_SUCCESS || !len || keytype != REG_SZ)
419  {
420  TRACE("error %d reading size of 'Name' from registry\n", r );
421  RegCloseKey(key);
423  goto error;
424  }
425  if(!(provname = CRYPT_Alloc(len)))
426  {
427  RegCloseKey(key);
429  goto error;
430  }
431  r = RegQueryValueExW(key, nameW, NULL, NULL, (LPBYTE)provname, &len);
432  if( r != ERROR_SUCCESS )
433  {
434  TRACE("error %d reading 'Name' from registry\n", r );
435  RegCloseKey(key);
437  goto error;
438  }
439  RegCloseKey(key);
440  } else {
441  if ( !(provname = CRYPT_Alloc((strlenW(pszProvider) +1)*sizeof(WCHAR))) )
442  {
444  goto error;
445  }
446  strcpyW(provname, pszProvider);
447  }
448 
449  keyname = CRYPT_GetProvKeyName(provname);
450  r = RegOpenKeyW(HKEY_LOCAL_MACHINE, keyname, &key);
451  CRYPT_Free(keyname);
452  if (r != ERROR_SUCCESS)
453  {
455  goto error;
456  }
457  len = sizeof(DWORD);
459  if (r != ERROR_SUCCESS)
460  {
462  goto error;
463  }
464  if (type != dwProvType)
465  {
466  TRACE("Crypto provider has wrong type (%d vs expected %d).\n", type, dwProvType);
468  goto error;
469  }
470 
471  r = RegQueryValueExW(key, imagepathW, NULL, &keytype, NULL, &len);
472  if ( r != ERROR_SUCCESS || keytype != REG_SZ)
473  {
474  TRACE("error %d reading size of 'Image Path' from registry\n", r );
475  RegCloseKey(key);
477  goto error;
478  }
479  if (!(temp = CRYPT_Alloc(len)))
480  {
481  RegCloseKey(key);
483  goto error;
484  }
485  r = RegQueryValueExW(key, imagepathW, NULL, NULL, (LPBYTE)temp, &len);
486  if( r != ERROR_SUCCESS )
487  {
488  TRACE("error %d reading 'Image Path' from registry\n", r );
489  RegCloseKey(key);
491  goto error;
492  }
493  RegCloseKey(key);
495  if ( !(imagepath = CRYPT_Alloc(len*sizeof(WCHAR))) )
496  {
498  goto error;
499  }
500  if (!ExpandEnvironmentStringsW(temp, imagepath, len))
501  {
502  /* ExpandEnvironmentStrings will call SetLastError */
503  goto error;
504  }
505  pProv = CRYPT_LoadProvider(imagepath);
506  if (!pProv) {
507  /* CRYPT_LoadProvider calls SetLastError */
508  goto error;
509  }
510  pProv->pVTable->dwProvType = dwProvType;
511  if(!CRYPT_UnicodeToANSI(provname, &provnameA, 0))
512  {
513  /* CRYPT_UnicodeToANSI calls SetLastError */
514  goto error;
515  }
516  pProv->pVTable->pszProvName = provnameA;
517  if(!CRYPT_UnicodeToANSI(pszContainer, &pszContainerA, 0))
518  {
519  /* CRYPT_UnicodeToANSI calls SetLastError */
520  goto error;
521  }
522  if (pProv->pFuncs->pCPAcquireContext(&pProv->hPrivate, pszContainerA, dwFlags, pProv->pVTable))
523  {
524  /* MSDN: When this flag is set, the value returned in phProv is undefined,
525  * and thus, the CryptReleaseContext function need not be called afterwards.
526  * Therefore, we must clean up everything now.
527  */
529  {
530  pProv->dwMagic = 0;
531  FreeLibrary(pProv->hModule);
532  CRYPT_Free(provnameA);
533  CRYPT_Free(pProv->pVTable);
534  CRYPT_Free(pProv->pFuncs);
535  CRYPT_Free(pProv);
536  } else {
537  *phProv = (HCRYPTPROV)pProv;
538  }
539  CRYPT_Free(pszContainerA);
540  CRYPT_Free(provname);
541  CRYPT_Free(temp);
542  CRYPT_Free(imagepath);
543  return TRUE;
544  }
545  /* FALLTHROUGH TO ERROR IF FALSE - CSP internal error! */
546 error:
547  if (pProv)
548  {
549  pProv->dwMagic = 0;
550  if (pProv->hModule)
551  FreeLibrary(pProv->hModule);
552  CRYPT_Free(pProv->pVTable);
553  CRYPT_Free(pProv->pFuncs);
554  CRYPT_Free(pProv);
555  }
556  CRYPT_Free(pszContainerA);
557  CRYPT_Free(provnameA);
558  CRYPT_Free(provname);
559  CRYPT_Free(temp);
560  CRYPT_Free(imagepath);
561  return FALSE;
562 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define MAXPROVTYPES
Definition: crypt.h:87
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define ERROR_SUCCESS
Definition: deptool.c:10
#define CRYPT_Free(buffer)
Definition: crypt.c:62
#define error(str)
Definition: mkdosfs.c:1605
uint16_t * PWSTR
Definition: typedefs.h:54
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define HKEY_CURRENT_USER
Definition: winreg.h:11
static const WCHAR typeW[]
Definition: name.c:49
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define CRYPT_Alloc(size)
Definition: crypt.c:61
static PWSTR CRYPT_GetProvKeyName(PCWSTR pProvName)
Definition: crypt.c:64
static DWORD
Definition: crypt.c:45
#define NTE_PROV_TYPE_NOT_DEF
Definition: winerror.h:2891
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
HCRYPTPROV hPrivate
Definition: crypt.h:69
static HCRYPTPROV
Definition: crypt.c:107
LPSTR pszProvName
Definition: wincrypt.h:708
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3311
#define debugstr_w
Definition: kernel32.h:32
PPROVFUNCS pFuncs
Definition: crypt.h:68
smooth NULL
Definition: ftsmooth.c:416
PVTableProvStruc pVTable
Definition: crypt.h:70
HMODULE hModule
Definition: crypt.h:67
static const WCHAR nameW[]
Definition: main.c:46
#define TRACE(s)
Definition: solgame.cpp:4
#define FreeLibrary(x)
Definition: compat.h:405
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NTE_BAD_PROV_TYPE
Definition: winerror.h:2888
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
static void CRYPT_CreateMachineGuid(void)
Definition: crypt.c:277
#define NTE_PROV_TYPE_NO_MATCH
Definition: winerror.h:2895
DWORD dwMagic
Definition: crypt.h:65
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
#define NTE_KEYSET_NOT_DEF
Definition: winerror.h:2893
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
static PCRYPTPROV CRYPT_LoadProvider(PCWSTR pImage)
Definition: crypt.c:204
static calc_node_t temp
Definition: rpn_ieee.c:38
signed char * PSTR
Definition: retypes.h:7
static PWSTR CRYPT_GetTypeKeyName(DWORD dwType, BOOL user)
Definition: crypt.c:85
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
static BOOL CRYPT_UnicodeToANSI(LPCWSTR wstr, LPSTR *str, int strsize)
Definition: crypt.c:125
#define CRYPT_DELETEKEYSET
Definition: wincrypt.h:2071
unsigned int ULONG
Definition: retypes.h:1
DWORD dwProvType
Definition: wincrypt.h:705
static const unsigned char key[key_length]
Definition: crypt.c:1004
Definition: path.c:42
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define NTE_PROV_TYPE_ENTRY_BAD
Definition: winerror.h:2892
#define REG_SZ
Definition: layer.c:22

Referenced by CertCreateSelfSignCertificate(), CRYPT_AcquirePrivateKeyFromProvInfo(), CRYPT_GetDefaultProvider(), CryptAcquireContextA(), CryptCATAdminCalcHashFromFileHandle(), CryptCATAdminEnumCatalogFromHash(), CryptProtectData(), CryptUnprotectData(), DllRegisterServer(), export_acquire_private_key(), find_key_prov_info_in_provider(), I_CryptGetDefaultCryptProv(), init_function_pointers(), key_prov_info_matches_cert(), save_pfx(), SOFTPUB_VerifyImageHash(), START_TEST(), and testAcquireSecurityContext().

◆ CryptContextAddRef()

BOOL WINAPI CryptContextAddRef ( HCRYPTPROV  hProv,
DWORD pdwReserved,
DWORD  dwFlags 
)

Definition at line 613 of file crypt.c.

614 {
615  PCRYPTPROV pProv = (PCRYPTPROV)hProv;
616 
617  TRACE("(0x%lx, %p, %08x)\n", hProv, pdwReserved, dwFlags);
618 
619  if (!pProv)
620  {
622  return FALSE;
623  }
624 
625  if (pProv->dwMagic != MAGIC_CRYPTPROV)
626  {
628  return FALSE;
629  }
630 
631  pProv->refcount++;
632  return TRUE;
633 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
static HCRYPTPROV hProv
Definition: rsaenh.c:32
struct tagCRYPTPROV * PCRYPTPROV
#define MAGIC_CRYPTPROV
Definition: crypt.h:59
UINT refcount
Definition: crypt.h:66
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
DWORD dwMagic
Definition: crypt.h:65
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
_Reserved_ DWORD * pdwReserved
Definition: wincrypt.h:4254
#define NTE_BAD_UID
Definition: winerror.h:2869

Referenced by I_CryptGetDefaultCryptProv().

◆ CryptCreateHash()

BOOL WINAPI CryptCreateHash ( HCRYPTPROV  hProv,
ALG_ID  Algid,
HCRYPTKEY  hKey,
DWORD  dwFlags,
HCRYPTHASH phHash 
)

Definition at line 745 of file crypt.c.

747 {
748  PCRYPTPROV prov = (PCRYPTPROV)hProv;
749  PCRYPTKEY key = (PCRYPTKEY)hKey;
751 
752  TRACE("(0x%lx, 0x%x, 0x%lx, %08x, %p)\n", hProv, Algid, hKey, dwFlags, phHash);
753 
754  if (!prov || !phHash || prov->dwMagic != MAGIC_CRYPTPROV ||
755  (key && key->dwMagic != MAGIC_CRYPTKEY))
756  {
758  return FALSE;
759  }
760  if (dwFlags)
761  {
763  return FALSE;
764  }
765  if ( !(hash = CRYPT_Alloc(sizeof(CRYPTHASH))) )
766  {
768  return FALSE;
769  }
770 
771  hash->pProvider = prov;
772  hash->dwMagic = MAGIC_CRYPTHASH;
773  if (prov->pFuncs->pCPCreateHash(prov->hPrivate, Algid,
774  key ? key->hPrivate : 0, 0, &hash->hPrivate))
775  {
776  *phHash = (HCRYPTHASH)hash;
777  return TRUE;
778  }
779 
780  /* CSP error! */
781  hash->dwMagic = 0;
782  CRYPT_Free(hash);
783  *phHash = 0;
784  return FALSE;
785 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define CRYPT_Free(buffer)
Definition: crypt.c:62
struct tagCRYPTKEY * PCRYPTKEY
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define MAGIC_CRYPTHASH
Definition: crypt.h:61
#define CRYPT_Alloc(size)
Definition: crypt.c:61
static HCRYPTPROV hProv
Definition: rsaenh.c:32
#define MAGIC_CRYPTKEY
Definition: crypt.h:60
struct tagCRYPTPROV * PCRYPTPROV
int hash
Definition: main.c:58
HCRYPTPROV hPrivate
Definition: crypt.h:69
PPROVFUNCS pFuncs
Definition: crypt.h:68
#define MAGIC_CRYPTPROV
Definition: crypt.h:59
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
DWORD dwMagic
Definition: crypt.h:65
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define NTE_BAD_FLAGS
Definition: winerror.h:2877
Definition: _hash_fun.h:40
static HCRYPTHASH
Definition: crypt.c:57
Definition: path.c:42

Referenced by assembly_get_pubkey_token(), CDecodeMsg_FinalizeHashedContent(), CHashEncodeMsg_Open(), create_silly_rename(), CRYPT_VerifySignature(), CryptCATAdminCalcHashFromFileHandle(), CryptHashCertificate(), CryptHashPublicKeyInfo(), CryptHashToBeSigned(), CryptProtectData(), CryptSignCertificate(), CryptUnprotectData(), CSignedMsgData_ConstructSignerHandles(), derive_key(), hash_dib(), load_encryption_key(), nfs41_client_owner(), rdssl_hash_clear(), rdssl_hash_info_create(), rdssl_hmac_md5(), SOFTPUB_VerifyImageHash(), test_hashes(), test_hmac(), test_import_hmac(), test_key_derivation(), test_mac(), test_rc2(), test_rc4(), test_schannel_provider(), test_sha2(), test_verify_signature(), and verifySig().

◆ CryptDecrypt()

BOOL WINAPI CryptDecrypt ( HCRYPTKEY  hKey,
HCRYPTHASH  hHash,
BOOL  Final,
DWORD  dwFlags,
BYTE pbData,
DWORD pdwDataLen 
)

Definition at line 805 of file crypt.c.

807 {
808  PCRYPTPROV prov;
809  PCRYPTKEY key = (PCRYPTKEY)hKey;
811 
812  TRACE("(0x%lx, 0x%lx, %d, %08x, %p, %p)\n", hKey, hHash, Final, dwFlags, pbData, pdwDataLen);
813 
814  if (!key || !pbData || !pdwDataLen ||
815  !key->pProvider || key->dwMagic != MAGIC_CRYPTKEY ||
816  key->pProvider->dwMagic != MAGIC_CRYPTPROV)
817  {
819  return FALSE;
820  }
821 
822  prov = key->pProvider;
823  return prov->pFuncs->pCPDecrypt(prov->hPrivate, key->hPrivate, hash ? hash->hPrivate : 0,
825 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
_In_ HCRYPTHASH hHash
Definition: wincrypt.h:4198
struct tagCRYPTKEY * PCRYPTKEY
#define MAGIC_CRYPTKEY
Definition: crypt.h:60
HCRYPTPROV hPrivate
Definition: crypt.h:69
PPROVFUNCS pFuncs
Definition: crypt.h:68
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_updates_bytes_to_ pdwDataLen BYTE _Inout_ DWORD * pdwDataLen
Definition: wincrypt.h:4201
#define MAGIC_CRYPTPROV
Definition: crypt.h:59
struct tagCRYPTHASH * PCRYPTHASH
#define TRACE(s)
Definition: solgame.cpp:4
_In_ HCRYPTHASH _In_ BOOL Final
Definition: wincrypt.h:4198
#define SetLastError(x)
Definition: compat.h:409
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
Definition: _hash_fun.h:40
Definition: path.c:42
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_updates_bytes_to_ pdwDataLen BYTE * pbData
Definition: wincrypt.h:4201

Referenced by CDecodeEnvelopedMsg_CrtlDecrypt(), CryptUnprotectData(), test_3des(), test_3des112(), test_aes(), test_block_cipher_modes(), test_des(), test_import_private(), test_rc2(), test_rc4(), test_rsa_encrypt(), and test_rsa_round_trip().

◆ CryptDeriveKey()

BOOL WINAPI CryptDeriveKey ( HCRYPTPROV  hProv,
ALG_ID  Algid,
HCRYPTHASH  hBaseData,
DWORD  dwFlags,
HCRYPTKEY phKey 
)

Definition at line 843 of file crypt.c.

845 {
846  PCRYPTPROV prov = (PCRYPTPROV)hProv;
847  PCRYPTHASH hash = (PCRYPTHASH)hBaseData;
848  PCRYPTKEY key;
849 
850  TRACE("(0x%lx, 0x%08x, 0x%lx, 0x%08x, %p)\n", hProv, Algid, hBaseData, dwFlags, phKey);
851 
852  if (!prov || !hash)
853  {
855  return FALSE;
856  }
857  if (!phKey || prov->dwMagic != MAGIC_CRYPTPROV || hash->dwMagic != MAGIC_CRYPTHASH)
858  {
860  return FALSE;
861  }
862  if ( !(key = CRYPT_Alloc(sizeof(CRYPTKEY))) )
863  {
865  return FALSE;
866  }
867 
868  key->pProvider = prov;
869  key->dwMagic = MAGIC_CRYPTKEY;
870  if (prov->pFuncs->pCPDeriveKey(prov->hPrivate, Algid, hash->hPrivate, dwFlags, &key->hPrivate))
871  {
872  *phKey = (HCRYPTKEY)key;
873  return TRUE;
874  }
875 
876  /* CSP error! */
877  key->dwMagic = 0;
878  CRYPT_Free(key);
879  *phKey = 0;
880  return FALSE;
881 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define CRYPT_Free(buffer)
Definition: crypt.c:62
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define MAGIC_CRYPTHASH
Definition: crypt.h:61
#define CRYPT_Alloc(size)
Definition: crypt.c:61
static HCRYPTPROV hProv
Definition: rsaenh.c:32
#define MAGIC_CRYPTKEY
Definition: crypt.h:60
struct tagCRYPTPROV * PCRYPTPROV
HCRYPTPROV hPrivate
Definition: crypt.h:69
PPROVFUNCS pFuncs
Definition: crypt.h:68
#define MAGIC_CRYPTPROV
Definition: crypt.h:59
struct tagCRYPTHASH * PCRYPTHASH
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
DWORD dwMagic
Definition: crypt.h:65
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static HCRYPTKEY
Definition: crypt.c:51
Definition: _hash_fun.h:40
static const unsigned char key[key_length]
Definition: crypt.c:1004
Definition: path.c:42

Referenced by derive_key(), load_encryption_key(), test_key_derivation(), test_rc2(), test_rc4(), and test_schannel_provider().

◆ CryptDestroyHash()

BOOL WINAPI CryptDestroyHash ( HCRYPTHASH  hHash)

Definition at line 895 of file crypt.c.

896 {
898  PCRYPTPROV prov;
899  BOOL ret;
900 
901  TRACE("(0x%lx)\n", hHash);
902 
903  if (!hash)
904  {
906  return FALSE;
907  }
908 
909  if (!hash->pProvider || hash->dwMagic != MAGIC_CRYPTHASH ||
910  hash->pProvider->dwMagic != MAGIC_CRYPTPROV)
911  {
913  return FALSE;
914  }
915 
916  prov = hash->pProvider;
917  ret = prov->pFuncs->pCPDestroyHash(prov->hPrivate, hash->hPrivate);
918  hash->dwMagic = 0;
919  CRYPT_Free(hash);
920  return ret;
921 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define CRYPT_Free(buffer)
Definition: crypt.c:62
_In_ HCRYPTHASH hHash
Definition: wincrypt.h:4198
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define MAGIC_CRYPTHASH
Definition: crypt.h:61
unsigned int BOOL
Definition: ntddk_ex.h:94
HCRYPTPROV hPrivate
Definition: crypt.h:69
PPROVFUNCS pFuncs
Definition: crypt.h:68
#define MAGIC_CRYPTPROV
Definition: crypt.h:59
struct tagCRYPTHASH * PCRYPTHASH
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
int ret
Definition: _hash_fun.h:40

Referenced by assembly_get_pubkey_token(), CDecodeMsg_Close(), CHashEncodeMsg_Close(), create_silly_rename(), CRYPT_VerifySignature(), CryptCATAdminCalcHashFromFileHandle(), CryptHashCertificate(), CryptHashPublicKeyInfo(), CryptHashToBeSigned(), CryptProtectData(), CryptSignCertificate(), CryptUnprotectData(), CSignedMsgData_CloseHandles(), derive_key(), hash_dib(), load_encryption_key(), nfs41_client_owner(), rdssl_hash_clear(), rdssl_hash_info_delete(), rdssl_hmac_md5(), SOFTPUB_VerifyImageHash(), test_hashes(), test_hmac(), test_import_hmac(), test_key_derivation(), test_mac(), test_rc2(), test_rc4(), test_schannel_provider(), test_sha2(), test_verify_signature(), and verifySig().

◆ CryptDestroyKey()

BOOL WINAPI CryptDestroyKey ( HCRYPTKEY  hKey)

Definition at line 935 of file crypt.c.

936 {
937  PCRYPTKEY key = (PCRYPTKEY)hKey;
938  PCRYPTPROV prov;
939  BOOL ret;
940 
941  TRACE("(0x%lx)\n", hKey);
942 
943  if (!key)
944  {
946  return FALSE;
947  }
948 
949  if (!key->pProvider || key->dwMagic != MAGIC_CRYPTKEY ||
950  key->pProvider->dwMagic != MAGIC_CRYPTPROV)
951  {
953  return FALSE;
954  }
955 
956  prov = key->pProvider;
957  ret = prov->pFuncs->pCPDestroyKey(prov->hPrivate, key->hPrivate);
958  key->dwMagic = 0;
959  CRYPT_Free(key);
960  return ret;
961 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define CRYPT_Free(buffer)
Definition: crypt.c:62
struct tagCRYPTKEY * PCRYPTKEY
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define MAGIC_CRYPTKEY
Definition: crypt.h:60
unsigned int BOOL
Definition: ntddk_ex.h:94
HCRYPTPROV hPrivate
Definition: crypt.h:69
PPROVFUNCS pFuncs
Definition: crypt.h:68
#define MAGIC_CRYPTPROV
Definition: crypt.h:59
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
int ret
Definition: path.c:42

Referenced by CDecodeEnvelopedMsg_CrtlDecrypt(), CDecodeSignedMsg_VerifySignatureWithKey(), CEnvelopedEncodeMsg_Close(), CertCreateSelfSignCertificate(), CertGetPublicKeyLength(), CRYPT_CreateKeyProv(), CRYPT_ExportKeyTrans(), CRYPT_ExportPublicKeyInfoEx(), CRYPT_ImportKeyTrans(), CRYPT_VerifySignature(), CryptProtectData(), CryptUnprotectData(), export_is_key_exportable(), init_aes_environment(), init_base_environment(), rdssl_cert_to_rkey(), rdssl_rc4_info_delete(), rdssl_rc4_set_key(), test_3des(), test_3des112(), test_aes(), test_block_cipher_modes(), test_decode_msg_get_param(), test_des(), test_hashes(), test_hmac(), test_import_export(), test_import_hmac(), test_import_private(), test_key_derivation(), test_key_initialization(), test_key_permissions(), test_mac(), test_null_provider(), test_rc2(), test_rc4(), test_rsa_encrypt(), test_rsa_round_trip(), test_schannel_provider(), test_sign_message(), test_signed_msg_encoding(), test_signed_msg_update(), test_verify_signature(), testAcquireCertPrivateKey(), testAcquireSecurityContext(), testCreateSelfSignCert(), testExportPublicKey(), testImportPublicKey(), and testSignCert().

◆ CryptDuplicateHash()

BOOL WINAPI CryptDuplicateHash ( HCRYPTHASH  hHash,
DWORD pdwReserved,
DWORD  dwFlags,
HCRYPTHASH phHash 
)

Definition at line 978 of file crypt.c.

980 {
981  PCRYPTPROV prov;
982  PCRYPTHASH orghash, newhash;
983 
984  TRACE("(0x%lx, %p, %08x, %p)\n", hHash, pdwReserved, dwFlags, phHash);
985 
986  orghash = (PCRYPTHASH)hHash;
987  if (!orghash || pdwReserved || !phHash || !orghash->pProvider ||
988  orghash->dwMagic != MAGIC_CRYPTHASH || orghash->pProvider->dwMagic != MAGIC_CRYPTPROV)
989  {
991  return FALSE;
992  }
993 
994  prov = orghash->pProvider;
995  if (!prov->pFuncs->pCPDuplicateHash)
996  {
998  return FALSE;
999  }
1000 
1001  if ( !(newhash = CRYPT_Alloc(sizeof(CRYPTHASH))) )
1002  {
1004  return FALSE;
1005  }
1006 
1007  newhash->pProvider = prov;
1008  newhash->dwMagic = MAGIC_CRYPTHASH;
1009  if (prov->pFuncs->pCPDuplicateHash(prov->hPrivate, orghash->hPrivate, pdwReserved, dwFlags, &newhash->hPrivate))
1010  {
1011  *phHash = (HCRYPTHASH)newhash;
1012  return TRUE;
1013  }
1014  newhash->dwMagic = 0;
1015  CRYPT_Free(newhash);
1016  return FALSE;
1017 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
PCRYPTPROV pProvider
Definition: crypt.h:83
#define TRUE
Definition: types.h:120
#define CRYPT_Free(buffer)
Definition: crypt.c:62
_In_ HCRYPTHASH hHash
Definition: wincrypt.h:4198
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define MAGIC_CRYPTHASH
Definition: crypt.h:61
#define CRYPT_Alloc(size)
Definition: crypt.c:61
HCRYPTPROV hPrivate
Definition: crypt.h:69
PPROVFUNCS pFuncs
Definition: crypt.h:68
#define MAGIC_CRYPTPROV
Definition: crypt.h:59
struct tagCRYPTHASH * PCRYPTHASH
#define TRACE(s)
Definition: solgame.cpp:4
DWORD dwMagic
Definition: crypt.h:82
#define SetLastError(x)
Definition: compat.h:409
DWORD dwMagic
Definition: crypt.h:65
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
_Reserved_ DWORD * pdwReserved
Definition: wincrypt.h:4254
HCRYPTHASH hPrivate
Definition: crypt.h:84
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
static HCRYPTHASH
Definition: crypt.c:57

◆ CryptDuplicateKey()

BOOL WINAPI CryptDuplicateKey ( HCRYPTKEY  hKey,
DWORD pdwReserved,
DWORD  dwFlags,
HCRYPTKEY phKey 
)

Definition at line 1034 of file crypt.c.

1035 {
1036  PCRYPTPROV prov;
1037  PCRYPTKEY orgkey, newkey;
1038 
1039  TRACE("(0x%lx, %p, %08x, %p)\n", hKey, pdwReserved, dwFlags, phKey);
1040 
1041  orgkey = (PCRYPTKEY)hKey;
1042  if (!orgkey || pdwReserved || !phKey || !orgkey->pProvider ||
1043  orgkey->dwMagic != MAGIC_CRYPTKEY ||
1044  orgkey->pProvider->dwMagic != MAGIC_CRYPTPROV)
1045  {
1047  return FALSE;
1048  }
1049 
1050  prov = orgkey->pProvider;
1051  if (!prov->pFuncs->pCPDuplicateKey)
1052  {
1054  return FALSE;
1055  }
1056 
1057  if ( !(newkey = CRYPT_Alloc(sizeof(CRYPTKEY))) )
1058  {
1060  return FALSE;
1061  }
1062 
1063  newkey->pProvider = prov;
1064  newkey->dwMagic = MAGIC_CRYPTKEY;
1065  if (prov->pFuncs->pCPDuplicateKey(prov->hPrivate, orgkey->hPrivate, pdwReserved, dwFlags, &newkey->hPrivate))
1066  {
1067  *phKey = (HCRYPTKEY)newkey;
1068  return TRUE;
1069  }
1070  newkey->dwMagic = 0;
1071  CRYPT_Free(newkey);
1072  return FALSE;
1073 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define CRYPT_Free(buffer)
Definition: crypt.c:62
struct tagCRYPTKEY * PCRYPTKEY
HCRYPTKEY hPrivate
Definition: crypt.h:77
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define CRYPT_Alloc(size)
Definition: crypt.c:61
#define MAGIC_CRYPTKEY
Definition: crypt.h:60
HCRYPTPROV hPrivate
Definition: crypt.h:69
PPROVFUNCS pFuncs
Definition: crypt.h:68
#define MAGIC_CRYPTPROV
Definition: crypt.h:59
PCRYPTPROV pProvider
Definition: crypt.h:76
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
DWORD dwMagic
Definition: crypt.h:65
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
_Reserved_ DWORD * pdwReserved
Definition: wincrypt.h:4254
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
static HCRYPTKEY
Definition: crypt.c:51
DWORD dwMagic
Definition: crypt.h:75

◆ CryptEncrypt()

BOOL WINAPI CryptEncrypt ( HCRYPTKEY  hKey,
HCRYPTHASH  hHash,
BOOL  Final,
DWORD  dwFlags,
BYTE pbData,
DWORD pdwDataLen,
DWORD  dwBufLen 
)

Definition at line 1098 of file crypt.c.

1100 {
1101  PCRYPTPROV prov;
1102  PCRYPTKEY key = (PCRYPTKEY)hKey;
1104 
1105  TRACE("(0x%lx, 0x%lx, %d, %08x, %p, %p, %d)\n", hKey, hHash, Final, dwFlags, pbData, pdwDataLen, dwBufLen);
1106 
1107  if (!key || !pdwDataLen || !key->pProvider ||
1108  key->dwMagic != MAGIC_CRYPTKEY || key->pProvider->dwMagic != MAGIC_CRYPTPROV)
1109  {
1111  return FALSE;
1112  }
1113 
1114  prov = key->pProvider;
1115  return prov->pFuncs->pCPEncrypt(prov->hPrivate, key->hPrivate, hash ? hash->hPrivate : 0,
1117 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
_In_ HCRYPTHASH hHash
Definition: wincrypt.h:4198
struct tagCRYPTKEY * PCRYPTKEY
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_ DWORD _In_ DWORD dwBufLen
Definition: wincrypt.h:4245
#define MAGIC_CRYPTKEY
Definition: crypt.h:60
HCRYPTPROV hPrivate
Definition: crypt.h:69
PPROVFUNCS pFuncs
Definition: crypt.h:68
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_updates_bytes_to_ pdwDataLen BYTE _Inout_ DWORD * pdwDataLen
Definition: wincrypt.h:4201
#define MAGIC_CRYPTPROV
Definition: crypt.h:59
struct tagCRYPTHASH * PCRYPTHASH
#define TRACE(s)
Definition: solgame.cpp:4
_In_ HCRYPTHASH _In_ BOOL Final
Definition: wincrypt.h:4198
#define SetLastError(x)
Definition: compat.h:409
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
Definition: _hash_fun.h:40
Definition: path.c:42
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_updates_bytes_to_ pdwDataLen BYTE * pbData
Definition: wincrypt.h:4201

Referenced by CEnvelopedEncodeMsg_Update(), CryptProtectData(), rdssl_rc4_crypt(), test_3des(), test_3des112(), test_aes(), test_block_cipher_modes(), test_des(), test_key_derivation(), test_mac(), test_rc2(), test_rc4(), test_rsa_encrypt(), test_rsa_round_trip(), and test_schannel_provider().

◆ CryptEnumProvidersA()

BOOL WINAPI CryptEnumProvidersA ( DWORD  dwIndex,
DWORD pdwReserved,
DWORD  dwFlags,
DWORD pdwProvType,
LPSTR  pszProvName,
DWORD pcbProvName 
)

Definition at line 1233 of file crypt.c.

1235 {
1236  PWSTR str = NULL;
1237  DWORD bufsize;
1238  BOOL ret;
1239 
1240  TRACE("(%d, %p, %08x, %p, %p, %p)\n", dwIndex, pdwReserved, dwFlags,
1242 
1244  return FALSE;
1245  if ( pszProvName && !(str = CRYPT_Alloc(bufsize)) )
1246  {
1248  return FALSE;
1249  }
1251  if (str)
1253  *pcbProvName = bufsize / sizeof(WCHAR); /* FIXME: not correct */
1254  if (str)
1255  {
1256  CRYPT_Free(str);
1258  {
1260  return FALSE;
1261  }
1262  }
1263  return ret;
1264 }
_Reserved_ DWORD _In_ DWORD _Out_ DWORD * pdwProvType
Definition: wincrypt.h:4254
#define CRYPT_Free(buffer)
Definition: crypt.c:62
uint16_t * PWSTR
Definition: typedefs.h:54
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define CRYPT_Alloc(size)
Definition: crypt.c:61
GLenum GLuint GLsizei bufsize
Definition: glext.h:7473
unsigned int BOOL
Definition: ntddk_ex.h:94
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI CryptEnumProvidersW(DWORD dwIndex, DWORD *pdwReserved, DWORD dwFlags, DWORD *pdwProvType, LPWSTR pszProvName, DWORD *pcbProvName)
Definition: crypt.c:1141
#define TRACE(s)
Definition: solgame.cpp:4
_Reserved_ DWORD _In_ DWORD _Out_ DWORD _Out_writes_bytes_to_opt_ pcbProvName LPSTR _Inout_ DWORD * pcbProvName
Definition: wincrypt.h:4257
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
_Reserved_ DWORD _In_ DWORD _Out_writes_bytes_to_opt_ pcbProvName LPSTR pszProvName
Definition: wincrypt.h:4358
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define ERROR_MORE_DATA
Definition: dderror.h:13
_Reserved_ DWORD * pdwReserved
Definition: wincrypt.h:4254
static BOOL CRYPT_UnicodeToANSI(LPCWSTR wstr, LPSTR *str, int strsize)
Definition: crypt.c:125
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ CryptEnumProvidersW()

BOOL WINAPI CryptEnumProvidersW ( DWORD  dwIndex,
DWORD pdwReserved,
DWORD  dwFlags,
DWORD pdwProvType,
LPWSTR  pszProvName,
DWORD pcbProvName 
)

Definition at line 1141 of file crypt.c.

1143 {
1144  HKEY hKey;
1145  static const WCHAR providerW[] = {
1146  'S','o','f','t','w','a','r','e','\\',
1147  'M','i','c','r','o','s','o','f','t','\\',
1148  'C','r','y','p','t','o','g','r','a','p','h','y','\\',
1149  'D','e','f','a','u','l','t','s','\\',
1150  'P','r','o','v','i','d','e','r',0
1151  };
1152  static const WCHAR typeW[] = {'T','y','p','e',0};
1153  BOOL ret;
1154 
1155  TRACE("(%d, %p, %d, %p, %p, %p)\n", dwIndex, pdwReserved, dwFlags,
1157 
1158  if (pdwReserved || !pcbProvName)
1159  {
1161  return FALSE;
1162  }
1163  if (dwFlags)
1164  {
1166  return FALSE;
1167  }
1168 
1169  if (RegOpenKeyW(HKEY_LOCAL_MACHINE, providerW, &hKey))
1170  {
1172  return FALSE;
1173  }
1174 
1175  ret = TRUE;
1176  if (!pszProvName)
1177  {
1178  DWORD numkeys;
1179  WCHAR *provNameW;
1180 
1181  RegQueryInfoKeyW(hKey, NULL, NULL, NULL, &numkeys, pcbProvName,
1182  NULL, NULL, NULL, NULL, NULL, NULL);
1183 
1184  if (!(provNameW = CRYPT_Alloc(*pcbProvName * sizeof(WCHAR))))
1185  {
1187  RegCloseKey(hKey);
1188  return FALSE;
1189  }
1190 
1191  RegEnumKeyExW(hKey, dwIndex, provNameW, pcbProvName, NULL, NULL, NULL, NULL);
1192  CRYPT_Free(provNameW);
1193  (*pcbProvName)++;
1194  *pcbProvName *= sizeof(WCHAR);
1195 
1196  if (dwIndex >= numkeys)
1197  {
1199  ret = FALSE;
1200  }
1201  } else {
1202  DWORD size = sizeof(DWORD);
1203  DWORD result;
1204  HKEY subkey;
1205 
1206  result = RegEnumKeyW(hKey, dwIndex, pszProvName, *pcbProvName / sizeof(WCHAR));
1207  if (result)
1208  {
1210  RegCloseKey(hKey);
1211  return FALSE;
1212  }
1213  if (RegOpenKeyW(hKey, pszProvName, &subkey))
1214  {
1215  RegCloseKey(hKey);
1216  return FALSE;
1217  }
1218 
1219  if (RegQueryValueExW(subkey, typeW, NULL, NULL, (BYTE*)pdwProvType, &size))
1220  ret = FALSE;
1221 
1222  RegCloseKey(subkey);
1223  }
1224  RegCloseKey(hKey);
1225  return ret;
1226 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
_Reserved_ DWORD _In_ DWORD _Out_ DWORD * pdwProvType
Definition: wincrypt.h:4254
#define TRUE
Definition: types.h:120
#define CRYPT_Free(buffer)
Definition: crypt.c:62
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:95
static const WCHAR typeW[]
Definition: name.c:49
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define CRYPT_Alloc(size)
Definition: crypt.c:61
static DWORD
Definition: crypt.c:45
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define NTE_FAIL
Definition: winerror.h:2900
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3311
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
_Reserved_ DWORD _In_ DWORD _Out_ DWORD _Out_writes_bytes_to_opt_ pcbProvName LPSTR _Inout_ DWORD * pcbProvName
Definition: wincrypt.h:4257
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3704
_Reserved_ DWORD _In_ DWORD _Out_writes_bytes_to_opt_ pcbProvName LPSTR pszProvName
Definition: wincrypt.h:4358
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
unsigned char BYTE
Definition: mem.h:68
_Reserved_ DWORD * pdwReserved
Definition: wincrypt.h:4254
LONG WINAPI RegEnumKeyW(HKEY hKey, DWORD dwIndex, LPWSTR lpName, DWORD cbName)
Definition: reg.c:2430
#define NTE_BAD_FLAGS
Definition: winerror.h:2877
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2541
GLuint64EXT * result
Definition: glext.h:11304
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by CryptEnumProvidersA(), find_matching_provider(), and I_CryptGetDefaultCryptProv().

◆ CryptEnumProviderTypesA()

BOOL WINAPI CryptEnumProviderTypesA ( DWORD  dwIndex,
DWORD pdwReserved,
DWORD  dwFlags,
DWORD pdwProvType,
LPSTR  pszTypeName,
DWORD pcbTypeName 
)

Definition at line 1367 of file crypt.c.

1369 {
1370  PWSTR str = NULL;
1371  DWORD bufsize;
1372  BOOL ret;
1373 
1374  TRACE("(%d, %p, %08x, %p, %p, %p)\n", dwIndex, pdwReserved, dwFlags,
1375  pdwProvType, pszTypeName, pcbTypeName);
1376 
1378  return FALSE;
1379  if ( pszTypeName && !(str = CRYPT_Alloc(bufsize)) )
1380  {
1382  return FALSE;
1383  }
1385  if (str)
1386  CRYPT_UnicodeToANSI(str, &pszTypeName, *pcbTypeName);
1387  *pcbTypeName = bufsize / sizeof(WCHAR);
1388  if (str)
1389  {
1390  CRYPT_Free(str);
1392  {
1394  return FALSE;
1395  }
1396  }
1397  return ret;
1398 }
_Reserved_ DWORD _In_ DWORD _Out_ DWORD * pdwProvType
Definition: wincrypt.h:4254
#define CRYPT_Free(buffer)
Definition: crypt.c:62
uint16_t * PWSTR
Definition: typedefs.h:54
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define CRYPT_Alloc(size)
Definition: crypt.c:61
GLenum GLuint GLsizei bufsize
Definition: glext.h:7473
unsigned int BOOL
Definition: ntddk_ex.h:94
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
_Reserved_ DWORD _In_ DWORD _Out_ DWORD _Out_writes_bytes_to_opt_ pcbTypeName LPSTR _Inout_ DWORD * pcbTypeName
Definition: wincrypt.h:4283
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL WINAPI CryptEnumProviderTypesW(DWORD dwIndex, DWORD *pdwReserved, DWORD dwFlags, DWORD *pdwProvType, LPWSTR pszTypeName, DWORD *pcbTypeName)
Definition: crypt.c:1288
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define ERROR_MORE_DATA
Definition: dderror.h:13
_Reserved_ DWORD * pdwReserved
Definition: wincrypt.h:4254
static BOOL CRYPT_UnicodeToANSI(LPCWSTR wstr, LPSTR *str, int strsize)
Definition: crypt.c:125
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ CryptEnumProviderTypesW()

BOOL WINAPI CryptEnumProviderTypesW ( DWORD  dwIndex,
DWORD pdwReserved,
DWORD  dwFlags,
DWORD pdwProvType,
LPWSTR  pszTypeName,
DWORD pcbTypeName 
)

Definition at line 1288 of file crypt.c.

1290 {
1291  HKEY hKey, hSubkey;
1292  DWORD keylen, numkeys, dwType;
1293  PWSTR keyname, ch;
1294  DWORD result;
1295  static const WCHAR KEYSTR[] = {
1296  'S','o','f','t','w','a','r','e','\\',
1297  'M','i','c','r','o','s','o','f','t','\\',
1298  'C','r','y','p','t','o','g','r','a','p','h','y','\\',
1299  'D','e','f','a','u','l','t','s','\\',
1300  'P','r','o','v','i','d','e','r',' ','T','y','p','e','s',0
1301  };
1302  static const WCHAR typenameW[] = {'T','y','p','e','N','a','m','e',0};
1303 
1304  TRACE("(%d, %p, %08x, %p, %p, %p)\n", dwIndex, pdwReserved,
1305  dwFlags, pdwProvType, pszTypeName, pcbTypeName);
1306 
1307  if (pdwReserved || !pdwProvType || !pcbTypeName)
1308  {
1310  return FALSE;
1311  }
1312  if (dwFlags)
1313  {
1315  return FALSE;
1316  }
1317 
1318  if (RegOpenKeyW(HKEY_LOCAL_MACHINE, KEYSTR, &hKey))
1319  return FALSE;
1320 
1321  RegQueryInfoKeyW(hKey, NULL, NULL, NULL, &numkeys, &keylen, NULL, NULL, NULL, NULL, NULL, NULL);
1322  if (dwIndex >= numkeys)
1323  {
1325  RegCloseKey(hKey);
1326  return FALSE;
1327  }
1328  keylen++;
1329  if ( !(keyname = CRYPT_Alloc(keylen*sizeof(WCHAR))) )
1330  {
1332  RegCloseKey(hKey);
1333  return FALSE;
1334  }
1335  if ( RegEnumKeyW(hKey, dwIndex, keyname, keylen) ) {
1336  CRYPT_Free(keyname);
1337  RegCloseKey(hKey);
1338  return FALSE;
1339  }
1340  RegOpenKeyW(hKey, keyname, &hSubkey);
1341  RegCloseKey(hKey);
1342 
1343  ch = keyname + strlenW(keyname);
1344  /* Convert "Type 000" to 0, etc/ */
1345  *pdwProvType = *(--ch) - '0';
1346  *pdwProvType += (*(--ch) - '0') * 10;
1347  *pdwProvType += (*(--ch) - '0') * 100;
1348  CRYPT_Free(keyname);
1349 
1350  result = RegQueryValueExW(hSubkey, typenameW, NULL, &dwType, (LPBYTE)pszTypeName, pcbTypeName);
1351  if (result)
1352  {
1354  RegCloseKey(hSubkey);
1355  return FALSE;
1356  }
1357 
1358  RegCloseKey(hSubkey);
1359  return TRUE;
1360 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
_Reserved_ DWORD _In_ DWORD _Out_ DWORD * pdwProvType
Definition: wincrypt.h:4254
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define CRYPT_Free(buffer)
Definition: crypt.c:62
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:95
uint16_t * PWSTR
Definition: typedefs.h:54
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define CRYPT_Alloc(size)
Definition: crypt.c:61
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3311
smooth NULL
Definition: ftsmooth.c:416
_Reserved_ DWORD _In_ DWORD _Out_ DWORD _Out_writes_bytes_to_opt_ pcbTypeName LPSTR _Inout_ DWORD * pcbTypeName
Definition: wincrypt.h:4283
#define TRACE(s)
Definition: solgame.cpp:4
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3704
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
_Reserved_ DWORD * pdwReserved
Definition: wincrypt.h:4254
LONG WINAPI RegEnumKeyW(HKEY hKey, DWORD dwIndex, LPWSTR lpName, DWORD cbName)
Definition: reg.c:2430
#define NTE_BAD_FLAGS
Definition: winerror.h:2877
GLuint64EXT * result
Definition: glext.h:11304
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by CryptEnumProviderTypesA().

◆ CryptExportKey()

BOOL WINAPI CryptExportKey ( HCRYPTKEY  hKey,
HCRYPTKEY  hExpKey,
DWORD  dwBlobType,
DWORD  dwFlags,
BYTE pbData,
DWORD pdwDataLen 
)

Definition at line 1421 of file crypt.c.

1423 {
1424  PCRYPTPROV prov;
1425  PCRYPTKEY key = (PCRYPTKEY)hKey, expkey = (PCRYPTKEY)hExpKey;
1426 
1427  TRACE("(0x%lx, 0x%lx, %d, %08x, %p, %p)\n", hKey, hExpKey, dwBlobType, dwFlags, pbData, pdwDataLen);
1428 
1429  if (!key || !pdwDataLen || !key->pProvider ||
1430  key->dwMagic != MAGIC_CRYPTKEY || key->pProvider->dwMagic != MAGIC_CRYPTPROV)
1431  {
1433  return FALSE;
1434  }
1435 
1436  prov = key->pProvider;
1437  return prov->pFuncs->pCPExportKey(prov->hPrivate, key->hPrivate, expkey ? expkey->hPrivate : 0,
1438  dwBlobType, dwFlags, pbData, pdwDataLen);
1439 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
struct tagCRYPTKEY * PCRYPTKEY
#define MAGIC_CRYPTKEY
Definition: crypt.h:60
HCRYPTPROV hPrivate
Definition: crypt.h:69
PPROVFUNCS pFuncs
Definition: crypt.h:68
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_updates_bytes_to_ pdwDataLen BYTE _Inout_ DWORD * pdwDataLen
Definition: wincrypt.h:4201
#define MAGIC_CRYPTPROV
Definition: crypt.h:59
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
Definition: path.c:42
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_updates_bytes_to_ pdwDataLen BYTE * pbData
Definition: wincrypt.h:4201

Referenced by CRYPT_ExportKeyTrans(), CRYPT_ExportPublicKeyInfoEx(), rdssl_cert_to_rkey(), test_import_export(), test_import_private(), test_key_permissions(), test_rsa_encrypt(), test_rsa_round_trip(), and testAcquireCertPrivateKey().

◆ CryptGenKey()

BOOL WINAPI CryptGenKey ( HCRYPTPROV  hProv,
ALG_ID  Algid,
DWORD  dwFlags,
HCRYPTKEY phKey 
)

Definition at line 1456 of file crypt.c.

1457 {
1458  PCRYPTPROV prov = (PCRYPTPROV)hProv;
1459  PCRYPTKEY key;
1460 
1461  TRACE("(0x%lx, %d, %08x, %p)\n", hProv, Algid, dwFlags, phKey);
1462 
1463  if (!phKey || !prov || prov->dwMagic != MAGIC_CRYPTPROV)
1464  {
1466  return FALSE;
1467  }
1468  if ( !(key = CRYPT_Alloc(sizeof(CRYPTKEY))) )
1469  {
1471  return FALSE;
1472  }
1473 
1474  key->pProvider = prov;
1475  key->dwMagic = MAGIC_CRYPTKEY;
1476  if (prov->pFuncs->pCPGenKey(prov->hPrivate, Algid, dwFlags, &key->hPrivate))
1477  {
1478  *phKey = (HCRYPTKEY)key;
1479  return TRUE;
1480  }
1481 
1482  /* CSP error! */
1483  key->dwMagic = 0;
1484  CRYPT_Free(key);
1485  return FALSE;
1486 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define CRYPT_Free(buffer)
Definition: crypt.c:62
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define CRYPT_Alloc(size)
Definition: crypt.c:61
static HCRYPTPROV hProv
Definition: rsaenh.c:32
#define MAGIC_CRYPTKEY
Definition: crypt.h:60
struct tagCRYPTPROV * PCRYPTPROV
HCRYPTPROV hPrivate
Definition: crypt.h:69
PPROVFUNCS pFuncs
Definition: crypt.h:68
#define MAGIC_CRYPTPROV
Definition: crypt.h:59
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
DWORD dwMagic
Definition: crypt.h:65
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static HCRYPTKEY
Definition: crypt.c:51
static const unsigned char key[key_length]
Definition: crypt.c:1004
Definition: path.c:42

Referenced by CertCreateSelfSignCertificate(), CRYPT_CreateKeyProv(), CRYPT_GenKey(), init_aes_environment(), init_base_environment(), test_null_provider(), test_rsa_round_trip(), testCreateSelfSignCert(), testExportPublicKey(), and testSignCert().

◆ CryptGenRandom()

BOOL WINAPI CryptGenRandom ( HCRYPTPROV  hProv,
DWORD  dwLen,
BYTE pbBuffer 
)

Definition at line 705 of file crypt.c.

706 {
707  PCRYPTPROV prov = (PCRYPTPROV)hProv;
708 
709  TRACE("(0x%lx, %d, %p)\n", hProv, dwLen, pbBuffer);
710 
711  if (!hProv)
712  {
714  return FALSE;
715  }
716 
717  if (prov->dwMagic != MAGIC_CRYPTPROV)
718  {
720  return FALSE;
721  }
722 
723  return prov->pFuncs->pCPGenRandom(prov->hPrivate, dwLen, pbBuffer);
724 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
static HCRYPTPROV hProv
Definition: rsaenh.c:32
struct tagCRYPTPROV * PCRYPTPROV
HCRYPTPROV hPrivate
Definition: crypt.h:69
PPROVFUNCS pFuncs
Definition: crypt.h:68
#define MAGIC_CRYPTPROV
Definition: crypt.h:59
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
DWORD dwMagic
Definition: crypt.h:65

Referenced by CertCreateSelfSignCertificate(), fill_protect_data(), and test_gen_random().

◆ CryptGetDefaultProviderA()

BOOL WINAPI CryptGetDefaultProviderA ( DWORD  dwProvType,
DWORD pdwReserved,
DWORD  dwFlags,
LPSTR  pszProvName,
DWORD pcbProvName 
)

Definition at line 1565 of file crypt.c.

1567 {
1568  PWSTR str = NULL;
1569  DWORD bufsize;
1570  BOOL ret;
1571 
1572  TRACE("(%d, %p, %08x, %p, %p)\n", dwProvType, pdwReserved, dwFlags, pszProvName, pcbProvName);
1573 
1575  if ( pszProvName && !(str = CRYPT_Alloc(bufsize)) )
1576  {
1578  return FALSE;
1579  }
1581  if (str)
1583  *pcbProvName = bufsize / sizeof(WCHAR);
1584  if (str)
1585  {
1586  CRYPT_Free(str);
1588  {
1590  return FALSE;
1591  }
1592  }
1593  return ret;
1594 }
#define CRYPT_Free(buffer)
Definition: crypt.c:62
uint16_t * PWSTR
Definition: typedefs.h:54
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI CryptGetDefaultProviderW(DWORD dwProvType, DWORD *pdwReserved, DWORD dwFlags, LPWSTR pszProvName, DWORD *pcbProvName)
Definition: crypt.c:1508
#define CRYPT_Alloc(size)
Definition: crypt.c:61
GLenum GLuint GLsizei bufsize
Definition: glext.h:7473
unsigned int BOOL
Definition: ntddk_ex.h:94
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
_Reserved_ DWORD _In_ DWORD _Out_ DWORD _Out_writes_bytes_to_opt_ pcbProvName LPSTR _Inout_ DWORD * pcbProvName
Definition: wincrypt.h:4257
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
_Reserved_ DWORD _In_ DWORD _Out_writes_bytes_to_opt_ pcbProvName LPSTR pszProvName
Definition: wincrypt.h:4358
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define ERROR_MORE_DATA
Definition: dderror.h:13
_Reserved_ DWORD * pdwReserved
Definition: wincrypt.h:4254
static BOOL CRYPT_UnicodeToANSI(LPCWSTR wstr, LPSTR *str, int strsize)
Definition: crypt.c:125
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ CryptGetDefaultProviderW()

BOOL WINAPI CryptGetDefaultProviderW ( DWORD  dwProvType,
DWORD pdwReserved,
DWORD  dwFlags,
LPWSTR  pszProvName,
DWORD pcbProvName 
)

Definition at line 1508 of file crypt.c.

1510 {
1511  HKEY hKey;
1512  PWSTR keyname;
1513  DWORD result;
1514  static const WCHAR nameW[] = {'N','a','m','e',0};
1515 
1516  if (pdwReserved || !pcbProvName)
1517  {
1519  return FALSE;
1520  }
1522  {
1524  return FALSE;
1525  }
1526  if (dwProvType > 999)
1527  {
1529  return FALSE;
1530  }
1531  if ( !(keyname = CRYPT_GetTypeKeyName(dwProvType, dwFlags & CRYPT_USER_DEFAULT)) )
1532  {
1534  return FALSE;
1535  }
1537  {
1538  CRYPT_Free(keyname);
1540  return FALSE;
1541  }
1542  CRYPT_Free(keyname);
1543 
1545  RegCloseKey(hKey);
1546 
1547  if (result)
1548  {
1549  if (result != ERROR_MORE_DATA)
1551  else
1553 
1554  return FALSE;
1555  }
1556 
1557  return TRUE;
1558 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define CRYPT_Free(buffer)
Definition: crypt.c:62
uint16_t * PWSTR
Definition: typedefs.h:54
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define NTE_PROV_TYPE_NOT_DEF
Definition: winerror.h:2891
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3311
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR nameW[]
Definition: main.c:46
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
_Reserved_ DWORD _In_ DWORD _Out_ DWORD _Out_writes_bytes_to_opt_ pcbProvName LPSTR _Inout_ DWORD * pcbProvName
Definition: wincrypt.h:4257
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NTE_BAD_PROV_TYPE
Definition: winerror.h:2888
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
_Reserved_ DWORD _In_ DWORD _Out_writes_bytes_to_opt_ pcbProvName LPSTR pszProvName
Definition: wincrypt.h:4358
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define ERROR_MORE_DATA
Definition: dderror.h:13
_Reserved_ DWORD * pdwReserved
Definition: wincrypt.h:4254
#define CRYPT_USER_DEFAULT
Definition: wincrypt.h:2077
static PWSTR CRYPT_GetTypeKeyName(DWORD dwType, BOOL user)
Definition: crypt.c:85
#define NTE_BAD_FLAGS
Definition: winerror.h:2877
GLuint64EXT * result
Definition: glext.h:11304
#define CRYPT_MACHINE_DEFAULT
Definition: wincrypt.h:2076
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define NTE_PROV_TYPE_ENTRY_BAD
Definition: winerror.h:2892

Referenced by CryptGetDefaultProviderA().

◆ CryptGetHashParam()

BOOL WINAPI CryptGetHashParam ( HCRYPTHASH  hHash,
DWORD  dwParam,
BYTE pbData,
DWORD pdwDataLen,
DWORD  dwFlags 
)

Definition at line 1615 of file crypt.c.

1617 {
1618  PCRYPTPROV prov;
1620 
1621  TRACE("(0x%lx, %d, %p, %p, %08x)\n", hHash, dwParam, pbData, pdwDataLen, dwFlags);
1622 
1623  if (!hash || !pdwDataLen || !hash->pProvider ||
1624  hash->dwMagic != MAGIC_CRYPTHASH || hash->pProvider->dwMagic != MAGIC_CRYPTPROV)
1625  {
1627  return FALSE;
1628  }
1629 
1630  prov = hash->pProvider;
1631  return prov->pFuncs->pCPGetHashParam(prov->hPrivate, hash->hPrivate, dwParam,
1633 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
_In_ HCRYPTHASH hHash
Definition: wincrypt.h:4198
#define MAGIC_CRYPTHASH
Definition: crypt.h:61
HCRYPTPROV hPrivate
Definition: crypt.h:69
PPROVFUNCS pFuncs
Definition: crypt.h:68
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_updates_bytes_to_ pdwDataLen BYTE _Inout_ DWORD * pdwDataLen
Definition: wincrypt.h:4201
#define MAGIC_CRYPTPROV
Definition: crypt.h:59
struct tagCRYPTHASH * PCRYPTHASH
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
Definition: _hash_fun.h:40
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_updates_bytes_to_ pdwDataLen BYTE * pbData
Definition: wincrypt.h:4201

Referenced by assembly_get_pubkey_token(), CDecodeHashMsg_GetParam(), CDecodeSignedMsg_GetParam(), CHashEncodeMsg_GetParam(), convert_hash_to_blob(), create_silly_rename(), CRYPT_EncodePKCSDigestedData(), CryptCATAdminCalcHashFromFileHandle(), CryptHashCertificate(), CryptHashPublicKeyInfo(), CryptHashToBeSigned(), CryptSignCertificate(), CSignedEncodeMsg_GetParam(), CSignedMsgData_AppendMessageDigestAttribute(), derive_key(), hash_dib(), nfs41_client_owner(), rdssl_hash_complete(), rdssl_hmac_md5(), SOFTPUB_VerifyImageHash(), test_hashes(), test_hmac(), test_import_hmac(), test_key_derivation(), test_mac(), test_rc2(), test_rc4(), test_schannel_provider(), and test_sha2().

◆ CryptGetKeyParam()

BOOL WINAPI CryptGetKeyParam ( HCRYPTKEY  hKey,
DWORD  dwParam,
BYTE pbData,
DWORD pdwDataLen,
DWORD  dwFlags 
)

Definition at line 1654 of file crypt.c.

1656 {
1657  PCRYPTPROV prov;
1658  PCRYPTKEY key = (PCRYPTKEY)hKey;
1659 
1660  TRACE("(0x%lx, %d, %p, %p, %08x)\n", hKey, dwParam, pbData, pdwDataLen, dwFlags);
1661 
1662  if (!key || !pdwDataLen || !key->pProvider ||
1663  key->dwMagic != MAGIC_CRYPTKEY || key->pProvider->dwMagic != MAGIC_CRYPTPROV)
1664  {
1666  return FALSE;
1667  }
1668 
1669  prov = key->pProvider;
1670  return prov->pFuncs->pCPGetKeyParam(prov->hPrivate, key->hPrivate, dwParam,
1672 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
struct tagCRYPTKEY * PCRYPTKEY
#define MAGIC_CRYPTKEY
Definition: crypt.h:60
HCRYPTPROV hPrivate
Definition: crypt.h:69
PPROVFUNCS pFuncs
Definition: crypt.h:68
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_updates_bytes_to_ pdwDataLen BYTE _Inout_ DWORD * pdwDataLen
Definition: wincrypt.h:4201
#define MAGIC_CRYPTPROV
Definition: crypt.h:59
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
Definition: path.c:42
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_updates_bytes_to_ pdwDataLen BYTE * pbData
Definition: wincrypt.h:4201

Referenced by CertGetPublicKeyLength(), export_is_key_exportable(), test_aes(), test_block_cipher_modes(), test_des(), test_import_export(), test_import_private(), test_key_derivation(), test_key_permissions(), test_rc2(), test_rc4(), test_rsa_encrypt(), and testImportPublicKey().

◆ CryptGetProvParam()

BOOL WINAPI CryptGetProvParam ( HCRYPTPROV  hProv,
DWORD  dwParam,
BYTE pbData,
DWORD pdwDataLen,
DWORD  dwFlags 
)

Definition at line 1693 of file crypt.c.

1695 {
1696  PCRYPTPROV prov = (PCRYPTPROV)hProv;
1697 
1698  TRACE("(0x%lx, %d, %p, %p, %08x)\n", hProv, dwParam, pbData, pdwDataLen, dwFlags);
1699 
1700  if (!prov || prov->dwMagic != MAGIC_CRYPTPROV)
1701  {
1703  return FALSE;
1704  }
1705 
1706  return prov->pFuncs->pCPGetProvParam(prov->hPrivate, dwParam, pbData, pdwDataLen, dwFlags);
1707 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
static HCRYPTPROV hProv
Definition: rsaenh.c:32
struct tagCRYPTPROV * PCRYPTPROV
HCRYPTPROV hPrivate
Definition: crypt.h:69
PPROVFUNCS pFuncs
Definition: crypt.h:68
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_updates_bytes_to_ pdwDataLen BYTE _Inout_ DWORD * pdwDataLen
Definition: wincrypt.h:4201
#define MAGIC_CRYPTPROV
Definition: crypt.h:59
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
DWORD dwMagic
Definition: crypt.h:65
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_updates_bytes_to_ pdwDataLen BYTE * pbData
Definition: wincrypt.h:4201

Referenced by CertContext_SetKeyProvInfo(), find_key_prov_info_in_provider(), is_supported_algid(), test_container_sd(), test_enum_container(), test_getDefaultCryptProv(), test_null_provider(), and test_prov().

◆ CryptGetUserKey()

BOOL WINAPI CryptGetUserKey ( HCRYPTPROV  hProv,
DWORD  dwKeySpec,
HCRYPTKEY phUserKey 
)

Definition at line 1723 of file crypt.c.

1724 {
1725  PCRYPTPROV prov = (PCRYPTPROV)hProv;
1726  PCRYPTKEY key;
1727 
1728  TRACE("(0x%lx, %d, %p)\n", hProv, dwKeySpec, phUserKey);
1729 
1730  if (!prov)
1731  {
1733  return FALSE;
1734  }
1735  if (!phUserKey || prov->dwMagic != MAGIC_CRYPTPROV)
1736  {
1738  return FALSE;
1739  }
1740  if ( !(key = CRYPT_Alloc(sizeof(CRYPTKEY))) )
1741  {
1743  return FALSE;
1744  }
1745 
1746  key->pProvider = prov;
1747  key->dwMagic = MAGIC_CRYPTKEY;
1748  if (prov->pFuncs->pCPGetUserKey(prov->hPrivate, dwKeySpec, &key->hPrivate))
1749  {
1750  *phUserKey = (HCRYPTKEY)key;
1751  return TRUE;
1752  }
1753 
1754  /* CSP Error */
1755  key->dwMagic = 0;
1756  CRYPT_Free(key);
1757  *phUserKey = 0;
1758  return FALSE;
1759 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define CRYPT_Free(buffer)
Definition: crypt.c:62
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define CRYPT_Alloc(size)
Definition: crypt.c:61
static HCRYPTPROV hProv
Definition: rsaenh.c:32
#define MAGIC_CRYPTKEY
Definition: crypt.h:60
struct tagCRYPTPROV * PCRYPTPROV
HCRYPTPROV hPrivate
Definition: crypt.h:69
PPROVFUNCS pFuncs
Definition: crypt.h:68
#define MAGIC_CRYPTPROV
Definition: crypt.h:59
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
DWORD dwMagic
Definition: crypt.h:65
static HCRYPTKEY
Definition: crypt.c:51
static const unsigned char key[key_length]
Definition: crypt.c:1004
Definition: path.c:42

Referenced by CertCreateSelfSignCertificate(), CRYPT_ExportPublicKeyInfoEx(), CRYPT_ImportKeyTrans(), export_is_key_exportable(), test_import_export(), test_key_initialization(), test_key_permissions(), test_null_provider(), test_rsa_encrypt(), and test_rsa_round_trip().

◆ CryptHashData()

BOOL WINAPI CryptHashData ( HCRYPTHASH  hHash,
const BYTE pbData,
DWORD  dwDataLen,
DWORD  dwFlags 
)

Definition at line 1776 of file crypt.c.

1777 {
1779  PCRYPTPROV prov;
1780 
1781  TRACE("(0x%lx, %p, %d, %08x)\n", hHash, pbData, dwDataLen, dwFlags);
1782 
1783  if (!hash)
1784  {
1786  return FALSE;
1787  }
1788  if (!hash->pProvider || hash->dwMagic != MAGIC_CRYPTHASH ||
1789  hash->pProvider->dwMagic != MAGIC_CRYPTPROV)
1790  {
1792  return FALSE;
1793  }
1794 
1795  prov = hash->pProvider;
1796  return prov->pFuncs->pCPHashData(prov->hPrivate, hash->hPrivate, pbData, dwDataLen, dwFlags);
1797 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
_In_ HCRYPTHASH hHash
Definition: wincrypt.h:4198
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define MAGIC_CRYPTHASH
Definition: crypt.h:61
HCRYPTPROV hPrivate
Definition: crypt.h:69
PPROVFUNCS pFuncs
Definition: crypt.h:68
#define MAGIC_CRYPTPROV
Definition: crypt.h:59
struct tagCRYPTHASH * PCRYPTHASH
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
Definition: _hash_fun.h:40
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_updates_bytes_to_ pdwDataLen BYTE * pbData
Definition: wincrypt.h:4201

Referenced by assembly_get_pubkey_token(), CDecodeMsg_FinalizeHashedContent(), CHashEncodeMsg_Update(), create_silly_rename(), CRYPT_VerifySignature(), CryptCATAdminCalcHashFromFileHandle(), CryptHashCertificate(), CryptHashPublicKeyInfo(), CryptHashToBeSigned(), CryptSignCertificate(), CSignedMsgData_UpdateAuthenticatedAttributes(), CSignedMsgData_UpdateHash(), derive_key(), hash_dib(), hash_mac_addrs(), load_encryption_key(), nfs41_client_owner(), rdssl_hash_transform(), rdssl_hmac_md5(), SOFTPUB_HashPEFile(), test_hashes(), test_hmac(), test_import_hmac(), test_key_derivation(), test_mac(), test_rc2(), test_rc4(), test_schannel_provider(), test_sha2(), test_verify_signature(), and verifySig().

◆ CryptHashSessionKey()

BOOL WINAPI CryptHashSessionKey ( HCRYPTHASH  hHash,
HCRYPTKEY  hKey,
DWORD  dwFlags 
)

Definition at line 1813 of file crypt.c.

1814 {
1816  PCRYPTKEY key = (PCRYPTKEY)hKey;
1817  PCRYPTPROV prov;
1818 
1819  TRACE("(0x%lx, 0x%lx, %08x)\n", hHash, hKey, dwFlags);
1820 
1821  if (!hash || !key)
1822  {
1824  return FALSE;
1825  }
1826 
1827  if (!hash->pProvider || hash->dwMagic != MAGIC_CRYPTHASH ||
1828  hash->pProvider->dwMagic != MAGIC_CRYPTPROV || key->dwMagic != MAGIC_CRYPTKEY)
1829  {
1831  return FALSE;
1832  }
1833 
1834  prov = hash->pProvider;
1835  return prov->pFuncs->pCPHashSessionKey(prov->hPrivate, hash->hPrivate, key->hPrivate, dwFlags);
1836 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
_In_ HCRYPTHASH hHash
Definition: wincrypt.h:4198
struct tagCRYPTKEY * PCRYPTKEY
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define MAGIC_CRYPTHASH
Definition: crypt.h:61
#define MAGIC_CRYPTKEY
Definition: crypt.h:60
HCRYPTPROV hPrivate
Definition: crypt.h:69
PPROVFUNCS pFuncs
Definition: crypt.h:68
#define MAGIC_CRYPTPROV
Definition: crypt.h:59
struct tagCRYPTHASH * PCRYPTHASH
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
Definition: _hash_fun.h:40
Definition: path.c:42

◆ CryptImportKey()

BOOL WINAPI CryptImportKey ( HCRYPTPROV  hProv,
const BYTE pbData,
DWORD  dwDataLen,
HCRYPTKEY  hPubKey,
DWORD  dwFlags,
HCRYPTKEY phKey 
)

Definition at line 1855 of file crypt.c.

1857 {
1858  PCRYPTPROV prov = (PCRYPTPROV)hProv;
1859  PCRYPTKEY pubkey = (PCRYPTKEY)hPubKey, importkey;
1860 
1861  TRACE("(0x%lx, %p, %d, 0x%lx, %08x, %p)\n", hProv, pbData, dwDataLen, hPubKey, dwFlags, phKey);
1862 
1863  if (!prov || !pbData || !dwDataLen || !phKey ||
1864  prov->dwMagic != MAGIC_CRYPTPROV ||
1865  (pubkey && pubkey->dwMagic != MAGIC_CRYPTKEY))
1866  {
1868  return FALSE;
1869  }
1870 
1871  if ( !(importkey = CRYPT_Alloc(sizeof(CRYPTKEY))) )
1872  {
1874  return FALSE;
1875  }
1876 
1877  importkey->pProvider = prov;
1878  importkey->dwMagic = MAGIC_CRYPTKEY;
1879  if (prov->pFuncs->pCPImportKey(prov->hPrivate, pbData, dwDataLen,
1880  pubkey ? pubkey->hPrivate : 0, dwFlags, &importkey->hPrivate))
1881  {
1882  *phKey = (HCRYPTKEY)importkey;
1883  return TRUE;
1884  }
1885 
1886  importkey->dwMagic = 0;
1887  CRYPT_Free(importkey);
1888  return FALSE;
1889 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define CRYPT_Free(buffer)
Definition: crypt.c:62
static const WCHAR pubkey[]
Definition: asmname.c:66
struct tagCRYPTKEY * PCRYPTKEY
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define CRYPT_Alloc(size)
Definition: crypt.c:61
static HCRYPTPROV hProv
Definition: rsaenh.c:32
#define MAGIC_CRYPTKEY
Definition: crypt.h:60
struct tagCRYPTPROV * PCRYPTPROV
HCRYPTPROV hPrivate
Definition: crypt.h:69
PPROVFUNCS pFuncs
Definition: crypt.h:68
#define MAGIC_CRYPTPROV
Definition: crypt.h:59
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
DWORD dwMagic
Definition: crypt.h:65
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static HCRYPTKEY
Definition: crypt.c:51
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_updates_bytes_to_ pdwDataLen BYTE * pbData
Definition: wincrypt.h:4201

Referenced by CRYPT_ImportKeyTrans(), CRYPT_ImportPublicKeyInfoEx(), rdssl_hmac_md5(), rdssl_rc4_set_key(), test_decode_msg_get_param(), test_hashes(), test_import_export(), test_import_hmac(), test_import_private(), test_key_initialization(), test_null_provider(), test_rsa_round_trip(), test_schannel_provider(), test_sign_message(), test_signed_msg_encoding(), test_signed_msg_update(), test_verify_signature(), testAcquireCertPrivateKey(), and testAcquireSecurityContext().

◆ CryptReleaseContext()

BOOL WINAPI CryptReleaseContext ( HCRYPTPROV  hProv,
ULONG_PTR  dwFlags 
)

Definition at line 651 of file crypt.c.

653 {
654  PCRYPTPROV pProv = (PCRYPTPROV)hProv;
655  BOOL ret = TRUE;
656 
657  TRACE("(0x%lx, %08lx)\n", hProv, dwFlags);
658 
659  if (!pProv)
660  {
662  return FALSE;
663  }
664 
665  if (pProv->dwMagic != MAGIC_CRYPTPROV)
666  {
668  return FALSE;
669  }
670 
671  pProv->refcount--;
672  if (pProv->refcount <= 0)
673  {
674  ret = pProv->pFuncs->pCPReleaseContext(pProv->hPrivate, dwFlags);
675  pProv->dwMagic = 0;
676  FreeLibrary(pProv->hModule);
677 #if 0
678  CRYPT_Free(pProv->pVTable->pContextInfo);
679 #endif
680  CRYPT_Free(pProv->pVTable->pszProvName);
681  CRYPT_Free(pProv->pVTable);
682  CRYPT_Free(pProv->pFuncs);
683  CRYPT_Free(pProv);
684  }
685  return ret;
686 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define CRYPT_Free(buffer)
Definition: crypt.c:62
static HCRYPTPROV hProv
Definition: rsaenh.c:32
struct tagCRYPTPROV * PCRYPTPROV
unsigned int BOOL
Definition: ntddk_ex.h:94
HCRYPTPROV hPrivate
Definition: crypt.h:69
LPSTR pszProvName
Definition: wincrypt.h:708
PPROVFUNCS pFuncs
Definition: crypt.h:68
#define MAGIC_CRYPTPROV
Definition: crypt.h:59
UINT refcount
Definition: crypt.h:66
PVTableProvStruc pVTable
Definition: crypt.h:70
HMODULE hModule
Definition: crypt.h:67
#define TRACE(s)
Definition: solgame.cpp:4
#define FreeLibrary(x)
Definition: compat.h:405
#define SetLastError(x)
Definition: compat.h:409
DWORD dwMagic
Definition: crypt.h:65
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define NTE_BAD_UID
Definition: winerror.h:2869

Referenced by assembly_get_pubkey_token(), CDecodeMsg_Close(), CEnvelopedEncodeMsg_Close(), CEnvelopedEncodeMsg_Open(), CertContext_SetProperty(), CertCreateSelfSignCertificate(), CHashEncodeMsg_Close(), clean_up_aes_environment(), clean_up_base_environment(), create_silly_rename(), CRYPT_FileNameOpenStoreW(), CRYPT_FileOpenStore(), CRYPT_GetDefaultProvider(), CRYPT_MemOpenStore(), CRYPT_MsgOpenStore(), CRYPT_RegOpenStore(), CRYPT_SysOpenStoreW(), CryptCATAdminCalcHashFromFileHandle(), CryptCATAdminEnumCatalogFromHash(), CryptProtectData(), CryptSignMessage(), CryptUnprotectData(), CSignedEncodeMsg_Open(), detect_nt(), DllMain(), DllRegisterServer(), export_private_key_dlg_proc(), find_key_prov_info_in_provider(), I_CryptGetDefaultCryptProv(), key_prov_info_matches_cert(), nfs41_client_owner(), rdssl_cert_to_rkey(), rdssl_hash_info_create(), rdssl_hash_info_delete(), rdssl_hmac_md5(), rdssl_rc4_info_delete(), SOFTPUB_VerifyImageHash(), START_TEST(), test_container_sd(), test_decode_msg_get_param(), test_encrypt_message(), test_enveloped_msg_open(), test_getDefaultCryptProv(), test_hashes(), test_key_initialization(), test_null_provider(), test_rsa_round_trip(), test_schannel_provider(), test_sign_message(), test_signed_msg_encoding(), test_signed_msg_get_param(), test_signed_msg_open(), test_signed_msg_update(), test_sip(), testAcquireCertPrivateKey(), testAcquireSecurityContext(), testCertSigs(), testCreateSelfSignCert(), and testPortPublicKeyInfo().

◆ CryptSetHashParam()

BOOL WINAPI CryptSetHashParam ( HCRYPTHASH  hHash,
DWORD  dwParam,
const BYTE pbData,
DWORD  dwFlags 
)

Definition at line 1975 of file crypt.c.

1976 {
1977  PCRYPTPROV prov;
1979 
1980  TRACE("(0x%lx, %d, %p, %08x)\n", hHash, dwParam, pbData, dwFlags);
1981 
1982  if (!hash || !pbData || !hash->pProvider ||
1983  hash->dwMagic != MAGIC_CRYPTHASH || hash->pProvider->dwMagic != MAGIC_CRYPTPROV)
1984  {
1986  return FALSE;
1987  }
1988 
1989  prov = hash->pProvider;
1990  return prov->pFuncs->pCPSetHashParam(prov->hPrivate, hash->hPrivate,
1991  dwParam, pbData, dwFlags);
1992 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
_In_ HCRYPTHASH hHash
Definition: wincrypt.h:4198
#define MAGIC_CRYPTHASH
Definition: crypt.h:61
HCRYPTPROV hPrivate
Definition: crypt.h:69
PPROVFUNCS pFuncs
Definition: crypt.h:68
#define MAGIC_CRYPTPROV
Definition: crypt.h:59
struct tagCRYPTHASH * PCRYPTHASH
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
Definition: _hash_fun.h:40
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_updates_bytes_to_ pdwDataLen BYTE * pbData
Definition: wincrypt.h:4201

Referenced by rdssl_hmac_md5(), test_hashes(), test_hmac(), test_import_hmac(), and test_schannel_provider().

◆ CryptSetKeyParam()

BOOL WINAPI CryptSetKeyParam ( HCRYPTKEY  hKey,
DWORD  dwParam,
const BYTE pbData,
DWORD  dwFlags 
)

Definition at line 2009 of file crypt.c.

2010 {
2011  PCRYPTPROV prov;
2012  PCRYPTKEY key = (PCRYPTKEY)hKey;
2013 
2014  TRACE("(0x%lx, %d, %p, %08x)\n", hKey, dwParam, pbData, dwFlags);
2015 
2016  if (!key || !pbData || !key->pProvider ||
2017  key->dwMagic != MAGIC_CRYPTKEY || key->pProvider->dwMagic != MAGIC_CRYPTPROV)
2018  {
2020  return FALSE;
2021  }
2022 
2023  prov = key->pProvider;
2024  return prov->pFuncs->pCPSetKeyParam(prov->hPrivate, key->hPrivate,
2025  dwParam, pbData, dwFlags);
2026 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
struct tagCRYPTKEY * PCRYPTKEY
#define MAGIC_CRYPTKEY
Definition: crypt.h:60
HCRYPTPROV hPrivate
Definition: crypt.h:69
PPROVFUNCS pFuncs
Definition: crypt.h:68
#define MAGIC_CRYPTPROV
Definition: crypt.h:59
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
Definition: path.c:42
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_updates_bytes_to_ pdwDataLen BYTE * pbData
Definition: wincrypt.h:4201

Referenced by test_block_cipher_modes(), test_des(), test_key_permissions(), test_rc2(), test_rc4(), test_rsa_encrypt(), and test_schannel_provider().

◆ CryptSetProviderA()

BOOL WINAPI CryptSetProviderA ( LPCSTR  pszProvName,
DWORD  dwProvType 
)

Definition at line 2041 of file crypt.c.

2042 {
2043  TRACE("(%s, %d)\n", pszProvName, dwProvType);
2045 }
BOOL WINAPI CryptSetProviderExA(LPCSTR pszProvName, DWORD dwProvType, DWORD *pdwReserved, DWORD dwFlags)
Definition: crypt.c:2154
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
_Reserved_ DWORD _In_ DWORD _Out_writes_bytes_to_opt_ pcbProvName LPSTR pszProvName
Definition: wincrypt.h:4358
#define CRYPT_USER_DEFAULT
Definition: wincrypt.h:2077

◆ CryptSetProviderExA()

BOOL WINAPI CryptSetProviderExA ( LPCSTR  pszProvName,
DWORD  dwProvType,
DWORD pdwReserved,
DWORD  dwFlags 
)

Definition at line 2154 of file crypt.c.

2155 {
2156  BOOL ret = FALSE;
2157  PWSTR str = NULL;
2158 
2159  TRACE("(%s, %d, %p, %08x)\n", pszProvName, dwProvType, pdwReserved, dwFlags);
2160 
2161  if (CRYPT_ANSIToUnicode(pszProvName, &str, -1))
2162  {
2163  ret = CryptSetProviderExW(str, dwProvType, pdwReserved, dwFlags);
2164  CRYPT_Free(str);
2165  }
2166  return ret;
2167 }
#define CRYPT_Free(buffer)
Definition: crypt.c:62
static BOOL CRYPT_ANSIToUnicode(LPCSTR str, LPWSTR *wstr, int wstrsize)
Definition: crypt.c:158
uint16_t * PWSTR
Definition: typedefs.h:54
unsigned int BOOL
Definition: ntddk_ex.h:94
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
_Reserved_ DWORD _In_ DWORD _Out_writes_bytes_to_opt_ pcbProvName LPSTR pszProvName
Definition: wincrypt.h:4358
int ret
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
_Reserved_ DWORD * pdwReserved
Definition: wincrypt.h:4254
BOOL WINAPI CryptSetProviderExW(LPCWSTR pszProvName, DWORD dwProvType, DWORD *pdwReserved, DWORD dwFlags)
Definition: crypt.c:2073

Referenced by CryptSetProviderA().

◆ CryptSetProviderExW()

BOOL WINAPI CryptSetProviderExW ( LPCWSTR  pszProvName,
DWORD  dwProvType,
DWORD pdwReserved,
DWORD  dwFlags 
)

Definition at line 2073 of file crypt.c.

2074 {
2075  HKEY hProvKey, hTypeKey;
2076  PWSTR keyname;
2077  static const WCHAR nameW[] = {'N','a','m','e',0};
2078 
2079  TRACE("(%s, %d, %p, %08x)\n", debugstr_w(pszProvName), dwProvType, pdwReserved, dwFlags);
2080 
2081  if (!pszProvName || pdwReserved)
2082  {
2084  return FALSE;
2085  }
2086  if (dwProvType > MAXPROVTYPES)
2087  {
2089  return FALSE;
2090  }
2093  {
2095  return FALSE;
2096  }
2097 
2098  if (!(keyname = CRYPT_GetTypeKeyName(dwProvType, dwFlags & CRYPT_USER_DEFAULT)))
2099  {
2101  return FALSE;
2102  }
2104  keyname, &hTypeKey))
2105  {
2106  CRYPT_Free(keyname);
2108  return FALSE;
2109  }
2110  CRYPT_Free(keyname);
2111 
2113  {
2114  RegDeleteValueW(hTypeKey, nameW);
2115  }
2116  else
2117  {
2118  if (!(keyname = CRYPT_GetProvKeyName(pszProvName)))
2119  {
2120  RegCloseKey(hTypeKey);
2122  return FALSE;
2123  }
2125  keyname, &hProvKey))
2126  {
2127  CRYPT_Free(keyname);
2128  RegCloseKey(hTypeKey);
2130  return FALSE;
2131  }
2132  CRYPT_Free(keyname);
2133 
2134  if (RegSetValueExW(hTypeKey, nameW, 0, REG_SZ, (const BYTE *)pszProvName,
2135  (strlenW(pszProvName) + 1)*sizeof(WCHAR)))
2136  {
2137  RegCloseKey(hTypeKey);
2138  RegCloseKey(hProvKey);
2139  return FALSE;
2140  }
2141 
2142  RegCloseKey(hProvKey);
2143  }
2144  RegCloseKey(hTypeKey);
2145 
2146  return TRUE;
2147 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define MAXPROVTYPES
Definition: crypt.h:87
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define CRYPT_Free(buffer)
Definition: crypt.c:62
uint16_t * PWSTR
Definition: typedefs.h:54
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
static PWSTR CRYPT_GetProvKeyName(PCWSTR pProvName)
Definition: crypt.c:64
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3311
#define debugstr_w
Definition: kernel32.h:32
static const WCHAR nameW[]
Definition: main.c:46
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4917
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NTE_BAD_PROV_TYPE
Definition: winerror.h:2888
#define SetLastError(x)
Definition: compat.h:409
#define NTE_BAD_PROVIDER
Definition: winerror.h:2887
_Reserved_ DWORD _In_ DWORD _Out_writes_bytes_to_opt_ pcbProvName LPSTR pszProvName
Definition: wincrypt.h:4358
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
unsigned char BYTE
Definition: mem.h:68
_Reserved_ DWORD * pdwReserved
Definition: wincrypt.h:4254
#define CRYPT_USER_DEFAULT
Definition: wincrypt.h:2077
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2368
#define CRYPT_DELETE_DEFAULT
Definition: wincrypt.h:2078
static PWSTR CRYPT_GetTypeKeyName(DWORD dwType, BOOL user)
Definition: crypt.c:85
#define NTE_BAD_FLAGS
Definition: winerror.h:2877
#define CRYPT_MACHINE_DEFAULT
Definition: wincrypt.h:2076
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define REG_SZ
Definition: layer.c:22

Referenced by CryptSetProviderExA(), and CryptSetProviderW().

◆ CryptSetProviderW()

BOOL WINAPI CryptSetProviderW ( LPCWSTR  pszProvName,
DWORD  dwProvType 
)

Definition at line 2052 of file crypt.c.

2053 {
2054  TRACE("(%s, %d)\n", debugstr_w(pszProvName), dwProvType);
2056 }
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
_Reserved_ DWORD _In_ DWORD _Out_writes_bytes_to_opt_ pcbProvName LPSTR pszProvName
Definition: wincrypt.h:4358
BOOL WINAPI CryptSetProviderExW(LPCWSTR pszProvName, DWORD dwProvType, DWORD *pdwReserved, DWORD dwFlags)
Definition: crypt.c:2073
#define CRYPT_USER_DEFAULT
Definition: wincrypt.h:2077

◆ CryptSetProvParam()

BOOL WINAPI CryptSetProvParam ( HCRYPTPROV  hProv,
DWORD  dwParam,
const BYTE pbData,
DWORD  dwFlags 
)

Definition at line 2184 of file crypt.c.

2185 {
2186  PCRYPTPROV prov = (PCRYPTPROV)hProv;
2187 
2188  TRACE("(0x%lx, %d, %p, %08x)\n", hProv, dwParam, pbData, dwFlags);
2189 
2190  if (!prov)
2191  {
2193  return FALSE;
2194  }
2195  if (prov->dwMagic != MAGIC_CRYPTPROV)
2196  {
2198  return FALSE;
2199  }
2200  if (dwParam == PP_USE_HARDWARE_RNG)
2201  {
2202  FIXME("PP_USE_HARDWARE_RNG: What do I do with this?\n");
2203  FIXME("\tLetting the CSP decide.\n");
2204  }
2205  if (dwFlags & PP_CLIENT_HWND)
2206  {
2207  /* FIXME: Should verify the parameter */
2208  if (pbData /* && IsWindow((HWND)pbData) */)
2209  {
2210  crypt_hWindow = (HWND)(pbData);
2211  return TRUE;
2212  } else {
2214  return FALSE;
2215  }
2216  }
2217  /* All other flags go to the CSP */
2218  return prov->pFuncs->pCPSetProvParam(prov->hPrivate, dwParam, pbData, dwFlags);
2219 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define PP_CLIENT_HWND
Definition: wincrypt.h:2081
#define TRUE
Definition: types.h:120
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
HANDLE HWND
Definition: compat.h:13
static HCRYPTPROV hProv
Definition: rsaenh.c:32
struct tagCRYPTPROV * PCRYPTPROV
HCRYPTPROV hPrivate
Definition: crypt.h:69
#define FIXME(fmt,...)
Definition: debug.h:110
PPROVFUNCS pFuncs
Definition: crypt.h:68
#define MAGIC_CRYPTPROV
Definition: crypt.h:59
#define PP_USE_HARDWARE_RNG
Definition: wincrypt.h:2113
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
DWORD dwMagic
Definition: crypt.h:65
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
static HWND crypt_hWindow
Definition: crypt.c:59
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_updates_bytes_to_ pdwDataLen BYTE * pbData
Definition: wincrypt.h:4201

Referenced by CRYPT_AcquirePrivateKeyFromProvInfo(), and export_acquire_private_key().

◆ CryptSignHashA()

BOOL WINAPI CryptSignHashA ( HCRYPTHASH  hHash,
DWORD  dwKeySpec,
LPCSTR  sDescription,
DWORD  dwFlags,
BYTE pbSignature,
DWORD pdwSigLen 
)

Definition at line 1944 of file crypt.c.

1946 {
1947  LPWSTR wsDescription;
1948  BOOL result;
1949 
1950  TRACE("(0x%lx, %d, %s, %08x, %p, %p)\n",
1951  hHash, dwKeySpec, debugstr_a(sDescription), dwFlags, pbSignature, pdwSigLen);
1952 
1953  CRYPT_ANSIToUnicode(sDescription, &wsDescription, -1);
1954  result = CryptSignHashW(hHash, dwKeySpec, wsDescription, dwFlags, pbSignature, pdwSigLen);
1955  CRYPT_Free(wsDescription);
1956 
1957  return result;
1958 }
#define CRYPT_Free(buffer)
Definition: crypt.c:62
_In_ HCRYPTHASH hHash
Definition: wincrypt.h:4198
static BOOL CRYPT_ANSIToUnicode(LPCSTR str, LPWSTR *wstr, int wstrsize)
Definition: crypt.c:158
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
BOOL WINAPI CryptSignHashW(HCRYPTHASH hHash, DWORD dwKeySpec, LPCWSTR sDescription, DWORD dwFlags, BYTE *pbSignature, DWORD *pdwSigLen)
Definition: crypt.c:1913
WCHAR * LPWSTR
Definition: xmlstorage.h:184
GLuint64EXT * result
Definition: glext.h:11304

Referenced by test_hashes(), and verifySig().

◆ CryptSignHashW()

BOOL WINAPI CryptSignHashW ( HCRYPTHASH  hHash,
DWORD  dwKeySpec,
LPCWSTR  sDescription,
DWORD  dwFlags,
BYTE pbSignature,
DWORD pdwSigLen 
)

Definition at line 1913 of file crypt.c.

1915 {
1917  PCRYPTPROV prov;
1918 
1919  TRACE("(0x%lx, %d, %s, %08x, %p, %p)\n",
1920  hHash, dwKeySpec, debugstr_w(sDescription), dwFlags, pbSignature, pdwSigLen);
1921 
1922  if (!hash)
1923  {
1925  return FALSE;
1926  }
1927  if (!pdwSigLen || !hash->pProvider || hash->dwMagic != MAGIC_CRYPTHASH ||
1928  hash->pProvider->dwMagic != MAGIC_CRYPTPROV)
1929  {
1931  return FALSE;
1932  }
1933 
1934  prov = hash->pProvider;
1935  return prov->pFuncs->pCPSignHash(prov->hPrivate, hash->hPrivate, dwKeySpec, sDescription,
1936  dwFlags, pbSignature, pdwSigLen);
1937 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
_In_ HCRYPTHASH hHash
Definition: wincrypt.h:4198
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
#define MAGIC_CRYPTHASH
Definition: crypt.h:61
HCRYPTPROV hPrivate
Definition: crypt.h:69
#define debugstr_w
Definition: kernel32.h:32
PPROVFUNCS pFuncs
Definition: crypt.h:68
#define MAGIC_CRYPTPROV
Definition: crypt.h:59
struct tagCRYPTHASH * PCRYPTHASH
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
Definition: _hash_fun.h:40

Referenced by CryptSignCertificate(), CryptSignHashA(), and CSignedMsgData_Sign().

◆ CryptVerifySignatureA()

BOOL WINAPI CryptVerifySignatureA ( HCRYPTHASH  hHash,
const BYTE pbSignature,
DWORD  dwSigLen,
HCRYPTKEY  hPubKey,
LPCSTR  sDescription,
DWORD  dwFlags 
)

Definition at line 2271 of file crypt.c.

2273 {
2274  LPWSTR wsDescription;
2275  BOOL result;
2276 
2277  TRACE("(0x%lx, %p, %d, 0x%lx, %s, %08x)\n", hHash, pbSignature,
2278  dwSigLen, hPubKey, debugstr_a(sDescription), dwFlags);
2279 
2280  CRYPT_ANSIToUnicode(sDescription, &wsDescription, -1);
2281  result = CryptVerifySignatureW(hHash, pbSignature, dwSigLen, hPubKey, wsDescription, dwFlags);
2282  CRYPT_Free(wsDescription);
2283 
2284  return result;
2285 }
#define CRYPT_Free(buffer)
Definition: crypt.c:62
_In_ HCRYPTHASH hHash
Definition: wincrypt.h:4198
static BOOL CRYPT_ANSIToUnicode(LPCSTR str, LPWSTR *wstr, int wstrsize)
Definition: crypt.c:158
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI CryptVerifySignatureW(HCRYPTHASH hHash, const BYTE *pbSignature, DWORD dwSigLen, HCRYPTKEY hPubKey, LPCWSTR sDescription, DWORD dwFlags)
Definition: crypt.c:2243
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
WCHAR * LPWSTR
Definition: xmlstorage.h:184
GLuint64EXT * result
Definition: glext.h:11304

Referenced by test_verify_signature().

◆ CryptVerifySignatureW()

BOOL WINAPI CryptVerifySignatureW ( HCRYPTHASH  hHash,
const BYTE pbSignature,
DWORD  dwSigLen,
HCRYPTKEY  hPubKey,
LPCWSTR  sDescription,
DWORD  dwFlags 
)

Definition at line 2243 of file crypt.c.

2245 {
2247  PCRYPTKEY key = (PCRYPTKEY)hPubKey;
2248  PCRYPTPROV prov;
2249 
2250  TRACE("(0x%lx, %p, %d, 0x%lx, %s, %08x)\n", hHash, pbSignature,
2251  dwSigLen, hPubKey, debugstr_w(sDescription), dwFlags);
2252 
2253  if (!hash || !key || key->dwMagic != MAGIC_CRYPTKEY || hash->dwMagic != MAGIC_CRYPTHASH ||
2254  !hash->pProvider || hash->pProvider->dwMagic != MAGIC_CRYPTPROV ||
2255  !key->pProvider || key->pProvider->dwMagic != MAGIC_CRYPTPROV)
2256  {
2258  return FALSE;
2259  }
2260 
2261  prov = hash->pProvider;
2262  return prov->pFuncs->pCPVerifySignature(prov->hPrivate, hash->hPrivate, pbSignature, dwSigLen,
2263  key->hPrivate, sDescription, dwFlags);
2264 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
_In_ HCRYPTHASH hHash
Definition: wincrypt.h:4198
struct tagCRYPTKEY * PCRYPTKEY
#define MAGIC_CRYPTHASH
Definition: crypt.h:61
#define MAGIC_CRYPTKEY
Definition: crypt.h:60
HCRYPTPROV hPrivate
Definition: crypt.h:69
#define debugstr_w
Definition: kernel32.h:32
PPROVFUNCS pFuncs
Definition: crypt.h:68
#define MAGIC_CRYPTPROV
Definition: crypt.h:59
struct tagCRYPTHASH * PCRYPTHASH
#define TRACE(s)
Definition: solgame.cpp:4
#define SetLastError(x)
Definition: compat.h:409
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
Definition: _hash_fun.h:40
Definition: path.c:42

Referenced by CDecodeSignedMsg_VerifySignatureWithKey(), CRYPT_VerifySignature(), and CryptVerifySignatureA().

◆ OpenEncryptedFileRawA()

DWORD WINAPI OpenEncryptedFileRawA ( LPCSTR  filename,
ULONG  flags,
PVOID context 
)

Definition at line 2292 of file crypt.c.

2293 {
2294  FIXME("(%s, %x, %p): stub\n", debugstr_a(filename), flags, context);
2296 }
Definition: http.c:6587
const char * filename
Definition: ioapi.h:135
#define FIXME(fmt,...)
Definition: debug.h:110
#define debugstr_a
Definition: kernel32.h:31
GLbitfield flags
Definition: glext.h:7161
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92

◆ OpenEncryptedFileRawW()

DWORD WINAPI OpenEncryptedFileRawW ( LPCWSTR  filename,
ULONG  flags,
PVOID context 
)

Definition at line 2311 of file crypt.c.

2312 {
2313  FIXME("(%s, %x, %p): stub\n", debugstr_w(filename), flags, context);
2315 }
Definition: http.c:6587
const char * filename
Definition: ioapi.h:135
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
GLbitfield flags
Definition: glext.h:7161
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92

◆ ReadEncryptedFileRaw()

DWORD WINAPI ReadEncryptedFileRaw ( PFE_EXPORT_FUNC  export,
PVOID  callback,
PVOID  context 
)

Definition at line 2330 of file crypt.c.

2331 {
2332  FIXME("(%p, %p, %p): stub\n", export, callback, context);
2334 }
Definition: http.c:6587
#define FIXME(fmt,...)
Definition: debug.h:110
MmuTrapHandler callback[0x30]
Definition: mmuobject.c:44
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92

◆ SystemFunction030()

BOOL WINAPI SystemFunction030 ( LPCVOID  b1,
LPCVOID  b2 
)

Definition at line 2349 of file crypt.c.

2350 {
2351  return !memcmp(b1, b2, 0x10);
2352 }
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
static CRYPT_DATA_BLOB b1[]
Definition: msg.c:573
static CRYPT_DATA_BLOB b2[]
Definition: msg.c:582

◆ SystemFunction035()

BOOL WINAPI SystemFunction035 ( LPCSTR  lpszDllFilePath)

Definition at line 2363 of file crypt.c.

2364 {
2365  FIXME("%s: stub\n", debugstr_a(lpszDllFilePath));
2366  return TRUE;
2367 }
#define TRUE
Definition: types.h:120
#define FIXME(fmt,...)
Definition: debug.h:110
#define debugstr_a
Definition: kernel32.h:31

◆ SystemFunction036()

BOOLEAN WINAPI SystemFunction036 ( PVOID  pbBuffer,
ULONG  dwLen 
)

Definition at line 2383 of file crypt.c.

2384 {
2385  int dev_random;
2386 
2387  dev_random = open("/dev/urandom", O_RDONLY);
2388  if (dev_random != -1)
2389  {
2390  if (!IsBadWritePtr( pbBuffer, dwLen ) &&
2391  read(dev_random, pbBuffer, dwLen) == (ssize_t)dwLen)
2392  {
2393  close(dev_random);
2394  return TRUE;
2395  }
2396  close(dev_random);
2397  }
2398  else
2399  FIXME("couldn't open /dev/urandom\n");
2401  return FALSE;
2402 }
#define TRUE
Definition: types.h:120
BOOL NTAPI IsBadWritePtr(IN LPVOID lp, IN UINT_PTR ucb)
Definition: except.c:885
#define open
Definition: acwin.h:71
#define NTE_FAIL
Definition: winerror.h:2900
#define FIXME(fmt,...)
Definition: debug.h:110
#define SetLastError(x)
Definition: compat.h:409
int ssize_t
Definition: rosdhcp.h:48
#define close
Definition: acwin.h:74
_CRTIMP int __cdecl read(_In_ int _FileHandle, _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, _In_ unsigned int _MaxCharCount)
#define O_RDONLY
Definition: acwin.h:82

Referenced by gen_rand_impl().

◆ SystemFunction040()

NTSTATUS WINAPI SystemFunction040 ( PVOID  memory,
ULONG  length,
ULONG  flags 
)

Definition at line 2431 of file crypt.c.

2432 {
2433  FIXME("(%p, %x, %x): stub [RtlEncryptMemory]\n", memory, length, flags);
2434  return STATUS_SUCCESS;
2435 }
static char memory[1024 *256]
Definition: process.c:116
#define FIXME(fmt,...)
Definition: debug.h:110
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
GLbitfield flags
Definition: glext.h:7161
return STATUS_SUCCESS
Definition: btrfs.c:2745

◆ SystemFunction041()

NTSTATUS WINAPI SystemFunction041 ( PVOID  memory,
ULONG  length,
ULONG  flags 
)

Definition at line 2459 of file crypt.c.

2460 {
2461  FIXME("(%p, %x, %x): stub [RtlDecryptMemory]\n", memory, length, flags);
2462  return STATUS_SUCCESS;
2463 }
static char memory[1024 *256]
Definition: process.c:116
#define FIXME(fmt,...)
Definition: debug.h:110
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
GLbitfield flags
Definition: glext.h:7161
return STATUS_SUCCESS
Definition: btrfs.c:2745

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( crypt  )

◆ WriteEncryptedFileRaw()

DWORD WINAPI WriteEncryptedFileRaw ( PFE_IMPORT_FUNC  import,
PVOID  callback,
PVOID  context 
)

Definition at line 2479 of file crypt.c.

2480 {
2481  FIXME("(%p, %p, %p): stub\n", import, callback, context);
2483 }
Definition: http.c:6587
#define FIXME(fmt,...)
Definition: debug.h:110
MmuTrapHandler callback[0x30]
Definition: mmuobject.c:44
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92

Variable Documentation

◆ crypt_hWindow

HWND crypt_hWindow
static

Definition at line 59 of file crypt.c.

Referenced by CRYPT_ReturnhWnd(), and CryptSetProvParam().