1 Screenshot
2 Source code
/*
* PubKeyInfo.cpp
* Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.
*/
// SOL9
// 2009/03/17
#include <sol/crypt/RSACryptServiceProvider.h>
#include <sol/crypt/CryptError.h>
void _tmain(int argc, TCHAR** argv)
{
try {
// Specify a CSP with a container name.
CryptServiceProvider csp(_T("SOL"));
DWORD keySpec = AT_KEYEXCHANGE;
DWORD encodingType = X509_ASN_ENCODING;
PCERT_PUBLIC_KEY_INFO pKeyInfo = NULL;
printf("1 Try to csp.exportPublicKeyInfo\n");
if (csp.exportPublicKeyInfo(keySpec,
encodingType,
&pKeyInfo) == NO_ERROR) {
printf("2 OK, csp.exportPublicKeyInfo\n");
HCRYPTKEY hKey = NULL;
printf("3 Try to csp.importPublicKeyInfo\n");
if (csp.importPublicKeyInfo(encodingType,
pKeyInfo,
&hKey) == NO_ERROR) {
printf("4 OK, csp.importPublicKeyInfo\n");
} else {
printf("5 Failed to csp.exportPublicKeyInfo\n");
printf("Error: %s\n",
CryptError::getMessage(GetLastError()) );
}
} else {
printf("6 Failed to csp.exportPublicKeyInfo\n");
printf("Error: %s\n",
CryptError::getMessage(GetLastError()) );
}
} catch (...) {
printf("Exception:\n");
}
}
Last modified: 2 May 2016
Copyright (c) 2016 Antillia.com ALL RIGHTS RESERVED.