├── .gitignore ├── .gitmodules ├── .travis.yml ├── CMake-Modules ├── FindCrypto++.cmake ├── FindEXPAT.cmake ├── FindLibDL.cmake └── FindPCSC.cmake ├── CMakeLists.txt ├── Makefile ├── README ├── README.md ├── eIDClientCore ├── AUTHORS ├── CMakeLists.txt ├── COPYING ├── ChangeLog ├── INSTALL_OS_X ├── Makefile.am ├── NEWS ├── README ├── android │ ├── Makefile │ ├── eIDClientCore Selbstauskunft │ │ ├── .classpath │ │ ├── .fdroid │ │ │ └── metadata │ │ │ │ └── de.bdr.eidcc.eidcc_selbstauskunft.txt │ │ ├── .project │ │ ├── .settings │ │ │ └── org.eclipse.jdt.core.prefs │ │ ├── AndroidManifest.xml │ │ ├── Makefile │ │ ├── README.md │ │ ├── build.xml │ │ ├── ic_launcher-web.png │ │ ├── libs │ │ │ └── android-support-v4.jar │ │ ├── proguard-project.txt │ │ ├── project.properties │ │ ├── res │ │ │ ├── drawable-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable │ │ │ │ ├── personalausweis_logo_0_completed.gif │ │ │ │ ├── personalausweis_logo_1_completed.gif │ │ │ │ ├── personalausweis_logo_2_completed.gif │ │ │ │ ├── personalausweis_logo_3_completed.gif │ │ │ │ ├── personalausweis_logo_4_completed.gif │ │ │ │ ├── personalausweis_logo_5_completed.gif │ │ │ │ └── personalausweis_logo_6_completed.gif │ │ │ ├── layout │ │ │ │ ├── activity_main.xml │ │ │ │ ├── activity_show_results.xml │ │ │ │ ├── chat.xml │ │ │ │ └── errors.xml │ │ │ ├── values-v11 │ │ │ │ └── styles.xml │ │ │ ├── values-v14 │ │ │ │ └── styles.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ └── values │ │ │ │ ├── dimens.xml │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ └── src │ │ │ └── de │ │ │ └── bdr │ │ │ └── eidcc │ │ │ └── eIDClientCore Selbstauskunft │ │ │ ├── CookieContext.java │ │ │ ├── GetWebPage.java │ │ │ ├── MainActivity.java │ │ │ ├── NPAReader.java │ │ │ ├── ShowResultsActivity.java │ │ │ ├── TcToken.java │ │ │ ├── eIDCCTestcase.java │ │ │ └── eIDCCTestcaseAusweisApp2.java │ ├── eIDClientLib │ │ ├── .classpath │ │ ├── .project │ │ ├── .settings │ │ │ └── org.eclipse.jdt.core.prefs │ │ ├── AndroidManifest.xml │ │ ├── build.xml │ │ ├── jni │ │ │ ├── Android.mk │ │ │ ├── Application.mk │ │ │ ├── de_bdr_eidclient_EIdSession.cpp │ │ │ ├── de_bdr_eidclient_EIdSession.h │ │ │ ├── de_bdr_eidclient_external_reader.cpp │ │ │ ├── de_bdr_eidclient_external_reader.h │ │ │ └── deps.mk │ │ ├── project.properties │ │ └── src │ │ │ └── de │ │ │ └── bdr │ │ │ ├── eidclient │ │ │ ├── Chat.java │ │ │ ├── EIdSession.java │ │ │ ├── EIdStatus.java │ │ │ ├── EacCallback.java │ │ │ ├── EidClient.java │ │ │ ├── Logging.java │ │ │ ├── Reader.java │ │ │ ├── SPDescription.java │ │ │ └── UserInput.java │ │ │ └── reader │ └── reader │ │ ├── java │ │ ├── reader │ │ │ └── Reader.java │ │ └── readerimpl │ │ │ ├── CyberJackReader.java │ │ │ ├── NFCReader.java │ │ │ ├── NFCWatchDog.java │ │ │ └── Util.java │ │ └── jni │ │ ├── Android.mk │ │ ├── de_bdr_eidclient_external_reader.cpp │ │ └── de_bdr_eidclient_external_reader.h ├── bin │ ├── CMakeLists.txt │ ├── Makefile.am │ ├── SimpleClient │ │ ├── CMakeLists.txt │ │ ├── CeIdObject.cpp │ │ ├── CeIdObject.h │ │ ├── CivetServer.cpp │ │ ├── CivetServer.h │ │ ├── Makefile.am │ │ ├── civetweb.c │ │ ├── civetweb.h │ │ ├── eidui_cli.cpp │ │ ├── eidui_cli.h │ │ ├── eidui_gui │ │ │ ├── CMakeLists.txt │ │ │ ├── ErrorMessages.cpp │ │ │ ├── ErrorMessages.h │ │ │ ├── MainFrame.cpp │ │ │ ├── MainFrame.h │ │ │ ├── Makefile.am │ │ │ ├── eidui_gui.cpp │ │ │ ├── eidui_gui.h │ │ │ └── test_script.sh │ │ ├── main.cpp │ │ └── md5.inl │ └── Test_nPAClientLib │ │ ├── CMakeLists.txt │ │ ├── Makefile.am │ │ ├── Start_Testcase.cpp │ │ ├── Start_Testcase.ggo │ │ ├── Test_nPAClientLib.cpp │ │ ├── Test_nPAClientLib.h │ │ ├── cmdline.c │ │ ├── cmdline.h │ │ ├── eidui_cli.cpp │ │ ├── eidui_cli.h │ │ ├── load_test.bash │ │ └── url.h ├── configure.ac ├── lib │ ├── CMakeLists.txt │ ├── Makefile.am │ ├── crypto.h │ ├── debug.c │ ├── debug.h │ ├── eCardCore │ │ ├── CMakeLists.txt │ │ ├── CardCommand.cpp │ │ ├── CardCommand.h │ │ ├── ExternalManager.h │ │ ├── ExternalReader.cpp │ │ ├── ExternalReader.h │ │ ├── ICard.cpp │ │ ├── ICard.h │ │ ├── ICardDetector.h │ │ ├── IReader.cpp │ │ ├── IReader.h │ │ ├── IReaderManager.h │ │ ├── Makefile.am │ │ ├── PCSCManager.cpp │ │ ├── PCSCManager.h │ │ ├── PCSCReader.cpp │ │ ├── PCSCReader.h │ │ ├── Transceiver.h │ │ ├── eCardStatus.h │ │ ├── eCardTypes.h │ │ ├── eIdClientCardReader.cpp │ │ ├── eIdClientCardReader.h │ │ ├── externalReader.def │ │ ├── externalReaderd.def │ │ ├── pace_reader.cpp │ │ └── pace_reader.h │ ├── eIDClientConnection │ │ ├── CMakeLists.txt │ │ ├── Makefile.am │ │ ├── eIDClientConnection.c │ │ ├── eIDClientConnection.def │ │ ├── eIDClientConnection.h │ │ ├── eIDClientConnectiond.def │ │ └── socket.c │ ├── eIDClientCore │ │ ├── CMakeLists.txt │ │ ├── Makefile.am │ │ ├── eIDClientCore.cpp │ │ ├── eIDClientCore.def │ │ ├── eIDClientCore.h │ │ ├── eIDClientCored.def │ │ ├── eIDECardClientPAOS.cpp │ │ ├── eIDECardClientPAOS.h │ │ ├── eIDUtils.cpp │ │ ├── eIDUtils.h │ │ ├── nPAClient.cpp │ │ ├── nPAClient.h │ │ ├── nPAClientProtocol.cpp │ │ └── nPAClientProtocol.h │ ├── eidasn1 │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── GeneralizedTime-putenv.c │ │ ├── Makefile.am │ │ ├── definitions │ │ │ └── tr31xx.asn1 │ │ ├── eIDHelper.h │ │ └── eIDOID.h │ ├── loadlib.h │ ├── nPA-EAC │ │ ├── CMakeLists.txt │ │ ├── Makefile.am │ │ ├── nPAAPI.h │ │ ├── nPACard.cpp │ │ ├── nPACard.h │ │ ├── nPACommon.cpp │ │ ├── nPACommon.h │ │ ├── nPAStatus.h │ │ ├── nPA_CA.cpp │ │ ├── nPA_PACE.cpp │ │ └── nPA_TA.cpp │ ├── testing.c │ └── testing.h ├── m4 │ ├── ax_check_openssl.m4 │ ├── ax_cxx_compile_stdcxx_11.m4 │ ├── ax_pthread.m4 │ └── libcurl.m4 └── winbuild │ ├── SimpleClient │ └── SimpleClient.vcxproj │ ├── Test_nPAClientLib │ └── Test_nPAClientLib.vcxproj │ ├── eCardCore │ └── eCardCore.vcxproj │ ├── eIDClientConnection │ └── eIDClientConnection.vcxproj │ ├── eIDClientCore │ └── eIDClientCore.vcxproj │ ├── eIDClientVS2012.sln │ ├── eidasn1 │ └── eIDASN1.vcxproj │ └── nPA-EAC │ └── nPA-EAC.vcxproj └── trusted_ca ├── CAcert.pem └── COMODO-chain.pem /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.swp 3 | 4 | *.lo 5 | *.o 6 | 7 | *.so 8 | 9 | *.lai 10 | *.la 11 | *.a 12 | *.sdf 13 | *.suo 14 | 15 | INSTALL 16 | Makefile.in 17 | Makefile 18 | ltmain.sh 19 | stamp-h1 20 | libtool 21 | autom4te.cache 22 | aclocal.m4 23 | compile 24 | configure 25 | depcomp 26 | install-sh 27 | missing 28 | config.guess 29 | config.h 30 | config.h.in 31 | config.log 32 | config.status 33 | config.sub 34 | .libs 35 | .deps 36 | 37 | bin/Test_nPAClientLib/Test_nPAClientLib 38 | lib/eIDClientConnection/gnutls-2.10.2.tar.bz2 39 | lib/eIDClientConnection/gnutls-2.10.2/ 40 | eIDClientCore/winbuild/Debug 41 | eIDClientCore/winbuild/Release 42 | eIDClientCore/winbuild/*/Debug 43 | eIDClientCore/winbuild/*/Release 44 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "eIDClientCore/bin/SimpleClient/civetweb"] 2 | path = eIDClientCore/bin/SimpleClient/civetweb 3 | url = https://github.com/civetweb/civetweb 4 | [submodule "eIDClientCore/bin/Test_nPAClientLib/wingetopt"] 5 | path = eIDClientCore/bin/Test_nPAClientLib/wingetopt 6 | url = https://github.com/alex85k/wingetopt.git 7 | [submodule "OpenSSL"] 8 | path = OpenSSL 9 | url = https://github.com/misery/openssl.git 10 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | 3 | sudo: false 4 | 5 | env: 6 | global: 7 | - PREFIX=$HOME/target 8 | - PATH=$PREFIX/bin:$PATH 9 | - INSECURE=true 10 | - ANDROID_API=android-19 11 | #For the newer version of Cryptopp setenv-android.sh 12 | - AOSP_API=$ANDROID_API 13 | 14 | compiler: 15 | - clang 16 | - gcc 17 | 18 | addons: 19 | apt: 20 | packages: 21 | #See https://github.com/JakeWharton/sdk-manager-plugin/issues/13 22 | - libstdc++6:i386 23 | - lib32z1 24 | - expect 25 | - libpcsclite-dev 26 | #For makedepend, needed when building OpenSSL 27 | - xutils-dev 28 | # For supporting C++11 29 | - gcc-4.8 30 | - g++-4.8 31 | sources: 32 | # For g++-4.8 (needed for C++11 support) 33 | - ubuntu-toolchain-r-test 34 | 35 | before_install: 36 | - wget --no-check-certificate https://cmake.org/files/v3.0/cmake-3.0.2.tar.gz 37 | - tar xzf cmake-3.0.2.tar.gz 38 | - cd cmake-3.0.2 39 | - ./bootstrap --system-curl --prefix=$PREFIX 40 | - make > /dev/null 41 | - make install 42 | - cd - 43 | - wget https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz 44 | - tar xzf android-sdk_r24.4.1-linux.tgz 45 | - export ANDROID_SDK_ROOT=$PWD/android-sdk-linux/ 46 | - export ANDROID_HOME=$ANDROID_SDK_ROOT 47 | - echo "y" | android-sdk-linux/tools/android update sdk -s --no-ui --all --filter platform-tools 48 | - echo "y" | android-sdk-linux/tools/android update sdk -s --no-ui --all --filter android-19 49 | - echo "y" | android-sdk-linux/tools/android update sdk -s --no-ui --all --filter build-tools-19.1.0 50 | - wget https://dl.google.com/android/ndk/android-ndk-r10e-linux-x86_64.bin 51 | - chmod +x android-ndk-r10e-linux-x86_64.bin 52 | - ./android-ndk-r10e-linux-x86_64.bin | egrep -v ^Extracting 53 | - export ANDROID_NDK_ROOT=$PWD/android-ndk-r10e/ 54 | - wget https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.0/wxWidgets-3.1.0.tar.bz2 55 | - tar -xjf wxWidgets-3.1.0.tar.bz2 56 | - cd wxWidgets-3.1.0 57 | - mkdir gtk-build 58 | - cd gtk-build 59 | - ../configure --enable-unicode --enable-debug --prefix=$PREFIX 60 | - make > /dev/null 61 | - make install 62 | - cd ../.. 63 | - cp $PREFIX/share/aclocal/wxwin.m4 eIDClientCore/m4/ 64 | 65 | install: 66 | - make cryptopp libexpat openssl libcurl asn1c PREFIX=$PREFIX INSECURE=$INSECURE 67 | 68 | script: 69 | - make eIDClient PREFIX=$PREFIX INSECURE=$INSECURE 70 | - if [ "$CC" = "gcc" ]; then export CHANGE_GCC_FOR_CMAKE="true"; fi 71 | - export CC= 72 | - make -C eIDClientCore/android/ ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT ANDROID_NDK_ROOT=$ANDROID_NDK_ROOT ANDROID_API=$ANDROID_API 73 | - make -C eIDClientCore/android/eIDClientCore\ Selbstauskunft ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT ANDROID_NDK_ROOT=$ANDROID_NDK_ROOT ANDROID_API=$ANDROID_API 74 | - if [ "$CHANGE_GCC_FOR_CMAKE" = "true" ]; then export CXX="g++-4.8" CC="gcc-4.8"; else export CC="clang"; fi 75 | - mkdir build && cd build && cmake .. && make 76 | 77 | cache: 78 | directories: 79 | - $HOME/target 80 | -------------------------------------------------------------------------------- /CMake-Modules/FindCrypto++.cmake: -------------------------------------------------------------------------------- 1 | # From https://raw.githubusercontent.com/harningt/cryptoface/master/Modules/FindCrypto%2B%2B.cmake 2 | # Modified by Erik Nellessen, erik.nellessen@informatik.hu-berlin.de 3 | 4 | # - Find Crypto++ 5 | 6 | if(CRYPTO++_INCLUDE_DIR AND CRYPTO++_LIBRARIES) 7 | set(CRYPTO++_FOUND TRUE) 8 | 9 | else(CRYPTO++_INCLUDE_DIR AND CRYPTO++_LIBRARIES) 10 | find_path(CRYPTO++_INCLUDE_DIR cryptlib.h 11 | ${CMAKE_PREFIX_PATH}/include/cryptopp 12 | /usr/include/crypto++ 13 | /usr/include/cryptopp 14 | /usr/local/include/crypto++ 15 | /usr/local/include/cryptopp 16 | /opt/local/include/crypto++ 17 | /opt/local/include/cryptopp 18 | $ENV{SystemDrive}/Crypto++/include 19 | ) 20 | 21 | find_library(CRYPTO++_LIBRARIES NAMES cryptopp 22 | PATHS 23 | ${CMAKE_PREFIX_PATH}/lib 24 | ${CMAKE_PREFIX_PATH}/lib64 25 | /usr/lib 26 | /usr/local/lib 27 | /opt/local/lib 28 | $ENV{SystemDrive}/Crypto++/lib 29 | ) 30 | 31 | if(CRYPTO++_INCLUDE_DIR AND CRYPTO++_LIBRARIES) 32 | set(CRYPTO++_FOUND TRUE) 33 | message(STATUS "Found Crypto++: ${CRYPTO++_INCLUDE_DIR}, ${CRYPTO++_LIBRARIES}") 34 | else(CRYPTO++_INCLUDE_DIR AND CRYPTO++_LIBRARIES) 35 | set(CRYPTO++_FOUND FALSE) 36 | message(STATUS "Crypto++ not found.") 37 | endif(CRYPTO++_INCLUDE_DIR AND CRYPTO++_LIBRARIES) 38 | 39 | mark_as_advanced(CRYPTO++_INCLUDE_DIR CRYPTO++_LIBRARIES) 40 | 41 | endif(CRYPTO++_INCLUDE_DIR AND CRYPTO++_LIBRARIES) 42 | -------------------------------------------------------------------------------- /CMake-Modules/FindEXPAT.cmake: -------------------------------------------------------------------------------- 1 | # From https://github.com/Kitware/CMake/blob/master/Modules/FindEXPAT.cmake 2 | # Modified by Erik Nellessen, erik.nellessen@informatik.hu-berlin.de 3 | 4 | #.rst: 5 | # FindEXPAT 6 | # --------- 7 | # 8 | # Find expat 9 | # 10 | # Find the native EXPAT headers and libraries. 11 | # 12 | # :: 13 | # 14 | # EXPAT_INCLUDE_DIRS - where to find expat.h, etc. 15 | # EXPAT_LIBRARIES - List of libraries when using expat. 16 | # EXPAT_FOUND - True if expat found. 17 | 18 | #============================================================================= 19 | # Copyright 2006-2009 Kitware, Inc. 20 | # 21 | # Distributed under the OSI-approved BSD License (the "License"); 22 | # see accompanying file Copyright.txt for details. 23 | # 24 | # This software is distributed WITHOUT ANY WARRANTY; without even the 25 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 26 | # See the License for more information. 27 | #============================================================================= 28 | # (To distribute this file outside of CMake, substitute the full 29 | # License text for the above reference.) 30 | 31 | # Look for the header file. 32 | find_path(EXPAT_INCLUDE_DIR NAMES expat.h) 33 | 34 | # Look for the library. 35 | find_library(EXPAT_LIBRARY NAMES expat libexpat) 36 | 37 | if (EXPAT_INCLUDE_DIR AND EXISTS "${EXPAT_INCLUDE_DIR}/expat.h") 38 | file(STRINGS "${EXPAT_INCLUDE_DIR}/expat.h" expat_version_str 39 | REGEX "^#[\t ]*define[\t ]+XML_(MAJOR|MINOR|MICRO)_VERSION[\t ]+[0-9]+$") 40 | 41 | unset(EXPAT_VERSION_STRING) 42 | foreach(VPART MAJOR MINOR MICRO) 43 | foreach(VLINE ${expat_version_str}) 44 | if(VLINE MATCHES "^#[\t ]*define[\t ]+XML_${VPART}_VERSION[\t ]+([0-9]+)$") 45 | set(EXPAT_VERSION_PART "${CMAKE_MATCH_1}") 46 | if(EXPAT_VERSION_STRING) 47 | set(EXPAT_VERSION_STRING "${EXPAT_VERSION_STRING}.${EXPAT_VERSION_PART}") 48 | else() 49 | set(EXPAT_VERSION_STRING "${EXPAT_VERSION_PART}") 50 | endif() 51 | endif() 52 | endforeach() 53 | endforeach() 54 | endif () 55 | 56 | # handle the QUIETLY and REQUIRED arguments and set EXPAT_FOUND to TRUE if 57 | # all listed variables are TRUE 58 | include(FindPackageHandleStandardArgs) 59 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(EXPAT 60 | REQUIRED_VARS EXPAT_LIBRARY EXPAT_INCLUDE_DIR 61 | VERSION_VAR EXPAT_VERSION_STRING) 62 | 63 | # Copy the results to the output variables. 64 | if(EXPAT_FOUND) 65 | set(EXPAT_LIBRARIES ${EXPAT_LIBRARY}) 66 | set(EXPAT_INCLUDE_DIRS ${EXPAT_INCLUDE_DIR}) 67 | endif() 68 | 69 | mark_as_advanced(EXPAT_INCLUDE_DIR EXPAT_LIBRARY) 70 | -------------------------------------------------------------------------------- /CMake-Modules/FindLibDL.cmake: -------------------------------------------------------------------------------- 1 | # From https://github.com/Fadis/libdcompile/blob/master/CMakeFiles/modules/FindLibDL.cmake 2 | # - Find libdl 3 | # Find the native LIBDL includes and library 4 | # 5 | # LIBDL_INCLUDE_DIR - where to find dlfcn.h, etc. 6 | # LIBDL_LIBRARIES - List of libraries when using libdl. 7 | # LIBDL_FOUND - True if libdl found. 8 | 9 | 10 | IF (LIBDL_INCLUDE_DIR) 11 | # Already in cache, be silent 12 | SET(LIBDL_FIND_QUIETLY TRUE) 13 | ENDIF (LIBDL_INCLUDE_DIR) 14 | 15 | FIND_PATH(LIBDL_INCLUDE_DIR dlfcn.h) 16 | 17 | SET(LIBDL_NAMES dl libdl ltdl libltdl) 18 | FIND_LIBRARY(LIBDL_LIBRARY NAMES ${LIBDL_NAMES} ) 19 | 20 | # handle the QUIETLY and REQUIRED arguments and set LIBDL_FOUND to TRUE if 21 | # all listed variables are TRUE 22 | INCLUDE(FindPackageHandleStandardArgs) 23 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibDL DEFAULT_MSG LIBDL_LIBRARY LIBDL_INCLUDE_DIR) 24 | 25 | IF(LIBDL_FOUND) 26 | SET( LIBDL_LIBRARIES ${LIBDL_LIBRARY} ) 27 | ELSE(LIBDL_FOUND) 28 | SET( LIBDL_LIBRARIES ) 29 | ENDIF(LIBDL_FOUND) 30 | 31 | MARK_AS_ADVANCED( LIBDL_LIBRARY LIBDL_INCLUDE_DIR ) 32 | -------------------------------------------------------------------------------- /CMake-Modules/FindPCSC.cmake: -------------------------------------------------------------------------------- 1 | #From https://github.com/FreeRDP/FreeRDP/blob/master/cmake/FindPCSC.cmake 2 | 3 | # - Try to find the PC/SC smart card library 4 | # Once done this will define 5 | # 6 | # PCSC_FOUND - system has the PC/SC library 7 | # PCSC_INCLUDE_DIRS - the PC/SC include directory 8 | # PCSC_LIBRARIES - The libraries needed to use PC/SC 9 | # 10 | # Author: F. Kooman 11 | # Version: 20101019 12 | # 13 | 14 | FIND_PACKAGE (PkgConfig) 15 | IF(PKG_CONFIG_FOUND) 16 | # Will find PC/SC library on Linux/BSDs using PkgConfig 17 | PKG_CHECK_MODULES(PCSC libpcsclite) 18 | # PKG_CHECK_MODULES(PCSC QUIET libpcsclite) # IF CMake >= 2.8.2? 19 | ENDIF(PKG_CONFIG_FOUND) 20 | 21 | IF(NOT PCSC_FOUND) 22 | # Will find PC/SC headers both on Mac and Windows 23 | FIND_PATH(PCSC_INCLUDE_DIRS WinSCard.h) 24 | # PCSC library is for Mac, WinSCard library is for Windows 25 | FIND_LIBRARY(PCSC_LIBRARIES NAMES PCSC libwinscard) 26 | ENDIF(NOT PCSC_FOUND) 27 | 28 | INCLUDE(FindPackageHandleStandardArgs) 29 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCSC DEFAULT_MSG 30 | PCSC_LIBRARIES 31 | PCSC_INCLUDE_DIRS 32 | ) 33 | MARK_AS_ADVANCED(PCSC_INCLUDE_DIRS PCSC_LIBRARIES) 34 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0.2) 2 | project(eIDClientCore) 3 | 4 | option(RebuildOpenSSL "Rebuild OpenSSL" ON) 5 | 6 | include(ExternalProject) 7 | 8 | set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake-Modules) 9 | set(BUILD_DIR ${CMAKE_SOURCE_DIR}/build) 10 | set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/build) 11 | set(CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/build) 12 | 13 | ExternalProject_Add(libcryptopp 14 | GIT_REPOSITORY https://github.com/weidai11/cryptopp 15 | PREFIX ${BUILD_DIR} 16 | CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} 17 | ) 18 | 19 | #ASN1C does not use cmake 20 | set(ASN1C_DOWNLOAD_DIR ${BUILD_DIR}/src/asn1c) 21 | ExternalProject_Add(asn1c 22 | URL https://lionet.info/soft/asn1c-0.9.24.tar.gz 23 | PREFIX ${BUILD_DIR} 24 | CONFIGURE_COMMAND ${ASN1C_DOWNLOAD_DIR}/configure --prefix=${BUILD_DIR} 25 | BUILD_IN_SOURCE 1 26 | BUILD_COMMAND make -C ${ASN1C_DOWNLOAD_DIR} 27 | INSTALL_COMMAND make -C ${ASN1C_DOWNLOAD_DIR} install 28 | ) 29 | 30 | ExternalProject_Add(libexpat 31 | URL http://sourceforge.net/projects/expat/files/expat/2.1.0/expat-2.1.0.tar.gz 32 | URL_HASH SHA1=b08197d146930a5543a7b99e871cba3da614f6f0 33 | PREFIX ${BUILD_DIR} 34 | CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} 35 | ) 36 | 37 | #OpenSSL does not use cmake 38 | set(OPENSSL_DOWNLOAD_DIR ${BUILD_DIR}/src/openssl) 39 | if(RebuildOpenSSL) 40 | set(OPENSSL_BUILD_COMMAND make -C ${OPENSSL_DOWNLOAD_DIR} depend && ) 41 | message("RebuildOpenSSL switched on. To disable, use cmake -DRebuildOpenSSL=OFF") 42 | else() 43 | message("RebuildOpenSSL switched off. To enable, use cmake -DRebuildOpenSSL=ON") 44 | endif() 45 | set(OPENSSL_BUILD_COMMAND ${OPENSSL_BUILD_COMMAND} make -C ${OPENSSL_DOWNLOAD_DIR}) 46 | ExternalProject_Add(openssl 47 | GIT_REPOSITORY https://github.com/misery/openssl 48 | GIT_TAG OpenSSL_1_0_2-stable 49 | PREFIX ${BUILD_DIR} 50 | CONFIGURE_COMMAND ${OPENSSL_DOWNLOAD_DIR}/config --prefix=${BUILD_DIR} shared 51 | BUILD_IN_SOURCE 1 52 | BUILD_COMMAND ${OPENSSL_BUILD_COMMAND} 53 | INSTALL_COMMAND make -C ${OPENSSL_DOWNLOAD_DIR} install_sw 54 | TEST_AFTER_INSTALL 1 55 | TEST_COMMAND ${BUILD_DIR}/bin/openssl ciphers -v | grep RSAPSK 56 | ) 57 | 58 | ExternalProject_Add(libcurl 59 | URL https://github.com/bagder/curl/releases/download/curl-7_44_0/curl-7.44.0.tar.gz 60 | PREFIX ${BUILD_DIR} 61 | CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} 62 | ) 63 | add_dependencies(libcurl openssl) 64 | 65 | ExternalProject_Add(eIDClientCore 66 | DOWNLOAD_COMMAND "" 67 | SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/eIDClientCore 68 | PREFIX ${BUILD_DIR} 69 | CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} -DCMAKE_MODULE_PATH=${CMAKE_MODULE_PATH} 70 | ) 71 | add_dependencies(eIDClientCore libcryptopp asn1c libexpat openssl libcurl) 72 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | SHELL=/bin/bash 2 | 3 | PREFIX ?= $(shell pwd) 4 | 5 | ASN1C ?= "$(PREFIX)/bin/asn1c" 6 | 7 | #INSECURE = "true" 8 | 9 | #BASIERT auf: https://github.com/BeID-lab/eIDClientCore/blob/master/README.md 10 | 11 | ALL_DEPS = cryptopp asn1c libexpat openssl libcurl 12 | MY_DEPS = cryptopp asn1c libexpat openssl libcurl 13 | 14 | all: $(MY_DEPS) eIDClient 15 | 16 | mydeps: $(MY_DEPS) 17 | 18 | delete_all: 19 | rm -rf *[^Makefile]* 20 | 21 | clean_cryptopp: 22 | make -C cryptopp*/ clean 23 | 24 | clean_asn1c: 25 | make -C asn1c*/ clean 26 | 27 | clean_libexpat: 28 | make -C expat*/ clean 29 | 30 | clean_openssl: 31 | make -C OpenSSL*/ clean 32 | 33 | clean_libcurl: 34 | make -C curl*/ clean 35 | 36 | clean_eIDClient: 37 | make -C eIDClientCore/ clean 38 | 39 | clean: clean_cryptopp clean_asn1c clean_libexpat clean_openssl clean_libcurl clean_eIDClient 40 | 41 | cryptopp: 42 | svn checkout https://svn.code.sf.net/p/cryptopp/code/trunk/c5 cryptopp 43 | sed -i.org -e "s%^#.*\(CXXFLAGS += -fPIC.*\)%\1%g" cryptopp/GNUmakefile 44 | make -C cryptopp all libcryptopp.so 45 | make -C cryptopp install PREFIX=$(PREFIX) 46 | 47 | asn1c: 48 | wget https://sourceforge.net/projects/asn1c/files/asn1c/asn1c-0.9.24/asn1c-0.9.24.tar.gz 49 | tar xzf asn1c-0.9.24.tar.gz 50 | cd asn1c-0.9.24 ;\ 51 | ./configure --prefix=$(PREFIX) ;\ 52 | make install 53 | 54 | libexpat: 55 | wget https://github.com/libexpat/libexpat/releases/download/R_2_1_0/expat-2.1.0.tar.gz 56 | echo "823705472f816df21c8f6aa026dd162b280806838bb55b3432b0fb1fcca7eb86 expat-2.1.0.tar.gz" | sha256sum -c - 57 | tar xzf expat-2.1.0.tar.gz 58 | cd expat-2.1.0 ;\ 59 | ./configure --prefix=$(PREFIX) ;\ 60 | make install 61 | 62 | openssl: 63 | cd OpenSSL ;\ 64 | git submodule init ;\ 65 | git submodule update ;\ 66 | ./config --prefix=$(PREFIX) shared ;\ 67 | make -j8 ;\ 68 | make install_sw ;\ 69 | apps/openssl ciphers 'RSAPSK' -v ;\ 70 | if test $$? -ne 0 ; then \ 71 | echo "No RSA-PSK cipher suites found. OpenSSL build some somehow failed!" ;\ 72 | exit 1 ;\ 73 | fi 74 | 75 | libcurl: 76 | wget https://github.com/bagder/curl/releases/download/curl-7_44_0/curl-7.44.0.tar.gz 77 | tar xzf curl-7.44.0.tar.gz 78 | cd curl-7.44.0 ;\ 79 | ./configure --prefix=$(PREFIX) PKG_CONFIG_PATH=$(PREFIX)/lib/pkgconfig:$(PREFIX)/lib64/pkgconfig ;\ 80 | make install 81 | 82 | eIDClient: 83 | cd eIDClientCore ;\ 84 | autoreconf -vis ;\ 85 | env LD_LIBRARY_PATH=$(PREFIX)/lib:$(PREFIX)/lib64 ./configure --prefix=$(PREFIX) \ 86 | --with-openssl=$(PREFIX) --with-libcurl=$(PREFIX) \ 87 | PKG_CONFIG_PATH=$(PREFIX)/lib/pkgconfig:$(PREFIX)/lib64/pkgconfig\ 88 | ASN1C="$(ASN1C)" CRYPTOPP_CFLAGS="-I$(PREFIX)/include" CRYPTOPP_LIBS="-L$(PREFIX)/lib -lcryptopp" 89 | [[ -v INSECURE ]] || \ 90 | sed -i.org -e "s%^\(CPPFLAGS = .*\)%\1 -DSKIP_PEER_VERIFICATION -DSKIP_HOSTNAME_VERIFICATION%g"\ 91 | eIDClientCore/lib/eIDClientConnection/Makefile ;\ 92 | make -C eIDClientCore install 93 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | README.md -------------------------------------------------------------------------------- /eIDClientCore/AUTHORS: -------------------------------------------------------------------------------- 1 | Bundesdruckerei GmbH 2 | -------------------------------------------------------------------------------- /eIDClientCore/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0.2) 2 | 3 | find_package(Git) 4 | execute_process (COMMAND ${GIT_EXECUTABLE} submodule init) 5 | execute_process (COMMAND ${GIT_EXECUTABLE} submodule update) 6 | 7 | include(GNUInstallDirs) 8 | include(FindPkgConfig) 9 | include(CheckIncludeFile) 10 | 11 | set(ENV{PKG_CONFIG_PATH} "${BUILD_DIR}/lib/pkgconfig/:${BUILD_DIR}/lib64/pkgconfig/:$ENV{PKG_CONFIG_PATH}") 12 | 13 | find_program(ASN1C asn1c) 14 | find_program(GENGETOPT gengetopt) 15 | 16 | # Do not use special C++11 settings when cross-compiling for android 17 | if(NOT ANDROID) 18 | #Usable in cmake 3.1 and higher 19 | #set(CMAKE_CXX_STANDARD 11) 20 | #set(CMAKE_CXX_STANDARD_REQUIRED ON) 21 | #Also usable below cmake 3.1 22 | set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -std=c++11) 23 | endif() 24 | 25 | find_package(Crypto++ REQUIRED) 26 | find_package(EXPAT REQUIRED) 27 | 28 | find_package(Threads) 29 | 30 | find_package(PCSC REQUIRED) 31 | if(WIN32) 32 | if(NOT PCSC_LIBRARIES) 33 | set(PCSC_LIBRARIES -lwinscard) 34 | endif() 35 | else() 36 | find_package(LibDL REQUIRED) 37 | endif() 38 | 39 | option(DISABLE_EXTERNAL "Define if External reader is disabled." OFF) 40 | option(DISABLE_PCSC "Define if PC/SC readers are disabled." OFF) 41 | 42 | CHECK_INCLUDE_FILE(eIDmfcUI.h EID_GUI_AVAILABLE) 43 | if(NOT EID_GUI_AVAILABLE) 44 | add_definitions(-DDISABLE_EIDGUI) 45 | endif() 46 | 47 | find_package(CURL REQUIRED) 48 | if(CURL_FOUND) 49 | add_definitions(-DHAVE_LIBCURL) 50 | endif() 51 | find_package(OpenSSL REQUIRED) 52 | 53 | set(wxWidgets_CONFIG_OPTIONS --libs richtext) 54 | find_package(wxWidgets 3.0.2 REQUIRED) 55 | 56 | add_subdirectory(lib) 57 | add_subdirectory(bin) -------------------------------------------------------------------------------- /eIDClientCore/ChangeLog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BeID-lab/eIDClientCore/c734211d03b5118629880ce8850f14c9bc31fa3b/eIDClientCore/ChangeLog -------------------------------------------------------------------------------- /eIDClientCore/INSTALL_OS_X: -------------------------------------------------------------------------------- 1 | install ports 2 | 3 | port install automake autoconf libtool pkgconfig wget libcryptopp libgcrypt libusb 4 | 5 | make and install asn1c-0.9.24 6 | make and install cryptopp-562 (make dynamic) 7 | 8 | download and install reiner sct basis ccid-driver http://www.reiner-sct.com/support/download/treiber-und-software/cyberjack/rfid-basis-macos.html?grp=kontaktlos 9 | 10 | # eIDClientCore 11 | autoreconf -vis 12 | ./configure \ 13 | CFLAGS="-I/opt/local/include" \ 14 | LIBS="-Wl,-framework,PCSC -L/opt/local/lib -lgcrypt" \ 15 | PCSC_LIBS="-Wl,-framework,PCSC" \ 16 | PCSC_CFLAGS=-I"/usr/local/include/PCSC -I/Library/Frameworks/jsoncpp.framework/Versions/2.0.0/Headers/json -framework PCSC" \ 17 | CRYPTOPP_CFLAGS="-I/usr/include" \ 18 | CRYPTOPP_LIBS="-L/usr/lib -lcryptopp" 19 | make 20 | 21 | # if gnutls can't find gcrypt: 22 | lib/eIDClientConnection/gnutls-2.10.2/configure CFLAGS="-I/opt/local/include" LIBS="-L/opt/local/lib -lgcrypt" 23 | -------------------------------------------------------------------------------- /eIDClientCore/Makefile.am: -------------------------------------------------------------------------------- 1 | ACLOCAL_AMFLAGS = -I m4 2 | SUBDIRS = lib bin 3 | EXTRA_DIST = android 4 | -------------------------------------------------------------------------------- /eIDClientCore/NEWS: -------------------------------------------------------------------------------- 1 | eIDClientCore 0.2 - 2013-11-08 2 | 3 | - eIDClientCore: 4 | - removed unused namespaces 5 | - fixed compiling for Mac OS and Android 6 | - added some error codes 7 | - catch some exceptions. exceptions should be removed in future releases, though 8 | - now using nPAeIdPerformAuthenticationProtocol(READER_PCSC, ...) instead of nPAeIdPerformAuthenticationProtocolPcSc(...) 9 | - now passing a decoded version of CHAT and certificate description to the application 10 | - removed unused eIDECardClient class 11 | 12 | - eCardCore: 13 | - added support for boxing commands from BSI TR-03119 1.2 14 | - added support for selecting a card reader by name 15 | - added interface for external reader to be loaded at runtime 16 | 17 | - eIDClientConnection: 18 | - switched to libcurl with OpenSSL for RSA-PSK. Crypto++ should be removed in favor of OpenPACE in future releases 19 | - added wrappers for HTTP/PAOS/raw socket communication 20 | 21 | - nPA-EAC: added support for 3DES and DH for PACE 22 | 23 | - eidasn1: fixed handling of CVCA link certificates 24 | 25 | - Test_nPAClientLib: 26 | - separated ui 27 | - added support for new calling convention with redirect to localhost 28 | - fixed thread handling 29 | 30 | - added implementation and wrappers for Android 31 | - added more information about building building the library in README.md 32 | - fixed some other minor bug 33 | 34 | -------------------------------------------------------------------------------- /eIDClientCore/README: -------------------------------------------------------------------------------- 1 | ../README.md -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/.fdroid/metadata/de.bdr.eidcc.eidcc_selbstauskunft.txt: -------------------------------------------------------------------------------- 1 | Categories:Security,Development 2 | License:OpenSource-Lizenz der Humboldt-Universität zu Berlin für die Software „eIDClientCore“, https://github.com/BeID-lab/eIDClientCore/blob/master/eIDClientCore/COPYING 3 | Web Site: 4 | Source Code:https://github.com/BeID-lab/eIDClientCore/ 5 | Issue Tracker:https://github.com/BeID-lab/eIDClientCore//issues 6 | 7 | Auto Name:eIDClientCore Selbstauskunft 8 | Summary:Selbstauskunft on your smartphone 9 | Description: 10 | This Android app allows to use Selbstauskunft Services on an Android smartphone. [https://github.com/BeID-lab/eIDClientCore/tree/master/eIDClientCore/android/eIDClientCore%20Selbstauskunft#welcome Readme] 11 | 12 | Warning: This is just proof-of-concept code and should NOT be used in production environments 13 | . 14 | 15 | Repo Type:git 16 | Repo:https://github.com/BeID-lab/eIDClientCore/ 17 | 18 | Build:1.0,1 19 | commit=7e0ce4e4bd90ffe0d456565c12c0bab8717e49f0 20 | subdir=eIDClientCore/android/eIDClientCore\ Selbstauskunft 21 | build=sed -i.org '/^libeIDClientConnection_la_CPPFLAGS/{/-DSKIP_PEER_VERIFICATION -DSKIP_HOSTNAME_VERIFICATION/! s/$$/ -DSKIP_PEER_VERIFICATION -DSKIP_HOSTNAME_VERIFICATION/}' ../../lib/eIDClientConnection/Makefile.am && make -C ../ ANDROID_NDK_ROOT=$$NDK$$ ANDROID_SDK_ROOT=$$SDK$$ ANDROID_API=android-21 AOSP_API=android-21 && $$SDK$$/tools/android update project --path . --target $ANDROID_API 22 | 23 | Auto Update Mode:None 24 | Update Check Mode:Tags 25 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | eIDClientCore Selbstauskunft 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 3 | org.eclipse.jdt.core.compiler.compliance=1.6 4 | org.eclipse.jdt.core.compiler.source=1.6 5 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 14 | 15 | 18 | 19 | 24 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 37 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | sed -i.org '/^libeIDClientConnection_la_CPPFLAGS/{/-DSKIP_PEER_VERIFICATION -DSKIP_HOSTNAME_VERIFICATION/! s/$$/ -DSKIP_PEER_VERIFICATION -DSKIP_HOSTNAME_VERIFICATION/}' ../../lib/eIDClientConnection/Makefile.am 3 | make -C ../ ANDROID_NDK_ROOT=$(ANDROID_NDK_ROOT) ANDROID_SDK_ROOT=$(ANDROID_SDK_ROOT) ANDROID_API=$(ANDROID_API) 4 | $(ANDROID_SDK_ROOT)/tools/android update project --path . --target $(ANDROID_API) 5 | ant debug 6 | 7 | install: 8 | $(ANDROID_SDK_ROOT)/platform-tools/adb install -r bin/MainActivity-debug.apk -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/README.md: -------------------------------------------------------------------------------- 1 | # Welcome 2 | 3 | This Android app allows to use the Selbstauskunft Service of Ausweisapp2 on an Android smartphone. 4 | 5 | All relevant information about the eIDClientCore can be found at: 6 | http://sar.informatik.hu-berlin.de/BeID-lab/eIDClientCore 7 | 8 | Warning: This is just proof-of-concept code and should _NOT_ be used in 9 | production environments 10 | 11 | # Tested platforms: 12 | 13 | * Android 5.0.2 Lollipop on LG G2 Mini 14 | 15 | On this system, the app worked without changing anything on the smartphone. 16 | 17 | * Android 4.4 Kitkat on Nexus 5 18 | 19 | We used a modified Android to be able to send extended APDUs, see https://code.google.com/p/android/issues/detail?id=76598 . A tutorial for building Android for Nexus 5 can be found on http://nosemaj.org/howto-build-android-kitkat-nexus-5 . 20 | 21 | # Building 22 | 23 | We used eclipse to create this app. 24 | 25 | To use the app, build it using the makefile in the following way: 26 | 27 | ```sh 28 | make ANDROID_NDK_ROOT=$ANDROID_NDK_ROOT ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT ANDROID_API=$ANDROID_API 29 | ``` 30 | 31 | We used android-ndk-r10b-target-32-bit as NDK, adt-bundle-linux-x86_64-20140702 as SDK and android-19 as API. The OS on which we build the app is OpenSUSE 13.1 (64 Bit). 32 | 33 | Afterwards, you can install the app like this: 34 | 35 | ```sh 36 | make install 37 | ``` 38 | 39 | Make sure, that your device is connected to your computer and that USB debugging is enabled. 40 | 41 | # TODO 42 | 43 | * - -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 29 | 30 | 31 | 35 | 36 | 37 | 38 | 39 | 40 | 49 | 50 | 51 | 52 | 56 | 57 | 69 | 70 | 71 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BeID-lab/eIDClientCore/c734211d03b5118629880ce8850f14c9bc31fa3b/eIDClientCore/android/eIDClientCore Selbstauskunft/ic_launcher-web.png -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/libs/android-support-v4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BeID-lab/eIDClientCore/c734211d03b5118629880ce8850f14c9bc31fa3b/eIDClientCore/android/eIDClientCore Selbstauskunft/libs/android-support-v4.jar -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-19 15 | android.library.reference.1=../eIDClientLib/ 16 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BeID-lab/eIDClientCore/c734211d03b5118629880ce8850f14c9bc31fa3b/eIDClientCore/android/eIDClientCore Selbstauskunft/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BeID-lab/eIDClientCore/c734211d03b5118629880ce8850f14c9bc31fa3b/eIDClientCore/android/eIDClientCore Selbstauskunft/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BeID-lab/eIDClientCore/c734211d03b5118629880ce8850f14c9bc31fa3b/eIDClientCore/android/eIDClientCore Selbstauskunft/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BeID-lab/eIDClientCore/c734211d03b5118629880ce8850f14c9bc31fa3b/eIDClientCore/android/eIDClientCore Selbstauskunft/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/res/drawable/personalausweis_logo_0_completed.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BeID-lab/eIDClientCore/c734211d03b5118629880ce8850f14c9bc31fa3b/eIDClientCore/android/eIDClientCore Selbstauskunft/res/drawable/personalausweis_logo_0_completed.gif -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/res/drawable/personalausweis_logo_1_completed.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BeID-lab/eIDClientCore/c734211d03b5118629880ce8850f14c9bc31fa3b/eIDClientCore/android/eIDClientCore Selbstauskunft/res/drawable/personalausweis_logo_1_completed.gif -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/res/drawable/personalausweis_logo_2_completed.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BeID-lab/eIDClientCore/c734211d03b5118629880ce8850f14c9bc31fa3b/eIDClientCore/android/eIDClientCore Selbstauskunft/res/drawable/personalausweis_logo_2_completed.gif -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/res/drawable/personalausweis_logo_3_completed.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BeID-lab/eIDClientCore/c734211d03b5118629880ce8850f14c9bc31fa3b/eIDClientCore/android/eIDClientCore Selbstauskunft/res/drawable/personalausweis_logo_3_completed.gif -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/res/drawable/personalausweis_logo_4_completed.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BeID-lab/eIDClientCore/c734211d03b5118629880ce8850f14c9bc31fa3b/eIDClientCore/android/eIDClientCore Selbstauskunft/res/drawable/personalausweis_logo_4_completed.gif -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/res/drawable/personalausweis_logo_5_completed.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BeID-lab/eIDClientCore/c734211d03b5118629880ce8850f14c9bc31fa3b/eIDClientCore/android/eIDClientCore Selbstauskunft/res/drawable/personalausweis_logo_5_completed.gif -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/res/drawable/personalausweis_logo_6_completed.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BeID-lab/eIDClientCore/c734211d03b5118629880ce8850f14c9bc31fa3b/eIDClientCore/android/eIDClientCore Selbstauskunft/res/drawable/personalausweis_logo_6_completed.gif -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 11 | 12 | 19 | 20 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/res/layout/activity_show_results.xml: -------------------------------------------------------------------------------- 1 | 11 | 12 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/res/layout/errors.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 10 | 11 | 18 | 19 | 26 | 27 | 34 | 35 | 42 | 43 | 50 | 51 | 52 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/res/values-v11/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/res/values-v14/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 64dp 9 | 10 | 11 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16dp 5 | 16dp 6 | 7 | 8 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | eIDClientCore Selbstauskunft 5 | Dienstanbieterinformationen anzeigen 6 | Dienstanbieterinformationen ausblenden 7 | Zugriffsberechtigungen anzeigen 8 | Zugriffsberechtigungen ausblenden 9 | Dieses Bild zeigt den Fortschritt des Vorgangs an. 10 | Ihre Ergebnisse 11 | Altersnachweis 12 | Bestätigung des Wohnorts 13 | Restricted ID 14 | Privilegiert 15 | CAN erlaubt 16 | PIN Management 17 | Zertifikat installieren 18 | Qualifiziertes Zertifikat installieren 19 | Dokumententyp lesen 20 | Ausstellenden Staat lesen 21 | Ablaufdatum lesen 22 | Vornamen lesen 23 | Familiennamen lesen 24 | Künstlernamen lesen 25 | Akademischen Titel lesen 26 | Geburtsdatum lesen 27 | Geburtsort lesen 28 | Staatszugehörigkeit lesen 29 | Geschlecht lesen 30 | DG12 lesen 31 | DG13 lesen 32 | DG14 lesen 33 | DG15 lesen 34 | DG16 lesen 35 | Adresse lesen 36 | Wohnort-ID lesen 37 | Aufenthaltserlaubnis I lesen 38 | Aufenthaltserlaubnis II lesen 39 | DG21 lesen 40 | Adresse ändern 41 | Wohnort-ID ändern 42 | Aufenthaltserlaubnis I ändern 43 | Aufenthaltserlaubnis II ändern 44 | DG21 ändern 45 | RFU1 46 | RFU2 47 | RFU3 48 | RFU4 49 | role 50 | Verbindung zum Dienstanbieter 51 | PIN korrekt 52 | Prüfung der Leseberechtigung 53 | Echtheitsprüfung des Ausweises 54 | Daten ausgelesen 55 | 56 | 57 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/src/de/bdr/eidcc/eIDClientCore Selbstauskunft/CookieContext.java: -------------------------------------------------------------------------------- 1 | package de.bdr.eidcc.eidclientcore_selbstauskunft; 2 | 3 | import org.apache.http.client.CookieStore; 4 | import org.apache.http.client.protocol.ClientContext; 5 | import org.apache.http.impl.client.BasicCookieStore; 6 | import org.apache.http.impl.client.DefaultHttpClient; 7 | import org.apache.http.protocol.BasicHttpContext; 8 | import org.apache.http.protocol.HttpContext; 9 | 10 | public class CookieContext { 11 | DefaultHttpClient httpClient; 12 | HttpContext localContext; 13 | String url; 14 | CookieStore cookieStore; 15 | 16 | public CookieContext(String url){ 17 | this.httpClient = new DefaultHttpClient(); 18 | this.localContext = new BasicHttpContext(); 19 | this.cookieStore = new BasicCookieStore(); 20 | this.localContext.setAttribute(ClientContext.COOKIE_STORE, this.cookieStore); 21 | this.url = url; 22 | } 23 | 24 | public void setUrl(String url){ 25 | this.url = url; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/src/de/bdr/eidcc/eIDClientCore Selbstauskunft/GetWebPage.java: -------------------------------------------------------------------------------- 1 | package de.bdr.eidcc.eidclientcore_selbstauskunft; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.IOException; 5 | import java.io.InputStream; 6 | import java.io.UnsupportedEncodingException; 7 | 8 | import org.apache.http.HttpResponse; 9 | import org.apache.http.client.methods.HttpGet; 10 | 11 | import android.os.AsyncTask; 12 | 13 | public class GetWebPage extends AsyncTask { 14 | CookieContext mCookieContext; 15 | 16 | public GetWebPage(CookieContext mCookieContext){ 17 | this.mCookieContext = mCookieContext; 18 | } 19 | 20 | protected String doInBackground(Void... voids) { 21 | HttpGet get = new HttpGet(mCookieContext.url); 22 | HttpResponse response = null; 23 | try { 24 | response = mCookieContext.httpClient.execute(get, mCookieContext.localContext); 25 | } catch (Exception e) { 26 | e.printStackTrace(); 27 | } 28 | 29 | ByteArrayOutputStream out = new ByteArrayOutputStream(); 30 | try { 31 | InputStream mInputStream = response.getEntity().getContent(); 32 | int character; 33 | while ((character = mInputStream.read()) != -1) { 34 | out.write(character); 35 | } 36 | } catch (IOException e) { 37 | e.printStackTrace(); 38 | } catch (Exception e) { 39 | e.printStackTrace(); 40 | } 41 | 42 | String result = ""; 43 | try{ 44 | result = out.toString("UTF-8"); 45 | } catch (UnsupportedEncodingException e) { 46 | e.printStackTrace(); 47 | } 48 | 49 | return result; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/src/de/bdr/eidcc/eIDClientCore Selbstauskunft/NPAReader.java: -------------------------------------------------------------------------------- 1 | package de.bdr.eidcc.eidclientcore_selbstauskunft; 2 | 3 | import java.io.IOException; 4 | 5 | import android.nfc.Tag; 6 | import android.nfc.tech.IsoDep; 7 | import de.bdr.reader.Reader; 8 | 9 | public class NPAReader implements Reader{ 10 | private IsoDep card; 11 | 12 | public NPAReader(Tag tag){ 13 | this.card = IsoDep.get(tag); 14 | card.setTimeout(20000); 15 | try { 16 | card.connect(); 17 | } catch (IOException e) { 18 | e.printStackTrace(); 19 | } 20 | } 21 | 22 | /** 23 | * Sends the command APDU to the ICC and returns the response APDU. 24 | * 25 | * @param cAPDU 26 | * command APDU 27 | * @return response APDU or null in the case of an error 28 | */ 29 | public byte[] processAPDU(byte[] cAPDU){ 30 | try{ 31 | return card.transceive(cAPDU); 32 | } catch (IOException e) { 33 | return null; 34 | } 35 | } 36 | 37 | /** 38 | * Turns the reader on 39 | * 40 | * @return true, or false in the case of an error 41 | */ 42 | public boolean powerOn(){ 43 | return true; 44 | } 45 | 46 | /** 47 | * Turns the reader off 48 | */ 49 | public void powerOff(){ 50 | return; 51 | } 52 | 53 | /** 54 | * Returns the answer-to-reset 55 | * 56 | * @return ATR or null in the case of an error 57 | */ 58 | /* Code taken from remote Smart Card Reader, see 59 | * http://frankmorgner.github.io/vsmartcard/remote-reader/README.html 60 | */ 61 | public byte[] getATR(){ 62 | /* calculation based on https://code.google.com/p/ifdnfc/source/browse/src/atr.c */ 63 | byte[] historicalBytes = card.getHistoricalBytes(); 64 | if (historicalBytes == null) { 65 | historicalBytes = new byte[0]; 66 | } 67 | 68 | /* copy historical bytes if available */ 69 | byte[] atr = new byte[4 + historicalBytes.length + 1]; 70 | atr[0] = (byte) 0x3b; 71 | atr[1] = (byte) (0x80 + historicalBytes.length); 72 | atr[2] = (byte) 0x80; 73 | atr[3] = (byte) 0x01; 74 | System.arraycopy(historicalBytes, 0, atr, 4, historicalBytes.length); 75 | 76 | /* calculate TCK */ 77 | byte tck = atr[1]; 78 | for (int idx = 2; idx < atr.length; idx++) { 79 | tck ^= atr[idx]; 80 | } 81 | atr[atr.length - 1] = tck; 82 | 83 | return atr; 84 | } 85 | 86 | /** 87 | * Indicates whether the reader supports PACE or not. 88 | * 89 | * If the reader supports PACE, the eidClientCore sends the CT-API commands 90 | * to perform PACE. 91 | * 92 | * @return true, if reader supports PACE. 93 | */ 94 | public boolean supportsPACE(){ 95 | return false; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/src/de/bdr/eidcc/eIDClientCore Selbstauskunft/ShowResultsActivity.java: -------------------------------------------------------------------------------- 1 | package de.bdr.eidcc.eidclientcore_selbstauskunft; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.view.Menu; 6 | import android.view.MenuItem; 7 | import android.view.View; 8 | import android.widget.TableLayout; 9 | 10 | public class ShowResultsActivity extends Activity { 11 | 12 | public final static String EXTRA_STRING_ARRAY = "de.bdr.eidcc.eidclientcore_selbstauskunft.EXTRA_STRING_ARRAY"; 13 | 14 | @Override 15 | protected void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | setContentView(R.layout.activity_show_results); 18 | 19 | final String[] resultStrings = getIntent().getStringArrayExtra(EXTRA_STRING_ARRAY); 20 | final Activity mActivity = this; 21 | 22 | runOnUiThread(new Runnable(){ 23 | public void run() { 24 | MainActivity.buildTable((TableLayout) findViewById(R.id.showOutputToUserInShowResultsActivity), 25 | resultStrings, mActivity); 26 | } 27 | }); 28 | } 29 | 30 | public void exit(View view) { 31 | finish(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/src/de/bdr/eidcc/eIDClientCore Selbstauskunft/TcToken.java: -------------------------------------------------------------------------------- 1 | package de.bdr.eidcc.eidclientcore_selbstauskunft; 2 | 3 | import java.io.IOException; 4 | import java.io.StringReader; 5 | 6 | import javax.xml.parsers.ParserConfigurationException; 7 | import javax.xml.parsers.SAXParser; 8 | import javax.xml.parsers.SAXParserFactory; 9 | 10 | import org.xml.sax.Attributes; 11 | import org.xml.sax.InputSource; 12 | import org.xml.sax.SAXException; 13 | import org.xml.sax.helpers.DefaultHandler; 14 | 15 | public class TcToken extends DefaultHandler{ 16 | public String sessionId; 17 | public String serverAddress; 18 | public String pathSecurityParams; 19 | public String refreshURL; 20 | 21 | private String tempVal; 22 | 23 | public TcToken(String toParse) { 24 | parseDocument(toParse); 25 | if(sessionId == null || serverAddress == null 26 | || pathSecurityParams == null || refreshURL == null) 27 | throw new IllegalArgumentException("Could not get everything needed from the given String."); 28 | } 29 | 30 | private void parseDocument(String xml) { 31 | // get a factory 32 | SAXParserFactory spf = SAXParserFactory.newInstance(); 33 | try { 34 | // get a new instance of parser 35 | SAXParser sp = spf.newSAXParser(); 36 | 37 | // parse the string and also register this class for call backs 38 | sp.parse(new InputSource(new StringReader(xml)), this); 39 | } catch (SAXException se) { 40 | se.printStackTrace(); 41 | } catch (ParserConfigurationException pce) { 42 | pce.printStackTrace(); 43 | } catch (IOException ie) { 44 | ie.printStackTrace(); 45 | } 46 | } 47 | 48 | // Event Handlers 49 | public void startElement(String uri, String localName, String qName, 50 | Attributes attributes) throws SAXException { 51 | // reset 52 | tempVal = ""; 53 | } 54 | 55 | public void characters(char[] ch, int start, int length) throws SAXException { 56 | tempVal = tempVal.concat(new String(ch,start,length)); 57 | } 58 | 59 | public void endElement(String uri, String localName, String qName) throws SAXException { 60 | if(qName.equalsIgnoreCase("SessionIdentifier")) { 61 | sessionId = tempVal; 62 | }else if (qName.equalsIgnoreCase("ServerAddress")) { 63 | serverAddress = tempVal; 64 | }else if (qName.equalsIgnoreCase("PSK")) { 65 | pathSecurityParams = tempVal; 66 | }else if (qName.equalsIgnoreCase("RefreshAddress")) { 67 | refreshURL = tempVal; 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/src/de/bdr/eidcc/eIDClientCore Selbstauskunft/eIDCCTestcase.java: -------------------------------------------------------------------------------- 1 | package de.bdr.eidcc.eidclientcore_selbstauskunft; 2 | 3 | public interface eIDCCTestcase { 4 | /** 5 | * Returns a TcToken, if everything went correct. error contains the empty string then. 6 | * Returns null and error message, which will be shown in the app, if something 7 | * went wrong. Append error message to error. 8 | */ 9 | public TcToken getTcToken(StringBuilder error); 10 | 11 | /** 12 | * Returns a result page, if everything went correct. error contains the empty string then. 13 | * Returns null and error message, which will be shown in the app, if something 14 | * went wrong. Append error message to error. 15 | */ 16 | public String getResultPage(StringBuilder error); 17 | 18 | /** 19 | * Gets a webpage as input and provides a string to show to the user in the UI. 20 | */ 21 | public String[] parseResult(String result); 22 | } 23 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientCore Selbstauskunft/src/de/bdr/eidcc/eIDClientCore Selbstauskunft/eIDCCTestcaseAusweisApp2.java: -------------------------------------------------------------------------------- 1 | package de.bdr.eidcc.eidclientcore_selbstauskunft; 2 | 3 | import java.util.ArrayList; 4 | 5 | import android.text.Html; 6 | 7 | public class eIDCCTestcaseAusweisApp2 implements eIDCCTestcase{ 8 | CookieContext mCookieContext; 9 | String refreshURL; 10 | 11 | public eIDCCTestcaseAusweisApp2(){ 12 | mCookieContext = new CookieContext( 13 | "https://www.autentapp.de/AusweisAuskunft/WebServiceRequesterServlet?mode=autentappde"); 14 | } 15 | 16 | public TcToken getTcToken(StringBuilder error){ 17 | GetWebPage mGetWebPage = new GetWebPage(mCookieContext); 18 | TcToken mTcToken = null; 19 | 20 | try { 21 | mTcToken = new TcToken(mGetWebPage.execute().get()); 22 | } catch (Exception e) { 23 | e.printStackTrace(); 24 | error.append("Konnte keinen TcToken erhalten. Bitte stellen Sie sicher, dass eine Internetverbindung besteht."); 25 | return null; 26 | } 27 | 28 | refreshURL = mTcToken.refreshURL; 29 | 30 | error = null; 31 | return mTcToken; 32 | } 33 | 34 | public String getResultPage(StringBuilder error){ 35 | mCookieContext.setUrl(refreshURL); 36 | GetWebPage mGetWebPage = new GetWebPage(mCookieContext); 37 | String result = ""; 38 | try { 39 | result = mGetWebPage.execute().get(); 40 | } catch (Exception e) { 41 | e.printStackTrace(); 42 | error.append("Konnte die Ergebnisseite nicht erhalten."); 43 | return null; 44 | } 45 | 46 | error = null; 47 | return result; 48 | } 49 | 50 | public String[] parseResult(String result){ 51 | String beginOfValueSearchString = ""; 52 | String endOfValueSearchString = ""; 53 | String [] searchStrings = {"Titel:", "Künstlername:", 54 | "Vorname:", "Nachname:", 55 | "Geburtsname:", "Wohnort:", 56 | "Geburtsort:", "Geburtsdatum:", 57 | "Dokumententyp:", "Ausstellender Staat:", 58 | "Staatsangehörigkeit:", "Aufenthaltserlaubnis I:", 59 | }; 60 | 61 | int copyStart; 62 | int copyEnd; 63 | ArrayList stringList = new ArrayList(); 64 | for(int i = 0; i < searchStrings.length; i++){ 65 | copyStart = result.indexOf(searchStrings[i], 0); 66 | copyStart = result.indexOf(beginOfValueSearchString, copyStart + beginOfValueSearchString.length()); 67 | copyStart += beginOfValueSearchString.length(); 68 | copyEnd = result.indexOf(endOfValueSearchString, copyStart); 69 | stringList.add(Html.fromHtml( 70 | searchStrings[i].replace("", "").replace("", "")).toString()); 71 | stringList.add(Html.fromHtml(result.substring(copyStart, copyEnd).toString()).toString()); 72 | } 73 | 74 | return stringList.toArray(new String[stringList.size()]); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientLib/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientLib/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | eIDClientLib 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientLib/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 4 | 8 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientLib/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 29 | 30 | 31 | 35 | 36 | 37 | 38 | 39 | 40 | 49 | 50 | 51 | 52 | 56 | 57 | 69 | 70 | 71 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientLib/jni/Android.mk: -------------------------------------------------------------------------------- 1 | ## 2 | # Copyright (C) 2013 Bundesdruckerei GmbH 3 | ## 4 | LOCAL_PATH := $(call my-dir) 5 | ##LIB_PATH relative to LOCAL_PATH 6 | LIB_PATH := ../../eIDClientCore-0.2_arm/lib 7 | LIBEID_PATH := $(LOCAL_PATH)/../../../lib 8 | 9 | ######################################################### 10 | ### START DEPENDENCIES 11 | ######################################################### 12 | #Crypto 13 | include $(CLEAR_VARS) 14 | 15 | LOCAL_MODULE := crypto-static 16 | LOCAL_SRC_FILES := $(LIB_PATH)/libcrypto.a 17 | 18 | include $(PREBUILT_STATIC_LIBRARY) 19 | ############################################################# 20 | #SSL 21 | include $(CLEAR_VARS) 22 | 23 | LOCAL_MODULE := ssl-static 24 | LOCAL_SRC_FILES := $(LIB_PATH)/libssl.a 25 | LOCAL_STATIC_LIBRARIES := crypto-static 26 | 27 | include $(PREBUILT_STATIC_LIBRARY) 28 | ############################################################# 29 | #Curl 30 | include $(CLEAR_VARS) 31 | 32 | LOCAL_MODULE := curl-static 33 | LOCAL_SRC_FILES := $(LIB_PATH)/libcurl.a 34 | LOCAL_STATIC_LIBRARIES := ssl-static 35 | LOCAL_LDLIBS := -lz 36 | 37 | include $(PREBUILT_STATIC_LIBRARY) 38 | ############################################################# 39 | #Expat 40 | include $(CLEAR_VARS) 41 | 42 | LOCAL_MODULE := expat-static 43 | LOCAL_SRC_FILES := $(LIB_PATH)/libexpat.a 44 | 45 | include $(PREBUILT_STATIC_LIBRARY) 46 | 47 | ############################################################# 48 | # eIDClientConnection 49 | include $(CLEAR_VARS) 50 | 51 | LOCAL_MODULE := eIDClientConnection-static 52 | LOCAL_SRC_FILES := $(LIB_PATH)/libeIDClientConnection.a 53 | 54 | LOCAL_STATIC_LIBRARIES := curl-static 55 | 56 | include $(PREBUILT_STATIC_LIBRARY) 57 | ############################################################# 58 | #CryptoPP 59 | include $(CLEAR_VARS) 60 | 61 | LOCAL_MODULE := cryptopp-static 62 | LOCAL_SRC_FILES := $(LIB_PATH)/libcryptopp.a 63 | 64 | include $(PREBUILT_STATIC_LIBRARY) 65 | ######################################################## 66 | # eIDClientCore 67 | include $(CLEAR_VARS) 68 | 69 | LOCAL_MODULE := eIDClientCore-static 70 | LOCAL_SRC_FILES := $(LIB_PATH)/libeIDClientCore.a 71 | LOCAL_STATIC_LIBRARIES := cryptopp-static expat-static eIDClientConnection-static 72 | 73 | include $(PREBUILT_STATIC_LIBRARY) 74 | ######################################################### 75 | ### END DEPENDENCIES 76 | ######################################################### 77 | 78 | 79 | include $(CLEAR_VARS) 80 | 81 | LOCAL_MODULE := eidclient-wrapper 82 | LOCAL_SRC_FILES := de_bdr_eidclient_EIdSession.cpp 83 | LOCAL_C_INCLUDES := $(LIBEID_PATH) 84 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../reader/jni 85 | LOCAL_LDLIBS := -lz -llog 86 | LOCAL_STATIC_LIBRARIES := eIDClientCore-static 87 | 88 | include $(BUILD_SHARED_LIBRARY) 89 | 90 | ######################################################## 91 | # external Reader 92 | READER_SHARED_LIBRARIES:= eidclient-wrapper 93 | include $(LOCAL_PATH)/../../reader/jni/Android.mk 94 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientLib/jni/Application.mk: -------------------------------------------------------------------------------- 1 | ## 2 | # Copyright (C) 2013 Bundesdruckerei GmbH 3 | ## 4 | APP_OPTIM := release 5 | NDK_TOOLCHAIN_VERSION := 4.8 6 | APP_ABI := armeabi 7 | APP_CPPFLAGS += -fexceptions -frtti 8 | APP_STL := stlport_shared 9 | APP_MODULES :=stlport_shared eidclient-wrapper externalReader -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientLib/jni/de_bdr_eidclient_EIdSession.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | /* Header for class de_bdr_eidclient_EIdSession */ 4 | 5 | #ifndef _Included_de_bdr_eidclient_EIdSession 6 | #define _Included_de_bdr_eidclient_EIdSession 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: de_bdr_eidclient_EIdSession 12 | * Method: nativePipeSTDOUTToLogcat 13 | * Signature: ()V 14 | */ 15 | JNIEXPORT void JNICALL Java_de_bdr_eidclient_EIdSession_pipeStdOut 16 | (JNIEnv *, jobject); 17 | 18 | /* 19 | * Class: de_bdr_eidclient_EIdSession 20 | * Method: performEAC 21 | * Signature: (Lde/bdr/eidclient/reader/Reader;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)J 22 | */ 23 | JNIEXPORT jlong JNICALL Java_de_bdr_eidclient_EIdSession_performEAC 24 | (JNIEnv *, jobject, jobject, jstring, jstring, jstring); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | #endif 30 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientLib/jni/de_bdr_eidclient_external_reader.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BeID-lab/eIDClientCore/c734211d03b5118629880ce8850f14c9bc31fa3b/eIDClientCore/android/eIDClientLib/jni/de_bdr_eidclient_external_reader.h -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientLib/jni/deps.mk: -------------------------------------------------------------------------------- 1 | ## 2 | # Copyright (C) 2013 Bundesdruckerei GmbH 3 | ## 4 | 5 | ############################################################# 6 | #Crypto 7 | include $(CLEAR_VARS) 8 | 9 | LOCAL_MODULE := crypto-static 10 | LOCAL_SRC_FILES := $(LIB_PATH)/libcrypto.a 11 | 12 | include $(PREBUILT_STATIC_LIBRARY) 13 | ############################################################# 14 | #SSL 15 | include $(CLEAR_VARS) 16 | 17 | LOCAL_MODULE := ssl-static 18 | LOCAL_SRC_FILES := $(LIB_PATH)/libssl.a 19 | LOCAL_STATIC_LIBRARIES += crypto-static 20 | 21 | include $(PREBUILT_STATIC_LIBRARY) 22 | ############################################################# 23 | #Curl 24 | include $(CLEAR_VARS) 25 | 26 | LOCAL_MODULE := curl-static 27 | LOCAL_SRC_FILES := $(LIB_PATH)/libcurl.a 28 | LOCAL_STATIC_LIBRARIES += ssl-static 29 | LOCAL_LDLIBS += -lz 30 | 31 | include $(PREBUILT_STATIC_LIBRARY) 32 | ############################################################# 33 | #Expat 34 | include $(CLEAR_VARS) 35 | 36 | LOCAL_MODULE := expat-static 37 | LOCAL_SRC_FILES := $(LIB_PATH)/libexpat.a 38 | 39 | include $(PREBUILT_STATIC_LIBRARY) 40 | 41 | ############################################################# 42 | # eIDClientConnection 43 | include $(CLEAR_VARS) 44 | 45 | LOCAL_MODULE := eIDClientConnection-static 46 | LOCAL_SRC_FILES := $(LIB_PATH)/libeIDClientConnection.a 47 | 48 | LOCAL_STATIC_LIBRARIES += curl-static 49 | 50 | include $(PREBUILT_STATIC_LIBRARY) 51 | ############################################################# 52 | #CryptoPP 53 | include $(CLEAR_VARS) 54 | 55 | LOCAL_MODULE := cryptopp-static 56 | LOCAL_SRC_FILES := $(LIB_PATH)/libcryptopp.a 57 | 58 | include $(PREBUILT_STATIC_LIBRARY) 59 | ######################################################## 60 | # eIDClientCore 61 | include $(CLEAR_VARS) 62 | 63 | LOCAL_MODULE := eIDClientCore-static 64 | LOCAL_SRC_FILES := $(LIB_PATH)/libeIDClientCore.a 65 | LOCAL_STATIC_LIBRARIES += cryptopp-static expat-static eIDClientConnection-static 66 | 67 | include $(PREBUILT_STATIC_LIBRARY) 68 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientLib/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-19 15 | android.library=true 16 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientLib/src/de/bdr/eidclient/EIdSession.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Bundesdruckerei GmbH 3 | */ 4 | 5 | package de.bdr.eidclient; 6 | 7 | import de.bdr.reader.Reader; 8 | 9 | final class EIdSession { 10 | 11 | private Reader mReader; 12 | 13 | private EacCallback mCallback; 14 | 15 | private String mEACServerAddress; 16 | private String mEACSessionID; 17 | private String mEACPathSecurityParams; 18 | private String mEIDRefreshURL; 19 | 20 | // load native libraries 21 | static { 22 | System.loadLibrary("stlport_shared"); 23 | System.loadLibrary("eidclient-wrapper"); 24 | System.loadLibrary("externalReader"); 25 | } 26 | 27 | // pipe eid client core native stdout to android log 28 | public native void pipeStdOut(); 29 | 30 | private native long performEAC(Reader reader, String url, String sessionid, 31 | String pathsecurityparams); 32 | 33 | EIdSession(Reader reader, EacCallback callback, String serverAddress, 34 | String refreshURL, String sessionID, String pathSecurityParams) { 35 | 36 | // check mandatory parameters 37 | if (reader == null || serverAddress == null || sessionID == null 38 | || pathSecurityParams == null) 39 | throw new NullPointerException(); 40 | 41 | mReader = reader; 42 | mCallback = callback; 43 | mEACSessionID = sessionID; 44 | mEACServerAddress = serverAddress; 45 | mEACPathSecurityParams = pathSecurityParams; 46 | mEIDRefreshURL = refreshURL; 47 | } 48 | 49 | long perform() { 50 | 51 | // activate native logging if Logging.doLog is true 52 | if (Logging.doLog) { 53 | new Thread(new Runnable() { 54 | 55 | @Override 56 | public void run() { 57 | pipeStdOut(); 58 | } 59 | }).start(); 60 | } 61 | 62 | return performEAC(mReader, mEACServerAddress, mEACSessionID, 63 | mEACPathSecurityParams); 64 | } 65 | 66 | private void updateStatus(final int status, final int error) { 67 | Logging.d("EIDSession", status + ", " + error); 68 | 69 | if (mCallback != null) 70 | mCallback.onStatusChange(status, error); 71 | } 72 | 73 | private boolean userInteractionCallback(SPDescription spDescription, 74 | UserInput userInput) { 75 | Logging.d("EIDSession CALL", spDescription.toString()); 76 | 77 | if (mCallback != null) 78 | return mCallback.userInteractionCallback(spDescription, userInput); 79 | 80 | return true; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientLib/src/de/bdr/eidclient/EIdStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Bundesdruckerei GmbH 3 | */ 4 | 5 | package de.bdr.eidclient; 6 | 7 | /** 8 | * This class defines status and error codes. To see all error codes please take 9 | * a look at the corresponding C header files. 10 | */ 11 | public class EIdStatus { 12 | 13 | private EIdStatus() { 14 | }; 15 | 16 | /** 17 | * initialization state 18 | */ 19 | public final static long STATE_INITIALIZE = 1; 20 | /** 21 | * got PACE information 22 | */ 23 | public final static long STATE_GOT_PACE_INFO = 2; 24 | /** 25 | * PACE performed 26 | */ 27 | public final static long STATE_PACE_PERFORMED = 3; 28 | /** 29 | * Terminal Authentication (TA) performed. 30 | */ 31 | public final static long STATE_TA_PERFORMED = 4; 32 | /** 33 | * Chip Authentication (CA) performed. 34 | */ 35 | public final static long STATE_CA_PERFORMED = 5; 36 | /** 37 | * Attributes read. 38 | */ 39 | public final static long STATE_READ_ATTRIBUTES = 6; 40 | 41 | /** 42 | * success 43 | */ 44 | public final static long ERROR_SUCCESS = 0; 45 | } 46 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientLib/src/de/bdr/eidclient/EacCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Bundesdruckerei GmbH 3 | */ 4 | 5 | package de.bdr.eidclient; 6 | 7 | /** 8 | * EAC Callback Interface which must be implemented by the application. 9 | */ 10 | public interface EacCallback { 11 | 12 | /** 13 | * This callback is called on protocol status changes. The protocol states 14 | * and error codes are defined in {@link EIdStatus}. 15 | * 16 | * @param status 17 | * protocol status (see {@link EIdStatus}) 18 | * @param error 19 | * error code (see {@link EIdStatus}) 20 | */ 21 | public void onStatusChange(long status, long error); 22 | 23 | /** 24 | * This method is called in the PACE protocol step. The parameters contain 25 | * the description of the service provider, CHAT and the PIN. If a PIN is 26 | * required, the application must set the PIN field in the userInput. The 27 | * selected chat of userInput is initialized with the service provider's 28 | * required chat. 29 | * 30 | * @param spDescription 31 | * description of the service provider and CHAT. 32 | * @param userInput 33 | * description about the PIN. PIN field must be set if required 34 | * @return false if user aborts, else true 35 | */ 36 | public boolean userInteractionCallback(SPDescription spDescription, 37 | UserInput userInput); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientLib/src/de/bdr/eidclient/EidClient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Bundesdruckerei GmbH 3 | */ 4 | 5 | package de.bdr.eidclient; 6 | 7 | import de.bdr.reader.Reader; 8 | 9 | /** 10 | * EID Client 11 | */ 12 | public class EidClient { 13 | 14 | /** 15 | * Perform EAC 16 | * 17 | * Call this method NOT in the UI-Thread 18 | * 19 | * NOTE: This method is not thread-safe (no concurrent executions allowed) 20 | * 21 | * @param reader 22 | * reader instance 23 | * @param callback 24 | * eac callback 25 | * @param sessionId 26 | * session id 27 | * @param serverAddress 28 | * eid server address 29 | * @param pathSecurityParams 30 | * path security parameters 31 | * @param refreshURL 32 | * refresh URL 33 | * @return status eidclient status 34 | */ 35 | public static long performEAC(final Reader reader, EacCallback callback, 36 | String sessionId, String serverAddress, String pathSecurityParams, 37 | String refreshURL) { 38 | 39 | EIdSession session = new EIdSession(reader, callback, serverAddress, 40 | refreshURL, sessionId, pathSecurityParams); 41 | long res = session.perform(); 42 | 43 | return res; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientLib/src/de/bdr/eidclient/Logging.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Bundesdruckerei GmbH 3 | */ 4 | 5 | package de.bdr.eidclient; 6 | 7 | import android.util.Log; 8 | 9 | /** 10 | * Simple logging class. 11 | */ 12 | public class Logging { 13 | 14 | /** 15 | * Error logging level 16 | */ 17 | public static final byte ERR = 0; 18 | /** 19 | * Debug logging level 20 | */ 21 | public static final byte DEB = 1; 22 | /** 23 | * Info logging level 24 | */ 25 | public static final byte INFO = 2; 26 | 27 | /** 28 | * turn logging on/off 29 | */ 30 | public static boolean doLog = true; 31 | /** 32 | * max logging level 33 | */ 34 | public static byte logLevel = 2; 35 | 36 | private Logging() { 37 | // only static 38 | } 39 | 40 | /** 41 | * log a error message. 42 | * 43 | * @param tag 44 | * tag 45 | * @param msg 46 | * log message 47 | * @param e 48 | * exception 49 | */ 50 | public static void e(String tag, String msg, Exception e) { 51 | log(ERR, tag, msg, e); 52 | } 53 | 54 | /** 55 | * log a debug message 56 | * 57 | * @param tag 58 | * tag 59 | * @param msg 60 | * log message 61 | */ 62 | public static void d(String tag, String msg) { 63 | log(DEB, tag, msg, null); 64 | } 65 | 66 | /** 67 | * log a info message 68 | * 69 | * @param tag 70 | * tag 71 | * @param msg 72 | * log message 73 | */ 74 | public static void i(String tag, String msg) { 75 | log(INFO, tag, msg, null); 76 | } 77 | 78 | private static void log(final byte level, String tag, String msg, 79 | Exception e) { 80 | if (!doLog) 81 | return; 82 | 83 | switch (level) { 84 | case ERR: 85 | if (logLevel >= ERR) 86 | Log.e(tag, msg); 87 | break; 88 | case DEB: 89 | if (logLevel >= DEB) 90 | Log.d(tag, msg); 91 | break; 92 | case INFO: 93 | if (logLevel >= INFO) 94 | Log.d(tag, msg); 95 | break; 96 | } 97 | 98 | if (e != null) 99 | e.printStackTrace(); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientLib/src/de/bdr/eidclient/Reader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Bundesdruckerei GmbH 3 | */ 4 | 5 | package de.bdr.eidclient; 6 | 7 | /** 8 | * Reader interface 9 | */ 10 | public interface Reader { 11 | 12 | /** 13 | * Sends the command APDU to the ICC and returns the response APDU. 14 | * 15 | * @param cAPDU 16 | * command APDU 17 | * @return response APDU or null in the case of an error 18 | */ 19 | public byte[] processAPDU(byte[] cAPDU); 20 | 21 | /** 22 | * Turns the reader on 23 | * 24 | * @return true, or false in the case of an error 25 | */ 26 | public boolean powerOn(); 27 | 28 | /** 29 | * Turns the reader off 30 | */ 31 | public void powerOff(); 32 | 33 | /** 34 | * Returns the answer-to-reset 35 | * 36 | * @return ATR or null in the case of an error 37 | */ 38 | public byte[] getATR(); 39 | 40 | /** 41 | * Indicates whether the reader supports PACE or not. 42 | * 43 | * If the reader supports PACE, the eidClientCore sends the CT-API commands 44 | * to perform PACE. 45 | * 46 | * @return true, if reader supports PACE. 47 | */ 48 | public boolean supportsPACE(); 49 | } 50 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientLib/src/de/bdr/eidclient/SPDescription.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Bundesdruckerei GmbH 3 | */ 4 | 5 | package de.bdr.eidclient; 6 | 7 | import java.util.Date; 8 | 9 | /** 10 | * Service Provider Description 11 | */ 12 | public class SPDescription { 13 | /** 14 | * undefined description type 15 | */ 16 | public static final byte DESCRIPTION_TYPE_UNDEF = 0; 17 | /** 18 | * plain description type 19 | */ 20 | public static final byte DESCRIPTION_TYPE_PLAIN = 1; 21 | /** 22 | * HTML description type 23 | */ 24 | public static final byte DESCRIPTION_TYPE_HTML = 2; 25 | /** 26 | * PDF description type 27 | */ 28 | public static final byte DESCRIPTION_TYPE_PDF = 3; 29 | 30 | /** 31 | * encoding type of the description 32 | */ 33 | public final byte descriptionType; 34 | /** 35 | * Name of the service provider 36 | */ 37 | public final String name; 38 | /** 39 | * Description of the service provider 40 | */ 41 | public final String description; 42 | /** 43 | * URL of the service provider 44 | */ 45 | public final String url; 46 | /** 47 | * SP's Certificate begin of validation 48 | */ 49 | public final long validFrom; 50 | /** 51 | * SP's Certificate end of validation 52 | */ 53 | public final long validTo; 54 | /** 55 | * required Chat 56 | */ 57 | public final Chat chatRequired; 58 | /** 59 | * optional Chat 60 | */ 61 | public final Chat chatOptional; 62 | 63 | SPDescription(byte descriptionType, String name, String description, 64 | String url, long valid_from, long valid_to, Chat chatRequired, 65 | Chat chatOptional) { 66 | this.descriptionType = descriptionType; 67 | this.name = name; 68 | this.description = description; 69 | this.url = url; 70 | this.validFrom = valid_from; 71 | this.validTo = valid_to; 72 | this.chatRequired = chatRequired; 73 | this.chatOptional = chatOptional; 74 | } 75 | 76 | @Override 77 | public String toString() { 78 | return "SPDescription [descriptionType=" + descriptionType + ", name=" 79 | + name + ", description=" + description + ", url=" + url 80 | + ", validFrom=" + new Date(validFrom * 1000).toString() 81 | + ", validTo=" + new Date(validTo * 1000).toString() 82 | + ", chatRequired=" + chatRequired + ", chatOptional=" 83 | + chatOptional + "]"; 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientLib/src/de/bdr/eidclient/UserInput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Bundesdruckerei GmbH 3 | */ 4 | 5 | package de.bdr.eidclient; 6 | 7 | /** 8 | * User Input class includes the PIN and selected CHAT. 9 | */ 10 | public class UserInput { 11 | 12 | /** 13 | * undefined PIN_ID 14 | */ 15 | public final static byte PIN_ID_UNDEF = 0; 16 | /** 17 | * Machine Readable Zone (MRZ) PIN_ID 18 | */ 19 | public final static byte PIN_ID_MRZ = 1; 20 | /** 21 | * Card Access Number (CAN) PIN_ID; 22 | */ 23 | public final static byte PIN_ID_CAN = 2; 24 | /** 25 | * PIN 26 | */ 27 | public final static byte PIN_ID_PIN = 3; 28 | /** 29 | * PUK 30 | */ 31 | public final static byte PIN_ID_PUK = 4; 32 | 33 | /** 34 | * indicates whether a pin is required or not. 35 | */ 36 | public final boolean pinRequired; 37 | /** 38 | * pinID 39 | */ 40 | public final byte pinID; 41 | /** 42 | * user-selected CHAT 43 | */ 44 | public Chat chatSelected; 45 | /** 46 | * user-entered pin 47 | */ 48 | public String pin; 49 | 50 | UserInput(boolean pinRequired, byte pinID, Chat chatSelected, String pin) { 51 | this.pinRequired = pinRequired; 52 | this.pinID = pinID; 53 | this.chatSelected = chatSelected; 54 | this.pin = pin; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /eIDClientCore/android/eIDClientLib/src/de/bdr/reader: -------------------------------------------------------------------------------- 1 | ../../../../reader/java/reader -------------------------------------------------------------------------------- /eIDClientCore/android/reader/java/reader/Reader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Bundesdruckerei GmbH 3 | */ 4 | 5 | package de.bdr.reader; 6 | 7 | /** 8 | * Reader interface 9 | */ 10 | public interface Reader { 11 | 12 | /** 13 | * Sends the command APDU to the ICC and returns the response APDU. 14 | * 15 | * @param cAPDU 16 | * command APDU 17 | * @return response APDU or null in the case of an error 18 | */ 19 | public byte[] processAPDU(byte[] cAPDU); 20 | 21 | /** 22 | * Turns the reader on 23 | * 24 | * @return true, or false in the case of an error 25 | */ 26 | public boolean powerOn(); 27 | 28 | /** 29 | * Turns the reader off 30 | */ 31 | public void powerOff(); 32 | 33 | /** 34 | * Returns the answer-to-reset 35 | * 36 | * @return ATR or null in the case of an error 37 | */ 38 | public byte[] getATR(); 39 | } 40 | -------------------------------------------------------------------------------- /eIDClientCore/android/reader/java/readerimpl/CyberJackReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Bundesdruckerei GmbH 3 | */ 4 | 5 | package de.bdr.readerimpl; 6 | 7 | import com.reinersct.cyberjack.Data; 8 | import com.reinersct.cyberjack.SmartCardReader; 9 | 10 | import de.bdr.eidclient.Logging; 11 | import de.bdr.reader.Reader; 12 | 13 | public class CyberJackReader implements Reader { 14 | 15 | private static final String TAG = CyberJackReader.class.getSimpleName(); 16 | 17 | private SmartCardReader reader; 18 | 19 | public CyberJackReader(SmartCardReader reader) { 20 | this.reader = reader; 21 | } 22 | 23 | @Override 24 | public byte[] processAPDU(byte[] cAPDU) { 25 | Logging.d( 26 | TAG, 27 | "Process APDU (length: " + cAPDU.length + "):" 28 | + Util.bytesToHex(cAPDU)); 29 | 30 | Data cmd = new Data(Data.DAD_CARD, cAPDU); 31 | 32 | Data rsp = null; 33 | try { 34 | rsp = reader.transmit(cmd); 35 | } catch (Exception e) { 36 | Logging.e(TAG, "reader transmit failed", e); 37 | } 38 | if (rsp == null) 39 | return null; 40 | Logging.d(TAG, "Response APDU:" + Util.bytesToHex(rsp.getMessage())); 41 | 42 | return rsp.getMessage(); 43 | } 44 | 45 | @Override 46 | public boolean powerOn() { 47 | Logging.d(TAG, "Power On"); 48 | 49 | try { 50 | return reader.connect(); 51 | } catch (Exception e) { 52 | Logging.e(TAG, "Unable to connect to reader (in power on)", e); 53 | return false; 54 | } 55 | } 56 | 57 | @Override 58 | public void powerOff() { 59 | Logging.d(TAG, "Power Off"); 60 | try { 61 | reader.disconnect(); 62 | } catch (Exception e) { 63 | Logging.e(TAG, "Failure power off: " + e.getMessage(), e); 64 | } 65 | } 66 | 67 | @Override 68 | public byte[] getATR() { 69 | Logging.d(TAG, "Reader get ATR"); 70 | 71 | try { 72 | String atrS = reader.cardReset(); 73 | Logging.d(TAG, "ATR: " + atrS); 74 | return Util.hexToBytes(atrS); 75 | } catch (Exception e) { 76 | Logging.e(TAG, "FAILURE ATR: " + e.getMessage(), e); 77 | return null; 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /eIDClientCore/android/reader/java/readerimpl/NFCReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Bundesdruckerei GmbH 3 | */ 4 | 5 | package de.bdr.readerimpl; 6 | 7 | import java.io.IOException; 8 | import java.util.Arrays; 9 | import java.util.List; 10 | 11 | import android.nfc.Tag; 12 | import android.nfc.tech.IsoDep; 13 | import de.bdr.eidclient.Logging; 14 | import de.bdr.reader.Reader; 15 | 16 | public class NFCReader implements Reader { 17 | private static final String TAG = NFCReader.class.getSimpleName(); 18 | public static final String NFC_A_STRING = "android.nfc.tech.NfcA"; 19 | public static final String NFC_B_STRING = "android.nfc.tech.NfcB"; 20 | public static final byte NFC_A = 1; 21 | public static final byte NFC_B = 2; 22 | 23 | private IsoDep icc; 24 | private byte tech = 0; 25 | 26 | public NFCReader(IsoDep icc) { 27 | this.icc = icc; 28 | 29 | Tag tag = icc.getTag(); 30 | 31 | if (tag != null) { 32 | List techList = Arrays.asList(tag.getTechList()); 33 | if (techList.contains(NFC_A_STRING)) { 34 | tech = NFC_A; 35 | } else if (techList.contains(NFC_B_STRING)) { 36 | tech = NFC_B; 37 | } 38 | } 39 | 40 | Logging.d( 41 | TAG, 42 | "NFC Reader constructed - supported length: " 43 | + icc.getMaxTransceiveLength()); 44 | } 45 | 46 | @Override 47 | public byte[] processAPDU(byte[] cAPDU) { 48 | Logging.d( 49 | TAG, 50 | "Process APDU (length: " + cAPDU.length + "):" 51 | + Util.bytesToHex(cAPDU)); 52 | 53 | if (cAPDU[0] == 0x01 && cAPDU[1] == (byte) 0xef) { 54 | byte[] res = new byte[] { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 55 | (byte) 0x90, 0x00 }; 56 | Logging.d(TAG, "Response APDU: " + Util.bytesToHex(res)); 57 | return res; 58 | } 59 | try { 60 | byte[] res = icc.transceive(cAPDU); 61 | Logging.d(TAG, "Response APDU: " + Util.bytesToHex(res)); 62 | return res; 63 | } catch (IOException e) { 64 | Logging.e(TAG, "Process APDU failed: " + e.getMessage(), e); 65 | return new byte[] { (byte) 0x6F, 0x00 }; 66 | } 67 | } 68 | 69 | @Override 70 | public boolean powerOn() { 71 | Logging.d(TAG, "Power On"); 72 | 73 | try { 74 | icc.connect(); 75 | icc.setTimeout(10500); 76 | } catch (IOException e) { 77 | Logging.e(TAG, "unable to connect NFC", e); 78 | return false; 79 | } 80 | return true; 81 | } 82 | 83 | @Override 84 | public void powerOff() { 85 | Logging.d(TAG, "Power Off"); 86 | } 87 | 88 | @Override 89 | public byte[] getATR() { 90 | Logging.d(TAG, "Reader get ATR"); 91 | byte[] atr; 92 | if (NFC_A == tech) { 93 | atr = icc.getHistoricalBytes(); 94 | } else if (NFC_B == tech) { 95 | atr = icc.getHiLayerResponse(); 96 | } else { 97 | atr = new byte[] { 0 }; 98 | } 99 | Logging.d(TAG, "ATR: " + Util.bytesToHex(atr)); 100 | return atr; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /eIDClientCore/android/reader/java/readerimpl/NFCWatchDog.java: -------------------------------------------------------------------------------- 1 | package de.bdr.readerimpl; 2 | 3 | import android.app.ActivityManager; 4 | import android.app.ActivityManager.RunningAppProcessInfo; 5 | import android.content.Context; 6 | import android.os.AsyncTask; 7 | import android.os.Debug.MemoryInfo; 8 | import de.bdr.eidclient.Logging; 9 | 10 | public final class NFCWatchDog { 11 | 12 | private static final String NFC_PROCESS = "com.android.nfc"; 13 | 14 | private static final String TAG = NFCWatchDog.class.getSimpleName(); 15 | 16 | public static final int DEFAULT_INTERVALL = 5000; 17 | 18 | private static WatchDogTask watchDogTask = null; 19 | 20 | public static void startWatchDog(Context context, Listener listener, 21 | int intervall) { 22 | stopWatchDog(); 23 | 24 | if (intervall <= 0) { 25 | throw new IllegalArgumentException("intervall must be positive"); 26 | } 27 | 28 | watchDogTask = new WatchDogTask(context, intervall); 29 | watchDogTask 30 | .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, listener); 31 | } 32 | 33 | public static void stopWatchDog() { 34 | if (watchDogTask != null) { 35 | watchDogTask.stopRequest = true; 36 | } 37 | } 38 | 39 | private NFCWatchDog() { 40 | 41 | } 42 | 43 | private static class WatchDogTask extends 44 | AsyncTask { 45 | 46 | private int[] pid = new int[] { 0 }; 47 | private ActivityManager manager; 48 | private final Context context; 49 | private final int intervall; 50 | volatile boolean stopRequest; 51 | 52 | public WatchDogTask(Context context, int intervall) { 53 | this.context = context; 54 | this.intervall = intervall; 55 | } 56 | 57 | @Override 58 | protected Boolean doInBackground(Listener... listener) { 59 | Logging.d(TAG, "started"); 60 | if (!setPid()) { 61 | Logging.d(TAG, "no nfc service process found"); 62 | return false; 63 | } 64 | while (!stopRequest) { 65 | if (processIsAlive()) { 66 | Logging.d(TAG, "nfc service still alive"); 67 | 68 | } else { 69 | Logging.d(TAG, "nfc service dead"); 70 | if (listener.length > 0 & listener[0] != null) { 71 | listener[0].onNFCServiceDied(); 72 | } 73 | } 74 | try { 75 | Thread.sleep(intervall); 76 | } catch (InterruptedException e) { 77 | Logging.e(TAG, "Thread interrupted", e); 78 | } 79 | } 80 | return true; 81 | } 82 | 83 | @Override 84 | protected void onPostExecute(Boolean result) { 85 | Logging.d(TAG, "Thread terminated with result: " + result); 86 | } 87 | 88 | private boolean processIsAlive() { 89 | MemoryInfo[] memInfo = manager.getProcessMemoryInfo(pid); 90 | if (memInfo[0].getTotalSharedDirty() == 0) { 91 | return false; 92 | } 93 | return true; 94 | } 95 | 96 | boolean setPid() { 97 | manager = (ActivityManager) context 98 | .getSystemService(Context.ACTIVITY_SERVICE); 99 | for (RunningAppProcessInfo process : manager 100 | .getRunningAppProcesses()) { 101 | if (NFC_PROCESS.equals(process.processName)) { 102 | pid[0] = process.pid; 103 | return true; 104 | } 105 | } 106 | return false; 107 | } 108 | 109 | } 110 | 111 | public interface Listener { 112 | 113 | public void onNFCServiceDied(); 114 | 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /eIDClientCore/android/reader/java/readerimpl/Util.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Bundesdruckerei GmbH 3 | */ 4 | 5 | package de.bdr.readerimpl; 6 | 7 | import java.math.BigInteger; 8 | 9 | /** 10 | * Util class 11 | */ 12 | public class Util { 13 | 14 | private Util() { 15 | // only static 16 | } 17 | 18 | /** 19 | * Converts a byte buffer to a hex-string 20 | * 21 | * @param b 22 | * byte buffer 23 | * @return hex string 24 | */ 25 | public static String bytesToHex(byte[] b) { 26 | String r = ""; 27 | for (int i = 0; i < b.length; i++) { 28 | r += Integer.toString((b[i] & 0xff) + 0x100, 16).substring(1); 29 | } 30 | return r; 31 | } 32 | 33 | /** 34 | * Converts a hex-string to a byte buffer. 35 | * 36 | * @param hex 37 | * hex-string 38 | * @return byte buffer 39 | */ 40 | public static byte[] hexToBytes(String hex) { 41 | return new BigInteger(hex.replace(" ", ""), 16).toByteArray(); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /eIDClientCore/android/reader/jni/Android.mk: -------------------------------------------------------------------------------- 1 | ## 2 | # Copyright (C) 2013 Bundesdruckerei GmbH 3 | ## 4 | 5 | #YOU HAVE TO SET READER_SHARED_LIBRARIES 6 | # i.e SET READER_SHARED_LIBRARIES:= eidclient-wrapper 7 | # 8 | ######################################################## 9 | LOCAL_PATH := $(call my-dir) 10 | include $(CLEAR_VARS) 11 | 12 | LIBEID_PATH := $(LOCAL_PATH)/../../../lib 13 | 14 | LOCAL_MODULE := externalReader 15 | LOCAL_SRC_FILES := de_bdr_eidclient_external_reader.cpp 16 | LOCAL_C_INCLUDES := $(LIBEID_PATH) 17 | LOCAL_LDLIBS := -llog 18 | LOCAL_SHARED_LIBRARIES := $(READER_SHARED_LIBRARIES) 19 | 20 | include $(BUILD_SHARED_LIBRARY) 21 | -------------------------------------------------------------------------------- /eIDClientCore/android/reader/jni/de_bdr_eidclient_external_reader.h: -------------------------------------------------------------------------------- 1 | #ifdef __cplusplus 2 | extern "C" { 3 | #endif 4 | 5 | extern JNIEnv *EID_env; 6 | extern jobject EID_reader; 7 | 8 | #ifdef __cplusplus 9 | } 10 | #endif 11 | -------------------------------------------------------------------------------- /eIDClientCore/bin/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0.2) 2 | 3 | add_subdirectory(Test_nPAClientLib) 4 | add_subdirectory(SimpleClient) -------------------------------------------------------------------------------- /eIDClientCore/bin/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = SimpleClient/eidui_gui Test_nPAClientLib SimpleClient 2 | -------------------------------------------------------------------------------- /eIDClientCore/bin/SimpleClient/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0.2) 2 | 3 | add_executable(SimpleClient main.cpp eidui_cli.cpp CeIdObject.cpp CivetServer.cpp civetweb.c) 4 | 5 | include_directories(. 6 | ${EXPAT_INCLUDE_DIRS} 7 | ${CMAKE_SOURCE_DIR}/lib 8 | ${CMAKE_SOURCE_DIR}/lib/eIDClientConnection 9 | ${CMAKE_SOURCE_DIR}/lib/eIDClientCore 10 | ${CMAKE_CURRENT_SOURCE_DIR}/eidui_gui) 11 | 12 | if(WIN32) 13 | target_link_libraries(SimpleClient -lws2_32 -lwininet) 14 | else() 15 | target_link_libraries(SimpleClient ${CMAKE_THREAD_LIBS_INIT}) 16 | endif() 17 | 18 | add_subdirectory(eidui_gui) 19 | 20 | message("wxWidgets_LIBRARY_DIRS: ${wxWidgets_LIBRARY_DIRS}") 21 | #set(INSTALL_RPATH_USE_LINK_PATH ${wxWidgets_LIBRARY_DIRS}) 22 | set_target_properties(SimpleClient PROPERTIES 23 | INSTALL_RPATH "${INSTALL_RPATH};${wxWidgets_LIBRARY_DIRS}" 24 | BUILD_WITH_INSTALL_RPATH TRUE) 25 | target_link_libraries(SimpleClient ${EXPAT_LIBRARIES} ${LIBDL_LIBRARIES} eIDClientConnection eIDClientCore eidui_gui) 26 | install(TARGETS SimpleClient DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}) 27 | add_definitions(-DPACKAGE="eidclientcore" -DVERSION="0.2") -------------------------------------------------------------------------------- /eIDClientCore/bin/SimpleClient/CeIdObject.cpp: -------------------------------------------------------------------------------- 1 | #include "CeIdObject.h" 2 | #include 3 | 4 | using namespace std; 5 | 6 | CeIdObject::CeIdObject() 7 | { 8 | } 9 | 10 | CeIdObject::~CeIdObject(void) 11 | { 12 | } 13 | 14 | void CeIdObject::StartElementHandler(void *pUserData, const XML_Char *pszName, const XML_Char **papszAttrs) 15 | { 16 | CeIdObject *pThis = (CeIdObject *) pUserData; 17 | pThis ->OnStartElement(pszName, papszAttrs); 18 | } 19 | 20 | void CeIdObject::OnStartElement(const XML_Char *pszName, const XML_Char **papszAttrs) 21 | { 22 | //Current Element 23 | string strElement = pszName; 24 | 25 | if(m_strRootElement.empty()) { 26 | m_strRootElement.assign(strElement); 27 | } 28 | 29 | //We have an eCard-Object, save State for subelements 30 | if(!strElement.compare("object")) { 31 | for (int i = 0; papszAttrs[i]; i += 2) { 32 | string strParam(papszAttrs[i]); 33 | 34 | if (!strParam.compare("type")) { 35 | if(!strcmp(papszAttrs[i + 1], "application/vnd.ecard-client")) { 36 | m_strCurrentElement.assign(pszName); 37 | return; 38 | } 39 | 40 | } 41 | } 42 | } 43 | 44 | //Object Tag 45 | if(!m_strCurrentElement.compare("object")) { 46 | if (!strElement.compare("param")) { 47 | string strParamName = ""; 48 | string strParamValue = ""; 49 | for (int i = 0; papszAttrs[i]; i += 2) { 50 | string strParam(papszAttrs[i]); 51 | 52 | if (!strParam.compare("name")) { 53 | strParamName.assign(papszAttrs[i + 1]); 54 | } 55 | else if(!strParam.compare("value")) { 56 | strParamValue.assign(papszAttrs[i + 1]); 57 | } 58 | 59 | if(strParamName.empty() || strParamValue.empty()) { 60 | continue; 61 | } 62 | 63 | if (!strParamName.compare("SessionIdentifier")) { 64 | m_strSessionID.assign(strParamValue); 65 | 66 | } else if (!strParamName.compare("PathSecurity-Parameters")) { 67 | m_strPSK.assign(strParamValue); 68 | 69 | } else if (!strParamName.compare("RefreshAddress")) { 70 | m_strRefreshAddress.assign(strParamValue); 71 | /*Some eID-Servers use this CDATA "Flag" to 72 | * tell the XML-Parser that the following URL shouldnt be parsed */ 73 | size_t cDataPos = m_strRefreshAddress.find("") */ 77 | m_strRefreshAddress = m_strRefreshAddress.substr(cDataPos + 9, m_strRefreshAddress.length() - 9 - 3); 78 | } 79 | 80 | } else if (!strParamName.compare("ServerAddress")) { 81 | m_strServerAddress.assign(strParamValue); 82 | } 83 | } 84 | return; 85 | } 86 | } 87 | 88 | //Element inside a TCToken Element 89 | if(!m_strRootElement.compare("TCTokenType")) { 90 | m_strCurrentElement.assign(strElement); 91 | } 92 | } 93 | 94 | void CeIdObject::EndElementHandler(void *pUserData, const XML_Char *pszName) 95 | { 96 | CeIdObject *pThis = (CeIdObject *) pUserData; 97 | pThis ->OnEndElement(pszName); 98 | } 99 | 100 | void CeIdObject::OnEndElement(const XML_Char *pszName) 101 | { 102 | m_strCurrentElement.assign(""); 103 | } 104 | 105 | void CeIdObject::CharacterDataHandler(void *pUserData, const XML_Char *pszName, int len) 106 | { 107 | CeIdObject *pThis = (CeIdObject *) pUserData; 108 | pThis ->OnCharacterData(pszName, len); 109 | } 110 | 111 | void CeIdObject::OnCharacterData(const XML_Char *pszName, int len) { 112 | if(len == 1) //I often get Character Data of this length 113 | return; 114 | 115 | else if(!m_strCurrentElement.compare("ServerAddress")) 116 | m_strServerAddress = string(pszName, pszName+len); 117 | 118 | else if(!m_strCurrentElement.compare("SessionIdentifier")) 119 | m_strSessionID = string(pszName, pszName+len); 120 | 121 | else if(!m_strCurrentElement.compare("RefreshAddress") && m_strRefreshAddress.empty()) 122 | m_strRefreshAddress = string(pszName, pszName+len); 123 | 124 | else if(!m_strCurrentElement.compare("PSK")) 125 | m_strPSK = string(pszName, pszName+len); 126 | 127 | return; 128 | 129 | } 130 | 131 | bool CeIdObject::GetParams(string strToParse) 132 | { 133 | XML_Parser parser = XML_ParserCreate(NULL); 134 | XML_SetUserData(parser, (void *) this); 135 | XML_SetStartElementHandler(parser, StartElementHandler); 136 | XML_SetEndElementHandler(parser, EndElementHandler); 137 | XML_SetCharacterDataHandler(parser, CharacterDataHandler); 138 | XML_Status status = XML_Parse(parser, strToParse.c_str(), strToParse.length(), true); 139 | XML_ParserFree(parser); 140 | return status == XML_STATUS_OK; 141 | } 142 | -------------------------------------------------------------------------------- /eIDClientCore/bin/SimpleClient/CeIdObject.h: -------------------------------------------------------------------------------- 1 | #ifndef _CEIDOBJECT_H_ 2 | #define _CEIDOBJECT_H_ 3 | #include 4 | 5 | #define XML_STATIC 6 | #include 7 | 8 | class CeIdObject 9 | { 10 | public: 11 | CeIdObject(); 12 | ~CeIdObject(void); 13 | 14 | public: 15 | bool GetParams(std::string strToParse); 16 | 17 | protected: 18 | static void StartElementHandler(void *pUserData, const XML_Char *pszName, const XML_Char **papszAttrs); 19 | static void EndElementHandler(void *pUserData, const XML_Char *pszName); 20 | static void CharacterDataHandler(void *pUserData, const XML_Char *pszName, int len); 21 | void OnStartElement(const XML_Char *pszName, const XML_Char **papszAttrs); 22 | void OnEndElement(const XML_Char *pszName); 23 | void OnCharacterData(const XML_Char *pszName, int len); 24 | 25 | public: 26 | std::string m_strAction; 27 | std::string m_strMethod; 28 | std::string m_strSAMLRequest; 29 | std::string m_strSAMLResponse; 30 | std::string m_strSigAlg; 31 | std::string m_strSignature; 32 | std::string m_strRelayState; 33 | std::string m_strSessionID; 34 | std::string m_strPSK; 35 | std::string m_strRefreshAddress; 36 | std::string m_strServerAddress; 37 | std::string m_strTransactionURL; 38 | 39 | protected: 40 | std::string m_strCurrentElement; 41 | std::string m_strRootElement; 42 | }; 43 | 44 | #endif //_CEIDOBJECT_H_ -------------------------------------------------------------------------------- /eIDClientCore/bin/SimpleClient/CivetServer.cpp: -------------------------------------------------------------------------------- 1 | civetweb/src/CivetServer.cpp -------------------------------------------------------------------------------- /eIDClientCore/bin/SimpleClient/CivetServer.h: -------------------------------------------------------------------------------- 1 | civetweb/include/CivetServer.h -------------------------------------------------------------------------------- /eIDClientCore/bin/SimpleClient/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = SimpleClient 2 | 3 | noinst_HEADERS = CeIdObject.h CivetServer.h civetweb.h eidui_cli.h 4 | 5 | SimpleClient_SOURCES = main.cpp eidui_cli.cpp CeIdObject.cpp CivetServer.cpp civetweb.c 6 | SimpleClient_CPPFLAGS = $(EXPAT_CFLAGS) \ 7 | -I$(top_srcdir)/lib \ 8 | -I$(top_srcdir)/lib/eIDClientConnection \ 9 | -I$(top_srcdir)/lib/eIDClientCore \ 10 | -I$(top_srcdir)/bin/SimpleClient/eidui_gui 11 | SimpleClient_LDADD = $(EXPAT_LIBS) \ 12 | $(top_builddir)/lib/eIDClientConnection/libeIDClientConnection.la \ 13 | $(top_builddir)/lib/eIDClientCore/libeIDClientCore.la \ 14 | $(top_builddir)/bin/SimpleClient/eidui_gui/libeidui_gui.la 15 | if WIN32 16 | SimpleClient_LDADD += -lws2_32 -lwininet 17 | else 18 | SimpleClient_CPPFLAGS+= $(PTHREAD_CFLAGS) 19 | SimpleClient_LDADD += $(PTHREAD_CFLAGS) $(PTHREAD_LIBS) 20 | endif 21 | -------------------------------------------------------------------------------- /eIDClientCore/bin/SimpleClient/civetweb.c: -------------------------------------------------------------------------------- 1 | civetweb/src/civetweb.c -------------------------------------------------------------------------------- /eIDClientCore/bin/SimpleClient/civetweb.h: -------------------------------------------------------------------------------- 1 | civetweb/include/civetweb.h -------------------------------------------------------------------------------- /eIDClientCore/bin/SimpleClient/eidui_cli.cpp: -------------------------------------------------------------------------------- 1 | ../Test_nPAClientLib/eidui_cli.cpp -------------------------------------------------------------------------------- /eIDClientCore/bin/SimpleClient/eidui_cli.h: -------------------------------------------------------------------------------- 1 | ../Test_nPAClientLib/eidui_cli.h -------------------------------------------------------------------------------- /eIDClientCore/bin/SimpleClient/eidui_gui/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0.2) 2 | 3 | add_library(eidui_gui SHARED MainFrame.cpp eidui_gui.cpp ErrorMessages.cpp) 4 | 5 | include_directories(. 6 | ${CMAKE_SOURCE_DIR}/lib 7 | ${CMAKE_SOURCE_DIR}/lib/eIDClientCore 8 | ${wxWidgets_INCLUDE_DIRS}) 9 | 10 | message("wxWidgets_CXX_FLAGS: ${wxWidgets_CXX_FLAGS}, wxWidgets_DEFINITIONS: ${wxWidgets_DEFINITIONS}") 11 | add_definitions(${wxWidgets_CXX_FLAGS}) 12 | target_compile_definitions(eidui_gui PRIVATE ${wxWidgets_DEFINITIONS}) 13 | 14 | #Private to prevent overlinking, see http://www.kaizou.org/2015/01/linux-libraries/ 15 | #and https://github.com/kaizouman/linux-shlib-link-samples/blob/master/CMakeLists.txt 16 | message("wxWidgets_LIBRARIES: ${wxWidgets_LIBRARIES}") 17 | target_link_libraries(eidui_gui PRIVATE ${wxWidgets_LIBRARIES}) 18 | 19 | install(TARGETS eidui_gui DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}) -------------------------------------------------------------------------------- /eIDClientCore/bin/SimpleClient/eidui_gui/ErrorMessages.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | // For compilers that don't support precompilation, include "wx/wx.h" 15 | #include 16 | #ifndef WX_PRECOMP 17 | #include 18 | #endif 19 | 20 | #include "ErrorMessages.h" 21 | 22 | using namespace std; 23 | 24 | ErrorMessageApp* eApp; 25 | 26 | 27 | bool ErrorMessageApp::OnInit() 28 | { 29 | wxString errorString(mError.c_str(), wxConvUTF8); 30 | 31 | wxMessageDialog *dial = new wxMessageDialog(NULL, errorString, wxT("Info"), wxOK); 32 | dial->ShowModal(); 33 | 34 | exit(1); 35 | return(false); 36 | } 37 | 38 | ErrorMessageApp::ErrorMessageApp(string error) 39 | : wxApp() 40 | { 41 | mError = error; 42 | } 43 | 44 | void ErrorMessageApp::showError(string error) { 45 | 46 | } 47 | 48 | int showErrorMessage(string error) 49 | { 50 | 51 | char **argv_ = NULL; 52 | int argc_ = 0; 53 | 54 | eApp = new ErrorMessageApp(error); 55 | 56 | wxApp::SetInstance(eApp); 57 | wxEntry(argc_, argv_); 58 | 59 | 60 | return 0; 61 | } 62 | 63 | -------------------------------------------------------------------------------- /eIDClientCore/bin/SimpleClient/eidui_gui/ErrorMessages.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #ifndef ERRORMESSAGES_H 6 | #define ERRORMESSAGES_H 7 | 8 | #include "wx/wxprec.h" 9 | 10 | #ifndef WX_PRECOMP 11 | # include "wx/wx.h" 12 | #endif 13 | 14 | using namespace std; 15 | 16 | 17 | class ErrorMessageApp: public wxApp { 18 | public: 19 | ErrorMessageApp(string error); 20 | virtual bool OnInit(); 21 | void showError(string error); 22 | 23 | private: 24 | string mError; 25 | }; 26 | 27 | 28 | int showErrorMessage(string error); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /eIDClientCore/bin/SimpleClient/eidui_gui/MainFrame.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | 6 | #ifndef MAINFRAME_H 7 | #define MAINFRAME_H 8 | 9 | #include "wx/wxprec.h" 10 | 11 | #ifndef WX_PRECOMP 12 | # include "wx/wx.h" 13 | #endif 14 | 15 | 16 | using namespace std; 17 | 18 | const wxString tt_is[] = { 19 | "Fingerabdruck lesen", 20 | "Iris lesen", 21 | "eID lesen" 22 | }; 23 | 24 | const wxString tt_at[] = { 25 | "Altersnachweis", 26 | "Bestätigung des Wohnorts", 27 | "Restricted ID", 28 | "Privilegiertes Terminal", 29 | "CAN erlaubt", 30 | "PIN Management", 31 | "Zertifikat installieren", 32 | "Qualifiziertes Zertifikat installieren", 33 | "Dokumententyp lesen", 34 | "Ausstellenden Staat lesen", 35 | "Ablaufdatum lesen", 36 | "Vornamen lesen", 37 | "Familiennamen lesen", 38 | "Künstlernamen lesen", 39 | "Akademischen Titel lesen", 40 | "Geburtsdatum lesen", 41 | "Geburtsort lesen", 42 | "Staatszugehörigkeit lesen", 43 | "Geschlecht lesen", 44 | "DG12 lesen", 45 | "DG13 lesen", 46 | "DG14 lesen", 47 | "DG15 lesen", 48 | "DG16 lesen", 49 | "Adresse lesen", 50 | "Wohnort-ID lesen", 51 | "Aufenthaltserlaubnis I lesen", 52 | "Aufenthaltserlaubnis II lesen", 53 | "DG21 lesen", 54 | "DG21 ändern", 55 | "Aufenthaltserlaubnis I ändern", 56 | "Aufenthaltserlaubnis II ändern", 57 | "Wohnort-ID ändern", 58 | "Adresse ändern" 59 | }; 60 | 61 | const wxString tt_st[] = { 62 | "Elektronische Signatur erzeugen", 63 | "Qualifizierte elektronische Signatur erzeugen" 64 | }; 65 | 66 | class MainFrame: public wxFrame { 67 | public: 68 | MainFrame(const SPDescription_t *description, UserInput_t *input, int *status, const wxString& title, const wxPoint& pos, const wxSize& size); 69 | 70 | private: 71 | void ShowServiceInfo(wxPanel *panel, wxBoxSizer *hbox); 72 | void ShowTerminalInfo(wxPanel *panel, wxBoxSizer *hbox); 73 | void SetUserInput(); 74 | void OnExit(wxCommandEvent& event); 75 | void OnAbout(wxCommandEvent& event); 76 | void OnButtonOK(wxCommandEvent& event); 77 | void OnButtonCancel(wxCommandEvent& event); 78 | bool getPinFromUser(); 79 | void addCheckBox(int id, bool required, bool optional, wxString name); 80 | wxDECLARE_EVENT_TABLE(); 81 | wxPanel *panel; 82 | wxGridSizer *grid_sizer; 83 | wxTextCtrl *status_text; 84 | wxTextCtrl* m_passwordEntry; 85 | 86 | wxCheckListBox *clb_terminal_info; 87 | list checkBoxes; 88 | const SPDescription_t *m_description; 89 | UserInput_t *m_input; 90 | int *m_status; 91 | 92 | }; 93 | 94 | class MainApp: public wxApp { 95 | public: 96 | MainApp(const SPDescription_t *description, UserInput_t *input, int *status); 97 | virtual bool OnInit(); 98 | void appendText(string text); 99 | 100 | private: 101 | MainFrame *frame; 102 | const SPDescription_t *m_description; 103 | UserInput_t *m_input; 104 | int *m_status; 105 | }; 106 | 107 | class CheckBox : public wxFrame 108 | { 109 | public: 110 | 111 | 112 | }; 113 | 114 | const int ID_CHECKBOX = 100; 115 | const int ID_CHECKLISTBOX = 101; 116 | 117 | 118 | int start_gui(const SPDescription_t *description, UserInput_t *input); 119 | 120 | 121 | 122 | #endif 123 | -------------------------------------------------------------------------------- /eIDClientCore/bin/SimpleClient/eidui_gui/Makefile.am: -------------------------------------------------------------------------------- 1 | lib_LTLIBRARIES = libeidui_gui.la 2 | 3 | noinst_HEADERS = MainFrame.h ErrorMessages.h 4 | 5 | libeidui_gui_la_SOURCES = MainFrame.cpp eidui_gui.cpp ErrorMessages.cpp 6 | libeidui_gui_la_CPPFLAGS = -I$(top_srcdir)/lib/eIDClientCore -I$(top_srcdir)/lib 7 | -------------------------------------------------------------------------------- /eIDClientCore/bin/SimpleClient/eidui_gui/eidui_gui.h: -------------------------------------------------------------------------------- 1 | #ifndef EIDUI_GUI_H 2 | #define EIDUI_GUI_H 3 | 4 | #include 5 | 6 | void nPAeIdProtocolStateCallback_gui(const NPACLIENT_STATE state, const NPACLIENT_ERROR error); 7 | NPACLIENT_ERROR nPAeIdUserInteractionCallback_gui(const SPDescription_t *description, UserInput_t *input); 8 | void nPAeIdCleanup_gui(); 9 | 10 | #endif -------------------------------------------------------------------------------- /eIDClientCore/bin/SimpleClient/eidui_gui/test_script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | 4 | 5 | #g++ main.cpp MainFrame.cpp `../gtk-build/wx-config --cxxflags --libs` -o widgetTest 6 | 7 | g++ -g -c -Wall -fPIC -std=gnu++11 MainFrame.cpp eidui_gui.cpp -I../../../lib/eIDClientCore -I../../../lib `wxWidgets-3.0.2/gtk-build/wx-config --cxxflags --libs` && 8 | g++ -shared -o libeidui_gui.so MainFrame.o eidui_gui.o 9 | 10 | #mv libTextFrame.so lib && 11 | 12 | #g++ -std=gnu++11 -L ./lib -L/lib64 main.cpp -leidui_gui `../gtk-build/wx-config --cxxflags --libs` -o widgetTest && 13 | 14 | #LD_LIBRARY_PATH=$PWD/lib ./widgetTest 15 | -------------------------------------------------------------------------------- /eIDClientCore/bin/SimpleClient/md5.inl: -------------------------------------------------------------------------------- 1 | civetweb/src/md5.inl -------------------------------------------------------------------------------- /eIDClientCore/bin/Test_nPAClientLib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0.2) 2 | 3 | install(PROGRAMS load_test.bash DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}) 4 | 5 | if(GENGETOPT) 6 | add_custom_command(OUTPUT cmdline.c cmdline.h switch_file COMMAND gengetopt --include-getopt < ${CMAKE_CURRENT_SOURCE_DIR}/Start_Testcase.ggo && echo "new" > switch_file) 7 | set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES switch_file) 8 | # TODO: 9 | # clean-local: 10 | # touch Start_Testcase.ggo #Do not delete cmdline.c and cmdline.h, but trigger rebuild of these two files 11 | endif() 12 | 13 | include_directories(. 14 | ${EXPAT_INCLUDE_DIRS} 15 | ${CMAKE_SOURCE_DIR}/lib 16 | ${CMAKE_SOURCE_DIR}/lib/eIDClientConnection 17 | ${CMAKE_SOURCE_DIR}/lib/eIDClientCore) 18 | 19 | set(TEST_NPACLIENTLIB_SOURCES Test_nPAClientLib.cpp eidui_cli.cpp) 20 | add_library(Test_nPAClientLib SHARED ${TEST_NPACLIENTLIB_SOURCES}) 21 | target_link_libraries(Test_nPAClientLib ${EXPAT_LIBRARIES} eIDClientConnection eIDClientCore) 22 | 23 | if(WIN32) 24 | target_link_libraries(Test_nPAClientLib -lws2_32 -lwininet) 25 | else() 26 | target_link_libraries(Test_nPAClientLib ${CMAKE_THREAD_LIBS_INIT}) 27 | endif() 28 | 29 | install(TARGETS Test_nPAClientLib DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}) 30 | 31 | add_executable(Start_Testcase Start_Testcase.cpp cmdline.c) 32 | target_link_libraries(Start_Testcase Test_nPAClientLib eIDClientCore) 33 | install(TARGETS Start_Testcase DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}) 34 | add_definitions(-DPACKAGE="eidclientcore" -DVERSION="0.2") 35 | -------------------------------------------------------------------------------- /eIDClientCore/bin/Test_nPAClientLib/Makefile.am: -------------------------------------------------------------------------------- 1 | lib_LTLIBRARIES = libTest_nPAClientLib.la 2 | bin_PROGRAMS = Start_Testcase 3 | dist_bin_SCRIPTS = load_test.bash 4 | 5 | noinst_HEADERS = eidui_cli.h 6 | include_HEADERS = Test_nPAClientLib.h 7 | 8 | if HAS_GENGETOPT 9 | BUILT_SOURCES = cmdline.c #cmdline.h is generated implicitly 10 | cmdline.c: Start_Testcase.ggo 11 | gengetopt --include-getopt < Start_Testcase.ggo 12 | 13 | clean-local: 14 | touch Start_Testcase.ggo #Do not delete cmdline.c and cmdline.h, but trigger rebuild of these two files 15 | endif 16 | 17 | libTest_nPAClientLib_la_SOURCES = Test_nPAClientLib.cpp eidui_cli.cpp 18 | libTest_nPAClientLib_la_CPPFLAGS = $(EXPAT_CFLAGS) \ 19 | -I$(top_srcdir)/lib \ 20 | -I$(top_srcdir)/lib/eIDClientConnection \ 21 | -I$(top_srcdir)/lib/eIDClientCore 22 | libTest_nPAClientLib_la_LIBADD = $(EXPAT_LIBS) \ 23 | $(top_builddir)/lib/eIDClientConnection/libeIDClientConnection.la \ 24 | $(top_builddir)/lib/eIDClientCore/libeIDClientCore.la 25 | 26 | if WIN32 27 | libTest_nPAClientLib_la_LIBADD += -lws2_32 -lwininet 28 | else 29 | libTest_nPAClientLib_la_CPPFLAGS += $(PTHREAD_CFLAGS) 30 | libTest_nPAClientLib_la_LIBADD += $(PTHREAD_CFLAGS) $(PTHREAD_LIBS) 31 | endif 32 | 33 | Start_Testcase_SOURCES = Start_Testcase.cpp cmdline.c 34 | Start_Testcase_CPPFLAGS = -I$(top_srcdir)/lib 35 | Start_Testcase_LDADD = libTest_nPAClientLib.la \ 36 | $(top_builddir)/lib/eIDClientCore/libeIDClientCore.la 37 | -------------------------------------------------------------------------------- /eIDClientCore/bin/Test_nPAClientLib/Start_Testcase.ggo: -------------------------------------------------------------------------------- 1 | # Options 2 | option "service-provider" s "Service Provider URL" string typestr="URL" optional 3 | 4 | option "testcase" t "SAML/Testcase selection. This option is mandatory." values="No_SAML","SAML_1","SAML_2","Selbstauskunft_Wuerzburg","AutentApp" enum typestr="Testcase" required 5 | 6 | option "card-reader" c "Part of Card Reader Name. If the Card Reader Name contains spaces, embrace it with quotes, i.e. \"Card Reader Name\"" string optional 7 | 8 | option "pin" p "PIN" string optional 9 | 10 | option "loopcount" l "Loopcount" int optional 11 | 12 | option "cancel-after-paos" a "Cancel after PAOS connection establishment." flag off 13 | 14 | option "debug-level" v "Debug level (verbosity) as a number. Debug levels are:\n\ 15 | \tAPDU :\t\t1\n\ 16 | \tCRYPTO :\t2\n\ 17 | \tSSL :\t\t4\n\ 18 | \tPAOS :\t\t8\n\ 19 | \tCARD :\t\t16\n\ 20 | \tCLIENT :\t32\n\ 21 | To choose multiple Debug Levels at the same time, just sum the corresponding numbers and take the result as parameter." int optional default="0" 22 | -------------------------------------------------------------------------------- /eIDClientCore/bin/Test_nPAClientLib/Test_nPAClientLib.h: -------------------------------------------------------------------------------- 1 | #if !defined(__TEST_NPACLIENTLIB_H_INCLUDED__) 2 | #define __TEST_NPACLIENTLIB_H_INCLUDED__ 3 | 4 | int performEID(std::string strServiceURL, 5 | std::string strIdpAddress, 6 | std::string strSessionIdentifier, 7 | std::string strPathSecurityParameters, 8 | std::string strRef, 9 | std::string cardReaderName, 10 | std::string &response); 11 | 12 | std::string str_replace_ifnot(std::string rep, std::string wit, std::string ifnot, std::string in); 13 | 14 | #include "cmdline.h" 15 | #include 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | extern enum enum_testcase SAML_VERSION; 22 | extern const char *pin; 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /eIDClientCore/bin/Test_nPAClientLib/eidui_cli.h: -------------------------------------------------------------------------------- 1 | #ifndef _EIDUI_CLI_H 2 | #define _EIDUI_CLI_H 3 | #if defined(__cplusplus) 4 | extern "C" 5 | { 6 | #endif 7 | 8 | #include 9 | 10 | void nPAeIdProtocolStateCallback_ui(const NPACLIENT_STATE state, const NPACLIENT_ERROR error); 11 | NPACLIENT_ERROR nPAeIdUserInteractionCallback_ui(const SPDescription_t *description, UserInput_t *input); 12 | void nPAeIdCleanup_ui(); 13 | 14 | #if defined(__cplusplus) 15 | } 16 | #endif 17 | #endif 18 | -------------------------------------------------------------------------------- /eIDClientCore/bin/Test_nPAClientLib/load_test.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | usage() { 4 | echo "Need at least two parameters." 5 | echo 6 | echo "Usage: $0 number_of_threads command [arguments of command]" 7 | echo 8 | echo "Example usage: $0 20 bin/Start_Testcase --testcase=AutentApp --card-reader=\"Virtual PCD 00 00\"" 9 | exit 1 10 | } 11 | 12 | if [ $# -lt 2 ] 13 | then 14 | usage 15 | fi 16 | 17 | NUM_THREADS=$1 18 | 19 | if ! [[ $NUM_THREADS =~ ^[1-9][0-9]*$ ]] ; then 20 | echo "First argument \"$NUM_THREADS\" has to be a positive integer." 21 | usage 22 | fi 23 | 24 | shift 25 | #"$@" now only contains: "command" ["argument of command"] ... 26 | 27 | #Waits for all PIDs in an array 28 | wait_for_pids() { 29 | declare -a PIDs=("${!1}") 30 | for i in "${PIDs[@]}" 31 | do 32 | wait "$i" 33 | done 34 | } 35 | 36 | # Add a prefix to each line of stdin. 37 | add_prefix() { 38 | local line 39 | while read line; do printf '%s%s\n' "$1" "$line"; done 40 | } 41 | 42 | # Prepend prefix 43 | start_with_prefix() { 44 | PREFIX=$1 45 | shift 46 | #"$@" now only contains: "command" ["argument of command"] ... 47 | 48 | # Create FIFOs for the command's stdout and stderr. 49 | stdout=$(mktemp /tmp/eID_DOS.$$.stdout.XXXXXXXX -u) 50 | stderr=$(mktemp /tmp/eID_DOS.$$.stderr.XXXXXXXX -u) 51 | mkfifo "$stdout" "$stderr" 52 | 53 | #Save PIDs to wait for them later 54 | PIDs=() 55 | 56 | # Read from the FIFOs in the background, adding the desired prefixes. 57 | add_prefix ${PREFIX}'_O:' < "$stdout" >&1 & 58 | PIDs+=($!) 59 | add_prefix ${PREFIX}'_E:' < "$stderr" >&2 & 60 | PIDs+=($!) 61 | 62 | # Now execute the command, sending its stdout and stderr to the FIFOs. 63 | "$@" 1> "$stdout" 2> "$stderr" & 64 | PIDs+=($!) 65 | 66 | #It is important to wait for the add_prefix calls, because otherwise 67 | #we return before they wrote everything to the command line. They will 68 | #then continue to write to the command line (until they wrote 69 | #everything). It will look like the program hangs. 70 | wait_for_pids PIDs[@] 71 | 72 | rm $stdout 73 | rm $stderr 74 | } 75 | 76 | ( 77 | PIDs=() 78 | 79 | for i in $(seq -f "%0${#NUM_THREADS}g" 1 $NUM_THREADS); 80 | do 81 | start_with_prefix "$i" "$@" & 82 | PIDs+=($!) 83 | done 84 | 85 | wait_for_pids PIDs[@] 86 | ) 87 | -------------------------------------------------------------------------------- /eIDClientCore/bin/Test_nPAClientLib/url.h: -------------------------------------------------------------------------------- 1 | #ifndef _URL_H 2 | #define _URL_H 3 | 4 | #include 5 | #include 6 | 7 | class URL 8 | { 9 | public: 10 | URL(const char *const url) { 11 | _scheme.assign(""); 12 | _hostname.assign(""); 13 | _port.assign(""); 14 | _path.assign(""); 15 | 16 | if (url && *url) { 17 | std::string _str(url); 18 | _valid = parse_url(_str); 19 | } else _valid = false; 20 | } 21 | 22 | std::string _scheme; 23 | std::string _hostname; 24 | std::string _port; 25 | std::string _path; 26 | bool _valid; 27 | 28 | bool parse_url(std::string& url) { 29 | std::string prefix("https"); 30 | std::string::size_type idx; 31 | 32 | _port.assign("80"); 33 | 34 | if (prefix.length() >= url.length()) 35 | return false; 36 | idx = url.find("://"); 37 | if (idx != std::string::npos) { 38 | auto res = std::mismatch(prefix.begin(), prefix.end(), url.begin()); 39 | if (res.first == prefix.end()) { 40 | _scheme = "https"; 41 | _port = "443"; 42 | } else if (res.first == (prefix.end()-1)) { 43 | _scheme = "http"; 44 | } else { 45 | return false; 46 | } 47 | url.erase(0, (idx+3)); 48 | } 49 | idx = url.find(":"); 50 | if (idx != std::string::npos) { 51 | _hostname = url.substr(0, idx); 52 | url.erase(0, (idx+1)); 53 | idx = url.find("/"); 54 | if (idx != std::string::npos) { 55 | _port = url.substr(0, idx); 56 | url.erase(0, idx); 57 | _path = url; 58 | } 59 | } else { 60 | idx = url.find("/"); 61 | if (idx != std::string::npos) { 62 | _hostname = url.substr(0, idx); 63 | url.erase(0, idx); 64 | _path = url; 65 | } 66 | } 67 | return true; 68 | } 69 | }; 70 | #endif 71 | -------------------------------------------------------------------------------- /eIDClientCore/lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0.2) 2 | 3 | add_subdirectory(eIDClientConnection) 4 | add_subdirectory(eCardCore) 5 | add_subdirectory(eidasn1) 6 | get_directory_property(LIBEIDASN1_BINARY_DIR DIRECTORY eidasn1 DEFINITION LIBEIDASN1_BINARY_DIR) 7 | add_subdirectory(nPA-EAC) 8 | add_subdirectory(eIDClientCore) -------------------------------------------------------------------------------- /eIDClientCore/lib/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = eCardCore eIDClientConnection eidasn1 nPA-EAC eIDClientCore 2 | noinst_HEADERS = debug.h loadlib.h testing.h 3 | nobase_include_HEADERS = \ 4 | eIDClientCore/eIDClientCore.h \ 5 | eCardCore/eCardTypes.h \ 6 | nPA-EAC/nPAStatus.h 7 | -------------------------------------------------------------------------------- /eIDClientCore/lib/crypto.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Bundesdruckerei GmbH 3 | */ 4 | 5 | #if !defined(__CRYPTO_INCLUDED__) 6 | #define __CRYPTO_INCLUDED__ 7 | 8 | #if defined(WIN32) 9 | // CRYPTOPP includes 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include // Elliptic curve over GF(p) 16 | #include 17 | #include 18 | #else 19 | // CRYPTOPP includes 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include // Elliptic curve over GF(p) 26 | #include 27 | #include 28 | #endif 29 | 30 | using CryptoPP::DH; 31 | using CryptoPP::Integer; 32 | using CryptoPP::CBC_Mode; 33 | using CryptoPP::AES; 34 | using CryptoPP::CMAC; 35 | using CryptoPP::AutoSeededRandomPool; 36 | using CryptoPP::ECP; 37 | using CryptoPP::SHA1; 38 | using CryptoPP::SHA224; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /eIDClientCore/lib/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Bundesdruckerei GmbH 3 | */ 4 | 5 | #if !defined(__DEBUG_H_INCLUDED__) 6 | #define __DEBUG_H_INCLUDED__ 7 | 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | 14 | #define DEBUG_LEVEL_APDU 0x01 15 | #define DEBUG_LEVEL_CRYPTO 0x02 16 | #define DEBUG_LEVEL_SSL 0x04 17 | #define DEBUG_LEVEL_PAOS 0x08 18 | #define DEBUG_LEVEL_CARD 0x10 19 | #define DEBUG_LEVEL_CLIENT 0x20 20 | #define DEBUG_LEVEL_READER 0x40 21 | #define DEBUG_LEVEL_TIME 0x80 22 | #define DEBUG_LEVEL_ALL (DEBUG_LEVEL_APDU|DEBUG_LEVEL_CRYPTO|DEBUG_LEVEL_SSL|DEBUG_LEVEL_PAOS|DEBUG_LEVEL_CARD|DEBUG_LEVEL_CLIENT) 23 | extern unsigned char USED_DEBUG_LEVEL; 24 | 25 | #ifdef __ANDROID__ 26 | /* stlport doesn't provide vector.data() */ 27 | #define DATA(v) ((v).size()?&v[0]:NULL) 28 | #else 29 | #define DATA(v) ((v).data()) 30 | #endif 31 | 32 | #define hexdump(level, caption, buffer, length) { \ 33 | if (level & USED_DEBUG_LEVEL) _hexdump(caption, buffer, length); } 34 | #define startTimer(){ \ 35 | if ( DEBUG_LEVEL_TIME & USED_DEBUG_LEVEL) _startTimer(); } 36 | #define stopTimer(){ \ 37 | if ( DEBUG_LEVEL_TIME & USED_DEBUG_LEVEL) _stopTimer(); } 38 | #define eCardCore_info(level, ...) { \ 39 | if (level & USED_DEBUG_LEVEL) _eCardCore_info(__VA_ARGS__); } 40 | #define eCardCore_warn(level, ...) { \ 41 | if (level & USED_DEBUG_LEVEL) _eCardCore_warn(__VA_ARGS__); } 42 | #define eCardCore_debug(level, ...) { \ 43 | if (level & USED_DEBUG_LEVEL) _eCardCore_debug(__VA_ARGS__); } 44 | 45 | 46 | void timestamp(); 47 | 48 | #if defined(_WIN32) && !defined(_WIN32_WCE) 49 | #include 50 | #define my_puts(s) { timestamp(); OutputDebugStringA(s); OutputDebugStringA("\n"); } 51 | #else 52 | #include 53 | #define my_puts(s) { timestamp(); puts(s);fflush(stdout); } 54 | #endif 55 | void _hexdump(const char *const caption, 56 | const void *const buffer, size_t length); 57 | void _startTimer(); 58 | void _stopTimer(); 59 | void _eCardCore_info(const char *format, ...); 60 | void _eCardCore_warn(const char *format, ...); 61 | void _eCardCore_debug(const char *format, ...); 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eCardCore/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0.2) 2 | 3 | set(LIBECARDCORE_SOURCES ICard.cpp CardCommand.cpp IReader.cpp) 4 | 5 | 6 | if(NOT DISABLE_EXTERNAL) 7 | set (LIBECARDCORE_SOURCES ${LIBECARDCORE_SOURCES} ExternalReader.cpp) 8 | endif() 9 | 10 | if(NOT DISABLE_PCSC) 11 | set(LIBECARDCORE_SOURCES ${LIBECARDCORE_SOURCES} PCSCManager.cpp PCSCReader.cpp pace_reader.cpp) 12 | endif() 13 | 14 | add_library(eCardCore SHARED ${LIBECARDCORE_SOURCES}) 15 | include_directories(../ ${PCSC_INCLUDE_DIRS}) 16 | 17 | if(NOT DISABLE_PCSC) 18 | if(PCSC_LIBRARIES) 19 | target_link_libraries(eCardCore ${PCSC_LIBRARIES}) 20 | endif() 21 | endif() 22 | 23 | install(TARGETS eCardCore DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}) -------------------------------------------------------------------------------- /eIDClientCore/lib/eCardCore/ExternalManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Bundesdruckerei GmbH 3 | */ 4 | 5 | #if !defined(__EXTERNALMANAGER_INCLUDED__) 6 | #define __EXTERNALMANAGER_INCLUDED__ 7 | 8 | #include "IReaderManager.h" 9 | #include "ExternalReader.h" 10 | 11 | class ExternalManager : public IReaderManager 12 | { 13 | public: 14 | ExternalManager(void) 15 | { 16 | m_readerList.push_back(new ExternalReader("ExternalReader", m_cardDetectors)); 17 | } 18 | 19 | ECARD_PROTOCOL getProtocol() 20 | { 21 | return PROTOCOL_EXTERNAL; 22 | }; 23 | }; 24 | 25 | #endif // __EXTERNALMANAGER_INCLUDED__ 26 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eCardCore/ExternalReader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Bundesdruckerei GmbH 3 | */ 4 | 5 | #if !defined(__EXTERNALREADER_INCLUDED__) 6 | #define __EXTERNALREADER_INCLUDED__ 7 | 8 | #include "IReader.h" 9 | #include "eCardTypes.h" 10 | #include "eIdClientCardReader.h" 11 | 12 | class ExternalReader : public IndividualReader 13 | { 14 | private: 15 | void* m_hLib; 16 | CardReaderOpen_t m_hOpen; 17 | CardReaderClose_t m_hClose; 18 | CardReaderSend_t m_hSend; 19 | CardReaderGetATR_t m_hGetATR; 20 | CardReaderSupportsPACE_t m_hSupportsPACE; 21 | CardReaderDoPACE_t m_hDoPACE; 22 | EIDCLIENT_CARD_READER_HANDLE m_hCardReader; 23 | void m_libcleanup(void); 24 | bool m_libload(void); 25 | static const size_t MAX_BUFFER_SIZE = 0xFFF; 26 | unsigned char buffer[MAX_BUFFER_SIZE]; 27 | 28 | public: 29 | ExternalReader(const std::string &, std::vector&); 30 | ~ExternalReader(void); 31 | 32 | bool open(void); 33 | void close(void); 34 | 35 | std::vector transceive(const std::vector& cmd); 36 | 37 | std::vector getATRForPresentCard(void); 38 | 39 | bool supportsPACEnative(void); 40 | PaceOutput establishPACEChannelNative(const PaceInput &input); 41 | }; 42 | 43 | #endif // __EXTERNALREADER_INCLUDED__ 44 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eCardCore/ICard.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Bundesdruckerei GmbH 3 | */ 4 | 5 | #include "ICard.h" 6 | #include "CardCommand.h" 7 | #include "IReaderManager.h" 8 | 9 | ICard::ICard( 10 | IReader *subSystem) : m_subSystem(subSystem) 11 | {} 12 | 13 | ICard::~ICard() 14 | { 15 | } 16 | 17 | void ICard::debug_CAPDU(const char *label, const CAPDU& capdu) const 18 | { 19 | eCardCore_info(DEBUG_LEVEL_APDU, "%s%sC-APDU: CLA=%02X INS=%02X P1=%02X P2=%02X Nc=%-' '5u Ne=%u", 20 | label, label ? " " : "", capdu.getCLA(), capdu.getINS(), capdu.getP1(), 21 | capdu.getP2(), capdu.getData().size(), capdu.getNe()); 22 | hexdump(DEBUG_LEVEL_APDU, NULL, 23 | DATA(capdu.getData()), capdu.getData().size()); 24 | } 25 | 26 | void ICard::debug_RAPDU(const char *label, const RAPDU& rapdu) const 27 | { 28 | eCardCore_info(DEBUG_LEVEL_APDU, "%s%sR-APDU: SW=%04X Nr=%u", 29 | label, label ? " " : "", rapdu.getSW(), rapdu.getData().size()); 30 | if (!rapdu.getData().empty()) 31 | hexdump(DEBUG_LEVEL_APDU, NULL, 32 | DATA(rapdu.getData()), rapdu.getData().size()); 33 | } 34 | 35 | std::vector > 36 | ICard::get_buffers(const std::vector & apdus) 37 | { 38 | std::vector > buffers; 39 | 40 | for (std::vector::const_iterator i = apdus.begin(); i < apdus.end(); ++i) { 41 | debug_CAPDU("Outgoing", *i); 42 | buffers.push_back(i->asBuffer()); 43 | } 44 | 45 | return buffers; 46 | } 47 | 48 | std::vector 49 | ICard::get_rapdus(const std::vector > & buffers) 50 | { 51 | std::vector rapdus; 52 | 53 | for (std::vector >::const_iterator i = buffers.begin(); i < buffers.end(); ++i) { 54 | RAPDU rapdu(*i); 55 | debug_RAPDU("Incoming", rapdu); 56 | rapdus.push_back(rapdu); 57 | } 58 | 59 | return rapdus; 60 | } 61 | 62 | RAPDU ICard::transceive(const CAPDU &cmd) 63 | { 64 | debug_CAPDU("Outgoing", cmd); 65 | 66 | RAPDU rapdu(m_subSystem->transceive(cmd.asBuffer())); 67 | debug_RAPDU("Incoming", rapdu); 68 | 69 | return rapdu; 70 | } 71 | 72 | std::vector ICard::transceive(const std::vector &cmds) 73 | { 74 | return get_rapdus(m_subSystem->transceive(get_buffers(cmds))); 75 | } 76 | 77 | IReader *ICard::getSubSystem(void) const 78 | { 79 | return m_subSystem; 80 | } 81 | 82 | bool ICard::selectMF( 83 | void) 84 | { 85 | SelectFile select(SelectFile::P1_SELECT_FID, SelectFile::P2_NO_RESPONSE); 86 | RAPDU response = transceive(select); 87 | return response.isOK(); 88 | } 89 | 90 | bool ICard::selectEF( 91 | unsigned short FID) 92 | { 93 | SelectFile select(SelectFile::P1_SELECT_EF, SelectFile::P2_NO_RESPONSE, FID); 94 | RAPDU response = transceive(select); 95 | return response.isOK(); 96 | } 97 | 98 | bool ICard::selectEF( 99 | unsigned short FID, 100 | std::vector& fcp) 101 | { 102 | SelectFile select(SelectFile::P1_SELECT_EF, SelectFile::P2_FCP_TEMPLATE, FID); 103 | select.setNe(CAPDU::DATA_SHORT_MAX); 104 | RAPDU response = transceive(select); 105 | fcp = response.getData(); 106 | return response.isOK(); 107 | } 108 | 109 | bool ICard::selectDF( 110 | unsigned short FID) 111 | { 112 | SelectFile select(SelectFile::P1_SELECT_DF, SelectFile::P2_NO_RESPONSE, FID); 113 | RAPDU response = transceive(select); 114 | return response.isOK(); 115 | } 116 | 117 | bool ICard::readFile( 118 | unsigned char sfid, 119 | size_t chunk_size, 120 | std::vector& result) 121 | { 122 | ReadBinary read = ReadBinary(0, sfid); 123 | read.setNe(chunk_size); 124 | RAPDU response = transceive(read); 125 | 126 | while (response.isOK() && response.getData().size() == chunk_size) { 127 | result.insert(result.end(), response.getData().begin(), response.getData().end()); 128 | 129 | read = ReadBinary(result.size()); 130 | read.setNe(chunk_size); 131 | response = transceive(read); 132 | } 133 | 134 | result.insert(result.end(), response.getData().begin(), response.getData().end()); 135 | 136 | if (result.empty()) { 137 | return response.isOK(); 138 | } 139 | 140 | return true; 141 | } 142 | 143 | bool ICard::readFile( 144 | std::vector& result) 145 | { 146 | ReadBinary read = ReadBinary(); 147 | read.setNe(CAPDU::DATA_EXTENDED_MAX); 148 | RAPDU response = transceive(read); 149 | result = response.getData(); 150 | return response.isOK(); 151 | } 152 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eCardCore/ICard.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Bundesdruckerei GmbH 3 | */ 4 | 5 | #if !defined(__ICARD_INCLUDED__) 6 | #define __ICARD_INCLUDED__ 7 | 8 | #include "CardCommand.h" 9 | #include "IReaderManager.h" 10 | 11 | #include 12 | 13 | /* ISO 7816 smart card */ 14 | class ICard: public Transceiver 15 | { 16 | private: 17 | ICard( 18 | const ICard &); 19 | 20 | ICard &operator=( 21 | const ICard &); 22 | 23 | std::vector > get_buffers( 24 | const std::vector & apdus); 25 | std::vector get_rapdus( 26 | const std::vector > & buffers); 27 | 28 | protected: 29 | IReader *m_subSystem; 30 | void debug_CAPDU(const char *label, const CAPDU &cmd) const; 31 | void debug_RAPDU(const char *label, const RAPDU &cmd) const; 32 | 33 | public: 34 | static const unsigned short FID_MF = 0x3F00; 35 | 36 | ICard(IReader *subSystem); 37 | virtual ~ICard(void); 38 | 39 | bool selectMF(void); 40 | bool selectDF(unsigned short FID); 41 | bool selectEF(unsigned short FID); 42 | bool selectEF(unsigned short FID, std::vector& fcp); 43 | 44 | bool readFile(std::vector& result); 45 | bool readFile(unsigned char sfid, size_t chunk_size, std::vector& result); 46 | 47 | virtual RAPDU transceive(const CAPDU& cmd); 48 | virtual std::vector transceive(const std::vector& cmds); 49 | 50 | IReader *getSubSystem(void) const; 51 | 52 | // ------------------------------------------------------------------------- 53 | // Pure virtuals 54 | // ------------------------------------------------------------------------- 55 | 56 | virtual std::string getCardDescription(void) = 0; 57 | 58 | }; // class ICard 59 | 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eCardCore/ICardDetector.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Bundesdruckerei GmbH 3 | */ 4 | 5 | #if !defined(__ICARDDETECTOR_INCLUDED__) 6 | #define __ICARDDETECTOR_INCLUDED__ 7 | 8 | class ICard; 9 | 10 | class IReader; 11 | 12 | class ICardDetector 13 | { 14 | public: 15 | /*! 16 | * 17 | */ 18 | virtual ~ICardDetector( 19 | void) {}; 20 | 21 | /*! 22 | * 23 | */ 24 | virtual ICard *getCard( 25 | IReader *) = 0; 26 | }; 27 | 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eCardCore/IReaderManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Bundesdruckerei GmbH 3 | */ 4 | 5 | #if !defined(__IREADERMANAGER_INCLUDED__) 6 | #define __IREADERMANAGER_INCLUDED__ 7 | 8 | #include "IReader.h" 9 | #include "eCardTypes.h" 10 | 11 | #include 12 | #include 13 | 14 | /*! 15 | * @class IReaderManager 16 | */ 17 | 18 | class IReaderManager 19 | { 20 | protected: 21 | std::vector m_readerList; 22 | std::vector m_cardDetectors; 23 | 24 | public: 25 | /*! 26 | * 27 | */ 28 | IReaderManager( 29 | void) {} 30 | 31 | /*! 32 | * 33 | */ 34 | virtual ~IReaderManager( 35 | void) { 36 | // Delete all known readers. 37 | for (std::vector::iterator it = m_readerList.begin(); 38 | it != m_readerList.end(); it++) { 39 | IReader *reader = *it; 40 | delete reader; 41 | } 42 | 43 | // Delete all known card detectors 44 | for (std::vector::iterator it = m_cardDetectors.begin(); 45 | it != m_cardDetectors.end(); it++) { 46 | ICardDetector *detector = *it; 47 | delete detector; 48 | } 49 | }; 50 | 51 | /*! 52 | * 53 | */ 54 | size_t getReaderCount( 55 | void) { 56 | return m_readerList.size(); 57 | } 58 | 59 | /*! 60 | * 61 | */ 62 | IReader *getReader( 63 | size_t idx) { 64 | if (idx > m_readerList.size()) 65 | return 0x0; 66 | 67 | return m_readerList[idx]; 68 | } 69 | 70 | /*! 71 | * 72 | */ 73 | std::vector getReaders( 74 | void) { return m_readerList; }; 75 | 76 | /*! 77 | * 78 | */ 79 | IReader *getReader( 80 | const std::string &readerName) { 81 | for (std::vector::iterator it = m_readerList.begin(); 82 | it != m_readerList.end(); it++) { 83 | IReader *reader = *it; 84 | 85 | if (reader->getReaderName().compare(readerName) == 0) 86 | return reader; 87 | } 88 | 89 | return 0x0; 90 | } 91 | 92 | /*! 93 | * 94 | */ 95 | void addCardDetector( 96 | ICardDetector *detector) { 97 | m_cardDetectors.push_back(detector); 98 | } 99 | 100 | // ------------------------------------------------------------------------- 101 | // Pure virtuals 102 | // ------------------------------------------------------------------------- 103 | 104 | /*! 105 | * 106 | */ 107 | virtual ECARD_PROTOCOL getProtocol( 108 | void) = 0; 109 | }; 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eCardCore/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libeCardCore.la 2 | 3 | noinst_HEADERS = CardCommand.h eCardStatus.h ICard.h PCSCManager.h eCardTypes.h IReader.h PCSCReader.h ICardDetector.h IReaderManager.h ExternalManager.h ExternalReader.h pace_reader.h Transceiver.h eIdClientCardReader.h 4 | 5 | libeCardCore_la_SOURCES = ICard.cpp CardCommand.cpp IReader.cpp 6 | libeCardCore_la_CPPFLAGS = -I$(top_srcdir)/lib 7 | libeCardCore_la_LIBADD = 8 | 9 | if DISABLE_EXTERNAL 10 | else 11 | libeCardCore_la_SOURCES += ExternalReader.cpp 12 | endif 13 | 14 | if DISABLE_PCSC 15 | else 16 | libeCardCore_la_SOURCES += PCSCManager.cpp PCSCReader.cpp pace_reader.cpp 17 | libeCardCore_la_CPPFLAGS += $(PCSC_CFLAGS) 18 | libeCardCore_la_LIBADD += $(PCSC_LIBS) 19 | endif 20 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eCardCore/PCSCManager.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Bundesdruckerei GmbH 3 | */ 4 | #include "PCSCManager.h" 5 | #include "PCSCReader.h" 6 | #include 7 | 8 | #if defined(WIN32) 9 | # include 10 | #endif 11 | #if !(defined(UNICODE) || defined(_UNICODE)) 12 | #include 13 | #endif 14 | 15 | /* 16 | * 17 | */ 18 | PCSCManager::PCSCManager(const char * userSelectedCardReader) : IReaderManager() 19 | { 20 | findReaders(userSelectedCardReader); 21 | } 22 | 23 | /* 24 | * 25 | */ 26 | void PCSCManager::findReaders(const char * userSelectedCardReader) 27 | { 28 | long retValue = SCARD_S_SUCCESS; 29 | SCARDCONTEXT hScardContext = 0x0; 30 | 31 | if ((retValue = SCardEstablishContext(SCARD_SCOPE_SYSTEM, 0x0, 32 | 0x0, &hScardContext)) != SCARD_S_SUCCESS) { 33 | eCardCore_warn(DEBUG_LEVEL_CARD, "SCardEstablishContext failed. 0x%08X (%s:%d)", 34 | retValue, __FILE__, __LINE__); 35 | return; 36 | } 37 | 38 | DWORD dwSize = 0; 39 | 40 | if ((retValue = SCardListReaders(hScardContext, NULL, 41 | NULL, &dwSize)) != SCARD_S_SUCCESS) { 42 | eCardCore_warn(DEBUG_LEVEL_CARD, "SCardListReaders failed. 0x%08X (%s:%d)", 43 | retValue, __FILE__, __LINE__); 44 | return; 45 | } 46 | 47 | #if defined(WIN32) || defined(WINCE) 48 | LPTSTR readers = new TCHAR[dwSize]; 49 | #else 50 | char *readers = new char[dwSize]; 51 | #endif 52 | 53 | if ((retValue = SCardListReaders(hScardContext, NULL, 54 | readers, &dwSize)) != SCARD_S_SUCCESS) { 55 | eCardCore_warn(DEBUG_LEVEL_CARD, "SCardListReaders failed. 0x%08X (%s:%d)", 56 | retValue, __FILE__, __LINE__); 57 | return; 58 | } 59 | 60 | if (0x00 == readers) { 61 | eCardCore_warn(DEBUG_LEVEL_CARD, "No readers available. (%s:%d)", 62 | __FILE__, __LINE__); 63 | return; 64 | } 65 | 66 | #if defined(WIN32) || defined(WINCE) 67 | LPTSTR pReader = readers; 68 | #else 69 | char *pReader = readers; 70 | #endif 71 | 72 | while ('\0' != *pReader) { 73 | #if defined(UNICODE) || defined(_UNICODE) 74 | int size = wcslen(pReader) + 1; 75 | char *pMBBuffer = new char[size]; 76 | memset(pMBBuffer, 0, size); 77 | wcstombs(pMBBuffer, pReader, wcslen(pReader)); 78 | /*Dont know if this is correct or we have to do some conversions before*/ 79 | if(!userSelectedCardReader || strstr(pMBBuffer, userSelectedCardReader)) 80 | IReader *newReader = new PCSCReader(pMBBuffer, m_cardDetectors); 81 | m_readerList.push_back(newReader); 82 | delete [] pMBBuffer; 83 | pReader = pReader + wcslen(pReader) + 1; 84 | #else 85 | /*To Do: Case insensitive compare*/ 86 | if(!userSelectedCardReader || !strlen(userSelectedCardReader) || strstr(pReader, userSelectedCardReader)) 87 | m_readerList.push_back(new PCSCReader(pReader, m_cardDetectors)); 88 | pReader = pReader + strlen(pReader) + 1; 89 | #endif 90 | } 91 | 92 | delete [] readers; 93 | SCardReleaseContext(hScardContext); 94 | } 95 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eCardCore/PCSCManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Bundesdruckerei GmbH 3 | */ 4 | 5 | #if !defined(__PCSCMANAGER_INCLUDED__) 6 | #define __PCSCMANAGER_INCLUDED__ 7 | 8 | #include "IReaderManager.h" 9 | 10 | /*! 11 | * @class PCSCManager 12 | */ 13 | class PCSCManager : public IReaderManager 14 | { 15 | private: 16 | void findReaders(const char * userSelectedCardReader); 17 | 18 | public: 19 | /*! 20 | * 21 | */ 22 | PCSCManager(const char * userSelectedCardReader); 23 | 24 | /*! 25 | * 26 | */ 27 | ECARD_PROTOCOL getProtocol() { 28 | return PROTOCOL_PCSC; 29 | }; 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eCardCore/PCSCReader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Bundesdruckerei GmbH 3 | */ 4 | 5 | #if !defined(__PCSCREDARE_INCLUDED__) 6 | #define __PCSCREDARE_INCLUDED__ 7 | 8 | #include "IReader.h" 9 | #include "ICardDetector.h" 10 | 11 | #include 12 | 13 | /*! 14 | * @class PCSCReader 15 | */ 16 | 17 | class PCSCReader : public IndividualReader 18 | { 19 | private: 20 | SCARDHANDLE m_hCard; // Handle to a card 21 | DWORD m_dwProtocol; // Actual used protocol (T1/T0) 22 | SCARDCONTEXT m_hScardContext; // Handle to the PCSC subsystem 23 | DWORD m_ioctl_pace; 24 | 25 | public: 26 | /*! 27 | * @brief Constructor 28 | * 29 | * This function calls SCardEstablishContext to get a handle 30 | * to the PCSC subsystem. The handle is stored in m_hScardContext. 31 | */ 32 | PCSCReader( 33 | const std::string &, 34 | std::vector&); 35 | 36 | /*! 37 | * @brief Destructor 38 | * 39 | * This function calls SCardReleaseContext to free the handle 40 | * to the PCSC subsystem. The handle is stored in m_hScardContext. 41 | */ 42 | ~PCSCReader( 43 | void); 44 | 45 | /*! 46 | * @brief Open a connection to a card. 47 | * 48 | * This function calls SCardConnectA to open a connection to a card. 49 | * The resulting handle ist stored in m_hCard. 50 | * 51 | * @return true if success. Otherwise false. 52 | */ 53 | bool open( 54 | void); 55 | 56 | /*! 57 | * @brief Closing a card connection. 58 | * 59 | * This function calls SCardDisconnect to close the card connection. 60 | */ 61 | void close( 62 | void); 63 | 64 | /*! 65 | * @brief This command uses SCardTransmit to send a command to the card. 66 | */ 67 | std::vector transceive( 68 | const std::vector& cmd); 69 | 70 | /*! 71 | * 72 | */ 73 | std::vector getATRForPresentCard( 74 | void); 75 | 76 | bool supportsPACEnative(void); 77 | 78 | PaceOutput establishPACEChannelNative(const PaceInput &); 79 | }; 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eCardCore/Transceiver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Bundesdruckerei GmbH 3 | */ 4 | 5 | #if !defined(__TRANSCEIVER_INCLUDED__) 6 | #define __TRANSCEIVER_INCLUDED__ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | /** 13 | * @note Classes using this template should overwrite and implement one transceive function 14 | */ 15 | template class Transceiver 16 | { 17 | public: 18 | virtual R transceive(const S& cmd) = 0; 19 | virtual std::vector transceive(const std::vector &cmds) = 0; 20 | }; 21 | 22 | template class IndividualTransceiver: public Transceiver 23 | { 24 | public: 25 | virtual R transceive(const S& cmd) = 0; 26 | virtual std::vector transceive(const std::vector &cmds) 27 | { 28 | std::vector resps; 29 | for (size_t i = 0; i < cmds.size(); i++) 30 | resps.push_back(this->transceive(cmds[i])); 31 | return resps; 32 | }; 33 | }; 34 | 35 | template class BatchTransceiver: public Transceiver 36 | { 37 | public: 38 | virtual R transceive(const S& cmd) { 39 | std::vector cmds; 40 | cmds.push_back(cmd); 41 | std::vector resps = this->transceive(cmds); 42 | return resps.front(); 43 | }; 44 | virtual std::vector transceive(const std::vector &cmds) = 0; 45 | }; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eCardCore/eCardStatus.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Bundesdruckerei GmbH 3 | */ 4 | 5 | #if !defined(__ECARDSTATUS_INCLUDED__) 6 | #define __ECARDSTATUS_INCLUDED__ 7 | 8 | typedef unsigned long ECARD_STATUS; 9 | 10 | #define ECARD_INFO 0x11000000 11 | #define ECARD_WARNING 0x12000000 12 | #define ECARD_ERROR 0x13000000 13 | 14 | //#define IS_ECARD_INFO(x) (EDA_INFO == (x & 0xF0000000)) 15 | //#define IS_ECARD_WARNING(x) (EDA_WARNING == (x & 0xF0000000)) 16 | //#define IS_ECARD_ERROR(x) (EDA_ERROR == (x & 0xF0000000)) 17 | 18 | #define ECARD_SUCCESS (ECARD_STATUS) 0x00000000 19 | 20 | #define ECARD_PROTOCOL_NOT_IMPLEMENTED ECARD_ERROR + 0x00000001 21 | #define ECARD_PROTOCOL_UNKNOWN ECARD_ERROR + 0x00000002 22 | #define ECARD_PIN_VERIFICATION_FAILED ECARD_ERROR + 0x00000003 23 | #define ECARD_INVALID_PARAMETER_1 ECARD_ERROR + 0x00000004 24 | #define ECARD_NO_SUCH_READER ECARD_ERROR + 0x00000005 25 | #define ECARD_READER_NOT_AVAILABLE ECARD_ERROR + 0x00000006 26 | #define ECARD_BUFFER_TO_SMALL ECARD_ERROR + 0x00000007 27 | #define ECARD_UNKNOWN_CARD ECARD_ERROR + 0x00000008 28 | #define ECARD_READ_ERROR ECARD_ERROR + 0x00000008 29 | #define ECARD_WRITE_ERROR ECARD_ERROR + 0x00000009 30 | #define ECARD_SELECT_FILE_FAILD ECARD_ERROR + 0x0000000A 31 | #define ECARD_VERIFY_PIN_FAILD ECARD_ERROR + 0x0000000B 32 | #define ECARD_INVALID_FILE_SIZE ECARD_ERROR + 0x0000000C 33 | #define ECARD_INVALID_CA_DOMAIN_PARAMS ECARD_ERROR + 0x0000000C 34 | #define ECARD_INVALID_CA_CAPKI ECARD_ERROR + 0x0000000D 35 | #define ECARD_ASN1_PARSER_ERROR ECARD_ERROR + 0x0000000E 36 | #define ECARD_EXTERNAL_PACE_ERROR ECARD_ERROR + 0x0000000F 37 | 38 | #define ECARD_READER_OPEN_FAILED ECARD_ERROR + 0x0000E100 39 | #define ECARD_READER_TRANSCEIVE_FAILED ECARD_ERROR + 0x0000E200 40 | #define ECARD_READER_GETATR_FAILED ECARD_ERROR + 0x0000E300 41 | #define ECARD_READER_CLOSE_FAILED ECARD_ERROR + 0x0000E400 42 | 43 | #define ECARD_FILE_ALREADY_EXIST ECARD_WARNING + 0x00000001 44 | 45 | #define ECARD_USER_INFO_OFFSET ECARD_INFO + 0x0000A000 46 | #define ECARD_MAKE_USER_INFO(x) ECARD_USER_INFO_OFFSET + x 47 | 48 | #define ECARD_USER_WARNING_OFFSET ECARD_WARNING + 0x0000B000 49 | #define ECARD_MAKE_USER_WARNING(x) ECARD_USER_WARNING_OFFSET + x 50 | 51 | #define ECARD_USER_ERROR_OFFSET ECARD_ERROR + 0x0000C000 52 | #define ECARD_MAKE_USER_ERROR(x) ECARD_USER_ERROR_OFFSET + x 53 | 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eCardCore/eCardTypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Bundesdruckerei GmbH 3 | */ 4 | 5 | #if !defined(__ECARDTYPES_INCLUDED__) 6 | #define __ECARDTYPES_INCLUDED__ 7 | 8 | #include 9 | 10 | typedef unsigned char BYTE; 11 | typedef BYTE *PBYTE; 12 | 13 | typedef unsigned long DWORD; 14 | typedef DWORD *PDWORD; 15 | 16 | typedef void *ECARD_HANDLE; 17 | typedef ECARD_HANDLE *PECARD_HANDLE; 18 | #define ECARD_INVALID_HANDLE_VALUE ((ECARD_HANDLE) 0xFFFFFFFF) 19 | 20 | typedef long long INT64; 21 | typedef unsigned long long UINT64; 22 | 23 | typedef short SHORT; 24 | typedef unsigned short USHORT; 25 | 26 | typedef unsigned int UINT32; 27 | 28 | typedef unsigned long ULONG; 29 | 30 | typedef void *LPVOID; 31 | 32 | 33 | /*! 34 | * @enum ECARD_PROTOCOL 35 | */ 36 | enum ECARD_PROTOCOL { 37 | PROTOCOL_PCSC, 38 | PROTOCOL_EXTERNAL, 39 | }; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eCardCore/eIdClientCardReader.cpp: -------------------------------------------------------------------------------- 1 | // --------------------------------------------------------------------------- 2 | // Copyright (c) 2013 Bundesdruckerei GmbH 3 | // All rights reserved. 4 | // 5 | // $Id$ 6 | // --------------------------------------------------------------------------- 7 | 8 | #include "eIDClientCardReader.h" 9 | 10 | #if defined(__cplusplus) 11 | extern "C" 12 | { 13 | #endif 14 | 15 | ECARD_STATUS CardReaderOpen(P_EIDCLIENT_CARD_READER_HANDLE hCardReader, const char* const readerName) 16 | { 17 | return ECARD_SUCCESS; 18 | } 19 | 20 | ECARD_STATUS CardReaderClose(EIDCLIENT_CARD_READER_HANDLE hCardReader) 21 | { 22 | return ECARD_SUCCESS; 23 | } 24 | 25 | ECARD_STATUS CardReaderSend(EIDCLIENT_CARD_READER_HANDLE hCardReader, 26 | const unsigned char* const cardCommand, 27 | const unsigned long nLengthCardCommand, 28 | unsigned char* const result, 29 | unsigned long* const nLengthResult) 30 | { 31 | return ECARD_SUCCESS; 32 | } 33 | 34 | 35 | ECARD_STATUS CardReaderGetATR(EIDCLIENT_CARD_READER_HANDLE hCardReader, 36 | unsigned char* const result, 37 | unsigned long* const nLengthResult) 38 | { 39 | return ECARD_SUCCESS; 40 | } 41 | 42 | 43 | ECARD_STATUS CardReaderSupportsPACE(EIDCLIENT_CARD_READER_HANDLE hCardReader) 44 | { 45 | return ECARD_SUCCESS; 46 | } 47 | 48 | ECARD_STATUS CardReaderDoPACE(EIDCLIENT_CARD_READER_HANDLE hCardReader, 49 | const enum PinID pinid, 50 | const nPADataBuffer_t *pin, 51 | const nPADataBuffer_t *chat, 52 | const nPADataBuffer_t *chat_required, 53 | const nPADataBuffer_t *chat_optional, 54 | const nPADataBuffer_t *certificate_description, 55 | const nPADataBuffer_t *transaction_info_hidden, 56 | unsigned int *result, 57 | unsigned short *status_mse_set_at, 58 | nPADataBuffer_t *ef_cardaccess, 59 | nPADataBuffer_t *car_curr, 60 | nPADataBuffer_t *car_prev, 61 | nPADataBuffer_t *id_icc, 62 | nPADataBuffer_t *chat_used) 63 | { 64 | return ECARD_SUCCESS; 65 | } 66 | 67 | #if defined(__cplusplus) 68 | } 69 | #endif 70 | 71 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eCardCore/eIdClientCardReader.h: -------------------------------------------------------------------------------- 1 | // --------------------------------------------------------------------------- 2 | // Copyright (c) 2013 Bundesdruckerei GmbH 3 | // All rights reserved. 4 | // 5 | // $Id$ 6 | // --------------------------------------------------------------------------- 7 | 8 | #if !defined(__EIDCLIENTCARDREADER_INCLUDE__) 9 | #define __EIDCLIENTCARDREADER_INCLUDE__ 10 | 11 | #include "eIDClientCore/eIDClientCore.h" 12 | #include "eCardCore/eCardStatus.h" 13 | 14 | typedef void *EIDCLIENT_CARD_READER_HANDLE; 15 | typedef EIDCLIENT_CARD_READER_HANDLE *P_EIDCLIENT_CARD_READER_HANDLE; 16 | 17 | #if defined(__cplusplus) 18 | extern "C" 19 | { 20 | #endif 21 | 22 | ECARD_STATUS CardReaderOpen(P_EIDCLIENT_CARD_READER_HANDLE hCardReader, const char* const readerName); 23 | ECARD_STATUS CardReaderClose(EIDCLIENT_CARD_READER_HANDLE hCardReader); 24 | ECARD_STATUS CardReaderSend(EIDCLIENT_CARD_READER_HANDLE hCardReader, 25 | const unsigned char* const cardCommand, 26 | const unsigned long nLengthCardCommand, 27 | unsigned char* const result, 28 | unsigned long* const nLengthResult); 29 | ECARD_STATUS CardReaderGetATR(EIDCLIENT_CARD_READER_HANDLE hCardReader, 30 | unsigned char* const result, 31 | unsigned long* const nLengthResult); 32 | ECARD_STATUS CardReaderSupportsPACE(EIDCLIENT_CARD_READER_HANDLE hCardReader); 33 | ECARD_STATUS CardReaderDoPACE(EIDCLIENT_CARD_READER_HANDLE hCardReader, 34 | const enum PinID pinid, 35 | const nPADataBuffer_t *pin, 36 | const nPADataBuffer_t *chat, 37 | const nPADataBuffer_t *chat_required, 38 | const nPADataBuffer_t *chat_optional, 39 | const nPADataBuffer_t *certificate_description, 40 | const nPADataBuffer_t *transaction_info_hidden, 41 | unsigned int *result, 42 | unsigned short *status_mse_set_at, 43 | nPADataBuffer_t *ef_cardaccess, 44 | nPADataBuffer_t *car_curr, 45 | nPADataBuffer_t *car_prev, 46 | nPADataBuffer_t *id_icc, 47 | nPADataBuffer_t *chat_used); 48 | 49 | 50 | typedef ECARD_STATUS (*CardReaderOpen_t)(P_EIDCLIENT_CARD_READER_HANDLE hCardReader, const char* const readerName); 51 | typedef ECARD_STATUS (*CardReaderClose_t)(EIDCLIENT_CARD_READER_HANDLE hCardReader); 52 | typedef ECARD_STATUS (*CardReaderSend_t)(EIDCLIENT_CARD_READER_HANDLE hCardReader, 53 | const unsigned char* const cardCommand, 54 | const unsigned long nLengthCardCommand, 55 | unsigned char* const result, 56 | unsigned long* const nLengthResult); 57 | typedef ECARD_STATUS (*CardReaderGetATR_t)(EIDCLIENT_CARD_READER_HANDLE hCardReader, 58 | unsigned char* const result, 59 | unsigned long* const nLengthResult); 60 | typedef ECARD_STATUS (*CardReaderSupportsPACE_t)(EIDCLIENT_CARD_READER_HANDLE hCardReader); 61 | typedef ECARD_STATUS (*CardReaderDoPACE_t)(EIDCLIENT_CARD_READER_HANDLE hCardReader, 62 | const enum PinID pinid, 63 | const nPADataBuffer_t *pin, 64 | const nPADataBuffer_t *chat, 65 | const nPADataBuffer_t *chat_required, 66 | const nPADataBuffer_t *chat_optional, 67 | const nPADataBuffer_t *certificate_description, 68 | const nPADataBuffer_t *transaction_info_hidden, 69 | unsigned int *result, 70 | unsigned short *status_mse_set_at, 71 | nPADataBuffer_t *ef_cardaccess, 72 | nPADataBuffer_t *car_curr, 73 | nPADataBuffer_t *car_prev, 74 | nPADataBuffer_t *id_icc, 75 | nPADataBuffer_t *chat_used); 76 | #if defined(__cplusplus) 77 | } 78 | #endif 79 | 80 | #endif // __EIDCLIENTCARDREADER_INCLUDE__ 81 | 82 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eCardCore/externalReader.def: -------------------------------------------------------------------------------- 1 | LIBRARY "externalReader" 2 | 3 | EXPORTS 4 | CardReaderOpen 5 | CardReaderClose 6 | CardReaderSend 7 | CardReaderGetATR 8 | CardReaderSupportsPACE 9 | CardReaderDoPACE 10 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eCardCore/externalReaderd.def: -------------------------------------------------------------------------------- 1 | LIBRARY "externalReaderd" 2 | 3 | EXPORTS 4 | CardReaderOpen 5 | CardReaderClose 6 | CardReaderSend 7 | CardReaderGetATR 8 | CardReaderSupportsPACE 9 | CardReaderDoPACE 10 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eCardCore/pace_reader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Bundesdruckerei GmbH 3 | */ 4 | 5 | #if !defined(__PACE_READER_INCLUDED__) 6 | #define __PACE_READER_INCLUDED__ 7 | 8 | #include "eCardCore/IReader.h" 9 | 10 | std::vector establishPACEChannel_getBuffer(const PaceInput &input); 11 | std::vector getReadersPACECapabilities_getBuffer(void); 12 | 13 | PaceOutput establishPACEChannel_parseBuffer(unsigned char *output, size_t output_length); 14 | 15 | bool getReadersPACECapabilities_supportsPACE(unsigned char *output, size_t output_length); 16 | bool getReadersPACECapabilities_supportsEID(unsigned char *output, size_t output_length); 17 | bool getReadersPACECapabilities_supportsSignature(unsigned char *output, size_t output_length); 18 | bool getReadersPACECapabilities_supportsDestroy(unsigned char *output, size_t output_length); 19 | 20 | 21 | #endif // #if !defined(__PACE_READER_INCLUDED__) 22 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eIDClientConnection/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0.2) 2 | 3 | add_library(eIDClientConnection SHARED eIDClientConnection.c socket.c) 4 | include_directories(../ ${CURL_INCLUDE_DIRS}) 5 | 6 | #TODO: Check, if the test cases can also work without these two flags 7 | add_definitions(-DSKIP_PEER_VERIFICATION -DSKIP_HOSTNAME_VERIFICATION) 8 | 9 | target_link_libraries(eIDClientConnection ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES}) 10 | install(TARGETS eIDClientConnection DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}) -------------------------------------------------------------------------------- /eIDClientCore/lib/eIDClientConnection/Makefile.am: -------------------------------------------------------------------------------- 1 | DEFS = eIDClientConnection.def 2 | EXPORTS = eIDClientConnection.exports 3 | 4 | EXTRA_DIST = $(DEFS) 5 | 6 | lib_LTLIBRARIES = libeIDClientConnection.la 7 | 8 | noinst_HEADERS = eIDClientConnection.h 9 | 10 | libeIDClientConnection_la_SOURCES = eIDClientConnection.c socket.c 11 | libeIDClientConnection_la_LIBADD = $(LIBCURL) $(OPENSSL_LIBS) 12 | libeIDClientConnection_la_LDFLAGS = $(AM_LDFLAGS) $(OPENSSL_LDFLAGS) 13 | libeIDClientConnection_la_CPPFLAGS = -I$(top_srcdir)/lib -DHAVE_CONFIG_H $(LIBCURL_CPPFLAGS) $(OPENSSL_INCLUDES) 14 | libeIDClientConnection_la_DEPENDENCIES = 15 | if WIN32 16 | libeIDClientConnection_la_LIBADD += -lws2_32 17 | libeIDClientConnection_la_LDFLAGS += -export-symbols $(EXPORTS) -no-undefined 18 | libeIDClientConnection_la_DEPENDENCIES += $(EXPORTS) 19 | endif 20 | 21 | $(EXPORTS): $(DEFS) 22 | cat $^ | grep -v LIBRARY | grep -v EXPORTS | grep eID > $@ 23 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eIDClientConnection/eIDClientConnection.def: -------------------------------------------------------------------------------- 1 | LIBRARY "eIDClientConnection" 2 | 3 | EXPORTS 4 | eIDClientConnectionStartRaw 5 | eIDClientConnectionStartHttp 6 | eIDClientConnectionEnd 7 | eIDClientConnectionTransceive 8 | eIDClientConnectionTransceivePAOS 9 | 10 | 11 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eIDClientConnection/eIDClientConnection.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Bundesdruckerei GmbH 3 | * 4 | * This Lib can only handle 1 Connection at a time 5 | * -> Its also not threadsafe 6 | * Reasons (so far): curl_global_init in Startfunctions, 7 | * global PSK and Identity Variables 8 | */ 9 | 10 | #if !defined(__EIDCLIENTCONNECTION_INCLUDED__) 11 | #define __EIDCLIENTCONNECTION_INCLUDED__ 12 | 13 | typedef void *EIDCLIENT_CONNECTION_HANDLE; 14 | typedef EIDCLIENT_CONNECTION_HANDLE *P_EIDCLIENT_CONNECTION_HANDLE; 15 | 16 | typedef unsigned long EID_CLIENT_CONNECTION_ERROR; 17 | #define EID_CLIENT_CONNECTION_INFO 0x41000000 18 | #define EID_CLIENT_CONNECTION_WARN 0x42000000 19 | #define EID_CLIENT_CONNECTION_ERRO 0x43000000 20 | 21 | #define EID_CLIENT_CONNECTION_ERROR_SUCCESS 0x00000000 22 | 23 | #define EID_CLIENT_CONNECTION_SOCKET_ERROR EID_CLIENT_CONNECTION_ERRO + 0x00000001 24 | #define EID_CLIENT_CONNECTION_TLS_HANDSHAKE_ERROR EID_CLIENT_CONNECTION_ERRO + 0x00000002 25 | #define EID_CLIENT_CONNECTION_WSA_STARTUP_FAILED EID_CLIENT_CONNECTION_ERRO + 0x00000003 26 | #define EID_CLIENT_CONNECTION_INVALID_HANDLE EID_CLIENT_CONNECTION_ERRO + 0x00000004 27 | #define EID_CLIENT_CONNECTION_DNS_ERROR EID_CLIENT_CONNECTION_ERRO + 0x00000005 28 | #define EID_CLIENT_CONNECTION_CURL_ERROR EID_CLIENT_CONNECTION_ERRO + 0x00000006 29 | #define EID_CLIENT_CONNECTION_MODE_ERROR EID_CLIENT_CONNECTION_ERRO + 0x00000007 30 | #define EID_CLIENT_CONNECTION_BUFF_TOO_SMALL_ERROR EID_CLIENT_CONNECTION_ERRO + 0x00010000 31 | 32 | enum HttpHeaderInclusion { 33 | DontGetHttpHeader = 0, 34 | GetHttpHeader = 1 35 | }; 36 | 37 | enum HttpRedirect { 38 | DontFollowHttpRedirect = 0, 39 | FollowHttpRedirect = 1 40 | }; 41 | 42 | #ifdef _WIN32 43 | #define EIDCC_COOKIE_FILE "%temp%\eidcc_cookie_file" 44 | #else 45 | #define EIDCC_COOKIE_FILE "/tmp/eidcc_cookie_file" 46 | #endif 47 | 48 | #if defined(__cplusplus) 49 | extern "C" 50 | { 51 | #endif 52 | 53 | /** 54 | * 55 | */ 56 | 57 | EID_CLIENT_CONNECTION_ERROR eIDClientConnectionStartRaw(P_EIDCLIENT_CONNECTION_HANDLE hConnection, const char *const hostname, const char *const port, const char *const sid, const char *const pskKey); 58 | 59 | /*After a successfull Call to eIDClientConnectionStartHttp you MUST call eIDClientConnectionEnd*/ 60 | EID_CLIENT_CONNECTION_ERROR eIDClientConnectionStartHttp(P_EIDCLIENT_CONNECTION_HANDLE hConnection, const char *const url, const char *const sid, const char *const pskKey, enum HttpHeaderInclusion includeHeader, enum HttpRedirect httpRedirect); 61 | 62 | EID_CLIENT_CONNECTION_ERROR eIDClientConnectionEnd(EIDCLIENT_CONNECTION_HANDLE hConnection); 63 | 64 | EID_CLIENT_CONNECTION_ERROR eIDClientConnectionTransceive(EIDCLIENT_CONNECTION_HANDLE hConnection, const char *const data, const size_t dataLength, char *const bufResult, size_t *nBufResultLength); 65 | 66 | /*Connection has to be established using eIDClientConnectionStartHttp*/ 67 | EID_CLIENT_CONNECTION_ERROR eIDClientConnectionTransceivePAOS(EIDCLIENT_CONNECTION_HANDLE hConnection, const char *const data, const size_t dataLength, char *const bufResult, size_t *nBufResultLength); 68 | 69 | typedef EID_CLIENT_CONNECTION_ERROR(*eIDClientConnectionRaw_t)(P_EIDCLIENT_CONNECTION_HANDLE, const char *const, const char *const, const char *const, const char *const); 70 | 71 | typedef EID_CLIENT_CONNECTION_ERROR(*eIDClientConnectionHttp_t)(P_EIDCLIENT_CONNECTION_HANDLE, const char *const, const char *const, const char *const, enum HttpHeaderInclusion, enum HttpRedirect); 72 | 73 | typedef EID_CLIENT_CONNECTION_ERROR(*eIDClientConnectionEnd_t)(EIDCLIENT_CONNECTION_HANDLE); 74 | 75 | typedef EID_CLIENT_CONNECTION_ERROR(*eIDClientConnectionTransceive_t)(EIDCLIENT_CONNECTION_HANDLE, const char *const, const size_t, char *const, size_t *); 76 | 77 | typedef EID_CLIENT_CONNECTION_ERROR(*eIDClientConnectionTransceivePAOS_t)(EIDCLIENT_CONNECTION_HANDLE, const char *const, const size_t, char *const, size_t *); 78 | 79 | #if defined(__cplusplus) 80 | } 81 | #endif 82 | 83 | #endif // #if !defined(__EIDCLIENTCONNECTION_INCLUDED__) 84 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eIDClientConnection/eIDClientConnectiond.def: -------------------------------------------------------------------------------- 1 | LIBRARY "eIDClientConnectiond" 2 | 3 | EXPORTS 4 | eIDClientConnectionStartRaw 5 | eIDClientConnectionStartHttp 6 | eIDClientConnectionEnd 7 | eIDClientConnectionTransceive 8 | eIDClientConnectionTransceivePAOS 9 | 10 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eIDClientConnection/socket.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Bundesdruckerei GmbH 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #ifdef _WIN32 10 | #include 11 | #include 12 | #pragma comment(lib, "ws2_32") 13 | #else 14 | #include 15 | #include 16 | #include 17 | #include 18 | #endif 19 | 20 | #ifndef SHUT_RDWR 21 | #define SHUT_RDWR SD_BOTH 22 | #endif 23 | 24 | int my_closesocket(int s) 25 | { 26 | if (0 != shutdown(s, SHUT_RDWR)) 27 | return -1; 28 | 29 | #ifdef _WIN32 30 | return closesocket(s); 31 | #else 32 | return close(s); 33 | #endif 34 | } 35 | 36 | int my_connectsocket(const char *const hostname, const char *const port) 37 | { 38 | struct addrinfo hints, *res, *cur_res; 39 | int fd = -1, err; 40 | #ifdef _WIN32 41 | WSADATA info; 42 | 43 | if (WSAStartup(MAKEWORD(2, 2), &info)) { 44 | fprintf(stderr, "Error initializing Winsock.\n"); 45 | } 46 | 47 | #endif 48 | memset(&hints, 0, sizeof(hints)); 49 | hints.ai_family = AF_UNSPEC; /* Allow IPv4 or IPv6 */ 50 | hints.ai_socktype = SOCK_STREAM; /* Stream socket */ 51 | err = getaddrinfo(hostname, port, &hints, &res); 52 | 53 | if (err != 0) { 54 | fprintf(stderr, "Cannot connect to %s:%s: %s\n", hostname, port, gai_strerror(err)); 55 | return fd; 56 | } 57 | 58 | /* getaddrinfo() returns a list of address structures. Try each address 59 | * until we successfully connect(2). If socket(2) (or connect(2)) fails, 60 | * we (close the socket and) try the next address. */ 61 | for (cur_res = res; cur_res != NULL; cur_res = cur_res->ai_next) { 62 | fd = socket(cur_res->ai_family, cur_res->ai_socktype, cur_res->ai_protocol); 63 | 64 | if (fd == -1) 65 | continue; 66 | 67 | if (connect(fd, cur_res->ai_addr, cur_res->ai_addrlen) != -1) 68 | break; 69 | 70 | my_closesocket(fd); 71 | } 72 | 73 | if (fd == -1) { 74 | fprintf(stderr, "Cannot connect to %s:%s: %s\n", hostname, port, strerror(errno)); 75 | } 76 | 77 | freeaddrinfo(res); 78 | return fd; 79 | } 80 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eIDClientCore/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0.2) 2 | 3 | add_library(eIDClientCore SHARED eIDClientCore.cpp eIDUtils.cpp eIDECardClientPAOS.cpp ../debug.c ../testing.c) 4 | include_directories(${CRYPTO++_INCLUDE_DIR}/.. ../ ../eIDClientConnection ${LIBEIDASN1_BINARY_DIR} ../eidasn1) 5 | 6 | target_link_libraries(eIDClientCore ${EXPAT_LIBRARIES} ${CRYPTO++_LIBRARIES} eCardCore eIDClientConnection eidasn1 nPA-EAC) 7 | install(TARGETS eIDClientCore DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}) -------------------------------------------------------------------------------- /eIDClientCore/lib/eIDClientCore/Makefile.am: -------------------------------------------------------------------------------- 1 | lib_LTLIBRARIES = libeIDClientCore.la 2 | 3 | noinst_HEADERS = eIDClientCore.h eIDUtils.h eIDECardClientPAOS.h 4 | 5 | libeIDClientCore_la_SOURCES = eIDClientCore.cpp eIDUtils.cpp eIDECardClientPAOS.cpp $(srcdir)/../debug.c $(srcdir)/../testing.c 6 | libeIDClientCore_la_LIBADD = $(EXPAT_LIBS) $(CRYPTOPP_LIBS) \ 7 | $(top_builddir)/lib/eCardCore/libeCardCore.la \ 8 | $(top_builddir)/lib/eIDClientConnection/libeIDClientConnection.la \ 9 | $(top_builddir)/lib/eidasn1/libeidasn1.la \ 10 | $(top_builddir)/lib/nPA-EAC/libnPA-EAC.la 11 | libeIDClientCore_la_CPPFLAGS = $(EXPAT_CFLAGS) $(CRYPTOPP_CFLAGS) \ 12 | -I$(top_srcdir)/lib \ 13 | -I$(top_srcdir)/lib/eIDClientConnection \ 14 | -I$(top_srcdir)/lib/eidasn1 15 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eIDClientCore/eIDClientCore.def: -------------------------------------------------------------------------------- 1 | LIBRARY "eIdClientCore" 2 | 3 | EXPORTS 4 | nPAeIdPerformAuthenticationProtocol 5 | encode_EstablishPACEChannelInput 6 | decode_EstablishPACEChannelOutput 7 | USED_DEBUG_LEVEL 8 | _hexdump 9 | _eCardCore_info 10 | _eCardCore_warn 11 | _eCardCore_debug 12 | CANCEL_AFTER_PAOS_CONNECTION_ESTABLISHMENT 13 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eIDClientCore/eIDClientCored.def: -------------------------------------------------------------------------------- 1 | LIBRARY "eIdClientCored" 2 | 3 | EXPORTS 4 | nPAeIdPerformAuthenticationProtocol 5 | encode_EstablishPACEChannelInput 6 | decode_EstablishPACEChannelOutput 7 | USED_DEBUG_LEVEL 8 | _hexdump 9 | _eCardCore_info 10 | _eCardCore_warn 11 | _eCardCore_debug 12 | CANCEL_AFTER_PAOS_CONNECTION_ESTABLISHMENT 13 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eIDClientCore/eIDUtils.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Bundesdruckerei GmbH 3 | */ 4 | 5 | #include "eIDUtils.h" 6 | using namespace Bundesdruckerei::eIDUtils; 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | #if defined(WIN32) 14 | # include 15 | #else 16 | #include 17 | #endif 18 | 19 | #if !defined(WIN32) 20 | 21 | // _itoa isn't standard compliant :( I think to define _itoa is the best way to 22 | // solve this problem. 23 | char *_itoa(int value, char *str, int base) 24 | { 25 | switch (base) { 26 | case 8: 27 | sprintf(str, "%o", value); 28 | break; 29 | case 10: 30 | sprintf(str, "%d", value); 31 | break; 32 | case 16: 33 | sprintf(str, "%x", value); 34 | break; 35 | } 36 | 37 | return str; 38 | } 39 | 40 | #endif 41 | 42 | std::string BDRDate::fromBCD( 43 | const std::vector& data) 44 | { 45 | char tempVal[2]; 46 | std::string retValue; 47 | std::vector internalData(data); 48 | _itoa(internalData[4], (char *) &tempVal, 10); 49 | retValue += tempVal; 50 | _itoa(internalData[5], (char *) &tempVal, 10); 51 | retValue += tempVal; 52 | retValue += "."; 53 | _itoa(internalData[2], (char *) &tempVal, 10); 54 | retValue += tempVal; 55 | _itoa(internalData[3], (char *) &tempVal, 10); 56 | retValue += tempVal; 57 | retValue += "."; 58 | retValue += "20"; 59 | _itoa(internalData[0], (char *) &tempVal, 10); 60 | retValue += tempVal; 61 | _itoa(internalData[1], (char *) &tempVal, 10); 62 | retValue += tempVal; 63 | return retValue; 64 | } 65 | 66 | time_t BDRDate::timeFromBCD( 67 | const std::vector& data) 68 | { 69 | std::vector internalData(data); 70 | struct tm tmReturn; 71 | char buf[5]; 72 | int tempValue = 0; 73 | tempValue = internalData[4] << 4; 74 | tempValue += internalData[5]; 75 | sprintf(buf, "%02x", tempValue); 76 | tmReturn.tm_mday = atoi(buf); 77 | tempValue = internalData[2] << 4; 78 | tempValue += internalData[3]; 79 | sprintf(buf, "%02x", tempValue); 80 | tmReturn.tm_mon = atoi(buf) - 1; 81 | tempValue = internalData[0] << 4; 82 | tempValue += internalData[1]; 83 | sprintf(buf, "20%02x", tempValue); 84 | tmReturn.tm_year = atoi(buf) - 1900; 85 | tmReturn.tm_hour = 0; 86 | tmReturn.tm_isdst = 0; 87 | tmReturn.tm_min = 0; 88 | tmReturn.tm_sec = 0; 89 | tmReturn.tm_wday = 0; 90 | tmReturn.tm_yday = 0; 91 | return mktime(&tmReturn); 92 | } 93 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eIDClientCore/eIDUtils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Bundesdruckerei GmbH 3 | */ 4 | 5 | #if !defined(__EIDUTILS__) 6 | #define __EIDUTILS__ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | namespace Bundesdruckerei 14 | { 15 | namespace eIDUtils 16 | { 17 | 18 | /* 19 | * @class BDRDate 20 | * 21 | */ 22 | class BDRDate 23 | { 24 | public: 25 | static std::string fromBCD( 26 | const std::vector&); 27 | 28 | static time_t timeFromBCD( 29 | const std::vector&); 30 | }; 31 | } 32 | } 33 | 34 | #endif // __EIDUTILS__ 35 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eIDClientCore/nPAClientProtocol.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Bundesdruckerei GmbH 3 | */ 4 | 5 | #include "eCardCore/eCardStatus.h" 6 | #include "nPAClientProtocol.h" 7 | #include 8 | 9 | /** 10 | */ 11 | ePAClientProtocol::ePAClientProtocol( 12 | ICard *hCard) : m_hCard(hCard) 13 | { 14 | } 15 | 16 | ePAClientProtocol::~ePAClientProtocol( 17 | void) 18 | { 19 | } 20 | 21 | /** 22 | */ 23 | ECARD_STATUS ePAClientProtocol::PACE( 24 | const PaceInput &pace_input) 25 | { 26 | ECARD_STATUS status_ = ECARD_SUCCESS; 27 | // Setup output variables 28 | std::vector car_cvca_; 29 | 30 | if (!m_hCard) 31 | return ECARD_ERROR; 32 | 33 | // Try to get ePA card 34 | ePACard &ePA_ = dynamic_cast(*m_hCard); 35 | 36 | // Run the PACE protocol. 37 | if (ECARD_SUCCESS != (status_ = ePAPerformPACE(ePA_, pace_input, 38 | car_cvca_, m_idPICC, m_ca_oid))) 39 | return status_; 40 | 41 | // Copy the PACE results for further usage. 42 | m_carCVCA = std::string(car_cvca_.begin(), car_cvca_.end()); 43 | 44 | return ECARD_SUCCESS; 45 | } 46 | 47 | /** 48 | */ 49 | ECARD_STATUS ePAClientProtocol::TerminalAuthentication( 50 | const std::vector >& list_certificates, 51 | const std::vector& terminalCertificate, 52 | const std::vector& PuK_IFD_DH_CA, 53 | const std::vector& authenticatedAuxiliaryData, 54 | std::vector& toBeSigned) 55 | { 56 | std::vector carCVCA_; 57 | carCVCA_ = std::vector (m_carCVCA.begin(), m_carCVCA.end()); 58 | 59 | if (!m_hCard) 60 | return ECARD_ERROR; 61 | 62 | // Try to get ePA card 63 | ePACard &ePA_ = dynamic_cast(*m_hCard); 64 | 65 | // Run the CA protocol. 66 | return ePAPerformTA(ePA_, carCVCA_, list_certificates, terminalCertificate, 67 | m_ca_oid, PuK_IFD_DH_CA, authenticatedAuxiliaryData, toBeSigned); 68 | } 69 | 70 | /** 71 | */ 72 | ECARD_STATUS ePAClientProtocol::SendSignature( 73 | const std::vector& signature) 74 | { 75 | if (!m_hCard) 76 | return ECARD_ERROR; 77 | 78 | return ePASendSignature(*m_hCard, signature); 79 | } 80 | 81 | /** 82 | */ 83 | ECARD_STATUS ePAClientProtocol::ChipAuthentication( 84 | const std::vector& Puk_IFD_DH, 85 | std::vector& GeneralAuthenticationResult) 86 | { 87 | ECARD_STATUS status_ = ECARD_SUCCESS; 88 | 89 | if (!m_hCard) 90 | return ECARD_ERROR; 91 | 92 | if (ECARD_SUCCESS != (status_ = ePAPerformCA(*m_hCard, m_ca_oid, Puk_IFD_DH, GeneralAuthenticationResult))) 93 | return status_; 94 | 95 | return ECARD_SUCCESS; 96 | } 97 | 98 | ECARD_STATUS ePAClientProtocol::GetIDPICC( 99 | std::vector& idPICC) 100 | { 101 | idPICC = m_idPICC; 102 | return ECARD_SUCCESS; 103 | } 104 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eIDClientCore/nPAClientProtocol.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Bundesdruckerei GmbH 3 | */ 4 | 5 | #if !defined(__EPACLIENTPROTOCOL_INCLUDED__) 6 | #define __EPACLIENTPROTOCOL_INCLUDED__ 7 | 8 | #include 9 | #include 10 | 11 | #include "eCardCore/ICard.h" 12 | #include "eCardCore/eCardStatus.h" 13 | #include "nPA-EAC/nPAAPI.h" 14 | 15 | /** 16 | */ 17 | class ePAClientProtocol 18 | { 19 | private: 20 | /** Handle to a valid ePA card */ 21 | ICard *m_hCard; 22 | /** X part of Puk_ICC_DH2 after PACE */ 23 | std::vector m_idPICC; 24 | /** CAR of the CVCA for TA after PACE */ 25 | std::string m_carCVCA; 26 | /** Authenticated auxiliary data */ 27 | std::vector authenticatedAuxiliaryData; 28 | std::vector m_ca_oid; 29 | 30 | // No copy 31 | ePAClientProtocol( 32 | const ePAClientProtocol &); 33 | 34 | ePAClientProtocol &operator=( 35 | const ePAClientProtocol &); 36 | 37 | public: 38 | /*! 39 | * ctor 40 | * 41 | * @param hCard Handle to an ePA card 42 | */ 43 | ePAClientProtocol( 44 | ICard *hCard); 45 | 46 | ~ePAClientProtocol( 47 | void); 48 | 49 | /** 50 | * @brief Perform the PACE protocol. 51 | */ 52 | ECARD_STATUS PACE( 53 | const PaceInput &pace_input); 54 | 55 | /** 56 | * @brief Perform the terminal authentication. 57 | * 58 | * @param dvCertificate The DVCA certificate. 59 | * @param terminalCertificate The certificate of the terminal. 60 | * @param toBeSigned The data which will be signed by the eID server. 61 | */ 62 | ECARD_STATUS TerminalAuthentication( 63 | const std::vector >& list_certificates, 64 | const std::vector& terminalCertificate, 65 | const std::vector& PuK_IFD_DH_CA, 66 | const std::vector& authenticatedAuxiliaryData, 67 | std::vector& toBeSigned); 68 | 69 | /** 70 | * @brief Send the signature, created by the eID server, to the chip. 71 | * 72 | * @param signature The signature data. 73 | */ 74 | ECARD_STATUS SendSignature( 75 | const std::vector& signature); 76 | 77 | /** 78 | * @brief Perform the chip authentication. 79 | */ 80 | ECARD_STATUS ChipAuthentication( 81 | const std::vector& Puk_IFD_DH, 82 | std::vector& GeneralAuthenticationResult); 83 | 84 | /** 85 | * @brief Get the IDPICC. 86 | */ 87 | ECARD_STATUS GetIDPICC( 88 | std::vector& idPICC); 89 | 90 | std::string GetCARCVCA() { 91 | return m_carCVCA; 92 | } 93 | }; // class ePAClientProtocol 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eidasn1/.gitignore: -------------------------------------------------------------------------------- 1 | # generated files 2 | *.c 3 | *.h 4 | Makefile.am.sample 5 | # except 6 | !GeneralizedTime-putenv.c 7 | !eIDHelper.h 8 | !eIDOID.h 9 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eidasn1/eIDHelper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Bundesdruckerei GmbH 3 | */ 4 | 5 | #if !defined(__EIDHELPER_INCLUDED__) 6 | #define __EIDHELPER_INCLUDED__ 7 | 8 | #include"OBJECT_IDENTIFIER.h" 9 | 10 | inline bool operator==(const OBJECT_IDENTIFIER_t a, const OBJECT_IDENTIFIER_t b) 11 | { 12 | return a.size == b.size && 0 == memcmp(a.buf, b.buf, b.size); 13 | } 14 | 15 | inline bool operator!=(const OBJECT_IDENTIFIER_t a, const OBJECT_IDENTIFIER_t b) 16 | { 17 | return !(a == b); 18 | } 19 | 20 | inline bool operator<(const OBJECT_IDENTIFIER_t a, const OBJECT_IDENTIFIER_t b) 21 | { 22 | return a.size < b.size && 0 == memcmp(a.buf, b.buf, a.size); 23 | } 24 | 25 | inline bool operator>(const OBJECT_IDENTIFIER_t a, const OBJECT_IDENTIFIER_t b) 26 | { 27 | return !(a < b) && a != b; 28 | } 29 | 30 | inline bool operator>=(const OBJECT_IDENTIFIER_t a, const OBJECT_IDENTIFIER_t b) 31 | { 32 | return a > b || a == b; 33 | } 34 | 35 | inline bool operator<=(const OBJECT_IDENTIFIER_t a, const OBJECT_IDENTIFIER_t b) 36 | { 37 | return a < b || a == b; 38 | } 39 | 40 | inline OBJECT_IDENTIFIER_t makeOID(const char *oidValue) 41 | { 42 | long tempArcs[1]; 43 | long *tempArcs2 = 0x00; 44 | long *realArcs = 0x00; 45 | int realLength = OBJECT_IDENTIFIER_parse_arcs(oidValue, -1, tempArcs, 1, 0x00); 46 | 47 | if (realLength > 1) { 48 | tempArcs2 = new long[realLength]; 49 | OBJECT_IDENTIFIER_parse_arcs(oidValue, -1, tempArcs2, realLength, 0x00); 50 | realArcs = tempArcs2; 51 | 52 | } else { 53 | realArcs = &tempArcs[0]; // This should never be happen ... 54 | } 55 | 56 | OBJECT_IDENTIFIER_t oid; 57 | oid.buf = 0x00; 58 | oid.size = 0; 59 | OBJECT_IDENTIFIER_set_arcs(&oid, realArcs, sizeof(unsigned long), realLength); 60 | 61 | if (0x00 != tempArcs2) 62 | delete [] tempArcs2; 63 | 64 | return oid; 65 | } 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /eIDClientCore/lib/eidasn1/eIDOID.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Bundesdruckerei GmbH 3 | */ 4 | 5 | #if !defined(__EIDOID_INCLUDED__) 6 | #define __EIDOID_INCLUDED__ 7 | 8 | #define bsi_de "0.4.0.127.0.7" 9 | 10 | #define id_STANDARDIZED_DP bsi_de ".1.2" 11 | 12 | #define id_PACE bsi_de ".2.2.4" 13 | #define id_PACE_DH id_PACE ".1" 14 | #define id_PACE_DH_3DES_CBC_CBC id_PACE_DH ".1" 15 | #define id_PACE_DH_AES_CBC_CMAC_128 id_PACE_DH ".2" 16 | #define id_PACE_DH_AES_CBC_CMAC_192 id_PACE_DH ".3" 17 | #define id_PACE_DH_AES_CBC_CMAC_256 id_PACE_DH ".4" 18 | #define id_PACE_ECDH id_PACE ".2" 19 | #define id_PACE_ECDH_3DES_CBC_CBC id_PACE_ECDH ".1" 20 | #define id_PACE_ECDH_AES_CBC_CMAC_128 id_PACE_ECDH ".2" 21 | #define id_PACE_ECDH_AES_CBC_CMAC_192 id_PACE_ECDH ".3" 22 | #define id_PACE_ECDH_AES_CBC_CMAC_256 id_PACE_ECDH ".4" 23 | 24 | #define id_TA bsi_de ".2.2.2" 25 | #define id_TA_ECDSA id_TA ".2" 26 | #define id_TA_ECDSA_SHA_1 id_TA_ECDSA ".1" 27 | #define id_TA_ECDSA_SHA_224 id_TA_ECDSA ".2" 28 | #define id_TA_ECDSA_SHA_256 id_TA_ECDSA ".3" 29 | 30 | #define id_CA bsi_de ".2.2.3" 31 | #define id_CA_ECDH id_CA ".2" 32 | #define id_CA_ECDH_3DES_CBC_CBC id_CA_ECDH ".1" 33 | #define id_CA_ECDH_AES_CBC_CMAC_128 id_CA_ECDH ".2" 34 | #define id_CA_ECDH_AES_CBC_CMAC_192 id_CA_ECDH ".3" 35 | #define id_CA_ECDH_AES_CBC_CMAC_256 id_CA_ECDH ".4" 36 | #define id_CA_DH id_CA ".1" 37 | #define id_CA_DH_3DES_CBC_CBC id_CA_DH ".1" 38 | #define id_CA_DH_AES_CBC_CMAC_128 id_CA_DH ".2" 39 | #define id_CA_DH_AES_CBC_CMAC_192 id_CA_DH ".3" 40 | #define id_CA_DH_AES_CBC_CMAC_256 id_CA_DH ".4" 41 | 42 | #define id_PK bsi_de ".2.2.1" 43 | #define id_PK_ECDH id_PK ".2" 44 | #define id_PK_DH id_PK ".1" 45 | 46 | #define id_RI_ECDH bsi_de ".2.2.5.2" 47 | 48 | #define id_CI bsi_de ".2.2.6" 49 | 50 | #define id_AUXILIARY_DATA bsi_de ".3.1.4" 51 | #define id_AUXILIARY_DATA_DATE_OF_BIRTH id_AUXILIARY_DATA ".1" 52 | #define id_AUXILIARY_DATA_DATE_OF_EXPIARY id_AUXILIARY_DATA ".2" 53 | #define id_AUXILIARY_DATA_COMMUNITY_ID id_AUXILIARY_DATA ".3" 54 | 55 | #define id_ROLES bsi_de ".3.1.2" 56 | #define id_IS id_ROLES ".1" 57 | #define id_AT id_ROLES ".2" 58 | #define id_ST id_ROLES ".3" 59 | 60 | #define id_ECDSA_WITH_SHA224 "1.2.840.10045.4.3.1" 61 | #define id_ECDSA_WITH_SHA256 "1.2.840.10045.4.3.2" 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /eIDClientCore/lib/loadlib.h: -------------------------------------------------------------------------------- 1 | #if defined(WIN32) 2 | # include 3 | # include 4 | # define LOAD_LIBRARY(libName) LoadLibrary(_T(libName)) 5 | # define GET_FUNCTION(hModule, funcName) GetProcAddress((HMODULE) hModule, #funcName) 6 | # define FREE_LIBRARY(hModule) FreeLibrary((HMODULE) hModule) 7 | #elif defined(__APPLE__) && (TARGET_OS_IPHONE == 1) 8 | # include 9 | # define LOAD_LIBRARY(libName) 1 10 | # define GET_FUNCTION(hModule, funcName) funcName 11 | # define FREE_LIBRARY(hModule) 12 | #else 13 | # include 14 | # define LOAD_LIBRARY(libName) dlopen(libName, RTLD_LAZY) 15 | # define GET_FUNCTION(hModule, funcName) dlsym(hModule, #funcName) 16 | # define FREE_LIBRARY(hModule) dlclose(hModule) 17 | #endif 18 | -------------------------------------------------------------------------------- /eIDClientCore/lib/nPA-EAC/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0.2) 2 | 3 | include_directories(${CRYPTO++_INCLUDE_DIR}/.. ../ ../eidasn1) 4 | include_directories(${LIBEIDASN1_BINARY_DIR}) 5 | 6 | set(NPA-EAC_SOURCES nPA_CA.cpp nPACard.cpp nPACommon.cpp nPA_PACE.cpp nPA_TA.cpp) 7 | add_library(nPA-EAC SHARED ${NPA-EAC_SOURCES}) 8 | 9 | if(CRYPTO++_LIBRARIES) 10 | target_link_libraries(nPA-EAC ${CRYPTO++_LIBRARIES}) 11 | endif() 12 | 13 | install(TARGETS nPA-EAC DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}) -------------------------------------------------------------------------------- /eIDClientCore/lib/nPA-EAC/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libnPA-EAC.la 2 | 3 | noinst_HEADERS = nPAAPI.h nPACard.h nPACommon.h nPAStatus.h 4 | 5 | libnPA_EAC_la_SOURCES = nPA_CA.cpp nPACard.cpp nPACommon.cpp nPA_PACE.cpp nPA_TA.cpp 6 | libnPA_EAC_la_LIBADD = $(CRYPTOPP_LIBS) 7 | libnPA_EAC_la_CPPFLAGS = $(CRYPTOPP_CFLAGS) \ 8 | -I$(top_srcdir)/lib \ 9 | -I$(top_srcdir)/lib/eidasn1 10 | -------------------------------------------------------------------------------- /eIDClientCore/lib/nPA-EAC/nPACard.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Bundesdruckerei GmbH 3 | */ 4 | 5 | #if !defined(__NPACARD_INCLUDED__) 6 | #define __NPACARD_INCLUDED__ 7 | 8 | #include "eCardCore/ICard.h" 9 | #include "eCardCore/ICardDetector.h" 10 | 11 | class ePACard : public ICard, BatchTransceiver 12 | { 13 | public: 14 | std::vector m_kEnc; 15 | std::vector m_kMac; 16 | std::vector m_ef_cardaccess; 17 | std::vector m_ef_cardsecurity; 18 | unsigned long long m_ssc; 19 | 20 | static const unsigned short FID_EF_CARDACCESS = 0x011C; 21 | static const unsigned short FID_EF_CARDSECURITY = 0x011D; 22 | static const unsigned char SFID_EF_CARDACCESS = 0x1C; 23 | static const unsigned char SFID_EF_CARDSECURITY = 0x1D; 24 | 25 | static const unsigned short FID_DG1 = 0x0101; 26 | static const unsigned short FID_DG2 = 0x0102; 27 | static const unsigned short FID_DG3 = 0x0103; 28 | static const unsigned short FID_DG4 = 0x0104; 29 | static const unsigned short FID_DG5 = 0x0105; 30 | static const unsigned short FID_DG6 = 0x0106; 31 | static const unsigned short FID_DG7 = 0x0107; 32 | static const unsigned short FID_DG8 = 0x0108; 33 | static const unsigned short FID_DG9 = 0x0109; 34 | static const unsigned short FID_DG10 = 0x010A; 35 | static const unsigned short FID_DG11 = 0x010B; 36 | static const unsigned short FID_DG12 = 0x010C; 37 | static const unsigned short FID_DG13 = 0x010D; 38 | static const unsigned short FID_DG14 = 0x010E; 39 | static const unsigned short FID_DG15 = 0x010F; 40 | static const unsigned short FID_DG16 = 0x0111; 41 | static const unsigned short FID_DG17 = 0x0112; 42 | static const unsigned short FID_DG18 = 0x0113; 43 | static const unsigned short FID_DG19 = 0x0114; 44 | static const unsigned short FID_DG20 = 0x0115; 45 | static const unsigned short FID_DG21 = 0x0116; 46 | 47 | static const unsigned char SFID_DG1 = 0x01; 48 | static const unsigned char SFID_DG2 = 0x02; 49 | static const unsigned char SFID_DG3 = 0x03; 50 | static const unsigned char SFID_DG4 = 0x04; 51 | static const unsigned char SFID_DG5 = 0x05; 52 | static const unsigned char SFID_DG6 = 0x06; 53 | static const unsigned char SFID_DG7 = 0x07; 54 | static const unsigned char SFID_DG8 = 0x08; 55 | static const unsigned char SFID_DG9 = 0x09; 56 | static const unsigned char SFID_DG10 = 0x0A; 57 | static const unsigned char SFID_DG11 = 0x0B; 58 | static const unsigned char SFID_DG12 = 0x0C; 59 | static const unsigned char SFID_DG13 = 0x0D; 60 | static const unsigned char SFID_DG14 = 0x0E; 61 | static const unsigned char SFID_DG15 = 0x0F; 62 | static const unsigned char SFID_DG16 = 0x10; 63 | static const unsigned char SFID_DG17 = 0x11; 64 | static const unsigned char SFID_DG18 = 0x12; 65 | static const unsigned char SFID_DG19 = 0x13; 66 | static const unsigned char SFID_DG20 = 0x14; 67 | static const unsigned char SFID_DG21 = 0x15; 68 | 69 | ePACard(IReader *); 70 | 71 | ePACard(IReader *, const std::vector ef_cardaccess); 72 | 73 | CAPDU applySM(const CAPDU &apdu); 74 | RAPDU removeSM(const RAPDU &apdu); 75 | 76 | std::string getCardDescription(void); 77 | 78 | const std::vector& get_ef_cardaccess(void) const; 79 | const std::vector& get_ef_cardsecurity(void); 80 | 81 | RAPDU receive(void); 82 | std::vector receive(size_t count); 83 | 84 | void send(const CAPDU &cmd); 85 | void send(const std::vector &cmds); 86 | 87 | RAPDU transceive(const CAPDU& cmd); 88 | std::vector transceive(const std::vector& cmds); 89 | 90 | void setKeys(const std::vector& kEnc, const std::vector& kMac); 91 | void setSSC(unsigned long long ssc); 92 | }; 93 | 94 | 95 | class ePACardDetector : public ICardDetector 96 | { 97 | public: 98 | ICard *getCard(IReader *); 99 | }; // class ePACardDetector : public ICardDetector 100 | 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /eIDClientCore/lib/nPA-EAC/nPACommon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Bundesdruckerei GmbH 3 | */ 4 | 5 | #if !defined(__NPACOMMON_INCLUDED__) 6 | #define __NPACOMMON_INCLUDED__ 7 | 8 | #include "../crypto.h" 9 | 10 | #include 11 | #include 12 | 13 | /** 14 | */ 15 | std::vector calculateMAC( 16 | const std::vector& toBeMaced, 17 | const std::vector& kMac); 18 | 19 | /** 20 | * 21 | */ 22 | std::vector getCAR( 23 | const std::vector& certificate); 24 | 25 | /** 26 | * 27 | */ 28 | std::vector getCHR( 29 | const std::vector& certificate); 30 | 31 | std::vector generate_PrK_IFD_DHx(uint8_t standardizedDP); 32 | 33 | std::vector calculate_PuK_IFD_DH1( 34 | uint8_t standardizedDP, 35 | const std::vector& PrK_IFD_DH1); 36 | 37 | std::vector calculate_SMKeys( std::vector input, bool generateMac); 38 | 39 | std::vector generate_compressed_PuK( 40 | const OBJECT_IDENTIFIER_t &OID_, 41 | const std::vector &PuK_IFD_DH2); 42 | 43 | ECP::Point vector2point(const std::vector &v); 44 | std::vector point2vector(const ECP::Point &p, int curveLength); 45 | std::vector get_y(const std::vector &v); 46 | std::vector get_x(const std::vector &v); 47 | 48 | std::vector TLV_encode(unsigned int tag, const std::vector &data); 49 | std::vector TLV_decode(const std::vector &tlv, 50 | unsigned int *tag, std::vector &data); 51 | 52 | std::vector calculate_KIFD_ICC( 53 | const OBJECT_IDENTIFIER_t &OID_, 54 | const std::vector& PrK_IFD_DH2, 55 | const std::vector& PuK_ICC_DH2); 56 | std::vector calculate_ID_ICC(const std::vector& PuK_ICC_DH2); 57 | 58 | DH get_std_dp_0(void); 59 | 60 | char* my_itoa ( int value, char * str, int base ); 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /eIDClientCore/lib/nPA-EAC/nPAStatus.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Bundesdruckerei GmbH 3 | */ 4 | 5 | #if !defined(__NPASTATUS_INCLUDED__) 6 | #define __NPASTATUS_INCLUDED__ 7 | 8 | #define EAC_INFO 0x21000000 9 | #define EAC_WARNING 0x22000000 10 | #define EAC_ERROR 0x23000000 11 | 12 | #define EAC_SUCCESS 0x00000000 13 | #define EAC_INVALID_EPA EAC_ERROR + 0x001 14 | 15 | // PACE related errors 16 | #define EAC_EFCARDACCESS_PARSER_ERROR EAC_ERROR + 0x002 17 | #define EAC_PACE_STEP_B_FAILED EAC_ERROR + 0x003 18 | #define EAC_PACE_STEP_C_FAILED EAC_ERROR + 0x004 19 | #define EAC_PACE_STEP_C_DECRYPTION_FAILED EAC_ERROR + 0x005 20 | #define EAC_PACE_STEP_D_FAILED EAC_ERROR + 0x006 21 | #define EAC_PACE_STEP_E_FAILED EAC_ERROR + 0x007 22 | #define EAC_PACE_STEP_F_FAILED EAC_ERROR + 0x008 23 | #define EAC_PACE_STEP_F_VERIFICATION_FAILED EAC_ERROR + 0x009 24 | 25 | // Terminal Authentication related errors 26 | #define EAC_TA_STEP_A_FAILED EAC_ERROR + 0x00A 27 | #define EAC_TA_STEP_A_VERIFY_FAILED EAC_ERROR + 0x00B 28 | #define EAC_TA_STEP_B_FAILED EAC_ERROR + 0x00C 29 | #define EAC_TA_STEP_B_INVALID_CERTIFCATE_FORMAT EAC_ERROR + 0x00D 30 | #define EAC_TA_STEP_B_VERIFY_FAILED EAC_ERROR + 0x00E 31 | #define EAC_TA_STEP_C_FAILED EAC_ERROR + 0x00F 32 | #define EAC_TA_STEP_C_VERIFY_FAILED EAC_ERROR + 0x010 33 | #define EAC_TA_STEP_D_FAILED EAC_ERROR + 0x011 34 | #define EAC_TA_STEP_D_VERIFY_FAILED EAC_ERROR + 0x012 35 | #define EAC_TA_STEP_D_INVALID_CERTIFCATE_FORMAT EAC_ERROR + 0x013 36 | #define EAC_TA_STEP_E_FAILED EAC_ERROR + 0x014 37 | #define EAC_TA_STEP_E_VERIFY_FAILED EAC_ERROR + 0x015 38 | #define EAC_TA_STEP_F_FAILED EAC_ERROR + 0x016 39 | #define EAC_TA_STEP_F_VERIFY_FAILED EAC_ERROR + 0x017 40 | #define EAC_TA_STEP_G_FAILED EAC_ERROR + 0x018 41 | #define EAC_TA_STEP_G_VERIFY_FAILED EAC_ERROR + 0x019 42 | 43 | // Chip Authentication related errors 44 | #define EAC_CA_STEP_B_FAILED EAC_ERROR + 0x01A 45 | #define EAC_CA_STEP_B_VERIFY_FAILED EAC_ERROR + 0x01B 46 | #define EAC_EFCARDSECURYITY_PARSER_ERROR EAC_ERROR + 0x01C 47 | #define EAC_VERIFY_RESPONSE_FAILED EAC_ERROR + 0x01D 48 | 49 | // PIN Management related errors 50 | #define EAC_CHANGE_PIN_FAILED EAC_ERROR + 0x020 51 | #define EAC_PIN_DEACTIVATED EAC_ERROR + 0x021 52 | #define EAC_CAN_REQUIRED EAC_ERROR + 0x022 53 | #define EAC_PIN_FIRST_FAIL EAC_ERROR + 0x023 54 | #define EAC_PIN_SECOND_FAIL EAC_ERROR + 0x024 55 | #endif 56 | -------------------------------------------------------------------------------- /eIDClientCore/lib/nPA-EAC/nPA_CA.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Bundesdruckerei GmbH 3 | */ 4 | 5 | #include "nPACommon.h" 6 | 7 | #include "nPAAPI.h" 8 | #include "nPAStatus.h" 9 | #include "nPACard.h" 10 | #include 11 | 12 | #include "eidasn1/eIDHelper.h" 13 | #include "eidasn1/eIDOID.h" 14 | 15 | CAPDU build_CA_Step_B(const OBJECT_IDENTIFIER_t& CA_OID, const unsigned char sessionid) 16 | { 17 | MSE mse = MSE(MSE::P1_SET | MSE::P1_COMPUTE, MSE::P2_AT); 18 | // Build up command data field 19 | std::vector oid(CA_OID.buf, CA_OID.buf+CA_OID.size);; 20 | std::vector data = TLV_encode(0x80, oid); 21 | if (sessionid) { 22 | data.push_back(0xE0); 23 | data.push_back(0x03); 24 | data.push_back(0x81); 25 | data.push_back(0x01); 26 | data.push_back(sessionid); 27 | } 28 | mse.setData(data); 29 | 30 | return mse; 31 | } 32 | 33 | ECARD_STATUS process_CA_Step_B(const RAPDU& rapdu) 34 | { 35 | if (rapdu.getSW() != RAPDU::ISO_SW_NORMAL) 36 | return EAC_CA_STEP_B_FAILED; 37 | 38 | return EAC_SUCCESS; 39 | } 40 | 41 | CAPDU build_CA_Step_C(const std::vector& Puk_IFD_DH) 42 | { 43 | GeneralAuthenticate authenticate = GeneralAuthenticate( 44 | GeneralAuthenticate::P1_NO_INFO, GeneralAuthenticate::P2_NO_INFO); 45 | authenticate.setNe(CAPDU::DATA_SHORT_MAX); 46 | 47 | std::vector puk; 48 | //The server sends the public ephemeral key already with 0x04 49 | //prefix. So we do not need to prepend it anymore. 50 | //puk.push_back(0x04); 51 | puk.insert(puk.end(), Puk_IFD_DH.begin(), Puk_IFD_DH.end()); 52 | 53 | authenticate.setData(TLV_encode(0x7C, TLV_encode(0x80, puk))); 54 | 55 | return authenticate; 56 | } 57 | 58 | ECARD_STATUS process_CA_Step_C(const RAPDU rapdu, 59 | std::vector& GeneralAuthenticationResult) 60 | { 61 | if (rapdu.getSW() != RAPDU::ISO_SW_NORMAL) 62 | return EAC_CA_STEP_B_FAILED; 63 | 64 | GeneralAuthenticationResult = rapdu.getData(); 65 | 66 | return EAC_SUCCESS; 67 | } 68 | 69 | ECARD_STATUS __STDCALL__ ePAPerformCA( 70 | ICard &hCard, 71 | const std::vector& CA_OID, 72 | const std::vector& Puk_IFD_DH, 73 | std::vector& GeneralAuthenticationResult) 74 | { 75 | try { 76 | 77 | ECARD_STATUS status_ = ECARD_SUCCESS; 78 | const OBJECT_IDENTIFIER_t ca_oid = {(unsigned char *) DATA(CA_OID), static_cast(CA_OID.size())}; 79 | 80 | std::vector capdus; 81 | capdus.push_back(build_CA_Step_B(ca_oid, 0)); 82 | capdus.push_back(build_CA_Step_C(Puk_IFD_DH)); 83 | 84 | std::vector rapdus = hCard.transceive(capdus); 85 | std::vector::const_iterator it = rapdus.begin(); 86 | 87 | switch (rapdus.size()) { 88 | case 0: 89 | /* step B failed */ 90 | return EAC_CA_STEP_B_FAILED; 91 | case 1: 92 | /* step C failed */ 93 | return EAC_CA_STEP_B_FAILED; 94 | case 2: 95 | /* OK */ 96 | break; 97 | default: 98 | /* too many rapdus */ 99 | return EAC_CA_STEP_B_FAILED; 100 | } 101 | if (EAC_SUCCESS != (status_ = process_CA_Step_B(*it))) 102 | return status_; 103 | ++it; 104 | 105 | if (EAC_SUCCESS != (status_ = process_CA_Step_C(*it, 106 | GeneralAuthenticationResult))) 107 | return status_; 108 | 109 | return EAC_SUCCESS; 110 | 111 | } catch (...) { 112 | return EAC_CA_STEP_B_FAILED; 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /eIDClientCore/lib/testing.c: -------------------------------------------------------------------------------- 1 | unsigned char CANCEL_AFTER_PAOS_CONNECTION_ESTABLISHMENT; 2 | -------------------------------------------------------------------------------- /eIDClientCore/lib/testing.h: -------------------------------------------------------------------------------- 1 | #if !defined(__TESTING_H_INCLUDED__) 2 | #define __TESTING_H_INCLUDED__ 3 | 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | extern unsigned char CANCEL_AFTER_PAOS_CONNECTION_ESTABLISHMENT; 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /eIDClientCore/m4/ax_check_openssl.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_check_openssl.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_CHECK_OPENSSL([action-if-found[, action-if-not-found]]) 8 | # 9 | # DESCRIPTION 10 | # 11 | # Look for OpenSSL in a number of default spots, or in a user-selected 12 | # spot (via --with-openssl). Sets 13 | # 14 | # OPENSSL_INCLUDES to the include directives required 15 | # OPENSSL_LIBS to the -l directives required 16 | # OPENSSL_LDFLAGS to the -L or -R flags required 17 | # 18 | # and calls ACTION-IF-FOUND or ACTION-IF-NOT-FOUND appropriately 19 | # 20 | # This macro sets OPENSSL_INCLUDES such that source files should use the 21 | # openssl/ directory in include directives: 22 | # 23 | # #include 24 | # 25 | # LICENSE 26 | # 27 | # Copyright (c) 2009,2010 Zmanda Inc. 28 | # Copyright (c) 2009,2010 Dustin J. Mitchell 29 | # 30 | # Copying and distribution of this file, with or without modification, are 31 | # permitted in any medium without royalty provided the copyright notice 32 | # and this notice are preserved. This file is offered as-is, without any 33 | # warranty. 34 | 35 | #serial 8 36 | 37 | AU_ALIAS([CHECK_SSL], [AX_CHECK_OPENSSL]) 38 | AC_DEFUN([AX_CHECK_OPENSSL], [ 39 | found=false 40 | AC_ARG_WITH([openssl], 41 | [AS_HELP_STRING([--with-openssl=DIR], 42 | [root of the OpenSSL directory])], 43 | [ 44 | case "$withval" in 45 | "" | y | ye | yes | n | no) 46 | AC_MSG_ERROR([Invalid --with-openssl value]) 47 | ;; 48 | *) ssldirs="$withval" 49 | ;; 50 | esac 51 | ], [ 52 | # if pkg-config is installed and openssl has installed a .pc file, 53 | # then use that information and don't search ssldirs 54 | AC_PATH_PROG([PKG_CONFIG], [pkg-config]) 55 | if test x"$PKG_CONFIG" != x""; then 56 | OPENSSL_LDFLAGS=`$PKG_CONFIG openssl --libs-only-L 2>/dev/null` 57 | if test $? = 0; then 58 | OPENSSL_LIBS=`$PKG_CONFIG openssl --libs-only-l 2>/dev/null` 59 | OPENSSL_INCLUDES=`$PKG_CONFIG openssl --cflags-only-I 2>/dev/null` 60 | found=true 61 | fi 62 | fi 63 | 64 | # no such luck; use some default ssldirs 65 | if ! $found; then 66 | ssldirs="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr" 67 | fi 68 | ] 69 | ) 70 | 71 | 72 | # note that we #include , so the OpenSSL headers have to be in 73 | # an 'openssl' subdirectory 74 | 75 | if ! $found; then 76 | OPENSSL_INCLUDES= 77 | for ssldir in $ssldirs; do 78 | AC_MSG_CHECKING([for openssl/ssl.h in $ssldir]) 79 | if test -f "$ssldir/include/openssl/ssl.h"; then 80 | OPENSSL_INCLUDES="-I$ssldir/include" 81 | OPENSSL_LDFLAGS="-L$ssldir/lib" 82 | OPENSSL_LIBS="-lssl -lcrypto" 83 | found=true 84 | AC_MSG_RESULT([yes]) 85 | break 86 | else 87 | AC_MSG_RESULT([no]) 88 | fi 89 | done 90 | 91 | # if the file wasn't found, well, go ahead and try the link anyway -- maybe 92 | # it will just work! 93 | fi 94 | 95 | # try the preprocessor and linker with our new flags, 96 | # being careful not to pollute the global LIBS, LDFLAGS, and CPPFLAGS 97 | 98 | AC_MSG_CHECKING([whether compiling and linking against OpenSSL works]) 99 | echo "Trying link with OPENSSL_LDFLAGS=$OPENSSL_LDFLAGS;" \ 100 | "OPENSSL_LIBS=$OPENSSL_LIBS; OPENSSL_INCLUDES=$OPENSSL_INCLUDES" >&AS_MESSAGE_LOG_FD 101 | 102 | save_LIBS="$LIBS" 103 | save_LDFLAGS="$LDFLAGS" 104 | save_CPPFLAGS="$CPPFLAGS" 105 | LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS" 106 | LIBS="$OPENSSL_LIBS $LIBS" 107 | CPPFLAGS="$OPENSSL_INCLUDES $CPPFLAGS" 108 | AC_LINK_IFELSE( 109 | [AC_LANG_PROGRAM([#include ], [SSL_new(NULL)])], 110 | [ 111 | AC_MSG_RESULT([yes]) 112 | $1 113 | ], [ 114 | AC_MSG_RESULT([no]) 115 | $2 116 | ]) 117 | CPPFLAGS="$save_CPPFLAGS" 118 | LDFLAGS="$save_LDFLAGS" 119 | LIBS="$save_LIBS" 120 | 121 | AC_SUBST([OPENSSL_INCLUDES]) 122 | AC_SUBST([OPENSSL_LIBS]) 123 | AC_SUBST([OPENSSL_LDFLAGS]) 124 | ]) 125 | -------------------------------------------------------------------------------- /trusted_ca/CAcert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIHPTCCBSWgAwIBAgIBADANBgkqhkiG9w0BAQQFADB5MRAwDgYDVQQKEwdSb290 3 | IENBMR4wHAYDVQQLExVodHRwOi8vd3d3LmNhY2VydC5vcmcxIjAgBgNVBAMTGUNB 4 | IENlcnQgU2lnbmluZyBBdXRob3JpdHkxITAfBgkqhkiG9w0BCQEWEnN1cHBvcnRA 5 | Y2FjZXJ0Lm9yZzAeFw0wMzAzMzAxMjI5NDlaFw0zMzAzMjkxMjI5NDlaMHkxEDAO 6 | BgNVBAoTB1Jvb3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEi 7 | MCAGA1UEAxMZQ0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJ 8 | ARYSc3VwcG9ydEBjYWNlcnQub3JnMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC 9 | CgKCAgEAziLA4kZ97DYoB1CW8qAzQIxL8TtmPzHlawI229Z89vGIj053NgVBlfkJ 10 | 8BLPRoZzYLdufujAWGSuzbCtRRcMY/pnCujW0r8+55jE8Ez64AO7NV1sId6eINm6 11 | zWYyN3L69wj1x81YyY7nDl7qPv4coRQKFWyGhFtkZip6qUtTefWIonvuLwphK42y 12 | fk1WpRPs6tqSnqxEQR5YYGUFZvjARL3LlPdCfgv3ZWiYUQXw8wWRBB0bF4LsyFe7 13 | w2t6iPGwcswlWyCR7BYCEo8y6RcYSNDHBS4CMEK4JZwFaz+qOqfrU0j36NK2B5jc 14 | G8Y0f3/JHIJ6BVgrCFvzOKKrF11myZjXnhCLotLddJr3cQxyYN/Nb5gznZY0dj4k 15 | epKwDpUeb+agRThHqtdB7Uq3EvbXG4OKDy7YCbZZ16oE/9KTfWgu3YtLq1i6L43q 16 | laegw1SJpfvbi1EinbLDvhG+LJGGi5Z4rSDTii8aP8bQUWWHIbEZAWV/RRyH9XzQ 17 | QUxPKZgh/TMfdQwEUfoZd9vUFBzugcMd9Zi3aQaRIt0AUMyBMawSB3s42mhb5ivU 18 | fslfrejrckzzAeVLIL+aplfKkQABi6F1ITe1Yw1nPkZPcCBnzsXWWdsC4PDSy826 19 | YreQQejdIOQpvGQpQsgi3Hia/0PsmBsJUUtaWsJx8cTLc6nloQsCAwEAAaOCAc4w 20 | ggHKMB0GA1UdDgQWBBQWtTIb1Mfz4OaO873SsDrusjkY0TCBowYDVR0jBIGbMIGY 21 | gBQWtTIb1Mfz4OaO873SsDrusjkY0aF9pHsweTEQMA4GA1UEChMHUm9vdCBDQTEe 22 | MBwGA1UECxMVaHR0cDovL3d3dy5jYWNlcnQub3JnMSIwIAYDVQQDExlDQSBDZXJ0 23 | IFNpZ25pbmcgQXV0aG9yaXR5MSEwHwYJKoZIhvcNAQkBFhJzdXBwb3J0QGNhY2Vy 24 | dC5vcmeCAQAwDwYDVR0TAQH/BAUwAwEB/zAyBgNVHR8EKzApMCegJaAjhiFodHRw 25 | czovL3d3dy5jYWNlcnQub3JnL3Jldm9rZS5jcmwwMAYJYIZIAYb4QgEEBCMWIWh0 26 | dHBzOi8vd3d3LmNhY2VydC5vcmcvcmV2b2tlLmNybDA0BglghkgBhvhCAQgEJxYl 27 | aHR0cDovL3d3dy5jYWNlcnQub3JnL2luZGV4LnBocD9pZD0xMDBWBglghkgBhvhC 28 | AQ0ESRZHVG8gZ2V0IHlvdXIgb3duIGNlcnRpZmljYXRlIGZvciBGUkVFIGhlYWQg 29 | b3ZlciB0byBodHRwOi8vd3d3LmNhY2VydC5vcmcwDQYJKoZIhvcNAQEEBQADggIB 30 | ACjH7pyCArpcgBLKNQodgW+JapnM8mgPf6fhjViVPr3yBsOQWqy1YPaZQwGjiHCc 31 | nWKdpIevZ1gNMDY75q1I08t0AoZxPuIrA2jxNGJARjtT6ij0rPtmlVOKTV39O9lg 32 | 18p5aTuxZZKmxoGCXJzN600BiqXfEVWqFcofN8CCmHBh22p8lqOOLlQ+TyGpkO/c 33 | gr/c6EWtTZBzCDyUZbAEmXZ/4rzCahWqlwQ3JNgelE5tDlG+1sSPypZt90Pf6DBl 34 | Jzt7u0NDY8RD97LsaMzhGY4i+5jhe1o+ATc7iwiwovOVThrLm82asduycPAtStvY 35 | sONvRUgzEv/+PDIqVPfE94rwiCPCR/5kenHA0R6mY7AHfqQv0wGP3J8rtsYIqQ+T 36 | SCX8Ev2fQtzzxD72V7DX3WnRBnc0CkvSyqD/HMaMyRa+xMwyN2hzXwj7UfdJUzYF 37 | CpUCTPJ5GhD22Dp1nPMd8aINcGeGG7MW9S/lpOt5hvk9C8JzC6WZrG/8Z7jlLwum 38 | GCSNe9FINSkYQKyTYOGWhlC0elnYjyELn8+CkcY7v2vcB5G5l1YjqrZslMZIBjzk 39 | zk6q5PYvCdxTby78dOs6Y5nCpqyJvKeyRKANihDjbPIky/qbn3BHLt4Ui9SyIAmW 40 | omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD 41 | -----END CERTIFICATE----- 42 | -------------------------------------------------------------------------------- /trusted_ca/COMODO-chain.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIF2DCCA8CgAwIBAgIQTKr5yttjb+Af907YWwOGnTANBgkqhkiG9w0BAQwFADCB 3 | hTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G 4 | A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNV 5 | BAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAwMTE5 6 | MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0IxGzAZBgNVBAgT 7 | EkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR 8 | Q09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNh 9 | dGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCR 10 | 6FSS0gpWsawNJN3Fz0RndJkrN6N9I3AAcbxT38T6KhKPS38QVr2fcHK3YX/JSw8X 11 | pz3jsARh7v8Rl8f0hj4K+j5c+ZPmNHrZFGvnnLOFoIJ6dq9xkNfs/Q36nGz637CC 12 | 9BR++b7Epi9Pf5l/tfxnQ3K9DADWietrLNPtj5gcFKt+5eNu/Nio5JIk2kNrYrhV 13 | /erBvGy2i/MOjZrkm2xpmfh4SDBF1a3hDTxFYPwyllEnvGfDyi62a+pGx8cgoLEf 14 | Zd5ICLqkTqnyg0Y3hOvozIFIQ2dOciqbXL1MGyiKXCJ7tKuY2e7gUYPDCUZObT6Z 15 | +pUX2nwzV0E8jVHtC7ZcryxjGt9XyD+86V3Em69FmeKjWiS0uqlWPc9vqv9JWL7w 16 | qP/0uK3pN/u6uPQLOvnoQ0IeidiEyxPx2bvhiWC4jChWrBQdnArncevPDt09qZah 17 | SL0896+1DSJMwBGB7FY79tOi4lu3sgQiUpWAk2nojkxl8ZEDLXB0AuqLZxUpaVIC 18 | u9ffUGpVRr+goyhhf3DQw6KqLCGqR84onAZFdr+CGCe01a60y1Dma/RMhnEw6abf 19 | Fobg2P9A3fvQQoh/ozM6LlweQRGBY84YcWsr7KaKtzFcOmpH4MN5WdYgGq/yapiq 20 | crxXStJLnbsQ/LBMQeXtHT1eKJ2czL+zUdqnR+WEUwIDAQABo0IwQDAdBgNVHQ4E 21 | FgQUu69+Aj36pvE8hI6t7jiY7NkyMtQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB 22 | /wQFMAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAArx1UaEt65Ru2yyTUEUAJNMnMvl 23 | wFTPoCWOAvn9sKIN9SCYPBMtrFaisNZ+EZLpLrqeLppysb0ZRGxhNaKatBYSaVqM 24 | 4dc+pBroLwP0rmEdEBsqpIt6xf4FpuHA1sj+nq6PK7o9mfjYcwlYRm6mnPTXJ9OV 25 | 2jeDchzTc+CiR5kDOF3VSXkAKRzH7JsgHAckaVd4sjn8OoSgtZx8jb8uk2Intzna 26 | FxiuvTwJaP+EmzzV1gsD41eeFPfR60/IvYcjt7ZJQ3mFXLrrkguhxuhoqEwWsRqZ 27 | CuhTLJK7oQkYdQxlqHvLI7cawiiFwxv/0Cti76R7CZGYZ4wUAc1oBmpjIXUDgIiK 28 | boHGhfKppC3n9KUkEEeDys30jXlYsQab5xoq2Z0B15R97QNKyvDb6KkBPvVWmcke 29 | jkk9u+UJueBPSZI9FoJAzMxZxuY67RIuaTxslbH9qh17f4a+Hg4yRvv7E491f0yL 30 | S0Zj/gA0QHDBw7mh3aZw4gSzQbzpgJHqZJx64SIDqZxubw5lT2yHh17zbqD5daWb 31 | QOhTsiedSrnAdyGN/4fy3ryM7xfft0kL0fJuMAsaDk527RH89elWsn2/x20Kk4yl 32 | 0MC2Hb46TpSi125sC8KKfPog88Tk5c0NqMuRkrF8hey1FGlmDoLnzc7ILaZRfyHB 33 | NVOFBkpdn627G190 34 | -----END CERTIFICATE----- 35 | -----BEGIN CERTIFICATE----- 36 | MIIGCDCCA/CgAwIBAgIQKy5u6tl1NmwUim7bo3yMBzANBgkqhkiG9w0BAQwFADCB 37 | hTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G 38 | A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNV 39 | BAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTQwMjEy 40 | MDAwMDAwWhcNMjkwMjExMjM1OTU5WjCBkDELMAkGA1UEBhMCR0IxGzAZBgNVBAgT 41 | EkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR 42 | Q09NT0RPIENBIExpbWl0ZWQxNjA0BgNVBAMTLUNPTU9ETyBSU0EgRG9tYWluIFZh 43 | bGlkYXRpb24gU2VjdXJlIFNlcnZlciBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEP 44 | ADCCAQoCggEBAI7CAhnhoFmk6zg1jSz9AdDTScBkxwtiBUUWOqigwAwCfx3M28Sh 45 | bXcDow+G+eMGnD4LgYqbSRutA776S9uMIO3Vzl5ljj4Nr0zCsLdFXlIvNN5IJGS0 46 | Qa4Al/e+Z96e0HqnU4A7fK31llVvl0cKfIWLIpeNs4TgllfQcBhglo/uLQeTnaG6 47 | ytHNe+nEKpooIZFNb5JPJaXyejXdJtxGpdCsWTWM/06RQ1A/WZMebFEh7lgUq/51 48 | UHg+TLAchhP6a5i84DuUHoVS3AOTJBhuyydRReZw3iVDpA3hSqXttn7IzW3uLh0n 49 | c13cRTCAquOyQQuvvUSH2rnlG51/ruWFgqUCAwEAAaOCAWUwggFhMB8GA1UdIwQY 50 | MBaAFLuvfgI9+qbxPISOre44mOzZMjLUMB0GA1UdDgQWBBSQr2o6lFoL2JDqElZz 51 | 30O0Oija5zAOBgNVHQ8BAf8EBAMCAYYwEgYDVR0TAQH/BAgwBgEB/wIBADAdBgNV 52 | HSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwGwYDVR0gBBQwEjAGBgRVHSAAMAgG 53 | BmeBDAECATBMBgNVHR8ERTBDMEGgP6A9hjtodHRwOi8vY3JsLmNvbW9kb2NhLmNv 54 | bS9DT01PRE9SU0FDZXJ0aWZpY2F0aW9uQXV0aG9yaXR5LmNybDBxBggrBgEFBQcB 55 | AQRlMGMwOwYIKwYBBQUHMAKGL2h0dHA6Ly9jcnQuY29tb2RvY2EuY29tL0NPTU9E 56 | T1JTQUFkZFRydXN0Q0EuY3J0MCQGCCsGAQUFBzABhhhodHRwOi8vb2NzcC5jb21v 57 | ZG9jYS5jb20wDQYJKoZIhvcNAQEMBQADggIBAE4rdk+SHGI2ibp3wScF9BzWRJ2p 58 | mj6q1WZmAT7qSeaiNbz69t2Vjpk1mA42GHWx3d1Qcnyu3HeIzg/3kCDKo2cuH1Z/ 59 | e+FE6kKVxF0NAVBGFfKBiVlsit2M8RKhjTpCipj4SzR7JzsItG8kO3KdY3RYPBps 60 | P0/HEZrIqPW1N+8QRcZs2eBelSaz662jue5/DJpmNXMyYE7l3YphLG5SEXdoltMY 61 | dVEVABt0iN3hxzgEQyjpFv3ZBdRdRydg1vs4O2xyopT4Qhrf7W8GjEXCBgCq5Ojc 62 | 2bXhc3js9iPc0d1sjhqPpepUfJa3w/5Vjo1JXvxku88+vZbrac2/4EjxYoIQ5QxG 63 | V/Iz2tDIY+3GH5QFlkoakdH368+PUq4NCNk+qKBR6cGHdNXJ93SrLlP7u3r7l+L4 64 | HyaPs9Kg4DdbKDsx5Q5XLVq4rXmsXiBmGqW5prU5wfWYQ//u+aen/e7KJD2AFsQX 65 | j4rBYKEMrltDR5FL1ZoXX/nUh8HCjLfn4g8wGTeGrODcQgPmlKidrv0PJFGUzpII 66 | 0fxQ8ANAe4hZ7Q7drNJ3gjTcBpUC2JD5Leo31Rpg0Gcg19hCC0Wvgmje3WYkN5Ap 67 | lBlGGSW4gNfL1IYoakRwJiNiqZ+Gb7+6kHDSVneFeO/qJakXzlByjAA6quPbYzSf 68 | +AZxAeKCINT+b72x 69 | -----END CERTIFICATE----- 70 | --------------------------------------------------------------------------------