2014-09-15 21:04:03 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS api tests
|
|
|
|
* LICENSE: GPLv2+ - See COPYING in the top level directory
|
|
|
|
* PURPOSE: Test for RtlEncrypt/DecryptMemory
|
|
|
|
* PROGRAMMER: Timo Kreuzer <timo.kreuzer@reactos.org>
|
|
|
|
*/
|
|
|
|
|
2017-12-12 11:44:32 +00:00
|
|
|
#include "precomp.h"
|
2014-09-15 21:04:03 +00:00
|
|
|
|
2014-09-15 21:08:00 +00:00
|
|
|
#include <ntsecapi.h>
|
2014-09-15 21:04:03 +00:00
|
|
|
|
|
|
|
START_TEST(RtlEncryptMemory)
|
|
|
|
{
|
2016-06-15 17:45:06 +00:00
|
|
|
static const CHAR TestData[32] = "This is some test Message!!!";
|
2014-09-15 21:04:03 +00:00
|
|
|
CHAR Buffer[32];
|
|
|
|
NTSTATUS Status;
|
|
|
|
|
|
|
|
/* Size must be aligned to 8 bytes */
|
|
|
|
Status = RtlEncryptMemory(Buffer, 7, RTL_ENCRYPT_OPTION_SAME_PROCESS);
|
|
|
|
ok_ntstatus(Status, STATUS_INVALID_PARAMETER);
|
|
|
|
|
|
|
|
/* Buffer must not be aligned to 8 bytes */
|
|
|
|
Status = RtlEncryptMemory(&Buffer[1], 8, RTL_ENCRYPT_OPTION_SAME_PROCESS);
|
|
|
|
ok_ntstatus(Status, STATUS_SUCCESS);
|
|
|
|
|
|
|
|
RtlCopyMemory(Buffer, TestData, sizeof(Buffer));
|
|
|
|
Status = RtlEncryptMemory(Buffer, sizeof(Buffer), RTL_ENCRYPT_OPTION_SAME_PROCESS);
|
|
|
|
ok_ntstatus(Status, STATUS_SUCCESS);
|
|
|
|
ok_int(RtlEqualMemory(Buffer, TestData, sizeof(Buffer)), 0);
|
|
|
|
Status = RtlDecryptMemory(Buffer, sizeof(Buffer), RTL_ENCRYPT_OPTION_SAME_PROCESS);
|
|
|
|
ok_ntstatus(Status, STATUS_SUCCESS);
|
|
|
|
ok_int(RtlEqualMemory(Buffer, TestData, sizeof(Buffer)), 1);
|
|
|
|
|
|
|
|
}
|