changes for new libpcscxx, works, but crashes at the end; refs #176

This commit is contained in:
Marc Wäckerlin
2013-11-12 13:04:59 +00:00
parent c8a8493acb
commit 9e131500e3
16 changed files with 109 additions and 96 deletions

View File

@@ -41,7 +41,7 @@ class CryptokiEngine: public QObject, public openssl::Engine {
return _privateKey.get();
}
cryptoki::Init& cryptoki() {
cryptoki::Library& cryptoki() {
return _cryptoki;
}
@@ -139,7 +139,7 @@ class CryptokiEngine: public QObject, public openssl::Engine {
private:
cryptoki::Init _cryptoki;
cryptoki::Library _cryptoki;
std::auto_ptr<cryptoki::Object> _privateKey;
};
@@ -260,17 +260,17 @@ class SmartCardAuth: public QObject {
TRC; LOG<<name.c_str();
try {
pcsc::Connection pcsc;
pcsc::Connection::Reader& reader(pcsc.reader(name));
mrw::Shared<pcsc::Connection::Reader> reader(pcsc.reader(name));
#ifndef Q_OS_MAC
pcsc::Connection::Reader::Transaction lock(reader);
#endif
// first try to read version info
if (reader.transmit(0x00, 0xA4, 0x08, 0x0C, "\x3f\x00\x56\x49", 4)
if (reader->transmit(0x00, 0xA4, 0x08, 0x0C, "\x3f\x00\x56\x49", 4)
!= std::string("\x90\x00", 2) || !reader) {
LOG<<"Select File failed";
return -2;
}
std::string res(reader.transmit(0x00, 0xB0, 0x00, 0x00));
std::string res(reader->transmit(0x00, 0xB0, 0x00, 0x00));
if (res.substr(res.size()-2)!=std::string("\x90\x00", 2)) {
LOG<<"read error";
return -2;
@@ -281,8 +281,8 @@ class SmartCardAuth: public QObject {
// LOG<<"unsupported card";
// return -2;
// }
if (retCode(reader.transmit(0x00, 0xA4, 0x00, 0x0C)) == 0x9000) {
int value(retCode(reader.transmit(0x00, 0x20, 0x00, 0x81)));
if (retCode(reader->transmit(0x00, 0xA4, 0x00, 0x0C)) == 0x9000) {
int value(retCode(reader->transmit(0x00, 0x20, 0x00, 0x81)));
if ((value&0x63C0)==0x63C0) return value&0x0F;
} else {
LOG<<"**** ERROR in select MF while reading pin status";
@@ -298,17 +298,17 @@ class SmartCardAuth: public QObject {
TRC; LOG<<name.c_str();
try {
pcsc::Connection pcsc;
pcsc::Connection::Reader& reader(pcsc.reader(name));
mrw::Shared<pcsc::Connection::Reader> reader(pcsc.reader(name));
#ifndef Q_OS_MAC
pcsc::Connection::Reader::Transaction lock(reader);
#endif
// first try to read version info
if (reader.transmit(0x00, 0xA4, 0x08, 0x0C, "\x3f\x00\x56\x49", 4)
if (reader->transmit(0x00, 0xA4, 0x08, 0x0C, "\x3f\x00\x56\x49", 4)
!= std::string("\x90\x00", 2) || !reader) {
LOG<<"Select File failed";
return -2;
}
std::string res(reader.transmit(0x00, 0xB0, 0x00, 0x00));
std::string res(reader->transmit(0x00, 0xB0, 0x00, 0x00));
if (res.substr(res.size()-2)!=std::string("\x90\x00", 2)) {
LOG<<"read error";
return -2;
@@ -319,8 +319,8 @@ class SmartCardAuth: public QObject {
// LOG<<"unsupported card";
// return -2;
// }
if (retCode(reader.transmit(0x00, 0xA4, 0x00, 0x0C)) == 0x9000) {
int value(retCode(reader.transmit(0x00, 0x20, 0x00, 0x81)));
if (retCode(reader->transmit(0x00, 0xA4, 0x00, 0x0C)) == 0x9000) {
int value(retCode(reader->transmit(0x00, 0x20, 0x00, 0x81)));
if ((value&0x63C0)==0x63C0) return value&0x0F;
} else {
LOG<<"**** ERROR in select MF while reading pin status";
@@ -336,17 +336,17 @@ class SmartCardAuth: public QObject {
TRC; LOG<<name.c_str();
try {
pcsc::Connection pcsc;
pcsc::Connection::Reader& reader(pcsc.reader(name));
mrw::Shared<pcsc::Connection::Reader> reader(pcsc.reader(name));
#ifndef Q_OS_MAC
pcsc::Connection::Reader::Transaction lock(reader);
#endif
// first try to read version info
if (reader.transmit(0x00, 0xA4, 0x08, 0x0C, "\x3f\x00\x56\x49", 4)
if (reader->transmit(0x00, 0xA4, 0x08, 0x0C, "\x3f\x00\x56\x49", 4)
!= std::string("\x90\x00", 2) || !reader) {
LOG<<"Select File failed";
return -2;
}
std::string res(reader.transmit(0x00, 0xB0, 0x00, 0x00));
std::string res(reader->transmit(0x00, 0xB0, 0x00, 0x00));
if (res.substr(res.size()-2)!=std::string("\x90\x00", 2)) {
LOG<<"read error";
return -2;
@@ -357,8 +357,8 @@ class SmartCardAuth: public QObject {
// LOG<<"unsupported card";
// return -2;
// }
if (retCode(reader.transmit(0x00, 0xA4, 0x00, 0x0C)) == 0x9000) {
int value(retCode(reader.transmit(0x00, 0x20, 0x00, 0x81)));
if (retCode(reader->transmit(0x00, 0xA4, 0x00, 0x0C)) == 0x9000) {
int value(retCode(reader->transmit(0x00, 0x20, 0x00, 0x81)));
if ((value&0x63C0)==0x63C0) return value&0x0F;
} else {
LOG<<"**** ERROR in select MF while reading pin status";