first test with cryptoki
This commit is contained in:
57
doc/examples/cryptoki-demo.cpp
Normal file
57
doc/examples/cryptoki-demo.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
// g++ -I ../../src -I /usr/include/opencryptoki cryptoki-demo.cpp ../../src/cryptoki.cxx -ldl -ggdb3
|
||||
#include <cryptoki.hxx>
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, char const*const*const argv) try {
|
||||
cryptoki::Init init(argc==2?argv[1]:"onepin-opensc-pkcs11.so");
|
||||
cryptoki::Info inf(init.info());
|
||||
std::cout<<"##################### INFO #####################"<<std::endl
|
||||
<<"cryptokiVersion: \""<<(int)inf.cryptokiVersion.major
|
||||
<<'.'<<(int)inf.cryptokiVersion.minor<<'"'<<std::endl
|
||||
<<"manufacturerID: \""<<inf.manufacturerID<<'"'<<std::endl
|
||||
<<"flags: \""<<inf.flags<<'"'<<std::endl
|
||||
<<"libraryDescription: \""<<inf.libraryDescription<<'"'<<std::endl
|
||||
<<"libraryVersion: \""<<(int)inf.libraryVersion.major
|
||||
<<'.'<<(int)inf.libraryVersion.minor<<'"'<<std::endl;
|
||||
cryptoki::SlotList slots(init.slotList());
|
||||
for (cryptoki::SlotList::iterator it(slots.begin()); it!=slots.end(); ++it)
|
||||
try {
|
||||
cryptoki::SlotInfo slotInfo(it->slotInfo());
|
||||
std::cout<<"##################### S-CARD #####################"<<std::endl
|
||||
<<"slotDescription: \""<<slotInfo.slotDescription<<'"'<<std::endl
|
||||
<<"manufacturerID: \""<<slotInfo.manufacturerID<<'"'<<std::endl
|
||||
<<"flags: \""<<slotInfo.flags<<'"'<<std::endl
|
||||
<<"hardwareVersion: \""<<(int)slotInfo.hardwareVersion.major
|
||||
<<'.'<<(int)slotInfo.hardwareVersion.minor<<'"'<<std::endl
|
||||
<<"firmwareVersion: \""<<(int)slotInfo.firmwareVersion.major
|
||||
<<'.'<<(int)slotInfo.firmwareVersion.minor<<'"'<<std::endl;
|
||||
cryptoki::TokenInfo info(it->tokenInfo());
|
||||
std::cout<<"--------------------------------------------------"<<std::endl
|
||||
<<"label: \""<<info.label<<'"'<<std::endl
|
||||
<<"manufacturerID: \""<<info.manufacturerID<<'"'<<std::endl
|
||||
<<"model: \""<<info.model<<'"'<<std::endl
|
||||
<<"serialNumber: \""<<info.serialNumber<<'"'<<std::endl
|
||||
<<"flags: \""<<info.flags<<'"'<<std::endl
|
||||
<<"maxSessionCount: \""<<info.maxSessionCount<<'"'<<std::endl
|
||||
<<"sessionCount: \""<<info.sessionCount<<'"'<<std::endl
|
||||
<<"maxRwSessionCount: \""<<info.maxRwSessionCount<<'"'<<std::endl
|
||||
<<"rwSessionCount: \""<<info.rwSessionCount<<'"'<<std::endl
|
||||
<<"maxPinLen: \""<<info.maxPinLen<<'"'<<std::endl
|
||||
<<"minPinLen: \""<<info.minPinLen<<'"'<<std::endl
|
||||
<<"totalPublicMemory: \""<<info.totalPublicMemory<<'"'<<std::endl
|
||||
<<"freePublicMemory: \""<<info.freePublicMemory<<'"'<<std::endl
|
||||
<<"totalPrivateMemory: \""<<info.totalPrivateMemory<<'"'
|
||||
<<std::endl
|
||||
<<"freePrivateMemory: \""<<info.freePrivateMemory<<'"'<<std::endl
|
||||
<<"hardwareVersion: \""<<(int)info.hardwareVersion.major
|
||||
<<'.'<<(int)info.hardwareVersion.minor<<'"'<<std::endl
|
||||
<<"firmwareVersion: \""<<(int)info.firmwareVersion.major
|
||||
<<'.'<<(int)info.firmwareVersion.minor<<'"'<<std::endl
|
||||
<<"utcTime: \""<<info.utcTime<<'"'<<std::endl;
|
||||
} catch (std::exception& x) {
|
||||
std::cerr<<"**** FEHLER in "<<*argv<<": "<<x.what()<<std::endl;
|
||||
}
|
||||
return 0;
|
||||
} catch (std::exception& x) {
|
||||
std::cerr<<"**** FEHLER in "<<*argv<<": "<<x.what()<<std::endl;
|
||||
}
|
@@ -1,6 +1,5 @@
|
||||
//g++ -I ../svn -I /usr/include/PCSC test.cpp -lpcsclite -ggdb3
|
||||
#include "pcscpp/pcsc.hxx"
|
||||
//#include "pcscpp/cardos.hxx"
|
||||
#include <iostream>
|
||||
|
||||
int main(int, char const*const*const argv) try {
|
||||
|
Reference in New Issue
Block a user