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

RSACipherText.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: RSACipherText.cc,v 1.3 2004/05/19 15:56:47 mmarsh Exp $
00008 //
00009 // $Log: RSACipherText.cc,v $
00010 // Revision 1.3  2004/05/19 15:56:47  mmarsh
00011 // *** empty log message ***
00012 //
00013 // Revision 1.2  2003/11/04 22:31:47  mmarsh
00014 // *** empty log message ***
00015 //
00016 //
00017 
00018 #include "RSA.h"
00019 #include "CODEX_Exceptions/BignumExceptions.h"
00020 
00021 using namespace CODEX_Ciphers;
00022 
00023 RSACipherText*
00024 RSACipherText::blind( const RSACipherText& aOther,
00025                       const CODEX_ASN1::BigNumber& modulus ) const
00026 {
00027    RSACipherText* retVal = 0;
00028    // The notation is somewhat historical.
00029    const BIGNUM * kbn = value();
00030    const BIGNUM * b = aOther.value();
00031    const BIGNUM * n = modulus.value();
00032    BIGNUM * bk = 0;
00033    BN_CTX * ctx = 0;
00034    try
00035    {
00036       ctx = BN_CTX_new();
00037       if ( 0 == ctx )
00038       {
00039          throw CODEX_Exceptions::BignumContextException( __FILE__ , __LINE__ );
00040       }
00041       bk = BN_new();
00042       if ( 0 == bk )
00043       {
00044          throw CODEX_Exceptions::BignumNullException( __FILE__ , __LINE__ );
00045       }
00046       if ( ! BN_mod_mul( bk, b, kbn, n, ctx ) )
00047       {
00048          throw CODEX_Exceptions::BignumModMulException( __FILE__ , __LINE__ );
00049       }
00050       retVal = new RSACipherText( bk );
00051       bk = 0;
00052       BN_CTX_free( ctx );
00053       ctx = 0;
00054       return retVal;
00055    }
00056    catch ( ... )
00057    {
00058       if ( 0 != ctx ) BN_CTX_free( ctx );
00059       if ( 0 != bk ) BN_free( bk );
00060       throw;
00061    }
00062 }

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