简体   繁体   中英

How to get public and private key from CNG (BCrypt) RSA algorithm?

I am kind of stuck, I want to generate new pair of public and private keys. But I can't find a way to extract them.

I used this: (C++)

    status = BCryptOpenAlgorithmProvider(&hAlg,
                                         BCRYPT_RSA_ALGORITHM,
                                         NULL,
                                         0);

    if (status) {}

    status = BCryptGenerateKeyPair(hAlg, &hKey, 1024, 0);

    if (status) {}

    status = BCryptFinalizeKeyPair(&hKey, 0);

    if (status) {}

(dont mind the status, ill check it later:-) ) but now I want to extract the pair of keys, cant find an example or matching function I might do something wrong, but what?

"export it to?" BCryptExportKey function exports a key to a memory BLOB that can be persisted for later use.

And then you could use the BCryptImportKeyPair function imports a public/private key pair from a key BLOB.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM