• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

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

Generated on Thu Jul 22 2010 for BeeCrypt by  doxygen 1.7.1