(Unicode C) RSA Import Private Key
Shows how to select/import a private key for RSA signing or decryption.
#include <C_CkPrivateKeyW.h>
#include <C_CkRsaW.h>
void ChilkatSample(void)
{
HCkPrivateKeyW privKey;
const wchar_t *password;
BOOL success;
HCkRsaW rsa;
privKey = CkPrivateKeyW_Create();
password = L"secret";
// In all Chilkat methods expecting a path, you pass either absolute or relative paths.
success = CkPrivateKeyW_LoadAnyFormatFile(privKey,L"rsaKeys/myTestRsaPrivate.pem",password);
if (success == FALSE) {
wprintf(L"%s\n",CkPrivateKeyW_lastErrorText(privKey));
CkPrivateKeyW_Dispose(privKey);
return;
}
rsa = CkRsaW_Create();
// Tell the RSA object to use the private key (i.e. import the private key)
CkRsaW_ImportPrivateKeyObj(rsa,privKey);
CkPrivateKeyW_Dispose(privKey);
CkRsaW_Dispose(rsa);
}
|