mirror-ac/driver/crypt.h

78 lines
1.6 KiB
C
Raw Normal View History

2024-01-28 08:34:09 +01:00
#ifndef CRYPT_H
#define CRYPT_H
#include "common.h"
2024-06-21 16:22:11 +02:00
#define XOR_ROTATION_AMT 13
2024-05-30 07:42:35 +02:00
2024-06-21 16:22:11 +02:00
FORCEINLINE
VOID
CryptEncryptPointer64(_Inout_ PUINT64 Pointer, _In_ UINT64 Key)
{
*Pointer = _rotl64(*Pointer ^ Key, XOR_ROTATION_AMT);
}
FORCEINLINE
VOID
CryptDecryptPointer64(_Inout_ PUINT64 Pointer, _In_ UINT64 Key)
{
*Pointer = _rotr64(*Pointer, XOR_ROTATION_AMT) ^ Key;
}
FORCEINLINE
UINT64
CryptDecryptPointerOutOfPlace64(_In_ PUINT64 Pointer, _In_ UINT64 Key)
{
volatile UINT64 temp = *Pointer;
CryptDecryptPointer64(&temp, Key);
return temp;
}
2024-05-30 07:42:35 +02:00
2024-01-28 08:34:09 +01:00
VOID
CryptEncryptImportsArray(_In_ PUINT64 Array, _In_ UINT32 Entries);
2024-01-28 08:34:09 +01:00
UINT64
2024-04-13 10:23:14 +02:00
CryptDecryptImportsArrayEntry(_In_ PUINT64 Array,
_In_ UINT32 Entries,
_In_ UINT32 EntryIndex);
2024-01-28 08:34:09 +01:00
2024-05-11 14:54:58 +02:00
NTSTATUS
CryptInitialiseProvider();
UINT32
CryptRequestRequiredBufferLength(_In_ UINT32 BufferLength);
NTSTATUS
CryptEncryptBuffer(_In_ PVOID Buffer, _In_ UINT32 BufferLength);
NTSTATUS
CryptInitialiseSessionCryptObjects();
VOID
CryptCloseSessionCryptObjects();
2024-01-31 08:32:13 +01:00
VOID
2024-05-11 14:54:58 +02:00
CryptCloseProvider();
2024-01-31 08:32:13 +01:00
2024-05-30 07:42:35 +02:00
NTSTATUS
TpmExtractEndorsementKey();
2024-06-21 15:55:23 +02:00
UINT64
CryptXorKeyGenerate_uint64();
VOID
CryptEncryptPointer64(_Inout_ PUINT64 Pointer, _In_ UINT64 Key);
VOID
CryptDecryptPointer64(_Inout_ PUINT64 Pointer, _In_ UINT64 Key);
UINT64
CryptDecryptPointerOutOfPlace64(_In_ PUINT64 Pointer, _In_ UINT64 Key);
2024-07-19 16:27:50 +02:00
NTSTATUS
CryptHashBuffer_sha256(_In_ PVOID Buffer,
_In_ ULONG BufferSize,
_Out_ PVOID* HashResult,
_Out_ PULONG HashResultSize);
2024-01-28 08:34:09 +01:00
#endif