Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ReadKeyMsg.cc

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: ReadKeyMsg.cc,v 1.4 2004/05/19 15:56:48 mmarsh Exp $
00008 //
00009 // $Log: ReadKeyMsg.cc,v $
00010 // Revision 1.4  2004/05/19 15:56:48  mmarsh
00011 // *** empty log message ***
00012 //
00013 // Revision 1.3  2003/11/04 22:31:48  mmarsh
00014 // *** empty log message ***
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 ReadKeyMsg::ReadKeyMsg() :
00025    Message( false )
00026 {
00027 }
00028 
00029 ReadKeyMsg::ReadKeyMsg( const OctetString& name,
00030                         const BlindingCipherTextType& blinding,
00031 #ifndef ELGAMAL
00032                         const RSAPlaintextPK& proof,
00033 #endif
00034                         const Credentials& credentials ) :
00035    Message( true ),
00036    m_name( name ),
00037    m_blinding( blinding ),
00038 #ifndef ELGAMAL
00039    m_proof( proof ),
00040 #endif
00041    m_credentials( credentials )
00042 {
00043 }
00044 
00045 ReadKeyMsg::ReadKeyMsg( const ReadKeyMsg& aRKM ) :
00046    Message( aRKM.m_initialized ),
00047    m_name( aRKM.m_name ),
00048    m_blinding( aRKM.m_blinding ),
00049 #ifndef ELGAMAL
00050    m_proof( aRKM.m_proof ),
00051 #endif
00052    m_credentials( aRKM.m_credentials )
00053 {
00054 }
00055 
00056 void
00057 ReadKeyMsg::operator=( const ReadKeyMsg& aRKM )
00058 {
00059    m_initialized = aRKM.m_initialized;
00060    m_name        = aRKM.m_name;
00061    m_blinding    = aRKM.m_blinding;
00062 #ifndef ELGAMAL
00063    m_proof       = aRKM.m_proof;
00064 #endif
00065    m_credentials = aRKM.m_credentials;
00066 }
00067 
00068 int
00069 ReadKeyMsg::marshal( unsigned char ** pp ) const
00070 {
00071    int r=0;
00072    int ret=0;
00073    unsigned char * p;
00074 
00075    ret += m_name.marshal(0);
00076    ret += m_blinding.marshal(0);
00077 #ifndef ELGAMAL
00078    ret += m_proof.marshal(0);
00079 #endif
00080    ret += m_credentials.marshal(0);
00081    M_ASN1_I2D_seq_total();
00082    m_name.marshal(&p);
00083    m_blinding.marshal(&p);
00084 #ifndef ELGAMAL
00085    m_proof.marshal(&p);
00086 #endif
00087    m_credentials.marshal(&p);
00088    M_ASN1_I2D_finish();
00089 }
00090 
00091 void*
00092 ReadKeyMsg::unmarshal( void* bogus, unsigned char ** pp, long length )
00093 {
00094    if ( m_initialized )
00095    {
00096       return NULL;
00097    }
00098    if ( (NULL == pp) || (NULL == *pp) )
00099    {
00100       return NULL;
00101    }
00102    ASN1_CTX c;
00103    c.pp = pp;
00104    c.q = *pp;
00105    c.error = ERR_R_NESTED_ASN1_ERROR;
00106    int i;
00107 
00108    M_ASN1_D2I_Init();
00109    M_ASN1_D2I_start_sequence();
00110    M_ASN1_D2I_get(i, m_name.unmarshal);
00111    M_ASN1_D2I_get(i, m_blinding.unmarshal);
00112 #ifndef ELGAMAL
00113    M_ASN1_D2I_get(i, m_proof.unmarshal);
00114 #endif
00115    M_ASN1_D2I_get(i, m_credentials.unmarshal);
00116    if ( !asn1_Finish(&c) )
00117    {
00118       return NULL;
00119    }
00120    *pp=c.p;
00121    m_initialized = true;
00122    return this;
00123   err: // needed by ASN.1 macros
00124    return NULL;
00125 }

Generated on Fri May 6 17:40:52 2005 for COrnell Data EXchange (CODEX) by  doxygen 1.4.1