more documentation; refs #28
This commit is contained in:
		| @@ -9,9 +9,11 @@ template <typename Array> void print(const std::vector<Array>& v) { | ||||
| } | ||||
|  | ||||
| int main(int argc, char const*const*const argv) try { | ||||
| //   //std::vector<int> v(toVector<4>((int[]){1,2,3,4})); | ||||
| //   std::vector<int> v(VECTOR(((int[]){1,2,3,4}))); | ||||
| //   print(v); | ||||
|   std::cout<<"Example for buffer to vector conversion:"<<std::endl; | ||||
|   int buff[] = {1, 2, 3, 4}; | ||||
|   std::vector<int> vec(cryptoki::toVector(buff)); | ||||
|   print(vec); | ||||
|   std::cout<<std::endl; | ||||
|   cryptoki::Library cryptoki(argc==2?argv[1]:"onepin-opensc-pkcs11.so"); | ||||
|   cryptoki::Info inf(cryptoki.info()); | ||||
|   std::cout<<"Library-Version: "<<pcsc::version()<<std::endl; | ||||
| @@ -61,15 +63,14 @@ int main(int argc, char const*const*const argv) try { | ||||
|                <<"utcTime: \""<<crypto::readable(info.utcTime) | ||||
|                <<'"'<<std::endl; | ||||
|       cryptoki::MechanismList mechs(it->mechanismlist()); | ||||
|       for (cryptoki::MechanismList::iterator it2(mechs.begin()); | ||||
|            it2!=mechs.end(); ++it2) { | ||||
|         cryptoki::MechanismInfo mechinfo(it->mechanisminfo(*it2)); | ||||
|       for (cryptoki::MechanismList::iterator mechinfo(mechs.begin()); | ||||
|            mechinfo!=mechs.end(); ++mechinfo) { | ||||
|         std::cout<<"-------------------- Mechanism -----------------"<<std::endl | ||||
|                  <<"id: \""<<mechinfo.id<<'"'<<std::endl | ||||
|                  <<"name: \""<<mechinfo.name<<'"'<<std::endl | ||||
|                  <<"minKeySize: \""<<mechinfo.minKeySize<<'"'<<std::endl | ||||
|                  <<"maxKeySize: \""<<mechinfo.maxKeySize<<'"'<<std::endl | ||||
|                  <<"flags: \""<<mechinfo.flags<<'"'<<std::endl; | ||||
|                  <<"id: \""<<mechinfo->id<<'"'<<std::endl | ||||
|                  <<"name: \""<<mechinfo->name<<'"'<<std::endl | ||||
|                  <<"minKeySize: \""<<mechinfo->minKeySize<<'"'<<std::endl | ||||
|                  <<"maxKeySize: \""<<mechinfo->maxKeySize<<'"'<<std::endl | ||||
|                  <<"flags: \""<<mechinfo->flags<<'"'<<std::endl; | ||||
|       } | ||||
|       cryptoki::Session session(*it); | ||||
|       cryptoki::ObjectList objs(session.find()); | ||||
| @@ -80,8 +81,8 @@ int main(int argc, char const*const*const argv) try { | ||||
|         cryptoki::AttributeMap attrs(it->attributes()); | ||||
|         for (cryptoki::AttributeMap::iterator it(attrs.begin()); | ||||
|              it!=attrs.end(); ++it) { | ||||
|           std::cout<<" - attribute: "<<it->second.name()<<"=\"" | ||||
|                    <<crypto::readable(it->second.value)<<'"'<<std::endl; | ||||
|           std::cout<<" - attribute: "<<it->second.name()<<" = "<<std::endl | ||||
|                    <<crypto::readable(it->second.value, 15, 5)<<std::endl; | ||||
|         } | ||||
|       } | ||||
|       std::cout<<"**** Success"<<std::endl; | ||||
|   | ||||
| @@ -99,7 +99,11 @@ int main(int argc, char** argv) try { | ||||
|       auto start = std::chrono::system_clock::now(); | ||||
| #endif | ||||
|       for (int i(0); i<r; ++i) | ||||
|         keys[0].sign(txt, CKM_RSA_PKCS); | ||||
|         std::cout<<"Text:"<<std::endl | ||||
|                  <<crypto::readable(txt)<<std::endl | ||||
|                  <<"Signature:"<<std::endl | ||||
|                  <<crypto::readable(keys[0].sign(txt, CKM_RSA_PKCS)) | ||||
|                  <<std::endl; | ||||
| #ifndef MRW__OLD_PRE11_COMPILER | ||||
|       auto end = std::chrono::system_clock::now(); | ||||
|       auto elapsed(std::chrono::duration_cast<std::chrono::milliseconds> | ||||
|   | ||||
| @@ -11,15 +11,18 @@ | ||||
| #include <QtNetwork/QSslCertificate> | ||||
| #include <QtCore/QDateTime> | ||||
|  | ||||
| void show(const QStringList& sl, const std::string& p="item: ") { | ||||
|   for (QStringList::const_iterator s(sl.begin()); s!=sl.end(); ++s) | ||||
|     std::cout<<p<<QString(s->toUtf8()).toStdString()<<std::endl; | ||||
| } | ||||
|  | ||||
| // show certificate information | ||||
| void show(const suisseid::Certificate& cert) { | ||||
| // makes use of qt library's certificate class | ||||
|   QSslCertificate c(QByteArray(cert.data(), cert.size()), QSsl::Der); | ||||
|   std::cout<<"Certificate info: CN=" | ||||
|            <<QString(c.subjectInfo(QSslCertificate::CommonName) | ||||
|                      .toUtf8()).toStdString() | ||||
|                      <<std::endl | ||||
|            <<"  Valid until: " | ||||
|   std::cout<<"Certificate info:"; | ||||
|   show(c.subjectInfo(QSslCertificate::CommonName), "  CN="); | ||||
|   std::cout<<"  Valid until: " | ||||
|            <<QString(c.expiryDate().toString().toUtf8()).toStdString() | ||||
|            <<std::endl; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user