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
25
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
39struct _mpbarrett
40#endif
41{
42 size_t size;
43 mpw* modl; /* (size) words */
44 mpw* mu; /* (size+1) words */
45
46#ifdef __cplusplus
50
52
53 void wipe();
54
55 size_t bitlength() const;
56#endif
57};
58
59#ifndef __cplusplus
60typedef struct _mpbarrett mpbarrett;
61#else
63std::ostream& operator<<(std::ostream&, const mpbarrett&);
64#endif
65
66#ifdef __cplusplus
67extern "C" {
68#endif
69
73void mpbinit(mpbarrett*, size_t);
80
82void mpbset(mpbarrett*, size_t, const mpw*);
83
85int mpbsetbin(mpbarrett*, const byte*, size_t);
87int mpbsethex(mpbarrett*, const char*);
88
90void mpbsubone(const mpbarrett*, mpw*);
91
94
101
103void mpbneg_w(const mpbarrett*, const mpw*, mpw*);
105void mpbmod_w(const mpbarrett*, const mpw*, mpw*, mpw*);
106
108void mpbaddmod_w(const mpbarrett*, size_t, const mpw*, size_t, const mpw*, mpw*, mpw*);
110void mpbsubmod_w(const mpbarrett*, size_t, const mpw*, size_t, const mpw*, mpw*, mpw*);
112void mpbmulmod_w(const mpbarrett*, size_t, const mpw*, size_t, const mpw*, mpw*, mpw*);
114void mpbsqrmod_w(const mpbarrett*, size_t, const mpw*, mpw*, mpw*);
116void mpbpowmod_w(const mpbarrett*, size_t, const mpw*, size_t, const mpw*, mpw*, mpw*);
118void mpbpowmodsld_w(const mpbarrett*, const mpw*, size_t, const mpw*, mpw*, mpw*);
120void 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 */
126void mpbsm2powmod(const mpbarrett*, const mpw*, const mpw*, const mpw*, const mpw*);
128void 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
139void mpbnmulmod(const mpbarrett*, const mpnumber*, const mpnumber*, mpnumber*);
141void mpbnsqrmod(const mpbarrett*, const mpnumber*, mpnumber*);
142
144void mpbnpowmod (const mpbarrett*, const mpnumber*, const mpnumber*, mpnumber*);
146void mpbnpowmodsld(const mpbarrett*, const mpw*, const mpnumber*, mpnumber*);
147
149size_t mpbbits(const mpbarrett*);
150
151#ifdef __cplusplus
152}
153#endif
154
155#endif
#define BEECRYPTAPI
Definition api.h:52
uint64_t mpw
Definition api.h:87
BeeCrypt API, headers.
void mpbwipe(mpbarrett *)
void mpbset(mpbarrett *, size_t, const mpw *)
void mpbpowmodsld_w(const mpbarrett *, const mpw *, size_t, const mpw *, mpw *, mpw *)
void mpbzero(mpbarrett *)
void mpbrnd_w(const mpbarrett *, randomGeneratorContext *, mpw *, mpw *)
void mpbnrnd(const mpbarrett *, randomGeneratorContext *, mpnumber *)
std::ostream & operator<<(std::ostream &, const mpbarrett &)
void mpbsubone(const mpbarrett *, mpw *)
void mpbmulmod_w(const mpbarrett *, size_t, const mpw *, size_t, const mpw *, mpw *, mpw *)
void mpbsubmod_w(const mpbarrett *, size_t, const mpw *, size_t, const mpw *, mpw *, mpw *)
void mpbcopy(mpbarrett *, const mpbarrett *)
void mpbtwopowmod_w(const mpbarrett *, size_t, const mpw *, mpw *, mpw *)
size_t mpbbits(const mpbarrett *)
void mpbrndodd_w(const mpbarrett *, randomGeneratorContext *, mpw *, mpw *)
void mpbnmulmod(const mpbarrett *, const mpnumber *, const mpnumber *, mpnumber *)
void mpbnsqrmod(const mpbarrett *, const mpnumber *, mpnumber *)
void mpbfree(mpbarrett *)
void mpbrndinv_w(const mpbarrett *, randomGeneratorContext *, mpw *, mpw *, mpw *)
void mpbsm3powmod(const mpbarrett *, const mpw *, const mpw *, const mpw *, const mpw *, const mpw *, const mpw *)
void mpbnpowmod(const mpbarrett *, const mpnumber *, const mpnumber *, mpnumber *)
int mpbpprime_w(const mpbarrett *, randomGeneratorContext *, int, mpw *)
void mpbsm2powmod(const mpbarrett *, const mpw *, const mpw *, const mpw *, const mpw *)
void mpbmu_w(mpbarrett *, mpw *)
void mpbinit(mpbarrett *, size_t)
int mpbsethex(mpbarrett *, const char *)
void mpbaddmod_w(const mpbarrett *, size_t, const mpw *, size_t, const mpw *, mpw *, mpw *)
void mpbmod_w(const mpbarrett *, const mpw *, mpw *, mpw *)
void mpbnpowmodsld(const mpbarrett *, const mpw *, const mpnumber *, mpnumber *)
void mpbneg_w(const mpbarrett *, const mpw *, mpw *)
void mpbsqrmod_w(const mpbarrett *, size_t, const mpw *, mpw *, mpw *)
int mpbsetbin(mpbarrett *, const byte *, size_t)
void mpbpowmod_w(const mpbarrett *, size_t, const mpw *, size_t, const mpw *, mpw *, mpw *)
Multi-precision numbers, headers.
Definition mpbarrett.h:41
mpbarrett(const mpbarrett &)
size_t size
Definition mpbarrett.h:42
const mpbarrett & operator=(const mpbarrett &)
mpw * modl
Definition mpbarrett.h:43
size_t bitlength() const
mpw * mu
Definition mpbarrett.h:44
void wipe()
Definition mpnumber.h:40
Definition beecrypt.h:239