summaryrefslogtreecommitdiff
path: root/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/mpnumber.h
diff options
context:
space:
mode:
authorMaurus Cuelenaere <mcuelenaere@gmail.com>2008-07-11 15:50:46 +0000
committerMaurus Cuelenaere <mcuelenaere@gmail.com>2008-07-11 15:50:46 +0000
commit14c7f45cdae826f88dc539c8c38dd95caf305731 (patch)
tree832da054b7cfb2dc6fd63339af736625f31d21aa /utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/mpnumber.h
parent7c84ede3781c27db73403bd6302f320c76a58c8c (diff)
downloadrockbox-14c7f45cdae826f88dc539c8c38dd95caf305731.tar.gz
rockbox-14c7f45cdae826f88dc539c8c38dd95caf305731.zip
Add zook's ZenUtils to SVN
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18010 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/mpnumber.h')
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/mpnumber.h115
1 files changed, 115 insertions, 0 deletions
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/mpnumber.h b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/mpnumber.h
new file mode 100755
index 0000000000..f42e82a80f
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/mpnumber.h
@@ -0,0 +1,115 @@
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
20/*!\file mpnumber.h
21 * \brief Multi-precision numbers, headers.
22 * \author Bob Deblier <bob.deblier@pandora.be>
23 * \ingroup MP_m
24 */
25
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
36struct BEECRYPTAPI mpnumber
37#else
38struct _mpnumber
39#endif
40{
41 size_t size;
42 mpw* data;
43
44#ifdef __cplusplus
45 static const mpnumber ZERO;
46 static const mpnumber ONE;
47
48 mpnumber();
49 mpnumber(unsigned int);
50 mpnumber(const mpnumber&);
51 ~mpnumber();
52
53 const mpnumber& operator=(const mpnumber&);
54 bool operator==(const mpnumber&) const throw ();
55 bool operator!=(const mpnumber&) const throw ();
56
57 void wipe();
58
59 size_t bitlength() const throw ();
60#endif
61};
62
63#ifndef __cplusplus
64typedef struct _mpnumber mpnumber;
65#else
66BEECRYPTAPI
67std::ostream& operator<<(std::ostream&, const mpnumber&);
68/*
69BEECRYPTAPI
70std::istream& operator>>(std::istream&, mpnumber&);
71*/
72#endif
73
74#ifdef __cplusplus
75extern "C" {
76#endif
77
78BEECRYPTAPI
79void mpnzero(mpnumber*);
80BEECRYPTAPI
81void mpnsize(mpnumber*, size_t);
82BEECRYPTAPI
83void mpninit(mpnumber*, size_t, const mpw*);
84BEECRYPTAPI
85void mpnfree(mpnumber*);
86BEECRYPTAPI
87void mpncopy(mpnumber*, const mpnumber*);
88BEECRYPTAPI
89void mpnwipe(mpnumber*);
90
91BEECRYPTAPI
92void mpnset (mpnumber*, size_t, const mpw*);
93BEECRYPTAPI
94void mpnsetw (mpnumber*, mpw);
95
96BEECRYPTAPI
97int mpnsetbin(mpnumber*, const byte*, size_t);
98BEECRYPTAPI
99int mpnsethex(mpnumber*, const char*);
100
101BEECRYPTAPI
102int mpninv(mpnumber*, const mpnumber*, const mpnumber*);
103
104/*!\brief Truncate the mpnumber to the specified number of (least significant) bits.
105 */
106BEECRYPTAPI
107size_t mpntrbits(mpnumber*, size_t);
108BEECRYPTAPI
109size_t mpnbits(const mpnumber*);
110
111#ifdef __cplusplus
112}
113#endif
114
115#endif