mpnumber.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2003 Bob Deblier
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017  *
00018  */
00019 
00026 #ifndef _MPNUMBER_H
00027 #define _MPNUMBER_H
00028 
00029 #include "beecrypt/mp.h"
00030 
00031 #ifdef __cplusplus
00032 # include <iostream>
00033 #endif
00034 
00035 #ifdef __cplusplus
00036 struct BEECRYPTAPI mpnumber
00037 #else
00038 struct _mpnumber
00039 #endif
00040 {
00041     size_t  size;
00042     mpw*    data;
00043 
00044 #ifdef __cplusplus
00045     static const mpnumber ZERO;
00046     static const mpnumber ONE;
00047 
00048     mpnumber();
00049     mpnumber(unsigned int);
00050     mpnumber(const mpnumber&);
00051     ~mpnumber();
00052 
00053     const mpnumber& operator=(const mpnumber&);
00054     bool operator==(const mpnumber&) const throw ();
00055     bool operator!=(const mpnumber&) const throw ();
00056 
00057     void wipe();
00058 
00059     size_t bitlength() const throw ();
00060 #endif
00061 };
00062 
00063 #ifndef __cplusplus
00064 typedef struct _mpnumber mpnumber;
00065 #else
00066 BEECRYPTAPI
00067 std::ostream& operator<<(std::ostream&, const mpnumber&);
00068 /*
00069 BEECRYPTAPI
00070 std::istream& operator>>(std::istream&, mpnumber&);
00071 */
00072 #endif
00073 
00074 #ifdef __cplusplus
00075 extern "C" {
00076 #endif
00077 
00078 BEECRYPTAPI
00079 void mpnzero(mpnumber*);
00080 BEECRYPTAPI
00081 void mpnsize(mpnumber*, size_t);
00082 BEECRYPTAPI
00083 void mpninit(mpnumber*, size_t, const mpw*);
00084 BEECRYPTAPI
00085 void mpnfree(mpnumber*);
00086 BEECRYPTAPI
00087 void mpncopy(mpnumber*, const mpnumber*);
00088 BEECRYPTAPI
00089 void mpnwipe(mpnumber*);
00090 
00091 BEECRYPTAPI
00092 void mpnset   (mpnumber*, size_t, const mpw*);
00093 BEECRYPTAPI
00094 void mpnsetw  (mpnumber*, mpw);
00095 
00096 BEECRYPTAPI
00097 int mpnsetbin(mpnumber*, const byte*, size_t);
00098 BEECRYPTAPI
00099 int mpnsethex(mpnumber*, const char*);
00100 
00101 BEECRYPTAPI
00102 int  mpninv(mpnumber*, const mpnumber*, const mpnumber*);
00103 
00106 BEECRYPTAPI
00107 size_t mpntrbits(mpnumber*, size_t);
00108 BEECRYPTAPI
00109 size_t mpnbits(const mpnumber*);
00110 
00111 #ifdef __cplusplus
00112 }
00113 #endif
00114 
00115 #endif

Generated on Sat Jan 19 01:53:19 2008 for BeeCrypt by  doxygen 1.5.4