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: ModIntRange.cc,v 1.3 2004/05/19 15:57:01 mmarsh Exp $ 00008 // 00009 // $Log: ModIntRange.cc,v $ 00010 // Revision 1.3 2004/05/19 15:57:01 mmarsh 00011 // *** empty log message *** 00012 // 00013 // Revision 1.2 2003/11/04 22:23:08 mmarsh 00014 // General code cleanup. 00015 // 00016 // 00017 00018 #include "ModIntRange.h" 00019 #include "CODEX_Exceptions/BignumExceptions.h" 00020 00021 using namespace CODEX_VSS; 00022 00023 ModIntRange::ModIntRange( const BIGNUM * modulus ) 00024 { 00025 m_min = BN_new(); 00026 if ( 0 == m_min ) 00027 { 00028 throw CODEX_Exceptions::BignumNullException( __FILE__ , __LINE__ ); 00029 } 00030 if ( ! BN_zero( m_min ) ) 00031 { 00032 throw CODEX_Exceptions::BignumSetWordException( __FILE__ , __LINE__ ); 00033 } 00034 00035 m_max = BN_new(); 00036 if ( 0 == m_max ) 00037 { 00038 throw CODEX_Exceptions::BignumNullException( __FILE__ , __LINE__ ); 00039 } 00040 if ( ! BN_sub( m_max, modulus, BN_value_one() ) ) 00041 { 00042 throw CODEX_Exceptions::BignumSubException( __FILE__ , __LINE__ ); 00043 } 00044 } 00045 00046 ModIntRange::~ModIntRange() 00047 { 00048 if ( 0 != m_min ) BN_free( m_min ); 00049 if ( 0 != m_max ) BN_free( m_max ); 00050 }
1.4.1