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 "precomp.h"
9 
10 #include <ntsecapi.h>
11 
12 START_TEST(RtlEncryptMemory)
13 {
14     static const CHAR TestData[32] = "This is some test Message!!!";
15     CHAR Buffer[32];
16     NTSTATUS Status;
17 
18     /* Size must be aligned to 8 bytes */
19     Status = RtlEncryptMemory(Buffer, 7, RTL_ENCRYPT_OPTION_SAME_PROCESS);
20     ok_ntstatus(Status, STATUS_INVALID_PARAMETER);
21 
22     /* Buffer must not be aligned to 8 bytes */
23     Status = RtlEncryptMemory(&Buffer[1], 8, RTL_ENCRYPT_OPTION_SAME_PROCESS);
24     ok_ntstatus(Status, STATUS_SUCCESS);
25 
26     RtlCopyMemory(Buffer, TestData, sizeof(Buffer));
27     Status = RtlEncryptMemory(Buffer, sizeof(Buffer), RTL_ENCRYPT_OPTION_SAME_PROCESS);
28     ok_ntstatus(Status, STATUS_SUCCESS);
29     ok_int(RtlEqualMemory(Buffer, TestData, sizeof(Buffer)), 0);
30     Status = RtlDecryptMemory(Buffer, sizeof(Buffer), RTL_ENCRYPT_OPTION_SAME_PROCESS);
31     ok_ntstatus(Status, STATUS_SUCCESS);
32     ok_int(RtlEqualMemory(Buffer, TestData, sizeof(Buffer)), 1);
33 
34 }
35