Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   Related Pages  

ServerSignature.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: ServerSignature.cc,v 1.3 2004/05/19 15:56:58 mmarsh Exp $
00008 //
00009 // $Log: ServerSignature.cc,v $
00010 // Revision 1.3  2004/05/19 15:56:58  mmarsh
00011 // *** empty log message ***
00012 //
00013 // Revision 1.2  2003/11/04 22:31:51  mmarsh
00014 // *** empty log message ***
00015 //
00016 //
00017 
00018 #include "ServerSignature.h"
00019 #include "CODEX_ASN1/Array.h"
00020 
00021 using namespace CODEX_Server;
00022 
00023 ServerSignature::ServerSignature() :
00024    CODEX_ASN1::Base( false )
00025 {}
00026 
00027 ServerSignature::ServerSignature( unsigned int serverID ,
00028                                   const CODEX_Ciphers::RSASignature& sig ) :
00029    CODEX_ASN1::Base( true ),
00030    m_serverID( serverID ),
00031    m_signature( sig )
00032 {
00033 }
00034 
00035 ServerSignature::ServerSignature( const CODEX_ASN1::Integer& serverID,
00036                                   const CODEX_Ciphers::RSASignature& sig ) :
00037    CODEX_ASN1::Base( true ),
00038    m_serverID( serverID ),
00039    m_signature( sig )
00040 {
00041 }
00042 
00043 ServerSignature::ServerSignature( const ServerSignature& aOther ) :
00044    CODEX_ASN1::Base( aOther.m_initialized ),
00045    m_serverID( aOther.m_serverID ),
00046    m_signature( aOther.m_signature )
00047 {
00048 }
00049 
00050 void ServerSignature::operator=( const ServerSignature& aOther )
00051 {
00052    m_initialized = aOther.m_initialized;
00053    m_serverID    = aOther.m_serverID;
00054    m_signature   = aOther.m_signature;
00055 }
00056 
00057 int ServerSignature::marshal( unsigned char ** pp ) const
00058 {
00059    int r=0;
00060    int ret=0;
00061    unsigned char * p;
00062 
00063    ret += m_serverID.marshal(0);
00064    ret += m_signature.marshal(0);
00065    M_ASN1_I2D_seq_total();
00066    m_serverID.marshal(&p);
00067    m_signature.marshal(&p);
00068    M_ASN1_I2D_finish();
00069 }
00070 
00071 void* ServerSignature::unmarshal( void* bogus,
00072                                   unsigned char ** pp,
00073                                   long length )
00074 {
00075    if ( m_initialized )
00076    {
00077       return NULL;
00078    }
00079    if ( (NULL == pp) || (NULL == *pp) )
00080    {
00081       return NULL;
00082    }
00083    ASN1_CTX c;
00084    c.pp = pp;
00085    c.q = *pp;
00086    c.error = ERR_R_NESTED_ASN1_ERROR;
00087    int i;
00088 
00089    M_ASN1_D2I_Init();
00090    M_ASN1_D2I_start_sequence();
00091    M_ASN1_D2I_get(i, m_serverID.unmarshal);
00092    M_ASN1_D2I_get(i, m_signature.unmarshal);
00093    if ( !asn1_Finish(&c) )
00094    {
00095       return NULL;
00096    }
00097    *pp=c.p;
00098    m_initialized = true;
00099    return this;
00100   err: // needed by ASN.1 macros
00101    return NULL;
00102 }

Generated on Wed Jun 2 16:32:56 2004 for COrnell Data EXchange (CODEX) by doxygen1.2.18