00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __CODEX_KEYSERVICE_CLIENTREADCALLBACK_H__
00019 #define __CODEX_KEYSERVICE_CLIENTREADCALLBACK_H__
00020
00021 #include <map>
00022
00023 #include "ResponseCallback.h"
00024 #include "CODEX_Events/Activity.h"
00025 #include "CODEX_ASN1/Array.h"
00026 #include "CODEX_ASN1/BigNumber.h"
00027 #include "CODEX_Client/Message.h"
00028 #include "LabeledReadKeyMsg.h"
00029 #include "CODEX_Server/ServerSignature.h"
00030 #include "CODEX_Server/SignRequestHandler.h"
00031 #include "ClientResponseHandler.h"
00032 #include "StateInfo.h"
00033 #include "CODEX_Server/BroadcastRequestHandler.h"
00034
00035 #ifdef ELGAMAL
00036 #include "CODEX_ThresholdCrypto/DLProof.h"
00037 #endif
00038
00039 namespace CODEX_KeyService
00040 {
00046 class ClientReadCallback : public ResponseCallback,
00047 public CODEX_Events::Activity
00048 {
00049 private :
00050 typedef CODEX_ASN1::BigNumber BigNumber;
00051
00053 struct BN_less :
00054 public binary_function<const BigNumber&, const BigNumber&, bool>
00055 {
00056 bool operator()( const BigNumber& __x,
00057 const BigNumber& __y ) const
00058 {
00059 return BN_cmp( __x.value() , __y.value() ) < 0;
00060 }
00061 };
00062
00063 public :
00065 typedef CODEX_ASN1::Array< CODEX_Server::ServerSignature >
00066 ServerArray;
00067
00069 typedef CODEX_Server::ServerState::ShareType ShareType;
00070
00072 typedef CODEX_Server::ServerState::ShareSetType ShareSetType;
00073
00075 typedef CODEX_Client::CipherTextType CipherTextType;
00076
00078 typedef CODEX_Client::BlindCipherTextType BlindCipherTextType;
00079
00081 typedef CODEX_Client::BlindPlainTextType BlindPlainTextType;
00082
00084 static const unsigned int NumShares = ShareType::NumShares;
00085
00086 #ifndef ELGAMAL
00087
00088 typedef vector< ShareType* > PartialArray;
00089 #else
00090
00091 typedef ShareSetType PartialArray;
00092
00094 typedef vector< CODEX_ThresholdCrypto::DLProof > ProofArray;
00095
00097 typedef map< CipherTextType , ProofArray > ProofMap;
00098
00100 typedef map< CipherTextType , unsigned int > RespMap;
00101 #endif
00102
00104 typedef map< BlindCipherTextType , PartialArray > PartialMap;
00105
00107 typedef map< BlindCipherTextType , BIGNUM* > DigestMap;
00108
00110 typedef map< BlindCipherTextType , ServerArray > EvidenceMap;
00111
00113 typedef CODEX_Server::ServerState::ChallengeVector ChallengeVector;
00114
00116 ClientReadCallback(
00117 CODEX_Events::DeadPileType& deadPile,
00118 CODEX_Events::QType& eventQueue,
00119 CODEX_Server::SignRequestHandler* destination,
00120 ClientResponseHandler* clientAct,
00121 const LabeledReadKeyMsg& req,
00122 const unsigned char* seqNum,
00123 CODEX_Server::BroadcastRequestHandler* reqHandler );
00124
00126 virtual ~ClientReadCallback();
00127
00128 bool operator()( unsigned int server, CODEX_Quorum::Message* msg );
00129
00130 private :
00131 void constructBlindedKey( BlindPlainTextType& blindedKey,
00132 const BlindCipherTextType& blinding,
00133 const PartialArray& partials );
00134
00135 private :
00136 CODEX_Server::SignRequestHandler* m_destination;
00137 ClientResponseHandler* m_clientAct;
00138 LabeledReadKeyMsg m_request;
00139 EvidenceMap m_evidence;
00140 DigestMap m_digests;
00141 PartialMap m_partials;
00142 #ifdef ELGAMAL
00143 ProofMap m_proofs;
00144 RespMap m_nResp;
00145 #endif
00146 bool m_complete;
00147 ChallengeVector m_challenges;
00148 CODEX_Server::BroadcastRequestHandler* m_reqHandler;
00149 };
00150
00151 }
00152
00153 #endif