BeeCrypt  4.2.1
mpbarrett.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2003 Bob Deblier
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  */
19 
26 #ifndef _MPBARRETT_H
27 #define _MPBARRETT_H
28 
29 #include "beecrypt/beecrypt.h"
30 #include "beecrypt/mpnumber.h"
31 
32 #ifdef __cplusplus
33 # include <iostream>
34 #endif
35 
36 #ifdef __cplusplus
38 #else
39 struct _mpbarrett
40 #endif
41 {
42  size_t size;
43  mpw* modl; /* (size) words */
44  mpw* mu; /* (size+1) words */
45 
46 #ifdef __cplusplus
50 
51  const mpbarrett& operator=(const mpbarrett&);
52 
53  void wipe();
54 
55  size_t bitlength() const;
56 #endif
57 };
58 
59 #ifndef __cplusplus
60 typedef struct _mpbarrett mpbarrett;
61 #else
63 std::ostream& operator<<(std::ostream&, const mpbarrett&);
64 #endif
65 
66 #ifdef __cplusplus
67 extern "C" {
68 #endif
69 
73 void mpbinit(mpbarrett*, size_t);
77 void mpbcopy(mpbarrett*, const mpbarrett*);
80 
82 void mpbset(mpbarrett*, size_t, const mpw*);
83 
85 int mpbsetbin(mpbarrett*, const byte*, size_t);
87 int mpbsethex(mpbarrett*, const char*);
88 
90 void mpbsubone(const mpbarrett*, mpw*);
91 
94 
101 
103 void mpbneg_w(const mpbarrett*, const mpw*, mpw*);
105 void mpbmod_w(const mpbarrett*, const mpw*, mpw*, mpw*);
106 
108 void mpbaddmod_w(const mpbarrett*, size_t, const mpw*, size_t, const mpw*, mpw*, mpw*);
110 void mpbsubmod_w(const mpbarrett*, size_t, const mpw*, size_t, const mpw*, mpw*, mpw*);
112 void mpbmulmod_w(const mpbarrett*, size_t, const mpw*, size_t, const mpw*, mpw*, mpw*);
114 void mpbsqrmod_w(const mpbarrett*, size_t, const mpw*, mpw*, mpw*);
116 void mpbpowmod_w(const mpbarrett*, size_t, const mpw*, size_t, const mpw*, mpw*, mpw*);
118 void mpbpowmodsld_w(const mpbarrett*, const mpw*, size_t, const mpw*, mpw*, mpw*);
120 void mpbtwopowmod_w(const mpbarrett*, size_t, const mpw*, mpw*, mpw*);
121 
122 /* To be added:
123  * simultaneous multiple exponentiation, for use in dsa and elgamal signature verification
124  */
126 void mpbsm2powmod(const mpbarrett*, const mpw*, const mpw*, const mpw*, const mpw*);
128 void mpbsm3powmod(const mpbarrett*, const mpw*, const mpw*, const mpw*, const mpw*, const mpw*, const mpw*);
129 
132 
133 /* the next routines take mpnumbers as parameters */
134 
137 
139 void mpbnmulmod(const mpbarrett*, const mpnumber*, const mpnumber*, mpnumber*);
141 void mpbnsqrmod(const mpbarrett*, const mpnumber*, mpnumber*);
142 
144 void mpbnpowmod (const mpbarrett*, const mpnumber*, const mpnumber*, mpnumber*);
146 void mpbnpowmodsld(const mpbarrett*, const mpw*, const mpnumber*, mpnumber*);
147 
149 size_t mpbbits(const mpbarrett*);
150 
151 #ifdef __cplusplus
152 }
153 #endif
154 
155 #endif
mpbsm2powmod
void mpbsm2powmod(const mpbarrett *, const mpw *, const mpw *, const mpw *, const mpw *)
mpbmu_w
void mpbmu_w(mpbarrett *, mpw *)
mpnumber.h
Multi-precision numbers, headers.
mpbsubone
void mpbsubone(const mpbarrett *, mpw *)
beecrypt.h
BeeCrypt API, headers.
mpbarrett::size
size_t size
Definition: mpbarrett.h:42
mpbwipe
void mpbwipe(mpbarrett *)
mpbnpowmod
void mpbnpowmod(const mpbarrett *, const mpnumber *, const mpnumber *, mpnumber *)
mpbsubmod_w
void mpbsubmod_w(const mpbarrett *, size_t, const mpw *, size_t, const mpw *, mpw *, mpw *)
mpbcopy
void mpbcopy(mpbarrett *, const mpbarrett *)
BEECRYPTAPI
#define BEECRYPTAPI
Definition: api.h:52
mpbinit
void mpbinit(mpbarrett *, size_t)
mpbnpowmodsld
void mpbnpowmodsld(const mpbarrett *, const mpw *, const mpnumber *, mpnumber *)
mpbarrett::modl
mpw * modl
Definition: mpbarrett.h:43
mpbrndodd_w
void mpbrndodd_w(const mpbarrett *, randomGeneratorContext *, mpw *, mpw *)
mpbaddmod_w
void mpbaddmod_w(const mpbarrett *, size_t, const mpw *, size_t, const mpw *, mpw *, mpw *)
mpbnrnd
void mpbnrnd(const mpbarrett *, randomGeneratorContext *, mpnumber *)
mpbarrett::mpbarrett
mpbarrett(const mpbarrett &)
mpbarrett::~mpbarrett
~mpbarrett()
mpbsetbin
int mpbsetbin(mpbarrett *, const byte *, size_t)
mpbneg_w
void mpbneg_w(const mpbarrett *, const mpw *, mpw *)
mpbzero
void mpbzero(mpbarrett *)
mpbpowmod_w
void mpbpowmod_w(const mpbarrett *, size_t, const mpw *, size_t, const mpw *, mpw *, mpw *)
mpbmulmod_w
void mpbmulmod_w(const mpbarrett *, size_t, const mpw *, size_t, const mpw *, mpw *, mpw *)
mpw
uint32_t mpw
Definition: api.h:94
mpbfree
void mpbfree(mpbarrett *)
mpbsethex
int mpbsethex(mpbarrett *, const char *)
mpbpprime_w
int mpbpprime_w(const mpbarrett *, randomGeneratorContext *, int, mpw *)
mpbarrett::mpbarrett
mpbarrett()
mpbnsqrmod
void mpbnsqrmod(const mpbarrett *, const mpnumber *, mpnumber *)
mpbtwopowmod_w
void mpbtwopowmod_w(const mpbarrett *, size_t, const mpw *, mpw *, mpw *)
mpbarrett::operator=
const mpbarrett & operator=(const mpbarrett &)
mpbset
void mpbset(mpbarrett *, size_t, const mpw *)
mpbarrett::mu
mpw * mu
Definition: mpbarrett.h:44
mpbnmulmod
void mpbnmulmod(const mpbarrett *, const mpnumber *, const mpnumber *, mpnumber *)
operator<<
std::ostream & operator<<(std::ostream &, const mpbarrett &)
mpnumber
Definition: mpnumber.h:40
mpbarrett
Definition: mpbarrett.h:41
mpbbits
size_t mpbbits(const mpbarrett *)
mpbrndinv_w
void mpbrndinv_w(const mpbarrett *, randomGeneratorContext *, mpw *, mpw *, mpw *)
mpbmod_w
void mpbmod_w(const mpbarrett *, const mpw *, mpw *, mpw *)
mpbarrett::bitlength
size_t bitlength() const
mpbrnd_w
void mpbrnd_w(const mpbarrett *, randomGeneratorContext *, mpw *, mpw *)
mpbsqrmod_w
void mpbsqrmod_w(const mpbarrett *, size_t, const mpw *, mpw *, mpw *)
mpbpowmodsld_w
void mpbpowmodsld_w(const mpbarrett *, const mpw *, size_t, const mpw *, mpw *, mpw *)
randomGeneratorContext
Definition: beecrypt.h:239
mpbarrett::wipe
void wipe()
mpbsm3powmod
void mpbsm3powmod(const mpbarrett *, const mpw *, const mpw *, const mpw *, const mpw *, const mpw *, const mpw *)