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
00023 BoundNameMsg::BoundNameMsg() :
00024 Message( false )
00025 {
00026 }
00027
00028 BoundNameMsg::BoundNameMsg( const OctetString& name,
00029 const SignedCreateKeyMsg& request ) :
00030 Message( true ),
00031 m_name( name ),
00032 m_request( request )
00033 {
00034 }
00035
00036 BoundNameMsg::BoundNameMsg( const BoundNameMsg& aBNM ) :
00037 Message( aBNM.m_initialized ),
00038 m_name( aBNM.m_name ),
00039 m_request( aBNM.m_request )
00040 {
00041 }
00042
00043 void
00044 BoundNameMsg::operator=( const BoundNameMsg& aBNM )
00045 {
00046 m_initialized = aBNM.m_initialized;
00047 m_name = aBNM.m_name;
00048 m_request = aBNM.m_request;
00049 }
00050
00051 int
00052 BoundNameMsg::marshal( unsigned char ** pp ) const
00053 {
00054 int r=0;
00055 int ret=0;
00056 unsigned char * p;
00057
00058 ret += m_name.marshal(0);
00059 ret += m_request.marshal(0);
00060 M_ASN1_I2D_seq_total();
00061 m_name.marshal(&p);
00062 m_request.marshal(&p);
00063 M_ASN1_I2D_finish();
00064 }
00065
00066 void*
00067 BoundNameMsg::unmarshal( void* bogus, unsigned char ** pp, long length )
00068 {
00069 if ( m_initialized )
00070 {
00071 return NULL;
00072 }
00073 if ( (NULL == pp) || (NULL == *pp) )
00074 {
00075 return NULL;
00076 }
00077 ASN1_CTX c;
00078 c.pp = pp;
00079 c.q = *pp;
00080 c.error = ERR_R_NESTED_ASN1_ERROR;
00081 int i;
00082
00083 M_ASN1_D2I_Init();
00084 M_ASN1_D2I_start_sequence();
00085 M_ASN1_D2I_get(i, m_name.unmarshal);
00086 M_ASN1_D2I_get(i, m_request.unmarshal);
00087 if ( !asn1_Finish(&c) )
00088 {
00089 return NULL;
00090 }
00091 *pp=c.p;
00092 m_initialized = true;
00093 return this;
00094 err:
00095 return NULL;
00096 }