Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

ctservice.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  $RCSfile: ctservice.h,v $
00003  -------------------
00004  cvs         : $Id: ctservice.h,v 1.17 2003/05/08 12:26:40 aquamaniac Exp $
00005  begin       : Thu Nov 28 2002
00006  copyright   : (C) 2002 by Martin Preuss
00007  email       : martin@libchipcard.de
00008 
00009  ***************************************************************************
00010  *                                                                         *
00011  *   This library is free software; you can redistribute it and/or         *
00012  *   modify it under the terms of the GNU Lesser General Public            *
00013  *   License as published by the Free Software Foundation; either          *
00014  *   version 2.1 of the License, or (at your option) any later version.    *
00015  *                                                                         *
00016  *   This library is distributed in the hope that it will be useful,       *
00017  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00018  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00019  *   Lesser General Public License for more details.                       *
00020  *                                                                         *
00021  *   You should have received a copy of the GNU Lesser General Public      *
00022  *   License along with this library; if not, write to the Free Software   *
00023  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston,                 *
00024  *   MA  02111-1307  USA                                                   *
00025  *                                                                         *
00026  ***************************************************************************/
00027 
00028 
00029 #ifndef CTSERVICE_H
00030 #define CTSERVICE_H
00031 
00032 #ifdef __cplusplus
00033 extern "C" {
00034 #endif
00035 
00036 
00037 #include <chameleon/chameleon.h>
00038 #include <chameleon/cryp.h>
00039 #include <chameleon/ipcmessage.h>
00040 #include <chameleon/conf.h>
00041 
00042 #define CTSERVICE_MSGCODE_BF                       0x10001
00043 #define CTSERVICE_MSGCODE_BF_VERSION               0x00100
00044 
00045 #define CTSERVICE_MSGCODE_RQ_EXCHANGE_KEYS         0x10002
00046 #define CTSERVICE_MSGCODE_RQ_EXCHANGE_KEYS_VERSION 0x00101
00047 #define CTSERVICE_MSGCODE_RP_EXCHANGE_KEYS         0x10003
00048 #define CTSERVICE_MSGCODE_RP_EXCHANGE_KEYS_VERSION 0x00100
00049 
00050 #define CTSERVICE_MSGCODE_RQ_SESSION_KEY           0x10004
00051 #define CTSERVICE_MSGCODE_RQ_SESSION_KEY_VERSION   0x00100
00052 #define CTSERVICE_MSGCODE_RP_SESSION_KEY           0x10005
00053 #define CTSERVICE_MSGCODE_RP_SESSION_KEY_VERSION   0x00100
00054 
00055 #define CTSERVICE_MSGCODE_RP_ERROR                 0x10006
00056 #define CTSERVICE_MSGCODE_RP_ERROR_VERSION         0x00100
00057 
00058 #define CTSERVICE_MSGCODE_RQ_OPEN                  0x10007
00059 #define CTSERVICE_MSGCODE_RQ_OPEN_VERSION          0x00100
00060 #define CTSERVICE_MSGCODE_RP_OPEN                  0x10008
00061 #define CTSERVICE_MSGCODE_RP_OPEN_VERSION          0x00100
00062 
00063 
00064 #define CTSERVICE_ERROR_TYPE "CTService"
00065 #define CTSERVICE_SUCCESS                   0
00066 #define CTSERVICE_ERROR_DRIVER              1
00067 #define CTSERVICE_ERROR_INVALID             2
00068 #define CTSERVICE_ERROR_BUFFER              3
00069 #define CTSERVICE_ERROR_NO_REQUEST          5
00070 #define CTSERVICE_ERROR_NO_MESSAGE          6
00071 #define CTSERVICE_ERROR_BAD_CHANNEL_STATUS  7
00072 #define CTSERVICE_ERROR_BAD_MESSAGE_VERSION 8
00073 #define CTSERVICE_ERROR_BAD_MESSAGE_CODE    9
00074 #define CTSERVICE_ERROR_BAD_BUFFERSIZE      10
00075 #define CTSERVICE_ERROR_NO_COMMANDS         11
00076 #define CTSERVICE_ERROR_NO_CONFIG           12
00077 #define CTSERVICE_ERROR_UNREACHABLE         13
00078 #define CTSERVICE_ERROR_NO_MESSAGELAYER     14
00079 #define CTSERVICE_ERROR_NO_CLIENT           15
00080 #define CTSERVICE_ERROR_REMOTE              16
00081 #define CTSERVICE_ERROR_NO_TRANSPORT_LAYER  17
00082 #define CTSERVICE_ERROR_BAD_CONFIG          18
00083 #define CTSERVICE_ERROR_SYSTEM_ERROR        19
00084 #define CTSERVICE_ERROR_EXPIRED             20
00085 #define CTSERVICE_ERROR_INTERRUPTED         21
00086 #define CTSERVICE_ERROR_INTERNAL            22
00087 #define CTSERVICE_ERROR_NO_SERVICE          23
00088 
00089 /* TODO: Remove this from CTService ! */
00090 #define CTSERVICE_ERROR_CARD_REMOVED        100
00091 #define CTSERVICE_ERROR_CARD_LOCKED         101
00092 
00093 #define CTSERVICE_DEFAULT_PORT 32891
00094 #define CTSERVICE_DEFAULT_ACCESS "777"
00095 
00096 
00097 typedef struct CTSERVICEREQUESTSTRUCT CTSERVICEREQUEST;
00098 
00099 struct CTSERVICEREQUESTSTRUCT {
00100   CTSERVICEREQUEST *next;
00101   int requestId;
00102   int serviceId;
00103   int persistent;
00104   int abandoned; 
00105   int responseCount;
00106   IPCMESSAGE *message;
00107   IPCMESSAGE *responses;
00108 };
00109 
00110 
00111 typedef enum {
00112   ChannelClosed=0,
00113   ChannelOpening,
00114   ChannelOpen
00115 } CTSERVICE_CHANNEL_STATE;
00116 
00117 
00118 struct CTSERVICEDATASTRUCT {
00119   CRYP_RSAKEY *tempKey;
00120   CRYP_BFKEY *sessionKey;
00121   CTSERVICE_CHANNEL_STATE channelState;
00122   int nextSignId;
00123   int lastPeerSignId;
00124   CTSERVICEREQUEST *requests;
00125 };
00126 typedef struct CTSERVICEDATASTRUCT CTSERVICEDATA;
00127 
00128 
00129 ERRORCODE CTService_ModuleInit();
00130 ERRORCODE CTService_ModuleFini();
00131 
00132 
00133 
00134 CTSERVICEDATA *CTService_PeerData_new();
00135 void CTService_PeerData_free(CTSERVICEDATA *pd);
00136 
00137 
00138 CTSERVICEREQUEST *CTService_Request_new();
00139 void CTService_Request_free(CTSERVICEREQUEST *rq);
00140 
00141 IPCMESSAGE *CTService_Request_NextResponse(CTSERVICEREQUEST *rq);
00142 IPCMESSAGE *CTService_Request_PeekResponse(CTSERVICEREQUEST *rq);
00143 
00144 
00151 IPCMESSAGE *CTService_EncryptMessage(CTSERVICEDATA *pd,
00152                                      IPCMESSAGE *msg);
00159 IPCMESSAGE *CTService_DecryptMessage(CTSERVICEDATA *pd,
00160                                      IPCMESSAGE *msg);
00161 
00162 
00163 void CTService_Request_AddRequest(CTSERVICEREQUEST *req,
00164                                   CTSERVICEREQUEST **head);
00165 void CTService_Request_RemoveRequest(CTSERVICEREQUEST *req,
00166                                      CTSERVICEREQUEST **head);
00167 CTSERVICEREQUEST *CTService_Request_FindRequest(int id,
00168                                                 CTSERVICEREQUEST **head);
00169 
00170 
00171 IPCMESSAGE *CTService_Message_Create(int msgCode,
00172                                      int msgVersion,
00173                                      int msgId,
00174                                      int msgReply,
00175                                      int msgSize);
00176 
00177 CTSERVICEREQUEST *CTService_Request_Create(int serviceid,
00178                                            int msgCode,
00179                                            int msgVersion,
00180                                            int msgId,
00181                                            int msgReply,
00182                                            int msgSize);
00183 
00184 ERRORCODE CTService_CheckMsgCodeAndVersion(IPCMESSAGE *msg,
00185                                            int msgCode,
00186                                            int msgVersion);
00187 
00188 unsigned int Debug_CreateKeyFingerprint(CRYP_RSAKEY *key1);
00189 unsigned int Debug_DataFingerPrint(const char *data, int size);
00190 
00191 #ifdef __cplusplus
00192 }
00193 #endif
00194 
00195 
00196 #endif /* CTSERVICE_H */
00197 
00198 
00199 
00200 
00201 
00202 
00203 

Generated on Sat Feb 11 15:20:28 2006 for libchipcard by  doxygen 1.4.2