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

CODEX_APSS/Message.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: Message.cc,v 1.3 2004/05/19 15:56:24 mmarsh Exp $
00008 //
00009 // $Log: Message.cc,v $
00010 // Revision 1.3  2004/05/19 15:56:24  mmarsh
00011 // Added copyright and license statements.
00012 //
00013 // Revision 1.2  2003/11/04 22:31:45  mmarsh
00014 // *** empty log message ***
00015 //
00016 //
00017 
00018 #include "CODEX_Exceptions/BignumExceptions.h"
00019 #include "Message.h"
00020 
00021 using namespace CODEX_APSS;
00022 
00023 BIGNUM *
00024 Message::digest( const CODEX_Ciphers::HashFunction& hf ) const
00025 {
00026    unsigned char* buff = NULL;
00027    BIGNUM * retVal = NULL;
00028    CODEX_ASN1::ustring* str = NULL;
00029 
00030    try
00031    {
00032       int length = marshal(0);
00033       buff = new unsigned char[ length ];
00034       unsigned char* pBuff = buff;
00035       marshal(&pBuff);
00036       str = hf( CODEX_ASN1::ustring( buff, length ) );
00037       delete [] buff;
00038       buff = NULL;
00039       retVal = BN_new();
00040       if ( NULL == retVal )
00041       {
00042          throw CODEX_Exceptions::BignumNullException( __FILE__ , __LINE__ );
00043       }
00044       if ( NULL == BN_bin2bn( str->data(), str->length(), retVal ) )
00045       {
00046          throw CODEX_Exceptions::BignumBin2BNException( __FILE__ , __LINE__ );
00047       }
00048       delete str;
00049 
00050       return retVal;
00051    }
00052    catch ( ... )
00053    {
00054       if ( NULL != buff ) delete buff;
00055       if ( NULL != str ) delete str;
00056       if ( NULL != retVal ) BN_free( retVal );
00057       throw;
00058    }
00059 }
00060 
00061 template SignedInitMsg;
00062 template SignedEstablishMsg;
00063 template SignedEstablishedMsg;
00064 template SignedContributeMsg;
00065 template SignedComputeMsg;
00066 template SignedComputedMsg;
00067 template SignedFinishedMsg;
00068 template SignedRecoverMsg;
00069 template SignedRecoveredMsg;

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