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
58269419
Commit
58269419
authored
Nov 06, 2007
by
Juan Lang
Committed by
Alexandre Julliard
Nov 07, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rsaenh: Use helper function to persist keys.
parent
95c72855
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
64 deletions
+63
-64
rsaenh.c
dlls/rsaenh/rsaenh.c
+63
-64
No files found.
dlls/rsaenh/rsaenh.c
View file @
58269419
...
@@ -858,61 +858,42 @@ static HCRYPTKEY new_key(HCRYPTPROV hProv, ALG_ID aiAlgid, DWORD dwFlags, CRYPTK
...
@@ -858,61 +858,42 @@ static HCRYPTKEY new_key(HCRYPTPROV hProv, ALG_ID aiAlgid, DWORD dwFlags, CRYPTK
}
}
/******************************************************************************
/******************************************************************************
*
destroy_key_containe
r [Internal]
*
store_key_pai
r [Internal]
*
*
*
Destructor for key containers.
*
Stores a key pair to the registry
*
*
* PARAMS
* PARAMS
* pObjectHdr [I] Pointer to the key container to be destroyed.
* hCryptKey [I] Handle to the key to be stored
* hKey [I] Registry key where the key pair is to be stored
* szValueName [I] Registry value where key pair's value is to be stored
* dwFlags [I] Flags for protecting the key
*/
*/
static
void
destroy_key_container
(
OBJECTHDR
*
pObjectHdr
)
static
void
store_key_pair
(
HCRYPTKEY
hCryptKey
,
HKEY
hKey
,
LPCSTR
szValueName
,
DWORD
dwFlags
)
{
{
KEYCONTAINER
*
pKeyContainer
=
(
KEYCONTAINER
*
)
pObjectHdr
;
DATA_BLOB
blobIn
,
blobOut
;
DATA_BLOB
blobIn
,
blobOut
;
CRYPTKEY
*
pKey
;
CRYPTKEY
*
pKey
;
CHAR
szRSABase
[
MAX_PATH
];
HKEY
hKey
,
hRootKey
;
DWORD
dwLen
;
DWORD
dwLen
;
BYTE
*
pbKey
;
BYTE
*
pbKey
;
if
(
!
(
pKeyContainer
->
dwFlags
&
CRYPT_VERIFYCONTEXT
))
{
if
(
lookup_handle
(
&
handle_table
,
hCryptKey
,
RSAENH_MAGIC_KEY
,
/* On WinXP, persistent keys are stored in a file located at:
* $AppData$\\Microsoft\\Crypto\\RSA\\$SID$\\some_hex_string
*/
sprintf
(
szRSABase
,
RSAENH_REGKEY
,
pKeyContainer
->
szName
);
if
(
pKeyContainer
->
dwFlags
&
CRYPT_MACHINE_KEYSET
)
{
hRootKey
=
HKEY_LOCAL_MACHINE
;
}
else
{
hRootKey
=
HKEY_CURRENT_USER
;
}
/* @@ Wine registry key: HKLM\Software\Wine\Crypto\RSA */
/* @@ Wine registry key: HKCU\Software\Wine\Crypto\RSA */
if
(
RegCreateKeyExA
(
hRootKey
,
szRSABase
,
0
,
NULL
,
REG_OPTION_NON_VOLATILE
,
KEY_WRITE
,
NULL
,
&
hKey
,
NULL
)
==
ERROR_SUCCESS
)
{
if
(
lookup_handle
(
&
handle_table
,
pKeyContainer
->
hKeyExchangeKeyPair
,
RSAENH_MAGIC_KEY
,
(
OBJECTHDR
**
)
&
pKey
))
(
OBJECTHDR
**
)
&
pKey
))
{
{
if
(
RSAENH_CPExportKey
(
pKey
->
hProv
,
pKeyContainer
->
hKeyExchangeKeyPair
,
0
,
if
(
RSAENH_CPExportKey
(
pKey
->
hProv
,
hCryptKey
,
0
,
PRIVATEKEYBLOB
,
0
,
0
,
PRIVATEKEYBLOB
,
0
,
0
,
&
dwLen
))
&
dwLen
))
{
{
pbKey
=
HeapAlloc
(
GetProcessHeap
(),
0
,
dwLen
);
pbKey
=
HeapAlloc
(
GetProcessHeap
(),
0
,
dwLen
);
if
(
pbKey
)
if
(
pbKey
)
{
{
if
(
RSAENH_CPExportKey
(
pKey
->
hProv
,
pKeyContainer
->
hKeyExchangeKeyPair
,
0
,
if
(
RSAENH_CPExportKey
(
pKey
->
hProv
,
hCryptKey
,
0
,
PRIVATEKEYBLOB
,
0
,
pbKey
,
&
dwLen
))
PRIVATEKEYBLOB
,
0
,
pbKey
,
&
dwLen
))
{
{
blobIn
.
pbData
=
pbKey
;
blobIn
.
pbData
=
pbKey
;
blobIn
.
cbData
=
dwLen
;
blobIn
.
cbData
=
dwLen
;
if
(
CryptProtectData
(
&
blobIn
,
NULL
,
NULL
,
NULL
,
NULL
,
if
(
CryptProtectData
(
&
blobIn
,
NULL
,
NULL
,
NULL
,
NULL
,
(
pKeyContainer
->
dwFlags
&
CRYPT_MACHINE_KEYSET
)
?
dwFlags
,
&
blobOut
))
CRYPTPROTECT_LOCAL_MACHINE
:
0
,
&
blobOut
))
{
{
RegSetValueExA
(
hKey
,
"KeyExchangeKeyPair"
,
0
,
REG_BINARY
,
RegSetValueExA
(
hKey
,
szValueName
,
0
,
REG_BINARY
,
blobOut
.
pbData
,
blobOut
.
cbData
);
blobOut
.
pbData
,
blobOut
.
cbData
);
HeapFree
(
GetProcessHeap
(),
0
,
blobOut
.
pbData
);
HeapFree
(
GetProcessHeap
(),
0
,
blobOut
.
pbData
);
}
}
...
@@ -920,46 +901,64 @@ static void destroy_key_container(OBJECTHDR *pObjectHdr)
...
@@ -920,46 +901,64 @@ static void destroy_key_container(OBJECTHDR *pObjectHdr)
HeapFree
(
GetProcessHeap
(),
0
,
pbKey
);
HeapFree
(
GetProcessHeap
(),
0
,
pbKey
);
}
}
}
}
release_handle
(
&
handle_table
,
pKeyContainer
->
hKeyExchangeKeyPair
,
release_handle
(
&
handle_table
,
hCryptKey
,
RSAENH_MAGIC_KEY
);
RSAENH_MAGIC_KEY
);
}
}
}
if
(
lookup_handle
(
&
handle_table
,
pKeyContainer
->
hSignatureKeyPair
,
RSAENH_MAGIC_KEY
,
/******************************************************************************
(
OBJECTHDR
**
)
&
pKey
))
* store_key_container_keys [Internal]
{
*
if
(
RSAENH_CPExportKey
(
pKey
->
hProv
,
pKeyContainer
->
hSignatureKeyPair
,
0
,
* Stores key container's keys in a persistent location.
PRIVATEKEYBLOB
,
0
,
0
,
&
dwLen
))
*
{
* PARAMS
pbKey
=
HeapAlloc
(
GetProcessHeap
(),
0
,
dwLen
);
* pKeyContainer [I] Pointer to the key container to be destroyed.
if
(
pbKey
)
*/
{
static
void
store_key_container_keys
(
KEYCONTAINER
*
pKeyContainer
)
if
(
RSAENH_CPExportKey
(
pKey
->
hProv
,
pKeyContainer
->
hSignatureKeyPair
,
0
,
{
PRIVATEKEYBLOB
,
0
,
pbKey
,
&
dwLen
))
CHAR
szRSABase
[
MAX_PATH
];
{
HKEY
hKey
,
hRootKey
;
blobIn
.
pbData
=
pbKey
;
DWORD
dwFlags
;
blobIn
.
cbData
=
dwLen
;
if
(
CryptProtectData
(
&
blobIn
,
NULL
,
NULL
,
NULL
,
NULL
,
/* On WinXP, persistent keys are stored in a file located at:
(
pKeyContainer
->
dwFlags
&
CRYPT_MACHINE_KEYSET
)
?
* $AppData$\\Microsoft\\Crypto\\RSA\\$SID$\\some_hex_string
CRYPTPROTECT_LOCAL_MACHINE
:
0
,
*/
&
blobOut
))
sprintf
(
szRSABase
,
RSAENH_REGKEY
,
pKeyContainer
->
szName
);
{
RegSetValueExA
(
hKey
,
"SignatureKeyPair"
,
0
,
REG_BINARY
,
if
(
pKeyContainer
->
dwFlags
&
CRYPT_MACHINE_KEYSET
)
{
blobOut
.
pbData
,
blobOut
.
cbData
);
hRootKey
=
HKEY_LOCAL_MACHINE
;
HeapFree
(
GetProcessHeap
(),
0
,
blobOut
.
pbData
);
dwFlags
=
CRYPTPROTECT_LOCAL_MACHINE
;
}
}
else
{
}
hRootKey
=
HKEY_CURRENT_USER
;
HeapFree
(
GetProcessHeap
(),
0
,
pbKey
);
dwFlags
=
0
;
}
}
release_handle
(
&
handle_table
,
pKeyContainer
->
hSignatureKeyPair
,
RSAENH_MAGIC_KEY
);
}
}
/* @@ Wine registry key: HKLM\Software\Wine\Crypto\RSA */
/* @@ Wine registry key: HKCU\Software\Wine\Crypto\RSA */
if
(
RegCreateKeyExA
(
hRootKey
,
szRSABase
,
0
,
NULL
,
REG_OPTION_NON_VOLATILE
,
KEY_WRITE
,
NULL
,
&
hKey
,
NULL
)
==
ERROR_SUCCESS
)
{
store_key_pair
(
pKeyContainer
->
hKeyExchangeKeyPair
,
hKey
,
"KeyExchangeKeyPair"
,
dwFlags
);
store_key_pair
(
pKeyContainer
->
hSignatureKeyPair
,
hKey
,
"SignatureKeyPair"
,
dwFlags
);
RegCloseKey
(
hKey
);
RegCloseKey
(
hKey
);
}
}
}
}
/******************************************************************************
* destroy_key_container [Internal]
*
* Destructor for key containers.
*
* PARAMS
* pObjectHdr [I] Pointer to the key container to be destroyed.
*/
static
void
destroy_key_container
(
OBJECTHDR
*
pObjectHdr
)
{
KEYCONTAINER
*
pKeyContainer
=
(
KEYCONTAINER
*
)
pObjectHdr
;
if
(
!
(
pKeyContainer
->
dwFlags
&
CRYPT_VERIFYCONTEXT
))
store_key_container_keys
(
pKeyContainer
);
HeapFree
(
GetProcessHeap
(),
0
,
pKeyContainer
);
HeapFree
(
GetProcessHeap
(),
0
,
pKeyContainer
);
}
}
...
...
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