Created
November 16, 2019 00:29
-
-
Save gentilkiwi/7361e27b00637d942e1e2bbddbd7f762 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define NCRYPT_VIRTUAL_ISO_MAYBE 0x10000 | |
#define NCRYPT_VIRTUAL_ISO 0x20000 | |
#define NCRYPT_PER_BOOT_KEY 0x40000 | |
NTSTATUS kuhl_m_standard_test(int argc, wchar_t * argv[]) | |
{ | |
SECURITY_STATUS status; | |
NCRYPT_PROV_HANDLE hCngProv = 0; | |
NCRYPT_KEY_HANDLE hCngKey = 0; | |
DWORD keyLen = 2048; | |
status = NCryptOpenStorageProvider(&hCngProv, MS_KEY_STORAGE_PROVIDER, 0); | |
if(status == ERROR_SUCCESS) | |
{ | |
status = NCryptCreatePersistedKey(hCngProv, &hCngKey, BCRYPT_RSA_ALGORITHM, L"test", 0, NCRYPT_VIRTUAL_ISO); | |
if(status == ERROR_SUCCESS) | |
{ | |
status = NCryptSetProperty(hCngKey, NCRYPT_LENGTH_PROPERTY, (PBYTE) &keyLen, sizeof(keyLen), NCRYPT_PERSIST_FLAG); | |
if(status == ERROR_SUCCESS) | |
{ | |
status = NCryptFinalizeKey(hCngKey, 0); | |
if(status == ERROR_SUCCESS) | |
W00T(L"Protected by VSM\n"); | |
else PRINT_ERROR(L"NCryptFinalizeKey: 0x%08x\n", status); | |
} | |
else PRINT_ERROR(L"NCryptSetProperty(NCRYPT_LENGTH_PROPERTY - %u): 0x%08x\n", keyLen, status); | |
NCryptFreeObject(hCngKey); | |
} | |
else PRINT_ERROR(L"NCryptCreatePersistedKey: 0x%08x\n", status); | |
NCryptFreeObject(hCngProv); | |
} | |
else PRINT_ERROR(L"NCryptOpenStorageProvider: 0x%08x\n", status); | |
return STATUS_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment