[ADVAPI32_APITEST]
[reactos.git] / rostests / apitests / advapi32 / RtlEncryptMemory.c
1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Test for RtlEncrypt/DecryptMemory
5 * PROGRAMMER: Timo Kreuzer <timo.kreuzer@reactos.org>
6 */
7
8 #include <apitest.h>
9
10 #define WIN32_NO_STATUS
11 #include <windows.h>
12 #include <ndk/ntndk.h>
13 #include <winsafer.h>
14 #include <ntsecapi.h>
15
16 START_TEST(RtlEncryptMemory)
17 {
18 static const CHAR const TestData[32] = "This is some test Message!!!";
19 CHAR Buffer[32];
20 NTSTATUS Status;
21
22 /* Size must be aligned to 8 bytes */
23 Status = RtlEncryptMemory(Buffer, 7, RTL_ENCRYPT_OPTION_SAME_PROCESS);
24 ok_ntstatus(Status, STATUS_INVALID_PARAMETER);
25
26 /* Buffer must not be aligned to 8 bytes */
27 Status = RtlEncryptMemory(&Buffer[1], 8, RTL_ENCRYPT_OPTION_SAME_PROCESS);
28 ok_ntstatus(Status, STATUS_SUCCESS);
29
30 RtlCopyMemory(Buffer, TestData, sizeof(Buffer));
31 Status = RtlEncryptMemory(Buffer, sizeof(Buffer), RTL_ENCRYPT_OPTION_SAME_PROCESS);
32 ok_ntstatus(Status, STATUS_SUCCESS);
33 ok_int(RtlEqualMemory(Buffer, TestData, sizeof(Buffer)), 0);
34 Status = RtlDecryptMemory(Buffer, sizeof(Buffer), RTL_ENCRYPT_OPTION_SAME_PROCESS);
35 ok_ntstatus(Status, STATUS_SUCCESS);
36 ok_int(RtlEqualMemory(Buffer, TestData, sizeof(Buffer)), 1);
37
38 }