summaryrefslogtreecommitdiff
path: root/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt
diff options
context:
space:
mode:
Diffstat (limited to 'utils/zenutils/libraries/beecrypt-4.1.2/beecrypt')
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/AUTHORS11
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/BENCHMARKS73
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/BUGS69
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/CONTRIBUTORS19
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/COPYING336
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/COPYING.LIB504
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/ChangeLog0
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/INSTALL187
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/NEWS184
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/README143
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/README.DLL37
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/README.WIN3243
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/api.h89
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/beecrypt.h799
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/blockmode.c137
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/blockmode.h92
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/blowfish.c509
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/blowfish.h132
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/blowfishopt.h82
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/endianness.c94
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/endianness.h128
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/gnu.h67
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/hmac.c123
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/hmac.h53
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/hmacsha1.c77
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/hmacsha1.h60
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/memchunk.h53
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/mp.c1537
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/mp.h691
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/mpnumber.h115
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/mpopt.h205
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/rsa.h121
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/sha1.c329
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/sha1.h120
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/sha1opt.h65
-rwxr-xr-xutils/zenutils/libraries/beecrypt-4.1.2/beecrypt/win.h139
36 files changed, 7423 insertions, 0 deletions
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/AUTHORS b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/AUTHORS
new file mode 100755
index 0000000000..878abf5a3f
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/AUTHORS
@@ -0,0 +1,11 @@
1BeeCrypt Cryptograpy Library:
2
3Bob Deblier <bob.deblier@pandora.be>
4
5C++ Interface:
6
7Bob Deblier <bob.deblier@pandora.be>
8
9Python Interface:
10
11Jeff Johson <jbj@redhat.com>
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/BENCHMARKS b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/BENCHMARKS
new file mode 100755
index 0000000000..7919f340db
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/BENCHMARKS
@@ -0,0 +1,73 @@
1Note: timings are average values and may vary under different conditions,
2i.e. the amount of free memory, swapped memory, amount of cpu cache, etc.
3I've tried to make them as accurate as possible, within limits.
4
5Note: many of the testing systems were provided by HP's testdrive program;
6many thanks to them for giving me access to their systems. Also thanks to
7SourceForge for their compile farm!
8
9Note: to avoid religious wars, in the table below read GNU/Linux for
10Linux - I'm just a little cramped for space...
11
12BENCHmark Modular Exponentation (more is better):
13
14BeeCrypt 4.0.0 | gcc-3.3.3 | Fedora Core 2 | Athlon 64 3000+| 1 GB: 24870
15BeeCrypt 4.1.0 | gcc-3.4.2 | Fedora Core 3 | Athlon 64 3000+| 1 GB: 24566
16BeeCrypt 4.0.0 | gcc-3.2.2 | SuSE 8 EL | Opteron 1600 | 1 GB: 19460
17BeeCrypt 3.0.0 | gcc-3.x | RedHat Linux | Opteron MP 1600 | : 17230
18BeeCrypt 3.1.0 | gcc-2.96 | RedHat AS 2.1 | Itanium 2 1400 | 1 GB: 11453
19BeeCrypt 3.0.0 | gcc-3.2.2 | Debian Linux 3.0 | Itanium 2 900 | 12 GB: 7317
20BeeCrypt 3.0.0 | gcc-3.3 | RedHat AS 2.1 | P4 Xeon 2400 | 4 GB: 6920 [--with-arch=pentium4]
21BeeCrypt 4.1.0 | gcc-3.3.3 | Fedora Core 2 | P4 Xeon 2400 | 1 GB: 6811 [--with-arch=pentium4]
22BeeCrypt 4.1.0 | gcc-3.3.3 | SuSE Enterprise 9 | POWER4 1000 | 16 GB: 5858
23BeeCrypt 3.0.0 | gcc-2.95.4 | Debian Linux 3.0 | Alpha EV6.7 666 | 2 GB: 5742
24BeeCrypt 3.0.0 | gcc-2.96 | RedHat AS 2.1 | P4 Xeon 2400 | 4 GB: 3280 [--with-arch=pentiumpro]
25BeeCrypt 3.0.0 | gcc-3.x | RedHat Linux | POWER4+ 1200 | : 2592
26BeeCrypt 3.0.0 | gcc-3.x | RedHat Linux | P3 Xeon 900 | : 2169
27BeeCrypt 3.0.0 | gcc-3.2.2 | AIX 5.1 | POWER3-II 333 | 512 MB: 1782 [--with-arch=powerpc64]
28BeeCrypt 3.0.0 | gcc-3.x | RedHat Linux | zSeries 900 | : 1687 (s390x)
29BeeCrypt 3.0.0 | gcc-3.3 | SuSE Linux 8.2 | Pentium 3 600 | 512 MB: 1447 [--with-arch=pentium3]
30BeeCrypt 3.0.0 | gcc-3.2.2 | AIX 5.1 | POWER3-II 333 | 512 MB: 756
31BeeCrypt 3.0.0 | Forte C 5.1 | Solaris 8 | UltraSparc II 400 | 4 GB: 425 [--with-arch=sparcv8plus]
32BeeCrypt 3.0.0 | | Debian Linux 3.0 | StrongARM 1110 128 | 32 MB: 341
33BeeCrypt 3.0.0 | gcc-2.95.4 | Debian Linux 3.0r1 | M68040 33 | 52 MB: 24
34BeeCrypt 3.0.0 | gcc-2.95.4 | Debian Linux 3.0r1 | M68030 25 | 36 MB: 8
35
36BENCHmark Hash Function (more is better):
37
38MD5
39BeeCrypt 4.1.0 | gcc-3.4.2 | Fedora Core 3 | Athlon 64 3000+| 1 GB: 190.5 MB/s
40BeeCrypt 3.0.0 | gcc-2.96 | RedHat AS 2.1 | P4 Xeon 2400 | 4 GB: 137.0 MB/s [--with-arch=pentiumpro]
41BeeCrypt 4.1.0 | gcc-3.3.3 | Fedora Core 2 | P4 Xeon 2400 | 1 GB: 97.2 MB/s [--with-arch=pentium4]
42BeeCrypt 4.1.0 | gcc-3.3.3 | SuSE Enterprise 9 | POWER4 1000 | 16 GB: 38.8 MB/s
43
44SHA-1
45BeeCrypt 4.1.0 | gcc-3.4.2 | Fedora Core 3 | Athlon 64 3000+| 1 GB: 117.4 MB/s
46BeeCrypt 4.1.0 | gcc-3.3.3 | Fedora Core 2 | P4 Xeon 2400 | 1 GB: 81.9 MB/s [--with-arch=pentium4]
47BeeCrypt 3.0.0 | gcc-2.96 | RedHat AS 2.1 | P4 Xeon 2400 | 4 GB: 77.0 MB/s [--with-arch=pentiumpro]
48BeeCrypt 4.1.0 | gcc-3.3.3 | SuSE Enterprise 9 | POWER4 1000 | 16 GB: 51.2 MB/s
49
50SHA-256
51BeeCrypt 4.1.0 | gcc-3.4.2 | Fedora Core 3 | Athlon 64 3000+| 1 GB: 85.1 MB/s
52BeeCrypt 4.1.0 | gcc-3.3.3 | Fedora Core 2 | P4 Xeon 2400 | 1 GB: 42.4 MB/s [--with-arch=pentium4]
53BeeCrypt 3.0.0 | gcc-2.96 | RedHat AS 2.1 | P4 Xeon 2400 | 4 GB: 37.8 MB/s [--with-arch=pentiumpro]
54BeeCrypt 4.1.0 | gcc-3.3.3 | SuSE Enterprise 9 | POWER4 1000 | 16 GB: 33.0 MB/s
55
56SHA-512
57BeeCrypt 4.1.0 | gcc-3.4.2 | Fedora Core 3 | Athlon 64 3000+| 1 GB: 129.6 MB/s
58BeeCrypt 4.1.0 | gcc-3.3.3 | SuSE Enterprise 9 | POWER4 1000 | 16 GB: 57.6 MB/s
59BeeCrypt 4.1.0 | gcc-3.3.3 | Fedora Core 2 | P4 Xeon 2400 | 1 GB: 46.3 MB/s [--with-arch=pentium4]
60
61BENCHmark Block Cipher (more is better):
62
63AES, 128 bits
64BeeCrypt 4.1.0 | gcc-3.4.2 | Fedora Core 3 | Athlon 64 3000+| 1 GB: 97.0 MB/s [ECB encrypt]
65BeeCrypt 4.1.0 | gcc-3.4.2 | Fedora Core 3 | Athlon 64 3000+| 1 GB: 93.5 MB/s [CBC encrypt]
66BeeCrypt 4.1.0 | gcc-3.4.2 | Fedora Core 3 | Athlon 64 3000+| 1 GB: 104.6 MB/s [ECB decrypt]
67BeeCrypt 4.1.0 | gcc-3.4.2 | Fedora Core 3 | Athlon 64 3000+| 1 GB: 99.2 MB/s [CBC decrypt]
68
69Blowfish, 128 bits
70BeeCrypt 4.1.0 | gcc-3.4.2 | Fedora Core 3 | Athlon 64 3000+| 1 GB: 59.4 MB/s [ECB encrypt]
71BeeCrypt 4.1.0 | gcc-3.4.2 | Fedora Core 3 | Athlon 64 3000+| 1 GB: 57.7 MB/s [CBC encrypt]
72BeeCrypt 4.1.0 | gcc-3.4.2 | Fedora Core 3 | Athlon 64 3000+| 1 GB: 61.4 MB/s [ECB decrypt]
73BeeCrypt 4.1.0 | gcc-3.4.2 | Fedora Core 3 | Athlon 64 3000+| 1 GB: 59.3 MB/s [CBC decrypt]
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/BUGS b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/BUGS
new file mode 100755
index 0000000000..577c5adac5
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/BUGS
@@ -0,0 +1,69 @@
1Legend:
2 - = open bug
3 * = fixed bug
4
54.1.0:
6 - SuSE 9.2 (x86) compiler is buggy: the MMX-optimized version fails all
7 test vectors. Since all other Linux distro's handle this perfectly it's
8 up to them to fix this bug.
9
103.1.0:
11 * Error in final result computation of mpextgcd_w in certain circumstances.
12 * PowerPC 64-bit assembler symbols aren't defined according to LSB 1.3.
13
143.0.0:
15 - Can't seem to generate 64-bit shared libraries on AIX; use
16 --disable-shared on this platform for now.
17 - Intel icc can't cope with gcj headers. There's also a problem in
18 combination with aio.h; solution should be to not test gcj when using
19 this compiler. As a workaround, you can specify --without-javaglue.
20 - GCC 3.3 produces faster output for Blowfish on Pentium 4 than the
21 included assembler source; try coding two Blowfish rounds (without swap)
22 in C and compile to assembler to see how GCC accomplishes this.
23
242.3.0pre:
25 * bug in certain instances of computing modular inverse.
26 * incorrectly translated intel-style assembler version of x86 mp32odd
27 and mp32even routines into gnu assembler format.
28 * base64 decoding of '+' and '/' characters is wrong.
29 * incorrect testing of the result of the gcd operation in mp32prndconone.
30 * Chinese Remainer Theorem for RSA private key operation doesn't work
31 * incorrect header file inclusion when --disable-threads is selected or
32 when no multithreading is available.
33
342.2.0:
35 [ Released by Jeff Johnson of RedHat, Inc.; lint & doxygen enhanced version
36 of 2.1.0. ]
37
382.1.0:
39 * Entropy gathering from /dev/dsp contained error; size in words of entropy
40 data to gather was overwritten with audio sample size - which resulted in
41 much less entropy.
42
432.0.0:
44 - Chinese Remainder Theorem for RSA private key operation doesn't work; it
45 needs fixing.
46
471.1.2:
48 * SHA-1 i586 assembler code uses local variables below the current stack
49 frame.
50
511.1.1:
52 * discrete logarithm domain parameter generator calculations contains bugs
53 - was detected in this release but present since the first release.
54
551.1.0:
56 * The javaglue produces a NullPointerException when initializing with a
57 null IV; this should be treated correctly, i.e. as an all zero IV.
58
591.0.2:
60
611.0.1:
62 * The Windows 2000 bug is still around
63
641.0.0:
65 * On Windows 2000, the entropy system gets error WAVERR_BADFORMAT in
66 waveInOpen; So far I've been unable to determine why the system does this
67 for format WAVE_FORMAT_PCM. Suggestions to fix this problem are more than
68 welcome.
69 * The assembler code for SHA-1 in gnu/fips180opt.gas.i586.s contains bugs.
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/CONTRIBUTORS b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/CONTRIBUTORS
new file mode 100755
index 0000000000..7f61011475
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/CONTRIBUTORS
@@ -0,0 +1,19 @@
1I would like to thank the following people (in alphabetical order):
2
3- Seth Arnold, for contributing to the documentation.
4- Jan-Rudolph Bührmann, for helping me get started on the 64-bit multi-
5 precision integer library.
6- Luca Filipozzi, maintainer/packager of BeeCrypt for Debian GNU/Linux.
7- Jeff Johnson, the guy behind RedHat's Package Manager, who has inspired
8 and contributed to many of the changes for version 3.0.0; 73 de Bob.
9- Jon Sturgeon, bug hunter extraordinaire.
10
11Further thanks go to:
12- AMD, for donating a copy of "AMD x86-64 Architecture Programmer's Manual".
13- ARM Ltd, for donating a copy of "ARM Architecture Reference Manual".
14- HP/Compaq, for their testdrive program, which gave me the opportunity to
15 test and BeeCrypt on many new platforms.
16- SourceForge, for their excellent open source development platform!
17
18Last but not least: thanks to everyone who provided bits of information,
19reported bugs and provided feedback.
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/COPYING b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/COPYING
new file mode 100755
index 0000000000..a6d7d0188a
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/COPYING
@@ -0,0 +1,336 @@
1 GNU GENERAL PUBLIC LICENSE
2 Version 2, June 1991
3
4 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6 Everyone is permitted to copy and distribute verbatim copies
7 of this license document, but changing it is not allowed.
8
9 Preamble
10
11 The licenses for most software are designed to take away your
12freedom to share and change it. By contrast, the GNU General Public
13License is intended to guarantee your freedom to share and change free
14software--to make sure the software is free for all its users. This
15General Public License applies to most of the Free Software
16Foundation's software and to any other program whose authors commit to
17using it. (Some other Free Software Foundation software is covered by
18the GNU Library General Public License instead.) You can apply it to
19your programs, too.
20
21 When we speak of free software, we are referring to freedom, not
22price. Our General Public Licenses are designed to make sure that you
23have the freedom to distribute copies of free software (and charge for
24this service if you wish), that you receive source code or can get it
25if you want it, that you can change the software or use pieces of it
26in new free programs; and that you know you can do these things.
27
28 To protect your rights, we need to make restrictions that forbid
29anyone to deny you these rights or to ask you to surrender the rights.
30These restrictions translate to certain responsibilities for you if you
31distribute copies of the software, or if you modify it.
32
33 For example, if you distribute copies of such a program, whether
34gratis or for a fee, you must give the recipients all the rights that
35you have. You must make sure that they, too, receive or can get the
36source code. And you must show them these terms so they know their
37rights.
38
39 We protect your rights with two steps: (1) copyright the software, and
40(2) offer you this license which gives you legal permission to copy,
41distribute and/or modify the software.
42
43 Also, for each author's protection and ours, we want to make certain
44that everyone understands that there is no warranty for this free
45software. If the software is modified by someone else and passed on, we
46want its recipients to know that what they have is not the original, so
47that any problems introduced by others will not reflect on the original
48authors' reputations.
49
50 Finally, any free program is threatened constantly by software
51patents. We wish to avoid the danger that redistributors of a free
52program will individually obtain patent licenses, in effect making the
53program proprietary. To prevent this, we have made it clear that any
54patent must be licensed for everyone's free use or not licensed at all.
55
56 The precise terms and conditions for copying, distribution and
57modification follow.
58
59 GNU GENERAL PUBLIC LICENSE
60 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
62 0. This License applies to any program or other work which contains
63a notice placed by the copyright holder saying it may be distributed
64under the terms of this General Public License. The "Program", below,
65refers to any such program or work, and a "work based on the Program"
66means either the Program or any derivative work under copyright law:
67that is to say, a work containing the Program or a portion of it,
68either verbatim or with modifications and/or translated into another
69language. (Hereinafter, translation is included without limitation in
70the term "modification".) Each licensee is addressed as "you".
71
72Activities other than copying, distribution and modification are not
73covered by this License; they are outside its scope. The act of
74running the Program is not restricted, and the output from the Program
75is covered only if its contents constitute a work based on the
76Program (independent of having been made by running the Program).
77Whether that is true depends on what the Program does.
78
79 1. You may copy and distribute verbatim copies of the Program's
80source code as you receive it, in any medium, provided that you
81conspicuously and appropriately publish on each copy an appropriate
82copyright notice and disclaimer of warranty; keep intact all the
83notices that refer to this License and to the absence of any warranty;
84and give any other recipients of the Program a copy of this License
85along with the Program.
86
87You may charge a fee for the physical act of transferring a copy, and
88you may at your option offer warranty protection in exchange for a fee.
89
90 2. You may modify your copy or copies of the Program or any portion
91of it, thus forming a work based on the Program, and copy and
92distribute such modifications or work under the terms of Section 1
93above, provided that you also meet all of these conditions:
94
95 a) You must cause the modified files to carry prominent notices
96 stating that you changed the files and the date of any change.
97
98 b) You must cause any work that you distribute or publish, that in
99 whole or in part contains or is derived from the Program or any
100 part thereof, to be licensed as a whole at no charge to all third
101 parties under the terms of this License.
102
103 c) If the modified program normally reads commands interactively
104 when run, you must cause it, when started running for such
105 interactive use in the most ordinary way, to print or display an
106 announcement including an appropriate copyright notice and a
107 notice that there is no warranty (or else, saying that you provide
108 a warranty) and that users may redistribute the program under
109 these conditions, and telling the user how to view a copy of this
110 License. (Exception: if the Program itself is interactive but
111 does not normally print such an announcement, your work based on
112 the Program is not required to print an announcement.)
113
114These requirements apply to the modified work as a whole. If
115identifiable sections of that work are not derived from the Program,
116and can be reasonably considered independent and separate works in
117themselves, then this License, and its terms, do not apply to those
118sections when you distribute them as separate works. But when you
119distribute the same sections as part of a whole which is a work based
120on the Program, the distribution of the whole must be on the terms of
121this License, whose permissions for other licensees extend to the
122entire whole, and thus to each and every part regardless of who wrote it.
123
124Thus, it is not the intent of this section to claim rights or contest
125your rights to work written entirely by you; rather, the intent is to
126exercise the right to control the distribution of derivative or
127collective works based on the Program.
128
129In addition, mere aggregation of another work not based on the Program
130with the Program (or with a work based on the Program) on a volume of
131a storage or distribution medium does not bring the other work under
132the scope of this License.
133
134 3. You may copy and distribute the Program (or a work based on it,
135under Section 2) in object code or executable form under the terms of
136Sections 1 and 2 above provided that you also do one of the following:
137
138 a) Accompany it with the complete corresponding machine-readable
139 source code, which must be distributed under the terms of Sections
140 1 and 2 above on a medium customarily used for software interchange; or,
141
142 b) Accompany it with a written offer, valid for at least three
143 years, to give any third party, for a charge no more than your
144 cost of physically performing source distribution, a complete
145 machine-readable copy of the corresponding source code, to be
146 distributed under the terms of Sections 1 and 2 above on a medium
147 customarily used for software interchange; or,
148
149 c) Accompany it with the information you received as to the offer
150 to distribute corresponding source code. (This alternative is
151 allowed only for noncommercial distribution and only if you
152 received the program in object code or executable form with such
153 an offer, in accord with Subsection b above.)
154
155The source code for a work means the preferred form of the work for
156making modifications to it. For an executable work, complete source
157code means all the source code for all modules it contains, plus any
158associated interface definition files, plus the scripts used to
159control compilation and installation of the executable. However, as a
160special exception, the source code distributed need not include
161anything that is normally distributed (in either source or binary
162form) with the major components (compiler, kernel, and so on) of the
163operating system on which the executable runs, unless that component
164itself accompanies the executable.
165
166If distribution of executable or object code is made by offering
167access to copy from a designated place, then offering equivalent
168access to copy the source code from the same place counts as
169distribution of the source code, even though third parties are not
170compelled to copy the source along with the object code.
171
172 4. You may not copy, modify, sublicense, or distribute the Program
173except as expressly provided under this License. Any attempt
174otherwise to copy, modify, sublicense or distribute the Program is
175void, and will automatically terminate your rights under this License.
176However, parties who have received copies, or rights, from you under
177this License will not have their licenses terminated so long as such
178parties remain in full compliance.
179
180 5. You are not required to accept this License, since you have not
181signed it. However, nothing else grants you permission to modify or
182distribute the Program or its derivative works. These actions are
183prohibited by law if you do not accept this License. Therefore, by
184modifying or distributing the Program (or any work based on the
185Program), you indicate your acceptance of this License to do so, and
186all its terms and conditions for copying, distributing or modifying
187the Program or works based on it.
188
189 6. Each time you redistribute the Program (or any work based on the
190Program), the recipient automatically receives a license from the
191original licensor to copy, distribute or modify the Program subject to
192these terms and conditions. You may not impose any further
193restrictions on the recipients' exercise of the rights granted herein.
194You are not responsible for enforcing compliance by third parties to
195this License.
196
197 7. If, as a consequence of a court judgment or allegation of patent
198infringement or for any other reason (not limited to patent issues),
199conditions are imposed on you (whether by court order, agreement or
200otherwise) that contradict the conditions of this License, they do not
201excuse you from the conditions of this License. If you cannot
202distribute so as to satisfy simultaneously your obligations under this
203License and any other pertinent obligations, then as a consequence you
204may not distribute the Program at all. For example, if a patent
205license would not permit royalty-free redistribution of the Program by
206all those who receive copies directly or indirectly through you, then
207the only way you could satisfy both it and this License would be to
208refrain entirely from distribution of the Program.
209
210If any portion of this section is held invalid or unenforceable under
211any particular circumstance, the balance of the section is intended to
212apply and the section as a whole is intended to apply in other
213circumstances.
214
215It is not the purpose of this section to induce you to infringe any
216patents or other property right claims or to contest validity of any
217such claims; this section has the sole purpose of protecting the
218integrity of the free software distribution system, which is
219implemented by public license practices. Many people have made
220generous contributions to the wide range of software distributed
221through that system in reliance on consistent application of that
222system; it is up to the author/donor to decide if he or she is willing
223to distribute software through any other system and a licensee cannot
224impose that choice.
225
226This section is intended to make thoroughly clear what is believed to
227be a consequence of the rest of this License.
228
229 8. If the distribution and/or use of the Program is restricted in
230certain countries either by patents or by copyrighted interfaces, the
231original copyright holder who places the Program under this License
232may add an explicit geographical distribution limitation excluding
233those countries, so that distribution is permitted only in or among
234countries not thus excluded. In such case, this License incorporates
235the limitation as if written in the body of this License.
236
237 9. The Free Software Foundation may publish revised and/or new versions
238of the General Public License from time to time. Such new versions will
239be similar in spirit to the present version, but may differ in detail to
240address new problems or concerns.
241
242Each version is given a distinguishing version number. If the Program
243specifies a version number of this License which applies to it and "any
244later version", you have the option of following the terms and conditions
245either of that version or of any later version published by the Free
246Software Foundation. If the Program does not specify a version number of
247this License, you may choose any version ever published by the Free Software
248Foundation.
249
250 10. If you wish to incorporate parts of the Program into other free
251programs whose distribution conditions are different, write to the author
252to ask for permission. For software which is copyrighted by the Free
253Software Foundation, write to the Free Software Foundation; we sometimes
254make exceptions for this. Our decision will be guided by the two goals
255of preserving the free status of all derivatives of our free software and
256of promoting the sharing and reuse of software generally.
257
258 NO WARRANTY
259
260 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268REPAIR OR CORRECTION.
269
270 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278POSSIBILITY OF SUCH DAMAGES.
279
280 END OF TERMS AND CONDITIONS
281
282 How to Apply These Terms to Your New Programs
283
284 If you develop a new program, and you want it to be of the greatest
285possible use to the public, the best way to achieve this is to make it
286free software which everyone can redistribute and change under these terms.
287
288 To do so, attach the following notices to the program. It is safest
289to attach them to the start of each source file to most effectively
290convey the exclusion of warranty; and each file should have at least
291the "copyright" line and a pointer to where the full notice is found.
292
293 <one line to give the program's name and a brief idea of what it does.>
294 Copyright (C) <year> <name of author>
295
296 This program is free software; you can redistribute it and/or modify
297 it under the terms of the GNU General Public License as published by
298 the Free Software Foundation; either version 2 of the License, or
299 (at your option) any later version.
300
301 This program is distributed in the hope that it will be useful,
302 but WITHOUT ANY WARRANTY; without even the implied warranty of
303 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 GNU General Public License for more details.
305
306 You should have received a copy of the GNU General Public License
307 along with this program; if not, write to the Free Software
308 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
309
310
311Also add information on how to contact you by electronic and paper mail.
312
313If the program is interactive, make it output a short notice like this
314when it starts in an interactive mode:
315
316 Gnomovision version 69, Copyright (C) year name of author
317 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
318 This is free software, and you are welcome to redistribute it
319 under certain conditions; type `show c' for details.
320
321The hypothetical commands `show w' and `show c' should show the appropriate
322parts of the General Public License. Of course, the commands you use may
323be called something other than `show w' and `show c'; they could even be
324mouse-clicks or menu items--whatever suits your program.
325
326You should also get your employer (if you work as a programmer) or your
327school, if any, to sign a "copyright disclaimer" for the program, if
328necessary. Hereny it with the complete corresponding machine-readable
329 source code, which must be distributed under the terms of Sections
330 1 and 2 above on a medium customarily used for software interchange; or,
331
332 b) Accompany it with a written offer, valid for at least three
333 years, to give any third party, for a charge no more than your
334 cost of physically performing source distribution, a complete
335 machine-readable copy of the corresponding source code, to be
336 distributed under the terms of Section
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/COPYING.LIB b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/COPYING.LIB
new file mode 100755
index 0000000000..223ede7de3
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/COPYING.LIB
@@ -0,0 +1,504 @@
1 GNU LESSER GENERAL PUBLIC LICENSE
2 Version 2.1, February 1999
3
4 Copyright (C) 1991, 1999 Free Software Foundation, Inc.
5 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6 Everyone is permitted to copy and distribute verbatim copies
7 of this license document, but changing it is not allowed.
8
9[This is the first released version of the Lesser GPL. It also counts
10 as the successor of the GNU Library Public License, version 2, hence
11 the version number 2.1.]
12
13 Preamble
14
15 The licenses for most software are designed to take away your
16freedom to share and change it. By contrast, the GNU General Public
17Licenses are intended to guarantee your freedom to share and change
18free software--to make sure the software is free for all its users.
19
20 This license, the Lesser General Public License, applies to some
21specially designated software packages--typically libraries--of the
22Free Software Foundation and other authors who decide to use it. You
23can use it too, but we suggest you first think carefully about whether
24this license or the ordinary General Public License is the better
25strategy to use in any particular case, based on the explanations below.
26
27 When we speak of free software, we are referring to freedom of use,
28not price. Our General Public Licenses are designed to make sure that
29you have the freedom to distribute copies of free software (and charge
30for this service if you wish); that you receive source code or can get
31it if you want it; that you can change the software and use pieces of
32it in new free programs; and that you are informed that you can do
33these things.
34
35 To protect your rights, we need to make restrictions that forbid
36distributors to deny you these rights or to ask you to surrender these
37rights. These restrictions translate to certain responsibilities for
38you if you distribute copies of the library or if you modify it.
39
40 For example, if you distribute copies of the library, whether gratis
41or for a fee, you must give the recipients all the rights that we gave
42you. You must make sure that they, too, receive or can get the source
43code. If you link other code with the library, you must provide
44complete object files to the recipients, so that they can relink them
45with the library after making changes to the library and recompiling
46it. And you must show them these terms so they know their rights.
47
48 We protect your rights with a two-step method: (1) we copyright the
49library, and (2) we offer you this license, which gives you legal
50permission to copy, distribute and/or modify the library.
51
52 To protect each distributor, we want to make it very clear that
53there is no warranty for the free library. Also, if the library is
54modified by someone else and passed on, the recipients should know
55that what they have is not the original version, so that the original
56author's reputation will not be affected by problems that might be
57introduced by others.
58
59 Finally, software patents pose a constant threat to the existence of
60any free program. We wish to make sure that a company cannot
61effectively restrict the users of a free program by obtaining a
62restrictive license from a patent holder. Therefore, we insist that
63any patent license obtained for a version of the library must be
64consistent with the full freedom of use specified in this license.
65
66 Most GNU software, including some libraries, is covered by the
67ordinary GNU General Public License. This license, the GNU Lesser
68General Public License, applies to certain designated libraries, and
69is quite different from the ordinary General Public License. We use
70this license for certain libraries in order to permit linking those
71libraries into non-free programs.
72
73 When a program is linked with a library, whether statically or using
74a shared library, the combination of the two is legally speaking a
75combined work, a derivative of the original library. The ordinary
76General Public License therefore permits such linking only if the
77entire combination fits its criteria of freedom. The Lesser General
78Public License permits more lax criteria for linking other code with
79the library.
80
81 We call this license the "Lesser" General Public License because it
82does Less to protect the user's freedom than the ordinary General
83Public License. It also provides other free software developers Less
84of an advantage over competing non-free programs. These disadvantages
85are the reason we use the ordinary General Public License for many
86libraries. However, the Lesser license provides advantages in certain
87special circumstances.
88
89 For example, on rare occasions, there may be a special need to
90encourage the widest possible use of a certain library, so that it becomes
91a de-facto standard. To achieve this, non-free programs must be
92allowed to use the library. A more frequent case is that a free
93library does the same job as widely used non-free libraries. In this
94case, there is little to gain by limiting the free library to free
95software only, so we use the Lesser General Public License.
96
97 In other cases, permission to use a particular library in non-free
98programs enables a greater number of people to use a large body of
99free software. For example, permission to use the GNU C Library in
100non-free programs enables many more people to use the whole GNU
101operating system, as well as its variant, the GNU/Linux operating
102system.
103
104 Although the Lesser General Public License is Less protective of the
105users' freedom, it does ensure that the user of a program that is
106linked with the Library has the freedom and the wherewithal to run
107that program using a modified version of the Library.
108
109 The precise terms and conditions for copying, distribution and
110modification follow. Pay close attention to the difference between a
111"work based on the library" and a "work that uses the library". The
112former contains code derived from the library, whereas the latter must
113be combined with the library in order to run.
114
115 GNU LESSER GENERAL PUBLIC LICENSE
116 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
117
118 0. This License Agreement applies to any software library or other
119program which contains a notice placed by the copyright holder or
120other authorized party saying it may be distributed under the terms of
121this Lesser General Public License (also called "this License").
122Each licensee is addressed as "you".
123
124 A "library" means a collection of software functions and/or data
125prepared so as to be conveniently linked with application programs
126(which use some of those functions and data) to form executables.
127
128 The "Library", below, refers to any such software library or work
129which has been distributed under these terms. A "work based on the
130Library" means either the Library or any derivative work under
131copyright law: that is to say, a work containing the Library or a
132portion of it, either verbatim or with modifications and/or translated
133straightforwardly into another language. (Hereinafter, translation is
134included without limitation in the term "modification".)
135
136 "Source code" for a work means the preferred form of the work for
137making modifications to it. For a library, complete source code means
138all the source code for all modules it contains, plus any associated
139interface definition files, plus the scripts used to control compilation
140and installation of the library.
141
142 Activities other than copying, distribution and modification are not
143covered by this License; they are outside its scope. The act of
144running a program using the Library is not restricted, and output from
145such a program is covered only if its contents constitute a work based
146on the Library (independent of the use of the Library in a tool for
147writing it). Whether that is true depends on what the Library does
148and what the program that uses the Library does.
149
150 1. You may copy and distribute verbatim copies of the Library's
151complete source code as you receive it, in any medium, provided that
152you conspicuously and appropriately publish on each copy an
153appropriate copyright notice and disclaimer of warranty; keep intact
154all the notices that refer to this License and to the absence of any
155warranty; and distribute a copy of this License along with the
156Library.
157
158 You may charge a fee for the physical act of transferring a copy,
159and you may at your option offer warranty protection in exchange for a
160fee.
161
162 2. You may modify your copy or copies of the Library or any portion
163of it, thus forming a work based on the Library, and copy and
164distribute such modifications or work under the terms of Section 1
165above, provided that you also meet all of these conditions:
166
167 a) The modified work must itself be a software library.
168
169 b) You must cause the files modified to carry prominent notices
170 stating that you changed the files and the date of any change.
171
172 c) You must cause the whole of the work to be licensed at no
173 charge to all third parties under the terms of this License.
174
175 d) If a facility in the modified Library refers to a function or a
176 table of data to be supplied by an application program that uses
177 the facility, other than as an argument passed when the facility
178 is invoked, then you must make a good faith effort to ensure that,
179 in the event an application does not supply such function or
180 table, the facility still operates, and performs whatever part of
181 its purpose remains meaningful.
182
183 (For example, a function in a library to compute square roots has
184 a purpose that is entirely well-defined independent of the
185 application. Therefore, Subsection 2d requires that any
186 application-supplied function or table used by this function must
187 be optional: if the application does not supply it, the square
188 root function must still compute square roots.)
189
190These requirements apply to the modified work as a whole. If
191identifiable sections of that work are not derived from the Library,
192and can be reasonably considered independent and separate works in
193themselves, then this License, and its terms, do not apply to those
194sections when you distribute them as separate works. But when you
195distribute the same sections as part of a whole which is a work based
196on the Library, the distribution of the whole must be on the terms of
197this License, whose permissions for other licensees extend to the
198entire whole, and thus to each and every part regardless of who wrote
199it.
200
201Thus, it is not the intent of this section to claim rights or contest
202your rights to work written entirely by you; rather, the intent is to
203exercise the right to control the distribution of derivative or
204collective works based on the Library.
205
206In addition, mere aggregation of another work not based on the Library
207with the Library (or with a work based on the Library) on a volume of
208a storage or distribution medium does not bring the other work under
209the scope of this License.
210
211 3. You may opt to apply the terms of the ordinary GNU General Public
212License instead of this License to a given copy of the Library. To do
213this, you must alter all the notices that refer to this License, so
214that they refer to the ordinary GNU General Public License, version 2,
215instead of to this License. (If a newer version than version 2 of the
216ordinary GNU General Public License has appeared, then you can specify
217that version instead if you wish.) Do not make any other change in
218these notices.
219
220 Once this change is made in a given copy, it is irreversible for
221that copy, so the ordinary GNU General Public License applies to all
222subsequent copies and derivative works made from that copy.
223
224 This option is useful when you wish to copy part of the code of
225the Library into a program that is not a library.
226
227 4. You may copy and distribute the Library (or a portion or
228derivative of it, under Section 2) in object code or executable form
229under the terms of Sections 1 and 2 above provided that you accompany
230it with the complete corresponding machine-readable source code, which
231must be distributed under the terms of Sections 1 and 2 above on a
232medium customarily used for software interchange.
233
234 If distribution of object code is made by offering access to copy
235from a designated place, then offering equivalent access to copy the
236source code from the same place satisfies the requirement to
237distribute the source code, even though third parties are not
238compelled to copy the source along with the object code.
239
240 5. A program that contains no derivative of any portion of the
241Library, but is designed to work with the Library by being compiled or
242linked with it, is called a "work that uses the Library". Such a
243work, in isolation, is not a derivative work of the Library, and
244therefore falls outside the scope of this License.
245
246 However, linking a "work that uses the Library" with the Library
247creates an executable that is a derivative of the Library (because it
248contains portions of the Library), rather than a "work that uses the
249library". The executable is therefore covered by this License.
250Section 6 states terms for distribution of such executables.
251
252 When a "work that uses the Library" uses material from a header file
253that is part of the Library, the object code for the work may be a
254derivative work of the Library even though the source code is not.
255Whether this is true is especially significant if the work can be
256linked without the Library, or if the work is itself a library. The
257threshold for this to be true is not precisely defined by law.
258
259 If such an object file uses only numerical parameters, data
260structure layouts and accessors, and small macros and small inline
261functions (ten lines or less in length), then the use of the object
262file is unrestricted, regardless of whether it is legally a derivative
263work. (Executables containing this object code plus portions of the
264Library will still fall under Section 6.)
265
266 Otherwise, if the work is a derivative of the Library, you may
267distribute the object code for the work under the terms of Section 6.
268Any executables containing that work also fall under Section 6,
269whether or not they are linked directly with the Library itself.
270
271 6. As an exception to the Sections above, you may also combine or
272link a "work that uses the Library" with the Library to produce a
273work containing portions of the Library, and distribute that work
274under terms of your choice, provided that the terms permit
275modification of the work for the customer's own use and reverse
276engineering for debugging such modifications.
277
278 You must give prominent notice with each copy of the work that the
279Library is used in it and that the Library and its use are covered by
280this License. You must supply a copy of this License. If the work
281during execution displays copyright notices, you must include the
282copyright notice for the Library among them, as well as a reference
283directing the user to the copy of this License. Also, you must do one
284of these things:
285
286 a) Accompany the work with the complete corresponding
287 machine-readable source code for the Library including whatever
288 changes were used in the work (which must be distributed under
289 Sections 1 and 2 above); and, if the work is an executable linked
290 with the Library, with the complete machine-readable "work that
291 uses the Library", as object code and/or source code, so that the
292 user can modify the Library and then relink to produce a modified
293 executable containing the modified Library. (It is understood
294 that the user who changes the contents of definitions files in the
295 Library will not necessarily be able to recompile the application
296 to use the modified definitions.)
297
298 b) Use a suitable shared library mechanism for linking with the
299 Library. A suitable mechanism is one that (1) uses at run time a
300 copy of the library already present on the user's computer system,
301 rather than copying library functions into the executable, and (2)
302 will operate properly with a modified version of the library, if
303 the user installs one, as long as the modified version is
304 interface-compatible with the version that the work was made with.
305
306 c) Accompany the work with a written offer, valid for at
307 least three years, to give the same user the materials
308 specified in Subsection 6a, above, for a charge no more
309 than the cost of performing this distribution.
310
311 d) If distribution of the work is made by offering access to copy
312 from a designated place, offer equivalent access to copy the above
313 specified materials from the same place.
314
315 e) Verify that the user has already received a copy of these
316 materials or that you have already sent this user a copy.
317
318 For an executable, the required form of the "work that uses the
319Library" must include any data and utility programs needed for
320reproducing the executable from it. However, as a special exception,
321the materials to be distributed need not include anything that is
322normally distributed (in either source or binary form) with the major
323components (compiler, kernel, and so on) of the operating system on
324which the executable runs, unless that component itself accompanies
325the executable.
326
327 It may happen that this requirement contradicts the license
328restrictions of other proprietary libraries that do not normally
329accompany the operating system. Such a contradiction means you cannot
330use both them and the Library together in an executable that you
331distribute.
332
333 7. You may place library facilities that are a work based on the
334Library side-by-side in a single library together with other library
335facilities not covered by this License, and distribute such a combined
336library, provided that the separate distribution of the work based on
337the Library and of the other library facilities is otherwise
338permitted, and provided that you do these two things:
339
340 a) Accompany the combined library with a copy of the same work
341 based on the Library, uncombined with any other library
342 facilities. This must be distributed under the terms of the
343 Sections above.
344
345 b) Give prominent notice with the combined library of the fact
346 that part of it is a work based on the Library, and explaining
347 where to find the accompanying uncombined form of the same work.
348
349 8. You may not copy, modify, sublicense, link with, or distribute
350the Library except as expressly provided under this License. Any
351attempt otherwise to copy, modify, sublicense, link with, or
352distribute the Library is void, and will automatically terminate your
353rights under this License. However, parties who have received copies,
354or rights, from you under this License will not have their licenses
355terminated so long as such parties remain in full compliance.
356
357 9. You are not required to accept this License, since you have not
358signed it. However, nothing else grants you permission to modify or
359distribute the Library or its derivative works. These actions are
360prohibited by law if you do not accept this License. Therefore, by
361modifying or distributing the Library (or any work based on the
362Library), you indicate your acceptance of this License to do so, and
363all its terms and conditions for copying, distributing or modifying
364the Library or works based on it.
365
366 10. Each time you redistribute the Library (or any work based on the
367Library), the recipient automatically receives a license from the
368original licensor to copy, distribute, link with or modify the Library
369subject to these terms and conditions. You may not impose any further
370restrictions on the recipients' exercise of the rights granted herein.
371You are not responsible for enforcing compliance by third parties with
372this License.
373
374 11. If, as a consequence of a court judgment or allegation of patent
375infringement or for any other reason (not limited to patent issues),
376conditions are imposed on you (whether by court order, agreement or
377otherwise) that contradict the conditions of this License, they do not
378excuse you from the conditions of this License. If you cannot
379distribute so as to satisfy simultaneously your obligations under this
380License and any other pertinent obligations, then as a consequence you
381may not distribute the Library at all. For example, if a patent
382license would not permit royalty-free redistribution of the Library by
383all those who receive copies directly or indirectly through you, then
384the only way you could satisfy both it and this License would be to
385refrain entirely from distribution of the Library.
386
387If any portion of this section is held invalid or unenforceable under any
388particular circumstance, the balance of the section is intended to apply,
389and the section as a whole is intended to apply in other circumstances.
390
391It is not the purpose of this section to induce you to infringe any
392patents or other property right claims or to contest validity of any
393such claims; this section has the sole purpose of protecting the
394integrity of the free software distribution system which is
395implemented by public license practices. Many people have made
396generous contributions to the wide range of software distributed
397through that system in reliance on consistent application of that
398system; it is up to the author/donor to decide if he or she is willing
399to distribute software through any other system and a licensee cannot
400impose that choice.
401
402This section is intended to make thoroughly clear what is believed to
403be a consequence of the rest of this License.
404
405 12. If the distribution and/or use of the Library is restricted in
406certain countries either by patents or by copyrighted interfaces, the
407original copyright holder who places the Library under this License may add
408an explicit geographical distribution limitation excluding those countries,
409so that distribution is permitted only in or among countries not thus
410excluded. In such case, this License incorporates the limitation as if
411written in the body of this License.
412
413 13. The Free Software Foundation may publish revised and/or new
414versions of the Lesser General Public License from time to time.
415Such new versions will be similar in spirit to the present version,
416but may differ in detail to address new problems or concerns.
417
418Each version is given a distinguishing version number. If the Library
419specifies a version number of this License which applies to it and
420"any later version", you have the option of following the terms and
421conditions either of that version or of any later version published by
422the Free Software Foundation. If the Library does not specify a
423license version number, you may choose any version ever published by
424the Free Software Foundation.
425
426 14. If you wish to incorporate parts of the Library into other free
427programs whose distribution conditions are incompatible with these,
428write to the author to ask for permission. For software which is
429copyrighted by the Free Software Foundation, write to the Free
430Software Foundation; we sometimes make exceptions for this. Our
431decision will be guided by the two goals of preserving the free status
432of all derivatives of our free software and of promoting the sharing
433and reuse of software generally.
434
435 NO WARRANTY
436
437 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
438WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
439EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
440OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
441KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
442IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
443PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
444LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
445THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
446
447 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
448WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
449AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
450FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
451CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
452LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
453RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
454FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
455SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
456DAMAGES.
457
458 END OF TERMS AND CONDITIONS
459
460 How to Apply These Terms to Your New Libraries
461
462 If you develop a new library, and you want it to be of the greatest
463possible use to the public, we recommend making it free software that
464everyone can redistribute and change. You can do so by permitting
465redistribution under these terms (or, alternatively, under the terms of the
466ordinary General Public License).
467
468 To apply these terms, attach the following notices to the library. It is
469safest to attach them to the start of each source file to most effectively
470convey the exclusion of warranty; and each file should have at least the
471"copyright" line and a pointer to where the full notice is found.
472
473 <one line to give the library's name and a brief idea of what it does.>
474 Copyright (C) <year> <name of author>
475
476 This library is free software; you can redistribute it and/or
477 modify it under the terms of the GNU Lesser General Public
478 License as published by the Free Software Foundation; either
479 version 2 of the License, or (at your option) any later version.
480
481 This library is distributed in the hope that it will be useful,
482 but WITHOUT ANY WARRANTY; without even the implied warranty of
483 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
484 Lesser General Public License for more details.
485
486 You should have received a copy of the GNU Lesser General Public
487 License along with this library; if not, write to the Free Software
488 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
489
490Also add information on how to contact you by electronic and paper mail.
491
492You should also get your employer (if you work as a programmer) or your
493school, if any, to sign a "copyright disclaimer" for the library, if
494necessary. Here is a sample; alter the names:
495
496 Yoyodyne, Inc., hereby disclaims all copyright interest in the
497 library `Frob' (a library for tweaking knobs) written by James Random Hacker.
498
499 <signature of Ty Coon>, 1 April 1990
500 Ty Coon, President of Vice
501
502That's all there is to it!
503
504
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/ChangeLog b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/ChangeLog
new file mode 100755
index 0000000000..e69de29bb2
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/ChangeLog
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/INSTALL b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/INSTALL
new file mode 100755
index 0000000000..bca44d042e
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/INSTALL
@@ -0,0 +1,187 @@
1Basic Installation
2==================
3
4 The `configure' shell script attempts to guess correct values for
5various system-dependent variables used during compilation. It uses
6those values to create a `Makefile' in each directory of the package.
7It may also create one or more `.h' files containing system-dependent
8definitions. Finally, it creates a shell script `config.status' that
9you can run in the future to recreate the current configuration, a file
10`config.cache' that saves the results of its tests to speed up
11reconfiguring, and a file `config.log' containing compiler output
12(useful mainly for debugging `configure').
13
14 If you need to do unusual things to compile the package, please try
15to figure out how `configure' could check whether to do them, and mail
16diffs or instructions to the address given in the `README' so they can
17be considered for the next release. If at some point `config.cache'
18contains results you don't want to keep, you may remove or edit it.
19
20 The file `configure.in' is used to create `configure' by a program
21called `autoconf'. You only need `configure.in' if you want to change
22it or regenerate `configure' using a newer version of `autoconf'.
23
24The simplest way to compile this package is:
25
26 1. `cd' to the directory containing the package's source code and type
27 `./configure' to configure the package for your system. If you're
28 using `csh' on an old version of System V, you might need to type
29 `sh ./configure' instead to prevent `csh' from trying to execute
30 `configure' itself.
31
32 Running `configure' takes awhile. While running, it prints some
33 messages telling which features it is checking for.
34
35 2. Type `make' to compile the package.
36
37 If you're building GNU make on a system which does not already have
38 a `make', you can use the build.sh shell script to compile. Run
39 `sh ./build.sh'. This should compile the program in the current
40 directory. Then you will have a Make program that you can use for
41 `make install', or whatever else.
42
43 3. Optionally, type `./make check' to run any self-tests that come with
44 the package.
45
46 4. Type `make install' to install the programs and any data files and
47 documentation.
48
49 5. You can remove the program binaries and object files from the
50 source code directory by typing `make clean'. To also remove the
51 files that `configure' created (so you can compile the package for
52 a different kind of computer), type `make distclean'. There is
53 also a `make maintainer-clean' target, but that is intended mainly
54 for the package's developers. If you use it, you may have to get
55 all sorts of other programs in order to regenerate files that came
56 with the distribution.
57
58Compilers and Options
59=====================
60
61 Some systems require unusual options for compilation or linking that
62the `configure' script does not know about. You can give `configure'
63initial values for variables by setting them in the environment. Using
64a Bourne-compatible shell, you can do that on the command line like
65this:
66 CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
67
68Or on systems that have the `env' program, you can do it like this:
69 env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
70
71Compiling For Multiple Architectures
72====================================
73
74 You can compile the package for more than one kind of computer at the
75same time, by placing the object files for each architecture in their
76own directory. To do this, you must use a version of `make' that
77supports the `VPATH' variable, such as GNU `make'. `cd' to the
78directory where you want the object files and executables to go and run
79the `configure' script. `configure' automatically checks for the
80source code in the directory that `configure' is in and in `..'.
81
82 If you have to use a `make' that does not supports the `VPATH'
83variable, you have to compile the package for one architecture at a time
84in the source code directory. After you have installed the package for
85one architecture, use `make distclean' before reconfiguring for another
86architecture.
87
88Installation Names
89==================
90
91 By default, `make install' will install the package's files in
92`/usr/local/bin', `/usr/local/man', etc. You can specify an
93installation prefix other than `/usr/local' by giving `configure' the
94option `--prefix=PATH'.
95
96 You can specify separate installation prefixes for
97architecture-specific files and architecture-independent files. If you
98give `configure' the option `--exec-prefix=PATH', the package will use
99PATH as the prefix for installing programs and libraries.
100Documentation and other data files will still use the regular prefix.
101
102 In addition, if you use an unusual directory layout you can give
103options like `--bindir=PATH' to specify different values for particular
104kinds of files. Run `configure --help' for a list of the directories
105you can set and what kinds of files go in them.
106
107 If the package supports it, you can cause programs to be installed
108with an extra prefix or suffix on their names by giving `configure' the
109option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
110
111Optional Features
112=================
113
114 Some packages pay attention to `--enable-FEATURE' options to
115`configure', where FEATURE indicates an optional part of the package.
116They may also pay attention to `--with-PACKAGE' options, where PACKAGE
117is something like `gnu-as' or `x' (for the X Window System). The
118`README' should mention any `--enable-' and `--with-' options that the
119package recognizes.
120
121 For packages that use the X Window System, `configure' can usually
122find the X include and library files automatically, but if it doesn't,
123you can use the `configure' options `--x-includes=DIR' and
124`--x-libraries=DIR' to specify their locations.
125
126Specifying the System Type
127==========================
128
129 There may be some features `configure' can not figure out
130automatically, but needs to determine by the type of host the package
131will run on. Usually `configure' can figure that out, but if it prints
132a message saying it can not guess the host type, give it the
133`--host=TYPE' option. TYPE can either be a short name for the system
134type, such as `sun4', or a canonical name with three fields:
135 CPU-COMPANY-SYSTEM
136
137See the file `config.sub' for the possible values of each field. If
138`config.sub' isn't included in this package, then this package doesn't
139need to know the host type.
140
141 If you are building compiler tools for cross-compiling, you can also
142use the `--target=TYPE' option to select the type of system they will
143produce code for and the `--build=TYPE' option to select the type of
144system on which you are compiling the package.
145
146Sharing Defaults
147================
148
149 If you want to set default values for `configure' scripts to share,
150you can create a site shell script called `config.site' that gives
151default values for variables like `CC', `cache_file', and `prefix'.
152`configure' looks for `PREFIX/share/config.site' if it exists, then
153`PREFIX/etc/config.site' if it exists. Or, you can set the
154`CONFIG_SITE' environment variable to the location of the site script.
155A warning: not all `configure' scripts look for a site script.
156
157Operation Controls
158==================
159
160 `configure' recognizes the following options to control how it
161operates.
162
163`--cache-file=FILE'
164 Use and save the results of the tests in FILE instead of
165 `./config.cache'. Set FILE to `/dev/null' to disable caching, for
166 debugging `configure'.
167
168`--help'
169 Print a summary of the options to `configure', and exit.
170
171`--quiet'
172`--silent'
173`-q'
174 Do not print messages saying which checks are being made. To
175 suppress all normal output, redirect it to `/dev/null' (any error
176 messages will still be shown).
177
178`--srcdir=DIR'
179 Look for the package's source code in directory DIR. Usually
180 `configure' can determine that directory automatically.
181
182`--version'
183 Print the version of Autoconf used to generate the `configure'
184 script, and exit.
185
186`configure' also accepts some other, not widely useful, options.
187
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/NEWS b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/NEWS
new file mode 100755
index 0000000000..6c6bbd0175
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/NEWS
@@ -0,0 +1,184 @@
14.1.2:
2 - Fixed Cygwin DLL missing symbols problem.
3 - Fixed GNU-stack assembler section on some platforms (Debian-ARM).
4 - Fixed problem cause by include of <asm/byteorder.h>.
5 - Fixed SHA-384 and SHA-512 code Visual C++ compatibility.
6 - Improved detection of IBM ICU library version; has to be >= 2.8.
7
84.1.1:
9 - Fixed shared library version info.
10
114.1.0:
12 - Added SHA-384 and SHA-512 algorithms.
13 - Added HMAC-SHA-384 and HMAC-SHA-512 algorithms.
14 - Added generic SSE2 optimization for the above algorithms.
15 - Added more digest algorithms for PKCS#1 EMSA.
16 - Optimized swap32 and swap64 routines on Linux.
17 - Fixed missing definition in mpopt.h for s390x.
18 - Fixed nostackexec configuration bug.
19 - Fixed problem in Date::toString.
20 - Fixed deadlock problem which occured in certain cases where security
21 or crypto SPI constructor called getInstance for another security or
22 crypto SPI.
23 - Fixed a bug in the generic CBC encryption code; when called with
24 nblocks == 1, the feedback was set incorrectly.
25 - Fixed a bug in mpbsubmod; sometimes it takes multiple additions of
26 the modulus to get a positive number.
27 - Fixed PowerPC 64-bit configuration problem on Linux.
28
294.0.0:
30 - Added a C++ API interface, modeled after Java's security & crypto API.
31 - Added the new GNU noexecstack feature.
32 - Added more x86_64 and s390x assembler routines.
33 - Modified i2osp, so that it only requires as many octets as there are
34 significant bytes in the multi-precision integers.
35 - Fixed a bug in the creation of rsa keypairs; code was not correctly
36 migrated to new calling sequence. The code now implements the method
37 described in IEEE P.1363.
38 - Fixed another bug in mpextgcd_w which sometimes returned incorrect
39 results.
40 - Fixed a bug in mprshiftlsz, which didn't work correctly when size = 1.
41 - Fixed a configuration problem on Tru64 Unix.
42
433.1.0:
44 - Added wiping of private key components of keypairs before freeing.
45 - Fixed bug in mpextgcd_w which sometimes returned incorrect result.
46 - Fixed error in PowerPC 64-bit assembler symbol definitions.
47
483.0.0:
49 - Cleaned up installed header files.
50 - Modified the API so that all keys can be passed as arrays of bytes.
51 - Modified the API so that all key sizes are given in bits.
52 - Modified the multi-precision integer library to work better on 64-bit
53 machines.
54 - Modified the assembly source generation mechanism, employing the m4
55 macro processor.
56 - Added multi-precision integer vectorized assembler routines for
57 Itanium.
58 - Added multi-precision integer assembler routines for PowerPC 64-bit.
59 - Added multi-precision integer assembler routines for Alpha.
60 - Added multi-precision integer assembler routines for Opteron.
61 - Added multi-precision integer assembler routines for IBM zSeries 64-bit.
62 - Added multi-precision integer assembler routines for M68K.
63 - Added Jeff Johnson's python bindings.
64 - Added new unit tests.
65 - Added new benchmarking programs.
66
672.3.0pre:
68 - Modified the header files so that the library now uses self-contained autoconf-generated configuration files; a program employing BeeCrypt can now use the symbols already tested and defined instead of having to regenerate them (thus also eliminating the risk of inconsistencies).
69 - Added the AES algorithm, with assembler routines for i586 and powerpc.
70 - Added the DSA signature algorithm.
71 - Added PowerPC assembler routines for blowfish.
72 - Added Pentium4 SSE2 assembler multiplication routines.
73 - Fixed the RSA CRT algorithm.
74 - Fixed the gas/i386 mp32even and mp32odd routines.
75 - Fixed a bug in modular inverse computation; thanks to Jeff Johnson of RedHat for pointing this out.
76 - Fixed a bug in testing the result of a gcd operation in the mp32prndconone routine.
77 - Fixed an ugly bug in base64 decoding.
78 - Fixed compatibility with the latest automake & autoconf versions.
79 - Replaces CPU optimization mechanism in configure script.
80
812.1.0:
82 - Added support for automake, autoheader and libtool, which should make compiling the library even easier.
83 - Changed DHAES API to conform to IEEE P.1363 submission and to allow for uneven key splitting.
84 - Improved PKCS#5 padding routines.
85 - Added a hash reset to the hashFunctionContextInit function. This was pointed out by Marko Kreen.
86 - Fixed problem with configuring on i486-pc-linux-gnu. This was pointed out Steve O'Neill.
87 - Fixed problem in the C version of mp32sub where carry would sometimes be missed. This was pointed out by Jon Sturgeon.
88 - Revised entropy gathering system to do timeouts & asynchronous I/O where possible, to avoid hangs in case there's no noise on the audio device (i.e. digital silence), or when no data is available on devices such as /dev/random.
89 - Changed mp32opt i386 assembler routines for slight performance improvement.
90 - Changed mp32opt powerpc assembler routines for slight performance improvement.
91 - Changed mp32opt sparcv9 assembler routines for slight performance improvement.
92 - Added sparcv8 assembler routines for multi-precision integer multiplication.
93 - Added arm assembler routines for multi-precision integer multiplication.
94 - Added prototype 64-bit ia64 assembler routines for multi-precision integer operations.
95 - Started writing the long-awaited documentation.
96
972.0.0:
98 - Changed mp32barrett struct and operations to be multithread-safe; this required a change in API.
99 - Changed hashFunction struct to incorporate internal block size parameter.
100 - Changed HMAC algorithm and file names to match names in RFC 2104.
101 - Changed SHA-1 C code for slightly faster results.
102 - Changed detection of entropy devices.
103 - Changed most void-returning functions to return int for error conditions.
104 - Changed beecrypt-java class names in javaglue.
105 - Added RSA keypair generation.
106 - Added RSA private & public key operations.
107 - Added SHA-256 hash function.
108 - Added HMAC-MD5 and HMAC-SHA-256 keyed hash functions.
109 - Added PKCS#5 padding.
110 - Added DHAES encryption scheme.
111 - Added Microsoft Visual C support, added Makefile.mak for this purpose.
112 - Added Solaris/Sparc Forte C 64 bit support.
113 - Added configure --disable-optimized option (disables assembler & processor-specific optimizations).
114 - Fixed bug in SHA-1 assembler code for Pentium, where local variables were used below the current stack pointer; this could cause a problem if the routine was interrupted. This was pointed out by Richard Clayton.
115 - Fixed bug in (certain cases of) modular inverse computation.
116 - Fixed buffer overrun in base64 encoding. This was pointed out by Jon Sturgeon.
117 - Fixed various minor bugs.
118 - Renamed text files to match automake conventions.
119
1201.1.2:
121 - Fixed bugs in discrete logarithm domain parameter generator. The code to make a generator of order q and (p-1) was wrong. This was pointed out by Susumu Yamamoto.
122 - Added MD5 hash function.
123
1241.1.1:
125 - Changed autoconfig script for easier porting.
126 - Changed sources for easier compilation on Microsoft Visual C++; no assembler-optimization on this platform yet.
127 - Fixed bug in javaglue when passing null IV to blockcipher.
128 - Shared library is now linked dynamically, with shared object name and version.
129 - Tested on Alpha Linux.
130 - Tested on Alpha FreeBSD.
131 - Added support for Compaq Alpha Tru64 Unix.
132 - Added initial support for QNX.
133
1341.1.0:
135 - Added glue for interfacing from BeeCrypt Java Cryptography Provider.
136 - Changed blockcipher struct to support interfacing with Java.
137 - Added better blockcipher IV handling.
138 - Multi-pass block processing is now possible with blockEncrypt/blockDecrypt.
139 - Updated config.sub and config.guess to latest version from sources.redhat.com
140 - Changed opening of entropy devices to blocking read-only mode instead of non-blocking read-write.
141 - Added win32 'wincrypt' entropy source.
142 - Added win32 'console' entropy source.
143 - Added FreeBSD support.
144 - Added PowerPC assembler optimized multiprecision subtraction routines.
145 - Added initial ia64 support.
146 - Added initial Darwin support (everything compiles, but the shared library doesn't build yet).
147
1481.0.2:
149 - Fixed Windows 2000 entropy bug; instead of using the first waveIn device, entropy now uses WAVE_MAPPER.
150 - Added sparcv9 mp32addsqrtrc GNU assembler routine.
151 - Added more hashFunctionContext and keyedHashFunctionContext functions.
152
1531.0.1:
154 - Added a sliding window modular exponentiation, about 30% faster than left-to-right exponentiation.
155 - Fixed bugs in fips180opt.gas.i586.s (Linux SHA-1 assembler code for Pentium/Pentium Pro) - the Windows/Metrowerks version was okay.
156
1571.0.0:
158 - Added Win32 support; compiled as DLL with MetroWerks CodeWarrior Pro 5, it runs fine on Windows 95, 98, NT 4.0 (if you have a soundcard with a microphone port). Note that there is a know issue on Windows 2000, see BUGS.
159 - Global code overhaul to support Win32
160 - Added more assembler routines, including SHA-1 for Pentium Pro (60% faster)
161 - Added cleanup function to randomGenerator
162 - Added missing functions in endianness.c
163 - Fixed bug in entropy.c where devices might stay open
164 - Eliminated mutex.h include file; it was more clear to do everything conditionally than to expand the macros in this file to encompass the Win32 API calls.
165
1660.9.5:
167 - Added PowerPC assembler optimization for multiprecision integers, 80% faster on our PowerMac 7200/90
168 - Fixed /dev/random entropy provider
169 - Changed name SHA1 to SHA-1 in fips180 for consistency
170
1710.9.4a:
172 - Added missing file 'blowfishopt.o'
173
1740.9.4:
175 - Changes to configure script, to distinguish between different processors of the x86 family
176 - Changes to blowfish code, 586/686 assembler optimization added, 30% faster on Pentium/PentiumPro
177 - Changes to blowfish code, eliminated static blowfishSetupEncrypt; incorporated into regular encrypt
178 - Changes to Makefile to selectively use blowfish assember code, depending on cpu type
179 - Added missing routines 'mp32bzero' and 'mp32bnpowmod' to mp32barrett.c
180 - Fixed 'const register' to 'register const' in mp32.c
181 - Minor fixes in included header files
182
1830.9.3:
184 - Initial public release
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/README b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/README
new file mode 100755
index 0000000000..d875372c39
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/README
@@ -0,0 +1,143 @@
1Welcome to the BeeCrypt crypto library!
2
3Copyright (c) 1997, 1998, 1999, 2000, 2001 Virtual Unlimited B.V.
4Copyright (c) 2002, 2003, Bob Deblier (for certain parts)
5
6Author: Bob Deblier <bob.deblier@pandora.be>
7
8This library is free software; you can redistribute it and/or
9modify it under the terms of the GNU Lesser General Public
10License as published by the Free Software Foundation; either
11version 2.1 of the License, or (at your option) any later version.
12
13This library is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16Lesser General Public License for more details.
17
18You should have received a copy of the GNU Lesser General Public
19License along with this library; if not, write to the Free Software
20Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
22For the specifics of this license, see file 'COPYING.LIB', included in
23this distribution.
24
25
26
27Welcome to version 3.0.0 of BeeCrypt:
28
29AES support has been added, and the library has been thoroughly debugged,
30with the addition of unit tests. Once you've built the library, you can
31verify the correct functioning with 'make check'.
32
33Multi-precision integer routines should now perform dramatically better
34an 64-bit processors, especially Alpha and Itanium.
35
36Benchmarks can be obtained with 'make bench'.
37
38As usual, your comments are welcome.
39
40
41
42About BeeCrypt:
43
44This library is an ongoing project of Virtual Unlimited B.V. Its goal is
45to provide strong and fast cryptography for use by our products, but
46we're not limiting the use to that. We're releasing it under the LGPL
47license, because we feel that cryptography should be open to inspection
48by everybody, and available for use by everybody to safeguard privacy.
49
50Note that depending on where you are, the use of cryptography may be
51limited or forbidden by law. Before using this library, make sure you
52are legally entitled to do so.
53
54
55For more on Virtual Unlimited B.V. and our products please consult our
56website: http://www.virtualunlimited.com/
57
58
59<plug>
60Most of the algorithms are implemented from reliable sources such as:
61
62"Handbook of Applied Cryptography"
63 Alfred J. Menezes, Paul C. van Oorschot, Scott A. Vanstone
64 CRC Press
65
66"Applied Cryptography", second edition
67 Bruce Schneier
68 Wiley
69
70
71For crypto enthusiasts these books are invaluable background material.
72
73IEEE P1363 "Standard Specifications for Public Key Cryptography" is a
74very interesting draft standard, which we will try to comply with.
75</plug>
76
77The structures in the library are geared towards exchange with Java
78and its security and cryptography classes. This library can also be
79accessed from Java by installing BeeCrypt for Java, a JCE 1.2 crypto
80provider and the counterpart of this library.
81
82
83Included in the library are:
84 - entropy sources for initializing pseudo-random generators
85 - pseudo-random generators: FIPS-186, Mersenne Twister
86 - block ciphers: AES, Blowfish
87 - hash functions: MD5, SHA-1, SHA-256
88 - keyed hash functions: HMAC-MD5, HMAC-SHA-1, HMAC-SHA-256
89 - multi-precision integer library, with assembler-optimized routines
90 for several processors
91 - probabilistic primality testing, with optimized small prime trial
92 division
93 - discrete logarithm parameter generation over a prime field
94 - Diffie-Hellman key agreement
95 - DSA signature scheme
96 - ElGamal signature scheme (two variants)
97 - RSA keypair generation with chinese remainder theorem variables
98 - RSA public & private key operations
99 - DHAES encryption scheme
100
101Planned for the near future are:
102 - compliance with and compliance statements for IEEE P1363
103 - more blockciphers (Twofish, ... )
104 - more hash functions (RIPEMD-160, SHA-384, SHA-512, HAVAL, Tiger)
105 - RSA signatures as specified by RFC-2440.
106 - Elliptic Curves (ECDSA, ... )
107 - more blockcipher modes (OFB, ... )
108
109The library has been tested on the following platforms:
110 - AIX 5.1 ppc
111 - AIX 5.1 ppc64
112 - Darwin 6.5 (a.k.a. MacOS X 10.2)
113 - FreeBSD 4.0 alpha
114 - FreeBSD 4.0, 4.2 x86
115 - Linux glibc 2.x alpha
116 - Linux glibc 2.x arm
117 - Linux glibc 2.x ia64
118 - Linux glibc 2.x ppc
119 - Linux glibc 2.x sparc
120 - Linux glibc 2.x x86
121 - Solaris 2.6/2.7/2.8/2.9 sparc (with Forte or gnu compilers)
122 - Solaris 2.7/2.8 x86 (with Forte or GNU compilers)
123 - Tru64 Unix alpha
124 - Win32 (Windows 95, 98, NT 4.0, 2000, XP)
125
126The library is currently in the process of being ported to:
127 - Cygwin (Can't seem to get the DLL to build properly with the current
128 version of the autotools)
129 - HP/UX is a pain in the backside; I'll try getting it working, but the
130 configure script doesn't seem capable of properly detecting gettimeofday.
131
132For more information, refer to the HTML documentation in the docs directory.
133
134If you want to report bugs, make suggestions, contribute fixes or
135enhancements, please see the beecrypt-specific website:
136
137http://sourceforge.net/projects/beecrypt
138
139or contact me at mailto:bob.deblier@pandora.be
140
141Sincerely,
142
143Bob Deblier
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/README.DLL b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/README.DLL
new file mode 100755
index 0000000000..2131f87ce2
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/README.DLL
@@ -0,0 +1,37 @@
1File beetest.exe is a compiled version of the test program included in
2the source distribution, which you can find on our website:
3http://beecrypt.virtualunlimited.com/
4
5To run, it needs file beecrypt.dll present in the same directory.
6
7For Developers:
8
9Files beecrypt.dll and beecrypt.lib are a pre-compiled version of the
10BeeCrypt library for Pentium Pro processors.
11
12If you want to develop applications with this library, you'll also need
13the header files, included in the source distribution (see higher).
14
15Please make sure you respect the term of the license under which the
16BeeCrypt library is released:
17
18Copyright (c) 1997, 1998, 1999, 2000, 2001 Virtual Unlimited B.V.
19
20Author: Bob Deblier <bob@virtualunlimited.com>
21
22This library is free software; you can redistribute it and/or
23modify it under the terms of the GNU Lesser General Public
24License as published by the Free Software Foundation; either
25version 2.1 of the License, or (at your option) any later version.
26
27This library is distributed in the hope that it will be useful,
28but WITHOUT ANY WARRANTY; without even the implied warranty of
29MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30Lesser General Public License for more details.
31
32You should have received a copy of the GNU Lesser General Public
33License along with this library; if not, write to the Free Software
34Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35
36For the specifics of this license, see file 'COPYING', included in this
37distribution.
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/README.WIN32 b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/README.WIN32
new file mode 100755
index 0000000000..411116fea2
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/README.WIN32
@@ -0,0 +1,43 @@
1This file contains information on how to build and use the BeeCrypt DLL on
2Win32 platforms.
3
4The platform of preference is currently MicroSoft Visual C++ 6.0, but
5Metrowerks CodeWarrior is also still supported.
6
7To be able to use the assembler files with Visual C++, you need to have the
8Visual C++ 6.0 Processor Pack installed. It can be found at:
9
10http://msdn.microsoft.com/vstudio/downloads/ppack/default.asp
11
12To be able to use the assembler files with Metrowerks CodeWarrior, you will
13need to install an unsupported (but working for the included files) assembler
14plug-in, which can be found on the CodeWarrior download page.
15
16To build the java glue into the DLL, you should also have Sun's JDK 1.3,
17including the JNI headers, installed.
18
19Make sure all Visual C++ tools can be found on the path, i.e.:
20
21cl.exe (the compiler)
22ml.exe (the assembler)
23link.exe (the linker)
24nmake.exe (the make utility)
25
26For convenience, copy file 'Makefile.mak' to 'Makefile' and adjust paths as
27required. The Makefile assumes you will be building in support for java.
28If this is not the case, you will have to adjust the Makefile, which shouldn't
29be too difficult.
30
31Next, run 'nmake' and the library and the test program will be built.
32
33Once running, you can use any of three entropy source available on this
34platform, in order of preference:
35
36wavein (uses noise on the soundcard microphone port)
37console (uses keyboard clicks with a high resolution timer)
38wincrypt (uses random data generated by the Windows CryptAPI)
39
40To enable a specific entropy device, set variable BEECRYPT_ENTROPY to any of
41these three values; if not specified, the library will use 'wavein' as default.
42
43In the future, additional sources of entropy on this platform will be made available.
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/api.h b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/api.h
new file mode 100755
index 0000000000..f5ef7ff04a
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/api.h
@@ -0,0 +1,89 @@
1/*
2 * Copyright (c) 2001, 2002, 2004 Beeyond Software Holding BV
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 api.h
21 * \brief BeeCrypt API, portability headers.
22 * \author Bob Deblier <bob.deblier@pandora.be>
23 */
24
25#ifndef _BEECRYPT_API_H
26#define _BEECRYPT_API_H
27
28#if defined(_WIN32) && !defined(WIN32)
29# define WIN32 1
30#endif
31
32#if WIN32
33# if !__CYGWIN32__
34# include "beecrypt/win.h"
35# else
36# include "beecrypt/gnu.h"
37# endif
38# ifdef BEECRYPT_DLL_EXPORT
39# define BEECRYPTAPI //__declspec(dllexport)
40# else
41# define BEECRYPTAPI //__declspec(dllimport)
42# endif
43# ifdef BEECRYPT_CXX_DLL_EXPORT
44# define BEECRYPTCXXAPI //__declspec(dllexport)
45# define BEECRYPTCXXTEMPLATE
46# else
47# define BEECRYPTCXXAPI //__declspec(dllimport)
48# define BEECRYPTCXXTEMPLATE extern
49# endif
50#else
51# include "beecrypt/gnu.h"
52# define BEECRYPTAPI
53# define BEECRYPTCXXAPI
54#endif
55
56#ifndef ROTL32
57# define ROTL32(x, s) (((x) << (s)) | ((x) >> (32 - (s))))
58#endif
59#ifndef ROTR32
60# define ROTR32(x, s) (((x) >> (s)) | ((x) << (32 - (s))))
61#endif
62#ifndef ROTR64
63# define ROTR64(x, s) (((x) >> (s)) | ((x) << (64 - (s))))
64#endif
65
66typedef uint8_t byte;
67
68typedef int8_t javabyte;
69typedef int16_t javashort;
70typedef int32_t javaint;
71typedef int64_t javalong;
72
73typedef uint16_t javachar;
74
75#if (MP_WBITS == 64)
76typedef uint64_t mpw;
77typedef uint32_t mphw;
78#elif (MP_WBITS == 32)
79# if HAVE_UINT64_T
80# define HAVE_MPDW 1
81typedef uint64_t mpdw;
82# endif
83typedef uint32_t mpw;
84typedef uint16_t mphw;
85#else
86# error
87#endif
88
89#endif
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/beecrypt.h b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/beecrypt.h
new file mode 100755
index 0000000000..a4c8780d03
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/beecrypt.h
@@ -0,0 +1,799 @@
1/*
2 * Copyright (c) 1999, 2000, 2001, 2002 Virtual Unlimited B.V.
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 beecrypt.h
21 * \brief BeeCrypt API, headers.
22 *
23 * These API functions provide an abstract way for using most of
24 * the various algorithms implemented by the library.
25 *
26 * \author Bob Deblier <bob.deblier@pandora.be>
27 * \ingroup ES_m PRNG_m HASH_m HMAC_m BC_m
28 */
29
30#ifndef _BEECRYPT_H
31#define _BEECRYPT_H
32
33#include "beecrypt/api.h"
34
35#include "beecrypt/memchunk.h"
36#include "beecrypt/mpnumber.h"
37
38/*
39 * Entropy Sources
40 */
41
42/*!\typedef entropyNext
43 * \brief Prototype definition for an entropy-generating function.
44 * \ingroup ES_m
45 */
46typedef int (*entropyNext)(byte*, size_t);
47
48/*!\brief This struct holds information and pointers to code specific to each
49 * source of entropy.
50 * \ingroup ES_m
51 */
52#ifdef __cplusplus
53struct BEECRYPTAPI entropySource
54#else
55struct _entropySource
56#endif
57{
58 /*!\var name
59 * \brief The entropy source's name.
60 */
61 const char* name;
62 /*!\var next
63 * \brief Points to the function which produces the entropy.
64 */
65 const entropyNext next;
66};
67
68#ifndef __cplusplus
69typedef struct _entropySource entropySource;
70#endif
71
72#ifdef __cplusplus
73extern "C" {
74#endif
75
76/*!\fn int entropySourceCount()
77 * \brief This function returns the number of entropy sources implemented by
78 * the library.
79 * \return The number of implemented entropy sources.
80 */
81BEECRYPTAPI
82int entropySourceCount(void);
83
84/*!\fn const entropySource* entropySourceGet(int n)
85 * \brief This function returns the \a n -th entropy source implemented by
86 * the library.
87 * \param n Index of the requested entropy source; legal values are 0
88 * through entropySourceCount() - 1.
89 * \return A pointer to an entropy source or null, if the index was out of
90 * range.
91 */
92BEECRYPTAPI
93const entropySource* entropySourceGet(int n);
94
95/*!\fn const entropySource* entropySourceFind(const char* name)
96 * \brief This function returns the entropy source specified by the given name.
97 * \param name Name of the requested entropy source.
98 * \return A pointer to an entropy source or null, if the name wasn't found.
99 */
100BEECRYPTAPI
101const entropySource* entropySourceFind(const char* name);
102
103/*!\fn const entropySource* entropySourceDefault()
104 * \brief This functions returns the default entropy source; the default value
105 * can be specified by setting environment variable BEECRYPT_ENTROPY.
106 * \return A pointer to an entropy source or null, in case an error occured.
107 */
108BEECRYPTAPI
109const entropySource* entropySourceDefault(void);
110
111/*!\fn int entropyGatherNext(byte* data, size_t size)
112 * \brief This function gathers \a size bytes of entropy into \a data.
113 *
114 * Unless environment variable BEECRYPT_ENTROPY is set, this function will
115 * try each successive entropy source to gather up the requested amount.
116 *
117 * \param data Points to where the entropy should be stored.
118 * \param size Indicates how many bytes of entropy should be gathered.
119 * \retval 0 On success.
120 * \retval -1 On failure.
121 */
122BEECRYPTAPI
123int entropyGatherNext(byte*, size_t);
124
125#ifdef __cplusplus
126}
127#endif
128
129/*
130 * Pseudo-random Number Generators
131 */
132
133typedef void randomGeneratorParam;
134
135typedef int (*randomGeneratorSetup )(randomGeneratorParam*);
136typedef int (*randomGeneratorSeed )(randomGeneratorParam*, const byte*, size_t);
137typedef int (*randomGeneratorNext )(randomGeneratorParam*, byte*, size_t);
138typedef int (*randomGeneratorCleanup)(randomGeneratorParam*);
139
140/*
141 * The struct 'randomGenerator' holds information and pointers to code specific
142 * to each random generator. Each specific random generator MUST be written to
143 * be multithread safe.
144 *
145 * WARNING: each randomGenerator, when used in cryptographic applications, MUST
146 * be guaranteed to be of suitable quality and strength (i.e. don't use the
147 * random() function found in most UN*X-es).
148 *
149 * Multiple instances of each randomGenerator can be used (even concurrently),
150 * provided they each use their own randomGeneratorParam parameters, a chunk
151 * of memory which must be at least as large as indicated by the paramsize
152 * field.
153 *
154 */
155
156/*!\brief This struct holds information and pointers to code specific to each
157 * pseudo-random number generator.
158 * \ingroup PRNG_m
159 */
160#ifdef __cplusplus
161struct BEECRYPTAPI randomGenerator
162#else
163struct _randomGenerator
164#endif
165{
166 /*!\var name
167 * \brief The random generator's name.
168 */
169 const char* name;
170 /*!\var paramsize
171 * \brief The size of the random generator's parameters.
172 * \note The implementor should set this by using sizeof(<struct holding
173 * random generator's parameters>).
174 */
175 const size_t paramsize;
176 /*!\var setup
177 * \brief Points to the setup function.
178 */
179 const randomGeneratorSetup setup;
180 /*!\var seed
181 * \brief Points to the seeding function.
182 */
183 const randomGeneratorSeed seed;
184 /*!\var seed
185 * \brief Points to the function which generates the random data.
186 */
187 const randomGeneratorNext next;
188 /*!\var seed
189 * \brief Points to the cleanup function.
190 */
191 const randomGeneratorCleanup cleanup;
192};
193
194#ifndef __cplusplus
195typedef struct _randomGenerator randomGenerator;
196#endif
197
198/*
199 * You can use the following functions to find random generators implemented by
200 * the library:
201 *
202 * randomGeneratorCount returns the number of generators available.
203 *
204 * randomGeneratorGet returns the random generator with a given index (starting
205 * at zero, up to randomGeneratorCount() - 1), or NULL if the index was out of
206 * bounds.
207 *
208 * randomGeneratorFind returns the random generator with the given name, or
209 * NULL if no random generator exists with that name.
210 */
211
212#ifdef __cplusplus
213extern "C" {
214#endif
215
216BEECRYPTAPI
217int randomGeneratorCount(void);
218BEECRYPTAPI
219const randomGenerator* randomGeneratorGet(int);
220BEECRYPTAPI
221const randomGenerator* randomGeneratorFind(const char*);
222BEECRYPTAPI
223const randomGenerator* randomGeneratorDefault(void);
224
225#ifdef __cplusplus
226}
227#endif
228
229/*
230 * The struct 'randomGeneratorContext' is used to contain both the functional
231 * part (the randomGenerator), and its parameters.
232 */
233
234#ifdef __cplusplus
235struct BEECRYPTAPI randomGeneratorContext
236#else
237struct _randomGeneratorContext
238#endif
239{
240 const randomGenerator* rng;
241 randomGeneratorParam* param;
242
243 #ifdef __cplusplus
244 randomGeneratorContext();
245 randomGeneratorContext(const randomGenerator*);
246 ~randomGeneratorContext();
247 #endif
248};
249
250#ifndef __cplusplus
251typedef struct _randomGeneratorContext randomGeneratorContext;
252#endif
253
254/*
255 * The following functions can be used to initialize and free a
256 * randomGeneratorContext. Initializing will allocate a buffer of the size
257 * required by the randomGenerator, freeing will deallocate that buffer.
258 */
259
260#ifdef __cplusplus
261extern "C" {
262#endif
263
264BEECRYPTAPI
265int randomGeneratorContextInit(randomGeneratorContext*, const randomGenerator*);
266BEECRYPTAPI
267int randomGeneratorContextFree(randomGeneratorContext*);
268BEECRYPTAPI
269int randomGeneratorContextNext(randomGeneratorContext*, byte*, size_t);
270BEECRYPTAPI
271int randomGeneratorContextSeed(randomGeneratorContext*, const byte*, size_t);
272
273#ifdef __cplusplus
274}
275#endif
276
277/*
278 * Hash Functions
279 */
280
281/*!typedef void hashFunctionParam
282 * \ingroup HASH_m
283 */
284typedef void hashFunctionParam;
285
286typedef int (*hashFunctionReset )(hashFunctionParam*);
287typedef int (*hashFunctionUpdate)(hashFunctionParam*, const byte*, size_t);
288typedef int (*hashFunctionDigest)(hashFunctionParam*, byte*);
289
290/*
291 * The struct 'hashFunction' holds information and pointers to code specific
292 * to each hash function. Specific hash functions MAY be written to be
293 * multithread-safe.
294 *
295 * NOTE: data MUST have a size (in bytes) of at least 'digestsize' as described
296 * in the hashFunction struct.
297 * NOTE: for safety reasons, after calling digest, each specific implementation
298 * MUST reset itself so that previous values in the parameters are erased.
299 */
300#ifdef __cplusplus
301struct BEECRYPTAPI hashFunction
302#else
303struct _hashFunction
304#endif
305{
306 const char* name;
307 const size_t paramsize; /* in bytes */
308 const size_t blocksize; /* in bytes */
309 const size_t digestsize; /* in bytes */
310 const hashFunctionReset reset;
311 const hashFunctionUpdate update;
312 const hashFunctionDigest digest;
313};
314
315#ifndef __cplusplus
316typedef struct _hashFunction hashFunction;
317#endif
318
319/*
320 * You can use the following functions to find hash functions implemented by
321 * the library:
322 *
323 * hashFunctionCount returns the number of hash functions available.
324 *
325 * hashFunctionGet returns the hash function with a given index (starting
326 * at zero, up to hashFunctionCount() - 1), or NULL if the index was out of
327 * bounds.
328 *
329 * hashFunctionFind returns the hash function with the given name, or
330 * NULL if no hash function exists with that name.
331 */
332
333#ifdef __cplusplus
334extern "C" {
335#endif
336
337BEECRYPTAPI
338int hashFunctionCount(void);
339BEECRYPTAPI
340const hashFunction* hashFunctionGet(int);
341BEECRYPTAPI
342const hashFunction* hashFunctionFind(const char*);
343BEECRYPTAPI
344const hashFunction* hashFunctionDefault(void);
345
346#ifdef __cplusplus
347}
348#endif
349
350/*
351 * The struct 'hashFunctionContext' is used to contain both the functional
352 * part (the hashFunction), and its parameters.
353 */
354#ifdef __cplusplus
355struct BEECRYPTAPI hashFunctionContext
356#else
357struct _hashFunctionContext
358#endif
359{
360 const hashFunction* algo;
361 hashFunctionParam* param;
362
363 #ifdef __cplusplus
364 hashFunctionContext();
365 hashFunctionContext(const hashFunction*);
366 ~hashFunctionContext();
367 #endif
368};
369
370#ifndef __cplusplus
371typedef struct _hashFunctionContext hashFunctionContext;
372#endif
373
374/*
375 * The following functions can be used to initialize and free a
376 * hashFunctionContext. Initializing will allocate a buffer of the size
377 * required by the hashFunction, freeing will deallocate that buffer.
378 */
379
380#ifdef __cplusplus
381extern "C" {
382#endif
383
384BEECRYPTAPI
385int hashFunctionContextInit(hashFunctionContext*, const hashFunction*);
386BEECRYPTAPI
387int hashFunctionContextFree(hashFunctionContext*);
388BEECRYPTAPI
389int hashFunctionContextReset(hashFunctionContext*);
390BEECRYPTAPI
391int hashFunctionContextUpdate(hashFunctionContext*, const byte*, size_t);
392BEECRYPTAPI
393int hashFunctionContextUpdateMC(hashFunctionContext*, const memchunk*);
394BEECRYPTAPI
395int hashFunctionContextUpdateMP(hashFunctionContext*, const mpnumber*);
396BEECRYPTAPI
397int hashFunctionContextDigest(hashFunctionContext*, byte*);
398BEECRYPTAPI
399int hashFunctionContextDigestMP(hashFunctionContext*, mpnumber*);
400BEECRYPTAPI
401int hashFunctionContextDigestMatch(hashFunctionContext*, const mpnumber*);
402
403#ifdef __cplusplus
404}
405#endif
406
407/*
408 * Keyed Hash Functions, a.k.a. Message Authentication Codes
409 */
410
411/*!\typedef void keyedHashFunctionParam
412 * \ingroup HMAC_m
413 */
414typedef void keyedHashFunctionParam;
415
416typedef int (*keyedHashFunctionSetup )(keyedHashFunctionParam*, const byte*, size_t);
417typedef int (*keyedHashFunctionReset )(keyedHashFunctionParam*);
418typedef int (*keyedHashFunctionUpdate )(keyedHashFunctionParam*, const byte*, size_t);
419typedef int (*keyedHashFunctionDigest )(keyedHashFunctionParam*, byte*);
420
421/*
422 * The struct 'keyedHashFunction' holds information and pointers to code
423 * specific to each keyed hash function. Specific keyed hash functions MAY be
424 * written to be multithread-safe.
425 *
426 * The struct field 'keybitsmin' contains the minimum number of bits a key
427 * must contains, 'keybitsmax' the maximum number of bits a key may contain,
428 * 'keybitsinc', the increment in bits that may be used between min and max.
429 *
430 * NOTE: data must be at least have a bytesize of 'digestsize' as described
431 * in the keyedHashFunction struct.
432 * NOTE: for safety reasons, after calling digest, each specific implementation
433 * MUST reset itself so that previous values in the parameters are erased.
434 */
435#ifdef __cplusplus
436struct BEECRYPTAPI keyedHashFunction
437#else
438struct _keyedHashFunction
439#endif
440{
441 const char* name;
442 const size_t paramsize; /* in bytes */
443 const size_t blocksize; /* in bytes */
444 const size_t digestsize; /* in bytes */
445 const size_t keybitsmin; /* in bits */
446 const size_t keybitsmax; /* in bits */
447 const size_t keybitsinc; /* in bits */
448 const keyedHashFunctionSetup setup;
449 const keyedHashFunctionReset reset;
450 const keyedHashFunctionUpdate update;
451 const keyedHashFunctionDigest digest;
452};
453
454#ifndef __cplusplus
455typedef struct _keyedHashFunction keyedHashFunction;
456#endif
457
458/*
459 * You can use the following functions to find keyed hash functions implemented
460 * by the library:
461 *
462 * keyedHashFunctionCount returns the number of keyed hash functions available.
463 *
464 * keyedHashFunctionGet returns the keyed hash function with a given index
465 * (starting at zero, up to keyedHashFunctionCount() - 1), or NULL if the index
466 * was out of bounds.
467 *
468 * keyedHashFunctionFind returns the keyed hash function with the given name,
469 * or NULL if no keyed hash function exists with that name.
470 */
471
472#ifdef __cplusplus
473extern "C" {
474#endif
475
476BEECRYPTAPI
477int keyedHashFunctionCount(void);
478BEECRYPTAPI
479const keyedHashFunction* keyedHashFunctionGet(int);
480BEECRYPTAPI
481const keyedHashFunction* keyedHashFunctionFind(const char*);
482BEECRYPTAPI
483const keyedHashFunction* keyedHashFunctionDefault(void);
484
485#ifdef __cplusplus
486}
487#endif
488
489/*
490 * The struct 'keyedHashFunctionContext' is used to contain both the functional
491 * part (the keyedHashFunction), and its parameters.
492 */
493#ifdef __cplusplus
494struct BEECRYPTAPI keyedHashFunctionContext
495#else
496struct _keyedHashFunctionContext
497#endif
498{
499 const keyedHashFunction* algo;
500 keyedHashFunctionParam* param;
501
502 #ifdef __cplusplus
503 keyedHashFunctionContext();
504 keyedHashFunctionContext(const keyedHashFunction*);
505 ~keyedHashFunctionContext();
506 #endif
507};
508
509#ifndef __cplusplus
510typedef struct _keyedHashFunctionContext keyedHashFunctionContext;
511#endif
512
513/*
514 * The following functions can be used to initialize and free a
515 * keyedHashFunctionContext. Initializing will allocate a buffer of the size
516 * required by the keyedHashFunction, freeing will deallocate that buffer.
517 */
518
519#ifdef __cplusplus
520extern "C" {
521#endif
522
523BEECRYPTAPI
524int keyedHashFunctionContextInit(keyedHashFunctionContext*, const keyedHashFunction*);
525BEECRYPTAPI
526int keyedHashFunctionContextFree(keyedHashFunctionContext*);
527BEECRYPTAPI
528int keyedHashFunctionContextSetup(keyedHashFunctionContext*, const byte*, size_t);
529BEECRYPTAPI
530int keyedHashFunctionContextReset(keyedHashFunctionContext*);
531BEECRYPTAPI
532int keyedHashFunctionContextUpdate(keyedHashFunctionContext*, const byte*, size_t);
533BEECRYPTAPI
534int keyedHashFunctionContextUpdateMC(keyedHashFunctionContext*, const memchunk*);
535BEECRYPTAPI
536int keyedHashFunctionContextUpdateMP(keyedHashFunctionContext*, const mpnumber*);
537BEECRYPTAPI
538int keyedHashFunctionContextDigest(keyedHashFunctionContext*, byte*);
539BEECRYPTAPI
540int keyedHashFunctionContextDigestMP(keyedHashFunctionContext*, mpnumber*);
541BEECRYPTAPI
542int keyedHashFunctionContextDigestMatch(keyedHashFunctionContext*, const mpnumber*);
543
544#ifdef __cplusplus
545}
546#endif
547
548/*
549 * Block ciphers
550 */
551
552/*!\enum cipherOperation
553 * \brief Specifies whether to perform encryption or decryption.
554 * \ingroup BC_m
555 */
556typedef enum
557{
558 NOCRYPT,
559 ENCRYPT,
560 DECRYPT
561} cipherOperation;
562
563/*!\typedef void blockCipherParam
564 * \brief Placeholder type definition for blockcipher parameters.
565 * \sa aesParam, blowfishParam.
566 * \ingroup BC_m
567 */
568typedef void blockCipherParam;
569
570/*!\brief Prototype definition for a setup function.
571 * \ingroup BC_m
572 */
573typedef int (*blockCipherSetup )(blockCipherParam*, const byte*, size_t, cipherOperation);
574
575/*!\typedef int (*blockCipherSetIV)(blockCipherParam* bp, const byte* iv)
576 * \brief Prototype definition for an initialization vector setup function.
577 * \param bp The blockcipher's parameters.
578 * \param iv The blockciphers' IV value.
579 * \note iv length must be equal to the cipher's block size.
580 * \retval 0 on success.
581 * \retval -1 on failure.
582 * \ingroup BC_m
583 */
584typedef int (*blockCipherSetIV )(blockCipherParam*, const byte*);
585
586/*!\typedef int (*blockCipherRawcrypt)(blockCipherParam* bp, uint32_t* dst, const uint32_t* src)
587 * \brief Prototype for a \e raw encryption or decryption function.
588 * \param bp The blockcipher's parameters.
589 * \param dst The ciphertext address; must be aligned on 32-bit boundary.
590 * \param src The cleartext address; must be aligned on 32-bit boundary.
591 * \retval 0 on success.
592 * \retval -1 on failure.
593 * \ingroup BC_m
594 */
595typedef int (*blockCipherRawcrypt)(blockCipherParam*, uint32_t*, const uint32_t*);
596
597/*!\typedef int (*blockCipherModcrypt)(blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks)
598 * \brief Prototype for a \e encryption or decryption function which operates
599 * on multiple blocks in a certain mode.
600 * \param bp The blockcipher's parameters.
601 * \param dst The ciphertext address; must be aligned on 32-bit boundary.
602 * \param src The cleartext address; must be aligned on 32-bit boundary.
603 * \param nblocks The number of blocks to process.
604 * \retval 0 on success.
605 * \retval -1 on failure.
606 * \ingroup BC_m
607 */
608typedef int (*blockCipherModcrypt)(blockCipherParam*, uint32_t*, const uint32_t*, unsigned int);
609
610typedef uint32_t* (*blockCipherFeedback)(blockCipherParam*);
611
612typedef struct
613{
614 const blockCipherRawcrypt encrypt;
615 const blockCipherRawcrypt decrypt;
616} blockCipherRaw;
617
618typedef struct
619{
620 const blockCipherModcrypt encrypt;
621 const blockCipherModcrypt decrypt;
622} blockCipherMode;
623
624/*!\brief Holds information and pointers to code specific to each cipher.
625 *
626 * Specific block ciphers \e may be written to be multithread-safe.
627 *
628 * \ingroup BC_m
629 */
630#ifdef __cplusplus
631struct BEECRYPTAPI blockCipher
632#else
633struct _blockCipher
634#endif
635{
636 /*!\var name
637 * \brief The blockcipher's name.
638 */
639 const char* name;
640 /*!\var paramsize
641 * \brief The size of the parameters required by this cipher, in bytes.
642 */
643 const size_t paramsize;
644 /*!\var blocksize
645 * \brief The size of one block of data, in bytes.
646 */
647 const size_t blocksize;
648 /*!\var keybitsmin
649 * \brief The minimum number of key bits.
650 */
651 const size_t keybitsmin;
652 /*!\var keybitsmax
653 * \brief The maximum number of key bits.
654 */
655 const size_t keybitsmax;
656 /*!\var keybitsinc
657 * \brief The allowed increment in key bits between min and max.
658 * \see keybitsmin and keybitsmax.
659 */
660 const size_t keybitsinc;
661 /*!\var setup
662 * \brief Pointer to the cipher's setup function.
663 */
664 const blockCipherSetup setup;
665 /*!\var setiv
666 * \brief Pointer to the cipher's initialization vector setup function.
667 */
668 const blockCipherSetIV setiv;
669 /*!\var raw
670 * \brief The cipher's raw functions.
671 */
672 const blockCipherRaw raw;
673 /*!\var ecb
674 * \brief The cipher's ECB functions.
675 */
676 const blockCipherMode ecb;
677 const blockCipherMode cbc;
678 /*!\var getfb
679 * \brief Pointer to the cipher's feedback-returning function.
680 */
681 const blockCipherFeedback getfb;
682};
683
684#ifndef __cplusplus
685typedef struct _blockCipher blockCipher;
686#endif
687
688#ifdef __cplusplus
689extern "C" {
690#endif
691
692/*!\fn int blockCipherCount()
693 * \brief This function returns the number of blockciphers implemented
694 * by the library.
695 * \return The number of implemented blockciphers.
696 */
697BEECRYPTAPI
698int blockCipherCount(void);
699
700/*!\fn const blockCipher* blockCipherGet(int n)
701 * \brief This function returns the \a n -th blockcipher implemented by
702 * the library.
703 * \param n Index of the requested blockcipher; legal values are 0
704 * through blockCipherCount() - 1.
705 * \return A pointer to a blockcipher or null, if the index was out of
706 * range.
707 */
708BEECRYPTAPI
709const blockCipher* blockCipherGet(int);
710
711/*!\fn const blockCipher* blockCipherFind(const char* name)
712 * \brief This function returns the blockcipher specified by the given name.
713 * \param name Name of the requested blockcipher.
714 * \return A pointer to a blockcipher or null, if the name wasn't found.
715 */
716BEECRYPTAPI
717const blockCipher* blockCipherFind(const char*);
718
719/*!\fn const blockCipher* blockCipherDefault()
720 * \brief This functions returns the default blockcipher; the default value
721 * can be specified by setting environment variable BEECRYPT_CIPHER.
722 * \return A pointer to a blockcipher or null, in case an error occured.
723 */
724BEECRYPTAPI
725const blockCipher* blockCipherDefault(void);
726
727#ifdef __cplusplus
728}
729#endif
730
731/*!\brief Holds a pointer to a blockcipher as well as its parameters.
732 * \warning A context can be used by only one thread at the same time.
733 * \ingroup BC_m
734 */
735#ifdef __cplusplus
736struct BEECRYPTAPI blockCipherContext
737#else
738struct _blockCipherContext
739#endif
740{
741 /*!\var algo
742 * \brief Pointer to a blockCipher.
743 */
744 const blockCipher* algo;
745 /*!\var param
746 * \brief Pointer to the parameters used by algo.
747 */
748 blockCipherParam* param;
749 /*!\var op
750 */
751 cipherOperation op;
752
753 #ifdef __cplusplus
754 blockCipherContext();
755 blockCipherContext(const blockCipher*);
756 ~blockCipherContext();
757 #endif
758};
759
760#ifndef __cplusplus
761typedef struct _blockCipherContext blockCipherContext;
762#endif
763
764/*
765 * The following functions can be used to initialize and free a
766 * blockCipherContext. Initializing will allocate a buffer of the size
767 * required by the blockCipher, freeing will deallocate that buffer.
768 */
769
770#ifdef __cplusplus
771extern "C" {
772#endif
773
774BEECRYPTAPI
775int blockCipherContextInit(blockCipherContext*, const blockCipher*);
776
777BEECRYPTAPI
778int blockCipherContextSetup(blockCipherContext*, const byte*, size_t, cipherOperation);
779
780BEECRYPTAPI
781int blockCipherContextSetIV(blockCipherContext*, const byte*);
782
783BEECRYPTAPI
784int blockCipherContextFree(blockCipherContext*);
785
786BEECRYPTAPI
787int blockCipherContextECB(blockCipherContext*, uint32_t*, const uint32_t*, int);
788
789BEECRYPTAPI
790int blockCipherContextCBC(blockCipherContext*, uint32_t*, const uint32_t*, int);
791
792BEECRYPTAPI
793int blockCipherContextValidKeylen(blockCipherContext*, size_t);
794
795#ifdef __cplusplus
796}
797#endif
798
799#endif
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/blockmode.c b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/blockmode.c
new file mode 100755
index 0000000000..cfccd43337
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/blockmode.c
@@ -0,0 +1,137 @@
1/*
2 * Copyright (c) 2000, 2002 Virtual Unlimited B.V.
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 blockmode.c
21 * \brief Blockcipher operation modes.
22 * \author Bob Deblier <bob.deblier@pandora.be>
23 * \ingroup BC_m
24 */
25
26#define BEECRYPT_DLL_EXPORT
27
28#if HAVE_CONFIG_H
29# include "config.h"
30#endif
31
32#include "beecrypt/blockmode.h"
33
34int blockEncryptECB(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks)
35{
36 register const unsigned int blockwords = bc->blocksize >> 2;
37
38 while (nblocks > 0)
39 {
40 bc->raw.encrypt(bp, dst, src);
41
42 dst += blockwords;
43 src += blockwords;
44
45 nblocks--;
46 }
47
48 return 0;
49}
50
51int blockDecryptECB(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks)
52{
53 register const unsigned int blockwords = bc->blocksize >> 2;
54
55 while (nblocks > 0)
56 {
57 bc->raw.decrypt(bp, dst, src);
58
59 dst += blockwords;
60 src += blockwords;
61
62 nblocks--;
63 }
64
65 return 0;
66}
67
68int blockEncryptCBC(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks)
69{
70 register const unsigned int blockwords = bc->blocksize >> 2;
71 register uint32_t* fdback = bc->getfb(bp);
72
73 if (nblocks > 0)
74 {
75 register unsigned int i;
76
77 for (i = 0; i < blockwords; i++)
78 dst[i] = src[i] ^ fdback[i];
79
80 bc->raw.encrypt(bp, dst, dst);
81
82 nblocks--;
83
84 while (nblocks > 0)
85 {
86 for (i = 0; i < blockwords; i++)
87 dst[i+blockwords] = src[i+blockwords] ^ dst[i];
88
89 dst += blockwords;
90
91 bc->raw.encrypt(bp, dst, dst);
92
93 src += blockwords;
94
95 nblocks--;
96 }
97
98 for (i = 0; i < blockwords; i++)
99 fdback[i] = dst[i];
100 }
101
102 return 0;
103}
104
105int blockDecryptCBC(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks)
106{
107 register const unsigned int blockwords = bc->blocksize >> 2;
108 register uint32_t* fdback = bc->getfb(bp);
109 register uint32_t* buf = (uint32_t*) malloc(blockwords * sizeof(uint32_t));
110
111 if (buf)
112 {
113 while (nblocks > 0)
114 {
115 register uint32_t tmp;
116 register unsigned int i;
117
118 bc->raw.decrypt(bp, buf, src);
119
120 for (i = 0; i < blockwords; i++)
121 {
122 tmp = src[i];
123 dst[i] = buf[i] ^ fdback[i];
124 fdback[i] = tmp;
125 }
126
127 dst += blockwords;
128 src += blockwords;
129
130 nblocks--;
131 }
132 free(buf);
133 return 0;
134 }
135
136 return -1;
137}
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/blockmode.h b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/blockmode.h
new file mode 100755
index 0000000000..4f21b81f65
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/blockmode.h
@@ -0,0 +1,92 @@
1/*
2 * Copyright (c) 2000, 2002 Virtual Unlimited B.V.
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 blockmode.h
21 * \brief Blockcipher operation modes.
22 * \todo Additional modes, such as CFB and OFB.
23 * \author Bob Deblier <bob.deblier@pandora.be>
24 * \ingroup BC_m
25 */
26
27#ifndef _BLOCKMODE_H
28#define _BLOCKMODE_H
29
30#include "beecrypt/beecrypt.h"
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36/*!\fn int blockEncryptECB(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks)
37 * \brief This function encrypts a number of data blocks in Electronic Code
38 * Book mode.
39 * \param bc The blockcipher.
40 * \param bp The cipher's parameter block.
41 * \param dst The ciphertext data; should be aligned on a 32-bit boundary.
42 * \param src The cleartext data; should be aligned on a 32-bit boundary.
43 * \param nblocks The number of blocks to be encrypted.
44 * \retval 0 on success.
45 */
46BEECRYPTAPI
47int blockEncryptECB(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks);
48
49/*!\fn int blockDecryptECB(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks)
50 * \brief This function decrypts a number of data blocks in Electronic Code
51 * Book mode.
52 * \param bc The blockcipher.
53 * \param bp The cipher's parameter block.
54 * \param dst The cleartext data; should be aligned on a 32-bit boundary.
55 * \param src The ciphertext data; should be aligned on a 32-bit boundary.
56 * \param nblocks The number of blocks to be decrypted.
57 * \retval 0 on success.
58 */
59BEECRYPTAPI
60int blockDecryptECB(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks);
61
62/*!\fn int blockEncryptCBC(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks)
63 * \brief This function encrypts a number of data blocks in Cipher Block
64 * Chaining mode.
65 * \param bc The blockcipher.
66 * \param bp The cipher's parameter block.
67 * \param dst The ciphertext data; should be aligned on a 32-bit boundary.
68 * \param src The cleartext data; should be aligned on a 32-bit boundary.
69 * \param nblocks The number of blocks to be encrypted.
70 * \retval 0 on success.
71 */
72BEECRYPTAPI
73int blockEncryptCBC(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks);
74
75/*!\fn int blockDecryptCBC(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks)
76 * \brief This function decrypts a number of data blocks in Cipher Block
77 * Chaining mode.
78 * \param bc The blockcipher.
79 * \param bp The cipher's parameter block.
80 * \param dst The cleartext data; should be aligned on a 32-bit boundary.
81 * \param src The ciphertext data; should be aligned on a 32-bit boundary.
82 * \param nblocks The number of blocks to be decrypted.
83 * \retval 0 on success.
84 */
85BEECRYPTAPI
86int blockDecryptCBC(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks);
87
88#ifdef __cplusplus
89}
90#endif
91
92#endif
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/blowfish.c b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/blowfish.c
new file mode 100755
index 0000000000..a8b801e6ec
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/blowfish.c
@@ -0,0 +1,509 @@
1/*
2 * Copyright (c) 1999, 2000, 2002 Virtual Unlimited B.V.
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 blowfish.c
21 * \brief Blowfish block cipher.
22 * \author Bob Deblier <bob.deblier@pandora.be>
23 * \ingroup BC_m BC_blowfish_m
24 */
25
26#define BEECRYPT_DLL_EXPORT
27
28#if HAVE_CONFIG_H
29# include "config.h"
30#endif
31
32#include "beecrypt/blowfish.h"
33
34#if HAVE_ENDIAN_H && HAVE_ASM_BYTEORDER_H
35# include <endian.h>
36#endif
37
38#include "beecrypt/endianness.h"
39
40#ifdef ASM_BLOWFISHENCRYPTECB
41extern int blowfishEncryptECB(blowfishparam*, uint32_t*, const uint32_t*, unsigned int);
42#endif
43
44#ifdef ASM_BLOWFISHDECRYPTECB
45extern int blowfishDecryptECB(blowfishparam*, uint32_t*, const uint32_t*, unsigned int);
46#endif
47
48static uint32_t _bf_p[BLOWFISHPSIZE] = {
49 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344,
50 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89,
51 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,
52 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917,
53 0x9216d5d9, 0x8979fb1b
54};
55
56static uint32_t _bf_s[1024] = {
57 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7,
58 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,
59 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,
60 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,
61 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee,
62 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
63 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef,
64 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e,
65 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,
66 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440,
67 0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce,
68 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
69 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e,
70 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677,
71 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,
72 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032,
73 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88,
74 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
75 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e,
76 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0,
77 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,
78 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98,
79 0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88,
80 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
81 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6,
82 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d,
83 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,
84 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7,
85 0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba,
86 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
87 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f,
88 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09,
89 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,
90 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb,
91 0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279,
92 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
93 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab,
94 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82,
95 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,
96 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573,
97 0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0,
98 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
99 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790,
100 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8,
101 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,
102 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0,
103 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7,
104 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
105 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad,
106 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1,
107 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,
108 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9,
109 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477,
110 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
111 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49,
112 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af,
113 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,
114 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5,
115 0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41,
116 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
117 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400,
118 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915,
119 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,
120 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a,
121 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623,
122 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266,
123 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,
124 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e,
125 0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6,
126 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
127 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e,
128 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1,
129 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,
130 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8,
131 0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff,
132 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
133 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701,
134 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7,
135 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,
136 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331,
137 0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf,
138 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
139 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e,
140 0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87,
141 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,
142 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2,
143 0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16,
144 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
145 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b,
146 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509,
147 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,
148 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3,
149 0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f,
150 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
151 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4,
152 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960,
153 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,
154 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28,
155 0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802,
156 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
157 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510,
158 0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf,
159 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,
160 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e,
161 0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50,
162 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
163 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8,
164 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281,
165 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,
166 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696,
167 0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128,
168 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
169 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0,
170 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0,
171 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,
172 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250,
173 0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3,
174 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
175 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00,
176 0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061,
177 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,
178 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e,
179 0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735,
180 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
181 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9,
182 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340,
183 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,
184 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7,
185 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934,
186 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068,
187 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af,
188 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840,
189 0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45,
190 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
191 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a,
192 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb,
193 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,
194 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6,
195 0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42,
196 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
197 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2,
198 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb,
199 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527,
200 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b,
201 0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33,
202 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
203 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3,
204 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc,
205 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17,
206 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564,
207 0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b,
208 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
209 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922,
210 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728,
211 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0,
212 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e,
213 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37,
214 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
215 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804,
216 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b,
217 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,
218 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb,
219 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d,
220 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
221 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350,
222 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9,
223 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,
224 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe,
225 0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d,
226 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,
227 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f,
228 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61,
229 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,
230 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9,
231 0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2,
232 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,
233 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e,
234 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633,
235 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10,
236 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169,
237 0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52,
238 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
239 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5,
240 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62,
241 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634,
242 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76,
243 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24,
244 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
245 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4,
246 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c,
247 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837,
248 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0,
249 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b,
250 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe,
251 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,
252 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4,
253 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8,
254 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
255 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304,
256 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22,
257 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,
258 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6,
259 0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9,
260 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,
261 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593,
262 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51,
263 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,
264 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c,
265 0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b,
266 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,
267 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c,
268 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd,
269 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a,
270 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319,
271 0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb,
272 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
273 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991,
274 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32,
275 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680,
276 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166,
277 0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae,
278 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
279 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5,
280 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47,
281 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,
282 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d,
283 0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84,
284 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,
285 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8,
286 0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd,
287 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,
288 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7,
289 0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38,
290 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
291 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c,
292 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525,
293 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,
294 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442,
295 0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964,
296 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,
297 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8,
298 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d,
299 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,
300 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299,
301 0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02,
302 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,
303 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614,
304 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a,
305 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,
306 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b,
307 0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0,
308 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
309 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e,
310 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9,
311 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,
312 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6
313};
314
315#define EROUND(l,r) l ^= *(p++); r ^= ((s[((l>>24)&0xff)+0x000]+s[((l>>16)&0xff)+0x100])^s[((l>>8)&0xff)+0x200])+s[((l>>0)&0xff)+0x300]
316#define DROUND(l,r) l ^= *(p--); r ^= ((s[((l>>24)&0xff)+0x000]+s[((l>>16)&0xff)+0x100])^s[((l>>8)&0xff)+0x200])+s[((l>>0)&0xff)+0x300]
317
318const blockCipher blowfish = {
319 "Blowfish",
320 sizeof(blowfishParam),
321 8,
322 64,
323 448,
324 32,
325 (blockCipherSetup) blowfishSetup,
326 (blockCipherSetIV) blowfishSetIV,
327 /* raw */
328 {
329 (blockCipherRawcrypt) blowfishEncrypt,
330 (blockCipherRawcrypt) blowfishDecrypt
331 },
332 /* ecb */
333 {
334 #ifdef AES_BLOWFISHENCRYPTECB
335 (blockCipherModcrypt) blowfishEncryptECB,
336 #else
337 (blockCipherModcrypt) 0,
338 #endif
339 #ifdef AES_BLOWFISHENCRYPTECB
340 (blockCipherModcrypt) blowfishDecryptECB,
341 #else
342 (blockCipherModcrypt) 0
343 #endif
344 },
345 /* cbc */
346 {
347 (blockCipherModcrypt) 0,
348 (blockCipherModcrypt) 0
349 },
350 (blockCipherFeedback) blowfishFeedback
351};
352
353int blowfishSetup(blowfishParam* bp, const byte* key, size_t keybits, cipherOperation op)
354{
355 if ((op != ENCRYPT) && (op != DECRYPT))
356 return -1;
357
358 if (((keybits & 7) == 0) && (keybits >= 32) && (keybits <= 448))
359 {
360 register uint32_t* p = bp->p;
361 register uint32_t* s = bp->s;
362 register unsigned int i, j, k;
363
364 uint32_t tmp, work[2];
365
366 memcpy(s, _bf_s, 1024 * sizeof(uint32_t));
367
368 for (i = 0, k = 0; i < BLOWFISHPSIZE; i++)
369 {
370 tmp = 0;
371 for (j = 0; j < 4; j++)
372 {
373 tmp <<= 8;
374 tmp |= key[k++];
375 if (k >= (keybits >> 3))
376 k = 0;
377 }
378 p[i] = _bf_p[i] ^ tmp;
379 }
380
381 work[0] = work[1] = 0;
382
383 for (i = 0; i < BLOWFISHPSIZE; i += 2, p += 2)
384 {
385 blowfishEncrypt(bp, work, work);
386 #if WORDS_BIGENDIAN
387 p[0] = work[0];
388 p[1] = work[1];
389 #else
390 p[0] = swapu32(work[0]);
391 p[1] = swapu32(work[1]);
392 #endif
393 }
394
395 for (i = 0; i < 1024; i += 2, s += 2)
396 {
397 blowfishEncrypt(bp, work, work);
398 #if WORDS_BIGENDIAN
399 s[0] = work[0];
400 s[1] = work[1];
401 #else
402 s[0] = swapu32(work[0]);
403 s[1] = swapu32(work[1]);
404 #endif
405 }
406
407 /* clear fdback/iv */
408 bp->fdback[0] = 0;
409 bp->fdback[1] = 0;
410
411 return 0;
412 }
413 return -1;
414}
415
416#ifndef ASM_BLOWFISHSETIV
417int blowfishSetIV(blowfishParam* bp, const byte* iv)
418{
419 if (iv)
420 memcpy(bp->fdback, iv, 8);
421 else
422 memset(bp->fdback, 0, 8);
423
424 return 0;
425}
426#endif
427
428int blowfishBlowit(blowfishParam* bp, uint32_t* dst, const uint32_t* src)
429{
430 register uint32_t xl = src[0], xr = src[1];
431 register uint32_t* p = bp->p;
432 register uint32_t* s = bp->s;
433
434 EROUND(xl, xr); EROUND(xr, xl);
435
436 dst[1] = xr;
437 dst[0] = xl;
438
439 return 0;
440}
441
442#ifndef ASM_BLOWFISHENCRYPT
443int blowfishEncrypt(blowfishParam* bp, uint32_t* dst, const uint32_t* src)
444{
445 #if WORDS_BIGENDIAN
446 register uint32_t xl = src[0], xr = src[1];
447 #else
448 register uint32_t xl = swapu32(src[0]), xr = swapu32(src[1]);
449 #endif
450 register uint32_t* p = bp->p;
451 register uint32_t* s = bp->s;
452
453 EROUND(xl, xr); EROUND(xr, xl);
454 EROUND(xl, xr); EROUND(xr, xl);
455 EROUND(xl, xr); EROUND(xr, xl);
456 EROUND(xl, xr); EROUND(xr, xl);
457 EROUND(xl, xr); EROUND(xr, xl);
458 EROUND(xl, xr); EROUND(xr, xl);
459 EROUND(xl, xr); EROUND(xr, xl);
460 EROUND(xl, xr); EROUND(xr, xl);
461
462 #if WORDS_BIGENDIAN
463 dst[1] = xl ^ *(p++);
464 dst[0] = xr ^ *(p++);
465 #else
466 dst[1] = swapu32(xl ^ *(p++));
467 dst[0] = swapu32(xr ^ *(p++));
468 #endif
469
470 return 0;
471}
472#endif
473
474#ifndef ASM_BLOWFISHDECRYPT
475int blowfishDecrypt(blowfishParam* bp, uint32_t* dst, const uint32_t* src)
476{
477 #if WORDS_BIGENDIAN
478 register uint32_t xl = src[0], xr = src[1];
479 #else
480 register uint32_t xl = swapu32(src[0]), xr = swapu32(src[1]);
481 #endif
482 register uint32_t* p = bp->p+BLOWFISHPSIZE-1;
483 register uint32_t* s = bp->s;
484
485 DROUND(xl, xr); DROUND(xr, xl);
486 DROUND(xl, xr); DROUND(xr, xl);
487 DROUND(xl, xr); DROUND(xr, xl);
488 DROUND(xl, xr); DROUND(xr, xl);
489 DROUND(xl, xr); DROUND(xr, xl);
490 DROUND(xl, xr); DROUND(xr, xl);
491 DROUND(xl, xr); DROUND(xr, xl);
492 DROUND(xl, xr); DROUND(xr, xl);
493
494 #if WORDS_BIGENDIAN
495 dst[1] = xl ^ *(p--);
496 dst[0] = xr ^ *(p--);
497 #else
498 dst[1] = swapu32(xl ^ *(p--));
499 dst[0] = swapu32(xr ^ *(p--));
500 #endif
501
502 return 0;
503}
504#endif
505
506uint32_t* blowfishFeedback(blowfishParam* bp)
507{
508 return bp->fdback;
509}
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/blowfish.h b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/blowfish.h
new file mode 100755
index 0000000000..1d95ddb4f2
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/blowfish.h
@@ -0,0 +1,132 @@
1/*
2 * Copyright (c) 1999, 2000, 2002 Virtual Unlimited B.V.
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 blowfish.h
21 * \brief Blowfish block cipher.
22 *
23 * For more information on this blockcipher, see:
24 * "Applied Cryptography", second edition
25 * Bruce Schneier
26 * Wiley & Sons
27 *
28 * Also see http://www.counterpane.com/blowfish.html
29 *
30 * \author Bob Deblier <bob.deblier@pandora.be>
31 * \ingroup BC_m BC_blowfish_m
32 */
33
34#ifndef _BLOWFISH_H
35#define _BLOWFISH_H
36
37#include "beecrypt/beecrypt.h"
38#include "beecrypt/blowfishopt.h"
39
40#define BLOWFISHROUNDS 16
41#define BLOWFISHPSIZE (BLOWFISHROUNDS+2)
42
43/*!\brief Holds all the parameters necessary for the Blowfish cipher.
44 * \ingroup BC_blowfish_m
45 */
46#ifdef __cplusplus
47struct BEECRYPTAPI blowfishParam
48#else
49struct _blowfishParam
50#endif
51{
52 /*!\var p
53 * \brief Holds the key expansion.
54 */
55 uint32_t p[BLOWFISHPSIZE];
56 /*!\var s
57 * \brief Holds the s-boxes.
58 */
59 uint32_t s[1024];
60 /*!\var fdback
61 * \brief Buffer to be used by block chaining or feedback modes.
62 */
63 uint32_t fdback[2];
64};
65
66#ifndef __cplusplus
67typedef struct _blowfishParam blowfishParam;
68#endif
69
70#ifdef __cplusplus
71extern "C" {
72#endif
73
74/*!\var blowfish
75 * \brief Holds the full API description of the Blowfish algorithm.
76 */
77extern const BEECRYPTAPI blockCipher blowfish;
78
79/*!\fn int blowfishSetup(blowfishParam* bp, const byte* key, size_t keybits, cipherOperation
80 op)
81 * \brief The function performs the cipher's key expansion.
82 * \param bp The cipher's parameter block.
83 * \param key The key value.
84 * \param keybits The number of bits in the key; legal values are: 32 to 448,
85 * in multiples of 8.
86 * \param op ENCRYPT or DECRYPT.
87 * \retval 0 on success.
88 * \retval -1 on failure.
89 */
90BEECRYPTAPI
91int blowfishSetup (blowfishParam*, const byte*, size_t, cipherOperation);
92
93/*!\fn int blowfishSetIV(blowfishParam* bp, const byte* iv)
94 * \brief This function sets the Initialization Vector.
95 * \note This function is only useful in block chaining or feedback modes.
96 * \param bp The cipher's parameter block.
97 * \param iv The initialization vector; may be null.
98 * \retval 0 on success.
99 */
100BEECRYPTAPI
101int blowfishSetIV (blowfishParam*, const byte*);
102
103/*!\fn blowfishEncrypt(blowfishParam* bp, uint32_t* dst, const uint32_t* src)
104 * \brief This function performs the Blowfish encryption; it encrypts one block
105 * of 64 bits.
106 * \param bp The cipher's parameter block.
107 * \param dst The ciphertext; should be aligned on 32-bit boundary.
108 * \param src The cleartext; should be aligned on 32-bit boundary.
109 * \retval 0 on success.
110 */
111BEECRYPTAPI
112int blowfishEncrypt (blowfishParam*, uint32_t*, const uint32_t*);
113
114/*!\fn blowfishDecrypt(blowfishParam* bp, uint32_t* dst, const uint32_t* src)
115 * \brief This function performs the Blowfish decryption; it Rderypts one block
116 * of 64 bits.
117 * \param bp The cipher's parameter block.
118 * \param dst The cleartext; should be aligned on 32-bit boundary.
119 * \param src The ciphertext; should be aligned on 32-bit boundary.
120 * \retval 0 on success.
121 */
122BEECRYPTAPI
123int blowfishDecrypt (blowfishParam*, uint32_t*, const uint32_t*);
124
125BEECRYPTAPI
126uint32_t* blowfishFeedback(blowfishParam*);
127
128#ifdef __cplusplus
129}
130#endif
131
132#endif
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/blowfishopt.h b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/blowfishopt.h
new file mode 100755
index 0000000000..f38db94b52
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/blowfishopt.h
@@ -0,0 +1,82 @@
1/*
2 * Copyright (c) 2000, 2002, 2003 Virtual Unlimited B.V.
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 blowfishopt.h
21 * \brief Blowfish block cipher, assembler-optimized routines, headers.
22 * \author Bob Deblier <bob.deblier@pandora.be>
23 * \ingroup BC_blowfish_m
24 */
25
26#ifndef _BLOWFISHOPT_H
27#define _BLOWFISHOPT_H
28
29#include "beecrypt/beecrypt.h"
30#include "beecrypt/blowfish.h"
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36#if WIN32
37# if defined(_MSC_VER) && defined(_M_IX86)
38# define ASM_BLOWFISHENCRYPT
39# define ASM_BLOWFISHDECRYPT
40# elif __INTEL__ && __MWERKS__
41# define ASM_BLOWFISHENCRYPT
42# define ASM_BLOWFISHDECRYPT
43# endif
44#endif
45
46#if defined(__GNUC__)
47# if defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686)
48# define ASM_BLOWFISHENCRYPT
49# define ASM_BLOWFISHDECRYPT
50# endif
51# if defined(OPTIMIZE_POWERPC)
52# define ASM_BLOWFISHENCRYPT
53# define ASM_BLOWFISHDECRYPT
54# endif
55#endif
56
57#if defined(__IBMC__)
58# if defined(OPTIMIZE_POWERPC)
59# define ASM_BLOWFISHENCRYPT
60# define ASM_BLOWFISHDECRYPT
61# endif
62#endif
63
64#if defined(__INTEL_COMPILER)
65# if defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686)
66# define ASM_BLOWFISHENCRYPT
67# define ASM_BLOWFISHDECRYPT
68# endif
69#endif
70
71#if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
72/* nothing here yet */
73#endif
74
75#undef ASM_BLOWFISHENCRYPT
76#undef ASM_BLOWFISHDECRYPT
77
78#ifdef __cplusplus
79}
80#endif
81
82#endif
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/endianness.c b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/endianness.c
new file mode 100755
index 0000000000..8a0999b63e
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/endianness.c
@@ -0,0 +1,94 @@
1/*
2 * Copyright (c) 1998, 1999, 2000, 2001 Virtual Unlimited B.V.
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 endianness.c
21 * \brief Endian-dependant encoding/decoding.
22 * \author Bob Deblier <bob.deblier@pandora.be>
23 */
24
25#define BEECRYPT_DLL_EXPORT
26
27#if HAVE_CONFIG_H
28# include "config.h"
29#endif
30
31#if HAVE_ENDIAN_H && HAVE_ASM_BYTEORDER_H
32# include <endian.h>
33#endif
34
35#include "beecrypt/endianness.h"
36
37#undef swap16
38#undef swapu16
39#undef swap32
40#undef swapu32
41#undef swap64
42#undef swapu64
43
44int16_t swap16(int16_t n)
45{
46 return ( ((n & 0xff) << 8) |
47 ((n & 0xff00) >> 8) );
48}
49
50uint16_t swapu16(uint16_t n)
51{
52 return ( ((n & 0xffU) << 8) |
53 ((n & 0xff00U) >> 8) );
54}
55
56int32_t swap32(int32_t n)
57{
58 return ( ((n & 0xff) << 24) |
59 ((n & 0xff00) << 8) |
60 ((n & 0xff0000) >> 8) |
61 ((n & 0xff000000) >> 24) );
62}
63
64uint32_t swapu32(uint32_t n)
65{
66 return ( ((n & 0xffU) << 24) |
67 ((n & 0xff00U) << 8) |
68 ((n & 0xff0000U) >> 8) |
69 ((n & 0xff000000U) >> 24) );
70}
71
72int64_t swap64(int64_t n)
73{
74 return ( ((n & (((int64_t) 0xff) )) << 56) |
75 ((n & (((int64_t) 0xff) << 8)) << 40) |
76 ((n & (((int64_t) 0xff) << 16)) << 24) |
77 ((n & (((int64_t) 0xff) << 24)) << 8) |
78 ((n & (((int64_t) 0xff) << 32)) >> 8) |
79 ((n & (((int64_t) 0xff) << 40)) >> 24) |
80 ((n & (((int64_t) 0xff) << 48)) >> 40) |
81 ((n & (((int64_t) 0xff) << 56)) >> 56) );
82}
83
84uint64_t swapu64(uint64_t n)
85{
86 return ( ((n & (((uint64_t) 0xff) )) << 56) |
87 ((n & (((uint64_t) 0xff) << 8)) << 40) |
88 ((n & (((uint64_t) 0xff) << 16)) << 24) |
89 ((n & (((uint64_t) 0xff) << 24)) << 8) |
90 ((n & (((uint64_t) 0xff) << 32)) >> 8) |
91 ((n & (((uint64_t) 0xff) << 40)) >> 24) |
92 ((n & (((uint64_t) 0xff) << 48)) >> 40) |
93 ((n & (((uint64_t) 0xff) << 56)) >> 56) );
94}
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/endianness.h b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/endianness.h
new file mode 100755
index 0000000000..e136aa59f9
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/endianness.h
@@ -0,0 +1,128 @@
1/*
2 * endianness.h
3 *
4 * Endian-dependant encoding/decoding, header
5 *
6 * Copyright (c) 1998, 1999, 2000, 2001, 2004 Beeyond Software Holding
7 *
8 * Author: Bob Deblier <bob.deblier@telenet.be>
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 */
25
26#ifndef _ENDIANNESS_H
27#define _ENDIANNESS_H
28
29#include "beecrypt/beecrypt.h"
30
31#if defined(__cplusplus) || HAVE_INLINE
32
33static inline int16_t _swap16(int16_t n)
34{
35 return ( ((n & 0xff) << 8) |
36 ((n & 0xff00) >> 8) );
37}
38# define swap16(n) _swap16(n)
39
40static inline uint16_t _swapu16(uint16_t n)
41{
42 return ( ((n & 0xffU) << 8) |
43 ((n & 0xff00U) >> 8) );
44}
45# define swapu16(n) _swap16(n)
46
47# ifdef __arch__swab32
48# define swap32(n) __arch__swab32(n)
49# define swapu32(n) __arch__swab32(n)
50# else
51
52static inline int32_t _swap32(int32_t n)
53{
54 return ( ((n & 0xff) << 24) |
55 ((n & 0xff00) << 8) |
56 ((n & 0xff0000) >> 8) |
57 ((n & 0xff000000) >> 24) );
58}
59# define swap32(n) _swap32(n)
60
61static inline uint32_t _swapu32(uint32_t n)
62{
63 return ( ((n & 0xffU) << 24) |
64 ((n & 0xff00U) << 8) |
65 ((n & 0xff0000U) >> 8) |
66 ((n & 0xff000000U) >> 24) );
67}
68# define swapu32(n) _swapu32(n)
69
70# endif
71
72# ifdef __arch__swab64
73# define swap64(n) __arch__swab64(n)
74# define swapu64(n) __arch__swab64(n)
75# else
76
77static inline int64_t _swap64(int64_t n)
78{
79 return ( ((n & ((int64_t) 0xff) ) << 56) |
80 ((n & ((int64_t) 0xff) << 8) << 40) |
81 ((n & ((int64_t) 0xff) << 16) << 24) |
82 ((n & ((int64_t) 0xff) << 24) << 8) |
83 ((n & ((int64_t) 0xff) << 32) >> 8) |
84 ((n & ((int64_t) 0xff) << 40) >> 24) |
85 ((n & ((int64_t) 0xff) << 48) >> 40) |
86 ((n & ((int64_t) 0xff) << 56) >> 56) );
87}
88# define swap64(n) _swap64(n)
89
90static inline uint64_t _swapu64(uint64_t n)
91{
92 return ( ((n & ((uint64_t) 0xff) ) << 56) |
93 ((n & ((uint64_t) 0xff) << 8) << 40) |
94 ((n & ((uint64_t) 0xff) << 16) << 24) |
95 ((n & ((uint64_t) 0xff) << 24) << 8) |
96 ((n & ((uint64_t) 0xff) << 32) >> 8) |
97 ((n & ((uint64_t) 0xff) << 40) >> 24) |
98 ((n & ((uint64_t) 0xff) << 48) >> 40) |
99 ((n & ((uint64_t) 0xff) << 56) >> 56) );
100}
101# define swapu64(n) _swapu64(n)
102
103# endif
104
105#else
106BEECRYPTAPI
107 int16_t swap16 (int16_t);
108BEECRYPTAPI
109uint16_t swapu16(uint16_t);
110BEECRYPTAPI
111 int32_t swap32 (int32_t);
112BEECRYPTAPI
113uint32_t swapu32(uint32_t);
114BEECRYPTAPI
115 int64_t swap64 (int64_t);
116BEECRYPTAPI
117uint64_t swapu64(uint64_t);
118#endif
119
120#ifdef __cplusplus
121extern "C" {
122#endif
123
124#ifdef __cplusplus
125}
126#endif
127
128#endif
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/gnu.h b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/gnu.h
new file mode 100755
index 0000000000..18386ef997
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/gnu.h
@@ -0,0 +1,67 @@
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#ifndef _BEECRYPT_GNU_H
21#define _BEECRYPT_GNU_H
22
23#include <inttypes.h>
24#include <stdint.h>
25
26
27#include <pthread.h>
28#include <stdio.h>
29#include <stdlib.h>
30
31#include <string.h>
32#include <unistd.h>
33#include <dlfcn.h>
34
35typedef pthread_cond_t bc_cond_t;
36typedef pthread_mutex_t bc_mutex_t;
37typedef pthread_t bc_thread_t;
38
39
40
41
42
43
44
45
46
47
48
49
50
51#if defined(__GNUC__)
52# if !defined(__GNUC_PREREQ__)
53# define __GNUC_PREREQ__(maj, min) (__GNUC__ > (maj) || __GNUC__ == (maj) && __GNUC_MINOR__ >= (min))
54# endif
55#else
56# define __GNUC__ 0
57# define __GNUC_PREREQ__(maj, min) 0
58#endif
59
60/* WARNING: overriding this value is dangerous; some assembler routines
61 * make assumptions about the size set by the configure script
62 */
63#if !defined(MP_WBITS)
64# define MP_WBITS 64U
65#endif
66
67#endif
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/hmac.c b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/hmac.c
new file mode 100755
index 0000000000..c28770a05b
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/hmac.c
@@ -0,0 +1,123 @@
1/*
2 * Copyright (c) 1999, 2000, 2002 Virtual Unlimited B.V.
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 hmac.c
21 * \brief HMAC algorithm.
22 *
23 * \see RFC2104 HMAC: Keyed-Hashing for Message Authentication.
24 * H. Krawczyk, M. Bellare, R. Canetti.
25 *
26 * \author Bob Deblier <bob.deblier@pandore.be>
27 * \ingroup HMAC_m
28 */
29
30#define BEECRYPT_DLL_EXPORT
31
32#if HAVE_CONFIG_H
33# include "config.h"
34#endif
35
36#include "beecrypt/hmac.h"
37#include "beecrypt/endianness.h"
38
39/*!\addtogroup HMAC_m
40 * \{
41 */
42
43#define HMAC_IPAD 0x36
44#define HMAC_OPAD 0x5c
45
46int hmacSetup(byte* kxi, byte* kxo, const hashFunction* hash, hashFunctionParam* param, const byte* key, size_t keybits)
47{
48 register unsigned int i;
49
50 size_t keybytes = keybits >> 3;
51
52 /* if the key is too large, hash it first */
53 if (keybytes > hash->blocksize)
54 {
55 /* if the hash digest is too large, this doesn't help; this is really a sanity check */
56 if (hash->digestsize > hash->blocksize)
57 return -1;
58
59 if (hash->reset(param))
60 return -1;
61
62 if (hash->update(param, key, keybytes))
63 return -1;
64
65 if (hash->digest(param, kxi))
66 return -1;
67
68 memcpy(kxo, kxi, keybytes = hash->digestsize);
69 }
70 else if (keybytes > 0)
71 {
72 memcpy(kxi, key, keybytes);
73 memcpy(kxo, key, keybytes);
74 }
75 else
76 return -1;
77
78 for (i = 0; i < keybytes; i++)
79 {
80 kxi[i] ^= HMAC_IPAD;
81 kxo[i] ^= HMAC_OPAD;
82 }
83
84 for (i = keybytes; i < hash->blocksize; i++)
85 {
86 kxi[i] = HMAC_IPAD;
87 kxo[i] = HMAC_OPAD;
88 }
89
90 return hmacReset(kxi, hash, param);
91}
92
93int hmacReset(const byte* kxi, const hashFunction* hash, hashFunctionParam* param)
94{
95 if (hash->reset(param))
96 return -1;
97 if (hash->update(param, kxi, hash->blocksize))
98 return -1;
99
100 return 0;
101}
102
103int hmacUpdate(const hashFunction* hash, hashFunctionParam* param, const byte* data, size_t size)
104{
105 return hash->update(param, data, size);
106}
107
108int hmacDigest(const byte* kxo, const hashFunction* hash, hashFunctionParam* param, byte* data)
109{
110 if (hash->digest(param, data))
111 return -1;
112 if (hash->update(param, kxo, hash->blocksize))
113 return -1;
114 if (hash->update(param, data, hash->digestsize))
115 return -1;
116 if (hash->digest(param, data))
117 return -1;
118
119 return 0;
120}
121
122/*!\}
123 */
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/hmac.h b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/hmac.h
new file mode 100755
index 0000000000..709bb079f0
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/hmac.h
@@ -0,0 +1,53 @@
1/*
2 * Copyright (c) 1999, 2000, 2002 Virtual Unlimited B.V.
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 hmac.h
21 * \brief HMAC algorithm, headers.
22 * \author Bob Deblier <bob.deblier@pandora.be>
23 * \ingroup HMAC_m
24 */
25
26#ifndef _HMAC_H
27#define _HMAC_H
28
29#include "beecrypt/beecrypt.h"
30
31/*!\ingroup HMAC_m
32 */
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38/* not used directly as keyed hash function, but instead used as generic methods */
39
40BEECRYPTAPI
41int hmacSetup ( byte*, byte*, const hashFunction*, hashFunctionParam*, const byte*, size_t);
42BEECRYPTAPI
43int hmacReset (const byte*, const hashFunction*, hashFunctionParam*);
44BEECRYPTAPI
45int hmacUpdate( const hashFunction*, hashFunctionParam*, const byte*, size_t);
46BEECRYPTAPI
47int hmacDigest( const byte*, const hashFunction*, hashFunctionParam*, byte*);
48
49#ifdef __cplusplus
50}
51#endif
52
53#endif
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/hmacsha1.c b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/hmacsha1.c
new file mode 100755
index 0000000000..f201a45f0f
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/hmacsha1.c
@@ -0,0 +1,77 @@
1/*
2 * Copyright (c) 1999, 2000, 2001, 2002 Virtual Unlimited B.V.
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 hmacsha1.c
21 * \brief HMAC-SHA-1 message authentication code.
22 *
23 * \see RFC2202 - Test Cases for HMAC-MD5 and HMAC-SHA-1.
24 * P. Cheng, R. Glenn.
25 *
26 * \author Bob Deblier <bob.deblier@pandora.be>
27 * \ingroup HMAC_m HMAC_sha1_m
28 */
29
30#define BEECRYPT_DLL_EXPORT
31
32#if HAVE_CONFIG_H
33# include "config.h"
34#endif
35
36#include "beecrypt/hmacsha1.h"
37
38/*!\addtogroup HMAC_sha1_m
39 * \{
40 */
41
42const keyedHashFunction hmacsha1 = {
43 "HMAC-SHA-1",
44 sizeof(hmacsha1Param),
45 64,
46 20,
47 64,
48 512,
49 32,
50 (keyedHashFunctionSetup) hmacsha1Setup,
51 (keyedHashFunctionReset) hmacsha1Reset,
52 (keyedHashFunctionUpdate) hmacsha1Update,
53 (keyedHashFunctionDigest) hmacsha1Digest
54};
55
56int hmacsha1Setup (hmacsha1Param* sp, const byte* key, size_t keybits)
57{
58 return hmacSetup(sp->kxi, sp->kxo, &sha1, &sp->sparam, key, keybits);
59}
60
61int hmacsha1Reset (hmacsha1Param* sp)
62{
63 return hmacReset(sp->kxi, &sha1, &sp->sparam);
64}
65
66int hmacsha1Update(hmacsha1Param* sp, const byte* data, size_t size)
67{
68 return hmacUpdate(&sha1, &sp->sparam, data, size);
69}
70
71int hmacsha1Digest(hmacsha1Param* sp, byte* data)
72{
73 return hmacDigest(sp->kxo, &sha1, &sp->sparam, data);
74}
75
76/*!\}
77 */
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/hmacsha1.h b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/hmacsha1.h
new file mode 100755
index 0000000000..207f5df37f
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/hmacsha1.h
@@ -0,0 +1,60 @@
1/*
2 * Copyright (c) 1999, 2000, 2001, 2002 Virtual Unlimited B.V.
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 hmacsha1.h
21 * \brief HMAC-SHA-1 message authentication code, headers.
22 * \author Bob Deblier <bob.deblier@pandora.be>
23 * \ingroup HMAC_m HMAC_sha1_m
24 */
25
26#ifndef _HMACSHA1_H
27#define _HMACSHA1_H
28
29#include "beecrypt/hmac.h"
30#include "beecrypt/sha1.h"
31
32/*!\ingroup HMAC_sha1_m
33 */
34typedef struct
35{
36 sha1Param sparam;
37 byte kxi[64];
38 byte kxo[64];
39} hmacsha1Param;
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44
45extern BEECRYPTAPI const keyedHashFunction hmacsha1;
46
47BEECRYPTAPI
48int hmacsha1Setup (hmacsha1Param*, const byte*, size_t);
49BEECRYPTAPI
50int hmacsha1Reset (hmacsha1Param*);
51BEECRYPTAPI
52int hmacsha1Update(hmacsha1Param*, const byte*, size_t);
53BEECRYPTAPI
54int hmacsha1Digest(hmacsha1Param*, byte*);
55
56#ifdef __cplusplus
57}
58#endif
59
60#endif
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/memchunk.h b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/memchunk.h
new file mode 100755
index 0000000000..4778b7ca89
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/memchunk.h
@@ -0,0 +1,53 @@
1/*
2 * Copyright (c) 2001 Virtual Unlimited B.V.
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/*!\file memchunk.h
20 * \author Bob Deblier <bob.deblier@pandora.be>
21 */
22
23#ifndef _MEMCHUNK_H
24#define _MEMCHUNK_H
25
26#include "beecrypt/api.h"
27
28typedef struct
29{
30 size_t size;
31 byte* data;
32} memchunk;
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38BEECRYPTAPI
39memchunk* memchunkAlloc(size_t);
40BEECRYPTAPI
41void memchunkWipe(memchunk*);
42BEECRYPTAPI
43void memchunkFree(memchunk*);
44BEECRYPTAPI
45memchunk* memchunkResize(memchunk*, size_t);
46BEECRYPTAPI
47memchunk* memchunkClone(const memchunk*);
48
49#ifdef __cplusplus
50}
51#endif
52
53#endif
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/mp.c b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/mp.c
new file mode 100755
index 0000000000..82d272c17a
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/mp.c
@@ -0,0 +1,1537 @@
1/*
2 * Copyright (c) 2002, 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 mp.c
21 * \brief Multi-precision integer routines.
22 * \author Bob Deblier <bob.deblier@pandora.be>
23 * \ingroup MP_m
24 */
25
26#define BEECRYPT_DLL_EXPORT
27
28#if HAVE_CONFIG_H
29# include "config.h"
30#endif
31
32#include "beecrypt/mp.h"
33#include "beecrypt/mpopt.h"
34
35#ifndef ASM_MPZERO
36void mpzero(size_t size, mpw* data)
37{
38 while (size--)
39 *(data++) = 0;
40}
41#endif
42
43#ifndef ASM_MPFILL
44void mpfill(size_t size, mpw* data, mpw fill)
45{
46 while (size--)
47 *(data++) = fill;
48}
49#endif
50
51#ifndef ASM_MPODD
52int mpodd(size_t size, const mpw* data)
53{
54 return (int)(data[size-1] & 0x1);
55}
56#endif
57
58#ifndef ASM_MPEVEN
59int mpeven(size_t size, const mpw* data)
60{
61 return !(int)(data[size-1] & 0x1);
62}
63#endif
64
65#ifndef ASM_MPZ
66int mpz(size_t size, const mpw* data)
67{
68 while (size--)
69 if (*(data++))
70 return 0;
71 return 1;
72}
73#endif
74
75#ifndef ASM_MPNZ
76int mpnz(size_t size, const mpw* data)
77{
78 while (size--)
79 if (*(data++))
80 return 1;
81 return 0;
82}
83#endif
84
85#ifndef ASM_MPEQ
86int mpeq(size_t size, const mpw* xdata, const mpw* ydata)
87{
88 while (size--)
89 {
90 if (*xdata == *ydata)
91 {
92 xdata++;
93 ydata++;
94 }
95 else
96 return 0;
97 }
98 return 1;
99}
100#endif
101
102#ifndef ASM_MPEQX
103int mpeqx(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata)
104{
105 if (xsize > ysize)
106 {
107 register size_t diff = xsize - ysize;
108 return mpeq(ysize, xdata+diff, ydata) && mpz(diff, xdata);
109 }
110 else if (xsize < ysize)
111 {
112 register size_t diff = ysize - xsize;
113 return mpeq(xsize, ydata+diff, xdata) && mpz(diff, ydata);
114 }
115 else
116 return mpeq(xsize, xdata, ydata);
117}
118#endif
119
120#ifndef ASM_MPNE
121int mpne(size_t size, const mpw* xdata, const mpw* ydata)
122{
123 while (size--)
124 {
125 if (*xdata == *ydata)
126 {
127 xdata++;
128 ydata++;
129 }
130 else
131 return 1;
132 }
133 return 0;
134}
135#endif
136
137#ifndef ASM_MPNEX
138int mpnex(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata)
139{
140 if (xsize > ysize)
141 {
142 register size_t diff = xsize - ysize;
143 return mpnz(diff, xdata) || mpne(ysize, xdata+diff, ydata);
144 }
145 else if (xsize < ysize)
146 {
147 register size_t diff = ysize - xsize;
148 return mpnz(diff, ydata) || mpne(xsize, ydata+diff, xdata);
149 }
150 else
151 return mpne(xsize, xdata, ydata);
152}
153#endif
154
155#ifndef ASM_MPGT
156int mpgt(size_t size, const mpw* xdata, const mpw* ydata)
157{
158 while (size--)
159 {
160 if (*xdata < *ydata)
161 return 0;
162 if (*xdata > *ydata)
163 return 1;
164 xdata++; ydata++;
165 }
166 return 0;
167}
168#endif
169
170#ifndef ASM_MPGTX
171int mpgtx(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata)
172{
173 if (xsize > ysize)
174 {
175 register size_t diff = xsize - ysize;
176 return mpnz(diff, xdata) || mpgt(ysize, xdata + diff, ydata);
177 }
178 else if (xsize < ysize)
179 {
180 register size_t diff = ysize - xsize;
181 return mpz(diff, ydata) && mpgt(xsize, xdata, ydata + diff);
182 }
183 else
184 return mpgt(xsize, xdata, ydata);
185}
186#endif
187
188#ifndef ASM_MPLT
189int mplt(size_t size, const mpw* xdata, const mpw* ydata)
190{
191 while (size--)
192 {
193 if (*xdata > *ydata)
194 return 0;
195 if (*xdata < *ydata)
196 return 1;
197 xdata++; ydata++;
198 }
199 return 0;
200}
201#endif
202
203#ifndef ASM_MPLTX
204int mpltx(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata)
205{
206 if (xsize > ysize)
207 {
208 register size_t diff = xsize - ysize;
209 return mpz(diff, xdata) && mplt(ysize, xdata+diff, ydata);
210 }
211 else if (xsize < ysize)
212 {
213 register size_t diff = ysize - xsize;
214 return mpnz(diff, ydata) || mplt(xsize, xdata, ydata+diff);
215 }
216 else
217 return mplt(xsize, xdata, ydata);
218}
219#endif
220
221#ifndef ASM_MPGE
222int mpge(size_t size, const mpw* xdata, const mpw* ydata)
223{
224 while (size--)
225 {
226 if (*xdata < *ydata)
227 return 0;
228 if (*xdata > *ydata)
229 return 1;
230 xdata++; ydata++;
231 }
232 return 1;
233}
234#endif
235
236#ifndef ASM_MPGEX
237int mpgex(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata)
238{
239 if (xsize > ysize)
240 {
241 register size_t diff = xsize - ysize;
242 return mpnz(diff, xdata) || mpge(ysize, xdata+diff, ydata);
243 }
244 else if (xsize < ysize)
245 {
246 register size_t diff = ysize - xsize;
247 return mpz(diff, ydata) && mpge(xsize, xdata, ydata+diff);
248 }
249 else
250 return mpge(xsize, xdata, ydata);
251}
252#endif
253
254#ifndef ASM_MPLE
255int mple(size_t size, const mpw* xdata, const mpw* ydata)
256{
257 while (size--)
258 {
259 if (*xdata < *ydata)
260 return 1;
261 if (*xdata > *ydata)
262 return 0;
263 xdata++; ydata++;
264 }
265 return 1;
266}
267#endif
268
269#ifndef ASM_MPLEX
270int mplex(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata)
271{
272 if (xsize > ysize)
273 {
274 register size_t diff = xsize - ysize;
275 return mpz(diff, xdata) && mple(ysize, xdata+ diff, ydata);
276 }
277 else if (xsize < ysize)
278 {
279 register size_t diff = ysize - xsize;
280 return mpnz(diff, ydata) || mple(xsize, xdata, ydata+diff);
281 }
282 else
283 return mple(xsize, xdata, ydata);
284}
285#endif
286
287#ifndef ASM_MPISONE
288int mpisone(size_t size, const mpw* data)
289{
290 data += size;
291 if (*(--data) == 1)
292 {
293 while (--size)
294 if (*(--data))
295 return 0;
296 return 1;
297 }
298 return 0;
299}
300#endif
301
302#ifndef ASM_MPISTWO
303int mpistwo(size_t size, const mpw* data)
304{
305 data += size;
306 if (*(--data) == 2)
307 {
308 while (--size)
309 if (*(--data))
310 return 0;
311 return 1;
312 }
313 return 0;
314}
315#endif
316
317#ifndef ASM_MPEQMONE
318int mpeqmone(size_t size, const mpw* xdata, const mpw* ydata)
319{
320 xdata += size;
321 ydata += size;
322
323 if (*(--xdata)+1 == *(--ydata))
324 {
325 while (--size)
326 if (*(--xdata) != *(--ydata))
327 return 0;
328 return 1;
329 }
330 return 0;
331}
332#endif
333
334#ifndef ASM_MPLEONE
335int mpleone(size_t size, const mpw* data)
336{
337 data += size;
338 if (*(--data) > 1)
339 return 0;
340 else
341 {
342 while (--size)
343 if (*(--data))
344 return 0;
345 return 1;
346 }
347}
348#endif
349
350#ifndef ASM_MPMSBSET
351int mpmsbset(size_t size, const mpw* data)
352{
353 return (int)((*data) >> (MP_WBITS-1));
354}
355#endif
356
357#ifndef ASM_MPLSBSET
358int mplsbset(size_t size, const mpw* data)
359{
360 return (int)(data[size-1] & 0x1);
361}
362#endif
363
364#ifndef ASM_MPSETMSB
365void mpsetmsb(size_t size, mpw* data)
366{
367 *data |= MP_MSBMASK;
368}
369#endif
370
371#ifndef ASM_MPSETLSB
372void mpsetlsb(size_t size, mpw* data)
373{
374 data[size-1] |= MP_LSBMASK;
375}
376#endif
377
378#ifndef ASM_MPCLRMSB
379void mpclrmsb(size_t size, mpw* data)
380{
381 *data &= ~ MP_MSBMASK;
382}
383#endif
384
385#ifndef ASM_MPCLRLSB
386void mpclrlsb(size_t size, mpw* data)
387{
388 data[size-1] &= ~ MP_LSBMASK;
389}
390#endif
391
392#ifndef ASM_MPAND
393void mpand(size_t size, mpw* xdata, const mpw* ydata)
394{
395 while (size--)
396 xdata[size] &= ydata[size];
397}
398#endif
399
400#ifndef ASM_MPOR
401void mpor(size_t size, mpw* xdata, const mpw* ydata)
402{
403 while (size--)
404 xdata[size] |= ydata[size];
405}
406#endif
407
408#ifndef ASM_MPXOR
409void mpxor(size_t size, mpw* xdata, const mpw* ydata)
410{
411 while (size--)
412 xdata[size] ^= ydata[size];
413}
414#endif
415
416#ifndef ASM_MPNOT
417void mpnot(size_t size, mpw* data)
418{
419 while (size--)
420 data[size] = ~data[size];
421}
422#endif
423
424#ifndef ASM_MPSETW
425void mpsetw(size_t size, mpw* xdata, mpw y)
426{
427 while (--size)
428 *(xdata++) = 0;
429 *(xdata++) = y;
430}
431#endif
432
433#ifndef ASM_MPSETX
434void mpsetx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata)
435{
436 while (xsize > ysize)
437 {
438 xsize--;
439 *(xdata++) = 0;
440 }
441 while (ysize > xsize)
442 {
443 ysize--;
444 ydata++;
445 }
446 while (xsize--)
447 *(xdata++) = *(ydata++);
448}
449#endif
450
451#ifndef ASM_MPADDW
452int mpaddw(size_t size, mpw* xdata, mpw y)
453{
454 register mpw load, temp;
455 register int carry = 0;
456
457 xdata += size-1;
458
459 load = *xdata;
460 temp = load + y;
461 *(xdata--) = temp;
462 carry = (load > temp);
463
464 while (--size && carry)
465 {
466 load = *xdata;
467 temp = load + 1;
468 *(xdata--) = temp;
469 carry = (load > temp);
470 }
471 return carry;
472}
473#endif
474
475#ifndef ASM_MPADD
476int mpadd(size_t size, mpw* xdata, const mpw* ydata)
477{
478 register mpw load, temp;
479 register int carry = 0;
480
481 xdata += size-1;
482 ydata += size-1;
483
484 while (size--)
485 {
486 temp = *(ydata--);
487 load = *xdata;
488 temp = carry ? (load + temp + 1) : (load + temp);
489 *(xdata--) = temp;
490 carry = carry ? (load >= temp) : (load > temp);
491 }
492 return carry;
493}
494#endif
495
496#ifndef ASM_MPADDX
497int mpaddx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata)
498{
499 if (xsize > ysize)
500 {
501 register size_t diff = xsize - ysize;
502 return mpaddw(diff, xdata, (mpw) mpadd(ysize, xdata+diff, ydata));
503 }
504 else
505 {
506 register size_t diff = ysize - xsize;
507 return mpadd(xsize, xdata, ydata+diff);
508 }
509}
510#endif
511
512#ifndef ASM_MPSUBW
513int mpsubw(size_t size, mpw* xdata, mpw y)
514{
515 register mpw load, temp;
516 register int carry = 0;
517
518 xdata += size-1;
519
520 load = *xdata;
521 temp = load - y;
522 *(xdata--) = temp;
523 carry = (load < temp);
524
525 while (--size && carry)
526 {
527 load = *xdata;
528 temp = load - 1;
529 *(xdata--) = temp;
530 carry = (load < temp);
531 }
532 return carry;
533}
534#endif
535
536#ifndef ASM_MPSUB
537int mpsub(size_t size, mpw* xdata, const mpw* ydata)
538{
539 register mpw load, temp;
540 register int carry = 0;
541
542 xdata += size-1;
543 ydata += size-1;
544
545 while (size--)
546 {
547 temp = *(ydata--);
548 load = *xdata;
549 temp = carry ? (load - temp - 1) : (load - temp);
550 *(xdata--) = temp;
551 carry = carry ? (load <= temp) : (load < temp);
552 }
553 return carry;
554}
555#endif
556
557#ifndef ASM_MPSUBX
558int mpsubx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata)
559{
560 if (xsize > ysize)
561 {
562 register size_t diff = xsize - ysize;
563 return mpsubw(diff, xdata, (mpw) mpsub(ysize, xdata+diff, ydata));
564 }
565 else
566 {
567 register size_t diff = ysize - xsize;
568 return mpsub(xsize, xdata, ydata+diff);
569 }
570}
571#endif
572
573#ifndef ASM_MPNEG
574void mpneg(size_t size, mpw* data)
575{
576 mpnot(size, data);
577 mpaddw(size, data, 1);
578}
579#endif
580
581#ifndef ASM_MPSETMUL
582mpw mpsetmul(size_t size, mpw* result, const mpw* data, mpw y)
583{
584 #if HAVE_MPDW
585 register mpdw temp;
586 register mpw carry = 0;
587
588 data += size;
589 result += size;
590
591 while (size--)
592 {
593 temp = *(--data);
594 temp *= y;
595 temp += carry;
596 *(--result) = (mpw) temp;
597 carry = (mpw)(temp >> MP_WBITS);
598 }
599 #else
600 register mpw temp, load, carry = 0;
601 register mphw ylo, yhi;
602
603 ylo = (mphw) y;
604 yhi = (mphw) (y >> MP_HWBITS);
605
606 data += size;
607 result += size;
608
609 while (size--)
610 {
611 register mphw xlo, xhi;
612 register mpw rlo, rhi;
613
614 xlo = (mphw) (temp = *(--data));
615 xhi = (mphw) (temp >> MP_HWBITS);
616
617 rlo = (mpw) xlo * ylo;
618 rhi = (mpw) xhi * yhi;
619 load = rlo;
620 temp = (mpw) xhi * ylo;
621 rlo += (temp << MP_HWBITS);
622 rhi += (temp >> MP_HWBITS) + (load > rlo);
623 load = rlo;
624 temp = (mpw) xlo * yhi;
625 rlo += (temp << MP_HWBITS);
626 rhi += (temp >> MP_HWBITS) + (load > rlo);
627 load = rlo;
628 temp = rlo + carry;
629 carry = rhi + (load > temp);
630 *(--result) = temp;
631 }
632 #endif
633 return carry;
634}
635#endif
636
637#ifndef ASM_MPADDMUL
638mpw mpaddmul(size_t size, mpw* result, const mpw* data, mpw y)
639{
640 #if HAVE_MPDW
641 register mpdw temp;
642 register mpw carry = 0;
643
644 data += size;
645 result += size;
646
647 while (size--)
648 {
649 temp = *(--data);
650 temp *= y;
651 temp += carry;
652 temp += *(--result);
653 *result = (mpw) temp;
654 carry = (mpw)(temp >> MP_WBITS);
655 }
656 #else
657 register mpw temp, load, carry = 0;
658 register mphw ylo, yhi;
659
660 ylo = (mphw) y;
661 yhi = (mphw) (y >> MP_HWBITS);
662
663 data += size;
664 result += size;
665
666 while (size--)
667 {
668 register mphw xlo, xhi;
669 register mpw rlo, rhi;
670
671 xlo = (mphw) (temp = *(--data));
672 xhi = (mphw) (temp >> MP_HWBITS);
673
674 rlo = (mpw) xlo * ylo;
675 rhi = (mpw) xhi * yhi;
676 load = rlo;
677 temp = (mpw) xhi * ylo;
678 rlo += (temp << MP_HWBITS);
679 rhi += (temp >> MP_HWBITS) + (load > rlo);
680 load = rlo;
681 temp = (mpw) xlo * yhi;
682 rlo += (temp << MP_HWBITS);
683 rhi += (temp >> MP_HWBITS) + (load > rlo);
684 load = rlo;
685 rlo += carry;
686 temp = (load > rlo);
687 load = rhi;
688 rhi += temp;
689 carry = (load > rhi);
690 load = rlo;
691 rlo += *(--result);
692 *result = rlo;
693 carry += rhi + (load > rlo);
694 }
695 #endif
696 return carry;
697}
698#endif
699
700#ifndef ASM_MPMUL
701void mpmul(mpw* result, size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata)
702{
703 /* preferred passing of parameters is x the larger of the two numbers */
704 if (xsize >= ysize)
705 {
706 register mpw rc;
707
708 result += ysize;
709 ydata += ysize;
710
711 rc = mpsetmul(xsize, result, xdata, *(--ydata));
712 *(--result) = rc;
713
714 while (--ysize)
715 {
716 rc = mpaddmul(xsize, result, xdata, *(--ydata));
717 *(--result) = rc;
718 }
719 }
720 else
721 {
722 register mpw rc;
723
724 result += xsize;
725 xdata += xsize;
726
727 rc = mpsetmul(ysize, result, ydata, *(--xdata));
728 *(--result) = rc;
729
730 while (--xsize)
731 {
732 rc = mpaddmul(ysize, result, ydata, *(--xdata));
733 *(--result) = rc;
734 }
735 }
736}
737#endif
738
739#ifndef ASM_MPADDSQRTRC
740void mpaddsqrtrc(size_t size, mpw* result, const mpw* data)
741{
742 #if HAVE_MPDW
743 register mpdw temp;
744 register mpw load, carry = 0;
745
746 result += (size << 1);
747
748 while (size--)
749 {
750 temp = load = data[size];
751 temp *= load;
752 temp += carry;
753 temp += *(--result);
754 *result = (mpw) temp;
755 temp >>= MP_WBITS;
756 temp += *(--result);
757 *result = (mpw) temp;
758 carry = (mpw)(temp >> MP_WBITS);
759 }
760 #else
761 register mpw temp, load, carry = 0;
762
763 result += (size << 1);
764
765 while (size--)
766 {
767 register mphw xlo, xhi;
768 register mpw rlo, rhi;
769
770 xlo = (mphw) (temp = data[size]);
771 xhi = (mphw) (temp >> MP_HWBITS);
772
773 rlo = (mpw) xlo * xlo;
774 rhi = (mpw) xhi * xhi;
775 temp = (mpw) xhi * xlo;
776 load = rlo;
777 rlo += (temp << MP_HWBITS);
778 rhi += (temp >> MP_HWBITS) + (load > rlo);
779 load = rlo;
780 rlo += (temp << MP_HWBITS);
781 rhi += (temp >> MP_HWBITS) + (load > rlo);
782 load = rlo;
783 rlo += carry;
784 rhi += (load > rlo);
785 load = rlo;
786 rlo += *(--result);
787 *result = rlo;
788 temp = (load > rlo);
789 load = rhi;
790 rhi += temp;
791 carry = (load > rhi);
792 load = rhi;
793 rhi += *(--result);
794 *result = rhi;
795 carry += (load > rhi);
796 }
797 #endif
798}
799#endif
800
801#ifndef ASM_MPSQR
802void mpsqr(mpw* result, size_t size, const mpw* data)
803{
804 register mpw rc;
805 register size_t n = size-1;
806
807 result += size;
808 result[n] = 0;
809
810 if (n)
811 {
812 rc = mpsetmul(n, result, data, data[n]);
813 *(--result) = rc;
814 while (--n)
815 {
816 rc = mpaddmul(n, result, data, data[n]);
817 *(--result) = rc;
818 }
819 }
820
821 *(--result) = 0;
822
823 mpmultwo(size << 1, result);
824
825 mpaddsqrtrc(size, result, data);
826}
827#endif
828
829#ifndef ASM_MPSIZE
830size_t mpsize(size_t size, const mpw* data)
831{
832 while (size)
833 {
834 if (*data)
835 return size;
836 data++;
837 size--;
838 }
839 return 0;
840}
841#endif
842
843#ifndef ASM_MPBITS
844size_t mpbits(size_t size, const mpw* data)
845{
846 return MP_WORDS_TO_BITS(size) - mpmszcnt(size, data);
847}
848#endif
849
850#ifndef ASM_MPNORM
851size_t mpnorm(size_t size, mpw* data)
852{
853 register size_t shift = mpmszcnt(size, data);
854 mplshift(size, data, shift);
855 return shift;
856}
857#endif
858
859#ifndef ASM_MPDIVTWO
860void mpdivtwo(size_t size, mpw* data)
861{
862 register mpw temp, carry = 0;
863
864 while (size--)
865 {
866 temp = *data;
867 *(data++) = (temp >> 1) | carry;
868 carry = (temp << (MP_WBITS-1));
869 }
870}
871#endif
872
873#ifndef ASM_MPSDIVTWO
874void mpsdivtwo(size_t size, mpw* data)
875{
876 int carry = mpmsbset(size, data);
877 mpdivtwo(size, data);
878 if (carry)
879 mpsetmsb(size, data);
880}
881#endif
882
883#ifndef ASM_MPMULTWO
884int mpmultwo(size_t size, mpw* data)
885{
886 register mpw temp, carry = 0;
887
888 data += size;
889 while (size--)
890 {
891 temp = *(--data);
892 *data = (temp << 1) | carry;
893 carry = (temp >> (MP_WBITS-1));
894 }
895 return (int) carry;
896}
897#endif
898
899#ifndef ASM_MPMSZCNT
900size_t mpmszcnt(size_t size, const mpw* data)
901{
902 register size_t zbits = 0;
903 register size_t i = 0;
904
905 while (i < size)
906 {
907 register mpw temp = data[i++];
908 if (temp)
909 {
910 while (!(temp & MP_MSBMASK))
911 {
912 zbits++;
913 temp <<= 1;
914 }
915 break;
916 }
917 else
918 zbits += MP_WBITS;
919 }
920 return zbits;
921}
922#endif
923
924#ifndef ASM_MPLSZCNT
925size_t mplszcnt(size_t size, const mpw* data)
926{
927 register size_t zbits = 0;
928
929 while (size--)
930 {
931 register mpw temp = data[size];
932 if (temp)
933 {
934 while (!(temp & MP_LSBMASK))
935 {
936 zbits++;
937 temp >>= 1;
938 }
939 break;
940 }
941 else
942 zbits += MP_WBITS;
943 }
944 return zbits;
945}
946#endif
947
948#ifndef ASM_MPLSHIFT
949void mplshift(size_t size, mpw* data, size_t count)
950{
951 register size_t words = MP_BITS_TO_WORDS(count);
952
953 if (words < size)
954 {
955 register short lbits = (short) (count & (MP_WBITS-1));
956
957 /* first do the shifting, then do the moving */
958 if (lbits)
959 {
960 register mpw temp, carry = 0;
961 register short rbits = MP_WBITS - lbits;
962 register size_t i = size;
963
964 while (i > words)
965 {
966 temp = data[--i];
967 data[i] = (temp << lbits) | carry;
968 carry = (temp >> rbits);
969 }
970 }
971 if (words)
972 {
973 mpmove(size-words, data, data+words);
974 mpzero(words, data+size-words);
975 }
976 }
977 else
978 mpzero(size, data);
979}
980#endif
981
982#ifndef ASM_MPRSHIFT
983void mprshift(size_t size, mpw* data, size_t count)
984{
985 register size_t words = MP_BITS_TO_WORDS(count);
986
987 if (words < size)
988 {
989 register short rbits = (short) (count & (MP_WBITS-1));
990
991 /* first do the shifting, then do the moving */
992 if (rbits)
993 {
994 register mpw temp, carry = 0;
995 register short lbits = MP_WBITS - rbits;
996 register size_t i = 0;
997
998 while (i < size-words)
999 {
1000 temp = data[i];
1001 data[i++] = (temp >> rbits) | carry;
1002 carry = (temp << lbits);
1003 }
1004 }
1005 if (words)
1006 {
1007 mpmove(size-words, data+words, data);
1008 mpzero(words, data);
1009 }
1010 }
1011 else
1012 mpzero(size, data);
1013}
1014#endif
1015
1016#ifndef ASM_MPRSHIFTLSZ
1017size_t mprshiftlsz(size_t size, mpw* data)
1018{
1019 register mpw* slide = data+size-1;
1020 register size_t zwords = 0; /* counter for 'all zero bit' words */
1021 register short lbits, rbits = 0; /* counter for 'least significant zero' bits */
1022 register mpw temp, carry = 0;
1023
1024 data = slide;
1025
1026 /* count 'all zero' words and move src pointer */
1027 while (size--)
1028 {
1029 /* test if we have a non-zero word */
1030 if ((carry = *(slide--)))
1031 {
1032 /* count 'least signification zero bits and set zbits counter */
1033 while (!(carry & MP_LSBMASK))
1034 {
1035 carry >>= 1;
1036 rbits++;
1037 }
1038 break;
1039 }
1040 zwords++;
1041 }
1042
1043 if ((rbits == 0) && (zwords == 0))
1044 return 0;
1045
1046 /* prepare right-shifting of data */
1047 lbits = MP_WBITS - rbits;
1048
1049 /* shift data */
1050 while (size--)
1051 {
1052 temp = *(slide--);
1053 *(data--) = (temp << lbits) | carry;
1054 carry = (temp >> rbits);
1055 }
1056
1057 /* store the final carry */
1058 *(data--) = carry;
1059
1060 /* store the return value in size */
1061 size = MP_WORDS_TO_BITS(zwords) + rbits;
1062
1063 /* zero the (zwords) most significant words */
1064 while (zwords--)
1065 *(data--) = 0;
1066
1067 return size;
1068}
1069#endif
1070
1071/* try an alternate version here, with descending sizes */
1072/* also integrate lszcnt and rshift properly into one function */
1073#ifndef ASM_MPGCD_W
1074/*
1075 * mpgcd_w
1076 * need workspace of (size) words
1077 */
1078void mpgcd_w(size_t size, const mpw* xdata, const mpw* ydata, mpw* result, mpw* wksp)
1079{
1080 register size_t shift, temp;
1081
1082 if (mpge(size, xdata, ydata))
1083 {
1084 mpcopy(size, wksp, xdata);
1085 mpcopy(size, result, ydata);
1086 }
1087 else
1088 {
1089 mpcopy(size, wksp, ydata);
1090 mpcopy(size, result, xdata);
1091 }
1092
1093 /* get the smallest returned values, and set shift to that */
1094
1095 shift = mprshiftlsz(size, wksp);
1096 temp = mprshiftlsz(size, result);
1097
1098 if (shift > temp)
1099 shift = temp;
1100
1101 while (mpnz(size, wksp))
1102 {
1103 mprshiftlsz(size, wksp);
1104 mprshiftlsz(size, result);
1105
1106 if (mpge(size, wksp, result))
1107 mpsub(size, wksp, result);
1108 else
1109 mpsub(size, result, wksp);
1110
1111 /* slide past zero words in both operands by increasing pointers and decreasing size */
1112 if ((*wksp == 0) && (*result == 0))
1113 {
1114 size--;
1115 wksp++;
1116 result++;
1117 }
1118 }
1119
1120 /* figure out if we need to slide the result pointer back */
1121 if ((temp = MP_BITS_TO_WORDS(shift)))
1122 {
1123 size += temp;
1124 result -= temp;
1125 }
1126
1127 mplshift(size, result, shift);
1128}
1129#endif
1130
1131#ifndef ASM_MPEXTGCD_W
1132/* needs workspace of (6*size+6) words */
1133/* used to compute the modular inverse */
1134int mpextgcd_w(size_t size, const mpw* xdata, const mpw* ydata, mpw* result, mpw* wksp)
1135{
1136 /*
1137 * For computing a modular inverse, pass the modulus as xdata and the number
1138 * to be inverted as ydata.
1139 *
1140 * Fact: if a element of Zn, then a is invertible if and only if gcd(a,n) = 1
1141 * Hence: if n is even, then a must be odd, otherwise the gcd(a,n) >= 2
1142 *
1143 * The calling routine must guarantee this condition.
1144 */
1145
1146 register size_t sizep = size+1;
1147 register int full;
1148
1149 mpw* udata = wksp;
1150 mpw* vdata = udata+sizep;
1151 mpw* adata = vdata+sizep;
1152 mpw* bdata = adata+sizep;
1153 mpw* cdata = bdata+sizep;
1154 mpw* ddata = cdata+sizep;
1155
1156 mpsetx(sizep, udata, size, xdata);
1157 mpsetx(sizep, vdata, size, ydata);
1158 mpzero(sizep, bdata);
1159 mpsetw(sizep, ddata, 1);
1160
1161 if ((full = mpeven(sizep, udata)))
1162 {
1163 mpsetw(sizep, adata, 1);
1164 mpzero(sizep, cdata);
1165 }
1166
1167 while (1)
1168 {
1169 while (mpeven(sizep, udata))
1170 {
1171 mpdivtwo(sizep, udata);
1172
1173 if (mpodd(sizep, bdata) || (full && mpodd(sizep, adata)))
1174 {
1175 if (full) mpaddx(sizep, adata, size, ydata);
1176 mpsubx(sizep, bdata, size, xdata);
1177 }
1178
1179 if (full) mpsdivtwo(sizep, adata);
1180 mpsdivtwo(sizep, bdata);
1181 }
1182 while (mpeven(sizep, vdata))
1183 {
1184 mpdivtwo(sizep, vdata);
1185
1186 if (mpodd(sizep, ddata) || (full && mpodd(sizep, cdata)))
1187 {
1188 if (full) mpaddx(sizep, cdata, size, ydata);
1189 mpsubx(sizep, ddata, size, xdata);
1190 }
1191
1192 if (full) mpsdivtwo(sizep, cdata);
1193 mpsdivtwo(sizep, ddata);
1194 }
1195 if (mpge(sizep, udata, vdata))
1196 {
1197 mpsub(sizep, udata, vdata);
1198 if (full) mpsub(sizep, adata, cdata);
1199 mpsub(sizep, bdata, ddata);
1200 }
1201 else
1202 {
1203 mpsub(sizep, vdata, udata);
1204 if (full) mpsub(sizep, cdata, adata);
1205 mpsub(sizep, ddata, bdata);
1206 }
1207 if (mpz(sizep, udata))
1208 {
1209 if (mpisone(sizep, vdata))
1210 {
1211 if (result)
1212 {
1213 if (*ddata & MP_MSBMASK)
1214 {
1215 /* keep adding the modulus until we get a carry */
1216 while (!mpaddx(sizep, ddata, size, xdata));
1217 }
1218 else
1219 {
1220 /* in some computations, d ends up > x, hence:
1221 * keep subtracting n from d until d < x
1222 */
1223 while (mpgtx(sizep, ddata, size, xdata))
1224 mpsubx(sizep, ddata, size, xdata);
1225 }
1226 mpsetx(size, result, sizep, ddata);
1227 }
1228 return 1;
1229 }
1230 return 0;
1231 }
1232 }
1233}
1234#endif
1235
1236#ifndef ASM_MPPNDIV
1237mpw mppndiv(mpw xhi, mpw xlo, mpw y)
1238{
1239 register mpw result = 0;
1240 register short count = MP_WBITS;
1241 register int carry = 0;
1242
1243 while (count--)
1244 {
1245 if (carry | (xhi >= y))
1246 {
1247 xhi -= y;
1248 result++;
1249 }
1250 carry = (xhi >> (MP_WBITS-1));
1251 xhi <<= 1;
1252 xhi |= (xlo >> (MP_WBITS-1));
1253 xlo <<= 1;
1254 result <<= 1;
1255 }
1256 if (carry | (xhi >= y))
1257 {
1258 xhi -= y;
1259 result++;
1260 }
1261 return result;
1262}
1263#endif
1264
1265#ifndef ASM_MPMOD
1266void mpmod(mpw* result, size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata, mpw* workspace)
1267{
1268 /* result size xsize, workspace size 2*ysize+1 */
1269 mpw q, msw;
1270 mpw* rdata = result;
1271 mpw* ynorm = workspace+ysize+1;
1272 size_t shift, qsize = xsize-ysize;
1273
1274 mpcopy(ysize, ynorm, ydata);
1275 shift = mpnorm(ysize, ynorm);
1276 msw = *ynorm;
1277 mpcopy(xsize, rdata, xdata);
1278 if (mpge(ysize, rdata, ynorm))
1279 mpsub(ysize, rdata, ynorm);
1280
1281 while (qsize--)
1282 {
1283 q = mppndiv(rdata[0], rdata[1], msw);
1284
1285 *workspace = mpsetmul(ysize, workspace+1, ynorm, q);
1286
1287 while (mplt(ysize+1, rdata, workspace))
1288 {
1289 mpsubx(ysize+1, workspace, ysize, ynorm);
1290 q--;
1291 }
1292 mpsub(ysize+1, rdata, workspace);
1293 rdata++;
1294 }
1295 /* de-normalization steps */
1296 while (shift--)
1297 {
1298 mpdivtwo(ysize, ynorm);
1299 if (mpge(ysize, rdata, ynorm))
1300 mpsub(ysize, rdata, ynorm);
1301 }
1302}
1303#endif
1304
1305#ifndef ASM_MPNDIVMOD
1306void mpndivmod(mpw* result, size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata, register mpw* workspace)
1307{
1308 /* result must be xsize+1 in length */
1309 /* workspace must be ysize+1 in length */
1310 /* expect ydata to be normalized */
1311 mpw q;
1312 mpw msw = *ydata;
1313 size_t qsize = xsize-ysize;
1314
1315 *result = (mpge(ysize, xdata, ydata) ? 1 : 0);
1316 mpcopy(xsize, result+1, xdata);
1317
1318 if (*result)
1319 (void) mpsub(ysize, result+1, ydata);
1320
1321 result++;
1322
1323 while (qsize--)
1324 {
1325 q = mppndiv(result[0], result[1], msw);
1326
1327 *workspace = mpsetmul(ysize, workspace+1, ydata, q);
1328
1329 while (mplt(ysize+1, result, workspace))
1330 {
1331 mpsubx(ysize+1, workspace, ysize, ydata);
1332 q--;
1333 }
1334 mpsub(ysize+1, result, workspace);
1335 *(result++) = q;
1336 }
1337}
1338#endif
1339
1340void mpprint(size_t size, const mpw* data)
1341{
1342 mpfprint(stdout, size, data);
1343}
1344
1345void mpprintln(size_t size, const mpw* data)
1346{
1347 mpfprintln(stdout, size, data);
1348}
1349
1350void mpfprint(FILE* f, size_t size, const mpw* data)
1351{
1352 if (data == (mpw*) 0)
1353 return;
1354
1355 if (f == (FILE*) 0)
1356 return;
1357
1358 while (size--)
1359 {
1360 #if (MP_WBITS == 32)
1361 fprintf(f, "%08x", (unsigned) *(data++));
1362 #elif (MP_WBITS == 64)
1363 # if WIN32
1364 fprintf(f, "%016I64x", *(data++));
1365 # elif SIZEOF_UNSIGNED_LONG == 8
1366 fprintf(f, "%016lx", *(data++));
1367 # else
1368 fprintf(f, "%016llx", *(data++));
1369 # endif
1370 #else
1371 # error
1372 #endif
1373 }
1374 fflush(f);
1375}
1376
1377void mpfprintln(FILE* f, size_t size, const mpw* data)
1378{
1379 if (data == (mpw*) 0)
1380 return;
1381
1382 if (f == (FILE*) 0)
1383 return;
1384
1385 while (size--)
1386 {
1387 #if (MP_WBITS == 32)
1388 fprintf(f, "%08x", *(data++));
1389 #elif (MP_WBITS == 64)
1390 # if WIN32
1391 fprintf(f, "%016I64x", *(data++));
1392 # elif SIZEOF_UNSIGNED_LONG == 8
1393 fprintf(f, "%016lx", *(data++));
1394 # else
1395 fprintf(f, "%016llx", *(data++));
1396 # endif
1397 #else
1398 # error
1399 #endif
1400 }
1401 fprintf(f, "\n");
1402 fflush(f);
1403}
1404
1405int i2osp(byte *osdata, size_t ossize, const mpw* idata, size_t isize)
1406{
1407 #if WORDS_BIGENDIAN
1408 size_t max_bytes = MP_WORDS_TO_BYTES(isize);
1409 #endif
1410 size_t significant_bytes = (mpbits(isize, idata) + 7) >> 3;
1411
1412 /* verify that ossize is large enough to contain the significant bytes */
1413 if (ossize >= significant_bytes)
1414 {
1415 /* looking good; check if we have more space than significant bytes */
1416 if (ossize > significant_bytes)
1417 { /* fill most significant bytes with zero */
1418 memset(osdata, 0, ossize - significant_bytes);
1419 osdata += ossize - significant_bytes;
1420 }
1421 if (significant_bytes)
1422 { /* fill remaining bytes with endian-adjusted data */
1423 #if !WORDS_BIGENDIAN
1424 mpw w = idata[--isize];
1425 byte shift = 0;
1426
1427 /* fill right-to-left; much easier than left-to-right */
1428 do
1429 {
1430 osdata[--significant_bytes] = (byte)(w >> shift);
1431 shift += 8;
1432 if (shift == MP_WBITS)
1433 {
1434 shift = 0;
1435 w = idata[--isize];
1436 }
1437 } while (significant_bytes);
1438 #else
1439 /* just copy data past zero bytes */
1440 memcpy(osdata, ((byte*) idata) + (max_bytes - significant_bytes), significant_bytes);
1441 #endif
1442 }
1443 return 0;
1444 }
1445 return -1;
1446}
1447
1448int os2ip(mpw* idata, size_t isize, const byte* osdata, size_t ossize)
1449{
1450 size_t required;
1451
1452 /* skip non-significant leading zero bytes */
1453 while (!(*osdata) && ossize)
1454 {
1455 osdata++;
1456 ossize--;
1457 }
1458
1459 required = MP_BYTES_TO_WORDS(ossize + MP_WBYTES - 1);
1460
1461 if (isize >= required)
1462 {
1463 /* yes, we have enough space and can proceed */
1464 mpw w = 0;
1465 /* adjust counter so that the loop will start by skipping the proper
1466 * amount of leading bytes in the first significant word
1467 */
1468 byte b = (ossize % MP_WBYTES);
1469
1470 if (isize > required)
1471 { /* fill initials words with zero */
1472 mpzero(isize-required, idata);
1473 idata += isize-required;
1474 }
1475
1476 if (b == 0)
1477 b = MP_WBYTES;
1478
1479 while (ossize--)
1480 {
1481 w <<= 8;
1482 w |= *(osdata++);
1483 b--;
1484
1485 if (b == 0)
1486 {
1487 *(idata++) = w;
1488 w = 0;
1489 b = MP_WBYTES;
1490 }
1491 }
1492
1493 return 0;
1494 }
1495 return -1;
1496}
1497
1498int hs2ip(mpw* idata, size_t isize, const char* hsdata, size_t hssize)
1499{
1500 size_t required = MP_NIBBLES_TO_WORDS(hssize + MP_WNIBBLES - 1);
1501
1502 if (isize >= required)
1503 {
1504 register size_t i;
1505
1506
1507 if (isize > required)
1508 { /* fill initial words with zero */
1509 for (i = required; i < isize; i++)
1510 *(idata++) = 0;
1511 }
1512 while (hssize)
1513 {
1514 register mpw w = 0;
1515 register size_t chunk = hssize & (MP_WNIBBLES - 1);
1516 register char ch;
1517
1518 if (chunk == 0) chunk = MP_WNIBBLES;
1519
1520 for (i = 0; i < chunk; i++)
1521 {
1522 ch = *(hsdata++);
1523 w <<= 4;
1524 if (ch >= '0' && ch <= '9')
1525 w += (ch - '0');
1526 else if (ch >= 'A' && ch <= 'F')
1527 w += (ch - 'A') + 10;
1528 else if (ch >= 'a' && ch <= 'f')
1529 w += (ch - 'a') + 10;
1530 }
1531 *(idata++) = w;
1532 hssize -= chunk;
1533 }
1534 return 0;
1535 }
1536 return -1;
1537}
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/mp.h b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/mp.h
new file mode 100755
index 0000000000..57a3e6c502
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/mp.h
@@ -0,0 +1,691 @@
1/*
2 * Copyright (c) 2002, 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 mp.h
21 * \brief Multi-precision integer routines.
22 *
23 * The routines declared here are all low-level operations, most of them
24 * suitable to be implemented in assembler. Prime candidates are in order
25 * of importance (according to gprof):
26 * <ul>
27 * <li>mpaddmul
28 * <li>mpsetmul
29 * <li>mpaddsqrtrc
30 * <li>mpsub
31 * <li>mpadd
32 * </ul>
33 *
34 * With some smart use of available assembler instructions, it's possible
35 * to speed these routines up by a factor of 2 to 4.
36 *
37 * \author Bob Deblier <bob.deblier@pandora.be>
38 * \ingroup MP_m
39 */
40
41#ifndef _MP_H
42#define _MP_H
43
44#include "beecrypt/api.h"
45#include "beecrypt/mpopt.h"
46
47#define MP_HWBITS (MP_WBITS >> 1)
48#define MP_WBYTES (MP_WBITS >> 3)
49#define MP_WNIBBLES (MP_WBITS >> 2)
50
51#if (MP_WBITS == 64)
52# define MP_WORDS_TO_BITS(x) ((x) << 6)
53# define MP_WORDS_TO_NIBBLES(x) ((x) << 4)
54# define MP_WORDS_TO_BYTES(x) ((x) << 3)
55# define MP_BITS_TO_WORDS(x) ((x) >> 6)
56# define MP_NIBBLES_TO_WORDS(x) ((x) >> 4)
57# define MP_BYTES_TO_WORDS(x) ((x) >> 3)
58#elif (MP_WBITS == 32)
59# define MP_WORDS_TO_BITS(x) ((x) << 5)
60# define MP_WORDS_TO_NIBBLES(x) ((x) << 3)
61# define MP_WORDS_TO_BYTES(x) ((x) << 2)
62# define MP_BITS_TO_WORDS(x) ((x) >> 5)
63# define MP_NIBBLES_TO_WORDS(x) ((x) >> 3)
64# define MP_BYTES_TO_WORDS(x) ((x) >> 2)
65#else
66# error
67#endif
68
69#define MP_MSBMASK (((mpw) 0x1) << (MP_WBITS-1))
70#define MP_LSBMASK ((mpw) 0x1)
71#define MP_ALLMASK ~((mpw) 0x0)
72
73#ifdef __cplusplus
74extern "C" {
75#endif
76
77#ifndef ASM_MPCOPY
78# define mpcopy(size, dst, src) memcpy(dst, src, MP_WORDS_TO_BYTES(size))
79#else
80BEECRYPTAPI
81void mpcopy(size_t size, mpw* dest, const mpw* src);
82#endif
83
84#ifndef ASM_MPMOVE
85# define mpmove(size, dst, src) memmove(dst, src, MP_WORDS_TO_BYTES(size))
86#else
87BEECRYPTAPI
88void mpmove(size_t size, mpw* dest, const mpw* src);
89#endif
90
91/*!\fn void mpzero(size_t size, mpw* data)
92 * \brief This function zeroes a multi-precision integer of a given size.
93 * \param size The size of the multi-precision integer.
94 * \param data The multi-precision integer data.
95 */
96BEECRYPTAPI
97void mpzero(size_t size, mpw* data);
98
99/*!\fn void mpfill(size_t size, mpw* data, mpw fill)
100 * \brief This function fills each word of a multi-precision integer with a
101 * given value.
102 * \param size The size of the multi-precision integer.
103 * \param data The multi-precision integer data.
104 * \param fill The value fill the data with.
105 */
106BEECRYPTAPI
107void mpfill(size_t size, mpw* data, mpw fill);
108
109/*!\fn int mpodd(size_t size, const mpw* data)
110 * \brief This functions tests if a multi-precision integer is odd.
111 * \param size The size of the multi-precision integer.
112 * \param data The multi-precision integer data.
113 * \retval 1 if odd
114 * \retval 0 if even
115 */
116BEECRYPTAPI
117int mpodd (size_t size, const mpw* data);
118
119/*!\fn int mpeven(size_t size, const mpw* data)
120 * \brief This function tests if a multi-precision integer is even.
121 * \param size The size of the multi-precision integer.
122 * \param data The multi-precision integer data.
123 * \retval 1 if even
124 * \retval 0 if odd
125 */
126BEECRYPTAPI
127int mpeven(size_t size, const mpw* data);
128
129/*!\fn int mpz(size_t size, const mpw* data)
130 * \brief This function tests if a multi-precision integer is zero.
131 * \param size The size of the multi-precision integer.
132 * \param data The multi-precision integer data.
133 * \retval 1 if zero
134 * \retval 0 if not zero
135 */
136BEECRYPTAPI
137int mpz (size_t size, const mpw* data);
138
139/*!\fn int mpnz(size_t size, const mpw* data)
140 * \brief This function tests if a multi-precision integer is not zero.
141 * \param size The size of the multi-precision integer.
142 * \param data The multi-precision integer data.
143 * \retval 1 if not zero
144 * \retval 0 if zero
145 */
146BEECRYPTAPI
147int mpnz (size_t size, const mpw* data);
148
149/*!\fn int mpeq(size_t size, const mpw* xdata, const mpw* ydata)
150 * \brief This function tests if two multi-precision integers of the same size
151 * are equal.
152 * \param size The size of the multi-precision integers.
153 * \param xdata The first multi-precision integer.
154 * \param ydata The second multi-precision integer.
155 * \retval 1 if equal
156 * \retval 0 if not equal
157 */
158BEECRYPTAPI
159int mpeq (size_t size, const mpw* xdata, const mpw* ydata);
160
161/*!\fn int mpne(size_t size, const mpw* xdata, const mpw* ydata)
162 * \brief This function tests if two multi-precision integers of the same size
163 * differ.
164 * \param size The size of the multi-precision integers.
165 * \param xdata The first multi-precision integer.
166 * \param ydata The second multi-precision integer.
167 * \retval 1 if not equal
168 * \retval 0 if equal
169 */
170BEECRYPTAPI
171int mpne (size_t size, const mpw* xdata, const mpw* ydata);
172
173/*!\fn int mpgt(size_t size, const mpw* xdata, const mpw* ydata)
174 * \brief This function tests if the first of two multi-precision integers
175 * of the same size is greater than the second.
176 * \note The comparison treats the arguments as unsigned.
177 * \param size The size of the multi-precision integers.
178 * \param xdata The first multi-precision integer.
179 * \param ydata The second multi-precision integer.
180 * \retval 1 if greater
181 * \retval 0 if less or equal
182 */
183BEECRYPTAPI
184int mpgt (size_t size, const mpw* xdata, const mpw* ydata);
185
186/*!\fn int mplt(size_t size, const mpw* xdata, const mpw* ydata)
187 * \brief This function tests if the first of two multi-precision integers
188 * of the same size is less than the second.
189 * \note The comparison treats the arguments as unsigned.
190 * \param size The size of the multi-precision integers.
191 * \param xdata The first multi-precision integer.
192 * \param ydata The second multi-precision integer.
193 * \retval 1 if less
194 * \retval 0 if greater or equal
195 */
196BEECRYPTAPI
197int mplt (size_t size, const mpw* xdata, const mpw* ydata);
198
199/*!\fn int mpge(size_t size, const mpw* xdata, const mpw* ydata)
200 * \brief This function tests if the first of two multi-precision integers
201 * of the same size is greater than or equal to the second.
202 * \note The comparison treats the arguments as unsigned.
203 * \param size The size of the multi-precision integers.
204 * \param xdata The first multi-precision integer.
205 * \param ydata The second multi-precision integer.
206 * \retval 1 if greater or equal
207 * \retval 0 if less
208 */
209BEECRYPTAPI
210int mpge (size_t size, const mpw* xdata, const mpw* ydata);
211
212/*!\fn int mple(size_t size, const mpw* xdata, const mpw* ydata)
213 * \brief This function tests if the first of two multi-precision integers
214 * of the same size is less than or equal to the second.
215 * \note The comparison treats the arguments as unsigned.
216 * \param size The size of the multi-precision integers.
217 * \param xdata The first multi-precision integer.
218 * \param ydata The second multi-precision integer.
219 * \retval 1 if less or equal
220 * \retval 0 if greater
221 */
222BEECRYPTAPI
223int mple (size_t size, const mpw* xdata, const mpw* ydata);
224
225/*!\fn int mpeqx(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata)
226 * \brief This function tests if two multi-precision integers of different
227 * size are equal.
228 * \param xsize The size of the first multi-precision integer.
229 * \param xdata The first multi-precision integer.
230 * \param ysize The size of the first multi-precision integer.
231 * \param ydata The second multi-precision integer.
232 * \retval 1 if equal
233 * \retval 0 if not equal
234 */
235BEECRYPTAPI
236int mpeqx(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata);
237
238/*!\fn int mpnex(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata)
239 * \brief This function tests if two multi-precision integers of different
240 * size are equal.
241 * \param xsize The size of the first multi-precision integer.
242 * \param xdata The first multi-precision integer.
243 * \param ysize The size of the first multi-precision integer.
244 * \param ydata The second multi-precision integer.
245 * \retval 1 if equal
246 * \retval 0 if not equal
247*/
248BEECRYPTAPI
249int mpnex(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata);
250
251/*!\fn int mpgtx(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata)
252 * \brief This function tests if the first of two multi-precision integers
253 * of different size is greater than the second.
254 * \note The comparison treats the arguments as unsigned.
255 * \param xsize The size of the first multi-precision integer.
256 * \param xdata The first multi-precision integer.
257 * \param ysize The size of the second multi-precision integer.
258 * \param ydata The second multi-precision integer.
259 * \retval 1 if greater
260 * \retval 0 if less or equal
261 */
262BEECRYPTAPI
263int mpgtx(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata);
264
265/*!\fn int mpltx(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata)
266 * \brief This function tests if the first of two multi-precision integers
267 * of different size is less than the second.
268 * \note The comparison treats the arguments as unsigned.
269 * \param xsize The size of the first multi-precision integer.
270 * \param xdata The first multi-precision integer.
271 * \param ysize The size of the second multi-precision integer.
272 * \param ydata The second multi-precision integer.
273 * \retval 1 if less
274 * \retval 0 if greater or equal
275 */
276BEECRYPTAPI
277int mpltx(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata);
278
279/*!\fn int mpgex(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata)
280 * \brief This function tests if the first of two multi-precision integers
281 * of different size is greater than or equal to the second.
282 * \note The comparison treats the arguments as unsigned.
283 * \param xsize The size of the first multi-precision integer.
284 * \param xdata The first multi-precision integer.
285 * \param ysize The size of the second multi-precision integer.
286 * \param ydata The second multi-precision integer.
287 * \retval 1 if greater or equal
288 * \retval 0 if less
289 */
290BEECRYPTAPI
291int mpgex(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata);
292
293/*!\fn int mplex(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata)
294 * \brief This function tests if the first of two multi-precision integers
295 * of different size is less than or equal to the second.
296 * \note The comparison treats the arguments as unsigned.
297 * \param xsize The size of the first multi-precision integer.
298 * \param xdata The first multi-precision integer.
299 * \param ysize The size of the second multi-precision integer.
300 * \param ydata The second multi-precision integer.
301 * \retval 1 if less or equal
302 * \retval 0 if greater
303 */
304BEECRYPTAPI
305int mplex(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata);
306
307/*!\fn int mpisone(size_t size, const mpw* data)
308 * \brief This functions tests if the value of a multi-precision integer is
309 * equal to one.
310 * \param size The size of the multi-precision integer.
311 * \param data The multi-precision integer data.
312 * \retval 1 if one
313 * \retval 0 if not one
314 */
315BEECRYPTAPI
316int mpisone(size_t size, const mpw* data);
317
318/*!\fn int mpistwo(size_t size, const mpw* data)
319 * \brief This function tests if the value of a multi-precision integer is
320 * equal to two.
321 * \param size The size of the multi-precision integer.
322 * \param data The multi-precision integer data.
323 * \retval 1 if two
324 * \retval 0 if not two
325 */
326BEECRYPTAPI
327int mpistwo(size_t size, const mpw* data);
328
329/*!\fn int mpleone(size_t size, const mpw* data);
330 * \brief This function tests if the value of a multi-precision integer is
331 * less than or equal to one.
332 * \param size The size of the multi-precision integer.
333 * \param data The multi-precision integer data.
334 * \retval 1 if less than or equal to one.
335 * \retval 0 if greater than one.
336 */
337BEECRYPTAPI
338int mpleone(size_t size, const mpw* data);
339
340/*!\fn int mpeqmone(size_t size, const mpw* xdata, const mpw* ydata);
341 * \brief This function tests if multi-precision integer x is equal to y
342 * minus one.
343 * \param size The size of the multi-precision integers.
344 * \param xdata The first multi-precision integer.
345 * \param ydata The second multi-precision integer.
346 * \retval 1 if less than or equal to one.
347 * \retval 0 if greater than one.
348 */
349BEECRYPTAPI
350int mpeqmone(size_t size, const mpw* xdata, const mpw* ydata);
351
352/*!\fn int mpmsbset(size_t size, const mpw* data)
353 * \brief This function tests if the most significant bit of a multi-precision
354 * integer is set.
355 * \param size The size of the multi-precision integer.
356 * \param data The multi-precision integer data.
357 * \retval 1 if set
358 * \retval 0 if not set
359 */
360BEECRYPTAPI
361int mpmsbset(size_t size, const mpw* data);
362
363/*!\fn int mplsbset(size_t size, const mpw* data)
364 * \brief This function tests if the leiast significant bit of a multi-precision
365 * integer is set.
366 * \param size The size of the multi-precision integer.
367 * \param data The multi-precision integer data.
368 * \retval 1 if set
369 * \retval 0 if not set
370 */
371BEECRYPTAPI
372int mplsbset(size_t size, const mpw* data);
373
374/*!\fn void mpsetmsb(size_t size, mpw* data)
375 * \brief This function sets the most significant bit of a multi-precision
376 * integer.
377 * \param size The size of the multi-precision integer.
378 * \param data The multi-precision integer data.
379 */
380BEECRYPTAPI
381void mpsetmsb(size_t size, mpw* data);
382
383/*!\fn void mpsetlsb(size_t size, mpw* data)
384 * \brief This function sets the least significant bit of a multi-precision
385 * integer.
386 * \param size The size of the multi-precision integer.
387 * \param data The multi-precision integer data.
388 */
389BEECRYPTAPI
390void mpsetlsb(size_t size, mpw* data);
391
392/*!\fn void mpclrmsb(size_t size, mpw* data)
393 * \brief This function clears the most significant bit of a multi-precision
394 * integer.
395 * \param size The size of the multi-precision integer.
396 * \param data The multi-precision integer data.
397 */
398BEECRYPTAPI
399void mpclrmsb(size_t size, mpw* data);
400
401/*!\fn void mpclrlsb(size_t size, mpw* data)
402 * \brief This function clears the least significant bit of a multi-precision
403 * integer.
404 * \param size The size of the multi-precision integer.
405 * \param data The multi-precision integer data.
406 */
407BEECRYPTAPI
408void mpclrlsb(size_t size, mpw* data);
409
410/*!\fn mpand(size_t size, mpw* xdata, const mpw* ydata)
411 * \brief This function computes the bit-wise AND of two multi-precision
412 * integers. Modifies xdata.
413 * \param size The size of the multi-precision integers.
414 * \param xdata The multi-precision integer data.
415 * \param ydata The multi-precision integer data.
416 */
417BEECRYPTAPI
418void mpand(size_t size, mpw* xdata, const mpw* ydata);
419
420/*!\fn void mpor(size_t size, mpw* xdata, const mpw* ydata)
421 * \brief This function computes the bit-wise OR of two multi-precision
422 * integers. Modifies xdata.
423 * \param size The size of the multi-precision integer.
424 * \param xdata The multi-precision integer data.
425 * \param ydata The multi-precision integer data.
426 */
427BEECRYPTAPI
428void mpor(size_t size, mpw* xdata, const mpw* ydata);
429
430/*!\fn void mpxor(size_t size, mpw* xdata, const mpw* ydata)
431 * \brief This function computes the bit-wise XOR of two multi-precision
432 * integers. Modifies xdata.
433 * \param size The size of the multi-precision integer.
434 * \param xdata The multi-precision integer data.
435 * \param ydata The multi-precision integer data.
436 */
437BEECRYPTAPI
438void mpxor(size_t size, mpw* xdata, const mpw* ydata);
439
440/*!\fn mpnot(size_t size, mpw* data)
441 * \brief This function flips all bits of a multi-precision integer.
442 * \param size The size of the multi-precision integer.
443 * \param data The multi-precision integer data.
444 */
445BEECRYPTAPI
446void mpnot(size_t size, mpw* data);
447
448/*!\fn void mpsetw(size_t size, mpw* xdata, mpw y)
449 * \brief This function sets the value of a multi-precision integer to the
450 * given word. The given value is copied into the least significant word,
451 * while the most significant words are zeroed.
452 * \param size The size of the multi-precision integer.
453 * \param xdata The first multi-precision integer.
454 * \param y The multi-precision word.
455 */
456BEECRYPTAPI
457void mpsetw(size_t size, mpw* xdata, mpw y);
458
459/*!\fn void mpsetx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata)
460 * \brief This function set the value of the first multi-precision integer
461 * to the second, truncating the most significant words if ysize > xsize, or
462 * zeroing the most significant words if ysize < xsize.
463 * \param xsize The size of the first multi-precision integer.
464 * \param xdata The first multi-precision integer.
465 * \param ysize The size of the second multi-precision integer.
466 * \param ydata The second multi-precision integer.
467 */
468void mpsetx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata);
469
470/*!\fn int mpaddw(size_t size, mpw* xdata, mpw y)
471 * \brief This function adds one word to a multi-precision integer.
472 * The performed operation is in pseudocode: x += y.
473 * \param size The size of the multi-precision integer.
474 * \param xdata The first multi-precision integer.
475 * \param y The multi-precision word.
476 * \return The carry-over value of the operation; this value is either 0 or 1.
477 */
478BEECRYPTAPI
479int mpaddw(size_t size, mpw* xdata, mpw y);
480
481/*!\fn int mpadd(size_t size, mpw* xdata, const mpw* ydata)
482 * \brief This function adds two multi-precision integers of equal size.
483 * The performed operation is in pseudocode: x += y.
484 * \param size The size of the multi-precision integers.
485 * \param xdata The first multi-precision integer.
486 * \param ydata The second multi-precision integer.
487 * \return The carry-over value of the operation; this value is either 0 or 1.
488 */
489BEECRYPTAPI
490int mpadd (size_t size, mpw* xdata, const mpw* ydata);
491
492/*!\fn int mpaddx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata)
493 * \brief This function adds two multi-precision integers of different size.
494 * The performed operation in pseudocode: x += y.
495 * \param xsize The size of the first multi-precision integer.
496 * \param xdata The first multi-precision integer.
497 * \param ysize The size of the second multi-precision integer.
498 * \param ydata The second multi-precision integer.
499 * \return The carry-over value of the operation; this value is either 0 or 1.
500 */
501BEECRYPTAPI
502int mpaddx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata);
503
504/*!\fn int mpsubw(size_t size, mpw* xdata, mpw y)
505 * \brief This function subtracts one word to a multi-precision integer.
506 * The performed operation in pseudocode: x -= y
507 * \param size The size of the multi-precision integers.
508 * \param xdata The first multi-precision integer.
509 * \param y The multi-precision word.
510 * \return The carry-over value of the operation; this value is either 0 or 1.
511 */
512BEECRYPTAPI
513int mpsubw(size_t size, mpw* xdata, mpw y);
514
515/*!\fn int mpsub(size_t size, mpw* xdata, const mpw* ydata)
516 * \brief This function subtracts two multi-precision integers of equal size.
517 * The performed operation in pseudocode: x -= y
518 * \param size The size of the multi-precision integers.
519 * \param xdata The first multi-precision integer.
520 * \param ydata The second multi-precision integer.
521 * \return The carry-over value of the operation; this value is either 0 or 1.
522 */
523BEECRYPTAPI
524int mpsub (size_t size, mpw* xdata, const mpw* ydata);
525
526/*!\fn int mpsubx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata)
527 * \brief This function subtracts two multi-precision integers of different
528 * size. The performed operation in pseudocode: x -= y.
529 * \param xsize The size of the first multi-precision integer.
530 * \param xdata The first multi-precision integer.
531 * \param ysize The size of the second multi-precision integer.
532 * \param ydata The second multi-precision integer.
533 * \return The carry-over value of the operation; this value is either 0 or 1.
534 */
535BEECRYPTAPI
536int mpsubx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata);
537
538BEECRYPTAPI
539int mpmultwo(size_t size, mpw* data);
540
541/*!\fn void mpneg(size_t size, mpw* data)
542 * \brief This function negates a multi-precision integer.
543 * \param size The size of the multi-precision integer.
544 * \param data The multi-precision integer data.
545 */
546BEECRYPTAPI
547void mpneg(size_t size, mpw* data);
548
549/*!\fn size_t mpsize(size_t size, const mpw* data)
550 * \brief This function returns the true size of a multi-precision
551 * integer, after stripping leading zero words.
552 * \param size The size of the multi-precision integer.
553 * \param data The multi-precision integer data.
554 */
555BEECRYPTAPI
556size_t mpsize(size_t size, const mpw* data);
557
558/*!\fn size_t mpbits(size_t size, const mpw* data)
559 * \brief This function returns the number of significant bits
560 * in a multi-precision integer.
561 * \param size The size of the multi-precision integer.
562 * \param data The multi-precision integer data.
563 */
564BEECRYPTAPI
565size_t mpbits(size_t size, const mpw* data);
566
567BEECRYPTAPI
568size_t mpmszcnt(size_t size, const mpw* data);
569
570BEECRYPTAPI
571size_t mplszcnt(size_t size, const mpw* data);
572
573BEECRYPTAPI
574void mplshift(size_t size, mpw* data, size_t count);
575
576BEECRYPTAPI
577void mprshift(size_t size, mpw* data, size_t count);
578
579BEECRYPTAPI
580size_t mprshiftlsz(size_t size, mpw* data);
581
582BEECRYPTAPI
583size_t mpnorm(size_t size, mpw* data);
584
585BEECRYPTAPI
586void mpdivtwo (size_t size, mpw* data);
587
588BEECRYPTAPI
589void mpsdivtwo(size_t size, mpw* data);
590
591/*!\fn mpw mpsetmul(size_t size, mpw* result, const mpw* data, mpw y)
592 * \brief This function performs a multi-precision multiply-setup.
593 *
594 * This function is used in the computation of a full multi-precision
595 * multiplication. By using it we can shave off a few cycles; otherwise we'd
596 * have to zero the least significant half of the result first and use
597 * another call to the slightly slower mpaddmul function.
598 *
599 * \param size The size of multi-precision integer multiplier.
600 * \param result The place where result will be accumulated.
601 * \param data The multi-precision integer multiplier.
602 * \param y The multiplicand.
603 * \return The carry-over multi-precision word.
604 */
605BEECRYPTAPI
606mpw mpsetmul (size_t size, mpw* result, const mpw* data, mpw y);
607
608/*!\fn mpw mpaddmul(size_t size, mpw* result, const mpw* data, mpw y)
609 * \brief This function performs a mult-precision multiply-accumulate.
610 *
611 * This function is used in the computation of a full multi-precision
612 * multiplication. It computes the product-by-one-word and accumulates it with
613 * the previous result.
614 *
615 * \param size The size of multi-precision integer multiplier.
616 * \param result The place where result will be accumulated.
617 * \param data The multi-precision integer multiplier.
618 * \param y The multiplicand.
619 * \retval The carry-over multi-precision word.
620 */
621BEECRYPTAPI
622mpw mpaddmul (size_t size, mpw* result, const mpw* data, mpw y);
623
624/*!\fn void mpaddsqrtrc(size_t size, mpw* result, const mpw* data)
625 * \brief This function is used in the calculation of a multi-precision
626 * squaring.
627 */
628BEECRYPTAPI
629void mpaddsqrtrc(size_t size, mpw* result, const mpw* data);
630
631/*!\fn void mpmul(mpw* result, size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata)
632 * \brief This function computes a full multi-precision product.
633 */
634BEECRYPTAPI
635void mpmul(mpw* result, size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata);
636
637/*!\fn void mpsqr(mpw* result, size_t size, const mpw* data)
638 * \brief This function computes a full multi-precision square.
639 */
640BEECRYPTAPI
641void mpsqr(mpw* result, size_t size, const mpw* data);
642
643BEECRYPTAPI
644void mpgcd_w(size_t size, const mpw* xdata, const mpw* ydata, mpw* result, mpw* wksp);
645
646BEECRYPTAPI
647int mpextgcd_w(size_t size, const mpw* xdata, const mpw* ydata, mpw* result, mpw* wksp);
648
649BEECRYPTAPI
650mpw mppndiv(mpw xhi, mpw xlo, mpw y);
651
652BEECRYPTAPI
653void mpmod (mpw* result, size_t xsize, const mpw* xdata, size_t ysize, const mpw*ydata, mpw* wksp);
654
655BEECRYPTAPI
656void mpndivmod(mpw* result, size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata, mpw* wksp);
657
658/*
659 * Output Routines
660 */
661
662BEECRYPTAPI
663void mpprint(size_t size, const mpw* data);
664
665BEECRYPTAPI
666void mpprintln(size_t size, const mpw* data);
667
668BEECRYPTAPI
669void mpfprint(FILE* f, size_t size, const mpw* data);
670
671BEECRYPTAPI
672void mpfprintln(FILE* f, size_t size, const mpw* data);
673
674/*
675 * Conversion Routines
676 */
677
678BEECRYPTAPI
679int os2ip(mpw* idata, size_t isize, const byte* osdata, size_t ossize);
680
681BEECRYPTAPI
682int i2osp(byte* osdata, size_t ossize, const mpw* idata, size_t isize);
683
684BEECRYPTAPI
685int hs2ip(mpw* idata, size_t isize, const char* hsdata, size_t hssize);
686
687#ifdef __cplusplus
688}
689#endif
690
691#endif
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
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/mpopt.h b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/mpopt.h
new file mode 100755
index 0000000000..7ba66bb5f9
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/mpopt.h
@@ -0,0 +1,205 @@
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 mpopt.h
21 * \brief Multi-precision integer optimization definitions.
22 * \author Bob Deblier <bob.deblier@pandora.be>
23 * \ingroup MP_m
24 */
25
26#ifndef _MPOPT_H
27#define _MPOPT_H
28
29#if WIN32
30# if __MWERKS__ && __INTEL__
31# elif defined(_MSC_VER) && defined(_M_IX86)
32# define ASM_MPZERO
33# define ASM_MPFILL
34# define ASM_MPEVEN
35# define ASM_MPODD
36# define ASM_MPADDW
37# define ASM_MPSUBW
38# define ASM_MPADD
39# define ASM_MPSUB
40# define ASM_MPMULTWO
41# define ASM_MPDIVTWO
42# define ASM_MPSETMUL
43# define ASM_MPADDMUL
44# define ASM_MPADDSQRTRC
45# endif
46#endif
47
48#if defined(__DECC)
49# if defined(OPTIMIZE_ALPHA)
50# define ASM_MPADD
51# define ASM_MPSUB
52# define ASM_MPSETMUL
53# define ASM_MPADDMUL
54# define ASM_MPADDSQRTRC
55# endif
56#endif
57
58#if defined(__GNUC__)
59# if defined(OPTIMIZE_ALPHA)
60# define ASM_MPADD
61# define ASM_MPSUB
62# define ASM_MPSETMUL
63# define ASM_MPADDMUL
64# define ASM_MPADDSQRTRC
65# elif defined(OPTIMIZE_ARM)
66# define ASM_MPSETMUL
67# define ASM_MPADDMUL
68# define ASM_MPADDSQRTRC
69# elif defined(OPTIMIZE_I386) || defined(OPTIMIZE_I486) || defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686)
70# define ASM_MPZERO
71# define ASM_MPFILL
72# define ASM_MPEVEN
73# define ASM_MPODD
74# define ASM_MPADD
75# define ASM_MPADDW
76# define ASM_MPSUB
77# define ASM_MPSUBW
78# define ASM_MPMULTWO
79# define ASM_MPDIVTWO
80# define ASM_MPSETMUL
81# define ASM_MPADDMUL
82# define ASM_MPADDSQRTRC
83# define ASM_MPPNDIV
84# elif defined(OPTIMIZE_IA64)
85# define ASM_MPZERO
86# define ASM_MPCOPY
87# define ASM_MPADD
88# define ASM_MPSUB
89# define ASM_MPMULTWO
90# define ASM_MPSETMUL
91# define ASM_MPADDMUL
92# elif defined(OPTIMIZE_M68K)
93# define ASM_MPADD
94# define ASM_MPSUB
95# define ASM_MPSETMUL
96# define ASM_MPADDMUL
97# define ASM_MPADDSQRTRC
98# elif defined(OPTIMIZE_POWERPC) || defined(OPTIMIZE_POWERPC64)
99# define ASM_MPSETMUL
100# define ASM_MPADD
101# define ASM_MPADDW
102# define ASM_MPSUB
103# define ASM_MPSUBW
104# define ASM_MPMULTWO
105# define ASM_MPADDMUL
106# define ASM_MPADDSQRTRC
107# elif defined(OPTIMIZE_S390X)
108# define ASM_MPSETMUL
109# define ASM_MPADDMUL
110# define ASM_MPADDSQRTRC
111# elif defined(OPTIMIZE_SPARCV8)
112# define ASM_MPSETMUL
113# define ASM_MPADDMUL
114# define ASM_MPADDSQRTRC
115# elif defined(OPTIMIZE_SPARCV8PLUS)
116# define ASM_MPADDW
117# define ASM_MPSUBW
118# define ASM_MPADD
119# define ASM_MPSUB
120# define ASM_MPMULTWO
121# define ASM_MPSETMUL
122# define ASM_MPADDMUL
123# define ASM_MPADDSQRTRC
124# elif defined(OPTIMIZE_X86_64)
125# define ASM_MPZERO
126# define ASM_MPFILL
127# define ASM_MPEVEN
128# define ASM_MPODD
129# define ASM_MPADD
130# define ASM_MPADDW
131# define ASM_MPSUB
132# define ASM_MPSUBW
133# define ASM_MPDIVTWO
134# define ASM_MPMULTWO
135# define ASM_MPSETMUL
136# define ASM_MPADDMUL
137# define ASM_MPADDSQRTRC
138# endif
139#endif
140
141#if defined(__IBMC__)
142# if defined(OPTIMIZE_POWERPC) || defined(OPTIMIZE_POWERPC64)
143# define ASM_MPSETMUL
144# define ASM_MPADDW
145# define ASM_MPSUBW
146# define ASM_MPADD
147# define ASM_MPSUB
148# define ASM_MPMULTWO
149# define ASM_MPADDMUL
150# define ASM_MPADDSQRTRC
151# endif
152#endif
153
154#if defined(__INTEL_COMPILER)
155# if defined(OPTIMIZE_I386) || defined(OPTIMIZE_I486) || defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686)
156# define ASM_MPZERO
157# define ASM_MPFILL
158# define ASM_MPEVEN
159# define ASM_MPODD
160# define ASM_MPADDW
161# define ASM_MPSUBW
162# define ASM_MPADD
163# define ASM_MPSUB
164# define ASM_MPMULTWO
165# define ASM_MPDIVTWO
166# define ASM_MPSETMUL
167# define ASM_MPADDMUL
168# define ASM_MPADDSQRTRC
169# define ASM_MPPNDIV
170# endif
171#endif
172
173#if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
174# if defined(OPTIMIZE_SPARCV8)
175# define ASM_MPSETMUL
176# define ASM_MPADDMUL
177# define ASM_MPADDSQRTRC
178# elif defined(OPTIMIZE_SPARCV8PLUS)
179# define ASM_MPADDW
180# define ASM_MPSUBW
181# define ASM_MPADD
182# define ASM_MPSUB
183# define ASM_MPMULTWO
184# define ASM_MPSETMUL
185# define ASM_MPADDMUL
186# define ASM_MPADDSQRTRC
187# endif
188#endif
189
190#undef ASM_MPZERO
191#undef ASM_MPFILL
192#undef ASM_MPEVEN
193#undef ASM_MPODD
194#undef ASM_MPADD
195#undef ASM_MPADDW
196#undef ASM_MPSUB
197#undef ASM_MPSUBW
198#undef ASM_MPMULTWO
199#undef ASM_MPDIVTWO
200#undef ASM_MPSETMUL
201#undef ASM_MPADDMUL
202#undef ASM_MPADDSQRTRC
203#undef ASM_MPPNDIV
204
205#endif
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/rsa.h b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/rsa.h
new file mode 100755
index 0000000000..dbb0e45412
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/rsa.h
@@ -0,0 +1,121 @@
1/*
2 * Copyright (c) 2000, 2002 Virtual Unlimited B.V.
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 rsa.h
21 * \brief RSA algorithm.
22 * \author Bob Deblier <bob.deblier@pandora.be>
23 * \ingroup IF_m IF_rsa_m
24 */
25
26#ifndef _RSA_H
27#define _RSA_H
28
29#include "beecrypt/rsakp.h"
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35/*!\fn int rsapub(const mpbarrett* n, const mpnumber* e, const mpnumber* m, mpnumber* c)
36 * \brief This function performs a raw RSA public key operation.
37 *
38 * This function can be used for encryption and verifying.
39 *
40 * It performs the following operation:
41 * \li \f$c=m^{e}\ \textrm{mod}\ n\f$
42 *
43 * \param n The RSA modulus.
44 * \param e The RSA public exponent.
45 * \param m The message.
46 * \param c The ciphertext.
47 * \retval 0 on success.
48 * \retval -1 on failure.
49 */
50BEECRYPTAPI
51int rsapub(const mpbarrett* n, const mpnumber* e,
52 const mpnumber* m, mpnumber* c);
53
54/*!\fn int rsapri(const mpbarrett* n, const mpnumber* d, const mpnumber* c, mpnumber* m)
55 * \brief This function performs a raw RSA private key operation.
56 *
57 * This function can be used for decryption and signing.
58 *
59 * It performs the operation:
60 * \li \f$m=c^{d}\ \textrm{mod}\ n\f$
61 *
62 * \param n The RSA modulus.
63 * \param d The RSA private exponent.
64 * \param c The ciphertext.
65 * \param m The message.
66 * \retval 0 on success.
67 * \retval -1 on failure.
68 */
69BEECRYPTAPI
70int rsapri(const mpbarrett* n, const mpnumber* d,
71 const mpnumber* c, mpnumber* m);
72
73/*!\fn int rsapricrt(const mpbarrett* n, const mpbarrett* p, const mpbarrett* q, const mpnumber* dp, const mpnumber* dq, const mpnumber* qi, const mpnumber* c, mpnumber* m)
74 *
75 * \brief This function performs a raw RSA private key operation, with
76 * application of the Chinese Remainder Theorem.
77 *
78 * It performs the operation:
79 * \li \f$j_1=c^{dp}\ \textrm{mod}\ p\f$
80 * \li \f$j_2=c^{dq}\ \textrm{mod}\ q\f$
81 * \li \f$h=qi \cdot (j_1-j_2)\ \textrm{mod}\ p\f$
82 * \li \f$m=j_2+hq\f$
83 *
84 * \param n The RSA modulus.
85 * \param p The first RSA prime factor.
86 * \param q The second RSA prime factor.
87 * \param dp
88 * \param dq
89 * \param qi
90 * \param c The ciphertext.
91 * \param m The message.
92 * \retval 0 on success.
93 * \retval -1 on failure.
94 */
95BEECRYPTAPI
96int rsapricrt(const mpbarrett* n, const mpbarrett* p, const mpbarrett* q,
97 const mpnumber* dp, const mpnumber* dq, const mpnumber* qi,
98 const mpnumber* c, mpnumber* m);
99
100/*!\fn int rsavrfy(const mpbarrett* n, const mpnumber* e, const mpnumber* m, const mpnumber* c)
101 * \brief This function performs a raw RSA verification.
102 *
103 * It verifies if ciphertext \a c was encrypted from cleartext \a m
104 * with the private key matching the given public key \a (n, e).
105 *
106 * \param n The RSA modulus.
107 * \param e The RSA public exponent.
108 * \param m The cleartext message.
109 * \param c The ciphertext message.
110 * \retval 1 on success.
111 * \retval 0 on failure.
112 */
113BEECRYPTAPI
114int rsavrfy(const mpbarrett* n, const mpnumber* e,
115 const mpnumber* m, const mpnumber* c);
116
117#ifdef __cplusplus
118}
119#endif
120
121#endif
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/sha1.c b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/sha1.c
new file mode 100755
index 0000000000..fe7c2cd8b4
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/sha1.c
@@ -0,0 +1,329 @@
1/*
2 * Copyright (c) 1997, 1998, 1999, 2000, 2001 Virtual Unlimited B.V.
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 sha1.c
21 * \brief SHA-1 hash function, as specified by NIST FIPS 180-1.
22 * \author Bob Deblier <bob.deblier@pandora.be>
23 * \ingroup HASH_m HASH_sha1_m
24 */
25
26#define BEECRYPT_DLL_EXPORT
27
28#if HAVE_CONFIG_H
29# include "config.h"
30#endif
31
32#include "beecrypt/sha1.h"
33
34#if HAVE_ENDIAN_H && HAVE_ASM_BYTEORDER_H
35# include <endian.h>
36#endif
37
38#include "beecrypt/endianness.h"
39
40/*!\addtogroup HASH_sha1_m
41 * \{
42 */
43
44static const uint32_t k[4] = { 0x5a827999U, 0x6ed9eba1U, 0x8f1bbcdcU, 0xca62c1d6U };
45
46static const uint32_t hinit[5] = { 0x67452301U, 0xefcdab89U, 0x98badcfeU, 0x10325476U, 0xc3d2e1f0U };
47
48const hashFunction sha1 = {
49 "SHA-1",
50 sizeof(sha1Param),
51 64,
52 20,
53 (hashFunctionReset) sha1Reset,
54 (hashFunctionUpdate) sha1Update,
55 (hashFunctionDigest) sha1Digest
56};
57
58int sha1Reset(register sha1Param* p)
59{
60 memcpy(p->h, hinit, 5 * sizeof(uint32_t));
61 memset(p->data, 0, 80 * sizeof(uint32_t));
62 #if (MP_WBITS == 64)
63 mpzero(1, p->length);
64 #elif (MP_WBITS == 32)
65 mpzero(2, p->length);
66 #else
67 # error
68 #endif
69 p->offset = 0;
70 return 0;
71}
72
73#define SUBROUND1(a, b, c, d, e, w, k) \
74 e = ROTL32(a, 5) + ((b&(c^d))^d) + e + w + k; \
75 b = ROTR32(b, 2)
76#define SUBROUND2(a, b, c, d, e, w, k) \
77 e = ROTL32(a, 5) + (b^c^d) + e + w + k; \
78 b = ROTR32(b, 2)
79#define SUBROUND3(a, b, c, d, e, w, k) \
80 e = ROTL32(a, 5) + (((b|c)&d)|(b&c)) + e + w + k; \
81 b = ROTR32(b, 2)
82#define SUBROUND4(a, b, c, d, e, w, k) \
83 e = ROTL32(a, 5) + (b^c^d) + e + w + k; \
84 b = ROTR32(b, 2)
85
86#ifndef ASM_SHA1PROCESS
87void sha1Process(sha1Param* sp)
88{
89 register uint32_t a, b, c, d, e;
90 register uint32_t *w;
91 register byte t;
92
93 #if WORDS_BIGENDIAN
94 w = sp->data + 16;
95 #else
96 w = sp->data;
97 t = 16;
98 while (t--)
99 {
100 register uint32_t temp = swapu32(*w);
101 *(w++) = temp;
102 }
103 #endif
104
105 t = 64;
106 while (t--)
107 {
108 register uint32_t temp = w[-3] ^ w[-8] ^ w[-14] ^ w[-16];
109 *(w++) = ROTL32(temp, 1);
110 }
111
112 w = sp->data;
113
114 a = sp->h[0]; b = sp->h[1]; c = sp->h[2]; d = sp->h[3]; e = sp->h[4];
115
116 SUBROUND1(a,b,c,d,e,w[ 0],k[0]);
117 SUBROUND1(e,a,b,c,d,w[ 1],k[0]);
118 SUBROUND1(d,e,a,b,c,w[ 2],k[0]);
119 SUBROUND1(c,d,e,a,b,w[ 3],k[0]);
120 SUBROUND1(b,c,d,e,a,w[ 4],k[0]);
121 SUBROUND1(a,b,c,d,e,w[ 5],k[0]);
122 SUBROUND1(e,a,b,c,d,w[ 6],k[0]);
123 SUBROUND1(d,e,a,b,c,w[ 7],k[0]);
124 SUBROUND1(c,d,e,a,b,w[ 8],k[0]);
125 SUBROUND1(b,c,d,e,a,w[ 9],k[0]);
126 SUBROUND1(a,b,c,d,e,w[10],k[0]);
127 SUBROUND1(e,a,b,c,d,w[11],k[0]);
128 SUBROUND1(d,e,a,b,c,w[12],k[0]);
129 SUBROUND1(c,d,e,a,b,w[13],k[0]);
130 SUBROUND1(b,c,d,e,a,w[14],k[0]);
131 SUBROUND1(a,b,c,d,e,w[15],k[0]);
132 SUBROUND1(e,a,b,c,d,w[16],k[0]);
133 SUBROUND1(d,e,a,b,c,w[17],k[0]);
134 SUBROUND1(c,d,e,a,b,w[18],k[0]);
135 SUBROUND1(b,c,d,e,a,w[19],k[0]);
136
137 SUBROUND2(a,b,c,d,e,w[20],k[1]);
138 SUBROUND2(e,a,b,c,d,w[21],k[1]);
139 SUBROUND2(d,e,a,b,c,w[22],k[1]);
140 SUBROUND2(c,d,e,a,b,w[23],k[1]);
141 SUBROUND2(b,c,d,e,a,w[24],k[1]);
142 SUBROUND2(a,b,c,d,e,w[25],k[1]);
143 SUBROUND2(e,a,b,c,d,w[26],k[1]);
144 SUBROUND2(d,e,a,b,c,w[27],k[1]);
145 SUBROUND2(c,d,e,a,b,w[28],k[1]);
146 SUBROUND2(b,c,d,e,a,w[29],k[1]);
147 SUBROUND2(a,b,c,d,e,w[30],k[1]);
148 SUBROUND2(e,a,b,c,d,w[31],k[1]);
149 SUBROUND2(d,e,a,b,c,w[32],k[1]);
150 SUBROUND2(c,d,e,a,b,w[33],k[1]);
151 SUBROUND2(b,c,d,e,a,w[34],k[1]);
152 SUBROUND2(a,b,c,d,e,w[35],k[1]);
153 SUBROUND2(e,a,b,c,d,w[36],k[1]);
154 SUBROUND2(d,e,a,b,c,w[37],k[1]);
155 SUBROUND2(c,d,e,a,b,w[38],k[1]);
156 SUBROUND2(b,c,d,e,a,w[39],k[1]);
157
158 SUBROUND3(a,b,c,d,e,w[40],k[2]);
159 SUBROUND3(e,a,b,c,d,w[41],k[2]);
160 SUBROUND3(d,e,a,b,c,w[42],k[2]);
161 SUBROUND3(c,d,e,a,b,w[43],k[2]);
162 SUBROUND3(b,c,d,e,a,w[44],k[2]);
163 SUBROUND3(a,b,c,d,e,w[45],k[2]);
164 SUBROUND3(e,a,b,c,d,w[46],k[2]);
165 SUBROUND3(d,e,a,b,c,w[47],k[2]);
166 SUBROUND3(c,d,e,a,b,w[48],k[2]);
167 SUBROUND3(b,c,d,e,a,w[49],k[2]);
168 SUBROUND3(a,b,c,d,e,w[50],k[2]);
169 SUBROUND3(e,a,b,c,d,w[51],k[2]);
170 SUBROUND3(d,e,a,b,c,w[52],k[2]);
171 SUBROUND3(c,d,e,a,b,w[53],k[2]);
172 SUBROUND3(b,c,d,e,a,w[54],k[2]);
173 SUBROUND3(a,b,c,d,e,w[55],k[2]);
174 SUBROUND3(e,a,b,c,d,w[56],k[2]);
175 SUBROUND3(d,e,a,b,c,w[57],k[2]);
176 SUBROUND3(c,d,e,a,b,w[58],k[2]);
177 SUBROUND3(b,c,d,e,a,w[59],k[2]);
178
179 SUBROUND4(a,b,c,d,e,w[60],k[3]);
180 SUBROUND4(e,a,b,c,d,w[61],k[3]);
181 SUBROUND4(d,e,a,b,c,w[62],k[3]);
182 SUBROUND4(c,d,e,a,b,w[63],k[3]);
183 SUBROUND4(b,c,d,e,a,w[64],k[3]);
184 SUBROUND4(a,b,c,d,e,w[65],k[3]);
185 SUBROUND4(e,a,b,c,d,w[66],k[3]);
186 SUBROUND4(d,e,a,b,c,w[67],k[3]);
187 SUBROUND4(c,d,e,a,b,w[68],k[3]);
188 SUBROUND4(b,c,d,e,a,w[69],k[3]);
189 SUBROUND4(a,b,c,d,e,w[70],k[3]);
190 SUBROUND4(e,a,b,c,d,w[71],k[3]);
191 SUBROUND4(d,e,a,b,c,w[72],k[3]);
192 SUBROUND4(c,d,e,a,b,w[73],k[3]);
193 SUBROUND4(b,c,d,e,a,w[74],k[3]);
194 SUBROUND4(a,b,c,d,e,w[75],k[3]);
195 SUBROUND4(e,a,b,c,d,w[76],k[3]);
196 SUBROUND4(d,e,a,b,c,w[77],k[3]);
197 SUBROUND4(c,d,e,a,b,w[78],k[3]);
198 SUBROUND4(b,c,d,e,a,w[79],k[3]);
199
200 sp->h[0] += a;
201 sp->h[1] += b;
202 sp->h[2] += c;
203 sp->h[3] += d;
204 sp->h[4] += e;
205}
206#endif
207
208int sha1Update(sha1Param* sp, const byte* data, size_t size)
209{
210 register uint32_t proclength;
211
212 #if (MP_WBITS == 64)
213 mpw add[1];
214 mpsetw(1, add, size);
215 mplshift(1, add, 3);
216 mpadd(1, sp->length, add);
217 #elif (MP_WBITS == 32)
218 mpw add[2];
219 mpsetw(2, add, size);
220 mplshift(2, add, 3);
221 mpadd(2, sp->length, add);
222 #else
223 # error
224 #endif
225
226 while (size > 0)
227 {
228 proclength = ((sp->offset + size) > 64U) ? (64U - sp->offset) : size;
229 memcpy(((byte *) sp->data) + sp->offset, data, proclength);
230 size -= proclength;
231 data += proclength;
232 sp->offset += proclength;
233
234 if (sp->offset == 64)
235 {
236 sha1Process(sp);
237 sp->offset = 0;
238 }
239 }
240 return 0;
241}
242
243static void sha1Finish(sha1Param* sp)
244{
245 register byte *ptr = ((byte *) sp->data) + sp->offset++;
246
247 *(ptr++) = 0x80;
248
249 if (sp->offset > 56)
250 {
251 while (sp->offset++ < 64)
252 *(ptr++) = 0;
253
254 sha1Process(sp);
255 sp->offset = 0;
256 }
257
258 ptr = ((byte*) sp->data) + sp->offset;
259 while (sp->offset++ < 56)
260 *(ptr++) = 0;
261
262 #if WORDS_BIGENDIAN
263 memcpy(ptr, sp->length, 8);
264 #else
265 # if (MP_WBITS == 64)
266 ptr[0] = (byte)(sp->length[0] >> 56);
267 ptr[1] = (byte)(sp->length[0] >> 48);
268 ptr[2] = (byte)(sp->length[0] >> 40);
269 ptr[3] = (byte)(sp->length[0] >> 32);
270 ptr[4] = (byte)(sp->length[0] >> 24);
271 ptr[5] = (byte)(sp->length[0] >> 16);
272 ptr[6] = (byte)(sp->length[0] >> 8);
273 ptr[7] = (byte)(sp->length[0] );
274 #elif (MP_WBITS == 32)
275 ptr[0] = (byte)(sp->length[0] >> 24);
276 ptr[1] = (byte)(sp->length[0] >> 16);
277 ptr[2] = (byte)(sp->length[0] >> 8);
278 ptr[3] = (byte)(sp->length[0] );
279 ptr[4] = (byte)(sp->length[1] >> 24);
280 ptr[5] = (byte)(sp->length[1] >> 16);
281 ptr[6] = (byte)(sp->length[1] >> 8);
282 ptr[7] = (byte)(sp->length[1] );
283 # else
284 # error
285 # endif
286 #endif
287
288 sha1Process(sp);
289
290 sp->offset = 0;
291}
292
293int sha1Digest(sha1Param* sp, byte* data)
294{
295 sha1Finish(sp);
296
297 #if WORDS_BIGENDIAN
298 memcpy(data, sp->h, 20);
299 #else
300 /* encode 5 integers big-endian style */
301 data[ 0] = (byte)(sp->h[0] >> 24);
302 data[ 1] = (byte)(sp->h[0] >> 16);
303 data[ 2] = (byte)(sp->h[0] >> 8);
304 data[ 3] = (byte)(sp->h[0] >> 0);
305 data[ 4] = (byte)(sp->h[1] >> 24);
306 data[ 5] = (byte)(sp->h[1] >> 16);
307 data[ 6] = (byte)(sp->h[1] >> 8);
308 data[ 7] = (byte)(sp->h[1] >> 0);
309 data[ 8] = (byte)(sp->h[2] >> 24);
310 data[ 9] = (byte)(sp->h[2] >> 16);
311 data[10] = (byte)(sp->h[2] >> 8);
312 data[11] = (byte)(sp->h[2] >> 0);
313 data[12] = (byte)(sp->h[3] >> 24);
314 data[13] = (byte)(sp->h[3] >> 16);
315 data[14] = (byte)(sp->h[3] >> 8);
316 data[15] = (byte)(sp->h[3] >> 0);
317 data[16] = (byte)(sp->h[4] >> 24);
318 data[17] = (byte)(sp->h[4] >> 16);
319 data[18] = (byte)(sp->h[4] >> 8);
320 data[19] = (byte)(sp->h[4] >> 0);
321 #endif
322
323 sha1Reset(sp);
324
325 return 0;
326}
327
328/*!\}
329 */
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/sha1.h b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/sha1.h
new file mode 100755
index 0000000000..a35c917fdd
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/sha1.h
@@ -0,0 +1,120 @@
1/*
2 * Copyright (c) 1997, 1998, 1999, 2000, 2002 Virtual Unlimited B.V.
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 sha1.h
21 * \brief SHA-1 hash function, headers.
22 * \author Bob Deblier <bob.deblier@pandora.be>
23 * \ingroup HASH_m HASH_sha1_m
24 */
25
26#ifndef _SHA1_H
27#define _SHA1_H
28
29#include "beecrypt/beecrypt.h"
30#include "beecrypt/sha1opt.h"
31
32/*!\brief Holds all the parameters necessary for the SHA-1 algorithm.
33 * \ingroup HASH_sha1_m
34 */
35#ifdef __cplusplus
36struct BEECRYPTAPI sha1Param
37#else
38struct _sha1Param
39#endif
40{
41 /*!\var h
42 */
43 uint32_t h[5];
44 /*!\var data
45 */
46 uint32_t data[80];
47 /*!\var length
48 * \brief Multi-precision integer counter for the bits that have been
49 * processed so far.
50 */
51 #if (MP_WBITS == 64)
52 mpw length[1];
53 #elif (MP_WBITS == 32)
54 mpw length[2];
55 #else
56 # error
57 #endif
58 /*!\var offset
59 * \brief Offset into \a data; points to the place where new data will be
60 * copied before it is processed.
61 */
62 uint32_t offset;
63};
64
65#ifndef __cplusplus
66typedef struct _sha1Param sha1Param;
67#endif
68
69#ifdef __cplusplus
70extern "C" {
71#endif
72
73/*!\var sha1
74 * \brief Holds the full API description of the SHA-1 algorithm.
75 */
76extern BEECRYPTAPI const hashFunction sha1;
77
78/*!\fn void sha1Process(sha1Param* sp)
79 * \brief This function performs the core of the SHA-1 hash algorithm; it
80 * processes a block of 64 bytes.
81 * \param sp The hash function's parameter block.
82 */
83BEECRYPTAPI
84void sha1Process(sha1Param* sp);
85
86/*!\fn int sha1Reset(sha1Param* sp)
87 * \brief This function resets the parameter block so that it's ready for a
88 * new hash.
89 * \param sp The hash function's parameter block.
90 * \retval 0 on success.
91 */
92BEECRYPTAPI
93int sha1Reset (sha1Param* sp);
94
95/*!\fn int sha1Update(sha1Param* sp, const byte* data, size_t size)
96 * \brief This function should be used to pass successive blocks of data
97 * to be hashed.
98 * \param sp The hash function's parameter block.
99 * \param data
100 * \param size
101 * \retval 0 on success.
102 */
103BEECRYPTAPI
104int sha1Update (sha1Param* sp, const byte* data, size_t size);
105
106/*!\fn int sha1Digest(sha1Param* sp, byte* digest)
107 * \brief This function finishes the current hash computation and copies
108 * the digest value into \a digest.
109 * \param sp The hash function's parameter block.
110 * \param digest The place to store the 20-byte digest.
111 * \retval 0 on success.
112 */
113BEECRYPTAPI
114int sha1Digest (sha1Param* sp, byte* digest);
115
116#ifdef __cplusplus
117}
118#endif
119
120#endif
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/sha1opt.h b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/sha1opt.h
new file mode 100755
index 0000000000..62ea87718f
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/sha1opt.h
@@ -0,0 +1,65 @@
1/*
2 * sha1opt.h
3 *
4 * SHA-1 assembler-optimized routines, header
5 *
6 * Copyright (c) 2000, 2003 Virtual Unlimited B.V.
7 *
8 * Author: Bob Deblier <bob.deblier@pandora.be>
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 */
25
26#ifndef _SHA1OPT_H
27#define _SHA1OPT_H
28
29#include "beecrypt/beecrypt.h"
30#include "beecrypt/sha1.h"
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36#if WIN32
37# if defined(_MSC_VER) && defined(_M_IX86)
38# define ASM_SHA1PROCESS
39# elif __INTEL__ && __MWERKS__
40# define ASM_SHA1PROCESS
41# endif
42#endif
43
44#if defined(__GNUC__)
45# if defined(OPTIMIZE_I386) || defined(OPTIMIZE_I486) || defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686)
46# define ASM_SHA1PROCESS
47# endif
48#endif
49
50#if defined(__INTEL_COMPILER)
51# if defined(OPTIMIZE_I386) || defined(OPTIMIZE_I486) || defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686)
52# define ASM_SHA1PROCESS
53# endif
54#endif
55
56#if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
57#endif
58
59#undef ASM_SHA1PROCESS
60
61#ifdef __cplusplus
62}
63#endif
64
65#endif
diff --git a/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/win.h b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/win.h
new file mode 100755
index 0000000000..d578085c29
--- /dev/null
+++ b/utils/zenutils/libraries/beecrypt-4.1.2/beecrypt/win.h
@@ -0,0 +1,139 @@
1/*
2 * Copyright (c) 2000, 2001, 2002 Virtual Unlimited B.V.
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 win.h
21 * \brief BeeCrypt API, windows headers.
22 * \author Bob Deblier <bob.deblier@pandora.be>
23 */
24
25#ifndef _BEECRYPT_WIN_H
26#define _BEECRYPT_WIN_H
27
28#define _REENTRANT
29
30#if !defined(_WIN32_WINNT)
31#define _WIN32_WINNT 0x0400
32#endif
33
34#include <windows.h>
35
36#if __MWERKS__
37# if __INTEL__
38# define WORDS_BIGENDIAN 0
39# else
40# error Unknown CPU type in MetroWerks CodeWarrior
41# endif
42#elif defined(_MSC_VER)
43# if defined(_M_IX86)
44# define WORDS_BIGENDIAN 0
45# define ROTL32(x, s) _rotl(x, s)
46# define ROTR32(x, s) _rotr(x, s)
47# else
48# error Unknown CPU type in Microsoft Visual C
49# endif
50#else
51# error Unknown compiler for WIN32
52#endif
53
54#if defined(_MSC_VER) || __MWERKS__
55#include <stdio.h>
56#include <stdlib.h>
57#include <string.h>
58
59#define HAVE_ERRNO_H 1
60#define HAVE_CTYPE_H 1
61#define HAVE_FCNTL_H 1
62#define HAVE_TIME_H 1
63
64#define HAVE_SYS_TYPES_H 0
65#define HAVE_SYS_TIME_H 0
66
67#define HAVE_THREAD_H 0
68#define HAVE_SYNCH_H 0
69#define HAVE_PTHREAD_H 0
70#define HAVE_SEMAPHORE_H 0
71
72#define HAVE_TERMIO_H 0
73#define HAVE_SYS_AUDIOIO_H 0
74#define HAVE_SYS_IOCTL_H 0
75#define HAVE_SYS_SOUNDCARD_H 0
76
77#define HAVE_GETTIMEOFDAY 0
78#define HAVE_GETHRTIME 0
79
80#define HAVE_DEV_TTY 0
81#define HAVE_DEV_AUDIO 0
82#define HAVE_DEV_DSP 0
83#define HAVE_DEV_RANDOM 0
84#define HAVE_DEV_URANDOM 0
85#define HAVE_DEV_TTY 0
86
87#else
88#error Not set up for this compiler
89#endif
90
91#if __MWERKS__
92#define HAVE_SYS_STAT_H 0
93
94#define HAVE_LONG_LONG 1
95#define HAVE_UNSIGNED_LONG_LONG 1
96
97#define HAVE_64_BIT_INT 1
98#define HAVE_64_BIT_UINT 1
99
100typedef char int8_t;
101typedef short int16_t;
102typedef long int32_t;
103typedef long long int64_t;
104
105typedef unsigned char uint8_t;
106typedef unsigned short uint16_t;
107typedef unsigned long uint32_t;
108typedef unsigned long long uint64_t;
109
110#elif defined(_MSC_VER)
111#define HAVE_SYS_STAT_H 1
112
113#define HAVE_LONG_LONG 0
114#define HAVE_UNSIGNED_LONG_LONG 0
115
116#define HAVE_64_BIT_INT 1
117#define HAVE_64_BIT_UINT 1
118
119typedef signed char int8_t;
120typedef signed short int16_t;
121typedef signed int int32_t;
122typedef signed __int64 int64_t;
123
124typedef unsigned char uint8_t;
125typedef unsigned short uint16_t;
126typedef unsigned int uint32_t;
127typedef unsigned __int64 uint64_t;
128
129typedef long off_t;
130
131#endif
132
133#define MP_WBITS 32U
134
135typedef HANDLE bc_cond_t;
136typedef HANDLE bc_mutex_t;
137typedef HANDLE bc_thread_t;
138
139#endif