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

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

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