Skip to content

Instantly share code, notes, and snippets.

@woachk
Last active May 10, 2019 23:01
Show Gist options
  • Save woachk/71cb7692b2f328dc7331f21161a37283 to your computer and use it in GitHub Desktop.
Save woachk/71cb7692b2f328dc7331f21161a37283 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <windows.h>
#include <bcrypt.h>
#define STATUS_SUCCESS 0x00000000
int main(void) {
NTSTATUS ntStatus = STATUS_SUCCESS;
BCRYPT_ALG_HANDLE hAlg = NULL;
BCRYPT_KEY_HANDLE hKey = NULL;
ntStatus = BCryptOpenAlgorithmProvider(&hAlg, BCRYPT_RSA_ALGORITHM, MS_PRIMITIVE_PROVIDER, 0);
if (ntStatus != STATUS_SUCCESS)
exit(1);
ntStatus = BCryptGenerateKeyPair(hAlg, &hKey, 2047, 0);
if (ntStatus != STATUS_SUCCESS)
puts("Key generation failure.");
else
puts("Key generation success.");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment