Correctly decode values; refs #31
This commit is contained in:
27
configure.in
27
configure.in
@@ -99,24 +99,23 @@ PKG_CHECK_MODULES([QT_GUI], [Qt5Core Qt5Gui Qt5Widgets],
|
||||
UIC=${UIC:-$(pkg-config --variable=uic_location Qt5Core)}
|
||||
MOC=${MOC:-$(pkg-config --variable=moc_location Qt5Core)}
|
||||
have_qtgui=1],
|
||||
[PKG_CHECK_MODULES([QT_GUI], [QtCore QtGui])],
|
||||
[AC_DEFINE([HAVE_QTGUI])
|
||||
UIC=${UIC:-$(pkg-config --variable=uic_location QtCore)}
|
||||
MOC=${MOC:-$(pkg-config --variable=moc_location QtCore)}
|
||||
have_qtgui=1],
|
||||
[have_qtgui=0])
|
||||
[PKG_CHECK_MODULES([QT_GUI], [QtCore QtGui],
|
||||
[AC_DEFINE([HAVE_QTGUI])
|
||||
UIC=${UIC:-$(pkg-config --variable=uic_location QtCore)}
|
||||
MOC=${MOC:-$(pkg-config --variable=moc_location QtCore)}
|
||||
have_qtgui=1],
|
||||
[have_qtgui=0])])
|
||||
AM_CONDITIONAL(HAVE_QTGUI, test "$have_qtgui" = "1")
|
||||
PKG_CHECK_MODULES([QT_NETWORK], [Qt5Network],
|
||||
[AC_DEFINE([HAVE_QTNETWORK])
|
||||
UIC=${UIC:-$(pkg-config --variable=uic_location Qt5Core)}
|
||||
[UIC=${UIC:-$(pkg-config --variable=uic_location Qt5Core)}
|
||||
MOC=${MOC:-$(pkg-config --variable=moc_location Qt5Core)}
|
||||
have_qtnetwork=1],
|
||||
[PKG_CHECK_MODULES([QT_NETWORK], [QtNetwork])],
|
||||
[AC_DEFINE([HAVE_QTNETWORK])
|
||||
UIC=${UIC:-$(pkg-config --variable=uic_location QtCore)}
|
||||
MOC=${MOC:-$(pkg-config --variable=moc_location QtCore)}
|
||||
have_qtnetwork=1],
|
||||
[have_qtnetwork=0])
|
||||
[PKG_CHECK_MODULES([QT_NETWORK], [QtNetwork],
|
||||
[AC_DEFINE([HAVE_QTNETWORK])
|
||||
UIC=${UIC:-$(pkg-config --variable=uic_location QtCore)}
|
||||
MOC=${MOC:-$(pkg-config --variable=moc_location QtCore)}
|
||||
have_qtnetwork=1],
|
||||
[have_qtnetwork=0])])
|
||||
AM_CONDITIONAL(HAVE_QTNETWORK, test "$have_qtnetwork" = "1")
|
||||
AC_SUBST(UIC)
|
||||
AC_SUBST(MOC)
|
||||
|
@@ -40,7 +40,7 @@ if HAVE_QTNETWORK
|
||||
noinst_PROGRAMS += suisse-id-demo
|
||||
noinst_HEADERS = suisse-id-demo.hxx
|
||||
suisse_id_demo_SOURCES = suisse-id-demo.cxx
|
||||
suisse_id_demo_CXXFLAGS = ${QT_NETWORK_CFLAGS} -fPIC
|
||||
suisse_id_demo_CXXFLAGS = ${QT_NETWORK_CFLAGS}
|
||||
suisse_id_demo_LDADD = ${QT_NETWORK_LIBS}
|
||||
endif
|
||||
|
||||
|
@@ -128,17 +128,21 @@ namespace cardos {
|
||||
//@{
|
||||
|
||||
class BerValue {
|
||||
|
||||
public:
|
||||
|
||||
enum Class {
|
||||
UNIVERSAL = 0x00,
|
||||
APPLICATION = 0x40,
|
||||
CONTEXT_SPECIFIC = 0x80,
|
||||
PRIVATE = 0xC0
|
||||
};
|
||||
|
||||
enum PC {
|
||||
PRIMITIVE = 0x00,
|
||||
CONSTRUCTED = 0x20
|
||||
};
|
||||
|
||||
enum Type {
|
||||
END_OF_CONTENT = 0x00,
|
||||
BOOLEAN = 0x01,
|
||||
@@ -181,6 +185,10 @@ namespace cardos {
|
||||
}
|
||||
|
||||
BerValue(std::string& content) {
|
||||
set(content);
|
||||
}
|
||||
|
||||
void set(std::string& content) {
|
||||
if (content.size()<2)
|
||||
throw wrong_dataformat(content, "not a BER, header size too small: \""
|
||||
+crypto::binToHex(content)+"\"");
|
||||
@@ -198,6 +206,11 @@ namespace cardos {
|
||||
|
||||
public:
|
||||
|
||||
BerValue(const std::string& content) {
|
||||
std::string contentCopy(content);
|
||||
set(contentCopy);
|
||||
}
|
||||
|
||||
BerValue(unsigned char t, const std::string& v):
|
||||
_tag(t), _value(v) {
|
||||
if (isContainer())
|
||||
@@ -274,7 +287,8 @@ namespace cardos {
|
||||
|
||||
std::string print(int indent=0, int indentStep = 4) {
|
||||
std::stringstream ss;
|
||||
ss<<std::string(indent*indentStep, ' ')<<'['<<crypto::binToHex(_tag)<<'=';
|
||||
ss<<std::string(indent*indentStep, ' ')<<'['<<crypto::binToHex(_tag)
|
||||
<<'=';
|
||||
switch (tagClass()) {
|
||||
case UNIVERSAL: ss<<"UNIVERSAL,"; break;
|
||||
case APPLICATION: ss<<"APPLICATION,"; break;
|
||||
@@ -1471,8 +1485,8 @@ namespace cardos {
|
||||
return "No return code received";
|
||||
default:
|
||||
std::stringstream ss;
|
||||
if ((ret&&0xff00)==0x6100)
|
||||
ss<<(ret&&0xff)<<" bytes of response data can be received"
|
||||
if ((ret&0xff00)==0x6100)
|
||||
ss<<(ret&0xff)<<" bytes of response data can be received"
|
||||
<<" with GET RESPONSE (only T=0 transmission protocol)";
|
||||
else
|
||||
ss<<"Unknown CardOS error code: 0x"<<std::hex<<ret;
|
||||
|
@@ -57,7 +57,7 @@ cardgui_SOURCES = cardgui.cxx cardgui.hxx password.hxx cardgui-model.hxx \
|
||||
nodist_cardgui_SOURCES = cardgui_ui.hxx password_ui.hxx \
|
||||
moc_cardgui.cxx moc_password.cxx moc_cardgui-model.cxx
|
||||
BUILT_SOURCES = ${nodist_cardgui_SOURCES}
|
||||
cardgui_CXXFLAGS = ${QT_GUI_CFLAGS} -fPIC
|
||||
cardgui_CXXFLAGS = ${QT_GUI_CFLAGS}
|
||||
cardgui_LDADD = ${QT_GUI_LIBS} libpcscxx.la ${libpcscxx_la_LIBADD}
|
||||
endif
|
||||
|
||||
|
@@ -325,7 +325,7 @@ namespace suisseid {
|
||||
}
|
||||
|
||||
virtual unsigned int maximalPinLength() {
|
||||
if (_maxPinLen==0) evaluatePinLengths();
|
||||
if (_maxPinLen==(unsigned int)-1) evaluatePinLengths();
|
||||
return _maxPinLen;
|
||||
}
|
||||
|
||||
@@ -376,11 +376,12 @@ namespace suisseid {
|
||||
}
|
||||
|
||||
std::string versionFromMFFile(const std::string& file) {
|
||||
CRYPTOLOG("log");
|
||||
pcsc::Connection::Reader::Transaction lock(_reader);
|
||||
try {
|
||||
selectMfFile(file);
|
||||
return _version = cardos::BerValues(readBinary())[0].string();
|
||||
} catch (...) {
|
||||
return _version = cardos::BerValue(readBinary(file))[0].string();
|
||||
} catch (const std::exception& x) {
|
||||
CRYPTOLOG("exception, no version file: "<<x.what());
|
||||
return _version = "<unknown>";
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user