2 * Copyright (c) 2003 Bob Deblier
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.
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.
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
21 * \brief Multi-precision numbers, headers.
22 * \author Bob Deblier <bob.deblier@pandora.be>
29 #include "beecrypt/mp.h"
36 struct BEECRYPTAPI mpnumber
45 static const mpnumber ZERO
;
46 static const mpnumber ONE
;
49 mpnumber(unsigned int);
50 mpnumber(const mpnumber
&);
53 const mpnumber
& operator=(const mpnumber
&);
54 bool operator==(const mpnumber
&) const throw ();
55 bool operator!=(const mpnumber
&) const throw ();
59 size_t bitlength() const throw ();
64 typedef struct _mpnumber mpnumber
;
67 std::ostream
& operator<<(std::ostream
&, const mpnumber
&);
70 std::istream& operator>>(std::istream&, mpnumber&);
79 void mpnzero(mpnumber
*);
81 void mpnsize(mpnumber
*, size_t);
83 void mpninit(mpnumber
*, size_t, const mpw
*);
85 void mpnfree(mpnumber
*);
87 void mpncopy(mpnumber
*, const mpnumber
*);
89 void mpnwipe(mpnumber
*);
92 void mpnset (mpnumber
*, size_t, const mpw
*);
94 void mpnsetw (mpnumber
*, mpw
);
97 int mpnsetbin(mpnumber
*, const byte
*, size_t);
99 int mpnsethex(mpnumber
*, const char*);
102 int mpninv(mpnumber
*, const mpnumber
*, const mpnumber
*);
104 /*!\brief Truncate the mpnumber to the specified number of (least significant) bits.
107 size_t mpntrbits(mpnumber
*, size_t);
109 size_t mpnbits(const mpnumber
*);