Mixes for Privacy and Anonymity in the Internet
Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends | List of all members
CAMiddleMix Class Reference
Inheritance diagram for CAMiddleMix:
CAMixWithReplayDB CAMix

Public Member Functions

 CAMiddleMix ()
 
virtual ~CAMiddleMix ()
 
tMixType getType () const
 
- Public Member Functions inherited from CAMixWithReplayDB
 CAMixWithReplayDB ()
 
CADatabasegetReplayDB () const
 
- Public Member Functions inherited from CAMix
 CAMix ()
 
virtual ~CAMix ()
 
SINT32 start ()
 
virtual SINT32 reconfigure ()
 
virtual void shutDown ()
 
virtual bool isShutDown ()
 
SINT32 getMixCascadeInfo (XERCES_CPP_NAMESPACE::DOMDocument *&docMixCascadeInfo)
 Returns the Mix-Cascade info which should be send to the InfoService. More...
 
bool acceptsReconfiguration ()
 
CAControlChannelDispatchergetDownstreamControlChannelDispatcher () const
 
CAControlChannelDispatchergetUpstreamControlChannelDispatcher () const
 
UINT32 getLastConnectionTime ()
 
bool isConnected ()
 

Protected Attributes

CAQueuem_pQueueSendToMixBefore
 
CAQueuem_pQueueSendToMixAfter
 
UINT32 m_u32KeepAliveRecvInterval2
 
UINT32 m_u32KeepAliveSendInterval2
 
- Protected Attributes inherited from CAMixWithReplayDB
CADatabasem_pReplayDB
 
CAReplayCtrlChannelMsgProcm_pReplayMsgProc
 
- Protected Attributes inherited from CAMix
volatile bool m_bLoop
 
bool m_bReconfiguring
 
volatile bool m_bShutDown
 
CAMultiSignaturem_pMultiSignature
 
CAInfoServicem_pInfoService
 
UINT32 m_u32KeepAliveRecvInterval
 
UINT32 m_u32KeepAliveSendInterval
 
bool m_acceptReconfiguration
 
volatile bool m_bConnected
 
volatile UINT32 m_lLastConnectionTime
 
XERCES_CPP_NAMESPACE::DOMDocument * m_docMixCascadeInfo
 
CAControlChannelDispatcherm_pMuxOutControlChannelDispatcher
 
CAControlChannelDispatcherm_pMuxInControlChannelDispatcher
 

Private Member Functions

SINT32 loop ()
 Processes Upstream-MixPackets. More...
 
SINT32 init ()
 
SINT32 initOnce ()
 
SINT32 clean ()
 
SINT32 connectToNextMix (CASocketAddr *a_pAddrNext)
 
virtual SINT32 initMixCascadeInfo (DOMElement *)
 This method is not applicable to middle mixes; it does nothing. More...
 
virtual SINT32 processKeyExchange ()
 Processes key exchange with Mix n+1 and Mix n-1. More...
 
int accessSharedMemory (int semId, tPoolEntry *destination, tPoolEntry *source)
 

Private Attributes

CAMuxSocketm_pMuxIn
 
CAMuxSocketm_pMuxOut
 
CAASymCipherm_pRSA
 
volatile bool m_bRun
 
CAMiddleMixChannelListm_pMiddleMixChannelList
 
const char * upstreamMemoryPreName ="upstreamshmempre"
 
const char * upstreamMemoryPostName ="upstreamshmempost"
 
const char * downstreamMemoryPreName ="downstreamshmempre"
 
const char * downstreamMemoryPostName ="downstreamshmempost"
 
void * upstreamPreBuffer
 
void * upstreamPostBuffer
 
void * downstreamPreBuffer
 
void * downstreamPostBuffer
 
int upstreamSemPreId
 
int upstreamSemPostId
 
int downstreamSemPreId
 
int downstreamSemPostId
 
bool m_bShMemConfigured
 

Friends

THREAD_RETURN mm_loopSendToMixBefore (void *)
 DOWNSTREAM (to Client) Take the packets from the Queue and write them to the Socket. More...
 
THREAD_RETURN mm_loopSendToMixAfter (void *)
 UPSTREAM (to WEB) Take the packets from the Queue and write them to the Socket. More...
 
THREAD_RETURN mm_loopReadFromMixBefore (void *)
 
THREAD_RETURN mm_loopReadFromMixAfter (void *)
 
THREAD_RETURN mm_loopDownStream (void *)
 

Additional Inherited Members

- Public Types inherited from CAMix
enum  tMixType { FIRST_MIX, MIDDLE_MIX, LAST_MIX, JAP }
 
- Public Attributes inherited from CAMixWithReplayDB
UINT64 m_u64ReferenceTime
 
- Static Public Attributes inherited from CAMix
static const UINT32 TIMEOUT_MIX_CONNECTION_ESTABLISHEMENT = 60000
 
- Protected Member Functions inherited from CAMix
SINT32 checkCompatibility (DOMNode *a_parent, const char *a_mixPosition)
 
SINT32 appendCompatibilityInfo (DOMNode *a_parent)
 
SINT32 addMixInfo (DOMNode *a_element, bool a_bForceFirstNode)
 
SINT32 signXML (DOMNode *a_element)
 

Constructor & Destructor Documentation

◆ CAMiddleMix()

CAMiddleMix::CAMiddleMix ( )

◆ ~CAMiddleMix()

virtual CAMiddleMix::~CAMiddleMix ( )
virtual

References clean().

Member Function Documentation

◆ accessSharedMemory()

int CAMiddleMix::accessSharedMemory ( int  semId,
tPoolEntry destination,
tPoolEntry source 
)
private

◆ clean()

SINT32 CAMiddleMix::clean ( )
privatevirtual

◆ connectToNextMix()

SINT32 CAMiddleMix::connectToNextMix ( CASocketAddr a_pAddrNext)
private

◆ getType()

tMixType CAMiddleMix::getType ( ) const
virtual

◆ init()

SINT32 CAMiddleMix::init ( )
privatevirtual

Connect to next mix

Implements CAMix.

References CAMuxSocket::accept(), CATargetInterface::cleanAddr(), connectToNextMix(), CASocket::create(), downstreamMemoryPostName, downstreamMemoryPreName, downstreamPostBuffer, downstreamPreBuffer, downstreamSemPostId, downstreamSemPreId, E_SUCCESS, E_UNKNOWN, ev_net_nextConnected, ev_net_prevConnected, ev_net_prevConnectionClosed, CAASymCipher::generateKeyPair(), CAListenerInterface::getAddr(), CATargetInterface::getAddr(), CAMuxSocket::getCASocket(), CACmdLnOptions::getListenerInterface(), CACmdLnOptions::getListenerInterfaceCount(), CALibProxytest::getOptions(), CACmdLnOptions::getTargetInterface(), CACmdLnOptions::getTargetInterfaceCount(), CATargetInterface::getTargetType(), CASocketAddr::getType(), CAListenerInterface::isVirtual(), m_bShMemConfigured, m_pMiddleMixChannelList, m_pMuxIn, CAMix::m_pMuxInControlChannelDispatcher, m_pMuxOut, m_pQueueSendToMixAfter, m_pQueueSendToMixBefore, CAMixWithReplayDB::m_pReplayDB, CAMixWithReplayDB::m_pReplayMsgProc, m_pRSA, CAMixWithReplayDB::m_u64ReferenceTime, MIXPACKET_SIZE, MONITORING_FIRE_NET_EVENT, CAMsg::printMsg(), processKeyExchange(), readFile(), REPLAY_TIMESTAMP_PROPAGATION_INTERVALL, saveFile(), CASocket::setKeepAlive(), CASocket::setRecvBuff(), CASocket::setSendBuff(), CADatabase::start(), CAReplayCtrlChannelMsgProc::startTimeStampPorpagation(), TARGET_MIX, CASocketAddr::toString(), upstreamMemoryPostName, upstreamMemoryPreName, upstreamPostBuffer, upstreamPreBuffer, upstreamSemPostId, and upstreamSemPreId.

Referenced by getType().

◆ initMixCascadeInfo()

virtual SINT32 CAMiddleMix::initMixCascadeInfo ( DOMElement *  )
privatevirtual

This method is not applicable to middle mixes; it does nothing.

Parameters
dignored
Return values
E_SUCCESSin any case

Reimplemented from CAMix.

References E_SUCCESS, and processKeyExchange().

◆ initOnce()

SINT32 CAMiddleMix::initOnce ( )
privatevirtual

◆ loop()

SINT32 CAMiddleMix::loop ( )
privatevirtual

◆ processKeyExchange()

SINT32 CAMiddleMix::processKeyExchange ( )
privatevirtual

Processes key exchange with Mix n+1 and Mix n-1.

  • Step 1: Opens TCP/IP-Connection to Mix n+1.
  • Step 2: Receives info about Mix n+1 .. LastMix as XML struct (see XML struct)
  • Step 3: Verifies signature, generates symetric Keys used for link encryption with Mix
    +1.
  • Step 4: Sends symetric Key to Mix n+1, encrypted with PubKey of Mix n+1 (see XML struct)
  • Step 5: Sends info about Mix n .. LastMix as XML struct (see XML struct) to Mix n-1
  • Step 6: Recevies symetric Key used for link encrpytion with Mix n-1 (see XML struct)
    Return values
    E_SUCCESSif KeyExchange with Mix n+1 and Mix n-1 was succesful
    E_UNKNOWNotherwise

Getting the KeepAlive Traffice...

Getting and calculating the KeepAlive Traffice...

Implements CAMix.

References CAMix::addMixInfo(), CAMix::appendCompatibilityInfo(), CAMix::checkCompatibility(), createDOMDocument(), createDOMElement(), CABase64::decode(), decodeXMLEncryptedKey(), DOM_Output::dumpToMem(), E_SUCCESS, E_UNKNOWN, CABase64::encode(), encodeXMLEncryptedKey(), equals(), ev_net_keyExchangeNextFailed, ev_net_keyExchangeNextSuccessful, ev_net_keyExchangePrevFailed, ev_net_keyExchangePrevSuccessful, GET_NET_ERROR, GET_NET_ERROR_STR, CAMuxSocket::getCASocket(), getDOMChildByName(), getDOMElementAttribute(), getDOMElementValue(), CACmdLnOptions::getKeepAliveRecvInterval(), CACmdLnOptions::getKeepAliveSendInterval(), CACmdLnOptions::getMixId(), CACmdLnOptions::getNextMixTestCertificate(), CALibProxytest::getOptions(), CACmdLnOptions::getPrevMixTestCertificate(), CAASymCipher::getPublicKeyAsDOMElement(), getRandom(), CACmdLnOptions::getTrustedCertificateStore(), len, CAMix::m_pMultiSignature, m_pMuxIn, m_pMuxOut, m_pRSA, CAMix::m_u32KeepAliveRecvInterval, m_u32KeepAliveRecvInterval2, CAMix::m_u32KeepAliveSendInterval, m_u32KeepAliveSendInterval2, max, MONITORING_FIRE_NET_EVENT, parseDOMDocument(), CAMsg::printMsg(), CAMuxSocket::receiveFully(), CASocket::send(), setDOMElementAttribute(), setDOMElementValue(), CACmdLnOptions::setNextMixTestCertificate(), CACmdLnOptions::setPrevMixTestCertificate(), CAASymCipher::setPublicKeyAsDOMNode(), CAMuxSocket::setReceiveKey(), CAMuxSocket::setSendKey(), CAMultiSignature::signXML(), CAMix::signXML(), CAMix::TIMEOUT_MIX_CONNECTION_ESTABLISHEMENT, CACertStore::verifyMixCert(), CACmdLnOptions::verifyMixCertificates(), and CAMultiSignature::verifyXML().

Referenced by init(), and initMixCascadeInfo().

Friends And Related Function Documentation

◆ mm_loopDownStream

THREAD_RETURN mm_loopDownStream ( void *  )
friend

Referenced by getType().

◆ mm_loopReadFromMixAfter

THREAD_RETURN mm_loopReadFromMixAfter ( void *  param)
friend

SGX MIX locksem(downstreamSemPreId, SN_EMPTY); memcpy(downstreamPreBuffer,pPoolEntry, sizeof(tPoolEntry)); unlocksem(downstreamSemPreId, SN_FULL);

locksem(downstreamSemPostId, SN_FULL); memcpy(pPoolEntry,downstreamPostBuffer, sizeof(tPoolEntry)); unlocksem(downstreamSemPostId, SN_EMPTY); getRandom(pMixPacket->data,DATA_SIZE);

SGX MIX locksem(pMix->downstreamSemPreId, SN_EMPTY); memcpy(pMix->downstreamPreBuffer,pPoolEntry, sizeof(tPoolEntry)); unlocksem(pMix->downstreamSemPreId, SN_FULL);

locksem(pMix->downstreamSemPostId, SN_FULL); memcpy(pPoolEntry,pMix->downstreamPostBuffer, sizeof(tPoolEntry)); unlocksem(pMix->downstreamSemPostId, SN_EMPTY);

Referenced by getType(), and loop().

◆ mm_loopReadFromMixBefore

THREAD_RETURN mm_loopReadFromMixBefore ( void *  param)
friend

Referenced by getType(), and loop().

◆ mm_loopSendToMixAfter

THREAD_RETURN mm_loopSendToMixAfter ( void *  param)
friend

UPSTREAM (to WEB) Take the packets from the Queue and write them to the Socket.

Referenced by getType(), and loop().

◆ mm_loopSendToMixBefore

THREAD_RETURN mm_loopSendToMixBefore ( void *  param)
friend

DOWNSTREAM (to Client) Take the packets from the Queue and write them to the Socket.

Referenced by getType(), and loop().

Member Data Documentation

◆ downstreamMemoryPostName

const char* CAMiddleMix::downstreamMemoryPostName ="downstreamshmempost"
private

Referenced by clean(), and init().

◆ downstreamMemoryPreName

const char* CAMiddleMix::downstreamMemoryPreName ="downstreamshmempre"
private

Referenced by clean(), and init().

◆ downstreamPostBuffer

void* CAMiddleMix::downstreamPostBuffer
private

Referenced by init().

◆ downstreamPreBuffer

void* CAMiddleMix::downstreamPreBuffer
private

Referenced by init().

◆ downstreamSemPostId

int CAMiddleMix::downstreamSemPostId
private

Referenced by clean(), and init().

◆ downstreamSemPreId

int CAMiddleMix::downstreamSemPreId
private

Referenced by clean(), and init().

◆ m_bRun

volatile bool CAMiddleMix::m_bRun
private

◆ m_bShMemConfigured

bool CAMiddleMix::m_bShMemConfigured
private

Referenced by CAMiddleMix(), and init().

◆ m_pMiddleMixChannelList

CAMiddleMixChannelList* CAMiddleMix::m_pMiddleMixChannelList
private

◆ m_pMuxIn

CAMuxSocket* CAMiddleMix::m_pMuxIn
private

◆ m_pMuxOut

CAMuxSocket* CAMiddleMix::m_pMuxOut
private

◆ m_pQueueSendToMixAfter

CAQueue* CAMiddleMix::m_pQueueSendToMixAfter
protected

◆ m_pQueueSendToMixBefore

CAQueue* CAMiddleMix::m_pQueueSendToMixBefore
protected

◆ m_pRSA

CAASymCipher* CAMiddleMix::m_pRSA
private

◆ m_u32KeepAliveRecvInterval2

UINT32 CAMiddleMix::m_u32KeepAliveRecvInterval2
protected

Referenced by processKeyExchange().

◆ m_u32KeepAliveSendInterval2

UINT32 CAMiddleMix::m_u32KeepAliveSendInterval2
protected

◆ upstreamMemoryPostName

const char* CAMiddleMix::upstreamMemoryPostName ="upstreamshmempost"
private

Referenced by clean(), and init().

◆ upstreamMemoryPreName

const char* CAMiddleMix::upstreamMemoryPreName ="upstreamshmempre"
private

Referenced by clean(), and init().

◆ upstreamPostBuffer

void* CAMiddleMix::upstreamPostBuffer
private

Referenced by CAMiddleMix(), and init().

◆ upstreamPreBuffer

void* CAMiddleMix::upstreamPreBuffer
private

Referenced by CAMiddleMix(), and init().

◆ upstreamSemPostId

int CAMiddleMix::upstreamSemPostId
private

Referenced by clean(), and init().

◆ upstreamSemPreId

int CAMiddleMix::upstreamSemPreId
private

Referenced by clean(), and init().