00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "VerifiableBlindKeyMsg.h"
00019
00020 using namespace CODEX_KeyService;
00021
00022 VerifiableBlindKeyMsg::VerifiableBlindKeyMsg()
00023 {
00024 }
00025
00026 VerifiableBlindKeyMsg::VerifiableBlindKeyMsg(
00027 const CODEX_ASN1::OctetString& name,
00028 const BlindPlainTextType& blindedKey,
00029 const CODEX_Ciphers::RSASignature& requestSignature,
00030 #ifdef ELGAMAL
00031 const LabelType& label,
00032 const CODEX_Server::ServerState::ShareSetType& partials,
00033 const vector< DLProof >& proofs,
00034 #endif
00035 const BlindCipherTextType& blindCipher ) :
00036 CODEX_Client::BlindKeyMsg( name, blindedKey, requestSignature ),
00037 #ifdef ELGAMAL
00038 m_label( label ),
00039 #endif
00040 m_blindCipher( blindCipher )
00041 {
00042 #ifdef ELGAMAL
00043 for ( unsigned int i = 0 ; i < NumProofs ; ++i )
00044 {
00045 m_partials[i] = partials(i);
00046 m_proofs[i] = proofs[i];
00047 }
00048 #endif
00049 }
00050
00051 VerifiableBlindKeyMsg::VerifiableBlindKeyMsg(
00052 const VerifiableBlindKeyMsg& aBKM ) :
00053 CODEX_Client::BlindKeyMsg( aBKM ),
00054 #ifdef ELGAMAL
00055 m_label( aBKM.m_label ),
00056 #endif
00057 m_blindCipher( aBKM.m_blindCipher )
00058 {
00059 #ifdef ELGAMAL
00060 for ( unsigned int i = 0 ; i < NumProofs ; ++i )
00061 {
00062 m_partials[i] = aBKM.m_partials[i];
00063 m_proofs[i] = aBKM.m_proofs[i];
00064 }
00065 #endif
00066 }
00067
00068 void
00069 VerifiableBlindKeyMsg::operator=( const VerifiableBlindKeyMsg& aBKM )
00070 {
00071 CODEX_Client::BlindKeyMsg::operator=( aBKM );
00072 #ifdef ELGAMAL
00073 m_label = aBKM.m_label;
00074 for ( unsigned int i = 0 ; i < NumProofs ; ++i )
00075 {
00076 m_partials[i] = aBKM.m_partials[i];
00077 m_proofs[i] = aBKM.m_proofs[i];
00078 }
00079 #endif
00080 m_blindCipher = aBKM.m_blindCipher;
00081 }
00082
00083 int
00084 VerifiableBlindKeyMsg::marshal( unsigned char ** pp ) const
00085 {
00086 int r=0;
00087 int ret=0;
00088 unsigned char * p;
00089
00090 ret += CODEX_Client::BlindKeyMsg::marshal(0);
00091 #ifdef ELGAMAL
00092 ret += m_label.marshal(0);
00093 for ( unsigned int count = 0 ; count < NumProofs ; ++count )
00094 {
00095 ret += m_partials[count].marshal(0);
00096 ret += m_proofs[count].marshal(0);
00097 }
00098 #endif
00099 ret += m_blindCipher.marshal(0);
00100 M_ASN1_I2D_seq_total();
00101 CODEX_Client::BlindKeyMsg::marshal(&p);
00102 #ifdef ELGAMAL
00103 m_label.marshal(&p);
00104 for ( unsigned int count = 0 ; count < NumProofs ; ++count )
00105 {
00106 m_partials[count].marshal(&p);
00107 m_proofs[count].marshal(&p);
00108 }
00109 #endif
00110 m_blindCipher.marshal(&p);
00111 M_ASN1_I2D_finish();
00112 }
00113
00114 void*
00115 VerifiableBlindKeyMsg::unmarshal( void* bogus,
00116 unsigned char ** pp,
00117 long length )
00118 {
00119 if ( m_initialized )
00120 {
00121 return NULL;
00122 }
00123 if ( (NULL == pp) || (NULL == *pp) )
00124 {
00125 return NULL;
00126 }
00127 ASN1_CTX c;
00128 c.pp = pp;
00129 c.q = *pp;
00130 c.error = ERR_R_NESTED_ASN1_ERROR;
00131 int i;
00132
00133 M_ASN1_D2I_Init();
00134 M_ASN1_D2I_start_sequence();
00135 M_ASN1_D2I_get(i, CODEX_Client::BlindKeyMsg::unmarshal);
00136 #ifdef ELGAMAL
00137 M_ASN1_D2I_get(i, m_label.unmarshal);
00138 for ( unsigned int count = 0 ; count < NumProofs ; ++count )
00139 {
00140 M_ASN1_D2I_get(i, m_partials[count].unmarshal);
00141 M_ASN1_D2I_get(i, m_proofs[count].unmarshal);
00142 }
00143 #endif
00144 M_ASN1_D2I_get(i, m_blindCipher.unmarshal);
00145 if ( !asn1_Finish(&c) )
00146 {
00147 return NULL;
00148 }
00149 *pp=c.p;
00150 m_initialized = true;
00151 return this;
00152 err:
00153 return NULL;
00154 }