Mixe for Privacy and Anonymity in the Internet
CAControlChannelDispatcher.hpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2000, The JAP-Team
3 All rights reserved.
4 Redistribution and use in source and binary forms, with or without modification,
5 are permitted provided that the following conditions are met:
6 
7  - Redistributions of source code must retain the above copyright notice,
8  this list of conditions and the following disclaimer.
9 
10  - Redistributions in binary form must reproduce the above copyright notice,
11  this list of conditions and the following disclaimer in the documentation and/or
12  other materials provided with the distribution.
13 
14  - Neither the name of the University of Technology Dresden, Germany nor the names of its contributors
15  may be used to endorse or promote products derived from this software without specific
16  prior written permission.
17 
18 
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
20 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21 AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS
22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
27 */
28 
29 #ifndef _CACONTROLCHANNELDISPATCHER_H_HEADER_
30 #define _CACONTROLCHANNELDISPATCHER_H_HEADER_
31 #include "CAQueue.hpp"
32 #include "gcm/gcm.h"
34 
39 {
40  public:
45  CAControlChannelDispatcher(CAQueue* pSendQueue,UINT8* keyRecv,UINT8* keySent)
46  {
47  m_pSendQueue=pSendQueue;
51  memset(m_arControlChannels,0,256*sizeof(CAAbstractControlChannel*));
52  m_pcsSendMsg=new CAMutex();
54  m_pcsEnc=new CAMutex();
55  m_pcsDec=new CAMutex();
57  m_pEncMsgIV=new UINT32[3];
58  memset(m_pEncMsgIV,0,12);
60  m_pDecMsgIV=new UINT8[12];
61  memset(m_pDecMsgIV,0,12);
62  if(keySent!=NULL)
63  {
64  m_pGCMCtxEnc=new gcm_ctx_64k;
65  m_pGCMCtxDec=new gcm_ctx_64k;
66  gcm_init_64k(m_pGCMCtxEnc,keySent,128);
67  gcm_init_64k(m_pGCMCtxDec,keyRecv,128);
68  }
69  else
70  {
71  m_pGCMCtxEnc=NULL;
72  m_pGCMCtxDec=NULL;
73  }
74  }
75 
77  {
78  delete m_pcsSendMsg;
79  m_pcsSendMsg = NULL;
80  delete m_pcsRegisterChannel;
81  m_pcsRegisterChannel = NULL;
82  delete[] m_arControlChannels;
83  m_arControlChannels = NULL;
84  delete m_pQueueEntry;
85  m_pQueueEntry = NULL;
86  if(m_pGCMCtxEnc!=NULL)
87  delete m_pGCMCtxEnc;
88  if(m_pGCMCtxDec!=NULL)
89  delete m_pGCMCtxDec;
90  delete []m_pEncMsgIV;
91  delete m_pcsEnc;
92  delete []m_pDecMsgIV;
93  delete m_pcsDec;
94  }
95 
96  void deleteAllControlChannels(void);
97 
101 
102  bool proccessMixPacket(const MIXPACKET* pPacket);
103  SINT32 sendMessages(UINT32 id,const UINT8* msg,UINT32 msglen);
104 
109  SINT32 encryptMessage(const UINT8* in,UINT32 inlen, UINT8* out,UINT32* outlen);
114  SINT32 decryptMessage(const UINT8* in,UINT32 inlen, UINT8* out,UINT32* outlen);
116  bool isKeySet()
117  {
118  return m_pGCMCtxEnc!=NULL;
119  }
120 
121  private:
130 
131  gcm_ctx_64k* m_pGCMCtxEnc;
132  gcm_ctx_64k* m_pGCMCtxDec;
137 };
138 #endif
signed int SINT32
Definition: basetypedefs.h:132
unsigned char UINT8
Definition: basetypedefs.h:135
unsigned int UINT32
Definition: basetypedefs.h:131
The base of each control channel.
This class "dispatches" messages which it receives via proccessMixPacket() to the associated control ...
void deleteAllControlChannels(void)
Deregisters all control channels and calls delete on every registered control channel object.
CAControlChannelDispatcher(CAQueue *pSendQueue, UINT8 *keyRecv, UINT8 *keySent)
Constructs a new dispatcher.
bool isKeySet()
Temp workaorund function - to be removed soon...
CAAbstractControlChannel ** m_arControlChannels
SINT32 decryptMessage(const UINT8 *in, UINT32 inlen, UINT8 *out, UINT32 *outlen)
Decrypts a control channel message, which has to be of form: cipher text auth tag - 16 bytes.
SINT32 registerControlChannel(CAAbstractControlChannel *pControlChannel)
Registers a control channel for receiving messages.
SINT32 sendMessages(UINT32 id, const UINT8 *msg, UINT32 msglen)
SINT32 encryptMessage(const UINT8 *in, UINT32 inlen, UINT8 *out, UINT32 *outlen)
Encrypts a control channel message.
bool proccessMixPacket(const MIXPACKET *pPacket)
This is a simple FIFO-Queue.
Definition: CAQueue.hpp:50
Definition: typedefs.hpp:169
MIXPACKET packet
Definition: typedefs.hpp:170
struct t_queue_entry tQueueEntry
Definition: typedefs.hpp:188