1 
2 /* ****************************************************************************
3 
4  * eID Middleware Project.
5  * Copyright (C) 2008-2013 FedICT.
6  *
7  * This is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License version
9  * 3.0 as published by the Free Software Foundation.
10  *
11  * This software 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 software; if not, see
18  * http://www.gnu.org/licenses/.
19 
20 **************************************************************************** */
21 #pragma once
22 
23 #ifndef CARDLAYERCONST_H
24 #define CARDLAYERCONST_H
25 namespace eIDMW
26 {
27 
28 /**
29  * The maximum number of readers; if more readers are present
30  * only the first MAX_READERS that are found will used.
31  */
32 	const static unsigned long MAX_READERS = 24;
33 
34 	typedef enum
35 	{
36 		DISCONNECT_LEAVE_CARD = 0,
37 		DISCONNECT_RESET_CARD = 1,
38 	} tDisconnectMode;
39 
40 /*	typedef enum
41 	{
42 		FILE_OP_READ,
43 		FILE_OP_WRITE,
44 	} tFileOperation;
45 */
46 	typedef enum
47 	{
48 		PIN_OP_VERIFY,
49 		PIN_OP_CHANGE,
50 //		PIN_OP_LOGOFF,
51 	} tPinOperation;
52 
53 	const unsigned long SIGN_ALGO_RSA_RAW = 0x01;
54 	const unsigned long SIGN_ALGO_RSA_PKCS = 0x02;
55 	const unsigned long SIGN_ALGO_MD5_RSA_PKCS = 0x04;
56 	const unsigned long SIGN_ALGO_SHA1_RSA_PKCS = 0x08;
57 	const unsigned long SIGN_ALGO_SHA256_RSA_PKCS = 0x10;
58 	const unsigned long SIGN_ALGO_SHA384_RSA_PKCS = 0x20;
59 	const unsigned long SIGN_ALGO_SHA512_RSA_PKCS = 0x40;
60 	const unsigned long SIGN_ALGO_RIPEMD160_RSA_PKCS = 0x80;
61 	const unsigned long SIGN_ALGO_SHA1_RSA_PSS = 0x100;
62 	const unsigned long SIGN_ALGO_SHA256_RSA_PSS = 0x200;
63 	const unsigned long SIGN_ALGO_ECDSA_RAW = 0x400;
64 	const unsigned long SIGN_ALGO_SHA256_ECDSA = 0x800;
65 	const unsigned long SIGN_ALGO_SHA384_ECDSA = 0x1000;
66 	const unsigned long SIGN_ALGO_SHA512_ECDSA = 0x2000;
67 	const unsigned long SIGN_ALGO_SHA3_256_ECDSA = 0x4000;
68 	const unsigned long SIGN_ALGO_SHA3_384_ECDSA = 0x8000;
69 	const unsigned long SIGN_ALGO_SHA3_512_ECDSA = 0x10000;
70 
71 //	typedef enum
72 //	{
73 //		PIN_ENC_ASCII,
74 //		PIN_ENC_BCD,
75 //		PIN_ENC_GP,  // Global platorm encoding e.g. "12345" -> {0x25, 0x12, 0x34, 0x5F, 0xFF, ... 0xFF}
76 //	} tPinEncoding;
77 
78 	typedef enum
79 	{
80 		CARD_BEID,
81 		CARD_UNKNOWN,
82 	} tCardType;
83 
84 	typedef enum
85 	{
86 		CARD_INSERTED,
87 		CARD_NOT_PRESENT,
88 		CARD_STILL_PRESENT,
89 		CARD_REMOVED,
90 		CARD_OTHER,
91 		CARD_UNKNOWN_STATE,
92 	} tCardStatus;
93 
94 	const unsigned long TIMEOUT_INFINITE = 0xFFFFFFFF;	// used in CCardLayer::GetStatusChange()
95 	const unsigned long TIMEOUT_POLL = 0x000001F4;	// used in CCardLayer::GetStatusChange(), timeout in ms
96 
97 //	const unsigned long ALL_READERS = 0xFFFFFFFF;	// used in CCardLayer::GetStatusChange()
98 
99 	const unsigned long FULL_FILE = 0xFFFFFFFF;	// used in CReader::ReadFile()
100 
101 	const unsigned long PIN_STATUS_UNKNOWN = 0xFFFFFFFE;	// used in CReader::PinStatus()
102 
103 
104 /* used in CReader::Ctrl() */
105 
106 //	const long CTRL_BEID = 1000;
107 
108 /** Returns the unsigned card data (= same as CReader::GetInfo(), in case of a BE eID card).
109  *  No input data is needed, 28 bytes are returned. */
110 //	const long CTRL_BEID_GETCARDDATA = CTRL_BEID;
111 
112 /** Returns the signed card data (28 + 128 bytes). No input data is needed.
113  *  Not for V1 cards! */
114 //	const long CTRL_BEID_GETSIGNEDCARDDATA = CTRL_BEID + 1;
115 
116 /** Returns the signed PIN status (1 + 128 bytes).
117  * Not for V1 cards!
118  * The input data should consist of 1 byte: the pin reference. */
119 //	const long CTRL_BEID_GETSIGNEDPINSTATUS = CTRL_BEID + 2;
120 
121 /** Does an Internal Authenticate command, the signed challenge (128 bytes) is returned.
122  *  The input data should be 21 bytes:
123  *    - the key reference (1 byte)
124  *    - the challenge to be signed (20 bytes) */
125 //	const long CTRL_BEID_INTERNAL_AUTH = CTRL_BEID + 3;
126 }
127 
128 #endif
129