BeeCrypt
4.2.1
|
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(size_t, const mpw*); 00051 mpnumber(const mpnumber&); 00052 ~mpnumber(); 00053 00054 const mpnumber& operator=(const mpnumber&); 00055 00056 void wipe(); 00057 00058 size_t bitlength() const; 00059 #endif 00060 }; 00061 00062 #ifndef __cplusplus 00063 typedef struct _mpnumber mpnumber; 00064 #else 00065 BEECRYPTAPI 00066 std::ostream& operator<<(std::ostream&, const mpnumber&); 00067 #endif 00068 00069 #ifdef __cplusplus 00070 extern "C" { 00071 #endif 00072 00073 BEECRYPTAPI 00074 void mpnzero(mpnumber*); 00075 BEECRYPTAPI 00076 void mpnsize(mpnumber*, size_t); 00077 BEECRYPTAPI 00078 void mpninit(mpnumber*, size_t, const mpw*); 00079 BEECRYPTAPI 00080 void mpnfree(mpnumber*); 00081 BEECRYPTAPI 00082 void mpncopy(mpnumber*, const mpnumber*); 00083 BEECRYPTAPI 00084 void mpnwipe(mpnumber*); 00085 00086 BEECRYPTAPI 00087 void mpnset (mpnumber*, size_t, const mpw*); 00088 BEECRYPTAPI 00089 void mpnsetw (mpnumber*, mpw); 00090 00091 BEECRYPTAPI 00092 int mpnsetbin(mpnumber*, const byte*, size_t); 00093 BEECRYPTAPI 00094 int mpnsethex(mpnumber*, const char*); 00095 00096 BEECRYPTAPI 00097 int mpninv(mpnumber*, const mpnumber*, const mpnumber*); 00098 00101 BEECRYPTAPI 00102 size_t mpntrbits(mpnumber*, size_t); 00103 BEECRYPTAPI 00104 size_t mpnbits(const mpnumber*); 00105 00106 #ifdef __cplusplus 00107 } 00108 #endif 00109 00110 #endif