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