/*! @file @id $Id$ */ // 1 2 3 4 5 6 7 8 // 45678901234567890123456789012345678901234567890123456789012345678901234567890 #include #include #include #include #include #include #include #include #include #include #include #ifndef MRW__OLD_PRE11_COMPILER #include #endif int main(int argc, char** argv) try { // options unsigned long r(1); std::string txt("This is an example."); std::string lib("libcvP11.so"); std::string slot; std::string cert; mrw::args::parse(argc, argv, "Sign a text (optionally several times for performance" " measurements).", mrw::args::list() <slotinfo()); if (slot.size()&&slot!=si.slotDescription) continue; std::cout<<"Found Slot: "<tokeninfo()); std::cout<<"Found token: "<(CKO_CERTIFICATE))); for (cryptoki::ObjectList::iterator it(certs.begin()); it!=certs.end(); ++it) { std::string label(it->attribute(CKA_LABEL).value); if (cert.size()&&cert!=label) continue; cryptoki::Attribute id(it->attribute(CKA_ID)); cryptoki::ObjectList keys (session.find(cryptoki::Attribute(CKA_CLASS) .from(CKO_PUBLIC_KEY), id)); if (!keys.size()) continue; std::cout<<"Found Certificate: " <attribute(CKA_LABEL).value<>pin; session.login(pin); keys = session.find(cryptoki::Attribute(CKA_CLASS) .from(CKO_PRIVATE_KEY), id); if (keys.size()!=1) { std::cerr<<"**** ERROR: No private key: "< (end-start)); std::cout<<"Done in "<