From a29536131815492d668976a81b46e6ad3d24d99a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Mon, 5 May 2014 08:15:28 +0000 Subject: [PATCH] Correctly decode values; refs #31 --- configure.in | 27 +++++++++++++-------------- doc/examples/makefile.am | 2 +- src/cardos.hxx | 20 +++++++++++++++++--- src/makefile.am | 2 +- src/suisseid.hxx | 9 +++++---- 5 files changed, 37 insertions(+), 23 deletions(-) diff --git a/configure.in b/configure.in index b7bca40..becaef5 100644 --- a/configure.in +++ b/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) diff --git a/doc/examples/makefile.am b/doc/examples/makefile.am index 95d1a4f..c4ff17a 100644 --- a/doc/examples/makefile.am +++ b/doc/examples/makefile.am @@ -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 diff --git a/src/cardos.hxx b/src/cardos.hxx index 1b19f87..a217a49 100644 --- a/src/cardos.hxx +++ b/src/cardos.hxx @@ -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<