Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Zsolt Vadász
wine
Commits
5408471b
Commit
5408471b
authored
17 years ago
by
Juan Lang
Committed by
Alexandre Julliard
17 years ago
Browse files
Options
Downloads
Patches
Plain Diff
rsaenh: Use helper function to read key pairs from registry.
parent
9260fcf7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dlls/rsaenh/rsaenh.c
+54
-52
54 additions, 52 deletions
dlls/rsaenh/rsaenh.c
with
54 additions
and
52 deletions
dlls/rsaenh/rsaenh.c
+
54
−
52
View file @
5408471b
...
...
@@ -1099,6 +1099,51 @@ static HCRYPTPROV new_key_container(PCCH pszContainerName, DWORD dwFlags, const
return
hKeyContainer
;
}
/******************************************************************************
* read_key_value [Internal]
*
* Reads a key pair value from the registry
*
* PARAMS
* hKeyContainer [I] Crypt provider to use to import the key
* hKey [I] Registry key from which to read the key pair
* szValueName [I] Registry value from which to read the key pair's value
* dwFlags [I] Flags for unprotecting the key
* phCryptKey [O] Returned key
*/
static
BOOL
read_key_value
(
HCRYPTPROV
hKeyContainer
,
HKEY
hKey
,
LPCSTR
szValueName
,
DWORD
dwFlags
,
HCRYPTKEY
*
phCryptKey
)
{
DWORD
dwValueType
,
dwLen
;
BYTE
*
pbKey
;
DATA_BLOB
blobIn
,
blobOut
;
BOOL
ret
=
FALSE
;
if
(
RegQueryValueExA
(
hKey
,
szValueName
,
0
,
&
dwValueType
,
NULL
,
&
dwLen
)
==
ERROR_SUCCESS
)
{
pbKey
=
HeapAlloc
(
GetProcessHeap
(),
0
,
dwLen
);
if
(
pbKey
)
{
if
(
RegQueryValueExA
(
hKey
,
szValueName
,
0
,
&
dwValueType
,
pbKey
,
&
dwLen
)
==
ERROR_SUCCESS
)
{
blobIn
.
pbData
=
pbKey
;
blobIn
.
cbData
=
dwLen
;
if
(
CryptUnprotectData
(
&
blobIn
,
NULL
,
NULL
,
NULL
,
NULL
,
dwFlags
,
&
blobOut
))
{
ret
=
RSAENH_CPImportKey
(
hKeyContainer
,
blobOut
.
pbData
,
blobOut
.
cbData
,
0
,
0
,
phCryptKey
);
HeapFree
(
GetProcessHeap
(),
0
,
blobOut
.
pbData
);
}
}
HeapFree
(
GetProcessHeap
(),
0
,
pbKey
);
}
}
return
ret
;
}
/******************************************************************************
* read_key_container [Internal]
*
...
...
@@ -1115,12 +1160,9 @@ static HCRYPTPROV new_key_container(PCCH pszContainerName, DWORD dwFlags, const
*/
static
HCRYPTPROV
read_key_container
(
PCHAR
pszContainerName
,
DWORD
dwFlags
,
const
VTableProvStruc
*
pVTable
)
{
BYTE
*
pbKey
;
HKEY
hKey
;
DWORD
dwValueType
,
dwLen
;
KEYCONTAINER
*
pKeyContainer
;
HCRYPTPROV
hKeyContainer
;
DATA_BLOB
blobIn
,
blobOut
;
HCRYPTKEY
hCryptKey
;
if
(
!
open_container_key
(
pszContainerName
,
dwFlags
,
&
hKey
))
...
...
@@ -1132,59 +1174,19 @@ static HCRYPTPROV read_key_container(PCHAR pszContainerName, DWORD dwFlags, cons
hKeyContainer
=
new_key_container
(
pszContainerName
,
dwFlags
,
pVTable
);
if
(
hKeyContainer
!=
(
HCRYPTPROV
)
INVALID_HANDLE_VALUE
)
{
DWORD
dwProtectFlags
=
(
dwFlags
&
CRYPT_MACHINE_KEYSET
)
?
CRYPTPROTECT_LOCAL_MACHINE
:
0
;
if
(
!
lookup_handle
(
&
handle_table
,
hKeyContainer
,
RSAENH_MAGIC_CONTAINER
,
(
OBJECTHDR
**
)
&
pKeyContainer
))
return
(
HCRYPTPROV
)
INVALID_HANDLE_VALUE
;
if
(
RegQueryValueExA
(
hKey
,
"KeyExchangeKeyPair"
,
0
,
&
dwValueType
,
NULL
,
&
dwLen
)
==
ERROR_SUCCESS
)
{
pbKey
=
HeapAlloc
(
GetProcessHeap
(),
0
,
dwLen
);
if
(
pbKey
)
{
if
(
RegQueryValueExA
(
hKey
,
"KeyExchangeKeyPair"
,
0
,
&
dwValueType
,
pbKey
,
&
dwLen
)
==
ERROR_SUCCESS
)
{
blobIn
.
pbData
=
pbKey
;
blobIn
.
cbData
=
dwLen
;
if
(
CryptUnprotectData
(
&
blobIn
,
NULL
,
NULL
,
NULL
,
NULL
,
(
dwFlags
&
CRYPT_MACHINE_KEYSET
)
?
CRYPTPROTECT_LOCAL_MACHINE
:
0
,
&
blobOut
))
{
if
(
RSAENH_CPImportKey
(
hKeyContainer
,
blobOut
.
pbData
,
blobOut
.
cbData
,
0
,
0
,
&
hCryptKey
))
pKeyContainer
->
hKeyExchangeKeyPair
=
hCryptKey
;
HeapFree
(
GetProcessHeap
(),
0
,
blobOut
.
pbData
);
}
}
HeapFree
(
GetProcessHeap
(),
0
,
pbKey
);
}
}
if
(
RegQueryValueExA
(
hKey
,
"SignatureKeyPair"
,
0
,
&
dwValueType
,
NULL
,
&
dwLen
)
==
ERROR_SUCCESS
)
{
pbKey
=
HeapAlloc
(
GetProcessHeap
(),
0
,
dwLen
);
if
(
pbKey
)
{
if
(
RegQueryValueExA
(
hKey
,
"SignatureKeyPair"
,
0
,
&
dwValueType
,
pbKey
,
&
dwLen
)
==
ERROR_SUCCESS
)
{
blobIn
.
pbData
=
pbKey
;
blobIn
.
cbData
=
dwLen
;
if
(
CryptUnprotectData
(
&
blobIn
,
NULL
,
NULL
,
NULL
,
NULL
,
(
dwFlags
&
CRYPT_MACHINE_KEYSET
)
?
CRYPTPROTECT_LOCAL_MACHINE
:
0
,
&
blobOut
))
{
if
(
RSAENH_CPImportKey
(
hKeyContainer
,
blobOut
.
pbData
,
blobOut
.
cbData
,
0
,
0
,
&
hCryptKey
))
pKeyContainer
->
hSignatureKeyPair
=
hCryptKey
;
HeapFree
(
GetProcessHeap
(),
0
,
blobOut
.
pbData
);
}
}
HeapFree
(
GetProcessHeap
(),
0
,
pbKey
);
}
}
if
(
read_key_value
(
hKeyContainer
,
hKey
,
"KeyExchangeKeyPair"
,
dwProtectFlags
,
&
hCryptKey
))
pKeyContainer
->
hKeyExchangeKeyPair
=
hCryptKey
;
if
(
read_key_value
(
hKeyContainer
,
hKey
,
"SignatureKeyPair"
,
dwProtectFlags
,
&
hCryptKey
))
pKeyContainer
->
hSignatureKeyPair
=
hCryptKey
;
}
return
hKeyContainer
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment