Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
c534fa1e
Commit
c534fa1e
authored
Oct 27, 2005
by
Juan Lang
Committed by
Alexandre Julliard
Oct 27, 2005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement CryptMem and undocumented I_Crypt*Tls functions, with tests.
parent
473cac84
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
155 additions
and
7 deletions
+155
-7
crypt32.spec
dlls/crypt32/crypt32.spec
+8
-7
main.c
dlls/crypt32/main.c
+45
-0
main.c
dlls/crypt32/tests/main.c
+98
-0
wincrypt.h
include/wincrypt.h
+4
-0
No files found.
dlls/crypt32/crypt32.spec
View file @
c534fa1e
...
@@ -120,9 +120,9 @@
...
@@ -120,9 +120,9 @@
@ stdcall CryptInitOIDFunctionSet(str long)
@ stdcall CryptInitOIDFunctionSet(str long)
@ stub CryptInstallOIDFunctionAddress
@ stub CryptInstallOIDFunctionAddress
@ stub CryptLoadSip
@ stub CryptLoadSip
@ st
ub CryptMemAlloc
@ st
dcall CryptMemAlloc(long)
@ st
ub CryptMemFree
@ st
dcall CryptMemFree(ptr)
@ st
ub CryptMemRealloc
@ st
dcall CryptMemRealloc(ptr long)
@ stub CryptMsgCalculateEncodedLength
@ stub CryptMsgCalculateEncodedLength
@ stub CryptMsgClose
@ stub CryptMsgClose
@ stub CryptMsgControl
@ stub CryptMsgControl
...
@@ -164,21 +164,22 @@
...
@@ -164,21 +164,22 @@
@ stub CryptVerifyMessageSignature
@ stub CryptVerifyMessageSignature
@ stub CryptVerifyMessageSignatureWithKey
@ stub CryptVerifyMessageSignatureWithKey
@ stub CryptVerifySignatureU
@ stub CryptVerifySignatureU
@ st
ub I_CryptAllocTls
@ st
dcall I_CryptAllocTls()
@ stdcall I_CryptCreateLruCache(long long)
@ stdcall I_CryptCreateLruCache(long long)
@ stub I_CryptCreateLruEntry
@ stub I_CryptCreateLruEntry
@ st
ub I_CryptDetachTls
@ st
dcall I_CryptDetachTls(long)
@ stdcall I_CryptFindLruEntryData(long)
@ stdcall I_CryptFindLruEntryData(long)
@ stdcall I_CryptFlushLruCache(long)
@ stdcall I_CryptFlushLruCache(long)
@ stdcall I_CryptFreeLruCache(long)
@ stdcall I_CryptFreeLruCache(long)
@ stdcall I_CryptFreeTls(long long)
@ stub I_CryptGetDefaultCryptProv
@ stub I_CryptGetDefaultCryptProv
@ stub I_CryptGetDefaultCryptProvForEncrypt
@ stub I_CryptGetDefaultCryptProvForEncrypt
@ stub I_CryptGetOssGlobal
@ stub I_CryptGetOssGlobal
@ st
ub I_CryptGetTls
@ st
dcall I_CryptGetTls(long)
@ stub I_CryptInsertLruEntry
@ stub I_CryptInsertLruEntry
@ stub I_CryptInstallOssGlobal
@ stub I_CryptInstallOssGlobal
@ stub I_CryptReleaseLruEntry
@ stub I_CryptReleaseLruEntry
@ st
ub I_CryptSetTls
@ st
dcall I_CryptSetTls(long ptr)
@ stub I_CryptUninstallOssGlobal
@ stub I_CryptUninstallOssGlobal
@ stub PFXExportCertStore
@ stub PFXExportCertStore
@ stub PFXImportCertStore
@ stub PFXImportCertStore
...
...
dlls/crypt32/main.c
View file @
c534fa1e
...
@@ -304,3 +304,48 @@ DWORD WINAPI CertOIDToAlgId(LPCSTR pszObjId)
...
@@ -304,3 +304,48 @@ DWORD WINAPI CertOIDToAlgId(LPCSTR pszObjId)
}
}
return
0
;
return
0
;
}
}
LPVOID
WINAPI
CryptMemAlloc
(
ULONG
cbSize
)
{
return
HeapAlloc
(
GetProcessHeap
(),
0
,
cbSize
);
}
LPVOID
WINAPI
CryptMemRealloc
(
LPVOID
pv
,
ULONG
cbSize
)
{
return
HeapReAlloc
(
GetProcessHeap
(),
0
,
pv
,
cbSize
);
}
VOID
WINAPI
CryptMemFree
(
LPVOID
pv
)
{
HeapFree
(
GetProcessHeap
(),
0
,
pv
);
}
DWORD
WINAPI
I_CryptAllocTls
(
void
)
{
return
TlsAlloc
();
}
LPVOID
WINAPI
I_CryptDetachTls
(
DWORD
dwTlsIndex
)
{
LPVOID
ret
;
ret
=
TlsGetValue
(
dwTlsIndex
);
TlsSetValue
(
dwTlsIndex
,
NULL
);
return
ret
;
}
LPVOID
WINAPI
I_CryptGetTls
(
DWORD
dwTlsIndex
)
{
return
TlsGetValue
(
dwTlsIndex
);
}
BOOL
WINAPI
I_CryptSetTls
(
DWORD
dwTlsIndex
,
LPVOID
lpTlsValue
)
{
return
TlsSetValue
(
dwTlsIndex
,
lpTlsValue
);
}
BOOL
WINAPI
I_CryptFreeTls
(
DWORD
dwTlsIndex
,
DWORD
unknown
)
{
TRACE
(
"(%ld, %ld)
\n
"
,
dwTlsIndex
,
unknown
);
return
TlsFree
(
dwTlsIndex
);
}
dlls/crypt32/tests/main.c
View file @
c534fa1e
...
@@ -274,6 +274,102 @@ static void test_verifyTimeValidity(void)
...
@@ -274,6 +274,102 @@ static void test_verifyTimeValidity(void)
ok
(
ret
==
-
1
,
"Expected -1, got %ld
\n
"
,
ret
);
ok
(
ret
==
-
1
,
"Expected -1, got %ld
\n
"
,
ret
);
}
}
static
void
test_cryptAllocate
(
void
)
{
LPVOID
buf
;
buf
=
CryptMemAlloc
(
0
);
ok
(
buf
!=
NULL
,
"CryptMemAlloc failed: %08lx
\n
"
,
GetLastError
());
CryptMemFree
(
buf
);
buf
=
CryptMemRealloc
(
NULL
,
0
);
ok
(
!
buf
,
"Expected NULL
\n
"
);
buf
=
CryptMemAlloc
(
0
);
buf
=
CryptMemRealloc
(
buf
,
1
);
ok
(
buf
!=
NULL
,
"CryptMemRealloc failed: %08lx
\n
"
,
GetLastError
());
CryptMemFree
(
buf
);
}
typedef
DWORD
(
WINAPI
*
I_CryptAllocTlsFunc
)(
void
);
typedef
LPVOID
(
WINAPI
*
I_CryptDetachTlsFunc
)(
DWORD
dwTlsIndex
);
typedef
LPVOID
(
WINAPI
*
I_CryptGetTlsFunc
)(
DWORD
dwTlsIndex
);
typedef
BOOL
(
WINAPI
*
I_CryptSetTlsFunc
)(
DWORD
dwTlsIndex
,
LPVOID
lpTlsValue
);
typedef
BOOL
(
WINAPI
*
I_CryptFreeTlsFunc
)(
DWORD
dwTlsIndex
,
DWORD
unknown
);
static
I_CryptAllocTlsFunc
pI_CryptAllocTls
;
static
I_CryptDetachTlsFunc
pI_CryptDetachTls
;
static
I_CryptGetTlsFunc
pI_CryptGetTls
;
static
I_CryptSetTlsFunc
pI_CryptSetTls
;
static
I_CryptFreeTlsFunc
pI_CryptFreeTls
;
static
void
test_cryptTls
(
void
)
{
HMODULE
lib
=
LoadLibraryA
(
"crypt32.dll"
);
if
(
lib
)
{
DWORD
index
;
BOOL
ret
;
pI_CryptAllocTls
=
(
I_CryptAllocTlsFunc
)
GetProcAddress
(
lib
,
"I_CryptAllocTls"
);
pI_CryptDetachTls
=
(
I_CryptDetachTlsFunc
)
GetProcAddress
(
lib
,
"I_CryptDetachTls"
);
pI_CryptGetTls
=
(
I_CryptGetTlsFunc
)
GetProcAddress
(
lib
,
"I_CryptGetTls"
);
pI_CryptSetTls
=
(
I_CryptSetTlsFunc
)
GetProcAddress
(
lib
,
"I_CryptSetTls"
);
pI_CryptFreeTls
=
(
I_CryptFreeTlsFunc
)
GetProcAddress
(
lib
,
"I_CryptFreeTls"
);
/* One normal pass */
index
=
pI_CryptAllocTls
();
ok
(
index
,
"I_CryptAllocTls failed: %08lx
\n
"
,
GetLastError
());
if
(
index
)
{
LPVOID
ptr
;
ptr
=
pI_CryptGetTls
(
index
);
ok
(
!
ptr
,
"Expected NULL
\n
"
);
ret
=
pI_CryptSetTls
(
index
,
(
LPVOID
)
0xdeadbeef
);
ok
(
ret
,
"I_CryptSetTls failed: %08lx
\n
"
,
GetLastError
());
ptr
=
pI_CryptGetTls
(
index
);
ok
(
ptr
==
(
LPVOID
)
0xdeadbeef
,
"Expected 0xdeadbeef, got %p
\n
"
,
ptr
);
/* This crashes
ret = pI_CryptFreeTls(index, 1);
*/
ret
=
pI_CryptFreeTls
(
index
,
0
);
ok
(
ret
,
"I_CryptFreeTls failed: %08lx
\n
"
,
GetLastError
());
ret
=
pI_CryptFreeTls
(
index
,
0
);
/* Not sure if this fails because TlsFree should fail, so leave as
* todo for now.
*/
todo_wine
ok
(
!
ret
&&
GetLastError
()
==
HRESULT_FROM_WIN32
(
ERROR_INVALID_PARAMETER
),
"Expected HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER), got %08lx
\n
"
,
GetLastError
());
}
/* Similar pass, check I_CryptDetachTls */
index
=
pI_CryptAllocTls
();
ok
(
index
,
"I_CryptAllocTls failed: %08lx
\n
"
,
GetLastError
());
if
(
index
)
{
LPVOID
ptr
;
ptr
=
pI_CryptGetTls
(
index
);
ok
(
!
ptr
,
"Expected NULL
\n
"
);
ret
=
pI_CryptSetTls
(
index
,
(
LPVOID
)
0xdeadbeef
);
ok
(
ret
,
"I_CryptSetTls failed: %08lx
\n
"
,
GetLastError
());
ptr
=
pI_CryptGetTls
(
index
);
ok
(
ptr
==
(
LPVOID
)
0xdeadbeef
,
"Expected 0xdeadbeef, got %p
\n
"
,
ptr
);
ptr
=
pI_CryptDetachTls
(
index
);
ok
(
ptr
==
(
LPVOID
)
0xdeadbeef
,
"Expected 0xdeadbeef, got %p
\n
"
,
ptr
);
ptr
=
pI_CryptGetTls
(
index
);
ok
(
!
ptr
,
"Expected NULL
\n
"
);
}
FreeLibrary
(
lib
);
}
}
START_TEST
(
main
)
START_TEST
(
main
)
{
{
testOIDToAlgID
();
testOIDToAlgID
();
...
@@ -282,4 +378,6 @@ START_TEST(main)
...
@@ -282,4 +378,6 @@ START_TEST(main)
test_findExtension
();
test_findExtension
();
test_findRDNAttr
();
test_findRDNAttr
();
test_verifyTimeValidity
();
test_verifyTimeValidity
();
test_cryptAllocate
();
test_cryptTls
();
}
}
include/wincrypt.h
View file @
c534fa1e
...
@@ -2273,6 +2273,10 @@ BOOL WINAPI CryptVerifySignatureW (HCRYPTHASH hHash, BYTE *pbSignature, DWORD dw
...
@@ -2273,6 +2273,10 @@ BOOL WINAPI CryptVerifySignatureW (HCRYPTHASH hHash, BYTE *pbSignature, DWORD dw
#define CryptVerifySignature WINELIB_NAME_AW(CryptVerifySignature)
#define CryptVerifySignature WINELIB_NAME_AW(CryptVerifySignature)
/* crypt32.dll functions */
/* crypt32.dll functions */
LPVOID
WINAPI
CryptMemAlloc
(
ULONG
cbSize
);
LPVOID
WINAPI
CryptMemRealloc
(
LPVOID
pv
,
ULONG
cbSize
);
VOID
WINAPI
CryptMemFree
(
LPVOID
pv
);
BOOL
WINAPI
CryptRegisterOIDFunction
(
DWORD
,
LPCSTR
,
LPCSTR
,
LPCWSTR
,
LPCSTR
);
BOOL
WINAPI
CryptRegisterOIDFunction
(
DWORD
,
LPCSTR
,
LPCSTR
,
LPCWSTR
,
LPCSTR
);
BOOL
WINAPI
CryptGetOIDFunctionValue
(
DWORD
dwEncodingType
,
LPCSTR
pszFuncName
,
BOOL
WINAPI
CryptGetOIDFunctionValue
(
DWORD
dwEncodingType
,
LPCSTR
pszFuncName
,
LPCSTR
pszOID
,
LPCWSTR
szValueName
,
DWORD
*
pdwValueType
,
LPCSTR
pszOID
,
LPCWSTR
szValueName
,
DWORD
*
pdwValueType
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment