00001 /* 00002 * Copyright 2003 Michael A. Marsh, Cornell University. All rights reserved. 00003 * This software is released under the modified BSD license. 00004 * See the file LICENSE in the top-level directory for details. 00005 */ 00006 // 00007 // $Id: LabeledReadKeyMsg.cc,v 1.3 2004/05/19 15:56:52 mmarsh Exp $ 00008 // 00009 // $Log: LabeledReadKeyMsg.cc,v $ 00010 // Revision 1.3 2004/05/19 15:56:52 mmarsh 00011 // *** empty log message *** 00012 // 00013 // Revision 1.2 2003/11/04 22:31:49 mmarsh 00014 // *** empty log message *** 00015 // 00016 // 00017 00018 #include "LabeledReadKeyMsg.h" 00019 #include "ClientMessageEvent.h" 00020 00021 using namespace CODEX_KeyService; 00022 00023 LabeledReadKeyMsg::LabeledReadKeyMsg() : 00024 CODEX_Client::SignedReadKeyMsg() 00025 { 00026 } 00027 00028 LabeledReadKeyMsg::LabeledReadKeyMsg( 00029 const CODEX_Client::SignedReadKeyMsg& aRKM, 00030 const LabelType& label ) : 00031 CODEX_Client::SignedReadKeyMsg( aRKM ), 00032 m_label( label ) 00033 { 00034 } 00035 00036 LabeledReadKeyMsg::LabeledReadKeyMsg( const LabeledReadKeyMsg& aRKM ) : 00037 CODEX_Client::SignedReadKeyMsg( aRKM ), 00038 m_label( aRKM.m_label ) 00039 { 00040 } 00041 00042 void 00043 LabeledReadKeyMsg::operator=( const LabeledReadKeyMsg& aRKM ) 00044 { 00045 CODEX_Client::SignedReadKeyMsg::operator=( aRKM ); 00046 m_label = aRKM.m_label; 00047 } 00048 00049 int 00050 LabeledReadKeyMsg::marshal( unsigned char ** pp ) const 00051 { 00052 typedef CODEX_Client::SignedReadKeyMsg BaseType; 00053 int r=0; 00054 int ret=0; 00055 unsigned char * p; 00056 00057 ret += BaseType::marshal(0); 00058 ret += m_label.marshal(0); 00059 M_ASN1_I2D_seq_total(); 00060 BaseType::marshal(&p); 00061 m_label.marshal(&p); 00062 M_ASN1_I2D_finish(); 00063 } 00064 00065 void* 00066 LabeledReadKeyMsg::unmarshal( void* bogus, unsigned char ** pp, long length ) 00067 { 00068 typedef CODEX_Client::SignedReadKeyMsg BaseType; 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, BaseType::unmarshal); 00086 M_ASN1_D2I_get(i, m_label.unmarshal); 00087 if ( !asn1_Finish(&c) ) 00088 { 00089 return NULL; 00090 } 00091 *pp=c.p; 00092 m_initialized = true; 00093 return this; 00094 err: // needed by ASN.1 macros 00095 return NULL; 00096 }
1.4.1