BeeCrypt  4.2.1
mpnumber.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 _MPNUMBER_H
27 #define _MPNUMBER_H
28 
29 #include "beecrypt/mp.h"
30 
31 #ifdef __cplusplus
32 # include <iostream>
33 #endif
34 
35 #ifdef __cplusplus
37 #else
38 struct _mpnumber
39 #endif
40 {
41  size_t size;
43 
44 #ifdef __cplusplus
45  static const mpnumber ZERO;
46  static const mpnumber ONE;
47 
48  mpnumber();
49  mpnumber(unsigned int);
50  mpnumber(size_t, const mpw*);
51  mpnumber(const mpnumber&);
52  ~mpnumber();
53 
54  const mpnumber& operator=(const mpnumber&);
55 
56  void wipe();
57 
58  size_t bitlength() const;
59 #endif
60 };
61 
62 #ifndef __cplusplus
63 typedef struct _mpnumber mpnumber;
64 #else
66 std::ostream& operator<<(std::ostream&, const mpnumber&);
67 #endif
68 
69 #ifdef __cplusplus
70 extern "C" {
71 #endif
72 
74 void mpnzero(mpnumber*);
76 void mpnsize(mpnumber*, size_t);
78 void mpninit(mpnumber*, size_t, const mpw*);
80 void mpnfree(mpnumber*);
82 void mpncopy(mpnumber*, const mpnumber*);
84 void mpnwipe(mpnumber*);
85 
87 void mpnset (mpnumber*, size_t, const mpw*);
89 void mpnsetw (mpnumber*, mpw);
90 
92 int mpnsetbin(mpnumber*, const byte*, size_t);
94 int mpnsethex(mpnumber*, const char*);
95 
97 int mpninv(mpnumber*, const mpnumber*, const mpnumber*);
98 
102 size_t mpntrbits(mpnumber*, size_t);
104 size_t mpnbits(const mpnumber*);
105 
106 #ifdef __cplusplus
107 }
108 #endif
109 
110 #endif
void mpnsetw(mpnumber *, mpw)
mpw * data
Definition: mpnumber.h:42
void mpnzero(mpnumber *)
void mpnsize(mpnumber *, size_t)
void mpnset(mpnumber *, size_t, const mpw *)
void mpncopy(mpnumber *, const mpnumber *)
std::ostream & operator<<(std::ostream &, const mpnumber &)
int mpnsetbin(mpnumber *, const byte *, size_t)
size_t mpnbits(const mpnumber *)
uint8_t byte
Definition: api.h:72
uint64_t mpw
Definition: api.h:87
void mpnwipe(mpnumber *)
Multi-precision integer routines.
size_t mpntrbits(mpnumber *, size_t)
Truncate the mpnumber to the specified number of (least significant) bits.
#define BEECRYPTAPI
Definition: api.h:52
int mpnsethex(mpnumber *, const char *)
Definition: mpnumber.h:36
void mpnfree(mpnumber *)
static const mpnumber ZERO
Definition: mpnumber.h:45
void mpninit(mpnumber *, size_t, const mpw *)
size_t size
Definition: mpnumber.h:41
static const mpnumber ONE
Definition: mpnumber.h:46
int mpninv(mpnumber *, const mpnumber *, const mpnumber *)