1 /* 2 * reader-tr03119.h: interface related to escape commands with pseudo APDUs 3 * 4 * Copyright (C) 2013-2018 Frank Morgner 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 */ 20 21 #ifndef _READER_TR03119_H 22 #define _READER_TR03119_H 23 24 #include "libopensc/opensc.h" 25 #include "libopensc/pace.h" 26 27 #ifdef __cplusplus 28 extern "C" { 29 #endif 30 31 /** @brief NPA capabilities (TR-03119): PACE */ 32 #define EAC_BITMAP_PACE 0x40 33 /** @brief NPA capabilities (TR-03119): EPA: eID */ 34 #define EAC_BITMAP_EID 0x20 35 /** @brief NPA capabilities (TR-03119): EPA: eSign */ 36 #define EAC_BITMAP_ESIGN 0x10 37 38 /** 39 * @brief Get the PACE capabilities 40 * 41 * @param[in,out] bitmap where to store capabilities bitmap 42 * @note Since this code offers no support for terminal certificate, the bitmap is always \c PACE_BITMAP_PACE|PACE_BITMAP_EID 43 * 44 * @return \c SC_SUCCESS or error code if an error occurred 45 */ 46 int get_pace_capabilities(u8 *bitmap); 47 48 /** @brief NPA result (TR-03119): Kein Fehler */ 49 #define EAC_SUCCESS 0x00000000 50 /** @brief NPA result (TR-03119): Längen im Input sind inkonsistent */ 51 #define EAC_ERROR_LENGTH_INCONSISTENT 0xD0000001 52 /** @brief NPA result (TR-03119): Unerwartete Daten im Input */ 53 #define EAC_ERROR_UNEXPECTED_DATA 0xD0000002 54 /** @brief NPA result (TR-03119): Unerwartete Kombination von Daten im Input */ 55 #define EAC_ERROR_UNEXPECTED_DATA_COMBINATION 0xD0000003 56 /** @brief NPA result (TR-03119): Die Karte unterstützt das PACE – Verfahren nicht. (Unerwartete Struktur in Antwortdaten der Karte) */ 57 #define EAC_ERROR_CARD_NOT_SUPPORTED 0xE0000001 58 /** @brief NPA result (TR-03119): Der Kartenleser unterstützt den angeforderten bzw. den ermittelten Algorithmus nicht. */ 59 #define EAC_ERROR_ALGORITH_NOT_SUPPORTED 0xE0000002 60 /** @brief NPA result (TR-03119): Der Kartenleser kennt die PIN – ID nicht. */ 61 #define EAC_ERROR_PINID_NOT_SUPPORTED 0xE0000003 62 /** @brief NPA result (TR-03119): Negative Antwort der Karte auf Select EF_CardAccess (needs to be OR-ed with SW1|SW2) */ 63 #define EAC_ERROR_SELECT_EF_CARDACCESS 0xF0000000 64 /** @brief NPA result (TR-03119): Negative Antwort der Karte auf Read Binary (needs to be OR-ed with SW1|SW2) */ 65 #define EAC_ERROR_READ_BINARY 0xF0010000 66 /** @brief NPA result (TR-03119): Negative Antwort der Karte auf MSE: Set AT (needs to be OR-ed with SW1|SW2) */ 67 #define EAC_ERROR_MSE_SET_AT 0xF0020000 68 /** @brief NPA result (TR-03119): Negative Antwort der Karte auf General Authenticate Step 1 (needs to be OR-ed with SW1|SW2) */ 69 #define EAC_ERROR_GENERAL_AUTHENTICATE_1 0xF0030000 70 /** @brief NPA result (TR-03119): Negative Antwort der Karte auf General Authenticate Step 2 (needs to be OR-ed with SW1|SW2) */ 71 #define EAC_ERROR_GENERAL_AUTHENTICATE_2 0xF0040000 72 /** @brief NPA result (TR-03119): Negative Antwort der Karte auf General Authenticate Step 3 (needs to be OR-ed with SW1|SW2) */ 73 #define EAC_ERROR_GENERAL_AUTHENTICATE_3 0xF0050000 74 /** @brief NPA result (TR-03119): Negative Antwort der Karte auf General Authenticate Step 4 (needs to be OR-ed with SW1|SW2) */ 75 #define EAC_ERROR_GENERAL_AUTHENTICATE_4 0xF0060000 76 /** @brief NPA result (TR-03119): Kommunikationsabbruch mit Karte. */ 77 #define EAC_ERROR_COMMUNICATION 0xF0100001 78 /** @brief NPA result (TR-03119): Keine Karte im Feld. */ 79 #define EAC_ERROR_NO_CARD 0xF0100002 80 /** @brief NPA result (TR-03119): Benutzerabbruch. */ 81 #define EAC_ERROR_ABORTED 0xF0200001 82 /** @brief NPA result (TR-03119): Benutzer – Timeout */ 83 #define EAC_ERROR_TIMEOUT 0xF0200002 84 85 void sc_detect_escape_cmds(sc_reader_t *reader); 86 87 int escape_pace_input_to_buf(sc_context_t *ctx, 88 const struct establish_pace_channel_input *input, 89 unsigned char **asn1, size_t *asn1_len); 90 int escape_buf_to_pace_input(sc_context_t *ctx, 91 const unsigned char *asn1, size_t asn1_len, 92 struct establish_pace_channel_input *input); 93 int escape_pace_output_to_buf(sc_context_t *ctx, 94 const struct establish_pace_channel_output *output, 95 unsigned char **asn1, size_t *asn1_len); 96 int escape_buf_to_pace_output(sc_context_t *ctx, 97 const unsigned char *asn1, size_t asn1_len, 98 struct establish_pace_channel_output *output); 99 int escape_pace_capabilities_to_buf(sc_context_t *ctx, 100 const unsigned long sc_reader_t_capabilities, 101 unsigned char **asn1, size_t *asn1_len); 102 int escape_buf_to_pace_capabilities(sc_context_t *ctx, 103 const unsigned char *asn1, size_t asn1_len, 104 unsigned long *sc_reader_t_capabilities); 105 106 #ifdef __cplusplus 107 } 108 #endif 109 110 #endif 111 112