mpbarrett.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 _MPBARRETT_H
00027 #define _MPBARRETT_H
00028 
00029 #include "beecrypt/beecrypt.h"
00030 #include "beecrypt/mpnumber.h"
00031 
00032 #ifdef __cplusplus
00033 # include <iostream>
00034 #endif
00035 
00036 #ifdef __cplusplus
00037 struct BEECRYPTAPI mpbarrett
00038 #else
00039 struct _mpbarrett
00040 #endif
00041 {
00042     size_t  size;
00043     mpw*    modl;   /* (size) words */
00044     mpw*    mu;     /* (size+1) words */
00045 
00046 #ifdef __cplusplus
00047     mpbarrett();
00048     mpbarrett(const mpbarrett&);
00049     ~mpbarrett();
00050                                                                                 
00051     const mpbarrett& operator=(const mpbarrett&);
00052     bool operator==(const mpbarrett&) const throw ();
00053     bool operator!=(const mpbarrett&) const throw ();
00054                                                                                 
00055     void wipe();
00056     size_t bitlength() const throw ();
00057 #endif
00058 };
00059 
00060 #ifndef __cplusplus
00061 typedef struct _mpbarrett mpbarrett;
00062 #else
00063 BEECRYPTAPI
00064 std::ostream& operator<<(std::ostream&, const mpbarrett&);
00065 #endif
00066 
00067 #ifdef __cplusplus
00068 extern "C" {
00069 #endif
00070 
00071 BEECRYPTAPI
00072 void mpbzero(mpbarrett*);
00073 BEECRYPTAPI
00074 void mpbinit(mpbarrett*, size_t);
00075 BEECRYPTAPI
00076 void mpbfree(mpbarrett*);
00077 BEECRYPTAPI
00078 void mpbcopy(mpbarrett*, const mpbarrett*);
00079 BEECRYPTAPI
00080 void mpbwipe(mpbarrett*);
00081 
00082 BEECRYPTAPI
00083 void mpbset(mpbarrett*, size_t, const mpw*);
00084 
00085 BEECRYPTAPI
00086 int mpbsetbin(mpbarrett*, const byte*, size_t);
00087 BEECRYPTAPI
00088 int mpbsethex(mpbarrett*, const char*);
00089 
00090 BEECRYPTAPI
00091 void mpbsubone(const mpbarrett*, mpw*);
00092 
00093 BEECRYPTAPI
00094 void mpbmu_w(mpbarrett*, mpw*);
00095 
00096 BEECRYPTAPI
00097 void mpbrnd_w   (const mpbarrett*, randomGeneratorContext*, mpw*, mpw*);
00098 BEECRYPTAPI
00099 void mpbrndodd_w(const mpbarrett*, randomGeneratorContext*, mpw*, mpw*);
00100 BEECRYPTAPI
00101 void mpbrndinv_w(const mpbarrett*, randomGeneratorContext*, mpw*, mpw*, mpw*);
00102 
00103 BEECRYPTAPI
00104 void mpbneg_w(const mpbarrett*, const mpw*, mpw*);
00105 BEECRYPTAPI
00106 void mpbmod_w(const mpbarrett*, const mpw*, mpw*, mpw*);
00107 
00108 BEECRYPTAPI
00109 void mpbaddmod_w(const mpbarrett*, size_t, const mpw*, size_t, const mpw*, mpw*, mpw*);
00110 BEECRYPTAPI
00111 void mpbsubmod_w(const mpbarrett*, size_t, const mpw*, size_t, const mpw*, mpw*, mpw*);
00112 BEECRYPTAPI
00113 void mpbmulmod_w(const mpbarrett*, size_t, const mpw*, size_t, const mpw*, mpw*, mpw*);
00114 BEECRYPTAPI
00115 void mpbsqrmod_w(const mpbarrett*, size_t, const mpw*, mpw*, mpw*);
00116 BEECRYPTAPI
00117 void mpbpowmod_w(const mpbarrett*, size_t, const mpw*, size_t, const mpw*, mpw*, mpw*);
00118 BEECRYPTAPI
00119 void mpbpowmodsld_w(const mpbarrett*, const mpw*, size_t, const mpw*, mpw*, mpw*);
00120 BEECRYPTAPI
00121 void mpbtwopowmod_w(const mpbarrett*, size_t, const mpw*, mpw*, mpw*);
00122 
00123 /* To be added:
00124  * simultaneous multiple exponentiation, for use in dsa and elgamal signature verification
00125  */
00126 BEECRYPTAPI
00127 void mpbsm2powmod(const mpbarrett*, const mpw*, const mpw*, const mpw*, const mpw*);
00128 BEECRYPTAPI
00129 void mpbsm3powmod(const mpbarrett*, const mpw*, const mpw*, const mpw*, const mpw*, const mpw*, const mpw*);
00130 
00131 BEECRYPTAPI
00132 int  mpbpprime_w(const mpbarrett*, randomGeneratorContext*, int, mpw*);
00133 
00134 /* the next routines take mpnumbers as parameters */
00135 
00136 BEECRYPTAPI
00137 void mpbnrnd(const mpbarrett*, randomGeneratorContext*, mpnumber*);
00138 
00139 BEECRYPTAPI
00140 void mpbnmulmod(const mpbarrett*, const mpnumber*, const mpnumber*, mpnumber*);
00141 BEECRYPTAPI
00142 void mpbnsqrmod(const mpbarrett*, const mpnumber*, mpnumber*);
00143 
00144 BEECRYPTAPI
00145 void mpbnpowmod   (const mpbarrett*, const mpnumber*, const mpnumber*, mpnumber*);
00146 BEECRYPTAPI
00147 void mpbnpowmodsld(const mpbarrett*, const mpw*, const mpnumber*, mpnumber*);
00148 
00149 BEECRYPTAPI
00150 size_t mpbbits(const mpbarrett*);
00151 
00152 #ifdef __cplusplus
00153 }
00154 #endif
00155 
00156 #endif

Generated on Wed Aug 22 06:25:06 2007 for BeeCrypt by  doxygen 1.5.2