1 Screenshot
2 Source code
/*
* CSP.cpp
* Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.
*/
//2009/02/17
#include <sol\crypt\CryptServiceProvider.h>
#include <sol/Locale.h>
void _tmain(int argc, TCHAR* argv[])
{
Locale locale;
try {
CryptServiceProvider cspDefault;
cspDefault.stat();
String provider;
String container;
int n = 0;
cspDefault.getProviderName(provider);
cspDefault.getKeyContainer(container);
_tprintf(_T("%d ProviderName=%s\n"), ++n, (const TCHAR*)provider);
_tprintf(_T("%d KeyContainer=%s\n"), n, (const TCHAR*)container);
CryptServiceProvider cspAES(PROV_RSA_AES);
cspAES.stat();
cspAES.getProviderName(provider);
cspAES.getKeyContainer(container);
_tprintf(_T("%d ProviderName=%s\n"), ++n, (const TCHAR*)provider);
_tprintf(_T("%d KeyContainer=%s\n"), n, (const TCHAR*)container);
CryptServiceProvider cspSChannel(PROV_RSA_SCHANNEL);
cspSChannel.stat();
cspSChannel.getProviderName(provider);
cspSChannel.getKeyContainer(container);
_tprintf(_T("%d ProviderName=%s\n"), ++n, (const TCHAR*)provider);
_tprintf(_T("%d KeyContainer=%s\n"), n, (const TCHAR*)container);
CryptServiceProvider cspDH(PROV_DSS_DH);
cspDH.stat();
cspDH.getProviderName(provider);
cspDH.getKeyContainer(container);
_tprintf(_T("%d ProviderName=%s\n"), ++n, (const TCHAR*)provider);
_tprintf(_T("%d KeyContainer=%s\n"), n, (const TCHAR*)container);
CryptServiceProvider cspDHSch(PROV_DH_SCHANNEL);
cspDHSch.stat();
cspDHSch.getProviderName(provider);
cspDHSch.getKeyContainer(container);
_tprintf(_T("%d ProviderName=%s\n"), ++n, (const TCHAR*)provider);
_tprintf(_T("%d KeyContainer=%s\n"), n, (const TCHAR*)container);
CryptServiceProvider cspAES2(_T("MYKEY"), PROV_RSA_AES);
cspAES2.getProviderName(provider);
cspAES2.getKeyContainer(container);
_tprintf(_T("%d ProviderName=%s\n"), ++n, (const TCHAR*)provider);
_tprintf(_T("%d KeyContainer=%s\n"), n, (const TCHAR*)container);
//
CryptServiceProvider cspSChannel2(_T("MYTEST"), PROV_RSA_SCHANNEL);
cspSChannel2.getProviderName(provider);
cspSChannel2.getKeyContainer(container);
_tprintf(_T("%d ProviderName=%s\n"), ++n, (const TCHAR*)provider);
_tprintf(_T("%d KeyContainer=%s\n"), n, (const TCHAR*)container);
CryptServiceProvider dss(_T("DSS"), PROV_DSS);
dss.getProviderName(provider);
dss.getKeyContainer(container);
_tprintf(_T("%d ProviderName=%s\n"), ++n, (const TCHAR*)provider);
_tprintf(_T("%d KeyContainer=%s\n"), n, (const TCHAR*)container);
_tprintf(_T("Try to cause an IException....\n"));
CryptServiceProvider cspFoo(1000);
} catch (Exception& ex) {
printf("Exception %s\n", ex.getErrorMessage());
}
}
Last modified: 2 May 2016
Copyright (c) 2016 Antillia.com ALL RIGHTS RESERVED.