mirror of
https://github.com/reactos/reactos.git
synced 2025-05-27 21:18:15 +00:00
[ADVAPI32][SERVICES] Use the context handle to encrypt and decrypt service passwords
This commit is contained in:
parent
3965c93732
commit
4cae349811
4 changed files with 18 additions and 9 deletions
|
@ -699,6 +699,7 @@ done:
|
||||||
|
|
||||||
DWORD
|
DWORD
|
||||||
ScmDecryptPassword(
|
ScmDecryptPassword(
|
||||||
|
_In_ PVOID ContextHandle,
|
||||||
_In_ PBYTE pPassword,
|
_In_ PBYTE pPassword,
|
||||||
_In_ DWORD dwPasswordSize,
|
_In_ DWORD dwPasswordSize,
|
||||||
_Out_ PWSTR *pClearTextPassword)
|
_Out_ PWSTR *pClearTextPassword)
|
||||||
|
@ -709,7 +710,7 @@ ScmDecryptPassword(
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
/* Get the session key */
|
/* Get the session key */
|
||||||
Status = SystemFunction028(NULL,
|
Status = SystemFunction028(ContextHandle,
|
||||||
SessionKey);
|
SessionKey);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* FILE: base/system/services/rpcserver.c
|
* FILE: base/system/services/rpcserver.c
|
||||||
* PURPOSE: RPC server interface for the advapi32 calls
|
* PURPOSE: RPC server interface for the advapi32 calls
|
||||||
* COPYRIGHT: Copyright 2005-2006 Eric Kohl
|
* COPYRIGHT: Copyright 2005-2006 Eric Kohl
|
||||||
* Copyright 2006-2007 Hervé Poussineau <hpoussin@reactos.org>
|
* Copyright 2006-2007 Hervé Poussineau <hpoussin@reactos.org>
|
||||||
* Copyright 2007 Ged Murphy <gedmurphy@reactos.org>
|
* Copyright 2007 Ged Murphy <gedmurphy@reactos.org>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -2208,7 +2208,8 @@ RChangeServiceConfigW(
|
||||||
if (*(LPWSTR)lpPassword != 0)
|
if (*(LPWSTR)lpPassword != 0)
|
||||||
{
|
{
|
||||||
/* Decrypt the password */
|
/* Decrypt the password */
|
||||||
dwError = ScmDecryptPassword(lpPassword,
|
dwError = ScmDecryptPassword(hService,
|
||||||
|
lpPassword,
|
||||||
dwPwSize,
|
dwPwSize,
|
||||||
&lpClearTextPassword);
|
&lpClearTextPassword);
|
||||||
if (dwError != ERROR_SUCCESS)
|
if (dwError != ERROR_SUCCESS)
|
||||||
|
@ -2609,7 +2610,8 @@ RCreateServiceW(
|
||||||
if (lpPassword != NULL && *(LPWSTR)lpPassword != 0)
|
if (lpPassword != NULL && *(LPWSTR)lpPassword != 0)
|
||||||
{
|
{
|
||||||
/* Decrypt the password */
|
/* Decrypt the password */
|
||||||
dwError = ScmDecryptPassword(lpPassword,
|
dwError = ScmDecryptPassword(hSCManager,
|
||||||
|
lpPassword,
|
||||||
dwPwSize,
|
dwPwSize,
|
||||||
&lpClearTextPassword);
|
&lpClearTextPassword);
|
||||||
if (dwError != ERROR_SUCCESS)
|
if (dwError != ERROR_SUCCESS)
|
||||||
|
|
|
@ -155,6 +155,7 @@ ScmDeleteRegKey(
|
||||||
|
|
||||||
DWORD
|
DWORD
|
||||||
ScmDecryptPassword(
|
ScmDecryptPassword(
|
||||||
|
_In_ PVOID ContextHandle,
|
||||||
_In_ PBYTE pPassword,
|
_In_ PBYTE pPassword,
|
||||||
_In_ DWORD dwPasswordSize,
|
_In_ DWORD dwPasswordSize,
|
||||||
_Out_ PWSTR *pDecryptedPassword);
|
_Out_ PWSTR *pDecryptedPassword);
|
||||||
|
|
|
@ -171,6 +171,7 @@ ScmRpcStatusToWinError(RPC_STATUS Status)
|
||||||
static
|
static
|
||||||
DWORD
|
DWORD
|
||||||
ScmEncryptPassword(
|
ScmEncryptPassword(
|
||||||
|
_In_ PVOID ContextHandle,
|
||||||
_In_ PCWSTR pClearTextPassword,
|
_In_ PCWSTR pClearTextPassword,
|
||||||
_Out_ PBYTE *pEncryptedPassword,
|
_Out_ PBYTE *pEncryptedPassword,
|
||||||
_Out_ PDWORD pEncryptedPasswordSize)
|
_Out_ PDWORD pEncryptedPasswordSize)
|
||||||
|
@ -181,7 +182,7 @@ ScmEncryptPassword(
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
/* Get the session key */
|
/* Get the session key */
|
||||||
Status = SystemFunction028(NULL,
|
Status = SystemFunction028(ContextHandle,
|
||||||
SessionKey);
|
SessionKey);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
@ -417,7 +418,8 @@ ChangeServiceConfigA(SC_HANDLE hService,
|
||||||
(int)(strlen(lpPassword) + 1));
|
(int)(strlen(lpPassword) + 1));
|
||||||
|
|
||||||
/* Encrypt the unicode password */
|
/* Encrypt the unicode password */
|
||||||
dwError = ScmEncryptPassword(lpPasswordW,
|
dwError = ScmEncryptPassword(hService,
|
||||||
|
lpPasswordW,
|
||||||
&lpEncryptedPassword,
|
&lpEncryptedPassword,
|
||||||
&dwPasswordSize);
|
&dwPasswordSize);
|
||||||
if (dwError != ERROR_SUCCESS)
|
if (dwError != ERROR_SUCCESS)
|
||||||
|
@ -517,7 +519,8 @@ ChangeServiceConfigW(SC_HANDLE hService,
|
||||||
|
|
||||||
if (lpPassword != NULL)
|
if (lpPassword != NULL)
|
||||||
{
|
{
|
||||||
dwError = ScmEncryptPassword(lpPassword,
|
dwError = ScmEncryptPassword(hService,
|
||||||
|
lpPassword,
|
||||||
&lpEncryptedPassword,
|
&lpEncryptedPassword,
|
||||||
&dwPasswordSize);
|
&dwPasswordSize);
|
||||||
if (dwError != ERROR_SUCCESS)
|
if (dwError != ERROR_SUCCESS)
|
||||||
|
@ -742,7 +745,8 @@ CreateServiceA(SC_HANDLE hSCManager,
|
||||||
(int)(strlen(lpPassword) + 1));
|
(int)(strlen(lpPassword) + 1));
|
||||||
|
|
||||||
/* Encrypt the password */
|
/* Encrypt the password */
|
||||||
dwError = ScmEncryptPassword(lpPasswordW,
|
dwError = ScmEncryptPassword(hSCManager,
|
||||||
|
lpPasswordW,
|
||||||
&lpEncryptedPassword,
|
&lpEncryptedPassword,
|
||||||
&dwPasswordSize);
|
&dwPasswordSize);
|
||||||
if (dwError != ERROR_SUCCESS)
|
if (dwError != ERROR_SUCCESS)
|
||||||
|
@ -856,7 +860,8 @@ CreateServiceW(SC_HANDLE hSCManager,
|
||||||
if (lpPassword != NULL)
|
if (lpPassword != NULL)
|
||||||
{
|
{
|
||||||
/* Encrypt the password */
|
/* Encrypt the password */
|
||||||
dwError = ScmEncryptPassword(lpPassword,
|
dwError = ScmEncryptPassword(hSCManager,
|
||||||
|
lpPassword,
|
||||||
&lpEncryptedPassword,
|
&lpEncryptedPassword,
|
||||||
&dwPasswordSize);
|
&dwPasswordSize);
|
||||||
if (dwError != ERROR_SUCCESS)
|
if (dwError != ERROR_SUCCESS)
|
||||||
|
|
Loading…
Reference in a new issue