00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "Message.h"
00019
00020 using namespace CODEX_Client;
00021 using namespace CODEX_ASN1;
00022 using namespace CODEX_Ciphers;
00023
00024 BlindKeyMsg::BlindKeyMsg() :
00025 Message( false )
00026 {
00027 }
00028
00029 BlindKeyMsg::BlindKeyMsg( const OctetString& name,
00030 const BlindPlainTextType& blindedKey,
00031 const RSASignature& requestSignature ) :
00032 Message( true ),
00033 m_name( name ),
00034 m_blindedKey( blindedKey ),
00035 m_requestSignature( requestSignature )
00036 {
00037 }
00038
00039 BlindKeyMsg::BlindKeyMsg( const BlindKeyMsg& aBKM ) :
00040 Message( aBKM.m_initialized ),
00041 m_name( aBKM.m_name ),
00042 m_blindedKey( aBKM.m_blindedKey ),
00043 m_requestSignature( aBKM.m_requestSignature )
00044 {
00045 }
00046
00047 void
00048 BlindKeyMsg::operator=( const BlindKeyMsg& aBKM )
00049 {
00050 m_initialized = aBKM.m_initialized;
00051 m_name = aBKM.m_name;
00052 m_blindedKey = aBKM.m_blindedKey;
00053 m_requestSignature = aBKM.m_requestSignature;
00054 }
00055
00056 int
00057 BlindKeyMsg::marshal( unsigned char ** pp ) const
00058 {
00059 int r=0;
00060 int ret=0;
00061 unsigned char * p;
00062
00063 ret += m_name.marshal(0);
00064 ret += m_blindedKey.marshal(0);
00065 ret += m_requestSignature.marshal(0);
00066 M_ASN1_I2D_seq_total();
00067 m_name.marshal(&p);
00068 m_blindedKey.marshal(&p);
00069 m_requestSignature.marshal(&p);
00070 M_ASN1_I2D_finish();
00071 }
00072
00073 void*
00074 BlindKeyMsg::unmarshal( void* bogus, unsigned char ** pp, long length )
00075 {
00076 if ( m_initialized )
00077 {
00078 return NULL;
00079 }
00080 if ( (NULL == pp) || (NULL == *pp) )
00081 {
00082 return NULL;
00083 }
00084 ASN1_CTX c;
00085 c.pp = pp;
00086 c.q = *pp;
00087 c.error = ERR_R_NESTED_ASN1_ERROR;
00088 int i;
00089
00090 M_ASN1_D2I_Init();
00091 M_ASN1_D2I_start_sequence();
00092 M_ASN1_D2I_get(i, m_name.unmarshal);
00093 M_ASN1_D2I_get(i, m_blindedKey.unmarshal);
00094 M_ASN1_D2I_get(i, m_requestSignature.unmarshal);
00095 if ( !asn1_Finish(&c) )
00096 {
00097 return NULL;
00098 }
00099 *pp=c.p;
00100 m_initialized = true;
00101 return this;
00102 err:
00103 return NULL;
00104 }