This library provides a simple and nice C++ wrapper around these libraries, so that programmers can concentrate on functionality. It offers general support for PCSC-lite, OpenSSL, PKCS#11, plus specific functionality for the SuisseID.
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
3.4 KiB
91 lines
3.4 KiB
11 years ago
|
/*! @file
|
||
|
|
||
|
@id $Id$
|
||
|
*/
|
||
|
// 1 2 3 4 5 6 7 8
|
||
|
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
||
|
|
||
|
// #include <pcsc.hxx>
|
||
|
// #include <cryptaux.hxx>
|
||
|
// #include <openssl.hxx>
|
||
|
#include <cardos.hxx>
|
||
|
|
||
|
#include <mrw/vector.hxx>
|
||
|
#include <mrw/args.hxx>
|
||
|
|
||
|
#include <string>
|
||
11 years ago
|
#include <mrw/checkcxx11.hxx>
|
||
11 years ago
|
#include <memory>
|
||
|
#include <cctype>
|
||
|
#include <stdexcept>
|
||
|
#include <sstream>
|
||
|
#include <iostream>
|
||
|
#include <iomanip>
|
||
|
|
||
|
void list() {
|
||
11 years ago
|
pcsc::Connection::Strings readers(pcsc::Connection::scan());
|
||
11 years ago
|
std::cout<<"Found "<<readers.size()<<" readers"
|
||
|
<<(readers.size()?":":".")<<std::endl;
|
||
|
int i(0);
|
||
|
for (pcsc::Connection::Strings::iterator r(readers.begin());
|
||
|
r!=readers.end(); ++r, ++i)
|
||
|
std::cout<<i<<": "<<*r<<std::endl;
|
||
|
}
|
||
|
|
||
|
int main(int argc, char** argv) try {
|
||
11 years ago
|
unsigned int reader(0);
|
||
11 years ago
|
std::string pin;
|
||
11 years ago
|
std::string path("3f00");
|
||
11 years ago
|
std::string id("8888");
|
||
|
std::string data("Hallo Welt");
|
||
11 years ago
|
mrw::args::parse(argc, argv, "Write data to card.",
|
||
|
mrw::args::defaults()
|
||
|
<<mrw::args::decl("l", "list", "list readers",
|
||
|
mrw::args::decl::param_list()
|
||
|
<<mrw::args::func(list)
|
||
|
<<mrw::args::exit())
|
||
|
<<mrw::args::decl("r", "reader", "select reader",
|
||
|
mrw::args::decl::param_list()
|
||
|
<<mrw::args::param(reader, "num"))
|
||
|
<<mrw::args::decl("p", "path", "full path",
|
||
|
mrw::args::decl::param_list()
|
||
|
<<mrw::args::param(path, "path"))
|
||
11 years ago
|
<<mrw::args::decl("l", "pin", "full path",
|
||
|
mrw::args::decl::param_list()
|
||
|
<<mrw::args::param(path, "path"))
|
||
|
<<mrw::args::decl("i", "id", "file id",
|
||
|
mrw::args::decl::param_list()
|
||
|
<<mrw::args::param(id, "file"))
|
||
|
<<mrw::args::decl("d", "data", "data",
|
||
|
mrw::args::decl::param_list()
|
||
|
<<mrw::args::param(data, "text"))
|
||
11 years ago
|
);
|
||
11 years ago
|
pcsc::Connection::Strings readers(pcsc::Connection::scan());
|
||
11 years ago
|
if (readers.size()<reader) {
|
||
11 years ago
|
std::cerr<<"reader not found: "<<reader<<std::endl;
|
||
|
return 1;
|
||
|
}
|
||
11 years ago
|
cardos::Commands cmd(pcsc::Connection::reader(readers[reader]));
|
||
|
cardos::Dir d(cmd, path);
|
||
11 years ago
|
//cardos::BerValues d(cmd.readBerFile(path));
|
||
11 years ago
|
//cardos::BerValues d(cmd.directory(path));
|
||
|
std::cout<<"-----------------------------------------------------"<<std::endl
|
||
|
<<d.print()<<std::endl
|
||
|
<<"-----------------------------------------------------"<<std::endl;
|
||
11 years ago
|
//std::string res(cmd.readBinary(path));
|
||
|
//std::cout<<"HEX:"<<std::endl<<crypto::readable(res)<<std::endl;
|
||
|
//std::cout<<"BER:"<<std::endl<<cardos::BerValues(res).print()<<std::endl;
|
||
11 years ago
|
// if (!pin.size()) {
|
||
|
// std::cout<<"PIN: ";
|
||
|
// std::cin>>pin;
|
||
|
// }
|
||
|
// if (pin.size()) cmd.logonTransport(pin);
|
||
|
// cmd.phaseControl();
|
||
|
// cmd.createBinary(path, id, data);
|
||
|
// cmd.phaseControl();
|
||
11 years ago
|
return 0;
|
||
|
} catch (std::exception& x) {
|
||
|
std::cerr<<"ERROR: "<<x.what()<<std::endl;
|
||
|
return 2;
|
||
|
}
|