Generating And Retrieving RSA/Schannel Public/Private Keys
RSA/Schannel Keys may be generated with a call to CryptGenKey. The call to CryptGenKey requires an AT_KEYEXCHANGE algorithm identifier passed in the Algid argument.
To generate a RSA/Schannel public/private key pair
-
Call CryptAcquireContext to get a pointer to the Microsoft RSA/Schannel Cryptographic Provider.
-
Call CryptGenKey to generate the keys. AT_KEYEXCHANGE must be passed in for the Algid argument and the upper 16 bits of the dwFlags argument must be set to the desired key size (512 bits). A HCRYPTKEY handle is returned in the hKey argument.
To retrieve a pointer to previously generated RSA/Schannel user keys
-
Call CryptAcquireContext to get a pointer to the Microsoft RSA/Schannel Cryptographic Provider.
-
Call CryptGetUserKey, with the dwKeySpec argument set to AT_KEYEXCHANGE.