erste suisseid demo; refs #28

master
Marc Wäckerlin 11 years ago
parent fc85aab326
commit 91b075d61b
  1. 10
      doc/examples/makefile.am
  2. 48
      doc/examples/suisse-id-demo.cxx
  3. 2
      src/pcsc.hxx

@ -5,7 +5,7 @@
noinst_PROGRAMS = pcsc-demo cryptoki-sign-demo cryptoki-demo \ noinst_PROGRAMS = pcsc-demo cryptoki-sign-demo cryptoki-demo \
openssl-tcp-demo openssl-ssl-demo \ openssl-tcp-demo openssl-ssl-demo \
openssl-engine-demo openssl-engine-demo suisse-id-demo
AM_CPPFLAGS += -I/usr/include/PCSC AM_CPPFLAGS += -I/usr/include/PCSC
@ -70,4 +70,12 @@ if MINGW32
openssl_engine_demo_LDADD += /opt/local/i586-mingw32msvc/lib/ssleay32.a /opt/local/i586-mingw32msvc/lib/libeay32.a openssl_engine_demo_LDADD += /opt/local/i586-mingw32msvc/lib/ssleay32.a /opt/local/i586-mingw32msvc/lib/libeay32.a
endif endif
suisse_id_demo_SOURCES = suisse-id-demo.cxx
suisse_id_demo_CPPFLAGS = -I${top_srcdir}/src -I/usr/include/PCSC
suisse_id_demo_LDFLAGS = -L${top_builddir}/src
suisse_id_demo_LDADD = -lpcscxx
if MINGW32
suisse_id_demo_LDADD += /opt/local/i586-mingw32msvc/lib/ssleay32.a /opt/local/i586-mingw32msvc/lib/libeay32.a
endif
MAINTAINERCLEANFILES = makefile.in MAINTAINERCLEANFILES = makefile.in

@ -0,0 +1,48 @@
/*! @file
@id $Id$
*/
// 1 2 3 4 5 6 7 8
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
#include <cryptoki.hxx>
#include <pcsc.hxx>
#include <mrw/args.hxx>
#include <mrw/vector.hxx>
#include <stdexcept>
#include <iostream>
int main(int argc, char** argv) try {
std::string lib("libcvP11.so");
mrw::args::parse(argc, argv,
"Sign a text (optionally several times for performance"
" measurements).",
mrw::args::list()
<<mrw::args::decl("h", "help", "show help",
mrw::args::decl::param_list()
<<mrw::args::help()
<<mrw::args::exit())
<<mrw::args::decl("l", "library", "cryptoki lirary to load",
mrw::args::decl::param_list()
<<mrw::args::param(lib, "lib")));
pcsc::Connection pcsc;
cryptoki::Init cryptoki(lib);
// Scan for a Post SuisseID
pcsc::Connection::Strings readers
(pcsc.getReadersWithAtr("4b53776973735369676e"));
std::cout<<"found "<<readers.size()<<" readers"<<std::endl;
for (pcsc::Connection::Strings::iterator reader(readers.begin());
reader!=readers.end(); ++reader) {
std::cout<<"Found SuisseID in reader: "<<*reader<<std::endl;
// Each PCSC reader has exactly one corresponding Cryptoki slot; find it
cryptoki::SlotList slots(cryptoki.slotList(true, *reader));
if (slots.size()!=1) throw std::runtime_error("error scanning cryptoki");
}
return 0;
} catch (std::exception& x) {
std::cerr<<"**** ERROR in "<<*argv<<": "<<x.what()<<std::endl;
}

@ -556,7 +556,7 @@ namespace pcsc {
pcsc::Connection::Strings readers(scan()); pcsc::Connection::Strings readers(scan());
for (pcsc::Connection::Strings::const_iterator it(readers.begin()); for (pcsc::Connection::Strings::const_iterator it(readers.begin());
it!=readers.end(); ++it) it!=readers.end(); ++it)
if (_reader[*it]->status().atr.find(atr)!=string::npos) if (crypto::hex(reader(*it).status().atr).find(atr)!=string::npos)
res.push_back(*it); res.push_back(*it);
return res; return res;
} }

Loading…
Cancel
Save