add logging for kimmo; refs #155
This commit is contained in:
@@ -249,6 +249,82 @@ class SmartCardAuth: public QObject {
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
int minPinLen(const std::string& name) {
|
||||
TRC; LOG<<name.c_str();
|
||||
try {
|
||||
pcsc::Connection pcsc;
|
||||
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)
|
||||
!= std::string("\x90\x00", 2) || !reader) {
|
||||
LOG<<"Select File failed";
|
||||
return -2;
|
||||
}
|
||||
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;
|
||||
}
|
||||
LOG<<"version text is: "<<res.substr(4, res[3]).c_str();
|
||||
// if (res.substr(4, res[3]) != "RAPost 2009" &&
|
||||
// res.substr(4, res[3]) != "RAPost 2010") {
|
||||
// LOG<<"unsupported card";
|
||||
// return -2;
|
||||
// }
|
||||
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";
|
||||
}
|
||||
return -1; // locked
|
||||
} catch (const std::exception& x) {
|
||||
LOG<<"**** ERROR while reading pin status: "<<x.what();
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
int maxPinLen(const std::string& name) {
|
||||
TRC; LOG<<name.c_str();
|
||||
try {
|
||||
pcsc::Connection pcsc;
|
||||
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)
|
||||
!= std::string("\x90\x00", 2) || !reader) {
|
||||
LOG<<"Select File failed";
|
||||
return -2;
|
||||
}
|
||||
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;
|
||||
}
|
||||
LOG<<"version text is: "<<res.substr(4, res[3]).c_str();
|
||||
// if (res.substr(4, res[3]) != "RAPost 2009" &&
|
||||
// res.substr(4, res[3]) != "RAPost 2010") {
|
||||
// LOG<<"unsupported card";
|
||||
// return -2;
|
||||
// }
|
||||
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";
|
||||
}
|
||||
return -1; // locked
|
||||
} catch (const std::exception& x) {
|
||||
LOG<<"**** ERROR while reading pin status: "<<x.what();
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
int retries(const std::string& name) {
|
||||
TRC; LOG<<name.c_str();
|
||||
|
Reference in New Issue
Block a user