mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 04:33:32 +00:00
[ADVAPI32][SERVICES] Use the session key provided by SystemFunction028 to encrypt and decrypt the service passwords.
This commit is contained in:
parent
9f87785e96
commit
76588be0d1
2 changed files with 35 additions and 6 deletions
|
@ -29,6 +29,11 @@ SystemFunction005(
|
||||||
const struct ustring *key,
|
const struct ustring *key,
|
||||||
struct ustring *out);
|
struct ustring *out);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
WINAPI
|
||||||
|
SystemFunction028(
|
||||||
|
IN PVOID ContextHandle,
|
||||||
|
OUT LPBYTE SessionKey);
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
@ -699,17 +704,26 @@ ScmDecryptPassword(
|
||||||
_Out_ PWSTR *pClearTextPassword)
|
_Out_ PWSTR *pClearTextPassword)
|
||||||
{
|
{
|
||||||
struct ustring inData, keyData, outData;
|
struct ustring inData, keyData, outData;
|
||||||
PCHAR pszKey = "TestEncryptionKey";
|
BYTE SessionKey[16];
|
||||||
PWSTR pBuffer;
|
PWSTR pBuffer;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
/* Get the session key */
|
||||||
|
Status = SystemFunction028(NULL,
|
||||||
|
SessionKey);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("SystemFunction028 failed (Status 0x%08lx)\n", Status);
|
||||||
|
return RtlNtStatusToDosError(Status);
|
||||||
|
}
|
||||||
|
|
||||||
inData.Length = dwPasswordSize;
|
inData.Length = dwPasswordSize;
|
||||||
inData.MaximumLength = inData.Length;
|
inData.MaximumLength = inData.Length;
|
||||||
inData.Buffer = pPassword;
|
inData.Buffer = pPassword;
|
||||||
|
|
||||||
keyData.Length = strlen(pszKey);
|
keyData.Length = sizeof(SessionKey);
|
||||||
keyData.MaximumLength = keyData.Length;
|
keyData.MaximumLength = keyData.Length;
|
||||||
keyData.Buffer = (unsigned char *)pszKey;
|
keyData.Buffer = SessionKey;
|
||||||
|
|
||||||
outData.Length = 0;
|
outData.Length = 0;
|
||||||
outData.MaximumLength = 0;
|
outData.MaximumLength = 0;
|
||||||
|
|
|
@ -19,6 +19,12 @@ SystemFunction004(
|
||||||
const struct ustring *key,
|
const struct ustring *key,
|
||||||
struct ustring *out);
|
struct ustring *out);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
WINAPI
|
||||||
|
SystemFunction028(
|
||||||
|
IN PVOID ContextHandle,
|
||||||
|
OUT LPBYTE SessionKey);
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
handle_t __RPC_USER
|
handle_t __RPC_USER
|
||||||
|
@ -169,17 +175,26 @@ ScmEncryptPassword(
|
||||||
_Out_ PDWORD pEncryptedPasswordSize)
|
_Out_ PDWORD pEncryptedPasswordSize)
|
||||||
{
|
{
|
||||||
struct ustring inData, keyData, outData;
|
struct ustring inData, keyData, outData;
|
||||||
PCHAR pszKey = "TestEncryptionKey";
|
BYTE SessionKey[16];
|
||||||
PBYTE pBuffer;
|
PBYTE pBuffer;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
/* Get the session key */
|
||||||
|
Status = SystemFunction028(NULL,
|
||||||
|
SessionKey);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
ERR("SystemFunction028 failed (Status 0x%08lx)\n", Status);
|
||||||
|
return RtlNtStatusToDosError(Status);
|
||||||
|
}
|
||||||
|
|
||||||
inData.Length = (wcslen(pClearTextPassword) + 1) * sizeof(WCHAR);
|
inData.Length = (wcslen(pClearTextPassword) + 1) * sizeof(WCHAR);
|
||||||
inData.MaximumLength = inData.Length;
|
inData.MaximumLength = inData.Length;
|
||||||
inData.Buffer = (unsigned char *)pClearTextPassword;
|
inData.Buffer = (unsigned char *)pClearTextPassword;
|
||||||
|
|
||||||
keyData.Length = strlen(pszKey);
|
keyData.Length = sizeof(SessionKey);
|
||||||
keyData.MaximumLength = keyData.Length;
|
keyData.MaximumLength = keyData.Length;
|
||||||
keyData.Buffer = (unsigned char *)pszKey;
|
keyData.Buffer = SessionKey;
|
||||||
|
|
||||||
outData.Length = 0;
|
outData.Length = 0;
|
||||||
outData.MaximumLength = 0;
|
outData.MaximumLength = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue