00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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:
00086 return NULL;
00087 }