diff options
author | Paul Nasrat <pnasrat@redhat.com> | 2007-02-16 16:20:02 +0000 |
---|---|---|
committer | Paul Nasrat <pnasrat@redhat.com> | 2007-02-16 16:20:02 +0000 |
commit | 1302fd60fc65fc3bd71c301c6d06e3505cdcf95e (patch) | |
tree | c4ffa89da116eae15496f5ded4f08d0457b914a1 | |
parent | 29f8a24e89a3daaa7b325faa5bcb44cd0c2cb9b8 (diff) | |
download | librpm-tizen-1302fd60fc65fc3bd71c301c6d06e3505cdcf95e.tar.gz librpm-tizen-1302fd60fc65fc3bd71c301c6d06e3505cdcf95e.tar.bz2 librpm-tizen-1302fd60fc65fc3bd71c301c6d06e3505cdcf95e.zip |
Remove internal beecrypt
507 files changed, 0 insertions, 65759 deletions
diff --git a/beecrypt/.cvsignore b/beecrypt/.cvsignore deleted file mode 100644 index 488d91980..000000000 --- a/beecrypt/.cvsignore +++ /dev/null @@ -1,42 +0,0 @@ -.deps -.depend -.depend-done -.libs -Doxyfile -Makefile -Makefile.in -aclocal.m4 -missing -mkinstalldirs -apidocs -autom4te* -gnu.h -beecrypt.spec -beecrypt-*.tar.gz -config.h -config.h.in -config.cache -config.guess -config.log -config.m4 -config.status -config.sub -configure -depcomp -doxygen -libtool -listobjs -ltconfig -ltmain.sh -aesopt.c -blowfishopt.c -mpopt.c -sha1opt.c -*.la -*.lcd -*.lo -*.o -*.s -stamp-h -stamp-h1 -stamp-h.in diff --git a/beecrypt/.splintrc b/beecrypt/.splintrc deleted file mode 100644 index f1dbea662..000000000 --- a/beecrypt/.splintrc +++ /dev/null @@ -1,113 +0,0 @@ --I. -I/usr/lib/gcc-lib/i386-redhat-linux/3.1/include -DHAVE_CONFIG_H -D_GNU_SOURCE -DHAVE_DEV_DSP -DHAVE_SYS_SOUNDCARD - -+partial -+forcehints - --warnposix - -+unixlib - --unrecogcomments # XXX ignore doxygen markings - -+strict # lclint level - -# --- in progress -+likelybounds --bufferoverflowhigh - --aliasunique --bitwisesigned --boolops --branchstate --castfcnptr --compdef --compdestroy --compmempass --evalorder --globs --globstate --infloops --infloopsuncon # 2 --internalglobs --mayaliasunique --modfilesys --moduncon # 22 --mustfreefresh --mustfreeonly --namechecks --noeffect --noeffectuncon # 12 --nullderef --nullpass # 14 --nullptrarith --nullret # 2 --nullstate # 1 --paramuse --protoparammatch # 7 -+ptrnegate --retalias --retvalint --retvalother --shadow --shiftimplementation --shiftnegative --sizeoftype --type --unreachable --usedef --usereleased - --dependenttrans --immediatetrans --observertrans --readonlytrans --statictrans --temptrans --unqualifiedtrans # 11 - --looploopbreak --looploopcontinue --loopswitchbreak --switchswitchbreak - --declundef --exportheader --exportheadervar --exportlocal --fcnuse --typeuse - --elseifcomplete --whileempty - -# --- not-yet at strict level --exportconst # 3 --exportfcn # 308 --exporttype # 53 --exportvar # 14 --protoparamname # 826 - --ansi-reserved-internal # goofy - --ptrarith # 212 - --mustdefine # 64 --strictops # 23 - --impcheckedstrictglobs --impcheckedstrictstatics --strictbranchstate - --forblock # 15 --ifblock # 455 --whileblock # 25 --sys-dir-errors # 1296 - -# --- not-yet at checks level --predboolptr # 88 --ansi-reserved # goofy - -# --- not-yet at standard level -+boolint # 329 -+charint # 3 -+matchanyintegral # 573 diff --git a/beecrypt/AUTHORS b/beecrypt/AUTHORS deleted file mode 100644 index 878abf5a3..000000000 --- a/beecrypt/AUTHORS +++ /dev/null @@ -1,11 +0,0 @@ -BeeCrypt Cryptograpy Library: - -Bob Deblier <bob.deblier@pandora.be> - -C++ Interface: - -Bob Deblier <bob.deblier@pandora.be> - -Python Interface: - -Jeff Johson <jbj@redhat.com> diff --git a/beecrypt/BENCHMARKS b/beecrypt/BENCHMARKS deleted file mode 100644 index efdd50996..000000000 --- a/beecrypt/BENCHMARKS +++ /dev/null @@ -1,50 +0,0 @@ -Note: timings are average values and may vary under different conditions, -i.e. the amount of free memory, swapped memory, amount of cpu cache, etc. -I've tried to make them as accurate as possible, within limits. - -Note: many of the testing systems were provided by HP's testdrive program; -many thanks to them for giving me access to their systems. Also thanks to -SourceForge for their compile farm! - -Note: to avoid religious wars, in the table below read GNU/Linux for -Linux - I'm just a little cramped for space... - -BENCHmark Modular Exponentation (more is better): - -BeeCrypt 4.0.0 | gcc-3.3.3 | Fedora Core 2 | Athlon 64 3000+| 1 GB: 24740 -BeeCrypt 4.0.0 | gcc-3.2.2 | SuSE 8 EL | Opteron 1600 | 1 GB: 19460 -BeeCrypt 3.0.0 | gcc-3.x | RedHat Linux | Opteron MP 1600 | : 17230 -BeeCrypt 3.2.0 | gcc-2.96 | RedHat AS 2.1 | Itanium 2 1400 | 1 GB: 11453 -BeeCrypt 3.0.0 | gcc-3.2.2 | Debian Linux 3.0 | Itanium 2 900 | 12 GB: 7317 -BeeCrypt 3.0.0 | gcc-3.3 | RedHat AS 2.1 | P4 Xeon 2400 | 4 GB: 6920 [--with-arch=pentium4] -BeeCrypt 3.0.0 | gcc-2.95.4 | Debian Linux 3.0 | Alpha EV6.7 666 | 2 GB: 5742 -BeeCrypt 3.0.0 | gcc-2.96 | RedHat AS 2.1 | P4 Xeon 2400 | 4 GB: 3280 [--with-arch=pentiumpro] -BeeCrypt 3.0.0 | gcc-3.x | RedHat Linux | POWER4+ 1200 | : 2592 -BeeCrypt 3.0.0 | gcc-3.x | RedHat Linux | P3 Xeon 900 | : 2169 -BeeCrypt 3.0.0 | gcc-3.2.2 | AIX 5.1 | POWER3-II 333 | 512 MB: 1782 [--with-arch=powerpc64] -BeeCrypt 3.0.0 | gcc-3.x | RedHat Linux | zSeries 900 | : 1687 (s390x) -BeeCrypt 3.0.0 | gcc-3.3 | SuSE Linux 8.2 | Pentium 3 600 | 512 MB: 1447 [--with-arch=pentium3] -BeeCrypt 3.0.0 | gcc-3.2.2 | AIX 5.1 | POWER3-II 333 | 512 MB: 756 -BeeCrypt 3.0.0 | Forte C 5.1 | Solaris 8 | UltraSparc II 400 | 4 GB: 425 [--with-arch=sparcv8plus] -BeeCrypt 3.0.0 | | Debian Linux 3.0 | StrongARM 1110 128 | 32 MB: 341 -BeeCrypt 3.0.0 | gcc-2.95.4 | Debian Linux 3.0r1 | M68040 33 | 52 MB: 24 -BeeCrypt 3.0.0 | gcc-2.95.4 | Debian Linux 3.0r1 | M68030 25 | 36 MB: 8 - -BENCHmark Hash Function (more is better): - -MD5 -BeeCrypt 4.0.0 | gcc-3.3.3 | Fedora Core 2 | Athlon 64 3000+| 1 GB: 186.6 MB/s -BeeCrypt 3.0.0 | gcc-2.96 | RedHat AS 2.1 | P4 Xeon 2400 | 4 GB: 137.0 MB/s [--with-arch=pentiumpro] - -SHA-1 -BeeCrypt 4.0.0 | gcc-3.3.3 | Fedora Core 2 | Athlon 64 3000+| 1 GB: 104.7 MB/s -BeeCrypt 3.0.0 | gcc-2.96 | RedHat AS 2.1 | P4 Xeon 2400 | 4 GB: 77.0 MB/s [--with-arch=pentiumpro] - -SHA-256 -BeeCrypt 3.0.0 | gcc-2.96 | RedHat AS 2.1 | P4 Xeon 2400 | 4 GB: 37.8 MB/s [--with-arch=pentiumpro] - -BENCHmark Block Cipher (more is better): - -AES, 128 bits - -Blowfish, 128 bits diff --git a/beecrypt/BUGS b/beecrypt/BUGS deleted file mode 100644 index 57bed50a3..000000000 --- a/beecrypt/BUGS +++ /dev/null @@ -1,64 +0,0 @@ -Legend: - - = open bug - * = fixed bug - -3.1.0: - * Error in final result computation of mpextgcd_w in certain circumstances. - * PowerPC 64-bit assembler symbols aren't defined according to LSB 1.3. - -3.0.0: - - Can't seem to generate 64-bit shared libraries on AIX; use - --disable-shared on this platform for now. - - Intel icc can't cope with gcj headers. There's also a problem in - combination with aio.h; solution should be to not test gcj when using - this compiler. As a workaround, you can specify --without-javaglue. - - GCC 3.3 produces faster output for Blowfish on Pentium 4 than the - included assembler source; try coding two Blowfish rounds (without swap) - in C and compile to assembler to see how GCC accomplishes this. - -2.3.0pre: - * bug in certain instances of computing modular inverse. - * incorrectly translated intel-style assembler version of x86 mp32odd - and mp32even routines into gnu assembler format. - * base64 decoding of '+' and '/' characters is wrong. - * incorrect testing of the result of the gcd operation in mp32prndconone. - * Chinese Remainer Theorem for RSA private key operation doesn't work - * incorrect header file inclusion when --disable-threads is selected or - when no multithreading is available. - -2.2.0: - [ Released by Jeff Johnson of RedHat, Inc.; lint & doxygen enhanced version - of 2.1.0. ] - -2.1.0: - * Entropy gathering from /dev/dsp contained error; size in words of entropy - data to gather was overwritten with audio sample size - which resulted in - much less entropy. - -2.0.0: - - Chinese Remainder Theorem for RSA private key operation doesn't work; it - needs fixing. - -1.1.2: - * SHA-1 i586 assembler code uses local variables below the current stack - frame. - -1.1.1: - * discrete logarithm domain parameter generator calculations contains bugs - - was detected in this release but present since the first release. - -1.1.0: - * The javaglue produces a NullPointerException when initializing with a - null IV; this should be treated correctly, i.e. as an all zero IV. - -1.0.2: - -1.0.1: - * The Windows 2000 bug is still around - -1.0.0: - * On Windows 2000, the entropy system gets error WAVERR_BADFORMAT in - waveInOpen; So far I've been unable to determine why the system does this - for format WAVE_FORMAT_PCM. Suggestions to fix this problem are more than - welcome. - * The assembler code for SHA-1 in gnu/fips180opt.gas.i586.s contains bugs. diff --git a/beecrypt/CHANGELOG b/beecrypt/CHANGELOG deleted file mode 100644 index f91ef0d64..000000000 --- a/beecrypt/CHANGELOG +++ /dev/null @@ -1,28 +0,0 @@ -1.0.0: - - 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. - - Global code overhaul to support Win32 - - Added more assembler routines, including SHA-1 for Pentium Pro (60% faster) - - Added cleanup function to randomGenerator - - Added missing functions in endianness.c - - Fixed bug in entropy.c where devices might stay open - - 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. - -0.9.5: - - Added PowerPC assembler optimization for multiprecision integers, 80% faster on our PowerMac 7200/90 - - Fixed /dev/random entropy provider - - Changed name SHA1 to SHA-1 in fips180 for consistency - -0.9.4a: - - Added missing file 'blowfishopt.o' - -0.9.4: - - Changes to configure script, to distinguish between different processors of the x86 family - - Changes to blowfish code, 586/686 assembler optimization added, 30% faster on Pentium/PentiumPro - - Changes to blowfish code, eliminated static blowfishSetupEncrypt; incorporated into regular encrypt - - Changes to Makefile to selectively use blowfish assember code, depending on cpu type - - Added missing routines 'mp32bzero' and 'mp32bnpowmod' to mp32barrett.c - - Fixed 'const register' to 'register const' in mp32.c - - Minor fixes in included header files - -0.9.3: - - Initial public release diff --git a/beecrypt/CONTRIBUTORS b/beecrypt/CONTRIBUTORS deleted file mode 100644 index 7f6101147..000000000 --- a/beecrypt/CONTRIBUTORS +++ /dev/null @@ -1,19 +0,0 @@ -I would like to thank the following people (in alphabetical order): - -- Seth Arnold, for contributing to the documentation. -- Jan-Rudolph Bührmann, for helping me get started on the 64-bit multi- - precision integer library. -- Luca Filipozzi, maintainer/packager of BeeCrypt for Debian GNU/Linux. -- Jeff Johnson, the guy behind RedHat's Package Manager, who has inspired - and contributed to many of the changes for version 3.0.0; 73 de Bob. -- Jon Sturgeon, bug hunter extraordinaire. - -Further thanks go to: -- AMD, for donating a copy of "AMD x86-64 Architecture Programmer's Manual". -- ARM Ltd, for donating a copy of "ARM Architecture Reference Manual". -- HP/Compaq, for their testdrive program, which gave me the opportunity to - test and BeeCrypt on many new platforms. -- SourceForge, for their excellent open source development platform! - -Last but not least: thanks to everyone who provided bits of information, -reported bugs and provided feedback. diff --git a/beecrypt/COPYING b/beecrypt/COPYING deleted file mode 100644 index a6d7d0188..000000000 --- a/beecrypt/COPYING +++ /dev/null @@ -1,336 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - <one line to give the program's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Hereny it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Section diff --git a/beecrypt/COPYING.LIB b/beecrypt/COPYING.LIB deleted file mode 100644 index 223ede7de..000000000 --- a/beecrypt/COPYING.LIB +++ /dev/null @@ -1,504 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - <one line to give the library's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - <signature of Ty Coon>, 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/beecrypt/ChangeLog b/beecrypt/ChangeLog deleted file mode 100644 index e69de29bb..000000000 --- a/beecrypt/ChangeLog +++ /dev/null diff --git a/beecrypt/Doxyfile.in b/beecrypt/Doxyfile.in deleted file mode 100644 index 678470575..000000000 --- a/beecrypt/Doxyfile.in +++ /dev/null @@ -1,1091 +0,0 @@ -# Doxyfile 1.3.4 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = BeeCrypt - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = @VERSION@ - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = @top_srcdir@/docs - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch, -# Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en -# (Japanese with English messages), Korean, Norwegian, Polish, Portuguese, -# Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. - -OUTPUT_LANGUAGE = English - -# This tag can be used to specify the encoding used in the generated output. -# The encoding is not always determined by the language that is chosen, -# but also whether or not the output is meant for Windows or non-Windows users. -# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES -# forces the Windows encoding (this is the default for the Windows binary), -# whereas setting the tag to NO uses a Unix-style encoding (the default for -# all platforms other than Windows). - -USE_WINDOWS_ENCODING = NO - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited -# members of a class in the documentation of that class as if those members were -# ordinary class members. Constructors, destructors and assignment operators of -# the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. It is allowed to use relative paths in the argument list. - -STRIP_FROM_PATH = @top_srcdir@/ - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like the Qt-style comments (thus requiring an -# explict @brief command for a brief description. - -JAVADOC_AUTOBRIEF = YES - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - -DETAILS_AT_TOP = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# reimplements. - -INHERIT_DOCS = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 4 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources -# only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = YES - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources -# only. Doxygen will then generate output that is more tailored for Java. -# For instance, namespaces will be presented as packages, qualified scopes -# will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = YES - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = YES - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. - -WARN_FORMAT = - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = @top_srcdir@/Doxyheader \ - @top_srcdir@/ \ - @top_srcdir@/c++ \ - @top_srcdir@/c++/crypto \ - @top_srcdir@/c++/crypto/interfaces \ - @top_srcdir@/c++/crypto/spec \ - @top_srcdir@/c++/io \ - @top_srcdir@/c++/lang \ - @top_srcdir@/c++/provider \ - @top_srcdir@/c++/security \ - @top_srcdir@/c++/security/cert \ - @top_srcdir@/c++/security/interfaces \ - @top_srcdir@/c++/security/spec \ - @top_srcdir@/c++/util - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp -# *.h++ *.idl *.odl *.cs *.php *.php3 *.inc - -FILE_PATTERNS = *.h - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = NO - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories -# that are symbolic links (a Unix filesystem feature) are excluded from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. - -EXCLUDE_PATTERNS = *config*.h - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = @top_srcdir@/docs - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command <filter> <input-file>, where <filter> -# is the value of the INPUT_FILTER tag, and <input-file> is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. - -INPUT_FILTER = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES (the default) -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES (the default) -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = YES - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = NO - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet - -HTML_STYLESHEET = - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output dir. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. - -GENERATE_TREEVIEW = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = YES - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4 - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = dsfont - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = YES - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = YES - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimised for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assigments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_PREDEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. - -PREDEFINED = __cplusplus MP_WBITS=@MP_WBITS@ - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse the -# parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::addtions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base or -# super classes. Setting the tag to NO turns the diagrams off. Note that this -# option is superceded by the HAVE_DOT option below. This is only a fallback. It is -# recommended to install and use dot, since it yields more powerful graphs. - -CLASS_DIAGRAMS = YES - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = YES - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similiar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a call dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable call graphs for selected -# functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found on the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. - -MAX_DOT_GRAPH_WIDTH = 1024 - -# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. - -MAX_DOT_GRAPH_HEIGHT = 1024 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes that -# lay further from the root node will be omitted. Note that setting this option to -# 1 or 2 may greatly reduce the computation time needed for large code bases. Also -# note that a graph may be further truncated if the graph's image dimensions are -# not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH and MAX_DOT_GRAPH_HEIGHT). -# If 0 is used for the depth value (the default), the graph is not depth-constrained. - -MAX_DOT_GRAPH_DEPTH = 0 - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES - -#--------------------------------------------------------------------------- -# Configuration::addtions related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = NO diff --git a/beecrypt/Doxyheader b/beecrypt/Doxyheader deleted file mode 100644 index d83fdb9e3..000000000 --- a/beecrypt/Doxyheader +++ /dev/null @@ -1,201 +0,0 @@ -/*! \mainpage BeeCrypt API Documentation. - -BeeCrypt started its life when the need for a portable and fast cryptography -library arose at Virtual Unlimited in 1997. I'm still trying to make it -faster, easier to use and more portable, in addition to providing better -documentation. The library is currently in full swing again, thanks to the -Beeyond Software Holding BV. - -BeeCrypt is released under the following license: - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Legal disclaimer: note that depending on where you are, the use of -cryptography may be limited or forbidden by law. Before using this library, -make sure you are legally entitled to do so. - -Included in the library are: -<ul> - <li>entropy sources for initializing pseudo-random generators - <li>pseudo-random generators - <ul> - <li>FIPS-186 - </ul> - <li>block ciphers - <ul> - <li>AES - <li>Blowfish - </ul> - <li>hash functions - <ul> - <li>MD5 - <li>SHA-1 - <li>SHA-256 - </ul> - <li>keyed hash functions (a.k.a. message authentication codes) - <ul> - <li>HMAC-MD5 - <li>HMAC-SHA-1 - <li>HMAC-SHA-256 - </ul> - <li>multi-precision integer library, with assembler-optimized routines - for a range of processors; optimized to perform well on both 32-bit - and 64-bit machines; uses Barrett modular reduction instead of the - more common usual Montgomery algorithm; also implements sliding - windows. - <li>probabilistic primality testing, with optimized small prime trial - division - <li>discrete logarithm parameter generation over a prime field - <li>Diffie-Hellman key agreement - <li>DHAES encryption scheme - <li>DSA signature scheme - <li>ElGamal signature scheme (two variants) - <li>RSA keypair generation with chinese remainder theorem variables - <li>RSA public & private key operations -</ul> - -A new feature in version 4.x is the C++ API, built to resemble Java's security -and cryptography API. At this moment the number of classes provided is just -enough to build CSPs. If there is enough interest, we may expand this library. - -Planned for the future are: -<ul> - <li>compliance with and compliance statements for IEEE P1363 - <li>more blockciphers (Twofish, ... ) - <li>more blockcipher modes (CTR, OFB, ... ) - <li>more hash functions (RIPEMD-160, SHA-384, SHA-512, HAVAL, Tiger) - <li>RSA signatures as specified by RFC-2440. - <li>Elliptic Curves (ECDSA, ... ) -</ul> - -The library has been tested on the following platforms: -<ul> - <li>Darwin - <li>Linux glibc 2.x alpha - <li>Linux glibc 2.x arm - <li>Linux glibc 2.x ia64 - <li>Linux glibc 2.x m68k - <li>Linux glibc 2.x ppc - <li>Linux glibc 2.x s390x - <li>Linux glibc 2.x sparc - <li>Linux glibc 2.x x86 - <li>Linux glibc 2.x x86_64 - <li>Solaris 2.[6789] sparc (with Forte or GNU compilers) - <li>Solaris 2.[78] x86 (with Forte or GNU compilers) - <li>Tru64 Unix alpha - <li>Win32 (Windows 95, 98, NT 4.0, 2000, XP) -</ul> - -The library is currently in the process of being ported to: -<ul> - <li>AIX (shared libraries don't seem to work in 64-bit mode) - <li>Cygwin (the DLL builds now, but needs to be tested) -</ul> - -The structures in the library are geared towards exchange with Java -and its security and cryptography classes. This library can also be -accessed from Java by installing BeeCrypt for Java, a JCE 1.2 crypto -provider and the counterpart of this library. - - */ - -/*!\defgroup ES_m Entropy sources - */ -/*!\defgroup ES_audio_m Entropy sources: /dev/audio - */ -/*!\defgroup ES_dsp_m Entropy sources: /dev/dsp - */ -/*!\defgroup ES_random_m Entropy sources: /dev/random - */ -/*!\defgroup ES_urandom_m Entropy sources: /dev/urandom - */ -/*!\defgroup ES_tty_m Entropy sources: /dev/tty - */ -/*!\defgroup PRNG_m Pseudo-Random Number Generators - */ -/*!\defgroup PRNG_fips186_m Pseudo-Random Number Generators: FIPS-186 - */ -/*!\defgroup PRNG_mt_m Pseudo-Random Number Generators: Mersenne Twister - */ -/*!\defgroup HASH_m Hash Functions - */ -/*!\defgroup HASH_md5_m Hash Functions: MD5 - */ -/*!\defgroup HASH_sha1_m Hash Functions: SHA-1 - */ -/*!\defgroup HASH_sha256_m Hash Functions: SHA-256 - */ -/*!\defgroup HMAC_m Keyed Hash Functions, a.k.a. Message Authentication Codes - */ -/*!\defgroup HMAC_md5_m Keyed Hash Functions: HMAC-MD5 - */ -/*!\defgroup HMAC_sha1_m Keyed Hash Functions: HMAC-SHA-1 - */ -/*!\defgroup HMAC_sha256_m Keyed Hash Functions: HMAC-SHA-256 - */ -/*!\defgroup BC_m Block ciphers - */ -/*!\defgroup BC_aes_m Block ciphers: AES - */ -/*!\defgroup BC_blowfish_m Block ciphers: Blowfish - */ -/*!\defgroup MP_m Multiple Precision Integer Arithmetic - */ -/*!\defgroup DL_m Discrete Logarithm Primitives - */ -/*!\defgroup DL_dh_m Discrete Logarithm Primitives: Diffie-Hellman - */ -/*!\defgroup DL_dsa_m Discrete Logarithm Primitives: DSA - */ -/*!\defgroup DL_elgamal_m Discrete Logarithm Primitives: ElGamal - */ -/*!\defgroup IF_m Integer Factorization Primitives - */ -/*!\defgroup IF_rsa_m Integer Factorization Primitives: RSA - */ -/*!\defgroup PKCS1_m PKCS#1 - */ -/*!\defgroup PKCS12_m PKCS#12 - */ -/*!\defgroup CXX_m C++ API - */ -/*!\defgroup CXX_CRYPTO_m C++ classes mimicking javax.crypto - */ -/*!\defgroup CXX_CRYPTO_INTERFACES_m C++ classes mimicking javax.crypto.interfaces - */ -/*!\defgroup CXX_CRYPTO_SPEC_m C++ classes mimicking javax.crypto.spec - */ -/*!\defgroup CXX_IO_m C++ classes mimicking java.io - */ -/*!\defgroup CXX_LANG_m C++ classes mimicking java.lang - */ -/*!\defgroup CXX_PROV_m C++ Base Cryptographic Service Provider - */ -/*!\defgroup CXX_SECURITY_m C++ classes mimicking java.security - */ -/*!\defgroup CXX_SECURITY_CERT_m C++ classes mimicking java.security.cert - */ -/*!\defgroup CXX_SECURITY_INTERFACES_m C++ classes mimicking java.security.interfaces - */ -/*!\defgroup CXX_SECURITY_SPEC_m C++ classes mimicking java.security.spec - */ -/*!\defgroup CXX_UTIL_m C++ classes mimicking java.util - */ -/*!\defgroup JAVA_m Java API - */ -/*!\defgroup UNIT_m Unit tests - */ -/*!\defgroup BENCH_m Benchmark tests - */ diff --git a/beecrypt/INSTALL b/beecrypt/INSTALL deleted file mode 100644 index bca44d042..000000000 --- a/beecrypt/INSTALL +++ /dev/null @@ -1,187 +0,0 @@ -Basic Installation -================== - - The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, a file -`config.cache' that saves the results of its tests to speed up -reconfiguring, and a file `config.log' containing compiler output -(useful mainly for debugging `configure'). - - If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can -be considered for the next release. If at some point `config.cache' -contains results you don't want to keep, you may remove or edit it. - - The file `configure.in' is used to create `configure' by a program -called `autoconf'. You only need `configure.in' if you want to change -it or regenerate `configure' using a newer version of `autoconf'. - -The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. If you're - using `csh' on an old version of System V, you might need to type - `sh ./configure' instead to prevent `csh' from trying to execute - `configure' itself. - - Running `configure' takes awhile. While running, it prints some - messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - If you're building GNU make on a system which does not already have - a `make', you can use the build.sh shell script to compile. Run - `sh ./build.sh'. This should compile the program in the current - directory. Then you will have a Make program that you can use for - `make install', or whatever else. - - 3. Optionally, type `./make check' to run any self-tests that come with - the package. - - 4. Type `make install' to install the programs and any data files and - documentation. - - 5. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly - for the package's developers. If you use it, you may have to get - all sorts of other programs in order to regenerate files that came - with the distribution. - -Compilers and Options -===================== - - Some systems require unusual options for compilation or linking that -the `configure' script does not know about. You can give `configure' -initial values for variables by setting them in the environment. Using -a Bourne-compatible shell, you can do that on the command line like -this: - CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure - -Or on systems that have the `env' program, you can do it like this: - env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure - -Compiling For Multiple Architectures -==================================== - - You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you must use a version of `make' that -supports the `VPATH' variable, such as GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. - - If you have to use a `make' that does not supports the `VPATH' -variable, you have to compile the package for one architecture at a time -in the source code directory. After you have installed the package for -one architecture, use `make distclean' before reconfiguring for another -architecture. - -Installation Names -================== - - By default, `make install' will install the package's files in -`/usr/local/bin', `/usr/local/man', etc. You can specify an -installation prefix other than `/usr/local' by giving `configure' the -option `--prefix=PATH'. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -give `configure' the option `--exec-prefix=PATH', the package will use -PATH as the prefix for installing programs and libraries. -Documentation and other data files will still use the regular prefix. - - In addition, if you use an unusual directory layout you can give -options like `--bindir=PATH' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - -Optional Features -================= - - Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. - -Specifying the System Type -========================== - - There may be some features `configure' can not figure out -automatically, but needs to determine by the type of host the package -will run on. Usually `configure' can figure that out, but if it prints -a message saying it can not guess the host type, give it the -`--host=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name with three fields: - CPU-COMPANY-SYSTEM - -See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the host type. - - If you are building compiler tools for cross-compiling, you can also -use the `--target=TYPE' option to select the type of system they will -produce code for and the `--build=TYPE' option to select the type of -system on which you are compiling the package. - -Sharing Defaults -================ - - If you want to set default values for `configure' scripts to share, -you can create a site shell script called `config.site' that gives -default values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Operation Controls -================== - - `configure' recognizes the following options to control how it -operates. - -`--cache-file=FILE' - Use and save the results of the tests in FILE instead of - `./config.cache'. Set FILE to `/dev/null' to disable caching, for - debugging `configure'. - -`--help' - Print a summary of the options to `configure', and exit. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error - messages will still be shown). - -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. - -`--version' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`configure' also accepts some other, not widely useful, options. - diff --git a/beecrypt/LICENSE b/beecrypt/LICENSE deleted file mode 100644 index 223ede7de..000000000 --- a/beecrypt/LICENSE +++ /dev/null @@ -1,504 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - <one line to give the library's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - <signature of Ty Coon>, 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/beecrypt/Makefile.am b/beecrypt/Makefile.am deleted file mode 100644 index 504966ec4..000000000 --- a/beecrypt/Makefile.am +++ /dev/null @@ -1,93 +0,0 @@ -# -# Makefile.am contains the top-level automake definitions -# -# Copyright (c) 2001, 2002 Virtual Unlimited B.V. -# -# Author: Bob Deblier <bob.deblier@pandora.be> -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# - -# -# 1. No interfaces changes (good): Increment REVISION -# -# 2. Interfaces added, none removed (good): Increment CURRENT, increment AGE and REVISION to 0. -# -# 3. Interfaces removed (bad): Increment CURRENT, set AGE and REVISION to 0. -# - -LIBBEECRYPT_LT_CURRENT = 8 -LIBBEECRYPT_LT_AGE = 2 -LIBBEECRYPT_LT_REVISION = 0 - -AUTOMAKE_OPTIONS = gnu check-news no-dependencies - -LINT = splint - -SUBDIRS = . $(MAYBE_SUB) tests docs gas masm - -SUFFIXES = .s - -INCLUDES = -I$(top_srcdir)/.. - -.s.lo: - $(LTCOMPILE) -c -o $@ `test -f $< || echo '$(srcdir)/'`$< - -BEECRYPT_OBJECTS = aes.lo aesopt.lo base64.lo beecrypt.lo blockmode.lo blockpad.lo blowfish.lo blowfishopt.lo dhaes.lo dldp.lo dlkp.lo dlpk.lo dlsvdp-dh.lo dsa.lo elgamal.lo endianness.lo entropy.lo fips186.lo hmac.lo hmacmd5.lo hmacsha1.lo hmacsha256.lo md5.lo memchunk.lo mp.lo mpopt.lo mpbarrett.lo mpnumber.lo mpprime.lo mtprng.lo pkcs1.lo pkcs12.lo rsa.lo rsakp.lo rsapk.lo sha1.lo sha1opt.lo sha256.lo timestamp.lo - -libaltdir=$(prefix)/lib@LIBALT@ - -libalt_LTLIBRARIES = libbeecrypt.la - -libbeecrypt_la_SOURCES = aes.c base64.c beecrypt.c blockmode.c blockpad.c blowfish.c dhaes.c dldp.c dlkp.c dlpk.c dlsvdp-dh.c dsa.c elgamal.c endianness.c entropy.c fips186.c hmac.c hmacmd5.c hmacsha1.c hmacsha256.c md5.c memchunk.c mp.c mpbarrett.c mpnumber.c mpprime.c mtprng.c pkcs1.c pkcs12.c rsa.c rsakp.c rsapk.c sha1.c sha256.c timestamp.c cppglue.cxx -libbeecrypt_la_DEPENDENCIES = $(BEECRYPT_OBJECTS) -libbeecrypt_la_LIBADD = aesopt.lo blowfishopt.lo mpopt.lo sha1opt.lo -libbeecrypt_la_LDFLAGS = -no-undefined -version-info $(LIBBEECRYPT_LT_CURRENT):$(LIBBEECRYPT_LT_REVISION):$(LIBBEECRYPT_LT_AGE) - -pkginclude_HEADERS = aes.h aesopt.h api.h base64.h beecrypt.h blockmode.h blockpad.h blowfish.h blowfishopt.h dhaes.h dldp.h dlkp.h dlpk.h dlsvdp-dh.h dsa.h elgamal.h endianness.h entropy.h fips186.h gnu.h hmac.h hmacmd5.h hmacsha1.h hmacsha256.h md5.h memchunk.h mp.h mpbarrett.h mpnumber.h mpopt.h mpprime.h mtprng.h pkcs1.h pkcs12.h rsa.h rsakp.h rsapk.h sha1.h sha1opt.h sha256.h timestamp.h win.h - -noinst_HEADERS = aes_be.h aes_le.h - -EXTRA_DIST = BENCHMARKS BUGS CONTRIBUTORS README.DLL README.WIN32 Doxyheader beecrypt.rc autogen.sh Makefile.mak - -DISTCLEANFILES = mpopt.s aesopt.s blowfishopt.s sha1opt.s - -bench: - (cd tests && $(MAKE) $(AM_MAKEFLAGS) bench) - -beecrypt.lcd: Makefile.am ${libbeecrypt_la_SOURCES} ${pkginclude_HEADERS} ${noinst_HEADERS} - $(LINT) $(DEFS) $(INCLUDES) ${libbeecrypt_la_SOURCES} -dump $@ - -# XXX don't bite into gcj java dependencies (yet) -libbeecrypt_splint_SOURCES = aes.c base64.c beecrypt.c blockmode.c blockpad.c blowfish.c dhaes.c dldp.c dlkp.c dlpk.c dlsvdp-dh.c dsa.c elgamal.c endianness.c entropy.c fips186.c hmac.c hmacmd5.c hmacsha1.c hmacsha256.c md5.c memchunk.c mp.c mpbarrett.c mpnumber.c mpprime.c mtprng.c pkcs1.c pkcs12.c rsa.c rsakp.c rsapk.c sha1.c sha256.c timestamp.c # cppglue.cxx - -.PHONY: sources -sources: - @echo $(libbeecrypt_splint_SOURCES:%=beecrypt/%) | sed -e 's,beecrypt/javaglue.c,,' - -# XXX don't bite into javaglue.c (yet) -.PHONY: lint -lint: - $(LINT) $(DEFS) $(INCLUDES) $(libbeecrypt_splint_SOURCES:javaglue.c=) # tests/beetest.c - -.PHONY: listobjs -listobjs: - @echo $(BEECRYPT_OBJECTS) > $@ - -DOXYGEN = /usr/bin/doxygen .PHONY: doxygen -doxygen apidocs: Doxyfile Doxyheader - rm -rf $@ - mkdir -p $@ - - [ -x ${DOXYGEN} ] && ${DOXYGEN} diff --git a/beecrypt/Makefile.mak b/beecrypt/Makefile.mak deleted file mode 100644 index 258910b47..000000000 --- a/beecrypt/Makefile.mak +++ /dev/null @@ -1,116 +0,0 @@ - -# -# Makefile.mak for the beecrypt library -# -# To be used with Microsoft's nmake utility; -# Will need the Visual C Processor Pack installed. -# -# Copyright (c) 2000, 2001, 2002 Virtual Unlimited B.V. -# -# Author: Bob Deblier <bob.deblier@pandora.be> -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# - -AS=ml.exe -CC=cl.exe -LD=link.exe -RC=rc.exe - -LIBS= \ - advapi32.lib \ - gdi32.lib \ - kernel32.lib \ - user32.lib \ - winmm.lib - -LIBPATH="C:\Program Files\Microsoft Visual Studio\VC98\Lib" -JAVAPATH="C:\j2sdk1.4.0\include" - - -# To enable SSE2 optimization, add switch /DUSE_SSE2 to ASFLAGS -ASFLAGS=/nologo /c /coff /Gd # /DUSE_SSE2 -CFLAGS=/nologo /TC /MT /GM /Ox /G6 /I. -# CFLAGS=/nologo /TC /MT /GM /ZI /G6 /I. -LDFLAGS=/nologo /fixed:no /machine:IX86 /libpath:$(LIBPATH) $(LIBS) # /DEBUG -RCFLAGS=/r /L 0x409 /FObeecrypt.res -JAVAFLAGS=/DJAVAGLUE=1 /I$(JAVAPATH) /I$(JAVAPATH)\win32 - -# To compile Java support, add file javaglue.obj to this list -OBJECTS= \ - aes.obj \ - aesopt.obj \ - base64.obj \ - beecrypt.obj \ - blockmode.obj \ - blockpad.obj \ - blowfish.obj \ - blowfishopt.obj \ - dhaes.obj \ - dldp.obj \ - dlkp.obj \ - dlpk.obj \ - dlsvdp-dh.obj \ - dsa.obj \ - elgamal.obj \ - endianness.obj \ - entropy.obj \ - fips186.obj \ - hmac.obj \ - hmacmd5.obj \ - hmacsha1.obj \ - hmacsha256.obj \ - md5.obj \ - memchunk.obj \ - mp.obj \ - mpopt.obj \ - mpbarrett.obj \ - mpnumber.obj \ - mpprime.obj \ - mtprng.obj \ - rsa.obj \ - rsakp.obj \ - rsapk.obj \ - sha1.obj \ - sha1opt.obj \ - sha256.obj \ - timestamp.obj \ - beecrypt.res - -all: .\beecrypt.dll - -beecrypt.dll: $(OBJECTS) - $(LD) $(LDFLAGS) $(OBJECTS) /dll /out:beecrypt.dll /implib:beecrypt.lib - -beecrypt.res: beecrypt.rc - $(RC) $(RCFLAGS) beecrypt.rc - -javaglue.obj: javaglue.c - $(CC) $(CFLAGS) $(JAVAFLAGS) /c javaglue.c - -aesopt.obj: masm\aesopt.i586.asm - $(AS) $(ASFLAGS) /Foaesopt.obj /c masm\aesopt.i586.asm - -blowfishopt.obj: masm\blowfishopt.i586.asm - $(AS) $(ASFLAGS) /Foblowfishopt.obj /c masm\blowfishopt.i586.asm - -sha1opt.obj: masm\sha1opt.i586.asm - $(AS) $(ASFLAGS) /Fosha1opt.obj /c masm\sha1opt.i586.asm - -mpopt.obj: masm\mpopt.x86.asm - $(AS) $(ASFLAGS) /Fompopt.obj /c masm\mpopt.x86.asm - -clean: - del *.obj diff --git a/beecrypt/NEWS b/beecrypt/NEWS deleted file mode 100644 index 9b34b553a..000000000 --- a/beecrypt/NEWS +++ /dev/null @@ -1,156 +0,0 @@ -4.0.0: - - Added a C++ API interface, modeled after Java's security & crypto API. - - Added the new GNU noexecstack feature. - - Added more x86_64 and s390x assembler routines. - - Modified i2osp, so that it only requires as many octets as there are - significant bytes in the multi-precision integers. - - Fixed a bug in the creation of rsa keypairs; code was not correctly - migrated to new calling sequence. The code now implements the method - described in IEEE P.1363. - - Fixed another bug in mpextgcd_w which sometimes returned incorrect - results. - - Fixed a bug in mprshiftlsz, which didn't work correctly when size = 1. - - Fixed a configuration problem on Tru64 Unix. - -3.1.0: - - Added wiping of private key components of keypairs before freeing. - - Fixed bug in mpextgcd_w which sometimes returned incorrect result. - - Fixed error in PowerPC 64-bit assembler symbol definitions. - -3.0.0: - - Cleaned up installed header files. - - Modified the API so that all keys can be passed as arrays of bytes. - - Modified the API so that all key sizes are given in bits. - - Modified the multi-precision integer library to work better on 64-bit - machines. - - Modified the assembly source generation mechanism, employing the m4 - macro processor. - - Added multi-precision integer vectorized assembler routines for - Itanium. - - Added multi-precision integer assembler routines for PowerPC 64-bit. - - Added multi-precision integer assembler routines for Alpha. - - Added multi-precision integer assembler routines for Opteron. - - Added multi-precision integer assembler routines for IBM zSeries 64-bit. - - Added multi-precision integer assembler routines for M68K. - - Added Jeff Johnson's python bindings. - - Added new unit tests. - - Added new benchmarking programs. - -2.3.0pre: - - 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). - - Added the AES algorithm, with assembler routines for i586 and powerpc. - - Added the DSA signature algorithm. - - Added PowerPC assembler routines for blowfish. - - Added Pentium4 SSE2 assembler multiplication routines. - - Fixed the RSA CRT algorithm. - - Fixed the gas/i386 mp32even and mp32odd routines. - - Fixed a bug in modular inverse computation; thanks to Jeff Johnson of RedHat for pointing this out. - - Fixed a bug in testing the result of a gcd operation in the mp32prndconone routine. - - Fixed an ugly bug in base64 decoding. - - Fixed compatibility with the latest automake & autoconf versions. - - Replaces CPU optimization mechanism in configure script. - -2.1.0: - - Added support for automake, autoheader and libtool, which should make compiling the library even easier. - - Changed DHAES API to conform to IEEE P.1363 submission and to allow for uneven key splitting. - - Improved PKCS#5 padding routines. - - Added a hash reset to the hashFunctionContextInit function. This was pointed out by Marko Kreen. - - Fixed problem with configuring on i486-pc-linux-gnu. This was pointed out Steve O'Neill. - - Fixed problem in the C version of mp32sub where carry would sometimes be missed. This was pointed out by Jon Sturgeon. - - 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. - - Changed mp32opt i386 assembler routines for slight performance improvement. - - Changed mp32opt powerpc assembler routines for slight performance improvement. - - Changed mp32opt sparcv9 assembler routines for slight performance improvement. - - Added sparcv8 assembler routines for multi-precision integer multiplication. - - Added arm assembler routines for multi-precision integer multiplication. - - Added prototype 64-bit ia64 assembler routines for multi-precision integer operations. - - Started writing the long-awaited documentation. - -2.0.0: - - Changed mp32barrett struct and operations to be multithread-safe; this required a change in API. - - Changed hashFunction struct to incorporate internal block size parameter. - - Changed HMAC algorithm and file names to match names in RFC 2104. - - Changed SHA-1 C code for slightly faster results. - - Changed detection of entropy devices. - - Changed most void-returning functions to return int for error conditions. - - Changed beecrypt-java class names in javaglue. - - Added RSA keypair generation. - - Added RSA private & public key operations. - - Added SHA-256 hash function. - - Added HMAC-MD5 and HMAC-SHA-256 keyed hash functions. - - Added PKCS#5 padding. - - Added DHAES encryption scheme. - - Added Microsoft Visual C support, added Makefile.mak for this purpose. - - Added Solaris/Sparc Forte C 64 bit support. - - Added configure --disable-optimized option (disables assembler & processor-specific optimizations). - - 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. - - Fixed bug in (certain cases of) modular inverse computation. - - Fixed buffer overrun in base64 encoding. This was pointed out by Jon Sturgeon. - - Fixed various minor bugs. - - Renamed text files to match automake conventions. - -1.1.2: - - 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. - - Added MD5 hash function. - -1.1.1: - - Changed autoconfig script for easier porting. - - Changed sources for easier compilation on Microsoft Visual C++; no assembler-optimization on this platform yet. - - Fixed bug in javaglue when passing null IV to blockcipher. - - Shared library is now linked dynamically, with shared object name and version. - - Tested on Alpha Linux. - - Tested on Alpha FreeBSD. - - Added support for Compaq Alpha Tru64 Unix. - - Added initial support for QNX. - -1.1.0: - - Added glue for interfacing from BeeCrypt Java Cryptography Provider. - - Changed blockcipher struct to support interfacing with Java. - - Added better blockcipher IV handling. - - Multi-pass block processing is now possible with blockEncrypt/blockDecrypt. - - Updated config.sub and config.guess to latest version from sources.redhat.com - - Changed opening of entropy devices to blocking read-only mode instead of non-blocking read-write. - - Added win32 'wincrypt' entropy source. - - Added win32 'console' entropy source. - - Added FreeBSD support. - - Added PowerPC assembler optimized multiprecision subtraction routines. - - Added initial ia64 support. - - Added initial Darwin support (everything compiles, but the shared library doesn't build yet). - -1.0.2: - - Fixed Windows 2000 entropy bug; instead of using the first waveIn device, entropy now uses WAVE_MAPPER. - - Added sparcv9 mp32addsqrtrc GNU assembler routine. - - Added more hashFunctionContext and keyedHashFunctionContext functions. - -1.0.1: - - Added a sliding window modular exponentiation, about 30% faster than left-to-right exponentiation. - - Fixed bugs in fips180opt.gas.i586.s (Linux SHA-1 assembler code for Pentium/Pentium Pro) - the Windows/Metrowerks version was okay. - -1.0.0: - - 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. - - Global code overhaul to support Win32 - - Added more assembler routines, including SHA-1 for Pentium Pro (60% faster) - - Added cleanup function to randomGenerator - - Added missing functions in endianness.c - - Fixed bug in entropy.c where devices might stay open - - 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. - -0.9.5: - - Added PowerPC assembler optimization for multiprecision integers, 80% faster on our PowerMac 7200/90 - - Fixed /dev/random entropy provider - - Changed name SHA1 to SHA-1 in fips180 for consistency - -0.9.4a: - - Added missing file 'blowfishopt.o' - -0.9.4: - - Changes to configure script, to distinguish between different processors of the x86 family - - Changes to blowfish code, 586/686 assembler optimization added, 30% faster on Pentium/PentiumPro - - Changes to blowfish code, eliminated static blowfishSetupEncrypt; incorporated into regular encrypt - - Changes to Makefile to selectively use blowfish assember code, depending on cpu type - - Added missing routines 'mp32bzero' and 'mp32bnpowmod' to mp32barrett.c - - Fixed 'const register' to 'register const' in mp32.c - - Minor fixes in included header files - -0.9.3: - - Initial public release diff --git a/beecrypt/README b/beecrypt/README deleted file mode 100644 index d875372c3..000000000 --- a/beecrypt/README +++ /dev/null @@ -1,143 +0,0 @@ -Welcome to the BeeCrypt crypto library! - -Copyright (c) 1997, 1998, 1999, 2000, 2001 Virtual Unlimited B.V. -Copyright (c) 2002, 2003, Bob Deblier (for certain parts) - -Author: Bob Deblier <bob.deblier@pandora.be> - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -For the specifics of this license, see file 'COPYING.LIB', included in -this distribution. - - - -Welcome to version 3.0.0 of BeeCrypt: - -AES support has been added, and the library has been thoroughly debugged, -with the addition of unit tests. Once you've built the library, you can -verify the correct functioning with 'make check'. - -Multi-precision integer routines should now perform dramatically better -an 64-bit processors, especially Alpha and Itanium. - -Benchmarks can be obtained with 'make bench'. - -As usual, your comments are welcome. - - - -About BeeCrypt: - -This library is an ongoing project of Virtual Unlimited B.V. Its goal is -to provide strong and fast cryptography for use by our products, but -we're not limiting the use to that. We're releasing it under the LGPL -license, because we feel that cryptography should be open to inspection -by everybody, and available for use by everybody to safeguard privacy. - -Note that depending on where you are, the use of cryptography may be -limited or forbidden by law. Before using this library, make sure you -are legally entitled to do so. - - -For more on Virtual Unlimited B.V. and our products please consult our -website: http://www.virtualunlimited.com/ - - -<plug> -Most of the algorithms are implemented from reliable sources such as: - -"Handbook of Applied Cryptography" - Alfred J. Menezes, Paul C. van Oorschot, Scott A. Vanstone - CRC Press - -"Applied Cryptography", second edition - Bruce Schneier - Wiley - - -For crypto enthusiasts these books are invaluable background material. - -IEEE P1363 "Standard Specifications for Public Key Cryptography" is a -very interesting draft standard, which we will try to comply with. -</plug> - -The structures in the library are geared towards exchange with Java -and its security and cryptography classes. This library can also be -accessed from Java by installing BeeCrypt for Java, a JCE 1.2 crypto -provider and the counterpart of this library. - - -Included in the library are: - - entropy sources for initializing pseudo-random generators - - pseudo-random generators: FIPS-186, Mersenne Twister - - block ciphers: AES, Blowfish - - hash functions: MD5, SHA-1, SHA-256 - - keyed hash functions: HMAC-MD5, HMAC-SHA-1, HMAC-SHA-256 - - multi-precision integer library, with assembler-optimized routines - for several processors - - probabilistic primality testing, with optimized small prime trial - division - - discrete logarithm parameter generation over a prime field - - Diffie-Hellman key agreement - - DSA signature scheme - - ElGamal signature scheme (two variants) - - RSA keypair generation with chinese remainder theorem variables - - RSA public & private key operations - - DHAES encryption scheme - -Planned for the near future are: - - compliance with and compliance statements for IEEE P1363 - - more blockciphers (Twofish, ... ) - - more hash functions (RIPEMD-160, SHA-384, SHA-512, HAVAL, Tiger) - - RSA signatures as specified by RFC-2440. - - Elliptic Curves (ECDSA, ... ) - - more blockcipher modes (OFB, ... ) - -The library has been tested on the following platforms: - - AIX 5.1 ppc - - AIX 5.1 ppc64 - - Darwin 6.5 (a.k.a. MacOS X 10.2) - - FreeBSD 4.0 alpha - - FreeBSD 4.0, 4.2 x86 - - Linux glibc 2.x alpha - - Linux glibc 2.x arm - - Linux glibc 2.x ia64 - - Linux glibc 2.x ppc - - Linux glibc 2.x sparc - - Linux glibc 2.x x86 - - Solaris 2.6/2.7/2.8/2.9 sparc (with Forte or gnu compilers) - - Solaris 2.7/2.8 x86 (with Forte or GNU compilers) - - Tru64 Unix alpha - - Win32 (Windows 95, 98, NT 4.0, 2000, XP) - -The library is currently in the process of being ported to: - - Cygwin (Can't seem to get the DLL to build properly with the current - version of the autotools) - - HP/UX is a pain in the backside; I'll try getting it working, but the - configure script doesn't seem capable of properly detecting gettimeofday. - -For more information, refer to the HTML documentation in the docs directory. - -If you want to report bugs, make suggestions, contribute fixes or -enhancements, please see the beecrypt-specific website: - -http://sourceforge.net/projects/beecrypt - -or contact me at mailto:bob.deblier@pandora.be - -Sincerely, - -Bob Deblier diff --git a/beecrypt/README.DLL b/beecrypt/README.DLL deleted file mode 100644 index 2131f87ce..000000000 --- a/beecrypt/README.DLL +++ /dev/null @@ -1,37 +0,0 @@ -File beetest.exe is a compiled version of the test program included in -the source distribution, which you can find on our website: -http://beecrypt.virtualunlimited.com/ - -To run, it needs file beecrypt.dll present in the same directory. - -For Developers: - -Files beecrypt.dll and beecrypt.lib are a pre-compiled version of the -BeeCrypt library for Pentium Pro processors. - -If you want to develop applications with this library, you'll also need -the header files, included in the source distribution (see higher). - -Please make sure you respect the term of the license under which the -BeeCrypt library is released: - -Copyright (c) 1997, 1998, 1999, 2000, 2001 Virtual Unlimited B.V. - -Author: Bob Deblier <bob@virtualunlimited.com> - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -For the specifics of this license, see file 'COPYING', included in this -distribution. diff --git a/beecrypt/README.WIN32 b/beecrypt/README.WIN32 deleted file mode 100644 index 411116fea..000000000 --- a/beecrypt/README.WIN32 +++ /dev/null @@ -1,43 +0,0 @@ -This file contains information on how to build and use the BeeCrypt DLL on -Win32 platforms. - -The platform of preference is currently MicroSoft Visual C++ 6.0, but -Metrowerks CodeWarrior is also still supported. - -To be able to use the assembler files with Visual C++, you need to have the -Visual C++ 6.0 Processor Pack installed. It can be found at: - -http://msdn.microsoft.com/vstudio/downloads/ppack/default.asp - -To be able to use the assembler files with Metrowerks CodeWarrior, you will -need to install an unsupported (but working for the included files) assembler -plug-in, which can be found on the CodeWarrior download page. - -To build the java glue into the DLL, you should also have Sun's JDK 1.3, -including the JNI headers, installed. - -Make sure all Visual C++ tools can be found on the path, i.e.: - -cl.exe (the compiler) -ml.exe (the assembler) -link.exe (the linker) -nmake.exe (the make utility) - -For convenience, copy file 'Makefile.mak' to 'Makefile' and adjust paths as -required. The Makefile assumes you will be building in support for java. -If this is not the case, you will have to adjust the Makefile, which shouldn't -be too difficult. - -Next, run 'nmake' and the library and the test program will be built. - -Once running, you can use any of three entropy source available on this -platform, in order of preference: - -wavein (uses noise on the soundcard microphone port) -console (uses keyboard clicks with a high resolution timer) -wincrypt (uses random data generated by the Windows CryptAPI) - -To enable a specific entropy device, set variable BEECRYPT_ENTROPY to any of -these three values; if not specified, the library will use 'wavein' as default. - -In the future, additional sources of entropy on this platform will be made available. diff --git a/beecrypt/acinclude.m4 b/beecrypt/acinclude.m4 deleted file mode 100644 index d6493d2e4..000000000 --- a/beecrypt/acinclude.m4 +++ /dev/null @@ -1,1231 +0,0 @@ -dnl BeeCrypt specific autoconf macros - -dnl Copyright 2003 Bob Deblier <bob.deblier@pandora.be> -dnl -dnl This file is part of the BeeCrypt crypto library -dnl -dnl -dnl LGPL - - -dnl BEECRYPT_WITH_CPU -AC_DEFUN([BEECRYPT_WITH_CPU],[ - ac_with_cpu=yes - bc_target_cpu=$withval - case $target_cpu in - i[[3456]]86) - case $withval in - i[[3456]]86 | \ - pentium | pentium-mmx | pentiumpro | pentium[[234]] | \ - athlon | athlon-tbird | athlon-4 | athlon-xp | athlon-mp) - ;; - *) - AC_MSG_WARN([invalid cpu type]) - bc_target_cpu=$target_cpu - ;; - esac - ;; - powerpc | powerpc64) - case $withval in - 403 | 505 | \ - 60[[1234]] | 60[[34]]e | 6[[23]]0 | \ - 7[[45]]0 | 74[[05]]0 | \ - 801 | 82[[13]] | 860 | \ - power | power2 | powerpc | powerpc64) - ;; - *) - AC_MSG_WARN([invalid cpu type]) - bc_target_cpu=$target_cpu - ;; - esac - ;; - sparc | sparc64) - case $withval in - sparcv8 | sparcv8plus | sparcv8plus[[ab]] | sparcv9 | sparcv9[[ab]]) - ;; - *) - AC_MSG_WARN([invalid cpu type]) - bc_target_cpu=$target_cpu - ;; - esac - ;; - x86) # QNX Neutrino doesn't list the exact cpu type - case $withval in - i[[3456]]86) - ;; - *) - AC_MSG_WARN([unsupported or invalid cpu type]) - bc_target_cpu=$target_cpu - ;; - esac - ;; - *) - AC_MSG_WARN([unsupported or invalid cpu type]) - bc_target_cpu=$target_cpu - ;; - esac - ]) - -dnl BEECRYPT_WITHOUT_CPU -AC_DEFUN([BEECRYPT_WITHOUT_CPU],[ - ac_with_cpu=no - bc_target_cpu=$target_cpu - ]) - - -dnl BEECRYPT_WITH_ARCH -AC_DEFUN([BEECRYPT_WITH_ARCH],[ - ac_with_arch=yes - bc_target_arch=$withval - case $target_cpu in - i[[3456]]86) - case $withval in - i[[3456]]86 | \ - pentium | pentium-mmx | pentiumpro | pentium[[234]] | \ - athlon | athlon-tbird | athlon-4 | athlon-xp | athlon-mp) - if test "$ac_with_cpu" != yes; then - bc_target_cpu=$withval - fi - ;; - esac - ;; - powerpc*) - case $withval in - powerpc) - ;; - powerpc64) - bc_target_arch=powerpc64 - ;; - *) - AC_MSG_WARN([unsupported on invalid arch type]) - bc_target_arch=powerpc - ;; - esac - ;; - esac - ]) - -dnl BEECRYPT_WITHOUT_ARCH -AC_DEFUN([BEECRYPT_WITHOUT_ARCH],[ - ac_with_arch=no - case $target_cpu in - alpha*) - bc_target_arch=alpha - ;; - arm*) - bc_target_arch=arm - ;; - i[[3456]]86) - bc_target_arch=i386 - ;; - ia64) - bc_target_arch=ia64 - ;; - m68k) - bc_target_arch=m68k - ;; - powerpc) - bc_target_arch=powerpc - ;; - powerpc64) - bc_target_arch=powerpc64 - ;; - s390x) - bc_target_arch=s390x - ;; - sparc*) - bc_target_arch=sparc - ;; - x86_64) - bc_target_arch=x86_64 - ;; - esac - ]) - - -dnl BEECRYPT_INT_TYPES -AC_DEFUN([BEECRYPT_INT_TYPES],[ - AC_TYPE_SIZE_T - bc_typedef_size_t= - if test $ac_cv_type_size_t != yes; then - bc_typedef_size_t="typedef unsigned size_t;" - fi - AC_SUBST(TYPEDEF_SIZE_T,$bc_typedef_size_t) - if test $ac_cv_header_inttypes_h = yes; then - AC_SUBST(INCLUDE_INTTYPES_H,["#include <inttypes.h>"]) - else - AC_SUBST(INCLUDE_INTTYPES_H,[ ]) - fi - if test $ac_cv_header_stdint_h = yes; then - AC_SUBST(INCLUDE_STDINT_H,["#include <stdint.h>"]) - else - AC_SUBST(INCLUDE_STDINT_H,[ ]) - fi - AH_TEMPLATE([HAVE_INT64_T]) - AH_TEMPLATE([HAVE_UINT64_T]) - bc_typedef_int8_t= - AC_CHECK_TYPE([int8_t],,[ - AC_CHECK_SIZEOF([signed char]) - if test $ac_cv_sizeof_signed_char -eq 1; then - bc_typedef_int8_t="typedef signed char int8_t;" - fi - ]) - AC_SUBST(TYPEDEF_INT8_T,$bc_typedef_int8_t) - bc_typedef_int16_t= - AC_CHECK_TYPE([int16_t],,[ - AC_CHECK_SIZEOF([short]) - if test $ac_cv_sizeof_short -eq 2; then - bc_typedef_int16_t="typedef short int16_t;" - fi - ]) - AC_SUBST(TYPEDEF_INT16_T,$bc_typedef_int16_t) - bc_typedef_int32_t= - AC_CHECK_TYPE([int32_t],,[ - AC_CHECK_SIZEOF([int]) - if test $ac_cv_sizeof_int -eq 4; then - bc_typedef_int32_t="typedef int int32_t;" - fi - ]) - AC_SUBST(TYPEDEF_INT32_T,$bc_typedef_int32_t) - bc_typedef_int64_t= - AC_CHECK_TYPE([int64_t],[ - AC_DEFINE([HAVE_INT64_T],1) - ],[ - AC_CHECK_SIZEOF([long]) - if test $ac_cv_sizeof_long -eq 8; then - bc_typedef_int64_t="typedef long int64_t;" - else - AC_CHECK_SIZEOF([long long]) - if test $ac_cv_sizeof_long_long -eq 8; then - AC_DEFINE([HAVE_INT64_T],1) - bc_typedef_int64_t="typedef long long int64_t;" - fi - fi - ]) - AC_SUBST(TYPEDEF_INT64_T,$bc_typedef_int64_t) - bc_typedef_uint8_t= - AC_CHECK_TYPE([uint8_t],,[ - AC_CHECK_SIZEOF([unsigned char]) - if test $ac_cv_sizeof_unsigned_char -eq 1; then - bc_typedef_uint8_t="typedef unsigned char uint8_t;" - fi - ]) - AC_SUBST(TYPEDEF_UINT8_T,$bc_typedef_uint8_t) - bc_typedef_uint16_t= - AC_CHECK_TYPE([uint16_t],,[ - AC_CHECK_SIZEOF([unsigned short]) - if test $ac_cv_sizeof_unsigned_short -eq 2; then - bc_typedef_uint16_t="typedef unsigned short uint16_t;" - fi - ]) - AC_SUBST(TYPEDEF_UINT16_T,$bc_typedef_uint16_t) - bc_typedef_uint32_t= - AC_CHECK_TYPE([uint32_t],,[ - AC_CHECK_SIZEOF([unsigned int]) - if test $ac_cv_sizeof_unsigned_int -eq 4; then - bc_typedef_uint32_t="typedef unsigned int uint32_t;" - fi - ]) - AC_SUBST(TYPEDEF_UINT32_T,$bc_typedef_uint32_t) - bc_typedef_uint64_t= - AC_CHECK_TYPE([uint64_t],[ - AC_DEFINE([HAVE_UINT64_T],1) - ],[ - AC_CHECK_SIZEOF([unsigned long]) - if test $ac_cv_sizeof_unsigned_long -eq 8; then - bc_typedef_uint64_t="typedef unsigned long uint64_t;" - else - AC_CHECK_SIZEOF([unsigned long long]) - if test $ac_cv_sizeof_unsigned_long_long -eq 8; then - AC_DEFINE([HAVE_UINT64_T],1) - bc_typedef_uint64_t="typedef unsigned long long uint64_t;" - fi - fi - ]) - AC_SUBST(TYPEDEF_UINT64_T,$bc_typedef_uint64_t) - ]) - - -dnl BEECRYPT_CPU_BITS -AC_DEFUN([BEECRYPT_CPU_BITS],[ - AC_CHECK_SIZEOF([unsigned long]) - if test $ac_cv_sizeof_unsigned_long -eq 8; then - AC_SUBST(MP_WBITS,64U) - elif test $ac_cv_sizeof_unsigned_long -eq 4; then - AC_SUBST(MP_WBITS,32U) - else - AC_MSG_ERROR([Illegal CPU word size]) - fi - ]) - - -dnl BEECRYPT_WORKING_AIO -AC_DEFUN([BEECRYPT_WORKING_AIO],[ - AC_CHECK_HEADERS(aio.h) - if test "$ac_cv_header_aio_h" = yes; then - AC_SEARCH_LIBS([aio_read],[c rt aio posix4],[ - AC_CACHE_CHECK([whether aio works],bc_cv_working_aio,[ - cat > conftest.aio << EOF -The quick brown fox jumps over the lazy dog. -EOF - AC_RUN_IFELSE([AC_LANG_SOURCE([[ -#if HAVE_ERRNO_H -# include <errno.h> -#endif -#if HAVE_FCNTL_H -# include <fcntl.h> -#endif -#if HAVE_STRING_H -# include <string.h> -#endif -#if HAVE_UNISTD_H -# include <unistd.h> -#endif -#include <stdio.h> -#include <aio.h> - -main() -{ - struct aiocb a; - const struct aiocb* a_list = &a; - struct timespec a_timeout; - - char buffer[32]; - - int i, rc, fd = open("conftest.aio", O_RDONLY); - - if (fd < 0) - exit(1); - - memset(&a, 0, sizeof(struct aiocb)); - - a.aio_fildes = fd; - a.aio_offset = 0; - a.aio_reqprio = 0; - a.aio_buf = buffer; - a.aio_nbytes = sizeof(buffer); - a.aio_sigevent.sigev_notify = SIGEV_NONE; - - a_timeout.tv_sec = 1; - a_timeout.tv_nsec = 0; - - if (aio_read(&a) < 0) - { - perror("aio_read"); - exit(1); - } - if (aio_suspend(&a_list, 1, &a_timeout) < 0) - { - #if HAVE_ERRNO_H - /* some linux systems don't await timeout and return instantly */ - if (errno == EAGAIN) - { - nanosleep(&a_timeout, (struct timespec*) 0); - - if (aio_suspend(&a_list, 1, &a_timeout) < 0) - { - perror("aio_suspend"); - exit(1); - } - } - else - { - perror("aio_suspend"); - exit(1); - } - #else - exit(1); - #endif - } - if (aio_error(&a) < 0) - exit(1); - - if (aio_return(&a) < 0) - exit(1); - - exit(0); -} - ]])],[bc_cv_working_aio=yes],[bc_cv_working_aio=no],[ - case $target_os in - linux* | solaris*) - bc_cv_working_aio=yes ;; - *) - bc_cv_working_aio=no ;; - esac - ]) - ],[ - bc_cv_working_aio=no - ]) - ]) - rm -fr conftest.aio - fi - ]) - - -dnl BEECRYPT_CFLAGS_REM -AC_DEFUN([BEECRYPT_CFLAGS_REM],[ - if test "$CFLAGS" != ""; then - CFLAGS_save="" - for flag in $CFLAGS - do - if test "$flag" != "$1"; then - CFLAGS_save="$CFLAGS_save $flag" - fi - done - CFLAGS="$CFLAGS_save" - fi - ]) - - -dnl BEECRYPT_CXXFLAGS_REM -AC_DEFUN([BEECRYPT_CXXFLAGS_REM],[ - if test "$CXXFLAGS" != ""; then - CXXFLAGS_save="" - for flag in $CXXFLAGS - do - if test "$flag" != "$1"; then - CXXFLAGS_save="$CXXFLAGS_save $flag" - fi - done - CXXFLAGS="$CXXFLAGS_save" - fi - ]) - - -dnl BEECRYPT_GNU_CC -AC_DEFUN([BEECRYPT_GNU_CC],[ - AC_REQUIRE([AC_PROG_CC]) - case $bc_target_arch in - ia64) - case $target_os in - # HP/UX on Itanium needs to be told that a long is 64-bit! - hpux*) - CFLAGS="$CFLAGS -mlp64" - ;; - esac - ;; - # PowerPC needs a signed char - powerpc) - CFLAGS="$CFLAGS -fsigned-char" - ;; - powerpc64) - CFLAGS="$CFLAGS -fsigned-char" - case $target_os in - aix*) - CC="$CC -maix64" - ;; - esac - ;; - esac - # Certain platforms needs special flags for multi-threaded code - if test "$ac_enable_threads" = yes; then - case $target_os in - freebsd*) - CFLAGS="$CFLAGS -pthread" - CPPFLAGS="$CPPFLAGS -pthread" - LDFLAGS="$LDFLAGS -pthread" - ;; - osf*) - CFLAGS="$CFLAGS -pthread" - CPPFLAGS="$CPPFLAGS -pthread" - ;; - esac - fi - if test "$ac_enable_debug" = yes; then - BEECRYPT_CFLAGS_REM([-O2]) - CFLAGS="$CFLAGS -Wall -pedantic" - else - # Generic optimizations, including cpu tuning - BEECRYPT_CFLAGS_REM([-g]) - BEECRYPT_CFLAGS_REM([-O2]) - CFLAGS="$CFLAGS -O3 -fomit-frame-pointer" - if test "$bc_cv_c_aggressive_opt" = yes; then - case $bc_target_cpu in - athlon*) - CFLAGS="$CFLAGS -mcpu=pentiumpro"; - ;; - i586) - CFLAGS="$CFLAGS -mcpu=pentium" - ;; - i686) - CFLAGS="$CFLAGS -mcpu=pentiumpro" - ;; - ia64) - # no -mcpu=... option on ia64 - ;; - pentium*) - CFLAGS="$CFLAGS -mcpu=$bc_target_arch" - ;; - esac - # Architecture-specific optimizations - case $bc_target_arch in - athlon*) - CFLAGS="$CFLAGS -march=$bc_target_arch" - ;; - i586) - CFLAGS="$CFLAGS -march=pentium" - ;; - i686) - CFLAGS="$CFLAGS -march=pentiumpro" - ;; - pentium*) - CFLAGS="$CFLAGS -march=$bc_target_arch" - ;; - powerpc | powerpc64) - CFLAGS="$CFLAGS -mcpu=$bc_target_arch" - ;; - sparcv8) - CFLAGS="$CFLAGS -mv8" - ;; - sparcv8plus) - CFLAGS="$CFLAGS -mv8plus" - ;; - esac - fi - fi - ]) - - -dnl BEECRYPT_GNU_CXX -AC_DEFUN([BEECRYPT_GNU_CXX],[ - AC_REQUIRE([AC_PROG_CXX]) - case $bc_target_arch in - ia64) - case $target_os in - # HP/UX on Itanium needs to be told that a long is 64-bit! - hpux*) - CXXFLAGS="$CXXFLAGS -mlp64" - ;; - esac - ;; - # PowerPC needs a signed char - powerpc) - CXXFLAGS="$CXXFLAGS -fsigned-char" - ;; - powerpc64) - CXXFLAGS="$CXXFLAGS -fsigned-char" - case $target_os in - aix*) - CXX="$CXX -maix64" - ;; - esac - ;; - esac - # Certain platforms needs special flags for multi-threaded code - if test "$ac_enable_threads" = yes; then - case $target_os in - freebsd*) - CXXFLAGS="$CXXFLAGS -pthread" - CXXCPPFLAGS="$CXXCPPFLAGS -pthread" - LDFLAGS="$LDFLAGS -pthread" - ;; - osf*) - CXXFLAGS="$CXXFLAGS -pthread" - CXXCPPFLAGS="$CXXCPPFLAGS -pthread" - ;; - esac - fi - if test "$ac_enable_debug" = yes; then - BEECRYPT_CXXFLAGS_REM([-O2]) - CXXFLAGS="$CXXFLAGS -Wall -pedantic" - else - # Generic optimizations, including cpu tuning - BEECRYPT_CXXFLAGS_REM([-g]) - if test "$bc_cv_c_aggressive_opt" = yes; then - case $bc_target_cpu in - athlon*) - CXXFLAGS="$CXXFLAGS -mcpu=pentiumpro"; - ;; - i586) - CXXFLAGS="$CXXFLAGS -mcpu=pentium" - ;; - i686) - CXXFLAGS="$CXXFLAGS -mcpu=pentiumpro" - ;; - ia64) - # no -mcpu=... option on ia64 - ;; - pentium*) - CXXFLAGS="$CXXFLAGS -mcpu=$bc_target_arch" - ;; - esac - # Architecture-specific optimizations - case $bc_target_arch in - athlon*) - CXXFLAGS="$CXXFLAGS -march=$bc_target_arch" - ;; - i586) - CXXFLAGS="$CXXFLAGS -march=pentium" - ;; - i686) - CXXFLAGS="$CXXFLAGS -march=pentiumpro" - ;; - pentium*) - CXXFLAGS="$CXXFLAGS -march=$bc_target_arch" - ;; - powerpc | powerpc64) - CXXFLAGS="$CXXFLAGS -mcpu=$bc_target_arch" - ;; - sparcv8) - CXXFLAGS="$CXXFLAGS -mv8" - ;; - sparcv8plus) - CXXFLAGS="$CXXFLAGS -mv8plus" - ;; - esac - fi - fi - ]) - - -dnl BEECRYPT_COMPAQ_CC -AC_DEFUN([BEECRYPT_COMPAQ_CC],[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_PROG_CPP]) - AC_CACHE_CHECK([whether we are using Compaq's C compiler],bc_cv_prog_COMPAQ_CC,[ - AC_EGREP_CPP(yes,[ - #ifdef __DECC - yes; - #endif - ],bc_cv_prog_COMPAQ_CC=yes,bc_cv_prog_COMPAQ_CC=no) - ]) - if test "$bc_cv_prog_COMPAQ_CC" = yes; then - if test "$ac_enable_threads" = yes; then - CFLAGS="$CFLAGS -pthread" - CPPFLAGS="$CPPFLAGS -pthread" - fi - if test "$ac_enable_debug" != yes; then - BEECRYPT_CFLAGS_REM([-g]) - if test "$bc_cv_c_aggressive_opt" = yes; then - CFLAGS="$CFLAGS -fast" - fi - fi - fi - ]) - - -dnl BEECRYPT_COMPAQ_CXX -AC_DEFUN([BEECRYPT_COMPAQ_CXX],[ - ]) - - -dnl BEECRYPT_HPUX_CC -AC_DEFUN([BEECRYPT_HPUX_CC],[ - if test "$ac_enable_debug" != yes; then - BEECRYPT_CFLAGS_REM([-g]) - if test "$bc_cv_c_aggressive_opt" = yes; then - CFLAGS="$CFLAGS -fast" - fi - fi - ]) - - -dnl BEECRYPT_HP_CXX -AC_DEFUN([BEECRYPT_HP_CXX],[ - ]) - - -dnl BEECRYPT_IBM_CC -AC_DEFUN([BEECRYPT_IBM_CC],[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_PROG_CPP]) - AC_CACHE_CHECK([whether we are using IBM C],bc_cv_prog_IBM_CC,[ - AC_EGREP_CPP(yes,[ - #ifdef __IBMC__ - yes; - #endif - ],bc_cv_prog_IBM_CC=yes,bc_cv_prog_IBM_CC=no) - ]) - if test "$bc_cv_prog_IBM_CC" = yes; then - case $bc_target_arch in - powerpc) - CC="$CC -q32 -qarch=ppc" - ;; - powerpc64) - CC="$CC -q64 -qarch=ppc64" - ;; - esac - if test "$ac_enable_debug" != yes; then - BEECRYPT_CFLAGS_REM([-g]) - if test "$bc_cv_c_aggressive_opt" = yes; then - if test "$ac_with_arch" = yes; then - CFLAGS="$CFLAGS -O5" - else - CFLAGS="$CFLAGS -O3" - fi - fi - fi - # Version 5.0 doesn't have this, but 6.0 does - AC_CHECK_FUNC([__rotatel4]) - fi - ]) - - -dnl BEECRYPT_IBM_CXX -AC_DEFUN([BEECRYPT_IBM_CXX],[ - ]) - - -dnl BEECRYPT_INTEL_CC -AC_DEFUN([BEECRYPT_INTEL_CC],[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_PROG_CPP]) - AC_CACHE_CHECK([whether we are using Intel C++],bc_cv_prog_INTEL_CC,[ - AC_EGREP_CPP(yes,[ - #ifdef __INTEL_COMPILER - yes; - #endif - ],bc_cv_prog_INTEL_CC=yes,bc_cv_prog_INTEL_CC=no) - ]) - if test "$bc_cv_prog_INTEL_CC" = yes; then - if test "$ac_enable_debug" != yes; then - BEECRYPT_CFLAGS_REM([-g]) - if test "$bc_cv_c_aggressive_opt" = yes; then - case $bc_target_cpu in - i586 | pentium | pentium-mmx) - CFLAGS="$CFLAGS -mcpu=pentium" - ;; - i686 | pentiumpro | pentium[[23]]) - CFLAGS="$CFLAGS -mcpu=pentiumpro" - ;; - pentium4) - CFLAGS="$CFLAGS -mcpu=pentium4" - ;; - esac - case $bc_target_arch in - i586 | pentium | pentium-mmx) - CFLAGS="$CFLAGS -tpp5" - ;; - i686 | pentiumpro) - CFLAGS="$CFLAGS -tpp6 -march=pentiumpro" - ;; - pentium2) - CFLAGS="$CFLAGS -tpp6 -march=pentiumii" - ;; - pentium3) - CFLAGS="$CFLAGS -tpp6 -march=pentiumiii" - ;; - pentium4) - CFLAGS="$CFLAGS -tpp7 -march=pentium4" - ;; - esac - fi - fi - AC_CHECK_FUNC([_rotl]) - AC_CHECK_FUNC([_rotr]) - fi - ]) - - -dnl BEECRYPT_INTEL_CXX -AC_DEFUN([BEECRYPT_INTEL_CXX],[ - ]) - - -dnl BEECRYPT_SUN_FORTE_CC -AC_DEFUN([BEECRYPT_SUN_FORTE_CC],[ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_PROG_CPP]) - AC_CACHE_CHECK([whether we are using Sun Forte C],bc_cv_prog_SUN_FORTE_CC,[ - AC_EGREP_CPP(yes,[ - #ifdef __SUNPRO_C - yes; - #endif - ],bc_cv_prog_SUN_FORTE_CC=yes,bc_cv_prog_SUN_FORTE_CC=no) - ]) - if test "$bc_cv_prog_SUN_FORTE_CC" = yes; then - if test "$ac_enable_threads" = yes; then - CFLAGS="$CFLAGS -mt" - fi - if test "$ac_enable_debug" != yes; then - BEECRYPT_CFLAGS_REM([-g]) - if test "$bc_cv_c_aggressive_opt" = yes; then - CFLAGS="$CFLAGS -fast" - case $bc_target_arch in - sparc) - CFLAGS="$CFLAGS -xtarget=generic -xarch=generic" - ;; - sparcv8) - CFLAGS="$CFLAGS -xtarget=generic -xarch=v8" - ;; - sparcv8plus*) - CFLAGS="$CFLAGS -xtarget=generic -xarch=v8plus" - ;; - sparcv9*) - CFLAGS="$CFLAGS -xtarget=generic64 -xarch=v9" - ;; - esac - fi - fi - fi - ]) - - -dnl BEECRYPT_SUN_FORTE_CXX -AC_DEFUN([BEECRYPT_SUN_FORTE_CXX],[ - ]) - - -dnl BEECRYPT_CC -AC_DEFUN([BEECRYPT_CC],[ - if test "$CFLAGS" = ""; then - bc_cv_c_aggressive_opt=yes - else - bc_cv_c_aggressive_opt=no - fi - # set flags for large file support - case $target_os in - linux* | solaris*) - CPPFLAGS="$CPPFLAGS `getconf LFS_CFLAGS`" - LDFLAGS="$LDFLAGS `getconf LFS_LDFLAGS`" - ;; - esac - if test "$ac_cv_c_compiler_gnu" = yes; then - # Intel's icc can be mistakenly identified as gcc - case $target_os in - linux*) - BEECRYPT_INTEL_CC - ;; - esac - if test "$bc_cv_prog_INTEL_CC" != yes; then - BEECRYPT_GNU_CC - fi - else - case $target_os in - aix*) - BEECRYPT_IBM_CC - ;; - hpux*) - BEECRYPT_HPUX_CC - ;; - linux*) - BEECRYPT_INTEL_CC - ;; - solaris*) - BEECRYPT_SUN_FORTE_CC - ;; - osf*) - BEECRYPT_COMPAQ_CC - ;; - esac - fi - ]) - - -dnl BEECRYPT_CXX -AC_DEFUN([BEECRYPT_CXX],[ - if test "$CXXFLAGS" = ""; then - bc_cv_cxx_aggressive_opt=yes - else - bc_cv_cxx_aggressive_opt=no - fi - if test "$ac_cv_cxx_compiler_gnu" = yes; then - # Intel's icc can be mistakenly identified as gcc - case $target_os in - linux*) - BEECRYPT_INTEL_CXX - ;; - esac - if test "$bc_cv_prog_INTEL_CXX" != yes; then - BEECRYPT_GNU_CXX - fi - else - case $target_os in - aix*) - BEECRYPT_IBM_CXX - ;; - hpux*) - BEECRYPT_HPUX_CXX - ;; - linux*) - BEECRYPT_INTEL_CXX - ;; - solaris*) - BEECRYPT_SUN_FORTE_CXX - ;; - osf*) - BEECRYPT_COMPAQ_CXX - ;; - esac - fi - ]) - - -dnl BEECRYPT_NOEXECSTACK -AC_DEFUN([BEECRYPT_NOEXECSTACK],[ - AC_CACHE_CHECK([whether the assembler can use noexecstack],bc_cv_as_noexecstack,[ - cat > conftest.c << EOF -void foo(void) { } -EOF - if AC_TRY_COMMAND([$CC -c -o conftest.o conftest.c]) then - bc_cv_as_noexecstack=yes - if test "$ac_cv_c_compiler_gnu" = yes; then - CFLAGS="$CFLAGS -Wa,--noexecstack" - fi - if test "$ac_cv_cxx_compiler_gnu" = yes; then - CXXFLAGS="$CXXFLAGS -Wa,--noexecstack" - fi - else - bc_cv_as_noexecstack=no - fi - ]) - AC_CACHE_CHECK([whether the linker can use noexecstack],bc_cv_ld_noexecstack,[ - if AC_TRY_COMMAND([$LD -z noexecstack -o conftest conftest.o]) then - bc_cv_ld_noexecstack=yes - LDFLAGS="$LDFLAGS -z noexecstack" - else - bc_cv_ld_noexecstack=no - fi - ]) - ]) - - -dnl BEECRYPT_LIBTOOL -AC_DEFUN([BEECRYPT_LIBTOOL],[ - case $target_os in - aix*) - case $bc_target_arch in - powerpc64) - AR="ar -X64" - NM="/usr/bin/nm -B -X64" - ;; - esac - ;; - solaris*) - case $bc_target_arch in - sparcv9*) - LD="/usr/ccs/bin/ld -64" - ;; - esac - ;; - esac - ]) - - -dnl BEECRYPT_OS_DEFS -AC_DEFUN([BEECRYPT_OS_DEFS],[ - AH_TEMPLATE([AIX],[Define to 1 if you are using AIX]) - AH_TEMPLATE([CYGWIN],[Define to 1 if you are using Cygwin]) - AH_TEMPLATE([DARWIN],[Define to 1 if you are using Darwin/MacOS X]) - AH_TEMPLATE([FREEBSD],[Define to 1 if you are using FreeBSD]) - AH_TEMPLATE([HPUX],[Define to 1 if you are using HPUX]) - AH_TEMPLATE([LINUX],[Define to 1 if you are using GNU/Linux]) - AH_TEMPLATE([NETBSD],[Define to 1 if you are using NetBSD]) - AH_TEMPLATE([OPENBSD],[Define to 1 if you are using OpenBSD]) - AH_TEMPLATE([OSF],[Define to 1 if you are using OSF]) - AH_TEMPLATE([QNX],[Define to 1 if you are using QNX]) - AH_TEMPLATE([SCO_UNIX],[Define to 1 if you are using SCO Unix]) - AH_TEMPLATE([SOLARIS],[Define to 1 if you are using Solaris]) - AH_VERBATIM([WIN32],[ -#ifndef WIN32 - #undef WIN32 -#endif - ]) - - case $target_os in - aix*) - AC_DEFINE([AIX]) - ;; - cygwin*) - AC_DEFINE([CYGWIN]) - AC_DEFINE([WIN32]) - ;; - darwin*) - AC_DEFINE([DARWIN]) - ;; - freebsd*) - AC_DEFINE([FREEBSD]) - ;; - hpux*) - AC_DEFINE([HPUX]) - ;; - linux*) - AC_DEFINE([LINUX]) - ;; - netbsd*) - AC_DEFINE([NETBSD]) - ;; - openbsd*) - AC_DEFINE([OPENBSD]) - ;; - osf*) - AC_DEFINE([OSF]) - ;; - *qnx) - AC_DEFINE([QNX]) - ;; - solaris*) - AC_DEFINE([SOLARIS]) - ;; - sysv*uv*) - AC_DEFINE([SCO_UNIX]) - ;; - *) - AC_MSG_WARN([Operating system type $target_os currently not supported and/or tested]) - ;; - esac - ]) - - -dnl BEECRYPT_ASM_DEFS -AC_DEFUN([BEECRYPT_ASM_DEFS],[ - AC_SUBST(ASM_OS,$target_os) - AC_SUBST(ASM_CPU,$bc_target_cpu) - AC_SUBST(ASM_ARCH,$bc_target_arch) - AC_SUBST(ASM_BIGENDIAN,$ac_cv_c_bigendian) - ]) - - -dnl BEECRYPT_ASM_TEXTSEG -AC_DEFUN([BEECRYPT_ASM_TEXTSEG],[ - AC_CACHE_CHECK([how to switch to text segment], - bc_cv_asm_textseg,[ - case $target_os in - aix*) - bc_cv_asm_textseg=[".csect .text[PR]"] ;; - hpux*) - if test "$bc_target_arch" = ia64; then - bc_cv_asm_textseg=[".section .text"] - else - bc_cv_asm_textseg=".code" - fi - ;; - *) - bc_cv_asm_textseg=".text" ;; - esac - ]) - AC_SUBST(ASM_TEXTSEG,$bc_cv_asm_textseg) - ]) - - -dnl BEECRYPT_ASM_GLOBL -AC_DEFUN([BEECRYPT_ASM_GLOBL],[ - AC_CACHE_CHECK([how to declare a global symbol], - bc_cv_asm_globl,[ - case $target_os in - hpux*) bc_cv_asm_globl=".export" ;; - *) bc_cv_asm_globl=".globl" ;; - esac - ]) - AC_SUBST(ASM_GLOBL,$bc_cv_asm_globl) - ]) - - -dnl BEECRYPT_ASM_GSYM_PREFIX -AC_DEFUN([BEECRYPT_ASM_GSYM_PREFIX],[ - AC_CACHE_CHECK([if global symbols need leading underscore], - bc_cv_asm_gsym_prefix,[ - case $target_os in - cygwin* | darwin*) bc_cv_asm_gsym_prefix="_" ;; - *) bc_cv_asm_gsym_prefix="" ;; - esac - ]) - AC_SUBST(ASM_GSYM_PREFIX,$bc_cv_asm_gsym_prefix) - ]) - - -dnl BEECRYPT_ASM_LSYM_PREFIX -AC_DEFUN([BEECRYPT_ASM_LSYM_PREFIX],[ - AC_CACHE_CHECK([how to declare a local symbol], - bc_cv_asm_lsym_prefix,[ - case $target_os in - aix* | darwin*) bc_cv_asm_lsym_prefix="L" ;; - hpux* | osf*) bc_cv_asm_lsym_prefix="$" ;; - linux*) - case $target_cpu in - alpha*) bc_cv_asm_lsym_prefix="$" ;; - *) bc_cv_asm_lsym_prefix=".L" ;; - esac - ;; - *) bc_cv_asm_lsym_prefix=".L" ;; - esac - ]) - AC_SUBST(ASM_LSYM_PREFIX,$bc_cv_asm_lsym_prefix) - ]) - - -dnl BEECRYPT_ASM_ALIGN -AC_DEFUN([BEECRYPT_ASM_ALIGN],[ - AC_CACHE_CHECK([how to align symbols], - bc_cv_asm_align,[ - case $target_cpu in - alpha*) - bc_cv_asm_align=".align 5" ;; - i[[3456]]86 | athlon*) - bc_cv_asm_align=".align 4" ;; - ia64) - bc_cv_asm_align=".align 16" ;; - powerpc*) - bc_cv_asm_align=".align 2" ;; - s390x) - bc_cv_asm_align=".align 4" ;; - sparc*) - bc_cv_asm_align=".align 4" ;; - x86_64) - bc_cv_asm_align=".align 16" ;; - esac - ]) - AC_SUBST(ASM_ALIGN,$bc_cv_asm_align) - ]) - - -dnl BEECRYPT_ASM_SOURCES -AC_DEFUN([BEECRYPT_ASM_SOURCES],[ - echo > mpopt.s - echo > aesopt.s - echo > blowfishopt.s - echo > sha1opt.s - if test "$ac_enable_debug" != yes; then - case $bc_target_arch in - arm) - AC_CONFIG_COMMANDS([mpopt.arm],[ - m4 $srcdir/gas/mpopt.arm.m4 > mpopt.s - ]) - ;; - alpha*) - AC_CONFIG_COMMANDS([mpopt.alpha],[ - m4 $srcdir/gas/mpopt.alpha.m4 > mpopt.s - ]) - ;; - athlon* | i[[3456]]86 | pentium*) - AC_CONFIG_COMMANDS([aesopt.x86],[ - m4 $srcdir/gas/aesopt.x86.m4 > aesopt.s - ]) - AC_CONFIG_COMMANDS([mpopt.x86],[ - m4 $srcdir/gas/mpopt.x86.m4 > mpopt.s - ]) - AC_CONFIG_COMMANDS([sha1opt.x86],[ - m4 $srcdir/gas/sha1opt.x86.m4 > sha1opt.s - ]) - ;; - ia64) - AC_CONFIG_COMMANDS([mpopt.ia64],[ - m4 $srcdir/gas/mpopt.ia64.m4 > mpopt.s - ]) - ;; - m68k) - AC_CONFIG_COMMANDS([mpopt.m68k],[ - m4 $srcdir/gas/mpopt.m68k.m4 > mpopt.s - ]) - ;; - powerpc) - AC_CONFIG_COMMANDS([mpopt.ppc],[ - m4 $srcdir/gas/mpopt.ppc.m4 > mpopt.s - ]) - AC_CONFIG_COMMANDS([blowfishopt.ppc],[ - m4 $srcdir/gas/blowfishopt.ppc.m4 > blowfishopt.s - ]) - ;; - powerpc64) - AC_CONFIG_COMMANDS([mpopt.ppc64],[ - m4 $srcdir/gas/mpopt.ppc64.m4 > mpopt.s - ]) - ;; - s390x) - AC_CONFIG_COMMANDS([mpopt.s390x],[ - m4 $srcdir/gas/mpopt.s390x.m4 > mpopt.s - ]) - ;; - sparcv8) - AC_CONFIG_COMMANDS([mpopt.sparcv8],[ - m4 $srcdir/gas/mpopt.sparcv8.m4 > mpopt.s - ]) - ;; - sparcv8plus) - AC_CONFIG_COMMANDS([mpopt.sparcv8plus],[ - m4 $srcdir/gas/mpopt.sparcv8plus.m4 > mpopt.s - ]) - ;; - x86_64) - AC_CONFIG_COMMANDS([mpopt.x86_64],[ - m4 $srcdir/gas/mpopt.x86_64.m4 > mpopt.s - ]) - ;; - esac - if test "$ac_with_arch" = yes; then - # Code is i586-specific! - case $bc_target_arch in - athlon* | i[[56]]86 | pentium*) - AC_CONFIG_COMMANDS([blowfishopt.i586],[ - m4 $srcdir/gas/blowfishopt.i586.m4 > blowfishopt.s - ]) - ;; - esac - fi - fi - ]) - - -dnl BEECRYPT_DLFCN - -AC_DEFUN([BEECRYPT_DLFCN],[ - AH_TEMPLATE([HAVE_DLFCN_H],[.]) - AC_CHECK_HEADERS([dlfcn.h]) - if test "$ac_cv_header_dlfcn_h" = yes; then - AC_SEARCH_LIBS([dlopen],[dl dld],[ - ]) - fi - ]) - - -dnl BEECRYPT_MULTITHREAD -AC_DEFUN([BEECRYPT_MULTITHREAD],[ - AH_TEMPLATE([ENABLE_THREADS],[Define to 1 if you want to enable multithread support]) - AH_TEMPLATE([HAVE_THREAD_H],[.]) - AH_TEMPLATE([HAVE_PTHREAD_H],[.]) - AH_TEMPLATE([HAVE_SYNCH_H],[.]) - AH_TEMPLATE([HAVE_SEMAPHORE_H],[.]) - - if test "$ac_enable_threads" = yes; then - AC_CHECK_HEADERS([synch.h thread.h pthread.h semaphore.h]) - fi - - bc_include_synch_h= - bc_include_thread_h= - bc_include_pthread_h= - bc_typedef_bc_cond_t= - bc_typedef_bc_mutex_t= - bc_typedef_bc_thread_t= - if test "$ac_enable_threads" = yes; then - if test "$ac_cv_header_thread_h" = yes -a "$ac_cv_header_synch_h" = yes; then - bc_include_synch_h="#include <synch.h>" - bc_include_thread_h="#include <thread.h>" - bc_typedef_bc_cond_t="typedef cond_t bc_cond_t;" - bc_typedef_bc_mutex_t="typedef mutex_t bc_mutex_t;" - bc_typedef_bc_thread_t="typedef thread_t bc_thread_t;" - AC_SEARCH_LIBS([mutex_lock],[thread],[ - AC_DEFINE([ENABLE_THREADS],1) - ]) - elif test "$ac_cv_header_pthread_h" = yes; then - bc_include_pthread_h="#include <pthread.h>" - bc_typedef_bc_cond_t="typedef pthread_cond_t bc_cond_t;" - bc_typedef_bc_mutex_t="typedef pthread_mutex_t bc_mutex_t;" - bc_typedef_bc_thread_t="typedef pthread_t bc_thread_t;" - # On most systems this tests will say 'none required', but that doesn't - # mean that the linked code will work correctly! - case $target_os in - linux* | solaris* ) - AC_DEFINE([ENABLE_THREADS],1) - LIBS="-lpthread $LIBS" - ;; - osf*) - AC_DEFINE([ENABLE_THREADS],1) - LIBS="-lpthread -lmach -lexc $LIBS" - ;; - *) - AC_SEARCH_LIBS([pthread_mutex_lock],[pthread],[ - AC_DEFINE([ENABLE_THREADS],1) - ]) - ;; - esac - else - AC_MSG_WARN([Don't know which thread library to check for]) - fi - fi - AC_SUBST(INCLUDE_SYNCH_H,$bc_include_synch_h) - AC_SUBST(INCLUDE_THREAD_H,$bc_include_thread_h) - AC_SUBST(INCLUDE_PTHREAD_H,$bc_include_pthread_h) - AC_SUBST(TYPEDEF_BC_COND_T,$bc_typedef_bc_cond_t) - AC_SUBST(TYPEDEF_BC_MUTEX_T,$bc_typedef_bc_mutex_t) - AC_SUBST(TYPEDEF_BC_THREAD_T,$bc_typedef_bc_thread_t) - ]) diff --git a/beecrypt/aes.c b/beecrypt/aes.c deleted file mode 100644 index a1e13142b..000000000 --- a/beecrypt/aes.c +++ /dev/null @@ -1,387 +0,0 @@ -/* - * Copyright (c) 2002, 2003 Bob Deblier - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file aes.c - * \brief AES block cipher, as specified by NIST FIPS 197. - * - * The table lookup method was inspired by Brian Gladman's AES implementation, - * which is much more readable than the standard code. - * - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup BC_aes_m BC_m - */ - -#include "system.h" - -#include "beecrypt.h" -#include "aesopt.h" -#include "aes.h" -#include "mp.h" - -#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && defined(LITTLE_ENDIAN) -# if (BYTE_ORDER != BIG_ENDIAN) && (BYTE_ORDER != LITTLE_ENDIAN) -# error unsupported endian-ness. -# endif -#endif - -#if WORDS_BIGENDIAN -# include "aes_be.h" -#else -# include "aes_le.h" -#endif - -#include "debug.h" - -#ifdef ASM_AESENCRYPTECB -extern int aesEncryptECB(aesParam*, uint32_t*, const uint32_t*, unsigned int); -#endif - -#ifdef ASM_AESDECRYPTECB -extern int aesDecryptECB(aesParam*, uint32_t*, const uint32_t*, unsigned int); -#endif - -const blockCipher aes = { - "AES", - sizeof(aesParam), - 16, - 128, - 256, - 64, - (blockCipherSetup) aesSetup, - (blockCipherSetIV) aesSetIV, - /* raw */ - { - (blockCipherRawcrypt) aesEncrypt, - (blockCipherRawcrypt) aesDecrypt - }, - /* ecb */ - { - #ifdef ASM_AESENCRYPTECB - (blockCipherModcrypt) aesEncryptECB, - #else - (blockCipherModcrypt) 0, - #endif - #ifdef ASM_AESDECRYPTECB - (blockCipherModcrypt) aesDecryptECB, - #else - (blockCipherModcrypt) 0, - #endif - }, - /* cbc */ - { - (blockCipherModcrypt) 0, - (blockCipherModcrypt) 0 - }, - (blockCipherFeedback) aesFeedback -}; - -int aesSetup(aesParam* ap, const byte* key, size_t keybits, cipherOperation op) -{ - if ((op != ENCRYPT) && (op != DECRYPT)) - return -1; - - if (((keybits & 63) == 0) && (keybits >= 128) && (keybits <= 256)) - { - register uint32_t* rk, t, i, j; - - /* clear fdback/iv */ - ap->fdback[0] = 0; - ap->fdback[1] = 0; - ap->fdback[2] = 0; - ap->fdback[3] = 0; - - ap->nr = 6 + (keybits >> 5); - - rk = ap->k; - - memcpy(rk, key, keybits >> 3); - - i = 0; - - if (keybits == 128) - { - while (1) - { - t = rk[3]; - #if WORDS_BIGENDIAN - t = (_ae4[(t >> 16) & 0xff] & 0xff000000) ^ - (_ae4[(t >> 8) & 0xff] & 0x00ff0000) ^ - (_ae4[(t ) & 0xff] & 0x0000ff00) ^ - (_ae4[(t >> 24) ] & 0x000000ff) ^ - _arc[i]; - #else - t = (_ae4[(t >> 8) & 0xff] & 0x000000ff) ^ - (_ae4[(t >> 16) & 0xff] & 0x0000ff00) ^ - (_ae4[(t >> 24) ] & 0x00ff0000) ^ - (_ae4[(t ) & 0xff] & 0xff000000) ^ - _arc[i]; - #endif - rk[4] = (t ^= rk[0]); - rk[5] = (t ^= rk[1]); - rk[6] = (t ^= rk[2]); - rk[7] = (t ^= rk[3]); - if (++i == 10) - break; - rk += 4; - } - } - else if (keybits == 192) - { - while (1) - { - t = rk[5]; - #if WORDS_BIGENDIAN - t = (_ae4[(t >> 16) & 0xff] & 0xff000000) ^ - (_ae4[(t >> 8) & 0xff] & 0x00ff0000) ^ - (_ae4[(t ) & 0xff] & 0x0000ff00) ^ - (_ae4[(t >> 24) ] & 0x000000ff) ^ - _arc[i]; - #else - t = (_ae4[(t >> 8) & 0xff] & 0x000000ff) ^ - (_ae4[(t >> 16) & 0xff] & 0x0000ff00) ^ - (_ae4[(t >> 24) ] & 0x00ff0000) ^ - (_ae4[(t ) & 0xff] & 0xff000000) ^ - _arc[i]; - #endif - rk[6] = (t ^= rk[0]); - rk[7] = (t ^= rk[1]); - rk[8] = (t ^= rk[2]); - rk[9] = (t ^= rk[3]); - if (++i == 8) - break; - rk[10] = (t ^= rk[4]); - rk[11] = (t ^= rk[5]); - rk += 6; - } - } - else if (keybits == 256) - { - while (1) - { - t = rk[7]; - #if WORDS_BIGENDIAN - t = (_ae4[(t >> 16) & 0xff] & 0xff000000) ^ - (_ae4[(t >> 8) & 0xff] & 0x00ff0000) ^ - (_ae4[(t ) & 0xff] & 0x0000ff00) ^ - (_ae4[(t >> 24) ] & 0x000000ff) ^ - _arc[i]; - #else - t = (_ae4[(t >> 8) & 0xff] & 0x000000ff) ^ - (_ae4[(t >> 16) & 0xff] & 0x0000ff00) ^ - (_ae4[(t >> 24) ] & 0x00ff0000) ^ - (_ae4[(t ) & 0xff] & 0xff000000) ^ - _arc[i]; - #endif - rk[8] = (t ^= rk[0]); - rk[9] = (t ^= rk[1]); - rk[10] = (t ^= rk[2]); - rk[11] = (t ^= rk[3]); - if (++i == 7) - break; - #if WORDS_BIGENDIAN - t = (_ae4[(t >> 24) ] & 0xff000000) ^ - (_ae4[(t >> 16) & 0xff] & 0x00ff0000) ^ - (_ae4[(t >> 8) & 0xff] & 0x0000ff00) ^ - (_ae4[(t ) & 0xff] & 0x000000ff); - #else - t = (_ae4[(t ) & 0xff] & 0x000000ff) ^ - (_ae4[(t >> 8) & 0xff] & 0x0000ff00) ^ - (_ae4[(t >> 16) & 0xff] & 0x00ff0000) ^ - (_ae4[(t >> 24) ] & 0xff000000); - #endif - rk[12] = (t ^= rk[4]); - rk[13] = (t ^= rk[5]); - rk[14] = (t ^= rk[6]); - rk[15] = (t ^= rk[7]); - rk += 8; - } - } - - if (op == DECRYPT) - { - rk = ap->k; - - for (i = 0, j = (ap->nr << 2); i < j; i += 4, j -= 4) - { - t = rk[i ]; rk[i ] = rk[j ]; rk[j ] = t; - t = rk[i+1]; rk[i+1] = rk[j+1]; rk[j+1] = t; - t = rk[i+2]; rk[i+2] = rk[j+2]; rk[j+2] = t; - t = rk[i+3]; rk[i+3] = rk[j+3]; rk[j+3] = t; - } - for (i = 1; i < ap->nr; i++) - { - rk += 4; - #if WORDS_BIGENDIAN - rk[0] = - _ad0[_ae4[(rk[0] >> 24) ] & 0xff] ^ - _ad1[_ae4[(rk[0] >> 16) & 0xff] & 0xff] ^ - _ad2[_ae4[(rk[0] >> 8) & 0xff] & 0xff] ^ - _ad3[_ae4[(rk[0] ) & 0xff] & 0xff]; - rk[1] = - _ad0[_ae4[(rk[1] >> 24) ] & 0xff] ^ - _ad1[_ae4[(rk[1] >> 16) & 0xff] & 0xff] ^ - _ad2[_ae4[(rk[1] >> 8) & 0xff] & 0xff] ^ - _ad3[_ae4[(rk[1] ) & 0xff] & 0xff]; - rk[2] = - _ad0[_ae4[(rk[2] >> 24) ] & 0xff] ^ - _ad1[_ae4[(rk[2] >> 16) & 0xff] & 0xff] ^ - _ad2[_ae4[(rk[2] >> 8) & 0xff] & 0xff] ^ - _ad3[_ae4[(rk[2] ) & 0xff] & 0xff]; - rk[3] = - _ad0[_ae4[(rk[3] >> 24) ] & 0xff] ^ - _ad1[_ae4[(rk[3] >> 16) & 0xff] & 0xff] ^ - _ad2[_ae4[(rk[3] >> 8) & 0xff] & 0xff] ^ - _ad3[_ae4[(rk[3] ) & 0xff] & 0xff]; - #else - rk[0] = - _ad0[_ae4[(rk[0] ) & 0xff] & 0xff] ^ - _ad1[_ae4[(rk[0] >> 8) & 0xff] & 0xff] ^ - _ad2[_ae4[(rk[0] >> 16) & 0xff] & 0xff] ^ - _ad3[_ae4[(rk[0] >> 24) ] & 0xff]; - rk[1] = - _ad0[_ae4[(rk[1] ) & 0xff] & 0xff] ^ - _ad1[_ae4[(rk[1] >> 8) & 0xff] & 0xff] ^ - _ad2[_ae4[(rk[1] >> 16) & 0xff] & 0xff] ^ - _ad3[_ae4[(rk[1] >> 24) ] & 0xff]; - rk[2] = - _ad0[_ae4[(rk[2] ) & 0xff] & 0xff] ^ - _ad1[_ae4[(rk[2] >> 8) & 0xff] & 0xff] ^ - _ad2[_ae4[(rk[2] >> 16) & 0xff] & 0xff] ^ - _ad3[_ae4[(rk[2] >> 24) ] & 0xff]; - rk[3] = - _ad0[_ae4[(rk[3] ) & 0xff] & 0xff] ^ - _ad1[_ae4[(rk[3] >> 8) & 0xff] & 0xff] ^ - _ad2[_ae4[(rk[3] >> 16) & 0xff] & 0xff] ^ - _ad3[_ae4[(rk[3] >> 24) ] & 0xff]; - #endif - } - } - return 0; - } - return -1; -} - -#ifndef ASM_AESSETIV -int aesSetIV(aesParam* ap, const byte* iv) -{ - if (iv) - memcpy(ap->fdback, iv, 16); - else - memset(ap->fdback, 0, 16); - - return 0; -} -#endif - -#ifndef ASM_AESENCRYPT -int aesEncrypt(aesParam* ap, uint32_t* dst, const uint32_t* src) -{ - register uint32_t s0, s1, s2, s3; - register uint32_t t0, t1, t2, t3; - register uint32_t* rk = ap->k; - - s0 = src[0] ^ rk[0]; - s1 = src[1] ^ rk[1]; - s2 = src[2] ^ rk[2]; - s3 = src[3] ^ rk[3]; - - etfs(4); /* round 1 */ - esft(8); /* round 2 */ - etfs(12); /* round 3 */ - esft(16); /* round 4 */ - etfs(20); /* round 5 */ - esft(24); /* round 6 */ - etfs(28); /* round 7 */ - esft(32); /* round 8 */ - etfs(36); /* round 9 */ - - if (ap->nr > 10) - { - esft(40); /* round 10 */ - etfs(44); /* round 11 */ - if (ap->nr > 12) - { - esft(48); /* round 12 */ - etfs(52); /* round 13 */ - } - } - - rk += (ap->nr << 2); - - elr(); /* last round */ - - dst[0] = s0; - dst[1] = s1; - dst[2] = s2; - dst[3] = s3; - - return 0; -} -#endif - -#ifndef ASM_AESDECRYPT -int aesDecrypt(aesParam* ap, uint32_t* dst, const uint32_t* src) -{ - register uint32_t s0, s1, s2, s3; - register uint32_t t0, t1, t2, t3; - register uint32_t* rk = ap->k; - - s0 = src[0] ^ rk[0]; - s1 = src[1] ^ rk[1]; - s2 = src[2] ^ rk[2]; - s3 = src[3] ^ rk[3]; - - dtfs(4); /* round 1 */ - dsft(8); /* round 2 */ - dtfs(12); /* round 3 */ - dsft(16); /* round 4 */ - dtfs(20); /* round 5 */ - dsft(24); /* round 6 */ - dtfs(28); /* round 7 */ - dsft(32); /* round 8 */ - dtfs(36); /* round 9 */ - - if (ap->nr > 10) - { - dsft(40); /* round 10 */ - dtfs(44); /* round 11 */ - if (ap->nr > 12) - { - dsft(48); /* round 12 */ - dtfs(52); /* round 13 */ - } - } - - rk += (ap->nr << 2); - - dlr(); /* last round */ - - dst[0] = s0; - dst[1] = s1; - dst[2] = s2; - dst[3] = s3; - - return 0; -} -#endif - -uint32_t* aesFeedback(aesParam* ap) -{ - return ap->fdback; -} diff --git a/beecrypt/aes.h b/beecrypt/aes.h deleted file mode 100644 index c8c22ceff..000000000 --- a/beecrypt/aes.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2002, 2003 Bob Deblier - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file aes.h - * \brief AES block cipher, as specified by NIST FIPS 197. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup BC_m BC_aes_m - */ - -#ifndef _AES_H -#define _AES_H - -#include "beecrypt.h" -#include "aesopt.h" - -/*!\brief Holds all the parameters necessary for the AES cipher. - * \ingroup BC_aes_m - */ -typedef struct -{ - /*!\var k - * \brief Holds the key expansion. - */ - uint32_t k[64]; - /*!\var nr - * \brief Number of rounds to be used in encryption/decryption. - */ - uint32_t nr; - /*!\var fdback - * \brief Buffer to be used by block chaining or feedback modes. - */ - uint32_t fdback[4]; -} aesParam; - -#ifdef __cplusplus -extern "C" { -#endif - -/*!\var aes - * \brief Holds the full API description of the AES algorithm. - */ -extern const BEECRYPTAPI blockCipher aes; - -/*!\fn int aesSetup(aesParam* ap, const byte* key, size_t keybits, cipherOperation op) - * \brief This function performs the cipher's key expansion. - * \param ap The cipher's parameter block. - * \param key The key value. - * \param keybits The number of bits in the key; legal values are: - * 128, 192 and 256. - * \param op ENCRYPT or DECRYPT. - * \retval 0 on success. - * \retval -1 on failure. - */ -BEECRYPTAPI -int aesSetup (aesParam* ap, const byte* key, size_t keybits, cipherOperation op) - /*@modifies ap @*/; - -/*!\fn int aesSetIV(aesParam* ap, const byte* iv) - * \brief This function sets the Initialization Vector. - * \note This function is only useful in block chaining or feedback modes. - * \param ap The cipher's parameter block. - * \param iv The initialization vector; may be null. - * \retval 0 on success. - */ -BEECRYPTAPI -int aesSetIV (aesParam* ap, const byte* iv) - /*@modifies ap @*/; - -/*!\fn aesEncrypt(aesParam* ap, uint32_t* dst, const uint32_t* src) - * \brief This function performs the raw AES encryption; it encrypts one block - * of 128 bits. - * \param ap The cipher's parameter block. - * \param dst The ciphertext; should be aligned on 32-bit boundary. - * \param src The cleartext; should be aligned on 32-bit boundary. - * \retval 0 on success. - */ -BEECRYPTAPI -int aesEncrypt (aesParam* ap, uint32_t* dst, const uint32_t* src) - /*@modifies dst @*/; - -/*!\fn aesDecrypt(aesParam* ap, uint32_t* dst, const uint32_t* src) - * \brief This function performs the raw AES decryption; it decrypts one block - * of 128 bits. - * \param ap The cipher's parameter block. - * \param dst The cleartext; should be aligned on 32-bit boundary. - * \param src The ciphertext; should be aligned on 32-bit boundary. - * \retval 0 on success. - */ -BEECRYPTAPI -int aesDecrypt (aesParam* ap, uint32_t* dst, const uint32_t* src) - /*@modifies dst @*/; - -BEECRYPTAPI -uint32_t* aesFeedback(aesParam* ap) - /*@*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/aes_be.h b/beecrypt/aes_be.h deleted file mode 100644 index 16fcbea10..000000000 --- a/beecrypt/aes_be.h +++ /dev/null @@ -1,850 +0,0 @@ -/* - * Copyright (c) 2003 Bob Deblier - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -const uint32_t _ae0[256] = { - 0xc66363a5, 0xf87c7c84, 0xee777799, 0xf67b7b8d, - 0xfff2f20d, 0xd66b6bbd, 0xde6f6fb1, 0x91c5c554, - 0x60303050, 0x02010103, 0xce6767a9, 0x562b2b7d, - 0xe7fefe19, 0xb5d7d762, 0x4dababe6, 0xec76769a, - 0x8fcaca45, 0x1f82829d, 0x89c9c940, 0xfa7d7d87, - 0xeffafa15, 0xb25959eb, 0x8e4747c9, 0xfbf0f00b, - 0x41adadec, 0xb3d4d467, 0x5fa2a2fd, 0x45afafea, - 0x239c9cbf, 0x53a4a4f7, 0xe4727296, 0x9bc0c05b, - 0x75b7b7c2, 0xe1fdfd1c, 0x3d9393ae, 0x4c26266a, - 0x6c36365a, 0x7e3f3f41, 0xf5f7f702, 0x83cccc4f, - 0x6834345c, 0x51a5a5f4, 0xd1e5e534, 0xf9f1f108, - 0xe2717193, 0xabd8d873, 0x62313153, 0x2a15153f, - 0x0804040c, 0x95c7c752, 0x46232365, 0x9dc3c35e, - 0x30181828, 0x379696a1, 0x0a05050f, 0x2f9a9ab5, - 0x0e070709, 0x24121236, 0x1b80809b, 0xdfe2e23d, - 0xcdebeb26, 0x4e272769, 0x7fb2b2cd, 0xea75759f, - 0x1209091b, 0x1d83839e, 0x582c2c74, 0x341a1a2e, - 0x361b1b2d, 0xdc6e6eb2, 0xb45a5aee, 0x5ba0a0fb, - 0xa45252f6, 0x763b3b4d, 0xb7d6d661, 0x7db3b3ce, - 0x5229297b, 0xdde3e33e, 0x5e2f2f71, 0x13848497, - 0xa65353f5, 0xb9d1d168, 0x00000000, 0xc1eded2c, - 0x40202060, 0xe3fcfc1f, 0x79b1b1c8, 0xb65b5bed, - 0xd46a6abe, 0x8dcbcb46, 0x67bebed9, 0x7239394b, - 0x944a4ade, 0x984c4cd4, 0xb05858e8, 0x85cfcf4a, - 0xbbd0d06b, 0xc5efef2a, 0x4faaaae5, 0xedfbfb16, - 0x864343c5, 0x9a4d4dd7, 0x66333355, 0x11858594, - 0x8a4545cf, 0xe9f9f910, 0x04020206, 0xfe7f7f81, - 0xa05050f0, 0x783c3c44, 0x259f9fba, 0x4ba8a8e3, - 0xa25151f3, 0x5da3a3fe, 0x804040c0, 0x058f8f8a, - 0x3f9292ad, 0x219d9dbc, 0x70383848, 0xf1f5f504, - 0x63bcbcdf, 0x77b6b6c1, 0xafdada75, 0x42212163, - 0x20101030, 0xe5ffff1a, 0xfdf3f30e, 0xbfd2d26d, - 0x81cdcd4c, 0x180c0c14, 0x26131335, 0xc3ecec2f, - 0xbe5f5fe1, 0x359797a2, 0x884444cc, 0x2e171739, - 0x93c4c457, 0x55a7a7f2, 0xfc7e7e82, 0x7a3d3d47, - 0xc86464ac, 0xba5d5de7, 0x3219192b, 0xe6737395, - 0xc06060a0, 0x19818198, 0x9e4f4fd1, 0xa3dcdc7f, - 0x44222266, 0x542a2a7e, 0x3b9090ab, 0x0b888883, - 0x8c4646ca, 0xc7eeee29, 0x6bb8b8d3, 0x2814143c, - 0xa7dede79, 0xbc5e5ee2, 0x160b0b1d, 0xaddbdb76, - 0xdbe0e03b, 0x64323256, 0x743a3a4e, 0x140a0a1e, - 0x924949db, 0x0c06060a, 0x4824246c, 0xb85c5ce4, - 0x9fc2c25d, 0xbdd3d36e, 0x43acacef, 0xc46262a6, - 0x399191a8, 0x319595a4, 0xd3e4e437, 0xf279798b, - 0xd5e7e732, 0x8bc8c843, 0x6e373759, 0xda6d6db7, - 0x018d8d8c, 0xb1d5d564, 0x9c4e4ed2, 0x49a9a9e0, - 0xd86c6cb4, 0xac5656fa, 0xf3f4f407, 0xcfeaea25, - 0xca6565af, 0xf47a7a8e, 0x47aeaee9, 0x10080818, - 0x6fbabad5, 0xf0787888, 0x4a25256f, 0x5c2e2e72, - 0x381c1c24, 0x57a6a6f1, 0x73b4b4c7, 0x97c6c651, - 0xcbe8e823, 0xa1dddd7c, 0xe874749c, 0x3e1f1f21, - 0x964b4bdd, 0x61bdbddc, 0x0d8b8b86, 0x0f8a8a85, - 0xe0707090, 0x7c3e3e42, 0x71b5b5c4, 0xcc6666aa, - 0x904848d8, 0x06030305, 0xf7f6f601, 0x1c0e0e12, - 0xc26161a3, 0x6a35355f, 0xae5757f9, 0x69b9b9d0, - 0x17868691, 0x99c1c158, 0x3a1d1d27, 0x279e9eb9, - 0xd9e1e138, 0xebf8f813, 0x2b9898b3, 0x22111133, - 0xd26969bb, 0xa9d9d970, 0x078e8e89, 0x339494a7, - 0x2d9b9bb6, 0x3c1e1e22, 0x15878792, 0xc9e9e920, - 0x87cece49, 0xaa5555ff, 0x50282878, 0xa5dfdf7a, - 0x038c8c8f, 0x59a1a1f8, 0x09898980, 0x1a0d0d17, - 0x65bfbfda, 0xd7e6e631, 0x844242c6, 0xd06868b8, - 0x824141c3, 0x299999b0, 0x5a2d2d77, 0x1e0f0f11, - 0x7bb0b0cb, 0xa85454fc, 0x6dbbbbd6, 0x2c16163a -}; - -const uint32_t _ae1[256] = { - 0xa5c66363, 0x84f87c7c, 0x99ee7777, 0x8df67b7b, - 0x0dfff2f2, 0xbdd66b6b, 0xb1de6f6f, 0x5491c5c5, - 0x50603030, 0x03020101, 0xa9ce6767, 0x7d562b2b, - 0x19e7fefe, 0x62b5d7d7, 0xe64dabab, 0x9aec7676, - 0x458fcaca, 0x9d1f8282, 0x4089c9c9, 0x87fa7d7d, - 0x15effafa, 0xebb25959, 0xc98e4747, 0x0bfbf0f0, - 0xec41adad, 0x67b3d4d4, 0xfd5fa2a2, 0xea45afaf, - 0xbf239c9c, 0xf753a4a4, 0x96e47272, 0x5b9bc0c0, - 0xc275b7b7, 0x1ce1fdfd, 0xae3d9393, 0x6a4c2626, - 0x5a6c3636, 0x417e3f3f, 0x02f5f7f7, 0x4f83cccc, - 0x5c683434, 0xf451a5a5, 0x34d1e5e5, 0x08f9f1f1, - 0x93e27171, 0x73abd8d8, 0x53623131, 0x3f2a1515, - 0x0c080404, 0x5295c7c7, 0x65462323, 0x5e9dc3c3, - 0x28301818, 0xa1379696, 0x0f0a0505, 0xb52f9a9a, - 0x090e0707, 0x36241212, 0x9b1b8080, 0x3ddfe2e2, - 0x26cdebeb, 0x694e2727, 0xcd7fb2b2, 0x9fea7575, - 0x1b120909, 0x9e1d8383, 0x74582c2c, 0x2e341a1a, - 0x2d361b1b, 0xb2dc6e6e, 0xeeb45a5a, 0xfb5ba0a0, - 0xf6a45252, 0x4d763b3b, 0x61b7d6d6, 0xce7db3b3, - 0x7b522929, 0x3edde3e3, 0x715e2f2f, 0x97138484, - 0xf5a65353, 0x68b9d1d1, 0x00000000, 0x2cc1eded, - 0x60402020, 0x1fe3fcfc, 0xc879b1b1, 0xedb65b5b, - 0xbed46a6a, 0x468dcbcb, 0xd967bebe, 0x4b723939, - 0xde944a4a, 0xd4984c4c, 0xe8b05858, 0x4a85cfcf, - 0x6bbbd0d0, 0x2ac5efef, 0xe54faaaa, 0x16edfbfb, - 0xc5864343, 0xd79a4d4d, 0x55663333, 0x94118585, - 0xcf8a4545, 0x10e9f9f9, 0x06040202, 0x81fe7f7f, - 0xf0a05050, 0x44783c3c, 0xba259f9f, 0xe34ba8a8, - 0xf3a25151, 0xfe5da3a3, 0xc0804040, 0x8a058f8f, - 0xad3f9292, 0xbc219d9d, 0x48703838, 0x04f1f5f5, - 0xdf63bcbc, 0xc177b6b6, 0x75afdada, 0x63422121, - 0x30201010, 0x1ae5ffff, 0x0efdf3f3, 0x6dbfd2d2, - 0x4c81cdcd, 0x14180c0c, 0x35261313, 0x2fc3ecec, - 0xe1be5f5f, 0xa2359797, 0xcc884444, 0x392e1717, - 0x5793c4c4, 0xf255a7a7, 0x82fc7e7e, 0x477a3d3d, - 0xacc86464, 0xe7ba5d5d, 0x2b321919, 0x95e67373, - 0xa0c06060, 0x98198181, 0xd19e4f4f, 0x7fa3dcdc, - 0x66442222, 0x7e542a2a, 0xab3b9090, 0x830b8888, - 0xca8c4646, 0x29c7eeee, 0xd36bb8b8, 0x3c281414, - 0x79a7dede, 0xe2bc5e5e, 0x1d160b0b, 0x76addbdb, - 0x3bdbe0e0, 0x56643232, 0x4e743a3a, 0x1e140a0a, - 0xdb924949, 0x0a0c0606, 0x6c482424, 0xe4b85c5c, - 0x5d9fc2c2, 0x6ebdd3d3, 0xef43acac, 0xa6c46262, - 0xa8399191, 0xa4319595, 0x37d3e4e4, 0x8bf27979, - 0x32d5e7e7, 0x438bc8c8, 0x596e3737, 0xb7da6d6d, - 0x8c018d8d, 0x64b1d5d5, 0xd29c4e4e, 0xe049a9a9, - 0xb4d86c6c, 0xfaac5656, 0x07f3f4f4, 0x25cfeaea, - 0xafca6565, 0x8ef47a7a, 0xe947aeae, 0x18100808, - 0xd56fbaba, 0x88f07878, 0x6f4a2525, 0x725c2e2e, - 0x24381c1c, 0xf157a6a6, 0xc773b4b4, 0x5197c6c6, - 0x23cbe8e8, 0x7ca1dddd, 0x9ce87474, 0x213e1f1f, - 0xdd964b4b, 0xdc61bdbd, 0x860d8b8b, 0x850f8a8a, - 0x90e07070, 0x427c3e3e, 0xc471b5b5, 0xaacc6666, - 0xd8904848, 0x05060303, 0x01f7f6f6, 0x121c0e0e, - 0xa3c26161, 0x5f6a3535, 0xf9ae5757, 0xd069b9b9, - 0x91178686, 0x5899c1c1, 0x273a1d1d, 0xb9279e9e, - 0x38d9e1e1, 0x13ebf8f8, 0xb32b9898, 0x33221111, - 0xbbd26969, 0x70a9d9d9, 0x89078e8e, 0xa7339494, - 0xb62d9b9b, 0x223c1e1e, 0x92158787, 0x20c9e9e9, - 0x4987cece, 0xffaa5555, 0x78502828, 0x7aa5dfdf, - 0x8f038c8c, 0xf859a1a1, 0x80098989, 0x171a0d0d, - 0xda65bfbf, 0x31d7e6e6, 0xc6844242, 0xb8d06868, - 0xc3824141, 0xb0299999, 0x775a2d2d, 0x111e0f0f, - 0xcb7bb0b0, 0xfca85454, 0xd66dbbbb, 0x3a2c1616 -}; - -const uint32_t _ae2[256] = { - 0x63a5c663, 0x7c84f87c, 0x7799ee77, 0x7b8df67b, - 0xf20dfff2, 0x6bbdd66b, 0x6fb1de6f, 0xc55491c5, - 0x30506030, 0x01030201, 0x67a9ce67, 0x2b7d562b, - 0xfe19e7fe, 0xd762b5d7, 0xabe64dab, 0x769aec76, - 0xca458fca, 0x829d1f82, 0xc94089c9, 0x7d87fa7d, - 0xfa15effa, 0x59ebb259, 0x47c98e47, 0xf00bfbf0, - 0xadec41ad, 0xd467b3d4, 0xa2fd5fa2, 0xafea45af, - 0x9cbf239c, 0xa4f753a4, 0x7296e472, 0xc05b9bc0, - 0xb7c275b7, 0xfd1ce1fd, 0x93ae3d93, 0x266a4c26, - 0x365a6c36, 0x3f417e3f, 0xf702f5f7, 0xcc4f83cc, - 0x345c6834, 0xa5f451a5, 0xe534d1e5, 0xf108f9f1, - 0x7193e271, 0xd873abd8, 0x31536231, 0x153f2a15, - 0x040c0804, 0xc75295c7, 0x23654623, 0xc35e9dc3, - 0x18283018, 0x96a13796, 0x050f0a05, 0x9ab52f9a, - 0x07090e07, 0x12362412, 0x809b1b80, 0xe23ddfe2, - 0xeb26cdeb, 0x27694e27, 0xb2cd7fb2, 0x759fea75, - 0x091b1209, 0x839e1d83, 0x2c74582c, 0x1a2e341a, - 0x1b2d361b, 0x6eb2dc6e, 0x5aeeb45a, 0xa0fb5ba0, - 0x52f6a452, 0x3b4d763b, 0xd661b7d6, 0xb3ce7db3, - 0x297b5229, 0xe33edde3, 0x2f715e2f, 0x84971384, - 0x53f5a653, 0xd168b9d1, 0x00000000, 0xed2cc1ed, - 0x20604020, 0xfc1fe3fc, 0xb1c879b1, 0x5bedb65b, - 0x6abed46a, 0xcb468dcb, 0xbed967be, 0x394b7239, - 0x4ade944a, 0x4cd4984c, 0x58e8b058, 0xcf4a85cf, - 0xd06bbbd0, 0xef2ac5ef, 0xaae54faa, 0xfb16edfb, - 0x43c58643, 0x4dd79a4d, 0x33556633, 0x85941185, - 0x45cf8a45, 0xf910e9f9, 0x02060402, 0x7f81fe7f, - 0x50f0a050, 0x3c44783c, 0x9fba259f, 0xa8e34ba8, - 0x51f3a251, 0xa3fe5da3, 0x40c08040, 0x8f8a058f, - 0x92ad3f92, 0x9dbc219d, 0x38487038, 0xf504f1f5, - 0xbcdf63bc, 0xb6c177b6, 0xda75afda, 0x21634221, - 0x10302010, 0xff1ae5ff, 0xf30efdf3, 0xd26dbfd2, - 0xcd4c81cd, 0x0c14180c, 0x13352613, 0xec2fc3ec, - 0x5fe1be5f, 0x97a23597, 0x44cc8844, 0x17392e17, - 0xc45793c4, 0xa7f255a7, 0x7e82fc7e, 0x3d477a3d, - 0x64acc864, 0x5de7ba5d, 0x192b3219, 0x7395e673, - 0x60a0c060, 0x81981981, 0x4fd19e4f, 0xdc7fa3dc, - 0x22664422, 0x2a7e542a, 0x90ab3b90, 0x88830b88, - 0x46ca8c46, 0xee29c7ee, 0xb8d36bb8, 0x143c2814, - 0xde79a7de, 0x5ee2bc5e, 0x0b1d160b, 0xdb76addb, - 0xe03bdbe0, 0x32566432, 0x3a4e743a, 0x0a1e140a, - 0x49db9249, 0x060a0c06, 0x246c4824, 0x5ce4b85c, - 0xc25d9fc2, 0xd36ebdd3, 0xacef43ac, 0x62a6c462, - 0x91a83991, 0x95a43195, 0xe437d3e4, 0x798bf279, - 0xe732d5e7, 0xc8438bc8, 0x37596e37, 0x6db7da6d, - 0x8d8c018d, 0xd564b1d5, 0x4ed29c4e, 0xa9e049a9, - 0x6cb4d86c, 0x56faac56, 0xf407f3f4, 0xea25cfea, - 0x65afca65, 0x7a8ef47a, 0xaee947ae, 0x08181008, - 0xbad56fba, 0x7888f078, 0x256f4a25, 0x2e725c2e, - 0x1c24381c, 0xa6f157a6, 0xb4c773b4, 0xc65197c6, - 0xe823cbe8, 0xdd7ca1dd, 0x749ce874, 0x1f213e1f, - 0x4bdd964b, 0xbddc61bd, 0x8b860d8b, 0x8a850f8a, - 0x7090e070, 0x3e427c3e, 0xb5c471b5, 0x66aacc66, - 0x48d89048, 0x03050603, 0xf601f7f6, 0x0e121c0e, - 0x61a3c261, 0x355f6a35, 0x57f9ae57, 0xb9d069b9, - 0x86911786, 0xc15899c1, 0x1d273a1d, 0x9eb9279e, - 0xe138d9e1, 0xf813ebf8, 0x98b32b98, 0x11332211, - 0x69bbd269, 0xd970a9d9, 0x8e89078e, 0x94a73394, - 0x9bb62d9b, 0x1e223c1e, 0x87921587, 0xe920c9e9, - 0xce4987ce, 0x55ffaa55, 0x28785028, 0xdf7aa5df, - 0x8c8f038c, 0xa1f859a1, 0x89800989, 0x0d171a0d, - 0xbfda65bf, 0xe631d7e6, 0x42c68442, 0x68b8d068, - 0x41c38241, 0x99b02999, 0x2d775a2d, 0x0f111e0f, - 0xb0cb7bb0, 0x54fca854, 0xbbd66dbb, 0x163a2c16 -}; - -const uint32_t _ae3[256] = { - 0x6363a5c6, 0x7c7c84f8, 0x777799ee, 0x7b7b8df6, - 0xf2f20dff, 0x6b6bbdd6, 0x6f6fb1de, 0xc5c55491, - 0x30305060, 0x01010302, 0x6767a9ce, 0x2b2b7d56, - 0xfefe19e7, 0xd7d762b5, 0xababe64d, 0x76769aec, - 0xcaca458f, 0x82829d1f, 0xc9c94089, 0x7d7d87fa, - 0xfafa15ef, 0x5959ebb2, 0x4747c98e, 0xf0f00bfb, - 0xadadec41, 0xd4d467b3, 0xa2a2fd5f, 0xafafea45, - 0x9c9cbf23, 0xa4a4f753, 0x727296e4, 0xc0c05b9b, - 0xb7b7c275, 0xfdfd1ce1, 0x9393ae3d, 0x26266a4c, - 0x36365a6c, 0x3f3f417e, 0xf7f702f5, 0xcccc4f83, - 0x34345c68, 0xa5a5f451, 0xe5e534d1, 0xf1f108f9, - 0x717193e2, 0xd8d873ab, 0x31315362, 0x15153f2a, - 0x04040c08, 0xc7c75295, 0x23236546, 0xc3c35e9d, - 0x18182830, 0x9696a137, 0x05050f0a, 0x9a9ab52f, - 0x0707090e, 0x12123624, 0x80809b1b, 0xe2e23ddf, - 0xebeb26cd, 0x2727694e, 0xb2b2cd7f, 0x75759fea, - 0x09091b12, 0x83839e1d, 0x2c2c7458, 0x1a1a2e34, - 0x1b1b2d36, 0x6e6eb2dc, 0x5a5aeeb4, 0xa0a0fb5b, - 0x5252f6a4, 0x3b3b4d76, 0xd6d661b7, 0xb3b3ce7d, - 0x29297b52, 0xe3e33edd, 0x2f2f715e, 0x84849713, - 0x5353f5a6, 0xd1d168b9, 0x00000000, 0xeded2cc1, - 0x20206040, 0xfcfc1fe3, 0xb1b1c879, 0x5b5bedb6, - 0x6a6abed4, 0xcbcb468d, 0xbebed967, 0x39394b72, - 0x4a4ade94, 0x4c4cd498, 0x5858e8b0, 0xcfcf4a85, - 0xd0d06bbb, 0xefef2ac5, 0xaaaae54f, 0xfbfb16ed, - 0x4343c586, 0x4d4dd79a, 0x33335566, 0x85859411, - 0x4545cf8a, 0xf9f910e9, 0x02020604, 0x7f7f81fe, - 0x5050f0a0, 0x3c3c4478, 0x9f9fba25, 0xa8a8e34b, - 0x5151f3a2, 0xa3a3fe5d, 0x4040c080, 0x8f8f8a05, - 0x9292ad3f, 0x9d9dbc21, 0x38384870, 0xf5f504f1, - 0xbcbcdf63, 0xb6b6c177, 0xdada75af, 0x21216342, - 0x10103020, 0xffff1ae5, 0xf3f30efd, 0xd2d26dbf, - 0xcdcd4c81, 0x0c0c1418, 0x13133526, 0xecec2fc3, - 0x5f5fe1be, 0x9797a235, 0x4444cc88, 0x1717392e, - 0xc4c45793, 0xa7a7f255, 0x7e7e82fc, 0x3d3d477a, - 0x6464acc8, 0x5d5de7ba, 0x19192b32, 0x737395e6, - 0x6060a0c0, 0x81819819, 0x4f4fd19e, 0xdcdc7fa3, - 0x22226644, 0x2a2a7e54, 0x9090ab3b, 0x8888830b, - 0x4646ca8c, 0xeeee29c7, 0xb8b8d36b, 0x14143c28, - 0xdede79a7, 0x5e5ee2bc, 0x0b0b1d16, 0xdbdb76ad, - 0xe0e03bdb, 0x32325664, 0x3a3a4e74, 0x0a0a1e14, - 0x4949db92, 0x06060a0c, 0x24246c48, 0x5c5ce4b8, - 0xc2c25d9f, 0xd3d36ebd, 0xacacef43, 0x6262a6c4, - 0x9191a839, 0x9595a431, 0xe4e437d3, 0x79798bf2, - 0xe7e732d5, 0xc8c8438b, 0x3737596e, 0x6d6db7da, - 0x8d8d8c01, 0xd5d564b1, 0x4e4ed29c, 0xa9a9e049, - 0x6c6cb4d8, 0x5656faac, 0xf4f407f3, 0xeaea25cf, - 0x6565afca, 0x7a7a8ef4, 0xaeaee947, 0x08081810, - 0xbabad56f, 0x787888f0, 0x25256f4a, 0x2e2e725c, - 0x1c1c2438, 0xa6a6f157, 0xb4b4c773, 0xc6c65197, - 0xe8e823cb, 0xdddd7ca1, 0x74749ce8, 0x1f1f213e, - 0x4b4bdd96, 0xbdbddc61, 0x8b8b860d, 0x8a8a850f, - 0x707090e0, 0x3e3e427c, 0xb5b5c471, 0x6666aacc, - 0x4848d890, 0x03030506, 0xf6f601f7, 0x0e0e121c, - 0x6161a3c2, 0x35355f6a, 0x5757f9ae, 0xb9b9d069, - 0x86869117, 0xc1c15899, 0x1d1d273a, 0x9e9eb927, - 0xe1e138d9, 0xf8f813eb, 0x9898b32b, 0x11113322, - 0x6969bbd2, 0xd9d970a9, 0x8e8e8907, 0x9494a733, - 0x9b9bb62d, 0x1e1e223c, 0x87879215, 0xe9e920c9, - 0xcece4987, 0x5555ffaa, 0x28287850, 0xdfdf7aa5, - 0x8c8c8f03, 0xa1a1f859, 0x89898009, 0x0d0d171a, - 0xbfbfda65, 0xe6e631d7, 0x4242c684, 0x6868b8d0, - 0x4141c382, 0x9999b029, 0x2d2d775a, 0x0f0f111e, - 0xb0b0cb7b, 0x5454fca8, 0xbbbbd66d, 0x16163a2c -}; - -const uint32_t _ae4[256] = { - 0x63636363, 0x7c7c7c7c, 0x77777777, 0x7b7b7b7b, - 0xf2f2f2f2, 0x6b6b6b6b, 0x6f6f6f6f, 0xc5c5c5c5, - 0x30303030, 0x01010101, 0x67676767, 0x2b2b2b2b, - 0xfefefefe, 0xd7d7d7d7, 0xabababab, 0x76767676, - 0xcacacaca, 0x82828282, 0xc9c9c9c9, 0x7d7d7d7d, - 0xfafafafa, 0x59595959, 0x47474747, 0xf0f0f0f0, - 0xadadadad, 0xd4d4d4d4, 0xa2a2a2a2, 0xafafafaf, - 0x9c9c9c9c, 0xa4a4a4a4, 0x72727272, 0xc0c0c0c0, - 0xb7b7b7b7, 0xfdfdfdfd, 0x93939393, 0x26262626, - 0x36363636, 0x3f3f3f3f, 0xf7f7f7f7, 0xcccccccc, - 0x34343434, 0xa5a5a5a5, 0xe5e5e5e5, 0xf1f1f1f1, - 0x71717171, 0xd8d8d8d8, 0x31313131, 0x15151515, - 0x04040404, 0xc7c7c7c7, 0x23232323, 0xc3c3c3c3, - 0x18181818, 0x96969696, 0x05050505, 0x9a9a9a9a, - 0x07070707, 0x12121212, 0x80808080, 0xe2e2e2e2, - 0xebebebeb, 0x27272727, 0xb2b2b2b2, 0x75757575, - 0x09090909, 0x83838383, 0x2c2c2c2c, 0x1a1a1a1a, - 0x1b1b1b1b, 0x6e6e6e6e, 0x5a5a5a5a, 0xa0a0a0a0, - 0x52525252, 0x3b3b3b3b, 0xd6d6d6d6, 0xb3b3b3b3, - 0x29292929, 0xe3e3e3e3, 0x2f2f2f2f, 0x84848484, - 0x53535353, 0xd1d1d1d1, 0x00000000, 0xedededed, - 0x20202020, 0xfcfcfcfc, 0xb1b1b1b1, 0x5b5b5b5b, - 0x6a6a6a6a, 0xcbcbcbcb, 0xbebebebe, 0x39393939, - 0x4a4a4a4a, 0x4c4c4c4c, 0x58585858, 0xcfcfcfcf, - 0xd0d0d0d0, 0xefefefef, 0xaaaaaaaa, 0xfbfbfbfb, - 0x43434343, 0x4d4d4d4d, 0x33333333, 0x85858585, - 0x45454545, 0xf9f9f9f9, 0x02020202, 0x7f7f7f7f, - 0x50505050, 0x3c3c3c3c, 0x9f9f9f9f, 0xa8a8a8a8, - 0x51515151, 0xa3a3a3a3, 0x40404040, 0x8f8f8f8f, - 0x92929292, 0x9d9d9d9d, 0x38383838, 0xf5f5f5f5, - 0xbcbcbcbc, 0xb6b6b6b6, 0xdadadada, 0x21212121, - 0x10101010, 0xffffffff, 0xf3f3f3f3, 0xd2d2d2d2, - 0xcdcdcdcd, 0x0c0c0c0c, 0x13131313, 0xecececec, - 0x5f5f5f5f, 0x97979797, 0x44444444, 0x17171717, - 0xc4c4c4c4, 0xa7a7a7a7, 0x7e7e7e7e, 0x3d3d3d3d, - 0x64646464, 0x5d5d5d5d, 0x19191919, 0x73737373, - 0x60606060, 0x81818181, 0x4f4f4f4f, 0xdcdcdcdc, - 0x22222222, 0x2a2a2a2a, 0x90909090, 0x88888888, - 0x46464646, 0xeeeeeeee, 0xb8b8b8b8, 0x14141414, - 0xdededede, 0x5e5e5e5e, 0x0b0b0b0b, 0xdbdbdbdb, - 0xe0e0e0e0, 0x32323232, 0x3a3a3a3a, 0x0a0a0a0a, - 0x49494949, 0x06060606, 0x24242424, 0x5c5c5c5c, - 0xc2c2c2c2, 0xd3d3d3d3, 0xacacacac, 0x62626262, - 0x91919191, 0x95959595, 0xe4e4e4e4, 0x79797979, - 0xe7e7e7e7, 0xc8c8c8c8, 0x37373737, 0x6d6d6d6d, - 0x8d8d8d8d, 0xd5d5d5d5, 0x4e4e4e4e, 0xa9a9a9a9, - 0x6c6c6c6c, 0x56565656, 0xf4f4f4f4, 0xeaeaeaea, - 0x65656565, 0x7a7a7a7a, 0xaeaeaeae, 0x08080808, - 0xbabababa, 0x78787878, 0x25252525, 0x2e2e2e2e, - 0x1c1c1c1c, 0xa6a6a6a6, 0xb4b4b4b4, 0xc6c6c6c6, - 0xe8e8e8e8, 0xdddddddd, 0x74747474, 0x1f1f1f1f, - 0x4b4b4b4b, 0xbdbdbdbd, 0x8b8b8b8b, 0x8a8a8a8a, - 0x70707070, 0x3e3e3e3e, 0xb5b5b5b5, 0x66666666, - 0x48484848, 0x03030303, 0xf6f6f6f6, 0x0e0e0e0e, - 0x61616161, 0x35353535, 0x57575757, 0xb9b9b9b9, - 0x86868686, 0xc1c1c1c1, 0x1d1d1d1d, 0x9e9e9e9e, - 0xe1e1e1e1, 0xf8f8f8f8, 0x98989898, 0x11111111, - 0x69696969, 0xd9d9d9d9, 0x8e8e8e8e, 0x94949494, - 0x9b9b9b9b, 0x1e1e1e1e, 0x87878787, 0xe9e9e9e9, - 0xcececece, 0x55555555, 0x28282828, 0xdfdfdfdf, - 0x8c8c8c8c, 0xa1a1a1a1, 0x89898989, 0x0d0d0d0d, - 0xbfbfbfbf, 0xe6e6e6e6, 0x42424242, 0x68686868, - 0x41414141, 0x99999999, 0x2d2d2d2d, 0x0f0f0f0f, - 0xb0b0b0b0, 0x54545454, 0xbbbbbbbb, 0x16161616 -}; - -const uint32_t _ad0[256] = { - 0x51f4a750, 0x7e416553, 0x1a17a4c3, 0x3a275e96, - 0x3bab6bcb, 0x1f9d45f1, 0xacfa58ab, 0x4be30393, - 0x2030fa55, 0xad766df6, 0x88cc7691, 0xf5024c25, - 0x4fe5d7fc, 0xc52acbd7, 0x26354480, 0xb562a38f, - 0xdeb15a49, 0x25ba1b67, 0x45ea0e98, 0x5dfec0e1, - 0xc32f7502, 0x814cf012, 0x8d4697a3, 0x6bd3f9c6, - 0x038f5fe7, 0x15929c95, 0xbf6d7aeb, 0x955259da, - 0xd4be832d, 0x587421d3, 0x49e06929, 0x8ec9c844, - 0x75c2896a, 0xf48e7978, 0x99583e6b, 0x27b971dd, - 0xbee14fb6, 0xf088ad17, 0xc920ac66, 0x7dce3ab4, - 0x63df4a18, 0xe51a3182, 0x97513360, 0x62537f45, - 0xb16477e0, 0xbb6bae84, 0xfe81a01c, 0xf9082b94, - 0x70486858, 0x8f45fd19, 0x94de6c87, 0x527bf8b7, - 0xab73d323, 0x724b02e2, 0xe31f8f57, 0x6655ab2a, - 0xb2eb2807, 0x2fb5c203, 0x86c57b9a, 0xd33708a5, - 0x302887f2, 0x23bfa5b2, 0x02036aba, 0xed16825c, - 0x8acf1c2b, 0xa779b492, 0xf307f2f0, 0x4e69e2a1, - 0x65daf4cd, 0x0605bed5, 0xd134621f, 0xc4a6fe8a, - 0x342e539d, 0xa2f355a0, 0x058ae132, 0xa4f6eb75, - 0x0b83ec39, 0x4060efaa, 0x5e719f06, 0xbd6e1051, - 0x3e218af9, 0x96dd063d, 0xdd3e05ae, 0x4de6bd46, - 0x91548db5, 0x71c45d05, 0x0406d46f, 0x605015ff, - 0x1998fb24, 0xd6bde997, 0x894043cc, 0x67d99e77, - 0xb0e842bd, 0x07898b88, 0xe7195b38, 0x79c8eedb, - 0xa17c0a47, 0x7c420fe9, 0xf8841ec9, 0x00000000, - 0x09808683, 0x322bed48, 0x1e1170ac, 0x6c5a724e, - 0xfd0efffb, 0x0f853856, 0x3daed51e, 0x362d3927, - 0x0a0fd964, 0x685ca621, 0x9b5b54d1, 0x24362e3a, - 0x0c0a67b1, 0x9357e70f, 0xb4ee96d2, 0x1b9b919e, - 0x80c0c54f, 0x61dc20a2, 0x5a774b69, 0x1c121a16, - 0xe293ba0a, 0xc0a02ae5, 0x3c22e043, 0x121b171d, - 0x0e090d0b, 0xf28bc7ad, 0x2db6a8b9, 0x141ea9c8, - 0x57f11985, 0xaf75074c, 0xee99ddbb, 0xa37f60fd, - 0xf701269f, 0x5c72f5bc, 0x44663bc5, 0x5bfb7e34, - 0x8b432976, 0xcb23c6dc, 0xb6edfc68, 0xb8e4f163, - 0xd731dcca, 0x42638510, 0x13972240, 0x84c61120, - 0x854a247d, 0xd2bb3df8, 0xaef93211, 0xc729a16d, - 0x1d9e2f4b, 0xdcb230f3, 0x0d8652ec, 0x77c1e3d0, - 0x2bb3166c, 0xa970b999, 0x119448fa, 0x47e96422, - 0xa8fc8cc4, 0xa0f03f1a, 0x567d2cd8, 0x223390ef, - 0x87494ec7, 0xd938d1c1, 0x8ccaa2fe, 0x98d40b36, - 0xa6f581cf, 0xa57ade28, 0xdab78e26, 0x3fadbfa4, - 0x2c3a9de4, 0x5078920d, 0x6a5fcc9b, 0x547e4662, - 0xf68d13c2, 0x90d8b8e8, 0x2e39f75e, 0x82c3aff5, - 0x9f5d80be, 0x69d0937c, 0x6fd52da9, 0xcf2512b3, - 0xc8ac993b, 0x10187da7, 0xe89c636e, 0xdb3bbb7b, - 0xcd267809, 0x6e5918f4, 0xec9ab701, 0x834f9aa8, - 0xe6956e65, 0xaaffe67e, 0x21bccf08, 0xef15e8e6, - 0xbae79bd9, 0x4a6f36ce, 0xea9f09d4, 0x29b07cd6, - 0x31a4b2af, 0x2a3f2331, 0xc6a59430, 0x35a266c0, - 0x744ebc37, 0xfc82caa6, 0xe090d0b0, 0x33a7d815, - 0xf104984a, 0x41ecdaf7, 0x7fcd500e, 0x1791f62f, - 0x764dd68d, 0x43efb04d, 0xccaa4d54, 0xe49604df, - 0x9ed1b5e3, 0x4c6a881b, 0xc12c1fb8, 0x4665517f, - 0x9d5eea04, 0x018c355d, 0xfa877473, 0xfb0b412e, - 0xb3671d5a, 0x92dbd252, 0xe9105633, 0x6dd64713, - 0x9ad7618c, 0x37a10c7a, 0x59f8148e, 0xeb133c89, - 0xcea927ee, 0xb761c935, 0xe11ce5ed, 0x7a47b13c, - 0x9cd2df59, 0x55f2733f, 0x1814ce79, 0x73c737bf, - 0x53f7cdea, 0x5ffdaa5b, 0xdf3d6f14, 0x7844db86, - 0xcaaff381, 0xb968c43e, 0x3824342c, 0xc2a3405f, - 0x161dc372, 0xbce2250c, 0x283c498b, 0xff0d9541, - 0x39a80171, 0x080cb3de, 0xd8b4e49c, 0x6456c190, - 0x7bcb8461, 0xd532b670, 0x486c5c74, 0xd0b85742 -}; - -const uint32_t _ad1[256] = { - 0x5051f4a7, 0x537e4165, 0xc31a17a4, 0x963a275e, - 0xcb3bab6b, 0xf11f9d45, 0xabacfa58, 0x934be303, - 0x552030fa, 0xf6ad766d, 0x9188cc76, 0x25f5024c, - 0xfc4fe5d7, 0xd7c52acb, 0x80263544, 0x8fb562a3, - 0x49deb15a, 0x6725ba1b, 0x9845ea0e, 0xe15dfec0, - 0x02c32f75, 0x12814cf0, 0xa38d4697, 0xc66bd3f9, - 0xe7038f5f, 0x9515929c, 0xebbf6d7a, 0xda955259, - 0x2dd4be83, 0xd3587421, 0x2949e069, 0x448ec9c8, - 0x6a75c289, 0x78f48e79, 0x6b99583e, 0xdd27b971, - 0xb6bee14f, 0x17f088ad, 0x66c920ac, 0xb47dce3a, - 0x1863df4a, 0x82e51a31, 0x60975133, 0x4562537f, - 0xe0b16477, 0x84bb6bae, 0x1cfe81a0, 0x94f9082b, - 0x58704868, 0x198f45fd, 0x8794de6c, 0xb7527bf8, - 0x23ab73d3, 0xe2724b02, 0x57e31f8f, 0x2a6655ab, - 0x07b2eb28, 0x032fb5c2, 0x9a86c57b, 0xa5d33708, - 0xf2302887, 0xb223bfa5, 0xba02036a, 0x5ced1682, - 0x2b8acf1c, 0x92a779b4, 0xf0f307f2, 0xa14e69e2, - 0xcd65daf4, 0xd50605be, 0x1fd13462, 0x8ac4a6fe, - 0x9d342e53, 0xa0a2f355, 0x32058ae1, 0x75a4f6eb, - 0x390b83ec, 0xaa4060ef, 0x065e719f, 0x51bd6e10, - 0xf93e218a, 0x3d96dd06, 0xaedd3e05, 0x464de6bd, - 0xb591548d, 0x0571c45d, 0x6f0406d4, 0xff605015, - 0x241998fb, 0x97d6bde9, 0xcc894043, 0x7767d99e, - 0xbdb0e842, 0x8807898b, 0x38e7195b, 0xdb79c8ee, - 0x47a17c0a, 0xe97c420f, 0xc9f8841e, 0x00000000, - 0x83098086, 0x48322bed, 0xac1e1170, 0x4e6c5a72, - 0xfbfd0eff, 0x560f8538, 0x1e3daed5, 0x27362d39, - 0x640a0fd9, 0x21685ca6, 0xd19b5b54, 0x3a24362e, - 0xb10c0a67, 0x0f9357e7, 0xd2b4ee96, 0x9e1b9b91, - 0x4f80c0c5, 0xa261dc20, 0x695a774b, 0x161c121a, - 0x0ae293ba, 0xe5c0a02a, 0x433c22e0, 0x1d121b17, - 0x0b0e090d, 0xadf28bc7, 0xb92db6a8, 0xc8141ea9, - 0x8557f119, 0x4caf7507, 0xbbee99dd, 0xfda37f60, - 0x9ff70126, 0xbc5c72f5, 0xc544663b, 0x345bfb7e, - 0x768b4329, 0xdccb23c6, 0x68b6edfc, 0x63b8e4f1, - 0xcad731dc, 0x10426385, 0x40139722, 0x2084c611, - 0x7d854a24, 0xf8d2bb3d, 0x11aef932, 0x6dc729a1, - 0x4b1d9e2f, 0xf3dcb230, 0xec0d8652, 0xd077c1e3, - 0x6c2bb316, 0x99a970b9, 0xfa119448, 0x2247e964, - 0xc4a8fc8c, 0x1aa0f03f, 0xd8567d2c, 0xef223390, - 0xc787494e, 0xc1d938d1, 0xfe8ccaa2, 0x3698d40b, - 0xcfa6f581, 0x28a57ade, 0x26dab78e, 0xa43fadbf, - 0xe42c3a9d, 0x0d507892, 0x9b6a5fcc, 0x62547e46, - 0xc2f68d13, 0xe890d8b8, 0x5e2e39f7, 0xf582c3af, - 0xbe9f5d80, 0x7c69d093, 0xa96fd52d, 0xb3cf2512, - 0x3bc8ac99, 0xa710187d, 0x6ee89c63, 0x7bdb3bbb, - 0x09cd2678, 0xf46e5918, 0x01ec9ab7, 0xa8834f9a, - 0x65e6956e, 0x7eaaffe6, 0x0821bccf, 0xe6ef15e8, - 0xd9bae79b, 0xce4a6f36, 0xd4ea9f09, 0xd629b07c, - 0xaf31a4b2, 0x312a3f23, 0x30c6a594, 0xc035a266, - 0x37744ebc, 0xa6fc82ca, 0xb0e090d0, 0x1533a7d8, - 0x4af10498, 0xf741ecda, 0x0e7fcd50, 0x2f1791f6, - 0x8d764dd6, 0x4d43efb0, 0x54ccaa4d, 0xdfe49604, - 0xe39ed1b5, 0x1b4c6a88, 0xb8c12c1f, 0x7f466551, - 0x049d5eea, 0x5d018c35, 0x73fa8774, 0x2efb0b41, - 0x5ab3671d, 0x5292dbd2, 0x33e91056, 0x136dd647, - 0x8c9ad761, 0x7a37a10c, 0x8e59f814, 0x89eb133c, - 0xeecea927, 0x35b761c9, 0xede11ce5, 0x3c7a47b1, - 0x599cd2df, 0x3f55f273, 0x791814ce, 0xbf73c737, - 0xea53f7cd, 0x5b5ffdaa, 0x14df3d6f, 0x867844db, - 0x81caaff3, 0x3eb968c4, 0x2c382434, 0x5fc2a340, - 0x72161dc3, 0x0cbce225, 0x8b283c49, 0x41ff0d95, - 0x7139a801, 0xde080cb3, 0x9cd8b4e4, 0x906456c1, - 0x617bcb84, 0x70d532b6, 0x74486c5c, 0x42d0b857 -}; - -const uint32_t _ad2[256] = { - 0xa75051f4, 0x65537e41, 0xa4c31a17, 0x5e963a27, - 0x6bcb3bab, 0x45f11f9d, 0x58abacfa, 0x03934be3, - 0xfa552030, 0x6df6ad76, 0x769188cc, 0x4c25f502, - 0xd7fc4fe5, 0xcbd7c52a, 0x44802635, 0xa38fb562, - 0x5a49deb1, 0x1b6725ba, 0x0e9845ea, 0xc0e15dfe, - 0x7502c32f, 0xf012814c, 0x97a38d46, 0xf9c66bd3, - 0x5fe7038f, 0x9c951592, 0x7aebbf6d, 0x59da9552, - 0x832dd4be, 0x21d35874, 0x692949e0, 0xc8448ec9, - 0x896a75c2, 0x7978f48e, 0x3e6b9958, 0x71dd27b9, - 0x4fb6bee1, 0xad17f088, 0xac66c920, 0x3ab47dce, - 0x4a1863df, 0x3182e51a, 0x33609751, 0x7f456253, - 0x77e0b164, 0xae84bb6b, 0xa01cfe81, 0x2b94f908, - 0x68587048, 0xfd198f45, 0x6c8794de, 0xf8b7527b, - 0xd323ab73, 0x02e2724b, 0x8f57e31f, 0xab2a6655, - 0x2807b2eb, 0xc2032fb5, 0x7b9a86c5, 0x08a5d337, - 0x87f23028, 0xa5b223bf, 0x6aba0203, 0x825ced16, - 0x1c2b8acf, 0xb492a779, 0xf2f0f307, 0xe2a14e69, - 0xf4cd65da, 0xbed50605, 0x621fd134, 0xfe8ac4a6, - 0x539d342e, 0x55a0a2f3, 0xe132058a, 0xeb75a4f6, - 0xec390b83, 0xefaa4060, 0x9f065e71, 0x1051bd6e, - 0x8af93e21, 0x063d96dd, 0x05aedd3e, 0xbd464de6, - 0x8db59154, 0x5d0571c4, 0xd46f0406, 0x15ff6050, - 0xfb241998, 0xe997d6bd, 0x43cc8940, 0x9e7767d9, - 0x42bdb0e8, 0x8b880789, 0x5b38e719, 0xeedb79c8, - 0x0a47a17c, 0x0fe97c42, 0x1ec9f884, 0x00000000, - 0x86830980, 0xed48322b, 0x70ac1e11, 0x724e6c5a, - 0xfffbfd0e, 0x38560f85, 0xd51e3dae, 0x3927362d, - 0xd9640a0f, 0xa621685c, 0x54d19b5b, 0x2e3a2436, - 0x67b10c0a, 0xe70f9357, 0x96d2b4ee, 0x919e1b9b, - 0xc54f80c0, 0x20a261dc, 0x4b695a77, 0x1a161c12, - 0xba0ae293, 0x2ae5c0a0, 0xe0433c22, 0x171d121b, - 0x0d0b0e09, 0xc7adf28b, 0xa8b92db6, 0xa9c8141e, - 0x198557f1, 0x074caf75, 0xddbbee99, 0x60fda37f, - 0x269ff701, 0xf5bc5c72, 0x3bc54466, 0x7e345bfb, - 0x29768b43, 0xc6dccb23, 0xfc68b6ed, 0xf163b8e4, - 0xdccad731, 0x85104263, 0x22401397, 0x112084c6, - 0x247d854a, 0x3df8d2bb, 0x3211aef9, 0xa16dc729, - 0x2f4b1d9e, 0x30f3dcb2, 0x52ec0d86, 0xe3d077c1, - 0x166c2bb3, 0xb999a970, 0x48fa1194, 0x642247e9, - 0x8cc4a8fc, 0x3f1aa0f0, 0x2cd8567d, 0x90ef2233, - 0x4ec78749, 0xd1c1d938, 0xa2fe8cca, 0x0b3698d4, - 0x81cfa6f5, 0xde28a57a, 0x8e26dab7, 0xbfa43fad, - 0x9de42c3a, 0x920d5078, 0xcc9b6a5f, 0x4662547e, - 0x13c2f68d, 0xb8e890d8, 0xf75e2e39, 0xaff582c3, - 0x80be9f5d, 0x937c69d0, 0x2da96fd5, 0x12b3cf25, - 0x993bc8ac, 0x7da71018, 0x636ee89c, 0xbb7bdb3b, - 0x7809cd26, 0x18f46e59, 0xb701ec9a, 0x9aa8834f, - 0x6e65e695, 0xe67eaaff, 0xcf0821bc, 0xe8e6ef15, - 0x9bd9bae7, 0x36ce4a6f, 0x09d4ea9f, 0x7cd629b0, - 0xb2af31a4, 0x23312a3f, 0x9430c6a5, 0x66c035a2, - 0xbc37744e, 0xcaa6fc82, 0xd0b0e090, 0xd81533a7, - 0x984af104, 0xdaf741ec, 0x500e7fcd, 0xf62f1791, - 0xd68d764d, 0xb04d43ef, 0x4d54ccaa, 0x04dfe496, - 0xb5e39ed1, 0x881b4c6a, 0x1fb8c12c, 0x517f4665, - 0xea049d5e, 0x355d018c, 0x7473fa87, 0x412efb0b, - 0x1d5ab367, 0xd25292db, 0x5633e910, 0x47136dd6, - 0x618c9ad7, 0x0c7a37a1, 0x148e59f8, 0x3c89eb13, - 0x27eecea9, 0xc935b761, 0xe5ede11c, 0xb13c7a47, - 0xdf599cd2, 0x733f55f2, 0xce791814, 0x37bf73c7, - 0xcdea53f7, 0xaa5b5ffd, 0x6f14df3d, 0xdb867844, - 0xf381caaf, 0xc43eb968, 0x342c3824, 0x405fc2a3, - 0xc372161d, 0x250cbce2, 0x498b283c, 0x9541ff0d, - 0x017139a8, 0xb3de080c, 0xe49cd8b4, 0xc1906456, - 0x84617bcb, 0xb670d532, 0x5c74486c, 0x5742d0b8 -}; - -const uint32_t _ad3[256] = { - 0xf4a75051, 0x4165537e, 0x17a4c31a, 0x275e963a, - 0xab6bcb3b, 0x9d45f11f, 0xfa58abac, 0xe303934b, - 0x30fa5520, 0x766df6ad, 0xcc769188, 0x024c25f5, - 0xe5d7fc4f, 0x2acbd7c5, 0x35448026, 0x62a38fb5, - 0xb15a49de, 0xba1b6725, 0xea0e9845, 0xfec0e15d, - 0x2f7502c3, 0x4cf01281, 0x4697a38d, 0xd3f9c66b, - 0x8f5fe703, 0x929c9515, 0x6d7aebbf, 0x5259da95, - 0xbe832dd4, 0x7421d358, 0xe0692949, 0xc9c8448e, - 0xc2896a75, 0x8e7978f4, 0x583e6b99, 0xb971dd27, - 0xe14fb6be, 0x88ad17f0, 0x20ac66c9, 0xce3ab47d, - 0xdf4a1863, 0x1a3182e5, 0x51336097, 0x537f4562, - 0x6477e0b1, 0x6bae84bb, 0x81a01cfe, 0x082b94f9, - 0x48685870, 0x45fd198f, 0xde6c8794, 0x7bf8b752, - 0x73d323ab, 0x4b02e272, 0x1f8f57e3, 0x55ab2a66, - 0xeb2807b2, 0xb5c2032f, 0xc57b9a86, 0x3708a5d3, - 0x2887f230, 0xbfa5b223, 0x036aba02, 0x16825ced, - 0xcf1c2b8a, 0x79b492a7, 0x07f2f0f3, 0x69e2a14e, - 0xdaf4cd65, 0x05bed506, 0x34621fd1, 0xa6fe8ac4, - 0x2e539d34, 0xf355a0a2, 0x8ae13205, 0xf6eb75a4, - 0x83ec390b, 0x60efaa40, 0x719f065e, 0x6e1051bd, - 0x218af93e, 0xdd063d96, 0x3e05aedd, 0xe6bd464d, - 0x548db591, 0xc45d0571, 0x06d46f04, 0x5015ff60, - 0x98fb2419, 0xbde997d6, 0x4043cc89, 0xd99e7767, - 0xe842bdb0, 0x898b8807, 0x195b38e7, 0xc8eedb79, - 0x7c0a47a1, 0x420fe97c, 0x841ec9f8, 0x00000000, - 0x80868309, 0x2bed4832, 0x1170ac1e, 0x5a724e6c, - 0x0efffbfd, 0x8538560f, 0xaed51e3d, 0x2d392736, - 0x0fd9640a, 0x5ca62168, 0x5b54d19b, 0x362e3a24, - 0x0a67b10c, 0x57e70f93, 0xee96d2b4, 0x9b919e1b, - 0xc0c54f80, 0xdc20a261, 0x774b695a, 0x121a161c, - 0x93ba0ae2, 0xa02ae5c0, 0x22e0433c, 0x1b171d12, - 0x090d0b0e, 0x8bc7adf2, 0xb6a8b92d, 0x1ea9c814, - 0xf1198557, 0x75074caf, 0x99ddbbee, 0x7f60fda3, - 0x01269ff7, 0x72f5bc5c, 0x663bc544, 0xfb7e345b, - 0x4329768b, 0x23c6dccb, 0xedfc68b6, 0xe4f163b8, - 0x31dccad7, 0x63851042, 0x97224013, 0xc6112084, - 0x4a247d85, 0xbb3df8d2, 0xf93211ae, 0x29a16dc7, - 0x9e2f4b1d, 0xb230f3dc, 0x8652ec0d, 0xc1e3d077, - 0xb3166c2b, 0x70b999a9, 0x9448fa11, 0xe9642247, - 0xfc8cc4a8, 0xf03f1aa0, 0x7d2cd856, 0x3390ef22, - 0x494ec787, 0x38d1c1d9, 0xcaa2fe8c, 0xd40b3698, - 0xf581cfa6, 0x7ade28a5, 0xb78e26da, 0xadbfa43f, - 0x3a9de42c, 0x78920d50, 0x5fcc9b6a, 0x7e466254, - 0x8d13c2f6, 0xd8b8e890, 0x39f75e2e, 0xc3aff582, - 0x5d80be9f, 0xd0937c69, 0xd52da96f, 0x2512b3cf, - 0xac993bc8, 0x187da710, 0x9c636ee8, 0x3bbb7bdb, - 0x267809cd, 0x5918f46e, 0x9ab701ec, 0x4f9aa883, - 0x956e65e6, 0xffe67eaa, 0xbccf0821, 0x15e8e6ef, - 0xe79bd9ba, 0x6f36ce4a, 0x9f09d4ea, 0xb07cd629, - 0xa4b2af31, 0x3f23312a, 0xa59430c6, 0xa266c035, - 0x4ebc3774, 0x82caa6fc, 0x90d0b0e0, 0xa7d81533, - 0x04984af1, 0xecdaf741, 0xcd500e7f, 0x91f62f17, - 0x4dd68d76, 0xefb04d43, 0xaa4d54cc, 0x9604dfe4, - 0xd1b5e39e, 0x6a881b4c, 0x2c1fb8c1, 0x65517f46, - 0x5eea049d, 0x8c355d01, 0x877473fa, 0x0b412efb, - 0x671d5ab3, 0xdbd25292, 0x105633e9, 0xd647136d, - 0xd7618c9a, 0xa10c7a37, 0xf8148e59, 0x133c89eb, - 0xa927eece, 0x61c935b7, 0x1ce5ede1, 0x47b13c7a, - 0xd2df599c, 0xf2733f55, 0x14ce7918, 0xc737bf73, - 0xf7cdea53, 0xfdaa5b5f, 0x3d6f14df, 0x44db8678, - 0xaff381ca, 0x68c43eb9, 0x24342c38, 0xa3405fc2, - 0x1dc37216, 0xe2250cbc, 0x3c498b28, 0x0d9541ff, - 0xa8017139, 0x0cb3de08, 0xb4e49cd8, 0x56c19064, - 0xcb84617b, 0x32b670d5, 0x6c5c7448, 0xb85742d0 -}; - -const uint32_t _ad4[256] = { - 0x52525252, 0x09090909, 0x6a6a6a6a, 0xd5d5d5d5, - 0x30303030, 0x36363636, 0xa5a5a5a5, 0x38383838, - 0xbfbfbfbf, 0x40404040, 0xa3a3a3a3, 0x9e9e9e9e, - 0x81818181, 0xf3f3f3f3, 0xd7d7d7d7, 0xfbfbfbfb, - 0x7c7c7c7c, 0xe3e3e3e3, 0x39393939, 0x82828282, - 0x9b9b9b9b, 0x2f2f2f2f, 0xffffffff, 0x87878787, - 0x34343434, 0x8e8e8e8e, 0x43434343, 0x44444444, - 0xc4c4c4c4, 0xdededede, 0xe9e9e9e9, 0xcbcbcbcb, - 0x54545454, 0x7b7b7b7b, 0x94949494, 0x32323232, - 0xa6a6a6a6, 0xc2c2c2c2, 0x23232323, 0x3d3d3d3d, - 0xeeeeeeee, 0x4c4c4c4c, 0x95959595, 0x0b0b0b0b, - 0x42424242, 0xfafafafa, 0xc3c3c3c3, 0x4e4e4e4e, - 0x08080808, 0x2e2e2e2e, 0xa1a1a1a1, 0x66666666, - 0x28282828, 0xd9d9d9d9, 0x24242424, 0xb2b2b2b2, - 0x76767676, 0x5b5b5b5b, 0xa2a2a2a2, 0x49494949, - 0x6d6d6d6d, 0x8b8b8b8b, 0xd1d1d1d1, 0x25252525, - 0x72727272, 0xf8f8f8f8, 0xf6f6f6f6, 0x64646464, - 0x86868686, 0x68686868, 0x98989898, 0x16161616, - 0xd4d4d4d4, 0xa4a4a4a4, 0x5c5c5c5c, 0xcccccccc, - 0x5d5d5d5d, 0x65656565, 0xb6b6b6b6, 0x92929292, - 0x6c6c6c6c, 0x70707070, 0x48484848, 0x50505050, - 0xfdfdfdfd, 0xedededed, 0xb9b9b9b9, 0xdadadada, - 0x5e5e5e5e, 0x15151515, 0x46464646, 0x57575757, - 0xa7a7a7a7, 0x8d8d8d8d, 0x9d9d9d9d, 0x84848484, - 0x90909090, 0xd8d8d8d8, 0xabababab, 0x00000000, - 0x8c8c8c8c, 0xbcbcbcbc, 0xd3d3d3d3, 0x0a0a0a0a, - 0xf7f7f7f7, 0xe4e4e4e4, 0x58585858, 0x05050505, - 0xb8b8b8b8, 0xb3b3b3b3, 0x45454545, 0x06060606, - 0xd0d0d0d0, 0x2c2c2c2c, 0x1e1e1e1e, 0x8f8f8f8f, - 0xcacacaca, 0x3f3f3f3f, 0x0f0f0f0f, 0x02020202, - 0xc1c1c1c1, 0xafafafaf, 0xbdbdbdbd, 0x03030303, - 0x01010101, 0x13131313, 0x8a8a8a8a, 0x6b6b6b6b, - 0x3a3a3a3a, 0x91919191, 0x11111111, 0x41414141, - 0x4f4f4f4f, 0x67676767, 0xdcdcdcdc, 0xeaeaeaea, - 0x97979797, 0xf2f2f2f2, 0xcfcfcfcf, 0xcececece, - 0xf0f0f0f0, 0xb4b4b4b4, 0xe6e6e6e6, 0x73737373, - 0x96969696, 0xacacacac, 0x74747474, 0x22222222, - 0xe7e7e7e7, 0xadadadad, 0x35353535, 0x85858585, - 0xe2e2e2e2, 0xf9f9f9f9, 0x37373737, 0xe8e8e8e8, - 0x1c1c1c1c, 0x75757575, 0xdfdfdfdf, 0x6e6e6e6e, - 0x47474747, 0xf1f1f1f1, 0x1a1a1a1a, 0x71717171, - 0x1d1d1d1d, 0x29292929, 0xc5c5c5c5, 0x89898989, - 0x6f6f6f6f, 0xb7b7b7b7, 0x62626262, 0x0e0e0e0e, - 0xaaaaaaaa, 0x18181818, 0xbebebebe, 0x1b1b1b1b, - 0xfcfcfcfc, 0x56565656, 0x3e3e3e3e, 0x4b4b4b4b, - 0xc6c6c6c6, 0xd2d2d2d2, 0x79797979, 0x20202020, - 0x9a9a9a9a, 0xdbdbdbdb, 0xc0c0c0c0, 0xfefefefe, - 0x78787878, 0xcdcdcdcd, 0x5a5a5a5a, 0xf4f4f4f4, - 0x1f1f1f1f, 0xdddddddd, 0xa8a8a8a8, 0x33333333, - 0x88888888, 0x07070707, 0xc7c7c7c7, 0x31313131, - 0xb1b1b1b1, 0x12121212, 0x10101010, 0x59595959, - 0x27272727, 0x80808080, 0xecececec, 0x5f5f5f5f, - 0x60606060, 0x51515151, 0x7f7f7f7f, 0xa9a9a9a9, - 0x19191919, 0xb5b5b5b5, 0x4a4a4a4a, 0x0d0d0d0d, - 0x2d2d2d2d, 0xe5e5e5e5, 0x7a7a7a7a, 0x9f9f9f9f, - 0x93939393, 0xc9c9c9c9, 0x9c9c9c9c, 0xefefefef, - 0xa0a0a0a0, 0xe0e0e0e0, 0x3b3b3b3b, 0x4d4d4d4d, - 0xaeaeaeae, 0x2a2a2a2a, 0xf5f5f5f5, 0xb0b0b0b0, - 0xc8c8c8c8, 0xebebebeb, 0xbbbbbbbb, 0x3c3c3c3c, - 0x83838383, 0x53535353, 0x99999999, 0x61616161, - 0x17171717, 0x2b2b2b2b, 0x04040404, 0x7e7e7e7e, - 0xbabababa, 0x77777777, 0xd6d6d6d6, 0x26262626, - 0xe1e1e1e1, 0x69696969, 0x14141414, 0x63636363, - 0x55555555, 0x21212121, 0x0c0c0c0c, 0x7d7d7d7d -}; - -static const uint32_t _arc[] = { - 0x01000000, 0x02000000, 0x04000000, 0x08000000, - 0x10000000, 0x20000000, 0x40000000, 0x80000000, - 0x1b000000, 0x36000000 -}; - -#define etfs(i) \ - t0 = \ - _ae0[(s0 >> 24) ] ^ \ - _ae1[(s1 >> 16) & 0xff] ^ \ - _ae2[(s2 >> 8) & 0xff] ^ \ - _ae3[(s3 ) & 0xff] ^ \ - rk[i+0]; \ - t1 = \ - _ae0[(s1 >> 24) ] ^ \ - _ae1[(s2 >> 16) & 0xff] ^ \ - _ae2[(s3 >> 8) & 0xff] ^ \ - _ae3[(s0 ) & 0xff] ^ \ - rk[i+1]; \ - t2 = \ - _ae0[(s2 >> 24) ] ^ \ - _ae1[(s3 >> 16) & 0xff] ^ \ - _ae2[(s0 >> 8) & 0xff] ^ \ - _ae3[(s1 ) & 0xff] ^ \ - rk[i+2]; \ - t3 = \ - _ae0[(s3 >> 24) ] ^ \ - _ae1[(s0 >> 16) & 0xff] ^ \ - _ae2[(s1 >> 8) & 0xff] ^ \ - _ae3[(s2 ) & 0xff] ^ \ - rk[i+3]; - -#define esft(i) \ - s0 = \ - _ae0[(t0 >> 24) ] ^ \ - _ae1[(t1 >> 16) & 0xff] ^ \ - _ae2[(t2 >> 8) & 0xff] ^ \ - _ae3[(t3 ) & 0xff] ^ \ - rk[i+0]; \ - s1 = \ - _ae0[(t1 >> 24) ] ^ \ - _ae1[(t2 >> 16) & 0xff] ^ \ - _ae2[(t3 >> 8) & 0xff] ^ \ - _ae3[(t0 ) & 0xff] ^ \ - rk[i+1]; \ - s2 = \ - _ae0[(t2 >> 24) ] ^ \ - _ae1[(t3 >> 16) & 0xff] ^ \ - _ae2[(t0 >> 8) & 0xff] ^ \ - _ae3[(t1 ) & 0xff] ^ \ - rk[i+2]; \ - s3 = \ - _ae0[(t3 >> 24) ] ^ \ - _ae1[(t0 >> 16) & 0xff] ^ \ - _ae2[(t1 >> 8) & 0xff] ^ \ - _ae3[(t2 ) & 0xff] ^ \ - rk[i+3]; - -#define elr() \ - s0 = \ - (_ae4[(t0 >> 24) ] & 0xff000000) ^ \ - (_ae4[(t1 >> 16) & 0xff] & 0x00ff0000) ^ \ - (_ae4[(t2 >> 8) & 0xff] & 0x0000ff00) ^ \ - (_ae4[(t3 ) & 0xff] & 0x000000ff) ^ \ - rk[0]; \ - s1 = \ - (_ae4[(t1 >> 24) ] & 0xff000000) ^ \ - (_ae4[(t2 >> 16) & 0xff] & 0x00ff0000) ^ \ - (_ae4[(t3 >> 8) & 0xff] & 0x0000ff00) ^ \ - (_ae4[(t0 ) & 0xff] & 0x000000ff) ^ \ - rk[1]; \ - s2 = \ - (_ae4[(t2 >> 24) ] & 0xff000000) ^ \ - (_ae4[(t3 >> 16) & 0xff] & 0x00ff0000) ^ \ - (_ae4[(t0 >> 8) & 0xff] & 0x0000ff00) ^ \ - (_ae4[(t1 ) & 0xff] & 0x000000ff) ^ \ - rk[2]; \ - s3 = \ - (_ae4[(t3 >> 24) ] & 0xff000000) ^ \ - (_ae4[(t0 >> 16) & 0xff] & 0x00ff0000) ^ \ - (_ae4[(t1 >> 8) & 0xff] & 0x0000ff00) ^ \ - (_ae4[(t2 ) & 0xff] & 0x000000ff) ^ \ - rk[3]; - -#define dtfs(i) \ - t0 = \ - _ad0[(s0 >> 24) ] ^ \ - _ad1[(s3 >> 16) & 0xff] ^ \ - _ad2[(s2 >> 8) & 0xff] ^ \ - _ad3[(s1 ) & 0xff] ^ \ - rk[i+0]; \ - t1 = \ - _ad0[(s1 >> 24) ] ^ \ - _ad1[(s0 >> 16) & 0xff] ^ \ - _ad2[(s3 >> 8) & 0xff] ^ \ - _ad3[(s2 ) & 0xff] ^ \ - rk[i+1]; \ - t2 = \ - _ad0[(s2 >> 24) ] ^ \ - _ad1[(s1 >> 16) & 0xff] ^ \ - _ad2[(s0 >> 8) & 0xff] ^ \ - _ad3[(s3 ) & 0xff] ^ \ - rk[i+2]; \ - t3 = \ - _ad0[(s3 >> 24) ] ^ \ - _ad1[(s2 >> 16) & 0xff] ^ \ - _ad2[(s1 >> 8) & 0xff] ^ \ - _ad3[(s0 ) & 0xff] ^ \ - rk[i+3]; - -#define dsft(i) \ - s0 = \ - _ad0[(t0 >> 24) ] ^ \ - _ad1[(t3 >> 16) & 0xff] ^ \ - _ad2[(t2 >> 8) & 0xff] ^ \ - _ad3[(t1 ) & 0xff] ^ \ - rk[i+0]; \ - s1 = \ - _ad0[(t1 >> 24) ] ^ \ - _ad1[(t0 >> 16) & 0xff] ^ \ - _ad2[(t3 >> 8) & 0xff] ^ \ - _ad3[(t2 ) & 0xff] ^ \ - rk[i+1]; \ - s2 = \ - _ad0[(t2 >> 24) ] ^ \ - _ad1[(t1 >> 16) & 0xff] ^ \ - _ad2[(t0 >> 8) & 0xff] ^ \ - _ad3[(t3 ) & 0xff] ^ \ - rk[i+2]; \ - s3 = \ - _ad0[(t3 >> 24) ] ^ \ - _ad1[(t2 >> 16) & 0xff] ^ \ - _ad2[(t1 >> 8) & 0xff] ^ \ - _ad3[(t0 ) & 0xff] ^ \ - rk[i+3]; - -#define dlr() \ - s0 = \ - (_ad4[(t0 >> 24) ] & 0xff000000) ^ \ - (_ad4[(t3 >> 16) & 0xff] & 0x00ff0000) ^ \ - (_ad4[(t2 >> 8) & 0xff] & 0x0000ff00) ^ \ - (_ad4[(t1 ) & 0xff] & 0x000000ff) ^ \ - rk[0]; \ - s1 = \ - (_ad4[(t1 >> 24) ] & 0xff000000) ^ \ - (_ad4[(t0 >> 16) & 0xff] & 0x00ff0000) ^ \ - (_ad4[(t3 >> 8) & 0xff] & 0x0000ff00) ^ \ - (_ad4[(t2 ) & 0xff] & 0x000000ff) ^ \ - rk[1]; \ - s2 = \ - (_ad4[(t2 >> 24) ] & 0xff000000) ^ \ - (_ad4[(t1 >> 16) & 0xff] & 0x00ff0000) ^ \ - (_ad4[(t0 >> 8) & 0xff] & 0x0000ff00) ^ \ - (_ad4[(t3 ) & 0xff] & 0x000000ff) ^ \ - rk[2]; \ - s3 = \ - (_ad4[(t3 >> 24) ] & 0xff000000) ^ \ - (_ad4[(t2 >> 16) & 0xff] & 0x00ff0000) ^ \ - (_ad4[(t1 >> 8) & 0xff] & 0x0000ff00) ^ \ - (_ad4[(t0 ) & 0xff] & 0x000000ff) ^ \ - rk[3]; diff --git a/beecrypt/aes_le.h b/beecrypt/aes_le.h deleted file mode 100644 index 6b62ea3e0..000000000 --- a/beecrypt/aes_le.h +++ /dev/null @@ -1,882 +0,0 @@ -/* - * Copyright (c) 2003 Bob Deblier - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#if defined(OPTIMIZE_MMX) && (defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686)) -const uint64_t _ae0[256] = { -#else -const uint32_t _ae0[256] = { -#endif - 0xa56363c6, 0x847c7cf8, 0x997777ee, 0x8d7b7bf6, - 0x0df2f2ff, 0xbd6b6bd6, 0xb16f6fde, 0x54c5c591, - 0x50303060, 0x03010102, 0xa96767ce, 0x7d2b2b56, - 0x19fefee7, 0x62d7d7b5, 0xe6abab4d, 0x9a7676ec, - 0x45caca8f, 0x9d82821f, 0x40c9c989, 0x877d7dfa, - 0x15fafaef, 0xeb5959b2, 0xc947478e, 0x0bf0f0fb, - 0xecadad41, 0x67d4d4b3, 0xfda2a25f, 0xeaafaf45, - 0xbf9c9c23, 0xf7a4a453, 0x967272e4, 0x5bc0c09b, - 0xc2b7b775, 0x1cfdfde1, 0xae93933d, 0x6a26264c, - 0x5a36366c, 0x413f3f7e, 0x02f7f7f5, 0x4fcccc83, - 0x5c343468, 0xf4a5a551, 0x34e5e5d1, 0x08f1f1f9, - 0x937171e2, 0x73d8d8ab, 0x53313162, 0x3f15152a, - 0x0c040408, 0x52c7c795, 0x65232346, 0x5ec3c39d, - 0x28181830, 0xa1969637, 0x0f05050a, 0xb59a9a2f, - 0x0907070e, 0x36121224, 0x9b80801b, 0x3de2e2df, - 0x26ebebcd, 0x6927274e, 0xcdb2b27f, 0x9f7575ea, - 0x1b090912, 0x9e83831d, 0x742c2c58, 0x2e1a1a34, - 0x2d1b1b36, 0xb26e6edc, 0xee5a5ab4, 0xfba0a05b, - 0xf65252a4, 0x4d3b3b76, 0x61d6d6b7, 0xceb3b37d, - 0x7b292952, 0x3ee3e3dd, 0x712f2f5e, 0x97848413, - 0xf55353a6, 0x68d1d1b9, 0x00000000, 0x2cededc1, - 0x60202040, 0x1ffcfce3, 0xc8b1b179, 0xed5b5bb6, - 0xbe6a6ad4, 0x46cbcb8d, 0xd9bebe67, 0x4b393972, - 0xde4a4a94, 0xd44c4c98, 0xe85858b0, 0x4acfcf85, - 0x6bd0d0bb, 0x2aefefc5, 0xe5aaaa4f, 0x16fbfbed, - 0xc5434386, 0xd74d4d9a, 0x55333366, 0x94858511, - 0xcf45458a, 0x10f9f9e9, 0x06020204, 0x817f7ffe, - 0xf05050a0, 0x443c3c78, 0xba9f9f25, 0xe3a8a84b, - 0xf35151a2, 0xfea3a35d, 0xc0404080, 0x8a8f8f05, - 0xad92923f, 0xbc9d9d21, 0x48383870, 0x04f5f5f1, - 0xdfbcbc63, 0xc1b6b677, 0x75dadaaf, 0x63212142, - 0x30101020, 0x1affffe5, 0x0ef3f3fd, 0x6dd2d2bf, - 0x4ccdcd81, 0x140c0c18, 0x35131326, 0x2fececc3, - 0xe15f5fbe, 0xa2979735, 0xcc444488, 0x3917172e, - 0x57c4c493, 0xf2a7a755, 0x827e7efc, 0x473d3d7a, - 0xac6464c8, 0xe75d5dba, 0x2b191932, 0x957373e6, - 0xa06060c0, 0x98818119, 0xd14f4f9e, 0x7fdcdca3, - 0x66222244, 0x7e2a2a54, 0xab90903b, 0x8388880b, - 0xca46468c, 0x29eeeec7, 0xd3b8b86b, 0x3c141428, - 0x79dedea7, 0xe25e5ebc, 0x1d0b0b16, 0x76dbdbad, - 0x3be0e0db, 0x56323264, 0x4e3a3a74, 0x1e0a0a14, - 0xdb494992, 0x0a06060c, 0x6c242448, 0xe45c5cb8, - 0x5dc2c29f, 0x6ed3d3bd, 0xefacac43, 0xa66262c4, - 0xa8919139, 0xa4959531, 0x37e4e4d3, 0x8b7979f2, - 0x32e7e7d5, 0x43c8c88b, 0x5937376e, 0xb76d6dda, - 0x8c8d8d01, 0x64d5d5b1, 0xd24e4e9c, 0xe0a9a949, - 0xb46c6cd8, 0xfa5656ac, 0x07f4f4f3, 0x25eaeacf, - 0xaf6565ca, 0x8e7a7af4, 0xe9aeae47, 0x18080810, - 0xd5baba6f, 0x887878f0, 0x6f25254a, 0x722e2e5c, - 0x241c1c38, 0xf1a6a657, 0xc7b4b473, 0x51c6c697, - 0x23e8e8cb, 0x7cdddda1, 0x9c7474e8, 0x211f1f3e, - 0xdd4b4b96, 0xdcbdbd61, 0x868b8b0d, 0x858a8a0f, - 0x907070e0, 0x423e3e7c, 0xc4b5b571, 0xaa6666cc, - 0xd8484890, 0x05030306, 0x01f6f6f7, 0x120e0e1c, - 0xa36161c2, 0x5f35356a, 0xf95757ae, 0xd0b9b969, - 0x91868617, 0x58c1c199, 0x271d1d3a, 0xb99e9e27, - 0x38e1e1d9, 0x13f8f8eb, 0xb398982b, 0x33111122, - 0xbb6969d2, 0x70d9d9a9, 0x898e8e07, 0xa7949433, - 0xb69b9b2d, 0x221e1e3c, 0x92878715, 0x20e9e9c9, - 0x49cece87, 0xff5555aa, 0x78282850, 0x7adfdfa5, - 0x8f8c8c03, 0xf8a1a159, 0x80898909, 0x170d0d1a, - 0xdabfbf65, 0x31e6e6d7, 0xc6424284, 0xb86868d0, - 0xc3414182, 0xb0999929, 0x772d2d5a, 0x110f0f1e, - 0xcbb0b07b, 0xfc5454a8, 0xd6bbbb6d, 0x3a16162c -}; - -#if defined(OPTIMIZE_MMX) && (defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686)) -const uint64_t _ae1[256] = { -#else -const uint32_t _ae1[256] = { -#endif - 0x6363c6a5, 0x7c7cf884, 0x7777ee99, 0x7b7bf68d, - 0xf2f2ff0d, 0x6b6bd6bd, 0x6f6fdeb1, 0xc5c59154, - 0x30306050, 0x01010203, 0x6767cea9, 0x2b2b567d, - 0xfefee719, 0xd7d7b562, 0xabab4de6, 0x7676ec9a, - 0xcaca8f45, 0x82821f9d, 0xc9c98940, 0x7d7dfa87, - 0xfafaef15, 0x5959b2eb, 0x47478ec9, 0xf0f0fb0b, - 0xadad41ec, 0xd4d4b367, 0xa2a25ffd, 0xafaf45ea, - 0x9c9c23bf, 0xa4a453f7, 0x7272e496, 0xc0c09b5b, - 0xb7b775c2, 0xfdfde11c, 0x93933dae, 0x26264c6a, - 0x36366c5a, 0x3f3f7e41, 0xf7f7f502, 0xcccc834f, - 0x3434685c, 0xa5a551f4, 0xe5e5d134, 0xf1f1f908, - 0x7171e293, 0xd8d8ab73, 0x31316253, 0x15152a3f, - 0x0404080c, 0xc7c79552, 0x23234665, 0xc3c39d5e, - 0x18183028, 0x969637a1, 0x05050a0f, 0x9a9a2fb5, - 0x07070e09, 0x12122436, 0x80801b9b, 0xe2e2df3d, - 0xebebcd26, 0x27274e69, 0xb2b27fcd, 0x7575ea9f, - 0x0909121b, 0x83831d9e, 0x2c2c5874, 0x1a1a342e, - 0x1b1b362d, 0x6e6edcb2, 0x5a5ab4ee, 0xa0a05bfb, - 0x5252a4f6, 0x3b3b764d, 0xd6d6b761, 0xb3b37dce, - 0x2929527b, 0xe3e3dd3e, 0x2f2f5e71, 0x84841397, - 0x5353a6f5, 0xd1d1b968, 0x00000000, 0xededc12c, - 0x20204060, 0xfcfce31f, 0xb1b179c8, 0x5b5bb6ed, - 0x6a6ad4be, 0xcbcb8d46, 0xbebe67d9, 0x3939724b, - 0x4a4a94de, 0x4c4c98d4, 0x5858b0e8, 0xcfcf854a, - 0xd0d0bb6b, 0xefefc52a, 0xaaaa4fe5, 0xfbfbed16, - 0x434386c5, 0x4d4d9ad7, 0x33336655, 0x85851194, - 0x45458acf, 0xf9f9e910, 0x02020406, 0x7f7ffe81, - 0x5050a0f0, 0x3c3c7844, 0x9f9f25ba, 0xa8a84be3, - 0x5151a2f3, 0xa3a35dfe, 0x404080c0, 0x8f8f058a, - 0x92923fad, 0x9d9d21bc, 0x38387048, 0xf5f5f104, - 0xbcbc63df, 0xb6b677c1, 0xdadaaf75, 0x21214263, - 0x10102030, 0xffffe51a, 0xf3f3fd0e, 0xd2d2bf6d, - 0xcdcd814c, 0x0c0c1814, 0x13132635, 0xececc32f, - 0x5f5fbee1, 0x979735a2, 0x444488cc, 0x17172e39, - 0xc4c49357, 0xa7a755f2, 0x7e7efc82, 0x3d3d7a47, - 0x6464c8ac, 0x5d5dbae7, 0x1919322b, 0x7373e695, - 0x6060c0a0, 0x81811998, 0x4f4f9ed1, 0xdcdca37f, - 0x22224466, 0x2a2a547e, 0x90903bab, 0x88880b83, - 0x46468cca, 0xeeeec729, 0xb8b86bd3, 0x1414283c, - 0xdedea779, 0x5e5ebce2, 0x0b0b161d, 0xdbdbad76, - 0xe0e0db3b, 0x32326456, 0x3a3a744e, 0x0a0a141e, - 0x494992db, 0x06060c0a, 0x2424486c, 0x5c5cb8e4, - 0xc2c29f5d, 0xd3d3bd6e, 0xacac43ef, 0x6262c4a6, - 0x919139a8, 0x959531a4, 0xe4e4d337, 0x7979f28b, - 0xe7e7d532, 0xc8c88b43, 0x37376e59, 0x6d6ddab7, - 0x8d8d018c, 0xd5d5b164, 0x4e4e9cd2, 0xa9a949e0, - 0x6c6cd8b4, 0x5656acfa, 0xf4f4f307, 0xeaeacf25, - 0x6565caaf, 0x7a7af48e, 0xaeae47e9, 0x08081018, - 0xbaba6fd5, 0x7878f088, 0x25254a6f, 0x2e2e5c72, - 0x1c1c3824, 0xa6a657f1, 0xb4b473c7, 0xc6c69751, - 0xe8e8cb23, 0xdddda17c, 0x7474e89c, 0x1f1f3e21, - 0x4b4b96dd, 0xbdbd61dc, 0x8b8b0d86, 0x8a8a0f85, - 0x7070e090, 0x3e3e7c42, 0xb5b571c4, 0x6666ccaa, - 0x484890d8, 0x03030605, 0xf6f6f701, 0x0e0e1c12, - 0x6161c2a3, 0x35356a5f, 0x5757aef9, 0xb9b969d0, - 0x86861791, 0xc1c19958, 0x1d1d3a27, 0x9e9e27b9, - 0xe1e1d938, 0xf8f8eb13, 0x98982bb3, 0x11112233, - 0x6969d2bb, 0xd9d9a970, 0x8e8e0789, 0x949433a7, - 0x9b9b2db6, 0x1e1e3c22, 0x87871592, 0xe9e9c920, - 0xcece8749, 0x5555aaff, 0x28285078, 0xdfdfa57a, - 0x8c8c038f, 0xa1a159f8, 0x89890980, 0x0d0d1a17, - 0xbfbf65da, 0xe6e6d731, 0x424284c6, 0x6868d0b8, - 0x414182c3, 0x999929b0, 0x2d2d5a77, 0x0f0f1e11, - 0xb0b07bcb, 0x5454a8fc, 0xbbbb6dd6, 0x16162c3a -}; - -#if defined(OPTIMIZE_MMX) && (defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686)) -const uint64_t _ae2[256] = { -#else -const uint32_t _ae2[256] = { -#endif - 0x63c6a563, 0x7cf8847c, 0x77ee9977, 0x7bf68d7b, - 0xf2ff0df2, 0x6bd6bd6b, 0x6fdeb16f, 0xc59154c5, - 0x30605030, 0x01020301, 0x67cea967, 0x2b567d2b, - 0xfee719fe, 0xd7b562d7, 0xab4de6ab, 0x76ec9a76, - 0xca8f45ca, 0x821f9d82, 0xc98940c9, 0x7dfa877d, - 0xfaef15fa, 0x59b2eb59, 0x478ec947, 0xf0fb0bf0, - 0xad41ecad, 0xd4b367d4, 0xa25ffda2, 0xaf45eaaf, - 0x9c23bf9c, 0xa453f7a4, 0x72e49672, 0xc09b5bc0, - 0xb775c2b7, 0xfde11cfd, 0x933dae93, 0x264c6a26, - 0x366c5a36, 0x3f7e413f, 0xf7f502f7, 0xcc834fcc, - 0x34685c34, 0xa551f4a5, 0xe5d134e5, 0xf1f908f1, - 0x71e29371, 0xd8ab73d8, 0x31625331, 0x152a3f15, - 0x04080c04, 0xc79552c7, 0x23466523, 0xc39d5ec3, - 0x18302818, 0x9637a196, 0x050a0f05, 0x9a2fb59a, - 0x070e0907, 0x12243612, 0x801b9b80, 0xe2df3de2, - 0xebcd26eb, 0x274e6927, 0xb27fcdb2, 0x75ea9f75, - 0x09121b09, 0x831d9e83, 0x2c58742c, 0x1a342e1a, - 0x1b362d1b, 0x6edcb26e, 0x5ab4ee5a, 0xa05bfba0, - 0x52a4f652, 0x3b764d3b, 0xd6b761d6, 0xb37dceb3, - 0x29527b29, 0xe3dd3ee3, 0x2f5e712f, 0x84139784, - 0x53a6f553, 0xd1b968d1, 0x00000000, 0xedc12ced, - 0x20406020, 0xfce31ffc, 0xb179c8b1, 0x5bb6ed5b, - 0x6ad4be6a, 0xcb8d46cb, 0xbe67d9be, 0x39724b39, - 0x4a94de4a, 0x4c98d44c, 0x58b0e858, 0xcf854acf, - 0xd0bb6bd0, 0xefc52aef, 0xaa4fe5aa, 0xfbed16fb, - 0x4386c543, 0x4d9ad74d, 0x33665533, 0x85119485, - 0x458acf45, 0xf9e910f9, 0x02040602, 0x7ffe817f, - 0x50a0f050, 0x3c78443c, 0x9f25ba9f, 0xa84be3a8, - 0x51a2f351, 0xa35dfea3, 0x4080c040, 0x8f058a8f, - 0x923fad92, 0x9d21bc9d, 0x38704838, 0xf5f104f5, - 0xbc63dfbc, 0xb677c1b6, 0xdaaf75da, 0x21426321, - 0x10203010, 0xffe51aff, 0xf3fd0ef3, 0xd2bf6dd2, - 0xcd814ccd, 0x0c18140c, 0x13263513, 0xecc32fec, - 0x5fbee15f, 0x9735a297, 0x4488cc44, 0x172e3917, - 0xc49357c4, 0xa755f2a7, 0x7efc827e, 0x3d7a473d, - 0x64c8ac64, 0x5dbae75d, 0x19322b19, 0x73e69573, - 0x60c0a060, 0x81199881, 0x4f9ed14f, 0xdca37fdc, - 0x22446622, 0x2a547e2a, 0x903bab90, 0x880b8388, - 0x468cca46, 0xeec729ee, 0xb86bd3b8, 0x14283c14, - 0xdea779de, 0x5ebce25e, 0x0b161d0b, 0xdbad76db, - 0xe0db3be0, 0x32645632, 0x3a744e3a, 0x0a141e0a, - 0x4992db49, 0x060c0a06, 0x24486c24, 0x5cb8e45c, - 0xc29f5dc2, 0xd3bd6ed3, 0xac43efac, 0x62c4a662, - 0x9139a891, 0x9531a495, 0xe4d337e4, 0x79f28b79, - 0xe7d532e7, 0xc88b43c8, 0x376e5937, 0x6ddab76d, - 0x8d018c8d, 0xd5b164d5, 0x4e9cd24e, 0xa949e0a9, - 0x6cd8b46c, 0x56acfa56, 0xf4f307f4, 0xeacf25ea, - 0x65caaf65, 0x7af48e7a, 0xae47e9ae, 0x08101808, - 0xba6fd5ba, 0x78f08878, 0x254a6f25, 0x2e5c722e, - 0x1c38241c, 0xa657f1a6, 0xb473c7b4, 0xc69751c6, - 0xe8cb23e8, 0xdda17cdd, 0x74e89c74, 0x1f3e211f, - 0x4b96dd4b, 0xbd61dcbd, 0x8b0d868b, 0x8a0f858a, - 0x70e09070, 0x3e7c423e, 0xb571c4b5, 0x66ccaa66, - 0x4890d848, 0x03060503, 0xf6f701f6, 0x0e1c120e, - 0x61c2a361, 0x356a5f35, 0x57aef957, 0xb969d0b9, - 0x86179186, 0xc19958c1, 0x1d3a271d, 0x9e27b99e, - 0xe1d938e1, 0xf8eb13f8, 0x982bb398, 0x11223311, - 0x69d2bb69, 0xd9a970d9, 0x8e07898e, 0x9433a794, - 0x9b2db69b, 0x1e3c221e, 0x87159287, 0xe9c920e9, - 0xce8749ce, 0x55aaff55, 0x28507828, 0xdfa57adf, - 0x8c038f8c, 0xa159f8a1, 0x89098089, 0x0d1a170d, - 0xbf65dabf, 0xe6d731e6, 0x4284c642, 0x68d0b868, - 0x4182c341, 0x9929b099, 0x2d5a772d, 0x0f1e110f, - 0xb07bcbb0, 0x54a8fc54, 0xbb6dd6bb, 0x162c3a16 -}; - -#if defined(OPTIMIZE_MMX) && (defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686)) -const uint64_t _ae3[256] = { -#else -const uint32_t _ae3[256] = { -#endif - 0xc6a56363, 0xf8847c7c, 0xee997777, 0xf68d7b7b, - 0xff0df2f2, 0xd6bd6b6b, 0xdeb16f6f, 0x9154c5c5, - 0x60503030, 0x02030101, 0xcea96767, 0x567d2b2b, - 0xe719fefe, 0xb562d7d7, 0x4de6abab, 0xec9a7676, - 0x8f45caca, 0x1f9d8282, 0x8940c9c9, 0xfa877d7d, - 0xef15fafa, 0xb2eb5959, 0x8ec94747, 0xfb0bf0f0, - 0x41ecadad, 0xb367d4d4, 0x5ffda2a2, 0x45eaafaf, - 0x23bf9c9c, 0x53f7a4a4, 0xe4967272, 0x9b5bc0c0, - 0x75c2b7b7, 0xe11cfdfd, 0x3dae9393, 0x4c6a2626, - 0x6c5a3636, 0x7e413f3f, 0xf502f7f7, 0x834fcccc, - 0x685c3434, 0x51f4a5a5, 0xd134e5e5, 0xf908f1f1, - 0xe2937171, 0xab73d8d8, 0x62533131, 0x2a3f1515, - 0x080c0404, 0x9552c7c7, 0x46652323, 0x9d5ec3c3, - 0x30281818, 0x37a19696, 0x0a0f0505, 0x2fb59a9a, - 0x0e090707, 0x24361212, 0x1b9b8080, 0xdf3de2e2, - 0xcd26ebeb, 0x4e692727, 0x7fcdb2b2, 0xea9f7575, - 0x121b0909, 0x1d9e8383, 0x58742c2c, 0x342e1a1a, - 0x362d1b1b, 0xdcb26e6e, 0xb4ee5a5a, 0x5bfba0a0, - 0xa4f65252, 0x764d3b3b, 0xb761d6d6, 0x7dceb3b3, - 0x527b2929, 0xdd3ee3e3, 0x5e712f2f, 0x13978484, - 0xa6f55353, 0xb968d1d1, 0x00000000, 0xc12ceded, - 0x40602020, 0xe31ffcfc, 0x79c8b1b1, 0xb6ed5b5b, - 0xd4be6a6a, 0x8d46cbcb, 0x67d9bebe, 0x724b3939, - 0x94de4a4a, 0x98d44c4c, 0xb0e85858, 0x854acfcf, - 0xbb6bd0d0, 0xc52aefef, 0x4fe5aaaa, 0xed16fbfb, - 0x86c54343, 0x9ad74d4d, 0x66553333, 0x11948585, - 0x8acf4545, 0xe910f9f9, 0x04060202, 0xfe817f7f, - 0xa0f05050, 0x78443c3c, 0x25ba9f9f, 0x4be3a8a8, - 0xa2f35151, 0x5dfea3a3, 0x80c04040, 0x058a8f8f, - 0x3fad9292, 0x21bc9d9d, 0x70483838, 0xf104f5f5, - 0x63dfbcbc, 0x77c1b6b6, 0xaf75dada, 0x42632121, - 0x20301010, 0xe51affff, 0xfd0ef3f3, 0xbf6dd2d2, - 0x814ccdcd, 0x18140c0c, 0x26351313, 0xc32fecec, - 0xbee15f5f, 0x35a29797, 0x88cc4444, 0x2e391717, - 0x9357c4c4, 0x55f2a7a7, 0xfc827e7e, 0x7a473d3d, - 0xc8ac6464, 0xbae75d5d, 0x322b1919, 0xe6957373, - 0xc0a06060, 0x19988181, 0x9ed14f4f, 0xa37fdcdc, - 0x44662222, 0x547e2a2a, 0x3bab9090, 0x0b838888, - 0x8cca4646, 0xc729eeee, 0x6bd3b8b8, 0x283c1414, - 0xa779dede, 0xbce25e5e, 0x161d0b0b, 0xad76dbdb, - 0xdb3be0e0, 0x64563232, 0x744e3a3a, 0x141e0a0a, - 0x92db4949, 0x0c0a0606, 0x486c2424, 0xb8e45c5c, - 0x9f5dc2c2, 0xbd6ed3d3, 0x43efacac, 0xc4a66262, - 0x39a89191, 0x31a49595, 0xd337e4e4, 0xf28b7979, - 0xd532e7e7, 0x8b43c8c8, 0x6e593737, 0xdab76d6d, - 0x018c8d8d, 0xb164d5d5, 0x9cd24e4e, 0x49e0a9a9, - 0xd8b46c6c, 0xacfa5656, 0xf307f4f4, 0xcf25eaea, - 0xcaaf6565, 0xf48e7a7a, 0x47e9aeae, 0x10180808, - 0x6fd5baba, 0xf0887878, 0x4a6f2525, 0x5c722e2e, - 0x38241c1c, 0x57f1a6a6, 0x73c7b4b4, 0x9751c6c6, - 0xcb23e8e8, 0xa17cdddd, 0xe89c7474, 0x3e211f1f, - 0x96dd4b4b, 0x61dcbdbd, 0x0d868b8b, 0x0f858a8a, - 0xe0907070, 0x7c423e3e, 0x71c4b5b5, 0xccaa6666, - 0x90d84848, 0x06050303, 0xf701f6f6, 0x1c120e0e, - 0xc2a36161, 0x6a5f3535, 0xaef95757, 0x69d0b9b9, - 0x17918686, 0x9958c1c1, 0x3a271d1d, 0x27b99e9e, - 0xd938e1e1, 0xeb13f8f8, 0x2bb39898, 0x22331111, - 0xd2bb6969, 0xa970d9d9, 0x07898e8e, 0x33a79494, - 0x2db69b9b, 0x3c221e1e, 0x15928787, 0xc920e9e9, - 0x8749cece, 0xaaff5555, 0x50782828, 0xa57adfdf, - 0x038f8c8c, 0x59f8a1a1, 0x09808989, 0x1a170d0d, - 0x65dabfbf, 0xd731e6e6, 0x84c64242, 0xd0b86868, - 0x82c34141, 0x29b09999, 0x5a772d2d, 0x1e110f0f, - 0x7bcbb0b0, 0xa8fc5454, 0x6dd6bbbb, 0x2c3a1616 -}; - -const uint32_t _ae4[256] = { - 0x63636363, 0x7c7c7c7c, 0x77777777, 0x7b7b7b7b, - 0xf2f2f2f2, 0x6b6b6b6b, 0x6f6f6f6f, 0xc5c5c5c5, - 0x30303030, 0x01010101, 0x67676767, 0x2b2b2b2b, - 0xfefefefe, 0xd7d7d7d7, 0xabababab, 0x76767676, - 0xcacacaca, 0x82828282, 0xc9c9c9c9, 0x7d7d7d7d, - 0xfafafafa, 0x59595959, 0x47474747, 0xf0f0f0f0, - 0xadadadad, 0xd4d4d4d4, 0xa2a2a2a2, 0xafafafaf, - 0x9c9c9c9c, 0xa4a4a4a4, 0x72727272, 0xc0c0c0c0, - 0xb7b7b7b7, 0xfdfdfdfd, 0x93939393, 0x26262626, - 0x36363636, 0x3f3f3f3f, 0xf7f7f7f7, 0xcccccccc, - 0x34343434, 0xa5a5a5a5, 0xe5e5e5e5, 0xf1f1f1f1, - 0x71717171, 0xd8d8d8d8, 0x31313131, 0x15151515, - 0x04040404, 0xc7c7c7c7, 0x23232323, 0xc3c3c3c3, - 0x18181818, 0x96969696, 0x05050505, 0x9a9a9a9a, - 0x07070707, 0x12121212, 0x80808080, 0xe2e2e2e2, - 0xebebebeb, 0x27272727, 0xb2b2b2b2, 0x75757575, - 0x09090909, 0x83838383, 0x2c2c2c2c, 0x1a1a1a1a, - 0x1b1b1b1b, 0x6e6e6e6e, 0x5a5a5a5a, 0xa0a0a0a0, - 0x52525252, 0x3b3b3b3b, 0xd6d6d6d6, 0xb3b3b3b3, - 0x29292929, 0xe3e3e3e3, 0x2f2f2f2f, 0x84848484, - 0x53535353, 0xd1d1d1d1, 0x00000000, 0xedededed, - 0x20202020, 0xfcfcfcfc, 0xb1b1b1b1, 0x5b5b5b5b, - 0x6a6a6a6a, 0xcbcbcbcb, 0xbebebebe, 0x39393939, - 0x4a4a4a4a, 0x4c4c4c4c, 0x58585858, 0xcfcfcfcf, - 0xd0d0d0d0, 0xefefefef, 0xaaaaaaaa, 0xfbfbfbfb, - 0x43434343, 0x4d4d4d4d, 0x33333333, 0x85858585, - 0x45454545, 0xf9f9f9f9, 0x02020202, 0x7f7f7f7f, - 0x50505050, 0x3c3c3c3c, 0x9f9f9f9f, 0xa8a8a8a8, - 0x51515151, 0xa3a3a3a3, 0x40404040, 0x8f8f8f8f, - 0x92929292, 0x9d9d9d9d, 0x38383838, 0xf5f5f5f5, - 0xbcbcbcbc, 0xb6b6b6b6, 0xdadadada, 0x21212121, - 0x10101010, 0xffffffff, 0xf3f3f3f3, 0xd2d2d2d2, - 0xcdcdcdcd, 0x0c0c0c0c, 0x13131313, 0xecececec, - 0x5f5f5f5f, 0x97979797, 0x44444444, 0x17171717, - 0xc4c4c4c4, 0xa7a7a7a7, 0x7e7e7e7e, 0x3d3d3d3d, - 0x64646464, 0x5d5d5d5d, 0x19191919, 0x73737373, - 0x60606060, 0x81818181, 0x4f4f4f4f, 0xdcdcdcdc, - 0x22222222, 0x2a2a2a2a, 0x90909090, 0x88888888, - 0x46464646, 0xeeeeeeee, 0xb8b8b8b8, 0x14141414, - 0xdededede, 0x5e5e5e5e, 0x0b0b0b0b, 0xdbdbdbdb, - 0xe0e0e0e0, 0x32323232, 0x3a3a3a3a, 0x0a0a0a0a, - 0x49494949, 0x06060606, 0x24242424, 0x5c5c5c5c, - 0xc2c2c2c2, 0xd3d3d3d3, 0xacacacac, 0x62626262, - 0x91919191, 0x95959595, 0xe4e4e4e4, 0x79797979, - 0xe7e7e7e7, 0xc8c8c8c8, 0x37373737, 0x6d6d6d6d, - 0x8d8d8d8d, 0xd5d5d5d5, 0x4e4e4e4e, 0xa9a9a9a9, - 0x6c6c6c6c, 0x56565656, 0xf4f4f4f4, 0xeaeaeaea, - 0x65656565, 0x7a7a7a7a, 0xaeaeaeae, 0x08080808, - 0xbabababa, 0x78787878, 0x25252525, 0x2e2e2e2e, - 0x1c1c1c1c, 0xa6a6a6a6, 0xb4b4b4b4, 0xc6c6c6c6, - 0xe8e8e8e8, 0xdddddddd, 0x74747474, 0x1f1f1f1f, - 0x4b4b4b4b, 0xbdbdbdbd, 0x8b8b8b8b, 0x8a8a8a8a, - 0x70707070, 0x3e3e3e3e, 0xb5b5b5b5, 0x66666666, - 0x48484848, 0x03030303, 0xf6f6f6f6, 0x0e0e0e0e, - 0x61616161, 0x35353535, 0x57575757, 0xb9b9b9b9, - 0x86868686, 0xc1c1c1c1, 0x1d1d1d1d, 0x9e9e9e9e, - 0xe1e1e1e1, 0xf8f8f8f8, 0x98989898, 0x11111111, - 0x69696969, 0xd9d9d9d9, 0x8e8e8e8e, 0x94949494, - 0x9b9b9b9b, 0x1e1e1e1e, 0x87878787, 0xe9e9e9e9, - 0xcececece, 0x55555555, 0x28282828, 0xdfdfdfdf, - 0x8c8c8c8c, 0xa1a1a1a1, 0x89898989, 0x0d0d0d0d, - 0xbfbfbfbf, 0xe6e6e6e6, 0x42424242, 0x68686868, - 0x41414141, 0x99999999, 0x2d2d2d2d, 0x0f0f0f0f, - 0xb0b0b0b0, 0x54545454, 0xbbbbbbbb, 0x16161616 -}; - -#if defined(OPTIMIZE_MMX) && (defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686)) -const uint64_t _ad0[256] = { -#else -const uint32_t _ad0[256] = { -#endif - 0x50a7f451, 0x5365417e, 0xc3a4171a, 0x965e273a, - 0xcb6bab3b, 0xf1459d1f, 0xab58faac, 0x9303e34b, - 0x55fa3020, 0xf66d76ad, 0x9176cc88, 0x254c02f5, - 0xfcd7e54f, 0xd7cb2ac5, 0x80443526, 0x8fa362b5, - 0x495ab1de, 0x671bba25, 0x980eea45, 0xe1c0fe5d, - 0x02752fc3, 0x12f04c81, 0xa397468d, 0xc6f9d36b, - 0xe75f8f03, 0x959c9215, 0xeb7a6dbf, 0xda595295, - 0x2d83bed4, 0xd3217458, 0x2969e049, 0x44c8c98e, - 0x6a89c275, 0x78798ef4, 0x6b3e5899, 0xdd71b927, - 0xb64fe1be, 0x17ad88f0, 0x66ac20c9, 0xb43ace7d, - 0x184adf63, 0x82311ae5, 0x60335197, 0x457f5362, - 0xe07764b1, 0x84ae6bbb, 0x1ca081fe, 0x942b08f9, - 0x58684870, 0x19fd458f, 0x876cde94, 0xb7f87b52, - 0x23d373ab, 0xe2024b72, 0x578f1fe3, 0x2aab5566, - 0x0728ebb2, 0x03c2b52f, 0x9a7bc586, 0xa50837d3, - 0xf2872830, 0xb2a5bf23, 0xba6a0302, 0x5c8216ed, - 0x2b1ccf8a, 0x92b479a7, 0xf0f207f3, 0xa1e2694e, - 0xcdf4da65, 0xd5be0506, 0x1f6234d1, 0x8afea6c4, - 0x9d532e34, 0xa055f3a2, 0x32e18a05, 0x75ebf6a4, - 0x39ec830b, 0xaaef6040, 0x069f715e, 0x51106ebd, - 0xf98a213e, 0x3d06dd96, 0xae053edd, 0x46bde64d, - 0xb58d5491, 0x055dc471, 0x6fd40604, 0xff155060, - 0x24fb9819, 0x97e9bdd6, 0xcc434089, 0x779ed967, - 0xbd42e8b0, 0x888b8907, 0x385b19e7, 0xdbeec879, - 0x470a7ca1, 0xe90f427c, 0xc91e84f8, 0x00000000, - 0x83868009, 0x48ed2b32, 0xac70111e, 0x4e725a6c, - 0xfbff0efd, 0x5638850f, 0x1ed5ae3d, 0x27392d36, - 0x64d90f0a, 0x21a65c68, 0xd1545b9b, 0x3a2e3624, - 0xb1670a0c, 0x0fe75793, 0xd296eeb4, 0x9e919b1b, - 0x4fc5c080, 0xa220dc61, 0x694b775a, 0x161a121c, - 0x0aba93e2, 0xe52aa0c0, 0x43e0223c, 0x1d171b12, - 0x0b0d090e, 0xadc78bf2, 0xb9a8b62d, 0xc8a91e14, - 0x8519f157, 0x4c0775af, 0xbbdd99ee, 0xfd607fa3, - 0x9f2601f7, 0xbcf5725c, 0xc53b6644, 0x347efb5b, - 0x7629438b, 0xdcc623cb, 0x68fcedb6, 0x63f1e4b8, - 0xcadc31d7, 0x10856342, 0x40229713, 0x2011c684, - 0x7d244a85, 0xf83dbbd2, 0x1132f9ae, 0x6da129c7, - 0x4b2f9e1d, 0xf330b2dc, 0xec52860d, 0xd0e3c177, - 0x6c16b32b, 0x99b970a9, 0xfa489411, 0x2264e947, - 0xc48cfca8, 0x1a3ff0a0, 0xd82c7d56, 0xef903322, - 0xc74e4987, 0xc1d138d9, 0xfea2ca8c, 0x360bd498, - 0xcf81f5a6, 0x28de7aa5, 0x268eb7da, 0xa4bfad3f, - 0xe49d3a2c, 0x0d927850, 0x9bcc5f6a, 0x62467e54, - 0xc2138df6, 0xe8b8d890, 0x5ef7392e, 0xf5afc382, - 0xbe805d9f, 0x7c93d069, 0xa92dd56f, 0xb31225cf, - 0x3b99acc8, 0xa77d1810, 0x6e639ce8, 0x7bbb3bdb, - 0x097826cd, 0xf418596e, 0x01b79aec, 0xa89a4f83, - 0x656e95e6, 0x7ee6ffaa, 0x08cfbc21, 0xe6e815ef, - 0xd99be7ba, 0xce366f4a, 0xd4099fea, 0xd67cb029, - 0xafb2a431, 0x31233f2a, 0x3094a5c6, 0xc066a235, - 0x37bc4e74, 0xa6ca82fc, 0xb0d090e0, 0x15d8a733, - 0x4a9804f1, 0xf7daec41, 0x0e50cd7f, 0x2ff69117, - 0x8dd64d76, 0x4db0ef43, 0x544daacc, 0xdf0496e4, - 0xe3b5d19e, 0x1b886a4c, 0xb81f2cc1, 0x7f516546, - 0x04ea5e9d, 0x5d358c01, 0x737487fa, 0x2e410bfb, - 0x5a1d67b3, 0x52d2db92, 0x335610e9, 0x1347d66d, - 0x8c61d79a, 0x7a0ca137, 0x8e14f859, 0x893c13eb, - 0xee27a9ce, 0x35c961b7, 0xede51ce1, 0x3cb1477a, - 0x59dfd29c, 0x3f73f255, 0x79ce1418, 0xbf37c773, - 0xeacdf753, 0x5baafd5f, 0x146f3ddf, 0x86db4478, - 0x81f3afca, 0x3ec468b9, 0x2c342438, 0x5f40a3c2, - 0x72c31d16, 0x0c25e2bc, 0x8b493c28, 0x41950dff, - 0x7101a839, 0xdeb30c08, 0x9ce4b4d8, 0x90c15664, - 0x6184cb7b, 0x70b632d5, 0x745c6c48, 0x4257b8d0 -}; - -#if defined(OPTIMIZE_MMX) && (defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686)) -const uint64_t _ad1[256] = { -#else -const uint32_t _ad1[256] = { -#endif - 0xa7f45150, 0x65417e53, 0xa4171ac3, 0x5e273a96, - 0x6bab3bcb, 0x459d1ff1, 0x58faacab, 0x03e34b93, - 0xfa302055, 0x6d76adf6, 0x76cc8891, 0x4c02f525, - 0xd7e54ffc, 0xcb2ac5d7, 0x44352680, 0xa362b58f, - 0x5ab1de49, 0x1bba2567, 0x0eea4598, 0xc0fe5de1, - 0x752fc302, 0xf04c8112, 0x97468da3, 0xf9d36bc6, - 0x5f8f03e7, 0x9c921595, 0x7a6dbfeb, 0x595295da, - 0x83bed42d, 0x217458d3, 0x69e04929, 0xc8c98e44, - 0x89c2756a, 0x798ef478, 0x3e58996b, 0x71b927dd, - 0x4fe1beb6, 0xad88f017, 0xac20c966, 0x3ace7db4, - 0x4adf6318, 0x311ae582, 0x33519760, 0x7f536245, - 0x7764b1e0, 0xae6bbb84, 0xa081fe1c, 0x2b08f994, - 0x68487058, 0xfd458f19, 0x6cde9487, 0xf87b52b7, - 0xd373ab23, 0x024b72e2, 0x8f1fe357, 0xab55662a, - 0x28ebb207, 0xc2b52f03, 0x7bc5869a, 0x0837d3a5, - 0x872830f2, 0xa5bf23b2, 0x6a0302ba, 0x8216ed5c, - 0x1ccf8a2b, 0xb479a792, 0xf207f3f0, 0xe2694ea1, - 0xf4da65cd, 0xbe0506d5, 0x6234d11f, 0xfea6c48a, - 0x532e349d, 0x55f3a2a0, 0xe18a0532, 0xebf6a475, - 0xec830b39, 0xef6040aa, 0x9f715e06, 0x106ebd51, - 0x8a213ef9, 0x06dd963d, 0x053eddae, 0xbde64d46, - 0x8d5491b5, 0x5dc47105, 0xd406046f, 0x155060ff, - 0xfb981924, 0xe9bdd697, 0x434089cc, 0x9ed96777, - 0x42e8b0bd, 0x8b890788, 0x5b19e738, 0xeec879db, - 0x0a7ca147, 0x0f427ce9, 0x1e84f8c9, 0x00000000, - 0x86800983, 0xed2b3248, 0x70111eac, 0x725a6c4e, - 0xff0efdfb, 0x38850f56, 0xd5ae3d1e, 0x392d3627, - 0xd90f0a64, 0xa65c6821, 0x545b9bd1, 0x2e36243a, - 0x670a0cb1, 0xe757930f, 0x96eeb4d2, 0x919b1b9e, - 0xc5c0804f, 0x20dc61a2, 0x4b775a69, 0x1a121c16, - 0xba93e20a, 0x2aa0c0e5, 0xe0223c43, 0x171b121d, - 0x0d090e0b, 0xc78bf2ad, 0xa8b62db9, 0xa91e14c8, - 0x19f15785, 0x0775af4c, 0xdd99eebb, 0x607fa3fd, - 0x2601f79f, 0xf5725cbc, 0x3b6644c5, 0x7efb5b34, - 0x29438b76, 0xc623cbdc, 0xfcedb668, 0xf1e4b863, - 0xdc31d7ca, 0x85634210, 0x22971340, 0x11c68420, - 0x244a857d, 0x3dbbd2f8, 0x32f9ae11, 0xa129c76d, - 0x2f9e1d4b, 0x30b2dcf3, 0x52860dec, 0xe3c177d0, - 0x16b32b6c, 0xb970a999, 0x489411fa, 0x64e94722, - 0x8cfca8c4, 0x3ff0a01a, 0x2c7d56d8, 0x903322ef, - 0x4e4987c7, 0xd138d9c1, 0xa2ca8cfe, 0x0bd49836, - 0x81f5a6cf, 0xde7aa528, 0x8eb7da26, 0xbfad3fa4, - 0x9d3a2ce4, 0x9278500d, 0xcc5f6a9b, 0x467e5462, - 0x138df6c2, 0xb8d890e8, 0xf7392e5e, 0xafc382f5, - 0x805d9fbe, 0x93d0697c, 0x2dd56fa9, 0x1225cfb3, - 0x99acc83b, 0x7d1810a7, 0x639ce86e, 0xbb3bdb7b, - 0x7826cd09, 0x18596ef4, 0xb79aec01, 0x9a4f83a8, - 0x6e95e665, 0xe6ffaa7e, 0xcfbc2108, 0xe815efe6, - 0x9be7bad9, 0x366f4ace, 0x099fead4, 0x7cb029d6, - 0xb2a431af, 0x233f2a31, 0x94a5c630, 0x66a235c0, - 0xbc4e7437, 0xca82fca6, 0xd090e0b0, 0xd8a73315, - 0x9804f14a, 0xdaec41f7, 0x50cd7f0e, 0xf691172f, - 0xd64d768d, 0xb0ef434d, 0x4daacc54, 0x0496e4df, - 0xb5d19ee3, 0x886a4c1b, 0x1f2cc1b8, 0x5165467f, - 0xea5e9d04, 0x358c015d, 0x7487fa73, 0x410bfb2e, - 0x1d67b35a, 0xd2db9252, 0x5610e933, 0x47d66d13, - 0x61d79a8c, 0x0ca1377a, 0x14f8598e, 0x3c13eb89, - 0x27a9ceee, 0xc961b735, 0xe51ce1ed, 0xb1477a3c, - 0xdfd29c59, 0x73f2553f, 0xce141879, 0x37c773bf, - 0xcdf753ea, 0xaafd5f5b, 0x6f3ddf14, 0xdb447886, - 0xf3afca81, 0xc468b93e, 0x3424382c, 0x40a3c25f, - 0xc31d1672, 0x25e2bc0c, 0x493c288b, 0x950dff41, - 0x01a83971, 0xb30c08de, 0xe4b4d89c, 0xc1566490, - 0x84cb7b61, 0xb632d570, 0x5c6c4874, 0x57b8d042 -}; - -#if defined(OPTIMIZE_MMX) && (defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686)) -const uint64_t _ad2[256] = { -#else -const uint32_t _ad2[256] = { -#endif - 0xf45150a7, 0x417e5365, 0x171ac3a4, 0x273a965e, - 0xab3bcb6b, 0x9d1ff145, 0xfaacab58, 0xe34b9303, - 0x302055fa, 0x76adf66d, 0xcc889176, 0x02f5254c, - 0xe54ffcd7, 0x2ac5d7cb, 0x35268044, 0x62b58fa3, - 0xb1de495a, 0xba25671b, 0xea45980e, 0xfe5de1c0, - 0x2fc30275, 0x4c8112f0, 0x468da397, 0xd36bc6f9, - 0x8f03e75f, 0x9215959c, 0x6dbfeb7a, 0x5295da59, - 0xbed42d83, 0x7458d321, 0xe0492969, 0xc98e44c8, - 0xc2756a89, 0x8ef47879, 0x58996b3e, 0xb927dd71, - 0xe1beb64f, 0x88f017ad, 0x20c966ac, 0xce7db43a, - 0xdf63184a, 0x1ae58231, 0x51976033, 0x5362457f, - 0x64b1e077, 0x6bbb84ae, 0x81fe1ca0, 0x08f9942b, - 0x48705868, 0x458f19fd, 0xde94876c, 0x7b52b7f8, - 0x73ab23d3, 0x4b72e202, 0x1fe3578f, 0x55662aab, - 0xebb20728, 0xb52f03c2, 0xc5869a7b, 0x37d3a508, - 0x2830f287, 0xbf23b2a5, 0x0302ba6a, 0x16ed5c82, - 0xcf8a2b1c, 0x79a792b4, 0x07f3f0f2, 0x694ea1e2, - 0xda65cdf4, 0x0506d5be, 0x34d11f62, 0xa6c48afe, - 0x2e349d53, 0xf3a2a055, 0x8a0532e1, 0xf6a475eb, - 0x830b39ec, 0x6040aaef, 0x715e069f, 0x6ebd5110, - 0x213ef98a, 0xdd963d06, 0x3eddae05, 0xe64d46bd, - 0x5491b58d, 0xc471055d, 0x06046fd4, 0x5060ff15, - 0x981924fb, 0xbdd697e9, 0x4089cc43, 0xd967779e, - 0xe8b0bd42, 0x8907888b, 0x19e7385b, 0xc879dbee, - 0x7ca1470a, 0x427ce90f, 0x84f8c91e, 0x00000000, - 0x80098386, 0x2b3248ed, 0x111eac70, 0x5a6c4e72, - 0x0efdfbff, 0x850f5638, 0xae3d1ed5, 0x2d362739, - 0x0f0a64d9, 0x5c6821a6, 0x5b9bd154, 0x36243a2e, - 0x0a0cb167, 0x57930fe7, 0xeeb4d296, 0x9b1b9e91, - 0xc0804fc5, 0xdc61a220, 0x775a694b, 0x121c161a, - 0x93e20aba, 0xa0c0e52a, 0x223c43e0, 0x1b121d17, - 0x090e0b0d, 0x8bf2adc7, 0xb62db9a8, 0x1e14c8a9, - 0xf1578519, 0x75af4c07, 0x99eebbdd, 0x7fa3fd60, - 0x01f79f26, 0x725cbcf5, 0x6644c53b, 0xfb5b347e, - 0x438b7629, 0x23cbdcc6, 0xedb668fc, 0xe4b863f1, - 0x31d7cadc, 0x63421085, 0x97134022, 0xc6842011, - 0x4a857d24, 0xbbd2f83d, 0xf9ae1132, 0x29c76da1, - 0x9e1d4b2f, 0xb2dcf330, 0x860dec52, 0xc177d0e3, - 0xb32b6c16, 0x70a999b9, 0x9411fa48, 0xe9472264, - 0xfca8c48c, 0xf0a01a3f, 0x7d56d82c, 0x3322ef90, - 0x4987c74e, 0x38d9c1d1, 0xca8cfea2, 0xd498360b, - 0xf5a6cf81, 0x7aa528de, 0xb7da268e, 0xad3fa4bf, - 0x3a2ce49d, 0x78500d92, 0x5f6a9bcc, 0x7e546246, - 0x8df6c213, 0xd890e8b8, 0x392e5ef7, 0xc382f5af, - 0x5d9fbe80, 0xd0697c93, 0xd56fa92d, 0x25cfb312, - 0xacc83b99, 0x1810a77d, 0x9ce86e63, 0x3bdb7bbb, - 0x26cd0978, 0x596ef418, 0x9aec01b7, 0x4f83a89a, - 0x95e6656e, 0xffaa7ee6, 0xbc2108cf, 0x15efe6e8, - 0xe7bad99b, 0x6f4ace36, 0x9fead409, 0xb029d67c, - 0xa431afb2, 0x3f2a3123, 0xa5c63094, 0xa235c066, - 0x4e7437bc, 0x82fca6ca, 0x90e0b0d0, 0xa73315d8, - 0x04f14a98, 0xec41f7da, 0xcd7f0e50, 0x91172ff6, - 0x4d768dd6, 0xef434db0, 0xaacc544d, 0x96e4df04, - 0xd19ee3b5, 0x6a4c1b88, 0x2cc1b81f, 0x65467f51, - 0x5e9d04ea, 0x8c015d35, 0x87fa7374, 0x0bfb2e41, - 0x67b35a1d, 0xdb9252d2, 0x10e93356, 0xd66d1347, - 0xd79a8c61, 0xa1377a0c, 0xf8598e14, 0x13eb893c, - 0xa9ceee27, 0x61b735c9, 0x1ce1ede5, 0x477a3cb1, - 0xd29c59df, 0xf2553f73, 0x141879ce, 0xc773bf37, - 0xf753eacd, 0xfd5f5baa, 0x3ddf146f, 0x447886db, - 0xafca81f3, 0x68b93ec4, 0x24382c34, 0xa3c25f40, - 0x1d1672c3, 0xe2bc0c25, 0x3c288b49, 0x0dff4195, - 0xa8397101, 0x0c08deb3, 0xb4d89ce4, 0x566490c1, - 0xcb7b6184, 0x32d570b6, 0x6c48745c, 0xb8d04257 -}; - -#if defined(OPTIMIZE_MMX) && (defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686)) -const uint64_t _ad3[256] = { -#else -const uint32_t _ad3[256] = { -#endif - 0x5150a7f4, 0x7e536541, 0x1ac3a417, 0x3a965e27, - 0x3bcb6bab, 0x1ff1459d, 0xacab58fa, 0x4b9303e3, - 0x2055fa30, 0xadf66d76, 0x889176cc, 0xf5254c02, - 0x4ffcd7e5, 0xc5d7cb2a, 0x26804435, 0xb58fa362, - 0xde495ab1, 0x25671bba, 0x45980eea, 0x5de1c0fe, - 0xc302752f, 0x8112f04c, 0x8da39746, 0x6bc6f9d3, - 0x03e75f8f, 0x15959c92, 0xbfeb7a6d, 0x95da5952, - 0xd42d83be, 0x58d32174, 0x492969e0, 0x8e44c8c9, - 0x756a89c2, 0xf478798e, 0x996b3e58, 0x27dd71b9, - 0xbeb64fe1, 0xf017ad88, 0xc966ac20, 0x7db43ace, - 0x63184adf, 0xe582311a, 0x97603351, 0x62457f53, - 0xb1e07764, 0xbb84ae6b, 0xfe1ca081, 0xf9942b08, - 0x70586848, 0x8f19fd45, 0x94876cde, 0x52b7f87b, - 0xab23d373, 0x72e2024b, 0xe3578f1f, 0x662aab55, - 0xb20728eb, 0x2f03c2b5, 0x869a7bc5, 0xd3a50837, - 0x30f28728, 0x23b2a5bf, 0x02ba6a03, 0xed5c8216, - 0x8a2b1ccf, 0xa792b479, 0xf3f0f207, 0x4ea1e269, - 0x65cdf4da, 0x06d5be05, 0xd11f6234, 0xc48afea6, - 0x349d532e, 0xa2a055f3, 0x0532e18a, 0xa475ebf6, - 0x0b39ec83, 0x40aaef60, 0x5e069f71, 0xbd51106e, - 0x3ef98a21, 0x963d06dd, 0xddae053e, 0x4d46bde6, - 0x91b58d54, 0x71055dc4, 0x046fd406, 0x60ff1550, - 0x1924fb98, 0xd697e9bd, 0x89cc4340, 0x67779ed9, - 0xb0bd42e8, 0x07888b89, 0xe7385b19, 0x79dbeec8, - 0xa1470a7c, 0x7ce90f42, 0xf8c91e84, 0x00000000, - 0x09838680, 0x3248ed2b, 0x1eac7011, 0x6c4e725a, - 0xfdfbff0e, 0x0f563885, 0x3d1ed5ae, 0x3627392d, - 0x0a64d90f, 0x6821a65c, 0x9bd1545b, 0x243a2e36, - 0x0cb1670a, 0x930fe757, 0xb4d296ee, 0x1b9e919b, - 0x804fc5c0, 0x61a220dc, 0x5a694b77, 0x1c161a12, - 0xe20aba93, 0xc0e52aa0, 0x3c43e022, 0x121d171b, - 0x0e0b0d09, 0xf2adc78b, 0x2db9a8b6, 0x14c8a91e, - 0x578519f1, 0xaf4c0775, 0xeebbdd99, 0xa3fd607f, - 0xf79f2601, 0x5cbcf572, 0x44c53b66, 0x5b347efb, - 0x8b762943, 0xcbdcc623, 0xb668fced, 0xb863f1e4, - 0xd7cadc31, 0x42108563, 0x13402297, 0x842011c6, - 0x857d244a, 0xd2f83dbb, 0xae1132f9, 0xc76da129, - 0x1d4b2f9e, 0xdcf330b2, 0x0dec5286, 0x77d0e3c1, - 0x2b6c16b3, 0xa999b970, 0x11fa4894, 0x472264e9, - 0xa8c48cfc, 0xa01a3ff0, 0x56d82c7d, 0x22ef9033, - 0x87c74e49, 0xd9c1d138, 0x8cfea2ca, 0x98360bd4, - 0xa6cf81f5, 0xa528de7a, 0xda268eb7, 0x3fa4bfad, - 0x2ce49d3a, 0x500d9278, 0x6a9bcc5f, 0x5462467e, - 0xf6c2138d, 0x90e8b8d8, 0x2e5ef739, 0x82f5afc3, - 0x9fbe805d, 0x697c93d0, 0x6fa92dd5, 0xcfb31225, - 0xc83b99ac, 0x10a77d18, 0xe86e639c, 0xdb7bbb3b, - 0xcd097826, 0x6ef41859, 0xec01b79a, 0x83a89a4f, - 0xe6656e95, 0xaa7ee6ff, 0x2108cfbc, 0xefe6e815, - 0xbad99be7, 0x4ace366f, 0xead4099f, 0x29d67cb0, - 0x31afb2a4, 0x2a31233f, 0xc63094a5, 0x35c066a2, - 0x7437bc4e, 0xfca6ca82, 0xe0b0d090, 0x3315d8a7, - 0xf14a9804, 0x41f7daec, 0x7f0e50cd, 0x172ff691, - 0x768dd64d, 0x434db0ef, 0xcc544daa, 0xe4df0496, - 0x9ee3b5d1, 0x4c1b886a, 0xc1b81f2c, 0x467f5165, - 0x9d04ea5e, 0x015d358c, 0xfa737487, 0xfb2e410b, - 0xb35a1d67, 0x9252d2db, 0xe9335610, 0x6d1347d6, - 0x9a8c61d7, 0x377a0ca1, 0x598e14f8, 0xeb893c13, - 0xceee27a9, 0xb735c961, 0xe1ede51c, 0x7a3cb147, - 0x9c59dfd2, 0x553f73f2, 0x1879ce14, 0x73bf37c7, - 0x53eacdf7, 0x5f5baafd, 0xdf146f3d, 0x7886db44, - 0xca81f3af, 0xb93ec468, 0x382c3424, 0xc25f40a3, - 0x1672c31d, 0xbc0c25e2, 0x288b493c, 0xff41950d, - 0x397101a8, 0x08deb30c, 0xd89ce4b4, 0x6490c156, - 0x7b6184cb, 0xd570b632, 0x48745c6c, 0xd04257b8 -}; - -const uint32_t _ad4[256] = { - 0x52525252, 0x09090909, 0x6a6a6a6a, 0xd5d5d5d5, - 0x30303030, 0x36363636, 0xa5a5a5a5, 0x38383838, - 0xbfbfbfbf, 0x40404040, 0xa3a3a3a3, 0x9e9e9e9e, - 0x81818181, 0xf3f3f3f3, 0xd7d7d7d7, 0xfbfbfbfb, - 0x7c7c7c7c, 0xe3e3e3e3, 0x39393939, 0x82828282, - 0x9b9b9b9b, 0x2f2f2f2f, 0xffffffff, 0x87878787, - 0x34343434, 0x8e8e8e8e, 0x43434343, 0x44444444, - 0xc4c4c4c4, 0xdededede, 0xe9e9e9e9, 0xcbcbcbcb, - 0x54545454, 0x7b7b7b7b, 0x94949494, 0x32323232, - 0xa6a6a6a6, 0xc2c2c2c2, 0x23232323, 0x3d3d3d3d, - 0xeeeeeeee, 0x4c4c4c4c, 0x95959595, 0x0b0b0b0b, - 0x42424242, 0xfafafafa, 0xc3c3c3c3, 0x4e4e4e4e, - 0x08080808, 0x2e2e2e2e, 0xa1a1a1a1, 0x66666666, - 0x28282828, 0xd9d9d9d9, 0x24242424, 0xb2b2b2b2, - 0x76767676, 0x5b5b5b5b, 0xa2a2a2a2, 0x49494949, - 0x6d6d6d6d, 0x8b8b8b8b, 0xd1d1d1d1, 0x25252525, - 0x72727272, 0xf8f8f8f8, 0xf6f6f6f6, 0x64646464, - 0x86868686, 0x68686868, 0x98989898, 0x16161616, - 0xd4d4d4d4, 0xa4a4a4a4, 0x5c5c5c5c, 0xcccccccc, - 0x5d5d5d5d, 0x65656565, 0xb6b6b6b6, 0x92929292, - 0x6c6c6c6c, 0x70707070, 0x48484848, 0x50505050, - 0xfdfdfdfd, 0xedededed, 0xb9b9b9b9, 0xdadadada, - 0x5e5e5e5e, 0x15151515, 0x46464646, 0x57575757, - 0xa7a7a7a7, 0x8d8d8d8d, 0x9d9d9d9d, 0x84848484, - 0x90909090, 0xd8d8d8d8, 0xabababab, 0x00000000, - 0x8c8c8c8c, 0xbcbcbcbc, 0xd3d3d3d3, 0x0a0a0a0a, - 0xf7f7f7f7, 0xe4e4e4e4, 0x58585858, 0x05050505, - 0xb8b8b8b8, 0xb3b3b3b3, 0x45454545, 0x06060606, - 0xd0d0d0d0, 0x2c2c2c2c, 0x1e1e1e1e, 0x8f8f8f8f, - 0xcacacaca, 0x3f3f3f3f, 0x0f0f0f0f, 0x02020202, - 0xc1c1c1c1, 0xafafafaf, 0xbdbdbdbd, 0x03030303, - 0x01010101, 0x13131313, 0x8a8a8a8a, 0x6b6b6b6b, - 0x3a3a3a3a, 0x91919191, 0x11111111, 0x41414141, - 0x4f4f4f4f, 0x67676767, 0xdcdcdcdc, 0xeaeaeaea, - 0x97979797, 0xf2f2f2f2, 0xcfcfcfcf, 0xcececece, - 0xf0f0f0f0, 0xb4b4b4b4, 0xe6e6e6e6, 0x73737373, - 0x96969696, 0xacacacac, 0x74747474, 0x22222222, - 0xe7e7e7e7, 0xadadadad, 0x35353535, 0x85858585, - 0xe2e2e2e2, 0xf9f9f9f9, 0x37373737, 0xe8e8e8e8, - 0x1c1c1c1c, 0x75757575, 0xdfdfdfdf, 0x6e6e6e6e, - 0x47474747, 0xf1f1f1f1, 0x1a1a1a1a, 0x71717171, - 0x1d1d1d1d, 0x29292929, 0xc5c5c5c5, 0x89898989, - 0x6f6f6f6f, 0xb7b7b7b7, 0x62626262, 0x0e0e0e0e, - 0xaaaaaaaa, 0x18181818, 0xbebebebe, 0x1b1b1b1b, - 0xfcfcfcfc, 0x56565656, 0x3e3e3e3e, 0x4b4b4b4b, - 0xc6c6c6c6, 0xd2d2d2d2, 0x79797979, 0x20202020, - 0x9a9a9a9a, 0xdbdbdbdb, 0xc0c0c0c0, 0xfefefefe, - 0x78787878, 0xcdcdcdcd, 0x5a5a5a5a, 0xf4f4f4f4, - 0x1f1f1f1f, 0xdddddddd, 0xa8a8a8a8, 0x33333333, - 0x88888888, 0x07070707, 0xc7c7c7c7, 0x31313131, - 0xb1b1b1b1, 0x12121212, 0x10101010, 0x59595959, - 0x27272727, 0x80808080, 0xecececec, 0x5f5f5f5f, - 0x60606060, 0x51515151, 0x7f7f7f7f, 0xa9a9a9a9, - 0x19191919, 0xb5b5b5b5, 0x4a4a4a4a, 0x0d0d0d0d, - 0x2d2d2d2d, 0xe5e5e5e5, 0x7a7a7a7a, 0x9f9f9f9f, - 0x93939393, 0xc9c9c9c9, 0x9c9c9c9c, 0xefefefef, - 0xa0a0a0a0, 0xe0e0e0e0, 0x3b3b3b3b, 0x4d4d4d4d, - 0xaeaeaeae, 0x2a2a2a2a, 0xf5f5f5f5, 0xb0b0b0b0, - 0xc8c8c8c8, 0xebebebeb, 0xbbbbbbbb, 0x3c3c3c3c, - 0x83838383, 0x53535353, 0x99999999, 0x61616161, - 0x17171717, 0x2b2b2b2b, 0x04040404, 0x7e7e7e7e, - 0xbabababa, 0x77777777, 0xd6d6d6d6, 0x26262626, - 0xe1e1e1e1, 0x69696969, 0x14141414, 0x63636363, - 0x55555555, 0x21212121, 0x0c0c0c0c, 0x7d7d7d7d -}; - -static const uint32_t _arc[] = { - 0x00000001, 0x00000002, 0x00000004, 0x00000008, - 0x00000010, 0x00000020, 0x00000040, 0x00000080, - 0x0000001b, 0x00000036 -}; - -#define etfs(i) \ - t0 = \ - _ae0[(s0 ) & 0xff] ^ \ - _ae1[(s1 >> 8) & 0xff] ^ \ - _ae2[(s2 >> 16) & 0xff] ^ \ - _ae3[(s3 >> 24) ] ^ \ - rk[i+0]; \ - t1 = \ - _ae0[(s1 ) & 0xff] ^ \ - _ae1[(s2 >> 8) & 0xff] ^ \ - _ae2[(s3 >> 16) & 0xff] ^ \ - _ae3[(s0 >> 24) ] ^ \ - rk[i+1]; \ - t2 = \ - _ae0[(s2 ) & 0xff] ^ \ - _ae1[(s3 >> 8) & 0xff] ^ \ - _ae2[(s0 >> 16) & 0xff] ^ \ - _ae3[(s1 >> 24) ] ^ \ - rk[i+2]; \ - t3 = \ - _ae0[(s3 ) & 0xff] ^ \ - _ae1[(s0 >> 8) & 0xff] ^ \ - _ae2[(s1 >> 16) & 0xff] ^ \ - _ae3[(s2 >> 24) ] ^ \ - rk[i+3]; - -#define esft(i) \ - s0 = \ - _ae0[(t0 ) & 0xff] ^ \ - _ae1[(t1 >> 8) & 0xff] ^ \ - _ae2[(t2 >> 16) & 0xff] ^ \ - _ae3[(t3 >> 24) ] ^ \ - rk[i+0]; \ - s1 = \ - _ae0[(t1 ) & 0xff] ^ \ - _ae1[(t2 >> 8) & 0xff] ^ \ - _ae2[(t3 >> 16) & 0xff] ^ \ - _ae3[(t0 >> 24) ] ^ \ - rk[i+1]; \ - s2 = \ - _ae0[(t2 ) & 0xff] ^ \ - _ae1[(t3 >> 8) & 0xff] ^ \ - _ae2[(t0 >> 16) & 0xff] ^ \ - _ae3[(t1 >> 24) ] ^ \ - rk[i+2]; \ - s3 = \ - _ae0[(t3 ) & 0xff] ^ \ - _ae1[(t0 >> 8) & 0xff] ^ \ - _ae2[(t1 >> 16) & 0xff] ^ \ - _ae3[(t2 >> 24) ] ^ \ - rk[i+3]; - -#define elr() \ - s0 = \ - (_ae4[(t0 ) & 0xff] & 0x000000ff) ^ \ - (_ae4[(t1 >> 8) & 0xff] & 0x0000ff00) ^ \ - (_ae4[(t2 >> 16) & 0xff] & 0x00ff0000) ^ \ - (_ae4[(t3 >> 24) ] & 0xff000000) ^ \ - rk[0]; \ - s1 = \ - (_ae4[(t1 ) & 0xff] & 0x000000ff) ^ \ - (_ae4[(t2 >> 8) & 0xff] & 0x0000ff00) ^ \ - (_ae4[(t3 >> 16) & 0xff] & 0x00ff0000) ^ \ - (_ae4[(t0 >> 24) ] & 0xff000000) ^ \ - rk[1]; \ - s2 = \ - (_ae4[(t2 ) & 0xff] & 0x000000ff) ^ \ - (_ae4[(t3 >> 8) & 0xff] & 0x0000ff00) ^ \ - (_ae4[(t0 >> 16) & 0xff] & 0x00ff0000) ^ \ - (_ae4[(t1 >> 24) ] & 0xff000000) ^ \ - rk[2]; \ - s3 = \ - (_ae4[(t3 ) & 0xff] & 0x000000ff) ^ \ - (_ae4[(t0 >> 8) & 0xff] & 0x0000ff00) ^ \ - (_ae4[(t1 >> 16) & 0xff] & 0x00ff0000) ^ \ - (_ae4[(t2 >> 24) ] & 0xff000000) ^ \ - rk[3]; - -#define dtfs(i) \ - t0 = \ - _ad0[(s0 ) & 0xff] ^ \ - _ad1[(s3 >> 8) & 0xff] ^ \ - _ad2[(s2 >> 16) & 0xff] ^ \ - _ad3[(s1 >> 24) ] ^ \ - rk[i+0]; \ - t1 = \ - _ad0[(s1 ) & 0xff] ^ \ - _ad1[(s0 >> 8) & 0xff] ^ \ - _ad2[(s3 >> 16) & 0xff] ^ \ - _ad3[(s2 >> 24) ] ^ \ - rk[i+1]; \ - t2 = \ - _ad0[(s2 ) & 0xff] ^ \ - _ad1[(s1 >> 8) & 0xff] ^ \ - _ad2[(s0 >> 16) & 0xff] ^ \ - _ad3[(s3 >> 24) ] ^ \ - rk[i+2]; \ - t3 = \ - _ad0[(s3 ) & 0xff] ^ \ - _ad1[(s2 >> 8) & 0xff] ^ \ - _ad2[(s1 >> 16) & 0xff] ^ \ - _ad3[(s0 >> 24) ] ^ \ - rk[i+3]; - -#define dsft(i) \ - s0 = \ - _ad0[(t0 ) & 0xff] ^ \ - _ad1[(t3 >> 8) & 0xff] ^ \ - _ad2[(t2 >> 16) & 0xff] ^ \ - _ad3[(t1 >> 24) ] ^ \ - rk[i+0]; \ - s1 = \ - _ad0[(t1 ) & 0xff] ^ \ - _ad1[(t0 >> 8) & 0xff] ^ \ - _ad2[(t3 >> 16) & 0xff] ^ \ - _ad3[(t2 >> 24) ] ^ \ - rk[i+1]; \ - s2 = \ - _ad0[(t2 ) & 0xff] ^ \ - _ad1[(t1 >> 8) & 0xff] ^ \ - _ad2[(t0 >> 16) & 0xff] ^ \ - _ad3[(t3 >> 24) ] ^ \ - rk[i+2]; \ - s3 = \ - _ad0[(t3 ) & 0xff] ^ \ - _ad1[(t2 >> 8) & 0xff] ^ \ - _ad2[(t1 >> 16) & 0xff] ^ \ - _ad3[(t0 >> 24) ] ^ \ - rk[i+3]; - -#define dlr() \ - s0 = \ - (_ad4[(t0 ) & 0xff] & 0x000000ff) ^ \ - (_ad4[(t3 >> 8) & 0xff] & 0x0000ff00) ^ \ - (_ad4[(t2 >> 16) & 0xff] & 0x00ff0000) ^ \ - (_ad4[(t1 >> 24) ] & 0xff000000) ^ \ - rk[0]; \ - s1 = \ - (_ad4[(t1 ) & 0xff] & 0x000000ff) ^ \ - (_ad4[(t0 >> 8) & 0xff] & 0x0000ff00) ^ \ - (_ad4[(t3 >> 16) & 0xff] & 0x00ff0000) ^ \ - (_ad4[(t2 >> 24) ] & 0xff000000) ^ \ - rk[1]; \ - s2 = \ - (_ad4[(t2 ) & 0xff] & 0x000000ff) ^ \ - (_ad4[(t1 >> 8) & 0xff] & 0x0000ff00) ^ \ - (_ad4[(t0 >> 16) & 0xff] & 0x00ff0000) ^ \ - (_ad4[(t3 >> 24) ] & 0xff000000) ^ \ - rk[2]; \ - s3 = \ - (_ad4[(t3 ) & 0xff] & 0x000000ff) ^ \ - (_ad4[(t2 >> 8) & 0xff] & 0x0000ff00) ^ \ - (_ad4[(t1 >> 16) & 0xff] & 0x00ff0000) ^ \ - (_ad4[(t0 >> 24) ] & 0xff000000) ^ \ - rk[3]; diff --git a/beecrypt/aesopt.h b/beecrypt/aesopt.h deleted file mode 100644 index 19a526ba6..000000000 --- a/beecrypt/aesopt.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2002 Bob Deblier - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file aesopt.h - * \brief AES block cipher, assembler-optimized routines, headers. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup BC_aes_m - */ - -#ifndef _AESOPT_H -#define _AESOPT_H - -#include "beecrypt.h" -#include "aes.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if WIN32 -# if defined(_MSC_VER) && defined(_M_IX86) -/* this space intentionally left blank */ -# elif __INTEL__ && __MWERKS__ -# endif -#endif - -#if defined(__GNUC__) -# if defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686) -# if defined(OPTIMIZE_MMX) -# define ASM_AESENCRYPT -# define ASM_AESENCRYPTECB -# define ASM_AESDECRYPT -# define ASM_AESDECRYPTECB -# endif -# endif -#endif - -#if defined(__INTEL_COMPILER) -# if defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686) -# if defined(OPTIMIZE_MMX) -# define ASM_AESENCRYPT -# define ASM_AESENCRYPTECB -# define ASM_AESDECRYPT -# define ASM_AESDECRYPTECB -# endif -# endif -#endif - -#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) -/* this space intentionally left blank */ -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/api.h b/beecrypt/api.h deleted file mode 100644 index 71cab1267..000000000 --- a/beecrypt/api.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2001, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file api.h - * \brief BeeCrypt API, portability headers. - * \author Bob Deblier <bob.deblier@pandora.be> - */ - -#ifndef _BEECRYPT_API_H -#define _BEECRYPT_API_H - -#if defined(_WIN32) && !defined(WIN32) -# define WIN32 1 -#endif - -#if WIN32 && !__CYGWIN32__ -# include "beecrypt/win.h" -# ifdef BEECRYPT_DLL_EXPORT -# define BEECRYPTAPI __declspec(dllexport) -# else -# define BEECRYPTAPI __declspec(dllimport) -# endif -# ifdef BEECRYPT_CXX_DLL_EXPORT -# define BEECRYPTCXXAPI __declspec(dllexport) -# define BEECRYPTCXXTEMPLATE -# else -# define BEECRYPTCXXAPI __declspec(dllimport) -# define BEECRYPTCXXTEMPLATE extern -# endif -#else -# include "beecrypt/gnu.h" -# define BEECRYPTAPI -# define BEECRYPTCXXAPI -#endif - -#ifndef ROTL32 -# define ROTL32(x, s) (((x) << (s)) | ((x) >> (32 - (s)))) -#endif -#ifndef ROTR32 -# define ROTR32(x, s) (((x) >> (s)) | ((x) << (32 - (s)))) -#endif - -typedef uint8_t byte; - -typedef int8_t javabyte; -typedef int16_t javashort; -typedef int32_t javaint; -typedef int64_t javalong; - -typedef uint16_t javachar; - -#if (MP_WBITS == 64) -typedef uint64_t mpw; -typedef uint32_t mphw; -#elif (MP_WBITS == 32) -# if HAVE_UINT64_T -# define HAVE_MPDW 1 -typedef uint64_t mpdw; -# endif -typedef uint32_t mpw; -typedef uint16_t mphw; -#else -# error -#endif - -#endif diff --git a/beecrypt/autogen.sh b/beecrypt/autogen.sh deleted file mode 100755 index c36786ef5..000000000 --- a/beecrypt/autogen.sh +++ /dev/null @@ -1,27 +0,0 @@ -#! /bin/sh - -export CFLAGS -export LDFLAGS - -libtoolize --force --copy -aclocal -autoheader -automake -a -c -autoconf - -if [ "$1" = "--noconfigure" ]; then - exit 0; -fi - -if [ X"$@" = X -a "X`uname -s`" = "XLinux" ]; then - if [ -d /usr/share/man ]; then - mandir=/usr/share/man - infodir=/usr/share/info - else - mandir=/usr/man - infodir=/usr/info - fi - CPPFLAGS="-Wall -g" ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --infodir=${infodir} --mandir=${mandir} --enable-static --with-python "$@" -else - ./configure "$@" -fi diff --git a/beecrypt/base64.c b/beecrypt/base64.c deleted file mode 100644 index 3f99d0a36..000000000 --- a/beecrypt/base64.c +++ /dev/null @@ -1,434 +0,0 @@ -/* - * Copyright (c) 2000, 2001, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file base64.c - * \brief Base64 encoding and decoding. - * \author Bob Deblier <bob.deblier@pandora.be> - */ - -#include "system.h" - -#include "base64.h" -#include "endianness.h" - -#include "debug.h" - -static const char* to_b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - -/* encode 64 characters per line */ -#define CHARS_PER_LINE 64 - -char* b64enc(const memchunk* chunk) -{ - int div = chunk->size / 3; - int rem = chunk->size % 3; - int chars = div*4 + rem + 1; - int newlines = (chars + CHARS_PER_LINE - 1) / CHARS_PER_LINE; - - const byte* data = chunk->data; - char* string = (char*) malloc(chars + newlines + 1); - - if (string) - { - register char* buf = string; - - chars = 0; - - while (div > 0) - { - buf[0] = to_b64[ (data[0] >> 2) & 0x3f]; - buf[1] = to_b64[((data[0] << 4) & 0x30) | ((data[1] >> 4) & 0xf)]; - buf[2] = to_b64[((data[1] << 2) & 0x3c) | ((data[2] >> 6) & 0x3)]; - buf[3] = to_b64[ data[2] & 0x3f]; - data += 3; - buf += 4; - div--; - chars += 4; - if (chars == CHARS_PER_LINE) - { - chars = 0; - *(buf++) = '\n'; - } - } - - switch (rem) - { - case 2: - buf[0] = to_b64[ (data[0] >> 2) & 0x3f]; - buf[1] = to_b64[((data[0] << 4) & 0x30) + ((data[1] >> 4) & 0xf)]; - buf[2] = to_b64[ (data[1] << 2) & 0x3c]; - buf[3] = '='; - buf += 4; - chars += 4; - break; - case 1: - buf[0] = to_b64[ (data[0] >> 2) & 0x3f]; - buf[1] = to_b64[ (data[0] << 4) & 0x30]; - buf[2] = '='; - buf[3] = '='; - buf += 4; - chars += 4; - break; - } - - /* *(buf++) = '\n'; This would result in a buffer overrun */ - *buf = '\0'; - } - - return string; -} - -memchunk* b64dec(const char* string) -{ - /* return a decoded memchunk, or a null pointer in case of failure */ - - memchunk* rc = 0; - - if (string) - { - register int length = strlen(string); - - /* do a format verification first */ - if (length > 0) - { - register int count = 0, rem = 0; - register const char* tmp = string; - - while (length > 0) - { - register int skip = strspn(tmp, to_b64); - count += skip; - length -= skip; - tmp += skip; - if (length > 0) - { - register int i, vrfy = strcspn(tmp, to_b64); - - for (i = 0; i < vrfy; i++) - { - if (isspace(tmp[i])) - continue; - - if (tmp[i] == '=') - { - /* we should check if we're close to the end of the string */ - rem = count % 4; - - /* rem must be either 2 or 3, otherwise no '=' should be here */ - if (rem < 2) - return 0; - - /* end-of-message recognized */ - break; - } - else - { - /* Transmission error; RFC tells us to ignore this, but: - * - the rest of the message is going to even more corrupt since we're sliding bits out of place - * If a message is corrupt, it should be dropped. Period. - */ - - return 0; - } - } - - length -= vrfy; - tmp += vrfy; - } - } - - rc = memchunkAlloc((count / 4) * 3 + (rem ? (rem - 1) : 0)); - - if (rc) - { - if (count > 0) - { - register int i, qw = 0, tw = 0; - register byte* data = rc->data; - - length = strlen(tmp = string); - - for (i = 0; i < length; i++) - { - register char ch = string[i]; - register byte bits = 0; - - if (isspace(ch)) - continue; - - if ((ch >= 'A') && (ch <= 'Z')) - { - bits = (byte) (ch - 'A'); - } - else if ((ch >= 'a') && (ch <= 'z')) - { - bits = (byte) (ch - 'a' + 26); - } - else if ((ch >= '0') && (ch <= '9')) - { - bits = (byte) (ch - '0' + 52); - } - else if (ch == '+') - { - bits = 62; - } - else if (ch == '/') - { - bits = 63; - } - else if (ch == '=') - break; - - switch (qw++) - { - case 0: - data[tw+0] = (bits << 2) & 0xfc; - break; - case 1: - data[tw+0] |= (bits >> 4) & 0x03; - data[tw+1] = (bits << 4) & 0xf0; - break; - case 2: - data[tw+1] |= (bits >> 2) & 0x0f; - data[tw+2] = (bits << 6) & 0xc0; - break; - case 3: - data[tw+2] |= bits & 0x3f; - break; - } - - if (qw == 4) - { - qw = 0; - tw += 3; - } - } - } - } - } - } - - return rc; -} - -int b64encode_chars_per_line = B64ENCODE_CHARS_PER_LINE; - -const char * b64encode_eolstr = B64ENCODE_EOLSTR; - -char* b64encode(const void* data, size_t ns) -{ - static char b64enc[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - const char *e; - const unsigned char *s = data; - unsigned char *t, *te; - int nt; - int lc; - unsigned c; - - if (s == NULL) return NULL; - if (*s == '\0') return calloc(1, sizeof(*t)); - - if (ns == 0) ns = strlen((const char*) s); - nt = ((ns + 2) / 3) * 4; - - /* Add additional bytes necessary for eol string(s). */ - if (b64encode_chars_per_line > 0 && b64encode_eolstr != NULL) - { - lc = (nt + b64encode_chars_per_line - 1) / b64encode_chars_per_line; - if (((nt + b64encode_chars_per_line - 1) % b64encode_chars_per_line) != 0) - ++lc; - nt += lc * strlen(b64encode_eolstr); - } - - t = te = malloc(nt + 1); - - lc = 0; - if (te) - while (ns > 0) - { - c = *s++; - *te++ = b64enc[ (c >> 2) ], lc++; - *te++ = b64enc[ ((c & 0x3) << 4) | (*s >> 4) ], lc++; - if (--ns == 0) - { - *te++ = '='; - *te++ = '='; - continue; - } - c = *s++; - *te++ = b64enc[ ((c & 0xf) << 2) | (*s >> 6) ], lc++; - if (--ns == 0) - { - *te++ = '='; - continue; - } - *te++ = b64enc[ (int)(*s & 0x3f) ], lc++; - - /* Append eol string if desired. */ - if (b64encode_chars_per_line > 0 && b64encode_eolstr != NULL) - { - if (lc >= b64encode_chars_per_line) - { - for (e = b64encode_eolstr; *e != '\0'; e++) - *te++ = *e; - lc = 0; - } - } - s++; - --ns; - } - - if (te) - { - /* Append eol string if desired. */ - if (b64encode_chars_per_line > 0 && b64encode_eolstr != NULL) - { - if (lc != 0) - { - for (e = b64encode_eolstr; *e != '\0'; e++) - *te++ = *e; - } - } - *te = '\0'; - } - - return (char*) t; -} - -#define CRC24_INIT 0xb704ceL -#define CRC24_POLY 0x1864cfbL - -char* b64crc (const unsigned char* data, size_t ns) -{ - const unsigned char *s = data; - uint32_t crc = CRC24_INIT; - - while (ns-- > 0) - { - int i; - crc ^= (*s++) << 16; - for (i = 0; i < 8; i++) - { - crc <<= 1; - if (crc & 0x1000000) - crc ^= CRC24_POLY; - } - } - crc &= 0xffffff; - #if !WORDS_BIGENDIAN - crc = swapu32(crc); - #endif - data = (byte *)&crc; - data++; - ns = 3; - - return b64encode(data, ns); -} - -const char* b64decode_whitespace = B64DECODE_WHITESPACE; - -int b64decode(const char* s, void** datap, size_t* lenp) -{ - unsigned char b64dec[256]; - const unsigned char *t; - unsigned char *te; - int ns, nt; - unsigned a, b, c, d; - - if (s == NULL) return 1; - - /* Setup character lookup tables. */ - memset(b64dec, 0x80, sizeof(b64dec)); - for (c = 'A'; c <= 'Z'; c++) - b64dec[ c ] = 0 + (c - 'A'); - for (c = 'a'; c <= 'z'; c++) - b64dec[ c ] = 26 + (c - 'a'); - for (c = '0'; c <= '9'; c++) - b64dec[ c ] = 52 + (c - '0'); - b64dec[(unsigned)'+'] = 62; - b64dec[(unsigned)'/'] = 63; - b64dec[(unsigned)'='] = 0; - - /* Mark whitespace characters. */ - if (b64decode_whitespace) - { - const char *e; - for (e = b64decode_whitespace; *e != '\0'; e++) - { - if (b64dec[ (unsigned)*e ] == 0x80) - b64dec[ (unsigned)*e ] = 0x81; - } - } - - /* Validate input buffer */ - ns = 0; - for (t = (unsigned char*) s; *t != '\0'; t++) - { - switch (b64dec[(unsigned) *t]) - { - case 0x80: /* invalid chararcter */ - return 3; - case 0x81: /* white space */ - break; - default: - ns++; - break; - } - } - - if (((unsigned) ns) & 0x3) return 2; - - nt = (ns / 4) * 3; - t = te = malloc(nt + 1); - - while (ns > 0) - { - /* Get next 4 characters, ignoring whitespace. */ - while ((a = b64dec[ (unsigned)*s++ ]) == 0x81) - ; - while ((b = b64dec[ (unsigned)*s++ ]) == 0x81) - ; - while ((c = b64dec[ (unsigned)*s++ ]) == 0x81) - ; - while ((d = b64dec[ (unsigned)*s++ ]) == 0x81) - ; - - ns -= 4; - *te++ = (a << 2) | (b >> 4); - if (s[-2] == '=') break; - *te++ = (b << 4) | (c >> 2); - if (s[-1] == '=') break; - *te++ = (c << 6) | d; - } - - if (ns != 0) - { /* XXX can't happen, just in case */ - if (t) free((void *)t); - return 1; - } - if (lenp) - *lenp = (te - t); - - if (datap) - *datap = (void *)t; - else - if (t) free((void *)t); - - return 0; -} diff --git a/beecrypt/base64.h b/beecrypt/base64.h deleted file mode 100644 index a1403d19e..000000000 --- a/beecrypt/base64.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2000, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file base64.h - * \brief Base64 encoding and decoding, headers. - * \author Bob Deblier <bob.deblier@pandora.be> - */ - -#ifndef _BASE64_H -#define _BASE64_H - -#include "beecrypt.h" - -/*!\ - * Decode white space character set (default). - */ -/*@unchecked@*/ /*@observer@*/ -extern const char* b64decode_whitespace; -#define B64DECODE_WHITESPACE " \f\n\r\t\v" - -/*!\ - * Encode 72 characters per line (default). - */ -/*@unchecked@*/ -extern int b64encode_chars_per_line; -#define B64ENCODE_CHARS_PER_LINE 72 - -/*!\ - * Encode end-of-line string (default). - */ -/*@unchecked@*/ /*@observer@*/ /*@null@*/ -extern const char* b64encode_eolstr; -#define B64ENCODE_EOLSTR "\n" - -#ifdef __cplusplus -extern "C" { -#endif - -/*! - * Encode chunks of 3 bytes of binary input into 4 bytes of base64 output. - * \param data binary data - * \param ns no. bytes of data (0 uses strlen(data)) - * \return (malloc'd) base64 string - */ -BEECRYPTAPI /*@null@*/ -char* b64encode(const void* data, size_t ns) - /*@*/; - -/*! - * Encode crc of binary input data into 5 bytes of base64 output. - * \param data binary data - * \param ns no. bytes of binary data - * \return (malloc'd) base64 string - */ -BEECRYPTAPI /*@null@*/ -char* b64crc(const unsigned char* data, size_t ns) - /*@*/; - -/*! - * Decode chunks of 4 bytes of base64 input into 3 bytes of binary output. - * \param s base64 string - * \retval datap address of (malloc'd) binary data - * \retval lenp address of no. bytes of binary data - * \return 0 on success, 1: s == NULL, 2: bad length, 3: bad char - */ -BEECRYPTAPI -int b64decode(const char* s, /*@out@*/ void** datap, /*@out@*/ size_t* lenp) - /*@modifies *datap, *lenp @*/; - -/*! - */ -BEECRYPTAPI /*@null@*/ -char* b64enc(const memchunk*) - /*@*/; - -/*! - */ -BEECRYPTAPI /*@null@*/ -memchunk* b64dec(const char*) - /*@*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/beecrypt.c b/beecrypt/beecrypt.c deleted file mode 100644 index 5e1517fe8..000000000 --- a/beecrypt/beecrypt.c +++ /dev/null @@ -1,887 +0,0 @@ -/* - * Copyright (c) 1999, 2000, 2001, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file beecrypt.c - * \brief BeeCrypt API. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup ES_m PRNG_m HASH_m HMAC_m BC_m - */ - -#include "system.h" - -#include "beecrypt.h" - -#include "entropy.h" -#include "fips186.h" -#include "hmacmd5.h" -#include "hmacsha1.h" -#include "hmacsha256.h" -#include "md5.h" -#include "mp.h" -#include "mtprng.h" -#include "sha1.h" -#include "sha256.h" - -#include "aes.h" -#include "blowfish.h" -#include "blockmode.h" - -#include "debug.h" - -static entropySource entropySourceList[] = -{ -#if WIN32 - { "wincrypt", entropy_wincrypt }, - { "console", entropy_console }, - { "wavein", entropy_wavein }, -#else -# if HAVE_DEV_URANDOM - { "urandom", entropy_dev_urandom }, -# endif -# if HAVE_DEV_RANDOM - { "random", entropy_dev_random }, -# endif -# if HAVE_DEV_TTY - { "tty", entropy_dev_tty }, -# endif -# if HAVE_DEV_AUDIO - { "audio", entropy_dev_audio }, -# endif -# if HAVE_DEV_DSP - { "dsp", entropy_dev_dsp }, -# endif -#endif -}; - -#define ENTROPYSOURCES (sizeof(entropySourceList) / sizeof(entropySource)) - -int entropySourceCount() -{ - return ENTROPYSOURCES; -} - -const entropySource* entropySourceGet(int n) -{ - if ((n < 0) || (n >= ENTROPYSOURCES)) - return (const entropySource*) 0; - - return entropySourceList+n; -} - -const entropySource* entropySourceFind(const char* name) -{ - register int index; - - for (index = 0; index < ENTROPYSOURCES; index++) - { - if (strcmp(name, entropySourceList[index].name) == 0) - return entropySourceList+index; - } - return (const entropySource*) 0; -} - -const entropySource* entropySourceDefault() -{ - const char* selection = getenv("BEECRYPT_ENTROPY"); - - if (selection) - { - return entropySourceFind(selection); - } - else if (ENTROPYSOURCES) - { - return entropySourceList+0; - } - return (const entropySource*) 0; -} - -int entropyGatherNext(byte* data, size_t size) -{ - const char* selection = getenv("BEECRYPT_ENTROPY"); - - if (selection) - { - const entropySource* ptr = entropySourceFind(selection); - - if (ptr) - return ptr->next(data, size); - } - else - { - register int index; - - for (index = 0; index < ENTROPYSOURCES; index++) - { - if (entropySourceList[index].next(data, size) == 0) - return 0; - } - } - return -1; -} - -static const randomGenerator* randomGeneratorList[] = -{ - &fips186prng, - &mtprng -}; - -#define RANDOMGENERATORS (sizeof(randomGeneratorList) / sizeof(randomGenerator*)) - -int randomGeneratorCount() -{ - return RANDOMGENERATORS; -} - -const randomGenerator* randomGeneratorGet(int index) -{ - if ((index < 0) || (index >= RANDOMGENERATORS)) - return (const randomGenerator*) 0; - - return randomGeneratorList[index]; -} - -const randomGenerator* randomGeneratorFind(const char* name) -{ - register int index; - - for (index = 0; index < RANDOMGENERATORS; index++) - { - if (strcmp(name, randomGeneratorList[index]->name) == 0) - return randomGeneratorList[index]; - } - return (const randomGenerator*) 0; -} - -const randomGenerator* randomGeneratorDefault() -{ - char* selection = getenv("BEECRYPT_RANDOM"); - - if (selection) - return randomGeneratorFind(selection); - else - return &fips186prng; -} - -int randomGeneratorContextInit(randomGeneratorContext* ctxt, const randomGenerator* rng) -{ - if (ctxt == (randomGeneratorContext*) 0) - return -1; - - if (rng == (randomGenerator*) 0) - return -1; - - ctxt->rng = rng; - - if (rng->paramsize) - { - ctxt->param = (randomGeneratorParam*) calloc(rng->paramsize, 1); - if (ctxt->param == (randomGeneratorParam*) 0) - return -1; - } - else - ctxt->param = (randomGeneratorParam*) 0; - - return ctxt->rng->setup(ctxt->param); -} - -int randomGeneratorContextFree(randomGeneratorContext* ctxt) -{ - register int rc = 0; - - if (ctxt == (randomGeneratorContext*) 0) - return -1; - - if (ctxt->rng == (randomGenerator*) 0) - return -1; - - if (ctxt->rng->paramsize) - { - if (ctxt->param == (randomGeneratorParam*) 0) - return -1; - - rc = ctxt->rng->cleanup(ctxt->param); - - free(ctxt->param); - - ctxt->param = (randomGeneratorParam*) 0; - } - - return rc; -} - -int randomGeneratorContextNext(randomGeneratorContext* ctxt, byte* data, size_t size) -{ - return ctxt->rng->next(ctxt->param, data, size); -} - -int randomGeneratorContextSeed(randomGeneratorContext* ctxt, const byte* data, size_t size) -{ - return ctxt->rng->seed(ctxt->param, data, size); -} - -static const hashFunction* hashFunctionList[] = -{ - &md5, - &sha1, - &sha256 -}; - -#define HASHFUNCTIONS (sizeof(hashFunctionList) / sizeof(hashFunction*)) - -int hashFunctionCount() -{ - return HASHFUNCTIONS; -} - -const hashFunction* hashFunctionDefault() -{ - char* selection = getenv("BEECRYPT_HASH"); - - if (selection) - return hashFunctionFind(selection); - else - return &sha1; -} - -const hashFunction* hashFunctionGet(int index) -{ - if ((index < 0) || (index >= HASHFUNCTIONS)) - return (const hashFunction*) 0; - - return hashFunctionList[index]; -} - -const hashFunction* hashFunctionFind(const char* name) -{ - register int index; - - for (index = 0; index < HASHFUNCTIONS; index++) - { - if (strcmp(name, hashFunctionList[index]->name) == 0) - return hashFunctionList[index]; - } - return (const hashFunction*) 0; -} - -int hashFunctionContextInit(hashFunctionContext* ctxt, const hashFunction* hash) -{ - if (ctxt == (hashFunctionContext*) 0) - return -1; - - if (hash == (hashFunction*) 0) - return -1; - - ctxt->algo = hash; - ctxt->param = (hashFunctionParam*) calloc(hash->paramsize, 1); - - if (ctxt->param == (hashFunctionParam*) 0) - return -1; - - return ctxt->algo->reset(ctxt->param); -} - -int hashFunctionContextFree(hashFunctionContext* ctxt) -{ - if (ctxt == (hashFunctionContext*) 0) - return -1; - - if (ctxt->param == (hashFunctionParam*) 0) - return -1; - - free(ctxt->param); - - ctxt->param = (hashFunctionParam*) 0; - - return 0; -} - -int hashFunctionContextReset(hashFunctionContext* ctxt) -{ - if (ctxt == (hashFunctionContext*) 0) - return -1; - - if (ctxt->algo == (hashFunction*) 0) - return -1; - - if (ctxt->param == (hashFunctionParam*) 0) - return -1; - - return ctxt->algo->reset(ctxt->param); -} - -int hashFunctionContextUpdate(hashFunctionContext* ctxt, const byte* data, size_t size) -{ - if (ctxt == (hashFunctionContext*) 0) - return -1; - - if (ctxt->algo == (hashFunction*) 0) - return -1; - - if (ctxt->param == (hashFunctionParam*) 0) - return -1; - - if (data == (const byte*) 0) - return -1; - - return ctxt->algo->update(ctxt->param, data, size); -} - -int hashFunctionContextUpdateMC(hashFunctionContext* ctxt, const memchunk* m) -{ - if (ctxt == (hashFunctionContext*) 0) - return -1; - - if (ctxt->algo == (hashFunction*) 0) - return -1; - - if (ctxt->param == (hashFunctionParam*) 0) - return -1; - - if (m == (memchunk*) 0) - return -1; - - return ctxt->algo->update(ctxt->param, m->data, m->size); -} - -int hashFunctionContextUpdateMP(hashFunctionContext* ctxt, const mpnumber* n) -{ - if (ctxt == (hashFunctionContext*) 0) - return -1; - - if (ctxt->algo == (hashFunction*) 0) - return -1; - - if (ctxt->param == (hashFunctionParam*) 0) - return -1; - - if (n != (mpnumber*) 0) - { - int rc; - - /* get the number of significant bits in the number */ - size_t sig = mpbits(n->size, n->data); - - /* calculate how many bytes we need for a java-style encoding; - * if the most significant bit of the most significant byte - * is set, then we need to prefix a zero byte. - */ - size_t req = ((sig+7) >> 3) + (((sig&7) == 0) ? 1 : 0); - - byte* tmp = (byte*) malloc(req); - - if (tmp == (byte*) 0) - return -1; - - i2osp(tmp, req, n->data, n->size); - - rc = ctxt->algo->update(ctxt->param, tmp, req); - - free(tmp); - - return rc; - } - return -1; -} - -int hashFunctionContextDigest(hashFunctionContext* ctxt, byte *digest) -{ - if (ctxt == (hashFunctionContext*) 0) - return -1; - - if (ctxt->algo == (hashFunction*) 0) - return -1; - - if (ctxt->param == (hashFunctionParam*) 0) - return -1; - - if (digest == (byte*) 0) - return -1; - - return ctxt->algo->digest(ctxt->param, digest); -} - -int hashFunctionContextDigestMP(hashFunctionContext* ctxt, mpnumber* d) -{ - if (ctxt == (hashFunctionContext*) 0) - return -1; - - if (ctxt->algo == (hashFunction*) 0) - return -1; - - if (ctxt->param == (hashFunctionParam*) 0) - return -1; - - if (d != (mpnumber*) 0) - { - int rc; - - byte *digest = (byte*) malloc(ctxt->algo->digestsize); - - if (digest == (byte*) 0) - return -1; - - if (ctxt->algo->digest(ctxt->param, digest)) - { - free(digest); - return -1; - } - - rc = os2ip(d->data, d->size, digest, ctxt->algo->digestsize); - - free(digest); - - return rc; - } - return -1; -} - -int hashFunctionContextDigestMatch(hashFunctionContext* ctxt, const mpnumber* d) -{ - int rc = 0; - - mpnumber match; - - mpnzero(&match); - - if (hashFunctionContextDigestMP(ctxt, &match) == 0) - rc = mpeqx(d->size, d->data, match.size, match.data); - - mpnfree(&match); - - return rc; -} - -static const keyedHashFunction* keyedHashFunctionList[] = -{ - &hmacmd5, - &hmacsha1, - &hmacsha256 -}; - -#define KEYEDHASHFUNCTIONS (sizeof(keyedHashFunctionList) / sizeof(keyedHashFunction*)) - -int keyedHashFunctionCount() -{ - return KEYEDHASHFUNCTIONS; -} - -const keyedHashFunction* keyedHashFunctionDefault() -{ - char* selection = getenv("BEECRYPT_KEYEDHASH"); - - if (selection) - return keyedHashFunctionFind(selection); - else - return &hmacsha1; -} - -const keyedHashFunction* keyedHashFunctionGet(int index) -{ - if ((index < 0) || (index >= KEYEDHASHFUNCTIONS)) - return (const keyedHashFunction*) 0; - - return keyedHashFunctionList[index]; -} - -const keyedHashFunction* keyedHashFunctionFind(const char* name) -{ - register int index; - - for (index = 0; index < KEYEDHASHFUNCTIONS; index++) - { - if (strcmp(name, keyedHashFunctionList[index]->name) == 0) - return keyedHashFunctionList[index]; - } - return (const keyedHashFunction*) 0; -} - -int keyedHashFunctionContextInit(keyedHashFunctionContext* ctxt, const keyedHashFunction* mac) -{ - if (ctxt == (keyedHashFunctionContext*) 0) - return -1; - - if (mac == (keyedHashFunction*) 0) - return -1; - - ctxt->algo = mac; - ctxt->param = (keyedHashFunctionParam*) calloc(mac->paramsize, 1); - - if (ctxt->param == (keyedHashFunctionParam*) 0) - return -1; - - return ctxt->algo->reset(ctxt->param); -} - -int keyedHashFunctionContextFree(keyedHashFunctionContext* ctxt) -{ - if (ctxt == (keyedHashFunctionContext*) 0) - return -1; - - if (ctxt->algo == (keyedHashFunction*) 0) - return -1; - - if (ctxt->param == (keyedHashFunctionParam*) 0) - return -1; - - free(ctxt->param); - - ctxt->param = (keyedHashFunctionParam*) 0; - - return 0; -} - -int keyedHashFunctionContextSetup(keyedHashFunctionContext* ctxt, const byte* key, size_t keybits) -{ - if (ctxt == (keyedHashFunctionContext*) 0) - return -1; - - if (ctxt->algo == (keyedHashFunction*) 0) - return -1; - - if (ctxt->param == (keyedHashFunctionParam*) 0) - return -1; - - if (key == (byte*) 0) - return -1; - - return ctxt->algo->setup(ctxt->param, key, keybits); -} - -int keyedHashFunctionContextReset(keyedHashFunctionContext* ctxt) -{ - if (ctxt == (keyedHashFunctionContext*) 0) - return -1; - - if (ctxt->algo == (keyedHashFunction*) 0) - return -1; - - if (ctxt->param == (keyedHashFunctionParam*) 0) - return -1; - - return ctxt->algo->reset(ctxt->param); -} - -int keyedHashFunctionContextUpdate(keyedHashFunctionContext* ctxt, const byte* data, size_t size) -{ - if (ctxt == (keyedHashFunctionContext*) 0) - return -1; - - if (ctxt->algo == (keyedHashFunction*) 0) - return -1; - - if (ctxt->param == (keyedHashFunctionParam*) 0) - return -1; - - if (data == (byte*) 0) - return -1; - - return ctxt->algo->update(ctxt->param, data, size); -} - -int keyedHashFunctionContextUpdateMC(keyedHashFunctionContext* ctxt, const memchunk* m) -{ - if (ctxt == (keyedHashFunctionContext*) 0) - return -1; - - if (ctxt->algo == (keyedHashFunction*) 0) - return -1; - - if (ctxt->param == (keyedHashFunctionParam*) 0) - return -1; - - if (m == (memchunk*) 0) - return -1; - - return ctxt->algo->update(ctxt->param, m->data, m->size); -} - -int keyedHashFunctionContextUpdateMP(keyedHashFunctionContext* ctxt, const mpnumber* n) -{ - if (ctxt == (keyedHashFunctionContext*) 0) - return -1; - - if (ctxt->algo == (keyedHashFunction*) 0) - return -1; - - if (ctxt->param == (keyedHashFunctionParam*) 0) - return -1; - - if (n != (mpnumber*) 0) - { - int rc; - - /* get the number of significant bits in the number */ - size_t sig = mpbits(n->size, n->data); - - /* calculate how many bytes we need a java-style encoding; if the - * most significant bit of the most significant byte is set, then - * we need to prefix a zero byte. - */ - size_t req = ((sig+7) >> 3) + (((sig&7) == 0) ? 1 : 0); - - byte* tmp = (byte*) malloc(req); - - if (tmp == (byte*) 0) - return -1; - - i2osp(tmp, req, n->data, n->size); - - rc = ctxt->algo->update(ctxt->param, tmp, req); - - free(tmp); - - return rc; - } - return -1; -} - -int keyedHashFunctionContextDigest(keyedHashFunctionContext* ctxt, byte* digest) -{ - if (ctxt == (keyedHashFunctionContext*) 0) - return -1; - - if (ctxt->algo == (keyedHashFunction*) 0) - return -1; - - if (ctxt->param == (keyedHashFunctionParam*) 0) - return -1; - - if (digest == (byte*) 0) - return -1; - - return ctxt->algo->digest(ctxt->param, digest); -} - -int keyedHashFunctionContextDigestMP(keyedHashFunctionContext* ctxt, mpnumber* d) -{ - if (ctxt == (keyedHashFunctionContext*) 0) - return -1; - - if (ctxt->algo == (keyedHashFunction*) 0) - return -1; - - if (ctxt->param == (keyedHashFunctionParam*) 0) - return -1; - - if (d != (mpnumber*) 0) - { - int rc; - - byte *digest = (byte*) malloc(ctxt->algo->digestsize); - - if (digest == (byte*) 0) - return -1; - - if (ctxt->algo->digest(ctxt->param, digest)) - { - free(digest); - return -1; - } - - rc = os2ip(d->data, d->size, digest, ctxt->algo->digestsize); - - free(digest); - - return rc; - } - return -1; -} - -int keyedHashFunctionContextDigestMatch(keyedHashFunctionContext* ctxt, const mpnumber* d) -{ - int rc = 0; - - mpnumber match; - - mpnzero(&match); - - if (keyedHashFunctionContextDigestMP(ctxt, &match) == 0) - rc = mpeqx(d->size, d->data, match.size, match.data); - - mpnfree(&match); - - return rc; -} - -static const blockCipher* blockCipherList[] = -{ - &aes, - &blowfish -}; - -#define BLOCKCIPHERS (sizeof(blockCipherList) / sizeof(blockCipher*)) - -int blockCipherCount() -{ - return BLOCKCIPHERS; -} - -const blockCipher* blockCipherDefault() -{ - char* selection = getenv("BEECRYPT_CIPHER"); - - if (selection) - return blockCipherFind(selection); - else - return &aes; -} - -const blockCipher* blockCipherGet(int index) -{ - if ((index < 0) || (index >= BLOCKCIPHERS)) - return (const blockCipher*) 0; - - return blockCipherList[index]; -} - -const blockCipher* blockCipherFind(const char* name) -{ - register int index; - - for (index = 0; index < BLOCKCIPHERS; index++) - { - if (strcmp(name, blockCipherList[index]->name) == 0) - return blockCipherList[index]; - } - - return (const blockCipher*) 0; -} - -int blockCipherContextInit(blockCipherContext* ctxt, const blockCipher* ciph) -{ - if (ctxt == (blockCipherContext*) 0) - return -1; - - if (ciph == (blockCipher*) 0) - return -1; - - ctxt->algo = ciph; - ctxt->param = (blockCipherParam*) calloc(ciph->paramsize, 1); - ctxt->op = NOCRYPT; - - if (ctxt->param == (blockCipherParam*) 0) - return -1; - - return 0; -} - -int blockCipherContextSetup(blockCipherContext* ctxt, const byte* key, size_t keybits, cipherOperation op) -{ - if (ctxt == (blockCipherContext*) 0) - return -1; - - if (ctxt->algo == (blockCipher*) 0) - return -1; - - if (ctxt->param == (blockCipherParam*) 0) - return -1; - - ctxt->op = op; - - if (key == (byte*) 0) - return -1; - - return ctxt->algo->setup(ctxt->param, key, keybits, op); -} - -int blockCipherContextSetIV(blockCipherContext* ctxt, const byte* iv) -{ - if (ctxt == (blockCipherContext*) 0) - return -1; - - if (ctxt->algo == (blockCipher*) 0) - return -1; - - if (ctxt->param == (blockCipherParam*) 0) - return -1; - - /* null is an allowed value for iv, so don't test it */ - - return ctxt->algo->setiv(ctxt->param, iv); -} - -int blockCipherContextFree(blockCipherContext* ctxt) -{ - if (ctxt == (blockCipherContext*) 0) - return -1; - - if (ctxt->param == (blockCipherParam*) 0) - return -1; - - free(ctxt->param); - - ctxt->param = (blockCipherParam*) 0; - - return 0; -} - -int blockCipherContextECB(blockCipherContext* ctxt, uint32_t* dst, const uint32_t* src, int nblocks) -{ - switch (ctxt->op) - { - case NOCRYPT: - memcpy(dst, src, nblocks * ctxt->algo->blocksize); - return 0; - case ENCRYPT: - return (ctxt->algo->ecb.encrypt) ? - ctxt->algo->ecb.encrypt(ctxt->param, dst, src, nblocks) : - blockEncryptECB(ctxt->algo, ctxt->param, dst, src, nblocks); - case DECRYPT: - return (ctxt->algo->ecb.decrypt) ? - ctxt->algo->ecb.decrypt(ctxt->param, dst, src, nblocks) : - blockDecryptECB(ctxt->algo, ctxt->param, dst, src, nblocks); - } - return -1; -} - -int blockCipherContextCBC(blockCipherContext* ctxt, uint32_t* dst, const uint32_t* src, int nblocks) -{ - switch (ctxt->op) - { - case NOCRYPT: - memcpy(dst, src, nblocks * ctxt->algo->blocksize); - return 0; - case ENCRYPT: - return (ctxt->algo->cbc.encrypt) ? - ctxt->algo->cbc.encrypt(ctxt->param, dst, src, nblocks) : - blockEncryptCBC(ctxt->algo, ctxt->param, dst, src, nblocks); - case DECRYPT: - return (ctxt->algo->cbc.decrypt) ? - ctxt->algo->cbc.decrypt(ctxt->param, dst, src, nblocks) : - blockDecryptCBC(ctxt->algo, ctxt->param, dst, src, nblocks); - } - return -1; -} - -#if WIN32 -__declspec(dllexport) -BOOL WINAPI DllMain(HINSTANCE hInst, DWORD fdwReason, LPVOID lpReserved) -{ - switch (fdwReason) - { - case DLL_PROCESS_ATTACH: - entropy_provider_setup(hInst); - break; - case DLL_PROCESS_DETACH: - entropy_provider_cleanup(); - break; - } - - return TRUE; -} -#endif diff --git a/beecrypt/beecrypt.h b/beecrypt/beecrypt.h deleted file mode 100644 index 5fec9ad4d..000000000 --- a/beecrypt/beecrypt.h +++ /dev/null @@ -1,869 +0,0 @@ -/* - * Copyright (c) 1999, 2000, 2001, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file beecrypt.h - * \brief BeeCrypt API, headers. - * - * These API functions provide an abstract way for using most of - * the various algorithms implemented by the library. - * - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup ES_m PRNG_m HASH_m HMAC_m BC_m - */ - -#ifndef _BEECRYPT_H -#define _BEECRYPT_H - -#include "api.h" - -#include "memchunk.h" -#include "mpnumber.h" -#include "mp.h" - -/* - * Entropy Sources - */ - -/*!\typedef entropyNext - * \brief Prototype definition for an entropy-generating function. - * \ingroup ES_m - */ -typedef int (*entropyNext)(byte*, size_t) - /*@*/; - -/*!\brief This struct holds information and pointers to code specific to each - * source of entropy. - * \ingroup ES_m - */ -#ifdef __cplusplus -struct BEECRYPTAPI entropySource -#else -struct _entropySource -#endif -{ - /*!\var name - * \brief The entropy source's name. - */ - const char* name; - /*!\var next - * \brief Points to the function which produces the entropy. - */ - const entropyNext next; -}; - -#ifndef __cplusplus -typedef struct _entropySource entropySource; -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/*!\fn int entropySourceCount() - * \brief This function returns the number of entropy sources implemented by - * the library. - * \return The number of implemented entropy sources. - */ -BEECRYPTAPI -int entropySourceCount(void) - /*@*/; - -/*!\fn const entropySource* entropySourceGet(int n) - * \brief This function returns the \a n -th entropy source implemented by - * the library. - * \param n Index of the requested entropy source; legal values are 0 - * through entropySourceCount() - 1. - * \return A pointer to an entropy source or null, if the index was out of - * range. - */ -BEECRYPTAPI /*@null@*/ -const entropySource* entropySourceGet(int n) - /*@*/; - -/*!\fn const entropySource* entropySourceFind(const char* name) - * \brief This function returns the entropy source specified by the given name. - * \param name Name of the requested entropy source. - * \return A pointer to an entropy source or null, if the name wasn't found. - */ -BEECRYPTAPI /*@null@*/ -const entropySource* entropySourceFind(const char* name) - /*@*/; - -/*!\fn const entropySource* entropySourceDefault() - * \brief This functions returns the default entropy source; the default value - * can be specified by setting environment variable BEECRYPT_ENTROPY. - * \return A pointer to an entropy source or null, in case an error occured. - */ -BEECRYPTAPI /*@null@*/ -const entropySource* entropySourceDefault(void) - /*@*/; - -/*!\fn int entropyGatherNext(byte* data, size_t size) - * \brief This function gathers \a size bytes of entropy into \a data. - * - * Unless environment variable BEECRYPT_ENTROPY is set, this function will - * try each successive entropy source to gather up the requested amount. - * - * \param data Points to where the entropy should be stored. - * \param size Indicates how many bytes of entropy should be gathered. - * \retval 0 On success. - * \retval -1 On failure. - */ -BEECRYPTAPI -int entropyGatherNext(byte* data, size_t size) - /*@modifies data @*/; - -#ifdef __cplusplus -} -#endif - -/* - * Pseudo-random Number Generators - */ - -typedef void randomGeneratorParam; - -typedef int (*randomGeneratorSetup )(randomGeneratorParam*) - /*@*/; -typedef int (*randomGeneratorSeed )(randomGeneratorParam*, const byte*, size_t) - /*@*/; -typedef int (*randomGeneratorNext )(randomGeneratorParam*, byte*, size_t) - /*@*/; -typedef int (*randomGeneratorCleanup)(randomGeneratorParam*) - /*@*/; - -/* - * The struct 'randomGenerator' holds information and pointers to code specific - * to each random generator. Each specific random generator MUST be written to - * be multithread safe. - * - * WARNING: each randomGenerator, when used in cryptographic applications, MUST - * be guaranteed to be of suitable quality and strength (i.e. don't use the - * random() function found in most UN*X-es). - * - * Multiple instances of each randomGenerator can be used (even concurrently), - * provided they each use their own randomGeneratorParam parameters, a chunk - * of memory which must be at least as large as indicated by the paramsize - * field. - * - */ - -/*!\brief This struct holds information and pointers to code specific to each - * pseudo-random number generator. - * \ingroup PRNG_m - */ -#ifdef __cplusplus -struct BEECRYPTAPI randomGenerator -#else -struct _randomGenerator -#endif -{ - /*!\var name - * \brief The random generator's name. - */ - const char* name; - /*!\var paramsize - * \brief The size of the random generator's parameters. - * \note The implementor should set this by using sizeof(<struct holding - * random generator's parameters>). - */ - const size_t paramsize; - /*!\var setup - * \brief Points to the setup function. - */ - const randomGeneratorSetup setup; - /*!\var seed - * \brief Points to the seeding function. - */ - const randomGeneratorSeed seed; - /*!\var seed - * \brief Points to the function which generates the random data. - */ - const randomGeneratorNext next; - /*!\var seed - * \brief Points to the cleanup function. - */ - const randomGeneratorCleanup cleanup; -}; - -#ifndef __cplusplus -typedef struct _randomGenerator randomGenerator; -#endif - -/* - * You can use the following functions to find random generators implemented by - * the library: - * - * randomGeneratorCount returns the number of generators available. - * - * randomGeneratorGet returns the random generator with a given index (starting - * at zero, up to randomGeneratorCount() - 1), or NULL if the index was out of - * bounds. - * - * randomGeneratorFind returns the random generator with the given name, or - * NULL if no random generator exists with that name. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -BEECRYPTAPI -int randomGeneratorCount(void) - /*@*/; -BEECRYPTAPI /*@null@*/ -const randomGenerator* randomGeneratorGet(int index) - /*@*/; -BEECRYPTAPI /*@null@*/ -const randomGenerator* randomGeneratorFind(const char* name) - /*@*/; -BEECRYPTAPI /*@null@*/ -const randomGenerator* randomGeneratorDefault(void) - /*@*/; - -#ifdef __cplusplus -} -#endif - -/* - * The struct 'randomGeneratorContext' is used to contain both the functional - * part (the randomGenerator), and its parameters. - */ - -#ifdef __cplusplus -struct BEECRYPTAPI randomGeneratorContext -#else -struct _randomGeneratorContext -#endif -{ - const randomGenerator* rng; -/*@relnull@*/ - randomGeneratorParam* param; - - #ifdef __cplusplus - randomGeneratorContext(); - randomGeneratorContext(const randomGenerator*); - ~randomGeneratorContext(); - #endif -}; - -#ifndef __cplusplus -typedef struct _randomGeneratorContext randomGeneratorContext; -#endif - -/* - * The following functions can be used to initialize and free a - * randomGeneratorContext. Initializing will allocate a buffer of the size - * required by the randomGenerator, freeing will deallocate that buffer. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -BEECRYPTAPI -int randomGeneratorContextInit(randomGeneratorContext* ctxt, const randomGenerator* rng) - /*@modifies ctxt @*/; -BEECRYPTAPI -int randomGeneratorContextFree(randomGeneratorContext* ctxt) - /*@modifies ctxt @*/; -BEECRYPTAPI -int randomGeneratorContextNext(randomGeneratorContext* ctxt, byte* data, size_t size) - /*@modifies ctxt @*/; -BEECRYPTAPI -int randomGeneratorContextSeed(randomGeneratorContext* ctxt, const byte* data, size_t size) - /*@modifies ctxt @*/; - -#ifdef __cplusplus -} -#endif - -/* - * Hash Functions - */ - -/*!typedef void hashFunctionParam - * \ingroup HASH_m - */ -typedef void hashFunctionParam; - -typedef int (*hashFunctionReset )(hashFunctionParam*) - /*@*/; -typedef int (*hashFunctionUpdate)(hashFunctionParam*, const byte*, size_t) - /*@*/; -typedef int (*hashFunctionDigest)(hashFunctionParam*, byte*) - /*@*/; - -/* - * The struct 'hashFunction' holds information and pointers to code specific - * to each hash function. Specific hash functions MAY be written to be - * multithread-safe. - * - * NOTE: data MUST have a size (in bytes) of at least 'digestsize' as described - * in the hashFunction struct. - * NOTE: for safety reasons, after calling digest, each specific implementation - * MUST reset itself so that previous values in the parameters are erased. - */ -#ifdef __cplusplus -struct BEECRYPTAPI hashFunction -#else -struct _hashFunction -#endif -{ - const char* name; - const size_t paramsize; /* in bytes */ - const size_t blocksize; /* in bytes */ - const size_t digestsize; /* in bytes */ - const hashFunctionReset reset; - const hashFunctionUpdate update; - const hashFunctionDigest digest; -}; - -#ifndef __cplusplus -typedef struct _hashFunction hashFunction; -#endif - -/* - * You can use the following functions to find hash functions implemented by - * the library: - * - * hashFunctionCount returns the number of hash functions available. - * - * hashFunctionGet returns the hash function with a given index (starting - * at zero, up to hashFunctionCount() - 1), or NULL if the index was out of - * bounds. - * - * hashFunctionFind returns the hash function with the given name, or - * NULL if no hash function exists with that name. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -BEECRYPTAPI -int hashFunctionCount(void) - /*@*/; -BEECRYPTAPI /*@null@*/ -const hashFunction* hashFunctionGet(int index) - /*@*/; -BEECRYPTAPI /*@null@*/ -const hashFunction* hashFunctionFind(const char* name) - /*@*/; -BEECRYPTAPI /*@null@*/ -const hashFunction* hashFunctionDefault(void) - /*@*/; - -#ifdef __cplusplus -} -#endif - -/* - * The struct 'hashFunctionContext' is used to contain both the functional - * part (the hashFunction), and its parameters. - */ -#ifdef __cplusplus -struct BEECRYPTAPI hashFunctionContext -#else -struct _hashFunctionContext -#endif -{ - const hashFunction* algo; -/*@relnull@*/ - hashFunctionParam* param; - - #ifdef __cplusplus - hashFunctionContext(); - hashFunctionContext(const hashFunction*); - ~hashFunctionContext(); - #endif -}; - -#ifndef __cplusplus -typedef struct _hashFunctionContext hashFunctionContext; -#endif - -/* - * The following functions can be used to initialize and free a - * hashFunctionContext. Initializing will allocate a buffer of the size - * required by the hashFunction, freeing will deallocate that buffer. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -BEECRYPTAPI -int hashFunctionContextInit(hashFunctionContext* ctxt, const hashFunction* hash) - /*@modifies ctxt @*/; -BEECRYPTAPI -int hashFunctionContextFree(hashFunctionContext* ctxt) - /*@modifies ctxt @*/; -BEECRYPTAPI -int hashFunctionContextReset(hashFunctionContext* ctxt) - /*@modifies ctxt @*/; -BEECRYPTAPI -int hashFunctionContextUpdate(hashFunctionContext* ctxt, const byte* data, size_t size) - /*@modifies ctxt @*/; -BEECRYPTAPI -int hashFunctionContextUpdateMC(hashFunctionContext* ctxt, const memchunk* m) - /*@modifies ctxt @*/; -BEECRYPTAPI -int hashFunctionContextUpdateMP(hashFunctionContext* ctxt, const mpnumber* n) - /*@modifies ctxt @*/; -BEECRYPTAPI -int hashFunctionContextDigest(hashFunctionContext* ctxt, byte* digest) - /*@modifies ctxt, digest @*/; -BEECRYPTAPI -int hashFunctionContextDigestMP(hashFunctionContext* ctxt, mpnumber* d) - /*@modifies ctxt, d @*/; -BEECRYPTAPI -int hashFunctionContextDigestMatch(hashFunctionContext* ctxt, const mpnumber*) - /*@modifies ctxt @*/; - -#ifdef __cplusplus -} -#endif - -/* - * Keyed Hash Functions, a.k.a. Message Authentication Codes - */ - -/*!\typedef void keyedHashFunctionParam - * \ingroup HMAC_m - */ -typedef void keyedHashFunctionParam; - -typedef int (*keyedHashFunctionSetup )(keyedHashFunctionParam*, const byte*, size_t) - /*@*/; -typedef int (*keyedHashFunctionReset )(keyedHashFunctionParam*) - /*@*/; -typedef int (*keyedHashFunctionUpdate )(keyedHashFunctionParam*, const byte*, size_t) - /*@*/; -typedef int (*keyedHashFunctionDigest )(keyedHashFunctionParam*, byte*) - /*@*/; - -/* - * The struct 'keyedHashFunction' holds information and pointers to code - * specific to each keyed hash function. Specific keyed hash functions MAY be - * written to be multithread-safe. - * - * The struct field 'keybitsmin' contains the minimum number of bits a key - * must contains, 'keybitsmax' the maximum number of bits a key may contain, - * 'keybitsinc', the increment in bits that may be used between min and max. - * - * NOTE: data must be at least have a bytesize of 'digestsize' as described - * in the keyedHashFunction struct. - * NOTE: for safety reasons, after calling digest, each specific implementation - * MUST reset itself so that previous values in the parameters are erased. - */ -#ifdef __cplusplus -struct BEECRYPTAPI keyedHashFunction -#else -struct _keyedHashFunction -#endif -{ - const char* name; - const size_t paramsize; /* in bytes */ - const size_t blocksize; /* in bytes */ - const size_t digestsize; /* in bytes */ - const size_t keybitsmin; /* in bits */ - const size_t keybitsmax; /* in bits */ - const size_t keybitsinc; /* in bits */ - const keyedHashFunctionSetup setup; - const keyedHashFunctionReset reset; - const keyedHashFunctionUpdate update; - const keyedHashFunctionDigest digest; -}; - -#ifndef __cplusplus -typedef struct _keyedHashFunction keyedHashFunction; -#endif - -/* - * You can use the following functions to find keyed hash functions implemented - * by the library: - * - * keyedHashFunctionCount returns the number of keyed hash functions available. - * - * keyedHashFunctionGet returns the keyed hash function with a given index - * (starting at zero, up to keyedHashFunctionCount() - 1), or NULL if the index - * was out of bounds. - * - * keyedHashFunctionFind returns the keyed hash function with the given name, - * or NULL if no keyed hash function exists with that name. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -BEECRYPTAPI -int keyedHashFunctionCount(void) - /*@*/; -BEECRYPTAPI /*@null@*/ -const keyedHashFunction* keyedHashFunctionGet(int index) - /*@*/; -BEECRYPTAPI /*@null@*/ -const keyedHashFunction* keyedHashFunctionFind(const char* name) - /*@*/; -BEECRYPTAPI /*@null@*/ -const keyedHashFunction* keyedHashFunctionDefault(void) - /*@*/; - -#ifdef __cplusplus -} -#endif - -/* - * The struct 'keyedHashFunctionContext' is used to contain both the functional - * part (the keyedHashFunction), and its parameters. - */ -#ifdef __cplusplus -struct BEECRYPTAPI keyedHashFunctionContext -#else -struct _keyedHashFunctionContext -#endif -{ - const keyedHashFunction* algo; -/*@relnull@*/ - keyedHashFunctionParam* param; - - #ifdef __cplusplus - keyedHashFunctionContext(); - keyedHashFunctionContext(const keyedHashFunction*); - ~keyedHashFunctionContext(); - #endif -}; - -#ifndef __cplusplus -typedef struct _keyedHashFunctionContext keyedHashFunctionContext; -#endif - -/* - * The following functions can be used to initialize and free a - * keyedHashFunctionContext. Initializing will allocate a buffer of the size - * required by the keyedHashFunction, freeing will deallocate that buffer. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -BEECRYPTAPI -int keyedHashFunctionContextInit(keyedHashFunctionContext* ctxt, const keyedHashFunction* mac) - /*@modifies ctxt @*/; -BEECRYPTAPI -int keyedHashFunctionContextFree(keyedHashFunctionContext* ctxt) - /*@modifies ctxt @*/; -BEECRYPTAPI -int keyedHashFunctionContextSetup(keyedHashFunctionContext* ctxt, const byte* key, size_t keybits) - /*@modifies ctxt @*/; -BEECRYPTAPI -int keyedHashFunctionContextReset(keyedHashFunctionContext* ctxt) - /*@modifies ctxt @*/; -BEECRYPTAPI -int keyedHashFunctionContextUpdate(keyedHashFunctionContext* ctxt, const byte* data, size_t size) - /*@modifies ctxt @*/; -BEECRYPTAPI -int keyedHashFunctionContextUpdateMC(keyedHashFunctionContext* ctxt, const memchunk* m) - /*@modifies ctxt @*/; -BEECRYPTAPI -int keyedHashFunctionContextUpdateMP(keyedHashFunctionContext* ctxt, const mpnumber* n) - /*@modifies ctxt @*/; -BEECRYPTAPI -int keyedHashFunctionContextDigest(keyedHashFunctionContext* ctxt, byte* digest) - /*@modifies ctxt @*/; -BEECRYPTAPI -int keyedHashFunctionContextDigestMP(keyedHashFunctionContext* ctxt, mpnumber* d) - /*@modifies ctxt, d @*/; -BEECRYPTAPI -int keyedHashFunctionContextDigestMatch(keyedHashFunctionContext* ctxt, const mpnumber* d) - /*@modifies ctxt @*/; - -#ifdef __cplusplus -} -#endif - -/* - * Block ciphers - */ - -/*!\enum cipherOperation - * \brief Specifies whether to perform encryption or decryption. - * \ingroup BC_m - */ -typedef enum -{ - NOCRYPT, - ENCRYPT, - DECRYPT -} cipherOperation; - -/*!\typedef void blockCipherParam - * \brief Placeholder type definition for blockcipher parameters. - * \sa aesParam, blowfishParam. - * \ingroup BC_m - */ -typedef void blockCipherParam; - -/*!\brief Prototype definition for a setup function. - * \ingroup BC_m - */ -typedef int (*blockCipherSetup )(blockCipherParam*, const byte*, size_t, cipherOperation) - /*@*/; - -/*!\typedef int (*blockCipherSetIV)(blockCipherPatam* bp, const byte* iv) - * \brief Prototype definition for an initialization vector setup function. - * \param bp The blockcipher's parameters. - * \param iv The blockciphers' IV value. - * \note iv length must be equal to the cipher's block size. - * \retval 0 on success. - * \retval -1 on failure. - * \ingroup BC_m - */ -typedef int (*blockCipherSetIV )(blockCipherParam*, const byte*) - /*@*/; - -/*!\typedef int (*blockCipherRawcrypt)(blockCipherParam* bp, uint32_t* dst, const uint32_t* src) - * \brief Prototype for a \e raw encryption or decryption function. - * \param bp The blockcipher's parameters. - * \param dst The ciphertext address; must be aligned on 32-bit boundary. - * \param src The cleartext address; must be aligned on 32-bit boundary. - * \retval 0 on success. - * \retval -1 on failure. - * \ingroup BC_m - */ -typedef int (*blockCipherRawcrypt)(blockCipherParam*, uint32_t*, const uint32_t*) - /*@*/; - -/*!\typedef int (*blockCipherModcrypt)(blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks) - * \brief Prototype for a \e encryption or decryption function which operates - * on multiple blocks in a certain mode. - * \param bp The blockcipher's parameters. - * \param dst The ciphertext address; must be aligned on 32-bit boundary. - * \param src The cleartext address; must be aligned on 32-bit boundary. - * \param nblocks The number of blocks to process. - * \retval 0 on success. - * \retval -1 on failure. - * \ingroup BC_m - */ -typedef int (*blockCipherModcrypt)(blockCipherParam*, uint32_t*, const uint32_t*, unsigned int) - /*@*/; - -typedef uint32_t* (*blockCipherFeedback)(blockCipherParam*) - /*@*/; - -typedef struct -{ - const blockCipherRawcrypt encrypt; - const blockCipherRawcrypt decrypt; -} blockCipherRaw; - -typedef struct -{ - const blockCipherModcrypt encrypt; - const blockCipherModcrypt decrypt; -} blockCipherMode; - -/*!\brief Holds information and pointers to code specific to each cipher. - * - * Specific block ciphers \e may be written to be multithread-safe. - * - * \ingroup BC_m - */ -#ifdef __cplusplus -struct BEECRYPTAPI blockCipher -#else -struct _blockCipher -#endif -{ - /*!\var name - * \brief The blockcipher's name. - */ - const char* name; - /*!\var paramsize - * \brief The size of the parameters required by this cipher, in bytes. - */ - const size_t paramsize; - /*!\var blocksize - * \brief The size of one block of data, in bytes. - */ - const size_t blocksize; - /*!\var keybitsmin - * \brief The minimum number of key bits. - */ - const size_t keybitsmin; - /*!\var keybitsmax - * \brief The maximum number of key bits. - */ - const size_t keybitsmax; - /*!\var keybitsinc - * \brief The allowed increment in key bits between min and max. - * \see keybitsmin and keybitsmax. - */ - const size_t keybitsinc; - /*!\var setup - * \brief Pointer to the cipher's setup function. - */ - const blockCipherSetup setup; - /*!\var setiv - * \brief Pointer to the cipher's initialization vector setup function. - */ - const blockCipherSetIV setiv; - /*!\var raw - * \brief The cipher's raw functions. - */ - const blockCipherRaw raw; - /*!\var ecb - * \brief The cipher's ECB functions. - */ - const blockCipherMode ecb; - const blockCipherMode cbc; - /*!\var getfb - * \brief Pointer to the cipher's feedback-returning function. - */ - const blockCipherFeedback getfb; -}; - -#ifndef __cplusplus -typedef struct _blockCipher blockCipher; -#endif - - -#ifdef __cplusplus -extern "C" { -#endif - -/*!\fn int blockCipherCount() - * \brief This function returns the number of blockciphers implemented - * by the library. - * \return The number of implemented blockciphers. - */ -BEECRYPTAPI -int blockCipherCount(void) - /*@*/; - -/*!\fn const blockCipher* blockCipherGet(int n) - * \brief This function returns the \a n -th blockcipher implemented by - * the library. - * \param n Index of the requested blockcipher; legal values are 0 - * through blockCipherCount() - 1. - * \return A pointer to a blockcipher or null, if the index was out of - * range. - */ -BEECRYPTAPI /*@null@*/ -const blockCipher* blockCipherGet(int index) - /*@*/; - -/*!\fn const blockCIiher* blockCipherFind(const char* name) - * \brief This function returns the blockcipher specified by the given name. - * \param name Name of the requested blockcipher. - * \return A pointer to a blockcipher or null, if the name wasn't found. - */ -BEECRYPTAPI /*@null@*/ -const blockCipher* blockCipherFind(const char* name) - /*@*/; - -/*!\fn const blockCipher* blockCipherDefault() - * \brief This functions returns the default blockcipher; the default value - * can be specified by setting environment variable BEECRYPT_CIPHER. - * \return A pointer to a blockcipher or null, in case an error occured. - */ -BEECRYPTAPI /*@null@*/ -const blockCipher* blockCipherDefault(void) - /*@*/; - -#ifdef __cplusplus -} -#endif - -/*!\brief Holds a pointer to a blockcipher as well as its parameters. - * \warning A context can be used by only one thread at the same time. - * \ingroup BC_m - */ -#ifdef __cplusplus -struct BEECRYPTAPI blockCipherContext -#else -struct _blockCipherContext -#endif -{ - /*!\var algo - * \brief Pointer to a blockCipher. - */ - const blockCipher* algo; - /*!\var param - * \brief Pointer to the parameters used by algo. - */ -/*@relnull@*/ - blockCipherParam* param; - /*!\var op - */ - cipherOperation op; - - #ifdef __cplusplus - blockCipherContext(); - blockCipherContext(const blockCipher*); - ~blockCipherContext(); - #endif -}; - -#ifndef __cplusplus -typedef struct _blockCipherContext blockCipherContext; -#endif - -/* - * The following functions can be used to initialize and free a - * blockCipherContext. Initializing will allocate a buffer of the size - * required by the blockCipher, freeing will deallocate that buffer. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -BEECRYPTAPI -int blockCipherContextInit(blockCipherContext* ctxt, const blockCipher* ciph) - /*@modifies ctxt @*/; - -BEECRYPTAPI -int blockCipherContextSetup(blockCipherContext* ctxt, const byte* key, size_t keybits, cipherOperation op) - /*@modifies ctxt @*/; - -BEECRYPTAPI -int blockCipherContextSetIV(blockCipherContext* ctxt, const byte* iv) - /*@modifies ctxt @*/; - -BEECRYPTAPI -int blockCipherContextFree(blockCipherContext* ctxt) - /*@modifies ctxt @*/; - -BEECRYPTAPI -int blockCipherContextECB(blockCipherContext* ctxt, uint32_t* dst, const uint32_t* src, int nblocks) - /*@modifies ctxt, dst @*/; - -BEECRYPTAPI -int blockCipherContextCBC(blockCipherContext* ctxt, uint32_t* dst, const uint32_t* src, int nblocks) - /*@modifies ctxt, dst @*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/beecrypt.rc b/beecrypt/beecrypt.rc deleted file mode 100644 index 27d63d05f..000000000 --- a/beecrypt/beecrypt.rc +++ /dev/null @@ -1,31 +0,0 @@ -#include <winver.h> - -1 VERSIONINFO - FILEVERSION 3,1,0,0 - PRODUCTVERSION 3,1,0,0 - FILEFLAGSMASK VS_FFI_FILEFLAGSMASK - FILEFLAGS 0x0L - FILEOS VOS__WINDOWS32 - FILETYPE VFT_DLL - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" /* U.S. English; Unicode */ - BEGIN - VALUE "CompanyName", "Virtual Unlimited B.V.\0" - VALUE "FileDescription", "BeeCrypt Cryptography Library\0" - VALUE "FileVersion", "3.1.0\0" - VALUE "InternalName", "beecrypt\0" - VALUE "LegalCopyright", "Copyright (c) 1997-2003 Virtual Unlimited B.V.\0" - VALUE "LegalTradeMarks", "BeeCrypt is a trademark of Virtual Unlimited B.V.\0" - VALUE "OriginalFileName", "BEECRYPT.DLL\0" - VALUE "ProductName", "BeeCrypt\0" - VALUE "ProductVersion", "3.1.0\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END diff --git a/beecrypt/blockmode.c b/beecrypt/blockmode.c deleted file mode 100644 index 41423c13d..000000000 --- a/beecrypt/blockmode.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) 2000, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file blockmode.c - * \brief Blockcipher operation modes. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup BC_m - */ - -#include "system.h" - -#include "blockmode.h" -#include "mp.h" - -#include "debug.h" - -int blockEncryptECB(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks) -{ - register const unsigned int blockwords = bc->blocksize >> 2; - - while (nblocks > 0) - { - bc->raw.encrypt(bp, dst, src); - - dst += blockwords; - src += blockwords; - - nblocks--; - } - - return 0; -} - -int blockDecryptECB(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks) -{ - register const unsigned int blockwords = bc->blocksize >> 2; - - while (nblocks > 0) - { - bc->raw.decrypt(bp, dst, src); - - dst += blockwords; - src += blockwords; - - nblocks--; - } - - return 0; -} - -int blockEncryptCBC(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks) -{ - register const unsigned int blockwords = bc->blocksize >> 2; - register uint32_t* fdback = bc->getfb(bp); - - if (nblocks > 0) - { - register unsigned int i; - - for (i = 0; i < blockwords; i++) - dst[i] = src[i] ^ fdback[i]; - - bc->raw.encrypt(bp, dst, dst); - - src += blockwords; - - nblocks--; - - while (nblocks > 0) - { - for (i = 0; i < blockwords; i++) - dst[i+blockwords] = src[i] ^ dst[i]; - - dst += blockwords; - - bc->raw.encrypt(bp, dst, dst); - - src += blockwords; - - nblocks--; - } - - dst -= blockwords; - - for (i = 0; i < blockwords; i++) - fdback[i] = dst[i]; - } - - return 0; -} - -int blockDecryptCBC(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks) -{ - register const unsigned int blockwords = bc->blocksize >> 2; - register uint32_t* fdback = bc->getfb(bp); - register uint32_t* buf = (uint32_t*) malloc(blockwords * sizeof(uint32_t)); - - if (buf) - { - while (nblocks > 0) - { - register uint32_t tmp; - register unsigned int i; - - bc->raw.decrypt(bp, buf, src); - - for (i = 0; i < blockwords; i++) - { - tmp = src[i]; - dst[i] = buf[i] ^ fdback[i]; - fdback[i] = tmp; - } - - dst += blockwords; - src += blockwords; - - nblocks--; - } - free(buf); - return 0; - } - - return -1; -} diff --git a/beecrypt/blockmode.h b/beecrypt/blockmode.h deleted file mode 100644 index 6cda1636f..000000000 --- a/beecrypt/blockmode.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2000, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file blockmode.h - * \brief Blockcipher operation modes. - * \todo Additional modes, such as CFB and OFB. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup BC_m - */ - -#ifndef _BLOCKMODE_H -#define _BLOCKMODE_H - -#include "beecrypt.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/*!\fn int blockEncryptECB(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks) - * \brief This function encrypts a number of data blocks in Electronic Code - * Book mode. - * \param bc The blockcipher. - * \param bp The cipher's parameter block. - * \param dst The ciphertext data; should be aligned on a 32-bit boundary. - * \param src The cleartext data; should be aligned on a 32-bit boundary. - * \param nblocks The number of blocks to be encrypted. - * \retval 0 on success. - */ -BEECRYPTAPI -int blockEncryptECB(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks) - /*@*/; - -/*!\fn int blockDecryptECB(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks) - * \brief This function decrypts a number of data blocks in Electronic Code - * Book mode. - * \param bc The blockcipher. - * \param bp The cipher's parameter block. - * \param dst The cleartext data; should be aligned on a 32-bit boundary. - * \param src The ciphertext data; should be aligned on a 32-bit boundary. - * \param nblocks The number of blocks to be decrypted. - * \retval 0 on success. - */ -BEECRYPTAPI -int blockDecryptECB(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks) - /*@*/; - -/*!\fn int blockEncryptCBC(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks) - * \brief This function encrypts a number of data blocks in Cipher Block - * Chaining mode. - * \param bc The blockcipher. - * \param bp The cipher's parameter block. - * \param dst The ciphertext data; should be aligned on a 32-bit boundary. - * \param src The cleartext data; should be aligned on a 32-bit boundary. - * \param nblocks The number of blocks to be encrypted. - * \retval 0 on success. - */ -BEECRYPTAPI -int blockEncryptCBC(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks) - /*@modifies dst @*/; - -/*!\fn int blockDecryptCBC(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks) - * \brief This function decrypts a number of data blocks in Cipher Block - * Chaining mode. - * \param bc The blockcipher. - * \param bp The cipher's parameter block. - * \param dst The cleartext data; should be aligned on a 32-bit boundary. - * \param src The ciphertext data; should be aligned on a 32-bit boundary. - * \param nblocks The number of blocks to be decrypted. - * \retval 0 on success. - */ -BEECRYPTAPI -int blockDecryptCBC(const blockCipher* bc, blockCipherParam* bp, uint32_t* dst, const uint32_t* src, unsigned int nblocks) - /*@modifies dst @*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/blockpad.c b/beecrypt/blockpad.c deleted file mode 100644 index c5e4c6b8c..000000000 --- a/beecrypt/blockpad.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2000, 2001, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file blockpad.c - * \brief Blockcipher padding algorithms. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup BC_m - */ - -#include "system.h" - -#include "blockpad.h" - -#include "debug.h" - -memchunk* pkcs5Pad(size_t blockbytes, memchunk* tmp) -{ - if (tmp) - { - byte padvalue = blockbytes - (tmp->size % blockbytes); - - tmp = memchunkResize(tmp, tmp->size + padvalue); - - if (tmp) - memset(tmp->data - padvalue, padvalue, padvalue); - } - - return tmp; -} - -memchunk* pkcs5Unpad(size_t blockbytes, memchunk* tmp) -{ - if (tmp) - { - byte padvalue = tmp->data[tmp->size - 1]; - - unsigned int i; - - if (padvalue > blockbytes) - return (memchunk*) 0; - - for (i = (tmp->size - padvalue); i < (tmp->size - 1); i++) - { - if (tmp->data[i] != padvalue) - return (memchunk*) 0; - } - - tmp->size -= padvalue; -/* tmp->data = (byte*) realloc(tmp->data, tmp->size); */ - } - - return tmp; -} - -memchunk* pkcs5PadCopy(size_t blockbytes, const memchunk* src) -{ - memchunk* tmp; - byte padvalue = blockbytes - (src->size % blockbytes); - - if (src == (memchunk*) 0) - return (memchunk*) 0; - - tmp = memchunkAlloc(src->size + padvalue); - - if (tmp) - { - memcpy(tmp->data, src->data, src->size); - memset(tmp->data+src->size, padvalue, padvalue); - } - - return tmp; -} - -memchunk* pkcs5UnpadCopy(size_t blockbytes, const memchunk* src) -{ - memchunk* tmp; - byte padvalue; - unsigned int i; - - if (src == (memchunk*) 0) - return (memchunk*) 0; - - padvalue = src->data[src->size - 1]; - - for (i = (src->size - padvalue); i < (src->size - 1); i++) - { - if (src->data[i] != padvalue) - return (memchunk*) 0; - } - - tmp = memchunkAlloc(src->size - padvalue); - - if (tmp) - memcpy(tmp->data, src->data, tmp->size); - - return tmp; -} diff --git a/beecrypt/blockpad.h b/beecrypt/blockpad.h deleted file mode 100644 index 75b259527..000000000 --- a/beecrypt/blockpad.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2000, 2001, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file blockpad.h - * \brief Blockcipher padding algorithms. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup BC_m - */ - -#ifndef _BLOCKPAD_H -#define _BLOCKPAD_H - -#include "beecrypt.h" - -#ifdef __cplusplus -extern "C" { -#endif - -BEECRYPTAPI /*@null@*/ -memchunk* pkcs5Pad (size_t blockbytes, memchunk* tmp) - /*@modifies tmp @*/; -BEECRYPTAPI /*@null@*/ -memchunk* pkcs5Unpad(size_t blockbytes, memchunk* tmp) - /*@modifies tmp @*/; - -BEECRYPTAPI /*@null@*/ -memchunk* pkcs5PadCopy (size_t blockbytes, const memchunk* src) - /*@*/; -BEECRYPTAPI /*@null@*/ -memchunk* pkcs5UnpadCopy(size_t blockbytes, const memchunk* src) - /*@*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/blowfish.c b/beecrypt/blowfish.c deleted file mode 100644 index 93808ce24..000000000 --- a/beecrypt/blowfish.c +++ /dev/null @@ -1,505 +0,0 @@ -/* - * Copyright (c) 1999, 2000, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file blowfish.c - * \brief Blowfish block cipher. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup BC_m BC_blowfish_m - */ - -#include "system.h" - -#include "beecrypt.h" -#include "blowfishopt.h" -#include "blowfish.h" -#include "endianness.h" - -#include "debug.h" - -#ifdef ASM_BLOWFISHENCRYPTECB -extern int blowfishEncryptECB(blowfishparam*, uint32_t*, const uint32_t*, unsigned int); -#endif - -#ifdef ASM_BLOWFISHDECRYPTECB -extern int blowfishDecryptECB(blowfishparam*, uint32_t*, const uint32_t*, unsigned int); -#endif - -static uint32_t _bf_p[BLOWFISHPSIZE] = { - 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, - 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, - 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c, - 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, - 0x9216d5d9, 0x8979fb1b -}; - -static uint32_t _bf_s[1024] = { - 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, - 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99, - 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16, - 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e, - 0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee, - 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013, - 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef, - 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e, - 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60, - 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440, - 0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce, - 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a, - 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e, - 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677, - 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193, - 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032, - 0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88, - 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239, - 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e, - 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0, - 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3, - 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98, - 0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88, - 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe, - 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6, - 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d, - 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b, - 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7, - 0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba, - 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463, - 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f, - 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09, - 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3, - 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb, - 0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279, - 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8, - 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab, - 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82, - 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db, - 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573, - 0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0, - 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b, - 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790, - 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8, - 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4, - 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0, - 0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7, - 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c, - 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad, - 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1, - 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299, - 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9, - 0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477, - 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf, - 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49, - 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af, - 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa, - 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5, - 0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41, - 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915, - 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400, - 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915, - 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664, - 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a, - 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, - 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266, - 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1, - 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e, - 0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6, - 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1, - 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e, - 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1, - 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737, - 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8, - 0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff, - 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd, - 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701, - 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7, - 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41, - 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331, - 0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf, - 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af, - 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e, - 0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87, - 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c, - 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2, - 0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16, - 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd, - 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b, - 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509, - 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e, - 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3, - 0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f, - 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a, - 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4, - 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960, - 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66, - 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28, - 0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802, - 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84, - 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510, - 0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf, - 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14, - 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e, - 0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50, - 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7, - 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8, - 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281, - 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99, - 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696, - 0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128, - 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73, - 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0, - 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0, - 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105, - 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250, - 0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3, - 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285, - 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00, - 0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061, - 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb, - 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e, - 0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735, - 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc, - 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, - 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340, - 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20, - 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7, - 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934, - 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068, - 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af, - 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840, - 0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45, - 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504, - 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a, - 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb, - 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee, - 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6, - 0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42, - 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b, - 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2, - 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb, - 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527, - 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b, - 0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33, - 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c, - 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3, - 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc, - 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17, - 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564, - 0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b, - 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115, - 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922, - 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728, - 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0, - 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e, - 0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37, - 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d, - 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804, - 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b, - 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3, - 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb, - 0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d, - 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c, - 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350, - 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9, - 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a, - 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe, - 0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d, - 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc, - 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f, - 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61, - 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2, - 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9, - 0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2, - 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c, - 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e, - 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633, - 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10, - 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169, - 0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52, - 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027, - 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5, - 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62, - 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634, - 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76, - 0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24, - 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc, - 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4, - 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c, - 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837, - 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0, - 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, - 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe, - 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b, - 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4, - 0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8, - 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6, - 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304, - 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22, - 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4, - 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6, - 0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9, - 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59, - 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593, - 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51, - 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28, - 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c, - 0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b, - 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28, - 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c, - 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd, - 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a, - 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319, - 0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb, - 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f, - 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991, - 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32, - 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680, - 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166, - 0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae, - 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb, - 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5, - 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47, - 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370, - 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d, - 0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84, - 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048, - 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8, - 0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd, - 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9, - 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7, - 0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38, - 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f, - 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c, - 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525, - 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1, - 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442, - 0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964, - 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e, - 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8, - 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d, - 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f, - 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299, - 0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02, - 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc, - 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614, - 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a, - 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6, - 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b, - 0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0, - 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060, - 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, - 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9, - 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f, - 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6 -}; - -#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] -#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] - -const blockCipher blowfish = { - "Blowfish", - sizeof(blowfishParam), - 8, - 64, - 448, - 32, - (blockCipherSetup) blowfishSetup, - (blockCipherSetIV) blowfishSetIV, - /* raw */ - { - (blockCipherRawcrypt) blowfishEncrypt, - (blockCipherRawcrypt) blowfishDecrypt - }, - /* ecb */ - { - #ifdef AES_BLOWFISHENCRYPTECB - (blockCipherModcrypt) blowfishEncryptECB, - #else - (blockCipherModcrypt) 0, - #endif - #ifdef AES_BLOWFISHENCRYPTECB - (blockCipherModcrypt) blowfishDecryptECB, - #else - (blockCipherModcrypt) 0 - #endif - }, - /* cbc */ - { - (blockCipherModcrypt) 0, - (blockCipherModcrypt) 0 - }, - (blockCipherFeedback) blowfishFeedback -}; - -int blowfishSetup(blowfishParam* bp, const byte* key, size_t keybits, cipherOperation op) -{ - if ((op != ENCRYPT) && (op != DECRYPT)) - return -1; - - if (((keybits & 7) == 0) && (keybits >= 32) && (keybits <= 448)) - { - register uint32_t* p = bp->p; - register uint32_t* s = bp->s; - register unsigned int i, j, k; - - uint32_t tmp, work[2]; - - memcpy(s, _bf_s, 1024 * sizeof(uint32_t)); - - for (i = 0, k = 0; i < BLOWFISHPSIZE; i++) - { - tmp = 0; - for (j = 0; j < 4; j++) - { - tmp <<= 8; - tmp |= key[k++]; - if (k >= (keybits >> 3)) - k = 0; - } - p[i] = _bf_p[i] ^ tmp; - } - - work[0] = work[1] = 0; - - for (i = 0; i < BLOWFISHPSIZE; i += 2, p += 2) - { - blowfishEncrypt(bp, work, work); - #if WORDS_BIGENDIAN - p[0] = work[0]; - p[1] = work[1]; - #else - p[0] = swapu32(work[0]); - p[1] = swapu32(work[1]); - #endif - } - - for (i = 0; i < 1024; i += 2, s += 2) - { - blowfishEncrypt(bp, work, work); - #if WORDS_BIGENDIAN - s[0] = work[0]; - s[1] = work[1]; - #else - s[0] = swapu32(work[0]); - s[1] = swapu32(work[1]); - #endif - } - - /* clear fdback/iv */ - bp->fdback[0] = 0; - bp->fdback[1] = 0; - - return 0; - } - return -1; -} - -#ifndef ASM_BLOWFISHSETIV -int blowfishSetIV(blowfishParam* bp, const byte* iv) -{ - if (iv) - memcpy(bp->fdback, iv, 8); - else - memset(bp->fdback, 0, 8); - - return 0; -} -#endif - -int blowfishBlowit(blowfishParam* bp, uint32_t* dst, const uint32_t* src) - /*@modifies dst @*/ -{ - register uint32_t xl = src[0], xr = src[1]; - register uint32_t* p = bp->p; - register uint32_t* s = bp->s; - - EROUND(xl, xr); EROUND(xr, xl); - - dst[1] = xr; - dst[0] = xl; - - return 0; -} - -#ifndef ASM_BLOWFISHENCRYPT -int blowfishEncrypt(blowfishParam* bp, uint32_t* dst, const uint32_t* src) -{ - #if WORDS_BIGENDIAN - register uint32_t xl = src[0], xr = src[1]; - #else - register uint32_t xl = swapu32(src[0]), xr = swapu32(src[1]); - #endif - register uint32_t* p = bp->p; - register uint32_t* s = bp->s; - - EROUND(xl, xr); EROUND(xr, xl); - EROUND(xl, xr); EROUND(xr, xl); - EROUND(xl, xr); EROUND(xr, xl); - EROUND(xl, xr); EROUND(xr, xl); - EROUND(xl, xr); EROUND(xr, xl); - EROUND(xl, xr); EROUND(xr, xl); - EROUND(xl, xr); EROUND(xr, xl); - EROUND(xl, xr); EROUND(xr, xl); - - #if WORDS_BIGENDIAN - dst[1] = xl ^ *(p++); - dst[0] = xr ^ *(p++); - #else - dst[1] = swapu32(xl ^ *(p++)); - dst[0] = swapu32(xr ^ *(p++)); - #endif - - return 0; -} -#endif - -#ifndef ASM_BLOWFISHDECRYPT -int blowfishDecrypt(blowfishParam* bp, uint32_t* dst, const uint32_t* src) -{ - #if WORDS_BIGENDIAN - register uint32_t xl = src[0], xr = src[1]; - #else - register uint32_t xl = swapu32(src[0]), xr = swapu32(src[1]); - #endif - register uint32_t* p = bp->p+BLOWFISHPSIZE-1; - register uint32_t* s = bp->s; - - DROUND(xl, xr); DROUND(xr, xl); - DROUND(xl, xr); DROUND(xr, xl); - DROUND(xl, xr); DROUND(xr, xl); - DROUND(xl, xr); DROUND(xr, xl); - DROUND(xl, xr); DROUND(xr, xl); - DROUND(xl, xr); DROUND(xr, xl); - DROUND(xl, xr); DROUND(xr, xl); - DROUND(xl, xr); DROUND(xr, xl); - - #if WORDS_BIGENDIAN - dst[1] = xl ^ *(p--); - dst[0] = xr ^ *(p--); - #else - dst[1] = swapu32(xl ^ *(p--)); - dst[0] = swapu32(xr ^ *(p--)); - #endif - - return 0; -} -#endif - -uint32_t* blowfishFeedback(blowfishParam* bp) -{ - return bp->fdback; -} diff --git a/beecrypt/blowfish.h b/beecrypt/blowfish.h deleted file mode 100644 index 219f23eca..000000000 --- a/beecrypt/blowfish.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 1999, 2000, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file blowfish.h - * \brief Blowfish block cipher. - * - * For more information on this blockcipher, see: - * "Applied Cryptography", second edition - * Bruce Schneier - * Wiley & Sons - * - * Also see http://www.counterpane.com/blowfish.html - * - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup BC_m BC_blowfish_m - */ - -#ifndef _BLOWFISH_H -#define _BLOWFISH_H - -#include "beecrypt.h" -#include "blowfishopt.h" - -#define BLOWFISHROUNDS 16 -#define BLOWFISHPSIZE (BLOWFISHROUNDS+2) - -/*!\brief Holds all the parameters necessary for the Blowfish cipher. - * \ingroup BC_blowfish_m - */ -typedef struct -{ - /*!\var p - * \brief Holds the key expansion. - */ - uint32_t p[BLOWFISHPSIZE]; - /*!\var s - * \brief Holds the s-boxes. - */ - uint32_t s[1024]; - /*!\var fdback - * \brief Buffer to be used by block chaining or feedback modes. - */ - uint32_t fdback[2]; -} blowfishParam; - -#ifdef __cplusplus -extern "C" { -#endif - -/*!\var blowfish - * \brief Holds the full API description of the Blowfish algorithm. - */ -extern const BEECRYPTAPI blockCipher blowfish; - -/*!\fn int blowfishSetup(blowfishParam* bp, const byte* key, size_t keybits, cipherOperation - op) - * \brief The function performs the cipher's key expansion. - * \param bp The cipher's parameter block. - * \param key The key value. - * \param keybits The number of bits in the key; legal values are: 32 to 448, - * in multiples of 8. - * \param op ENCRYPT or DECRYPT. - * \retval 0 on success. - * \retval -1 on failure. - */ -BEECRYPTAPI -int blowfishSetup (blowfishParam* bp, const byte* key, size_t keybits, cipherOperation op) - /*@modifies bp @*/; - -/*!\fn int blowfishSetIV(blowfishParam* bp, const byte* iv) - * \brief This function sets the Initialization Vector. - * \note This function is only useful in block chaining or feedback modes. - * \param bp The cipher's parameter block. - * \param iv The initialization vector; may be null. - * \retval 0 on success. - */ -BEECRYPTAPI -int blowfishSetIV (blowfishParam* bp, const byte* iv) - /*@modifies bp @*/; - -/*!\fn blowfishEncrypt(blowfishParam* bp, uint32_t* dst, const uint32_t* src) - * \brief This function performs the Blowfish encryption; it encrypts one block - * of 64 bits. - * \param bp The cipher's parameter block. - * \param dst The ciphertext; should be aligned on 32-bit boundary. - * \param src The cleartext; should be aligned on 32-bit boundary. - * \retval 0 on success. - */ -BEECRYPTAPI -int blowfishEncrypt (blowfishParam* bp, uint32_t* dst, const uint32_t* src) - /*@modifies bp, dst @*/; - -/*!\fn blowfishDecrypt(blowfishParam* bp, uint32_t* dst, const uint32_t* src) - * \brief This function performs the Blowfish decryption; it Rderypts one block - * of 64 bits. - * \param bp The cipher's parameter block. - * \param dst The cleartext; should be aligned on 32-bit boundary. - * \param src The ciphertext; should be aligned on 32-bit boundary. - * \retval 0 on success. - */ -BEECRYPTAPI -int blowfishDecrypt (blowfishParam* bp, uint32_t* dst, const uint32_t* src) - /*@modifies bp, dst @*/; - -BEECRYPTAPI -uint32_t* blowfishFeedback(blowfishParam* bp) - /*@modifies bp @*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/blowfishopt.h b/beecrypt/blowfishopt.h deleted file mode 100644 index 27a229a5a..000000000 --- a/beecrypt/blowfishopt.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2000, 2002, 2003 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file blowfishopt.h - * \brief Blowfish block cipher, assembler-optimized routines, headers. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup BC_blowfish_m - */ - -#ifndef _BLOWFISHOPT_H -#define _BLOWFISHOPT_H - -#include "beecrypt.h" -#include "blowfish.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if WIN32 -# if defined(_MSC_VER) && defined(_M_IX86) -# define ASM_BLOWFISHENCRYPT -# define ASM_BLOWFISHDECRYPT -# elif __INTEL__ && __MWERKS__ -# define ASM_BLOWFISHENCRYPT -# define ASM_BLOWFISHDECRYPT -# endif -#endif - -#if defined(__GNUC__) -# if defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686) -# define ASM_BLOWFISHENCRYPT -# define ASM_BLOWFISHDECRYPT -# endif -# if defined(OPTIMIZE_POWERPC) -# define ASM_BLOWFISHENCRYPT -# define ASM_BLOWFISHDECRYPT -# endif -#endif - -#if defined(__IBMC__) -# if defined(OPTIMIZE_POWERPC) -# define ASM_BLOWFISHENCRYPT -# define ASM_BLOWFISHDECRYPT -# endif -#endif - -#if defined(__INTEL_COMPILER) -# if defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686) -# define ASM_BLOWFISHENCRYPT -# define ASM_BLOWFISHDECRYPT -# endif -#endif - -#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) -/* nothing here yet */ -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/c++/.cvsignore b/beecrypt/c++/.cvsignore deleted file mode 100644 index da7b4816b..000000000 --- a/beecrypt/c++/.cvsignore +++ /dev/null @@ -1,5 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo diff --git a/beecrypt/c++/Makefile.am b/beecrypt/c++/Makefile.am deleted file mode 100644 index 11433b430..000000000 --- a/beecrypt/c++/Makefile.am +++ /dev/null @@ -1,44 +0,0 @@ -LIBBEECRYPT_CXX_LT_CURRENT = 8 -LIBBEECRYPT_CXX_LT_AGE = 2 -LIBBEECRYPT_CXX_LT_REVISION = 0 - -INCLUDES = -I$(top_srcdir)/.. - -AUTOMAKE_OPTIONS = gnu no-dependencies - -SUBDIRS = lang io util security crypto beeyond . provider - -libaltdir=$(prefix)/lib@LIBALT@ -cxxdir=$(pkgincludedir)/c++ - -libalt_LTLIBRARIES = libbeecrypt_cxx.la - -libbeecrypt_cxx_la_SOURCES = \ -adapter.cxx \ -bstream.cxx \ -resource.cxx - -libbeecrypt_cxx_la_LIBADD = ../libbeecrypt.la beeyond/libcxxbeeyond.la crypto/libcxxcrypto.la io/libcxxio.la lang/libcxxlang.la util/libcxxutil.la security/libcxxsecurity.la -licuuc -licuio -libbeecrypt_cxx_la_LDFLAGS = -no-undefined -version-info $(LIBBEECRYPT_CXX_LT_CURRENT):$(LIBBEECRYPT_CXX_LT_REVISION):$(LIBBEECRYPT_CXX_LT_AGE) - -cxx_HEADERS = \ -array.h \ -bstream.h \ -mutex.h - -noinst_HEADERS = \ -adapter.h \ -resource.h - -TESTS = testdsa testrsa testks - -check_PROGRAMS = testdsa testrsa testks - -testdsa_SOURCES = testdsa.cxx -testdsa_LDADD = libbeecrypt_cxx.la - -testrsa_SOURCES = testrsa.cxx -testrsa_LDADD = libbeecrypt_cxx.la - -testks_SOURCES = testks.cxx -testks_LDADD = libbeecrypt_cxx.la diff --git a/beecrypt/c++/adapter.cxx b/beecrypt/c++/adapter.cxx deleted file mode 100644 index c67380979..000000000 --- a/beecrypt/c++/adapter.cxx +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#if HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/adapter.h" - -using namespace beecrypt; - -int sraSetup(SecureRandom* random) -{ - return 0; -} - -int sraSeed(SecureRandom* random, const byte* data, size_t size) -{ - random->setSeed(data, size); - return 0; -} - -int sraNext(SecureRandom* random, byte* data, size_t size) -{ - random->nextBytes(data, size); - return 0; -} - -int sraCleanup(SecureRandom* random) -{ - return 0; -} - -const randomGenerator sraprng = { - "SecureRandom Adapter", - 0, - (randomGeneratorSetup) sraSetup, - (randomGeneratorSeed) sraSeed, - (randomGeneratorNext) sraNext, - (randomGeneratorCleanup) sraCleanup -}; - -randomGeneratorContextAdapter::randomGeneratorContextAdapter(SecureRandom* random) : randomGeneratorContext(&sraprng) -{ - param = (randomGeneratorParam*) random; -} - -// SecureRandom systemsr; diff --git a/beecrypt/c++/adapter.h b/beecrypt/c++/adapter.h deleted file mode 100644 index 330b9e1d7..000000000 --- a/beecrypt/c++/adapter.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file adapter.h - * \brief In-between layer for BeeCrypt C and C++ code. - * \author Bob Deblier <bob.deblier@telenet.be> - */ - -#ifndef _BEECRYPT_ADAPTER_H -#define _BEECRYPT_ADAPTER_H - -#include "beecrypt/beecrypt.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/security/SecureRandom.h" -using beecrypt::security::SecureRandom; - -namespace beecrypt { - /*!\brief Class which transforms a SecureRandom generator into a randomGeneratorContext. - */ - struct BEECRYPTCXXAPI randomGeneratorContextAdapter : randomGeneratorContext - { - randomGeneratorContextAdapter(SecureRandom*); - }; -} - -#endif - -#endif diff --git a/beecrypt/c++/array.h b/beecrypt/c++/array.h deleted file mode 100644 index b60611af7..000000000 --- a/beecrypt/c++/array.h +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file array.h - * \brief Array template class. - * \author Bob Deblier <bob.deblier@telenet.be> - * \ingroup CXX_m - */ - -#ifndef _TEMPLATE_ARRAY_H -#define _TEMPLATE_ARRAY_H - -#include "beecrypt/api.h" - -#ifdef __cplusplus - -#include <new> - -namespace beecrypt { - - template <typename T> - class array - { - private: - T* _data; - size_t _size; - - public: - array() throw () - { - _data = 0; - _size = 0; - } - - array(size_t size) throw (std::bad_alloc) - { - if (size) - { - _data = (T*) malloc(size * sizeof(T)); - if (_data == 0) - throw std::bad_alloc(); - } - else - _data = 0; - _size = size; - } - - array(const T* data, size_t size) throw (std::bad_alloc) - { - _data = (T*) malloc(size * sizeof(T)); - if (_data == 0) - throw std::bad_alloc(); - _size = size; - memcpy(_data, data, _size * sizeof(T)); - } - - array(const array& _copy) throw (std::bad_alloc) - { - _data = (T*) malloc(_copy._size * sizeof(T)); - if (_data == 0) - throw std::bad_alloc(); - _size = _copy._size; - memcpy(_data, _copy._data, _size * sizeof(T)); - } - - ~array() throw () - { - if (_data) - free(_data); - } - - const array& operator=(const array& _set) throw (std::bad_alloc) - { - resize(_set._size); - if (_size) - memcpy(_data, _set._data, _size * sizeof(T)); - - return *this; - } - - bool operator==(const array& _cmp) const throw () - { - if (_size != _cmp.size) - return false; - - if (_size == 0 && _cmp._size == 0) - return true; - - return !memcmp(_data, _cmp._data, _size * sizeof(T)); - } - - bool operator!=(const array& _cmp) const throw () - { - if (_size != _cmp._size) - return true; - - if (_size == 0 && _cmp._size == 0) - return false; - - return memcmp(_data, _cmp._data, _size * sizeof(T)); - } - - T* data() throw () - { - return _data; - } - - const T* data() const throw () - { - return _data; - } - - size_t size() const throw () - { - return _size; - } - - void resize(size_t _newsize) throw (std::bad_alloc) - { - if (_newsize) - { - _data = (T*) (_data ? realloc(_data, _newsize * sizeof(T)) : malloc(_newsize * sizeof(T))); - if (_data == 0) - throw std::bad_alloc(); - } - else - { - if (_data) - { - free(_data); - _data = 0; - } - } - _size = _newsize; - } - - T& operator[](size_t _n) throw () - { - return _data[_n]; - } - - const T operator[](size_t _n) const throw () - { - return _data[_n]; - } - - const array<T>& operator+=(const array<T>& _rhs) throw () - { - if (_rhs._size) - { - size_t _curr = _size; - resize(_size+_rhs._size); - memcpy(_data+_curr, _rhs._data, _rhs._size * sizeof(T)); - } - return *this; - } - }; - - template<typename T> - array<T> operator+(const array<T>& _lhs, const array<T>& _rhs) - { - array<T> _con(_lhs); - - return _con += _rhs; - }; - - typedef array<byte> bytearray; - typedef array<javachar> javachararray; -} - -#endif - -#endif diff --git a/beecrypt/c++/beeyond/.cvsignore b/beecrypt/c++/beeyond/.cvsignore deleted file mode 100644 index da7b4816b..000000000 --- a/beecrypt/c++/beeyond/.cvsignore +++ /dev/null @@ -1,5 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo diff --git a/beecrypt/c++/beeyond/AnyEncodedKeySpec.cxx b/beecrypt/c++/beeyond/AnyEncodedKeySpec.cxx deleted file mode 100644 index 17eec6316..000000000 --- a/beecrypt/c++/beeyond/AnyEncodedKeySpec.cxx +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#include "beecrypt/c++/beeyond/AnyEncodedKeySpec.h" - -using namespace beecrypt::beeyond; - -AnyEncodedKeySpec::AnyEncodedKeySpec(const String& format, const byte* data, size_t size) : EncodedKeySpec(data, size), _format(format) -{ -} - -AnyEncodedKeySpec::AnyEncodedKeySpec(const String& format, const bytearray& copy) : EncodedKeySpec(copy), _format(format) -{ -} - -AnyEncodedKeySpec::~AnyEncodedKeySpec() -{ -} - -const String& AnyEncodedKeySpec::getFormat() const throw () -{ - return _format; -} diff --git a/beecrypt/c++/beeyond/AnyEncodedKeySpec.h b/beecrypt/c++/beeyond/AnyEncodedKeySpec.h deleted file mode 100644 index de8a9edff..000000000 --- a/beecrypt/c++/beeyond/AnyEncodedKeySpec.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file AnyEncodedKeySpec.h - * \ingroup CXX_BEEYOND_m - */ - -#ifndef _CLASS_ANYENCODEDKEYSPEC_H -#define _CLASS_ANYENCODEDKEYSPEC_H - -#ifdef __cplusplus - -#include "beecrypt/c++/lang/String.h" -using beecrypt::lang::String; -#include "beecrypt/c++/security/spec/EncodedKeySpec.h" -using beecrypt::security::spec::EncodedKeySpec; - -namespace beecrypt { - namespace beeyond { - class BEECRYPTCXXAPI AnyEncodedKeySpec : public EncodedKeySpec - { - private: - String _format; - - public: - AnyEncodedKeySpec(const String& format, const byte*, size_t); - AnyEncodedKeySpec(const String& format, const bytearray&); - - virtual ~AnyEncodedKeySpec(); - - virtual const String& getFormat() const throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/beeyond/BeeCertificate.cxx b/beecrypt/c++/beeyond/BeeCertificate.cxx deleted file mode 100644 index 08fe43760..000000000 --- a/beecrypt/c++/beeyond/BeeCertificate.cxx +++ /dev/null @@ -1,619 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/beeyond/BeeCertificate.h" -#include "beecrypt/c++/beeyond/AnyEncodedKeySpec.h" -#include "beecrypt/c++/io/ByteArrayInputStream.h" -using beecrypt::io::ByteArrayInputStream; -#include "beecrypt/c++/io/ByteArrayOutputStream.h" -using beecrypt::io::ByteArrayOutputStream; -#include "beecrypt/c++/lang/NullPointerException.h" -using beecrypt::lang::NullPointerException; -#include "beecrypt/c++/security/KeyFactory.h" -using beecrypt::security::KeyFactory; -#include "beecrypt/c++/security/Signature.h" -using beecrypt::security::Signature; -#include "beecrypt/c++/security/cert/CertificateFactory.h" -using beecrypt::security::cert::CertificateFactory; - -using namespace beecrypt::beeyond; - -BeeCertificate::Field::~Field() -{ -} - -BeeCertificate::UnknownField::UnknownField() -{ -} - -BeeCertificate::UnknownField::UnknownField(const UnknownField& copy) : encoding(copy.encoding) -{ - type = copy.type; -} - -BeeCertificate::UnknownField::~UnknownField() -{ -} - -BeeCertificate::Field* BeeCertificate::UnknownField::clone() const -{ - return new BeeCertificate::UnknownField(*this); -} - -void BeeCertificate::UnknownField::decode(DataInputStream& in) throw (IOException) -{ - encoding.resize(in.available()); - - in.readFully(encoding); -} - -void BeeCertificate::UnknownField::encode(DataOutputStream& out) const throw (IOException) -{ - out.write(encoding); -} - -const javaint BeeCertificate::PublicKeyField::FIELD_TYPE = 0x5055424b; // 'PUBK' - -BeeCertificate::PublicKeyField::PublicKeyField() -{ - type = BeeCertificate::PublicKeyField::FIELD_TYPE; - pub = 0; -} - -BeeCertificate::PublicKeyField::PublicKeyField(const PublicKey& key) -{ - type = BeeCertificate::PublicKeyField::FIELD_TYPE; - pub = key.clone(); -} - -BeeCertificate::PublicKeyField::~PublicKeyField() -{ - delete pub; -} - -BeeCertificate::Field* BeeCertificate::PublicKeyField::clone() const -{ - return new BeeCertificate::PublicKeyField(*pub); -} - -void BeeCertificate::PublicKeyField::decode(DataInputStream& in) throw (IOException) -{ - String format; - - in.readUTF(format); - - // no need for a try-catch around this; calling function is expecting a thrown NoSuchAlgorithmException - KeyFactory* kf = KeyFactory::getInstance(format); - - try - { - javaint encsize = in.readInt(); - - if (encsize <= 0) - throw IOException("Invalid key encoding size"); - - bytearray enc(encsize); - - in.readFully(enc); - - AnyEncodedKeySpec spec(format, enc); - - pub = kf->generatePublic(spec); - - delete kf; - } - catch (...) - { - delete kf; - throw; - } -} - -void BeeCertificate::PublicKeyField::encode(DataOutputStream& out) const throw (IOException) -{ - out.writeUTF(*pub->getFormat()); - - const bytearray* pubenc = pub->getEncoded(); - - if (!pubenc) - throw NullPointerException("PublicKey has no encoding"); - - out.writeInt(pubenc->size()); - out.write(*pubenc); -} - -const javaint BeeCertificate::ParentCertificateField::FIELD_TYPE = 0x43455254; // 'CERT' - -BeeCertificate::ParentCertificateField::ParentCertificateField() -{ - type = BeeCertificate::ParentCertificateField::FIELD_TYPE; - parent = 0; -} - -BeeCertificate::ParentCertificateField::ParentCertificateField(const Certificate& cert) -{ - type = BeeCertificate::ParentCertificateField::FIELD_TYPE; - parent = cert.clone(); -} - -BeeCertificate::ParentCertificateField::~ParentCertificateField() -{ - delete parent; -} - -BeeCertificate::Field* BeeCertificate::ParentCertificateField::clone() const -{ - return new BeeCertificate::ParentCertificateField(*parent); -} - -void BeeCertificate::ParentCertificateField::decode(DataInputStream& in) throw (IOException) -{ - String type; - - in.readUTF(type); - - CertificateFactory* cf = CertificateFactory::getInstance(type); - - try - { - javaint encsize = in.readInt(); - - if (encsize <= 0) - throw IOException("Invalid certificate encoding size"); - - bytearray enc(encsize); - - in.readFully(enc); - - ByteArrayInputStream bin(enc); - - parent = cf->generateCertificate(bin); - - throw RuntimeException(); - - delete cf; - } - catch (...) - { - delete cf; - throw; - } -} - -void BeeCertificate::ParentCertificateField::encode(DataOutputStream& out) const throw (IOException) -{ - out.writeUTF(parent->getType()); - - const bytearray& parentenc = parent->getEncoded(); - - out.writeInt(parentenc.size()); - out.write(parentenc); -} - -BeeCertificate::Field* BeeCertificate::instantiateField(javaint type) -{ - switch (type) - { - case PublicKeyField::FIELD_TYPE: - return new PublicKeyField(); - - case ParentCertificateField::FIELD_TYPE: - return new ParentCertificateField(); - - default: - return new UnknownField(); - } -} - -const Date BeeCertificate::FOREVER((javalong) -1L); - -BeeCertificate::BeeCertificate() : Certificate("BEE") -{ - enc = 0; -} - -BeeCertificate::BeeCertificate(InputStream& in) throw (IOException) : Certificate("BEE") -{ - enc = 0; - - DataInputStream dis(in); - - dis.readUTF(issuer); - dis.readUTF(subject); - - created.setTime(dis.readLong()); - expires.setTime(dis.readLong()); - - javaint fieldcount = dis.readInt(); - if (fieldcount < 0) - throw IOException("field count < 0"); - - for (javaint i = 0; i < fieldcount; i++) - { - bytearray fenc; - - javaint type = dis.readInt(); - javaint size = dis.readInt(); - - fenc.resize(size); - - dis.readFully(fenc); - - ByteArrayInputStream bis(fenc); - DataInputStream fis(bis); - - Field* f = instantiateField(type); - - try - { - f->decode(fis); - fields.push_back(f); - } - catch (...) - { - delete f; - throw; - } - } - - dis.readUTF(signature_algorithm); - - javaint siglength = dis.readInt(); - - if (siglength < 0) - throw IOException("signature length < 0"); - - if (siglength > 0) - { - signature.resize(siglength); - dis.readFully(signature); - } -} - -BeeCertificate::BeeCertificate(const BeeCertificate& copy) : Certificate("BEE") -{ - issuer = copy.issuer; - subject = copy.subject; - created = copy.created; - expires = copy.expires; - for (fields_const_iterator it = copy.fields.begin(); it != copy.fields.end(); it++) - fields.push_back((*it)->clone()); - signature_algorithm = copy.signature_algorithm; - signature = copy.signature; - enc = 0; -} - -BeeCertificate::~BeeCertificate() -{ - if (enc) - delete enc; -} - -BeeCertificate* BeeCertificate::clone() const -{ - return new BeeCertificate(*this); -} - -const bytearray& BeeCertificate::getEncoded() const -{ - if (!enc) - { - // The following sequence shouldn't throw an exception - ByteArrayOutputStream bos; - DataOutputStream dos(bos); - - dos.writeUTF(issuer); - dos.writeUTF(subject); - dos.writeLong(created.getTime()); - dos.writeLong(expires.getTime()); - dos.writeInt(fields.size()); - - for (fields_vector::const_iterator it = fields.begin(); it != fields.end(); it++) - { - ByteArrayOutputStream bout; - DataOutputStream dout(bout); - - Field* f = (*it); - - f->encode(dout); - dout.close(); - - bytearray* fenc = bout.toByteArray(); - - dos.writeInt(f->type); - dos.writeInt(fenc->size()); - dos.write(*fenc); - - delete fenc; - } - - dos.writeUTF(signature_algorithm); - dos.writeInt(signature.size()); - dos.write(signature); - dos.close(); - bos.close(); - - enc = bos.toByteArray(); - } - - return *enc; -} - -const PublicKey& BeeCertificate::getPublicKey() const -{ - for (fields_const_iterator it = fields.begin(); it != fields.end(); it++) - { - if ((*it)->type == PublicKeyField::FIELD_TYPE) - { - const PublicKeyField* f = dynamic_cast<const PublicKeyField*>(*it); - - if (f) - return *f->pub; - else - throw GeneralSecurityException("Somebody's trying to cheat with a new Field subclass"); - } - } - - throw CertificateException("BeeCertificate doesn't contain a PublicKey"); -} - -const Certificate& BeeCertificate::getParentCertificate() const -{ - for (fields_const_iterator it = fields.begin(); it != fields.end(); it++) - { - if ((*it)->type == ParentCertificateField::FIELD_TYPE) - { - const ParentCertificateField* f = dynamic_cast<const ParentCertificateField*>(*it); - - if (f) - return *f->parent; - else - throw GeneralSecurityException("Somebody's trying to cheat with a new Field subclass"); - } - } - - throw CertificateException("BeeCertificate doesn't contain a parent Certificate"); -} - -void BeeCertificate::verify(const PublicKey& pub) throw (CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException) -{ - Signature* sig = Signature::getInstance(signature_algorithm); - - try - { - sig->initVerify(pub); - - bytearray* tmp = encodeTBS(); - - try - { - sig->update(*tmp); - delete tmp; - } - catch (...) - { - delete tmp; - throw; - } - - if (!sig->verify(signature)) - throw CertificateException("signature doesn't match"); - - delete sig; - } - catch (...) - { - delete sig; - throw; - } -} - -void BeeCertificate::verify(const PublicKey& pub, const String& sigProvider) throw (CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException) -{ - Signature* sig = Signature::getInstance(signature_algorithm, sigProvider); - - try - { - sig->initVerify(pub); - - bytearray* tmp = encodeTBS(); - - try - { - sig->update(*tmp); - delete tmp; - } - catch (...) - { - delete tmp; - throw; - } - - if (!sig->verify(signature)) - throw CertificateException("signature doesn't match"); - - delete sig; - } - catch (...) - { - delete sig; - throw; - } -} - -const String& BeeCertificate::toString() const throw () -{ - if (!str) - str = new String(); - - return *str; -} - -void BeeCertificate::checkValidity() const throw (CertificateExpiredException, CertificateNotYetValidException) -{ - Date now; - - checkValidity(now); -} - -void BeeCertificate::checkValidity(const Date& at) const throw (CertificateExpiredException, CertificateNotYetValidException) -{ - if (at.before(created)) - throw CertificateNotYetValidException(); - - if (expires != FOREVER) - if (at.after(expires)) - throw CertificateExpiredException(); -} - -const Date& BeeCertificate::getNotAfter() const throw () -{ - return expires; -} - -const Date& BeeCertificate::getNotBefore() const throw () -{ - return created; -} - -const bytearray& BeeCertificate::getSignature() const throw () -{ - return signature; -} - -const String& BeeCertificate::getSigAlgName() const throw () -{ - return signature_algorithm; -} - -bool BeeCertificate::hasPublicKey() const -{ - for (fields_vector::const_iterator it = fields.begin(); it != fields.end(); it++) - { - switch ((*it)->type) - { - case PublicKeyField::FIELD_TYPE: - // do an extra check with dynamic_cast - if (dynamic_cast<PublicKeyField*>(*it)) - return true; - else - throw GeneralSecurityException("Somebody's trying to cheat with a new Field subclass"); - } - } - return false; -} - -bool BeeCertificate::hasParentCertificate() const -{ - for (fields_vector::const_iterator it = fields.begin(); it != fields.end(); it++) - { - switch ((*it)->type) - { - case ParentCertificateField::FIELD_TYPE: - // do an extra check with dynamic_cast - if (dynamic_cast<ParentCertificateField*>(*it)) - return true; - else - throw GeneralSecurityException("Somebody's trying to cheat with a new Field subclass"); - } - } - return false; -} - -bytearray* BeeCertificate::encodeTBS() const -{ - ByteArrayOutputStream bos; - DataOutputStream dos(bos); - - dos.writeUTF(issuer); - dos.writeUTF(subject); - dos.writeLong(created.getTime()); - dos.writeLong(expires.getTime()); - dos.writeInt(fields.size()); - for (fields_vector::const_iterator it = fields.begin(); it != fields.end(); it++) - { - Field* f = (*it); - - dos.writeInt(f->type); - f->encode(dos); - } - - dos.close(); - bos.close(); - return bos.toByteArray(); -} - -BeeCertificate* BeeCertificate::self(const PublicKey& pub, const PrivateKey& pri, const String& signatureAlgorithm) throw (InvalidKeyException, NoSuchAlgorithmException) -{ - // if the public key doesn't have an encoding, it's not worth going through the effort - if (!pub.getEncoded()) - throw InvalidKeyException("PublicKey doesn't have an encoding"); - - Signature* sig = Signature::getInstance(signatureAlgorithm); - - try - { - sig->initSign(pri); - - BeeCertificate* cert = new BeeCertificate(); - - try - { - // issuer is kept blank - cert->subject = "PublicKey Certificate"; - cert->expires = FOREVER; - cert->signature_algorithm = signatureAlgorithm; - cert->fields.push_back(new PublicKeyField(pub)); - - bytearray* tmp = cert->encodeTBS(); - - try - { - sig->update(*tmp); - delete tmp; - } - catch (...) - { - delete tmp; - throw; - } - - sig->sign(cert->signature); - } - catch (...) - { - delete cert; - throw; - } - - delete sig; - - return cert; - } - catch (...) - { - delete sig; - throw; - } -} diff --git a/beecrypt/c++/beeyond/BeeCertificate.h b/beecrypt/c++/beeyond/BeeCertificate.h deleted file mode 100644 index f89f13e23..000000000 --- a/beecrypt/c++/beeyond/BeeCertificate.h +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file BeeCertificate.h - * \ingroup CXX_BEEYOND_m - */ - -#ifndef _CLASS_BEECERTIFICATE_H -#define _CLASS_BEECERTIFICATE_H - -#ifdef __cplusplus - -#include "beecrypt/c++/array.h" -using beecrypt::array; -#include "beecrypt/c++/io/DataInputStream.h" -using beecrypt::io::DataInputStream; -#include "beecrypt/c++/io/DataOutputStream.h" -using beecrypt::io::DataOutputStream; -#include "beecrypt/c++/provider/BeeCertificateFactory.h" -using beecrypt::provider::BeeCertificateFactory; -#include "beecrypt/c++/security/PublicKey.h" -using beecrypt::security::PublicKey; -#include "beecrypt/c++/security/PrivateKey.h" -using beecrypt::security::PrivateKey; -#include "beecrypt/c++/security/cert/Certificate.h" -using beecrypt::security::cert::Certificate; -#include "beecrypt/c++/security/cert/CertificateExpiredException.h" -using beecrypt::security::cert::CertificateExpiredException; -#include "beecrypt/c++/security/cert/CertificateNotYetValidException.h" -using beecrypt::security::cert::CertificateNotYetValidException; -#include "beecrypt/c++/util/Date.h" -using beecrypt::util::Date; - -#include <vector> -using std::vector; - -namespace beecrypt { - namespace beeyond { - /* We use short certificate chains, embedded in the certificate as parent certificates - * Issuer is informational - * Subject is used to identify the type of certificate - */ - class BEECRYPTCXXAPI BeeCertificate : public Certificate - { - friend class BeeCertificateFactory; - - public: - static const Date FOREVER; - - protected: - struct Field - { - javaint type; - - virtual ~Field(); - - virtual Field* clone() const = 0; - - virtual void decode(DataInputStream&) throw (IOException) = 0; - virtual void encode(DataOutputStream&) const throw (IOException) = 0; - }; - - struct UnknownField : public Field - { - bytearray encoding; - - UnknownField(); - UnknownField(const UnknownField&); - virtual ~UnknownField(); - - virtual Field* clone() const; - - virtual void decode(DataInputStream&) throw (IOException); - virtual void encode(DataOutputStream&) const throw (IOException); - }; - - struct PublicKeyField : public Field - { - static const javaint FIELD_TYPE; - - PublicKey* pub; - - PublicKeyField(); - PublicKeyField(const PublicKey& key); - virtual ~PublicKeyField(); - - virtual Field* clone() const; - - virtual void decode(DataInputStream&) throw (IOException); - virtual void encode(DataOutputStream&) const throw (IOException); - }; - - struct ParentCertificateField : public Field - { - static const javaint FIELD_TYPE; - - Certificate* parent; - - ParentCertificateField(); - ParentCertificateField(const Certificate&); - virtual ~ParentCertificateField(); - - virtual Field* clone() const; - - virtual void decode(DataInputStream&) throw (IOException); - virtual void encode(DataOutputStream&) const throw (IOException); - }; - - virtual Field* instantiateField(javaint type); - - public: - typedef vector<Field*> fields_vector; - typedef vector<Field*>::iterator fields_iterator; - typedef vector<Field*>::const_iterator fields_const_iterator; - - protected: - String issuer; - String subject; - Date created; - Date expires; - fields_vector fields; - String signature_algorithm; - bytearray signature; - - mutable bytearray* enc; - mutable String* str; - - BeeCertificate(); - BeeCertificate(InputStream& in) throw (IOException); - - bytearray* encodeTBS() const; - - public: - BeeCertificate(const BeeCertificate&); - virtual ~BeeCertificate(); - - virtual BeeCertificate* clone() const; - - virtual const bytearray& getEncoded() const; - virtual const PublicKey& getPublicKey() const; - - virtual void verify(const PublicKey&) throw (CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException); - virtual void verify(const PublicKey&, const String&) throw (CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException); - virtual const String& toString() const throw (); - - void checkValidity() const throw (CertificateExpiredException, CertificateNotYetValidException); - void checkValidity(const Date&) const throw (CertificateExpiredException, CertificateNotYetValidException); - - const String& getIssuer() const throw (); - const String& getSubject() const throw (); - - const Date& getNotAfter() const throw (); - const Date& getNotBefore() const throw (); - - const bytearray& getSignature() const throw (); - const String& getSigAlgName() const throw (); - - bool hasPublicKey() const; - bool hasParentCertificate() const; - - const Certificate& getParentCertificate() const; - - public: - static BeeCertificate* self(const PublicKey&, const PrivateKey&, const String& sigAlgName) throw (InvalidKeyException, NoSuchAlgorithmException); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/beeyond/BeeEncodedKeySpec.cxx b/beecrypt/c++/beeyond/BeeEncodedKeySpec.cxx deleted file mode 100644 index 54a1de40c..000000000 --- a/beecrypt/c++/beeyond/BeeEncodedKeySpec.cxx +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#include "beecrypt/c++/beeyond/BeeEncodedKeySpec.h" - -using namespace beecrypt::beeyond; - -BeeEncodedKeySpec::BeeEncodedKeySpec(const byte* data, size_t size) : EncodedKeySpec(data, size) -{ -} - -BeeEncodedKeySpec::BeeEncodedKeySpec(const bytearray& copy) : EncodedKeySpec(copy) -{ -} - -BeeEncodedKeySpec::~BeeEncodedKeySpec() -{ -} - -const String& BeeEncodedKeySpec::getFormat() const throw () -{ - static const String* format = 0; - - if (!format) - format = new String("BEE"); - - return *format; -} diff --git a/beecrypt/c++/beeyond/BeeEncodedKeySpec.h b/beecrypt/c++/beeyond/BeeEncodedKeySpec.h deleted file mode 100644 index 09bf08762..000000000 --- a/beecrypt/c++/beeyond/BeeEncodedKeySpec.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file BeeEncodedKeySpec.h - * \ingroup CXX_BEEYOND_m - */ - -#ifndef _CLASS_BEEENCODEDKEYSPEC_H -#define _CLASS_BEEENCODEDKEYSPEC_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/spec/EncodedKeySpec.h" -using beecrypt::security::spec::EncodedKeySpec; - -namespace beecrypt { - namespace beeyond { - class BEECRYPTCXXAPI BeeEncodedKeySpec : public EncodedKeySpec - { - public: - BeeEncodedKeySpec(const byte*, size_t); - BeeEncodedKeySpec(const bytearray&); - - virtual ~BeeEncodedKeySpec(); - - virtual const String& getFormat() const throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/beeyond/BeeInputStream.cxx b/beecrypt/c++/beeyond/BeeInputStream.cxx deleted file mode 100644 index 7b7f9d4b7..000000000 --- a/beecrypt/c++/beeyond/BeeInputStream.cxx +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/beeyond/BeeInputStream.h" - -using namespace beecrypt::beeyond; - -BeeInputStream::BeeInputStream(InputStream& in) : DataInputStream(in) -{ -} - -BeeInputStream::~BeeInputStream() -{ -} - -void BeeInputStream::read(mpnumber& n) throw (IOException) -{ - int size = readInt(); - byte* data = new byte[size]; - - try - { - readFully(data, 0, size); - mpnsetbin(&n, data, size); - delete[] data; - } - catch (IOException) - { - // free buffer - delete[] data; - // re-throw exception - throw; - } -} - -void BeeInputStream::read(mpbarrett& b) throw (IOException) -{ - int size = readInt(); - byte* data = new byte[size]; - - try - { - readFully(data, 0, size); - mpbsetbin(&b, data, size); - delete[] data; - } - catch (IOException) - { - // free buffer - delete[] data; - // re-throw exception - throw; - } -} diff --git a/beecrypt/c++/beeyond/BeeInputStream.h b/beecrypt/c++/beeyond/BeeInputStream.h deleted file mode 100644 index 1825dc576..000000000 --- a/beecrypt/c++/beeyond/BeeInputStream.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file BeeInputStream.h - * \ingroup CXX_BEEYOND_m - */ - -#ifndef _CLASS_BEEINPUTSTREAM_H -#define _CLASS_BEEINPUTSTREAM_H - -#include "beecrypt/mpbarrett.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/io/DataInputStream.h" -using beecrypt::io::DataInputStream; - -namespace beecrypt { - namespace beeyond { - class BEECRYPTCXXAPI BeeInputStream : public DataInputStream - { - public: - BeeInputStream(InputStream& in); - virtual ~BeeInputStream(); - - void read(mpnumber&) throw (IOException); - void read(mpbarrett&) throw (IOException); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/beeyond/BeeOutputStream.cxx b/beecrypt/c++/beeyond/BeeOutputStream.cxx deleted file mode 100644 index cb0c4eb05..000000000 --- a/beecrypt/c++/beeyond/BeeOutputStream.cxx +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/beeyond/BeeOutputStream.h" - -using namespace beecrypt::beeyond; - -BeeOutputStream::BeeOutputStream(OutputStream& out) : DataOutputStream(out) -{ -} - -BeeOutputStream::~BeeOutputStream() -{ -} - -void BeeOutputStream::write(const mpnumber& n) throw (IOException) -{ - size_t bits = n.bitlength(); - size_t length = ((bits + 7) >> 3) + (((bits & 7) == 0) ? 1 : 0); - - byte* buffer = new byte[length]; - - try - { - i2osp(buffer, length, n.data, n.size); - - DataOutputStream::writeInt(length); - DataOutputStream::write(buffer, 0, length); - - delete[] buffer; - } - catch (IOException) - { - delete[] buffer; - throw; - } -} - -void BeeOutputStream::write(const mpbarrett& b) throw (IOException) -{ - size_t bits = b.bitlength(); - size_t length = ((bits + 7) >> 3) + (((bits & 7) == 0) ? 1 : 0); - - byte* buffer = new byte[length]; - - try - { - i2osp(buffer, length, b.modl, b.size); - - DataOutputStream::writeInt(length); - DataOutputStream::write(buffer, 0, length); - - delete[] buffer; - } - catch (IOException) - { - delete[] buffer; - throw; - } -} diff --git a/beecrypt/c++/beeyond/BeeOutputStream.h b/beecrypt/c++/beeyond/BeeOutputStream.h deleted file mode 100644 index c6ce4e2ff..000000000 --- a/beecrypt/c++/beeyond/BeeOutputStream.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file BeeOutputStream.h - * \ingroup CXX_BEEYOND_m - */ - -#ifndef _CLASS_BEEOUTPUTSTREAM_H -#define _CLASS_BEEOUTPUTSTREAM_H - -#include "beecrypt/mpbarrett.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/io/DataOutputStream.h" -using beecrypt::io::DataOutputStream; - -namespace beecrypt { - namespace beeyond { - class BEECRYPTCXXAPI BeeOutputStream : public DataOutputStream - { - public: - BeeOutputStream(OutputStream& out); - virtual ~BeeOutputStream(); - - void write(const mpnumber&) throw (IOException); - void write(const mpbarrett&) throw (IOException); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/beeyond/Makefile.am b/beecrypt/c++/beeyond/Makefile.am deleted file mode 100644 index 098d13ff4..000000000 --- a/beecrypt/c++/beeyond/Makefile.am +++ /dev/null @@ -1,30 +0,0 @@ -INCLUDES = -I$(top_srcdir)/.. - -LIBS = -licuuc -licuio - -AUTOMAKE_OPTIONS = gnu no-dependencies - -noinst_LTLIBRARIES = libcxxbeeyond.la - -libcxxbeeyond_la_SOURCES = \ -AnyEncodedKeySpec.cxx \ -BeeCertificate.cxx \ -BeeEncodedKeySpec.cxx \ -BeeInputStream.cxx \ -BeeOutputStream.cxx \ -PKCS12PBEKey.cxx - -noinst_HEADERS = \ -AnyEncodedKeySpec.h \ -BeeCertificate.h \ -BeeEncodedKeySpec.h \ -BeeInputStream.h \ -BeeOutputStream.h \ -PKCS12PBEKey.h - -TESTS = testcert - -check_PROGRAMS = testcert - -testcert_SOURCES = testcert.cxx -testcert_LDADD = ../libbeecrypt_cxx.la diff --git a/beecrypt/c++/beeyond/PKCS12PBEKey.cxx b/beecrypt/c++/beeyond/PKCS12PBEKey.cxx deleted file mode 100644 index f7ad0cb1b..000000000 --- a/beecrypt/c++/beeyond/PKCS12PBEKey.cxx +++ /dev/null @@ -1,86 +0,0 @@ -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/beeyond/PKCS12PBEKey.h" - -#include <iostream> -using std::cout; -using std::endl; - -using namespace beecrypt::beeyond; - -PKCS12PBEKey::PKCS12PBEKey(const array<javachar>& password, const bytearray* salt, size_t iterationCount) : _pswd(password) -{ - if (salt) - _salt = new bytearray(*salt); - else - _salt = 0; - _iter = iterationCount; - _enc = 0; -} - -PKCS12PBEKey::~PKCS12PBEKey() -{ - if (_salt) - delete _salt; -} - -PKCS12PBEKey* PKCS12PBEKey::clone() const -{ - return new PKCS12PBEKey(_pswd, _salt, _iter); -} - -bytearray* PKCS12PBEKey::encode(const array<javachar>& password, const bytearray* salt, size_t iterationCount) -{ - size_t i; - - bytearray* result = new bytearray((password.size() + 1) * 2); - - for (i = 0; i < password.size(); i++) - { - (*result)[2*i ] = (password[i] >> 8) & 0xff; - (*result)[2*i+1] = (password[i] ) & 0xff; - } - (*result)[2*i ] = 0; - (*result)[2*i+1] = 0; - - return result; -} - -size_t PKCS12PBEKey::getIterationCount() const throw () -{ - return _iter; -} - -const array<javachar>& PKCS12PBEKey::getPassword() const throw () -{ - return _pswd; -} - -const bytearray* PKCS12PBEKey::getSalt() const throw () -{ - return _salt; -} - -const bytearray* PKCS12PBEKey::getEncoded() const -{ - if (!_enc) - _enc = encode(_pswd, _salt, _iter); - - return _enc; -} - -const String& PKCS12PBEKey::getAlgorithm() const throw () -{ - static const String ALGORITHM = UNICODE_STRING_SIMPLE("PKCS#12/PBE"); - return ALGORITHM; -} - -const String* PKCS12PBEKey::getFormat() const throw () -{ - static const String FORMAT = UNICODE_STRING_SIMPLE("RAW"); - return &FORMAT; -} diff --git a/beecrypt/c++/beeyond/PKCS12PBEKey.h b/beecrypt/c++/beeyond/PKCS12PBEKey.h deleted file mode 100644 index 8aacf273d..000000000 --- a/beecrypt/c++/beeyond/PKCS12PBEKey.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file PKCS12PBEKey.h - * \ingroup CXX_BEEYOND_m - */ - -#ifndef _CLASS_PKCS12PBEKEY_H -#define _CLASS_PKCS12PBEKEY_H - -#ifdef __cplusplus - -#include "beecrypt/c++/array.h" -using beecrypt::array; -using beecrypt::bytearray; -#include "beecrypt/c++/crypto/interfaces/PBEKey.h" -using beecrypt::crypto::interfaces::PBEKey; - -namespace beecrypt { - namespace beeyond { - class BEECRYPTCXXAPI PKCS12PBEKey : public PBEKey - { - private: - array<javachar> _pswd; - bytearray* _salt; - size_t _iter; - mutable bytearray* _enc; - - public: - static bytearray* encode(const array<javachar>&, const bytearray*, size_t); - - public: - PKCS12PBEKey(const array<javachar>&, const bytearray*, size_t); - virtual ~PKCS12PBEKey(); - - virtual PKCS12PBEKey* clone() const; - - virtual size_t getIterationCount() const throw (); - virtual const array<javachar>& getPassword() const throw (); - virtual const bytearray* getSalt() const throw (); - - virtual const bytearray* getEncoded() const; - - virtual const String& getAlgorithm() const throw(); - virtual const String* getFormat() const throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/beeyond/testcert.cxx b/beecrypt/c++/beeyond/testcert.cxx deleted file mode 100644 index eecc4e5a7..000000000 --- a/beecrypt/c++/beeyond/testcert.cxx +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "c++/bstream.h" -#include "c++/beeyond/BeeCertificate.h" -using beecrypt::beeyond::BeeCertificate; -#include "c++/io/ByteArrayInputStream.h" -using beecrypt::io::ByteArrayInputStream; -#include "c++/security/AlgorithmParameterGenerator.h" -using beecrypt::security::AlgorithmParameterGenerator; -#include "c++/security/AlgorithmParameters.h" -using beecrypt::security::AlgorithmParameters; -#include "c++/security/KeyFactory.h" -using beecrypt::security::KeyFactory; -#include "c++/security/KeyPairGenerator.h" -using beecrypt::security::KeyPairGenerator; -#include "c++/security/Signature.h" -using beecrypt::security::Signature; -#include "c++/security/cert/CertificateFactory.h" -using beecrypt::security::cert::CertificateFactory; -#include "c++/security/spec/EncodedKeySpec.h" -using beecrypt::security::spec::EncodedKeySpec; - -#include <iostream> -using namespace std; -#include <unicode/ustream.h> - -int main(int argc, char* argv[]) -{ - int failures = 0; - - try - { - KeyPairGenerator* kpg = KeyPairGenerator::getInstance("DSA"); - - kpg->initialize(1024); - - KeyPair* pair = kpg->generateKeyPair(); - - cout << "keypair generated" << endl << flush; - - BeeCertificate* self = BeeCertificate::self(pair->getPublic(), pair->getPrivate(), "SHA1withDSA"); - - cout << "self generated" << endl << flush; - - ByteArrayInputStream bis(self->getEncoded()); - - CertificateFactory* cf = CertificateFactory::getInstance("BEE"); - - cout << "got cf" << endl << flush; - - Certificate* cert = cf->generateCertificate(bis); - - cout << "verifying" << endl << flush; - - cert->verify(pair->getPublic()); - - cout << "verified" << endl << flush; - - if (!(*cert == *self)) - { - cerr << "certificates differ" << endl; - failures++; - } - else - cout << "certificates equal" << endl << flush; - - delete cert; - delete cf; - delete self; - delete pair; - delete kpg; - } - catch (Exception& ex) - { - std::cerr << "exception: " << ex.getMessage(); - std::cerr << " type " << typeid(ex).name() << std::endl; - failures++; - } - catch (...) - { - std::cerr << "exception" << std::endl; - failures++; - } - return failures; -} diff --git a/beecrypt/c++/bstream.cxx b/beecrypt/c++/bstream.cxx deleted file mode 100644 index 2c345c76a..000000000 --- a/beecrypt/c++/bstream.cxx +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#include "beecrypt/c++/bstream.h" - -#include "beecrypt/c++/crypto/interfaces/DHPublicKey.h" -using beecrypt::crypto::interfaces::DHPublicKey; -#include "beecrypt/c++/security/interfaces/DSAPublicKey.h" -using beecrypt::security::interfaces::DSAPublicKey; -#include "beecrypt/c++/security/interfaces/RSAPublicKey.h" -using beecrypt::security::interfaces::RSAPublicKey; - -#include <unicode/ustream.h> - -using namespace beecrypt; - -ostream& operator<<(ostream& stream, const PublicKey& pub) -{ - stream << pub.getAlgorithm() << " public key" << endl; - - const DHPublicKey* dh = dynamic_cast<const DHPublicKey*>(&pub); - if (dh) - { - return stream << "P = " << dh->getParams().getP() << endl << - "G = " << dh->getParams().getG() << endl << - "Y = " << dh->getY() << endl; - } - - const DSAPublicKey* dsa = dynamic_cast<const DSAPublicKey*>(&pub); - if (dsa) - { - return stream << "P = " << dsa->getParams().getP() << endl << - "Q = " << dsa->getParams().getQ() << endl << - "G = " << dsa->getParams().getG() << endl << - "Y = " << dsa->getY() << endl; - } - - const RSAPublicKey* rsa = dynamic_cast<const RSAPublicKey*>(&pub); - if (rsa) - { - return stream << "N = " << rsa->getModulus() << endl << - "E = " << rsa->getPublicExponent() << endl; - } - - return stream; -} diff --git a/beecrypt/c++/bstream.h b/beecrypt/c++/bstream.h deleted file mode 100644 index a31f84d44..000000000 --- a/beecrypt/c++/bstream.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file bstream.h - * \brief C++ Object-to-stream output. - * \author Bob Deblier <bob.deblier@telenet.be> - */ - -#ifndef _BEECRYPT_STREAM_H -#define _BEECRYPT_STREAM_H - -#include "beecrypt/api.h" - -#ifdef __cplusplus - -#include <iostream> -using std::cout; -using std::ostream; -using std::endl; - -#include "beecrypt/c++/security/PublicKey.h" -using beecrypt::security::PublicKey; - -namespace beecrypt { - BEECRYPTCXXAPI - ostream& operator<<(ostream& stream, const PublicKey&); -} - -#endif - -#endif diff --git a/beecrypt/c++/crypto/.cvsignore b/beecrypt/c++/crypto/.cvsignore deleted file mode 100644 index da7b4816b..000000000 --- a/beecrypt/c++/crypto/.cvsignore +++ /dev/null @@ -1,5 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo diff --git a/beecrypt/c++/crypto/BadPaddingException.cxx b/beecrypt/c++/crypto/BadPaddingException.cxx deleted file mode 100644 index eea765f96..000000000 --- a/beecrypt/c++/crypto/BadPaddingException.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/crypto/BadPaddingException.h" - -using namespace beecrypt::crypto; - -BadPaddingException::BadPaddingException() throw () -{ -} - -BadPaddingException::BadPaddingException(const String& message) throw () : GeneralSecurityException(message) -{ -} diff --git a/beecrypt/c++/crypto/BadPaddingException.h b/beecrypt/c++/crypto/BadPaddingException.h deleted file mode 100644 index c93860610..000000000 --- a/beecrypt/c++/crypto/BadPaddingException.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file BadPaddingException.h - * \ingroup CXX_CRYPTO_m - */ - -#ifndef _CLASS_BADPADDINGEXCEPTION_H -#define _CLASS_BADPADDINGEXCEPTION_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/GeneralSecurityException.h" -using beecrypt::security::GeneralSecurityException; - -namespace beecrypt { - namespace crypto { - class BEECRYPTCXXAPI BadPaddingException : public GeneralSecurityException - { - public: - BadPaddingException() throw (); - BadPaddingException(const String&) throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/crypto/Mac.cxx b/beecrypt/c++/crypto/Mac.cxx deleted file mode 100644 index ccb83d17f..000000000 --- a/beecrypt/c++/crypto/Mac.cxx +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/crypto/Mac.h" -#include "beecrypt/c++/lang/IllegalArgumentException.h" -using beecrypt::lang::IllegalArgumentException; -#include "beecrypt/c++/security/Security.h" -using beecrypt::security::Security; - -using namespace beecrypt::crypto; - -Mac::Mac(MacSpi* spi, const String& algorithm, const Provider& provider) -{ - _mspi = spi; - _algo = algorithm; - _prov = &provider; - _init = false; -} - -Mac::~Mac() -{ - delete _mspi; -} - -Mac* Mac::getInstance(const String& algorithm) throw (NoSuchAlgorithmException) -{ - Security::spi* tmp = Security::getSpi(algorithm, "Mac"); - - Mac* result = new Mac((MacSpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; -} - -Mac* Mac::getInstance(const String& algorithm, const String& provider) throw (NoSuchAlgorithmException, NoSuchProviderException) -{ - Security::spi* tmp = Security::getSpi(algorithm, "Mac", provider); - - Mac* result = new Mac((MacSpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; -} - -Mac* Mac::getInstance(const String& algorithm, const Provider& provider) throw (NoSuchAlgorithmException) -{ - Security::spi* tmp = Security::getSpi(algorithm, "Mac", provider); - - Mac* result = new Mac((MacSpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; -} - -Mac* Mac::clone() const -{ - MacSpi* _mspc = _mspi->clone(); - - if (_mspc) - { - // don't forget to also clone the _init state! - Mac* result = new Mac(_mspc, _algo, *_prov); - result->_init = _init; - return result; - } - else - return 0; -} - -const bytearray& Mac::doFinal() throw (IllegalStateException) -{ - if (!_init) - throw IllegalStateException(); - - return _mspi->engineDoFinal(); -} - -const bytearray& Mac::doFinal(const bytearray& b) throw (IllegalStateException) -{ - if (!_init) - throw IllegalStateException(); - - _mspi->engineUpdate(b.data(), 0, b.size()); - return _mspi->engineDoFinal(); -} - -size_t Mac::doFinal(byte* data, size_t offset, size_t length) throw (IllegalStateException, ShortBufferException) -{ - if (!_init) - throw IllegalStateException(); - - return _mspi->engineDoFinal(data, offset, length); -} - -size_t Mac::getMacLength() -{ - return _mspi->engineGetMacLength(); -} - -void Mac::init(const Key& key) throw (InvalidKeyException) -{ - try - { - _mspi->engineInit(key, 0); - } - catch (InvalidAlgorithmParameterException) - { - throw IllegalArgumentException("Mac apparently requires an AlgorithmParameterSpec"); - } - _init = true; -} - -void Mac::init(const Key& key, const AlgorithmParameterSpec* spec) throw (InvalidKeyException, InvalidAlgorithmParameterException) -{ - _mspi->engineInit(key, spec); - _init = true; -} - -void Mac::reset() -{ - _mspi->engineReset(); -} - -void Mac::update(byte b) throw (IllegalStateException) -{ - if (!_init) - throw IllegalStateException(); - - _mspi->engineUpdate(b); -} - -void Mac::update(const bytearray& b) throw (IllegalStateException) -{ - if (!_init) - throw IllegalStateException(); - - _mspi->engineUpdate(b.data(), 0, b.size()); -} - -void Mac::update(const byte* data, size_t offset, size_t length) throw (IllegalStateException) -{ - if (!_init) - throw IllegalStateException(); - - _mspi->engineUpdate(data, offset, length); -} - -const String& Mac::getAlgorithm() const throw () -{ - return _algo; -} - -const Provider& Mac::getProvider() const throw () -{ - return *_prov; -} diff --git a/beecrypt/c++/crypto/Mac.h b/beecrypt/c++/crypto/Mac.h deleted file mode 100644 index 2d790d2cf..000000000 --- a/beecrypt/c++/crypto/Mac.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file Mac.h - * \ingroup CXX_CRYPTO_m - */ - -#ifndef _CLASS_MAC_H -#define _CLASS_MAC_H - -// #include "beecrypt/beecrypt.api.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/crypto/MacSpi.h" -using beecrypt::crypto::MacSpi; -#include "beecrypt/c++/security/Provider.h" -using beecrypt::security::Provider; -#include "beecrypt/c++/security/NoSuchAlgorithmException.h" -using beecrypt::security::NoSuchAlgorithmException; -#include "beecrypt/c++/security/NoSuchProviderException.h" -using beecrypt::security::NoSuchProviderException; - -namespace beecrypt { - namespace crypto { - class BEECRYPTCXXAPI Mac - { - public: - static Mac* getInstance(const String&) throw (NoSuchAlgorithmException); - static Mac* getInstance(const String&, const String&) throw (NoSuchAlgorithmException, NoSuchProviderException); - static Mac* getInstance(const String&, const Provider&) throw (NoSuchAlgorithmException); - - private: - MacSpi* _mspi; - String _algo; - const Provider* _prov; - bool _init; - - protected: - Mac(MacSpi*, const String&, const Provider&); - - public: - ~Mac(); - - Mac* clone() const; - - const bytearray& doFinal() throw (IllegalStateException); - const bytearray& doFinal(const bytearray&) throw (IllegalStateException); - size_t doFinal(byte* data, size_t offset, size_t length) throw (ShortBufferException, IllegalStateException); - size_t getMacLength(); - void init(const Key&) throw (InvalidKeyException); - void init(const Key&, const AlgorithmParameterSpec*) throw (InvalidKeyException, InvalidAlgorithmParameterException); - void reset(); - void update(byte) throw (IllegalStateException); - void update(const byte* data, size_t offset, size_t length) throw (IllegalStateException); - void update(const bytearray&) throw (IllegalStateException); - - const String& getAlgorithm() const throw (); - const Provider& getProvider() const throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/crypto/MacInputStream.cxx b/beecrypt/c++/crypto/MacInputStream.cxx deleted file mode 100644 index 7d924ecf1..000000000 --- a/beecrypt/c++/crypto/MacInputStream.cxx +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/crypto/MacInputStream.h" -#include "beecrypt/c++/lang/NullPointerException.h" -using beecrypt::lang::NullPointerException; - -using namespace beecrypt::crypto; - -MacInputStream::MacInputStream(InputStream& in, Mac& m) : FilterInputStream(in), mac(m) -{ - _on = true; -} - -MacInputStream::~MacInputStream() -{ -} - -int MacInputStream::read() throw (IOException) -{ - int rc = in.read(); - if (rc >= 0 && _on) - mac.update((byte) rc); - return rc; -} - -int MacInputStream::read(byte *data, size_t offset, size_t length) throw (IOException) -{ - if (!data) - throw NullPointerException(); - - int rc = in.read(data, offset, length); - if (rc >= 0 && _on) - mac.update(data, offset, rc); - return rc; -} - -void MacInputStream::on(bool on) -{ - _on = on; -} - -Mac& MacInputStream::getMac() -{ - return mac; -} - -void MacInputStream::setMac(Mac& m) -{ - mac = m; -} diff --git a/beecrypt/c++/crypto/MacInputStream.h b/beecrypt/c++/crypto/MacInputStream.h deleted file mode 100644 index 0b3700c74..000000000 --- a/beecrypt/c++/crypto/MacInputStream.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file MacInputStream.h - * \ingroup CXX_CRYPTO_m - */ - -#ifndef _CLASS_MACINPUTSTREAM_H -#define _CLASS_MACINPUTSTREAM_H - -#ifdef __cplusplus - -#include "beecrypt/c++/crypto/Mac.h" -using beecrypt::crypto::Mac; -#include "beecrypt/c++/io/FilterInputStream.h" -using beecrypt::io::FilterInputStream; - -namespace beecrypt { - namespace crypto { - class BEECRYPTCXXAPI MacInputStream : public FilterInputStream - { - private: - bool _on; - - protected: - Mac& mac; - - public: - MacInputStream(InputStream&, Mac&); - virtual ~MacInputStream(); - - virtual int read() throw (IOException); - virtual int read(byte* data, size_t offset, size_t length) throw (IOException); - - void on(bool); - - Mac& getMac(); - void setMac(Mac&); - - }; - } -} - -#endif - -#endif - diff --git a/beecrypt/c++/crypto/MacOutputStream.cxx b/beecrypt/c++/crypto/MacOutputStream.cxx deleted file mode 100644 index 976deb8d9..000000000 --- a/beecrypt/c++/crypto/MacOutputStream.cxx +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/crypto/MacOutputStream.h" -#include "beecrypt/c++/lang/NullPointerException.h" -using beecrypt::lang::NullPointerException; - -using namespace beecrypt::crypto; - -MacOutputStream::MacOutputStream(OutputStream& out, Mac& m) : FilterOutputStream(out), mac(m) -{ - _on = true; -} - -MacOutputStream::~MacOutputStream() -{ -} - -void MacOutputStream::write(byte b) throw (IOException) -{ - out.write(b); - if (_on) - mac.update(b); -} - -void MacOutputStream::write(const byte *data, size_t offset, size_t length) throw (IOException) -{ - if (!data) - throw NullPointerException(); - - out.write(data, offset, length); - if (_on) - mac.update(data, offset, length); -} - -void MacOutputStream::on(bool on) -{ - _on = on; -} - -Mac& MacOutputStream::getMac() -{ - return mac; -} - -void MacOutputStream::setMac(Mac& m) -{ - mac = m; -} diff --git a/beecrypt/c++/crypto/MacOutputStream.h b/beecrypt/c++/crypto/MacOutputStream.h deleted file mode 100644 index ff8256314..000000000 --- a/beecrypt/c++/crypto/MacOutputStream.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file MacOutputStream.h - * \ingroup CXX_CRYPTO_m - */ - -#ifndef _CLASS_MACOUTPUTSTREAM_H -#define _CLASS_MACOUTPUTSTREAM_H - -#ifdef __cplusplus - -#include "beecrypt/c++/crypto/Mac.h" -using beecrypt::crypto::Mac; -#include "beecrypt/c++/io/FilterOutputStream.h" -using beecrypt::io::FilterOutputStream; - -namespace beecrypt { - namespace crypto { - class BEECRYPTCXXAPI MacOutputStream : public FilterOutputStream - { - private: - bool _on; - - protected: - Mac& mac; - - public: - MacOutputStream(OutputStream&, Mac&); - virtual ~MacOutputStream(); - - virtual void write(byte) throw (IOException); - virtual void write(const byte* data, size_t offset, size_t length) throw (IOException); - - void on(bool); - - Mac& getMac(); - void setMac(Mac&); - - }; - } -} - -#endif - -#endif - diff --git a/beecrypt/c++/crypto/MacSpi.h b/beecrypt/c++/crypto/MacSpi.h deleted file mode 100644 index b06104d2a..000000000 --- a/beecrypt/c++/crypto/MacSpi.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file MacSpi.h - * \ingroup CXX_CRYPTO_m - */ - -#ifndef _CLASS_MACSPI_H -#define _CLASS_MACSPI_H - -#include "beecrypt/api.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/array.h" -using beecrypt::array; -#include "beecrypt/c++/lang/IllegalStateException.h" -using beecrypt::lang::IllegalStateException; -#include "beecrypt/c++/security/InvalidAlgorithmParameterException.h" -using beecrypt::security::InvalidAlgorithmParameterException; -#include "beecrypt/c++/security/InvalidKeyException.h" -using beecrypt::security::InvalidKeyException; -#include "beecrypt/c++/security/Key.h" -using beecrypt::security::Key; -#include "beecrypt/c++/security/ShortBufferException.h" -using beecrypt::security::ShortBufferException; -#include "beecrypt/c++/security/spec/AlgorithmParameterSpec.h" -using beecrypt::security::spec::AlgorithmParameterSpec; - -namespace beecrypt { - namespace crypto { - class BEECRYPTCXXAPI MacSpi - { - friend class Mac; - - protected: - virtual const bytearray& engineDoFinal() = 0; - virtual size_t engineDoFinal(byte*, size_t, size_t) throw (ShortBufferException) = 0; - virtual size_t engineGetMacLength() = 0; - virtual void engineInit(const Key&, const AlgorithmParameterSpec*) throw (InvalidKeyException, InvalidAlgorithmParameterException) = 0; - virtual void engineReset() = 0; - virtual void engineUpdate(byte) = 0; - virtual void engineUpdate(const byte*, size_t, size_t) = 0; - - public: - virtual ~MacSpi() {}; - - virtual MacSpi* clone() const = 0; - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/crypto/Makefile.am b/beecrypt/c++/crypto/Makefile.am deleted file mode 100644 index 9a9a7863c..000000000 --- a/beecrypt/c++/crypto/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -INCLUDES = -I$(top_srcdir)/.. - -AUTOMAKE_OPTIONS = gnu no-dependencies - -SUBDIRS = interfaces spec - -noinst_LTLIBRARIES = libcxxcrypto.la - -cxxcryptodir=$(pkgincludedir)/c++/crypto - -libcxxcrypto_la_SOURCES = \ -BadPaddingException.cxx \ -Mac.cxx \ -MacInputStream.cxx \ -MacOutputStream.cxx \ -SecretKeyFactory.cxx -libcxxcrypto_la_LIBADD = spec/libcxxcryptospec.la - -cxxcrypto_HEADERS = \ -BadPaddingException.h \ -Mac.h \ -MacInputStream.h \ -MacOutputStream.h \ -MacSpi.h \ -SecretKey.h \ -SecretKeyFactory.h \ -SecretKeyFactorySpi.h diff --git a/beecrypt/c++/crypto/SecretKey.h b/beecrypt/c++/crypto/SecretKey.h deleted file mode 100644 index 07b2f75ef..000000000 --- a/beecrypt/c++/crypto/SecretKey.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file SecretKey.h - * \ingroup CXX_CRYPTO_m - */ - -#ifndef _INTERFACE_SECRETKEY_H -#define _INTERFACE_SECRETKEY_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/Key.h" -using beecrypt::security::Key; - -namespace beecrypt { - namespace crypto { - /*!\brief SecretKey interface - * \ingroup CXX_CRYPTO_m - */ - class BEECRYPTCXXAPI SecretKey : public Key - { - public: - virtual SecretKey* clone() const = 0; - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/crypto/SecretKeyFactory.cxx b/beecrypt/c++/crypto/SecretKeyFactory.cxx deleted file mode 100644 index ff25e8500..000000000 --- a/beecrypt/c++/crypto/SecretKeyFactory.cxx +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/crypto/SecretKeyFactory.h" -#include "beecrypt/c++/security/Security.h" -using beecrypt::security::Security; - -using namespace beecrypt::crypto; - -SecretKeyFactory::SecretKeyFactory(SecretKeyFactorySpi* spi, const String& algorithm, const Provider& provider) -{ - _kspi = spi; - _algo = algorithm; - _prov = &provider; -} - -SecretKeyFactory::~SecretKeyFactory() -{ - delete _kspi; -} - -SecretKeyFactory* SecretKeyFactory::getInstance(const String& algorithm) throw (NoSuchAlgorithmException) -{ - Security::spi* tmp = Security::getSpi(algorithm, "SecretKeyFactory"); - - SecretKeyFactory* result = new SecretKeyFactory((SecretKeyFactorySpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; -} - -SecretKeyFactory* SecretKeyFactory::getInstance(const String& algorithm, const String& provider) throw (NoSuchAlgorithmException, NoSuchProviderException) -{ - Security::spi* tmp = Security::getSpi(algorithm, "SecretKeyFactory", provider); - - SecretKeyFactory* result = new SecretKeyFactory((SecretKeyFactorySpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; -} - -SecretKeyFactory* SecretKeyFactory::getInstance(const String& algorithm, const Provider& provider) throw (NoSuchAlgorithmException) -{ - Security::spi* tmp = Security::getSpi(algorithm, "SecretKeyFactory", provider); - - SecretKeyFactory* result = new SecretKeyFactory((SecretKeyFactorySpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; -} - -SecretKey* SecretKeyFactory::generateSecret(const KeySpec& spec) throw (InvalidKeySpecException) -{ - return _kspi->engineGenerateSecret(spec); -} - -KeySpec* SecretKeyFactory::getKeySpec(const SecretKey& key, const type_info& info) throw (InvalidKeySpecException) -{ - return _kspi->engineGetKeySpec(key, info); -} - -SecretKey* SecretKeyFactory::translateKey(const SecretKey& key) throw (InvalidKeyException) -{ - return _kspi->engineTranslateKey(key); -} - -const String& SecretKeyFactory::getAlgorithm() const throw () -{ - return _algo; -} - -const Provider& SecretKeyFactory::getProvider() const throw () -{ - return *_prov; -} diff --git a/beecrypt/c++/crypto/SecretKeyFactory.h b/beecrypt/c++/crypto/SecretKeyFactory.h deleted file mode 100644 index f2c1a55a4..000000000 --- a/beecrypt/c++/crypto/SecretKeyFactory.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file SecretKeyFactory.h - * \ingroup CXX_CRYPTO_m - */ - -#ifndef _CLASS_SECRETKEYFACTORY_H -#define _CLASS_SECRETKEYFACTORY_H - -// #include "beecrypt/beecrypt.api.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/crypto/SecretKeyFactorySpi.h" -using beecrypt::crypto::SecretKeyFactorySpi; -#include "beecrypt/c++/security/Provider.h" -using beecrypt::security::Provider; -#include "beecrypt/c++/security/NoSuchAlgorithmException.h" -using beecrypt::security::NoSuchAlgorithmException; -#include "beecrypt/c++/security/NoSuchProviderException.h" -using beecrypt::security::NoSuchProviderException; - -#include <typeinfo> -using std::type_info; - -namespace beecrypt { - namespace crypto { - class BEECRYPTCXXAPI SecretKeyFactory - { - public: - static SecretKeyFactory* getInstance(const String&) throw (NoSuchAlgorithmException); - static SecretKeyFactory* getInstance(const String&, const String&) throw (NoSuchAlgorithmException, NoSuchProviderException); - static SecretKeyFactory* getInstance(const String&, const Provider&) throw (NoSuchAlgorithmException); - - private: - SecretKeyFactorySpi* _kspi; - String _algo; - const Provider* _prov; - - protected: - SecretKeyFactory(SecretKeyFactorySpi*, const String&, const Provider&); - - public: - ~SecretKeyFactory(); - - SecretKey* generateSecret(const KeySpec&) throw (InvalidKeySpecException); - - KeySpec* getKeySpec(const SecretKey& key, const type_info&) throw (InvalidKeySpecException); - - SecretKey* translateKey(const SecretKey&) throw (InvalidKeyException); - - const String& getAlgorithm() const throw (); - const Provider& getProvider() const throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/crypto/SecretKeyFactorySpi.h b/beecrypt/c++/crypto/SecretKeyFactorySpi.h deleted file mode 100644 index 023cc082a..000000000 --- a/beecrypt/c++/crypto/SecretKeyFactorySpi.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file SecretKeyFactorySpi.h - * \ingroup CXX_CRYPTO_m - */ - -#ifndef _CLASS_SECRETKEYFACTORYSPI_H -#define _CLASS_SECRETKEYFACTORYSPI_H - -#include "beecrypt/api.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/crypto/SecretKey.h" -using beecrypt::crypto::SecretKey; -#include "beecrypt/c++/security/InvalidKeyException.h" -using beecrypt::security::InvalidKeyException; -#include "beecrypt/c++/security/spec/KeySpec.h" -using beecrypt::security::spec::KeySpec; -#include "beecrypt/c++/security/spec/InvalidKeySpecException.h" -using beecrypt::security::spec::InvalidKeySpecException; - -#include <typeinfo> -using std::type_info; - -namespace beecrypt { - namespace crypto { - class BEECRYPTCXXAPI SecretKeyFactorySpi - { - friend class SecretKeyFactory; - - protected: - virtual SecretKey* engineGenerateSecret(const KeySpec&) throw (InvalidKeySpecException) = 0; - virtual KeySpec* engineGetKeySpec(const SecretKey&, const type_info&) throw (InvalidKeySpecException) = 0; - virtual SecretKey* engineTranslateKey(const SecretKey&) throw (InvalidKeyException) = 0; - - public: - virtual ~SecretKeyFactorySpi() {}; - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/crypto/interfaces/.cvsignore b/beecrypt/c++/crypto/interfaces/.cvsignore deleted file mode 100644 index da7b4816b..000000000 --- a/beecrypt/c++/crypto/interfaces/.cvsignore +++ /dev/null @@ -1,5 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo diff --git a/beecrypt/c++/crypto/interfaces/DHKey.h b/beecrypt/c++/crypto/interfaces/DHKey.h deleted file mode 100644 index 95232498f..000000000 --- a/beecrypt/c++/crypto/interfaces/DHKey.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DHKey.h - * \ingroup CXX_CRYPTO_INTERFACES_m - */ - -#ifndef _INTERFACE_DHKEY_H -#define _INTERFACE_DHKEY_H - -#ifdef __cplusplus - -#include "beecrypt/c++/crypto/interfaces/DHParams.h" -using beecrypt::crypto::interfaces::DHParams; - -namespace beecrypt { - namespace crypto { - namespace interfaces { - /*!\brief Diffie-Hellman key interface. - * \ingroup CXX_IF_m - */ - class DHKey - { - public: - virtual const DHParams& getParams() const throw () = 0; - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/crypto/interfaces/DHParams.h b/beecrypt/c++/crypto/interfaces/DHParams.h deleted file mode 100644 index c6f9e64fd..000000000 --- a/beecrypt/c++/crypto/interfaces/DHParams.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DHParams.h - * \ingroup CXX_CRYPTO_INTERFACES_m - */ - -#ifndef _INTERFACE_DHPARAMS_H -#define _INTERFACE_DHPARAMS_H - -#include "beecrypt/api.h" -#include "beecrypt/mpbarrett.h" - -#ifdef __cplusplus - -namespace beecrypt { - namespace crypto { - namespace interfaces { - class DHParams - { - public: - virtual const mpbarrett& getP() const throw () = 0; - virtual const mpnumber& getG() const throw () = 0; - virtual size_t getL() const throw () = 0; - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/crypto/interfaces/DHPrivateKey.h b/beecrypt/c++/crypto/interfaces/DHPrivateKey.h deleted file mode 100644 index 91e7ab43a..000000000 --- a/beecrypt/c++/crypto/interfaces/DHPrivateKey.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DHPrivateKey.h - * \ingroup CXX_CRYPTO_INTERFACES_m - */ - -#ifndef _INTERFACE_DHPRIVATEKEY_H -#define _INTERFACE_DHPRIVATEKEY_H - -#include "beecrypt/api.h" -#include "beecrypt/dldp.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/security/PrivateKey.h" -using beecrypt::security::PrivateKey; -#include "beecrypt/c++/crypto/interfaces/DHKey.h" -using beecrypt::crypto::interfaces::DHKey; - -namespace beecrypt { - namespace crypto { - namespace interfaces { - /*!\brief Diffie-Hellman PrivateKey interface - * \ingroup CXX_IF_m - */ - class DHPrivateKey : public PrivateKey, public DHKey - { - public: - virtual const mpnumber& getX() const throw () = 0; - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/crypto/interfaces/DHPublicKey.h b/beecrypt/c++/crypto/interfaces/DHPublicKey.h deleted file mode 100644 index c33ee2972..000000000 --- a/beecrypt/c++/crypto/interfaces/DHPublicKey.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DHPublicKey.h - * \ingroup CXX_CRYPTO_INTERFACES_m - */ - -#ifndef _INTERFACE_DHPUBLICKEY_H -#define _INTERFACE_DHPUBLICKEY_H - -#include "beecrypt/api.h" -#include "beecrypt/mpnumber.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/security/PublicKey.h" -using beecrypt::security::PublicKey; -#include "beecrypt/c++/crypto/interfaces/DHKey.h" -using beecrypt::crypto::interfaces::DHKey; - -namespace beecrypt { - namespace crypto { - namespace interfaces { - /*!\brief Diffie-Hellman PublicKey interface - * \ingroup CXX_IF_m - */ - class DHPublicKey : public PublicKey, public DHKey - { - public: - virtual const mpnumber& getY() const throw () = 0; - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/crypto/interfaces/Makefile.am b/beecrypt/c++/crypto/interfaces/Makefile.am deleted file mode 100644 index 41cd5754f..000000000 --- a/beecrypt/c++/crypto/interfaces/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -INCLUDES = -I$(top_srcdir)/.. - -AUTOMAKE_OPTIONS = gnu no-dependencies - -cxxcryptointerfacesdir=$(pkgincludedir)/c++/crypto/interfaces - -cxxcryptointerfaces_HEADERS =\ -DHKey.h \ -DHParams.h \ -DHPrivateKey.h \ -DHPublicKey.h \ -PBEKey.h diff --git a/beecrypt/c++/crypto/interfaces/PBEKey.h b/beecrypt/c++/crypto/interfaces/PBEKey.h deleted file mode 100644 index 11df99d17..000000000 --- a/beecrypt/c++/crypto/interfaces/PBEKey.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file PBEKey.h - * \ingroup CXX_CRYPTO_INTERFACES_m - */ - -#ifndef _INTERFACE_PBEKEY_H -#define _INTERFACE_PBEKEY_H - -#ifdef __cplusplus - -#include "beecrypt/c++/crypto/SecretKey.h" -using beecrypt::crypto::SecretKey; - -namespace beecrypt { - namespace crypto { - namespace interfaces { - /*!\brief PBEKey interface - * \ingroup CXX_CRYPTO_m - */ - class BEECRYPTCXXAPI PBEKey : public SecretKey - { - public: - virtual size_t getIterationCount() const throw () = 0; - virtual const array<javachar>& getPassword() const throw () = 0; - virtual const bytearray* getSalt() const throw () = 0; - - virtual PBEKey* clone() const = 0; - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/crypto/spec/.cvsignore b/beecrypt/c++/crypto/spec/.cvsignore deleted file mode 100644 index da7b4816b..000000000 --- a/beecrypt/c++/crypto/spec/.cvsignore +++ /dev/null @@ -1,5 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo diff --git a/beecrypt/c++/crypto/spec/DHParameterSpec.cxx b/beecrypt/c++/crypto/spec/DHParameterSpec.cxx deleted file mode 100644 index 8f47c1fe5..000000000 --- a/beecrypt/c++/crypto/spec/DHParameterSpec.cxx +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#include "beecrypt/c++/crypto/spec/DHParameterSpec.h" - -using namespace beecrypt::crypto::spec; - -DHParameterSpec::DHParameterSpec(const DHParams& copy) -{ - _p = copy.getP(); - _g = copy.getG(); - _l = copy.getL(); -} - -DHParameterSpec::DHParameterSpec(const mpbarrett& p, const mpnumber& g) -{ - _p = p; - _g = g; - _l = 0; -} - -DHParameterSpec::DHParameterSpec(const mpbarrett& p, const mpnumber& g, size_t l) -{ - _p = p; - _g = g; - _l = l; -} - -DHParameterSpec::~DHParameterSpec() -{ -} - -const mpbarrett& DHParameterSpec::getP() const throw () -{ - return _p; -} - -const mpnumber& DHParameterSpec::getG() const throw () -{ - return _g; -} - -size_t DHParameterSpec::getL() const throw () -{ - return _l; -} diff --git a/beecrypt/c++/crypto/spec/DHParameterSpec.h b/beecrypt/c++/crypto/spec/DHParameterSpec.h deleted file mode 100644 index 5e2bf3f92..000000000 --- a/beecrypt/c++/crypto/spec/DHParameterSpec.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DHParameterSpec.h - * \ingroup CXX_CRYPTO_SPEC_m - */ - -#ifndef _CLASS_DHPARAMETERSPEC_H -#define _CLASS_DHPARAMETERSPEC_H - -#include "beecrypt/api.h" -#include "beecrypt/mpbarrett.h" -#include "beecrypt/dlsvdp-dh.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/crypto/interfaces/DHParams.h" -using beecrypt::crypto::interfaces::DHParams; -#include "beecrypt/c++/security/spec/AlgorithmParameterSpec.h" -using beecrypt::security::spec::AlgorithmParameterSpec; - -namespace beecrypt { - namespace crypto { - namespace spec { - class BEECRYPTCXXAPI DHParameterSpec : public AlgorithmParameterSpec, public DHParams - { - private: - mpbarrett _p; - mpnumber _g; - size_t _l; - - public: - DHParameterSpec(const DHParams&); - DHParameterSpec(const mpbarrett& p, const mpnumber& g); - DHParameterSpec(const mpbarrett& p, const mpnumber& g, size_t l); - virtual ~DHParameterSpec(); - - const mpbarrett& getP() const throw (); - const mpnumber& getG() const throw (); - size_t getL() const throw (); - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/crypto/spec/DHPrivateKeySpec.cxx b/beecrypt/c++/crypto/spec/DHPrivateKeySpec.cxx deleted file mode 100644 index e67530bba..000000000 --- a/beecrypt/c++/crypto/spec/DHPrivateKeySpec.cxx +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#include "beecrypt/c++/crypto/spec/DHPrivateKeySpec.h" - -using namespace beecrypt::crypto::spec; - -DHPrivateKeySpec::DHPrivateKeySpec(const mpbarrett& p, const mpnumber& g, const mpnumber& x) -{ - _p = p; - _g = g; - _x = x; -} - -DHPrivateKeySpec::~DHPrivateKeySpec() -{ - _x.wipe(); -} - -const mpbarrett& DHPrivateKeySpec::getP() const throw () -{ - return _p; -} - -const mpnumber& DHPrivateKeySpec::getG() const throw () -{ - return _g; -} - -const mpnumber& DHPrivateKeySpec::getX() const throw () -{ - return _x; -} diff --git a/beecrypt/c++/crypto/spec/DHPrivateKeySpec.h b/beecrypt/c++/crypto/spec/DHPrivateKeySpec.h deleted file mode 100644 index d4dfefb0b..000000000 --- a/beecrypt/c++/crypto/spec/DHPrivateKeySpec.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DHPrivateKeySpec.h - * \ingroup CXX_CRYPTO_SPEC_m - */ - -#ifndef _CLASS_DHPRIVATEKEYSPEC_H -#define _CLASS_DHPRIVATEKEYSPEC_H - -#include "beecrypt/api.h" -#include "beecrypt/mpbarrett.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/security/spec/KeySpec.h" -using beecrypt::security::spec::KeySpec; - -namespace beecrypt { - namespace crypto { - namespace spec { - class BEECRYPTCXXAPI DHPrivateKeySpec : public KeySpec - { - private: - mpbarrett _p; - mpnumber _g; - mpnumber _x; - - public: - DHPrivateKeySpec(const mpbarrett& p, const mpnumber& g, const mpnumber& x); - virtual ~DHPrivateKeySpec(); - - const mpbarrett& getP() const throw (); - const mpnumber& getG() const throw (); - const mpnumber& getX() const throw (); - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/crypto/spec/DHPublicKeySpec.cxx b/beecrypt/c++/crypto/spec/DHPublicKeySpec.cxx deleted file mode 100644 index 15431cb7d..000000000 --- a/beecrypt/c++/crypto/spec/DHPublicKeySpec.cxx +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#include "beecrypt/c++/crypto/spec/DHPublicKeySpec.h" - -using namespace beecrypt::crypto::spec; - -DHPublicKeySpec::DHPublicKeySpec(const mpbarrett& p, const mpnumber& g, const mpnumber& y) -{ - _p = p; - _g = g; - _y = y; -} - -DHPublicKeySpec::~DHPublicKeySpec() -{ -} - -const mpbarrett& DHPublicKeySpec::getP() const throw () -{ - return _p; -} - -const mpnumber& DHPublicKeySpec::getG() const throw () -{ - return _g; -} - -const mpnumber& DHPublicKeySpec::getY() const throw () -{ - return _y; -} diff --git a/beecrypt/c++/crypto/spec/DHPublicKeySpec.h b/beecrypt/c++/crypto/spec/DHPublicKeySpec.h deleted file mode 100644 index a5a746887..000000000 --- a/beecrypt/c++/crypto/spec/DHPublicKeySpec.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DHPublicKeySpec.h - * \ingroup CXX_CRYPTO_SPEC_m - */ - -#ifndef _CLASS_DHPUBLICKEYSPEC_H -#define _CLASS_DHPUBLICKEYSPEC_H - -#include "beecrypt/api.h" -#include "beecrypt/mpbarrett.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/security/spec/KeySpec.h" -using beecrypt::security::spec::KeySpec; - -namespace beecrypt { - namespace crypto { - namespace spec { - class BEECRYPTCXXAPI DHPublicKeySpec : public KeySpec - { - private: - mpbarrett _p; - mpnumber _g; - mpnumber _y; - - public: - DHPublicKeySpec(const mpbarrett& p, const mpnumber& g, const mpnumber& y); - virtual ~DHPublicKeySpec(); - - const mpbarrett& getP() const throw (); - const mpnumber& getG() const throw (); - const mpnumber& getY() const throw (); - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/crypto/spec/Makefile.am b/beecrypt/c++/crypto/spec/Makefile.am deleted file mode 100644 index 234fecaed..000000000 --- a/beecrypt/c++/crypto/spec/Makefile.am +++ /dev/null @@ -1,19 +0,0 @@ -INCLUDES = -I$(top_srcdir)/.. - -AUTOMAKE_OPTIONS = gnu no-dependencies - -noinst_LTLIBRARIES = libcxxcryptospec.la - -cxxcryptospecdir=$(pkgincludedir)/c++/crypto/spec - -libcxxcryptospec_la_SOURCES =\ -DHParameterSpec.cxx \ -DHPrivateKeySpec.cxx \ -DHPublicKeySpec.cxx \ -PBEKeySpec.cxx - -cxxcryptospec_HEADERS =\ -DHParameterSpec.h \ -DHPrivateKeySpec.h \ -DHPublicKeySpec.h \ -PBEKeySpec.h diff --git a/beecrypt/c++/crypto/spec/PBEKeySpec.cxx b/beecrypt/c++/crypto/spec/PBEKeySpec.cxx deleted file mode 100644 index 38ad49b90..000000000 --- a/beecrypt/c++/crypto/spec/PBEKeySpec.cxx +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/crypto/spec/PBEKeySpec.h" - -using namespace beecrypt::crypto::spec; - -PBEKeySpec::PBEKeySpec(const array<javachar>* password) : _password(password ? *password : 0) -{ - _salt = 0; - _iteration_count = 0; - _key_length = 0; -} - -PBEKeySpec::PBEKeySpec(const array<javachar>* password, const bytearray* salt, size_t iterationCount, size_t keyLength) : _password(password ? *password : 0) -{ - if (salt) - _salt = new bytearray(*salt); - _iteration_count = iterationCount; - _key_length = keyLength; -} - -PBEKeySpec::~PBEKeySpec() -{ -} - -const array<javachar>& PBEKeySpec::getPassword() const throw () -{ - return _password; -} - -const bytearray* PBEKeySpec::getSalt() const throw () -{ - return _salt; -} - -size_t PBEKeySpec::getIterationCount() const throw () -{ - return _iteration_count; -} - -size_t PBEKeySpec::getKeyLength() const throw () -{ - return _key_length; -} diff --git a/beecrypt/c++/crypto/spec/PBEKeySpec.h b/beecrypt/c++/crypto/spec/PBEKeySpec.h deleted file mode 100644 index d4cf14b3f..000000000 --- a/beecrypt/c++/crypto/spec/PBEKeySpec.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file PBEKeySpec.h - * \ingroup CXX_CRYPTO_SPEC_m - */ - -#ifndef _CLASS_PBEKEYSPEC_H -#define _CLASS_PBEKEYSPEC_H - -#ifdef __cplusplus - -#include "beecrypt/c++/array.h" -using beecrypt::array; -using beecrypt::bytearray; -#include "beecrypt/c++/security/spec/KeySpec.h" -using beecrypt::security::spec::KeySpec; - -namespace beecrypt { - namespace crypto { - namespace spec { - class BEECRYPTCXXAPI PBEKeySpec : public KeySpec - { - private: - array<javachar> _password; - bytearray* _salt; - size_t _iteration_count; - size_t _key_length; - - public: - PBEKeySpec(const array<javachar>* password); - PBEKeySpec(const array<javachar>* password, const bytearray* salt, size_t iterationCount, size_t keyLength); - virtual ~PBEKeySpec(); - - const array<javachar>& getPassword() const throw (); - const bytearray* getSalt() const throw (); - size_t getIterationCount() const throw (); - size_t getKeyLength() const throw (); - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/io/.cvsignore b/beecrypt/c++/io/.cvsignore deleted file mode 100644 index da7b4816b..000000000 --- a/beecrypt/c++/io/.cvsignore +++ /dev/null @@ -1,5 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo diff --git a/beecrypt/c++/io/ByteArrayInputStream.cxx b/beecrypt/c++/io/ByteArrayInputStream.cxx deleted file mode 100644 index 415d77eb6..000000000 --- a/beecrypt/c++/io/ByteArrayInputStream.cxx +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/io/ByteArrayInputStream.h" -#include "beecrypt/c++/lang/NullPointerException.h" -using beecrypt::lang::NullPointerException; - -using namespace beecrypt::io; - -ByteArrayInputStream::ByteArrayInputStream(const bytearray& b) : _buf(b) -{ - _lock.init(); - _count = _buf.size(); - _mark = 0; - _pos = 0; -} - -ByteArrayInputStream::ByteArrayInputStream(const byte* data, size_t offset, size_t length) : _buf(data+offset, length) -{ - _lock.init(); - _count = _buf.size(); - _mark = 0; - _pos = 0; -} - -ByteArrayInputStream::~ByteArrayInputStream() -{ - _lock.destroy(); -} - -off_t ByteArrayInputStream::available() throw (IOException) -{ - return (off_t)(_count - _pos); -} - -void ByteArrayInputStream::close() throw (IOException) -{ -} - -void ByteArrayInputStream::mark(off_t readlimit) throw () -{ - _mark = _pos; -} - -bool ByteArrayInputStream::markSupported() throw () -{ - return true; -} - -int ByteArrayInputStream::read() throw (IOException) -{ - register int rc; - _lock.lock(); - rc = (_pos < _count) ? _buf[_pos++] : -1; - _lock.unlock(); - return rc; -} - -int ByteArrayInputStream::read(byte* data, size_t offset, size_t length) throw (IOException) -{ - if (!data) - throw NullPointerException(); - - _lock.lock(); - if (_pos >= _count) - { - _lock.unlock(); - return -1; - } - - if (_pos + length > _count) - length = _count - _pos; - - if (length == 0) - { - _lock.unlock(); - return 0; - } - - memcpy(data+offset, _buf.data()+_pos, length); - _pos += length; - - _lock.unlock(); - - return length; -} - -int ByteArrayInputStream::read(bytearray& b) throw (IOException) -{ - return read(b.data(), 0, b.size()); -} - -void ByteArrayInputStream::reset() throw (IOException) -{ - _lock.lock(); - _pos = _mark; - _lock.unlock(); -} - -off_t ByteArrayInputStream::skip(off_t n) throw (IOException) -{ - _lock.lock(); - if (_pos + n > _count) - n = _count - _pos; - _pos += n; - _lock.unlock(); - return n; -} diff --git a/beecrypt/c++/io/ByteArrayInputStream.h b/beecrypt/c++/io/ByteArrayInputStream.h deleted file mode 100644 index 60c9d5edd..000000000 --- a/beecrypt/c++/io/ByteArrayInputStream.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file ByteArrayInputStream.h - * \ingroup CXX_IO_m - */ - -#ifndef _CLASS_BYTEARRAYINPUTSTREAM_H -#define _CLASS_BYTEARRAYINPUTSTREAM_H - -#ifdef __cplusplus - -#include "beecrypt/c++/array.h" -using beecrypt::bytearray; -#include "beecrypt/c++/mutex.h" -using beecrypt::mutex; -#include "beecrypt/c++/io/InputStream.h" -using beecrypt::io::InputStream; - -namespace beecrypt { - namespace io { - class BEECRYPTCXXAPI ByteArrayInputStream : public InputStream - { - private: - mutex _lock; - - protected: - bytearray _buf; - size_t _count; - size_t _mark; - size_t _pos; - - public: - ByteArrayInputStream(const byte* data, size_t offset, size_t length); - ByteArrayInputStream(const bytearray& b); - virtual ~ByteArrayInputStream(); - - virtual off_t available() throw (IOException); - virtual void close() throw (IOException); - virtual void mark(off_t readlimit) throw (); - virtual bool markSupported() throw (); - virtual int read() throw (IOException); - virtual int read(byte* data, size_t offset, size_t length) throw (IOException); - virtual int read(bytearray&) throw (IOException); - virtual void reset() throw (IOException); - virtual off_t skip(off_t n) throw (IOException); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/io/ByteArrayOutputStream.cxx b/beecrypt/c++/io/ByteArrayOutputStream.cxx deleted file mode 100644 index a45a031aa..000000000 --- a/beecrypt/c++/io/ByteArrayOutputStream.cxx +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/io/ByteArrayOutputStream.h" -#include "beecrypt/c++/lang/NullPointerException.h" -using beecrypt::lang::NullPointerException; - -using namespace beecrypt::io; - -ByteArrayOutputStream::ByteArrayOutputStream() : _buf(32) -{ - _lock.init(); - _count = 0; -} - -ByteArrayOutputStream::ByteArrayOutputStream(size_t size) : _buf(size) -{ - _lock.init(); - _count = 0; -} - -ByteArrayOutputStream::~ByteArrayOutputStream() -{ - _lock.destroy(); -} - -void ByteArrayOutputStream::reset() throw () -{ - _count = 0; -} - -size_t ByteArrayOutputStream::size() throw () -{ - return _count; -} - -bytearray* ByteArrayOutputStream::toByteArray() -{ - bytearray* result = new bytearray(); - - toByteArray(*result); - - return result; -} - -void ByteArrayOutputStream::toByteArray(bytearray& b) -{ - _lock.lock(); - - b.resize(_count); - memcpy(b.data(), _buf.data(), _count); - - _lock.unlock(); -} - -void ByteArrayOutputStream::close() throw (IOException) -{ -} - -void ByteArrayOutputStream::flush() throw (IOException) -{ -} - -void ByteArrayOutputStream::write(byte b) throw (IOException) -{ - _lock.lock(); - - size_t newcount = _count+1; - size_t actualsz = _buf.size(); - - if (actualsz < newcount) - { - if (actualsz == 0) - _buf.resize(32); - else - _buf.resize(actualsz << 1); - } - - _buf[_count++] = b; - - _lock.unlock(); -} - -void ByteArrayOutputStream::write(const byte* data, size_t offset, size_t length) throw (IOException) -{ - if (!data) - throw NullPointerException(); - - _lock.lock(); - - size_t newcount = _count + length; - size_t actualsz = _buf.size(); - - if (newcount > actualsz) - { - _buf.resize(newcount > (actualsz << 1) ? newcount : (actualsz << 1)); - } - memcpy(_buf.data()+_count, data, length); - _count += length; - _lock.unlock(); -} - -void ByteArrayOutputStream::write(const bytearray& b) throw (IOException) -{ - write(b.data(), 0, b.size()); -} diff --git a/beecrypt/c++/io/ByteArrayOutputStream.h b/beecrypt/c++/io/ByteArrayOutputStream.h deleted file mode 100644 index febae874c..000000000 --- a/beecrypt/c++/io/ByteArrayOutputStream.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file ByteArrayOutputStream.h - * \ingroup CXX_IO_m - */ - -#ifndef _CLASS_BYTEARRAYOUTPUTSTREAM_H -#define _CLASS_BYTEARRAYOUTPUTSTREAM_H - -#ifdef __cplusplus - -#include "beecrypt/c++/mutex.h" -using beecrypt::mutex; -#include "beecrypt/c++/io/OutputStream.h" -using beecrypt::io::OutputStream; - -namespace beecrypt { - namespace io { - class BEECRYPTCXXAPI ByteArrayOutputStream : public OutputStream - { - private: - mutex _lock; - - protected: - bytearray _buf; - size_t _count; - - public: - ByteArrayOutputStream(); - ByteArrayOutputStream(size_t); - virtual ~ByteArrayOutputStream(); - - void reset() throw (); - size_t size() throw (); - bytearray* toByteArray(); - void toByteArray(bytearray&); - void writeTo(OutputStream& out) throw (IOException); - - virtual void close() throw (IOException); - virtual void flush() throw (IOException); - virtual void write(byte b) throw (IOException); - virtual void write(const byte* data, size_t offset, size_t length) throw (IOException); - virtual void write(const bytearray& b) throw (IOException); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/io/DataInput.h b/beecrypt/c++/io/DataInput.h deleted file mode 100644 index ce1d5d1c0..000000000 --- a/beecrypt/c++/io/DataInput.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DataInput.h - * \ingroup CXX_IO_m - */ - -#ifndef _INTERFACE_DATAINPUT_H -#define _INTERFACE_DATAINPUT_H - -#ifdef __cplusplus - -#include "beecrypt/c++/array.h" -using beecrypt::bytearray; -#include "beecrypt/c++/io/IOException.h" -using beecrypt::io::IOException; - -namespace beecrypt { - namespace io { - class DataInput - { - public: - virtual bool readBoolean() throw (IOException) = 0; - virtual javabyte readByte() throw (IOException) = 0; - virtual javachar readChar() throw (IOException) = 0; - virtual void readFully(byte*, size_t, size_t) = 0; - virtual void readFully(bytearray&) = 0; - virtual javaint readInt() throw (IOException) = 0; - virtual String* readLine() throw (IOException) = 0; - virtual void readLine(String&) throw (IOException) = 0; - virtual javalong readLong() throw (IOException) = 0; - virtual javashort readShort() throw (IOException) = 0; - virtual int readUnsignedByte() throw (IOException) = 0; - virtual int readUnsignedShort() throw (IOException) = 0; - virtual String* readUTF() throw (IOException) = 0; - virtual void readUTF(String&) throw (IOException) = 0; - virtual off_t skipBytes(off_t n) throw (IOException) = 0; - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/io/DataInputStream.cxx b/beecrypt/c++/io/DataInputStream.cxx deleted file mode 100644 index 54ae57b12..000000000 --- a/beecrypt/c++/io/DataInputStream.cxx +++ /dev/null @@ -1,370 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/io/DataInputStream.h" -#include "beecrypt/c++/io/EOFException.h" -#include "beecrypt/c++/io/PushbackInputStream.h" -#include "beecrypt/c++/lang/NullPointerException.h" -using beecrypt::lang::NullPointerException; - -#define MAX_BYTES_PER_CHARACTER 8 - -using namespace beecrypt::io; - -DataInputStream::DataInputStream(InputStream& in) : FilterInputStream(in) -{ - _pin = ∈ - _del = false; - _utf = 0; - _loc = 0; -} - -DataInputStream::~DataInputStream() -{ - if (_utf) - { - ucnv_close(_utf); - _utf = 0; - } - - if (_loc) - { - ucnv_close(_loc); - _loc = 0; - } - - if (_del) - { - delete _pin; - _pin = 0; - } -} - -bool DataInputStream::readBoolean() throw (IOException) -{ - register int b = _pin->read(); - - if (b < 0) - throw EOFException(); - - return (b != 0); -} - -javabyte DataInputStream::readByte() throw (IOException) -{ - register int b = _pin->read(); - - if (b < 0) - throw EOFException(); - - return static_cast<javabyte>(b); -} - -int DataInputStream::readUnsignedByte() throw (IOException) -{ - register int b = _pin->read(); - - if (b < 0) - throw EOFException(); - - return b; -} - -javashort DataInputStream::readShort() throw (IOException) -{ - register javashort tmp = 0; - register int rc; - - for (register unsigned i = 0; i < 2; i++) - { - if ((rc = _pin->read()) < 0) - throw EOFException(); - - tmp = (tmp << 8) + rc; - } - - return tmp; -} - -int DataInputStream::readUnsignedShort() throw (IOException) -{ - register int tmp = 0, rc; - - for (register unsigned i = 0; i < 2; i++) - { - if ((rc = _pin->read()) < 0) - throw EOFException(); - - tmp = (tmp << 8) + rc; - } - - return tmp; -} - -javachar DataInputStream::readChar() throw (IOException) -{ - register javachar tmp = 0; - register int rc; - - for (register unsigned i = 0; i < 2; i++) - { - if ((rc = _pin->read()) < 0) - throw EOFException(); - - tmp = (tmp << 8) + rc; - } - - return tmp; -} - -javaint DataInputStream::readInt() throw (IOException) -{ - register javaint tmp = 0; - register int rc; - - for (register unsigned i = 0; i < 4; i++) - { - if ((rc = _pin->read()) < 0) - throw EOFException(); - - tmp = (tmp << 8) + rc; - } - - return tmp; -} - -javalong DataInputStream::readLong() throw (IOException) -{ - register javalong tmp = 0; - register int rc; - - for (register unsigned i = 0; i < 8; i++) - { - if ((rc = _pin->read()) < 0) - throw EOFException(); - - tmp = (tmp << 8) + rc; - } - - return tmp; -} - -void DataInputStream::readUTF(String& str) throw (IOException) -{ - UErrorCode status = U_ZERO_ERROR; - - if (!_utf) - { - // UTF-8 converter lazy initialization - _utf = ucnv_open("UTF-8", &status); - if (U_FAILURE(status)) - throw IOException("unable to open ICU UTF-8 converter"); - } - - int utflen = readUnsignedShort(); - - if (utflen > 0) - { - byte* data = new byte[utflen]; - - readFully(data, 0, utflen); - - status = U_ZERO_ERROR; - size_t ulen = ucnv_toUChars(_utf, 0, 0, (const char*) data, (size_t) utflen, &status); - if (status != U_BUFFER_OVERFLOW_ERROR) - { - delete[] data; - throw "error in ucnv_toUChars"; - } - - UChar* buffer = str.getBuffer(ulen+1); - - if (buffer) - { - status = U_ZERO_ERROR; - ucnv_toUChars(_utf, buffer, ulen+1, (const char*) data, (size_t) utflen, &status); - - delete[] data; - - if (status != U_ZERO_ERROR) - throw "error in ucnv_toUChars"; - - str.releaseBuffer(ulen); - } - else - { - delete[] data; - throw "error in String::getBuffer(size_t)"; - } - } -} - -String* DataInputStream::readUTF() throw (IOException) -{ - String* str = new String(); - - try - { - readUTF(*str); - } - catch (IOException ex) - { - /* cleanup str */ - delete str; - /* re-throw exception */ - throw ex; - } - return str; -} - -String* DataInputStream::readLine() throw (IOException) -{ - String* result = new String(); - - readLine(*result); - - return result; -} - -void DataInputStream::readLine(String& line) throw (IOException) -{ - UErrorCode status = U_ZERO_ERROR; - - if (!_loc) - { - // default locale converter lazy initialization - _loc = ucnv_open(0, &status); - if (U_FAILURE(status)) - throw IOException("unable to open ICU default locale converter"); - } - - UChar target_buffer[1]; - UChar* target = target_buffer; - const UChar* target_limit = target_buffer+1; - char source_buffer[MAX_BYTES_PER_CHARACTER]; - const char* source = source_buffer; - char* source_limit = source_buffer; - - bool cr = false; - - int ch; - - // clear the line - line.remove(); - - do - { - ch = _pin->read(); - - if (ch >= 0) - { - if ((source_limit-source_buffer) == MAX_BYTES_PER_CHARACTER) - throw IOException("fubar in readLine"); - - *(source_limit++) = (byte) ch; - } - - status = U_ZERO_ERROR; - // use the default locale converter; flush if ch == -1 - ucnv_toUnicode(_loc, &target, target_limit, &source, source_limit, NULL, (UBool) (ch == -1), &status); - - if (U_FAILURE(status)) - throw IOException("error in ucnv_toUnicode"); - - if (target == target_limit) - { - // we got a whole character from the converter - if (cr) - { - // last character read was ASCII <CR>; is this one a <LF>? - if (target_buffer[0] != 0x0A) - { - // unread the right number of bytes - PushbackInputStream* p = dynamic_cast<PushbackInputStream*>(_pin); - if (p) - p->unread((const byte*) source_buffer, 0, source-source_buffer); - else - throw IOException("fubar in dynamic_cast"); - } - // we're now officially at the end of the line - break; - } - - // did we get an ASCII <LF>? - if (target_buffer[0] == 0x0A) - break; - - // did we get an ASCII <CR>? - if (target_buffer[0] == 0x0D) - { - cr = true; - - // the next character may be a <LF> but if not we'll have to 'unread' it - if (!_del) - { - // lazy push - _pin = new PushbackInputStream(in, MAX_BYTES_PER_CHARACTER); - _del = true; - } - } - else - { - // append character to string and reset pointers - source = source_limit = source_buffer; - line.append(*(target = target_buffer)); - } - } - } while (ch >= 0); -} - -void DataInputStream::readFully(byte* data, size_t offset, size_t length) throw (IOException) -{ - if (!data) - throw NullPointerException(); - - size_t total = 0; - - while (total < length) - { - int rc = _pin->read(data, offset+total, length-total); - if (rc < 0) - throw EOFException(); - total += rc; - } -} - -void DataInputStream::readFully(bytearray& b) throw (IOException) -{ - readFully(b.data(), 0, b.size()); -} - -off_t DataInputStream::skipBytes(off_t n) throw (IOException) -{ - off_t total = 0, rc; - - while ((total < n) && ((rc = _pin->skip(n - total)) > 0)) - total += rc; - - return total; -} diff --git a/beecrypt/c++/io/DataInputStream.h b/beecrypt/c++/io/DataInputStream.h deleted file mode 100644 index 2dd4c01e6..000000000 --- a/beecrypt/c++/io/DataInputStream.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DataInputStream.h - * \ingroup CXX_IO_m - */ - -#ifndef _CLASS_DATAINPUTSTREAM_H -#define _CLASS_DATAINPUTSTREAM_H - -#ifdef __cplusplus - -#include "beecrypt/c++/io/DataInput.h" -using beecrypt::io::DataInput; -#include "beecrypt/c++/io/FilterInputStream.h" -using beecrypt::io::FilterInputStream; - -#include <unicode/ucnv.h> - -namespace beecrypt { - namespace io { - class BEECRYPTCXXAPI DataInputStream : public FilterInputStream, public DataInput - { - private: - bool _del; - InputStream* _pin; - UConverter* _utf; - UConverter* _loc; - - public: - DataInputStream(InputStream& in); - virtual ~DataInputStream(); - - virtual bool readBoolean() throw (IOException); - virtual javabyte readByte() throw (IOException); - virtual javachar readChar() throw (IOException); - virtual void readFully(byte* data, size_t offset, size_t length) throw (IOException); - virtual void readFully(bytearray& b) throw (IOException); - virtual javaint readInt() throw (IOException); - virtual String* readLine() throw (IOException); - virtual void readLine(String&) throw (IOException); - virtual javalong readLong() throw (IOException); - virtual javashort readShort() throw (IOException); - virtual int readUnsignedByte() throw (IOException); - virtual int readUnsignedShort() throw (IOException); - virtual String* readUTF() throw (IOException); - virtual void readUTF(String&) throw (IOException); - virtual off_t skipBytes(off_t n) throw (IOException); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/io/DataOutput.h b/beecrypt/c++/io/DataOutput.h deleted file mode 100644 index 2962a6133..000000000 --- a/beecrypt/c++/io/DataOutput.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DataOutput.h - * \ingroup CXX_IO_m - */ - -#ifndef _INTERFACE_DATAOUTPUT_H -#define _INTERFACE_DATAOUTPUT_H - -#ifdef __cplusplus - -#include "beecrypt/c++/array.h" -using beecrypt::bytearray; -#include "beecrypt/c++/io/IOException.h" -using beecrypt::io::IOException; - -namespace beecrypt { - namespace io { - class DataOutput - { - public: - virtual void write(const bytearray&) throw (IOException) = 0; - virtual void write(const byte*, size_t, size_t) throw (IOException) = 0; - virtual void write(byte) throw (IOException) = 0; - virtual void writeBoolean(bool) throw (IOException) = 0; - virtual void writeByte(byte) throw (IOException) = 0; - virtual void writeChars(const String&) throw (IOException) = 0; - virtual void writeInt(javaint) throw (IOException) = 0; - virtual void writeLong(javalong) throw (IOException) = 0; - virtual void writeShort(javashort) throw (IOException) = 0; - virtual void writeUTF(const String&) throw (IOException) = 0; - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/io/DataOutputStream.cxx b/beecrypt/c++/io/DataOutputStream.cxx deleted file mode 100644 index c8f544513..000000000 --- a/beecrypt/c++/io/DataOutputStream.cxx +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/io/DataOutputStream.h" - -using namespace beecrypt::io; - -DataOutputStream::DataOutputStream(OutputStream& out) : FilterOutputStream(out) -{ - _lock.init(); - _utf = 0; - written = 0; -} - -DataOutputStream::~DataOutputStream() -{ - _lock.destroy(); - if (_utf) - ucnv_close(_utf); -} - -size_t DataOutputStream::size() const throw () -{ - return written; -} - -void DataOutputStream::write(byte b) throw (IOException) -{ - _lock.lock(); - out.write(b); - written++; - _lock.unlock(); -} - -void DataOutputStream::write(const byte* data, size_t offset, size_t len) throw (IOException) -{ - _lock.lock(); - out.write(data, offset, len); - written += len; - _lock.unlock(); -} - -void DataOutputStream::write(const bytearray& b) throw (IOException) -{ - write(b.data(), 0, b.size()); -} - -void DataOutputStream::writeBoolean(bool b) throw (IOException) -{ - _lock.lock(); - out.write(b ? 1 : 0); - written++; - _lock.unlock(); -} - -void DataOutputStream::writeByte(byte b) throw (IOException) -{ - _lock.lock(); - out.write(b); - written++; - _lock.unlock(); -} - -void DataOutputStream::writeShort(javashort s) throw (IOException) -{ - _lock.lock(); - out.write((s >> 8) ); - out.write((s ) & 0xff); - written += 2; - _lock.unlock(); -} - -void DataOutputStream::writeInt(javaint i) throw (IOException) -{ - _lock.lock(); - out.write((i >> 24) ); - out.write((i >> 16) & 0xff); - out.write((i >> 8) & 0xff); - out.write((i ) & 0xff); - written += 4; - _lock.unlock(); -} - -void DataOutputStream::writeLong(javalong l) throw (IOException) -{ - _lock.lock(); - out.write((l >> 56) ); - out.write((l >> 48) & 0xff); - out.write((l >> 40) & 0xff); - out.write((l >> 32) & 0xff); - out.write((l >> 24) & 0xff); - out.write((l >> 16) & 0xff); - out.write((l >> 8) & 0xff); - out.write((l ) & 0xff); - written += 8; - _lock.unlock(); -} - -void DataOutputStream::writeChars(const String& str) throw (IOException) -{ - const UChar* buffer = str.getBuffer(); - size_t len = str.length(); - - _lock.lock(); - for (size_t i = 0; i < len; i++) - { - out.write((buffer[i] >> 8) & 0xff); - out.write((buffer[i] ) & 0xff); - } - written += (len << 1); - _lock.unlock(); -} - -void DataOutputStream::writeUTF(const String& str) throw (IOException) -{ - UErrorCode status = U_ZERO_ERROR; - - if (!_utf) - { - // UTF-8 converter lazy initialization - _utf = ucnv_open("UTF-8", &status); - if (U_FAILURE(status)) - throw IOException("unable to open ICU UTF-8 converter"); - } - - // the expected status code here is U_BUFFER_OVERFLOW_ERROR - size_t need = ucnv_fromUChars(_utf, 0, 0, str.getBuffer(), str.length(), &status); - if (U_FAILURE(status)) - if (status != U_BUFFER_OVERFLOW_ERROR) - throw IOException("unexpected error in ucnv_fromUChars"); - - if (need > 0xffff) - throw IOException("String length >= 64K"); - - byte* buffer = new byte[need]; - - status = U_ZERO_ERROR; - - // the expected status code here is U_STRING_NOT_TERMINATED_WARNING - ucnv_fromUChars(_utf, (char*) buffer, need, str.getBuffer(), str.length(), &status); - if (status != U_STRING_NOT_TERMINATED_WARNING) - { - delete[] buffer; - throw IOException("error in ucnv_fromUChars"); - } - - // everything ready for the critical section - _lock.lock(); - try - { - out.write((need >> 8) & 0xff); - out.write((need ) & 0xff); - out.write(buffer, 0, need); - written += 2 + need; - _lock.unlock(); - - delete[] buffer; - } - catch (IOException) - { - _lock.unlock(); - delete[] buffer; - throw; - } -} diff --git a/beecrypt/c++/io/DataOutputStream.h b/beecrypt/c++/io/DataOutputStream.h deleted file mode 100644 index ae09080ab..000000000 --- a/beecrypt/c++/io/DataOutputStream.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DataOutputStream.h - * \ingroup CXX_IO_m - */ - -#ifndef _CLASS_DATAOUTPUTSTREAM_H -#define _CLASS_DATAOUTPUTSTREAM_H - -#ifdef __cplusplus - -#include "beecrypt/c++/mutex.h" -using beecrypt::mutex; -#include "beecrypt/c++/io/DataOutput.h" -using beecrypt::io::DataOutput; -#include "beecrypt/c++/io/FilterOutputStream.h" -using beecrypt::io::FilterOutputStream; - -#include <unicode/ucnv.h> - -namespace beecrypt { - namespace io { - class BEECRYPTCXXAPI DataOutputStream : public FilterOutputStream, public DataOutput - { - private: - mutex _lock; - UConverter* _utf; - - protected: - size_t written; - - public: - DataOutputStream(OutputStream& out); - virtual ~DataOutputStream(); - - size_t size() const throw (); - - virtual void write(byte) throw (IOException); - virtual void write(const byte* data, size_t offset, size_t length) throw (IOException); - virtual void write(const bytearray&) throw (IOException); - virtual void writeBoolean(bool) throw (IOException); - virtual void writeByte(byte) throw (IOException); - virtual void writeChars(const String&) throw (IOException); - virtual void writeInt(javaint) throw (IOException); - virtual void writeLong(javalong) throw (IOException); - virtual void writeShort(javashort) throw (IOException); - virtual void writeUTF(const String&) throw (IOException); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/io/EOFException.cxx b/beecrypt/c++/io/EOFException.cxx deleted file mode 100644 index 049881020..000000000 --- a/beecrypt/c++/io/EOFException.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/io/EOFException.h" - -using namespace beecrypt::io; - -EOFException::EOFException() throw () -{ -} - -EOFException::EOFException(const String& message) throw () : IOException(message) -{ -} diff --git a/beecrypt/c++/io/EOFException.h b/beecrypt/c++/io/EOFException.h deleted file mode 100644 index ceb550899..000000000 --- a/beecrypt/c++/io/EOFException.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file EOFException.h - * \ingroup CXX_IO_m - */ - -#ifndef _CLASS_EOFEXCEPTION_H -#define _CLASS_EOFEXCEPTION_H - -#ifdef __cplusplus - -#include "beecrypt/c++/io/IOException.h" -using beecrypt::io::IOException; - -namespace beecrypt { - namespace io { - class BEECRYPTCXXAPI EOFException : public IOException - { - public: - EOFException() throw (); - EOFException(const String&) throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/io/FileInputStream.cxx b/beecrypt/c++/io/FileInputStream.cxx deleted file mode 100644 index 49c096b57..000000000 --- a/beecrypt/c++/io/FileInputStream.cxx +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#if HAVE_ERRNO_H -# include <errno.h> -#endif - -#include "beecrypt/c++/io/FileInputStream.h" -#include "beecrypt/c++/lang/NullPointerException.h" -using beecrypt::lang::NullPointerException; - -using namespace beecrypt::io; - -FileInputStream::FileInputStream(FILE* f) -{ - _f = f; - _mark = -1; -} - -FileInputStream::~FileInputStream() -{ -} - -off_t FileInputStream::available() throw (IOException) -{ - if (!_f) - throw IOException("not a valid file handle"); - - long _curr, _size; - - if ((_curr = ftell(_f)) == -1) - #if HAVE_ERRNO_H - throw IOException(strerror(errno)); - #else - throw IOException("ftell failed"); - #endif - - if (fseek(_f, 0, SEEK_END)) - #if HAVE_ERRNO_H - throw IOException(strerror(errno)); - #else - throw IOException("fseek failed"); - #endif - - if ((_size = ftell(_f)) == -1) - #if HAVE_ERRNO_H - throw IOException(strerror(errno)); - #else - throw IOException("ftell failed"); - #endif - - if (fseek(_f, _curr, SEEK_SET)) - #if HAVE_ERRNO_H - throw IOException(strerror(errno)); - #else - throw IOException("fseek failed"); - #endif - - return (off_t) (_size - _curr); -} - -void FileInputStream::close() throw (IOException) -{ - if (_f) - { - if (fclose(_f)) - #if HAVE_ERRNO_H - throw IOException(strerror(errno)); - #else - throw IOException("fclose failed"); - #endif - - _f = 0; - } -} - -void FileInputStream::mark(off_t readlimit) throw () -{ - if (_f) - _mark = ftell(_f); -} - -bool FileInputStream::markSupported() throw () -{ - return true; -} - -int FileInputStream::read() throw (IOException) -{ - if (!_f) - throw IOException("not a valid file handle"); - - return fgetc(_f); -} - -int FileInputStream::read(byte* data, size_t offset, size_t length) throw (IOException) -{ - if (!_f) - throw IOException("not a valid file handle"); - - if (!data) - throw NullPointerException(); - - size_t rc = fread(data+offset, 1, length, _f); - - if (rc == 0) - return -1; - - return rc; -} - -int FileInputStream::read(bytearray& b) throw (IOException) -{ - return read(b.data(), 0, b.size()); -} - -void FileInputStream::reset() throw (IOException) -{ - if (!_f) - throw IOException("not a valid file handle"); - - if (_mark < 0) - throw IOException("not a valid mark"); - - if (fseek(_f, _mark, SEEK_SET)) - #if HAVE_ERRNO_H - throw IOException(strerror(errno)); - #else - throw IOException("fseek failed"); - #endif -} - -off_t FileInputStream::skip(off_t n) throw (IOException) -{ - if (!_f) - throw IOException("not a valid file handle"); - - off_t _avail = available(); - - if (n > _avail) - n = _avail; - - if (fseek(_f, (long) n, SEEK_CUR)) - #if HAVE_ERRNO_H - throw IOException(strerror(errno)); - #else - throw IOException("fseek failed"); - #endif - - return n; -} diff --git a/beecrypt/c++/io/FileInputStream.h b/beecrypt/c++/io/FileInputStream.h deleted file mode 100644 index 1f14a8fc5..000000000 --- a/beecrypt/c++/io/FileInputStream.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file FileInputStream.h - * \ingroup CXX_IO_m - */ - -#ifndef _CLASS_FILEINPUTSTREAM_H -#define _CLASS_FILEINPUTSTREAM_H - -#include <stdio.h> - -#ifdef __cplusplus - -#include "beecrypt/c++/io/InputStream.h" -using beecrypt::io::InputStream; - -namespace beecrypt { - namespace io { - class BEECRYPTCXXAPI FileInputStream : public InputStream - { - private: - FILE* _f; - long _mark; - - public: - FileInputStream(FILE* f); - virtual ~FileInputStream(); - - virtual off_t available() throw (IOException); - virtual void close() throw (IOException); - virtual void mark(off_t readlimit) throw (); - virtual bool markSupported() throw (); - virtual int read() throw (IOException); - virtual int read(byte* data, size_t offset, size_t length) throw (IOException); - virtual int read(bytearray&) throw (IOException); - virtual void reset() throw (IOException); - virtual off_t skip(off_t n) throw (IOException); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/io/FileOutputStream.cxx b/beecrypt/c++/io/FileOutputStream.cxx deleted file mode 100644 index 8f6d19de8..000000000 --- a/beecrypt/c++/io/FileOutputStream.cxx +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#if HAVE_ERRNO_H -# include <errno.h> -#endif - -#include "beecrypt/c++/io/FileOutputStream.h" -#include "beecrypt/c++/lang/NullPointerException.h" -using beecrypt::lang::NullPointerException; - -using namespace beecrypt::io; - -FileOutputStream::FileOutputStream(FILE *f) -{ - _f = f; -} - -FileOutputStream::~FileOutputStream() -{ -} - -void FileOutputStream::close() throw (IOException) -{ - if (_f) - { - if (fclose(_f)) - #if HAVE_ERRNO_H - throw IOException(strerror(errno)); - #else - throw IOException("fclose failed"); - #endif - - _f = 0; - } -} - -void FileOutputStream::flush() throw (IOException) -{ - if (!_f) - throw IOException("no valid file handle to flush"); - - if (fflush(_f)) - #if HAVE_ERRNO_H - throw IOException(strerror(errno)); - #else - throw IOException("fflush failed"); - #endif -} - -void FileOutputStream::write(byte b) throw (IOException) -{ - if (!_f) - throw IOException("no valid file handle to write"); - - size_t rc = fwrite(&b, 1, 1, _f); - - if (rc < 1) - #if HAVE_ERRNO_H - throw IOException(strerror(errno)); - #else - throw IOException("incomplete fwrite"); - #endif -} - -void FileOutputStream::write(const byte* data, size_t offset, size_t length) throw (IOException) -{ - if (!data) - throw NullPointerException(); - - if (!_f) - throw IOException("no valid file handle to write"); - - size_t rc = fwrite(data+offset, 1, length, _f); - - if (rc < length) - #if HAVE_ERRNO_H - throw IOException(strerror(errno)); - #else - throw IOException("incomplete fwrite"); - #endif -} - -void FileOutputStream::write(const bytearray& b) throw (IOException) -{ - write(b.data(), 0, b.size()); -} diff --git a/beecrypt/c++/io/FileOutputStream.h b/beecrypt/c++/io/FileOutputStream.h deleted file mode 100644 index 6afa4f395..000000000 --- a/beecrypt/c++/io/FileOutputStream.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file FileOutputStream.h - * \ingroup CXX_IO_m - */ - -#ifndef _CLASS_FILEOUTPUTSTREAM_H -#define _CLASS_FILEOUTPUTSTREAM_H - -#ifdef __cplusplus - -#include "beecrypt/c++/io/OutputStream.h" -using beecrypt::io::OutputStream; - -namespace beecrypt { - namespace io { - class BEECRYPTCXXAPI FileOutputStream : public OutputStream - { - private: - FILE* _f; - - public: - FileOutputStream(FILE* f); - virtual ~FileOutputStream(); - - virtual void close() throw (IOException); - virtual void flush() throw (IOException); - virtual void write(byte b) throw (IOException); - virtual void write(const byte* data, size_t offset, size_t length) throw (IOException); - virtual void write(const bytearray&) throw (IOException); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/io/FilterInputStream.cxx b/beecrypt/c++/io/FilterInputStream.cxx deleted file mode 100644 index a04952628..000000000 --- a/beecrypt/c++/io/FilterInputStream.cxx +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/io/FilterInputStream.h" - -using namespace beecrypt::io; - -FilterInputStream::FilterInputStream(InputStream& in) : in(in) -{ - _lock.init(); -} - -FilterInputStream::~FilterInputStream() -{ - _lock.destroy(); -} - -off_t FilterInputStream::available() throw (IOException) -{ - return in.available(); -} - -void FilterInputStream::close() throw (IOException) -{ - in.close(); -} - -void FilterInputStream::mark(off_t readlimit) throw () -{ - _lock.lock(); - in.mark(readlimit); - _lock.unlock(); -} - -bool FilterInputStream::markSupported() throw () -{ - return in.markSupported(); -} - -int FilterInputStream::read() throw (IOException) -{ - return in.read(); -} - -int FilterInputStream::read(byte* data, size_t offset, size_t len) throw (IOException) -{ - return in.read(data, offset, len); -} - -int FilterInputStream::read(bytearray& b) throw (IOException) -{ - return in.read(b); -} - -void FilterInputStream::reset() throw (IOException) -{ - _lock.lock(); - in.reset(); - _lock.unlock(); -} - -off_t FilterInputStream::skip(off_t n) throw (IOException) -{ - return in.skip(n); -} diff --git a/beecrypt/c++/io/FilterInputStream.h b/beecrypt/c++/io/FilterInputStream.h deleted file mode 100644 index 31323776e..000000000 --- a/beecrypt/c++/io/FilterInputStream.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file FilterInputStream.h - * \ingroup CXX_IO_m - */ - -#ifndef _CLASS_FILTERINPUTSTREAM_H -#define _CLASS_FILTERINPUTSTREAM_H - -#ifdef __cplusplus - -#include "beecrypt/c++/mutex.h" -using beecrypt::mutex; -#include "beecrypt/c++/io/InputStream.h" -using beecrypt::io::InputStream; - -namespace beecrypt { - namespace io { - class BEECRYPTCXXAPI FilterInputStream : public InputStream - { - private: - mutex _lock; - - protected: - InputStream& in; - - public: - FilterInputStream(InputStream& in); - virtual ~FilterInputStream(); - - virtual off_t available() throw (IOException); - virtual void close() throw (IOException); - virtual void mark(off_t) throw (); - virtual bool markSupported() throw (); - virtual int read() throw (IOException); - virtual int read(byte* data, size_t offset, size_t length) throw (IOException); - virtual int read(bytearray& b) throw (IOException); - virtual void reset() throw (IOException); - virtual off_t skip(off_t) throw (IOException); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/io/FilterOutputStream.cxx b/beecrypt/c++/io/FilterOutputStream.cxx deleted file mode 100644 index 6131fe02c..000000000 --- a/beecrypt/c++/io/FilterOutputStream.cxx +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/io/FilterOutputStream.h" - -using namespace beecrypt::io; - -FilterOutputStream::FilterOutputStream(OutputStream& out) : out(out) -{ -} - -FilterOutputStream::~FilterOutputStream() -{ -} - -void FilterOutputStream::close() throw (IOException) -{ - try - { - flush(); - } - catch (IOException) - { - // ignore - } - out.close(); -} - -void FilterOutputStream::flush() throw (IOException) -{ - out.flush(); -} - -void FilterOutputStream::write(byte b) throw (IOException) -{ - out.write(b); -} - -void FilterOutputStream::write(const byte* data, size_t offset, size_t len) throw (IOException) -{ - out.write(data, offset, len); -} - -void FilterOutputStream::write(const bytearray& b) throw (IOException) -{ - out.write(b.data(), 0, b.size()); -} diff --git a/beecrypt/c++/io/FilterOutputStream.h b/beecrypt/c++/io/FilterOutputStream.h deleted file mode 100644 index bb76ce517..000000000 --- a/beecrypt/c++/io/FilterOutputStream.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file FilterOutputStream.h - * \ingroup CXX_IO_m - */ - -#ifndef _CLASS_FILTEROUTPUTSTREAM_H -#define _CLASS_FILTEROUTPUTSTREAM_H - -#ifdef __cplusplus - -#include "beecrypt/c++/io/OutputStream.h" -using beecrypt::io::OutputStream; - -namespace beecrypt { - namespace io { - class BEECRYPTCXXAPI FilterOutputStream : public OutputStream - { - protected: - OutputStream& out; - - public: - FilterOutputStream(OutputStream& out); - virtual ~FilterOutputStream(); - - virtual void close() throw (IOException); - virtual void flush() throw (IOException); - virtual void write(byte b) throw (IOException); - virtual void write(const byte* data, size_t offset, size_t length) throw (IOException); - virtual void write(const bytearray&) throw (IOException); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/io/IOException.cxx b/beecrypt/c++/io/IOException.cxx deleted file mode 100644 index 3cf3994e5..000000000 --- a/beecrypt/c++/io/IOException.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/io/IOException.h" - -using namespace beecrypt::io; - -IOException::IOException() -{ -} - -IOException::IOException(const String& message) : Exception(message) -{ -} diff --git a/beecrypt/c++/io/IOException.h b/beecrypt/c++/io/IOException.h deleted file mode 100644 index 69f9012ba..000000000 --- a/beecrypt/c++/io/IOException.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file IOException.h - * \ingroup CXX_IO_m - */ - -#ifndef _CLASS_IOEXCEPTION_H -#define _CLASS_IOEXCEPTION_H - -#ifdef __cplusplus - -#include "beecrypt/c++/lang/Exception.h" -using beecrypt::lang::Exception; - -namespace beecrypt { - namespace io { - class BEECRYPTCXXAPI IOException : public Exception - { - public: - IOException(); - IOException(const String&); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/io/InputStream.cxx b/beecrypt/c++/io/InputStream.cxx deleted file mode 100644 index f586ce02b..000000000 --- a/beecrypt/c++/io/InputStream.cxx +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/io/InputStream.h" -#include "beecrypt/c++/lang/NullPointerException.h" -using beecrypt::lang::NullPointerException; - -using namespace beecrypt::io; - -off_t InputStream::available() throw (IOException) -{ - return 0; -} - -void InputStream::close() throw (IOException) -{ -} - -void InputStream::mark(off_t readlimit) throw () -{ -} - -bool InputStream::markSupported() throw () -{ - return false; -} - -int InputStream::read(bytearray& b) throw (IOException) -{ - return read(b.data(), 0, b.size()); -} - -int InputStream::read(byte* data, size_t offset, size_t length) throw (IOException) -{ - if (!data) - throw NullPointerException(); - - int b = read(); - if (b < 0) - return -1; - - data[offset] = (byte) b; - - size_t i = 1; - try - { - while (i < length) - { - b = read(); - if (b < 0) - break; - data[offset+i++] = (byte) b; - } - } - catch (IOException) - { - // ignore - } - return i; -} - -off_t InputStream::skip(off_t n) throw (IOException) -{ - off_t remaining = n; - - byte skip[2048]; - - while (remaining > 0) - { - int rc = read(skip, 0, remaining > 2048 ? 2048 : remaining); - if (rc < 0) - break; - remaining -= rc; - } - - return n - remaining; -} - -void InputStream::reset() throw (IOException) -{ - throw IOException("reset not supported"); -} diff --git a/beecrypt/c++/io/InputStream.h b/beecrypt/c++/io/InputStream.h deleted file mode 100644 index aea61c540..000000000 --- a/beecrypt/c++/io/InputStream.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file InputStream.h - * \ingroup CXX_IO_m - */ - -#ifndef _CLASS_INPUTSTREAM_H -#define _CLASS_INPUTSTREAM_H - -#ifdef __cplusplus - -#include "beecrypt/c++/array.h" -using beecrypt::bytearray; -#include "beecrypt/c++/io/IOException.h" -using beecrypt::io::IOException; - -namespace beecrypt { - namespace io { - class BEECRYPTCXXAPI InputStream - { - public: - virtual ~InputStream() {}; - - virtual off_t available() throw (IOException); - virtual void close() throw (IOException); - virtual void mark(off_t readlimit) throw (); - virtual bool markSupported() throw (); - virtual int read() throw (IOException) = 0; - virtual int read(byte* data, size_t offset, size_t length) throw (IOException); - virtual int read(bytearray& b) throw (IOException); - virtual void reset() throw (IOException); - virtual off_t skip(off_t n) throw (IOException); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/io/Makefile.am b/beecrypt/c++/io/Makefile.am deleted file mode 100644 index a86a0c2a8..000000000 --- a/beecrypt/c++/io/Makefile.am +++ /dev/null @@ -1,48 +0,0 @@ -INCLUDES = -I$(top_srcdir)/.. - -AUTOMAKE_OPTIONS = gnu no-dependencies - -noinst_LTLIBRARIES = libcxxio.la -cxxiodir= $(pkgincludedir)/c++/io - -libcxxio_la_SOURCES =\ -ByteArrayInputStream.cxx \ -ByteArrayOutputStream.cxx \ -DataInputStream.cxx \ -DataOutputStream.cxx \ -EOFException.cxx \ -FileInputStream.cxx \ -FileOutputStream.cxx \ -FilterInputStream.cxx \ -FilterOutputStream.cxx \ -InputStream.cxx \ -IOException.cxx \ -OutputStream.cxx \ -PrintStream.cxx \ -PushbackInputStream.cxx -libcxxio_la_LIBADD = -licuuc - -cxxio_HEADERS =\ -ByteArrayInputStream.h \ -ByteArrayOutputStream.h \ -DataInput.h \ -DataOutput.h \ -DataInputStream.h \ -DataOutputStream.h \ -EOFException.h \ -FileInputStream.h \ -FileOutputStream.h \ -FilterInputStream.h \ -FilterOutputStream.h \ -InputStream.h \ -IOException.h \ -OutputStream.h \ -PrintStream.h \ -PushbackInputStream.h - -TESTS = test - -check_PROGRAMS = test - -test_SOURCES = test.cxx -test_LDADD = libcxxio.la ../lang/libcxxlang.la $(top_builddir)/libbeecrypt.la -licuuc -licuio diff --git a/beecrypt/c++/io/OutputStream.cxx b/beecrypt/c++/io/OutputStream.cxx deleted file mode 100644 index ca45278cf..000000000 --- a/beecrypt/c++/io/OutputStream.cxx +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/io/OutputStream.h" -#include "beecrypt/c++/lang/NullPointerException.h" -using beecrypt::lang::NullPointerException; - -using namespace beecrypt::io; - -void OutputStream::close() throw (IOException) -{ -} - -void OutputStream::flush() throw (IOException) -{ -} - -void OutputStream::write(const byte* data, size_t offset, size_t len) throw (IOException) -{ - if (!data) - throw NullPointerException(); - - for (size_t i = 0; i < len; i++) - write(data[offset+i]); -} - -void OutputStream::write(const bytearray& b) throw (IOException) -{ - write(b.data(), 0, b.size()); -} diff --git a/beecrypt/c++/io/OutputStream.h b/beecrypt/c++/io/OutputStream.h deleted file mode 100644 index d2f43079e..000000000 --- a/beecrypt/c++/io/OutputStream.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file OutputStream.h - * \ingroup CXX_IO_m - */ - -#ifndef _CLASS_OUTPUTSTREAM_H -#define _CLASS_OUTPUTSTREAM_H - -#ifdef __cplusplus - -#include "beecrypt/c++/array.h" -using beecrypt::bytearray; -#include "beecrypt/c++/io/IOException.h" -using beecrypt::io::IOException; - -namespace beecrypt { - namespace io { - class BEECRYPTCXXAPI OutputStream - { - public: - virtual ~OutputStream() {}; - - virtual void close() throw (IOException); - virtual void flush() throw (IOException); - virtual void write(byte b) throw (IOException) = 0; - virtual void write(const byte* data, size_t offset, size_t length) throw (IOException); - virtual void write(const bytearray& b) throw (IOException); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/io/PrintStream.cxx b/beecrypt/c++/io/PrintStream.cxx deleted file mode 100644 index 340ad694a..000000000 --- a/beecrypt/c++/io/PrintStream.cxx +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/io/PrintStream.h" -#include "beecrypt/c++/lang/IllegalArgumentException.h" -using beecrypt::lang::IllegalArgumentException; - -#define MAX_BYTES_PER_CHARACTER 8 - -using namespace beecrypt::io; - -PrintStream::PrintStream(OutputStream& out, bool autoflush, const char* encoding) : FilterOutputStream(out) -{ - UErrorCode status = U_ZERO_ERROR; - - _loc = ucnv_open(encoding, &status); - if (U_FAILURE(status)) - throw IllegalArgumentException("invalid encoding"); - - _closed = false; - _error = false; - _flush = autoflush; -} - -PrintStream::~PrintStream() -{ - ucnv_close(_loc); -} - -void PrintStream::close() throw () -{ - try - { - out.close(); - _closed = true; - } - catch (IOException) - { - _error = true; - } -} - -void PrintStream::flush() throw () -{ - if (!_closed) - { - try - { - out.flush(); - } - catch (IOException) - { - _error = true; - } - } -} - -void PrintStream::write(byte b) throw () -{ - if (!_closed) - { - try - { - out.write(b); - } - catch (IOException) - { - _error = true; - } - } -} - -void PrintStream::write(const byte* data, size_t offset, size_t length) throw () -{ - if (!_closed) - { - try - { - out.write(data, offset, length); - } - catch (IOException) - { - _error = true; - } - } -} - -void PrintStream::print(const UChar* str, size_t length) throw () -{ - if (!_closed) - { - try - { - UErrorCode status = U_ZERO_ERROR; - - // pre-flighting - size_t need = ucnv_fromUChars(_loc, 0, 0, str, length, &status); - if (U_FAILURE(status)) - if (status != U_BUFFER_OVERFLOW_ERROR) - throw IOException(); - - byte* buffer = new byte[need]; - - status = U_ZERO_ERROR; - - try - { - ucnv_fromUChars(_loc, (char*) buffer, need, str, length, &status); - if (status != U_STRING_NOT_TERMINATED_WARNING) - throw IOException(); - - out.write(buffer, 0, need); - - if (_flush) - { - for (size_t i = 0; i < length; i++) - if (str[i] == 0xA) - out.flush(); - } - - delete[] buffer; - } - catch (IOException) - { - delete[] buffer; - throw; - } - } - catch (IOException) - { - _error = true; - } - } -} - -void PrintStream::print(bool b) throw () -{ - static const String* STR_TRUE = 0; - static const String* STR_FALSE = 0; - - if (!_closed) - { - if (b) - { - if (!STR_FALSE) - STR_FALSE = new String("true"); - - print(*STR_TRUE); - } - else - { - if (!STR_FALSE) - STR_FALSE = new String("false"); - - print(*STR_FALSE); - } - } -} - -void PrintStream::print(javachar ch) throw () -{ - if (!_closed) - { - char buffer[MAX_BYTES_PER_CHARACTER]; - - try - { - UErrorCode status = U_ZERO_ERROR; - - // do conversion of one character - size_t used = ucnv_fromUChars(_loc, buffer, 8, &ch, 1, &status); - if (U_FAILURE(status)) - throw IOException("failure in ucnv_fromUChars"); - - out.write((const byte*) buffer, 0, used); - - // check if we need to flush - if (_flush && ch == 0xA) - out.flush(); - } - catch (IOException) - { - _error = true; - } - } -} - -void PrintStream::print(const array<javachar>& chars) throw () -{ - print(chars.data(), chars.size()); -} - -void PrintStream::print(const String& str) throw () -{ - print(str.getBuffer(), str.length()); -} - -void PrintStream::println() throw () -{ - if (!_closed) - { - #if WIN32 - print((javachar) 0xD); - print((javachar) 0xA); - #else - print((javachar) 0xA); - #endif - } -} - -void PrintStream::println(bool b) throw () -{ - if (!_closed) - { - print(b); - println(); - } -} - -void PrintStream::println(const array<javachar>& chars) throw () -{ - if (!_closed) - { - print(chars); - println(); - } -} - -void PrintStream::println(const String& str) throw () -{ - if (!_closed) - { - print(str); - println(); - } -} diff --git a/beecrypt/c++/io/PrintStream.h b/beecrypt/c++/io/PrintStream.h deleted file mode 100644 index f53044950..000000000 --- a/beecrypt/c++/io/PrintStream.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file PrintStream.h - * \ingroup CXX_IO_m - */ - -#ifndef _CLASS_PRINTSTREAM_H -#define _CLASS_PRINTSTREAM_H - -#ifdef __cplusplus - -#include "beecrypt/c++/array.h" -using beecrypt::array; -using beecrypt::bytearray; -#include "beecrypt/c++/io/FilterOutputStream.h" -using beecrypt::io::FilterOutputStream; - -#include <unicode/ucnv.h> - -namespace beecrypt { - namespace io { - class BEECRYPTCXXAPI PrintStream : public FilterOutputStream - { - private: - bool _closed; - bool _error; - bool _flush; - UConverter* _loc; - - void print(const UChar*, size_t) throw (); - - protected: - void setError() throw (); - - public: - PrintStream(OutputStream& out, bool autoflush = false, const char* encoding = 0); - virtual ~PrintStream(); - - virtual void close() throw (); - virtual void flush() throw (); - virtual void write(byte) throw (); - virtual void write(const byte*, size_t, size_t) throw (); - - bool checkError() throw (); - void print(bool) throw (); - void print(javachar) throw (); - void print(javaint) throw (); - void print(javalong) throw (); - void print(javashort) throw (); - // void print(javafloat) throw (); - // void print(javadouble) throw (); - // void print(const char*) throw (); - void print(const array<javachar>&) throw (); - void print(const String&) throw (); - void println() throw (); - void println(bool) throw (); - void println(javachar) throw (); - void println(javaint) throw (); - void println(javalong) throw (); - void println(javashort) throw (); - // void println(javafloat) throw (); - // void println(javadouble) throw (); - // void println(const char*) throw (); - void println(const array<javachar>&) throw (); - void println(const String&) throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/io/PushbackInputStream.cxx b/beecrypt/c++/io/PushbackInputStream.cxx deleted file mode 100644 index 908991bd6..000000000 --- a/beecrypt/c++/io/PushbackInputStream.cxx +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/io/PushbackInputStream.h" -#include "beecrypt/c++/lang/NullPointerException.h" -using beecrypt::lang::NullPointerException; - -using namespace beecrypt::io; - -PushbackInputStream::PushbackInputStream(InputStream& in, size_t size) : FilterInputStream(in), buf(size) -{ - _closed = false; - pos = 0; -} - -PushbackInputStream::~PushbackInputStream() -{ -} - -off_t PushbackInputStream::available() throw (IOException) -{ - if (_closed) - throw IOException("Stream closed"); - - return in.available() + (buf.size() - pos); -} - -void PushbackInputStream::close() throw (IOException) -{ - if (!_closed) - { - in.close(); - _closed = true; - } -} - -int PushbackInputStream::read() throw (IOException) -{ - if (_closed) - throw IOException("Stream closed"); - - if (pos < buf.size()) - return buf[pos++]; - - return in.read(); -} - -bool PushbackInputStream::markSupported() throw () -{ - return false; -} - -int PushbackInputStream::read(byte* data, size_t offset, size_t length) throw (IOException) -{ - if (!data) - throw NullPointerException(); - - if (_closed) - throw IOException("Stream closed"); - - if (length == 0) - return 0; - - size_t buffered = buf.size() - pos; - - if (buffered > 0) - { - if (length < buffered) - buffered = length; - - memcpy(data+offset, buf.data()+pos, buffered); - - pos += buffered; - offset += buffered; - length -= buffered; - } - - if (length > 0) - { - int rc = in.read(data, offset, length); - if (rc < 0) - if (buffered == 0) - return -1; // nothing in buffer and nothing read - else - return buffered; // something in buffer and nothing read - - return buffered + rc; // something in buffer and something read - } - - return buffered; // everything was in buffer -} - -off_t PushbackInputStream::skip(off_t n) throw (IOException) -{ - if (_closed) - throw IOException("Stream closed"); - - if (n == 0) - return 0; - - size_t canskip = buf.size() - pos; - - if (canskip > 0) - { - if (n < canskip) - { - // more in buffer than we need to skip - canskip = n; - } - pos += canskip; - n -= canskip; - } - - if (n > 0) - { - // apparently we didn't have enough in the buffer - canskip += in.skip(n); - } - - return canskip; -} - -void PushbackInputStream::unread(byte b) throw (IOException) -{ - if (_closed) - throw IOException("Stream closed"); - - if (pos == 0) - throw IOException("Pushback buffer is full"); - - buf[--pos] = b; -} - -void PushbackInputStream::unread(const bytearray& b) throw (IOException) -{ - unread(b.data(), 0, b.size()); -} - -void PushbackInputStream::unread(const byte* data, size_t offset, size_t length) throw (IOException) -{ - if (!data) - throw NullPointerException(); - - pos -= length; - - memcpy(buf.data()+pos, data+offset, length); -} diff --git a/beecrypt/c++/io/PushbackInputStream.h b/beecrypt/c++/io/PushbackInputStream.h deleted file mode 100644 index ff63dfc09..000000000 --- a/beecrypt/c++/io/PushbackInputStream.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file PushbackInputStream.h - * \ingroup CXX_IO_m - */ - -#ifndef _CLASS_PUSHBACKINPUTSTREAM_H -#define _CLASS_PUSHBACKINPUTSTREAM_H - -#ifdef __cplusplus - -#include "beecrypt/c++/io/FilterInputStream.h" -using beecrypt::io::FilterInputStream; - -namespace beecrypt { - namespace io { - class BEECRYPTCXXAPI PushbackInputStream : public FilterInputStream - { - private: - bool _closed; - - protected: - bytearray buf; - size_t pos; - - public: - PushbackInputStream(InputStream& in, size_t size = 1); - virtual ~PushbackInputStream(); - - virtual off_t available() throw (IOException); - virtual void close() throw (IOException); - virtual bool markSupported() throw (); - virtual int read() throw (IOException); - virtual int read(byte* data, size_t offset, size_t length) throw (IOException); - virtual off_t skip(off_t n) throw (IOException); - - void unread(byte) throw (IOException); - void unread(const byte* data, size_t offset, size_t length) throw (IOException); - void unread(const bytearray& b) throw (IOException); - - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/io/test.cxx b/beecrypt/c++/io/test.cxx deleted file mode 100644 index 2d9095fb6..000000000 --- a/beecrypt/c++/io/test.cxx +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "c++/io/ByteArrayInputStream.h" -using beecrypt::io::ByteArrayInputStream; -#include "c++/io/ByteArrayOutputStream.h" -using beecrypt::io::ByteArrayOutputStream; -#include "c++/io/DataInputStream.h" -using beecrypt::io::DataInputStream; -#include "c++/io/DataOutputStream.h" -using beecrypt::io::DataOutputStream; - -#include <iostream> -#include <unicode/ustream.h> -using namespace std; - -int main(int argc, char* argv[]) -{ - String input = UNICODE_STRING_SIMPLE("The quick brown fox jumps over the lazy dog"); - - int failures = 0; - - try - { - ByteArrayOutputStream bos; - DataOutputStream dos(bos); - - dos.writeUTF(input); - dos.close(); - - bytearray* b = bos.toByteArray(); - - if (b) - { - if (b->size() != 45) - { - cerr << "failed test 1" << endl; - failures++; - } - - ByteArrayInputStream bin(*b); - DataInputStream din(bin); - - String test; - - din.readUTF(test); - - if (input != test) - { - cerr << "failed test 2" << endl; - failures++; - } - - if (din.available() != 0) - { - cerr << "failed test 3" << endl; - cerr << "remaining bytes in stream: " << din.available() << endl; - failures++; - } - - din.close(); - bin.close(); - } - else - { - cerr << "failed structural 1" << endl; - failures++; - } - } - catch (IOException& ex) - { - cerr << "failed structural 2" << endl; - failures++; - } - catch (...) - { - cerr << "failed structural 3" << endl; - failures++; - } - - return failures; -} diff --git a/beecrypt/c++/lang/.cvsignore b/beecrypt/c++/lang/.cvsignore deleted file mode 100644 index da7b4816b..000000000 --- a/beecrypt/c++/lang/.cvsignore +++ /dev/null @@ -1,5 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo diff --git a/beecrypt/c++/lang/Error.cxx b/beecrypt/c++/lang/Error.cxx deleted file mode 100644 index 2e0238139..000000000 --- a/beecrypt/c++/lang/Error.cxx +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/lang/Error.h" -using namespace beecrypt::lang; - -Error::Error() throw () -{ -} - -Error::Error(const String& message) throw () : Throwable(message) -{ -} diff --git a/beecrypt/c++/lang/Error.h b/beecrypt/c++/lang/Error.h deleted file mode 100644 index d5d01e390..000000000 --- a/beecrypt/c++/lang/Error.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file Error.h - * \ingroup CXX_LANG_m - */ - -#ifndef _CLASS_ERROR_H -#define _CLASS_ERROR_H - -#ifdef __cplusplus - -#include "beecrypt/c++/lang/Throwable.h" -using beecrypt::lang::Throwable; - -namespace beecrypt { - namespace lang { - class BEECRYPTCXXAPI Error : public Throwable - { - public: - Error() throw (); - Error(const String&) throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/lang/Exception.cxx b/beecrypt/c++/lang/Exception.cxx deleted file mode 100644 index 5626e28db..000000000 --- a/beecrypt/c++/lang/Exception.cxx +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/lang/Exception.h" -using namespace beecrypt::lang; - -Exception::Exception() throw () -{ -} - -Exception::Exception(const String& message) throw () : Throwable(message) -{ -} diff --git a/beecrypt/c++/lang/Exception.h b/beecrypt/c++/lang/Exception.h deleted file mode 100644 index 7ba56e08b..000000000 --- a/beecrypt/c++/lang/Exception.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file Exception.h - * \ingroup CXX_LANG_m - */ - -#ifndef _CLASS_EXCEPTION_H -#define _CLASS_EXCEPTION_H - -#ifdef __cplusplus - -#include "beecrypt/c++/lang/Throwable.h" -using beecrypt::lang::Throwable; - -namespace beecrypt { - namespace lang { - class BEECRYPTCXXAPI Exception : public Throwable - { - public: - Exception() throw (); - Exception(const String&) throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/lang/IllegalArgumentException.cxx b/beecrypt/c++/lang/IllegalArgumentException.cxx deleted file mode 100644 index e6ff1ddea..000000000 --- a/beecrypt/c++/lang/IllegalArgumentException.cxx +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/lang/IllegalArgumentException.h" -using namespace beecrypt::lang; - -IllegalArgumentException::IllegalArgumentException() throw () -{ -} - -IllegalArgumentException::IllegalArgumentException(const String& message) throw () : RuntimeException(message) -{ -} diff --git a/beecrypt/c++/lang/IllegalArgumentException.h b/beecrypt/c++/lang/IllegalArgumentException.h deleted file mode 100644 index a0e73db86..000000000 --- a/beecrypt/c++/lang/IllegalArgumentException.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file IllegalArgumentException.h - * \ingroup CXX_LANG_m - */ - -#ifndef _CLASS_ILLEGALARGUMENTEXCEPTION_H -#define _CLASS_ILLEGALARGUMENTEXCEPTION_H - -#ifdef __cplusplus - -#include "beecrypt/c++/lang/RuntimeException.h" -using beecrypt::lang::RuntimeException; - -namespace beecrypt { - namespace lang { - class BEECRYPTCXXAPI IllegalArgumentException : public RuntimeException - { - public: - IllegalArgumentException() throw (); - IllegalArgumentException(const String&) throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/lang/IllegalStateException.cxx b/beecrypt/c++/lang/IllegalStateException.cxx deleted file mode 100644 index e1668aba6..000000000 --- a/beecrypt/c++/lang/IllegalStateException.cxx +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/lang/IllegalStateException.h" -using namespace beecrypt::lang; - -IllegalStateException::IllegalStateException() throw () -{ -} - -IllegalStateException::IllegalStateException(const String& message) throw () : RuntimeException(message) -{ -} diff --git a/beecrypt/c++/lang/IllegalStateException.h b/beecrypt/c++/lang/IllegalStateException.h deleted file mode 100644 index bcbc2c5b7..000000000 --- a/beecrypt/c++/lang/IllegalStateException.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file IllegalStateException.h - * \ingroup CXX_LANG_m - */ - -#ifndef _CLASS_ILLEGALSTATEEXCEPTION_H -#define _CLASS_ILLEGALSTATEEXCEPTION_H - -#ifdef __cplusplus - -#include "beecrypt/c++/lang/RuntimeException.h" -using beecrypt::lang::RuntimeException; - -namespace beecrypt { - namespace lang { - class BEECRYPTCXXAPI IllegalStateException : public RuntimeException - { - public: - IllegalStateException() throw (); - IllegalStateException(const String&) throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/lang/Makefile.am b/beecrypt/c++/lang/Makefile.am deleted file mode 100644 index 4bafe6a37..000000000 --- a/beecrypt/c++/lang/Makefile.am +++ /dev/null @@ -1,28 +0,0 @@ -INCLUDES = -I$(top_srcdir)/.. - -AUTOMAKE_OPTIONS = gnu no-dependencies - -noinst_LTLIBRARIES = libcxxlang.la - -cxxlangdir=$(pkgincludedir)/c++/lang - -libcxxlang_la_SOURCES =\ -Error.cxx \ -Exception.cxx \ -IllegalArgumentException.cxx \ -IllegalStateException.cxx \ -NullPointerException.cxx \ -OutOfMemoryError.cxx \ -RuntimeException.cxx \ -Throwable.cxx - -cxxlang_HEADERS =\ -Error.h \ -Exception.h \ -IllegalArgumentException.h \ -IllegalStateException.h \ -NullPointerException.h \ -OutOfMemoryError.h \ -RuntimeException.h \ -String.h \ -Throwable.h diff --git a/beecrypt/c++/lang/NullPointerException.cxx b/beecrypt/c++/lang/NullPointerException.cxx deleted file mode 100644 index d06d085a7..000000000 --- a/beecrypt/c++/lang/NullPointerException.cxx +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/lang/NullPointerException.h" -using namespace beecrypt::lang; - -NullPointerException::NullPointerException() throw () -{ -} - -NullPointerException::NullPointerException(const String& message) throw () : RuntimeException(message) -{ -} diff --git a/beecrypt/c++/lang/NullPointerException.h b/beecrypt/c++/lang/NullPointerException.h deleted file mode 100644 index 7e9b5a0e7..000000000 --- a/beecrypt/c++/lang/NullPointerException.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file NullPointerException.h - * \ingroup CXX_LANG_m - */ - -#ifndef _CLASS_NULLPOINTEREXCEPTION_H -#define _CLASS_NULLPOINTEREXCEPTION_H - -#ifdef __cplusplus - -#include "beecrypt/c++/lang/RuntimeException.h" -using beecrypt::lang::RuntimeException; - -namespace beecrypt { - namespace lang { - class BEECRYPTCXXAPI NullPointerException : public RuntimeException - { - public: - NullPointerException() throw (); - NullPointerException(const String&) throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/lang/OutOfMemoryError.cxx b/beecrypt/c++/lang/OutOfMemoryError.cxx deleted file mode 100644 index 2ed18a77d..000000000 --- a/beecrypt/c++/lang/OutOfMemoryError.cxx +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/lang/OutOfMemoryError.h" -using namespace beecrypt::lang; - -OutOfMemoryError::OutOfMemoryError() throw () -{ -} - -OutOfMemoryError::OutOfMemoryError(const String& message) throw () : Error(message) -{ -} diff --git a/beecrypt/c++/lang/OutOfMemoryError.h b/beecrypt/c++/lang/OutOfMemoryError.h deleted file mode 100644 index bdd996ffb..000000000 --- a/beecrypt/c++/lang/OutOfMemoryError.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file OutOfMemoryError.h - * \ingroup CXX_LANG_m - */ - -#ifndef _CLASS_OUTOFMEMORYERROR_H -#define _CLASS_OUTOFMEMORYERROR_H - -#ifdef __cplusplus - -#include "beecrypt/c++/lang/Error.h" -using beecrypt::lang::Error; - -namespace beecrypt { - namespace lang { - class BEECRYPTCXXAPI OutOfMemoryError : public Error - { - public: - OutOfMemoryError() throw (); - OutOfMemoryError(const String&) throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/lang/RuntimeException.cxx b/beecrypt/c++/lang/RuntimeException.cxx deleted file mode 100644 index e9dd31da9..000000000 --- a/beecrypt/c++/lang/RuntimeException.cxx +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/lang/RuntimeException.h" -using namespace beecrypt::lang; - -RuntimeException::RuntimeException() throw () -{ -} - -RuntimeException::RuntimeException(const String& message) throw () : Exception(message) -{ -} diff --git a/beecrypt/c++/lang/RuntimeException.h b/beecrypt/c++/lang/RuntimeException.h deleted file mode 100644 index 47707675f..000000000 --- a/beecrypt/c++/lang/RuntimeException.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file RuntimeException.h - * \ingroup CXX_LANG_m - */ - -#ifndef _CLASS_RUNTIMEEXCEPTION_H -#define _CLASS_RUNTIMEEXCEPTION_H - -#ifdef __cplusplus - -#include "beecrypt/c++/lang/Exception.h" -using beecrypt::lang::Exception; - -namespace beecrypt { - namespace lang { - class BEECRYPTCXXAPI RuntimeException : public Exception - { - public: - RuntimeException() throw (); - RuntimeException(const String&) throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/lang/String.h b/beecrypt/c++/lang/String.h deleted file mode 100644 index 25a3eddbe..000000000 --- a/beecrypt/c++/lang/String.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file String.h - * \ingroup CXX_LANG_m - */ - -#ifndef _BEECRYPT_CLASS_STRING_H -#define _BEECRYPT_CLASS_STRING_H - -#ifdef __cplusplus - -#include <unicode/unistr.h> - -namespace beecrypt { - namespace lang { - typedef UnicodeString String; - } -} - -#endif - -#endif - diff --git a/beecrypt/c++/lang/Throwable.cxx b/beecrypt/c++/lang/Throwable.cxx deleted file mode 100644 index f687a5dd3..000000000 --- a/beecrypt/c++/lang/Throwable.cxx +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/lang/Throwable.h" -using namespace beecrypt::lang; - -Throwable::Throwable() throw () -{ -} - -Throwable::Throwable(const String& message) throw () -{ - _msg = message; -} - -Throwable::Throwable(const Throwable& copy) throw () -{ - _msg = copy._msg; -} - -const String& Throwable::getMessage() const throw () -{ - return _msg; -} diff --git a/beecrypt/c++/lang/Throwable.h b/beecrypt/c++/lang/Throwable.h deleted file mode 100644 index 5df4480a1..000000000 --- a/beecrypt/c++/lang/Throwable.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file Throwable.h - * \ingroup CXX_LANG_m - */ - -#ifndef _CLASS_THROWABLE_H -#define _CLASS_THROWABLE_H - -#include "beecrypt/api.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/lang/String.h" -using beecrypt::lang::String; - -namespace beecrypt { - namespace lang { - class BEECRYPTCXXAPI Throwable - { - private: - String _msg; - - public: - Throwable() throw (); - Throwable(const String&) throw (); - Throwable(const Throwable&) throw (); - - virtual ~Throwable() throw () {}; - - const String& getMessage() const throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/mutex.h b/beecrypt/c++/mutex.h deleted file mode 100644 index e5575e965..000000000 --- a/beecrypt/c++/mutex.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file mutex.h - * \brief MUTually EXclusive lock class. - * \author Bob Deblier <bob.deblier@telenet.be> - * \ingroup CXX_m - */ - -#ifndef _CLASS_BEECRYPT_MUTEX_H -#define _CLASS_BEECRYPT_MUTEX_H - -#include "beecrypt/api.h" - -#ifdef __cplusplus - -#if HAVE_ERRNO_H -# include <errno.h> -#endif - -namespace beecrypt { - class BEECRYPTCXXAPI mutex - { - private: - bc_mutex_t _lock; - - public: - inline void init() throw (char*) - { - #if WIN32 - _lock = CreateMutex((LPSECURITY_ATTRIBUTES) 0, FALSE, (LPCSTR) 0); - if (!_lock) - throw "CreateMutex failed"; - #else - register int rc; - # if HAVE_SYNCH_H - if ((rc = mutex_init(&_lock, USYNC_THREAD, 0))) - throw strerror(rc); - # elif HAVE_PTHREAD_H - if ((rc = pthread_mutex_init(&_lock, 0))) - throw strerror(rc); - # else - # error - # endif - #endif - } - - inline void lock() throw (char*) - { - #if WIN32 - if (WaitForSingleObject(_lock, INFINITE) == WAIT_OBJECT_0) - return; - throw "WaitForSingleObject failed"; - #else - register int rc; - # if HAVE_SYNCH_H - if ((rc = mutex_lock(&_lock))) - throw strerror(rc); - # elif HAVE_PTHREAD_H - if ((rc = pthread_mutex_lock(&_lock))) - throw strerror(rc); - # else - # error - # endif - #endif - } - - inline bool trylock() throw (char*) - { - #if WIN32 - switch (WaitForSingleObject(_lock, 0)) - { - case WAIT_TIMEOUT: - return false; - case WAIT_OBJECT_0: - return true; - default: - throw "WaitForSingleObbject failed"; - } - #else - register int rc; - # if HAVE_SYNCH_H - if ((rc = mutex_trylock(&_lock)) == 0) - return true; - if (rc == EBUSY) - return false; - throw strerror(rc); - # elif HAVE_PTHREAD_H - if ((rc = pthread_mutex_trylock(&_lock)) == 0) - return true; - if (rc == EBUSY) - return false; - throw strerror(rc); - # else - # error - # endif - #endif - } - - inline void unlock() throw (char*) - { - #if WIN32 - if (!ReleaseMutex(_lock)) - throw "ReleaseMutex failed"; - #else - register int rc; - # if HAVE_SYNCH_H - if ((rc = mutex_unlock(&_lock))) - throw strerror(rc); - # elif HAVE_PTHREAD_H - if ((rc = pthread_mutex_unlock(&_lock))) - throw strerror(rc); - # else - # error - # endif - #endif - } - - inline void destroy() throw (char*) - { - #if WIN32 - if (!CloseHandle(_lock)) - throw "CloseHandle failed"; - #else - register int rc; - # if HAVE_SYNCH_H - if ((rc = mutex_destroy(&_lock))) - throw strerror(rc); - # elif HAVE_PTHREAD_H - if ((rc = pthread_mutex_destroy(&_lock))) - throw strerror(rc); - # else - # error - # endif - #endif - } - }; -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/.cvsignore b/beecrypt/c++/provider/.cvsignore deleted file mode 100644 index da7b4816b..000000000 --- a/beecrypt/c++/provider/.cvsignore +++ /dev/null @@ -1,5 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo diff --git a/beecrypt/c++/provider/BeeCertificateFactory.cxx b/beecrypt/c++/provider/BeeCertificateFactory.cxx deleted file mode 100644 index bc288d076..000000000 --- a/beecrypt/c++/provider/BeeCertificateFactory.cxx +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/beeyond/BeeCertificate.h" -using beecrypt::beeyond::BeeCertificate; -#include "beecrypt/c++/provider/BeeCertificateFactory.h" - -using namespace beecrypt::provider; - -BeeCertificateFactory::BeeCertificateFactory() -{ -} - -BeeCertificateFactory::~BeeCertificateFactory() -{ -} - -Certificate* BeeCertificateFactory::engineGenerateCertificate(InputStream& in) throw (CertificateException) -{ - try - { - return new BeeCertificate(in); - } - catch (Exception& ex) - { - throw CertificateException(ex.getMessage()); - } -} - -vector<Certificate*>* BeeCertificateFactory::engineGenerateCertificates(InputStream& in) throw (CertificateException) -{ - vector<Certificate*>* result = new vector<Certificate*>; - - try - { - while (in.available()) - { - result->push_back(new BeeCertificate(in)); - } - } - catch (...) - { - delete result; - throw; - } - - return result; -} diff --git a/beecrypt/c++/provider/BeeCertificateFactory.h b/beecrypt/c++/provider/BeeCertificateFactory.h deleted file mode 100644 index 2dfb4e872..000000000 --- a/beecrypt/c++/provider/BeeCertificateFactory.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file BeeCertificateFactory.h - * \ingroup CXX_PROV_m - */ - -#ifndef _CLASS_BEECERTIFICATEFACTORY_H -#define _CLASS_BEECERTIFICATEFACTORY_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/cert/CertificateFactorySpi.h" -using beecrypt::security::cert::CertificateFactorySpi; - -namespace beecrypt { - namespace provider { - class BeeCertificateFactory : public CertificateFactorySpi - { - protected: - virtual Certificate* engineGenerateCertificate(InputStream& in) throw (CertificateException); - virtual vector<Certificate*>* engineGenerateCertificates(InputStream& in) throw (CertificateException); - - public: - BeeCertificateFactory(); - virtual ~BeeCertificateFactory(); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/BeeCryptProvider.cxx b/beecrypt/c++/provider/BeeCryptProvider.cxx deleted file mode 100644 index 6f42c3058..000000000 --- a/beecrypt/c++/provider/BeeCryptProvider.cxx +++ /dev/null @@ -1,289 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/provider/BeeCertificateFactory.h" -#include "beecrypt/c++/provider/BeeCryptProvider.h" -#include "beecrypt/c++/provider/BeeKeyFactory.h" -#include "beecrypt/c++/provider/BeeKeyStore.h" -#include "beecrypt/c++/provider/BeeSecureRandom.h" -#include "beecrypt/c++/provider/DHKeyFactory.h" -#include "beecrypt/c++/provider/DHKeyPairGenerator.h" -#include "beecrypt/c++/provider/DHParameterGenerator.h" -#include "beecrypt/c++/provider/DHParameters.h" -#include "beecrypt/c++/provider/DSAKeyFactory.h" -#include "beecrypt/c++/provider/DSAKeyPairGenerator.h" -#include "beecrypt/c++/provider/DSAParameterGenerator.h" -#include "beecrypt/c++/provider/DSAParameters.h" -#include "beecrypt/c++/provider/HMACMD5.h" -#include "beecrypt/c++/provider/HMACSHA256.h" -#include "beecrypt/c++/provider/MD5Digest.h" -#include "beecrypt/c++/provider/MD5withRSASignature.h" -#include "beecrypt/c++/provider/PKCS12KeyFactory.h" -#include "beecrypt/c++/provider/RSAKeyFactory.h" -#include "beecrypt/c++/provider/RSAKeyPairGenerator.h" -#include "beecrypt/c++/provider/SHA1Digest.h" -#include "beecrypt/c++/provider/SHA1withDSASignature.h" -#include "beecrypt/c++/provider/SHA1withRSASignature.h" -#include "beecrypt/c++/provider/SHA256withRSASignature.h" - -namespace { - const String PROVIDER_NAME = UNICODE_STRING_SIMPLE("BeeCrypt++"); - const String PROVIDER_INFO = UNICODE_STRING_SIMPLE("Copyright (c) 2004 Beeyond Software Holding"); - const double PROVIDER_VERSION = 0.1; -} - -extern "C" { - -#if WIN32 -# define PROVAPI __declspec(dllexport) -#else -# define PROVAPI -#endif - -PROVAPI -void* beecrypt_BeeCertificateFactory_create() -{ - return new beecrypt::provider::BeeCertificateFactory(); -} - -PROVAPI -void* beecrypt_BeeKeyFactory_create() -{ - return new beecrypt::provider::BeeKeyFactory(); -} - -PROVAPI -void* beecrypt_BeeKeyStore_create() -{ - return new beecrypt::provider::BeeKeyStore(); -} - -PROVAPI -void* beecrypt_BeeSecureRandom_create() -{ - return new beecrypt::provider::BeeSecureRandom(); -} - -PROVAPI -void* beecrypt_DHKeyFactory_create() -{ - return new beecrypt::provider::DHKeyFactory(); -} - -PROVAPI -void* beecrypt_DHKeyPairGenerator_create() -{ - return new beecrypt::provider::DHKeyPairGenerator(); -} - -PROVAPI -void* beecrypt_HParameterGenerator_create() -{ - return new beecrypt::provider::DHParameterGenerator(); -} - -PROVAPI -void* beecrypt_DHParameters_create() -{ - return new beecrypt::provider::DHParameters(); -} - -PROVAPI -void* beecrypt_DSAKeyFactory_create() -{ - return new beecrypt::provider::DSAKeyFactory(); -} - -PROVAPI -void* beecrypt_DSAKeyPairGenerator_create() -{ - return new beecrypt::provider::DSAKeyPairGenerator(); -} - -PROVAPI -void* beecrypt_DSAParameterGenerator_create() -{ - return new beecrypt::provider::DSAParameterGenerator(); -} - -PROVAPI -void* beecrypt_DSAParameters_create() -{ - return new beecrypt::provider::DSAParameters(); -} - -PROVAPI -void* beecrypt_HMACMD5_create() -{ - return new beecrypt::provider::HMACMD5(); -} - -PROVAPI -void* beecrypt_HMACSHA256_create() -{ - return new beecrypt::provider::HMACSHA256(); -} - -PROVAPI -void* beecrypt_MD5Digest_create() -{ - return new beecrypt::provider::MD5Digest(); -} - -PROVAPI -void* beecrypt_MD5withRSASignature_create() -{ - return new beecrypt::provider::MD5withRSASignature(); -} - -PROVAPI -void* beecrypt_PKCS12KeyFactory_create() -{ - return new beecrypt::provider::PKCS12KeyFactory(); -} - -PROVAPI -void* beecrypt_RSAKeyFactory_create() -{ - return new beecrypt::provider::RSAKeyFactory(); -} - -PROVAPI -void* beecrypt_RSAKeyPairGenerator_create() -{ - return new beecrypt::provider::RSAKeyPairGenerator(); -} - -PROVAPI -void* beecrypt_SHA1Digest_create() -{ - return new beecrypt::provider::SHA1Digest(); -} - -PROVAPI -void* beecrypt_SHA1withDSASignature_create() -{ - return new beecrypt::provider::SHA1withDSASignature(); -} - -PROVAPI -void* beecrypt_SHA1withRSASignature_create() -{ - return new beecrypt::provider::SHA1withRSASignature(); -} - -PROVAPI -void* beecrypt_SHA256withRSASignature_create() -{ - return new beecrypt::provider::SHA256withRSASignature(); -} - -} - -using namespace beecrypt::provider; - -BeeCryptProvider::BeeCryptProvider() : Provider(PROVIDER_NAME, PROVIDER_VERSION, PROVIDER_INFO) -{ - _dlhandle = 0; - - putall(); -} - -BeeCryptProvider::BeeCryptProvider(void* dlhandle) : Provider(PROVIDER_NAME, PROVIDER_VERSION, PROVIDER_INFO) -{ - _dlhandle = dlhandle; - - putall(); -} - -BeeCryptProvider::~BeeCryptProvider() -{ -} - -void BeeCryptProvider::putall() -{ - put("AlgorithmParameterGenerator.DH" , "beecrypt_DHParameterGenerator_create"); - put("AlgorithmParameterGenerator.DSA" , "beecrypt_DSAParameterGenerator_create"); - put("AlgorithmParameters.DH" , "beecrypt_DHParameters_create"); - put("AlgorithmParameters.DSA" , "beecrypt_DSAParameters_create"); - put("CertificateFactory.BEE" , "beecrypt_BeeCertificateFactory_create"); - put("KeyFactory.BEE" , "beecrypt_BeeKeyFactory_create"); - put("KeyFactory.DH" , "beecrypt_DHKeyFactory_create"); - put("KeyFactory.DSA" , "beecrypt_DSAKeyFactory_create"); - put("KeyFactory.RSA" , "beecrypt_RSAKeyFactory_create"); - put("KeyStore.BEE" , "beecrypt_BeeKeyStore_create"); - put("KeyPairGenerator.DH" , "beecrypt_DHKeyPairGenerator_create"); - put("KeyPairGenerator.DSA" , "beecrypt_DSAKeyPairGenerator_create"); - put("KeyPairGenerator.RSA" , "beecrypt_RSAKeyPairGenerator_create"); - put("Mac.HMAC-MD5" , "beecrypt_HMACMD5_create"); - put("Mac.HMAC-SHA-1" , "beecrypt_HMACSHA1_create"); - put("Mac.HMAC-SHA-256" , "beecrypt_HMACSHA256_create"); - put("MessageDigest.MD5" , "beecrypt_MD5Digest_create"); - put("MessageDigest.SHA-1" , "beecrypt_SHA1Digest_create"); - put("SecretKeyFactory.PKCS#12/PBE" , "beecrypt_PKCS12KeyFactory_create"); - put("SecureRandom.BEE" , "beecrypt_BeeSecureRandom_create"); - put("Signature.MD5withRSA" , "beecrypt_MD5withRSASignature_create"); - put("Signature.SHA1withDSA" , "beecrypt_SHA1withDSASignature_create"); - put("Signature.SHA1withRSA" , "beecrypt_SHA1withRSASignature_create"); - put("Signature.SHA256withRSA" , "beecrypt_SHA256withRSASignature_create"); - put("Alg.Alias.KeyFactory.DiffieHellman" , "KeyFactory.DH"); - put("Alg.Alias.KeyPairGenerator.DiffieHellman" , "KeyFactory.DH"); - put("Alg.Alias.Signature.DSS" , "Signature.SHA1withDSA"); - put("Alg.Alias.Signature.SHAwithDSA" , "Signature.SHA1withDSA"); - put("Alg.Alias.Signature.SHA/DSA" , "Signature.SHA1withDSA"); - put("Alg.Alias.Signature.SHA-1/DSA" , "Signature.SHA1withDSA"); -} - -namespace { - bool init = false; - BeeCryptProvider* singleton; -} - -extern "C" { - -#if WIN32 -__declspec(dllexport) -BOOL WINAPI DllMain(HINSTANCE hInst, DWORD wDataSeg, LPVOID lpReserved) -{ - switch (wDataSeg) - { - case DLL_PROCESS_ATTACH: - break; - case DLL_PROCESS_DETACH: - break; - } - return TRUE; -} - -__declspec(dllexport) -#endif -const Provider& provider_const_ref(void *dlhandle) -{ - if (!init) - { - singleton = new BeeCryptProvider(dlhandle); - init = true; - } - return *singleton; -} - -} diff --git a/beecrypt/c++/provider/BeeCryptProvider.h b/beecrypt/c++/provider/BeeCryptProvider.h deleted file mode 100644 index 6f672259f..000000000 --- a/beecrypt/c++/provider/BeeCryptProvider.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file BeeCryptProvider.h - * \ingroup CXX_PROV_m - */ - -#ifndef _CLASS_BEECRYPTPROVIDER_H -#define _CLASS_BEECRYPTPROVIDER_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/Provider.h" -using beecrypt::security::Provider; - -namespace beecrypt { - namespace provider { - class BeeCryptProvider : public Provider - { - private: - void putall(); - - public: - BeeCryptProvider(); - BeeCryptProvider(void*); - virtual ~BeeCryptProvider(); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/BeeKeyFactory.cxx b/beecrypt/c++/provider/BeeKeyFactory.cxx deleted file mode 100644 index 96c4147cc..000000000 --- a/beecrypt/c++/provider/BeeKeyFactory.cxx +++ /dev/null @@ -1,391 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/beeyond/BeeEncodedKeySpec.h" -using beecrypt::beeyond::BeeEncodedKeySpec; -#include "beecrypt/c++/beeyond/BeeInputStream.h" -using beecrypt::beeyond::BeeInputStream; -#include "beecrypt/c++/beeyond/BeeOutputStream.h" -using beecrypt::beeyond::BeeOutputStream; -#include "beecrypt/c++/io/ByteArrayInputStream.h" -using beecrypt::io::ByteArrayInputStream; -#include "beecrypt/c++/io/ByteArrayOutputStream.h" -using beecrypt::io::ByteArrayOutputStream; -#include "beecrypt/c++/provider/BeeKeyFactory.h" -#include "beecrypt/c++/provider/DHPrivateKeyImpl.h" -#include "beecrypt/c++/provider/DHPublicKeyImpl.h" -#include "beecrypt/c++/provider/DSAPrivateKeyImpl.h" -#include "beecrypt/c++/provider/DSAPublicKeyImpl.h" -#include "beecrypt/c++/provider/RSAPrivateKeyImpl.h" -#include "beecrypt/c++/provider/RSAPrivateCrtKeyImpl.h" -#include "beecrypt/c++/provider/RSAPublicKeyImpl.h" - -namespace { - const String ALGORITHM_DH = UNICODE_STRING_SIMPLE("DH"); - const String ALGORITHM_DSA = UNICODE_STRING_SIMPLE("DSA"); - const String ALGORITHM_RSA = UNICODE_STRING_SIMPLE("RSA"); -} - -using namespace beecrypt::provider; - -BeeKeyFactory::BeeKeyFactory() -{ -} - -BeeKeyFactory::~BeeKeyFactory() -{ -} - -PrivateKey* BeeKeyFactory::decodePrivate(const byte* data, size_t offset, size_t size) -{ - try - { - String algo; - - ByteArrayInputStream bis(data, offset, size); - BeeInputStream bee(bis); - - bee.readUTF(algo); - - if (algo == ALGORITHM_DH) - { - mpbarrett p; - mpnumber g; - mpnumber x; - - bee.read(p); - bee.read(g); - bee.read(x); - - return new DHPrivateKeyImpl(p, g, x); - } - - if (algo == ALGORITHM_DSA) - { - mpbarrett p; - mpbarrett q; - mpnumber g; - mpnumber x; - - bee.read(p); - bee.read(q); - bee.read(g); - bee.read(x); - - return new DSAPrivateKeyImpl(p, q, g, x); - } - - if (algo == ALGORITHM_RSA) - { - mpbarrett n; - mpnumber d; - - bee.read(n); - bee.read(d); - - if (bee.available() > 0) - { - mpnumber e; - mpbarrett p; - mpbarrett q; - mpnumber dp; - mpnumber dq; - mpnumber qi; - - bee.read(e); - bee.read(p); - bee.read(q); - bee.read(dp); - bee.read(dq); - bee.read(qi); - - return new RSAPrivateCrtKeyImpl(n, e, d, p, q, dp, dq, qi); - } - return new RSAPrivateKeyImpl(n, d); - } - } - catch (IOException) - { - } - return 0; -} - -PublicKey* BeeKeyFactory::decodePublic(const byte* data, size_t offset, size_t size) -{ - try - { - String algo; - - ByteArrayInputStream bis(data, offset, size); - BeeInputStream bee(bis); - - bee.readUTF(algo); - - if (algo == ALGORITHM_DH) - { - mpbarrett p; - mpnumber g; - mpnumber y; - - bee.read(p); - bee.read(g); - bee.read(y); - - return new DHPublicKeyImpl(p, g, y); - } - - if (algo == ALGORITHM_DSA) - { - mpbarrett p; - mpbarrett q; - mpnumber g; - mpnumber y; - - bee.read(p); - bee.read(q); - bee.read(g); - bee.read(y); - - return new DSAPublicKeyImpl(p, q, g, y); - } - - if (algo == ALGORITHM_RSA) - { - mpbarrett n; - mpnumber e; - - bee.read(n); - bee.read(e); - - return new RSAPublicKeyImpl(n, e); - } - } - catch (IOException) - { - } - return 0; -} - -bytearray* BeeKeyFactory::encode(const PrivateKey& pri) -{ - try - { - ByteArrayOutputStream bos; - BeeOutputStream bee(bos); - - bee.writeUTF(pri.getAlgorithm()); - - const DHPrivateKey* dh = dynamic_cast<const DHPrivateKey*>(&pri); - if (dh) - { - bee.write(dh->getParams().getP()); - bee.write(dh->getParams().getG()); - bee.write(dh->getX()); - bee.close(); - - return bos.toByteArray(); - } - - const DSAPrivateKey* dsa = dynamic_cast<const DSAPrivateKey*>(&pri); - if (dsa) - { - bee.write(dsa->getParams().getP()); - bee.write(dsa->getParams().getQ()); - bee.write(dsa->getParams().getG()); - bee.write(dsa->getX()); - bee.close(); - - return bos.toByteArray(); - } - - const RSAPrivateKey* rsa = dynamic_cast<const RSAPrivateKey*>(&pri); - if (rsa) - { - bee.write(rsa->getModulus()); - - const RSAPrivateCrtKey* crt = dynamic_cast<const RSAPrivateCrtKey*>(rsa); - - if (crt) - { - bee.write(crt->getPublicExponent()); - bee.write(crt->getPrivateExponent()); - bee.write(crt->getPrimeP()); - bee.write(crt->getPrimeQ()); - bee.write(crt->getPrimeExponentP()); - bee.write(crt->getPrimeExponentQ()); - bee.write(crt->getCrtCoefficient()); - } - else - { - bee.write(rsa->getPrivateExponent()); - } - bee.close(); - - return bos.toByteArray(); - } - } - catch (IOException) - { - } - return 0; -} - - -bytearray* BeeKeyFactory::encode(const PublicKey& pub) -{ - try - { - ByteArrayOutputStream bos; - BeeOutputStream bee(bos); - - bee.writeUTF(pub.getAlgorithm()); - - const DHPublicKey* dh = dynamic_cast<const DHPublicKey*>(&pub); - if (dh) - { - bee.write(dh->getParams().getP()); - bee.write(dh->getParams().getG()); - bee.write(dh->getY()); - bee.close(); - - return bos.toByteArray(); - } - - const DSAPublicKey* dsa = dynamic_cast<const DSAPublicKey*>(&pub); - if (dsa) - { - bee.write(dsa->getParams().getP()); - bee.write(dsa->getParams().getQ()); - bee.write(dsa->getParams().getG()); - bee.write(dsa->getY()); - bee.close(); - - return bos.toByteArray(); - } - - const RSAPublicKey* rsa = dynamic_cast<const RSAPublicKey*>(&pub); - if (rsa) - { - bee.write(rsa->getModulus()); - bee.write(rsa->getPublicExponent()); - bee.close(); - - return bos.toByteArray(); - } - } - catch (IOException) - { - } - return 0; -} - -PrivateKey* BeeKeyFactory::engineGeneratePrivate(const KeySpec& spec) throw (InvalidKeySpecException) -{ - const EncodedKeySpec* enc = dynamic_cast<const EncodedKeySpec*>(&spec); - - if (enc && enc->getFormat().caseCompare("BEE", 0) == 0) - { - const bytearray& encoding = enc->getEncoded(); - - PrivateKey* pri = decodePrivate(encoding.data(), 0, encoding.size()); - - if (pri) - return pri; - else - throw InvalidKeySpecException("Unable to decode this KeySpec to a PrivateKey"); - } - else - throw InvalidKeySpecException("Unsupported KeySpec"); -} - -PublicKey* BeeKeyFactory::engineGeneratePublic(const KeySpec& spec) throw (InvalidKeySpecException) -{ - const EncodedKeySpec* enc = dynamic_cast<const EncodedKeySpec*>(&spec); - - if (enc && enc->getFormat().caseCompare("BEE", 0) == 0) - { - const bytearray& encoding = enc->getEncoded(); - - PublicKey* pub = decodePublic(encoding.data(), 0, encoding.size()); - - if (pub) - return pub; - else - throw InvalidKeySpecException("Unable to decode this KeySpec to a PublicKey"); - } - else - throw InvalidKeySpecException("Unsupported KeySpec"); -} - -KeySpec* BeeKeyFactory::engineGetKeySpec(const Key& key, const type_info& info) throw (InvalidKeySpecException) -{ - KeySpec* result = 0; - - if (info == typeid(EncodedKeySpec)) - { - const String* format = key.getFormat(); - - if (format && format->caseCompare("BEE", 0) == 0) - { - result = new BeeEncodedKeySpec(*key.getEncoded()); - } - else - { - bytearray* enc; - - const PublicKey* pub = dynamic_cast<const PublicKey*>(&key); - - if (pub) - { - enc = encode(*pub); - } - else - { - const PrivateKey* pri = dynamic_cast<const PrivateKey*>(&key); - - if (pri) - { - enc = encode(*pri); - } - } - - if (enc) - { - result = new BeeEncodedKeySpec(*enc); - - delete enc; - } - } - - if (result) - return result; - else - throw InvalidKeySpecException("Unsupported key type"); - } - else - throw InvalidKeySpecException("Unsupported KeySpec type"); -} - -Key* BeeKeyFactory::engineTranslateKey(const Key&) throw (InvalidKeyException) -{ - throw InvalidKeyException("This KeyFactory can only be used for encoding and decoding"); -} diff --git a/beecrypt/c++/provider/BeeKeyFactory.h b/beecrypt/c++/provider/BeeKeyFactory.h deleted file mode 100644 index 87238d339..000000000 --- a/beecrypt/c++/provider/BeeKeyFactory.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file BeeKeyFactory.h - * \ingroup CXX_PROVIDER_m - */ - -#ifndef _CLASS_BEEKEYFACTORY_H -#define _CLASS_BEEKEYFACTORY_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/KeyFactorySpi.h" -using beecrypt::security::InvalidKeyException; -using beecrypt::security::Key; -using beecrypt::security::KeyFactorySpi; -using beecrypt::security::PrivateKey; -using beecrypt::security::PublicKey; -using beecrypt::security::spec::InvalidKeySpecException; -using beecrypt::security::spec::KeySpec; - -namespace beecrypt { - namespace provider { - class BeeKeyFactory : public KeyFactorySpi - { - public: - static PrivateKey* decodePrivate(const byte*, size_t, size_t); - static PublicKey* decodePublic(const byte*, size_t, size_t); - static bytearray* encode(const PrivateKey&); - static bytearray* encode(const PublicKey&); - - protected: - virtual PrivateKey* engineGeneratePrivate(const KeySpec&) throw (InvalidKeySpecException); - virtual PublicKey* engineGeneratePublic(const KeySpec&) throw (InvalidKeySpecException); - - virtual KeySpec* engineGetKeySpec(const Key&, const type_info&) throw (InvalidKeySpecException); - - virtual Key* engineTranslateKey(const Key&) throw (InvalidKeyException); - - public: - BeeKeyFactory(); - virtual ~BeeKeyFactory(); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/BeeKeyStore.cxx b/beecrypt/c++/provider/BeeKeyStore.cxx deleted file mode 100644 index 1a6e87089..000000000 --- a/beecrypt/c++/provider/BeeKeyStore.cxx +++ /dev/null @@ -1,639 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/aes.h" -#include "beecrypt/pkcs12.h" -#include "beecrypt/sha256.h" - -#include "beecrypt/c++/crypto/Mac.h" -using beecrypt::crypto::Mac; -#include "beecrypt/c++/io/ByteArrayInputStream.h" -using beecrypt::io::ByteArrayInputStream; -#include "beecrypt/c++/io/DataInputStream.h" -using beecrypt::io::DataInputStream; -#include "beecrypt/c++/io/DataOutputStream.h" -using beecrypt::io::DataOutputStream; -#include "beecrypt/c++/crypto/MacInputStream.h" -using beecrypt::crypto::MacInputStream; -#include "beecrypt/c++/crypto/MacOutputStream.h" -using beecrypt::crypto::MacOutputStream; -#include "beecrypt/c++/security/SecureRandom.h" -using beecrypt::security::SecureRandom; -#include "beecrypt/c++/beeyond/PKCS12PBEKey.h" -using beecrypt::beeyond::PKCS12PBEKey; -#include "beecrypt/c++/provider/KeyProtector.h" -using beecrypt::provider::KeyProtector; -#include "beecrypt/c++/provider/BeeKeyStore.h" - -using namespace beecrypt::provider; - -namespace { - const array<javachar> EMPTY_PASSWORD; -} - -#define BKS_MAGIC ((javaint) 0xbeecceec) -#define BKS_VERSION_1 ((javaint) 0x1) -#define BKS_PRIVATEKEY_ENTRY ((javaint) 0x1) -#define BKS_CERTIFICATE_ENTRY ((javaint) 0x2) - -BeeKeyStore::Entry::~Entry() -{ -} - -BeeKeyStore::KeyEntry::KeyEntry() -{ -} - -BeeKeyStore::KeyEntry::KeyEntry(const bytearray& b, const vector<Certificate*>& c) -{ - encryptedkey = b; - for (vector<Certificate*>::const_iterator it = c.begin(); it != c.end(); it++) - chain.push_back((*it)->clone()); -} - -BeeKeyStore::KeyEntry::~KeyEntry() -{ - // delete all the certificates in the chain - for (size_t i = 0; i < chain.size(); i++) - delete chain[i]; -} - -BeeKeyStore::CertEntry::CertEntry() -{ - cert = 0; -} - -BeeKeyStore::CertEntry::CertEntry(const Certificate& c) -{ - cert = c.clone(); -} - -BeeKeyStore::CertEntry::~CertEntry() -{ - if (cert) - { - delete cert; - cert = 0; - } -} - -BeeKeyStore::BeeKeyStore() -{ - _lock.init(); -} - -BeeKeyStore::~BeeKeyStore() -{ - _lock.lock(); - clearall(); - _lock.unlock(); - _lock.destroy(); -} - -BeeKeyStore::AliasEnum::AliasEnum(const BeeKeyStore::entry_map& map) -{ - _it = map.begin(); - _end = map.end(); -} - -BeeKeyStore::AliasEnum::~AliasEnum() throw () -{ -} - -bool BeeKeyStore::AliasEnum::hasMoreElements() throw () -{ - return _it != _end; -} - -const void* BeeKeyStore::AliasEnum::nextElement() throw (NoSuchElementException) -{ - if (_it == _end) - throw NoSuchElementException(); - - return (const void*) &((_it++)->first); -} - -void BeeKeyStore::clearall() -{ - keyfactory_map::iterator kit = _keyfactories.begin(); - while (kit != _keyfactories.end()) - { - delete kit->second; - _keyfactories.erase(kit++); - } - - certfactory_map::iterator cit = _certfactories.begin(); - while (cit != _certfactories.end()) - { - delete cit->second; - _certfactories.erase(cit++); - } - - entry_map::iterator eit = _entries.begin(); - while (eit != _entries.end()) - { - delete eit->second; - _entries.erase(eit++); - } -} - -Enumeration* BeeKeyStore::engineAliases() -{ - return new AliasEnum(_entries); -} - -bool BeeKeyStore::engineContainsAlias(const String& alias) -{ - return (_entries[alias] != 0); -} - -void BeeKeyStore::engineDeleteEntry(const String& alias) throw (KeyStoreException) -{ - _lock.lock(); - entry_map::iterator it = _entries.find(alias); - - if (it != _entries.end()) - { - delete it->second; - _entries.erase(it); - } - _lock.unlock(); -} - -const Date* BeeKeyStore::engineGetCreationDate(const String& alias) -{ - const Date* result = 0; - - _lock.lock(); - entry_map::iterator it = _entries.find(alias); - if (it != _entries.end()) - result = &(it->second->date); - _lock.unlock(); - return result; -} - -const Certificate* BeeKeyStore::engineGetCertificate(const String& alias) -{ - const Certificate* result = 0; - - _lock.lock(); - entry_map::iterator it = _entries.find(alias); - if (it != _entries.end()) - { - CertEntry* ce = dynamic_cast<CertEntry*>(it->second); - if (ce) - result = ce->cert; - } - _lock.unlock(); - return result; -} - -const String* BeeKeyStore::engineGetCertificateAlias(const Certificate& cert) -{ - const String* result = 0; - - _lock.lock(); - for (entry_map::const_iterator it = _entries.begin(); it != _entries.end(); ++it) - { - const CertEntry* ce = dynamic_cast<const CertEntry*>(it->second); - if (ce) - { - if (cert == *(ce->cert)) - { - result = &(it->first); - break; - } - } - } - _lock.unlock(); - return result; -} - -const vector<Certificate*>* BeeKeyStore::engineGetCertificateChain(const String& alias) -{ - const vector<Certificate*>* result = 0; - - _lock.unlock(); - entry_map::iterator it = _entries.find(alias); - if (it != _entries.end()) - { - KeyEntry* ke = dynamic_cast<KeyEntry*>(it->second); - if (ke) - result = &ke->chain; - } - _lock.unlock(); - return result; -} - -bool BeeKeyStore::engineIsCertificateEntry(const String& alias) -{ - bool result = false; - _lock.lock(); - entry_map::iterator it = _entries.find(alias); - if (it != _entries.end()) - result = (dynamic_cast<CertEntry*>(it->second) != 0); - _lock.unlock(); - return result; -} - -void BeeKeyStore::engineSetCertificateEntry(const String& alias, const Certificate& cert) throw (KeyStoreException) -{ - _entries[alias] = new CertEntry(cert); -} - -Key* BeeKeyStore::engineGetKey(const String& alias, const array<javachar>& password) throw (NoSuchAlgorithmException, UnrecoverableKeyException) -{ - Key* result = 0; - - _lock.lock(); - entry_map::iterator it = _entries.find(alias); - if (it != _entries.end()) - { - KeyEntry* ke = dynamic_cast<KeyEntry*>(it->second); - if (ke) - { - PKCS12PBEKey pbekey(password, &_salt, _iter); - - try - { - KeyProtector p(pbekey); - - result = p.recover(ke->encryptedkey); - } - catch (InvalidKeyException e) - { - _lock.unlock(); - throw KeyStoreException(e.getMessage()); - } - catch (...) - { - _lock.unlock(); - throw; - } - } - } - _lock.unlock(); - - return result; -} - -bool BeeKeyStore::engineIsKeyEntry(const String& alias) -{ - bool result = false; - _lock.lock(); - entry_map::iterator it = _entries.find(alias); - if (it != _entries.end()) - result = (dynamic_cast<KeyEntry*>(it->second) != 0); - _lock.unlock(); - return result; -} - -void BeeKeyStore::engineSetKeyEntry(const String& alias, const bytearray& key, const vector<Certificate*>& chain) throw (KeyStoreException) -{ - _lock.lock(); - _entries[alias] = new KeyEntry(key, chain); - _lock.unlock(); -} - -void BeeKeyStore::engineSetKeyEntry(const String& alias, const Key& key, const array<javachar>& password, const vector<Certificate*>& chain) throw (KeyStoreException) -{ - PKCS12PBEKey pbekey(password, &_salt, _iter); - - try - { - const PrivateKey* pri = dynamic_cast<const PrivateKey*>(&key); - if (pri) - { - KeyProtector p(pbekey); - - bytearray *tmp = p.protect(*pri); - - if (tmp) - engineSetKeyEntry(alias, *tmp, chain); - else - throw KeyStoreException("Failed to protect key"); - } - else - throw KeyStoreException("BeeKeyStore only supports storing of PrivateKey objects"); - } - catch (InvalidKeyException e) - { - throw KeyStoreException(e.getMessage()); - } -} - -size_t BeeKeyStore::engineSize() const -{ - return _entries.size(); -} - -void BeeKeyStore::engineLoad(InputStream* in, const array<javachar>* password) throw (IOException, CertificateException, NoSuchAlgorithmException) -{ - _lock.lock(); - - if (in == 0) - { - randomGeneratorContext rngc; - - /* salt size default is 64 bytes */ - _salt.resize(64); - /* generate a new salt */ - randomGeneratorContextNext(&rngc, _salt.data(), _salt.size()); - /* set default iteration count */ - _iter = 1024; - - _lock.unlock(); - - return; - } - - Mac* m = 0; - - try - { - m = Mac::getInstance("HMAC-SHA-256"); - - MacInputStream mis(*in, *m); - DataInputStream dis(mis); - - mis.on(false); - - javaint magic = dis.readInt(); - javaint version = dis.readInt(); - - if (magic != BKS_MAGIC || version != BKS_VERSION_1) - throw IOException("Invalid KeyStore format"); - - clearall(); - - javaint saltsize = dis.readInt(); - if (saltsize <= 0) - throw IOException("Invalid KeyStore salt size"); - - _salt.resize(saltsize); - dis.readFully(_salt); - - _iter = dis.readInt(); - if (_iter <= 0) - throw IOException("Invalid KeyStore iteration count"); - - PKCS12PBEKey pbekey(password ? *password : EMPTY_PASSWORD, &_salt, _iter); - - m->init(pbekey); - - mis.on(true); - - javaint entrycount = dis.readInt(); - - if (entrycount <= 0) - throw IOException("Invalid KeyStore entry count"); - - for (javaint i = 0; i < entrycount; i++) - { - String alias; - - switch (dis.readInt()) - { - case BKS_PRIVATEKEY_ENTRY: - { - dis.readUTF(alias); - - KeyEntry* e = new KeyEntry; - - try - { - e->date.setTime(dis.readLong()); - - javaint keysize = dis.readInt(); - - if (keysize <= 0) - throw IOException("Invalid KeyStore key length"); - - e->encryptedkey.resize((size_t) keysize); - - dis.readFully(e->encryptedkey); - - javaint certcount = dis.readInt(); - - if (certcount <= 0) - throw IOException("Invalid KeyStore certificate count"); - - for (javaint j = 0; j < certcount; j++) - { - String type; - - dis.readUTF(type); - - // see if we have a CertificateFactory of this type available - CertificateFactory* cf = _certfactories[type]; - if (!cf) - { - // apparently not; get a new one and cache it - _certfactories[type] = cf = CertificateFactory::getInstance(type); - } - - javaint certsize = dis.readInt(); - - if (certsize <= 0) - throw IOException("Invalid KeyStore certificate size"); - - bytearray cert(certsize); - - dis.readFully(cert); - - ByteArrayInputStream bis(cert); - - e->chain.push_back(cf->generateCertificate(bis)); - } - - _entries[alias] = e; - } - catch (...) - { - delete e; - throw; - } - } - break; - - case BKS_CERTIFICATE_ENTRY: - { - dis.readUTF(alias); - - CertEntry* e = new CertEntry; - - try - { - e->date.setTime(dis.readLong()); - - String type; - - dis.readUTF(type); - - // see if we have a CertificateFactory of this type available - CertificateFactory* cf = _certfactories[type]; - if (!cf) - { - // apparently not; get a new one and cache it - _certfactories[type] = cf = CertificateFactory::getInstance(type); - } - - javaint certsize = dis.readInt(); - - if (certsize <= 0) - throw IOException("Invalid KeyStore certificate size"); - - bytearray cert(certsize); - - dis.readFully(cert); - - ByteArrayInputStream bis(cert); - - e->cert = cf->generateCertificate(bis); - - _entries[alias] = e; - } - catch (...) - { - delete e; - throw; - } - } - break; - - default: - throw IOException("Invalid KeyStore entry tag"); - } - } - - bytearray computed_mac, original_mac; - - mis.on(false); - - javaint macsize = dis.available(); - if (macsize <= 0) - throw IOException("Invalid KeyStore MAC size"); - - computed_mac = m->doFinal(); - if (macsize != computed_mac.size()) - throw KeyStoreException("KeyStore has been tampered with, or password was incorrect"); - - original_mac.resize(macsize); - dis.readFully(original_mac); - - if (computed_mac != original_mac) - throw KeyStoreException("KeyStore has been tampered with, or password was incorrect"); - - delete m; - } - catch (...) - { - if (m) - delete m; - - _lock.unlock(); - throw; - } - - _lock.unlock(); -} - -void BeeKeyStore::engineStore(OutputStream& out, const array<javachar>* password) throw (IOException, CertificateException, NoSuchAlgorithmException) -{ - _lock.lock(); - - Mac* m = 0; - - try - { - m = Mac::getInstance("HMAC-SHA-256"); - - PKCS12PBEKey pbekey(password ? *password : EMPTY_PASSWORD, &_salt, _iter); - - m->init(pbekey); - - MacOutputStream mos(out, *m); - DataOutputStream dos(mos); - - mos.on(false); - dos.writeInt(BKS_MAGIC); - dos.writeInt(BKS_VERSION_1); - dos.writeInt(_salt.size()); - dos.write(_salt); - dos.writeInt(_iter); - mos.on(true); - dos.writeInt(_entries.size()); - - for (entry_map::const_iterator it = _entries.begin(); it != _entries.end(); ++it) - { - const KeyEntry* ke = dynamic_cast<const KeyEntry*>(it->second); - if (ke) - { - dos.writeInt(BKS_PRIVATEKEY_ENTRY); - dos.writeUTF(it->first); - dos.writeLong(ke->date.getTime()); - dos.writeInt(ke->encryptedkey.size()); - dos.write(ke->encryptedkey); - /* next do all the certificates for this key */ - dos.writeInt(ke->chain.size()); - for (vector<Certificate*>::const_iterator cit = ke->chain.begin(); cit != ke->chain.end(); ++cit) - { - const Certificate* cert = *cit; - - dos.writeUTF(cert->getType()); - dos.writeInt(cert->getEncoded().size()); - dos.write(cert->getEncoded()); - } - continue; - } - - const CertEntry* ce = dynamic_cast<const CertEntry*>(it->second); - if (ce) - { - dos.writeInt(BKS_CERTIFICATE_ENTRY); - dos.writeUTF(it->first); - dos.writeLong(ce->date.getTime()); - dos.writeUTF(ce->cert->getType()); - dos.writeInt(ce->cert->getEncoded().size()); - dos.write(ce->cert->getEncoded()); - continue; - } - - throw RuntimeException(); - } - /* don't call close on a FilterOutputStream because the - * underlying stream still has to write data! - */ - dos.flush(); - mos.flush(); - - out.write(m->doFinal()); - out.close(); - - _lock.unlock(); - } - catch (...) - { - _lock.unlock(); - throw; - } -} diff --git a/beecrypt/c++/provider/BeeKeyStore.h b/beecrypt/c++/provider/BeeKeyStore.h deleted file mode 100644 index 625346d42..000000000 --- a/beecrypt/c++/provider/BeeKeyStore.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file BeeKeyStore.h - * \ingroup CXX_PROVIDER_m - */ - -#ifndef _CLASS_BEEKEYSTORE_H -#define _CLASS_BEEKEYSTORE_H - -#ifdef __cplusplus - -#include "beecrypt/c++/mutex.h" -using beecrypt::mutex; -#include "beecrypt/c++/security/KeyStoreSpi.h" -using beecrypt::security::KeyStoreSpi; -#include "beecrypt/c++/security/KeyFactory.h" -using beecrypt::security::KeyFactory; -#include "beecrypt/c++/security/cert/CertificateFactory.h" -using beecrypt::security::cert::CertificateFactory; -#include "beecrypt/c++/util/Enumeration.h" -using beecrypt::util::Enumeration; - -#include <map> -using std::map; - -namespace beecrypt { - namespace provider { - /*!\brief The default BeeCrypt KeyStore. - */ - class BeeKeyStore : public KeyStoreSpi - { - private: - mutex _lock; - bytearray _bmac; - bytearray _salt; - size_t _iter; - - struct Entry - { - Date date; - virtual ~Entry(); - }; - - struct KeyEntry : public Entry - { - bytearray encryptedkey; - vector<Certificate*> chain; - - KeyEntry(); - KeyEntry(const bytearray& key, const vector<Certificate*>&); - virtual ~KeyEntry(); - }; - - struct CertEntry : public Entry - { - Certificate* cert; - - CertEntry(); - CertEntry(const Certificate&); - virtual ~CertEntry(); - }; - - typedef map<String, KeyFactory*> keyfactory_map; - keyfactory_map _keyfactories; - - typedef map<String, CertificateFactory*> certfactory_map; - certfactory_map _certfactories; - - typedef map<String, Entry*> entry_map; - entry_map _entries; - - struct AliasEnum : public Enumeration - { - entry_map::const_iterator _it; - entry_map::const_iterator _end; - - AliasEnum(const entry_map&); - virtual ~AliasEnum() throw (); - - virtual bool hasMoreElements() throw (); - virtual const void* nextElement() throw (NoSuchElementException); - }; - - void clearall(); - - protected: - virtual Enumeration* engineAliases(); - - virtual bool engineContainsAlias(const String& alias); - - virtual void engineDeleteEntry(const String& alias) throw (KeyStoreException); - virtual const Date* engineGetCreationDate(const String& alias); - - virtual const Certificate* engineGetCertificate(const String& alias); - virtual const String* engineGetCertificateAlias(const Certificate& cert); - virtual const vector<Certificate*>* engineGetCertificateChain(const String& alias); - virtual bool engineIsCertificateEntry(const String& alias); - virtual void engineSetCertificateEntry(const String& alias, const Certificate& cert) throw (KeyStoreException); - - virtual Key* engineGetKey(const String& alias, const array<javachar>& password) throw (NoSuchAlgorithmException, UnrecoverableKeyException); - virtual bool engineIsKeyEntry(const String& alias); - virtual void engineSetKeyEntry(const String& alias, const bytearray& key, const vector<Certificate*>&) throw (KeyStoreException); - virtual void engineSetKeyEntry(const String& alias, const Key& key, const array<javachar>& password, const vector<Certificate*>&) throw (KeyStoreException); - - virtual size_t engineSize() const; - - virtual void engineLoad(InputStream* in, const array<javachar>* password) throw (IOException, CertificateException, NoSuchAlgorithmException); - virtual void engineStore(OutputStream& out, const array<javachar>* password) throw (IOException, CertificateException, NoSuchAlgorithmException); - - public: - BeeKeyStore(); - ~BeeKeyStore(); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/BeeSecureRandom.cxx b/beecrypt/c++/provider/BeeSecureRandom.cxx deleted file mode 100644 index 3f3020011..000000000 --- a/beecrypt/c++/provider/BeeSecureRandom.cxx +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/provider/BeeSecureRandom.h" - -using namespace beecrypt::provider; - -BeeSecureRandom::BeeSecureRandom() -{ -} - -BeeSecureRandom::BeeSecureRandom(const randomGenerator* rng) : _rngc(rng) -{ -} - -BeeSecureRandom::~BeeSecureRandom() -{ -} - -SecureRandomSpi* BeeSecureRandom::create() -{ - return new BeeSecureRandom(); -} - -void BeeSecureRandom::engineGenerateSeed(byte* data, size_t size) -{ - entropyGatherNext(data, size); -} - -void BeeSecureRandom::engineNextBytes(byte* data, size_t size) -{ - randomGeneratorContextNext(&_rngc, data, size); -} - -void BeeSecureRandom::engineSetSeed(const byte* data, size_t size) -{ - randomGeneratorContextSeed(&_rngc, data, size); -} diff --git a/beecrypt/c++/provider/BeeSecureRandom.h b/beecrypt/c++/provider/BeeSecureRandom.h deleted file mode 100644 index 1f21934f0..000000000 --- a/beecrypt/c++/provider/BeeSecureRandom.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file BeeSecureRandom.h - * \ingroup CXX_PROVIDER_m - */ - -#ifndef _CLASS_BEESECURERANDOM_H -#define _CLASS_BEESECURERANDOM_H - -#include "beecrypt/beecrypt.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/security/SecureRandomSpi.h" -using beecrypt::security::SecureRandomSpi; - -namespace beecrypt { - namespace provider { - class BeeSecureRandom : public SecureRandomSpi - { - private: - randomGeneratorContext _rngc; - - protected: - BeeSecureRandom(const randomGenerator*); - - private: - static SecureRandomSpi* create(); - - virtual void engineGenerateSeed(byte*, size_t); - virtual void engineNextBytes(byte*, size_t); - virtual void engineSetSeed(const byte*, size_t); - - public: - BeeSecureRandom(); - virtual ~BeeSecureRandom(); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/DHKeyFactory.cxx b/beecrypt/c++/provider/DHKeyFactory.cxx deleted file mode 100644 index f9f42b2db..000000000 --- a/beecrypt/c++/provider/DHKeyFactory.cxx +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/crypto/spec/DHPrivateKeySpec.h" -using beecrypt::crypto::spec::DHPrivateKeySpec; -#include "beecrypt/c++/crypto/spec/DHPublicKeySpec.h" -using beecrypt::crypto::spec::DHPublicKeySpec; -#include "beecrypt/c++/provider/DHKeyFactory.h" -#include "beecrypt/c++/provider/DHPrivateKeyImpl.h" -#include "beecrypt/c++/provider/DHPublicKeyImpl.h" -#include "beecrypt/c++/security/KeyFactory.h" -using beecrypt::security::KeyFactory; -#include "beecrypt/c++/security/spec/EncodedKeySpec.h" -using beecrypt::security::spec::EncodedKeySpec; - -using namespace beecrypt::provider; - -DHKeyFactory::DHKeyFactory() -{ -} - -DHKeyFactory::~DHKeyFactory() -{ -} - -PrivateKey* DHKeyFactory::engineGeneratePrivate(const KeySpec& spec) throw (InvalidKeySpecException) -{ - const DHPrivateKeySpec* dh = dynamic_cast<const DHPrivateKeySpec*>(&spec); - if (dh) - { - return new DHPrivateKeyImpl(dh->getP(), dh->getG(), dh->getX()); - } - - const EncodedKeySpec* enc = dynamic_cast<const EncodedKeySpec*>(&spec); - if (enc) - { - try - { - KeyFactory* kf = KeyFactory::getInstance(enc->getFormat()); - try - { - PrivateKey* pri = kf->generatePrivate(*enc); - delete kf; - return pri; - } - catch (...) - { - delete kf; - throw; - } - } - catch (NoSuchAlgorithmException) - { - throw InvalidKeySpecException("Unsupported KeySpec encoding format"); - } - } - throw InvalidKeySpecException("Unsupported KeySpec type"); -} - -PublicKey* DHKeyFactory::engineGeneratePublic(const KeySpec& spec) throw (InvalidKeySpecException) -{ - const DHPublicKeySpec* dh = dynamic_cast<const DHPublicKeySpec*>(&spec); - if (dh) - { - return new DHPublicKeyImpl(dh->getP(), dh->getG(), dh->getY()); - } - - const EncodedKeySpec* enc = dynamic_cast<const EncodedKeySpec*>(&spec); - if (enc) - { - try - { - KeyFactory* kf = KeyFactory::getInstance(enc->getFormat()); - try - { - PublicKey* pub = kf->generatePublic(*enc); - delete kf; - return pub; - } - catch (...) - { - delete kf; - throw; - } - } - catch (NoSuchAlgorithmException) - { - throw InvalidKeySpecException("Unsupported KeySpec encoding format"); - } - } - throw InvalidKeySpecException("Unsupported KeySpec type"); -} - -KeySpec* DHKeyFactory::engineGetKeySpec(const Key& key, const type_info& info) throw (InvalidKeySpecException) -{ - const DHPublicKey* pub = dynamic_cast<const DHPublicKey*>(&key); - if (pub) - { - if (info == typeid(KeySpec) || info == typeid(DHPrivateKeySpec)) - { - const DHParams& params = pub->getParams(); - - return new DHPublicKeySpec(params.getP(), params.getG(), pub->getY()); - } - /*!\todo also support EncodedKeySpec - */ - /* - if (info == typeid(EncodedKeySpec)) - { - } - */ - - throw InvalidKeySpecException("Unsupported KeySpec type"); - } - - const DHPrivateKey* pri = dynamic_cast<const DHPrivateKey*>(&key); - if (pri) - { - if (info == typeid(KeySpec) || info == typeid(DHPublicKeySpec)) - { - const DHParams& params = pri->getParams(); - - return new DHPrivateKeySpec(params.getP(), params.getG(), pri->getX()); - } - /*!\todo also support EncodedKeySpec - */ - /* - if (info == typeid(EncodedKeySpec)) - { - } - */ - - throw InvalidKeySpecException("Unsupported KeySpec type"); - } - - throw InvalidKeySpecException("Unsupported Key type"); -} - -Key* DHKeyFactory::engineTranslateKey(const Key& key) throw (InvalidKeyException) -{ - const DHPublicKey* pub = dynamic_cast<const DHPublicKey*>(&key); - if (pub) - return new DHPublicKeyImpl(*pub); - - const DHPrivateKey* pri = dynamic_cast<const DHPrivateKey*>(&key); - if (pri) - return new DHPrivateKeyImpl(*pri); - - throw InvalidKeyException("Unsupported Key type"); -} diff --git a/beecrypt/c++/provider/DHKeyFactory.h b/beecrypt/c++/provider/DHKeyFactory.h deleted file mode 100644 index 7d367aca0..000000000 --- a/beecrypt/c++/provider/DHKeyFactory.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DHKeyFactory.h - * \ingroup CXX_PROV_m - */ - -#ifndef _CLASS_DHKEYFACTORY_H -#define _CLASS_DHKEYFACTORY_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/KeyFactorySpi.h" -using beecrypt::security::InvalidKeyException; -using beecrypt::security::Key; -using beecrypt::security::KeyFactorySpi; -using beecrypt::security::PrivateKey; -using beecrypt::security::PublicKey; -using beecrypt::security::spec::InvalidKeySpecException; -using beecrypt::security::spec::KeySpec; - -namespace beecrypt { - namespace provider { - class DHKeyFactory : public KeyFactorySpi - { - protected: - virtual PrivateKey* engineGeneratePrivate(const KeySpec&) throw (InvalidKeySpecException); - virtual PublicKey* engineGeneratePublic(const KeySpec&) throw (InvalidKeySpecException); - - virtual KeySpec* engineGetKeySpec(const Key&, const type_info&) throw (InvalidKeySpecException); - - virtual Key* engineTranslateKey(const Key&) throw (InvalidKeyException); - - public: - DHKeyFactory(); - virtual ~DHKeyFactory(); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/DHKeyPairGenerator.cxx b/beecrypt/c++/provider/DHKeyPairGenerator.cxx deleted file mode 100644 index 2e740a14f..000000000 --- a/beecrypt/c++/provider/DHKeyPairGenerator.cxx +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/adapter.h" -#include "beecrypt/c++/crypto/spec/DHParameterSpec.h" -#include "beecrypt/c++/provider/DHKeyPairGenerator.h" -#include "beecrypt/c++/provider/DHPublicKeyImpl.h" -#include "beecrypt/c++/provider/DHPrivateKeyImpl.h" -#include "beecrypt/c++/provider/BeeCryptProvider.h" -#include "beecrypt/c++/security/KeyPair.h" - -#include "beecrypt/dldp.h" - -/* precomputed safe primes; it's easy to create generators for these; - * - * using a dldp_p struct, set p from the hex value; set q = p/2 and r = 2 - * then call dldp_pgonGenerator. - */ -namespace { - const char* P_2048 = "fd12e8b7e096a28a00fb548035953cf0eba64ceb5dff0f5672d376d59c196da729f6b5586f18e6f3f1a86c73c5b15662f59439613b309e52aa257488619e5f76a7c4c3f7a426bdeac66bf88343482941413cef06256b39c62744dcb97e7b78e36ec6b885b143f6f3ad0a1cd8a5713e338916613892a264d4a47e72b583fbdaf5bce2bbb0097f7e65cbc86d684882e5bb8196d522dcacd6ad00dfbcd8d21613bdb59c485a65a58325d792272c09ad1173e12c98d865adb4c4d676ada79830c58c37c42dff8536e28f148a23f296513816d3dfed0397a3d4d6e1fa24f07e1b01643a68b4274646a3b876e810206eddacea2b9ef7636a1da5880ef654288b857ea3"; - const char* P_1024 = "e64a3deeddb723e2e4db54c2b09567d196367a86b3b302be07e43ffd7f2e016f866de5135e375bdd2fba6ea9b4299010fafa36dc6b02ba3853cceea07ee94bfe30e0cc82a69c73163be26e0c4012dfa0b2839c97d6cd71eee59a303d6177c6a6740ca63bd04c1ba084d6c369dc2fbfaeebe951d58a4824de52b580442d8cae77"; -}; - -using namespace beecrypt::provider; - -DHKeyPairGenerator::DHKeyPairGenerator() -{ - _size = 0; - _spec = 0; - _srng = 0; -} - -DHKeyPairGenerator::~DHKeyPairGenerator() -{ - _size = 0; - if (_spec) - { - delete _spec; - _spec = 0; - } - _srng = 0; -} - -KeyPair* DHKeyPairGenerator::genpair(randomGeneratorContext* rngc) -{ - dhparam param; - size_t l; - mpnumber x; - mpnumber y; - - if (_spec) - { - param.p = _spec->getP(); - param.g = _spec->getG(); - l = _spec->getL(); - } - else - { - if (_size == 2048) - { - mpbsethex(¶m.p, P_2048); - } - else if (_size == 1024 || _size == 0) - { - mpbsethex(¶m.p, P_1024); - } - - if (_size == 2048 || _size == 1024 || _size == 0) - { - mpnumber q; - - /* set q to half of P */ - mpnset(&q, param.p.size, param.p.modl); - mpdivtwo(q.size, q.data); - mpbset(¶m.q, q.size, q.data); - /* set r to 2 */ - mpnsetw(¶m.r, 2); - - /* make a generator, order n */ - dldp_pgonGenerator(¶m, rngc); - } - else - { - if (dldp_pgonMakeSafe(¶m, rngc, _size)) - throw "unexpected error in dldp_pMakeSafe"; - } - } - - if (_spec && _spec->getL()) - dldp_pPair_s(¶m, rngc, &x, &y, _spec->getL()); - else - dldp_pPair (¶m, rngc, &x, &y); - - KeyPair* result = new KeyPair(new DHPublicKeyImpl(param, y), new DHPrivateKeyImpl(param, x)); - - x.wipe(); - - return result; -} - -KeyPair* DHKeyPairGenerator::engineGenerateKeyPair() -{ - if (_srng) - { - randomGeneratorContextAdapter rngc(_srng); - - return genpair(&rngc); - } - else - { - randomGeneratorContext rngc(randomGeneratorDefault()); - - return genpair(&rngc); - } -} - -void DHKeyPairGenerator::engineInitialize(const AlgorithmParameterSpec& spec, SecureRandom* random) throw (InvalidAlgorithmParameterException) -{ - const DHParameterSpec* dhspec = dynamic_cast<const DHParameterSpec*>(&spec); - - if (dhspec) - { - if (_spec) - delete _spec; - - _spec = new DHParameterSpec(*dhspec); - _srng = random; - } - else - throw InvalidAlgorithmParameterException("not a DHParameterSpec"); -} - -void DHKeyPairGenerator::engineInitialize(size_t keysize, SecureRandom* random) throw (InvalidParameterException) -{ - if (keysize < 768) - throw InvalidParameterException("Safe prime size must be at least 768 bits"); - - _size = keysize; - if (_spec) - { - delete _spec; - _spec = 0; - } - _srng = random; -} diff --git a/beecrypt/c++/provider/DHKeyPairGenerator.h b/beecrypt/c++/provider/DHKeyPairGenerator.h deleted file mode 100644 index a01be6450..000000000 --- a/beecrypt/c++/provider/DHKeyPairGenerator.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DHKeyPairGenerator.h - * \ingroup CXX_PROV_m - */ - -#ifndef _CLASS_DHKEYPAIRGENERATOR_H -#define _CLASS_DHKEYPAIRGENERATOR_H - -#ifdef __cplusplus - -#include "beecrypt/c++/crypto/spec/DHParameterSpec.h" -using beecrypt::crypto::spec::DHParameterSpec; -#include "beecrypt/c++/security/KeyPairGeneratorSpi.h" -using beecrypt::security::KeyPairGeneratorSpi; - -namespace beecrypt { - namespace provider { - class DHKeyPairGenerator : public KeyPairGeneratorSpi - { - private: - size_t _size; - size_t _l; - DHParameterSpec* _spec; - SecureRandom* _srng; - - KeyPair* genpair(randomGeneratorContext*); - - protected: - virtual KeyPair* engineGenerateKeyPair(); - - virtual void engineInitialize(const AlgorithmParameterSpec&, SecureRandom*) throw (InvalidAlgorithmParameterException); - virtual void engineInitialize(size_t, SecureRandom*) throw (InvalidParameterException); - - public: - DHKeyPairGenerator(); - virtual ~DHKeyPairGenerator(); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/DHParameterGenerator.cxx b/beecrypt/c++/provider/DHParameterGenerator.cxx deleted file mode 100644 index d43aa7e3b..000000000 --- a/beecrypt/c++/provider/DHParameterGenerator.cxx +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/adapter.h" -using beecrypt::randomGeneratorContextAdapter; -#include "beecrypt/c++/provider/BeeCryptProvider.h" -#include "beecrypt/c++/provider/DHParameterGenerator.h" -#include "beecrypt/c++/security/AlgorithmParameters.h" -using beecrypt::security::AlgorithmParameters; -#include "beecrypt/c++/crypto/spec/DHParameterSpec.h" -using beecrypt::crypto::spec::DHParameterSpec; - -using namespace beecrypt::provider; - -DHParameterGenerator::DHParameterGenerator() -{ - _size = 0; - _spec = 0; - _srng = 0; -} - -DHParameterGenerator::~DHParameterGenerator() -{ - if (_spec) - { - delete _spec; - _spec = 0; - } - _size = 0; - _srng = 0; -} - -AlgorithmParameters* DHParameterGenerator::engineGenerateParameters() -{ - if (!_spec) - { - dldp_p param; - - if (_srng) - { - randomGeneratorContextAdapter rngc(_srng); - if (dldp_pgonMakeSafe(¶m, &rngc, _size)) - throw "unexpected error in dldp_pMake"; - } - else - { - randomGeneratorContext rngc(randomGeneratorDefault()); - if (dldp_pgonMakeSafe(¶m, &rngc, _size)) - throw "unexpected error in dldp_pMake"; - } - - _spec = new DHParameterSpec(param.p, param.g); - } - - try - { - AlgorithmParameters* param = AlgorithmParameters::getInstance("DH"); - - param->init(*_spec); - - return param; - } - catch (Exception* ex) - { - // shouldn't happen - delete ex; - } - - return 0; -} - -void DHParameterGenerator::engineInit(const AlgorithmParameterSpec& spec, SecureRandom* random) throw (InvalidAlgorithmParameterException) -{ - const DHParameterSpec* dhspec = dynamic_cast<const DHParameterSpec*>(&spec); - - if (dhspec) - { - if (_spec) - { - delete _spec; - _spec = 0; - } - - _spec = new DHParameterSpec(*dhspec); - - _srng = random; - } - else - throw InvalidAlgorithmParameterException("expected DHParameterSpec"); -} - -void DHParameterGenerator::engineInit(size_t keysize, SecureRandom* random) throw (InvalidParameterException) -{ - if ((keysize < 768) || ((keysize & 0x3f) != 0)) - throw InvalidParameterException("Prime size must be greater than 768 and be a multiple of 64"); - - _size = keysize; - if (_spec) - { - delete _spec; - _spec = 0; - } - _srng = random; -} diff --git a/beecrypt/c++/provider/DHParameterGenerator.h b/beecrypt/c++/provider/DHParameterGenerator.h deleted file mode 100644 index 42c87c1a4..000000000 --- a/beecrypt/c++/provider/DHParameterGenerator.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DHParameterGenerator.h - * \ingroup CXX_PROV_m - */ - -#ifndef _CLASS_DHPARAMETERGENERATOR_H -#define _CLASS_DHPARAMETERGENERATOR_H - -#include "beecrypt/dldp.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/security/AlgorithmParameterGeneratorSpi.h" -using beecrypt::security::AlgorithmParameterGeneratorSpi; -#include "beecrypt/c++/crypto/spec/DHParameterSpec.h" -using beecrypt::crypto::spec::DHParameterSpec; - -namespace beecrypt { - namespace provider { - class DHParameterGenerator : public AlgorithmParameterGeneratorSpi - { - private: - size_t _size; - DHParameterSpec* _spec; - SecureRandom* _srng; - - protected: - virtual AlgorithmParameters* engineGenerateParameters(); - - virtual void engineInit(const AlgorithmParameterSpec&, SecureRandom*) throw (InvalidAlgorithmParameterException); - virtual void engineInit(size_t, SecureRandom*) throw (InvalidParameterException); - - public: - DHParameterGenerator(); - virtual ~DHParameterGenerator(); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/DHParameters.cxx b/beecrypt/c++/provider/DHParameters.cxx deleted file mode 100644 index 0b06a8a31..000000000 --- a/beecrypt/c++/provider/DHParameters.cxx +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/provider/BeeCryptProvider.h" -#include "beecrypt/c++/provider/DHParameters.h" - -using namespace beecrypt::provider; - -DHParameters::DHParameters() -{ - _spec = 0; -} - -DHParameters::~DHParameters() -{ - if (_spec) - { - delete _spec; - _spec = 0; - } -} - -AlgorithmParameterSpec* DHParameters::engineGetParameterSpec(const type_info& info) throw (InvalidParameterSpecException) -{ - if (info == typeid(AlgorithmParameterSpec) || info == typeid(DHParameterSpec)) - { - if (_spec) - { - return new DHParameterSpec(*_spec); - } - else - throw InvalidParameterSpecException("not initialized"); - } - else - throw InvalidParameterSpecException("expected a DHParameterSpec"); -} - -void DHParameters::engineInit(const AlgorithmParameterSpec& spec) throw (InvalidParameterSpecException) -{ - const DHParameterSpec* tmp = dynamic_cast<const DHParameterSpec*>(&spec); - - if (tmp) - { - if (_spec) - { - delete _spec; - _spec = 0; - } - _spec = new DHParameterSpec(*tmp); - } - else - throw InvalidParameterSpecException("expected a DHParameterSpec"); -} - -void DHParameters::engineInit(const byte*, size_t) -{ - throw "not implemented"; -} - -void DHParameters::engineInit(const byte*, size_t, const String& format) -{ - throw "not implemented"; -} diff --git a/beecrypt/c++/provider/DHParameters.h b/beecrypt/c++/provider/DHParameters.h deleted file mode 100644 index 0beb6bac3..000000000 --- a/beecrypt/c++/provider/DHParameters.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DHParameters.h - * \ingroup CXX_PROV_m - */ - -#ifndef _CLASS_DHPARAMETERS_H -#define _CLASS_DHPARAMETERS_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/AlgorithmParametersSpi.h" -using beecrypt::security::AlgorithmParametersSpi; -#include "beecrypt/c++/crypto/spec/DHParameterSpec.h" -using beecrypt::crypto::spec::DHParameterSpec; - -namespace beecrypt { - namespace provider { - class DHParameters : public AlgorithmParametersSpi - { - private: - DHParameterSpec* _spec; - - protected: - virtual AlgorithmParameterSpec* engineGetParameterSpec(const type_info&) throw (InvalidParameterSpecException); - - virtual void engineInit(const AlgorithmParameterSpec&) throw (InvalidParameterSpecException); - virtual void engineInit(const byte*, size_t); - virtual void engineInit(const byte*, size_t, const String&); - - public: - DHParameters(); - virtual ~DHParameters(); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/DHPrivateKeyImpl.cxx b/beecrypt/c++/provider/DHPrivateKeyImpl.cxx deleted file mode 100644 index 7055629ce..000000000 --- a/beecrypt/c++/provider/DHPrivateKeyImpl.cxx +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/resource.h" -#include "beecrypt/c++/provider/DHPrivateKeyImpl.h" -#include "beecrypt/c++/provider/BeeKeyFactory.h" - -using namespace beecrypt::provider; - -DHPrivateKeyImpl::DHPrivateKeyImpl(const DHPrivateKey& copy) -{ - _params = new DHParameterSpec(copy.getParams()); - _x = copy.getX(); - _enc = 0; -} - -DHPrivateKeyImpl::DHPrivateKeyImpl(const DHParams& params, const mpnumber& x) -{ - _params = new DHParameterSpec(params.getP(), params.getG(), params.getL()); - _x = x; - _enc = 0; -} - -DHPrivateKeyImpl::DHPrivateKeyImpl(const dhparam& params, const mpnumber& x) -{ - _params = new DHParameterSpec(params.p, params.g); - _x = x; - _enc = 0; -} - -DHPrivateKeyImpl::DHPrivateKeyImpl(const mpbarrett& p, const mpnumber& g, const mpnumber& x) -{ - _params = new DHParameterSpec(p, g); - _x = x; - _enc = 0; -} - -DHPrivateKeyImpl::~DHPrivateKeyImpl() -{ - delete _params; - _x.wipe(); - if (_enc); - delete _enc; -} - -DHPrivateKey* DHPrivateKeyImpl::clone() const -{ - return new DHPrivateKeyImpl(*this); -} - -const DHParams& DHPrivateKeyImpl::getParams() const throw () -{ - return *_params; -} - -const mpnumber& DHPrivateKeyImpl::getX() const throw () -{ - return _x; -} - -const bytearray* DHPrivateKeyImpl::getEncoded() const -{ - if (!_enc) - _enc = BeeKeyFactory::encode(*this); - - return _enc; -} - -const String& DHPrivateKeyImpl::getAlgorithm() const throw () -{ - static const String ALGORITHM = UNICODE_STRING_SIMPLE("DH"); - return ALGORITHM; -} - -const String* DHPrivateKeyImpl::getFormat() const throw () -{ - static const String FORMAT = UNICODE_STRING_SIMPLE("BEE"); - return &FORMAT; -} diff --git a/beecrypt/c++/provider/DHPrivateKeyImpl.h b/beecrypt/c++/provider/DHPrivateKeyImpl.h deleted file mode 100644 index 164fb024e..000000000 --- a/beecrypt/c++/provider/DHPrivateKeyImpl.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DHPrivateKeyImpl.h - * \ingroup CXX_PROV_m - */ - -#ifndef _CLASS_DHPRIVATEKEYIMPL_H -#define _CLASS_DHPRIVATEKEYIMPL_H - -#ifdef __cplusplus - -#include "beecrypt/c++/crypto/interfaces/DHPrivateKey.h" -using beecrypt::crypto::interfaces::DHPrivateKey; -#include "beecrypt/c++/crypto/spec/DHParameterSpec.h" -using beecrypt::crypto::spec::DHParameterSpec; - -using beecrypt::bytearray; -using beecrypt::crypto::interfaces::DHParams; -using beecrypt::lang::String; - -namespace beecrypt { - namespace provider { - class DHPrivateKeyImpl : public DHPrivateKey - { - private: - DHParameterSpec* _params; - mpnumber _x; - mutable bytearray* _enc; - - public: - DHPrivateKeyImpl(const DHPrivateKey&); - DHPrivateKeyImpl(const DHParams&, const mpnumber&); - DHPrivateKeyImpl(const dhparam&, const mpnumber&); - DHPrivateKeyImpl(const mpbarrett&, const mpnumber&, const mpnumber&); - virtual ~DHPrivateKeyImpl(); - - virtual DHPrivateKey* clone() const; - - virtual const DHParams& getParams() const throw (); - virtual const mpnumber& getX() const throw (); - - virtual const bytearray* getEncoded() const; - - virtual const String& getAlgorithm() const throw (); - virtual const String* getFormat() const throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/DHPublicKeyImpl.cxx b/beecrypt/c++/provider/DHPublicKeyImpl.cxx deleted file mode 100644 index 65689b7bc..000000000 --- a/beecrypt/c++/provider/DHPublicKeyImpl.cxx +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/provider/BeeKeyFactory.h" -#include "beecrypt/c++/provider/DHPublicKeyImpl.h" - -using namespace beecrypt::provider; - -DHPublicKeyImpl::DHPublicKeyImpl(const DHPublicKey& copy) -{ - _params = new DHParameterSpec(copy.getParams()); - _y = copy.getY(); - _enc = 0; -} - -DHPublicKeyImpl::DHPublicKeyImpl(const DHParams& params, const mpnumber& y) -{ - _params = new DHParameterSpec(params.getP(), params.getG(), params.getL()); - _y = y; - _enc = 0; -} - -DHPublicKeyImpl::DHPublicKeyImpl(const dhparam& params, const mpnumber& y) -{ - _params = new DHParameterSpec(params.p, params.g); - _y = y; - _enc = 0; -} - -DHPublicKeyImpl::DHPublicKeyImpl(const mpbarrett& p, const mpnumber& g, const mpnumber& y) -{ - _params = new DHParameterSpec(p, g); - _y = y; - _enc = 0; -} - -DHPublicKeyImpl::~DHPublicKeyImpl() -{ - delete _params; - if (_enc) - delete _enc; -} - -DHPublicKey* DHPublicKeyImpl::clone() const -{ - return new DHPublicKeyImpl(*this); -} - -const DHParams& DHPublicKeyImpl::getParams() const throw () -{ - return *_params; -} - -const mpnumber& DHPublicKeyImpl::getY() const throw () -{ - return _y; -} - -const bytearray* DHPublicKeyImpl::getEncoded() const -{ - if (!_enc) - _enc = BeeKeyFactory::encode(*this); - - return _enc; -} - -const String& DHPublicKeyImpl::getAlgorithm() const throw () -{ - static const String ALGORITHM = UNICODE_STRING_SIMPLE("DH"); - return ALGORITHM; -} - -const String* DHPublicKeyImpl::getFormat() const throw () -{ - static const String FORMAT = UNICODE_STRING_SIMPLE("BEE"); - return &FORMAT; -} diff --git a/beecrypt/c++/provider/DHPublicKeyImpl.h b/beecrypt/c++/provider/DHPublicKeyImpl.h deleted file mode 100644 index a1d3be57a..000000000 --- a/beecrypt/c++/provider/DHPublicKeyImpl.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DHPublicKeyImpl.h - * \ingroup CXX_PROV_m - */ - -#ifndef _CLASS_DHPUBLICKEYIMPL_H -#define _CLASS_DHPUBLICKEYIMPL_H - -#ifdef __cplusplus - -#include "beecrypt/c++/crypto/interfaces/DHPublicKey.h" -using beecrypt::crypto::interfaces::DHPublicKey; -#include "beecrypt/c++/crypto/spec/DHParameterSpec.h" -using beecrypt::crypto::spec::DHParameterSpec; - -using beecrypt::bytearray; -using beecrypt::crypto::interfaces::DHParams; -using beecrypt::lang::String; - -namespace beecrypt { - namespace provider { - class DHPublicKeyImpl : public DHPublicKey - { - private: - DHParameterSpec* _params; - mpnumber _y; - mutable bytearray* _enc; - - public: - DHPublicKeyImpl(const DHPublicKey&); - DHPublicKeyImpl(const DHParams&, const mpnumber&); - DHPublicKeyImpl(const dhparam&, const mpnumber&); - DHPublicKeyImpl(const mpbarrett&, const mpnumber&, const mpnumber&); - ~DHPublicKeyImpl(); - - virtual DHPublicKey* clone() const; - - virtual const DHParams& getParams() const throw (); - virtual const mpnumber& getY() const throw (); - - virtual const bytearray* getEncoded() const; - - virtual const String& getAlgorithm() const throw (); - virtual const String* getFormat() const throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/DSAKeyFactory.cxx b/beecrypt/c++/provider/DSAKeyFactory.cxx deleted file mode 100644 index 249368fbc..000000000 --- a/beecrypt/c++/provider/DSAKeyFactory.cxx +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/provider/DSAKeyFactory.h" -#include "beecrypt/c++/provider/DSAPrivateKeyImpl.h" -#include "beecrypt/c++/provider/DSAPublicKeyImpl.h" -#include "beecrypt/c++/security/KeyFactory.h" -using beecrypt::security::KeyFactory; -#include "beecrypt/c++/security/spec/DSAPrivateKeySpec.h" -using beecrypt::security::spec::DSAPrivateKeySpec; -#include "beecrypt/c++/security/spec/DSAPublicKeySpec.h" -using beecrypt::security::spec::DSAPublicKeySpec; -#include "beecrypt/c++/security/spec/EncodedKeySpec.h" -using beecrypt::security::spec::EncodedKeySpec; - -using namespace beecrypt::provider; - -DSAKeyFactory::DSAKeyFactory() -{ -} - -DSAKeyFactory::~DSAKeyFactory() -{ -} - -PrivateKey* DSAKeyFactory::engineGeneratePrivate(const KeySpec& spec) throw (InvalidKeySpecException) -{ - const DSAPrivateKeySpec* dsa = dynamic_cast<const DSAPrivateKeySpec*>(&spec); - if (dsa) - { - return new DSAPrivateKeyImpl(dsa->getP(), dsa->getQ(), dsa->getG(), dsa->getX()); - } - - const EncodedKeySpec* enc = dynamic_cast<const EncodedKeySpec*>(&spec); - if (enc) - { - try - { - KeyFactory* kf = KeyFactory::getInstance(enc->getFormat()); - try - { - PrivateKey* pri = kf->generatePrivate(*enc); - delete kf; - return pri; - } - catch (...) - { - delete kf; - throw; - } - } - catch (NoSuchAlgorithmException) - { - throw InvalidKeySpecException("Unsupported KeySpec encoding format"); - } - } - throw InvalidKeySpecException("Unsupported KeySpec type"); -} - -PublicKey* DSAKeyFactory::engineGeneratePublic(const KeySpec& spec) throw (InvalidKeySpecException) -{ - const DSAPublicKeySpec* dsa = dynamic_cast<const DSAPublicKeySpec*>(&spec); - if (dsa) - { - return new DSAPublicKeyImpl(dsa->getP(), dsa->getQ(), dsa->getG(), dsa->getY()); - } - - const EncodedKeySpec* enc = dynamic_cast<const EncodedKeySpec*>(&spec); - if (enc) - { - try - { - KeyFactory* kf = KeyFactory::getInstance(enc->getFormat()); - try - { - PublicKey* pub = kf->generatePublic(*enc); - delete kf; - return pub; - } - catch (...) - { - delete kf; - throw; - } - } - catch (NoSuchAlgorithmException) - { - throw InvalidKeySpecException("Unsupported KeySpec encoding format"); - } - } - throw InvalidKeySpecException("Unsupported KeySpec type"); -} - -KeySpec* DSAKeyFactory::engineGetKeySpec(const Key& key, const type_info& info) throw (InvalidKeySpecException) -{ - const DSAPublicKey* pub = dynamic_cast<const DSAPublicKey*>(&key); - - if (pub) - { - if (info == typeid(KeySpec) || info == typeid(DSAPublicKeySpec)) - { - const DSAParams& params = pub->getParams(); - - return new DSAPublicKeySpec(params.getP(), params.getQ(), params.getG(), pub->getY()); - } - /*!\todo also support EncodeKeySpec - */ - /* - if (info == typeid(EncodedKeySpec)) - { - } - */ - - throw InvalidKeySpecException("Unsupported KeySpec type"); - } - - const DSAPrivateKey* pri = dynamic_cast<const DSAPrivateKey*>(&key); - - if (pri) - { - if (info == typeid(KeySpec) || info == typeid(DSAPrivateKeySpec)) - { - const DSAParams& params = pri->getParams(); - - return new DSAPrivateKeySpec(params.getP(), params.getQ(), params.getG(), pri->getX()); - } - /*!\todo also support EncodeKeySpec - */ - /* - if (info == typeid(EncodedKeySpec)) - { - } - */ - - throw InvalidKeySpecException("Unsupported KeySpec type"); - } - - throw InvalidKeySpecException("Unsupported Key type"); -} - -Key* DSAKeyFactory::engineTranslateKey(const Key& key) throw (InvalidKeyException) -{ - const DSAPublicKey* pub = dynamic_cast<const DSAPublicKey*>(&key); - if (pub) - return new DSAPublicKeyImpl(*pub); - - const DSAPrivateKey* pri = dynamic_cast<const DSAPrivateKey*>(&key); - if (pri) - return new DSAPrivateKeyImpl(*pri); - - throw InvalidKeyException("Unsupported Key type"); -} diff --git a/beecrypt/c++/provider/DSAKeyFactory.h b/beecrypt/c++/provider/DSAKeyFactory.h deleted file mode 100644 index b9c360b68..000000000 --- a/beecrypt/c++/provider/DSAKeyFactory.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DSAKeyFactory.h - * \ingroup CXX_PROV_m - */ - -#ifndef _CLASS_DSAKEYFACTORY_H -#define _CLASS_DSAKEYFACTORY_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/KeyFactorySpi.h" -using beecrypt::security::InvalidKeyException; -using beecrypt::security::Key; -using beecrypt::security::KeyFactorySpi; -using beecrypt::security::PrivateKey; -using beecrypt::security::PublicKey; -using beecrypt::security::spec::InvalidKeySpecException; -using beecrypt::security::spec::KeySpec; - -namespace beecrypt { - namespace provider { - class DSAKeyFactory : public KeyFactorySpi - { - protected: - virtual PrivateKey* engineGeneratePrivate(const KeySpec&) throw (InvalidKeySpecException); - virtual PublicKey* engineGeneratePublic(const KeySpec&) throw (InvalidKeySpecException); - - virtual KeySpec* engineGetKeySpec(const Key&, const type_info&) throw (InvalidKeySpecException); - - virtual Key* engineTranslateKey(const Key&) throw (InvalidKeyException); - - public: - DSAKeyFactory(); - virtual ~DSAKeyFactory(); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/DSAKeyPairGenerator.cxx b/beecrypt/c++/provider/DSAKeyPairGenerator.cxx deleted file mode 100644 index 139c83f78..000000000 --- a/beecrypt/c++/provider/DSAKeyPairGenerator.cxx +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/adapter.h" -using beecrypt::randomGeneratorContextAdapter; -#include "beecrypt/c++/provider/BeeCryptProvider.h" -#include "beecrypt/c++/provider/DSAKeyPairGenerator.h" -#include "beecrypt/c++/provider/DSAPublicKeyImpl.h" -#include "beecrypt/c++/provider/DSAPrivateKeyImpl.h" -#include "beecrypt/c++/security/KeyPair.h" -using beecrypt::security::KeyPair; -#include "beecrypt/c++/security/spec/DSAParameterSpec.h" -using beecrypt::security::spec::DSAParameterSpec; - -namespace { - const char* P_512 = "fca682ce8e12caba26efccf7110e526db078b05edecbcd1eb4a208f3ae1617ae01f35b91a47e6df63413c5e12ed0899bcd132acd50d99151bdc43ee737592e17"; - const char* Q_512 = "962eddcc369cba8ebb260ee6b6a126d9346e38c5"; - const char* G_512 = "678471b27a9cf44ee91a49c5147db1a9aaf244f05a434d6486931d2d14271b9e35030b71fd73da179069b32e2935630e1c2062354d0da20a6c416e50be794ca4"; - - const char* P_768 = "e9e642599d355f37c97ffd3567120b8e25c9cd43e927b3a9670fbec5d890141922d2c3b3ad2480093799869d1e846aab49fab0ad26d2ce6a22219d470bce7d777d4a21fbe9c270b57f607002f3cef8393694cf45ee3688c11a8c56ab127a3daf"; - const char* Q_768 = "9cdbd84c9f1ac2f38d0f80f42ab952e7338bf511"; - const char* G_768 = "30470ad5a005fb14ce2d9dcd87e38bc7d1b1c5facbaecbe95f190aa7a31d23c4dbbcbe06174544401a5b2c020965d8c2bd2171d3668445771f74ba084d2029d83c1c158547f3a9f1a2715be23d51ae4d3e5a1f6a7064f316933a346d3f529252"; - - const char* P_1024 = "fd7f53811d75122952df4a9c2eece4e7f611b7523cef4400c31e3f80b6512669455d402251fb593d8d58fabfc5f5ba30f6cb9b556cd7813b801d346ff26660b76b9950a5a49f9fe8047b1022c24fbba9d7feb7c61bf83b57e7c6a8a6150f04fb83f6d3c51ec3023554135a169132f675f3ae2b61d72aeff22203199dd14801c7"; - const char* Q_1024 = "9760508f15230bccb292b982a2eb840bf0581cf5"; - const char* G_1024 = "f7e1a085d69b3ddecbbcab5c36b857b97994afbbfa3aea82f9574c0b3d0782675159578ebad4594fe67107108180b449167123e84c281613b7cf09328cc8a6e13c167a8b547c8d28e0a3ae1e2bb3a675916ea37f0bfa213562f1fb627a01243bcca4f1bea8519089a883dfe15ae59f06928b665e807b552564014c3bfecf492a"; -}; - -using namespace beecrypt::provider; - -DSAKeyPairGenerator::DSAKeyPairGenerator() -{ - _size = 0; - _spec = 0; - _srng = 0; -} - -DSAKeyPairGenerator::~DSAKeyPairGenerator() -{ - _size = 0; - if (_spec) - { - delete _spec; - _spec = 0; - } - _srng = 0; -} - -KeyPair* DSAKeyPairGenerator::genpair(randomGeneratorContext* rngc) -{ - dsaparam param; - mpnumber x; - mpnumber y; - - if (_spec) - { - param.p = _spec->getP(); - param.q = _spec->getQ(); - param.g = _spec->getG(); - } - else - { - if (_size == 512) - { - mpbsethex(¶m.p, P_512); - mpbsethex(¶m.q, Q_512); - mpnsethex(¶m.g, G_512); - } - else if (_size == 768) - { - mpbsethex(¶m.p, P_768); - mpbsethex(¶m.q, Q_768); - mpnsethex(¶m.g, G_768); - } - else if ((_size == 1024) || !_size) - { - mpbsethex(¶m.p, P_1024); - mpbsethex(¶m.q, Q_1024); - mpnsethex(¶m.g, G_1024); - } - else - { - if (dsaparamMake(¶m, rngc, _size)) - throw "unexpected error in dsaparamMake"; - } - } - - if (dldp_pPair(¶m, rngc, &x, &y)) - throw "unexpected error in dldp_pPair"; - - KeyPair* result = new KeyPair(new DSAPublicKeyImpl(param, y), new DSAPrivateKeyImpl(param, x)); - - x.wipe(); - - return result; -} - -KeyPair* DSAKeyPairGenerator::engineGenerateKeyPair() -{ - if (_srng) - { - randomGeneratorContextAdapter rngc(_srng); - - return genpair(&rngc); - } - else - { - randomGeneratorContext rngc(randomGeneratorDefault()); - - return genpair(&rngc); - } -} - -void DSAKeyPairGenerator::engineInitialize(const AlgorithmParameterSpec& spec, SecureRandom* random) throw (InvalidAlgorithmParameterException) -{ - const DSAParameterSpec* dsaspec = dynamic_cast<const DSAParameterSpec*>(&spec); - - if (dsaspec) - { - if (_spec) - delete _spec; - - _spec = new DSAParameterSpec(*dsaspec); - _srng = random; - } - else - throw InvalidAlgorithmParameterException("not a DSAParameterSpec"); -} - -void DSAKeyPairGenerator::engineInitialize(size_t keysize, SecureRandom* random) throw (InvalidParameterException) -{ - if ((keysize < 512) || (keysize > 1024) || ((keysize & 0x3f) != 0)) - throw InvalidParameterException("Prime size must range from 512 to 1024 bits and be a multiple of 64"); - - _size = keysize; - if (_spec) - { - delete _spec; - _spec = 0; - } - _srng = random; -} diff --git a/beecrypt/c++/provider/DSAKeyPairGenerator.h b/beecrypt/c++/provider/DSAKeyPairGenerator.h deleted file mode 100644 index a9f834670..000000000 --- a/beecrypt/c++/provider/DSAKeyPairGenerator.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DSAKeyPairGenerator.h - * \ingroup CXX_PROV_m - */ - -#ifndef _CLASS_DSAKEYPAIRGENERATOR_H -#define _CLASS_DSAKEYPAIRGENERATOR_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/KeyPairGeneratorSpi.h" -using beecrypt::security::KeyPairGeneratorSpi; -#include "beecrypt/c++/security/SecureRandom.h" -using beecrypt::security::SecureRandom; -#include "beecrypt/c++/security/spec/DSAParameterSpec.h" -using beecrypt::security::spec::DSAParameterSpec; - -namespace beecrypt { - namespace provider { - class DSAKeyPairGenerator : public KeyPairGeneratorSpi - { - private: - size_t _size; - DSAParameterSpec* _spec; - SecureRandom* _srng; - - KeyPair* genpair(randomGeneratorContext*); - - protected: - virtual KeyPair* engineGenerateKeyPair(); - - virtual void engineInitialize(const AlgorithmParameterSpec&, SecureRandom*) throw (InvalidAlgorithmParameterException); - virtual void engineInitialize(size_t, SecureRandom*) throw (InvalidParameterException); - - public: - DSAKeyPairGenerator(); - virtual ~DSAKeyPairGenerator(); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/DSAParameterGenerator.cxx b/beecrypt/c++/provider/DSAParameterGenerator.cxx deleted file mode 100644 index 7acb2f0b9..000000000 --- a/beecrypt/c++/provider/DSAParameterGenerator.cxx +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/adapter.h" -using beecrypt::randomGeneratorContextAdapter; -#include "beecrypt/c++/provider/BeeCryptProvider.h" -#include "beecrypt/c++/provider/DSAParameterGenerator.h" -#include "beecrypt/c++/security/AlgorithmParameters.h" -using beecrypt::security::AlgorithmParameters; -#include "beecrypt/c++/security/spec/DSAParameterSpec.h" -using beecrypt::security::spec::DSAParameterSpec; - -using namespace beecrypt::provider; - -DSAParameterGenerator::DSAParameterGenerator() -{ - _size = 0; - _spec = 0; - _srng = 0; -} - -DSAParameterGenerator::~DSAParameterGenerator() -{ - if (_spec) - { - delete _spec; - _spec = 0; - } - _size = 0; - _srng = 0; -} - -AlgorithmParameters* DSAParameterGenerator::engineGenerateParameters() -{ - if (!_spec) - { - dsaparam param; - - if (_srng) - { - randomGeneratorContextAdapter rngc(_srng); - if (dsaparamMake(¶m, &rngc, _size)) - throw "unexpected error in dsaparamMake"; - } - else - { - randomGeneratorContext rngc(randomGeneratorDefault()); - if (dsaparamMake(¶m, &rngc, _size)) - throw "unexpected error in dsaparamMake"; - } - - _spec = new DSAParameterSpec(param.p, param.q, param.g); - } - - try - { - AlgorithmParameters* param = AlgorithmParameters::getInstance("DSA"); - - param->init(*_spec); - - return param; - } - catch (Exception* ex) - { - // shouldn't happen - delete ex; - } - - return 0; -} - -void DSAParameterGenerator::engineInit(const AlgorithmParameterSpec& spec, SecureRandom* random) throw (InvalidAlgorithmParameterException) -{ - const DSAParameterSpec* dsaspec = dynamic_cast<const DSAParameterSpec*>(&spec); - - if (dsaspec) - { - if (_spec) - { - delete _spec; - _spec = 0; - } - - _spec = new DSAParameterSpec(*dsaspec); - - _srng = random; - } - else - throw InvalidAlgorithmParameterException("expected DSAParameterSpec"); -} - -void DSAParameterGenerator::engineInit(size_t keysize, SecureRandom* random) throw (InvalidParameterException) -{ - if ((keysize < 512) || (keysize > 1024) || ((keysize & 0x3f) != 0)) - throw InvalidParameterException("Prime size must range from 512 to 1024 bits and be a multiple of 64"); - - _size = keysize; - if (_spec) - { - delete _spec; - _spec = 0; - } - _srng = random; -} diff --git a/beecrypt/c++/provider/DSAParameterGenerator.h b/beecrypt/c++/provider/DSAParameterGenerator.h deleted file mode 100644 index 2cbdfeee0..000000000 --- a/beecrypt/c++/provider/DSAParameterGenerator.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DSAParameterGenerator.h - * \ingroup CXX_PROV_m - */ - -#ifndef _CLASS_DSAPARAMETERGENERATOR_H -#define _CLASS_DSAPARAMETERGENERATOR_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/AlgorithmParameterGeneratorSpi.h" -using beecrypt::security::AlgorithmParameterGeneratorSpi; -#include "beecrypt/c++/security/spec/DSAParameterSpec.h" -using beecrypt::security::spec::DSAParameterSpec; - -namespace beecrypt { - namespace provider { - class DSAParameterGenerator : public AlgorithmParameterGeneratorSpi - { - private: - size_t _size; - DSAParameterSpec* _spec; - SecureRandom* _srng; - - protected: - virtual AlgorithmParameters* engineGenerateParameters(); - - virtual void engineInit(const AlgorithmParameterSpec&, SecureRandom*) throw (InvalidAlgorithmParameterException); - virtual void engineInit(size_t, SecureRandom*) throw (InvalidParameterException); - - public: - DSAParameterGenerator(); - virtual ~DSAParameterGenerator(); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/DSAParameters.cxx b/beecrypt/c++/provider/DSAParameters.cxx deleted file mode 100644 index f5cc99665..000000000 --- a/beecrypt/c++/provider/DSAParameters.cxx +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/provider/BeeCryptProvider.h" -#include "beecrypt/c++/provider/DSAParameters.h" - -using namespace beecrypt::provider; - -DSAParameters::DSAParameters() -{ - _spec = 0; -} - -DSAParameters::~DSAParameters() -{ - if (_spec) - { - delete _spec; - _spec = 0; - } -} - -AlgorithmParameterSpec* DSAParameters::engineGetParameterSpec(const type_info& info) throw (InvalidParameterSpecException) -{ - if (info == typeid(AlgorithmParameterSpec) || info == typeid(DSAParameterSpec)) - { - if (_spec) - { - return new DSAParameterSpec(*_spec); - } - else - throw InvalidParameterSpecException("not initialized"); - } - else - throw InvalidParameterSpecException("expected a DSAParameterSpec"); -} - -void DSAParameters::engineInit(const AlgorithmParameterSpec& spec) throw (InvalidParameterSpecException) -{ - const DSAParameterSpec* tmp = dynamic_cast<const DSAParameterSpec*>(&spec); - - if (tmp) - { - if (_spec) - { - delete _spec; - _spec = 0; - } - _spec = new DSAParameterSpec(*tmp); - } - else - throw InvalidParameterSpecException("expected a DSAParameterSpec"); -} - -void DSAParameters::engineInit(const byte*, size_t) -{ - throw "not implemented"; -} - -void DSAParameters::engineInit(const byte*, size_t, const String& format) -{ - throw "not implemented"; -} diff --git a/beecrypt/c++/provider/DSAParameters.h b/beecrypt/c++/provider/DSAParameters.h deleted file mode 100644 index ed12ef29e..000000000 --- a/beecrypt/c++/provider/DSAParameters.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DSAParameters.h - * \ingroup CXX_PROV_m - */ - -#ifndef _CLASS_DSAPARAMETERS_H -#define _CLASS_DSAPARAMETERS_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/AlgorithmParametersSpi.h" -using beecrypt::security::AlgorithmParametersSpi; -#include "beecrypt/c++/security/spec/DSAParameterSpec.h" -using beecrypt::security::spec::DSAParameterSpec; - -namespace beecrypt { - namespace provider { - class DSAParameters : public AlgorithmParametersSpi - { - // friend class DSAParameterGenerator; - - private: - DSAParameterSpec* _spec; - - protected: - virtual AlgorithmParameterSpec* engineGetParameterSpec(const type_info&) throw (InvalidParameterSpecException); - - virtual void engineInit(const AlgorithmParameterSpec&) throw (InvalidParameterSpecException); - virtual void engineInit(const byte*, size_t); - virtual void engineInit(const byte*, size_t, const String&); - - public: - DSAParameters(); - virtual ~DSAParameters(); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/DSAPrivateKeyImpl.cxx b/beecrypt/c++/provider/DSAPrivateKeyImpl.cxx deleted file mode 100644 index 1389eff19..000000000 --- a/beecrypt/c++/provider/DSAPrivateKeyImpl.cxx +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/resource.h" -#include "beecrypt/c++/provider/DSAPrivateKeyImpl.h" -#include "beecrypt/c++/provider/BeeKeyFactory.h" - -using namespace beecrypt::provider; - -DSAPrivateKeyImpl::DSAPrivateKeyImpl(const DSAPrivateKey& copy) -{ - _params = new DSAParameterSpec(copy.getParams()); - _x = copy.getX(); - _enc = 0; -} - -DSAPrivateKeyImpl::DSAPrivateKeyImpl(const DSAParams& params, const mpnumber& x) -{ - _params = new DSAParameterSpec(params.getP(), params.getQ(), params.getG()); - _x = x; - _enc = 0; -} - -DSAPrivateKeyImpl::DSAPrivateKeyImpl(const dsaparam& params, const mpnumber& x) -{ - _params = new DSAParameterSpec(params.p, params.q, params.g); - _x = x; - _enc = 0; -} - -DSAPrivateKeyImpl::DSAPrivateKeyImpl(const mpbarrett& p, const mpbarrett& q, const mpnumber& g, const mpnumber& x) -{ - _params = new DSAParameterSpec(p, q, g); - _x = x; - _enc = 0; -} - -DSAPrivateKeyImpl::~DSAPrivateKeyImpl() -{ - delete _params; - _x.wipe(); - if (_enc) - delete _enc; -} - -DSAPrivateKey* DSAPrivateKeyImpl::clone() const -{ - return new DSAPrivateKeyImpl(*this); -} - -const DSAParams& DSAPrivateKeyImpl::getParams() const throw () -{ - return *_params; -} - -const mpnumber& DSAPrivateKeyImpl::getX() const throw () -{ - return _x; -} - -const bytearray* DSAPrivateKeyImpl::getEncoded() const -{ - if (!_enc) - _enc = BeeKeyFactory::encode(*this); - - return _enc; -} - -const String& DSAPrivateKeyImpl::getAlgorithm() const throw () -{ - static const String ALGORITHM = UNICODE_STRING_SIMPLE("DSA"); - return ALGORITHM; -} - -const String* DSAPrivateKeyImpl::getFormat() const throw () -{ - static const String FORMAT = UNICODE_STRING_SIMPLE("BEE"); - return &FORMAT; -} diff --git a/beecrypt/c++/provider/DSAPrivateKeyImpl.h b/beecrypt/c++/provider/DSAPrivateKeyImpl.h deleted file mode 100644 index 3d14a05e2..000000000 --- a/beecrypt/c++/provider/DSAPrivateKeyImpl.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DSAPrivateKeyImpl.h - * \ingroup CXX_PROV_m - */ - -#ifndef _CLASS_DSAPRIVATEKEYIMPL_H -#define _CLASS_DSAPRIVATEKEYIMPL_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/interfaces/DSAPrivateKey.h" -using beecrypt::security::interfaces::DSAPrivateKey; -#include "beecrypt/c++/security/spec/DSAParameterSpec.h" -using beecrypt::security::spec::DSAParameterSpec; - -namespace beecrypt { - namespace provider { - class DSAPrivateKeyImpl : public DSAPrivateKey - { - private: - DSAParameterSpec* _params; - mpnumber _x; - mutable bytearray* _enc; - - public: - DSAPrivateKeyImpl(const DSAPrivateKey&); - DSAPrivateKeyImpl(const DSAParams&, const mpnumber&); - DSAPrivateKeyImpl(const dsaparam&, const mpnumber&); - DSAPrivateKeyImpl(const mpbarrett&, const mpbarrett&, const mpnumber&, const mpnumber&); - - virtual ~DSAPrivateKeyImpl(); - - virtual DSAPrivateKey* clone() const; - - virtual const DSAParams& getParams() const throw (); - virtual const mpnumber& getX() const throw (); - - virtual const bytearray* getEncoded() const; - virtual const String& getAlgorithm() const throw (); - virtual const String* getFormat() const throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/DSAPublicKeyImpl.cxx b/beecrypt/c++/provider/DSAPublicKeyImpl.cxx deleted file mode 100644 index 29c8a7155..000000000 --- a/beecrypt/c++/provider/DSAPublicKeyImpl.cxx +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/resource.h" -#include "beecrypt/c++/provider/DSAPublicKeyImpl.h" -#include "beecrypt/c++/provider/BeeKeyFactory.h" - -using namespace beecrypt::provider; - -DSAPublicKeyImpl::DSAPublicKeyImpl(const DSAPublicKey& copy) -{ - _params = new DSAParameterSpec(copy.getParams()); - _y = copy.getY(); - _enc = 0; -} - -DSAPublicKeyImpl::DSAPublicKeyImpl(const DSAParams& params, const mpnumber& y) -{ - _params = new DSAParameterSpec(params.getP(), params.getQ(), params.getG()); - _y = y; - _enc = 0; -} - -DSAPublicKeyImpl::DSAPublicKeyImpl(const dsaparam& params, const mpnumber& y) -{ - _params = new DSAParameterSpec(params.p, params.q, params.g); - _y = y; - _enc = 0; -} - -DSAPublicKeyImpl::DSAPublicKeyImpl(const mpbarrett& p, const mpbarrett& q, const mpnumber& g, const mpnumber& y) -{ - _params = new DSAParameterSpec(p, q, g); - _y = y; - _enc = 0; -} - -DSAPublicKeyImpl::~DSAPublicKeyImpl() -{ - delete _params; - if (_enc) - delete _enc; -} - -DSAPublicKey* DSAPublicKeyImpl::clone() const -{ - return new DSAPublicKeyImpl(*this); -} - -const DSAParams& DSAPublicKeyImpl::getParams() const throw () -{ - return *_params; -} - -const mpnumber& DSAPublicKeyImpl::getY() const throw () -{ - return _y; -} - -const bytearray* DSAPublicKeyImpl::getEncoded() const -{ - if (!_enc) - _enc = BeeKeyFactory::encode(*this); - - return _enc; -} - -const String& DSAPublicKeyImpl::getAlgorithm() const throw () -{ - static const String ALGORITHM = UNICODE_STRING_SIMPLE("DSA"); - return ALGORITHM; -} - -const String* DSAPublicKeyImpl::getFormat() const throw () -{ - static const String FORMAT = UNICODE_STRING_SIMPLE("BEE"); - return &FORMAT; -} diff --git a/beecrypt/c++/provider/DSAPublicKeyImpl.h b/beecrypt/c++/provider/DSAPublicKeyImpl.h deleted file mode 100644 index 85c532052..000000000 --- a/beecrypt/c++/provider/DSAPublicKeyImpl.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DSAPublicKeyImpl.h - * \ingroup CXX_PROV_m - */ - -#ifndef _CLASS_DSAPUBLICKEYIMPL_H -#define _CLASS_DSAPUBLICKEYIMPL_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/interfaces/DSAPublicKey.h" -using beecrypt::security::interfaces::DSAPublicKey; -#include "beecrypt/c++/security/spec/DSAParameterSpec.h" -using beecrypt::security::spec::DSAParameterSpec; - -namespace beecrypt { - namespace provider { - class DSAPublicKeyImpl : public DSAPublicKey - { - private: - DSAParameterSpec* _params; - mpnumber _y; - mutable bytearray* _enc; - - public: - DSAPublicKeyImpl(const DSAPublicKey&); - DSAPublicKeyImpl(const DSAParams&, const mpnumber&); - DSAPublicKeyImpl(const dsaparam&, const mpnumber&); - DSAPublicKeyImpl(const mpbarrett&, const mpbarrett&, const mpnumber&, const mpnumber&); - virtual ~DSAPublicKeyImpl(); - - virtual DSAPublicKey* clone() const; - - virtual const DSAParams& getParams() const throw (); - virtual const mpnumber& getY() const throw (); - - virtual const bytearray* getEncoded() const; - virtual const String& getAlgorithm() const throw (); - virtual const String* getFormat() const throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/HMACMD5.cxx b/beecrypt/c++/provider/HMACMD5.cxx deleted file mode 100644 index 93c1bc787..000000000 --- a/beecrypt/c++/provider/HMACMD5.cxx +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/pkcs12.h" - -#include "beecrypt/c++/crypto/interfaces/PBEKey.h" -using beecrypt::crypto::interfaces::PBEKey; -#include "beecrypt/c++/lang/NullPointerException.h" -using beecrypt::lang::NullPointerException; -#include "beecrypt/c++/provider/HMACMD5.h" - -using namespace beecrypt::provider; - -HMACMD5::HMACMD5() : _digest(16) -{ -} - -HMACMD5::~HMACMD5() -{ -} - -HMACMD5* HMACMD5::clone() const -{ - HMACMD5* result = new HMACMD5(); - - memcpy(&result->_param, &_param, sizeof(hmacmd5Param)); - - return result; -} - -const bytearray& HMACMD5::engineDoFinal() -{ - hmacmd5Digest(&_param, _digest.data()); - - return _digest; -} - -size_t HMACMD5::engineDoFinal(byte* data, size_t offset, size_t length) throw (ShortBufferException) -{ - if (!data) - throw NullPointerException(); - - if (length < 16) - throw ShortBufferException(); - - hmacmd5Digest(&_param, data); - - return 16; -} - -size_t HMACMD5::engineGetMacLength() -{ - return 16; -} - -void HMACMD5::engineReset() -{ - hmacmd5Reset(&_param); -} - -void HMACMD5::engineUpdate(byte b) -{ - hmacmd5Update(&_param, &b, 1); -} - -void HMACMD5::engineUpdate(const byte* data, size_t offset, size_t length) -{ - hmacmd5Update(&_param, data+offset, length); -} - -void HMACMD5::engineInit(const Key& key, const AlgorithmParameterSpec* spec) throw (InvalidKeyException, InvalidAlgorithmParameterException) -{ - if (spec) - throw InvalidAlgorithmParameterException("No AlgorithmParameterSpec supported"); - - const PBEKey* pbe = dynamic_cast<const PBEKey*>(&key); - if (pbe) - { - byte _mac_key[16]; - bytearray _rawk, _salt; - size_t _iter; - - if (pbe->getEncoded()) - _rawk = *(pbe->getEncoded()); - else - throw InvalidKeyException("PBEKey must have an encoding"); - - if (pbe->getSalt()) - _salt = *(pbe->getSalt()); - - _iter = pbe->getIterationCount(); - - if (pkcs12_derive_key(&md5, PKCS12_ID_MAC, _rawk.data(), _rawk.size(), _salt.data(), _salt.size(), _iter, _mac_key, 16)) - throw InvalidKeyException("pkcs12_derive_key returned error"); - - hmacmd5Setup(&_param, _mac_key, 128); - - return; - } - - throw InvalidKeyException("Expected a PBEKey"); -} diff --git a/beecrypt/c++/provider/HMACMD5.h b/beecrypt/c++/provider/HMACMD5.h deleted file mode 100644 index 586688c6d..000000000 --- a/beecrypt/c++/provider/HMACMD5.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file HMACMD5.h - * \ingroup CXX_PROV_m - */ - -#ifndef _CLASS_HMACMD5_H -#define _CLASS_HMACMD5_H - -#include "beecrypt/beecrypt.h" -#include "beecrypt/hmacmd5.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/crypto/MacSpi.h" -using beecrypt::crypto::MacSpi; - -namespace beecrypt { - namespace provider { - class HMACMD5 : public MacSpi - { - private: - hmacmd5Param _param; - bytearray _digest; - - protected: - virtual const bytearray& engineDoFinal(); - virtual size_t engineDoFinal(byte*, size_t, size_t) throw (ShortBufferException); - virtual size_t engineGetMacLength(); - virtual void engineInit(const Key&, const AlgorithmParameterSpec* spec) throw (InvalidKeyException, InvalidAlgorithmParameterException); - virtual void engineReset(); - virtual void engineUpdate(byte); - virtual void engineUpdate(const byte*, size_t, size_t); - - public: - HMACMD5(); - virtual ~HMACMD5(); - - virtual HMACMD5* clone() const; - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/HMACSHA1.cxx b/beecrypt/c++/provider/HMACSHA1.cxx deleted file mode 100644 index af59b934d..000000000 --- a/beecrypt/c++/provider/HMACSHA1.cxx +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/pkcs12.h" - -#include "beecrypt/c++/crypto/interfaces/PBEKey.h" -using beecrypt::crypto::interfaces::PBEKey; -#include "beecrypt/c++/lang/NullPointerException.h" -using beecrypt::lang::NullPointerException; -#include "beecrypt/c++/provider/HMACSHA1.h" - -using namespace beecrypt::provider; - -HMACSHA1::HMACSHA1() : _digest(20) -{ -} - -HMACSHA1::~HMACSHA1() -{ -} - -HMACSHA1* HMACSHA1::clone() const -{ - HMACSHA1* result = new HMACSHA1(); - - memcpy(&result->_param, &_param, sizeof(hmacsha1Param)); - - return result; -} - -const bytearray& HMACSHA1::engineDoFinal() -{ - hmacsha1Digest(&_param, _digest.data()); - - return _digest; -} - -size_t HMACSHA1::engineDoFinal(byte* data, size_t offset, size_t length) throw (ShortBufferException) -{ - if (!data) - throw NullPointerException(); - - if (length < 20) - throw ShortBufferException(); - - hmacsha1Digest(&_param, data); - - return 20; -} - -size_t HMACSHA1::engineGetMacLength() -{ - return 20; -} - -void HMACSHA1::engineReset() -{ - hmacsha1Reset(&_param); -} - -void HMACSHA1::engineUpdate(byte b) -{ - hmacsha1Update(&_param, &b, 1); -} - -void HMACSHA1::engineUpdate(const byte* data, size_t offset, size_t length) -{ - hmacsha1Update(&_param, data+offset, length); -} - -void HMACSHA1::engineInit(const Key& key, const AlgorithmParameterSpec* spec) throw (InvalidKeyException, InvalidAlgorithmParameterException) -{ - if (spec) - throw InvalidAlgorithmParameterException("No AlgorithmParameterSpec supported"); - - const PBEKey* pbe = dynamic_cast<const PBEKey*>(&key); - if (pbe) - { - byte _mac_key[20]; - bytearray _rawk, _salt; - size_t _iter; - - if (pbe->getEncoded()) - _rawk = *(pbe->getEncoded()); - else - throw InvalidKeyException("PBEKey must have an encoding"); - - if (pbe->getSalt()) - _salt = *(pbe->getSalt()); - - _iter = pbe->getIterationCount(); - - if (pkcs12_derive_key(&sha1, PKCS12_ID_MAC, _rawk.data(), _rawk.size(), _salt.data(), _salt.size(), _iter, _mac_key, 20)) - throw InvalidKeyException("pkcs12_derive_key returned error"); - - hmacsha1Setup(&_param, _mac_key, 160); - - return; - } - - throw InvalidKeyException("Expected a PBEKey"); -} diff --git a/beecrypt/c++/provider/HMACSHA1.h b/beecrypt/c++/provider/HMACSHA1.h deleted file mode 100644 index 19b48be05..000000000 --- a/beecrypt/c++/provider/HMACSHA1.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file HMACSHA1.h - * \ingroup CXX_PROV_m - */ - -#ifndef _CLASS_HMACSHA1_H -#define _CLASS_HMACSHA1_H - -#include "beecrypt/beecrypt.h" -#include "beecrypt/hmacsha1.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/crypto/MacSpi.h" -using beecrypt::crypto::MacSpi; - -namespace beecrypt { - namespace provider { - class HMACSHA1 : public MacSpi - { - private: - hmacsha1Param _param; - bytearray _digest; - - protected: - virtual const bytearray& engineDoFinal(); - virtual size_t engineDoFinal(byte*, size_t, size_t) throw (ShortBufferException); - virtual size_t engineGetMacLength(); - virtual void engineInit(const Key&, const AlgorithmParameterSpec* spec) throw (InvalidKeyException, InvalidAlgorithmParameterException); - virtual void engineReset(); - virtual void engineUpdate(byte); - virtual void engineUpdate(const byte*, size_t, size_t); - - public: - HMACSHA1(); - virtual ~HMACSHA1(); - - virtual HMACSHA1* clone() const; - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/HMACSHA256.cxx b/beecrypt/c++/provider/HMACSHA256.cxx deleted file mode 100644 index 6c22db0b0..000000000 --- a/beecrypt/c++/provider/HMACSHA256.cxx +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/pkcs12.h" - -#include "beecrypt/c++/crypto/interfaces/PBEKey.h" -using beecrypt::crypto::interfaces::PBEKey; -#include "beecrypt/c++/lang/NullPointerException.h" -using beecrypt::lang::NullPointerException; -#include "beecrypt/c++/provider/HMACSHA256.h" - -using namespace beecrypt::provider; - -HMACSHA256::HMACSHA256() : _digest(32) -{ -} - -HMACSHA256::~HMACSHA256() -{ -} - -HMACSHA256* HMACSHA256::clone() const -{ - HMACSHA256* result = new HMACSHA256(); - - memcpy(&result->_param, &_param, sizeof(hmacsha256Param)); - - return result; -} - -const bytearray& HMACSHA256::engineDoFinal() -{ - hmacsha256Digest(&_param, _digest.data()); - - return _digest; -} - -size_t HMACSHA256::engineDoFinal(byte* data, size_t offset, size_t length) throw (ShortBufferException) -{ - if (!data) - throw NullPointerException(); - - if (length < 32) - throw ShortBufferException(); - - hmacsha256Digest(&_param, data); - - return 32; -} - -size_t HMACSHA256::engineGetMacLength() -{ - return 32; -} - -void HMACSHA256::engineReset() -{ - hmacsha256Reset(&_param); -} - -void HMACSHA256::engineUpdate(byte b) -{ - hmacsha256Update(&_param, &b, 1); -} - -void HMACSHA256::engineUpdate(const byte* data, size_t offset, size_t length) -{ - hmacsha256Update(&_param, data+offset, length); -} - -void HMACSHA256::engineInit(const Key& key, const AlgorithmParameterSpec* spec) throw (InvalidKeyException, InvalidAlgorithmParameterException) -{ - if (spec) - throw InvalidAlgorithmParameterException("No AlgorithmParameterSpec supported"); - - const PBEKey* pbe = dynamic_cast<const PBEKey*>(&key); - if (pbe) - { - byte _mac_key[32]; - bytearray _rawk, _salt; - size_t _iter; - - if (pbe->getEncoded()) - _rawk = *(pbe->getEncoded()); - else - throw InvalidKeyException("PBEKey must have an encoding"); - - if (pbe->getSalt()) - _salt = *(pbe->getSalt()); - - _iter = pbe->getIterationCount(); - - if (pkcs12_derive_key(&sha256, PKCS12_ID_MAC, _rawk.data(), _rawk.size(), _salt.data(), _salt.size(), _iter, _mac_key, 32)) - throw InvalidKeyException("pkcs12_derive_key returned error"); - - hmacsha256Setup(&_param, _mac_key, 256); - - return; - } - - throw InvalidKeyException("Expected a PBEKey"); -} diff --git a/beecrypt/c++/provider/HMACSHA256.h b/beecrypt/c++/provider/HMACSHA256.h deleted file mode 100644 index 445b28d6c..000000000 --- a/beecrypt/c++/provider/HMACSHA256.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file HMACSHA256.h - * \ingroup CXX_PROV_m - */ - -#ifndef _CLASS_HMACSHA256_H -#define _CLASS_HMACSHA256_H - -#include "beecrypt/beecrypt.h" -#include "beecrypt/hmacsha256.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/crypto/MacSpi.h" -using beecrypt::crypto::MacSpi; - -namespace beecrypt { - namespace provider { - class HMACSHA256 : public MacSpi - { - private: - hmacsha256Param _param; - bytearray _digest; - - protected: - virtual const bytearray& engineDoFinal(); - virtual size_t engineDoFinal(byte*, size_t, size_t) throw (ShortBufferException); - virtual size_t engineGetMacLength(); - virtual void engineInit(const Key&, const AlgorithmParameterSpec* spec) throw (InvalidKeyException, InvalidAlgorithmParameterException); - virtual void engineReset(); - virtual void engineUpdate(byte); - virtual void engineUpdate(const byte*, size_t, size_t); - - public: - HMACSHA256(); - virtual ~HMACSHA256(); - - virtual HMACSHA256* clone() const; - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/KeyProtector.cxx b/beecrypt/c++/provider/KeyProtector.cxx deleted file mode 100644 index 5a7c71e22..000000000 --- a/beecrypt/c++/provider/KeyProtector.cxx +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/beecrypt.h" -#include "beecrypt/aes.h" -#include "beecrypt/blockmode.h" -#include "beecrypt/blockpad.h" -#include "beecrypt/hmacsha256.h" -#include "beecrypt/pkcs12.h" -#include "beecrypt/sha256.h" -#include "beecrypt/c++/provider/KeyProtector.h" -#include "beecrypt/c++/beeyond/AnyEncodedKeySpec.h" -using beecrypt::beeyond::AnyEncodedKeySpec; -#include "beecrypt/c++/crypto/BadPaddingException.h" -using beecrypt::crypto::BadPaddingException; -#include "beecrypt/c++/io/ByteArrayInputStream.h" -using beecrypt::io::ByteArrayInputStream; -#include "beecrypt/c++/io/ByteArrayOutputStream.h" -using beecrypt::io::ByteArrayOutputStream; -#include "beecrypt/c++/io/DataInputStream.h" -using beecrypt::io::DataInputStream; -#include "beecrypt/c++/io/DataOutputStream.h" -using beecrypt::io::DataOutputStream; -#include "beecrypt/c++/lang/NullPointerException.h" -using beecrypt::lang::NullPointerException; -#include "beecrypt/c++/security/KeyFactory.h" -using beecrypt::security::KeyFactory; - -using namespace beecrypt::provider; - -namespace { - /* eventually these will be moved to a different location */ - void pkcs5_pad(size_t blockbytes, bytearray& b) - { - size_t unpadded_size = b.size(); - - byte padvalue = blockbytes - (unpadded_size % blockbytes); - - b.resize(unpadded_size + padvalue); - - memset(b.data() + unpadded_size, padvalue, padvalue); - } - - void pkcs5_unpad(size_t blockbytes, bytearray& b) throw (BadPaddingException) - { - byte padvalue = b[b.size() - 1]; - - if (padvalue > blockbytes) - throw BadPaddingException(); - - for (size_t i = (b.size() - padvalue); i < (b.size() - 1); i++) - if (b[i] != padvalue) - throw BadPaddingException(); - - b.resize(b.size() - padvalue); - } -} - -KeyProtector::KeyProtector(PBEKey& key) throw (InvalidKeyException) -{ - bytearray _rawk, _salt; - size_t _iter; - - if (key.getEncoded()) - _rawk = *(key.getEncoded()); - else - throw InvalidKeyException("PBEKey must have an encoding"); - - if (key.getSalt()) - _salt = *(key.getSalt()); - - _iter = key.getIterationCount(); - - if (pkcs12_derive_key(&sha256, PKCS12_ID_CIPHER, _rawk.data(), _rawk.size(), _salt.data(), _salt.size(), _iter, _cipher_key, 32)) - throw InvalidKeyException("pkcs12_derive_key returned error"); - - if (pkcs12_derive_key(&sha256, PKCS12_ID_MAC, _rawk.data(), _rawk.size(), _salt.data(), _salt.size(), _iter, _mac_key, 32)) - throw InvalidKeyException("pkcs12_derive_key returned error"); - - if (pkcs12_derive_key(&sha256, PKCS12_ID_IV, _rawk.data(), _rawk.size(), _salt.data(), _salt.size(), _iter, _iv, 16)) - throw InvalidKeyException("pkcs12_derive_key returned error"); -} - -KeyProtector::~KeyProtector() throw () -{ - // wipe everything - memset(_cipher_key, 0, 32); - memset(_mac_key, 0, 32); - memset(_iv, 0, 16); -} - -bytearray* KeyProtector::protect(const PrivateKey& pri) throw () -{ - if (!pri.getEncoded()) - return 0; - - if (!pri.getFormat()) - return 0; - - /* Eventually we'll substitute this with the following construction: - * DataOutputStream(CipherOutputStream(ByteArrayOutputStream))) - */ - ByteArrayOutputStream bos; - DataOutputStream dos(bos); - - try - { - const bytearray* encoded_key = pri.getEncoded(); - - dos.writeUTF(pri.getAlgorithm()); - dos.writeUTF(*pri.getFormat()); - dos.writeInt(encoded_key->size()); - dos.write(*encoded_key); - dos.close(); - - bytearray cleartext, ciphertext, mac(hmacsha256.digestsize); - bos.toByteArray(cleartext); - - // Compute the MAC before padding - keyedHashFunctionContext mc(&hmacsha256); - keyedHashFunctionContextSetup(&mc, _mac_key, 256); - keyedHashFunctionContextUpdate(&mc, cleartext.data(), cleartext.size()); - keyedHashFunctionContextDigest(&mc, mac.data()); - - // Pad the cleartext - pkcs5_pad(aes.blocksize, cleartext); - - // Set the ciphertext size equal to the cleartext size - ciphertext.resize(cleartext.size()); - - // Encrypt the cleartext - blockCipherContext bc(&aes); - blockCipherContextSetup(&bc, _cipher_key, 256, ENCRYPT); - blockCipherContextSetIV(&bc, _iv); - blockCipherContextCBC(&bc, (uint32_t*) ciphertext.data(), (const uint32_t*) cleartext.data(), cleartext.size() / 16); - - // Return the concatenation of the two bytearrays - return new bytearray(ciphertext + mac); - } - catch (IOException) - { - } - - return 0; -} - -PrivateKey* KeyProtector::recover(const byte* data, size_t size) throw (NoSuchAlgorithmException, UnrecoverableKeyException) -{ - // If we don't have at least enough data for the digest then bail out - if (size <= hmacsha256.digestsize) - throw UnrecoverableKeyException("encrypted key data way too short"); - - size_t ciphertext_size = size - hmacsha256.digestsize; - - // Check if we have a whole number of blocks in the data - if ((ciphertext_size % aes.blocksize) != 0) - throw UnrecoverableKeyException("encrypted key data is not a whole number of blocks"); - - bytearray ciphertext(data, ciphertext_size), cleartext(ciphertext_size); - - // Decrypt the ciphertext - blockCipherContext bc(&aes); - blockCipherContextSetup(&bc, _cipher_key, 256, DECRYPT); - blockCipherContextSetIV(&bc, _iv); - blockCipherContextCBC(&bc, (uint32_t*) cleartext.data(), (const uint32_t*) ciphertext.data(), ciphertext_size / 16); - - try - { - pkcs5_unpad(aes.blocksize, cleartext); - } - catch (BadPaddingException) - { - // Corrupted data, most likely due to bad password - throw UnrecoverableKeyException("bad padding"); - } - - bytearray mac(hmacsha256.digestsize); - - // Verify the MAC before recovering the key - keyedHashFunctionContext mc(&hmacsha256); - keyedHashFunctionContextSetup(&mc, _mac_key, 256); - keyedHashFunctionContextUpdate(&mc, cleartext.data(), cleartext.size()); - keyedHashFunctionContextDigest(&mc, mac.data()); - - // Compare the two MACs and bail out if they're different - if (memcmp(data + ciphertext_size, mac.data(), hmacsha256.digestsize)) - return 0; - - // Now we're sure the password was correct, and we have the decrypted data - - ByteArrayInputStream bis(cleartext); - DataInputStream dis(bis); - - try - { - String algorithm, format; - bytearray enc; - - dis.readUTF(algorithm); - dis.readUTF(format); - - javaint encsize = dis.readInt(); - if (encsize <= 0) - throw IOException(); - - enc.resize(encsize); - - dis.readFully(enc); - - AnyEncodedKeySpec spec(format, enc); - KeyFactory* kf; - PrivateKey* pri; - - try - { - kf = KeyFactory::getInstance(algorithm); - pri = kf->generatePrivate(spec); - - delete kf; - - return pri; - } - catch (InvalidKeySpecException) - { - delete kf; - } - catch (NoSuchAlgorithmException) - { - } - } - catch (IOException) - { - } - throw UnrecoverableKeyException("parsing error in decrypted key"); -} - -PrivateKey* KeyProtector::recover(const bytearray& b) throw (NoSuchAlgorithmException, UnrecoverableKeyException) -{ - return recover(b.data(), b.size()); -} diff --git a/beecrypt/c++/provider/KeyProtector.h b/beecrypt/c++/provider/KeyProtector.h deleted file mode 100644 index 0332b16d7..000000000 --- a/beecrypt/c++/provider/KeyProtector.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _CLASS_KEYPROTECTOR_H -#define _CLASS_KEYPROTECTOR_H - -#include "beecrypt/api.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/crypto/interfaces/PBEKey.h" -using beecrypt::crypto::interfaces::PBEKey; -#include "beecrypt/c++/security/PrivateKey.h" -using beecrypt::security::PrivateKey; -#include "beecrypt/c++/security/InvalidKeyException.h" -using beecrypt::security::InvalidKeyException; -#include "beecrypt/c++/security/UnrecoverableKeyException.h" -using beecrypt::security::UnrecoverableKeyException; -#include "beecrypt/c++/security/NoSuchAlgorithmException.h" -using beecrypt::security::NoSuchAlgorithmException; - -namespace beecrypt { - namespace provider { - class KeyProtector - { - private: - byte _cipher_key[32]; - byte _mac_key[32]; - byte _iv[16]; - - public: - KeyProtector(PBEKey&) throw (InvalidKeyException); - ~KeyProtector() throw (); - - bytearray* protect(const PrivateKey&) throw (); - - PrivateKey* recover(const bytearray&) throw (NoSuchAlgorithmException, UnrecoverableKeyException); - PrivateKey* recover(const byte*, size_t) throw (NoSuchAlgorithmException, UnrecoverableKeyException); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/MD5Digest.cxx b/beecrypt/c++/provider/MD5Digest.cxx deleted file mode 100644 index 51c9749cd..000000000 --- a/beecrypt/c++/provider/MD5Digest.cxx +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/lang/NullPointerException.h" -using beecrypt::lang::NullPointerException; -#include "beecrypt/c++/provider/MD5Digest.h" - -using namespace beecrypt::provider; - -MD5Digest::MD5Digest() : _digest(16) -{ - md5Reset(&_param); -} - -MD5Digest::~MD5Digest() -{ -} - -MD5Digest* MD5Digest::clone() const -{ - MD5Digest* result = new MD5Digest(); - - memcpy(&result->_param, &_param, sizeof(md5Param)); - - return result; -} - -const bytearray& MD5Digest::engineDigest() -{ - md5Digest(&_param, _digest.data()); - - return _digest; -} - -size_t MD5Digest::engineDigest(byte* data, size_t offset, size_t length) throw (ShortBufferException) -{ - if (!data) - throw NullPointerException(); - - if (length < 16) - throw ShortBufferException(); - - md5Digest(&_param, data); - - return 16; -} - -size_t MD5Digest::engineGetDigestLength() -{ - return 16; -} - -void MD5Digest::engineReset() -{ - md5Reset(&_param); -} - -void MD5Digest::engineUpdate(byte b) -{ - md5Update(&_param, &b, 1); -} - -void MD5Digest::engineUpdate(const byte* data, size_t offset, size_t length) -{ - md5Update(&_param, data+offset, length); -} diff --git a/beecrypt/c++/provider/MD5Digest.h b/beecrypt/c++/provider/MD5Digest.h deleted file mode 100644 index f4bf7ba85..000000000 --- a/beecrypt/c++/provider/MD5Digest.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file MD5Digest.h - * \ingroup CXX_PROV_m - */ - -#ifndef _CLASS_MD5DIGEST_H -#define _CLASS_MD5DIGEST_H - -#include "beecrypt/beecrypt.h" -#include "beecrypt/md5.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/security/MessageDigestSpi.h" -using beecrypt::security::MessageDigestSpi; - -namespace beecrypt { - namespace provider { - class MD5Digest : public MessageDigestSpi - { - private: - md5Param _param; - bytearray _digest; - - protected: - virtual const bytearray& engineDigest(); - virtual size_t engineDigest(byte*, size_t, size_t) throw (ShortBufferException); - virtual size_t engineGetDigestLength(); - virtual void engineReset(); - virtual void engineUpdate(byte); - virtual void engineUpdate(const byte*, size_t, size_t); - - public: - MD5Digest(); - virtual ~MD5Digest(); - - virtual MD5Digest* clone() const; - - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/MD5withRSASignature.cxx b/beecrypt/c++/provider/MD5withRSASignature.cxx deleted file mode 100644 index a3bf05f13..000000000 --- a/beecrypt/c++/provider/MD5withRSASignature.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/provider/MD5withRSASignature.h" - -#include "beecrypt/md5.h" - -using namespace beecrypt::provider; - -MD5withRSASignature::MD5withRSASignature() : PKCS1RSASignature(&md5) -{ -} - -MD5withRSASignature::~MD5withRSASignature() -{ -} diff --git a/beecrypt/c++/provider/MD5withRSASignature.h b/beecrypt/c++/provider/MD5withRSASignature.h deleted file mode 100644 index 18a225181..000000000 --- a/beecrypt/c++/provider/MD5withRSASignature.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file MD5withRSASignature.h - * \ingroup CXX_PROV_m - */ - -#ifndef _CLASS_MD5WITHRSASIGNATURE_H -#define _CLASS_MD5WITHRSASIGNATURE_H - -#ifdef __cplusplus - -#include "beecrypt/c++/provider/PKCS1RSASignature.h" - -namespace beecrypt { - namespace provider { - class MD5withRSASignature : public PKCS1RSASignature - { - public: - MD5withRSASignature(); - ~MD5withRSASignature(); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/Makefile.am b/beecrypt/c++/provider/Makefile.am deleted file mode 100644 index 49a7c2abc..000000000 --- a/beecrypt/c++/provider/Makefile.am +++ /dev/null @@ -1,83 +0,0 @@ -INCLUDES = -I$(top_srcdir)/.. - -LIBS = -licuuc -licuio - -AUTOMAKE_OPTIONS = gnu no-dependencies - -pkgaltlibdir=$(prefix)/lib@LIBALT@ -pkgaltlib_LTLIBRARIES = base.la - -base_la_SOURCES = \ -BeeCertificateFactory.cxx \ -BeeCryptProvider.cxx \ -BeeKeyFactory.cxx \ -BeeKeyStore.cxx \ -BeeSecureRandom.cxx \ -DHKeyFactory.cxx \ -DHKeyPairGenerator.cxx \ -DHParameterGenerator.cxx \ -DHParameters.cxx \ -DHPrivateKeyImpl.cxx \ -DHPublicKeyImpl.cxx \ -DSAKeyFactory.cxx \ -DSAKeyPairGenerator.cxx \ -DSAParameterGenerator.cxx \ -DSAParameters.cxx \ -DSAPrivateKeyImpl.cxx \ -DSAPublicKeyImpl.cxx \ -HMACMD5.cxx \ -HMACSHA1.cxx \ -HMACSHA256.cxx \ -KeyProtector.cxx \ -MD5Digest.cxx \ -MD5withRSASignature.cxx \ -PKCS1RSASignature.cxx \ -PKCS12KeyFactory.cxx \ -RSAKeyFactory.cxx \ -RSAKeyPairGenerator.cxx \ -RSAPrivateCrtKeyImpl.cxx \ -RSAPrivateKeyImpl.cxx \ -RSAPublicKeyImpl.cxx \ -SHA1Digest.cxx \ -SHA1withDSASignature.cxx \ -SHA1withRSASignature.cxx \ -SHA256withRSASignature.cxx - -base_la_LDFLAGS = -module -base_la_LIBADD = $(top_builddir)/c++/libbeecrypt_cxx.la - -noinst_HEADERS = \ -BeeCertificateFactory.h \ -BeeCryptProvider.h \ -BeeKeyFactory.h \ -BeeKeyStore.h \ -BeeSecureRandom.h \ -DHKeyFactory.h \ -DHKeyPairGenerator.h \ -DHParameterGenerator.h \ -DHParameters.h \ -DHPrivateKeyImpl.h \ -DHPublicKeyImpl.h \ -DSAKeyFactory.h \ -DSAKeyPairGenerator.h \ -DSAParameterGenerator.h \ -DSAParameters.h \ -DSAPrivateKeyImpl.h \ -DSAPublicKeyImpl.h \ -HMACMD5.h \ -HMACSHA1.h \ -HMACSHA256.h \ -KeyProtector.h \ -MD5Digest.h \ -MD5withRSASignature.h \ -PKCS1RSASignature.h \ -PKCS12KeyFactory.h \ -RSAKeyFactory.h \ -RSAKeyPairGenerator.h \ -RSAPrivateCrtKeyImpl.h \ -RSAPrivateKeyImpl.h \ -RSAPublicKeyImpl.h \ -SHA1Digest.h \ -SHA1withDSASignature.h \ -SHA1withRSASignature.h \ -SHA256withRSASignature.h diff --git a/beecrypt/c++/provider/PKCS12KeyFactory.cxx b/beecrypt/c++/provider/PKCS12KeyFactory.cxx deleted file mode 100644 index e6844fca7..000000000 --- a/beecrypt/c++/provider/PKCS12KeyFactory.cxx +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/beeyond/PKCS12PBEKey.h" -using beecrypt::beeyond::PKCS12PBEKey; -#include "beecrypt/c++/crypto/spec/PBEKeySpec.h" -using beecrypt::crypto::spec::PBEKeySpec; -#include "beecrypt/c++/provider/PKCS12KeyFactory.h" - -using namespace beecrypt::provider; - -PKCS12KeyFactory::PKCS12KeyFactory() -{ -} - -PKCS12KeyFactory::~PKCS12KeyFactory() -{ -} - -SecretKey* PKCS12KeyFactory::engineGenerateSecret(const KeySpec& spec) throw (InvalidKeySpecException) -{ - const PBEKeySpec* pbe = dynamic_cast<const PBEKeySpec*>(&spec); - if (pbe) - { - return new PKCS12PBEKey(pbe->getPassword(), pbe->getSalt(), pbe->getIterationCount()); - } - throw InvalidKeySpecException("Expected a PBEKeySpec"); -} - -KeySpec* PKCS12KeyFactory::engineGetKeySpec(const SecretKey& key, const type_info& info) throw (InvalidKeySpecException) -{ - const PBEKey* pbe = dynamic_cast<const PBEKey*>(&key); - if (pbe) - { - if (info == typeid(KeySpec) || info == typeid(PBEKeySpec)) - { - return new PBEKeySpec(&pbe->getPassword(), pbe->getSalt(), pbe->getIterationCount(), 0); - } - throw InvalidKeySpecException("Unsupported KeySpec type"); - } - throw InvalidKeySpecException("Unsupported SecretKey type"); -} - -SecretKey* PKCS12KeyFactory::engineTranslateKey(const SecretKey& key) throw (InvalidKeyException) -{ - const PBEKey* pbe = dynamic_cast<const PBEKey*>(&key); - if (pbe) - { - return new PKCS12PBEKey(pbe->getPassword(), pbe->getSalt(), pbe->getIterationCount()); - } - throw InvalidKeyException("Unsupported SecretKey type"); -} diff --git a/beecrypt/c++/provider/PKCS12KeyFactory.h b/beecrypt/c++/provider/PKCS12KeyFactory.h deleted file mode 100644 index 4e3c95d75..000000000 --- a/beecrypt/c++/provider/PKCS12KeyFactory.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file PKCS12KeyFactory.h - * \ingroup CXX_PROV_m - */ - -#ifndef _CLASS_PKCS12KEYFACTORY_H -#define _CLASS_PKCS12KEYFACTORY_H - -#ifdef __cplusplus - -#include "beecrypt/c++/crypto/SecretKeyFactorySpi.h" -using beecrypt::crypto::SecretKeyFactorySpi; - -namespace beecrypt { - namespace provider { - class PKCS12KeyFactory : public SecretKeyFactorySpi - { - protected: - virtual SecretKey* engineGenerateSecret(const KeySpec&) throw (InvalidKeySpecException); - virtual KeySpec* engineGetKeySpec(const SecretKey&, const type_info&) throw (InvalidKeySpecException); - virtual SecretKey* engineTranslateKey(const SecretKey&) throw (InvalidKeyException); - - public: - PKCS12KeyFactory(); - virtual ~PKCS12KeyFactory(); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/PKCS1RSASignature.cxx b/beecrypt/c++/provider/PKCS1RSASignature.cxx deleted file mode 100644 index 1ecda324f..000000000 --- a/beecrypt/c++/provider/PKCS1RSASignature.cxx +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/lang/NullPointerException.h" -using beecrypt::lang::NullPointerException; -#include "beecrypt/c++/provider/PKCS1RSASignature.h" -#include "beecrypt/c++/security/interfaces/RSAPrivateKey.h" -using beecrypt::security::interfaces::RSAPrivateKey; -#include "beecrypt/c++/security/interfaces/RSAPrivateCrtKey.h" -using beecrypt::security::interfaces::RSAPrivateCrtKey; -#include "beecrypt/c++/security/interfaces/RSAPublicKey.h" -using beecrypt::security::interfaces::RSAPublicKey; - -#include "beecrypt/pkcs1.h" - -using namespace beecrypt::provider; - -PKCS1RSASignature::PKCS1RSASignature(const hashFunction* hf) : _hfc(hf) -{ -} - -PKCS1RSASignature::~PKCS1RSASignature() -{ -} - -AlgorithmParameters* PKCS1RSASignature::engineGetParameters() const -{ - return 0; -} - -void PKCS1RSASignature::engineSetParameter(const AlgorithmParameterSpec& spec) throw (InvalidAlgorithmParameterException) -{ - throw InvalidAlgorithmParameterException("unsupported for this algorithm"); -} - -void PKCS1RSASignature::engineInitSign(const PrivateKey& key, SecureRandom* random) throw (InvalidKeyException) -{ - const RSAPrivateKey* rsa = dynamic_cast<const RSAPrivateKey*>(&key); - - if (rsa) - { - /* copy key information */ - _pair.n = rsa->getModulus(); - _pair.d = rsa->getPrivateExponent(); - - const RSAPrivateCrtKey* crt = dynamic_cast<const RSAPrivateCrtKey*>(rsa); - - if (crt) - { - _pair.p = crt->getPrimeP(); - _pair.q = crt->getPrimeQ(); - _pair.dp = crt->getPrimeExponentP(); - _pair.dq = crt->getPrimeExponentQ(); - _pair.qi = crt->getCrtCoefficient(); - _crt = true; - } - else - _crt = false; - - /* reset the hash function */ - hashFunctionContextReset(&_hfc); - - _srng = random; - } - else - throw InvalidKeyException("key must be a RSAPrivateKey"); -} - -void PKCS1RSASignature::engineInitVerify(const PublicKey& key) throw (InvalidKeyException) -{ - const RSAPublicKey* rsa = dynamic_cast<const RSAPublicKey*>(&key); - - if (rsa) - { - /* copy key information */ - _pair.n = rsa->getModulus(); - _pair.e = rsa->getPublicExponent(); - - /* reset the hash function */ - hashFunctionContextReset(&_hfc); - - _srng = 0; - } - else - throw InvalidKeyException("key must be a RSAPrivateKey"); -} - -void PKCS1RSASignature::engineUpdate(byte b) -{ - hashFunctionContextUpdate(&_hfc, &b, 1); -} - -void PKCS1RSASignature::engineUpdate(const byte* data, size_t offset, size_t len) -{ - hashFunctionContextUpdate(&_hfc, data+offset, len); -} - -bytearray* PKCS1RSASignature::engineSign() throw (SignatureException) -{ - size_t sigsize = (_pair.n.bitlength()+7) >> 3; - - bytearray* signature = new bytearray(sigsize); - - engineSign(signature->data(), 0, signature->size()); - - return signature; -} - -size_t PKCS1RSASignature::engineSign(byte* signature, size_t offset, size_t len) throw (ShortBufferException, SignatureException) -{ - if (!signature) - throw NullPointerException(); - - size_t sigsize = (_pair.n.bitlength()+7) >> 3; - - /* test if we have enough space in output buffer */ - if (sigsize > (len - offset)) - throw ShortBufferException(); - - /* okay, we can continue */ - mpnumber c, m; - bytearray em(sigsize); - - if (pkcs1_emsa_encode_digest(&_hfc, em.data(), sigsize)) - throw SignatureException("internal error in emsa_pkcs1_encode_digest"); - - mpnsetbin(&c, em.data(), sigsize); - - if (_crt) - { - if (rsapricrt(&_pair.n, &_pair.p, &_pair.q, &_pair.dp, &_pair.dq, &_pair.qi, &c, &m)) - throw SignatureException("internal error in rsapricrt function"); - } - else - { - if (rsapri(&_pair.n, &_pair.d, &c, &m)) - throw SignatureException("internal error in rsapri function"); - } - - if (i2osp(signature+offset, sigsize, m.data, m.size)) - throw SignatureException("internal error in i2osp"); - - return sigsize; -} - -size_t PKCS1RSASignature::engineSign(bytearray& signature) throw (SignatureException) -{ - size_t sigsize = (_pair.n.bitlength()+7) >> 3; - - signature.resize(sigsize); - - return engineSign(signature.data(), 0, signature.size()); -} - -bool PKCS1RSASignature::engineVerify(const byte* signature, size_t offset, size_t len) throw (SignatureException) -{ - if (!signature) - throw NullPointerException(); - - size_t sigsize = (_pair.n.bitlength()+7) >> 3; - - /* test if we have enough data in signature */ - if (sigsize > (len - offset)) - return false; - - /* okay, we can continue */ - mpnumber c, m; - bytearray em(sigsize); - - if (pkcs1_emsa_encode_digest(&_hfc, em.data(), sigsize)) - throw SignatureException("internal error in emsa_pkcs1_encode_digest"); - - mpnsetbin(&c, em.data(), sigsize); - mpnsetbin(&m, signature+offset, sigsize); - - return rsavrfy(&_pair.n, &_pair.e, &m, &c); -} diff --git a/beecrypt/c++/provider/PKCS1RSASignature.h b/beecrypt/c++/provider/PKCS1RSASignature.h deleted file mode 100644 index a7fd8dfd4..000000000 --- a/beecrypt/c++/provider/PKCS1RSASignature.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file PKCS1RSASignature.h - * \ingroup CXX_PROV_m - */ - -#ifndef _CLASS_PKCS1RSASIGNATURE_H -#define _CLASS_PKCS1RSASIGNATURE_H - -#include "beecrypt/api.h" -#include "beecrypt/rsa.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/security/SignatureSpi.h" -using beecrypt::security::SecureRandom; -using beecrypt::security::SignatureSpi; -using beecrypt::security::AlgorithmParameters; -using beecrypt::security::InvalidAlgorithmParameterException; -using beecrypt::security::InvalidKeyException; -using beecrypt::security::PrivateKey; -using beecrypt::security::PublicKey; -using beecrypt::security::ShortBufferException; -using beecrypt::security::SignatureException; -using beecrypt::security::spec::AlgorithmParameterSpec; - -namespace beecrypt { - namespace provider { - class PKCS1RSASignature : public SignatureSpi - { - private: - rsakp _pair; - bool _crt; - hashFunctionContext _hfc; - SecureRandom* _srng; - - protected: - PKCS1RSASignature(const hashFunction*); - - virtual AlgorithmParameters* engineGetParameters() const; - virtual void engineSetParameter(const AlgorithmParameterSpec&) throw (InvalidAlgorithmParameterException); - - virtual void engineInitSign(const PrivateKey&, SecureRandom*) throw (InvalidKeyException); - virtual void engineInitVerify(const PublicKey&) throw (InvalidKeyException); - - virtual bytearray* engineSign() throw (SignatureException); - virtual size_t engineSign(byte*, size_t, size_t) throw (ShortBufferException, SignatureException); - virtual size_t engineSign(bytearray&) throw (SignatureException); - virtual bool engineVerify(const byte*, size_t, size_t) throw (SignatureException); - - virtual void engineUpdate(byte); - virtual void engineUpdate(const byte*, size_t, size_t); - - public: - virtual ~PKCS1RSASignature(); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/RSAKeyFactory.cxx b/beecrypt/c++/provider/RSAKeyFactory.cxx deleted file mode 100644 index 1bdb3fc6c..000000000 --- a/beecrypt/c++/provider/RSAKeyFactory.cxx +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/provider/RSAKeyFactory.h" -#include "beecrypt/c++/provider/RSAPrivateKeyImpl.h" -#include "beecrypt/c++/provider/RSAPrivateCrtKeyImpl.h" -#include "beecrypt/c++/provider/RSAPublicKeyImpl.h" -#include "beecrypt/c++/security/KeyFactory.h" -using beecrypt::security::KeyFactory; -#include "beecrypt/c++/security/spec/EncodedKeySpec.h" -using beecrypt::security::spec::EncodedKeySpec; -#include "beecrypt/c++/security/spec/RSAPrivateKeySpec.h" -using beecrypt::security::spec::RSAPrivateKeySpec; -#include "beecrypt/c++/security/spec/RSAPrivateCrtKeySpec.h" -using beecrypt::security::spec::RSAPrivateCrtKeySpec; -#include "beecrypt/c++/security/spec/RSAPublicKeySpec.h" -using beecrypt::security::spec::RSAPublicKeySpec; - -using beecrypt::security::NoSuchAlgorithmException; - -using namespace beecrypt::provider; - -RSAKeyFactory::RSAKeyFactory() -{ -} - -RSAKeyFactory::~RSAKeyFactory() -{ -} - -PrivateKey* RSAKeyFactory::engineGeneratePrivate(const KeySpec& spec) throw (InvalidKeySpecException) -{ - const RSAPrivateKeySpec* rsa = dynamic_cast<const RSAPrivateKeySpec*>(&spec); - if (rsa) - { - const RSAPrivateCrtKeySpec* crt = dynamic_cast<const RSAPrivateCrtKeySpec*>(rsa); - if (crt) - return new RSAPrivateCrtKeyImpl(crt->getModulus(), crt->getPublicExponent(), crt->getPrivateExponent(), crt->getPrimeP(), crt->getPrimeQ(), crt->getPrimeExponentP(), crt->getPrimeExponentQ(), crt->getCrtCoefficient()); - else - return new RSAPrivateKeyImpl(rsa->getModulus(), rsa->getPrivateExponent()); - } - - const EncodedKeySpec* enc = dynamic_cast<const EncodedKeySpec*>(&spec); - if (enc) - { - try - { - KeyFactory* kf = KeyFactory::getInstance(enc->getFormat()); - try - { - PrivateKey* pri = kf->generatePrivate(*enc); - delete kf; - return pri; - } - catch (...) - { - delete kf; - throw; - } - } - catch (NoSuchAlgorithmException) - { - throw InvalidKeySpecException("Unsupported KeySpec encoding format"); - } - } - throw InvalidKeySpecException("Unsupported KeySpec type"); -} - -PublicKey* RSAKeyFactory::engineGeneratePublic(const KeySpec& spec) throw (InvalidKeySpecException) -{ - const RSAPublicKeySpec* rsa = dynamic_cast<const RSAPublicKeySpec*>(&spec); - - if (rsa) - { - return new RSAPublicKeyImpl(rsa->getModulus(), rsa->getPublicExponent()); - } - - const EncodedKeySpec* enc = dynamic_cast<const EncodedKeySpec*>(&spec); - if (enc) - { - try - { - KeyFactory* kf = KeyFactory::getInstance(enc->getFormat()); - try - { - PublicKey* pub = kf->generatePublic(*enc); - delete kf; - return pub; - } - catch (...) - { - delete kf; - throw; - } - } - catch (NoSuchAlgorithmException) - { - throw InvalidKeySpecException("Unsupported KeySpec encoding format"); - } - } - throw InvalidKeySpecException("Unsupported KeySpec type"); -} - -KeySpec* RSAKeyFactory::engineGetKeySpec(const Key& key, const type_info& info) throw (InvalidKeySpecException) -{ - const RSAPublicKey* pub = dynamic_cast<const RSAPublicKey*>(&key); - - if (pub) - { - if (info == typeid(KeySpec) || info == typeid(RSAPublicKeySpec)) - { - return new RSAPublicKeySpec(pub->getModulus(), pub->getPublicExponent()); - } - /* todo: - if (info == typeid(EncodedKeySpec)) - { - } - */ - - throw InvalidKeySpecException("Unsupported KeySpec type"); - } - - const RSAPrivateKey* pri = dynamic_cast<const RSAPrivateKey*>(&key); - - if (pri) - { - const RSAPrivateCrtKey* crt = dynamic_cast<const RSAPrivateCrtKey*>(pri); - - if (crt) - { - if (info == typeid(KeySpec) || info == typeid(RSAPrivateCrtKeySpec)) - { - return new RSAPrivateCrtKeySpec(crt->getModulus(), crt->getPublicExponent(), crt->getPrivateExponent(), crt->getPrimeP(), crt->getPrimeQ(), crt->getPrimeExponentP(), crt->getPrimeExponentQ(), crt->getCrtCoefficient()); - } - /* todo: - if (info == typeid(EncodedKeySpec)) - { - } - */ - } - else - { - if (info == typeid(KeySpec) || info == typeid(RSAPrivateKeySpec)) - { - return new RSAPrivateKeySpec(pri->getModulus(), pri->getPrivateExponent()); - } - /* todo: - if (info == typeid(EncodedKeySpec)) - { - } - */ - } - - throw InvalidKeySpecException("Unsupported KeySpec type"); - } - - throw InvalidKeySpecException("Unsupported Key type"); -} - -Key* RSAKeyFactory::engineTranslateKey(const Key& key) throw (InvalidKeyException) -{ - const RSAPublicKey* pub = dynamic_cast<const RSAPublicKey*>(&key); - if (pub) - return new RSAPublicKeyImpl(*pub); - - const RSAPrivateKey* pri = dynamic_cast<const RSAPrivateKey*>(&key); - if (pri) - { - const RSAPrivateCrtKey* crt = dynamic_cast<const RSAPrivateCrtKey*>(pri); - if (crt) - return new RSAPrivateCrtKeyImpl(*crt); - else - return new RSAPrivateKeyImpl(*pri); - } - - throw InvalidKeyException("Unsupported Key type"); -} diff --git a/beecrypt/c++/provider/RSAKeyFactory.h b/beecrypt/c++/provider/RSAKeyFactory.h deleted file mode 100644 index d1d5ee3e8..000000000 --- a/beecrypt/c++/provider/RSAKeyFactory.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file RSAKeyFactory.h - * \ingroup CXX_PROV_m - */ - -#ifndef _CLASS_RSAKEYFACTORY_H -#define _CLASS_RSAKEYFACTORY_H - -#include "beecrypt/api.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/security/KeyFactorySpi.h" -using beecrypt::security::InvalidKeyException; -using beecrypt::security::Key; -using beecrypt::security::KeyFactorySpi; -using beecrypt::security::PrivateKey; -using beecrypt::security::PublicKey; -using beecrypt::security::spec::InvalidKeySpecException; -using beecrypt::security::spec::KeySpec; - -namespace beecrypt { - namespace provider { - class RSAKeyFactory : public KeyFactorySpi - { - friend class BeeCryptProvider; - - protected: - virtual PrivateKey* engineGeneratePrivate(const KeySpec&) throw (InvalidKeySpecException); - virtual PublicKey* engineGeneratePublic(const KeySpec&) throw (InvalidKeySpecException); - - virtual KeySpec* engineGetKeySpec(const Key&, const type_info&) throw (InvalidKeySpecException); - - virtual Key* engineTranslateKey(const Key&) throw (InvalidKeyException); - - public: - RSAKeyFactory(); - virtual ~RSAKeyFactory(); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/RSAKeyPairGenerator.cxx b/beecrypt/c++/provider/RSAKeyPairGenerator.cxx deleted file mode 100644 index f63646ac7..000000000 --- a/beecrypt/c++/provider/RSAKeyPairGenerator.cxx +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/adapter.h" -using beecrypt::randomGeneratorContextAdapter; -#include "beecrypt/c++/provider/BeeCryptProvider.h" -#include "beecrypt/c++/provider/RSAKeyPairGenerator.h" -#include "beecrypt/c++/provider/RSAPublicKeyImpl.h" -#include "beecrypt/c++/provider/RSAPrivateCrtKeyImpl.h" - -#include "beecrypt/rsakp.h" - -using namespace beecrypt::provider; - -RSAKeyPairGenerator::RSAKeyPairGenerator() -{ - _size = 0; - _spec = 0; - _srng = 0; -} - -RSAKeyPairGenerator::~RSAKeyPairGenerator() -{ - _size = 0; - if (_spec) - { - delete _spec; - _spec = 0; - } - _srng = 0; -} - -KeyPair* RSAKeyPairGenerator::genpair(randomGeneratorContext* rngc) -{ - rsakp _pair; - - if (rsakpMake(&_pair, rngc, _spec ? _spec->getKeysize() : (_size ? _size : 1024))) - throw "unexpected error in rsakpMake"; - - return new KeyPair(new RSAPublicKeyImpl(_pair.n, _pair.e), new RSAPrivateCrtKeyImpl(_pair.n, _pair.e, _pair.d, _pair.p, _pair.q, _pair.dp, _pair.dq, _pair.qi)); -} - -KeyPair* RSAKeyPairGenerator::engineGenerateKeyPair() -{ - if (_srng) - { - randomGeneratorContextAdapter rngc(_srng); - - return genpair(&rngc); - } - else - { - randomGeneratorContext rngc(randomGeneratorDefault()); - - return genpair(&rngc); - } -} - -void RSAKeyPairGenerator::engineInitialize(const AlgorithmParameterSpec& spec, SecureRandom* random) throw (InvalidAlgorithmParameterException) -{ - const RSAKeyGenParameterSpec* rsaspec = dynamic_cast<const RSAKeyGenParameterSpec*>(&spec); - - if (rsaspec) - { - if (_spec) - delete _spec; - - _spec = new RSAKeyGenParameterSpec(rsaspec->getKeysize(), rsaspec->getPublicExponent()); - } - else - throw InvalidAlgorithmParameterException("not an RSAKeyGenParameterSpec"); -} - -void RSAKeyPairGenerator::engineInitialize(size_t keysize, SecureRandom* random) throw (InvalidParameterException) -{ - if (keysize < 512) - throw InvalidParameterException("Modulus size must be at least 512 bits"); - - _size = keysize; - if (_spec) - { - delete _spec; - _spec = 0; - } - _srng = random; -} diff --git a/beecrypt/c++/provider/RSAKeyPairGenerator.h b/beecrypt/c++/provider/RSAKeyPairGenerator.h deleted file mode 100644 index d54eb4fce..000000000 --- a/beecrypt/c++/provider/RSAKeyPairGenerator.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file RSAKeyPairGenerator.h - * \ingroup CXX_PROV_m - */ - -#ifndef _CLASS_RSAKEYPAIRGENERATOR_H -#define _CLASS_RSAKEYPAIRGENERATOR_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/KeyPairGeneratorSpi.h" -using beecrypt::security::KeyPairGeneratorSpi; -using beecrypt::security::KeyPair; -#include "beecrypt/c++/security/SecureRandom.h" -using beecrypt::security::SecureRandom; -#include "beecrypt/c++/security/spec/RSAKeyGenParameterSpec.h" -using beecrypt::security::spec::RSAKeyGenParameterSpec; - -using beecrypt::security::InvalidAlgorithmParameterException; -using beecrypt::security::InvalidParameterException; - -namespace beecrypt { - namespace provider { - class RSAKeyPairGenerator : public KeyPairGeneratorSpi - { - private: - size_t _size; - RSAKeyGenParameterSpec* _spec; - SecureRandom* _srng; - - KeyPair* genpair(randomGeneratorContext*); - - protected: - virtual KeyPair* engineGenerateKeyPair(); - - virtual void engineInitialize(const AlgorithmParameterSpec&, SecureRandom*) throw (InvalidAlgorithmParameterException); - virtual void engineInitialize(size_t, SecureRandom*) throw (InvalidParameterException); - - public: - RSAKeyPairGenerator(); - virtual ~RSAKeyPairGenerator(); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/RSAPrivateCrtKeyImpl.cxx b/beecrypt/c++/provider/RSAPrivateCrtKeyImpl.cxx deleted file mode 100644 index c77333581..000000000 --- a/beecrypt/c++/provider/RSAPrivateCrtKeyImpl.cxx +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/provider/RSAPrivateCrtKeyImpl.h" -#include "beecrypt/c++/provider/BeeKeyFactory.h" - -using namespace beecrypt::provider; - -RSAPrivateCrtKeyImpl::RSAPrivateCrtKeyImpl(const RSAPrivateCrtKey& copy) -{ - _n = copy.getModulus(); - _e = copy.getPublicExponent(); - _d = copy.getPrivateExponent(); - _p = copy.getPrimeP(); - _q = copy.getPrimeQ(); - _dp = copy.getPrimeExponentP(); - _dq = copy.getPrimeExponentQ(); - _qi = copy.getCrtCoefficient(); - _enc = 0; -} - -RSAPrivateCrtKeyImpl::RSAPrivateCrtKeyImpl(const mpbarrett& n, const mpnumber& e, const mpnumber& d, const mpbarrett& p, const mpbarrett& q, const mpnumber& dp, const mpnumber& dq, const mpnumber& qi) -{ - _n = n; - _e = e; - _d = d; - _p = p; - _q = q; - _dp = dp; - _dq = dq; - _qi = qi; - _enc = 0; -} - -RSAPrivateCrtKeyImpl::~RSAPrivateCrtKeyImpl() -{ - _d.wipe(); - _p.wipe(); - _q.wipe(); - _dp.wipe(); - _dq.wipe(); - _qi.wipe(); - if (_enc) - delete _enc; -} - -RSAPrivateCrtKey* RSAPrivateCrtKeyImpl::clone() const -{ - return new RSAPrivateCrtKeyImpl(*this); -} - -const mpbarrett& RSAPrivateCrtKeyImpl::getModulus() const throw () -{ - return _n; -} - -const mpnumber& RSAPrivateCrtKeyImpl::getPrivateExponent() const throw () -{ - return _d; -} - -const mpnumber& RSAPrivateCrtKeyImpl::getPublicExponent() const throw () -{ - return _e; -} - -const mpbarrett& RSAPrivateCrtKeyImpl::getPrimeP() const throw () -{ - return _p; -} - -const mpbarrett& RSAPrivateCrtKeyImpl::getPrimeQ() const throw () -{ - return _q; -} - -const mpnumber& RSAPrivateCrtKeyImpl::getPrimeExponentP() const throw () -{ - return _dp; -} - -const mpnumber& RSAPrivateCrtKeyImpl::getPrimeExponentQ() const throw () -{ - return _dq; -} - -const mpnumber& RSAPrivateCrtKeyImpl::getCrtCoefficient() const throw () -{ - return _qi; -} - -const bytearray* RSAPrivateCrtKeyImpl::getEncoded() const -{ - if (!_enc) - _enc = BeeKeyFactory::encode(*this); - - return _enc; -} - -const String& RSAPrivateCrtKeyImpl::getAlgorithm() const throw () -{ - static const String ALGORITHM = UNICODE_STRING_SIMPLE("RSA"); - return ALGORITHM; -} - -const String* RSAPrivateCrtKeyImpl::getFormat() const throw () -{ - static const String FORMAT = UNICODE_STRING_SIMPLE("BEE"); - return &FORMAT; -} diff --git a/beecrypt/c++/provider/RSAPrivateCrtKeyImpl.h b/beecrypt/c++/provider/RSAPrivateCrtKeyImpl.h deleted file mode 100644 index 2f7affe30..000000000 --- a/beecrypt/c++/provider/RSAPrivateCrtKeyImpl.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file RSAPrivateCrtKeyImpl.h - * \ingroup CXX_PROV_m - */ - -#ifndef _CLASS_RSAPRIVATECRTKEYIMPL_H -#define _CLASS_RSAPRIVATECRTKEYIMPL_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/interfaces/RSAPrivateCrtKey.h" -using beecrypt::security::interfaces::RSAPrivateCrtKey; - -namespace beecrypt { - namespace provider { - class RSAPrivateCrtKeyImpl : public RSAPrivateCrtKey - { - private: - mpbarrett _n; - mpnumber _e; - mpnumber _d; - mpbarrett _p; - mpbarrett _q; - mpnumber _dp; - mpnumber _dq; - mpnumber _qi; - mutable bytearray* _enc; - - public: - RSAPrivateCrtKeyImpl(const RSAPrivateCrtKey&); - RSAPrivateCrtKeyImpl(const mpbarrett& modulus, const mpnumber& publicExponent, const mpnumber& privateExponent, const mpbarrett& primeP, const mpbarrett& primeQ, const mpnumber& primeExponentP, const mpnumber& primeExponentQ, const mpnumber& crtCoefficient); - virtual ~RSAPrivateCrtKeyImpl(); - - virtual RSAPrivateCrtKey* clone() const; - - virtual const mpbarrett& getModulus() const throw (); - virtual const mpnumber& getPrivateExponent() const throw (); - virtual const mpnumber& getPublicExponent() const throw (); - virtual const mpbarrett& getPrimeP() const throw (); - virtual const mpbarrett& getPrimeQ() const throw (); - virtual const mpnumber& getPrimeExponentP() const throw (); - virtual const mpnumber& getPrimeExponentQ() const throw (); - virtual const mpnumber& getCrtCoefficient() const throw (); - - virtual const bytearray* getEncoded() const; - virtual const String& getAlgorithm() const throw (); - virtual const String* getFormat() const throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/RSAPrivateKeyImpl.cxx b/beecrypt/c++/provider/RSAPrivateKeyImpl.cxx deleted file mode 100644 index 663983dbe..000000000 --- a/beecrypt/c++/provider/RSAPrivateKeyImpl.cxx +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/provider/RSAPrivateKeyImpl.h" -#include "beecrypt/c++/provider/BeeKeyFactory.h" - -using namespace beecrypt::provider; - -RSAPrivateKeyImpl::RSAPrivateKeyImpl(const RSAPrivateKey& copy) -{ - _n = copy.getModulus(); - _d = copy.getPrivateExponent(); - _enc = 0; -} - -RSAPrivateKeyImpl::RSAPrivateKeyImpl(const mpbarrett& n, const mpnumber& d) -{ - _n = n; - _d = d; - _enc = 0; -} - -RSAPrivateKeyImpl::~RSAPrivateKeyImpl() -{ - _d.wipe(); - if (_enc) - delete _enc; -} - -RSAPrivateKey* RSAPrivateKeyImpl::clone() const -{ - return new RSAPrivateKeyImpl(*this); -} - -const mpbarrett& RSAPrivateKeyImpl::getModulus() const throw () -{ - return _n; -} - -const mpnumber& RSAPrivateKeyImpl::getPrivateExponent() const throw () -{ - return _d; -} - -const bytearray* RSAPrivateKeyImpl::getEncoded() const -{ - if (!_enc) - _enc = BeeKeyFactory::encode(*this); - - return _enc; -} - -const String& RSAPrivateKeyImpl::getAlgorithm() const throw () -{ - static const String ALGORITHM = UNICODE_STRING_SIMPLE("RSA"); - return ALGORITHM; -} - -const String* RSAPrivateKeyImpl::getFormat() const throw () -{ - static const String FORMAT = UNICODE_STRING_SIMPLE("BEE"); - return &FORMAT; -} diff --git a/beecrypt/c++/provider/RSAPrivateKeyImpl.h b/beecrypt/c++/provider/RSAPrivateKeyImpl.h deleted file mode 100644 index 5b44f73ba..000000000 --- a/beecrypt/c++/provider/RSAPrivateKeyImpl.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file RSAPrivateKeyImpl.h - * \ingroup CXX_PROV_m - */ - -#ifndef _CLASS_RSAPRIVATEKEYIMPL_H -#define _CLASS_RSAPRIVATEKEYIMPL_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/interfaces/RSAPrivateKey.h" -using beecrypt::security::interfaces::RSAPrivateKey; - -namespace beecrypt { - namespace provider { - class RSAPrivateKeyImpl : public RSAPrivateKey - { - protected: - mpbarrett _n; - mpnumber _d; - mutable bytearray* _enc; - - public: - RSAPrivateKeyImpl(const RSAPrivateKey&); - RSAPrivateKeyImpl(const mpbarrett&, const mpnumber&); - virtual ~RSAPrivateKeyImpl(); - - virtual RSAPrivateKey* clone() const; - - virtual const mpbarrett& getModulus() const throw (); - virtual const mpnumber& getPrivateExponent() const throw (); - - virtual const bytearray* getEncoded() const; - virtual const String& getAlgorithm() const throw (); - virtual const String* getFormat() const throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/RSAPublicKeyImpl.cxx b/beecrypt/c++/provider/RSAPublicKeyImpl.cxx deleted file mode 100644 index b4ea54395..000000000 --- a/beecrypt/c++/provider/RSAPublicKeyImpl.cxx +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/provider/RSAPublicKeyImpl.h" -#include "beecrypt/c++/provider/BeeKeyFactory.h" - -using namespace beecrypt::provider; - -RSAPublicKeyImpl::RSAPublicKeyImpl(const RSAPublicKey& copy) -{ - _n = copy.getModulus(); - _e = copy.getPublicExponent(); - _enc = 0; -} - -RSAPublicKeyImpl::RSAPublicKeyImpl(const mpbarrett& n, const mpnumber& e) -{ - _n = n; - _e = e; - _enc = 0; -} - -RSAPublicKeyImpl::~RSAPublicKeyImpl() -{ - if (_enc) - delete _enc; -} - -RSAPublicKey* RSAPublicKeyImpl::clone() const -{ - return new RSAPublicKeyImpl(*this); -} - -const mpbarrett& RSAPublicKeyImpl::getModulus() const throw () -{ - return _n; -} - -const mpnumber& RSAPublicKeyImpl::getPublicExponent() const throw () -{ - return _e; -} - -const bytearray* RSAPublicKeyImpl::getEncoded() const -{ - if (!_enc) - _enc = BeeKeyFactory::encode(*this); - - return _enc; -} - -const String& RSAPublicKeyImpl::getAlgorithm() const throw () -{ - static const String ALGORITHM = UNICODE_STRING_SIMPLE("RSA"); - return ALGORITHM; -} - -const String* RSAPublicKeyImpl::getFormat() const throw () -{ - static const String FORMAT = UNICODE_STRING_SIMPLE("BEE"); - return &FORMAT; -} diff --git a/beecrypt/c++/provider/RSAPublicKeyImpl.h b/beecrypt/c++/provider/RSAPublicKeyImpl.h deleted file mode 100644 index 641ec0c67..000000000 --- a/beecrypt/c++/provider/RSAPublicKeyImpl.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file RSAPublicKeyImpl.h - * \ingroup CXX_PROV_m - */ - -#ifndef _CLASS_RSAPUBLICKEYIMPL_H -#define _CLASS_RSAPUBLICKEYIMPL_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/interfaces/RSAPublicKey.h" -using beecrypt::security::interfaces::RSAPublicKey; - -namespace beecrypt { - namespace provider { - class RSAPublicKeyImpl : public RSAPublicKey - { - private: - mpbarrett _n; - mpnumber _e; - mutable bytearray* _enc; - - public: - RSAPublicKeyImpl(const RSAPublicKey&); - RSAPublicKeyImpl(const mpbarrett&, const mpnumber&); - virtual ~RSAPublicKeyImpl(); - - virtual RSAPublicKey* clone() const; - - virtual const mpbarrett& getModulus() const throw (); - virtual const mpnumber& getPublicExponent() const throw (); - - virtual const bytearray* getEncoded() const; - virtual const String& getAlgorithm() const throw (); - virtual const String* getFormat() const throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/SHA1Digest.cxx b/beecrypt/c++/provider/SHA1Digest.cxx deleted file mode 100644 index bf6a070ad..000000000 --- a/beecrypt/c++/provider/SHA1Digest.cxx +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/lang/NullPointerException.h" -using beecrypt::lang::NullPointerException; -#include "beecrypt/c++/provider/SHA1Digest.h" - -using namespace beecrypt::provider; - -SHA1Digest::SHA1Digest() : _digest(20) -{ - sha1Reset(&_param); -} - -SHA1Digest::~SHA1Digest() -{ -} - -SHA1Digest* SHA1Digest::clone() const -{ - SHA1Digest* result = new SHA1Digest(); - - memcpy(&result->_param, &_param, sizeof(sha1Param)); - - return result; -} - -const bytearray& SHA1Digest::engineDigest() -{ - sha1Digest(&_param, _digest.data()); - - return _digest; -} - -size_t SHA1Digest::engineDigest(byte* data, size_t offset, size_t length) throw (ShortBufferException) -{ - if (!data) - throw NullPointerException(); - - if (length < 20) - throw ShortBufferException(); - - sha1Digest(&_param, data); - - return 20; -} - -size_t SHA1Digest::engineGetDigestLength() -{ - return 20; -} - -void SHA1Digest::engineReset() -{ - sha1Reset(&_param); -} - -void SHA1Digest::engineUpdate(byte b) -{ - sha1Update(&_param, &b, 1); -} - -void SHA1Digest::engineUpdate(const byte* data, size_t offset, size_t length) -{ - sha1Update(&_param, data+offset, length); -} diff --git a/beecrypt/c++/provider/SHA1Digest.h b/beecrypt/c++/provider/SHA1Digest.h deleted file mode 100644 index aec2fb379..000000000 --- a/beecrypt/c++/provider/SHA1Digest.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file SHA1Digest.h - * \ingroup CXX_PROV_m - */ - -#ifndef _CLASS_SHA1DIGEST_H -#define _CLASS_SHA1DIGEST_H - -#include "beecrypt/beecrypt.h" -#include "beecrypt/sha1.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/security/MessageDigestSpi.h" -using beecrypt::security::MessageDigestSpi; - -namespace beecrypt { - namespace provider { - class SHA1Digest : public MessageDigestSpi - { - private: - sha1Param _param; - bytearray _digest; - - protected: - virtual const bytearray& engineDigest(); - virtual size_t engineDigest(byte*, size_t, size_t) throw (ShortBufferException); - virtual size_t engineGetDigestLength(); - virtual void engineReset(); - virtual void engineUpdate(byte); - virtual void engineUpdate(const byte*, size_t, size_t); - - public: - SHA1Digest(); - virtual ~SHA1Digest(); - - virtual SHA1Digest* clone() const; - - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/SHA1withDSASignature.cxx b/beecrypt/c++/provider/SHA1withDSASignature.cxx deleted file mode 100644 index 6c5ca6d09..000000000 --- a/beecrypt/c++/provider/SHA1withDSASignature.cxx +++ /dev/null @@ -1,411 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/adapter.h" -#include "beecrypt/c++/lang/NullPointerException.h" -using beecrypt::lang::NullPointerException; -#include "beecrypt/c++/provider/SHA1withDSASignature.h" -#include "beecrypt/c++/security/interfaces/DSAPrivateKey.h" -using beecrypt::security::interfaces::DSAPrivateKey; -#include "beecrypt/c++/security/interfaces/DSAPublicKey.h" -using beecrypt::security::interfaces::DSAPublicKey; - -namespace { - const byte TAG_SEQUENCE = 0x30; - const byte TAG_INTEGER = 0x02; - - typedef int asn1error; - - const asn1error DER_NOT_ENOUGH_DATA = -1; - const asn1error DER_IMPLICIT_TAG_LENGTH = -2; - const asn1error DER_TAG_TOO_LONG = -3; - const asn1error DER_FORMAT_ERROR = -4; - const asn1error DER_CONVERSION_ERROR = -5; - - /* compute the size of a DER length encoding */ - size_t asn1_der_length(size_t length) throw () - { - if (length < 0x80) - return 1; - if (length < 0x100) - return 2; - if (length < 0x10000) - return 3; - if (length < 0x1000000) - return 4; - else - return 5; - } - - size_t asn1_der_length_of(const mpnumber& n) throw () - { - size_t sigbits = mpbits(n.size, n.data); - - return ((sigbits + 7) >> 3) + (((sigbits & 7) == 0) ? 1 : 0); - } - - size_t asn1_der_length_of_rssig(const mpnumber& r, const mpnumber& s) throw () - { - size_t intlen, seqlen = 0; - - intlen = asn1_der_length_of(r); - - seqlen += 1 + asn1_der_length(intlen) + intlen; - - intlen = asn1_der_length_of(s); - - seqlen += 1 + asn1_der_length(intlen) + intlen; - - return 1 + asn1_der_length(seqlen) + seqlen; - } - - size_t asn1_der_encode_length(byte* data, size_t length) throw () - { - if (length < 0x80) - { - data[0] = (byte) length; - return 1; - } - else if (length < 0x100) - { - data[0] = (byte) 0x81; - data[1] = (byte) length; - return 2; - } - else if (length < 0x10000) - { - data[0] = (byte) 0x82; - data[1] = (byte) (length >> 8); - data[2] = (byte) (length ); - return 3; - } - else if (length < 0x1000000) - { - data[0] = (byte) 0x83; - data[1] = (byte) (length >> 16); - data[2] = (byte) (length >> 8); - data[3] = (byte) (length ); - return 4; - } - else - { - data[0] = (byte) 0x84; - data[1] = (byte) (length >> 24); - data[2] = (byte) (length >> 16); - data[3] = (byte) (length >> 8); - data[4] = (byte) (length ); - return 5; - } - } - - size_t asn1_der_decode_length(const byte* data, size_t size, size_t* length) throw (asn1error) - { - size_t length_bytes; - byte tmp; - - if (size == 0) - throw DER_NOT_ENOUGH_DATA; - - tmp = *(data++); - - if (tmp < 0x80) - { - *length = tmp; - length_bytes = 0; - } - else - { - byte length_bytes = tmp & 0x7f; - - if (length_bytes == 0) - throw DER_IMPLICIT_TAG_LENGTH; - - if (length_bytes >= size) - throw DER_NOT_ENOUGH_DATA; - - if (length_bytes > sizeof(size_t)) - throw DER_TAG_TOO_LONG; - - size_t temp = 0; - - for (byte i = 0; i < length_bytes; i++) - { - tmp = *(data++); - temp <<= 8; - temp += tmp; - } - - *length = temp; - } - return 1 + length_bytes; - } - - size_t asn1_der_encode(byte* data, const mpnumber& n) throw () - { - size_t offset = 1, length = asn1_der_length_of(n); - - data[0] = TAG_INTEGER; - - offset += asn1_der_encode_length(data+offset, length); - - i2osp(data+offset, length, n.data, n.size); - - offset += length; - - return offset; - } - - size_t asn1_der_decode(const byte* data, size_t size, mpnumber& n) throw (asn1error) - { - size_t length, offset = 1; - - if (size < 2) - throw DER_NOT_ENOUGH_DATA; - - if (data[0] != TAG_INTEGER) - throw DER_FORMAT_ERROR; - - offset += asn1_der_decode_length(data+offset, size-offset, &length); - - if (length > (size-offset)) - throw DER_NOT_ENOUGH_DATA; - - if (mpnsetbin(&n, data+offset, length)) - throw DER_CONVERSION_ERROR; - - offset += length; - - return offset; - } - - size_t asn1_der_encode_rssig(byte* data, const mpnumber& r, const mpnumber& s) throw () - { - size_t intlen, seqlen = 0; - - intlen = asn1_der_length_of(r); - seqlen += 1 + asn1_der_length(intlen) + intlen; - intlen = asn1_der_length_of(s); - seqlen += 1 + asn1_der_length(intlen) + intlen; - - *(data++) = TAG_SEQUENCE; - - data += asn1_der_encode_length(data, seqlen); - data += asn1_der_encode(data, r); - data += asn1_der_encode(data, s); - - return 1 + asn1_der_length(seqlen) + seqlen; - } - - size_t asn1_der_decode_rssig(const byte* data, size_t size, mpnumber& r, mpnumber& s) throw (asn1error) - { - size_t tmp, length, offset = 1; - - if (size < 2) - throw DER_NOT_ENOUGH_DATA; - - if (data[0] != TAG_SEQUENCE) - throw DER_FORMAT_ERROR; - - offset += asn1_der_decode_length(data+offset, size-offset, &length); - - if (length > (size-offset)) - throw DER_NOT_ENOUGH_DATA; - - tmp = asn1_der_decode(data+offset, length, r); - - offset += tmp; - length -= tmp; - - tmp = asn1_der_decode(data+offset, length, s); - - offset += tmp; - length -= tmp; - - if (length > 0) - throw DER_FORMAT_ERROR; - - return offset; - } -} - -using namespace beecrypt::provider; - -SHA1withDSASignature::SHA1withDSASignature() -{ -} - -SHA1withDSASignature::~SHA1withDSASignature() -{ -} - -AlgorithmParameters* SHA1withDSASignature::engineGetParameters() const -{ - return 0; -} - -void SHA1withDSASignature::engineSetParameter(const AlgorithmParameterSpec& spec) throw (InvalidAlgorithmParameterException) -{ - throw InvalidAlgorithmParameterException("not supported for this algorithm"); -} - -void SHA1withDSASignature::engineInitSign(const PrivateKey& key, SecureRandom* random) throw (InvalidKeyException) -{ - const DSAPrivateKey* dsa = dynamic_cast<const DSAPrivateKey*>(&key); - - if (dsa) - { - /* copy key information */ - _params.p = dsa->getParams().getP(); - _params.q = dsa->getParams().getQ(); - _params.g = dsa->getParams().getG(); - _x = dsa->getX(); - - /* reset the hash function */ - sha1Reset(&_sp); - - _srng = random; - } - else - throw InvalidKeyException("key must be a DSAPrivateKey"); -} - -void SHA1withDSASignature::engineInitVerify(const PublicKey& key) throw (InvalidKeyException) -{ - const DSAPublicKey* dsa = dynamic_cast<const DSAPublicKey*>(&key); - - if (dsa) - { - /* copy key information */ - _params.p = dsa->getParams().getP(); - _params.q = dsa->getParams().getQ(); - _params.g = dsa->getParams().getG(); - _y = dsa->getY(); - - /* reset the hash function */ - sha1Reset(&_sp); - - _srng = 0; - } - else - throw InvalidKeyException("key must be a DSAPrivateKey"); -} - -void SHA1withDSASignature::engineUpdate(byte b) -{ - sha1Update(&_sp, &b, 1); -} - -void SHA1withDSASignature::engineUpdate(const byte* data, size_t offset, size_t len) -{ - sha1Update(&_sp, data+offset, len); -} - -void SHA1withDSASignature::rawsign(mpnumber& r, mpnumber& s) throw (SignatureException) -{ - mpnumber hm; - byte digest[20]; - - sha1Digest(&_sp, digest); - mpnsetbin(&hm, digest, 20); - - if (_srng) - { - randomGeneratorContextAdapter rngc(_srng); - if (dsasign(&_params.p, &_params.q, &_params.g, &rngc, &hm, &_x, &r, &s)) - throw SignatureException("internal error in dsasign function"); - } - else - { - randomGeneratorContext rngc(randomGeneratorDefault()); - if (dsasign(&_params.p, &_params.q, &_params.g, &rngc, &hm, &_x, &r, &s)) - throw SignatureException("internal error in dsasign function"); - } -} - -bool SHA1withDSASignature::rawvrfy(const mpnumber& r, const mpnumber& s) throw () -{ - mpnumber hm; - byte digest[20]; - - sha1Digest(&_sp, digest); - mpnsetbin(&hm, digest, 20); - - return dsavrfy(&_params.p, &_params.q, &_params.g, &hm, &_y, &r, &s); -} - -bytearray* SHA1withDSASignature::engineSign() throw (SignatureException) -{ - mpnumber r, s; - - rawsign(r, s); - - bytearray* signature = new bytearray(asn1_der_length_of_rssig(r, s)); - - asn1_der_encode_rssig(signature->data(), r, s); - - return signature; -} - -size_t SHA1withDSASignature::engineSign(byte* signature, size_t offset, size_t len) throw (ShortBufferException, SignatureException) -{ - if (!signature) - throw NullPointerException(); - - mpnumber r, s; - - rawsign(r, s); - - if (asn1_der_length_of_rssig(r, s) > (len - offset)) - throw ShortBufferException(); - - return asn1_der_encode_rssig(signature+offset, r, s); -} - -size_t SHA1withDSASignature::engineSign(bytearray& signature) throw (SignatureException) -{ - mpnumber r, s; - - rawsign(r, s); - - signature.resize(asn1_der_length_of_rssig(r, s)); - - return asn1_der_encode_rssig(signature.data(), r, s); -} - -bool SHA1withDSASignature::engineVerify(const byte* signature, size_t offset, size_t len) throw (SignatureException) -{ - if (!signature) - throw NullPointerException(); - - mpnumber r, s; - - try - { - asn1_der_decode_rssig(signature+offset, len-offset, r, s); - } - catch (asn1error ae) - { - throw SignatureException("invalid signature"); - } - - return rawvrfy(r, s); -} diff --git a/beecrypt/c++/provider/SHA1withDSASignature.h b/beecrypt/c++/provider/SHA1withDSASignature.h deleted file mode 100644 index f62b27f2d..000000000 --- a/beecrypt/c++/provider/SHA1withDSASignature.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file SHA1withDSASignature.h - * \ingroup CXX_PROV_m - */ - -#ifndef _CLASS_SHA1WITHDSASIGNATURE_H -#define _CLASS_SHA1WITHDSASIGNATURE_H - -#include "beecrypt/api.h" -#include "beecrypt/dsa.h" -#include "beecrypt/sha1.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/security/SignatureSpi.h" -using beecrypt::security::SecureRandom; -using beecrypt::security::SignatureSpi; -using beecrypt::security::AlgorithmParameters; -using beecrypt::security::InvalidAlgorithmParameterException; -using beecrypt::security::InvalidKeyException; -using beecrypt::security::PrivateKey; -using beecrypt::security::PublicKey; -using beecrypt::security::ShortBufferException; -using beecrypt::security::SignatureException; -using beecrypt::security::spec::AlgorithmParameterSpec; - -namespace beecrypt { - namespace provider { - class SHA1withDSASignature : public SignatureSpi - { - friend class BeeCryptProvider; - - private: - dsaparam _params; - mpnumber _x; - mpnumber _y; - sha1Param _sp; - SecureRandom* _srng; - - void rawsign(mpnumber &r, mpnumber&s) throw (SignatureException); - bool rawvrfy(const mpnumber &r, const mpnumber&s) throw (); - - protected: - virtual AlgorithmParameters* engineGetParameters() const; - virtual void engineSetParameter(const AlgorithmParameterSpec&) throw (InvalidAlgorithmParameterException); - - virtual void engineInitSign(const PrivateKey&, SecureRandom*) throw (InvalidKeyException); - virtual void engineInitVerify(const PublicKey&) throw (InvalidKeyException); - - virtual bytearray* engineSign() throw (SignatureException); - virtual size_t engineSign(byte*, size_t, size_t) throw (ShortBufferException, SignatureException); - virtual size_t engineSign(bytearray&) throw (SignatureException); - virtual bool engineVerify(const byte*, size_t, size_t) throw (SignatureException); - - virtual void engineUpdate(byte); - virtual void engineUpdate(const byte*, size_t, size_t); - - public: - SHA1withDSASignature(); - virtual ~SHA1withDSASignature(); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/SHA1withRSASignature.cxx b/beecrypt/c++/provider/SHA1withRSASignature.cxx deleted file mode 100644 index 7d1b41b90..000000000 --- a/beecrypt/c++/provider/SHA1withRSASignature.cxx +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/provider/SHA1withRSASignature.h" -#include "beecrypt/sha1.h" - -using namespace beecrypt::provider; - -SHA1withRSASignature::SHA1withRSASignature() : PKCS1RSASignature(&sha1) -{ -} - -SHA1withRSASignature::~SHA1withRSASignature() -{ -} diff --git a/beecrypt/c++/provider/SHA1withRSASignature.h b/beecrypt/c++/provider/SHA1withRSASignature.h deleted file mode 100644 index f929c4edf..000000000 --- a/beecrypt/c++/provider/SHA1withRSASignature.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file SHA1withRSASignature.h - * \ingroup CXX_PROV_m - */ - -#ifndef _CLASS_SHA1WITHRSASIGNATURE_H -#define _CLASS_SHA1WITHRSASIGNATURE_H - -#ifdef __cplusplus - -#include "beecrypt/c++/provider/PKCS1RSASignature.h" - -namespace beecrypt { - namespace provider { - class SHA1withRSASignature : public PKCS1RSASignature - { - public: - SHA1withRSASignature(); - ~SHA1withRSASignature(); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/provider/SHA256withRSASignature.cxx b/beecrypt/c++/provider/SHA256withRSASignature.cxx deleted file mode 100644 index 12f48782e..000000000 --- a/beecrypt/c++/provider/SHA256withRSASignature.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/provider/SHA256withRSASignature.h" - -#include "beecrypt/sha256.h" - -using namespace beecrypt::provider; - -SHA256withRSASignature::SHA256withRSASignature() : PKCS1RSASignature(&sha256) -{ -} - -SHA256withRSASignature::~SHA256withRSASignature() -{ -} diff --git a/beecrypt/c++/provider/SHA256withRSASignature.h b/beecrypt/c++/provider/SHA256withRSASignature.h deleted file mode 100644 index 252c55b04..000000000 --- a/beecrypt/c++/provider/SHA256withRSASignature.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file SHA256withRSASignature.h - * \ingroup CXX_PROV_m - */ - -#ifndef _CLASS_SHA256WITHRSASIGNATURE_H -#define _CLASS_SHA256WITHRSASIGNATURE_H - -#ifdef __cplusplus - -#include "beecrypt/c++/provider/PKCS1RSASignature.h" - -namespace beecrypt { - namespace provider { - class SHA256withRSASignature : public PKCS1RSASignature - { - public: - SHA256withRSASignature(); - ~SHA256withRSASignature(); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/resource.cxx b/beecrypt/c++/resource.cxx deleted file mode 100644 index d45971776..000000000 --- a/beecrypt/c++/resource.cxx +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#include "beecrypt/c++/resource.h" - -#if WIN32 -const char* BEECRYPT_CONF_FILE = "beecrypt.conf"; -#else -const char* BEECRYPT_CONF_FILE = "/etc/beecrypt.conf"; -#endif diff --git a/beecrypt/c++/resource.h b/beecrypt/c++/resource.h deleted file mode 100644 index e3f62c32c..000000000 --- a/beecrypt/c++/resource.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file resource.h - * \author Bob Deblier <bob.deblier@telenet.be> - * \ingroup CXX_m - */ - -#ifndef _BEECRYPT_RESOURCE_H -#define _BEECRYPT_RESOURCE_H - -#include "beecrypt/api.h" - -extern const char* BEECRYPT_CONF_FILE; - -#endif diff --git a/beecrypt/c++/security/.cvsignore b/beecrypt/c++/security/.cvsignore deleted file mode 100644 index da7b4816b..000000000 --- a/beecrypt/c++/security/.cvsignore +++ /dev/null @@ -1,5 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo diff --git a/beecrypt/c++/security/AlgorithmParameterGenerator.cxx b/beecrypt/c++/security/AlgorithmParameterGenerator.cxx deleted file mode 100644 index ab004f2fe..000000000 --- a/beecrypt/c++/security/AlgorithmParameterGenerator.cxx +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/AlgorithmParameterGenerator.h" -#include "beecrypt/c++/security/AlgorithmParameterGeneratorSpi.h" -#include "beecrypt/c++/security/AlgorithmParameters.h" -#include "beecrypt/c++/security/Provider.h" -#include "beecrypt/c++/security/Security.h" -#include "beecrypt/c++/security/spec/AlgorithmParameterSpec.h" - -using namespace beecrypt::security; - -AlgorithmParameterGenerator::AlgorithmParameterGenerator(AlgorithmParameterGeneratorSpi* spi, const String& algorithm, const Provider& provider) -{ - _aspi = spi; - _algo = algorithm; - _prov = &provider; -} - -AlgorithmParameterGenerator::~AlgorithmParameterGenerator() -{ - delete _aspi; -} - -AlgorithmParameterGenerator* AlgorithmParameterGenerator::getInstance(const String& algorithm) throw (NoSuchAlgorithmException) -{ - Security::spi* tmp = Security::getSpi(algorithm, "AlgorithmParameterGenerator"); - - AlgorithmParameterGenerator* result = new AlgorithmParameterGenerator((AlgorithmParameterGeneratorSpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; -} - -AlgorithmParameterGenerator* AlgorithmParameterGenerator::getInstance(const String& algorithm, const String& provider) throw (NoSuchAlgorithmException, NoSuchProviderException) -{ - Security::spi* tmp = Security::getSpi(algorithm, "AlgorithmParameterGenerator", provider); - - AlgorithmParameterGenerator* result = new AlgorithmParameterGenerator((AlgorithmParameterGeneratorSpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; -} - -AlgorithmParameterGenerator* AlgorithmParameterGenerator::getInstance(const String& algorithm, const Provider& provider) throw (NoSuchAlgorithmException) -{ - Security::spi* tmp = Security::getSpi(algorithm, "AlgorithmParameterGenerator", provider); - - AlgorithmParameterGenerator* result = new AlgorithmParameterGenerator((AlgorithmParameterGeneratorSpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; -} - -AlgorithmParameters* AlgorithmParameterGenerator::generateParameters() throw (InvalidAlgorithmParameterException) -{ - return _aspi->engineGenerateParameters(); -} - -void AlgorithmParameterGenerator::init(const AlgorithmParameterSpec& genParamSpec) throw (InvalidAlgorithmParameterException) -{ - _aspi->engineInit(genParamSpec, 0); -} - -void AlgorithmParameterGenerator::init(const AlgorithmParameterSpec& genParamSpec, SecureRandom* random) throw (InvalidAlgorithmParameterException) -{ - _aspi->engineInit(genParamSpec, random); -} - -void AlgorithmParameterGenerator::init(size_t size) throw (InvalidParameterException) -{ - _aspi->engineInit(size, 0); -} - -void AlgorithmParameterGenerator::init(size_t size, SecureRandom* random) throw (InvalidParameterException) -{ - _aspi->engineInit(size, random); -} - -const String& AlgorithmParameterGenerator::getAlgorithm() const throw () -{ - return _algo; -} - -const Provider& AlgorithmParameterGenerator::getProvider() const throw () -{ - return *_prov; -} diff --git a/beecrypt/c++/security/AlgorithmParameterGenerator.h b/beecrypt/c++/security/AlgorithmParameterGenerator.h deleted file mode 100644 index 61ae19fce..000000000 --- a/beecrypt/c++/security/AlgorithmParameterGenerator.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file AlgorithmParameterGenerator.h - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_ALGORITHMPARAMETERGENERATOR_H -#define _CLASS_ALGORITHMPARAMETERGENERATOR_H - -// #include "beecrypt/api.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/security/AlgorithmParameterGeneratorSpi.h" -using beecrypt::security::AlgorithmParameterGeneratorSpi; -#include "beecrypt/c++/security/Provider.h" -using beecrypt::security::Provider; -#include "beecrypt/c++/security/NoSuchAlgorithmException.h" -using beecrypt::security::NoSuchAlgorithmException; -#include "beecrypt/c++/security/NoSuchProviderException.h" -using beecrypt::security::NoSuchProviderException; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI AlgorithmParameterGenerator - { - public: - static AlgorithmParameterGenerator* getInstance(const String&) throw (NoSuchAlgorithmException); - static AlgorithmParameterGenerator* getInstance(const String&, const String&) throw (NoSuchAlgorithmException, NoSuchProviderException); - static AlgorithmParameterGenerator* getInstance(const String&, const Provider&) throw (NoSuchAlgorithmException); - - private: - AlgorithmParameterGeneratorSpi* _aspi; - String _algo; - const Provider* _prov; - - protected: - AlgorithmParameterGenerator(AlgorithmParameterGeneratorSpi*, const String&, const Provider&); - - public: - ~AlgorithmParameterGenerator(); - - AlgorithmParameters* generateParameters() throw (InvalidAlgorithmParameterException); - - void init(const AlgorithmParameterSpec&) throw (InvalidAlgorithmParameterException); - void init(const AlgorithmParameterSpec&, SecureRandom*) throw (InvalidAlgorithmParameterException); - void init(size_t) throw (InvalidParameterException); - void init(size_t, SecureRandom*) throw (InvalidParameterException); - - const String& getAlgorithm() const throw (); - const Provider& getProvider() const throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/AlgorithmParameterGeneratorSpi.h b/beecrypt/c++/security/AlgorithmParameterGeneratorSpi.h deleted file mode 100644 index 17a60e4b7..000000000 --- a/beecrypt/c++/security/AlgorithmParameterGeneratorSpi.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file AlgorithmParameterGeneratorSpi.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_ALGORITHMPARAMETERGENERATORSPI_H -#define _CLASS_ALGORITHMPARAMETERGENERATORSPI_H - -#include "beecrypt/api.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/security/AlgorithmParameters.h" -using beecrypt::security::AlgorithmParameters; -#include "beecrypt/c++/security/SecureRandom.h" -using beecrypt::security::SecureRandom; -#include "beecrypt/c++/security/InvalidAlgorithmParameterException.h" -using beecrypt::security::InvalidAlgorithmParameterException; -#include "beecrypt/c++/security/InvalidParameterException.h" -using beecrypt::security::InvalidParameterException; -#include "beecrypt/c++/security/spec/AlgorithmParameterSpec.h" -using beecrypt::security::spec::AlgorithmParameterSpec; - -#include <typeinfo> -using std::type_info; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI AlgorithmParameterGeneratorSpi - { - friend class BEECRYPTCXXAPI AlgorithmParameterGenerator; - - protected: - virtual AlgorithmParameters* engineGenerateParameters() = 0; - virtual void engineInit(const AlgorithmParameterSpec&, SecureRandom*) throw (InvalidAlgorithmParameterException) = 0; - virtual void engineInit(size_t, SecureRandom*) throw (InvalidParameterException) = 0; - - public: - virtual ~AlgorithmParameterGeneratorSpi() {}; - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/AlgorithmParameters.cxx b/beecrypt/c++/security/AlgorithmParameters.cxx deleted file mode 100644 index e61e87211..000000000 --- a/beecrypt/c++/security/AlgorithmParameters.cxx +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/AlgorithmParameters.h" -#include "beecrypt/c++/security/AlgorithmParametersSpi.h" -#include "beecrypt/c++/security/Provider.h" -#include "beecrypt/c++/security/Security.h" -#include "beecrypt/c++/security/spec/AlgorithmParameterSpec.h" -using beecrypt::security::spec::AlgorithmParameterSpec; - -using namespace beecrypt::security; - -AlgorithmParameters::AlgorithmParameters(AlgorithmParametersSpi* spi, const String& algorithm, const Provider& provider) -{ - _aspi = spi; - _algo = algorithm; - _prov = &provider; -} - -AlgorithmParameters::~AlgorithmParameters() -{ - delete _aspi; -} - -AlgorithmParameters* AlgorithmParameters::getInstance(const String& algorithm) throw (NoSuchAlgorithmException) -{ - Security::spi* tmp = Security::getSpi(algorithm, "AlgorithmParameters"); - - AlgorithmParameters* result = new AlgorithmParameters((AlgorithmParametersSpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; -} - -AlgorithmParameters* AlgorithmParameters::getInstance(const String& algorithm, const String& provider) throw (NoSuchAlgorithmException, NoSuchProviderException) -{ - Security::spi* tmp = Security::getSpi(algorithm, "AlgorithmParameters", provider); - - AlgorithmParameters* result = new AlgorithmParameters((AlgorithmParametersSpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; -} - -AlgorithmParameters* AlgorithmParameters::getInstance(const String& algorithm, const Provider& provider) throw (NoSuchAlgorithmException) -{ - Security::spi* tmp = Security::getSpi(algorithm, "AlgorithmParameters", provider); - - AlgorithmParameters* result = new AlgorithmParameters((AlgorithmParametersSpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; -} - -AlgorithmParameterSpec* AlgorithmParameters::getParameterSpec(const type_info& info) throw (InvalidParameterSpecException) -{ - return _aspi->engineGetParameterSpec(info); -} - -void AlgorithmParameters::init(const AlgorithmParameterSpec& spec) throw (InvalidParameterSpecException) -{ - _aspi->engineInit(spec); -} - -void AlgorithmParameters::init(const byte* data, size_t size) -{ - _aspi->engineInit(data, size); -} - -void AlgorithmParameters::init(const byte* data, size_t size, const String& format) -{ - _aspi->engineInit(data, size, format); -} - -const String& AlgorithmParameters::getAlgorithm() const throw () -{ - return _algo; -} - -const Provider& AlgorithmParameters::getProvider() const throw () -{ - return *_prov; -} diff --git a/beecrypt/c++/security/AlgorithmParameters.h b/beecrypt/c++/security/AlgorithmParameters.h deleted file mode 100644 index 13300c8e5..000000000 --- a/beecrypt/c++/security/AlgorithmParameters.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file AlgorithmParameters.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_ALGORITHMPARAMETERS_H -#define _CLASS_ALGORITHMPARAMETERS_H - -// #include "beecrypt/api.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/security/AlgorithmParametersSpi.h" -using beecrypt::security::AlgorithmParametersSpi; -#include "beecrypt/c++/security/Provider.h" -using beecrypt::security::Provider; -#include "beecrypt/c++/security/NoSuchAlgorithmException.h" -using beecrypt::security::NoSuchAlgorithmException; -#include "beecrypt/c++/security/NoSuchProviderException.h" -using beecrypt::security::NoSuchProviderException; - -#include <typeinfo> -using std::type_info; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI AlgorithmParameters - { - public: - static AlgorithmParameters* getInstance(const String&) throw (NoSuchAlgorithmException); - static AlgorithmParameters* getInstance(const String&, const String&) throw (NoSuchAlgorithmException, NoSuchProviderException); - static AlgorithmParameters* getInstance(const String&, const Provider&) throw (NoSuchAlgorithmException); - - private: - AlgorithmParametersSpi* _aspi; - String _algo; - const Provider* _prov; - - protected: - AlgorithmParameters(AlgorithmParametersSpi*, const String&, const Provider&); - - public: - ~AlgorithmParameters(); - - AlgorithmParameterSpec* getParameterSpec(const type_info&) throw (InvalidParameterSpecException); - - void init(const AlgorithmParameterSpec&) throw (InvalidParameterSpecException); - void init(const byte*, size_t); - void init(const byte*, size_t, const String&); - - const String& getAlgorithm() const throw (); - const Provider& getProvider() const throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/AlgorithmParametersSpi.h b/beecrypt/c++/security/AlgorithmParametersSpi.h deleted file mode 100644 index 8374108ce..000000000 --- a/beecrypt/c++/security/AlgorithmParametersSpi.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file AlgorithmParametersSpi.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_ALGORITHMPARAMETERSSPI_H -#define _CLASS_ALGORITHMPARAMETERSSPI_H - -#include "beecrypt/api.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/security/spec/AlgorithmParameterSpec.h" -using beecrypt::security::spec::AlgorithmParameterSpec; -#include "beecrypt/c++/security/spec/InvalidParameterSpecException.h" -using beecrypt::security::spec::InvalidParameterSpecException; - -#include <typeinfo> -using std::type_info; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI AlgorithmParametersSpi - { - friend class BEECRYPTCXXAPI AlgorithmParameters; - - protected: - virtual AlgorithmParameterSpec* engineGetParameterSpec(const type_info&) = 0; - - virtual void engineInit(const AlgorithmParameterSpec&) throw (InvalidParameterSpecException) = 0; - virtual void engineInit(const byte*, size_t) = 0; - virtual void engineInit(const byte*, size_t, const String&) = 0; - - public: - virtual ~AlgorithmParametersSpi() {}; - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/DigestInputStream.cxx b/beecrypt/c++/security/DigestInputStream.cxx deleted file mode 100644 index 5b7325993..000000000 --- a/beecrypt/c++/security/DigestInputStream.cxx +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/lang/NullPointerException.h" -using beecrypt::lang::NullPointerException; -#include "beecrypt/c++/security/DigestInputStream.h" - -using namespace beecrypt::security; - -DigestInputStream::DigestInputStream(InputStream& in, MessageDigest& m) : FilterInputStream(in), digest(m) -{ - _on = true; -} - -DigestInputStream::~DigestInputStream() -{ -} - -int DigestInputStream::read() throw (IOException) -{ - int rc = in.read(); - if (rc >= 0 && _on) - digest.update((byte) rc); - return rc; -} - -int DigestInputStream::read(byte *data, size_t offset, size_t length) throw (IOException) -{ - if (!data) - throw NullPointerException(); - - int rc = in.read(data, offset, length); - if (rc >= 0 && _on) - digest.update(data, offset, rc); - return rc; -} - -void DigestInputStream::on(bool on) -{ - _on = on; -} - -MessageDigest& DigestInputStream::getMessageDigest() -{ - return digest; -} - -void DigestInputStream::setMessageDigest(MessageDigest& m) -{ - digest = m; -} diff --git a/beecrypt/c++/security/DigestInputStream.h b/beecrypt/c++/security/DigestInputStream.h deleted file mode 100644 index 52ed2ac3c..000000000 --- a/beecrypt/c++/security/DigestInputStream.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DigestInputStream.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_DIGESTINPUTSTREAM_H -#define _CLASS_DIGESTINPUTSTREAM_H - -#ifdef __cplusplus - -#include "beecrypt/c++/io/FilterInputStream.h" -using beecrypt::io::FilterInputStream; -#include "beecrypt/c++/security/MessageDigest.h" -using beecrypt::security::MessageDigest; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI DigestInputStream : public FilterInputStream - { - private: - bool _on; - - protected: - MessageDigest& digest; - - public: - DigestInputStream(InputStream&, MessageDigest&); - virtual ~DigestInputStream(); - - virtual int read() throw (IOException); - virtual int read(byte* data, size_t offset, size_t length) throw (IOException); - - void on(bool); - - MessageDigest& getMessageDigest(); - void setMessageDigest(MessageDigest&); - }; - } -} - -#endif - -#endif - diff --git a/beecrypt/c++/security/DigestOutputStream.cxx b/beecrypt/c++/security/DigestOutputStream.cxx deleted file mode 100644 index 68996957c..000000000 --- a/beecrypt/c++/security/DigestOutputStream.cxx +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/lang/NullPointerException.h" -using beecrypt::lang::NullPointerException; -#include "beecrypt/c++/security/DigestOutputStream.h" - -using namespace beecrypt::security; - -DigestOutputStream::DigestOutputStream(OutputStream& out, MessageDigest& m) : FilterOutputStream(out), digest(m) -{ - _on = true; -} - -DigestOutputStream::~DigestOutputStream() -{ -} - -void DigestOutputStream::write(byte b) throw (IOException) -{ - out.write(b); - if (_on) - digest.update(b); -} - -void DigestOutputStream::write(const byte *data, size_t offset, size_t length) throw (IOException) -{ - if (!data) - throw NullPointerException(); - - out.write(data, offset, length); - if (_on) - digest.update(data, offset, length); -} - -void DigestOutputStream::on(bool on) -{ - _on = on; -} - -MessageDigest& DigestOutputStream::getMessageDigest() -{ - return digest; -} - -void DigestOutputStream::setMessageDigest(MessageDigest& m) -{ - digest = m; -} diff --git a/beecrypt/c++/security/DigestOutputStream.h b/beecrypt/c++/security/DigestOutputStream.h deleted file mode 100644 index b37686f43..000000000 --- a/beecrypt/c++/security/DigestOutputStream.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DigestOutputStream.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_DIGESTOUTPUTSTREAM_H -#define _CLASS_DIGESTOUTPUTSTREAM_H - -#ifdef __cplusplus - -#include "beecrypt/c++/io/FilterOutputStream.h" -using beecrypt::io::FilterOutputStream; -#include "beecrypt/c++/security/MessageDigest.h" -using beecrypt::security::MessageDigest; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI DigestOutputStream : public FilterOutputStream - { - private: - bool _on; - - protected: - MessageDigest& digest; - - public: - DigestOutputStream(OutputStream&, MessageDigest&); - virtual ~DigestOutputStream(); - - virtual void write(byte) throw (IOException); - virtual void write(const byte* data, size_t offset, size_t length) throw (IOException); - - void on(bool); - - MessageDigest& getMessageDigest(); - void setMessageDigest(MessageDigest&); - }; - } -} - -#endif - -#endif - diff --git a/beecrypt/c++/security/GeneralSecurityException.cxx b/beecrypt/c++/security/GeneralSecurityException.cxx deleted file mode 100644 index d482812d0..000000000 --- a/beecrypt/c++/security/GeneralSecurityException.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/GeneralSecurityException.h" - -using namespace beecrypt::security; - -GeneralSecurityException::GeneralSecurityException() throw () -{ -} - -GeneralSecurityException::GeneralSecurityException(const String& message) throw () : Exception(message) -{ -} diff --git a/beecrypt/c++/security/GeneralSecurityException.h b/beecrypt/c++/security/GeneralSecurityException.h deleted file mode 100644 index c20c11777..000000000 --- a/beecrypt/c++/security/GeneralSecurityException.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file GeneralSecurityException.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_GENERALSECURITYEXCEPTION_H -#define _CLASS_GENERALSECURITYEXCEPTION_H - -#ifdef __cplusplus - -#include "beecrypt/c++/lang/Exception.h" -using beecrypt::lang::Exception; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI GeneralSecurityException : public Exception - { - public: - GeneralSecurityException() throw (); - GeneralSecurityException(const String&) throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/InvalidAlgorithmParameterException.cxx b/beecrypt/c++/security/InvalidAlgorithmParameterException.cxx deleted file mode 100644 index 1ec06393c..000000000 --- a/beecrypt/c++/security/InvalidAlgorithmParameterException.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/InvalidAlgorithmParameterException.h" - -using namespace beecrypt::security; - -InvalidAlgorithmParameterException::InvalidAlgorithmParameterException() throw () -{ -} - -InvalidAlgorithmParameterException::InvalidAlgorithmParameterException(const String& message) throw () : GeneralSecurityException(message) -{ -} diff --git a/beecrypt/c++/security/InvalidAlgorithmParameterException.h b/beecrypt/c++/security/InvalidAlgorithmParameterException.h deleted file mode 100644 index 5af09b5de..000000000 --- a/beecrypt/c++/security/InvalidAlgorithmParameterException.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file InvalidAlgorithmParameterException.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_INVALIDALGORITHMPARAMETEREXCEPTION_H -#define _CLASS_INVALIDALGORITHMPARAMETEREXCEPTION_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/GeneralSecurityException.h" -using beecrypt::security::GeneralSecurityException; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI InvalidAlgorithmParameterException : public GeneralSecurityException - { - public: - InvalidAlgorithmParameterException() throw (); - InvalidAlgorithmParameterException(const String&) throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/InvalidKeyException.cxx b/beecrypt/c++/security/InvalidKeyException.cxx deleted file mode 100644 index 6f5bad295..000000000 --- a/beecrypt/c++/security/InvalidKeyException.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/InvalidKeyException.h" - -using namespace beecrypt::security; - -InvalidKeyException::InvalidKeyException() throw () -{ -} - -InvalidKeyException::InvalidKeyException(const String& message) throw () : KeyException(message) -{ -} diff --git a/beecrypt/c++/security/InvalidKeyException.h b/beecrypt/c++/security/InvalidKeyException.h deleted file mode 100644 index 2aa58edbe..000000000 --- a/beecrypt/c++/security/InvalidKeyException.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file InvalidKeyException.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_INVALIDKEYEXCEPTION_H -#define _CLASS_INVALIDKEYEXCEPTION_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/KeyException.h" -using beecrypt::security::KeyException; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI InvalidKeyException : public KeyException - { - public: - InvalidKeyException() throw (); - InvalidKeyException(const String&) throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/InvalidParameterException.cxx b/beecrypt/c++/security/InvalidParameterException.cxx deleted file mode 100644 index 0494334ab..000000000 --- a/beecrypt/c++/security/InvalidParameterException.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/InvalidParameterException.h" - -using namespace beecrypt::security; - -InvalidParameterException::InvalidParameterException() throw () -{ -} - -InvalidParameterException::InvalidParameterException(const String& message) throw () : IllegalArgumentException(message) -{ -} diff --git a/beecrypt/c++/security/InvalidParameterException.h b/beecrypt/c++/security/InvalidParameterException.h deleted file mode 100644 index 1a96a893c..000000000 --- a/beecrypt/c++/security/InvalidParameterException.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file InvalidParameterException.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_INVALIDPARAMETEREXCEPTION_H -#define _CLASS_INVALIDPARAMETEREXCEPTION_H - -#ifdef __cplusplus - -#include "beecrypt/c++/lang/IllegalArgumentException.h" -using beecrypt::lang::IllegalArgumentException; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI InvalidParameterException : public IllegalArgumentException - { - public: - InvalidParameterException() throw (); - InvalidParameterException(const String&) throw (); - }; - } -} -#endif - -#endif diff --git a/beecrypt/c++/security/Key.h b/beecrypt/c++/security/Key.h deleted file mode 100644 index 4ca88b1eb..000000000 --- a/beecrypt/c++/security/Key.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file Key.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _INTERFACE_KEY_H -#define _INTERFACE_KEY_H - -#ifdef __cplusplus - -#include "beecrypt/c++/array.h" -using beecrypt::bytearray; -#include "beecrypt/c++/lang/String.h" -using beecrypt::lang::String; - -namespace beecrypt { - namespace security { - /*!\brief The top-level interface for all keys. - * \ingroup CXX_IF_m - */ - class BEECRYPTCXXAPI Key - { - public: - virtual ~Key() {}; - - virtual Key* clone() const = 0; - - virtual const bytearray* getEncoded() const = 0; - - virtual const String& getAlgorithm() const throw () = 0; - virtual const String* getFormat() const throw () = 0; - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/KeyException.cxx b/beecrypt/c++/security/KeyException.cxx deleted file mode 100644 index b42da208d..000000000 --- a/beecrypt/c++/security/KeyException.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/KeyException.h" - -using namespace beecrypt::security; - -KeyException::KeyException() throw () -{ -} - -KeyException::KeyException(const String& message) throw () : GeneralSecurityException(message) -{ -} diff --git a/beecrypt/c++/security/KeyException.h b/beecrypt/c++/security/KeyException.h deleted file mode 100644 index 4b02faf9d..000000000 --- a/beecrypt/c++/security/KeyException.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file KeyException.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_KEYEXCEPTION_H -#define _CLASS_KEYEXCEPTION_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/GeneralSecurityException.h" -using beecrypt::security::GeneralSecurityException; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI KeyException : public GeneralSecurityException - { - public: - KeyException() throw (); - KeyException(const String&) throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/KeyFactory.cxx b/beecrypt/c++/security/KeyFactory.cxx deleted file mode 100644 index aaf910da8..000000000 --- a/beecrypt/c++/security/KeyFactory.cxx +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/KeyFactory.h" -#include "beecrypt/c++/security/Security.h" - -using namespace beecrypt::security; - -KeyFactory::KeyFactory(KeyFactorySpi* spi, const String& algorithm, const Provider& provider) -{ - _kspi = spi; - _algo = algorithm; - _prov = &provider; -} - -KeyFactory::~KeyFactory() -{ - delete _kspi; -} - -KeyFactory* KeyFactory::getInstance(const String& algorithm) throw (NoSuchAlgorithmException) -{ - Security::spi* tmp = Security::getSpi(algorithm, "KeyFactory"); - - KeyFactory* result = new KeyFactory((KeyFactorySpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; -} - -KeyFactory* KeyFactory::getInstance(const String& algorithm, const String& provider) throw (NoSuchAlgorithmException, NoSuchProviderException) -{ - Security::spi* tmp = Security::getSpi(algorithm, "KeyFactory", provider); - - KeyFactory* result = new KeyFactory((KeyFactorySpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; -} - -KeyFactory* KeyFactory::getInstance(const String& algorithm, const Provider& provider) throw (NoSuchAlgorithmException) -{ - Security::spi* tmp = Security::getSpi(algorithm, "KeyFactory", provider); - - KeyFactory* result = new KeyFactory((KeyFactorySpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; -} - -PrivateKey* KeyFactory::generatePrivate(const KeySpec& spec) throw (InvalidKeySpecException) -{ - return _kspi->engineGeneratePrivate(spec); -} - -PublicKey* KeyFactory::generatePublic(const KeySpec& spec) throw (InvalidKeySpecException) -{ - return _kspi->engineGeneratePublic(spec); -} - -KeySpec* KeyFactory::getKeySpec(const Key& key, const type_info& info) throw (InvalidKeySpecException) -{ - return _kspi->engineGetKeySpec(key, info); -} - -Key* KeyFactory::translateKey(const Key& key) throw (InvalidKeyException) -{ - return _kspi->engineTranslateKey(key); -} - -const String& KeyFactory::getAlgorithm() const throw () -{ - return _algo; -} - -const Provider& KeyFactory::getProvider() const throw () -{ - return *_prov; -} diff --git a/beecrypt/c++/security/KeyFactory.h b/beecrypt/c++/security/KeyFactory.h deleted file mode 100644 index fd992dd0b..000000000 --- a/beecrypt/c++/security/KeyFactory.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file KeyFactory.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_KEYFACTORY_H -#define _CLASS_KEYFACTORY_H - -#include "beecrypt/api.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/security/KeyFactorySpi.h" -using beecrypt::security::KeyFactorySpi; -#include "beecrypt/c++/security/Provider.h" -using beecrypt::security::Provider; -#include "beecrypt/c++/security/NoSuchAlgorithmException.h" -using beecrypt::security::NoSuchAlgorithmException; -#include "beecrypt/c++/security/NoSuchProviderException.h" -using beecrypt::security::NoSuchProviderException; - -#include <typeinfo> -using std::type_info; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI KeyFactory - { - public: - static KeyFactory* getInstance(const String&) throw (NoSuchAlgorithmException); - static KeyFactory* getInstance(const String&, const String&) throw (NoSuchAlgorithmException, NoSuchProviderException); - static KeyFactory* getInstance(const String&, const Provider&) throw (NoSuchAlgorithmException); - - private: - KeyFactorySpi* _kspi; - String _algo; - const Provider* _prov; - - protected: - KeyFactory(KeyFactorySpi*, const String&, const Provider&); - - public: - ~KeyFactory(); - - PrivateKey* generatePrivate(const KeySpec&) throw (InvalidKeySpecException); - PublicKey* generatePublic(const KeySpec&) throw (InvalidKeySpecException); - - KeySpec* getKeySpec(const Key& key, const type_info&) throw (InvalidKeySpecException); - - Key* translateKey(const Key&) throw (InvalidKeyException); - - const String& getAlgorithm() const throw (); - const Provider& getProvider() const throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/KeyFactorySpi.h b/beecrypt/c++/security/KeyFactorySpi.h deleted file mode 100644 index caca4b153..000000000 --- a/beecrypt/c++/security/KeyFactorySpi.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file KeyFactorySpi.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_KEYFACTORYSPI_H -#define _CLASS_KEYFACTORYSPI_H - -#include "beecrypt/api.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/security/PrivateKey.h" -using beecrypt::security::PrivateKey; -#include "beecrypt/c++/security/PublicKey.h" -using beecrypt::security::PublicKey; -#include "beecrypt/c++/security/InvalidKeyException.h" -#include "beecrypt/c++/security/spec/KeySpec.h" -using beecrypt::security::spec::KeySpec; -#include "beecrypt/c++/security/spec/InvalidKeySpecException.h" -using beecrypt::security::spec::InvalidKeySpecException; - -#include <typeinfo> -using std::type_info; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI KeyFactorySpi - { - friend class KeyFactory; - - protected: - virtual PrivateKey* engineGeneratePrivate(const KeySpec&) throw (InvalidKeySpecException) = 0; - virtual PublicKey* engineGeneratePublic(const KeySpec&) throw (InvalidKeySpecException) = 0; - - virtual KeySpec* engineGetKeySpec(const Key&, const type_info&) throw (InvalidKeySpecException) = 0; - - virtual Key* engineTranslateKey(const Key&) throw (InvalidKeyException) = 0; - - public: - virtual ~KeyFactorySpi() {}; - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/KeyPair.cxx b/beecrypt/c++/security/KeyPair.cxx deleted file mode 100644 index 659e29a79..000000000 --- a/beecrypt/c++/security/KeyPair.cxx +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/KeyPair.h" - -using namespace beecrypt::security; - -KeyPair::KeyPair(const PublicKey& pub, const PrivateKey& pri) : pub(pub.clone()), pri(pri.clone()) -{ -} - -KeyPair::KeyPair(PublicKey* pub, PrivateKey* pri) : pub(pub), pri(pri) -{ -} - -KeyPair::~KeyPair() -{ - delete pub; - delete pri; -} - -const PublicKey& KeyPair::getPublic() const throw () -{ - return *pub; -} - -const PrivateKey& KeyPair::getPrivate() const throw () -{ - return *pri; -} diff --git a/beecrypt/c++/security/KeyPair.h b/beecrypt/c++/security/KeyPair.h deleted file mode 100644 index 280dc20df..000000000 --- a/beecrypt/c++/security/KeyPair.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file KeyPair.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_KEYPAIR_H -#define _CLASS_KEYPAIR_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/PrivateKey.h" -using beecrypt::security::PrivateKey; -#include "beecrypt/c++/security/PublicKey.h" -using beecrypt::security::PublicKey; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI KeyPair - { - friend class KeyPairGenerator; - - private: - PublicKey* pub; - PrivateKey* pri; - - public: - KeyPair(const PublicKey&, const PrivateKey&); - KeyPair(PublicKey*, PrivateKey*); - ~KeyPair(); - - const PublicKey& getPublic() const throw (); - const PrivateKey& getPrivate() const throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/KeyPairGenerator.cxx b/beecrypt/c++/security/KeyPairGenerator.cxx deleted file mode 100644 index 45dbf851a..000000000 --- a/beecrypt/c++/security/KeyPairGenerator.cxx +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/KeyPairGenerator.h" -#include "beecrypt/c++/security/Security.h" - -using namespace beecrypt::security; - -KeyPairGenerator::KeyPairGenerator(KeyPairGeneratorSpi* spi, const String& algorithm, const Provider& provider) -{ - _kspi = spi; - _algo = algorithm; - _prov = &provider; -} - -KeyPairGenerator::~KeyPairGenerator() -{ - delete _kspi; -} - -KeyPairGenerator* KeyPairGenerator::getInstance(const String& algorithm) throw (NoSuchAlgorithmException) -{ - Security::spi* tmp = Security::getSpi(algorithm, "KeyPairGenerator"); - - KeyPairGenerator* result = new KeyPairGenerator((KeyPairGeneratorSpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; -} - -KeyPairGenerator* KeyPairGenerator::getInstance(const String& algorithm, const String& provider) throw (NoSuchAlgorithmException, NoSuchProviderException) -{ - Security::spi* tmp = Security::getSpi(algorithm, "KeyPairGenerator", provider); - - KeyPairGenerator* result = new KeyPairGenerator((KeyPairGeneratorSpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; -} - -KeyPairGenerator* KeyPairGenerator::getInstance(const String& algorithm, const Provider& provider) throw (NoSuchAlgorithmException) -{ - Security::spi* tmp = Security::getSpi(algorithm, "KeyPairGenerator", provider); - - KeyPairGenerator* result = new KeyPairGenerator((KeyPairGeneratorSpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; -} - -KeyPair* KeyPairGenerator::generateKeyPair() -{ - return _kspi->engineGenerateKeyPair(); -} - -void KeyPairGenerator::initialize(const AlgorithmParameterSpec& spec) throw (InvalidAlgorithmParameterException) -{ - _kspi->engineInitialize(spec, 0); -} - -void KeyPairGenerator::initialize(const AlgorithmParameterSpec& spec, SecureRandom* random) throw (InvalidAlgorithmParameterException) -{ - _kspi->engineInitialize(spec, random); -} - -void KeyPairGenerator::initialize(size_t keysize) throw (InvalidParameterException) -{ - _kspi->engineInitialize(keysize, 0); -} - -void KeyPairGenerator::initialize(size_t keysize, SecureRandom* random) throw (InvalidParameterException) -{ - _kspi->engineInitialize(keysize, random); -} - -const String& KeyPairGenerator::getAlgorithm() const throw () -{ - return _algo; -} - -const Provider& KeyPairGenerator::getProvider() const throw () -{ - return *_prov; -} diff --git a/beecrypt/c++/security/KeyPairGenerator.h b/beecrypt/c++/security/KeyPairGenerator.h deleted file mode 100644 index 50d3e4ec2..000000000 --- a/beecrypt/c++/security/KeyPairGenerator.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file KeyPairGenerator.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_KEYPAIRGENERATOR_H -#define _CLASS_KEYPAIRGENERATOR_H - -// #include "beecrypt/api.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/security/KeyPairGeneratorSpi.h" -using beecrypt::security::KeyPairGeneratorSpi; -#include "beecrypt/c++/security/Provider.h" -using beecrypt::security::Provider; -#include "beecrypt/c++/security/NoSuchAlgorithmException.h" -using beecrypt::security::NoSuchAlgorithmException; -#include "beecrypt/c++/security/NoSuchProviderException.h" -using beecrypt::security::NoSuchProviderException; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI KeyPairGenerator - { - public: - static KeyPairGenerator* getInstance(const String&) throw (NoSuchAlgorithmException); - static KeyPairGenerator* getInstance(const String&, const String&) throw (NoSuchAlgorithmException, NoSuchProviderException); - static KeyPairGenerator* getInstance(const String&, const Provider&) throw (NoSuchAlgorithmException); - - private: - KeyPairGeneratorSpi* _kspi; - String _algo; - const Provider* _prov; - - protected: - KeyPairGenerator(KeyPairGeneratorSpi*, const String&, const Provider&); - - public: - ~KeyPairGenerator(); - - KeyPair* generateKeyPair(); - - void initialize(const AlgorithmParameterSpec&) throw (InvalidAlgorithmParameterException); - void initialize(const AlgorithmParameterSpec&, SecureRandom*) throw (InvalidAlgorithmParameterException); - void initialize(size_t) throw(InvalidParameterException); - void initialize(size_t, SecureRandom*) throw (InvalidParameterException); - - const String& getAlgorithm() const throw (); - const Provider& getProvider() const throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/KeyPairGeneratorSpi.h b/beecrypt/c++/security/KeyPairGeneratorSpi.h deleted file mode 100644 index b67074e22..000000000 --- a/beecrypt/c++/security/KeyPairGeneratorSpi.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file KeyPairGeneratorSpi.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_KEYPAIRGENERATORSPI_H -#define _CLASS_KEYPAIRGENERATORSPI_H - -#include "beecrypt/api.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/security/KeyPair.h" -using beecrypt::security::KeyPair; -#include "beecrypt/c++/security/SecureRandom.h" -using beecrypt::security::SecureRandom; -#include "beecrypt/c++/security/InvalidAlgorithmParameterException.h" -using beecrypt::security::InvalidAlgorithmParameterException; -#include "beecrypt/c++/security/InvalidParameterException.h" -using beecrypt::security::InvalidParameterException; -#include "beecrypt/c++/security/spec/AlgorithmParameterSpec.h" -using beecrypt::security::spec::AlgorithmParameterSpec; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI KeyPairGeneratorSpi - { - friend class KeyPairGenerator; - - protected: - virtual KeyPair* engineGenerateKeyPair() = 0; - - virtual void engineInitialize(const AlgorithmParameterSpec&, SecureRandom*) throw (InvalidAlgorithmParameterException) = 0; - virtual void engineInitialize(size_t, SecureRandom*) throw (InvalidParameterException) = 0; - - public: - virtual ~KeyPairGeneratorSpi() {}; - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/KeyStore.cxx b/beecrypt/c++/security/KeyStore.cxx deleted file mode 100644 index 715f34f03..000000000 --- a/beecrypt/c++/security/KeyStore.cxx +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/KeyStore.h" -#include "beecrypt/c++/security/Security.h" - -using namespace beecrypt::security; - -KeyStore::KeyStore(KeyStoreSpi* spi, const String& type, const Provider& provider) -{ - _kspi = spi; - _type = type; - _prov = &provider; - _init = false; -} - -KeyStore::~KeyStore() -{ - delete _kspi; -} - -KeyStore* KeyStore::getInstance(const String& type) throw (KeyStoreException) -{ - try - { - Security::spi* tmp = Security::getSpi(type, "KeyStore"); - - KeyStore* result = new KeyStore((KeyStoreSpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; - } - catch (NoSuchAlgorithmException& ex) - { - throw KeyStoreException(ex.getMessage()); - } -} - -KeyStore* KeyStore::getInstance(const String& type, const String& provider) throw (KeyStoreException, NoSuchProviderException) -{ - try - { - Security::spi* tmp = Security::getSpi(type, "KeyStore", provider); - - KeyStore* result = new KeyStore((KeyStoreSpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; - } - catch (NoSuchAlgorithmException& ex) - { - throw KeyStoreException(ex.getMessage()); - } -} - -KeyStore* KeyStore::getInstance(const String& type, const Provider& provider) throw (KeyStoreException) -{ - try - { - Security::spi* tmp = Security::getSpi(type, "KeyStore", provider); - - KeyStore* result = new KeyStore((KeyStoreSpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; - } - catch (NoSuchAlgorithmException& ex) - { - throw KeyStoreException(ex.getMessage()); - } -} - -const String& KeyStore::getDefaultType() -{ - return Security::getKeyStoreDefault(); -} - -Key* KeyStore::getKey(const String& alias, const array<javachar>& password) throw (KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException) -{ - return _kspi->engineGetKey(alias, password); -} - -void KeyStore::setKeyEntry(const String& alias, const bytearray& key, const vector<Certificate*>& chain) throw (KeyStoreException) -{ - _kspi->engineSetKeyEntry(alias, key, chain); -} - -void KeyStore::setKeyEntry(const String& alias, const Key& key, const array<javachar>& password, const vector<Certificate*>& chain) throw (KeyStoreException) -{ - _kspi->engineSetKeyEntry(alias, key, password, chain); -} - -Enumeration* KeyStore::aliases() -{ - if (!_init) - throw KeyStoreException("Uninitialized keystore"); - - return _kspi->engineAliases(); -} - -bool KeyStore::containsAlias(const String& alias) throw (KeyStoreException) -{ - if (!_init) - throw KeyStoreException("Uninitialized keystore"); - - return _kspi->engineContainsAlias(alias); -} - -const Certificate* KeyStore::getCertificate(const String& alias) throw (KeyStoreException) -{ - if (!_init) - throw KeyStoreException("Uninitialized keystore"); - - return _kspi->engineGetCertificate(alias); -} - -bool KeyStore::isCertificateEntry(const String& alias) throw (KeyStoreException) -{ - if (!_init) - throw KeyStoreException("Uninitialized keystore"); - - return _kspi->engineIsCertificateEntry(alias); -} - -bool KeyStore::isKeyEntry(const String& alias) throw (KeyStoreException) -{ - if (!_init) - throw KeyStoreException("Uninitialized keystore"); - - return _kspi->engineIsKeyEntry(alias); -} - -void KeyStore::load(InputStream* in, const array<javachar>* password) throw (IOException, NoSuchAlgorithmException, CertificateException) -{ - _kspi->engineLoad(in, password); - - _init = true; -} - -size_t KeyStore::size() const throw (KeyStoreException) -{ - if (!_init) - throw KeyStoreException("Uninitialized keystore"); - - return _kspi->engineSize(); -} - -void KeyStore::store(OutputStream& out, const array<javachar>* password) throw (IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException) -{ - if (!_init) - throw KeyStoreException("Uninitialized keystore"); - - _kspi->engineStore(out, password); -} - -const String& KeyStore::getType() const throw () -{ - return _type; -} - -const Provider& KeyStore::getProvider() const throw () -{ - return *_prov; -} diff --git a/beecrypt/c++/security/KeyStore.h b/beecrypt/c++/security/KeyStore.h deleted file mode 100644 index c1dc29135..000000000 --- a/beecrypt/c++/security/KeyStore.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file KeyStore.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_KEYSTORE_H -#define _CLASS_KEYSTORE_H - -#include "beecrypt/api.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/io/InputStream.h" -using beecrypt::io::InputStream; -#include "beecrypt/c++/io/OutputStream.h" -using beecrypt::io::OutputStream; -#include "beecrypt/c++/security/KeyStoreSpi.h" -using beecrypt::security::KeyStoreSpi; -#include "beecrypt/c++/security/KeyStoreException.h" -using beecrypt::security::KeyStoreException; -#include "beecrypt/c++/security/Provider.h" -using beecrypt::security::Provider; -#include "beecrypt/c++/security/NoSuchProviderException.h" -using beecrypt::security::NoSuchProviderException; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI KeyStore - { - public: - static KeyStore* getInstance(const String&) throw (KeyStoreException); - static KeyStore* getInstance(const String&, const String&) throw (KeyStoreException, NoSuchProviderException); - static KeyStore* getInstance(const String&, const Provider&) throw (KeyStoreException); - - static const String& getDefaultType(); - - private: - KeyStoreSpi* _kspi; - String _type; - const Provider* _prov; - bool _init; - - protected: - KeyStore(KeyStoreSpi*, const String&, const Provider&); - - public: - ~KeyStore(); - - Enumeration* aliases(); - bool containsAlias(const String&) throw (KeyStoreException); - - const Certificate* getCertificate(const String&) throw (KeyStoreException); - const String& getCertificateAlias(const Certificate&) throw (KeyStoreException); - const vector<Certificate*>* getCertificateChain(const String&) throw (KeyStoreException); - bool isCertificateEntry(const String& alias) throw (KeyStoreException); - void setCertificateEntry(const String& alias, const Certificate& cert) throw (KeyStoreException); - - void deleteEntry(const String&) throw (KeyStoreException); - - Key* getKey(const String& alias, const array<javachar>& password) throw (KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException); - bool isKeyEntry(const String& alias) throw (KeyStoreException); - void setKeyEntry(const String& alias, const bytearray& key, const vector<Certificate*>&) throw (KeyStoreException); - void setKeyEntry(const String& alias, const Key& key, const array<javachar>& password, const vector<Certificate*>&) throw (KeyStoreException); - - size_t size() const throw (KeyStoreException); - - void load(InputStream* in, const array<javachar>* password) throw (IOException, NoSuchAlgorithmException, CertificateException); - void store(OutputStream& out, const array<javachar>* password) throw (KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException); - - const String& getType() const throw (); - const Provider& getProvider() const throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/KeyStoreException.cxx b/beecrypt/c++/security/KeyStoreException.cxx deleted file mode 100644 index 22b53c0db..000000000 --- a/beecrypt/c++/security/KeyStoreException.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/KeyStoreException.h" - -using namespace beecrypt::security; - -KeyStoreException::KeyStoreException() throw () -{ -} - -KeyStoreException::KeyStoreException(const String& message) throw () : GeneralSecurityException(message) -{ -} diff --git a/beecrypt/c++/security/KeyStoreException.h b/beecrypt/c++/security/KeyStoreException.h deleted file mode 100644 index ec522d7f8..000000000 --- a/beecrypt/c++/security/KeyStoreException.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file KeyStoreException.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_KEYSTOREEXCEPTION_H -#define _CLASS_KEYSTOREEXCEPTION_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/GeneralSecurityException.h" -using beecrypt::security::GeneralSecurityException; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI KeyStoreException : public GeneralSecurityException - { - public: - KeyStoreException() throw (); - KeyStoreException(const String&) throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/KeyStoreSpi.h b/beecrypt/c++/security/KeyStoreSpi.h deleted file mode 100644 index 32a09e03f..000000000 --- a/beecrypt/c++/security/KeyStoreSpi.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file KeyStoreSpi.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_KEYSTORESPI_H -#define _CLASS_KEYSTORESPI_H - -#include "beecrypt/api.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/io/InputStream.h" -using beecrypt::io::InputStream; -#include "beecrypt/c++/io/OutputStream.h" -using beecrypt::io::OutputStream; -#include "beecrypt/c++/security/KeyStoreException.h" -using beecrypt::security::KeyStoreException; -#include "beecrypt/c++/security/NoSuchAlgorithmException.h" -using beecrypt::security::NoSuchAlgorithmException; -#include "beecrypt/c++/security/NoSuchProviderException.h" -using beecrypt::security::NoSuchProviderException; -#include "beecrypt/c++/security/UnrecoverableKeyException.h" -using beecrypt::security::UnrecoverableKeyException; -#include "beecrypt/c++/security/cert/Certificate.h" -using beecrypt::security::cert::Certificate; -#include "beecrypt/c++/security/cert/CertificateException.h" -using beecrypt::security::cert::CertificateException; -#include "beecrypt/c++/util/Date.h" -using beecrypt::util::Date; -#include "beecrypt/c++/util/Enumeration.h" -using beecrypt::util::Enumeration; - -#include <typeinfo> -using std::type_info; -#include <vector> -using std::vector; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI KeyStoreSpi - { - friend class KeyStore; - - protected: - virtual Enumeration* engineAliases() = 0; - virtual bool engineContainsAlias(const String&) = 0; - - virtual void engineDeleteEntry(const String&) throw (KeyStoreException) = 0; - virtual const Date* engineGetCreationDate(const String&) = 0; - - virtual const Certificate* engineGetCertificate(const String&) = 0; - virtual const String* engineGetCertificateAlias(const Certificate&) = 0; - virtual const vector<Certificate*>* engineGetCertificateChain(const String&) = 0; - virtual bool engineIsCertificateEntry(const String& alias) = 0; - virtual void engineSetCertificateEntry(const String& alias, const Certificate& cert) throw (KeyStoreException) = 0; - - virtual Key* engineGetKey(const String& alias, const array<javachar>& password) throw (NoSuchAlgorithmException, UnrecoverableKeyException) = 0; - virtual bool engineIsKeyEntry(const String& alias) = 0; - virtual void engineSetKeyEntry(const String& alias, const bytearray& key, const vector<Certificate*>&) throw (KeyStoreException) = 0; - virtual void engineSetKeyEntry(const String& alias, const Key& key, const array<javachar>& password, const vector<Certificate*>&) throw (KeyStoreException) = 0; - - virtual size_t engineSize() const = 0; - - virtual void engineLoad(InputStream* in, const array<javachar>* password) throw (IOException, CertificateException, NoSuchAlgorithmException) = 0; - virtual void engineStore(OutputStream& out, const array<javachar>* password) throw (IOException, CertificateException, NoSuchAlgorithmException) = 0; - - public: - virtual ~KeyStoreSpi() {}; - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/Makefile.am b/beecrypt/c++/security/Makefile.am deleted file mode 100644 index ebf413c6a..000000000 --- a/beecrypt/c++/security/Makefile.am +++ /dev/null @@ -1,73 +0,0 @@ -INCLUDES = -I$(top_srcdir)/.. - -AUTOMAKE_OPTIONS = gnu no-dependencies - -SUBDIRS = cert interfaces spec - -noinst_LTLIBRARIES = libcxxsecurity.la - -cxxsecuritydir=$(pkgincludedir)/c++/security - -libcxxsecurity_la_SOURCES =\ -AlgorithmParameterGenerator.cxx \ -AlgorithmParameters.cxx \ -DigestInputStream.cxx \ -DigestOutputStream.cxx \ -GeneralSecurityException.cxx \ -InvalidAlgorithmParameterException.cxx \ -InvalidKeyException.cxx \ -InvalidParameterException.cxx \ -KeyException.cxx \ -KeyFactory.cxx \ -KeyPair.cxx \ -KeyPairGenerator.cxx \ -KeyStore.cxx \ -KeyStoreException.cxx \ -MessageDigest.cxx \ -NoSuchAlgorithmException.cxx \ -NoSuchProviderException.cxx \ -Provider.cxx \ -SecureRandom.cxx \ -Security.cxx \ -ShortBufferException.cxx \ -Signature.cxx \ -SignatureException.cxx \ -UnrecoverableKeyException.cxx -libcxxsecurity_la_LIBADD = cert/libcxxsecuritycert.la spec/libcxxsecurityspec.la - -cxxsecurity_HEADERS =\ -AlgorithmParameterGenerator.h \ -AlgorithmParameterGeneratorSpi.h \ -AlgorithmParameters.h \ -AlgorithmParametersSpi.h \ -DigestInputStream.h \ -DigestOutputStream.h \ -GeneralSecurityException.h \ -InvalidAlgorithmParameterException.h \ -InvalidKeyException.h \ -InvalidParameterException.h \ -KeyFactory.h \ -KeyFactorySpi.h \ -Key.h \ -KeyException.h \ -KeyPairGenerator.h \ -KeyPairGeneratorSpi.h \ -KeyPair.h \ -KeyStoreException.h \ -KeyStore.h \ -KeyStoreSpi.h \ -MessageDigest.h \ -MessageDigestSpi.h \ -NoSuchAlgorithmException.h \ -NoSuchProviderException.h \ -PrivateKey.h \ -Provider.h \ -PublicKey.h \ -SecureRandom.h \ -SecureRandomSpi.h \ -Security.h \ -ShortBufferException.h \ -Signature.h \ -SignatureException.h \ -SignatureSpi.h \ -UnrecoverableKeyException.h diff --git a/beecrypt/c++/security/MessageDigest.cxx b/beecrypt/c++/security/MessageDigest.cxx deleted file mode 100644 index dbd534863..000000000 --- a/beecrypt/c++/security/MessageDigest.cxx +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/MessageDigest.h" -#include "beecrypt/c++/security/Security.h" - -using namespace beecrypt::security; - -MessageDigest::MessageDigest(MessageDigestSpi* spi, const String& algorithm, const Provider& provider) -{ - _mspi = spi; - _algo = algorithm; - _prov = &provider; -} - -MessageDigest::~MessageDigest() -{ - delete _mspi; -} - -MessageDigest* MessageDigest::getInstance(const String& algorithm) throw (NoSuchAlgorithmException) -{ - Security::spi* tmp = Security::getSpi(algorithm, "MessageDigest"); - - MessageDigest* result = new MessageDigest((MessageDigestSpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; -} - -MessageDigest* MessageDigest::getInstance(const String& algorithm, const String& provider) throw (NoSuchAlgorithmException, NoSuchProviderException) -{ - Security::spi* tmp = Security::getSpi(algorithm, "MessageDigest", provider); - - MessageDigest* result = new MessageDigest((MessageDigestSpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; -} - -MessageDigest* MessageDigest::getInstance(const String& algorithm, const Provider& provider) throw (NoSuchAlgorithmException) -{ - Security::spi* tmp = Security::getSpi(algorithm, "MessageDigest", provider); - - MessageDigest* result = new MessageDigest((MessageDigestSpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; -} - -MessageDigest* MessageDigest::clone() const -{ - MessageDigestSpi* _mspc = _mspi->clone(); - - if (_mspc) - return new MessageDigest(_mspc, _algo, *_prov); - else - return 0; -} - -const bytearray& MessageDigest::digest() -{ - return _mspi->engineDigest(); -} - -const bytearray& MessageDigest::digest(const bytearray& b) -{ - _mspi->engineUpdate(b.data(), 0, b.size()); - return _mspi->engineDigest(); -} - -size_t MessageDigest::digest(byte* data, size_t offset, size_t length) throw (ShortBufferException) -{ - return _mspi->engineDigest(data, offset, length); -} - -size_t MessageDigest::getDigestLength() -{ - return _mspi->engineGetDigestLength(); -} - -void MessageDigest::reset() -{ - _mspi->engineReset(); -} - -void MessageDigest::update(byte b) -{ - _mspi->engineUpdate(b); -} - -void MessageDigest::update(const bytearray& b) -{ - _mspi->engineUpdate(b.data(), 0, b.size()); -} - -void MessageDigest::update(const byte* data, size_t offset, size_t length) -{ - _mspi->engineUpdate(data, offset, length); -} - -const String& MessageDigest::getAlgorithm() const throw () -{ - return _algo; -} - -const Provider& MessageDigest::getProvider() const throw () -{ - return *_prov; -} diff --git a/beecrypt/c++/security/MessageDigest.h b/beecrypt/c++/security/MessageDigest.h deleted file mode 100644 index 12ca2b84d..000000000 --- a/beecrypt/c++/security/MessageDigest.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file MessageDigest.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_MESSAGEDIGEST_H -#define _CLASS_MESSAGEDIGEST_H - -#include "beecrypt/api.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/security/MessageDigestSpi.h" -using beecrypt::security::MessageDigestSpi; -#include "beecrypt/c++/security/Provider.h" -using beecrypt::security::Provider; -#include "beecrypt/c++/security/NoSuchAlgorithmException.h" -using beecrypt::security::NoSuchAlgorithmException; -#include "beecrypt/c++/security/NoSuchProviderException.h" -using beecrypt::security::NoSuchProviderException; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI MessageDigest - { - public: - static MessageDigest* getInstance(const String&) throw (NoSuchAlgorithmException); - static MessageDigest* getInstance(const String&, const String&) throw (NoSuchAlgorithmException, NoSuchProviderException); - static MessageDigest* getInstance(const String&, const Provider&) throw (NoSuchAlgorithmException); - - private: - MessageDigestSpi* _mspi; - String _algo; - const Provider* _prov; - - protected: - MessageDigest(MessageDigestSpi*, const String&, const Provider&); - - public: - ~MessageDigest(); - - MessageDigest* clone() const; - - const bytearray& digest(); - const bytearray& digest(const bytearray&); - size_t digest(byte* data, size_t offset, size_t length) throw (ShortBufferException); - size_t getDigestLength(); - void reset(); - void update(byte); - void update(const byte* data, size_t offset, size_t length); - void update(const bytearray& b); - - const String& getAlgorithm() const throw (); - const Provider& getProvider() const throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/MessageDigestSpi.h b/beecrypt/c++/security/MessageDigestSpi.h deleted file mode 100644 index db2cc86e2..000000000 --- a/beecrypt/c++/security/MessageDigestSpi.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file MessageDigestSpi.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_MESSAGEDIGESTSPI_H -#define _CLASS_MESSAGEDIGESTSPI_H - -#include "beecrypt/api.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/array.h" -using beecrypt::bytearray; -#include "beecrypt/c++/security/ShortBufferException.h" -using beecrypt::security::ShortBufferException; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI MessageDigestSpi - { - friend class MessageDigest; - - protected: - virtual const bytearray& engineDigest() = 0; - virtual size_t engineDigest(byte*, size_t, size_t) throw (ShortBufferException) = 0; - virtual size_t engineGetDigestLength() = 0; - virtual void engineReset() = 0; - virtual void engineUpdate(byte) = 0; - virtual void engineUpdate(const byte*, size_t, size_t) = 0; - - public: - virtual ~MessageDigestSpi() {}; - - virtual MessageDigestSpi* clone() const = 0; - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/NoSuchAlgorithmException.cxx b/beecrypt/c++/security/NoSuchAlgorithmException.cxx deleted file mode 100644 index 69408e3e3..000000000 --- a/beecrypt/c++/security/NoSuchAlgorithmException.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/NoSuchAlgorithmException.h" - -using namespace beecrypt::security; - -NoSuchAlgorithmException::NoSuchAlgorithmException() throw () -{ -} - -NoSuchAlgorithmException::NoSuchAlgorithmException(const String& message) throw () : GeneralSecurityException(message) -{ -} diff --git a/beecrypt/c++/security/NoSuchAlgorithmException.h b/beecrypt/c++/security/NoSuchAlgorithmException.h deleted file mode 100644 index 3d97b2f5f..000000000 --- a/beecrypt/c++/security/NoSuchAlgorithmException.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file NoSuchAlgorithmException.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_NOSUCHALGORITHMEXCEPTION_H -#define _CLASS_NOSUCHALGORITHMEXCEPTION_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/GeneralSecurityException.h" -using beecrypt::security::GeneralSecurityException; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI NoSuchAlgorithmException : public GeneralSecurityException - { - public: - NoSuchAlgorithmException() throw (); - NoSuchAlgorithmException(const String&) throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/NoSuchProviderException.cxx b/beecrypt/c++/security/NoSuchProviderException.cxx deleted file mode 100644 index 101f077a5..000000000 --- a/beecrypt/c++/security/NoSuchProviderException.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/NoSuchProviderException.h" - -using namespace beecrypt::security; - -NoSuchProviderException::NoSuchProviderException() throw () -{ -} - -NoSuchProviderException::NoSuchProviderException(const String& message) throw () : GeneralSecurityException(message) -{ -} diff --git a/beecrypt/c++/security/NoSuchProviderException.h b/beecrypt/c++/security/NoSuchProviderException.h deleted file mode 100644 index f69b5e453..000000000 --- a/beecrypt/c++/security/NoSuchProviderException.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file NoSuchProviderException.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_NOSUCHPROVIDEREXCEPTION_H -#define _CLASS_NOSUCHPROVIDEREXCEPTION_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/GeneralSecurityException.h" -using beecrypt::security::GeneralSecurityException; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI NoSuchProviderException : public GeneralSecurityException - { - public: - NoSuchProviderException() throw (); - NoSuchProviderException(const String&) throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/PrivateKey.h b/beecrypt/c++/security/PrivateKey.h deleted file mode 100644 index eff83c209..000000000 --- a/beecrypt/c++/security/PrivateKey.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file PrivateKey.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _INTERFACE_PRIVATEKEY_H -#define _INTERFACE_PRIVATEKEY_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/Key.h" -using beecrypt::security::Key; - -namespace beecrypt { - namespace security { - /*!\brief PrivateKey interface - * \ingroup CXX_IF_m - */ - class PrivateKey : public Key - { - public: - virtual PrivateKey* clone() const = 0; - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/Provider.cxx b/beecrypt/c++/security/Provider.cxx deleted file mode 100644 index efb19e4ac..000000000 --- a/beecrypt/c++/security/Provider.cxx +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/Provider.h" - -using namespace beecrypt::security; - -Provider::Provider(const String& name, double version, const String& info) -{ - _name = name; - _info = info; - _vers = version; - - _lock.init(); - - UErrorCode status = U_ZERO_ERROR; - - _conv = ucnv_open(NULL, &status); - if (U_FAILURE(status)) - throw "failed to create default unicode converter"; - - #if WIN32 - _dlhandle = NULL; - #else - _dlhandle = RTLD_DEFAULT; - #endif -} - -Provider::~Provider() -{ - _lock.destroy(); - - ucnv_close(_conv); -} - -Provider::instantiator Provider::getInstantiator(const String& key) const -{ - instantiator_map::const_iterator it = _imap.find(key); - - if (it != _imap.end()) - return it->second; - else - return 0; -} - -void Provider::put(const String& key, const String& value) -{ - _lock.lock(); - - // add it in the properties - setProperty(key, value); - - // add it in the instantiator map only if there is no space in the value (i.e. it's a property instead of a class) - if (value.indexOf((UChar) 0x20) == -1) - { - char symname[1024]; - - UErrorCode status = U_ZERO_ERROR; - - ucnv_fromUChars(_conv, symname, 1024, value.getBuffer(), value.length(), &status); - - if (status != U_ZERO_ERROR) - { - _lock.unlock(); - throw "error in ucnv_fromUChars"; - } - - instantiator i; - - #if WIN32 - if (!_dlhandle) - _dlhandle = GetModuleHandle(NULL); - i = (instantiator) GetProcAddress((HMODULE) _dlhandle, symname); - #elif HAVE_DLFCN_H - i = (instantiator) dlsym(_dlhandle, symname); - #else - # error - #endif - - _imap[key] = i; - } - else - _imap[key] = 0; - - _lock.unlock(); -} - -const String& Provider::getInfo() const throw () -{ - return _info; -} - -const String& Provider::getName() const throw () -{ - return _name; -} - -double Provider::getVersion() const throw () -{ - return _vers; -} diff --git a/beecrypt/c++/security/Provider.h b/beecrypt/c++/security/Provider.h deleted file mode 100644 index 572a0b012..000000000 --- a/beecrypt/c++/security/Provider.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file Provider.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_PROVIDER_H -#define _CLASS_PROVIDER_H - -#ifdef __cplusplus - -#include "beecrypt/c++/mutex.h" -using beecrypt::mutex; -#include "beecrypt/c++/lang/String.h" -using beecrypt::lang::String; -#include "beecrypt/c++/util/Properties.h" -using beecrypt::util::Properties; - -#include <unicode/ucnv.h> -#include <map> -using std::map; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI Provider : public Properties - { - friend class Security; - - private: - String _name; - String _info; - double _vers; - - mutex _lock; - UConverter* _conv; - - typedef void* (*instantiator)(); - typedef map<String,instantiator> instantiator_map; - - instantiator_map _imap; - - instantiator getInstantiator(const String& name) const; - - protected: - #if WIN32 - HANDLE _dlhandle; - #else - void* _dlhandle; - #endif - - Provider(const String& name, double version, const String& info); - - public: - virtual ~Provider(); - - void put(const String& key, const String& value); - - const String& getName() const throw (); - const String& getInfo() const throw (); - double getVersion() const throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/PublicKey.h b/beecrypt/c++/security/PublicKey.h deleted file mode 100644 index 933629238..000000000 --- a/beecrypt/c++/security/PublicKey.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file PublicKey.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _INTERFACE_PUBLICKEY_H -#define _INTERFACE_PUBLICKEY_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/Key.h" -using beecrypt::security::Key; - -namespace beecrypt { - namespace security { - /*!\brief Public key interface. - * \ingroup CXX_IF_m - */ - class PublicKey : public Key - { - public: - virtual PublicKey* clone() const = 0; - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/SecureRandom.cxx b/beecrypt/c++/security/SecureRandom.cxx deleted file mode 100644 index b25d0e984..000000000 --- a/beecrypt/c++/security/SecureRandom.cxx +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/SecureRandom.h" -#include "beecrypt/c++/security/SecureRandomSpi.h" -#include "beecrypt/c++/security/Security.h" - -using namespace beecrypt::security; - -SecureRandom* SecureRandom::getInstance(const String& algorithm) throw (NoSuchAlgorithmException) -{ - Security::spi* tmp = Security::getSpi(algorithm, "SecureRandom"); - - SecureRandom* result = new SecureRandom((SecureRandomSpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; -} - -SecureRandom* SecureRandom::getInstance(const String& type, const String& provider) throw (NoSuchAlgorithmException, NoSuchProviderException) -{ - Security::spi* tmp = Security::getSpi(type, "SecureRandom", provider); - - SecureRandom* result = new SecureRandom((SecureRandomSpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; -} - -SecureRandom* SecureRandom::getInstance(const String& type, const Provider& provider) throw (NoSuchAlgorithmException) -{ - Security::spi* tmp = Security::getSpi(type, "SecureRandom", provider); - - SecureRandom* result = new SecureRandom((SecureRandomSpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; -} - -void SecureRandom::getSeed(byte* data, size_t size) -{ - entropyGatherNext(data, size); -} - -SecureRandom::SecureRandom() -{ - Security::spi* tmp = Security::getFirstSpi("SecureRandom"); - - _rspi = (SecureRandomSpi*) tmp->cspi; - _type = tmp->name; - _prov = &tmp->prov; - - delete tmp; -} - -SecureRandom::SecureRandom(SecureRandomSpi* rspi, const String& type, const Provider& provider) : _prov(&provider) -{ - _rspi = rspi; - _type = type; - _prov = &provider; -} - -SecureRandom::~SecureRandom() -{ - delete _rspi; -} - -void SecureRandom::generateSeed(byte* data, size_t size) -{ - _rspi->engineGenerateSeed(data, size); -} - -void SecureRandom::setSeed(const byte* data, size_t size) -{ - _rspi->engineSetSeed(data, size); -} - -void SecureRandom::nextBytes(byte* data, size_t size) -{ - _rspi->engineNextBytes(data, size); -} - -const String& SecureRandom::getType() const throw () -{ - return _type; -} - -const Provider& SecureRandom::getProvider() const throw () -{ - return *_prov; -} diff --git a/beecrypt/c++/security/SecureRandom.h b/beecrypt/c++/security/SecureRandom.h deleted file mode 100644 index 0baa6e1f0..000000000 --- a/beecrypt/c++/security/SecureRandom.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file SecureRandom.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_SECURERANDOM_H -#define _CLASS_SECURERANDOM_H - -#include "beecrypt/beecrypt.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/security/SecureRandomSpi.h" -using beecrypt::security::SecureRandomSpi; -#include "beecrypt/c++/security/Provider.h" -using beecrypt::security::Provider; -#include "beecrypt/c++/security/NoSuchAlgorithmException.h" -using beecrypt::security::NoSuchAlgorithmException; -#include "beecrypt/c++/security/NoSuchProviderException.h" -using beecrypt::security::NoSuchProviderException; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI SecureRandom - { - public: - static SecureRandom* getInstance(const String&) throw (NoSuchAlgorithmException); - static SecureRandom* getInstance(const String&, const String&) throw (NoSuchAlgorithmException, NoSuchProviderException); - static SecureRandom* getInstance(const String&, const Provider&) throw (NoSuchAlgorithmException); - - static void getSeed(byte*, size_t); - - private: - SecureRandomSpi* _rspi; - String _type; - const Provider* _prov; - - protected: - SecureRandom(SecureRandomSpi*, const String&, const Provider&); - - public: - SecureRandom(); - ~SecureRandom(); - - void generateSeed(byte*, size_t); - void nextBytes(byte*, size_t); - void setSeed(const byte*, size_t); - - const String& getType() const throw (); - const Provider& getProvider() const throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/SecureRandomSpi.h b/beecrypt/c++/security/SecureRandomSpi.h deleted file mode 100644 index 1c4b9103a..000000000 --- a/beecrypt/c++/security/SecureRandomSpi.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file SecureRandomSpi.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_SECURERANDOMSPI_H -#define _CLASS_SECURERANDOMSPI_H - -#include "beecrypt/api.h" - -#ifdef __cplusplus - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI SecureRandomSpi - { - friend class SecureRandom; - - protected: - virtual void engineGenerateSeed(byte*, size_t) = 0; - virtual void engineNextBytes(byte*, size_t) = 0; - virtual void engineSetSeed(const byte*, size_t) = 0; - - public: - virtual ~SecureRandomSpi() {}; - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/Security.cxx b/beecrypt/c++/security/Security.cxx deleted file mode 100644 index f2b75d0e1..000000000 --- a/beecrypt/c++/security/Security.cxx +++ /dev/null @@ -1,404 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/resource.h" -#include "beecrypt/c++/security/Security.h" -#include "beecrypt/c++/io/FileInputStream.h" -using beecrypt::io::FileInputStream; - -#include <iostream> -#include <unicode/ustream.h> - -using namespace beecrypt::security; - -namespace { - const String KEYSTORE_DEFAULT_TYPE = UNICODE_STRING_SIMPLE("BEE"); -} - -bool Security::_init = false; -mutex Security::_lock; -Properties Security::_props; -Security::provider_vector Security::_providers; - -/* Have to use lazy initialization here; static initialization doesn't work. - * Initialization adds a provider, apparently in another copy of Security, - * instead of where we would expect it. - * - * Don't dlclose the libraries or uninstall the providers. They'll - * disappear when the program closes. Since this happens only once per - * application which uses this library, that's acceptable. - * - * What we eventually need to do is the following: - * - treat the beecrypt.conf file as a collection of Properties, loaded from - * file with loadProperties. - * - get appropriate properties to do the initialization - */ - -void Security::initialize() -{ - _lock.init(); - _lock.lock(); - _init = true; - _lock.unlock(); - - /* get the configuration file here and load providers */ - const char* path = getenv("BEECRYPT_CONF_FILE"); - - FILE* props; - - if (path) - props = fopen(path, "r"); - else - props = fopen(BEECRYPT_CONF_FILE, "r"); - - if (!props) - { - std::cerr << "couldn't open beecrypt configuration file" << std::endl; - } - else - { - FileInputStream fis(props); - - try - { - // load properties from fis - _props.load(fis); - - for (int32_t index = 1; true; index++) - { - char num[32]; - - sprintf(num, "provider.%d", index); - - String key(num); - - const String* value = _props.getProperty(key); - - if (value) - { - int32_t reqlen = value->extract(0, value->length(), (char*) 0, (const char*) 0); - - char* shared_library = new char[reqlen+1]; - - value->extract(0, value->length(), shared_library, (const char*) 0); - - #if WIN32 - HANDLE handle = LoadLibraryEx(shared_library, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); - #elif HAVE_DLFCN_H - void *handle = dlopen(shared_library, RTLD_NOW); - #else - # error - #endif - - if (handle) - { - #if WIN32 - const Provider& (*inst)(void*) = (const Provider& (*)(void*)) GetProcAddress((HMODULE) handle, "provider_const_ref"); - #elif HAVE_PTHREAD_H - const Provider& (*inst)(void*) = (const Provider& (*)(void*)) dlsym(handle, "provider_const_ref"); - #else - # error - #endif - - if (inst) - { - addProvider(inst(handle)); - } - else - { - std::cerr << "library doesn't contain symbol provider_const_ref" << std::endl; - #if HAVE_DLFCN_H - std::cerr << "dlerror: " << dlerror() << std::endl; - #endif - } - } - else - { - std::cerr << "unable to open shared library " << shared_library << std::endl; - #if HAVE_DLFCN_H - std::cerr << "dlerror: " << dlerror() << std::endl; - #endif - } - - delete[] shared_library; - } - else - break; - } - } - catch (IOException) - { - } - } -} - -Security::spi::spi(void* cspi, const String& name, const Provider& prov) : cspi(cspi), name(name), prov(prov) -{ -} - -Security::spi* Security::getSpi(const String& name, const String& type) throw (NoSuchAlgorithmException) -{ - if (!_init) - initialize(); - - String afind = type + "." + name; - String alias = "Alg.Alias." + type + "." + name; - - _lock.lock(); - for (size_t i = 0; i < _providers.size(); i++) - { - Provider::instantiator inst = 0; - - const Provider* p = _providers[i]; - - if (p->getProperty(afind)) - { - inst = p->getInstantiator(afind); - } - else - { - const String* alias_of = p->getProperty(alias); - - if (alias_of) - inst = p->getInstantiator(*alias_of); - } - - if (inst) - { - register spi* result = new spi(inst(), name, *p); - _lock.unlock(); - return result; - } - } - - _lock.unlock(); - - throw NoSuchAlgorithmException(name + " " + type + " not available"); -} - -Security::spi* Security::getSpi(const String& name, const String& type, const String& provider) throw (NoSuchAlgorithmException, NoSuchProviderException) -{ - if (!_init) - initialize(); - - String afind = type + "." + name; - String alias = "Alg.Alias." + type + "." + name; - - _lock.lock(); - for (size_t i = 0; i < _providers.size(); i++) - { - const Provider* p = _providers[i]; - - if (p->getName() == provider) - { - Provider::instantiator inst = 0; - - const Provider* p = _providers[i]; - - if (p->getProperty(afind)) - { - inst = p->getInstantiator(afind); - } - else - { - const String* alias_of = p->getProperty(alias); - - if (alias_of) - inst = p->getInstantiator(*alias_of); - } - - if (inst) - { - register spi* result = new spi(inst(), name, *p); - _lock.unlock(); - return result; - } - - _lock.unlock(); - - throw NoSuchAlgorithmException(name + " " + type + " not available"); - } - } - - _lock.unlock(); - - throw NoSuchProviderException(provider + " Provider not available"); -} - -Security::spi* Security::getSpi(const String& name, const String& type, const Provider& provider) throw (NoSuchAlgorithmException) -{ - if (!_init) - initialize(); - - String afind = type + "." + name; - String alias = "Alg.Alias." + type + "." + name; - - Provider::instantiator inst = 0; - - if (provider.getProperty(afind)) - { - inst = provider.getInstantiator(afind); - } - else - { - const String* alias_of = provider.getProperty(alias); - - if (alias_of) - inst = provider.getInstantiator(*alias_of); - } - - if (inst) - return new spi(inst(), name, provider); - - throw NoSuchAlgorithmException(name + " " + type + " not available"); -} - -Security::spi* Security::getFirstSpi(const String& type) -{ - if (!_init) - initialize(); - - String afind = type + "."; - - for (size_t i = 0; i < _providers.size(); i++) - { - const Provider* p = _providers[i]; - - Enumeration* e = p->propertyNames(); - - while (e->hasMoreElements()) - { - const String* s = (const String*) e->nextElement(); - - if (s->startsWith(afind)) - { - String name; - - name.setTo(*s, afind.length()); - - Provider::instantiator inst = p->getInstantiator(*s); - - if (inst) - { - delete e; - - return new spi(inst(), name, *p); - } - } - } - - delete e; - } - return 0; -} - -const String& Security::getKeyStoreDefault() -{ - return *_props.getProperty("keystore.default", KEYSTORE_DEFAULT_TYPE); -} - -int Security::addProvider(const Provider& provider) -{ - if (!_init) - initialize(); - - if (getProvider(provider.getName())) - return -1; - - _lock.lock(); - - size_t rc = (int) _providers.size(); - - _providers.push_back(&provider); - - _lock.unlock(); - - return rc; -} - -int Security::insertProviderAt(const Provider& provider, size_t position) -{ - if (!_init) - initialize(); - - if (getProvider(provider.getName())) - return -1; - - _lock.lock(); - - size_t size = _providers.size(); - - if (position > size || position <= 0) - position = size+1; - - _providers.insert(_providers.begin()+position-1, &provider); - - _lock.unlock(); - - return (int) position; -} - -void Security::removeProvider(const String& name) -{ - if (!_init) - initialize(); - - _lock.lock(); - for (provider_vector_iterator it = _providers.begin(); it != _providers.end(); it++) - { - const Provider* p = *it; - - if (p->getName() == name) - { - _providers.erase(it); - _lock.unlock(); - return; - } - } - _lock.unlock(); -} - -const Security::provider_vector& Security::getProviders() -{ - if (!_init) - initialize(); - - return _providers; -} - -const Provider* Security::getProvider(const String& name) -{ - if (!_init) - initialize(); - - for (size_t i = 0; i < _providers.size(); i++) - { - const Provider* tmp = _providers[i]; - - if (tmp->getName() == name) - return _providers[i]; - } - - return 0; -} diff --git a/beecrypt/c++/security/Security.h b/beecrypt/c++/security/Security.h deleted file mode 100644 index 2623a853c..000000000 --- a/beecrypt/c++/security/Security.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file Security.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_SECURITY_H -#define _CLASS_SECURITY_H - -#ifdef __cplusplus - -#include "beecrypt/c++/mutex.h" -using beecrypt::mutex; -#include "beecrypt/c++/util/Properties.h" -using beecrypt::util::Properties; -#include "beecrypt/c++/security/Provider.h" -using beecrypt::security::Provider; -#include "beecrypt/c++/security/NoSuchAlgorithmException.h" -using beecrypt::security::NoSuchAlgorithmException; -#include "beecrypt/c++/security/NoSuchProviderException.h" -using beecrypt::security::NoSuchProviderException; -#include "beecrypt/c++/security/cert/CertificateFactory.h" -using beecrypt::security::cert::CertificateFactory; -#include "beecrypt/c++/crypto/Mac.h" -using beecrypt::crypto::Mac; -#include "beecrypt/c++/crypto/SecretKeyFactory.h" -using beecrypt::crypto::SecretKeyFactory; - -#include <vector> -using std::vector; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI Security - { - friend class AlgorithmParameterGenerator; - friend class AlgorithmParameters; - friend class CertificateFactory; - friend class KeyFactory; - friend class KeyPairGenerator; - friend class KeyStore; - friend class Mac; - friend class MessageDigest; - friend class SecretKeyFactory; - friend class SecureRandom; - friend class Signature; - - public: - typedef vector<const Provider*> provider_vector; - typedef provider_vector::iterator provider_vector_iterator; - - private: - struct spi - { - void* cspi; - String name; - const Provider& prov; - - spi(void* cspi, const String&, const Provider&); - }; - - static spi* getSpi(const String& name, const String& type) throw (NoSuchAlgorithmException); - static spi* getSpi(const String& algo, const String& type, const String& provider) throw (NoSuchAlgorithmException, NoSuchProviderException); - static spi* getSpi(const String& algo, const String& type, const Provider&) throw (NoSuchAlgorithmException); - static spi* getFirstSpi(const String& type); - - static const String& getKeyStoreDefault(); - - static bool _init; - static Properties _props; - static mutex _lock; - static provider_vector _providers; - - static void initialize(); - - public: - static int addProvider(const Provider& provider); - static int insertProviderAt(const Provider& provider, size_t position); - static void removeProvider(const String& name); - static const Provider* getProvider(const String& name); - static const provider_vector& getProviders(); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/ShortBufferException.cxx b/beecrypt/c++/security/ShortBufferException.cxx deleted file mode 100644 index f07197e72..000000000 --- a/beecrypt/c++/security/ShortBufferException.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/ShortBufferException.h" - -using namespace beecrypt::security; - -ShortBufferException::ShortBufferException() throw () -{ -} - -ShortBufferException::ShortBufferException(const String& message) throw () : GeneralSecurityException(message) -{ -} diff --git a/beecrypt/c++/security/ShortBufferException.h b/beecrypt/c++/security/ShortBufferException.h deleted file mode 100644 index 4ee0d3835..000000000 --- a/beecrypt/c++/security/ShortBufferException.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file ShortBufferException.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_SHORTBUFFEREXCEPTION_H -#define _CLASS_SHORTBUFFEREXCEPTION_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/GeneralSecurityException.h" -using beecrypt::security::GeneralSecurityException; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI ShortBufferException : public GeneralSecurityException - { - public: - ShortBufferException() throw (); - ShortBufferException(const String&) throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/Signature.cxx b/beecrypt/c++/security/Signature.cxx deleted file mode 100644 index 5cdb1f628..000000000 --- a/beecrypt/c++/security/Signature.cxx +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/Signature.h" -#include "beecrypt/c++/security/Security.h" - -using namespace beecrypt::security; - -Signature::Signature(SignatureSpi* spi, const String& algorithm, const Provider& provider) -{ - _sspi = spi; - _algo = algorithm; - _prov = &provider; -} - -Signature::~Signature() -{ - delete _sspi; -} - -Signature* Signature::getInstance(const String& algorithm) throw (NoSuchAlgorithmException) -{ - Security::spi* tmp = Security::getSpi(algorithm, "Signature"); - - Signature* result = new Signature((SignatureSpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; -} - -Signature* Signature::getInstance(const String& algorithm, const String& provider) throw (NoSuchAlgorithmException, NoSuchProviderException) -{ - Security::spi* tmp = Security::getSpi(algorithm, "Signature", provider); - - Signature* result = new Signature((SignatureSpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; -} - -Signature* Signature::getInstance(const String& algorithm, const Provider& provider) throw (NoSuchAlgorithmException) -{ - Security::spi* tmp = Security::getSpi(algorithm, "Signature", provider); - - Signature* result = new Signature((SignatureSpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; -} - -AlgorithmParameters* Signature::getParameters() const -{ - return _sspi->engineGetParameters(); -} - -void Signature::setParameter(const AlgorithmParameterSpec& spec) throw (InvalidAlgorithmParameterException) -{ - _sspi->engineSetParameter(spec); -} - -void Signature::initSign(const PrivateKey& key) throw (InvalidKeyException) -{ - _sspi->engineInitSign(key, (SecureRandom*) 0); - - state = SIGN; -} - -void Signature::initSign(const PrivateKey& key, SecureRandom* random) throw (InvalidKeyException) -{ - _sspi->engineInitSign(key, random); - - state = SIGN; -} - -void Signature::initVerify(const PublicKey& key) throw (InvalidKeyException) -{ - _sspi->engineInitVerify(key); - - state = VERIFY; -} - -bytearray* Signature::sign() throw (IllegalStateException, SignatureException) -{ - if (state != SIGN) - throw IllegalStateException("object not initialized for signing"); - - return _sspi->engineSign(); -} - -size_t Signature::sign(byte* outbuf, size_t offset, size_t len) throw (ShortBufferException, IllegalStateException, SignatureException) -{ - if (state != SIGN) - throw IllegalStateException("object not initialized for signing"); - - return _sspi->engineSign(outbuf, offset, len); -} - -size_t Signature::sign(bytearray& out) throw (IllegalStateException, SignatureException) -{ - if (state != SIGN) - throw IllegalStateException("object not initialized for signing"); - - return _sspi->engineSign(out); -} - -bool Signature::verify(const bytearray& signature) throw (IllegalStateException, SignatureException) -{ - return verify(signature.data(), 0, signature.size()); -} - -bool Signature::verify(const byte* signature, size_t offset, size_t len) throw (IllegalStateException, SignatureException) -{ - if (state != VERIFY) - throw IllegalStateException("object not initialized for verification"); - - return _sspi->engineVerify(signature, offset, len); -} - -void Signature::update(byte b) throw (IllegalStateException) -{ - if (state == UNINITIALIZED) - throw IllegalStateException("object not initialized for signing or verification"); - - _sspi->engineUpdate(b); -} - -void Signature::update(const byte* data, size_t offset, size_t len) throw (IllegalStateException) -{ - if (state == UNINITIALIZED) - throw IllegalStateException("object not initialized for signing or verification"); - - _sspi->engineUpdate(data, offset, len); -} - -void Signature::update(const bytearray& b) throw (IllegalStateException) -{ - update(b.data(), 0, b.size()); -} - -const String& Signature::getAlgorithm() const throw () -{ - return _algo; -} - -const Provider& Signature::getProvider() const throw () -{ - return *_prov; -} diff --git a/beecrypt/c++/security/Signature.h b/beecrypt/c++/security/Signature.h deleted file mode 100644 index 3a0e29ca9..000000000 --- a/beecrypt/c++/security/Signature.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file Signature.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_SIGNATURE_H -#define _CLASS_SIGNATURE_H - -#include "beecrypt/api.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/security/SignatureSpi.h" -using beecrypt::security::SignatureSpi; -#include "beecrypt/c++/security/NoSuchAlgorithmException.h" -using beecrypt::security::NoSuchAlgorithmException; -#include "beecrypt/c++/security/NoSuchProviderException.h" -using beecrypt::security::NoSuchProviderException; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI Signature - { - protected: - static const int UNINITIALIZED = 0; - static const int VERIFY = 1; - static const int SIGN = 2; - - public: - static Signature* getInstance(const String&) throw (NoSuchAlgorithmException); - static Signature* getInstance(const String&, const String&) throw (NoSuchAlgorithmException, NoSuchProviderException); - static Signature* getInstance(const String&, const Provider&) throw (NoSuchAlgorithmException); - - protected: - int state; - - private: - SignatureSpi* _sspi; - String _algo; - const Provider* _prov; - - protected: - Signature(SignatureSpi*, const String&, const Provider&); - - public: - ~Signature(); - - AlgorithmParameters* getParameters() const; - void setParameter(const AlgorithmParameterSpec&) throw (InvalidAlgorithmParameterException); - - void initSign(const PrivateKey&) throw (InvalidKeyException); - void initSign(const PrivateKey&, SecureRandom*) throw (InvalidKeyException); - - void initVerify(const PublicKey&) throw (InvalidKeyException); - - bytearray* sign() throw (IllegalStateException, SignatureException); - size_t sign(byte*, size_t, size_t) throw (ShortBufferException, IllegalStateException, SignatureException); - size_t sign(bytearray&) throw (IllegalStateException, SignatureException); - bool verify(const bytearray&) throw (IllegalStateException, SignatureException); - bool verify(const byte*, size_t, size_t) throw (IllegalStateException, SignatureException); - - void update(byte) throw (IllegalStateException); - void update(const byte*, size_t, size_t) throw (IllegalStateException); - void update(const bytearray&) throw (IllegalStateException); - - const String& getAlgorithm() const throw (); - const Provider& getProvider() const throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/SignatureException.cxx b/beecrypt/c++/security/SignatureException.cxx deleted file mode 100644 index 4cc329682..000000000 --- a/beecrypt/c++/security/SignatureException.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/SignatureException.h" - -using namespace beecrypt::security; - -SignatureException::SignatureException() throw () -{ -} - -SignatureException::SignatureException(const String& message) throw () : GeneralSecurityException(message) -{ -} diff --git a/beecrypt/c++/security/SignatureException.h b/beecrypt/c++/security/SignatureException.h deleted file mode 100644 index 32dd1bd84..000000000 --- a/beecrypt/c++/security/SignatureException.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file SignatureException.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_SIGNATUREEXCEPTION_H -#define _CLASS_SIGNATUREEXCEPTION_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/GeneralSecurityException.h" -using beecrypt::security::GeneralSecurityException; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI SignatureException : public GeneralSecurityException - { - public: - SignatureException() throw (); - SignatureException(const String&) throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/SignatureSpi.h b/beecrypt/c++/security/SignatureSpi.h deleted file mode 100644 index 3469e57ea..000000000 --- a/beecrypt/c++/security/SignatureSpi.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file SignatureSpi.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_SIGNATURESPI_H -#define _CLASS_SIGNATURESPI_H - -#include "beecrypt/api.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/array.h" -using beecrypt::bytearray; -#include "beecrypt/c++/lang/IllegalStateException.h" -using beecrypt::lang::IllegalStateException; -#include "beecrypt/c++/security/AlgorithmParameters.h" -using beecrypt::security::AlgorithmParameters; -#include "beecrypt/c++/security/PrivateKey.h" -using beecrypt::security::PrivateKey; -#include "beecrypt/c++/security/PublicKey.h" -using beecrypt::security::PublicKey; -#include "beecrypt/c++/security/SecureRandom.h" -using beecrypt::security::SecureRandom; -#include "beecrypt/c++/security/InvalidAlgorithmParameterException.h" -using beecrypt::security::InvalidAlgorithmParameterException; -#include "beecrypt/c++/security/InvalidKeyException.h" -using beecrypt::security::InvalidKeyException; -#include "beecrypt/c++/security/ShortBufferException.h" -using beecrypt::security::ShortBufferException; -#include "beecrypt/c++/security/SignatureException.h" -using beecrypt::security::SignatureException; -#include "beecrypt/c++/security/spec/AlgorithmParameterSpec.h" -using beecrypt::security::spec::AlgorithmParameterSpec; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI SignatureSpi - { - friend class Signature; - - protected: - virtual AlgorithmParameters* engineGetParameters() const = 0; - virtual void engineSetParameter(const AlgorithmParameterSpec&) throw (InvalidAlgorithmParameterException) = 0; - - virtual void engineInitSign(const PrivateKey&, SecureRandom*) throw (InvalidKeyException) = 0; - - virtual void engineInitVerify(const PublicKey&) = 0; - - virtual void engineUpdate(byte) = 0; - virtual void engineUpdate(const byte*, size_t, size_t) = 0; - - virtual bytearray* engineSign() throw (SignatureException) = 0; - virtual size_t engineSign(byte*, size_t, size_t) throw (ShortBufferException, SignatureException) = 0; - virtual size_t engineSign(bytearray&) throw (SignatureException) = 0; - virtual bool engineVerify(const byte*, size_t, size_t) throw (SignatureException) = 0; - - public: - virtual ~SignatureSpi() {}; - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/UnrecoverableKeyException.cxx b/beecrypt/c++/security/UnrecoverableKeyException.cxx deleted file mode 100644 index a46552a76..000000000 --- a/beecrypt/c++/security/UnrecoverableKeyException.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/UnrecoverableKeyException.h" - -using namespace beecrypt::security; - -UnrecoverableKeyException::UnrecoverableKeyException() throw () -{ -} - -UnrecoverableKeyException::UnrecoverableKeyException(const String& message) throw () : GeneralSecurityException(message) -{ -} diff --git a/beecrypt/c++/security/UnrecoverableKeyException.h b/beecrypt/c++/security/UnrecoverableKeyException.h deleted file mode 100644 index f4eb88789..000000000 --- a/beecrypt/c++/security/UnrecoverableKeyException.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file UnrecoverableKeyException.h - * \ingroup CXX_SECURITY_m - */ - -#ifndef _CLASS_UNRECOVERABLEKEYEXCEPTION_H -#define _CLASS_UNRECOVERABLEKEYEXCEPTION_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/GeneralSecurityException.h" -using beecrypt::security::GeneralSecurityException; - -namespace beecrypt { - namespace security { - class BEECRYPTCXXAPI UnrecoverableKeyException : public GeneralSecurityException - { - public: - UnrecoverableKeyException() throw (); - UnrecoverableKeyException(const String&) throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/cert/.cvsignore b/beecrypt/c++/security/cert/.cvsignore deleted file mode 100644 index da7b4816b..000000000 --- a/beecrypt/c++/security/cert/.cvsignore +++ /dev/null @@ -1,5 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo diff --git a/beecrypt/c++/security/cert/Certificate.cxx b/beecrypt/c++/security/cert/Certificate.cxx deleted file mode 100644 index aa58a988a..000000000 --- a/beecrypt/c++/security/cert/Certificate.cxx +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/cert/Certificate.h" - -using namespace beecrypt::security::cert; - -Certificate::Certificate(const String& type) -{ - _type = type; -} - -Certificate::~Certificate() -{ -} - -bool Certificate::operator==(const Certificate& cmp) const -{ - if (this == &cmp) - return true; - - if (_type != cmp._type) - return false; - - if (getEncoded() != cmp.getEncoded()) - return false; - - return true; -} - -const String& Certificate::getType() const throw () -{ - return _type; -} diff --git a/beecrypt/c++/security/cert/Certificate.h b/beecrypt/c++/security/cert/Certificate.h deleted file mode 100644 index 091165286..000000000 --- a/beecrypt/c++/security/cert/Certificate.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file Certificate.h - * \ingroup CXX_SECURITY_CERT_m - */ - -#ifndef _CLASS_CERTIFICATE_H -#define _CLASS_CERTIFICATE_H - -#ifdef __cplusplus - -#include "beecrypt/c++/array.h" -using beecrypt::array; -#include "beecrypt/c++/security/PublicKey.h" -using beecrypt::security::PublicKey; -#include "beecrypt/c++/security/InvalidKeyException.h" -using beecrypt::security::InvalidKeyException; -#include "beecrypt/c++/security/NoSuchAlgorithmException.h" -using beecrypt::security::NoSuchAlgorithmException; -#include "beecrypt/c++/security/NoSuchProviderException.h" -using beecrypt::security::NoSuchProviderException; -#include "beecrypt/c++/security/SignatureException.h" -using beecrypt::security::SignatureException; -#include "beecrypt/c++/security/cert/CertificateException.h" -using beecrypt::security::cert::CertificateException; - -namespace beecrypt { - namespace security { - namespace cert { - class BEECRYPTCXXAPI Certificate - { - private: - String _type; - - protected: - Certificate(const String& type); - - public: - virtual ~Certificate(); - - virtual bool operator==(const Certificate&) const; - - virtual Certificate* clone() const = 0; - - virtual const bytearray& getEncoded() const = 0; - virtual const PublicKey& getPublicKey() const = 0; - - virtual void verify(const PublicKey&) throw (CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException) = 0; - virtual void verify(const PublicKey&, const String&) throw (CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException) = 0; - - virtual const String& toString() const throw () = 0; - - const String& getType() const throw (); - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/cert/CertificateException.cxx b/beecrypt/c++/security/cert/CertificateException.cxx deleted file mode 100644 index 9b0f99484..000000000 --- a/beecrypt/c++/security/cert/CertificateException.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/cert/CertificateException.h" - -using namespace beecrypt::security::cert; - -CertificateException::CertificateException() throw () -{ -} - -CertificateException::CertificateException(const String& message) throw () : GeneralSecurityException(message) -{ -} diff --git a/beecrypt/c++/security/cert/CertificateException.h b/beecrypt/c++/security/cert/CertificateException.h deleted file mode 100644 index db0185a08..000000000 --- a/beecrypt/c++/security/cert/CertificateException.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file CertificateException.h - * \ingroup CXX_SECURITY_CERT_m - */ - -#ifndef _CLASS_CERTIFICATEEXCEPTION_H -#define _CLASS_CERTIFICATEEXCEPTION_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/GeneralSecurityException.h" -using beecrypt::security::GeneralSecurityException; - -namespace beecrypt { - namespace security { - namespace cert { - class BEECRYPTCXXAPI CertificateException : public GeneralSecurityException - { - public: - CertificateException() throw (); - CertificateException(const String&) throw (); - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/cert/CertificateExpiredException.cxx b/beecrypt/c++/security/cert/CertificateExpiredException.cxx deleted file mode 100644 index 7adf29a32..000000000 --- a/beecrypt/c++/security/cert/CertificateExpiredException.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/cert/CertificateExpiredException.h" - -using namespace beecrypt::security::cert; - -CertificateExpiredException::CertificateExpiredException() throw () -{ -} - -CertificateExpiredException::CertificateExpiredException(const String& message) throw () : CertificateException(message) -{ -} diff --git a/beecrypt/c++/security/cert/CertificateExpiredException.h b/beecrypt/c++/security/cert/CertificateExpiredException.h deleted file mode 100644 index 9ab9be6ba..000000000 --- a/beecrypt/c++/security/cert/CertificateExpiredException.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file CertificateExpiredException.h - * \ingroup CXX_SECURITY_CERT_m - */ - -#ifndef _CLASS_CERTIFICATEEXPIREDEXCEPTION_H -#define _CLASS_CERTIFICATEEXPIREDEXCEPTION_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/cert/CertificateException.h" -using beecrypt::security::cert::CertificateException; - -namespace beecrypt { - namespace security { - namespace cert { - class BEECRYPTCXXAPI CertificateExpiredException : public CertificateException - { - public: - CertificateExpiredException() throw (); - CertificateExpiredException(const String&) throw (); - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/cert/CertificateFactory.cxx b/beecrypt/c++/security/cert/CertificateFactory.cxx deleted file mode 100644 index 84d91da4a..000000000 --- a/beecrypt/c++/security/cert/CertificateFactory.cxx +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/Security.h" -#include "beecrypt/c++/security/cert/CertificateFactory.h" - -using namespace beecrypt::security::cert; - -CertificateFactory::CertificateFactory(CertificateFactorySpi* spi, const String& type, const Provider& provider) -{ - _cspi = spi; - _type = type; - _prov = &provider; -} - -CertificateFactory::~CertificateFactory() -{ - delete _cspi; -} - -CertificateFactory* CertificateFactory::getInstance(const String& type) throw (NoSuchAlgorithmException) -{ - Security::spi* tmp = Security::getSpi(type, "CertificateFactory"); - - CertificateFactory* result = new CertificateFactory((CertificateFactorySpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; -} - -CertificateFactory* CertificateFactory::getInstance(const String& type, const String& provider) throw (NoSuchAlgorithmException, NoSuchProviderException) -{ - Security::spi* tmp = Security::getSpi(type, "CertificateFactory", provider); - - CertificateFactory* result = new CertificateFactory((CertificateFactorySpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; -} - -CertificateFactory* CertificateFactory::getInstance(const String& type, const Provider& provider) throw (NoSuchAlgorithmException) -{ - Security::spi* tmp = Security::getSpi(type, "CertificateFactory", provider); - - CertificateFactory* result = new CertificateFactory((CertificateFactorySpi*) tmp->cspi, tmp->name, tmp->prov); - - delete tmp; - - return result; -} - -Certificate* CertificateFactory::generateCertificate(InputStream& in) throw (CertificateException) -{ - return _cspi->engineGenerateCertificate(in); -} - -vector<Certificate*>* CertificateFactory::generateCertificates(InputStream& in) throw (CertificateException) -{ - return _cspi->engineGenerateCertificates(in); -} - -const String& CertificateFactory::getType() const throw () -{ - return _type; -} - -const Provider& CertificateFactory::getProvider() const throw () -{ - return *_prov; -} diff --git a/beecrypt/c++/security/cert/CertificateFactory.h b/beecrypt/c++/security/cert/CertificateFactory.h deleted file mode 100644 index 09b43b7a5..000000000 --- a/beecrypt/c++/security/cert/CertificateFactory.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file CertificateFactory.h - * \ingroup CXX_SECURITY_CERT_m - */ - -#ifndef _CLASS_CERTIFICATEFACTORY_H -#define _CLASS_CERTIFICATEFACTORY_H - -#ifdef __cplusplus - -#include "beecrypt/c++/lang/String.h" -using beecrypt::lang::String; -#include "beecrypt/c++/security/Provider.h" -using beecrypt::security::Provider; -#include "beecrypt/c++/security/NoSuchAlgorithmException.h" -using beecrypt::security::NoSuchAlgorithmException; -#include "beecrypt/c++/security/cert/Certificate.h" -using beecrypt::security::cert::Certificate; -#include "beecrypt/c++/security/cert/CertificateFactorySpi.h" -using beecrypt::security::cert::CertificateFactorySpi; - -#include <vector> -using std::vector; - -namespace beecrypt { - namespace security { - namespace cert { - class BEECRYPTCXXAPI CertificateFactory - { - public: - static CertificateFactory* getInstance(const String&) throw (NoSuchAlgorithmException); - static CertificateFactory* getInstance(const String&, const String&) throw (NoSuchAlgorithmException, NoSuchProviderException); - static CertificateFactory* getInstance(const String&, const Provider&) throw (NoSuchAlgorithmException); - - private: - CertificateFactorySpi* _cspi; - String _type; - const Provider* _prov; - - protected: - CertificateFactory(CertificateFactorySpi*, const String&, const Provider&); - - public: - ~CertificateFactory(); - - Certificate* generateCertificate(InputStream& in) throw (CertificateException); - vector<Certificate*>* generateCertificates(InputStream& in) throw (CertificateException); - - const String& getType() const throw (); - const Provider& getProvider() const throw (); - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/cert/CertificateFactorySpi.h b/beecrypt/c++/security/cert/CertificateFactorySpi.h deleted file mode 100644 index b42fdcf9c..000000000 --- a/beecrypt/c++/security/cert/CertificateFactorySpi.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file CertificateFactorySpi.h - * \ingroup CXX_SECURITY_CERT_m - */ - -#ifndef _CLASS_CERTIFICATEFACTORYSPI_H -#define _CLASS_CERTIFICATEFACTORYSPI_H - -#include "beecrypt/api.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/io/InputStream.h" -using beecrypt::io::InputStream; -#include "beecrypt/c++/io/OutputStream.h" -using beecrypt::io::OutputStream; -#include "beecrypt/c++/security/cert/Certificate.h" -using beecrypt::security::cert::Certificate; - -#include <vector> -using std::vector; - -namespace beecrypt { - namespace security { - namespace cert { - class BEECRYPTCXXAPI CertificateFactorySpi - { - friend class CertificateFactory; - - protected: - virtual Certificate* engineGenerateCertificate(InputStream& in) throw (CertificateException) = 0; - virtual vector<Certificate*>* engineGenerateCertificates(InputStream& in) throw (CertificateException) = 0; - - public: - virtual ~CertificateFactorySpi() {}; - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/cert/CertificateNotYetValidException.cxx b/beecrypt/c++/security/cert/CertificateNotYetValidException.cxx deleted file mode 100644 index 6bcdc8ddc..000000000 --- a/beecrypt/c++/security/cert/CertificateNotYetValidException.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/cert/CertificateNotYetValidException.h" - -using namespace beecrypt::security::cert; - -CertificateNotYetValidException::CertificateNotYetValidException() throw () -{ -} - -CertificateNotYetValidException::CertificateNotYetValidException(const String& message) throw () : CertificateException(message) -{ -} diff --git a/beecrypt/c++/security/cert/CertificateNotYetValidException.h b/beecrypt/c++/security/cert/CertificateNotYetValidException.h deleted file mode 100644 index b9524f113..000000000 --- a/beecrypt/c++/security/cert/CertificateNotYetValidException.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file CertificateNotYetValidException.h - * \ingroup CXX_SECURITY_CERT_m - */ - -#ifndef _CLASS_CERTIFICATENOTYETVALIDEXCEPTION_H -#define _CLASS_CERTIFICATENOTYETVALIDEXCEPTION_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/cert/CertificateException.h" -using beecrypt::security::cert::CertificateException; - -namespace beecrypt { - namespace security { - namespace cert { - class BEECRYPTCXXAPI CertificateNotYetValidException : public CertificateException - { - public: - CertificateNotYetValidException() throw (); - CertificateNotYetValidException(const String&) throw (); - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/cert/Makefile.am b/beecrypt/c++/security/cert/Makefile.am deleted file mode 100644 index 7fa6b2ef7..000000000 --- a/beecrypt/c++/security/cert/Makefile.am +++ /dev/null @@ -1,22 +0,0 @@ -INCLUDES = -I$(top_srcdir)/.. - -AUTOMAKE_OPTIONS = gnu no-dependencies - -noinst_LTLIBRARIES = libcxxsecuritycert.la - -cxxsecuritycertdir=$(pkgincludedir)/c++/security/cert - -libcxxsecuritycert_la_SOURCES =\ -Certificate.cxx \ -CertificateException.cxx \ -CertificateExpiredException.cxx \ -CertificateFactory.cxx \ -CertificateNotYetValidException.cxx - -cxxsecuritycert_HEADERS =\ -Certificate.h \ -CertificateException.h \ -CertificateExpiredException.h \ -CertificateFactory.h \ -CertificateFactorySpi.h \ -CertificateNotYetValidException.h diff --git a/beecrypt/c++/security/interfaces/.cvsignore b/beecrypt/c++/security/interfaces/.cvsignore deleted file mode 100644 index da7b4816b..000000000 --- a/beecrypt/c++/security/interfaces/.cvsignore +++ /dev/null @@ -1,5 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo diff --git a/beecrypt/c++/security/interfaces/DSAKey.h b/beecrypt/c++/security/interfaces/DSAKey.h deleted file mode 100644 index edf865a0d..000000000 --- a/beecrypt/c++/security/interfaces/DSAKey.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DSAKey.h - * \ingroup CXX_SECURITY_INTERFACES_m - */ - -#ifndef _INTERFACE_DSAKEY_H -#define _INTERFACE_DSAKEY_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/interfaces/DSAParams.h" -using beecrypt::security::interfaces::DSAParams; - -namespace beecrypt { - namespace security { - namespace interfaces { - /*!\brief DSA key interface. - * \ingroup CXX_IF_m - */ - class DSAKey - { - public: - virtual const DSAParams& getParams() const throw () = 0; - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/interfaces/DSAParams.h b/beecrypt/c++/security/interfaces/DSAParams.h deleted file mode 100644 index d066c18cf..000000000 --- a/beecrypt/c++/security/interfaces/DSAParams.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DSAParams.h - * \ingroup CXX_SECURITY_INTERFACES_m - */ - -#ifndef _INTERFACE_DSAPARAMS_H -#define _INTERFACE_DSAPARAMS_H - -#include "beecrypt/api.h" -#include "beecrypt/mpbarrett.h" - -#ifdef __cplusplus - -namespace beecrypt { - namespace security { - namespace interfaces { - class DSAParams - { - public: - virtual const mpbarrett& getP() const throw () = 0; - virtual const mpbarrett& getQ() const throw () = 0; - virtual const mpnumber& getG() const throw () = 0; - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/interfaces/DSAPrivateKey.h b/beecrypt/c++/security/interfaces/DSAPrivateKey.h deleted file mode 100644 index 1bad935f3..000000000 --- a/beecrypt/c++/security/interfaces/DSAPrivateKey.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DSAPrivateKey.h - * \ingroup CXX_SECURITY_INTERFACES_m - */ - -#ifndef _INTERFACE_DSAPRIVATEKEY_H -#define _INTERFACE_DSAPRIVATEKEY_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/PrivateKey.h" -using beecrypt::security::PrivateKey; -#include "beecrypt/c++/security/interfaces/DSAKey.h" -using beecrypt::security::interfaces::DSAKey; - -namespace beecrypt { - namespace security { - namespace interfaces { - /*!\brief DSA PriveKey interface - * \ingroup CXX_IF_m - */ - class DSAPrivateKey : public PrivateKey, public DSAKey - { - public: - virtual const mpnumber& getX() const throw () = 0; - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/interfaces/DSAPublicKey.h b/beecrypt/c++/security/interfaces/DSAPublicKey.h deleted file mode 100644 index f596c9e0e..000000000 --- a/beecrypt/c++/security/interfaces/DSAPublicKey.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DSAPublicKey.h - * \ingroup CXX_SECURITY_INTERFACES_m - */ - -#ifndef _INTERFACE_DSAPUBLICKEY_H -#define _INTERFACE_DSAPUBLICKEY_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/PublicKey.h" -using beecrypt::security::PublicKey; -#include "beecrypt/c++/security/interfaces/DSAKey.h" -using beecrypt::security::interfaces::DSAKey; - -namespace beecrypt { - namespace security { - namespace interfaces { - /*!\brief DSA PublicKey interface - * \ingroup CXX_IF_m - */ - class DSAPublicKey : public PublicKey, public DSAKey - { - public: - virtual const mpnumber& getY() const throw () = 0; - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/interfaces/Makefile.am b/beecrypt/c++/security/interfaces/Makefile.am deleted file mode 100644 index f7f4d16bd..000000000 --- a/beecrypt/c++/security/interfaces/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -INCLUDES = -I$(top_srcdir)/.. - -AUTOMAKE_OPTIONS = gnu no-dependencies - -cxxsecurityinterfacesdir=$(pkgincludedir)/c++/security/interfaces - -cxxsecurityinterfaces_HEADERS =\ -DSAKey.h \ -DSAParams.h \ -DSAPrivateKey.h \ -DSAPublicKey.h \ -RSAKey.h \ -RSAPrivateCrtKey.h \ -RSAPrivateKey.h \ -RSAPublicKey.h diff --git a/beecrypt/c++/security/interfaces/RSAKey.h b/beecrypt/c++/security/interfaces/RSAKey.h deleted file mode 100644 index b622ae759..000000000 --- a/beecrypt/c++/security/interfaces/RSAKey.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file RSAKey.h - * \ingroup CXX_SECURITY_INTERFACES_m - */ - -#ifndef _INTERFACE_RSAKEY_H -#define _INTERFACE_RSAKEY_H - -#include "beecrypt/api.h" -#include "beecrypt/mpbarrett.h" - -#ifdef __cplusplus - -namespace beecrypt { - namespace security { - namespace interfaces { - /*!\brief RSA key interface. - * \ingroup CXX_IF_m - */ - class RSAKey - { - public: - virtual const mpbarrett& getModulus() const throw () = 0; - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/interfaces/RSAPrivateCrtKey.h b/beecrypt/c++/security/interfaces/RSAPrivateCrtKey.h deleted file mode 100644 index aa243b98f..000000000 --- a/beecrypt/c++/security/interfaces/RSAPrivateCrtKey.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file RSAPrivateCrtKey.h - * \ingroup CXX_SECURITY_INTERFACES_m - */ - -#ifndef _INTERFACE_RSAPRIVATECRTKEY_H -#define _INTERFACE_RSAPRIVATECRTKEY_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/interfaces/RSAPrivateKey.h" -using beecrypt::security::interfaces::RSAPrivateKey; - -namespace beecrypt { - namespace security { - namespace interfaces { - /*!\brief The interface to an RSA private key, as defined in the PKCS#1 standard, using the Chinese Remainder Theorem (CRT) information values. - * \ingroup CXX_IF_m - */ - class RSAPrivateCrtKey : public RSAPrivateKey - { - public: - virtual const mpnumber& getPublicExponent() const throw () = 0; - virtual const mpbarrett& getPrimeP() const throw () = 0; - virtual const mpbarrett& getPrimeQ() const throw () = 0; - virtual const mpnumber& getPrimeExponentP() const throw () = 0; - virtual const mpnumber& getPrimeExponentQ() const throw () = 0; - virtual const mpnumber& getCrtCoefficient() const throw () = 0; - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/interfaces/RSAPrivateKey.h b/beecrypt/c++/security/interfaces/RSAPrivateKey.h deleted file mode 100644 index 5fc8c47b5..000000000 --- a/beecrypt/c++/security/interfaces/RSAPrivateKey.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file RSAPrivateKey.h - * \ingroup CXX_SECURITY_INTERFACES_m - */ - -#ifndef _INTERFACE_RSAPRIVATEKEY_H -#define _INTERFACE_RSAPRIVATEKEY_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/PrivateKey.h" -using beecrypt::security::PrivateKey; -#include "beecrypt/c++/security/interfaces/RSAKey.h" -using beecrypt::security::interfaces::RSAKey; - -namespace beecrypt { - namespace security { - namespace interfaces { - /*!\ingroup CXX_IF_m - */ - class RSAPrivateKey : public PrivateKey, public RSAKey - { - public: - virtual const mpnumber& getPrivateExponent() const throw () = 0; - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/interfaces/RSAPublicKey.h b/beecrypt/c++/security/interfaces/RSAPublicKey.h deleted file mode 100644 index 93f9da1c3..000000000 --- a/beecrypt/c++/security/interfaces/RSAPublicKey.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file RSAPublicKey.h - * \ingroup CXX_SECURITY_INTERFACES_m - */ - -#ifndef _INTERFACE_RSAPUBLICKEY_H -#define _INTERFACE_RSAPUBLICKEY_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/PublicKey.h" -using beecrypt::security::PublicKey; -#include "beecrypt/c++/security/interfaces/RSAKey.h" -using beecrypt::security::interfaces::RSAKey; - -namespace beecrypt { - namespace security { - namespace interfaces { - /*!\ingroup CXX_IF_m - */ - class RSAPublicKey : public PublicKey, public RSAKey - { - public: - virtual const mpnumber& getPublicExponent() const throw () = 0; - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/spec/.cvsignore b/beecrypt/c++/security/spec/.cvsignore deleted file mode 100644 index da7b4816b..000000000 --- a/beecrypt/c++/security/spec/.cvsignore +++ /dev/null @@ -1,5 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo diff --git a/beecrypt/c++/security/spec/AlgorithmParameterSpec.h b/beecrypt/c++/security/spec/AlgorithmParameterSpec.h deleted file mode 100644 index 0010d0dff..000000000 --- a/beecrypt/c++/security/spec/AlgorithmParameterSpec.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file AlgorithmParameterSpec.h - * \ingroup CXX_SECURITY_SPEC_m - */ - -#ifndef _CLASS_ALGORITHMPARAMETERSPEC_H -#define _CLASS_ALGORITHMPARAMETERSPEC_H - -#include "beecrypt/api.h" - -#ifdef __cplusplus - -namespace beecrypt { - namespace security { - namespace spec { - /*!\brief The base class for specification of cryptographic parameters. - */ - class BEECRYPTCXXAPI AlgorithmParameterSpec - { - public: - virtual ~AlgorithmParameterSpec() {}; - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/spec/DSAParameterSpec.cxx b/beecrypt/c++/security/spec/DSAParameterSpec.cxx deleted file mode 100644 index cc9e85522..000000000 --- a/beecrypt/c++/security/spec/DSAParameterSpec.cxx +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/spec/DSAParameterSpec.h" - -using namespace beecrypt::security::spec; - -DSAParameterSpec::DSAParameterSpec(const DSAParams& copy) -{ - _p = copy.getP(); - _q = copy.getQ(); - _g = copy.getG(); -} - -DSAParameterSpec::DSAParameterSpec(const mpbarrett& p, const mpbarrett& q, const mpnumber& g) -{ - _p = p; - _q = q; - _g = g; -} - -DSAParameterSpec::~DSAParameterSpec() -{ -} - -const mpbarrett& DSAParameterSpec::getP() const throw () -{ - return _p; -} - -const mpbarrett& DSAParameterSpec::getQ() const throw () -{ - return _q; -} - -const mpnumber& DSAParameterSpec::getG() const throw () -{ - return _g; -} diff --git a/beecrypt/c++/security/spec/DSAParameterSpec.h b/beecrypt/c++/security/spec/DSAParameterSpec.h deleted file mode 100644 index cb71123d1..000000000 --- a/beecrypt/c++/security/spec/DSAParameterSpec.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DSAParameterSpec.h - * \ingroup CXX_SECURITY_SPEC_m - */ - -#ifndef _CLASS_DSAPARAMETERSPEC_H -#define _CLASS_DSAPARAMETERSPEC_H - -#include "beecrypt/api.h" -#include "beecrypt/mpbarrett.h" -#include "beecrypt/dsa.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/security/interfaces/DSAParams.h" -using beecrypt::security::interfaces::DSAParams; -#include "beecrypt/c++/security/spec/AlgorithmParameterSpec.h" -using beecrypt::security::spec::AlgorithmParameterSpec; - -namespace beecrypt { - namespace security { - namespace spec { - class BEECRYPTCXXAPI DSAParameterSpec : public AlgorithmParameterSpec, public DSAParams - { - private: - mpbarrett _p; - mpbarrett _q; - mpnumber _g; - - public: - DSAParameterSpec(const DSAParams&); - DSAParameterSpec(const mpbarrett& p, const mpbarrett& q, const mpnumber& g); - virtual ~DSAParameterSpec(); - - const mpbarrett& getP() const throw (); - const mpbarrett& getQ() const throw (); - const mpnumber& getG() const throw (); - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/spec/DSAPrivateKeySpec.cxx b/beecrypt/c++/security/spec/DSAPrivateKeySpec.cxx deleted file mode 100644 index dece65bc5..000000000 --- a/beecrypt/c++/security/spec/DSAPrivateKeySpec.cxx +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/spec/DSAPrivateKeySpec.h" - -using namespace beecrypt::security::spec; - -DSAPrivateKeySpec::DSAPrivateKeySpec(const mpbarrett& p, const mpbarrett& q, const mpnumber& g, const mpnumber& x) -{ - _p = p; - _q = q; - _g = g; - _x = x; -} - -DSAPrivateKeySpec::~DSAPrivateKeySpec() -{ - _x.wipe(); -} - -const mpbarrett& DSAPrivateKeySpec::getP() const throw () -{ - return _p; -} - -const mpbarrett& DSAPrivateKeySpec::getQ() const throw () -{ - return _q; -} - -const mpnumber& DSAPrivateKeySpec::getG() const throw () -{ - return _g; -} - -const mpnumber& DSAPrivateKeySpec::getX() const throw () -{ - return _x; -} diff --git a/beecrypt/c++/security/spec/DSAPrivateKeySpec.h b/beecrypt/c++/security/spec/DSAPrivateKeySpec.h deleted file mode 100644 index 057981aad..000000000 --- a/beecrypt/c++/security/spec/DSAPrivateKeySpec.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DSAPrivateKeySpec.h - * \ingroup CXX_SECURITY_SPEC_m - */ - -#ifndef _CLASS_DSAPRIVATEKEYSPEC_H -#define _CLASS_DSAPRIVATEKEYSPEC_H - -#include "beecrypt/api.h" -#include "beecrypt/mpbarrett.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/security/spec/KeySpec.h" -using beecrypt::security::spec::KeySpec; - -namespace beecrypt { - namespace security { - namespace spec { - class BEECRYPTCXXAPI DSAPrivateKeySpec : public KeySpec - { - private: - mpbarrett _p; - mpbarrett _q; - mpnumber _g; - mpnumber _x; - - public: - DSAPrivateKeySpec(const mpbarrett& p, const mpbarrett& q, const mpnumber& g, const mpnumber& x); - virtual ~DSAPrivateKeySpec(); - - const mpbarrett& getP() const throw (); - const mpbarrett& getQ() const throw (); - const mpnumber& getG() const throw (); - const mpnumber& getX() const throw (); - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/spec/DSAPublicKeySpec.cxx b/beecrypt/c++/security/spec/DSAPublicKeySpec.cxx deleted file mode 100644 index 7be7a58b9..000000000 --- a/beecrypt/c++/security/spec/DSAPublicKeySpec.cxx +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/spec/DSAPublicKeySpec.h" - -using namespace beecrypt::security::spec; - -DSAPublicKeySpec::DSAPublicKeySpec(const mpbarrett& p, const mpbarrett& q, const mpnumber& g, const mpnumber& y) -{ - _p = p; - _q = q; - _g = g; - _y = y; -} - -DSAPublicKeySpec::~DSAPublicKeySpec() -{ -} - -const mpbarrett& DSAPublicKeySpec::getP() const throw () -{ - return _p; -} - -const mpbarrett& DSAPublicKeySpec::getQ() const throw () -{ - return _q; -} - -const mpnumber& DSAPublicKeySpec::getG() const throw () -{ - return _g; -} - -const mpnumber& DSAPublicKeySpec::getY() const throw () -{ - return _y; -} diff --git a/beecrypt/c++/security/spec/DSAPublicKeySpec.h b/beecrypt/c++/security/spec/DSAPublicKeySpec.h deleted file mode 100644 index 3220f31a5..000000000 --- a/beecrypt/c++/security/spec/DSAPublicKeySpec.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file DSAPublicKeySpec.h - * \ingroup CXX_SECURITY_SPEC_m - */ - -#ifndef _CLASS_DSAPUBLICKEYSPEC_H -#define _CLASS_DSAPUBLICKEYSPEC_H - -#include "beecrypt/api.h" -#include "beecrypt/mpbarrett.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/security/spec/KeySpec.h" -using beecrypt::security::spec::KeySpec; - -namespace beecrypt { - namespace security { - namespace spec { - class BEECRYPTCXXAPI DSAPublicKeySpec : public KeySpec - { - private: - mpbarrett _p; - mpbarrett _q; - mpnumber _g; - mpnumber _y; - - public: - DSAPublicKeySpec(const mpbarrett& p, const mpbarrett& q, const mpnumber& g, const mpnumber& y); - virtual ~DSAPublicKeySpec(); - - const mpbarrett& getP() const throw (); - const mpbarrett& getQ() const throw (); - const mpnumber& getG() const throw (); - const mpnumber& getY() const throw (); - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/spec/EncodedKeySpec.cxx b/beecrypt/c++/security/spec/EncodedKeySpec.cxx deleted file mode 100644 index c6b05c322..000000000 --- a/beecrypt/c++/security/spec/EncodedKeySpec.cxx +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/spec/EncodedKeySpec.h" - -using namespace beecrypt::security::spec; - -EncodedKeySpec::EncodedKeySpec(const byte* data, size_t size) : _encoded(data, size) -{ -} - -EncodedKeySpec::EncodedKeySpec(const bytearray& copy) : _encoded(copy) -{ -} - -EncodedKeySpec::~EncodedKeySpec() -{ -} - -const bytearray& EncodedKeySpec::getEncoded() const throw () -{ - return _encoded; -} diff --git a/beecrypt/c++/security/spec/EncodedKeySpec.h b/beecrypt/c++/security/spec/EncodedKeySpec.h deleted file mode 100644 index 5af27f0f3..000000000 --- a/beecrypt/c++/security/spec/EncodedKeySpec.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file EncodedKeySpec.h - * \ingroup CXX_SECURITY_SPEC_m - */ - -#ifndef _CLASS_ENCODEDKEYSPEC_H -#define _CLASS_ENCODEDKEYSPEC_H - -#ifdef __cplusplus - -#include "beecrypt/c++/array.h" -using beecrypt::bytearray; -#include "beecrypt/c++/lang/String.h" -using beecrypt::lang::String; -#include "beecrypt/c++/security/spec/KeySpec.h" -using beecrypt::security::spec::KeySpec; - -namespace beecrypt { - namespace security { - namespace spec { - class BEECRYPTCXXAPI EncodedKeySpec : public KeySpec - { - private: - bytearray _encoded; - - public: - EncodedKeySpec(const byte*, size_t); - EncodedKeySpec(const bytearray&); - virtual ~EncodedKeySpec(); - - const bytearray& getEncoded() const throw (); - virtual const String& getFormat() const throw () = 0; - - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/spec/InvalidKeySpecException.cxx b/beecrypt/c++/security/spec/InvalidKeySpecException.cxx deleted file mode 100644 index d9ffc6d5d..000000000 --- a/beecrypt/c++/security/spec/InvalidKeySpecException.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/spec/InvalidKeySpecException.h" - -using namespace beecrypt::security::spec; - -InvalidKeySpecException::InvalidKeySpecException() throw () -{ -} - -InvalidKeySpecException::InvalidKeySpecException(const String& message) throw () : GeneralSecurityException(message) -{ -} diff --git a/beecrypt/c++/security/spec/InvalidKeySpecException.h b/beecrypt/c++/security/spec/InvalidKeySpecException.h deleted file mode 100644 index 4ecf20205..000000000 --- a/beecrypt/c++/security/spec/InvalidKeySpecException.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file InvalidKeySpecException.h - * \ingroup CXX_SECURITY_SPEC_m - */ - -#ifndef _CLASS_INVALIDKEYSPECEXCEPTION_H -#define _CLASS_INVALIDKEYSPECEXCEPTION_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/GeneralSecurityException.h" -using beecrypt::security::GeneralSecurityException; - -namespace beecrypt { - namespace security { - namespace spec { - class BEECRYPTCXXAPI InvalidKeySpecException : public GeneralSecurityException - { - public: - InvalidKeySpecException() throw (); - InvalidKeySpecException(const String&) throw (); - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/spec/InvalidParameterSpecException.cxx b/beecrypt/c++/security/spec/InvalidParameterSpecException.cxx deleted file mode 100644 index a987648ef..000000000 --- a/beecrypt/c++/security/spec/InvalidParameterSpecException.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/spec/InvalidParameterSpecException.h" - -using namespace beecrypt::security::spec; - -InvalidParameterSpecException::InvalidParameterSpecException() throw () -{ -} - -InvalidParameterSpecException::InvalidParameterSpecException(const String& message) throw () : GeneralSecurityException(message) -{ -} diff --git a/beecrypt/c++/security/spec/InvalidParameterSpecException.h b/beecrypt/c++/security/spec/InvalidParameterSpecException.h deleted file mode 100644 index a7e69dcf1..000000000 --- a/beecrypt/c++/security/spec/InvalidParameterSpecException.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file InvalidParameterSpecException.h - * \ingroup CXX_SECURITY_SPEC_m - */ - -#ifndef _CLASS_INVALIDPARAMETERSPECEXCEPTION_H -#define _CLASS_INVALIDPARAMETERSPECEXCEPTION_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/GeneralSecurityException.h" -using beecrypt::security::GeneralSecurityException; - -namespace beecrypt { - namespace security { - namespace spec { - class BEECRYPTCXXAPI InvalidParameterSpecException : public GeneralSecurityException - { - public: - InvalidParameterSpecException() throw (); - InvalidParameterSpecException(const String&) throw (); - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/spec/KeySpec.h b/beecrypt/c++/security/spec/KeySpec.h deleted file mode 100644 index eb102a198..000000000 --- a/beecrypt/c++/security/spec/KeySpec.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file KeySpec.h - * \ingroup CXX_SECURITY_SPEC_m - */ - -#ifndef _CLASS_KEYSPEC_H -#define _CLASS_KEYSPEC_H - -#include "beecrypt/api.h" - -#ifdef __cplusplus - -namespace beecrypt { - namespace security { - namespace spec { - /*!\brief The base class for specification of cryptographic keys. - */ - class BEECRYPTCXXAPI KeySpec - { - public: - virtual ~KeySpec() {} - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/spec/Makefile.am b/beecrypt/c++/security/spec/Makefile.am deleted file mode 100644 index 8d6cba665..000000000 --- a/beecrypt/c++/security/spec/Makefile.am +++ /dev/null @@ -1,33 +0,0 @@ -INCLUDES = -I$(top_srcdir)/.. - -AUTOMAKE_OPTIONS = gnu no-dependencies - -noinst_LTLIBRARIES = libcxxsecurityspec.la - -cxxsecurityspecdir=$(pkgincludedir)/c++/security/spec - -libcxxsecurityspec_la_SOURCES =\ -DSAParameterSpec.cxx \ -DSAPrivateKeySpec.cxx \ -DSAPublicKeySpec.cxx \ -EncodedKeySpec.cxx \ -InvalidKeySpecException.cxx \ -InvalidParameterSpecException.cxx \ -RSAKeyGenParameterSpec.cxx \ -RSAPrivateCrtKeySpec.cxx \ -RSAPrivateKeySpec.cxx \ -RSAPublicKeySpec.cxx - -cxxsecurityspec_HEADERS =\ -AlgorithmParameterSpec.h \ -DSAParameterSpec.h \ -DSAPrivateKeySpec.h \ -DSAPublicKeySpec.h \ -EncodedKeySpec.h \ -InvalidKeySpecException.h \ -InvalidParameterSpecException.h \ -KeySpec.h \ -RSAKeyGenParameterSpec.h \ -RSAPrivateCrtKeySpec.h \ -RSAPrivateKeySpec.h \ -RSAPublicKeySpec.h diff --git a/beecrypt/c++/security/spec/RSAKeyGenParameterSpec.cxx b/beecrypt/c++/security/spec/RSAKeyGenParameterSpec.cxx deleted file mode 100644 index 17cec6b0a..000000000 --- a/beecrypt/c++/security/spec/RSAKeyGenParameterSpec.cxx +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/spec/RSAKeyGenParameterSpec.h" - -using namespace beecrypt::security::spec; - -const mpnumber RSAKeyGenParameterSpec::F0(3); -const mpnumber RSAKeyGenParameterSpec::F4(65537); - -RSAKeyGenParameterSpec::RSAKeyGenParameterSpec(size_t keysize, const mpnumber& publicExponent) -{ - _keysize = keysize; - _e = publicExponent; -} - -RSAKeyGenParameterSpec::~RSAKeyGenParameterSpec() -{ -} - -size_t RSAKeyGenParameterSpec::getKeysize() const throw () -{ - return _keysize; -} - -const mpnumber& RSAKeyGenParameterSpec::getPublicExponent() const throw () -{ - return _e; -} diff --git a/beecrypt/c++/security/spec/RSAKeyGenParameterSpec.h b/beecrypt/c++/security/spec/RSAKeyGenParameterSpec.h deleted file mode 100644 index dd4f9a080..000000000 --- a/beecrypt/c++/security/spec/RSAKeyGenParameterSpec.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file RSAKeyGenParameterSpec.h - * \ingroup CXX_SECURITY_SPEC_m - */ - -#ifndef _CLASS_RSAKEYGENPARAMETERSPEC -#define _CLASS_RSAKEYGENPARAMETERSPEC - -#include "beecrypt/beecrypt.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/security/spec/AlgorithmParameterSpec.h" -using beecrypt::security::spec::AlgorithmParameterSpec; - -namespace beecrypt { - namespace security { - namespace spec { - class BEECRYPTCXXAPI RSAKeyGenParameterSpec : public AlgorithmParameterSpec - { - public: - static const mpnumber F0; - static const mpnumber F4; - - private: - size_t _keysize; - mpnumber _e; - - public: - RSAKeyGenParameterSpec(size_t, const mpnumber&); - virtual ~RSAKeyGenParameterSpec(); - - size_t getKeysize() const throw (); - const mpnumber& getPublicExponent() const throw (); - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/spec/RSAPrivateCrtKeySpec.cxx b/beecrypt/c++/security/spec/RSAPrivateCrtKeySpec.cxx deleted file mode 100644 index 7caeb5644..000000000 --- a/beecrypt/c++/security/spec/RSAPrivateCrtKeySpec.cxx +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/spec/RSAPrivateCrtKeySpec.h" - -using namespace beecrypt::security::spec; - -RSAPrivateCrtKeySpec::RSAPrivateCrtKeySpec(const mpbarrett& modulus, const mpnumber& publicExponent, const mpnumber& privateExponent, const mpbarrett& primeP, const mpbarrett& primeQ, const mpnumber& primeExponentP, const mpnumber& primeExponentQ, const mpnumber& crtCoefficient) : RSAPrivateKeySpec(modulus, privateExponent) -{ - _e = publicExponent; - _p = primeP; - _q = primeQ; - _dp = primeExponentP; - _dq = primeExponentQ; - _qi = crtCoefficient; -} - -RSAPrivateCrtKeySpec::~RSAPrivateCrtKeySpec() -{ -} - -const mpnumber& RSAPrivateCrtKeySpec::getPublicExponent() const throw () -{ - return _e; -} - -const mpbarrett& RSAPrivateCrtKeySpec::getPrimeP() const throw () -{ - return _p; -} - -const mpbarrett& RSAPrivateCrtKeySpec::getPrimeQ() const throw () -{ - return _q; -} - -const mpnumber& RSAPrivateCrtKeySpec::getPrimeExponentP() const throw () -{ - return _dp; -} - -const mpnumber& RSAPrivateCrtKeySpec::getPrimeExponentQ() const throw () -{ - return _dq; -} - -const mpnumber& RSAPrivateCrtKeySpec::getCrtCoefficient() const throw () -{ - return _qi; -} diff --git a/beecrypt/c++/security/spec/RSAPrivateCrtKeySpec.h b/beecrypt/c++/security/spec/RSAPrivateCrtKeySpec.h deleted file mode 100644 index 9642a965a..000000000 --- a/beecrypt/c++/security/spec/RSAPrivateCrtKeySpec.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file RSAPrivateCrtKeySpec.h - * \ingroup CXX_SECURITY_SPEC_m - */ - -#ifndef _CLASS_RSAPRIVATECRTKEYSPEC_H -#define _CLASS_RSAPRIVATECRTKEYSPEC_H - -#ifdef __cplusplus - -#include "beecrypt/c++/security/spec/RSAPrivateKeySpec.h" -using beecrypt::security::spec::RSAPrivateKeySpec; - -namespace beecrypt { - namespace security { - namespace spec { - class BEECRYPTCXXAPI RSAPrivateCrtKeySpec : public RSAPrivateKeySpec - { - private: - mpnumber _e; - mpbarrett _p; - mpbarrett _q; - mpnumber _dp; - mpnumber _dq; - mpnumber _qi; - - public: - RSAPrivateCrtKeySpec(const mpbarrett& modulus, const mpnumber& publicExponent, const mpnumber& privateExponent, const mpbarrett& primeP, const mpbarrett& primeQ, const mpnumber& primeExponentP, const mpnumber& primeExponentQ, const mpnumber& crtCoefficient); - virtual ~RSAPrivateCrtKeySpec(); - - const mpnumber& getPublicExponent() const throw (); - const mpbarrett& getPrimeP() const throw (); - const mpbarrett& getPrimeQ() const throw (); - const mpnumber& getPrimeExponentP() const throw (); - const mpnumber& getPrimeExponentQ() const throw (); - const mpnumber& getCrtCoefficient() const throw (); - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/spec/RSAPrivateKeySpec.cxx b/beecrypt/c++/security/spec/RSAPrivateKeySpec.cxx deleted file mode 100644 index 8b1d4b4a5..000000000 --- a/beecrypt/c++/security/spec/RSAPrivateKeySpec.cxx +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/spec/RSAPrivateKeySpec.h" - -using namespace beecrypt::security::spec; - -RSAPrivateKeySpec::RSAPrivateKeySpec(const mpbarrett& modulus, const mpnumber& privateExponent) -{ - _n = modulus; - _d = privateExponent; -} - -RSAPrivateKeySpec::~RSAPrivateKeySpec() -{ -} - -const mpbarrett& RSAPrivateKeySpec::getModulus() const throw () -{ - return _n; -} - -const mpnumber& RSAPrivateKeySpec::getPrivateExponent() const throw () -{ - return _d; -} diff --git a/beecrypt/c++/security/spec/RSAPrivateKeySpec.h b/beecrypt/c++/security/spec/RSAPrivateKeySpec.h deleted file mode 100644 index 456256025..000000000 --- a/beecrypt/c++/security/spec/RSAPrivateKeySpec.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file RSAPrivateKeySpec.h - * \ingroup CXX_SECURITY_SPEC_m - */ - -#ifndef _CLASS_RSAPRIVATEKEYSPEC_H -#define _CLASS_RSAPRIVATEKEYSPEC_H - -#include "beecrypt/api.h" -#include "beecrypt/mpbarrett.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/security/spec/KeySpec.h" -using beecrypt::security::spec::KeySpec; - -namespace beecrypt { - namespace security { - namespace spec { - class BEECRYPTCXXAPI RSAPrivateKeySpec : public KeySpec - { - private: - mpbarrett _n; - mpnumber _d; - - public: - RSAPrivateKeySpec(const mpbarrett& modulus, const mpnumber& privateExponent); - virtual ~RSAPrivateKeySpec(); - - const mpbarrett& getModulus() const throw (); - const mpnumber& getPrivateExponent() const throw (); - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/security/spec/RSAPublicKeySpec.cxx b/beecrypt/c++/security/spec/RSAPublicKeySpec.cxx deleted file mode 100644 index 779928e67..000000000 --- a/beecrypt/c++/security/spec/RSAPublicKeySpec.cxx +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/spec/RSAPublicKeySpec.h" - -using namespace beecrypt::security::spec; - -RSAPublicKeySpec::RSAPublicKeySpec(const mpbarrett& modulus, const mpnumber& publicExponent) -{ - _n = modulus; - _e = publicExponent; -} - -RSAPublicKeySpec::~RSAPublicKeySpec() -{ -} - -const mpbarrett& RSAPublicKeySpec::getModulus() const throw () -{ - return _n; -} - -const mpnumber& RSAPublicKeySpec::getPublicExponent() const throw () -{ - return _e; -} diff --git a/beecrypt/c++/security/spec/RSAPublicKeySpec.h b/beecrypt/c++/security/spec/RSAPublicKeySpec.h deleted file mode 100644 index 7a8c0e66a..000000000 --- a/beecrypt/c++/security/spec/RSAPublicKeySpec.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file RSAPublicKeySpec.h - * \ingroup CXX_SECURITY_SPEC_m - */ - -#ifndef _CLASS_RSAPUBLICKEYSPEC_H -#define _CLASS_RSAPUBLICKEYSPEC_H - -#include "beecrypt/api.h" -#include "beecrypt/mpbarrett.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/security/spec/KeySpec.h" -using beecrypt::security::spec::KeySpec; - -namespace beecrypt { - namespace security { - namespace spec { - class BEECRYPTCXXAPI RSAPublicKeySpec : public KeySpec - { - private: - mpbarrett _n; - mpnumber _e; - - public: - RSAPublicKeySpec(const mpbarrett& modulus, const mpnumber& publicExponent); - virtual ~RSAPublicKeySpec(); - - const mpbarrett& getModulus() const throw (); - const mpnumber& getPublicExponent() const throw (); - }; - } - } -} - -#endif - -#endif diff --git a/beecrypt/c++/testdsa.cxx b/beecrypt/c++/testdsa.cxx deleted file mode 100644 index 18832a40f..000000000 --- a/beecrypt/c++/testdsa.cxx +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/AlgorithmParameterGenerator.h" -using beecrypt::security::AlgorithmParameterGenerator; -#include "beecrypt/c++/security/AlgorithmParameters.h" -using beecrypt::security::AlgorithmParameters; -#include "beecrypt/c++/security/KeyFactory.h" -using beecrypt::security::KeyFactory; -#include "beecrypt/c++/security/KeyPairGenerator.h" -using beecrypt::security::KeyPairGenerator; -#include "beecrypt/c++/security/Signature.h" -using beecrypt::security::Signature; -#include "beecrypt/c++/security/spec/EncodedKeySpec.h" -using beecrypt::security::spec::EncodedKeySpec; - -#include <iostream> -using namespace std; -#include <unicode/ustream.h> - -int main(int argc, char* argv[]) -{ - int failures = 0; - - try - { - KeyPairGenerator* kpg = KeyPairGenerator::getInstance("DSA"); - - kpg->initialize(1024); - - KeyPair* pair = kpg->generateKeyPair(); - - Signature* sig = Signature::getInstance("SHA1withDSA"); - - sig->initSign(pair->getPrivate()); - - bytearray* tmp = sig->sign(); - - sig->initVerify(pair->getPublic()); - - if (!sig->verify(*tmp)) - failures++; - - KeyFactory* kf = KeyFactory::getInstance("BEE"); - - KeySpec* spec = kf->getKeySpec(pair->getPublic(), typeid(EncodedKeySpec)); - - PublicKey* pub = kf->generatePublic(*spec); - - delete pub; - delete spec; - delete kf; - delete tmp; - delete sig; - delete pair; - delete kpg; - } - catch (Exception& ex) - { - cerr << "exception: " << ex.getMessage() << endl; - failures++; - } - catch (...) - { - cerr << "exception" << endl; - failures++; - } - return failures; -} diff --git a/beecrypt/c++/testks.cxx b/beecrypt/c++/testks.cxx deleted file mode 100644 index 67153b45c..000000000 --- a/beecrypt/c++/testks.cxx +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/io/FileInputStream.h" -using beecrypt::io::FileInputStream; -#include "beecrypt/c++/io/FileOutputStream.h" -using beecrypt::io::FileOutputStream; -#include "beecrypt/c++/security/KeyStore.h" -using beecrypt::security::KeyStore; -#include "beecrypt/c++/security/KeyPairGenerator.h" -using beecrypt::security::KeyPairGenerator; -#include "beecrypt/c++/beeyond/BeeCertificate.h" -using beecrypt::beeyond::BeeCertificate; - -#include <iostream> -using std::cout; -using std::endl; -#include <unicode/ustream.h> - -int main(int argc, char* argv[]) -{ - try - { - array<javachar> password(4); - - password[0] = (javachar) 't'; - password[1] = (javachar) 'e'; - password[2] = (javachar) 's'; - password[3] = (javachar) 't'; - - KeyStore* ks = KeyStore::getInstance(KeyStore::getDefaultType()); - - if (argc == 2) - { - FileInputStream fin(fopen(argv[1], "rb")); - - ks->load(&fin, &password); - - Key* k = ks->getKey("rsa", password); - - cout << "k algorithm = " << k->getAlgorithm() << endl; - - delete k; - } - else - { - KeyPairGenerator* kpg = KeyPairGenerator::getInstance("RSA"); - - kpg->initialize(1024); - - KeyPair* pair = kpg->generateKeyPair(); - - vector<Certificate*> chain; - - chain.push_back(BeeCertificate::self(pair->getPublic(), pair->getPrivate(), "SHA1withRSA")); - - FileOutputStream fos(fopen("keystore", "wb")); - - // create an empty stream - ks->load((InputStream*) 0, &password); - ks->setKeyEntry("rsa", pair->getPrivate(), password, chain); - ks->store(fos, &password); - } - - delete ks; - } - catch (Exception e) - { - cout << "Exception: " + e.getMessage() << endl; - } -} diff --git a/beecrypt/c++/testrsa.cxx b/beecrypt/c++/testrsa.cxx deleted file mode 100644 index 3461cd95e..000000000 --- a/beecrypt/c++/testrsa.cxx +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/security/Security.h" -using beecrypt::security::Security; -#include "beecrypt/c++/security/AlgorithmParameterGenerator.h" -using beecrypt::security::AlgorithmParameterGenerator; -#include "beecrypt/c++/security/AlgorithmParameters.h" -using beecrypt::security::AlgorithmParameters; -#include "beecrypt/c++/security/KeyFactory.h" -using beecrypt::security::KeyFactory; -#include "beecrypt/c++/security/KeyPairGenerator.h" -using beecrypt::security::KeyPairGenerator; -#include "beecrypt/c++/security/Signature.h" -using beecrypt::security::Signature; -#include "beecrypt/c++/security/spec/EncodedKeySpec.h" -using beecrypt::security::spec::EncodedKeySpec; - -#include <iostream> -using namespace std; -#include <unicode/ustream.h> - -int main(int argc, char* argv[]) -{ - int failures = 0; - - try - { - KeyPairGenerator* kpg = KeyPairGenerator::getInstance("RSA"); - - kpg->initialize(1024); - - KeyPair* pair = kpg->generateKeyPair(); - - Signature* sig = Signature::getInstance("SHA1withRSA"); - - sig->initSign(pair->getPrivate()); - - bytearray* tmp = sig->sign(); - - sig->initVerify(pair->getPublic()); - - if (!sig->verify(*tmp)) - failures++; - - KeyFactory* kf = KeyFactory::getInstance("BEE"); - - KeySpec* spec = kf->getKeySpec(pair->getPublic(), typeid(EncodedKeySpec)); - - PublicKey* pub = kf->generatePublic(*spec); - - delete pub; - delete spec; - delete kf; - delete tmp; - delete sig; - delete pair; - delete kpg; - } - catch (Exception& ex) - { - cerr << "Exception: " << ex.getMessage() << endl; - failures++; - } - catch (...) - { - cerr << "exception" << endl; - failures++; - } - return failures; -} diff --git a/beecrypt/c++/util/.cvsignore b/beecrypt/c++/util/.cvsignore deleted file mode 100644 index da7b4816b..000000000 --- a/beecrypt/c++/util/.cvsignore +++ /dev/null @@ -1,5 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo diff --git a/beecrypt/c++/util/Date.cxx b/beecrypt/c++/util/Date.cxx deleted file mode 100644 index 8bce5f306..000000000 --- a/beecrypt/c++/util/Date.cxx +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/timestamp.h" -#include "beecrypt/c++/util/Date.h" - -#include <unicode/datefmt.h> - -namespace { - #if WIN32 - __declspec(thread) String* result = 0; - __declspec(thread) DateFormat* format = 0; - #else - # if __GNUC__ && __GNUC_PREREQ (3, 3) - __thread String* result = 0; - __thread DateFormat* format = 0; - # else - # warning Date.toString() method routine is not multi-thread safe - String* result = 0; - DateFormat* format = 0; - # endif - #endif -} - -using namespace beecrypt::util; - -Date::Date() throw () -{ - _time = timestamp(); -} - -Date::Date(javalong time) throw () -{ - _time = time; -} - -const Date& Date::operator=(const Date& set) throw () -{ - _time = set._time; - return *this; -} - -bool Date::operator==(const Date& cmp) const throw () -{ - return _time == cmp._time; -} - -bool Date::operator!=(const Date& cmp) const throw () -{ - return _time != cmp._time; -} - -bool Date::after(const Date& cmp) const throw () -{ - return _time > cmp._time; -} - -bool Date::before(const Date& cmp) const throw () -{ - return _time < cmp._time; -} - -javalong Date::getTime() const throw () -{ - return _time; -} - -void Date::setTime(javalong time) throw () -{ - _time = time; -} - -const String& Date::toString() const -{ - if (!format) - format = DateFormat::createDateTimeInstance(); - - if (!result) - result = new String(); - - *result = format->format((UDate) _time, *result); - - return *result; -} diff --git a/beecrypt/c++/util/Date.h b/beecrypt/c++/util/Date.h deleted file mode 100644 index a1e6db753..000000000 --- a/beecrypt/c++/util/Date.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file Date.h - * \ingroup CXX_UTIL_m - */ - -#ifndef _CLASS_DATE_H -#define _CLASS_DATE_H - -#include "beecrypt/api.h" - -#ifdef __cplusplus - -#include "beecrypt/c++/lang/String.h" -using beecrypt::lang::String; - -namespace beecrypt { - namespace util { - class BEECRYPTCXXAPI Date - { - private: - javalong _time; - - public: - Date() throw (); - Date(javalong) throw (); - - const Date& operator=(const Date&) throw (); - bool operator==(const Date&) const throw (); - bool operator!=(const Date&) const throw (); - - bool after(const Date&) const throw (); - bool before(const Date&) const throw (); - - javalong getTime() const throw (); - void setTime(javalong) throw (); - - const String& toString() const; - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/util/Enumeration.h b/beecrypt/c++/util/Enumeration.h deleted file mode 100644 index 78fd49b12..000000000 --- a/beecrypt/c++/util/Enumeration.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file Enumeration.h - * \ingroup CXX_UTIL_m - */ - -#ifndef _INTERFACE_ENUMERATION_H -#define _INTERFACE_ENUMERATION_H - -#ifdef __cplusplus - -#include "beecrypt/c++/util/NoSuchElementException.h" -using beecrypt::util::NoSuchElementException; - -namespace beecrypt { - namespace util { - class BEECRYPTCXXAPI Enumeration - { - public: - virtual ~Enumeration() throw () {}; - - virtual bool hasMoreElements() throw () = 0; - virtual const void* nextElement() throw (NoSuchElementException) = 0; - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/util/Makefile.am b/beecrypt/c++/util/Makefile.am deleted file mode 100644 index 7d5d7a19a..000000000 --- a/beecrypt/c++/util/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -INCLUDES = -I$(top_srcdir)/.. - -AUTOMAKE_OPTIONS = gnu no-dependencies - -noinst_LTLIBRARIES = libcxxutil.la -cxxutildir= $(pkgincludedir)/c++/util - -libcxxutil_la_SOURCES =\ -Date.cxx \ -NoSuchElementException.cxx \ -Properties.cxx - -cxxutil_HEADERS =\ -Date.h \ -Enumeration.h \ -NoSuchElementException.h \ -Properties.h - -TESTS = testdate testprop - -check_PROGRAMS = testdate testprop - -testdate_SOURCES = testdate.cxx -testdate_LDADD = ../libbeecrypt_cxx.la - -testprop_SOURCES = testprop.cxx -testprop_LDADD = ../libbeecrypt_cxx.la diff --git a/beecrypt/c++/util/NoSuchElementException.cxx b/beecrypt/c++/util/NoSuchElementException.cxx deleted file mode 100644 index 6d220742d..000000000 --- a/beecrypt/c++/util/NoSuchElementException.cxx +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/util/NoSuchElementException.h" - -using namespace beecrypt::util; - -NoSuchElementException::NoSuchElementException() throw () -{ -} - -NoSuchElementException::NoSuchElementException(const String& message) throw () : RuntimeException(message) -{ -} diff --git a/beecrypt/c++/util/NoSuchElementException.h b/beecrypt/c++/util/NoSuchElementException.h deleted file mode 100644 index 4271d20ad..000000000 --- a/beecrypt/c++/util/NoSuchElementException.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file NoSuchElementException.h - * \ingroup CXX_UTIL_m - */ - -#ifndef _CLASS_NOSUCHELEMENTEXCEPTION_H -#define _CLASS_NOSUCHELEMENTEXCEPTION_H - -#ifdef __cplusplus - -#include "beecrypt/c++/lang/RuntimeException.h" -using beecrypt::lang::RuntimeException; - -namespace beecrypt { - namespace util { - class BEECRYPTCXXAPI NoSuchElementException : public RuntimeException - { - public: - NoSuchElementException() throw (); - NoSuchElementException(const String&) throw (); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/util/Properties.cxx b/beecrypt/c++/util/Properties.cxx deleted file mode 100644 index d1b0b8cf3..000000000 --- a/beecrypt/c++/util/Properties.cxx +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/c++/util/Properties.h" -using beecrypt::util::Properties; -#include "beecrypt/c++/io/DataInputStream.h" -using beecrypt::io::DataInputStream; -#include "beecrypt/c++/io/PrintStream.h" -using beecrypt::io::PrintStream; - -using namespace beecrypt::util; - -Properties::PropEnum::PropEnum(const properties_map& _map) throw () -{ - _it = _map.begin(); - _end = _map.end(); -} - -Properties::PropEnum::~PropEnum() throw () -{ -} - -bool Properties::PropEnum::hasMoreElements() throw () -{ - return _it != _end; -} - -const void* Properties::PropEnum::nextElement() throw (NoSuchElementException) -{ - if (_it == _end) - throw NoSuchElementException(); - - return (const void*) &((_it++)->first); -} - -Properties::Properties() -{ - _lock.init(); - defaults = 0; -} - -Properties::Properties(const Properties& copy) -{ - _lock.init(); - /* copy every item in the map */ - _pmap = copy._pmap; - defaults = copy.defaults; -} - -Properties::Properties(const Properties* defaults) : defaults(defaults) -{ - _lock.init(); -} - -Properties::~Properties() -{ - _lock.destroy(); -} - -const String* Properties::getProperty(const String& key) const throw () -{ - properties_map::const_iterator it = _pmap.find(key); - - if (it != _pmap.end()) - return &(it->second); - else if (defaults) - return defaults->getProperty(key); - - return 0; -} - -const String* Properties::getProperty(const String& key, const String& defaultValue) const throw () -{ - const String* result = getProperty(key); - - if (result) - return result; - else - return &defaultValue; -} - -void Properties::setProperty(const String& key, const String& value) throw () -{ - _lock.lock(); - _pmap[key] = value; - _lock.unlock(); -} - -Enumeration* Properties::propertyNames() const -{ - return new PropEnum(_pmap); -} - -void Properties::load(InputStream& in) throw (IOException) -{ - String line; - String key; - String value; - - DataInputStream dis(in); - - _lock.lock(); - try - { - while (dis.available()) - { - dis.readLine(line); - - if (line.indexOf((UChar) 0x23) != 0) - { - // more advanced parsing can come later - // see if we can find an '=' somewhere inside the string - int32_t eqidx = line.indexOf((UChar) 0x3D); - if (eqidx >= 0) - { - // we can split the line into two parts - key.setTo(line, 0, eqidx); - value.setTo(line, eqidx+1); - _pmap[key] = value; - } - } - // else it's a comment line which we discard - } - _lock.unlock(); - } - catch (IOException) - { - _lock.unlock(); - throw; - } -} - -void Properties::store(OutputStream& out, const String& header) throw (IOException) -{ - properties_map::const_iterator pit; - PrintStream ps(out); - - ps.println("# " + header); - - _lock.lock(); - - for (pit = _pmap.begin(); pit != _pmap.end(); ++pit) - { - ps.print(pit->first); - ps.print((javachar) 0x3D); - ps.println(pit->second); - } - - _lock.unlock(); -} diff --git a/beecrypt/c++/util/Properties.h b/beecrypt/c++/util/Properties.h deleted file mode 100644 index f5a2aebdc..000000000 --- a/beecrypt/c++/util/Properties.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file Properties.h - * \ingroup CXX_UTIL_m - */ - -#ifndef _CLASS_PROPERTIES_H -#define _CLASS_PROPERTIES_H - -#ifdef __cplusplus - -#include "beecrypt/c++/mutex.h" -using beecrypt::mutex; -#include "beecrypt/c++/io/InputStream.h" -using beecrypt::io::InputStream; -#include "beecrypt/c++/io/OutputStream.h" -using beecrypt::io::OutputStream; -#include "beecrypt/c++/lang/String.h" -using beecrypt::lang::String; -#include "beecrypt/c++/util/Enumeration.h" -using beecrypt::util::Enumeration; - -#include <map> -using std::map; - -namespace beecrypt { - namespace util { - class BEECRYPTCXXAPI Properties - { - private: - typedef map<String,String> properties_map; - - class PropEnum : public Enumeration - { - public: - properties_map::const_iterator _it; - properties_map::const_iterator _end; - - public: - PropEnum(const properties_map&) throw (); - virtual ~PropEnum() throw (); - - virtual bool hasMoreElements() throw (); - virtual const void* nextElement() throw (NoSuchElementException); - }; - - properties_map _pmap; - - mutex _lock; - - protected: - const Properties* defaults; - - public: - Properties(); - Properties(const Properties& copy); - Properties(const Properties* defaults); - ~Properties(); - - const String* getProperty(const String& key) const throw (); - const String* getProperty(const String& key, const String& defaultValue) const throw (); - - void setProperty(const String& key, const String& value) throw (); - - Enumeration* propertyNames() const; - - void load(InputStream& in) throw (IOException); - void store(OutputStream& out, const String& header) throw (IOException); - }; - } -} - -#endif - -#endif diff --git a/beecrypt/c++/util/testdate.cxx b/beecrypt/c++/util/testdate.cxx deleted file mode 100644 index e822b31ed..000000000 --- a/beecrypt/c++/util/testdate.cxx +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -// #define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "c++/util/Date.h" -using beecrypt::util::Date; - -#include <unicode/ustream.h> -#include <iostream> -using namespace std; - -int main(int argc, char* argv[]) -{ - Date now; - - cout << now.toString() << endl; -} diff --git a/beecrypt/c++/util/testprop.cxx b/beecrypt/c++/util/testprop.cxx deleted file mode 100644 index 9646da404..000000000 --- a/beecrypt/c++/util/testprop.cxx +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2004 Beeyond Software Holding BV - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -// #define BEECRYPT_CXX_DLL_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "c++/io/FileOutputStream.h" -using beecrypt::io::FileOutputStream; -#include "c++/util/Properties.h" -using beecrypt::util::Properties; - -#include <unicode/ustream.h> -#include <iostream> -using namespace std; -#include <stdio.h> - -int main(int argc, char* argv[]) -{ - - Properties p; - - p.setProperty("apple", "red"); - p.setProperty("yam", "orange"); - p.setProperty("lime", "green"); - p.setProperty("grape", "blue"); - - Enumeration* e = p.propertyNames(); - - while (e->hasMoreElements()) - { - const String* s = (const String*) e->nextElement(); - - cout << *s << endl; - } - - delete e; - - FileOutputStream fso(stdout); - p.store(fso, "properties test"); -} diff --git a/beecrypt/config.m4.in b/beecrypt/config.m4.in deleted file mode 100644 index a39406504..000000000 --- a/beecrypt/config.m4.in +++ /dev/null @@ -1,15 +0,0 @@ -dnl config.m4 -ifdef(`__CONFIG_M4_INCLUDED__',,` -define(`CONFIG_TOP_SRCDIR',`@top_srcdir@') -define(`ASM_OS',`@ASM_OS@') -define(`ASM_CPU',`@ASM_CPU@') -define(`ASM_ARCH',`@ASM_ARCH@') -define(`ASM_BIGENDIAN',`@ASM_BIGENDIAN@') -define(`ASM_SRCDIR',`@top_srcdir@/gas') -define(`TEXTSEG',`@ASM_TEXTSEG@') -define(`GLOBL',`@ASM_GLOBL@') -define(`GSYM_PREFIX',`@ASM_GSYM_PREFIX@') -define(`LSYM_PREFIX',`@ASM_LSYM_PREFIX@') -define(`ALIGN',`@ASM_ALIGN@') -define(`__CONFIG_M4_INCLUDED__') -') diff --git a/beecrypt/configure.ac b/beecrypt/configure.ac deleted file mode 100644 index 69dba9467..000000000 --- a/beecrypt/configure.ac +++ /dev/null @@ -1,644 +0,0 @@ -# Process this file with autoconf to produce a configure script. - -AC_INIT([beecrypt],[4.0.0],[bob.deblier@telenet.be]) -AM_INIT_AUTOMAKE -AC_CANONICAL_TARGET -AC_CONFIG_SRCDIR(beecrypt.h) -AC_CONFIG_HEADERS([config.h]) -AC_LIBTOOL_WIN32_DLL - -# Checks for package options -AC_ARG_ENABLE(debug, [ --enable-debug creates debugging code [default=no]],[ - if test "$enableval" = no; then - ac_enable_debug=no - else - ac_enable_debug=yes - fi - ],[ ac_enable_debug=no]) - -AC_ARG_WITH(cpu,[ --with-cpu optimize for specific cpu],[ - BEECRYPT_WITH_CPU - ],[ - BEECRYPT_WITHOUT_CPU - ]) - -AC_ARG_WITH(arch,[ --with-arch optimize for specific architecture (may not run on other cpus of same family)],[ - BEECRYPT_WITH_ARCH - ],[ - BEECRYPT_WITHOUT_ARCH - ]) - -AC_ARG_ENABLE(threads,[ --enable-threads enables multithread support [default=yes]],[ - if test "$enableval" = no; then - ac_enable_threads=no - else - ac_enable_threads=yes - fi - ],[ ac_enable_threads=yes]) - -AC_ARG_ENABLE(aio,[ --enable-aio enables asynchronous i/o for entropy gathering [default=yes]],[ - if test "$enableval" = no; then - ac_enable_aio=no - else - ac_enable_aio=yes - fi - ],[ac_enable_aio=yes]) - -AH_TEMPLATE([ENABLE_AIO],[Define to 1 if you want to enable asynchronous I/O support]) - -AC_ARG_WITH(mtmalloc,[ --with-mtmalloc links against the mtmalloc library [default=no]],[ - if test "$withval" = no; then - ac_with_mtmalloc=no - else - ac_with_mtmalloc=yes - fi - ],[ac_with_mtmalloc=no]) - -AC_ARG_WITH(cplusplus,[ --with-cplusplus creates the C++ API code [default=yes]],[ - if test "$withval" = no; then - ac_with_cplusplus=no - else - ac_with_cplusplus=yes - fi - ],[ac_with_cplusplus=yes]) - -AC_ARG_WITH(java,[ --with-java creates the java glue code [default=yes]],[ - if test "$withval" = no; then - ac_with_java=no - else - ac_with_java=yes - fi - ],[ac_with_java=yes]) - -AC_ARG_WITH(python,[ --with-python creates the python bindings code [default=yes]],[ - if test "$withval" = no; then - ac_with_python=no - else - ac_with_python=yes - fi - ],[ac_with_python=yes]) - -# Check for Unix variants -AC_AIX - -# Checks for C compiler and preprocessor -AC_PROG_CC -AC_PROG_CPP -AC_PROG_CXX -AC_PROG_CXXCPP -AC_PROG_LD -AC_PROG_LN_S -AM_PROG_AS - -# Checks for compiler characteristics and flags -BEECRYPT_CC -BEECRYPT_CXX - -# Check for stack protection -BEECRYPT_NOEXECSTACK - -# Checks for program flags needed by libtool -BEECRYPT_LIBTOOL - -# Checks for further programs -AC_PROG_AWK -AC_PROG_INSTALL -AC_PROG_LIBTOOL - -# Predefines for autoheader -BEECRYPT_OS_DEFS - -AH_TEMPLATE([HAVE_CTYPE_H],[.]) -AH_TEMPLATE([HAVE_ERRNO_H],[.]) -AH_TEMPLATE([HAVE_FCNTL_H],[.]) -AH_TEMPLATE([HAVE_TERMIO_H],[.]) -AH_TEMPLATE([HAVE_TERMIOS_H],[.]) -AH_TEMPLATE([HAVE_TIME_H],[.]) -AH_TEMPLATE([HAVE_DLFCN_H],[.]) - -AH_TEMPLATE([HAVE_SYS_AUDIOIO_H],[.]) -AH_TEMPLATE([HAVE_SYS_IOCTL_H],[.]) -AH_TEMPLATE([HAVE_SYS_SOUNDCARD_H],[.]) -AH_TEMPLATE([HAVE_SYS_STAT_H],[.]) -AH_TEMPLATE([HAVE_SYS_TIME_H],[.]) -AH_TEMPLATE([HAVE_SYS_TYPES_H],[.]) - -AH_TEMPLATE([HAVE_AIO_H],[.]) - -AH_TEMPLATE([HAVE_DEV_AUDIO],[Define to 1 if your system has device /dev/audio]) -AH_TEMPLATE([HAVE_DEV_DSP],[Define to 1 if your system has device /dev/dsp]) -AH_TEMPLATE([HAVE_DEV_RANDOM],[Define to 1 if your system has device /dev/random]) -AH_TEMPLATE([HAVE_DEV_URANDOM],[Define to 1 if your system has device /dev/urandom]) -AH_TEMPLATE([HAVE_DEV_TTY],[Define to 1 if your system has device /dev/tty]) - -AH_BOTTOM([ -#if ENABLE_THREADS -# ifndef _REENTRANT -# define _REENTRANT -# endif -# if LINUX -# define _LIBC_REENTRANT -# endif -#else -# ifdef _REENTRANT -# undef _REENTRANT -# endif -#endif -]) - -# Checks for header files. -AC_HEADER_STDC -AC_CHECK_HEADERS([time.h sys/time.h]) -AC_HEADER_TIME -AC_CHECK_HEADERS([stdio.h ctype.h errno.h fcntl.h malloc.h termio.h termios.h]) -AC_CHECK_HEADERS([sys/ioctl.h sys/audioio.h sys/soundcard.h]) - -bc_include_stdio_h= -bc_include_stdlib_h= -bc_include_malloc_h= -bc_include_string_h= -bc_include_unistd_h= -bc_include_dlfcn_h= -if test "$ac_cv_header_stdio_h" = yes; then - bc_include_stdio_h="#include <stdio.h>" -fi -if test "$ac_cv_header_stdlib_h" = yes; then - bc_include_stdlib_h="#include <stdlib.h>" -elif test "$ac_cv_header_malloc_h" = yes; then - bc_include_malloc_h="#include <malloc.h>" -fi -if test "$ac_with_mtmalloc" = yes; then - AC_CHECK_HEADERS(mtmalloc.h) - if test "$ac_cv_header_mtmalloc_h" = yes; then - bc_include_stdlib_h= - bc_include_malloc_h="#include <mtmalloc.h>" - fi -fi -if test "$ac_cv_header_string_h" = yes; then - bc_include_string_h="#include <string.h>" -fi -if test "$ac_cv_header_unistd_h" = yes; then - bc_include_unistd_h="#include <unistd.h>" -fi -if test "$ac_cv_header_dlfcn_h" = yes; then - bc_include_dlfcn_h="#include <dlfcn.h>" -fi -AC_SUBST(INCLUDE_STDIO_H,$bc_include_stdio_h) -AC_SUBST(INCLUDE_STDLIB_H,$bc_include_stdlib_h) -AC_SUBST(INCLUDE_MALLOC_H,$bc_include_malloc_h) -AC_SUBST(INCLUDE_STRING_H,$bc_include_string_h) -AC_SUBST(INCLUDE_UNISTD_H,$bc_include_unistd_h) -AC_SUBST(INCLUDE_DLFCN_H,$bc_include_dlfcn_h) - -BEECRYPT_DLFCN -BEECRYPT_MULTITHREAD - -# Checks for libraries. -if test "$ac_enable_aio" = yes; then - BEECRYPT_WORKING_AIO - if test "$bc_cv_aio_works" = yes; then - AC_DEFINE([ENABLE_AIO],1) - fi -fi - -if test "$ac_with_mtmalloc" = yes; then - if test "$ac_cv_have_mtmalloc_h" = yes; then - AC_CHECK_LIB([mtmalloc],[main]) ac_cv_lib_mtmalloc=ac_cv_lib_mtmalloc_main - - fi -fi - -case $target_os in - cygwin*) - AC_CHECK_LIB([winmm],[main]) ac_cv_lib_winmm=ac_cv_lib_winmm_main - ;; -esac - -# Checks for typedefs, structures, and compiler characteristics. -AC_C_BIGENDIAN -AC_C_CONST -AC_C_INLINE - -# Checks for library functions. -AC_PROG_GCC_TRADITIONAL -AC_FUNC_MEMCMP -AC_FUNC_STAT -AC_CHECK_FUNCS([memset memcmp memmove strcspn strerror strspn]) - -AH_TEMPLATE([HAVE_GETHRTIME],[.]) -AH_TEMPLATE([HAVE_GETTIMEOFDAY],[.]) -if test "$ac_cv_header_sys_time_h" = yes; then - AC_CHECK_FUNCS([gethrtime]) - # gettimeofday detection fails on HP/UX! - AC_MSG_CHECKING([for gettimeofday]) - AC_TRY_LINK([#include <sys/time.h> ],[ - struct timeval dummy; - gettimeofday(&dummy, (void*) 0); - ],[ - AC_MSG_RESULT([yes]) - AC_DEFINE([HAVE_GETTIMEOFDAY],1) - ac_cv_func_gettimeofday=yes - ],[ - AC_MSG_RESULT([no]) - AC_DEFINE([HAVE_GETTIMEOFDAY],0) - ac_cv_func_gettimeofday=no - ]) -fi - -# Predefines and checks for C++ API support -AH_TEMPLATE([CPPGLUE],[Define to 1 if you want to include the C++ code]) - -if test "$ac_with_cplusplus" = yes; then - AC_MSG_CHECKING([for IBM's ICU library]) - AC_TRY_LINK([#include <unicode/uversion.h> ],[ - ],[ - AC_MSG_RESULT([yes]) - ],[ - AC_MSG_RESULT([no]) - AC_MSG_WARN([disabling cplusplus]) - ac_with_cplusplus=no - ]) -fi - -if test "$ac_with_cplusplus" = yes ; then - AC_DEFINE([CPPGLUE],1) -fi - - -# Predefines and checks for Java API support -AH_TEMPLATE([JAVAGLUE],[Define to 1 if you want to include the Java code]) - -if test "$ac_with_java" = yes ; then - AC_CHECK_PROG(ac_cv_have_gcj, gcj, yes, no) - if test "$ac_cv_have_gcj" = yes; then - AC_CACHE_CHECK([for java native interface headers], ac_cv_java_include, [ - cat > conftest.java << EOF -public class conftest -{ - public static void main(String[[]] argv) - { - System.out.println(System.getProperty("java.home")); - } -} -EOF - java_home="`gcj --main=conftest -o conftest conftest.java; ./conftest`" - if test X"$java_home" = X; then - java_home=/usr - fi - if test -d "$java_home" -a -d "$java_home/include"; then - ac_cv_java_headers=yes - ac_cv_java_include="-I$java_home/include" - gcjpath="$java_home/lib/gcc-lib/`gcj -dumpmachine`/`gcj -dumpversion`" - if test -d "$gcjpath" -a -d "$gcjpath/include"; then - ac_cv_java_include="$ac_cv_java_include -I$gcjpath/include" - fi - else - AC_MSG_WARN([java headers not found, disabling java glue]) - ac_cv_java_headers=no - ac_cv_java_include= - ac_with_java=no - fi - rm -fr conftest* - ]) - else - AC_CHECK_PROG(ac_cv_have_java, java, yes, no) - if test "$ac_cv_have_java" = yes; then - AC_CHECK_PROG(ac_cv_have_javac, javac, yes, no) - if test "$ac_cv_have_javac" = yes; then - AC_CACHE_CHECK([for java native interface headers],ac_cv_java_include,[ - cat > conftest.java << EOF -public class conftest -{ - public static void main(String[[]] argv) - { - System.out.println(System.getProperty("java.home")); - } -} -EOF - java_home=`javac conftest.java; java -classpath . conftest` - case $target_os in - cygwin*) - java_home=`cygpath -u -p "$java_home"` ;; - esac - if test -d "$java_home"; then - case $target_os in - darwin*) - java_include="$java_home/../../../Headers" ;; - *) - java_include="$java_home"/../include ;; - esac - if test -d "$java_include"; then - ac_cv_java_headers=yes - ac_cv_java_include="-I$java_include" - case $target_os in - aix*) - ac_cv_java_include="-I$java_include -I$java_include/aix" ;; - cygwin*) - ac_cv_java_include="-I$java_include -I$java_include/win32" ;; - darwin*) ;; - hpux*) - ac_cv_java_include="-I$java_include -I$java_include/hpux" ;; - linux*) - ac_cv_java_include="-I$java_include -I$java_include/linux" ;; - osf*) - ac_cv_java_include="-I$java_include -I$java_include/osf" ;; - solaris*) - ac_cv_java_include="-I$java_include -I$java_include/solaris" ;; - *) - AC_MSG_WARN([please add appropriate -I$java_include/<operating system> flag]) - ac_cv_java_include="-I$java_include" ;; - esac - else - AC_MSG_WARN([java headers not found, disabling java]) - ac_cv_java_headers=no - ac_cv_java_include= - ac_with_java=no - fi - fi - rm -fr conftest* - ]) - else - AC_MSG_WARN([javac not found, disabling java]) - ac_cv_java_headers=no - ac_cv_java_include= - ac_with_java=no - fi - else - AC_MSG_WARN([java not found, disabling java]) - ac_cv_java_headers=no - ac_with_java=no - fi - fi -fi - -if test "$ac_with_java" = yes ; then - AC_DEFINE([JAVAGLUE],1) - AC_SUBST(JAVAINC,$ac_cv_java_include) -fi - - -# Predefines and checks for Python API support -AH_TEMPLATE([PYTHONGLUE],[Define to 1 if you want to include the Python code]) - -if test "$ac_with_python" = yes ; then - AC_CHECK_PROG(ac_cv_have_python, python, yes, no) - if test "$ac_cv_have_python" = yes; then - AC_CACHE_CHECK([for python headers], ac_cv_python_include, [ - ac_cv_python_include="-I`python -c 'import distutils.sysconfig; print distutils.sysconfig.get_python_inc()'`" - ]) - AC_CACHE_CHECK([for python libraries], ac_cv_python_libdir, [ - ac_cv_python_libdir="`python -c 'import distutils.sysconfig; print distutils.sysconfig.get_python_lib()'`" - ]) - else - ac_with_python=no - fi -fi - -if test "$ac_with_python" = yes; then - AC_DEFINE([PYTHONGLUE],1) - AC_SUBST(PYTHONINC,$ac_cv_python_include) - AC_SUBST(PYTHONLIB,$ac_cv_python_libdir) -fi - - -# Checks for entropy sources. -AS_MESSAGE(checking for specific entropy devices...) -case $target_os in -cygwin*) - AC_MSG_CHECKING([for wavein]) - AC_MSG_RESULT(yes) - AC_MSG_CHECKING([for wincrypt]) - AC_MSG_RESULT(yes) - AC_MSG_CHECKING([for console]) - AC_MSG_RESULT(yes) - ;; -linux*) - AC_CACHE_CHECK([for /dev/dsp],ac_cv_have_dev_dsp,[ - if test -r /dev/dsp; then - ac_cv_have_dev_dsp=yes - else - ac_cv_have_dev_dsp=no - fi - ]) - if test "$ac_cv_have_dev_dsp" = yes; then - AC_DEFINE([HAVE_DEV_DSP], 1) - fi - ;; -solaris*) - AC_CACHE_CHECK([for /dev/audio],ac_cv_have_dev_audio,[ - if test -r /dev/audio; then - ac_cv_have_dev_audio=yes - else - ac_cv_have_dev_audio=no - fi - ]) - if test "$ac_cv_have_dev_audio" = yes; then - AC_DEFINE([HAVE_DEV_AUDIO], 1) - fi - ;; -*) - AC_MSG_WARN(no specific entropy devices present) - ;; -esac - -case $target_os in -cygwin*) - ;; -*) - AS_MESSAGE(checking for generic entropy devices...) - AC_CACHE_CHECK([for /dev/random],ac_cv_have_dev_random,[ - if test -r /dev/random; then - ac_cv_have_dev_random=yes - else - ac_cv_have_dev_random=no - fi - ]) - AC_CACHE_CHECK([for /dev/urandom],ac_cv_have_dev_urandom,[ - if test -r /dev/urandom; then - ac_cv_have_dev_urandom=yes - else - ac_cv_have_dev_urandom=no - fi - ]) - AC_CACHE_CHECK([for /dev/tty],ac_cv_have_dev_tty,[ - if test -r /dev/tty; then - ac_cv_have_dev_tty=yes - else - ac_cv_have_dev_tty=no - fi - ]) - ;; -esac - -if test "$ac_cv_have_dev_random" = yes; then - AC_DEFINE([HAVE_DEV_RANDOM],1) -fi -if test "$ac_cv_have_dev_urandom" = yes; then - AC_DEFINE([HAVE_DEV_URANDOM],1) -fi -if test "$ac_cv_have_dev_tty" = yes; then - AC_DEFINE([HAVE_DEV_TTY],1) -fi - -if test "$ac_enable_debug" != yes; then - case $bc_target_arch in - alpha*) - CPPFLAGS="$CPPFLAGS -DOPTIMIZE_ALPHA" - ;; - arm*) - CPPFLAGS="$CPPFLAGS -DOPTIMIZE_ARM" - ;; - athlon*) - CPPFLAGS="$CPPFLAGS -DOPTIMIZE_I386 -DOPTIMIZE_MMX" - ;; - i386) - CPPFLAGS="$CPPFLAGS -DOPTIMIZE_I386" - ;; - i486) - CPPFLAGS="$CPPFLAGS -DOPTIMIZE_I486" - ;; - i586) - CPPFLAGS="$CPPFLAGS -DOPTIMIZE_I586" - ;; - i686) - CPPFLAGS="$CPPFLAGS -DOPTIMIZE_I686" - ;; - ia64) - CPPFLAGS="$CPPFLAGS -DOPTIMIZE_IA64" - ;; - m68k) - CPPFLAGS="$CPPFLAGS -DOPTIMIZE_M68K" - ;; - pentium) - CPPFLAGS="$CPPFLAGS -DOPTIMIZE_I586" - ;; - pentium-mmx) - CPPFLAGS="$CPPFLAGS -DOPTIMIZE_I586 -DOPTIMIZE_MMX" - ;; - pentiumpro) - CPPFLAGS="$CPPFLAGS -DOPTIMIZE_I686" - ;; - pentium2) - CPPFLAGS="$CPPFLAGS -DOPTIMIZE_I686 -DOPTIMIZE_MMX" - ;; - pentium3) - CPPFLAGS="$CPPFLAGS -DOPTIMIZE_I686 -DOPTIMIZE_MMX -DOPTIMIZE_SSE" - ;; - pentium4) - CPPFLAGS="$CPPFLAGS -DOPTIMIZE_I686 -DOPTIMIZE_MMX -DOPTIMIZE_SSE -DOPTIMIZE_SSE2" - ;; - powerpc) - CPPFLAGS="$CPPFLAGS -DOPTIMIZE_POWERPC" - ;; - powerpc64) - CPPFLAGS="$CPPFLAGS -DOPTIMIZE_POWERPC64" - ;; - s390x) - CPPFLAGS="$CPPFLAGS -DOPTIMIZE_S390X" - ;; - sparcv8) - CPPFLAGS="$CPPFLAGS -DOPTIMIZE_SPARCV8" - CFLAGS="$CFLAGS -Wa,-xarch=v8" - ;; - sparcv8plus*) - CPPFLAGS="$CPPFLAGS -DOPTIMIZE_SPARCV8PLUS" - CFLAGS="$CFLAGS -Wa,-xarch=v8plus" - ;; - sparcv9*) - CPPFLAGS="$CPPFLAGS -DOPTIMIZE_SPARCV9" - CFLAGS="$CFLAGS -Wa,-xarch=v9" - ;; - x86_64) - CPPFLAGS="$CPPFLAGS -DOPTIMIZE_X86_64" - ;; - esac -fi - -if test "$ac_enable_debug" != yes; then - # find out how to use assembler - BEECRYPT_ASM_DEFS - BEECRYPT_ASM_TEXTSEG - BEECRYPT_ASM_GLOBL - BEECRYPT_ASM_GSYM_PREFIX - BEECRYPT_ASM_LSYM_PREFIX - BEECRYPT_ASM_ALIGN -fi - -# generate assembler source files from m4 files -BEECRYPT_ASM_SOURCES - -# Check for standard types and integers of specific sizes -BEECRYPT_INT_TYPES -BEECRYPT_CPU_BITS - -MAYBE_SUB= -MAYBE_LTLIB= - -if test "$ac_with_cplusplus" = yes; then - MAYBE_SUB="$MAYBE_SUB c++" - MAYBE_LTLIB="$MAYBE_LTLIB libbeecrypt_cxx.la" -fi - -if test "$ac_with_java" = yes; then - MAYBE_SUB="$MAYBE_SUB java" - MAYBE_LTLIB="$MAYBE_LTLIB libbeecrypt_java.la" -fi - -if test "$ac_with_python" = yes; then - MAYBE_SUB="$MAYBE_SUB python" -fi - -AC_SUBST([MAYBE_SUB]) -AC_SUBST([MAYBE_LTLIB]) - -# Check where to install the libraries -bc_libalt= -case $target_os in -linux*) - case $bc_target_arch in - alpha* | powerpc64 | s390x | x86_64) - bc_libalt="64" - ;; - esac - ;; -esac -AC_SUBST(LIBALT,$bc_libalt) - -# Generate output files. -AC_CONFIG_FILES([ - Makefile - Doxyfile - config.m4 - c++/Makefile - c++/beeyond/Makefile - c++/crypto/Makefile - c++/crypto/interfaces/Makefile - c++/crypto/spec/Makefile - c++/io/Makefile - c++/lang/Makefile - c++/provider/Makefile - c++/security/Makefile - c++/security/cert/Makefile - c++/security/interfaces/Makefile - c++/security/spec/Makefile - c++/util/Makefile - docs/Makefile - gas/Makefile - java/Makefile - masm/Makefile - python/Makefile - python/test/Makefile - tests/Makefile - ]) -AC_CONFIG_FILES([gnu.h],[ - if test $srcdir != "."; then - cp gnu.h $ac_top_srcdir/gnu.h - fi - ]) -AC_CONFIG_COMMANDS_POST([ - if test -h "beecrypt"; then - rm -f beecrypt - fi - $LN_S $srcdir beecrypt - ]) -AC_OUTPUT diff --git a/beecrypt/cppglue.cxx b/beecrypt/cppglue.cxx deleted file mode 100644 index 9a6261709..000000000 --- a/beecrypt/cppglue.cxx +++ /dev/null @@ -1,296 +0,0 @@ -/* - * Copyright (c) 2004 Bob Deblier - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define BEECRYPT_DLL_EXPORT - -#if HAVE_CONFIG_H -# include "config.h" -#endif - -#include "beecrypt/beecrypt.h" -#include "beecrypt/mpnumber.h" -#include "beecrypt/mpbarrett.h" -#include "beecrypt/dldp.h" -#include "beecrypt/dlkp.h" -#include "beecrypt/dlpk.h" -#include "beecrypt/rsakp.h" -#include "beecrypt/rsapk.h" - -#include <iomanip> - -#if CPPGLUE - -mpnumber::mpnumber() -{ - mpnzero(this); -} - -mpnumber::mpnumber(unsigned int value) -{ - mpnsize(this, 1); - mpnsetw(this, value); -} - -mpnumber::mpnumber(const mpnumber& copy) -{ - mpnzero(this); - mpncopy(this, ©); -} - -mpnumber::~mpnumber() -{ - mpnfree(this); -} - -const mpnumber& mpnumber::operator=(const mpnumber& copy) -{ - mpncopy(this, ©); - return *this; -} - -bool mpnumber::operator==(const mpnumber& cmp) -{ - return mpeqx(size, data, cmp.size, cmp.data); -} - -bool mpnumber::operator!=(const mpnumber& cmp) -{ - return mpnex(size, data, cmp.size, cmp.data); -} - -void mpnumber::wipe() -{ - mpnwipe(this); -} - -size_t mpnumber::bitlength() const -{ - return mpbits(size, data); -} - -std::ostream& operator<<(std::ostream& stream, const mpnumber& n) -{ - if (n.size) - { - stream << std::hex << std::setfill('0') << n.data[0]; - for (size_t i = 1; i < n.size; i++) - stream << std::setw(MP_WNIBBLES) << n.data[i]; - } - - return stream; -} - -/* -std::istream& operator>>(std:istream& stream, mpnumber& n) -{ -} -*/ - -mpbarrett::mpbarrett() -{ - mpbzero(this); -} - -mpbarrett::mpbarrett(const mpbarrett& copy) -{ - mpbzero(this); - mpbcopy(this, ©); -} - -mpbarrett::~mpbarrett() -{ - mpbfree(this); -} - -const mpbarrett& mpbarrett::operator=(const mpbarrett& copy) -{ - mpbcopy(this, ©); - return *this; -} - -bool mpbarrett::operator==(const mpbarrett& cmp) -{ - return mpeqx(size, modl, cmp.size, cmp.modl); -} - -bool mpbarrett::operator!=(const mpbarrett& cmp) -{ - return mpnex(size, modl, cmp.size, cmp.modl); -} - -void mpbarrett::wipe() -{ - mpbwipe(this); -} - -size_t mpbarrett::bitlength() const -{ - return mpbits(size, modl); -} - -std::ostream& operator<<(std::ostream& stream, const mpbarrett& b) -{ - stream << std::hex << std::setfill('0'); - - for (size_t i = 0; i < b.size; i++) - stream << std::setw(MP_WNIBBLES) << b.modl[i]; - - return stream; -} - -dldp_p::dldp_p() -{ - dldp_pInit(this); -} - -dldp_p::dldp_p(const dldp_p& copy) -{ - dldp_pInit(this); - dldp_pCopy(this, ©); -} - -dldp_p::~dldp_p() -{ - dldp_pFree(this); -} - -dlkp_p::dlkp_p() -{ - dlkp_pInit(this); -} - -dlkp_p::dlkp_p(const dlkp_p& copy) -{ - dlkp_pInit(this); - dlkp_pCopy(this, ©); -} - -dlkp_p::~dlkp_p() -{ - dlkp_pFree(this); -} - -dlpk_p::dlpk_p() -{ - dlpk_pInit(this); -} - -dlpk_p::dlpk_p(const dlpk_p& copy) -{ - dlpk_pInit(this); - dlpk_pCopy(this, ©); -} - -dlpk_p::~dlpk_p() -{ - dlpk_pFree(this); -} - -rsakp::rsakp() -{ - rsakpInit(this); -} - -rsakp::rsakp(const rsakp& copy) -{ - rsakpInit(this); - rsakpCopy(this, ©); -} - -rsakp::~rsakp() -{ - rsakpFree(this); -} - -rsapk::rsapk() -{ - rsapkInit(this); -} - -rsapk::rsapk(const rsapk& copy) -{ - rsapkInit(this); - rsapkCopy(this, ©); -} - -rsapk::~rsapk() -{ - rsapkFree(this); -} - -blockCipherContext::blockCipherContext() -{ - blockCipherContextInit(this, blockCipherDefault()); -} - -blockCipherContext::blockCipherContext(const blockCipher* b) -{ - blockCipherContextInit(this, b); -} - -blockCipherContext::~blockCipherContext() -{ - blockCipherContextFree(this); -} - -hashFunctionContext::hashFunctionContext() -{ - hashFunctionContextInit(this, hashFunctionDefault()); -} - -hashFunctionContext::hashFunctionContext(const hashFunction* h) -{ - hashFunctionContextInit(this, h); -} - -hashFunctionContext::~hashFunctionContext() -{ - hashFunctionContextFree(this); -} - -keyedHashFunctionContext::keyedHashFunctionContext() -{ - keyedHashFunctionContextInit(this, keyedHashFunctionDefault()); -} - -keyedHashFunctionContext::keyedHashFunctionContext(const keyedHashFunction* k) -{ - keyedHashFunctionContextInit(this, k); -} - -keyedHashFunctionContext::~keyedHashFunctionContext() -{ - keyedHashFunctionContextFree(this); -} - -randomGeneratorContext::randomGeneratorContext() -{ - randomGeneratorContextInit(this, randomGeneratorDefault()); -} - -randomGeneratorContext::randomGeneratorContext(const randomGenerator* rng) -{ - randomGeneratorContextInit(this, rng); -} - -randomGeneratorContext::~randomGeneratorContext() -{ - randomGeneratorContextFree(this); -} - -#endif diff --git a/beecrypt/debug.h b/beecrypt/debug.h deleted file mode 100644 index 19376c043..000000000 --- a/beecrypt/debug.h +++ /dev/null @@ -1,13 +0,0 @@ -/** - * To be included after all other includes. - */ -#ifndef H_DEBUG -#define H_DEBUG - -#include <assert.h> - -#ifdef DMALLOC -#include <dmalloc.h> -#endif - -#endif /* H_DEBUG */ diff --git a/beecrypt/dhaes.c b/beecrypt/dhaes.c deleted file mode 100644 index 53dcb8c5c..000000000 --- a/beecrypt/dhaes.c +++ /dev/null @@ -1,345 +0,0 @@ -/* - * Copyright (c) 2000, 2001, 2002 Virtual Unlimited, B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file dhaes.c - * \brief DHAES encryption scheme. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup DL_m DL_dh_m - */ - -#include "system.h" - -#include "dhaes.h" -#include "dlsvdp-dh.h" -#include "blockmode.h" -#include "blockpad.h" - -#include "debug.h" - -/* - * Good combinations will be: - * - * For 64-bit encryption: - * DHAES(MD5, Blowfish, HMAC-MD5) <- best candidate - * DHAES(MD5, Blowfish, HMAC-SHA-1) - * DHAES(MD5, Blowfish, HMAC-SHA-256) - * - * For 96-bit encryption with 64-bit mac: - * DHAES(SHA-1, Blowfish, HMAC-MD5, 96) - * DHAES(SHA-1, Blowfish, HMAC-SHA-1, 96) <- best candidate - * DHAES(SHA-1, Blowfish, HMAC-SHA-256, 96) <- best candidate - * - * For 128-bit encryption: - * DHAES(SHA-256, Blowfish, HMAC-MD5) - * DHAES(SHA-256, Blowfish, HMAC-SHA-1) - * DHAES(SHA-256, Blowfish, HMAC-SHA-256) - */ - -int dhaes_pUsable(const dhaes_pParameters* params) -{ - size_t keybits = (params->hash->digestsize << 3); /* digestsize in bytes times 8 bits */ - size_t cipherkeybits = params->cipherkeybits; - size_t mackeybits = params->mackeybits; - - /* test if keybits is a multiple of 32 */ - if ((keybits & 31) != 0) - return 0; - - /* test if cipherkeybits + mackeybits < keybits */ - if ((cipherkeybits + mackeybits) > keybits) - return 0; - - if (mackeybits == 0) - { - if (cipherkeybits == 0) - cipherkeybits = mackeybits = (keybits >> 1); - else - mackeybits = keybits - cipherkeybits; - } - - /* test if keybits length is appropriate for cipher */ - if ((cipherkeybits < params->cipher->keybitsmin) || - (cipherkeybits > params->cipher->keybitsmax)) - return 0; - - if (((cipherkeybits - params->cipher->keybitsmin) % params->cipher->keybitsinc) != 0) - return 0; - - /* test if keybits length is appropriate for mac */ - if ((mackeybits < params->mac->keybitsmin) || - (params->mackeybits > params->mac->keybitsmax)) - return 0; - - if (((mackeybits - params->mac->keybitsmin) % params->mac->keybitsinc) != 0) - return 0; - - return 1; -} - -int dhaes_pContextInit(dhaes_pContext* ctxt, const dhaes_pParameters* params) -{ - if (ctxt == (dhaes_pContext*) 0) - return -1; - - if (params == (dhaes_pParameters*) 0) - return -1; - - if (params->param == (dldp_p*) 0) - return -1; - - if (params->hash == (hashFunction*) 0) - return -1; - - if (params->cipher == (blockCipher*) 0) - return -1; - - if (params->mac == (keyedHashFunction*) 0) - return -1; - - if (!dhaes_pUsable(params)) - return -1; - - dldp_pInit(&ctxt->param); - dldp_pCopy(&ctxt->param, params->param); - - mpnzero(&ctxt->pub); - mpnzero(&ctxt->pri); - - if (hashFunctionContextInit(&ctxt->hash, params->hash)) - return -1; - - if (blockCipherContextInit(&ctxt->cipher, params->cipher)) - return -1; - - if (keyedHashFunctionContextInit(&ctxt->mac, params->mac)) - return -1; - - ctxt->cipherkeybits = params->cipherkeybits; - ctxt->mackeybits = params->mackeybits; - - return 0; -} - -int dhaes_pContextInitDecrypt(dhaes_pContext* ctxt, const dhaes_pParameters* params, const mpnumber* pri) -{ - if (dhaes_pContextInit(ctxt, params)) - return -1; - - mpncopy(&ctxt->pri, pri); - - return 0; -} - -int dhaes_pContextInitEncrypt(dhaes_pContext* ctxt, const dhaes_pParameters* params, const mpnumber* pub) -{ - if (dhaes_pContextInit(ctxt, params)) - return -1; - - mpncopy(&ctxt->pub, pub); - - return 0; -} - -int dhaes_pContextFree(dhaes_pContext* ctxt) -{ - dldp_pFree(&ctxt->param); - - mpnfree(&ctxt->pub); - mpnfree(&ctxt->pri); - - if (hashFunctionContextFree(&ctxt->hash)) - return -1; - - if (blockCipherContextFree(&ctxt->cipher)) - return -1; - - if (keyedHashFunctionContextFree(&ctxt->mac)) - return -1; - - return 0; -} - -static int dhaes_pContextSetup(dhaes_pContext* ctxt, const mpnumber* private, const mpnumber* public, const mpnumber* message, cipherOperation op) - /*@modifies ctxt @*/ -{ - register int rc; - - mpnumber secret; - - byte* digest = (byte*) malloc(ctxt->hash.algo->digestsize); - - if (digest == (byte*) 0) - return -1; - - /* compute the shared secret, Diffie-Hellman style */ - mpnzero(&secret); - if (dlsvdp_pDHSecret(&ctxt->param, private, public, &secret)) - { - mpnfree(&secret); - free(digest); - return -1; - } - - /* compute the hash of the message (ephemeral public) key and the shared secret */ - - hashFunctionContextReset (&ctxt->hash); - hashFunctionContextUpdateMP(&ctxt->hash, message); - hashFunctionContextUpdateMP(&ctxt->hash, &secret); - hashFunctionContextDigest (&ctxt->hash, digest); - - /* we don't need the secret anymore */ - mpnwipe(&secret); - mpnfree(&secret); - - /* - * NOTE: blockciphers and keyed hash functions take keys with sizes - * specified in bits and key data passed in bytes. - * - * Both blockcipher and keyed hash function have a min and max key size. - * - * This function will split the digest of the shared secret in two halves, - * and pad with zero bits or truncate if necessary to meet algorithm key - * size requirements. - */ - - if (ctxt->hash.algo->digestsize > 0) - { - byte* mackey = digest; - byte* cipherkey = digest + ((ctxt->mackeybits + 7) >> 3); - - if ((rc = keyedHashFunctionContextSetup(&ctxt->mac, mackey, ctxt->mackeybits))) - goto setup_end; - - if ((rc = blockCipherContextSetup(&ctxt->cipher, cipherkey, ctxt->cipherkeybits, op))) - goto setup_end; - - rc = 0; - } - else - rc = -1; - -setup_end: - /* wipe digest for good measure */ - memset(digest, 0, ctxt->hash.algo->digestsize); - free(digest); - - return rc; -} - -memchunk* dhaes_pContextEncrypt(dhaes_pContext* ctxt, mpnumber* ephemeralPublicKey, mpnumber* mac, const memchunk* cleartext, randomGeneratorContext* rng) -{ - memchunk* ciphertext = (memchunk*) 0; - memchunk* paddedtext; - - mpnumber ephemeralPrivateKey; - - /* make the ephemeral keypair */ - mpnzero(&ephemeralPrivateKey); - dldp_pPair(&ctxt->param, rng, &ephemeralPrivateKey, ephemeralPublicKey); - - /* Setup the key and initialize the mac and the blockcipher */ - if (dhaes_pContextSetup(ctxt, &ephemeralPrivateKey, &ctxt->pub, ephemeralPublicKey, ENCRYPT)) - goto encrypt_end; - - /* add pkcs-5 padding */ - paddedtext = pkcs5PadCopy(ctxt->cipher.algo->blocksize, cleartext); - - /* encrypt the memchunk in CBC mode */ - if (blockEncryptCBC(ctxt->cipher.algo, ctxt->cipher.param, (uint32_t*) paddedtext->data, (const uint32_t*) paddedtext->data, paddedtext->size / ctxt->cipher.algo->blocksize)) - { - free(paddedtext->data); - free(paddedtext); - goto encrypt_end; - } - - /* Compute the mac */ - if (keyedHashFunctionContextUpdateMC(&ctxt->mac, paddedtext)) - { - free(paddedtext->data); - free(paddedtext); - goto encrypt_end; - } - - if (keyedHashFunctionContextDigestMP(&ctxt->mac, mac)) - { - free(paddedtext->data); - free(paddedtext); - goto encrypt_end; - } - - ciphertext = paddedtext; - -encrypt_end: - mpnwipe(&ephemeralPrivateKey); - mpnfree(&ephemeralPrivateKey); - - return ciphertext; -} - -memchunk* dhaes_pContextDecrypt(dhaes_pContext* ctxt, const mpnumber* ephemeralPublicKey, const mpnumber* mac, const memchunk* ciphertext) -{ - memchunk* cleartext = (memchunk*) 0; - memchunk* paddedtext; - - /* Setup the key and initialize the mac and the blockcipher */ - if (dhaes_pContextSetup(ctxt, &ctxt->pri, ephemeralPublicKey, ephemeralPublicKey, DECRYPT)) - goto decrypt_end; - - /* Verify the mac */ - if (keyedHashFunctionContextUpdateMC(&ctxt->mac, ciphertext)) - goto decrypt_end; - - if (keyedHashFunctionContextDigestMatch(&ctxt->mac, mac) == 0) - goto decrypt_end; - - /* decrypt the memchunk with CBC mode */ - paddedtext = (memchunk*) calloc(1, sizeof(memchunk)); - - if (paddedtext == (memchunk*) 0) - goto decrypt_end; - - paddedtext->size = ciphertext->size; - paddedtext->data = (byte*) malloc(ciphertext->size); - - if (paddedtext->data == (byte*) 0) - { - free(paddedtext); - goto decrypt_end; - } - - if (blockDecryptCBC(ctxt->cipher.algo, ctxt->cipher.param, (uint32_t*) paddedtext->data, (const uint32_t*) ciphertext->data, paddedtext->size / ctxt->cipher.algo->blocksize)) - { - free(paddedtext->data); - free(paddedtext); - goto decrypt_end; - } - - /* remove pkcs-5 padding */ - cleartext = pkcs5Unpad(ctxt->cipher.algo->blocksize, paddedtext); - - if (cleartext == (memchunk*) 0) - { - free(paddedtext->data); - free(paddedtext); - } - -decrypt_end: - - return cleartext; -} diff --git a/beecrypt/dhaes.h b/beecrypt/dhaes.h deleted file mode 100644 index e67c71890..000000000 --- a/beecrypt/dhaes.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2000, 2001, 2002 Virtual Unlimited, B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file dhaes.h - * \brief DHAES encryption scheme. - * - * This code implements the encryption scheme from the paper: - * - * "DHAES: An Encryption Scheme Based on the Diffie-Hellman Problem" - * Michel Abdalla, Mihir Bellare, Phillip Rogaway - * September 1998 - * - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup DL_m DL_dh_m - */ - -#ifndef _DHAES_H -#define _DHAES_H - -#include "beecrypt.h" -#include "dldp.h" - -typedef struct -{ - const dldp_p* param; - const hashFunction* hash; - const blockCipher* cipher; - const keyedHashFunction* mac; - size_t cipherkeybits; - size_t mackeybits; -} dhaes_pParameters; - -typedef struct -{ - dldp_p param; - mpnumber pub; - mpnumber pri; - hashFunctionContext hash; - blockCipherContext cipher; - keyedHashFunctionContext mac; - size_t cipherkeybits; - size_t mackeybits; -} dhaes_pContext; - -#ifdef __cplusplus -extern "C" { -#endif - -BEECRYPTAPI -int dhaes_pUsable(const dhaes_pParameters* params) - /*@*/; - -BEECRYPTAPI -int dhaes_pContextInit (dhaes_pContext* ctxt, const dhaes_pParameters* params) - /*@modifies ctxt @*/; -BEECRYPTAPI -int dhaes_pContextInitDecrypt(dhaes_pContext* ctxt, const dhaes_pParameters* params, const mpnumber* pri) - /*@modifies ctxt @*/; -BEECRYPTAPI -int dhaes_pContextInitEncrypt(dhaes_pContext* ctxt, const dhaes_pParameters* params, const mpnumber* pub) - /*@modifies ctxt @*/; -BEECRYPTAPI -int dhaes_pContextFree (dhaes_pContext* ctxt) - /*@modifies ctxt @*/; - -BEECRYPTAPI -memchunk* dhaes_pContextEncrypt(dhaes_pContext* ctxt, mpnumber* ephemeralPublicKey, mpnumber* mac, const memchunk* cleartext, randomGeneratorContext* rng) - /*@modifies ctxt, ephemeralPublicKey, mac @*/; -BEECRYPTAPI /*@null@*/ -memchunk* dhaes_pContextDecrypt(dhaes_pContext* ctxt, const mpnumber* ephemeralPublicKey, const mpnumber* mac, const memchunk* ciphertext) - /*@modifies ctxt @*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/dldp.c b/beecrypt/dldp.c deleted file mode 100644 index e323c6e49..000000000 --- a/beecrypt/dldp.c +++ /dev/null @@ -1,469 +0,0 @@ -/* - * Copyright (c) 2000, 2001, 2002, 2003 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file dldp.c - * \brief Discrete Logarithm domain parameters. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup DL_m - */ - -#include "system.h" - -#include "dldp.h" -#include "mp.h" -#include "mpprime.h" - -#include "debug.h" - -/*!\addtogroup DL_m - * \{ - */ -static int dldp_pgoqGenerator_w(dldp_p* dp, randomGeneratorContext* rgc, mpw* wksp) - /*@modifies dp, wksp @*/; -static int dldp_pgonGenerator_w(dldp_p* dp, randomGeneratorContext* rgc, mpw* wksp) - /*@modifies dp, wksp @*/; - -int dldp_pPrivate(const dldp_p* dp, randomGeneratorContext* rgc, mpnumber* x) -{ - /* - * Note: the private key is randomly selected to be smaller than q - * - * This is the variant of Diffie-Hellman as described in IEEE P1363 - */ - - mpbnrnd(&dp->q, rgc, x); - - return 0; -} - -int dldp_pPrivate_s(const dldp_p* dp, randomGeneratorContext* rgc, mpnumber* x, size_t xbits) -{ - /* - * Note: the private key is randomly selected smaller than q with xbits < mpbits(q) - * - */ - - mpbnrnd(&dp->q, rgc, x); - mpntrbits(x, xbits); - - return 0; -} - -int dldp_pPublic(const dldp_p* dp, const mpnumber* x, mpnumber* y) -{ - /* - * Public key y is computed as g^x mod p - */ - - mpbnpowmod(&dp->p, &dp->g, x, y); - - return 0; -} - -int dldp_pPair(const dldp_p* dp, randomGeneratorContext* rgc, mpnumber* x, mpnumber* y) -{ - /* - * Combination of the two previous functions - */ - - mpbnrnd(&dp->q, rgc, x); - mpbnpowmod(&dp->p, &dp->g, x, y); - - return 0; -} - -int dldp_pPair_s(const dldp_p* dp, randomGeneratorContext* rgc, mpnumber* x, mpnumber* y, size_t xbits) -{ - mpbnrnd(&dp->q, rgc, x); - mpntrbits(x, xbits); - mpbnpowmod(&dp->p, &dp->g, x, y); - - return 0; -} - -int dldp_pEqual(const dldp_p* a, const dldp_p* b) -{ - return mpeqx(a->p.size, a->p.modl, b->p.size, b->p.modl) && - mpeqx(a->q.size, a->q.modl, b->q.size, b->q.modl) && - mpeqx(a->g.size, a->g.data, b->g.size, b->g.data); -} - -/* - * needs to make workspace of 8*size+2 - */ -int dldp_pValidate(const dldp_p* dp, randomGeneratorContext* rgc) -{ - register size_t size = dp->p.size; - - register mpw* temp = (mpw*) malloc((8*size+2) * sizeof(mpw)); - - if (temp) - { - /* check that p > 2 and p odd, then run miller-rabin test with t 50 */ - if (mpeven(dp->p.size, dp->p.modl)) - { - free(temp); - return 0; - } - - if (mppmilrab_w(&dp->p, rgc, 50, temp) == 0) - { - free(temp); - return 0; - } - - /* check that q > 2 and q odd, then run miller-rabin test with t 50 */ - if (mpeven(dp->q.size, dp->q.modl)) - { - free(temp); - return 0; - } - - if (mppmilrab_w(&dp->q, rgc, 50, temp) == 0) - { - free(temp); - return 0; - } - - free(temp); - - /* check that 1 < g < p */ - if (mpleone(dp->g.size, dp->g.data)) - return 0; - - if (mpgex(dp->g.size, dp->g.data, dp->p.size, dp->p.modl)) - return 0; - - return 1; - } - return -1; -} - -int dldp_pInit(dldp_p* dp) -{ - mpbzero(&dp->p); - mpbzero(&dp->q); - mpnzero(&dp->g); - mpnzero(&dp->r); - mpbzero(&dp->n); - - return 0; -} - -int dldp_pFree(dldp_p* dp) -{ - mpbfree(&dp->p); - mpbfree(&dp->q); - mpnfree(&dp->g); - mpnfree(&dp->r); - mpbfree(&dp->n); - - return 0; -} - -int dldp_pCopy(dldp_p* dst, const dldp_p* src) -{ - mpbcopy(&dst->p, &src->p); - mpbcopy(&dst->q, &src->q); - mpncopy(&dst->r, &src->r); - mpncopy(&dst->g, &src->g); - mpbcopy(&dst->n, &src->n); - - return 0; -} - -int dldp_pgoqMake(dldp_p* dp, randomGeneratorContext* rgc, size_t pbits, size_t qbits, int cofactor) -{ - /* - * Generate parameters as described by IEEE P1363, A.16.1 - */ - register size_t psize = MP_BITS_TO_WORDS(pbits + MP_WBITS - 1); - register mpw* temp = (mpw*) malloc((8*psize+2) * sizeof(mpw)); - - if (temp) - { - /* first generate q */ - mpprnd_w(&dp->q, rgc, qbits, mpptrials(qbits), (const mpnumber*) 0, temp); - - /* generate p with the appropriate congruences */ - mpprndconone_w(&dp->p, rgc, pbits, mpptrials(pbits), &dp->q, (const mpnumber*) 0, &dp->r, cofactor, temp); - - /* clear n */ - mpbzero(&dp->n); - - /* clear g */ - mpnzero(&dp->g); - - dldp_pgoqGenerator_w(dp, rgc, temp); - - free(temp); - - return 0; - } - - return -1; -} - -int dldp_pgoqMakeSafe(dldp_p* dp, randomGeneratorContext* rgc, size_t bits) -{ - /* - * Generate parameters with a safe prime; p = 2q+1 i.e. r=2 - * - */ - - register size_t size = MP_BITS_TO_WORDS(bits + MP_WBITS - 1); - register mpw* temp = (mpw*) malloc((8*size+2) * sizeof(mpw)); - - if (temp) - { - /* generate p */ - mpprndsafe_w(&dp->p, rgc, bits, mpptrials(bits), temp); - - /* set q */ - mpcopy(size, temp, dp->p.modl); - mpdivtwo(size, temp); - mpbset(&dp->q, size, temp); - - /* set r = 2 */ - mpnsetw(&dp->r, 2); - - /* clear n */ - mpbzero(&dp->n); - - dldp_pgoqGenerator_w(dp, rgc, temp); - - free(temp); - - return 0; - } - return -1; -} - -int dldp_pgoqGenerator_w(dldp_p* dp, randomGeneratorContext* rgc, mpw* wksp) -{ - /* - * Randomly determine a generator over the subgroup with order q - */ - - register size_t size = dp->p.size; - - mpnfree(&dp->g); - mpnsize(&dp->g, size); - - while (1) - { - /* get a random value h (stored into g) */ - mpbrnd_w(&dp->p, rgc, dp->g.data, wksp); - - /* first compute h^r mod p (stored in g) */ - mpbpowmod_w(&dp->p, size, dp->g.data, dp->r.size, dp->r.data, dp->g.data, wksp); - - if (mpisone(size, dp->g.data)) - continue; - - return 0; - } - return -1; -} - -int dldp_pgoqGenerator(dldp_p* dp, randomGeneratorContext* rgc) -{ - register size_t size = dp->p.size; - register mpw* temp = (mpw*) malloc((4*size+2)*sizeof(mpw)); - - if (temp) - { - dldp_pgoqGenerator_w(dp, rgc, temp); - - free(temp); - - return 0; - } - return -1; -} - -int dldp_pgoqValidate(const dldp_p* dp, randomGeneratorContext* rgc, int cofactor) -{ - register int rc = dldp_pValidate(dp, rgc); - - if (rc <= 0) - return rc; - - /* check that g^q mod p = 1 */ - - /* if r != 0, then check that qr+1 = p */ - - /* if cofactor, then check that q does not divide (r) */ - - return 1; -} - -int dldp_pgonMake(dldp_p* dp, randomGeneratorContext* rgc, size_t pbits, size_t qbits) -{ - /* - * Generate parameters with a prime p such that p = qr+1, with q prime, and r = 2s, with s prime - */ - - register size_t psize = MP_BITS_TO_WORDS(pbits + MP_WBITS - 1); - register mpw* temp = (mpw*) malloc((8*psize+2) * sizeof(mpw)); - - if (temp) - { - /* generate q */ - mpprnd_w(&dp->q, rgc, qbits, mpptrials(qbits), (const mpnumber*) 0, temp); - - /* generate p with the appropriate congruences */ - mpprndconone_w(&dp->p, rgc, pbits, mpptrials(pbits), &dp->q, (const mpnumber*) 0, &dp->r, 2, temp); - - /* set n */ - mpbsubone(&dp->p, temp); - mpbset(&dp->n, psize, temp); - - dldp_pgonGenerator_w(dp, rgc, temp); - - free(temp); - - return 0; - } - return -1; -} - -int dldp_pgonMakeSafe(dldp_p* dp, randomGeneratorContext* rgc, size_t pbits) -{ - /* - * Generate parameters with a safe prime; i.e. p = 2q+1, where q is prime - */ - - register size_t psize = MP_BITS_TO_WORDS(pbits + MP_WBITS - 1); - register mpw* temp = (mpw*) malloc((8*psize+2) * sizeof(mpw)); - - if (temp) - { - /* generate safe p */ - mpprndsafe_w(&dp->p, rgc, pbits, mpptrials(pbits), temp); - - /* set n */ - mpbsubone(&dp->p, temp); - mpbset(&dp->n, psize, temp); - - /* set q */ - mpcopy(psize, temp, dp->p.modl); - mpdivtwo(psize, temp); - mpbset(&dp->q, psize, temp); - - /* set r = 2 */ - mpnsetw(&dp->r, 2); - - dldp_pgonGenerator_w(dp, rgc, temp); - - free(temp); - - return 0; - } - return -1; -} - -int dldp_pgonGenerator_w(dldp_p* dp, randomGeneratorContext* rgc, mpw* wksp) -{ - register size_t size = dp->p.size; - - mpnfree(&dp->g); - mpnsize(&dp->g, size); - - while (1) - { - mpbrnd_w(&dp->p, rgc, dp->g.data, wksp); - - if (mpistwo(dp->r.size, dp->r.data)) - { - /* - * A little math here: the only element in the group which has order 2 is (p-1); - * the two group elements raised to power two which result in 1 (mod p) are thus (p-1) and 1 - * - * mpbrnd_w doesn't return 1 or (p-1), so the test where g^2 mod p = 1 can be safely skipped - */ - - /* check g^q mod p*/ - mpbpowmod_w(&dp->p, size, dp->g.data, dp->q.size, dp->q.modl, wksp, wksp+size); - if (mpisone(size, wksp)) - continue; - } - else - { - /* we can either compute g^r, g^2q and g^(qr/2) or - * we first compute s = r/2, and then compute g^2s, g^2q and g^qs - * - * hence we first compute t = g^s - * then compute t^2 mod p, and test if one - * then compute t^q mod p, and test if one - * then compute (g^q mod p)^2 mod p, and test if one - */ - - /* compute s = r/2 */ - mpsetx(size, wksp, dp->r.size, dp->r.data); - mpdivtwo(size, wksp); - - /* compute t = g^s mod p */ - mpbpowmod_w(&dp->p, size, dp->g.data, size, wksp, wksp+size, wksp+2*size); - /* compute t^2 mod p = g^2s mod p = g^r mod p*/ - mpbsqrmod_w(&dp->p, size, wksp+size, wksp+size, wksp+2*size); - if (mpisone(size, wksp+size)) - continue; - - /* compute t^q mod p = g^qs mod p */ - mpbpowmod_w(&dp->p, size, wksp, dp->q.size, dp->q.modl, wksp+size, wksp+2*size); - if (mpisone(size, wksp+size)) - continue; - - /* compute g^2q mod p */ - mpbpowmod_w(&dp->p, size, dp->g.data, dp->q.size, dp->q.modl, wksp, wksp+size); - mpbsqrmod_w(&dp->p, size, wksp, wksp+size, wksp+2*size); - if (mpisone(size, wksp+size)) - continue; - } - - return 0; - } - - return -1; -} - -int dldp_pgonGenerator(dldp_p* dp, randomGeneratorContext* rgc) -{ - register size_t psize = dp->p.size; - register mpw* temp = (mpw*) malloc((8*psize+2) * sizeof(mpw)); - - if (temp) - { - dldp_pgonGenerator_w(dp, rgc, temp); - - free(temp); - - return 0; - } - return -1; -} - -int dldp_pgonValidate(const dldp_p* dp, randomGeneratorContext* rgc) -{ - return dldp_pValidate((const dldp_p*) dp, rgc); -} - -/*!\} - */ diff --git a/beecrypt/dldp.h b/beecrypt/dldp.h deleted file mode 100644 index d576e1234..000000000 --- a/beecrypt/dldp.h +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (c) 2000, 2001, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file dldp.h - * \brief Discrete Logarithm domain parameters, headers. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup DL_m - */ - -#ifndef _DLDP_H -#define _DLDP_H - -#include "mpbarrett.h" - -/* - * Discrete Logarithm Domain Parameters - Prime - * - * Standard definition where p = qr+1; in case where p=2q+1, r=2 - * - * In IEEE P1363 naming is p = rk+1 - * - * Hence, IEEE prime r = q and cofactor k = r - * - * Make sure q is large enough to foil Pohlig-Hellman attacks - * See: "Handbook of Applied Cryptography", Chapter 3.6.4 - * - * g is either a generator of a subgroup of order q, or a generator of order - * n = (p-1) - */ - -/*!\brief Discrete Logarithm Domain Parameters over a prime field. - * - * For the variables in this structure /f$p=qr+1/f$; if /f$p=2q+1 then r=2/f$. - * - * \ingroup DL_m - */ -#ifdef __cplusplus -struct BEECRYPTAPI dldp_p -#else -struct _dldp_p -#endif -{ - /*!\var p - * \brief The prime. - * - */ - mpbarrett p; - /*!\var q - * \brief The cofactor. - * - * \f$q\f$ is a prime divisor of \f$p-1\f$. - */ - mpbarrett q; - /*!\var r - * - * \f$p=qr+1\f$ - */ - mpnumber r; - /*!\var g - * \brief The generator. - * - * \f$g\f$ is either a generator of \f$\mathds{Z}^{*}_p\f$, or a generator - * of a cyclic subgroup \f$G\f$ of \f$\mathds{Z}^{*}_p\f$ of order \f$q\f$. - */ - mpnumber g; - /*!\var n - * - * \f$n=p-1=qr\f$ - */ - mpbarrett n; -#ifdef __cplusplus - dldp_p(); - dldp_p(const dldp_p&); - ~dldp_p(); -#endif -}; - -#ifndef __cplusplus -typedef struct _dldp_p dldp_p; -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Functions for setting up and copying - */ - -BEECRYPTAPI -int dldp_pInit(dldp_p* dp) - /*@modifies dp @*/; -BEECRYPTAPI -int dldp_pFree(dldp_p* dp) - /*@modifies dp @*/; -BEECRYPTAPI -int dldp_pCopy(dldp_p* dst, const dldp_p* src) - /*@modifies dst @*/; - -/* - * Functions for generating keys - */ - -BEECRYPTAPI -int dldp_pPrivate (const dldp_p* dp, randomGeneratorContext* rgc, mpnumber* wksp) - /*@modifies wksp @*/; -BEECRYPTAPI -int dldp_pPrivate_s(const dldp_p* dp, randomGeneratorContext* rgc, mpnumber* x, size_t xbits) - /*@modifies x @*/; -BEECRYPTAPI -int dldp_pPublic (const dldp_p* dp, const mpnumber* x, mpnumber* y) - /*@modifies y @*/; -BEECRYPTAPI -int dldp_pPair (const dldp_p* dp, randomGeneratorContext* rgc, mpnumber* x, mpnumber* y) - /*@modifies x, y @*/; -BEECRYPTAPI -int dldp_pPair_s (const dldp_p* dp, randomGeneratorContext* rgc, mpnumber* x, mpnumber* y, size_t xbits) - /*@modifies x, y @*/; - -/* - * Function for comparing domain parameters - */ - -BEECRYPTAPI -int dldp_pEqual (const dldp_p* a, const dldp_p* b) - /*@*/; - -/* - * Functions for generating and validating dldp_pgoq variant domain parameters - */ - -BEECRYPTAPI -int dldp_pgoqMake (dldp_p* dp, randomGeneratorContext* rgc, size_t pbits, size_t qbits, int cofactor) - /*@modifies dp @*/; -BEECRYPTAPI -int dldp_pgoqMakeSafe (dldp_p* dp, randomGeneratorContext* rgc, size_t bits) - /*@modifies dp @*/; -BEECRYPTAPI -int dldp_pgoqGenerator(dldp_p* dp, randomGeneratorContext* rgc) - /*@modifies dp @*/; -BEECRYPTAPI -int dldp_pgoqValidate (const dldp_p* dp, randomGeneratorContext* rgc, int cofactor) - /*@*/; - -/* - * Functions for generating and validating dldp_pgon variant domain parameters - */ - -BEECRYPTAPI -int dldp_pgonMake (dldp_p* dp, randomGeneratorContext* rgc, size_t pbits, size_t qbits) - /*@modifies dp @*/; -BEECRYPTAPI -int dldp_pgonMakeSafe (dldp_p* dp, randomGeneratorContext* rgc, size_t pbits) - /*@modifies dp @*/; -BEECRYPTAPI -int dldp_pgonGenerator(dldp_p* dp, randomGeneratorContext* rgc) - /*@modifies dp @*/; -BEECRYPTAPI -int dldp_pgonValidate (const dldp_p* dp, randomGeneratorContext* rgc) - /*@*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/dlkp.c b/beecrypt/dlkp.c deleted file mode 100644 index 6ff310210..000000000 --- a/beecrypt/dlkp.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2000, 2001, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file dlkp.c - * \brief Discrete Logarithm keypair. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup DL_m - */ - -#include "system.h" - -#include "dlkp.h" - -#include "debug.h" - -int dlkp_pPair(dlkp_p* kp, randomGeneratorContext* rgc, const dldp_p* param) -{ - /* copy the parameters */ - if (dldp_pCopy(&kp->param, param) < 0) - return -1; - - if (dldp_pPair(param, rgc, &kp->x, &kp->y) < 0) - return -1; - - return 0; -} - -int dlkp_pInit(dlkp_p* kp) -{ - if (dldp_pInit(&kp->param) < 0) - return -1; - - mpnzero(&kp->y); - mpnzero(&kp->x); - - return 0; -} - -int dlkp_pFree(dlkp_p* kp) -{ - if (dldp_pFree(&kp->param) < 0) - return -1; - - mpnfree(&kp->y); - /* wipe secret key before freeing */ - mpnwipe(&kp->x); - mpnfree(&kp->x); - - return 0; -} - -int dlkp_pCopy(dlkp_p* dst, const dlkp_p* src) -{ - if (dldp_pCopy(&dst->param, &src->param) < 0) - return -1; - - mpncopy(&dst->y, &src->y); - mpncopy(&dst->x, &src->x); - - return 0; -} diff --git a/beecrypt/dlkp.h b/beecrypt/dlkp.h deleted file mode 100644 index 69c574f47..000000000 --- a/beecrypt/dlkp.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2000, 2001, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file dlkp.h - * \brief Discrete Logarithm keypair, headers. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup DL_m - */ - -#ifndef _DLKP_H -#define _DLKP_H - -#include "dlpk.h" - -/*!\ingroup DL_m - */ -#ifdef __cplusplus -struct BEECRYPTAPI dlkp_p -#else -struct _dlkp_p -#endif -{ - dldp_p param; - mpnumber y; - mpnumber x; - - #ifdef __cplusplus - dlkp_p(); - dlkp_p(const dlkp_p&); - ~dlkp_p(); - #endif -}; - -#ifndef __cplusplus -typedef struct _dlkp_p dlkp_p; -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -BEECRYPTAPI -int dlkp_pPair(dlkp_p* kp, randomGeneratorContext* rgc, const dldp_p* param) - /*@modifies kp @*/; -BEECRYPTAPI -int dlkp_pInit(dlkp_p* kp) - /*@modifies kp @*/; -BEECRYPTAPI -int dlkp_pFree(dlkp_p* kp) - /*@modifies kp @*/; -BEECRYPTAPI -int dlkp_pCopy(dlkp_p* dst, const dlkp_p* src) - /*@modifies dst @*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/dlpk.c b/beecrypt/dlpk.c deleted file mode 100644 index 8ce645aa7..000000000 --- a/beecrypt/dlpk.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2000, 2001, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file dlpk.h - * \brief Discrete Logarithm public key. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup DL_m - */ - -#include "system.h" - -#include "dlpk.h" -#include "mp.h" - -#include "debug.h" - -/*!\addtogroup DL_m - * \{ - */ - -int dlpk_pInit(dlpk_p* pk) -{ - if (dldp_pInit(&pk->param) < 0) - return -1; - - mpnzero(&pk->y); - - return 0; -} - -int dlpk_pFree(dlpk_p* pk) -{ - if (dldp_pFree(&pk->param) < 0) - return -1; - - mpnfree(&pk->y); - - return 0; -} - -int dlpk_pCopy(dlpk_p* dst, const dlpk_p* src) -{ - if (dldp_pCopy(&dst->param, &src->param) < 0) - return -1; - - mpncopy(&dst->y, &src->y); - - return 0; -} - -int dlpk_pEqual(const dlpk_p* a, const dlpk_p* b) -{ - return dldp_pEqual(&a->param, &b->param) && - mpeqx(a->y.size, a->y.data, b->y.size, b->y.data); -} - -int dlpk_pgoqValidate(const dlpk_p* pk, randomGeneratorContext* rgc, int cofactor) -{ - register int rc = dldp_pgoqValidate(&pk->param, rgc, cofactor); - - if (rc <= 0) - return rc; - - if (mpleone(pk->y.size, pk->y.data)) - return 0; - - if (mpgex(pk->y.size, pk->y.data, pk->param.p.size, pk->param.p.modl)) - return 0; - - return 1; -} - -int dlpk_pgonValidate(const dlpk_p* pk, randomGeneratorContext* rgc) -{ - register int rc = dldp_pgonValidate(&pk->param, rgc); - - if (rc <= 0) - return rc; - - if (mpleone(pk->y.size, pk->y.data)) - return 0; - - if (mpgex(pk->y.size, pk->y.data, pk->param.p.size, pk->param.p.modl)) - return 0; - - return 1; -} - -/*!\} - */ diff --git a/beecrypt/dlpk.h b/beecrypt/dlpk.h deleted file mode 100644 index 4eb4f631a..000000000 --- a/beecrypt/dlpk.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2000, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file dlpk.h - * \brief Discrete Logarithm public key, headers. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup DL_m - */ - -#ifndef _DLPK_H -#define _DLPK_H - -#include "dldp.h" - -/*!\ingroup DL_m - */ -#ifdef __cplusplus -struct BEECRYPTAPI dlpk_p -#else -struct _dlpk_p -#endif -{ - dldp_p param; - mpnumber y; -#ifdef __cplusplus - dlpk_p(); - dlpk_p(const dlpk_p&); - ~dlpk_p(); -#endif -}; - -#ifndef __cplusplus -typedef struct _dlpk_p dlpk_p; -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -BEECRYPTAPI -int dlpk_pInit(dlpk_p* pk) - /*@modifies pk @*/; -BEECRYPTAPI -int dlpk_pFree(dlpk_p* pk) - /*@modifies pk @*/; -BEECRYPTAPI -int dlpk_pCopy(dlpk_p* dst, const dlpk_p* src) - /*@modifies dst @*/; - -BEECRYPTAPI -int dlpk_pEqual(const dlpk_p* a, const dlpk_p* b) - /*@*/; - -BEECRYPTAPI -int dlpk_pgoqValidate(const dlpk_p* pk, randomGeneratorContext* rgc, int cofactor) - /*@*/; -BEECRYPTAPI -int dlpk_pgonValidate(const dlpk_p* pk, randomGeneratorContext* rgc) - /*@*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/dlsvdp-dh.c b/beecrypt/dlsvdp-dh.c deleted file mode 100644 index 5f5636495..000000000 --- a/beecrypt/dlsvdp-dh.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 1999, 2000, 2001, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file dlsvdp-dh.c - * \brief Diffie-Hellman algorithm. - * - * The IEEE P.1363 designation is: - * Discrete Logarithm Secret Value Derivation Primitive, Diffie-Hellman style. - * - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup DL_m DL_dh_m - */ - -#include "system.h" - -#include "dlsvdp-dh.h" - -#include "debug.h" - -/*!\addtogroup DL_dh_m - * \{ - */ - -/*!\fn dlsvdp_pDHSecret(const dhparam* dp, const mpnumber* x, const mpnumber* y, mpnumber* s) - * \brief Computes the shared secret. - * - * Equation: - * - * \li \f$s=y^{x}\ \textrm{mod}\ p\f$ - * - * \param dp The domain parameters. - * \param x The private value. - * \param y The public value (of the peer). - * \param s The computed secret value. - * - * \retval 0 on success. - * \retval -1 on failure. - */ -int dlsvdp_pDHSecret(const dhparam* dp, const mpnumber* x, const mpnumber* y, mpnumber* s) -{ - mpbnpowmod(&dp->p, y, x, s); - - return 0; -} - -/*!\} - */ diff --git a/beecrypt/dlsvdp-dh.h b/beecrypt/dlsvdp-dh.h deleted file mode 100644 index 7b4b8ed04..000000000 --- a/beecrypt/dlsvdp-dh.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2000, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file dlsvdp-dh.h - * \brief Diffie-Hellman algorithm, headers. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup DL_m DL_dh_m - */ - -#ifndef _DLSVDP_DH_H -#define _DLSVDP_DH_H - -#include "dldp.h" -#include "dlkp.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef dldp_p dhparam; -typedef dlkp_p dhkp; - -BEECRYPTAPI -int dlsvdp_pDHSecret(const dhparam* dp, const mpnumber* x, const mpnumber* y, mpnumber* s) - /*@modifies s @*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/docs/.cvsignore b/beecrypt/docs/.cvsignore deleted file mode 100644 index 540cfea1a..000000000 --- a/beecrypt/docs/.cvsignore +++ /dev/null @@ -1,19 +0,0 @@ -.deps -.depend -.depend-done -.libs -Makefile -Makefile.in -config.cache -config.guess -config.log -config.status -config.sub -configure -libtool -ltconfig -ltmain.sh -*.o -*.lo -stamp-h -stamp-h.in diff --git a/beecrypt/docs/Makefile.am b/beecrypt/docs/Makefile.am deleted file mode 100644 index 797486c24..000000000 --- a/beecrypt/docs/Makefile.am +++ /dev/null @@ -1,23 +0,0 @@ -# -# Makefile.am's purpose is to add the documentation html files to the dist -# -# Copyright (c) 2001 Virtual Unlimited B.V. -# -# Author: Bob Deblier <bob@virtualunlimited.com> -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# - -AUTOMAKE_OPTIONS = gnu no-dependencies diff --git a/beecrypt/dsa.c b/beecrypt/dsa.c deleted file mode 100644 index 3b266f66b..000000000 --- a/beecrypt/dsa.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (c) 2001, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file dsa.c - * \brief Digital Signature Algorithm. - * \ingroup DL_m DL_dsa_m - */ - -#include "system.h" - -#include "dsa.h" -#include "dldp.h" -#include "mp.h" - -#include "debug.h" - -int dsasign(const mpbarrett* p, const mpbarrett* q, const mpnumber* g, randomGeneratorContext* rgc, const mpnumber* hm, const mpnumber* x, mpnumber* r, mpnumber* s) -{ - register size_t psize = p->size; - register size_t qsize = q->size; - - register mpw* ptemp; - register mpw* qtemp; - - register mpw* pwksp; - register mpw* qwksp; - - register int rc = -1; - - ptemp = (mpw*) malloc((5*psize+2)*sizeof(mpw)); - if (ptemp == (mpw*) 0) - return rc; - - qtemp = (mpw*) malloc((9*qsize+6)*sizeof(mpw)); - if (qtemp == (mpw*) 0) - { - free(ptemp); - return rc; - } - - pwksp = ptemp+psize; - qwksp = qtemp+3*qsize; - - /* allocate r */ - mpnfree(r); - mpnsize(r, qsize); - - /* get a random k, invertible modulo q; store k @ qtemp, inv(k) @ qtemp+qsize */ - mpbrndinv_w(q, rgc, qtemp, qtemp+qsize, qwksp); - - /* g^k mod p */ - mpbpowmod_w(p, g->size, g->data, qsize, qtemp, ptemp, pwksp); - - /* (g^k mod p) mod q - simple modulo */ - mpmod(qtemp+2*qsize, psize, ptemp, qsize, q->modl, pwksp); - mpcopy(qsize, r->data, qtemp+psize+qsize); - - /* allocate s */ - mpnfree(s); - mpnsize(s, qsize); - - /* x*r mod q */ - mpbmulmod_w(q, x->size, x->data, r->size, r->data, qtemp, qwksp); - - /* add h(m) mod q */ - mpbaddmod_w(q, qsize, qtemp, hm->size, hm->data, qtemp+2*qsize, qwksp); - - /* multiply inv(k) mod q */ - mpbmulmod_w(q, qsize, qtemp+qsize, qsize, qtemp+2*qsize, s->data, qwksp); - - rc = 0; - - free(qtemp); - free(ptemp); - - return rc; -} - -int dsavrfy(const mpbarrett* p, const mpbarrett* q, const mpnumber* g, const mpnumber* hm, const mpnumber* y, const mpnumber* r, const mpnumber* s) -{ - register size_t psize = p->size; - register size_t qsize = q->size; - - register mpw* ptemp; - register mpw* qtemp; - - register mpw* pwksp; - register mpw* qwksp; - - register int rc = 0; - - if (mpz(r->size, r->data)) - return rc; - - if (mpgex(r->size, r->data, qsize, q->modl)) - return rc; - - if (mpz(s->size, s->data)) - return rc; - - if (mpgex(s->size, s->data, qsize, q->modl)) - return rc; - - ptemp = (mpw*) malloc((6*psize+2)*sizeof(mpw)); - if (ptemp == (mpw*) 0) - return rc; - - qtemp = (mpw*) malloc((8*qsize+6)*sizeof(mpw)); - if (qtemp == (mpw*) 0) - { - free(ptemp); - return rc; - } - - pwksp = ptemp+2*psize; - qwksp = qtemp+2*qsize; - - mpsetx(qsize, qtemp+qsize, s->size, s->data); - - /* compute w = inv(s) mod q */ - if (mpextgcd_w(qsize, q->modl, qtemp+qsize, qtemp, qwksp)) - { - /* compute u1 = h(m)*w mod q */ - mpbmulmod_w(q, hm->size, hm->data, qsize, qtemp, qtemp+qsize, qwksp); - - /* compute u2 = r*w mod q */ - mpbmulmod_w(q, r->size, r->data, qsize, qtemp, qtemp, qwksp); - - /* compute g^u1 mod p */ - mpbpowmod_w(p, g->size, g->data, qsize, qtemp+qsize, ptemp, pwksp); - - /* compute y^u2 mod p */ - mpbpowmod_w(p, y->size, y->data, qsize, qtemp, ptemp+psize, pwksp); - - /* multiply mod p */ - mpbmulmod_w(p, psize, ptemp, psize, ptemp+psize, ptemp, pwksp); - - /* modulo q */ - mpmod(ptemp+psize, psize, ptemp, qsize, q->modl, pwksp); - - rc = mpeqx(r->size, r->data, psize, ptemp+psize); - } - - free(qtemp); - free(ptemp); - - return rc; -} - -int dsaparamMake(dsaparam* dp, randomGeneratorContext* rgc, size_t psize) -{ - /* psize must be >= 512 and <= 1024 */ - if ((psize < 512) || (psize > 1024)) - return -1; - - /* psize must be a multiple of 64 */ - if ((psize & 0x3f) != 0) - return -1; - - return dldp_pgoqMake(dp, rgc, psize, 160, 1); -} diff --git a/beecrypt/dsa.h b/beecrypt/dsa.h deleted file mode 100644 index 138d3593e..000000000 --- a/beecrypt/dsa.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2001, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file dsa.h - * \brief Digital Signature Algorithm, as specified by NIST FIPS 186. - * - * FIPS 186 specifies the DSA algorithm as having a large prime \f$p\f$, - * a cofactor \f$q\f$ and a generator \f$g\f$ of a subgroup of - * \f$\mathds{Z}^{*}_p\f$ with order \f$q\f$. The private and public key - * values are \f$x\f$ and \f$y\f$ respectively. - * - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup DL_dsa_m - */ - -#ifndef _DSA_H -#define _DSA_H - -#include "dlkp.h" - -typedef dldp_p dsaparam; -typedef dlpk_p dsapub; -typedef dlkp_p dsakp; - -#ifdef __cplusplus -extern "C" { -#endif - -/*!\fn int dsasign(const mpbarrett* p, const mpbarrett* q, const mpnumber* g, randomGeneratorContext* rgc, const mpnumber* hm, const mpnumber* x, mpnumber* r, mpnumber* s) - * \brief This function performs a raw DSA signature. - * - * Signing equations: - * - * \li \f$r=(g^{k}\ \textrm{mod}\ p)\ \textrm{mod}\ q\f$ - * \li \f$s=k^{-1}(h(m)+xr)\ \textrm{mod}\ q\f$ - * - * \param p The prime. - * \param q The cofactor. - * \param g The generator. - * \param rgc The pseudo-random generator context. - * \param hm The hash to be signed. - * \param x The private key value. - * \param r The signature's \e r value. - * \param s The signature's \e s value. - * \retval 0 on success. - * \retval -1 on failure. - */ -BEECRYPTAPI -int dsasign(const mpbarrett* p, const mpbarrett* q, const mpnumber* g, randomGeneratorContext*, const mpnumber* hm, const mpnumber* x, mpnumber* r, mpnumber* s) - /*@modifies r, s @*/; - -/*!\fn int dsavrfy(const mpbarrett* p, const mpbarrett* q, const mpnumber* g, const mpnumber* hm, const mpnumber* y, const mpnumber* r, const mpnumber* s) - * \brief This function performs a raw DSA verification. - * - * Verifying equations: - * \li Check \f$0<r<q\f$ and \f$0<s<q\f$ - * \li \f$w=s^{-1}\ \textrm{mod}\ q\f$ - * \li \f$u_1=w \cdot h(m)\ \textrm{mod}\ q\f$ - * \li \f$u_2=rw\ \textrm{mod}\ q\f$ - * \li \f$v=(g^{u_1}y^{u_2}\ \textrm{mod}\ p)\ \textrm{mod}\ q\f$ - * \li Check \f$v=r\f$ - * - * \param p The prime. - * \param q The cofactor. - * \param g The generator. - * \param hm The digest to be verified. - * \param y The public key value. - * \param r The signature's \e r value. - * \param s The signature's \e s value. - * \retval 1 on success. - * \retval 0 on failure. - */ -BEECRYPTAPI -int dsavrfy(const mpbarrett* p, const mpbarrett* q, const mpnumber* g, const mpnumber* hm, const mpnumber* y, const mpnumber* r, const mpnumber* s) - /*@*/; - -/*!\fn int dsaparamMake(dsaparam* dp, randomGeneratorContext* rgc, size_t psize) - * \brief This function generates a set of DSA parameters. - * - * This function calls dldp_pgoqMake with appropriate parameters, i.e. - * qsize = 160 bits and cofactor = 1. - * - * \param dp The parameters to be generated. - * \param rgc The random generator context. - * \param psize The size of prime parameter p; psize must be >= 512 and <= 1024, and be a multiple of 64. - * \retval 0 on success. - * \retval -1 on failure. - */ -BEECRYPTAPI -int dsaparamMake(dsaparam* dp, randomGeneratorContext* rgc, size_t psize) - /*@modifies dp @*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/elgamal.c b/beecrypt/elgamal.c deleted file mode 100644 index 3453fa815..000000000 --- a/beecrypt/elgamal.c +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright (c) 1999, 2000, 2001, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file elgamal.c - * \brief ElGamal algorithm. - * \author Bob Deblier <bob.deblier@pandora.be> - */ - -#include "system.h" - -#include "elgamal.h" -#include "dldp.h" -#include "mp.h" - -#include "debug.h" - -int elgv1sign(const mpbarrett* p, const mpbarrett* n, const mpnumber* g, randomGeneratorContext* rgc, const mpnumber* hm, const mpnumber* x, mpnumber* r, mpnumber* s) -{ - register size_t size = p->size; - register mpw* temp = (mpw*) malloc((8*size+6)*sizeof(mpw)); - - if (temp) - { - /* get a random k, invertible modulo (p-1) */ - mpbrndinv_w(n, rgc, temp, temp+size, temp+2*size); - - /* compute r = g^k mod p */ - mpnfree(r); - mpnsize(r, size); - mpbpowmod_w(p, g->size, g->data, size, temp, r->data, temp+2*size); - - /* compute x*r mod n */ - mpbmulmod_w(n, x->size, x->data, r->size, r->data, temp, temp+2*size); - - /* compute -(x*r) mod n */ - mpneg(size, temp); - mpadd(size, temp, n->modl); - - /* compute h(m) - x*r mod n */ - mpbaddmod_w(n, hm->size, hm->data, size, temp, temp, temp+2*size); - - /* compute s = inv(k)*(h(m) - x*r) mod n */ - mpnfree(s); - mpnsize(s, size); - mpbmulmod_w(n, size, temp, size, temp+size, s->data, temp+2*size); - - free(temp); - - return 0; - } - return -1; -} - -int elgv1vrfy(const mpbarrett* p, const mpbarrett* n, const mpnumber* g, const mpnumber* hm, const mpnumber* y, const mpnumber* r, const mpnumber* s) -{ - register size_t size = p->size; - register mpw* temp; - - if (mpz(r->size, r->data)) - return 0; - - if (mpgex(r->size, r->data, size, p->modl)) - return 0; - - if (mpz(s->size, s->data)) - return 0; - - if (mpgex(s->size, s->data, n->size, n->modl)) - return 0; - - temp = (mpw*) malloc((6*size+2)*sizeof(mpw)); - - if (temp) - { - register int rc; - - /* compute u1 = y^r mod p */ - mpbpowmod_w(p, y->size, y->data, r->size, r->data, temp, temp+2*size); - - /* compute u2 = r^s mod p */ - mpbpowmod_w(p, r->size, r->data, s->size, s->data, temp+size, temp+2*size); - - /* compute v1 = u1*u2 mod p */ - mpbmulmod_w(p, size, temp, size, temp+size, temp+size, temp+2*size); - - /* compute v2 = g^h(m) mod p */ - mpbpowmod_w(p, g->size, g->data, hm->size, hm->data, temp, temp+2*size); - - rc = mpeq(size, temp, temp+size); - - free(temp); - - return rc; - } - return 0; -} - -int elgv3sign(const mpbarrett* p, const mpbarrett* n, const mpnumber* g, randomGeneratorContext* rgc, const mpnumber* hm, const mpnumber* x, mpnumber* r, mpnumber* s) -{ - register size_t size = p->size; - register mpw* temp = (mpw*) malloc((6*size+2)*sizeof(mpw)); - - if (temp) - { - /* get a random k */ - mpbrnd_w(p, rgc, temp, temp+2*size); - - /* compute r = g^k mod p */ - mpnfree(r); - mpnsize(r, size); - mpbpowmod_w(p, g->size, g->data, size, temp, r->data, temp+2*size); - - /* compute u1 = x*r mod n */ - mpbmulmod_w(n, x->size, x->data, size, r->data, temp+size, temp+2*size); - - /* compute u2 = k*h(m) mod n */ - mpbmulmod_w(n, size, temp, hm->size, hm->data, temp, temp+2*size); - - /* compute s = u1+u2 mod n */ - mpnfree(s); - mpnsize(s, n->size); - mpbaddmod_w(n, size, temp, size, temp+size, s->data, temp+2*size); - - free(temp); - - return 0; - } - return -1; -} - -int elgv3vrfy(const mpbarrett* p, const mpbarrett* n, const mpnumber* g, const mpnumber* hm, const mpnumber* y, const mpnumber* r, const mpnumber* s) -{ - register size_t size = p->size; - register mpw* temp; - - if (mpz(r->size, r->data)) - return 0; - - if (mpgex(r->size, r->data, size, p->modl)) - return 0; - - if (mpz(s->size, s->data)) - return 0; - - if (mpgex(s->size, s->data, n->size, n->modl)) - return 0; - - temp = (mpw*) malloc((6*size+2)*sizeof(mpw)); - - if (temp) - { - register int rc; - - /* compute u1 = y^r mod p */ - mpbpowmod_w(p, y->size, y->data, r->size, r->data, temp, temp+2*size); - - /* compute u2 = r^h(m) mod p */ - mpbpowmod_w(p, r->size, r->data, hm->size, hm->data, temp+size, temp+2*size); - - /* compute v2 = u1*u2 mod p */ - mpbmulmod_w(p, size, temp, size, temp+size, temp+size, temp+2*size); - - /* compute v1 = g^s mod p */ - mpbpowmod_w(p, g->size, g->data, s->size, s->data, temp, temp+2*size); - - rc = mpeq(size, temp, temp+size); - - free(temp); - - return rc; - } - return 0; -} - -/*!\} - */ diff --git a/beecrypt/elgamal.h b/beecrypt/elgamal.h deleted file mode 100644 index 5f68cceb5..000000000 --- a/beecrypt/elgamal.h +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) 2000, 2001, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file elgamal.h - * \brief ElGamal algorithm. - * - * For more information on this algorithm, see: - * "Handbook of Applied Cryptography", - * 11.5.2: "The ElGamal signature scheme", p. 454-459 - * - * Two of the signature variants in Note 11.70 are implemented. - * - * \todo Implement ElGamal encryption and decryption. - * - * \todo Explore the possibility of using simultaneous multiple exponentiation, - * as described in HAC, 14.87 (iii). - * - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup DL_m DL_elgamal_m - */ - -#ifndef _ELGAMAL_H -#define _ELGAMAL_H - -#include "mpbarrett.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/*!\fn int elgv1sign(const mpbarrett* p, const mpbarrett* n, const mpnumber* g, -randomGeneratorContext* rgc, const mpnumber* hm, const mpnumber* x, mpnumber* r, - mpnumber* s) - * \brief This function performs raw ElGamal signing, variant 1. - * - * Signing equations: - * - * \li \f$r=g^{k}\ \textrm{mod}\ p\f$ - * \li \f$s=k^{-1}(h(m)-xr)\ \textrm{mod}\ (p-1)\f$ - * - * \param p The prime. - * \param n The reducer mod (p-1). - * \param g The generator. - * \param rgc The pseudo-random generat - * \param hm The hash to be signed. - * \param x The private key value. - * \param r The signature's \e r value. - * \param s The signature's \e s value. - * \retval 0 on success. - * \retval -1 on failure. - */ -BEECRYPTAPI -int elgv1sign(const mpbarrett* p, const mpbarrett* n, const mpnumber* g, randomGeneratorContext*, const mpnumber* hm, const mpnumber* x, mpnumber* r, mpnumber* s) - /*@modifies r, s @*/; - -/*!\fn int elgv1vrfy(const mpbarrett* p, const mpbarrett* n, const mpnumber* g, const mpnumber* hm, const mpnumber* y, const mpnumber* r, const mpnumber* s) - * \brief This function performs raw ElGamal verification, variant 1. - * - * Verifying equations: - * - * \li Check \f$0<r<p\f$ and \f$0<s<(p-1)\f$ - * \li \f$v_1=y^{r}r^{s}\ \textrm{mod}\ p\f$ - * \li \f$v_2=g^{h(m)}\ \textrm{mod}\ p\f$ - * \li Check \f$v_1=v_2\f$ - * - * \param p The prime. - * \param n The reducer mod (p-1). - * \param g The generator. - * \param hm The hash to be signed. - * \param y The public key value. - * \param r The signature's \e r value. - * \param s The signature's \e s value. - * \retval 1 on success. - * \retval 0 on failure. - */ -BEECRYPTAPI -int elgv3sign(const mpbarrett* p, const mpbarrett* n, const mpnumber* g, randomGeneratorContext*, const mpnumber* hm, const mpnumber* x, mpnumber* r, mpnumber* s) - /*@modifies r, s @*/; - -/*!\fn int elgv3sign(const mpbarrett* p, const mpbarrett* n, const mpnumber* g, randomGeneratorContext* rgc, const mpnumber* hm, const mpnumber* x, mpnumber* r, mpnumber* s) - * \brief This function performs raw ElGamal signing, variant 3. - * - * Signing equations: - * - * \li \f$r=g^{k}\ \textrm{mod}\ p\f$ - * \li \f$s=xr+kh(m)\ \textrm{mod}\ (p-1)\f$ - * - * \param p The prime. - * \param n The reducer mod (p-1). - * \param g The generator. - * \param rgc The pseudo-random generat - * \param hm The hash to be signed. - * \param x The private key value. - * \param r The signature's \e r value. - * \param s The signature's \e s value. - * \retval 0 on success. - * \retval -1 on failure. - */ -BEECRYPTAPI -int elgv1vrfy(const mpbarrett* p, const mpbarrett* n, const mpnumber* g, const mpnumber* hm, const mpnumber* y, const mpnumber* r, const mpnumber* s) - /*@*/; - -/*!\fn int elgv3vrfy(const mpbarrett* p, const mpbarrett* n, const mpnumber* g, const mpnumber* hm, const mpnumber* y, const mpnumber* r, const mpnumber* s) - * \brief This function performs raw ElGamal verification, variant 3. - * - * Verifying equations: - * - * \li Check \f$0<r<p\f$ and \f$0<s<(p-1)\f$ - * \li \f$v_1=g^{s}\ \textrm{mod}\ p\f$ - * \li \f$v_2=y^{r}r^{h(m)}\ \textrm{mod}\ p\f$ - * \li Check \f$v_1=v_2\f$ - * - * \param p The prime. - * \param n The reducer mod (p-1). - * \param g The generator. - * \param hm The hash to be signed. - * \param y The public key value. - * \param r The signature's \e r value. - * \param s The signature's \e s value. - * \retval 1 on success. - * \retval 0 on failure. - */ -BEECRYPTAPI -int elgv3vrfy(const mpbarrett* p, const mpbarrett* n, const mpnumber* g, const mpnumber* hm, const mpnumber* y, const mpnumber* r, const mpnumber* s) - /*@*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/endianness.c b/beecrypt/endianness.c deleted file mode 100644 index bd1342b01..000000000 --- a/beecrypt/endianness.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 1998, 1999, 2000, 2001 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file endianness.c - * \brief Endian-dependant encoding/decoding. - * \author Bob Deblier <bob.deblier@pandora.be> - */ - -#include "system.h" - -#include "endianness.h" - -#include "debug.h" - -int16_t swap16(int16_t n) -{ - return ( ((n & 0xff) << 8) | - ((n & 0xff00) >> 8) ); -} - -uint16_t swapu16(uint16_t n) -{ - return ( ((n & 0xffU) << 8) | - ((n & 0xff00U) >> 8) ); -} - -int32_t swap32(int32_t n) -{ - return ( ((n & 0xff) << 24) | - ((n & 0xff00) << 8) | - ((n & 0xff0000) >> 8) | - ((n & 0xff000000) >> 24) ); -} - -uint32_t swapu32(uint32_t n) -{ - return ( ((n & 0xffU) << 24) | - ((n & 0xff00U) << 8) | - ((n & 0xff0000U) >> 8) | - ((n & 0xff000000U) >> 24) ); -} - -int64_t swap64(int64_t n) -{ - return ( ((n & (((int64_t) 0xff) )) << 56) | - ((n & (((int64_t) 0xff) << 8)) << 40) | - ((n & (((int64_t) 0xff) << 16)) << 24) | - ((n & (((int64_t) 0xff) << 24)) << 8) | - ((n & (((int64_t) 0xff) << 32)) >> 8) | - ((n & (((int64_t) 0xff) << 40)) >> 24) | - ((n & (((int64_t) 0xff) << 48)) >> 40) | - ((n & (((int64_t) 0xff) << 56)) >> 56) ); -} diff --git a/beecrypt/endianness.h b/beecrypt/endianness.h deleted file mode 100644 index 6c89ed71a..000000000 --- a/beecrypt/endianness.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * endianness.h - * - * Endian-dependant encoding/decoding, header - * - * Copyright (c) 1998, 1999, 2000, 2001 Virtual Unlimited B.V. - * - * Author: Bob Deblier <bob@virtualunlimited.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef _ENDIANNESS_H -#define _ENDIANNESS_H - -#include "beecrypt.h" - -#ifdef __cplusplus -inline int16_t swap16(int16_t n) -{ - return ( ((n & 0xff) << 8) | - ((n & 0xff00) >> 8) ); -} - -inline uint16_t swapu16(uint16_t n) -{ - return ( ((n & 0xffU) << 8) | - ((n & 0xff00U) >> 8) ); -} - -inline int32_t swap32(int32_t n) -{ - return ( ((n & 0xff) << 24) | - ((n & 0xff00) << 8) | - ((n & 0xff0000) >> 8) | - ((n & 0xff000000) >> 24) ); -} - -inline uint32_t swapu32(uint32_t n) -{ - return ( ((n & 0xffU) << 24) | - ((n & 0xff00U) << 8) | - ((n & 0xff0000U) >> 8) | - ((n & 0xff000000U) >> 24) ); -} - -inline int64_t swap64(int64_t n) -{ - return ( ((n & ((int64_t) 0xff) ) << 56) | - ((n & ((int64_t) 0xff) << 8) << 40) | - ((n & ((int64_t) 0xff) << 16) << 24) | - ((n & ((int64_t) 0xff) << 24) << 8) | - ((n & ((int64_t) 0xff) << 32) >> 8) | - ((n & ((int64_t) 0xff) << 40) >> 24) | - ((n & ((int64_t) 0xff) << 48) >> 40) | - ((n & ((int64_t) 0xff) << 56) >> 56) ); -} -#else - int16_t swap16 (int16_t) - /*@*/; -uint16_t swapu16(uint16_t) - /*@*/; - int32_t swap32 (int32_t) - /*@*/; -uint32_t swapu32(uint32_t) - /*@*/; - int64_t swap64 (int64_t) - /*@*/; -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/entropy.c b/beecrypt/entropy.c deleted file mode 100644 index 56299defe..000000000 --- a/beecrypt/entropy.c +++ /dev/null @@ -1,1419 +0,0 @@ -/* - * Copyright (c) 1998, 1999, 2000, 2001, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file entropy.c - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup ES_m ES_audio_m ES_dsp_m ES_random_m ES_urandom_m ES_tty_m - */ - -#include "system.h" - -#include "entropy.h" -#include "endianness.h" - -#if WIN32 -# include <mmsystem.h> -# include <wincrypt.h> -# include <winerror.h> -#else -# if HAVE_SYS_IOCTL_H -# include <sys/ioctl.h> -# endif -# if HAVE_SYS_AUDIOIO_H -# include <sys/audioio.h> -# endif -# if HAVE_SYS_SOUNDCARD_H -# include <sys/soundcard.h> -# endif -# if HAVE_TERMIOS_H -# include <termios.h> -# elif HAVE_TERMIO_H -# include <termio.h> -# endif -# ifdef _REENTRANT -# if HAVE_THREAD_H && HAVE_SYNCH_H -# include <synch.h> -# elif HAVE_PTHREAD_H -# include <pthread.h> -# endif -# endif -# if HAVE_AIO_H -# include <aio.h> -# endif -#endif - -#include "debug.h" - -#if WIN32 -static HINSTANCE entropy_instance = (HINSTANCE) 0; - -static HANDLE entropy_wavein_lock; -static HANDLE entropy_wavein_event; - -int entropy_provider_setup(HINSTANCE hInst) -{ - if (!entropy_instance) - { - entropy_instance = hInst; - if (!(entropy_wavein_lock = CreateMutex(NULL, FALSE, NULL))) - return -1; - if (!(entropy_wavein_event = CreateEvent(NULL, FALSE, FALSE, NULL))) - return -1; - } - return 0; -} - -int entropy_provider_cleanup() -{ - if (entropy_wavein_lock) - { - CloseHandle(entropy_wavein_lock); - entropy_wavein_lock = 0; - } - if (entropy_wavein_event) - { - CloseHandle(entropy_wavein_event); - entropy_wavein_event = 0; - } - return 0; -} -#endif - -#if WIN32 || HAVE_DEV_AUDIO || HAVE_DEV_DSP -/* - * Mask the low-order bit of a bunch of sound samples, analyze them and - * return an error in case they are all zeroes or ones. - */ -static int entropy_noise_filter(void* sampledata, int samplecount, int samplesize, int channels, int swap) - /*@globals errno @*/ - /*@modifies sampledata, errno @*/ -{ - register int rc = 0, i; - - switch (samplesize) - { - case 1: - { - uint8_t* samples = (uint8_t*) sampledata; - - switch (channels) - { - case 1: - { - int zero_count = 0; - int ones_count = 0; - - for (i = 0; i < samplecount; i++) - { - if (samples[i] &= 0x1) - ones_count++; - else - zero_count++; - } - - if ((zero_count == 0) || (ones_count == 0)) - { - #if HAVE_ERRNO_H - errno = EIO; - #endif - rc = -1; - } - } - break; - - case 2: - { - int zero_count_left = 0; - int ones_count_left = 0; - int zero_count_right = 0; - int ones_count_right = 0; - - for (i = 0; i < samplecount; i++) - { - if (i & 1) - { - if (samples[i] &= 0x1) - ones_count_left++; - else - zero_count_left++; - } - else - { - if (samples[i] &= 0x1) - ones_count_right++; - else - zero_count_right++; - } - } - - if ((zero_count_left == 0) || (ones_count_left == 0) || - (zero_count_right == 0) || (ones_count_right == 0)) - { - #if HAVE_ERRNO_H - errno = EIO; - #endif - rc = -1; - } - } - break; - - default: - #if HAVE_ERRNO_H - errno = EINVAL; - #endif - rc = -1; - } - } - break; - - case 2: - { - uint16_t* samples = (uint16_t*) sampledata; - - switch (channels) - { - case 1: - { - int zero_count = 0; - int ones_count = 0; - - for (i = 0; i < samplecount; i++) - { - if (swap) - samples[i] = swapu16(samples[i]); - - if (samples[i] &= 0x1) - ones_count++; - else - zero_count++; - } - - if ((zero_count == 0) || (ones_count == 0)) - { - #if HAVE_ERRNO_H - errno = EIO; - #endif - rc = -1; - } - } - break; - - case 2: - { - int zero_count_left = 0; - int ones_count_left = 0; - int zero_count_right = 0; - int ones_count_right = 0; - - for (i = 0; i < samplecount; i++) - { - if (swap) - samples[i] = swapu16(samples[i]); - - if (i & 1) - { - if (samples[i] &= 0x1) - ones_count_left++; - else - zero_count_left++; - } - else - { - if (samples[i] &= 0x1) - ones_count_right++; - else - zero_count_right++; - } - } - - if ((zero_count_left == 0) || (ones_count_left == 0) || - (zero_count_right == 0) || (ones_count_right == 0)) - { - #if HAVE_ERRNO_H - errno = EIO; - #endif - rc = -1; - } - } - break; - - default: - #if HAVE_ERRNO_H - errno = EINVAL; - #endif - rc = -1; - } - } - break; - - default: - #if HAVE_ERRNO_H - errno = EINVAL; - #endif - rc = -1; - } - - return 0; -} - -/* bit deskewing technique: the classical Von Neumann method - - only use the lsb bit of every sample - - there is a chance of bias in 0 or 1 bits, so to deskew this: - - look at two successive sampled bits - - if they are the same, discard them - - if they are different, they're either 0-1 or 1-0; use the first bit of the pair as output -*/ - -#if WIN32 -static int entropy_noise_gather(HWAVEIN wavein, int samplesize, int channels, int swap, int timeout, byte* data, size_t size) -#else -static int entropy_noise_gather(int fd, int samplesize, int channels, int swap, int timeout, byte* data, size_t size) -#endif - /*@globals errno @*/ - /*@modifies errno @*/ -{ - size_t randombits = size << 3; - byte temp = 0; - int rc, i; - - byte* sampledata = (byte*) malloc(1024 * samplesize * channels); - - #if WIN32 - WAVEHDR header; - - /* first set up a wave header */ - header.lpData = (LPSTR) sampledata; - header.dwBufferLength = 1024 * samplesize * channels; - header.dwFlags = 0; - - /* do error handling! */ - waveInStart(wavein); - - /* the first event is the due to the opening of the wave */ - ResetEvent(entropy_wavein_event); - #else - # if ENABLE_AIO - struct aiocb my_aiocb; - const struct aiocb* my_aiocb_list = &my_aiocb; - # if HAVE_TIME_H - struct timespec my_aiocb_timeout; - # else - # error - # endif - - memset(&my_aiocb, 0, sizeof(struct aiocb)); - - my_aiocb.aio_fildes = fd; - my_aiocb.aio_sigevent.sigev_notify = SIGEV_NONE; - # endif - #endif - - if (sampledata == (byte*) 0) - { - #if HAVE_ERRNO_H - errno = ENOMEM; - #endif - return -1; - } - - while (randombits) - { - #if WIN32 - /* pass the buffer to the wavein and wait for the event */ - waveInPrepareHeader(wavein, &header, sizeof(WAVEHDR)); - waveInAddBuffer(wavein, &header, sizeof(WAVEHDR)); - - /* in case we have to wait more than the specified timeout, bail out */ - if (WaitForSingleObject(entropy_wavein_event, timeout) == WAIT_OBJECT_0) - { - rc = header.dwBytesRecorded; - } - else - { - waveInStop(wavein); - waveInReset(wavein); - - free(sampledata); - return -1; - } - #else - # if ENABLE_AIO - my_aiocb.aio_buf = sampledata; - my_aiocb.aio_nbytes = 1024 * samplesize * channels; - - rc = aio_read(&my_aiocb); - # else - rc = read(fd, sampledata, 1024 * samplesize * channels); - # endif - - if (rc < 0) - { - free(sampledata); - return -1; - } - - # if ENABLE_AIO - my_aiocb_timeout.tv_sec = (timeout / 1000); - my_aiocb_timeout.tv_nsec = (timeout % 1000) * 1000000; - - rc = aio_suspend(&my_aiocb_list, 1, &my_aiocb_timeout); - - if (rc < 0) - { - #if HAVE_ERRNO_H - if (errno == EAGAIN) - { - /* certain linux glibc versions are buggy and don't aio_suspend properly */ - nanosleep(&my_aiocb_timeout, (struct timespec*) 0); - - my_aiocb_timeout.tv_sec = (timeout / 1000); - my_aiocb_timeout.tv_nsec = (timeout % 1000) * 1000000; - - /* and try again */ - rc = aio_suspend(&my_aiocb_list, 1, &my_aiocb_timeout); - } - #endif - } - - if (rc < 0) - { - /* cancel any remaining reads */ - while (rc != AIO_ALLDONE) - { - rc = aio_cancel(fd, (struct aiocb*) 0); - - if (rc == AIO_NOTCANCELED) - { - my_aiocb_timeout.tv_sec = (timeout / 1000); - my_aiocb_timeout.tv_nsec = (timeout % 1000) * 1000000; - - nanosleep(&my_aiocb_timeout, (struct timespec*) 0); - } - - if (rc < 0) - break; - } - free(sampledata); - return -1; - } - - rc = aio_error(&my_aiocb); - - if (rc) - { - free(sampledata); - return -1; - } - - rc = aio_return(&my_aiocb); - - if (rc < 0) - { - free(sampledata); - return -1; - } - # endif - #endif - - if (entropy_noise_filter(sampledata, rc / samplesize, samplesize, channels, swap) < 0) - { - fprintf(stderr, "noise filter indicates too much bias in audio samples\n"); - free(sampledata); - return -1; - } - - switch (samplesize) - { - case 1: - { - uint8_t* samples = (uint8_t*) sampledata; - - for (i = 0; randombits && (i < 1024); i += 2) - { - if (samples[i] ^ samples[i+1]) - { - temp <<= 1; - temp |= samples[i]; - randombits--; - if (!(randombits & 0x7)) - *(data++) = temp; - } - } - } - break; - - case 2: - { - uint16_t* samples = (uint16_t*) sampledata; - - for (i = 0; randombits && (i < 1024); i += 2) - { - if (samples[i] ^ samples[i+1]) - { - temp <<= 1; - temp |= samples[i]; - randombits--; - if (!(randombits & 0x7)) - *(data++) = temp; - } - } - } - break; - - default: - free(sampledata); - return -1; - } - } - - #if WIN32 - waveInStop(wavein); - waveInReset(wavein); - #endif - - free(sampledata); - return 0; -} -#endif - -#if WIN32 -int entropy_wavein(byte* data, size_t size) -{ - const char *timeout_env = getenv("BEECRYPT_ENTROPY_WAVEIN_TIMEOUT"); - - WAVEINCAPS waveincaps; - WAVEFORMATEX waveformatex; - HWAVEIN wavein; - MMRESULT rc; - - rc = waveInGetDevCaps(WAVE_MAPPER, &waveincaps, sizeof(WAVEINCAPS)); - if (rc != MMSYSERR_NOERROR) - return -1; - - /* first go for the 16 bits samples -> more chance of noise bits */ - switch (waveformatex.nChannels = waveincaps.wChannels) - { - case 1: - /* mono */ - if (waveincaps.dwFormats & WAVE_FORMAT_4M16) - { - waveformatex.nSamplesPerSec = 44100; - waveformatex.wBitsPerSample = 16; - } - else if (waveincaps.dwFormats & WAVE_FORMAT_2M16) - { - waveformatex.nSamplesPerSec = 22050; - waveformatex.wBitsPerSample = 16; - } - else if (waveincaps.dwFormats & WAVE_FORMAT_1M16) - { - waveformatex.nSamplesPerSec = 11025; - waveformatex.wBitsPerSample = 16; - } - else if (waveincaps.dwFormats & WAVE_FORMAT_4M08) - { - waveformatex.nSamplesPerSec = 44100; - waveformatex.wBitsPerSample = 8; - } - else if (waveincaps.dwFormats & WAVE_FORMAT_2M08) - { - waveformatex.nSamplesPerSec = 22050; - waveformatex.wBitsPerSample = 8; - } - else if (waveincaps.dwFormats & WAVE_FORMAT_1M08) - { - waveformatex.nSamplesPerSec = 11025; - waveformatex.wBitsPerSample = 8; - } - else - return -1; - - break; - case 2: - /* stereo */ - if (waveincaps.dwFormats & WAVE_FORMAT_4S16) - { - waveformatex.nSamplesPerSec = 44100; - waveformatex.wBitsPerSample = 16; - } - else if (waveincaps.dwFormats & WAVE_FORMAT_2S16) - { - waveformatex.nSamplesPerSec = 22050; - waveformatex.wBitsPerSample = 16; - } - else if (waveincaps.dwFormats & WAVE_FORMAT_1S16) - { - waveformatex.nSamplesPerSec = 11025; - waveformatex.wBitsPerSample = 16; - } - else if (waveincaps.dwFormats & WAVE_FORMAT_4S08) - { - waveformatex.nSamplesPerSec = 44100; - waveformatex.wBitsPerSample = 8; - } - else if (waveincaps.dwFormats & WAVE_FORMAT_2S08) - { - waveformatex.nSamplesPerSec = 22050; - waveformatex.wBitsPerSample = 8; - } - else if (waveincaps.dwFormats & WAVE_FORMAT_1S08) - { - waveformatex.nSamplesPerSec = 11025; - waveformatex.wBitsPerSample = 8; - } - else - return -1; - - break; - } - - waveformatex.wFormatTag = WAVE_FORMAT_PCM; - waveformatex.nAvgBytesPerSec = (waveformatex.nSamplesPerSec * waveformatex.nChannels * waveformatex.wBitsPerSample) / 8; - waveformatex.nBlockAlign = (waveformatex.nChannels * waveformatex.wBitsPerSample) / 8; - waveformatex.cbSize = 0; - - /* we now have the wavein's capabilities hammered out; from here on we need to lock */ - - if (WaitForSingleObject(entropy_wavein_lock, INFINITE) != WAIT_OBJECT_0) - return -1; - - rc = waveInOpen(&wavein, WAVE_MAPPER, &waveformatex, (DWORD) entropy_wavein_event, (DWORD) 0, CALLBACK_EVENT); - if (rc != MMSYSERR_NOERROR) - { - fprintf(stderr, "waveInOpen failed!\n"); fflush(stderr); - ReleaseMutex(entropy_wavein_lock); - return -1; - } - - rc = entropy_noise_gather(wavein, waveformatex.wBitsPerSample >> 3, waveformatex.nChannels, 0, timeout_env ? atoi(timeout_env) : 2000, data, size); - - waveInClose(wavein); - - ReleaseMutex(entropy_wavein_lock); - - return rc; -} - -int entropy_console(byte* data, size_t size) -{ - register size_t randombits = size << 3; - - HANDLE hStdin; - DWORD inRet; - INPUT_RECORD inEvent; - LARGE_INTEGER hrtsample; - - hStdin = GetStdHandle(STD_INPUT_HANDLE); - if (hStdin == INVALID_HANDLE_VALUE) - { - fprintf(stderr, "GetStdHandle error %d\n", GetLastError()); - return -1; - } - - printf("please press random keys on your keyboard\n"); fflush(stdout); - - while (randombits) - { - if (!ReadConsoleInput(hStdin, &inEvent, 1, &inRet)) - { - fprintf(stderr, "ReadConsoleInput failed\n"); fflush(stderr); - return -1; - } - if ((inRet == 1) && (inEvent.EventType == KEY_EVENT) && inEvent.Event.KeyEvent.bKeyDown) - { - printf("."); fflush(stdout); - if (!QueryPerformanceCounter(&hrtsample)) - { - fprintf(stderr, "QueryPerformanceCounter failed\n"); fflush(stderr); - return -1; - } - - /* get 8 bits from the sample */ - /* discard the 2 lowest bits */ - *(data++) = (byte)(hrtsample.LowPart >> 2); - randombits -= 8; - } - } - - printf("\nthanks\n"); - - Sleep(1000); - - if (!FlushConsoleInputBuffer(hStdin)) - { - fprintf(stderr, "FlushConsoleInputBuffer failed\n"); fflush(stderr); - return -1; - } - - return 0; -} - -int entropy_wincrypt(byte* data, size_t size) -{ - HCRYPTPROV hCrypt; - DWORD provType = PROV_RSA_FULL; - BOOL rc; - - /* consider using getenv("BEECRYPT_ENTROPY_WINCRYPT_PROVTYPE") to set provType */ - - if (!CryptAcquireContext(&hCrypt, "BeeCrypt", NULL, provType, 0)) - { - #if defined(NTE_BAD_KEYSET) - if (GetLastError() == NTE_BAD_KEYSET) - { - if (!CryptAcquireContext(&hCrypt, "BeeCrypt", NULL, provType, CRYPT_NEWKEYSET)) - return -1; - } - else - return -1; - #else - return -1; - #endif - } - - rc = CryptGenRandom(hCrypt, size, (BYTE*) data); - - CryptReleaseContext(hCrypt, 0); - - return rc ? 0 : -1; -} - -#else - -#if HAVE_DEV_AUDIO -/*!\addtogroup ES_audio_m - * \{ - */ -static const char* name_dev_audio = "/dev/audio"; -static int dev_audio_fd = -1; -# ifdef _REENTRANT -# if HAVE_THREAD_H && HAVE_SYNCH_H -static mutex_t dev_audio_lock = DEFAULTMUTEX; -# elif HAVE_PTHREAD_H -static pthread_mutex_t dev_audio_lock = PTHREAD_MUTEX_INITIALIZER; -# else -# error Need locking mechanism -# endif -# endif -/*!\} - */ -#endif - -#if HAVE_DEV_DSP -/*!\addtogroup ES_dsp_m - * \{ - */ -static const char* name_dev_dsp = "/dev/dsp"; -static int dev_dsp_fd = -1; -# ifdef _REENTRANT -# if HAVE_THREAD_H && HAVE_SYNCH_H -static mutex_t dev_dsp_lock = DEFAULTMUTEX; -# elif HAVE_PTHREAD_H -static pthread_mutex_t dev_dsp_lock = PTHREAD_MUTEX_INITIALIZER; -# else -# error Need locking mechanism -# endif -# endif -/*!\} - */ -#endif - -#if HAVE_DEV_RANDOM -/*!\addtogroup ES_random_m - * \{ - */ -static const char* name_dev_random = "/dev/random"; -static int dev_random_fd = -1; -# ifdef _REENTRANT -# if HAVE_THREAD_H && HAVE_SYNCH_H -static mutex_t dev_random_lock = DEFAULTMUTEX; -# elif HAVE_PTHREAD_H -static pthread_mutex_t dev_random_lock = PTHREAD_MUTEX_INITIALIZER; -# else -# error Need locking mechanism -# endif -# endif -/*!\} - */ -#endif - -#if HAVE_DEV_URANDOM -/*!\addtogroup ES_urandom_m - * \{ - */ -static const char* name_dev_urandom = "/dev/urandom"; -static int dev_urandom_fd = -1; -# ifdef _REENTRANT -# if HAVE_THREAD_H && HAVE_SYNCH_H -static mutex_t dev_urandom_lock = DEFAULTMUTEX; -# elif HAVE_PTHREAD_H -static pthread_mutex_t dev_urandom_lock = PTHREAD_MUTEX_INITIALIZER; -# else -# error Need locking mechanism -# endif -# endif -/*!\} - */ -#endif - -#if HAVE_DEV_TTY -/*!\addtogroup ES_tty_m - * \{ - */ -static const char *dev_tty_name = "/dev/tty"; -static int dev_tty_fd = -1; -# ifdef _REENTRANT -# if HAVE_THREAD_H && HAVE_SYNCH_H -static mutex_t dev_tty_lock = DEFAULTMUTEX; -# elif HAVE_PTHREAD_H -static pthread_mutex_t dev_tty_lock = PTHREAD_MUTEX_INITIALIZER; -# else -# error Need locking mechanism -# endif -# endif -/*!\} - */ -#endif - -#if HAVE_SYS_STAT_H -static int statdevice(const char *device) - /*@*/ -{ - struct stat s; - - if (stat(device, &s) < 0) - { - #if HAVE_ERRNO_H && HAVE_STRING_H - fprintf(stderr, "cannot stat %s: %s\n", device, strerror(errno)); - #endif - return -1; - } - if (!S_ISCHR(s.st_mode)) - { - fprintf(stderr, "%s is not a device\n", device); - return -1; - } - return 0; -} -#endif - -static int opendevice(const char *device) - /*@*/ -{ - register int fd; - - if ((fd = open(device, O_RDONLY)) < 0) - { - #if HAVE_ERRNO_H && HAVE_STRING_H - fprintf(stderr, "open of %s failed: %s\n", device, strerror(errno)); - #endif - return fd; - } - - return fd; -} - -#if HAVE_DEV_RANDOM || HAVE_DEV_URANDOM -/* timeout is in milliseconds */ -/*!\ingroup ES_random_m ES_urandom_m - */ -static int entropy_randombits(int fd, int timeout, byte* data, size_t size) - /*@modifies data @*/ -{ - register int rc; - - #if ENABLE_AIO - struct aiocb my_aiocb; - const struct aiocb* my_aiocb_list = &my_aiocb; - # if HAVE_TIME_H - struct timespec my_aiocb_timeout; - # else - # error - # endif - - memset(&my_aiocb, 0, sizeof(struct aiocb)); - - my_aiocb.aio_fildes = fd; - my_aiocb.aio_sigevent.sigev_notify = SIGEV_NONE; - #endif - - while (size) - { - #if ENABLE_AIO - my_aiocb.aio_buf = data; - my_aiocb.aio_nbytes = size; - - rc = aio_read(&my_aiocb); - #else - rc = read(fd, data, size); - #endif - - if (rc < 0) - return -1; - - #if ENABLE_AIO - my_aiocb_timeout.tv_sec = (timeout / 1000); - my_aiocb_timeout.tv_nsec = (timeout % 1000) * 1000000; - - rc = aio_suspend(&my_aiocb_list, 1, &my_aiocb_timeout); - - if (rc < 0) - { - #if HAVE_ERRNO_H - if (errno == EAGAIN) - { - /* certain linux glibc versions are buggy and don't aio_suspend properly */ - nanosleep(&my_aiocb_timeout, (struct timespec*) 0); - - my_aiocb_timeout.tv_sec = 0; - my_aiocb_timeout.tv_nsec = 0; - - /* and try again */ - rc = aio_suspend(&my_aiocb_list, 1, &my_aiocb_timeout); - } - #endif - } - - if (rc < 0) - { - /* cancel any remaining reads */ - while (rc != AIO_ALLDONE) - { - rc = aio_cancel(fd, (struct aiocb*) 0); - - if (rc == AIO_NOTCANCELED) - { - my_aiocb_timeout.tv_sec = (timeout / 1000); - my_aiocb_timeout.tv_nsec = (timeout % 1000) * 1000000; - - nanosleep(&my_aiocb_timeout, (struct timespec*) 0); - } - - if (rc < 0) - break; - } - - return -1; - } - - rc = aio_error(&my_aiocb); - - if (rc < 0) - return -1; - - rc = aio_return(&my_aiocb); - - if (rc < 0) - return -1; - #endif - - data += rc; - size -= rc; - } - return 0; -} -#endif - -#if HAVE_DEV_TTY -/*!\ingroup ES_tty_m - */ -static int entropy_ttybits(int fd, byte* data, size_t size) - /*@modifies data @*/ -{ - byte dummy; - - #if HAVE_TERMIOS_H - struct termios tio_save, tio_set; - #elif HAVE_TERMIO_H - struct termio tio_save, tio_set; - #else - # error need alternative - #endif - #if HAVE_GETHRTIME - hrtime_t hrtsample; - #elif HAVE_GETTIMEOFDAY - struct timeval tvsample; - #else - # error need alternative high-precision timer - #endif - - printf("please press random keys on your keyboard\n"); - - #if HAVE_TERMIOS_H - if (tcgetattr(fd, &tio_save) < 0) - { - #if HAVE_ERRNO_H - perror("tcgetattr failed"); - #endif - return -1; - } - - tio_set = tio_save; - tio_set.c_cc[VMIN] = 1; /* read 1 tty character at a time */ - tio_set.c_cc[VTIME] = 0; /* don't timeout the read */ - tio_set.c_iflag |= IGNBRK; /* ignore <ctrl>-c */ - tio_set.c_lflag &= ~(ECHO|ICANON); /* don't echo characters */ - - /* change the tty settings, and flush input characters */ - if (tcsetattr(fd, TCSAFLUSH, &tio_set) < 0) - { - #if HAVE_ERRNO_H - perror("tcsetattr failed"); - #endif - return -1; - } - #elif HAVE_TERMIO_H - if (ioctl(fd, TCGETA, &tio_save) < 0) - { - #if HAVE_ERRNO_H - perror("ioctl TCGETA failed"); - #endif - return -1; - } - - tio_set = tio_save; - tio_set.c_cc[VMIN] = 1; /* read 1 tty character at a time */ - tio_set.c_cc[VTIME] = 0; /* don't timeout the read */ - tio_set.c_iflag |= IGNBRK; /* ignore <ctrl>-c */ - tio_set.c_lflag &= ~(ECHO|ICANON); /* don't echo characters */ - - /* change the tty settings, and flush input characters */ - if (ioctl(fd, TCSETAF, &tio_set) < 0) - { - #if HAVE_ERRNO_H - perror("ioctl TCSETAF failed"); - #endif - return -1; - } - #else - # error Need alternative tty control library - #endif - - while (size) - { - if (read(fd, &dummy, 1) < 0) - { - #if HAVE_ERRNO_H - perror("tty read failed"); - #endif - return -1; - } - printf("."); fflush(stdout); - #if HAVE_GETHRTIME - hrtsample = gethrtime(); - /* discard the 10 lowest bits i.e. 1024 nanoseconds of a sample */ - *(data++) = (byte)(hrtsample >> 10); - size--; - #elif HAVE_GETTIMEOFDAY - /* discard the 4 lowest bits i.e. 4 microseconds */ - gettimeofday(&tvsample, 0); - /* get 8 bits from the sample */ - *(data) = (byte)(tvsample.tv_usec >> 2); - size--; - #else - # error Need alternative high-precision timer sample - #endif - } - - printf("\nthanks\n"); - - /* give the user 1 second to stop typing */ - sleep(1); - - #if HAVE_TERMIOS_H - /* change the tty settings, and flush input characters */ - if (tcsetattr(fd, TCSAFLUSH, &tio_save) < 0) - { - #if HAVE_ERRNO_H - perror("tcsetattr failed"); - #endif - return -1; - } - #elif HAVE_TERMIO_H - /* restore the tty settings, and flush input characters */ - if (ioctl(fd, TCSETAF, &tio_save) < 0) - { - #if HAVE_ERRNO_H - perror("ioctl TCSETAF failed"); - #endif - return -1; - } - #else - # error Need alternative tty control library - #endif - - return 0; -} -#endif - -#if HAVE_DEV_AUDIO -/*!\ingroup ES_audio_m - */ -int entropy_dev_audio(byte* data, size_t size) - /*@globals dev_audio_fd @*/ - /*@modifies dev_audio_fd @*/ -{ - const char* timeout_env = getenv("BEECRYPT_ENTROPY_AUDIO_TIMEOUT"); - - register int rc; - - #ifdef _REENTRANT - # if HAVE_THREAD_H && HAVE_SYNCH_H - if (mutex_lock(&dev_audio_lock)) - return -1; - # elif HAVE_PTHREAD_H - if (pthread_mutex_lock(&dev_audio_lock)) - return -1; - # endif - #endif - - #if HAVE_SYS_STAT_H - if (statdevice(name_dev_audio) < 0) - goto dev_audio_end; - #endif - - if ((rc = dev_audio_fd = opendevice(name_dev_audio)) < 0) - goto dev_audio_end; - - #if HAVE_SYS_AUDIOIO_H /* i.e. Solaris */ - { - struct audio_info info; - - AUDIO_INITINFO(&info); - - info.record.sample_rate = 48000; - info.record.channels = 2; - info.record.precision = 16; - info.record.encoding = AUDIO_ENCODING_LINEAR; - info.record.gain = AUDIO_MAX_GAIN; - info.record.pause = 0; - info.record.buffer_size = 4096; - info.record.samples = 0; - - if ((rc = ioctl(dev_audio_fd, AUDIO_SETINFO, &info)) < 0) - { - if (errno == EINVAL) - { - /* use a conservative setting this time */ - info.record.sample_rate = 22050; - info.record.channels = 1; - info.record.precision = 8; - - if ((rc = ioctl(dev_audio_fd, AUDIO_SETINFO, &info)) < 0) - { - #if HAVE_ERRNO_H - perror("ioctl AUDIO_SETINFO failed"); - #endif - close(dev_audio_fd); - - goto dev_audio_end; - } - } - else - { - #if HAVE_ERRNO_H - perror("ioctl AUDIO_SETINFO failed"); - #endif - close(dev_audio_fd); - - goto dev_audio_end; - } - } - - rc = entropy_noise_gather(dev_audio_fd, info.record.precision >> 3, info.record.channels, 0, timeout_env ? atoi(timeout_env) : 1000, data, size); - } - #else - # error Unknown type of /dev/audio interface - #endif - - close(dev_audio_fd); - -dev_audio_end: - #ifdef _REENTRANT - # if HAVE_THREAD_H && HAVE_SYNCH_H - mutex_unlock(&dev_audio_lock); - # elif HAVE_PTHREAD_H - pthread_mutex_unlock(&dev_audio_lock); - # endif - #endif - return rc; -} -#endif - -#if HAVE_DEV_DSP -/*!\ingroup ES_dsp_m - */ -int entropy_dev_dsp(byte* data, size_t size) - /*@globals dev_dsp_fd @*/ - /*@modifies dev_dsp_fd @*/ -{ - const char* timeout_env = getenv("BEECRYPT_ENTROPY_DSP_TIMEOUT"); - - register int rc; - - #ifdef _REENTRANT - # if HAVE_THREAD_H && HAVE_SYNCH_H - if (mutex_lock(&dev_dsp_lock)) - return -1; - # elif HAVE_PTHREAD_H - if (pthread_mutex_lock(&dev_dsp_lock)) - return -1; - # endif - #endif - - #if HAVE_SYS_STAT_H - if ((rc = statdevice(name_dev_dsp)) < 0) - goto dev_dsp_end; - #endif - - if ((rc = dev_dsp_fd = opendevice(name_dev_dsp)) < 0) - goto dev_dsp_end; - - #if HAVE_SYS_SOUNDCARD_H /* i.e. Linux audio */ - { - int mask, format, samplesize, stereo, speed, swap; - - if ((rc = ioctl(dev_dsp_fd, SNDCTL_DSP_GETFMTS, &mask)) < 0) - { - #if HAVE_ERRNO_H - perror("ioctl SNDCTL_DSP_GETFMTS failed"); - #endif - close (dev_dsp_fd); - - goto dev_dsp_end; - } - - #if WORDS_BIGENDIAN - if (mask & AFMT_S16_BE) - { - format = AFMT_S16_BE; - samplesize = 2; - swap = 0; - } - else if (mask & AFMT_S16_LE) - { - format = AFMT_S16_LE; - samplesize = 2; - swap = 1; - } - #else - if (mask & AFMT_S16_LE) - { - format = AFMT_S16_LE; - samplesize = 2; - swap = 0; - } - else if (mask & AFMT_S16_BE) - { - format = AFMT_S16_BE; - samplesize = 2; - swap = 1; - } - #endif - else if (mask & AFMT_S8) - { - format = AFMT_S8; - samplesize = 1; - swap = 0; - } - else - { - /* No linear audio format available */ - rc = -1; - - close(dev_dsp_fd); - - goto dev_dsp_end; - } - - if ((rc = ioctl(dev_dsp_fd, SNDCTL_DSP_SETFMT, &format)) < 0) - { - #if HAVE_ERRNO_H - perror("ioctl SNDCTL_DSP_SETFMT failed"); - #endif - close(dev_dsp_fd); - - goto dev_dsp_end; - } - - /* the next two commands are not critical */ - stereo = 1; - ioctl(dev_dsp_fd, SNDCTL_DSP_STEREO, &stereo); - - speed = 44100; - ioctl(dev_dsp_fd, SNDCTL_DSP_SPEED, &speed); - - rc = entropy_noise_gather(dev_dsp_fd, samplesize, 2, swap, timeout_env ? atoi(timeout_env) : 1000, data, size); - } - #else - # error Unknown type of /dev/dsp interface - #endif - - close(dev_dsp_fd); - -dev_dsp_end: - #ifdef _REENTRANT - # if HAVE_THREAD_H && HAVE_SYNCH_H - mutex_unlock(&dev_dsp_lock); - # elif HAVE_PTHREAD_H - pthread_mutex_unlock(&dev_dsp_lock); - # endif - #endif - - return rc; -} -#endif - -#if HAVE_DEV_RANDOM -/*!\ingroup ES_random_m - */ -int entropy_dev_random(byte* data, size_t size) - /*@globals dev_random_fd @*/ - /*@modifies dev_random_fd @*/ -{ - const char* timeout_env = getenv("BEECRYPT_ENTROPY_RANDOM_TIMEOUT"); - - int rc; - - #ifdef _REENTRANT - # if HAVE_THREAD_H && HAVE_SYNCH_H - if (mutex_lock(&dev_random_lock)) - return -1; - # elif HAVE_PTHREAD_H - if (pthread_mutex_lock(&dev_random_lock)) - return -1; - # endif - #endif - - #if HAVE_SYS_STAT_H - if ((rc = statdevice(name_dev_random)) < 0) - goto dev_random_end; - #endif - - if ((rc = dev_random_fd = opendevice(name_dev_random)) < 0) - goto dev_random_end; - - /* collect entropy, with timeout */ - rc = entropy_randombits(dev_random_fd, timeout_env ? atoi(timeout_env) : 1000, data, size); - - close(dev_random_fd); - -dev_random_end: - #ifdef _REENTRANT - # if HAVE_THREAD_H && HAVE_SYNCH_H - mutex_unlock(&dev_random_lock); - # elif HAVE_PTHREAD_H - pthread_mutex_unlock(&dev_random_lock); - # endif - #endif - return rc; -} -#endif - -#if HAVE_DEV_URANDOM -/*!\ingroup ES_urandom_m - */ -int entropy_dev_urandom(byte* data, size_t size) - /*@globals dev_urandom_fd @*/ - /*@modifies dev_urandom_fd @*/ -{ - const char* timeout_env = getenv("BEECRYPT_ENTROPY_URANDOM_TIMEOUT"); - - register int rc; - - #ifdef _REENTRANT - # if HAVE_THREAD_H && HAVE_SYNCH_H - if (mutex_lock(&dev_urandom_lock)) - return -1; - # elif HAVE_PTHREAD_H - if (pthread_mutex_lock(&dev_urandom_lock)) - return -1; - # endif - #endif - - #if HAVE_SYS_STAT_H - if ((rc = statdevice(name_dev_urandom)) < 0) - goto dev_urandom_end; - #endif - - if ((rc = dev_urandom_fd = opendevice(name_dev_urandom)) < 0) - goto dev_urandom_end; - - /* collect entropy, with timeout */ - rc = entropy_randombits(dev_urandom_fd, timeout_env ? atoi(timeout_env) : 1000, data, size); - - close(dev_urandom_fd); - -dev_urandom_end: - #ifdef _REENTRANT - # if HAVE_THREAD_H && HAVE_SYNCH_H - mutex_unlock(&dev_urandom_lock); - # elif HAVE_PTHREAD_H - pthread_mutex_unlock(&dev_urandom_lock); - # endif - #endif - return rc; -} -#endif - -#if HAVE_DEV_TTY -/*!\ingroup ES_tty_m - */ -int entropy_dev_tty(byte* data, size_t size) - /*@globals dev_tty_fd @*/ - /*@modifies dev_tty_fd @*/ -{ - register int rc; - - #ifdef _REENTRANT - # if HAVE_THREAD_H && HAVE_SYNCH_H - if (mutex_lock(&dev_tty_lock)) - return -1; - # elif HAVE_PTHREAD_H - if (pthread_mutex_lock(&dev_tty_lock)) - return -1; - # endif - #endif - - #if HAVE_SYS_STAT_H - if ((rc = statdevice(dev_tty_name)) < 0) - goto dev_tty_end; - #endif - - if ((rc = dev_tty_fd = opendevice(dev_tty_name)) < 0) - goto dev_tty_end; - - rc = entropy_ttybits(dev_tty_fd, data, size); - - close(dev_tty_fd); - -dev_tty_end: - #ifdef _REENTRANT - # if HAVE_THREAD_H && HAVE_SYNCH_H - mutex_unlock(&dev_tty_lock); - # elif HAVE_PTHREAD_H - pthread_mutex_unlock(&dev_tty_lock); - # endif - #endif - - return rc; -} -#endif - -#endif diff --git a/beecrypt/entropy.h b/beecrypt/entropy.h deleted file mode 100644 index f00160692..000000000 --- a/beecrypt/entropy.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 1998, 1999, 2000, 2001, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file entropy.h - * \brief Entropy sources, headers. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup ES_m ES_audio_m ES_dsp_m ES_random_m ES_urandom_m ES_tty_m - */ - -#ifndef _ENTROPY_H -#define _ENTROPY_H - -#include "beecrypt.h" - -#if WIN32 -#include <Windows.h> -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#if WIN32 -BEECRYPTAPI -int entropy_provider_setup(HINSTANCE); -BEECRYPTAPI -int entropy_provider_cleanup(); - -BEECRYPTAPI -int entropy_wavein(byte*, size_t); -BEECRYPTAPI -int entropy_console(byte*, size_t); -BEECRYPTAPI -int entropy_wincrypt(byte*, size_t); -#else -#if HAVE_DEV_AUDIO -int entropy_dev_audio (byte* data, size_t size) - /*@globals internalState @*/ - /*@modifies data, internalState @*/; -#endif -#if HAVE_DEV_DSP -int entropy_dev_dsp (byte* data, size_t size) - /*@globals internalState @*/ - /*@modifies data, internalState @*/; -#endif -#if HAVE_DEV_RANDOM -int entropy_dev_random (byte* data, size_t size) - /*@globals internalState @*/ - /*@modifies data, internalState @*/; -#endif -#if HAVE_DEV_URANDOM -int entropy_dev_urandom(byte* data, size_t size) - /*@globals internalState @*/ - /*@modifies data, internalState @*/; -#endif -#if HAVE_DEV_TTY -int entropy_dev_tty (byte* data, size_t size) - /*@globals internalState @*/ - /*@modifies data, internalState @*/; -#endif -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/fips186.c b/beecrypt/fips186.c deleted file mode 100644 index 1a9d9f568..000000000 --- a/beecrypt/fips186.c +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright (c) 1998, 1999, 2000, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file fips186.c - * \brief FIPS 186 pseudo-random number generator. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup PRNG_m PRNG_fips186_m - */ - -#include "system.h" - -#include "beecrypt.h" -#include "fips186.h" -#include "mpopt.h" -#include "mp.h" - -#include "debug.h" - -/*!\addtogroup PRNG_fips186_m - * \{ - */ - -static uint32_t fips186hinit[5] = { 0xefcdab89U, 0x98badcfeU, 0x10325476U, 0xc3d2e1f0U, 0x67452301U }; - -const randomGenerator fips186prng = { - "FIPS 186", - sizeof(fips186Param), - (randomGeneratorSetup) fips186Setup, - (randomGeneratorSeed) fips186Seed, - (randomGeneratorNext) fips186Next, - (randomGeneratorCleanup) fips186Cleanup -}; - -static int fips186init(register sha1Param* p) - /*@modifies p @*/ -{ - memcpy(p->h, fips186hinit, 5 * sizeof(uint32_t)); - return 0; -} - -int fips186Setup(fips186Param* fp) -{ - if (fp) - { - #ifdef _REENTRANT - # if WIN32 - if (!(fp->lock = CreateMutex(NULL, FALSE, NULL))) - return -1; - # else - # if HAVE_THREAD_H && HAVE_SYNCH_H - if (mutex_init(&fp->lock, USYNC_THREAD, (void *) 0)) - return -1; - # elif HAVE_PTHREAD_H - if (pthread_mutex_init(&fp->lock, (pthread_mutexattr_t *) 0)) - return -1; - # endif - # endif - #endif - - fp->digestremain = 0; - - return entropyGatherNext((byte*) fp->state, MP_WORDS_TO_BYTES(FIPS186_STATE_SIZE)); - } - return -1; -} - -int fips186Seed(fips186Param* fp, const byte* data, size_t size) -{ - if (fp) - { - #ifdef _REENTRANT - # if WIN32 - if (WaitForSingleObject(fp->lock, INFINITE) != WAIT_OBJECT_0) - return -1; - # else - # if HAVE_THREAD_H && HAVE_SYNCH_H - if (mutex_lock(&fp->lock)) - return -1; - # elif HAVE_PTHREAD_H - if (pthread_mutex_lock(&fp->lock)) - return -1; - # endif - # endif - #endif - if (data) - { - mpw seed[FIPS186_STATE_SIZE]; - - /* if there's too much data, cut off at what we can deal with */ - if (size > MP_WORDS_TO_BYTES(FIPS186_STATE_SIZE)) - size = MP_WORDS_TO_BYTES(FIPS186_STATE_SIZE); - - /* convert to multi-precision integer, and add to the state */ - if (os2ip(seed, FIPS186_STATE_SIZE, data, size) == 0) - mpadd(FIPS186_STATE_SIZE, fp->state, seed); - } - #ifdef _REENTRANT - # if WIN32 - if (!ReleaseMutex(fp->lock)) - return -1; - # else - # if HAVE_THREAD_H && HAVE_SYNCH_H - if (mutex_unlock(&fp->lock)) - return -1; - # elif HAVE_PTHREAD_H - if (pthread_mutex_unlock(&fp->lock)) - return -1; - # endif - # endif - #endif - return 0; - } - return -1; -} - -int fips186Next(fips186Param* fp, byte* data, size_t size) -{ - if (fp) - { - mpw dig[FIPS186_STATE_SIZE]; - - #ifdef _REENTRANT - # if WIN32 - if (WaitForSingleObject(fp->lock, INFINITE) != WAIT_OBJECT_0) - return -1; - # else - # if HAVE_THREAD_H && HAVE_SYNCH_H - if (mutex_lock(&fp->lock)) - return -1; - # elif HAVE_PTHREAD_H - if (pthread_mutex_lock(&fp->lock)) - return -1; - # endif - # endif - #endif - - while (size > 0) - { - register size_t copy; - - if (fp->digestremain == 0) - { - fips186init(&fp->param); - /* copy the 512 bits of state data into the sha1Param */ - memcpy(fp->param.data, fp->state, MP_WORDS_TO_BYTES(FIPS186_STATE_SIZE)); - /* process the data */ - sha1Process(&fp->param); - - #if WORDS_BIGENDIAN - memcpy(fp->digest, fp->param.h, 20); - #else - /* encode 5 integers big-endian style */ - fp->digest[ 0] = (byte)(fp->param.h[0] >> 24); - fp->digest[ 1] = (byte)(fp->param.h[0] >> 16); - fp->digest[ 2] = (byte)(fp->param.h[0] >> 8); - fp->digest[ 3] = (byte)(fp->param.h[0] >> 0); - fp->digest[ 4] = (byte)(fp->param.h[1] >> 24); - fp->digest[ 5] = (byte)(fp->param.h[1] >> 16); - fp->digest[ 6] = (byte)(fp->param.h[1] >> 8); - fp->digest[ 7] = (byte)(fp->param.h[1] >> 0); - fp->digest[ 8] = (byte)(fp->param.h[2] >> 24); - fp->digest[ 9] = (byte)(fp->param.h[2] >> 16); - fp->digest[10] = (byte)(fp->param.h[2] >> 8); - fp->digest[11] = (byte)(fp->param.h[2] >> 0); - fp->digest[12] = (byte)(fp->param.h[3] >> 24); - fp->digest[13] = (byte)(fp->param.h[3] >> 16); - fp->digest[14] = (byte)(fp->param.h[3] >> 8); - fp->digest[15] = (byte)(fp->param.h[3] >> 0); - fp->digest[16] = (byte)(fp->param.h[4] >> 24); - fp->digest[17] = (byte)(fp->param.h[4] >> 16); - fp->digest[18] = (byte)(fp->param.h[4] >> 8); - fp->digest[19] = (byte)(fp->param.h[4] >> 0); - #endif - - if (os2ip(dig, FIPS186_STATE_SIZE, fp->digest, 20) == 0) - { - /* set state to state + digest + 1 mod 2^512 */ - mpadd (FIPS186_STATE_SIZE, fp->state, dig); - mpaddw(FIPS186_STATE_SIZE, fp->state, 1); - } - /* else shouldn't occur */ - /* we now have 5 words of pseudo-random data */ - fp->digestremain = 20; - } - copy = (size > fp->digestremain) ? fp->digestremain : size; - memcpy(data, fp->digest+20-fp->digestremain, copy); - fp->digestremain -= copy; - size -= copy; - data += copy; - } - #ifdef _REENTRANT - # if WIN32 - if (!ReleaseMutex(fp->lock)) - return -1; - # else - # if HAVE_THREAD_H && HAVE_SYNCH_H - if (mutex_unlock(&fp->lock)) - return -1; - # elif HAVE_PTHREAD_H - if (pthread_mutex_unlock(&fp->lock)) - return -1; - # endif - # endif - #endif - return 0; - } - return -1; -} - -int fips186Cleanup(fips186Param* fp) -{ - if (fp) - { - #ifdef _REENTRANT - # if WIN32 - if (!CloseHandle(fp->lock)) - return -1; - # else - # if HAVE_THREAD_H && HAVE_SYNCH_H - if (mutex_destroy(&fp->lock)) - return -1; - # elif HAVE_PTHREAD_H - if (pthread_mutex_destroy(&fp->lock)) - return -1; - # endif - # endif - #endif - return 0; - } - return -1; -} - -/*!\} - */ diff --git a/beecrypt/fips186.h b/beecrypt/fips186.h deleted file mode 100644 index 815bf2eac..000000000 --- a/beecrypt/fips186.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 1998, 1999, 2000, 2001, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file fips186.h - * \brief FIPS-186 pseudo-random number generator, headers. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup PRNG_m PRNG_fips186_m - */ - -#ifndef _FIPS186_H -#define _FIPS186_H - -#include "beecrypt.h" -#include "sha1.h" - -#ifdef _REENTRANT -# if WIN32 -# include <windows.h> -# include <winbase.h> -# endif -#endif - -#if (MP_WBITS == 64) -# define FIPS186_STATE_SIZE 8 -#elif (MP_WBITS == 32) -# define FIPS186_STATE_SIZE 16 -#else -# error -#endif - -/*!\ingroup PRNG_fips186_m - */ -typedef struct -{ - #ifdef _REENTRANT - bc_mutex_t lock; - #endif - sha1Param param; - mpw state[FIPS186_STATE_SIZE]; - byte digest[20]; - unsigned char digestremain; -} fips186Param; - -#ifdef __cplusplus -extern "C" { -#endif - -extern BEECRYPTAPI const randomGenerator fips186prng; - -BEECRYPTAPI -int fips186Setup (fips186Param* fp) - /*@modifies fp @*/; -BEECRYPTAPI -int fips186Seed (fips186Param* fp, const byte* data, size_t size) - /*@modifies fp @*/; -BEECRYPTAPI -int fips186Next (fips186Param* fp, byte* data, size_t size) - /*@modifies fp, data @*/; -BEECRYPTAPI -int fips186Cleanup(fips186Param* fp) - /*@modifies fp @*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/gas/.cvsignore b/beecrypt/gas/.cvsignore deleted file mode 100644 index 540cfea1a..000000000 --- a/beecrypt/gas/.cvsignore +++ /dev/null @@ -1,19 +0,0 @@ -.deps -.depend -.depend-done -.libs -Makefile -Makefile.in -config.cache -config.guess -config.log -config.status -config.sub -configure -libtool -ltconfig -ltmain.sh -*.o -*.lo -stamp-h -stamp-h.in diff --git a/beecrypt/gas/Makefile.am b/beecrypt/gas/Makefile.am deleted file mode 100644 index 9c1f01eb2..000000000 --- a/beecrypt/gas/Makefile.am +++ /dev/null @@ -1,50 +0,0 @@ -# -# Makefile.am's purpose is to add the GNU Assembler sources to the dist -# -# Copyright (c) 2001, 2002, 2003 Virtual Unlimited B.V. -# -# Author: Bob Deblier <bob.deblier@pandora.be> -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# - -AUTOMAKE_OPTIONS = gnu no-dependencies - -EXTRA_DIST = \ - aesopt.x86.m4 \ - aesopt.ppc.m4 \ - alpha.m4 \ - asmdefs.m4 \ - blowfishopt.i586.m4 \ - blowfishopt.ppc.m4 \ - ia64.m4 \ - m68k.m4 \ - mpopt.alpha.m4 \ - mpopt.arm.m4 \ - mpopt.ia64.m4 \ - mpopt.m68k.m4 \ - mpopt.ppc.m4 \ - mpopt.ppc64.m4 \ - mpopt.s390x.m4 \ - mpopt.sparcv8.m4 \ - mpopt.sparcv8plus.m4 \ - mpopt.x86.m4 \ - mpopt.x86_64.m4 \ - ppc.m4 \ - ppc64.m4 \ - sha1opt.x86.m4 \ - sparc.m4 \ - x86.m4 \ - x86_64.m4 diff --git a/beecrypt/gas/aesopt.ppc.m4 b/beecrypt/gas/aesopt.ppc.m4 deleted file mode 100644 index 998f0f2ee..000000000 --- a/beecrypt/gas/aesopt.ppc.m4 +++ /dev/null @@ -1,605 +0,0 @@ -dnl aesopt.ppc.m4 -dnl -dnl NOTE: Only tested for big-endian PowerPC! -dnl -dnl Copyright (c) 2003 Bob Deblier -dnl -dnl Author: Bob Deblier <bob.deblier@pandora.be> -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -include(config.m4) -include(ASM_SRCDIR/asmdefs.m4) -include(ASM_SRCDIR/ppc.m4) - -define(`s0',`r24') -define(`s1',`r25') -define(`s2',`r26') -define(`s3',`r27') -define(`t0',`r28') -define(`t1',`r29') -define(`t2',`r30') -define(`t3',`r31') - -define(`sxrk',` - lwz s0, 0($2) - lwz s1, 4($2) - lwz s2, 8($2) - lwz s3,12($2) - lwz r7, 0($1) - lwz r8, 4($1) - lwz r9, 8($1) - lwz r10,12($1) - xor s0,s0,r7 - xor s1,s1,r8 - xor s2,s2,r9 - xor s3,s3,r10 -') - -define(`etfs',` - lwz t0,$2+ 0($1) - lwz t1,$2+ 4($1) - lwz t2,$2+ 8($1) - lwz t3,$2+12($1) -ifelse(ASM_BIGENDIAN,yes,` - rlwinm r7,s0,10,22,29 - rlwinm r8,s1,10,22,29 - rlwinm r9,s2,10,22,29 - rlwinm r10,s3,10,22,29 - lwzx r7,r7,r12 - lwzx r8,r8,r12 - lwzx r9,r9,r12 - lwzx r10,r10,r12 - xor t0,t0,r7 - xor t1,t1,r8 - xor t2,t2,r9 - xor t3,t3,r10 - - la r12,1024(r12) - - rlwinm r7,s1,18,22,29 - rlwinm r8,s2,18,22,29 - rlwinm r9,s3,18,22,29 - rlwinm r10,s0,18,22,29 - lwzx r7,r7,r12 - lwzx r8,r8,r12 - lwzx r9,r9,r12 - lwzx r10,r10,r12 - xor t0,t0,r7 - xor t1,t1,r8 - xor t2,t2,r9 - xor t3,t3,r10 - - la r12,1024(r12) - - rlwinm r7,s2,26,22,29 - rlwinm r8,s3,26,22,29 - rlwinm r9,s0,26,22,29 - rlwinm r10,s1,26,22,29 - lwzx r7,r7,r12 - lwzx r8,r8,r12 - lwzx r9,r9,r12 - lwzx r10,r10,r12 - xor t0,t0,r7 - xor t1,t1,r8 - xor t2,t2,r9 - xor t3,t3,r10 - - la r12,1024(r12) - - rlwinm r7,s3,2,22,29 - rlwinm r8,s0,2,22,29 - rlwinm r9,s1,2,22,29 - rlwinm r10,s2,2,22,29 - lwzx r7,r7,r12 - lwzx r8,r8,r12 - lwzx r9,r9,r12 - lwzx r10,r10,r12 - xor t0,t0,r7 - xor t1,t1,r8 - xor t2,t2,r9 - xor t3,t3,r10 -',` - dnl to be done -') - - la r12,-3072(r12) -') - -define(`esft',` - lwz s0,$2+ 0($1) - lwz s1,$2+ 4($1) - lwz s2,$2+ 8($1) - lwz s3,$2+12($1) -ifelse(ASM_BIGENDIAN,yes,` - rlwinm r7,t0,10,22,29 - rlwinm r8,t1,10,22,29 - rlwinm r9,t2,10,22,29 - rlwinm r10,t3,10,22,29 - lwzx r7,r7,r12 - lwzx r8,r8,r12 - lwzx r9,r9,r12 - lwzx r10,r10,r12 - xor s0,s0,r7 - xor s1,s1,r8 - xor s2,s2,r9 - xor s3,s3,r10 - - la r12,1024(r12) - - rlwinm r7,t1,18,22,29 - rlwinm r8,t2,18,22,29 - rlwinm r9,t3,18,22,29 - rlwinm r10,t0,18,22,29 - lwzx r7,r7,r12 - lwzx r8,r8,r12 - lwzx r9,r9,r12 - lwzx r10,r10,r12 - xor s0,s0,r7 - xor s1,s1,r8 - xor s2,s2,r9 - xor s3,s3,r10 - - la r12,1024(r12) - - rlwinm r7,t2,26,22,29 - rlwinm r8,t3,26,22,29 - rlwinm r9,t0,26,22,29 - rlwinm r10,t1,26,22,29 - lwzx r7,r7,r12 - lwzx r8,r8,r12 - lwzx r9,r9,r12 - lwzx r10,r10,r12 - xor s0,s0,r7 - xor s1,s1,r8 - xor s2,s2,r9 - xor s3,s3,r10 - - la r12,1024(r12) - - rlwinm r7,t3,2,22,29 - rlwinm r8,t0,2,22,29 - rlwinm r9,t1,2,22,29 - rlwinm r10,t2,2,22,29 - lwzx r7,r7,r12 - lwzx r8,r8,r12 - lwzx r9,r9,r12 - lwzx r10,r10,r12 - xor s0,s0,r7 - xor s1,s1,r8 - xor s2,s2,r9 - xor s3,s3,r10 -',` - dnl to be done -') - la r12,-3072(r12) -') - -define(`elr',` - lwz s0, 0($1) - lwz s1, 4($1) - lwz s2, 8($1) - lwz s3,12($1) - - la r12,4096(r12) -ifdef(ASM_BIGENDIAN,yes,` - rlwinm r7,t0,10,22,29 - rlwinm r8,t1,10,22,29 - rlwinm r9,t2,10,22,29 - rlwinm r10,t3,10,22,29 - lwzx r7,r7,r12 - lwzx r8,r8,r12 - lwzx r9,r9,r12 - lwzx r10,r10,r12 - rlwinm r7,r7,0,0,7 - rlwinm r8,r8,0,0,7 - rlwinm r9,r9,0,0,7 - rlwinm r10,r10,0,0,7 - xor s0,s0,r7 - xor s1,s1,r8 - xor s2,s2,r9 - xor s3,s3,r10 - - rlwinm r7,t1,18,22,29 - rlwinm r8,t2,18,22,29 - rlwinm r9,t3,18,22,29 - rlwinm r10,t0,18,22,29 - lwzx r7,r7,r12 - lwzx r8,r8,r12 - lwzx r9,r9,r12 - lwzx r10,r10,r12 - rlwinm r7,r7,0,8,15 - rlwinm r8,r8,0,8,15 - rlwinm r9,r9,0,8,15 - rlwinm r10,r10,0,8,15 - xor s0,s0,r7 - xor s1,s1,r8 - xor s2,s2,r9 - xor s3,s3,r10 - - rlwinm r7,t2,26,22,29 - rlwinm r8,t3,26,22,29 - rlwinm r9,t0,26,22,29 - rlwinm r10,t1,26,22,29 - lwzx r7,r7,r12 - lwzx r8,r8,r12 - lwzx r9,r9,r12 - lwzx r10,r10,r12 - rlwinm r7,r7,0,16,23 - rlwinm r8,r8,0,16,23 - rlwinm r9,r9,0,16,23 - rlwinm r10,r10,0,16,23 - xor s0,s0,r7 - xor s1,s1,r8 - xor s2,s2,r9 - xor s3,s3,r10 - - rlwinm r7,t3,2,22,29 - rlwinm r8,t0,2,22,29 - rlwinm r9,t1,2,22,29 - rlwinm r10,t2,2,22,29 - lwzx r7,r7,r12 - lwzx r8,r8,r12 - lwzx r9,r9,r12 - lwzx r10,r10,r12 - rlwinm r7,r7,0,24,31 - rlwinm r8,r8,0,24,31 - rlwinm r9,r9,0,24,31 - rlwinm r10,r10,0,24,31 - xor s0,s0,r7 - xor s1,s1,r8 - xor s2,s2,r9 - xor s3,s3,r10 -',` -dnl to be done -') - la r12,-4096(r12) -') - -define(`eblock',` - sxrk($1,$2) - - etfs($1,16) - esft($1,32) - etfs($1,48) - esft($1,64) - etfs($1,80) - esft($1,96) - etfs($1,112) - esft($1,128) - etfs($1,144) - - lwz r11,256($1) - cmpwi r11,10 - beq $3 - - esft($1,160) - etfs($1,176) - - cmpwi r11,12 - beq $3 - - esft($1,192) - etfs($1,208) - -$3: - slwi r11,r11,4 - add $1,$1,r11 - - elr($1) -') - -define(`dtfs',` - lwz t0,$2+ 0($1) - lwz t1,$2+ 4($1) - lwz t2,$2+ 8($1) - lwz t3,$2+12($1) - - rlwinm r7,s0,10,22,29 - rlwinm r8,s1,10,22,29 - rlwinm r9,s2,10,22,29 - rlwinm r10,s3,10,22,29 - lwzx r7,r7,r12 - lwzx r8,r8,r12 - lwzx r9,r9,r12 - lwzx r10,r10,r12 - xor t0,t0,r7 - xor t1,t1,r8 - xor t2,t2,r9 - xor t3,t3,r10 - - la r12,1024(r12) - - rlwinm r7,s3,18,22,29 - rlwinm r8,s0,18,22,29 - rlwinm r9,s1,18,22,29 - rlwinm r10,s2,18,22,29 - - lwzx r7,r7,r12 - lwzx r8,r8,r12 - lwzx r9,r9,r12 - lwzx r10,r10,r12 - xor t0,t0,r7 - xor t1,t1,r8 - xor t2,t2,r9 - xor t3,t3,r10 - - la r12,1024(r12) - - rlwinm r7,s2,26,22,29 - rlwinm r8,s3,26,22,29 - rlwinm r9,s0,26,22,29 - rlwinm r10,s1,26,22,29 - lwzx r7,r7,r12 - lwzx r8,r8,r12 - lwzx r9,r9,r12 - lwzx r10,r10,r12 - xor t0,t0,r7 - xor t1,t1,r8 - xor t2,t2,r9 - xor t3,t3,r10 - - la r12,1024(r12) - - rlwinm r7,s1,2,22,29 - rlwinm r8,s2,2,22,29 - rlwinm r9,s3,2,22,29 - rlwinm r10,s0,2,22,29 - lwzx r7,r7,r12 - lwzx r8,r8,r12 - lwzx r9,r9,r12 - lwzx r10,r10,r12 - xor t0,t0,r7 - xor t1,t1,r8 - xor t2,t2,r9 - xor t3,t3,r10 - - la r12,-3072(r12) -') - -define(`dsft',` - lwz s0,$2+ 0($1) - lwz s1,$2+ 4($1) - lwz s2,$2+ 8($1) - lwz s3,$2+12($1) - - rlwinm r7,t0,10,22,29 - rlwinm r8,t1,10,22,29 - rlwinm r9,t2,10,22,29 - rlwinm r10,t3,10,22,29 - lwzx r7,r7,r12 - lwzx r8,r8,r12 - lwzx r9,r9,r12 - lwzx r10,r10,r12 - xor s0,s0,r7 - xor s1,s1,r8 - xor s2,s2,r9 - xor s3,s3,r10 - - la r12,1024(r12) - - rlwinm r7,t3,18,22,29 - rlwinm r8,t0,18,22,29 - rlwinm r9,t1,18,22,29 - rlwinm r10,t2,18,22,29 - lwzx r7,r7,r12 - lwzx r8,r8,r12 - lwzx r9,r9,r12 - lwzx r10,r10,r12 - xor s0,s0,r7 - xor s1,s1,r8 - xor s2,s2,r9 - xor s3,s3,r10 - - la r12,1024(r12) - - rlwinm r7,t2,26,22,29 - rlwinm r8,t3,26,22,29 - rlwinm r9,t0,26,22,29 - rlwinm r10,t1,26,22,29 - lwzx r7,r7,r12 - lwzx r8,r8,r12 - lwzx r9,r9,r12 - lwzx r10,r10,r12 - xor s0,s0,r7 - xor s1,s1,r8 - xor s2,s2,r9 - xor s3,s3,r10 - - la r12,1024(r12) - - rlwinm r7,t1,2,22,29 - rlwinm r8,t2,2,22,29 - rlwinm r9,t3,2,22,29 - rlwinm r10,t0,2,22,29 - lwzx r7,r7,r12 - lwzx r8,r8,r12 - lwzx r9,r9,r12 - lwzx r10,r10,r12 - xor s0,s0,r7 - xor s1,s1,r8 - xor s2,s2,r9 - xor s3,s3,r10 - - la r12,-3072(r12) -') - -define(`dlr',` - lwz s0, 0($1) - lwz s1, 4($1) - lwz s2, 8($1) - lwz s3,12($1) - - la r12,4096(r12) - - rlwinm r7,t0,10,22,29 - rlwinm r8,t1,10,22,29 - rlwinm r9,t2,10,22,29 - rlwinm r10,t3,10,22,29 - lwzx r7,r7,r12 - lwzx r8,r8,r12 - lwzx r9,r9,r12 - lwzx r10,r10,r12 - rlwinm r7,r7,0,0,7 - rlwinm r8,r8,0,0,7 - rlwinm r9,r9,0,0,7 - rlwinm r10,r10,0,0,7 - xor s0,s0,r7 - xor s1,s1,r8 - xor s2,s2,r9 - xor s3,s3,r10 - - rlwinm r7,t3,18,22,29 - rlwinm r8,t0,18,22,29 - rlwinm r9,t1,18,22,29 - rlwinm r10,t2,18,22,29 - lwzx r7,r7,r12 - lwzx r8,r8,r12 - lwzx r9,r9,r12 - lwzx r10,r10,r12 - rlwinm r7,r7,0,8,15 - rlwinm r8,r8,0,8,15 - rlwinm r9,r9,0,8,15 - rlwinm r10,r10,0,8,15 - xor s0,s0,r7 - xor s1,s1,r8 - xor s2,s2,r9 - xor s3,s3,r10 - - rlwinm r7,t2,26,22,29 - rlwinm r8,t3,26,22,29 - rlwinm r9,t0,26,22,29 - rlwinm r10,t1,26,22,29 - lwzx r7,r7,r12 - lwzx r8,r8,r12 - lwzx r9,r9,r12 - lwzx r10,r10,r12 - rlwinm r7,r7,0,16,23 - rlwinm r8,r8,0,16,23 - rlwinm r9,r9,0,16,23 - rlwinm r10,r10,0,16,23 - xor s0,s0,r7 - xor s1,s1,r8 - xor s2,s2,r9 - xor s3,s3,r10 - - rlwinm r7,t1,2,22,29 - rlwinm r8,t2,2,22,29 - rlwinm r9,t3,2,22,29 - rlwinm r10,t0,2,22,29 - lwzx r7,r7,r12 - lwzx r8,r8,r12 - lwzx r9,r9,r12 - lwzx r10,r10,r12 - rlwinm r7,r7,0,24,31 - rlwinm r8,r8,0,24,31 - rlwinm r9,r9,0,24,31 - rlwinm r10,r10,0,24,31 - xor s0,s0,r7 - xor s1,s1,r8 - xor s2,s2,r9 - xor s3,s3,r10 - - la r12,-4096(r12) -') - -define(`dblock',` - sxrk($1,$2) - - dtfs($1,16) - dsft($1,32) - dtfs($1,48) - dsft($1,64) - dtfs($1,80) - dsft($1,96) - dtfs($1,112) - dsft($1,128) - dtfs($1,144) - - lwz r11,256($1) - cmpwi r11,10 - beq $3 - - dsft($1,160) - dtfs($1,176) - - cmpwi r11,12 - beq $3 - - dsft($1,192) - dtfs($1,208) - -$3: - slwi r11,r11,4 - add $1,$1,r11 - - dlr($1) -') - -EXTERNAL_VARIABLE(_ae0) -EXTERNAL_VARIABLE(_ad0) - -C_FUNCTION_BEGIN(aesEncrypt) - subi r1,r1,32 - stw r24, 0(r1) - stw r25, 4(r1) - stw r26, 8(r1) - stw r27,12(r1) - stw r28,16(r1) - stw r29,20(r1) - stw r30,24(r1) - stw r31,28(r1) - - LOAD_ADDRESS(_ae0,r12) - - eblock(r3,r5,LOCAL(00)) - - stw s0, 0(r4) - stw s1, 4(r4) - stw s2, 8(r4) - stw s3,12(r4) - - li r3,0 - lwzx 28(r1),r31 - lwzx 24(r1),r30 - lwzx 20(r1),r29 - lwzx 16(r1),r28 - lwzx 12(r1),r27 - lwzx 8(r1),r26 - lwzx 4(r1),r25 - lwzx 0(r1),r24 - addi r1,r1,32 - blr -C_FUNCTION_END(aesEncrypt) - - -C_FUNCTION_BEGIN(aesDecrypt) - subi r1,r1,32 - stmw r24,0(r1) - - LOAD_ADDRESS(_ad0,r12) - - dblock(r3,r5,LOCAL(01)) - - stw s0, 0(r4) - stw s1, 4(r4) - stw s2, 8(r4) - stw s3,12(r4) - - li r3,0 - lmw r24,0(r1) - addi r1,r1,32 - blr -C_FUNCTION_END(aesDecrypt) diff --git a/beecrypt/gas/aesopt.x86.m4 b/beecrypt/gas/aesopt.x86.m4 deleted file mode 100644 index bf422aedb..000000000 --- a/beecrypt/gas/aesopt.x86.m4 +++ /dev/null @@ -1,596 +0,0 @@ -include(config.m4) -include(ASM_SRCDIR/asmdefs.m4) -include(ASM_SRCDIR/x86.m4) - -ifdef(`USE_MMX',` - -define(`s0',`%mm0') -define(`s1',`%mm1') -define(`s2',`%mm2') -define(`s3',`%mm3') -define(`t0',`%mm4') -define(`t1',`%mm5') -define(`t2',`%mm6') -define(`t3',`%mm7') - - .section .rodata - - .p2align 4 -LOCAL(mask000000FF): - .quad 0x00000000000000ff -LOCAL(mask0000FF00): - .quad 0x000000000000ff00 -LOCAL(mask00FF0000): - .quad 0x0000000000ff0000 -LOCAL(maskFF000000): - .quad 0x00000000ff000000 - -define(`sxrk',` - movl (%esi),%eax - xorl (%ebp),%eax - movd %eax,s0 - movl 4(%esi),%ebx - xorl 4(%ebp),%ebx - movd %ebx,s1 - movl 8(%esi),%ecx - xorl 8(%ebp),%ecx - movd %ecx,s2 - movl 12(%esi),%edx - xorl 12(%ebp),%edx - movd %edx,s3 -') - -define(`etfs',` - movd $1+ 0(%ebp),t0 - movd s0,%eax - movd $1+ 4(%ebp),t1 - movd s1,%ebx - movd $1+ 8(%ebp),t2 - movzbl %al,%ecx - movd $1+12(%ebp),t3 - movzbl %bl,%edx - pxor 0(%esi,%ecx,8),t0 - movzbl %ah,%ecx - pxor 0(%esi,%edx,8),t1 - movzbl %bh,%edx - pxor 2048(%esi,%ecx,8),t3 - shrl `$'16,%eax - pxor 2048(%esi,%edx,8),t0 - movzbl %al,%ecx - shrl `$'16,%ebx - pxor 4096(%esi,%ecx,8),t2 - movzbl %bl,%edx - movzbl %ah,%ecx - pxor 4096(%esi,%edx,8),t3 - movzbl %bh,%edx - pxor 6144(%esi,%ecx,8),t1 - movd s2,%eax - pxor 6144(%esi,%edx,8),t2 - movzbl %al,%ecx - movd s3,%ebx - pxor 0(%esi,%ecx,8),t2 - movzbl %bl,%edx - movzbl %ah,%ecx - pxor 0(%esi,%edx,8),t3 - movzbl %bh,%edx - pxor 2048(%esi,%ecx,8),t1 - shrl `$'16,%eax - pxor 2048(%esi,%edx,8),t2 - movzbl %al,%ecx - shrl `$'16,%ebx - pxor 4096(%esi,%ecx,8),t0 - movzbl %bl,%edx - movzbl %ah,%ecx - pxor 4096(%esi,%edx,8),t1 - movzbl %bh,%edx - pxor 6144(%esi,%ecx,8),t3 - pxor 6144(%esi,%edx,8),t0 -') - -define(`esft',` - movd $1+ 0(%ebp),s0 - movd t0,%eax - movd $1+ 4(%ebp),s1 - movd t1,%ebx - movd $1+ 8(%ebp),s2 - movzbl %al,%ecx - movd $1+12(%ebp),s3 - movzbl %bl,%edx - pxor 0(%esi,%ecx,8),s0 - movzbl %ah,%ecx - pxor 0(%esi,%edx,8),s1 - movzbl %bh,%edx - pxor 2048(%esi,%ecx,8),s3 - shrl `$'16,%eax - pxor 2048(%esi,%edx,8),s0 - movzbl %al,%ecx - shrl `$'16,%ebx - pxor 4096(%esi,%ecx,8),s2 - movzbl %bl,%edx - movzbl %ah,%ecx - pxor 4096(%esi,%edx,8),s3 - movzbl %bh,%edx - pxor 6144(%esi,%ecx,8),s1 - movd t2,%eax - pxor 6144(%esi,%edx,8),s2 - movzbl %al,%ecx - movd t3,%ebx - pxor 0(%esi,%ecx,8),s2 - movzbl %bl,%edx - movzbl %ah,%ecx - pxor 0(%esi,%edx,8),s3 - movzbl %bh,%edx - pxor 2048(%esi,%ecx,8),s1 - shrl `$'16,%eax - pxor 2048(%esi,%edx,8),s2 - movzbl %al,%ecx - shrl `$'16,%ebx - pxor 4096(%esi,%ecx,8),s0 - movzbl %bl,%edx - movzbl %ah,%ecx - pxor 4096(%esi,%edx,8),s1 - movzbl %bh,%edx - pxor 6144(%esi,%ecx,8),s3 - pxor 6144(%esi,%edx,8),s0 -') - -define(`elr',` - movd 0(%ebp),s0 - movd t0,%eax - movd 4(%ebp),s1 - movd t1,%ebx - movd 8(%ebp),s2 - movzbl %al,%ecx - movd 12(%ebp),s3 - movzbl %bl,%edx - movd 8192(%esi,%ecx,4),t0 - movzbl %ah,%ecx - movd 8192(%esi,%edx,4),t1 - movzbl %bh,%edx - pand LOCAL(mask000000FF),t0 - pand LOCAL(mask000000FF),t1 - pxor t0,s0 - movd 8192(%esi,%ecx,4),t0 - pxor t1,s1 - movd 8192(%esi,%edx,4),t1 - pand LOCAL(mask0000FF00),t0 - shrl `$'16,%eax - pand LOCAL(mask0000FF00),t1 - shrl `$'16,%ebx - pxor t0,s3 - movzbl %al,%ecx - pxor t1,s0 - movzbl %bl,%edx - movd 8192(%esi,%ecx,4),t0 - movzbl %ah,%ecx - movd 8192(%esi,%edx,4),t1 - pand LOCAL(mask00FF0000),t0 - movzbl %bh,%edx - pand LOCAL(mask00FF0000),t1 - pxor t0,s2 - movd 8192(%esi,%ecx,4),t0 - pxor t1,s3 - movd 8192(%esi,%edx,4),t1 - movd t2,%eax - pand LOCAL(maskFF000000),t0 - movd t3,%ebx - pand LOCAL(maskFF000000),t1 - pxor t0,s1 - movzbl %al,%ecx - pxor t1,s2 - movzbl %bl,%edx - movd 8192(%esi,%ecx,4),t2 - movzbl %ah,%ecx - movd 8192(%esi,%edx,4),t3 - movzbl %bh,%edx - pand LOCAL(mask000000FF),t2 - pand LOCAL(mask000000FF),t3 - pxor t2,s2 - movd 8192(%esi,%ecx,4),t2 - pxor t3,s3 - movd 8192(%esi,%edx,4),t3 - pand LOCAL(mask0000FF00),t2 - shrl `$'16,%eax - pand LOCAL(mask0000FF00),t3 - shrl `$'16,%ebx - pxor t2,s1 - movzbl %al,%ecx - pxor t3,s2 - movzbl %bl,%edx - movd 8192(%esi,%ecx,4),t2 - movzbl %ah,%ecx - movd 8192(%esi,%edx,4),t3 - pand LOCAL(mask00FF0000),t2 - movzbl %bh,%edx - pand LOCAL(mask00FF0000),t3 - pxor t2,s0 - movd 8192(%esi,%ecx,4),t2 - pxor t3,s1 - movd 8192(%esi,%edx,4),t3 - pand LOCAL(maskFF000000),t2 - pand LOCAL(maskFF000000),t3 - pxor t2,s3 - pxor t3,s0 -') - -define(`eblock',` - sxrk - - movl `$'SYMNAME(_ae0),%esi - - etfs(16) - esft(32) - etfs(48) - esft(64) - etfs(80) - esft(96) - etfs(112) - esft(128) - etfs(144) - - movl 256(%ebp),%eax - cmp `$'10,%eax - je $1 - - esft(160) - etfs(176) - - movl 256(%ebp),%eax - cmp `$'12,%eax - je $1 - - esft(192) - etfs(208) - - movl 256(%ebp),%eax - - .align 4 -$1: - sall `$'4,%eax - addl %eax,%ebp - - elr -') - - -C_FUNCTION_BEGIN(aesEncrypt) - pushl %edi - pushl %esi - pushl %ebp - pushl %ebx - - movl 20(%esp),%ebp - movl 24(%esp),%edi - movl 28(%esp),%esi - - eblock(LOCAL(00)) - - movd s0, 0(%edi) - movd s1, 4(%edi) - movd s2, 8(%edi) - movd s3,12(%edi) - - xorl %eax,%eax - emms - - popl %ebx - popl %ebp - popl %esi - popl %edi - ret -C_FUNCTION_END(aesEncrypt) - - -C_FUNCTION_BEGIN(aesEncryptECB) - pushl %edi - pushl %esi - pushl %ebp - pushl %ebx - - movl 24(%esp),%edi - movl 28(%esp),%esi - - .p2align 4,,15 -LOCAL(aesEncryptECB_loop): - movl 20(%esp),%ebp - - eblock(LOCAL(01)) - - movd s0, 0(%edi) - movd s1, 4(%edi) - movd s2, 8(%edi) - movd s3,12(%edi) - - addl `$'16,%esi - addl `$'16,%edi - decl 32(%esp) - jnz LOCAL(aesEncryptECB_loop) - - xorl %eax,%eax - emms - - popl %ebx - popl %ebp - popl %esi - popl %edi - ret -C_FUNCTION_END(aesEncryptECB) - - -define(`dtfs',` - movd $1+ 0(%ebp),t0 - movd s0,%eax - movd $1+ 4(%ebp),t1 - movd s1,%ebx - movd $1+ 8(%ebp),t2 - movzbl %al,%ecx - movd $1+12(%ebp),t3 - movzbl %bl,%edx - pxor 0(%esi,%ecx,8),t0 - movzbl %ah,%ecx - pxor 0(%esi,%edx,8),t1 - movzbl %bh,%edx - pxor 2048(%esi,%ecx,8),t1 - shrl `$'16,%eax - pxor 2048(%esi,%edx,8),t2 - movzbl %al,%ecx - shrl `$'16,%ebx - pxor 4096(%esi,%ecx,8),t2 - movzbl %bl,%edx - movzbl %ah,%ecx - pxor 4096(%esi,%edx,8),t3 - movzbl %bh,%edx - pxor 6144(%esi,%ecx,8),t3 - movd s2,%eax - pxor 6144(%esi,%edx,8),t0 - movzbl %al,%ecx - movd s3,%ebx - pxor 0(%esi,%ecx,8),t2 - movzbl %bl,%edx - movzbl %ah,%ecx - pxor 0(%esi,%edx,8),t3 - movzbl %bh,%edx - pxor 2048(%esi,%ecx,8),t3 - shrl `$'16,%eax - pxor 2048(%esi,%edx,8),t0 - movzbl %al,%ecx - shrl `$'16,%ebx - pxor 4096(%esi,%ecx,8),t0 - movzbl %bl,%edx - movzbl %ah,%ecx - pxor 4096(%esi,%edx,8),t1 - movzbl %bh,%edx - pxor 6144(%esi,%ecx,8),t1 - pxor 6144(%esi,%edx,8),t2 -') - -define(`dsft',` - movd $1+ 0(%ebp),s0 - movd t0,%eax - movd $1+ 4(%ebp),s1 - movd t1,%ebx - movd $1+ 8(%ebp),s2 - movzbl %al,%ecx - movd $1+12(%ebp),s3 - movzbl %bl,%edx - pxor 0(%esi,%ecx,8),s0 - movzbl %ah,%ecx - pxor 0(%esi,%edx,8),s1 - movzbl %bh,%edx - pxor 2048(%esi,%ecx,8),s1 - shrl `$'16,%eax - pxor 2048(%esi,%edx,8),s2 - movzbl %al,%ecx - shrl `$'16,%ebx - pxor 4096(%esi,%ecx,8),s2 - movzbl %bl,%edx - movzbl %ah,%ecx - pxor 4096(%esi,%edx,8),s3 - movzbl %bh,%edx - pxor 6144(%esi,%ecx,8),s3 - movd t2,%eax - pxor 6144(%esi,%edx,8),s0 - movzbl %al,%ecx - movd t3,%ebx - pxor 0(%esi,%ecx,8),s2 - movzbl %bl,%edx - movzbl %ah,%ecx - pxor 0(%esi,%edx,8),s3 - movzbl %bh,%edx - pxor 2048(%esi,%ecx,8),s3 - shrl `$'16,%eax - pxor 2048(%esi,%edx,8),s0 - movzbl %al,%ecx - shrl `$'16,%ebx - pxor 4096(%esi,%ecx,8),s0 - movzbl %bl,%edx - movzbl %ah,%ecx - pxor 4096(%esi,%edx,8),s1 - movzbl %bh,%edx - pxor 6144(%esi,%ecx,8),s1 - pxor 6144(%esi,%edx,8),s2 -') - -define(`dlr',` - movd 0(%ebp),s0 - movd t0,%eax - movd 4(%ebp),s1 - movd t1,%ebx - movd 8(%ebp),s2 - movzbl %al,%ecx - movd 12(%ebp),s3 - movzbl %bl,%edx - movd 8192(%esi,%ecx,4),t0 - movzbl %ah,%ecx - movd 8192(%esi,%edx,4),t1 - movzbl %bh,%edx - pand LOCAL(mask000000FF),t0 - pand LOCAL(mask000000FF),t1 - pxor t0,s0 - movd 8192(%esi,%ecx,4),t0 - pxor t1,s1 - movd 8192(%esi,%edx,4),t1 - pand LOCAL(mask0000FF00),t0 - shrl `$'16,%eax - pand LOCAL(mask0000FF00),t1 - shrl `$'16,%ebx - pxor t0,s1 - movzbl %al,%ecx - pxor t1,s2 - movzbl %bl,%edx - movd 8192(%esi,%ecx,4),t0 - movzbl %ah,%ecx - movd 8192(%esi,%edx,4),t1 - pand LOCAL(mask00FF0000),t0 - movzbl %bh,%edx - pand LOCAL(mask00FF0000),t1 - pxor t0,s2 - movd 8192(%esi,%ecx,4),t0 - pxor t1,s3 - movd 8192(%esi,%edx,4),t1 - movd t2,%eax - pand LOCAL(maskFF000000),t0 - movd t3,%ebx - pand LOCAL(maskFF000000),t1 - pxor t0,s3 - movzbl %al,%ecx - pxor t1,s0 - movzbl %bl,%edx - movd 8192(%esi,%ecx,4),t2 - movzbl %ah,%ecx - movd 8192(%esi,%edx,4),t3 - movzbl %bh,%edx - pand LOCAL(mask000000FF),t2 - pand LOCAL(mask000000FF),t3 - pxor t2,s2 - movd 8192(%esi,%ecx,4),t2 - pxor t3,s3 - movd 8192(%esi,%edx,4),t3 - pand LOCAL(mask0000FF00),t2 - shrl `$'16,%eax - pand LOCAL(mask0000FF00),t3 - shrl `$'16,%ebx - pxor t2,s3 - movzbl %al,%ecx - pxor t3,s0 - movzbl %bl,%edx - movd 8192(%esi,%ecx,4),t2 - movzbl %ah,%ecx - movd 8192(%esi,%edx,4),t3 - pand LOCAL(mask00FF0000),t2 - movzbl %bh,%edx - pand LOCAL(mask00FF0000),t3 - pxor t2,s0 - movd 8192(%esi,%ecx,4),t2 - pxor t3,s1 - movd 8192(%esi,%edx,4),t3 - pand LOCAL(maskFF000000),t2 - pand LOCAL(maskFF000000),t3 - pxor t2,s1 - pxor t3,s2 -') - -define(`dblock',` - sxrk - - movl `$'SYMNAME(_ad0),%esi - - dtfs(16) - dsft(32) - dtfs(48) - dsft(64) - dtfs(80) - dsft(96) - dtfs(112) - dsft(128) - dtfs(144) - - movl 256(%ebp),%eax - cmp `$'10,%eax - je $1 - - dsft(160) - dtfs(176) - - movl 256(%ebp),%eax - cmp `$'12,%eax - je $1 - - dsft(192) - dtfs(208) - - movl 256(%ebp),%eax - - .align 4 -$1: - sall `$'4,%eax - addl %eax,%ebp - - dlr -') - - -C_FUNCTION_BEGIN(aesDecrypt) - pushl %edi - pushl %esi - pushl %ebp - pushl %ebx - - movl 20(%esp),%ebp - movl 24(%esp),%edi - movl 28(%esp),%esi - - dblock(LOCAL(10)) - - movd s0, 0(%edi) - movd s1, 4(%edi) - movd s2, 8(%edi) - movd s3,12(%edi) - - xorl %eax,%eax - emms - - popl %ebx - popl %ebp - popl %esi - popl %edi - ret -C_FUNCTION_END(aesDecrypt) - - -C_FUNCTION_BEGIN(aesDecryptECB) - pushl %edi - pushl %esi - pushl %ebp - pushl %ebx - - movl 24(%esp),%edi - movl 28(%esp),%esi - - .p2align 4,,15 -LOCAL(aesDecryptECB_loop): - movl 20(%esp),%ebp - - dblock(LOCAL(11)) - - movd s0, 0(%edi) - movd s1, 4(%edi) - movd s2, 8(%edi) - movd s3,12(%edi) - - addl `$'16,%esi - addl `$'16,%edi - decl 32(%esp) - jnz LOCAL(aesDecryptECB_loop) - - xorl %eax,%eax - emms - - popl %ebx - popl %ebp - popl %esi - popl %edi - ret -C_FUNCTION_END(aesDecryptECB) - -') diff --git a/beecrypt/gas/alpha.m4 b/beecrypt/gas/alpha.m4 deleted file mode 100644 index 49366dae0..000000000 --- a/beecrypt/gas/alpha.m4 +++ /dev/null @@ -1,34 +0,0 @@ -dnl alpha.m4 -dnl -dnl Copyright (c) 2003 Bob Deblier -dnl -dnl Author: Bob Deblier <bob.deblier@pandora.be> -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -undefine(`C_FUNCTION_BEGIN') -define(C_FUNCTION_BEGIN,` - .text - .align 5 - .globl $1 - .ent $1 -$1: - .frame `$'sp, 0, `$'26 - .prologue 0 -') -undefine(`C_FUNCTION_END') -define(C_FUNCTION_END,` - .end $1 -') diff --git a/beecrypt/gas/asmdefs.m4 b/beecrypt/gas/asmdefs.m4 deleted file mode 100644 index d67504ec6..000000000 --- a/beecrypt/gas/asmdefs.m4 +++ /dev/null @@ -1,64 +0,0 @@ -dnl asmdefs.m4 -dnl -dnl Copyright (c) 2003 Bob Deblier -dnl -dnl Author: Bob Deblier <bob.deblier@pandora.be> -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -ifelse(substr(ASM_OS,0,5),linux,` -define(USE_SIZE_DIRECTIVE,yes) -define(USE_TYPE_DIRECTIVE,yes) -') - -define(SYMNAME,`GSYM_PREFIX`$1'') -define(LOCAL,`LSYM_PREFIX`$1'') - -ifdef(`ALIGN',,`define(`ALIGN',`')') - -ifelse(USE_TYPE_DIRECTIVE,yes,` -ifelse(substr(ASM_ARCH,0,3),arm,` -define(FUNCTION_TYPE,`function') -',` -ifelse(substr(ASM_ARCH,0,5),sparc,` -define(FUNCTION_TYPE,`#function') -',` -define(FUNCTION_TYPE,`@function') -') -') -define(C_FUNCTION_BEGIN,` - TEXTSEG - ALIGN - GLOBL SYMNAME($1) - .type SYMNAME($1),FUNCTION_TYPE -SYMNAME($1): -') -',` -define(C_FUNCTION_BEGIN,` - TEXTSEG - ALIGN - GLOBL SYMNAME($1) -SYMNAME($1): -') -') - -ifelse(USE_SIZE_DIRECTIVE,yes,` -define(C_FUNCTION_END,` -LOCAL($1)_size: - .size SYMNAME($1), LOCAL($1)_size - SYMNAME($1) -') -',` -define(C_FUNCTION_END,`') -') diff --git a/beecrypt/gas/blowfishopt.i586.m4 b/beecrypt/gas/blowfishopt.i586.m4 deleted file mode 100644 index adc965b8d..000000000 --- a/beecrypt/gas/blowfishopt.i586.m4 +++ /dev/null @@ -1,163 +0,0 @@ -dnl blowfishopt.i586.m4 -dnl -dnl Copyright (c) 2003 Bob Deblier -dnl -dnl Author: Bob Deblier <bob.deblier@pandora.be> -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -include(config.m4) -include(ASM_SRCDIR/asmdefs.m4) -include(ASM_SRCDIR/x86.m4) - -dnl during this macro we assume: -dnl bp in %esi, xl and xr in %ecx and %edx, %eax and %ebx clear - -define(`etworounds',` - xorl $1+0(%esi),%ecx - roll `$'16,%ecx - movzx %ch,%eax - movzx %cl,%ebx - roll `$'16,%ecx - movl 0x000+72(%esi,%eax,4),%edi - addl 0x400+72(%esi,%ebx,4),%edi - movzx %ch,%eax - movzx %cl,%ebx - xorl 0x800+72(%esi,%eax,4),%edi - addl 0xC00+72(%esi,%ebx,4),%edi - xorl %edi,%edx - xorl $1+4(%esi),%edx - roll `$'16,%edx - movzx %dh,%eax - movzx %dl,%ebx - roll `$'16,%edx - movl 0x000+72(%esi,%eax,4),%edi - addl 0x400+72(%esi,%ebx,4),%edi - movzx %dh,%eax - movzx %dl,%ebx - xorl 0x800+72(%esi,%eax,4),%edi - addl 0xC00+72(%esi,%ebx,4),%edi - xorl %edi,%ecx -') - -dnl bp in %esi, xl and xr in %ecx and %edx, %eax and %ebx clear -define(`dtworounds',` - xorl $1+4(%esi),%ecx - roll `$'16,%ecx - movzx %ch,%eax - movzx %cl,%ebx - roll `$'16,%ecx - movl 0x000+72(%esi,%eax,4),%edi - addl 0x400+72(%esi,%ebx,4),%edi - movzx %ch,%eax - movzx %cl,%ebx - xorl 0x800+72(%esi,%eax,4),%edi - addl 0xC00+72(%esi,%ebx,4),%edi - xorl %edi,%edx - xorl $1+0(%esi),%edx - roll `$'16,%edx - movzx %dh,%eax - movzx %dl,%ebx - roll `$'16,%edx - movl 0x000+72(%esi,%eax,4),%edi - addl 0x400+72(%esi,%ebx,4),%edi - movzx %dh,%eax - movzx %dl,%ebx - xorl 0x800+72(%esi,%eax,4),%edi - addl 0xC00+72(%esi,%ebx,4),%edi - xorl %edi,%ecx -') - -C_FUNCTION_BEGIN(blowfishEncrypt) - pushl %edi - pushl %esi - pushl %ebx - - movl 16(%esp),%esi - movl 24(%esp),%edi - - movl 0(%edi),%ecx - movl 4(%edi),%edx - - bswap %ecx - bswap %edx - - etworounds(0) - etworounds(8) - etworounds(16) - etworounds(24) - etworounds(32) - etworounds(40) - etworounds(48) - etworounds(56) - - movl 20(%esp),%edi - xorl 64(%esi),%ecx - xorl 68(%esi),%edx - - bswap %ecx - bswap %edx - - movl %ecx,4(%edi) - movl %edx,0(%edi) - - xorl %eax,%eax - popl %ebx - popl %esi - popl %edi - ret -C_FUNCTION_END(blowfishEncrypt) - - -C_FUNCTION_BEGIN(blowfishDecrypt) - pushl %edi - pushl %esi - pushl %ebx - - movl 16(%esp),%esi - movl 24(%esp),%edi - - movl 0(%edi),%ecx - movl 4(%edi),%edx - - bswap %ecx - bswap %edx - - dtworounds(64) - dtworounds(56) - dtworounds(48) - dtworounds(40) - dtworounds(32) - dtworounds(24) - dtworounds(16) - dtworounds(8) - - movl 20(%esp),%edi - xorl 4(%esi),%ecx - xorl 0(%esi),%edx - - bswap %ecx - bswap %edx - - movl %ecx,4(%edi) - movl %edx,0(%edi) - - xorl %eax,%eax - - popl %ebx - popl %esi - popl %edi - ret -C_FUNCTION_END(blowfishDecrypt) diff --git a/beecrypt/gas/blowfishopt.ppc.m4 b/beecrypt/gas/blowfishopt.ppc.m4 deleted file mode 100644 index 92185001d..000000000 --- a/beecrypt/gas/blowfishopt.ppc.m4 +++ /dev/null @@ -1,164 +0,0 @@ -dnl blowfishopt.ppc.m4 -dnl -dnl Note: Only tested on big-endian PowerPC! -dnl -dnl Copyright (c) 2003 Bob Deblier -dnl -dnl Author: Bob Deblier <bob.deblier@pandora.be> -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -include(config.m4) -include(ASM_SRCDIR/asmdefs.m4) -include(ASM_SRCDIR/ppc.m4) - -define(`round',` - lwz r9,$3(r3) - xor $1,$1,r9 - rlwinm r9,$1,10,22,29 - rlwinm r10,$1,18,22,29 - lwzx r9,r9,r28 - lwzx r10,r10,r29 - rlwinm r11,$1,26,22,29 - add r9,r9,r10 - lwzx r11,r11,r30 - rlwinm r12,$1,2,22,29 - xor r9,r9,r11 - lwzx r12,r12,r31 - add r9,r9,r12 - xor $2,$2,r9 -') - -define(`eblock',` - round(r7,r8,0) - round(r8,r7,4) - round(r7,r8,8) - round(r8,r7,12) - round(r7,r8,16) - round(r8,r7,20) - round(r7,r8,24) - round(r8,r7,28) - round(r7,r8,32) - round(r8,r7,36) - round(r7,r8,40) - round(r8,r7,44) - round(r7,r8,48) - round(r8,r7,52) - round(r7,r8,56) - round(r8,r7,60) - lwz r9,64(r3) - lwz r10,68(r3) - xor r7,r7,r9 - xor r8,r8,r10 -') - -define(`dblock',` - round(r7,r8,68) - round(r8,r7,64) - round(r7,r8,60) - round(r8,r7,56) - round(r7,r8,52) - round(r8,r7,48) - round(r7,r8,44) - round(r8,r7,40) - round(r7,r8,36) - round(r8,r7,32) - round(r7,r8,28) - round(r8,r7,24) - round(r7,r8,20) - round(r8,r7,16) - round(r7,r8,12) - round(r8,r7,8) - lwz r9,4(r3) - lwz r10,0(r3) - xor r7,r7,r9 - xor r8,r8,r10 -') - - -C_FUNCTION_BEGIN(blowfishEncrypt) - la r1,-16(r1) - stmw r28,0(r1) - - la r28,72(r3) - la r29,1096(r3) - la r30,2120(r3) - la r31,3144(r3) - -ifelse(ASM_BIGENDIAN,yes,` - lwz r7,0(r5) - lwz r8,4(r5) -',` - li r0,0 - lwbrx r7,r5,r0 - li r0,4 - lwbrx r8,r5,r0 -') - - eblock - -ifelse(ASM_BIGENDIAN,yes,` - stw r7,4(r4) - stw r8,0(r4) -',` - li r0,4 - stwbrx r7,r4,r0 - li r0,0 - stwbrx r8,r4,r0 -') - - li r3,0 - lmw r28,0(r1) - la r1,16(r1) - blr -C_FUNCTION_END(blowfishEncrypt) - - -C_FUNCTION_BEGIN(blowfishDecrypt) - la r1,-16(r1) - stmw r28,0(r1) - - la r28,72(r3) - la r29,1096(r3) - la r30,2120(r3) - la r31,3144(r3) - -ifelse(ASM_BIGENDIAN,yes,` - lwz r7,0(r5) - lwz r8,4(r5) -',` - li r0,0 - lwbrx r7,r5,r0 - li r0,4 - lwbrx r7,r5,r0 -') - - dblock - -ifelse(ASM_BIGENDIAN,yes,` - stw r7,4(r4) - stw r8,0(r4) -',` - li r0,4 - stwbrx r7,r4,r0 - li r0,0 - stwbrx r7,r4,r0 -') - - li r3,0 - lmw r28,0(r1) - la r1,16(r1) - blr -C_FUNCTION_END(blowfishDecrypt) diff --git a/beecrypt/gas/ia64.m4 b/beecrypt/gas/ia64.m4 deleted file mode 100644 index be857dec3..000000000 --- a/beecrypt/gas/ia64.m4 +++ /dev/null @@ -1,56 +0,0 @@ -dnl ia64.m4 -dnl -dnl Copyright (c) 2003 Bob Deblier -dnl -dnl Author: Bob Deblier <bob.deblier@pandora.be> -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -define(`saved_pfs',`r31') -define(`saved_lc',`r30') -define(`saved_pr',`r29') - -ifelse(substr(ASM_OS,0,5),linux,` -undefine(`C_FUNCTION_BEGIN') -define(C_FUNCTION_BEGIN,` - TEXTSEG - ALIGN - GLOBL SYMNAME($1)# - .proc SYMNAME($1)# -SYMNAME($1): -') -undefine(`C_FUNCTION_END') -define(C_FUNCTION_END,` - .endp SYMNAME($1)# -') -') - -ifelse(substr(ASM_OS,0,4),hpux,` -undefine(`C_FUNCTION_BEGIN') -define(C_FUNCTION_BEGIN,` - TEXTSEG - ALIGN - GLOBL SYMNAME($1) - .proc SYMNAME($1) -SYMNAME($1): -') -undefine(`C_FUNCTION_END') -define(C_FUNCTION_END,` - .endp SYMNAME($1) -') -') - - .explicit diff --git a/beecrypt/gas/m68k.m4 b/beecrypt/gas/m68k.m4 deleted file mode 100644 index ad9267875..000000000 --- a/beecrypt/gas/m68k.m4 +++ /dev/null @@ -1,54 +0,0 @@ -dnl m68k.m4 -dnl -dnl Copyright (c) 2003 Bob Deblier -dnl -dnl Author: Bob Deblier <bob.deblier@pandora.be> -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -ifelse(REGISTERS_NEED_PERCENT,yes,` -define(d0,%d0) -define(d1,%d1) -define(d2,%d2) -define(d3,%d3) -define(d4,%d4) -define(d5,%d5) -define(d6,%d6) -define(d7,%d7) -define(a0,%a0) -define(a1,%a1) -define(a2,%a2) -define(a3,%a3) -define(a4,%a4) -define(a5,%a5) -define(a6,%a6) -define(a7,%a7) -define(sp,%sp) -') -ifelse(INSTRUCTIONS_NEED_DOT_SIZE_QUALIF,yes,` -define(addal,adda.l) -define(addl,add.l) -define(addql,addq.l) -define(addxl,addx.l) -define(clrl,clr.l) -define(lsll,lsl.l) -define(movel,move.l) -define(moveml,movem.l) -define(moveal,movea.l) -define(umull,umul.l) -define(subl,sub.l) -define(subql,subq.l) -define(subxl,subx.l) -') diff --git a/beecrypt/gas/mpopt.alpha.m4 b/beecrypt/gas/mpopt.alpha.m4 deleted file mode 100644 index 1bbfd15bc..000000000 --- a/beecrypt/gas/mpopt.alpha.m4 +++ /dev/null @@ -1,160 +0,0 @@ -dnl mpopt.alpha.m4 -dnl -dnl Copyright (c) 2003 Bob Deblier -dnl -dnl Author: Bob Deblier <bob.deblier@pandora.be> -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -include(config.m4) -include(ASM_SRCDIR/asmdefs.m4) -include(ASM_SRCDIR/alpha.m4) - - -C_FUNCTION_BEGIN(mpadd) - subq `$'16,1,`$'16 - s8addq `$'16,0,`$'1 - addq `$'17,`$'1,`$'17 - addq `$'18,`$'1,`$'18 - clr `$'0 - - .align 4 -LOCAL(mpadd_loop): - ldq `$'1,0(`$'17) - ldq `$'2,0(`$'18) - addq `$'1,`$'0,`$'3 - cmpult `$'3,`$'1,`$'0 - addq `$3',`$'2,`$'1 - cmpult `$'1,`$'3,`$'2 - stq `$'1,0(`$'17) - or `$'2,`$'0,`$'0 - subq `$'16,1,`$'16 - subq `$'17,8,`$'17 - subq `$'18,8,`$'18 - bge `$'16,LOCAL(mpadd_loop) - ret `$'31,(`$'26),1 -C_FUNCTION_END(mpadd) - - -C_FUNCTION_BEGIN(mpsub) - subq `$'16,1,`$'16 - s8addq `$'16,0,`$'1 - addq `$'17,`$'1,`$'17 - addq `$'18,`$'1,`$'18 - clr `$'0 - - .align 4 -LOCAL(mpsub_loop): - ldq `$'1,0(`$'17) - ldq `$'2,0(`$'18) - subq `$'1,`$'0,`$'3 - cmpult `$'1,`$'3,`$'0 - subq `$'3,`$'2,`$'1 - cmpult `$'3,`$'1,`$'2 - stq `$'1,0(`$'17) - or `$'2,`$'0,`$'0 - subq `$'16,1,`$'16 - subq `$'17,8,`$'17 - subq `$'18,8,`$'18 - bge `$'16,LOCAL(mpsub_loop) - ret `$'31,(`$'26),1 -C_FUNCTION_END(mpsub) - - -C_FUNCTION_BEGIN(mpsetmul) - subq `$'16,1,`$'16 - s8addq `$'16,0,`$'1 - addq `$'17,`$'1,`$'17 - addq `$'18,`$'1,`$'18 - clr `$'0 - - .align 4 -LOCAL(mpsetmul_loop): - ldq `$1',0(`$'18) - mulq `$'19,`$'1,`$'2 - umulh `$'19,`$'1,`$'3 - addq `$'2,`$'0,`$'2 - cmpult `$'2,`$'0,`$'0 - stq `$'2,0(`$'17) - addq `$'3,`$'0,`$'0 - subq `$'16,1,`$'16 - subq `$'17,8,`$'17 - subq `$'18,8,`$'18 - bge `$'16,LOCAL(mpsetmul_loop) - ret `$'31,(`$'26),1 -C_FUNCTION_END(mpsetmul) - - -C_FUNCTION_BEGIN(mpaddmul) - subq `$'16,1,`$'16 - s8addq `$'16,0,`$'1 - addq `$'17,`$'1,`$'17 - addq `$'18,`$'1,`$'18 - clr `$'0 - - .align 4 -LOCAL(mpaddmul_loop): - ldq `$'1,0(`$'17) - ldq `$'2,0(`$'18) - mulq `$'19,`$'2,`$'3 - umulh `$'19,`$'2,`$'4 - addq `$'3,`$'0,`$'3 - cmpult `$'3,`$'0,`$'0 - addq `$'4,`$'0,`$'4 - addq `$'3,`$'1,`$'3 - cmpult `$'3,`$'1,`$'0 - addq `$'4,`$'0,`$'0 - stq `$'3,0(`$'17) - subq `$'16,1,`$'16 - subq `$'17,8,`$'17 - subq `$'18,8,`$'18 - bge `$'16,LOCAL(mpaddmul_loop) - ret `$'31,(`$'26),1 -C_FUNCTION_END(mpaddmul) - - -C_FUNCTION_BEGIN(mpaddsqrtrc) - subq `$'16,1,`$'16 - s8addq `$'16,0,`$'1 - addq `$'17,`$'1,`$'17 - addq `$'18,`$'1,`$'18 - addq `$'17,`$'1,`$'17 - clr `$'0 - - .align 4 -LOCAL(mpaddsqrtrc_loop): - ldq `$'1,0(`$'18) - mulq `$1',`$1',`$'2 - umulh `$1',`$1',`$'1 - addq `$'2,`$'0,`$'3 - cmpult `$3',`$'2,`$'0 - ldq `$'2,8(`$'17) - addq `$'1,`$'0,`$'1 - addq `$'3,`$'2,`$'4 - cmpult `$'4,`$'3,`$'0 - ldq `$'3,0(`$'17) - addq `$'1,`$'0,`$'2 - cmpult `$2',`$'1,`$'0 - stq `$'4,8(`$'17) - addq `$'2,`$'3,`$'1 - cmpult `$'1,`$'2,`$2' - stq `$'1,0(`$'17) - addq `$'2,`$'0,`$'0 - subq `$'16,1,`$'16 - subq `$'17,16,`$'17 - subq `$'18,8,`$'18 - bge `$'16,LOCAL(mpaddsqrtrc_loop) - ret `$'31,(`$'26),1 -C_FUNCTION_END(mpaddsqrtrc) diff --git a/beecrypt/gas/mpopt.arm.m4 b/beecrypt/gas/mpopt.arm.m4 deleted file mode 100644 index dd298cfec..000000000 --- a/beecrypt/gas/mpopt.arm.m4 +++ /dev/null @@ -1,84 +0,0 @@ -dnl mpopt.arm.m4 -dnl -dnl Copyright (c) 2003 Bob Deblier -dnl -dnl Author: Bob Deblier <bob.deblier@pandora.be> -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -include(config.m4) -include(ASM_SRCDIR/asmdefs.m4) - - -C_FUNCTION_BEGIN(mpsetmul) - stmfd sp!, {r4, r5, lr} - add r1, r1, r0, asl #2 - add r2, r2, r0, asl #2 - mov ip, #0 -LOCAL(mpsetmul_loop): - ldr r4, [r2, #-4]! - mov r5, #0 - umlal ip, r5, r3, r4 - str ip, [r1, #-4]! - mov ip, r5 - subs r0, r0, #1 - bne LOCAL(mpsetmul_loop) - mov r0, ip - ldmfd sp!, {r4, r5, pc} -C_FUNCTION_END(mpsetmul) - - -C_FUNCTION_BEGIN(mpaddmul) - stmfd sp!, {r4, r5, r6, lr} - add r1, r1, r0, asl #2 - add r2, r2, r0, asl #2 - mov ip, #0 -LOCAL(mpaddmul_loop): - ldr r4, [r2, #-4]! - ldr r5, [r1, #-4] - mov r6, #0 - umlal ip, r6, r3, r4 - adds r5, r5, ip - adc ip, r6, #0 - str r5, [r1, #-4]! - subs r0, r0, #1 - bne LOCAL(mpaddmul_loop) - mov r0, ip - ldmfd sp!, {r4, r5, r6, pc} -C_FUNCTION_END(mpaddmul) - - -C_FUNCTION_BEGIN(mpaddsqrtrc) - stmfd sp!, {r4, r5, r6, lr} - add r1, r1, r0, asl #3 - add r2, r2, r0, asl #2 - mov r3, #0 - mov ip, #0 -LOCAL(mpaddsqrtrc_loop): - ldr r4, [r2, #-4]! - mov r6, #0 - umlal ip, r6, r4, r4 - ldr r5, [r1, #-4] - ldr r4, [r1, #-8] - adds r5, r5, ip - adcs r4, r4, r6 - str r5, [r1, #-4] - str r4, [r1, #-8]! - adc ip, r3, #0 - subs r0, r0, #1 - bne LOCAL(mpaddsqrtrc_loop) - mov r0, ip - ldmfd sp!, {r4, r5, r6, pc} -C_FUNCTION_END(mpaddsqrtrc) diff --git a/beecrypt/gas/mpopt.ia64.m4 b/beecrypt/gas/mpopt.ia64.m4 deleted file mode 100644 index 290fdb6ad..000000000 --- a/beecrypt/gas/mpopt.ia64.m4 +++ /dev/null @@ -1,369 +0,0 @@ -dnl mpopt.ia64.m4 -dnl -dnl Copyright (c) 2003 Bob Deblier -dnl -dnl Author: Bob Deblier <bob.deblier@pandora.be> -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -include(config.m4) -include(ASM_SRCDIR/asmdefs.m4) -include(ASM_SRCDIR/ia64.m4) - -define(`sze',`r14') -define(`dst',`r15') -define(`src',`r16') -define(`alt',`r17') - - -C_FUNCTION_BEGIN(mpzero) - .prologue - alloc saved_pfs = ar.pfs,2,0,0,0 - mov saved_lc = ar.lc - sub sze = in0,r0,1;; - -dnl adjust address - shladd dst = sze,3,in1 - -dnl prepare loop - mov ar.lc = sze;; - - .body -LOCAL(mpzero_loop): - st8 [dst] = r0,-8 - br.ctop.dptk LOCAL(mpzero_loop);; - - mov ar.lc = saved_lc - mov ar.pfs = saved_pfs - br.ret.sptk b0 -C_FUNCTION_END(mpzero) - - -C_FUNCTION_BEGIN(mpcopy) - .prologue - alloc saved_pfs = ar.pfs,3,6,0,8 - mov saved_lc = ar.lc - mov saved_pr = pr - sub sze = in0,r0,1;; - -dnl adjust addresses - shladd dst = sze,3,in1 - shladd src = sze,3,in2 - -dnl prepare modulo-scheduled loop - mov ar.lc = sze - mov ar.ec = 1 - mov pr.rot = (1 << 16);; - -LOCAL(mpcopy_loop): - (p16) ld8 r32 = [src],-8 - (p17) st8 [dst] = r33,-8 - br.ctop.dptk LOCAL(mpcopy_loop);; - -dnl epilogue - (p17) st8 [dst] = r33,-8 - ;; - - mov pr = saved_pr, -1 - mov ar.lc = saved_lc - mov ar.pfs = saved_pfs - br.ret.sptk b0 -C_FUNCTION_END(mpcopy) - - -C_FUNCTION_BEGIN(mpadd) - .prologue - alloc saved_pfs = ar.pfs,3,5,0,8 - mov saved_lc = ar.lc - mov saved_pr = pr - sub sze = in0,r0,1;; - -dnl adjust addresses - shladd dst = sze,3,in1 - shladd src = sze,3,in2 - shladd alt = sze,3,in1 - -dnl prepare modulo-scheduled loop - mov ar.lc = sze - mov ar.ec = 2 - mov pr.rot = ((1 << 16) | (1 << 19));; - - .body -LOCAL(mpadd_loop): - .pred.rel.mutex p20,p22 - (p16) ld8 r32 = [alt],-8 - (p16) ld8 r35 = [src],-8 - (p20) add r36 = r33,r36 - (p22) add r36 = r33,r36,1 - ;; - (p20) cmp.leu p19,p21 = r33,r36 - (p22) cmp.ltu p19,p21 = r33,r36 - (p18) st8 [dst] = r37,-8 - br.ctop.dptk LOCAL(mpadd_loop);; - -dnl loop epilogue: final store - (p18) st8 [dst] = r37,-8 - -dnl return carry - .pred.rel.mutex p20,p22 - (p20) add ret0 = r0,r0 - (p22) add ret0 = r0,r0,1 - ;; - mov pr = saved_pr, -1 - mov ar.lc = saved_lc - mov ar.pfs = saved_pfs - br.ret.sptk b0 -C_FUNCTION_END(mpadd) - - -C_FUNCTION_BEGIN(mpsub) - .prologue - alloc saved_pfs = ar.pfs,3,5,0,8 - mov saved_lc = ar.lc - mov saved_pr = pr - sub sze = in0,r0,1;; - -dnl adjust addresses - shladd dst = sze,3,in1 - shladd src = sze,3,in2 - shladd alt = sze,3,in1 - -dnl prepare modulo-scheduled loop - mov ar.lc = sze - mov ar.ec = 2 - mov pr.rot = ((1 << 16) | (1 << 19));; - - .body -LOCAL(mpsub_loop): - .pred.rel.mutex p20,p22 - (p16) ld8 r32 = [alt],-8 - (p16) ld8 r35 = [src],-8 - (p20) sub r36 = r33,r36 - (p22) sub r36 = r33,r36,1 - ;; - (p20) cmp.geu p19,p21 = r33,r36 - (p22) cmp.gtu p19,p21 = r33,r36 - (p18) st8 [dst] = r37,-8 - br.ctop.dptk LOCAL(mpsub_loop);; - -dnl loop epilogue: final store - (p18) st8 [dst] = r37,-8 - -dnl return carry - .pred.rel.mutex p20,p22 - (p20) add ret0 = r0,r0 - (p22) add ret0 = r0,r0,1 - ;; - mov pr = saved_pr, -1 - mov ar.lc = saved_lc - mov ar.pfs = saved_pfs - br.ret.sptk b0 -C_FUNCTION_END(mpsub) - - -C_FUNCTION_BEGIN(mpmultwo) - .prologue - alloc saved_pfs = ar.pfs,2,6,0,8 - mov saved_lc = ar.lc - mov saved_pr = pr - sub sze = in0,r0,1;; - -dnl adjust addresses - shladd dst = sze,3,in1 - shladd src = sze,3,in1 - -dnl prepare modulo-scheduled loop - mov ar.lc = sze - mov ar.ec = 2 - mov pr.rot = ((1 << 16) | (1 << 19));; - - .body -LOCAL(mpmultwo): - .pred.rel.mutex p20,p22 - (p16) ld8 r32 = [src],-8 - (p20) add r36 = r33,r33 - (p22) add r36 = r33,r33,1 - ;; - (p20) cmp.leu p19,p21 = r33,r36 - (p22) cmp.ltu p19,p21 = r33,r36 - (p18) st8 [dst] = r37,-8 - br.ctop.dptk LOCAL(mpmultwo);; - -dnl loop epilogue: final store - (p18) st8 [dst] = r37,-8 - -dnl return carry - .pred.rel.mutex p20,p22 - (p20) add ret0 = r0,r0 - (p22) add ret0 = r0,r0,1 - ;; - mov pr = saved_pr, -1 - mov ar.lc = saved_lc - mov ar.pfs = saved_pfs - br.ret.sptk b0 -C_FUNCTION_END(mpmultwo) - - -C_FUNCTION_BEGIN(mpsetmul) - .prologue - alloc saved_pfs = ar.pfs,4,4,0,8 - mov saved_lc = ar.lc - mov saved_pr = pr - - setf.sig f6 = in3 - setf.sig f7 = r0 - sub sze = in0,r0,1;; - -dnl adjust addresses - shladd dst = sze,3,in1 - shladd src = sze,3,in2 - -dnl prepare modulo-scheduled loop - mov ar.lc = sze - mov ar.ec = 3 - mov pr.rot = (1 << 16);; - - .body -LOCAL(mpsetmul_loop): - (p16) ldf8 f32 = [src],-8 - (p18) stf8 [dst] = f35,-8 - (p17) xma.lu f34 = f6,f33,f7 - (p17) xma.hu f7 = f6,f33,f7 - br.ctop.dptk LOCAL(mpsetmul_loop);; - -dnl return carry - getf.sig ret0 = f7;; - - mov pr = saved_pr, -1 - mov ar.lc = saved_lc - mov ar.pfs = saved_pfs - br.ret.sptk b0 -C_FUNCTION_END(mpsetmul) - - -C_FUNCTION_BEGIN(mpaddmul) - .prologue - alloc saved_pfs = ar.pfs,4,4,0,8 - mov saved_lc = ar.lc - mov saved_pr = pr - - setf.sig f6 = in3 - sub sze = in0,r0,1;; - -dnl adjust addresses - shladd dst = sze,3,in1 - shladd src = sze,3,in2 - shladd alt = sze,3,in1;; - -dnl prepare the rotate-in carry - mov r32 = r0 - -dnl prepare modulo-scheduled loop - mov ar.lc = sze - mov ar.ec = 4 - mov pr.rot = ((1 << 16) | (1 << 21));; - - .body -LOCAL(mpaddmul_loop): - .pred.rel.mutex p24,p26 - (p18) getf.sig r37 = f35 - (p24) add r35 = r38,r35 - (p17) xma.lu f34 = f6,f33,f37 - (p18) getf.sig r33 = f39 - (p26) add r35 = r38,r35,1 - (p17) xma.hu f38 = f6,f33,f37 - (p16) ldf8 f32 = [src],-8 - (p16) ldf8 f36 = [alt],-8 - ;; -dnl set carry from this operation - (p24) cmp.leu p23,p25 = r38,r35 - (p26) cmp.ltu p23,p25 = r38,r35 - (p20) st8 [dst] = r36,-8 - br.ctop.dptk LOCAL(mpaddmul_loop);; - -dnl loop epilogue: final store - (p20) st8 [dst] = r36,-8 - -dnl return carry - .pred.rel.mutex p24,p26 - (p24) add ret0 = r35,r0 - (p26) add ret0 = r35,r0,1 - - mov pr = saved_pr, -1 - mov ar.lc = saved_lc - mov ar.pfs = saved_pfs - br.ret.sptk b0 -C_FUNCTION_END(mpaddmul) - - -divert(-1) -C_FUNCTION_BEGIN(mpaddsqrtrc) - .prologue - alloc saved_pfs = ar.pfs,4,12,0,16 - mov saved_lc = ar.lc - mov saved_pr = pr - - setf.sig f6 = in3 - sub sze = in0,r0,1;; - -dnl adjust addresses -dnl use two addresses for dst, and two for src - shladd ? = sze,4,in1 - shladd ? = sze,4,in1 - shladd ? = sze,3,in2 - shladd ? = sze,3,in2;; - -dnl prepare the rotate-in carry - mov r32 = r0 - -dnl prepare modulo-scheduled loop - mov ar.lc = sze - mov ar.ec = 5 - mov pr.rot = ((1 << 16) | (1 << 22));; - - .body -LOCAL(mpaddsqrtrc_loop): - (p16) ldf8 f32 = [src],-8 - (p17) xma.lu f34 = f33,f33,f37 - (p17) xma.hu f38 = f33,f33,f37 - (p18) getf.sig r32 = f35 - (p18) getf.sig r35 = f39 - (p18) ld8 rlo = [alt],-8 - .pred.rel.mutex p25,p29 - (p25) add r33 = r33,r?? - (p29) add r37 = r37,r??,1 - .pred.rel.mutex p27,p31 - (p27) add hi to carry - (p31) add hi to carry+1 - ;; - (p16) ld8 r42 = [alt],-8 - (p25) cmpleu p24,p28 = lo - (p29) cmpltu p24,p28 = lo - (p20) st8 lo - (p27) cmpleu p26,p30 = hi - (p31) cmpltu p26,p30 = hi - (p21) st8 hi - ;; - br.ctop.dptk LOCAL(mpaddsqrtrc_loop);; - -dnl loop epilogue: final store - (p21) st8 [dst] = r36,-8 - - mov pr = saved_pr, -1 - mov ar.lc = saved_lc - mov ar.pfs = saved_pfs - br.ret.sptk b0 -C_FUNCTION_END(mpaddsqrtrc) -divert(0) diff --git a/beecrypt/gas/mpopt.m68k.m4 b/beecrypt/gas/mpopt.m68k.m4 deleted file mode 100644 index defc8f173..000000000 --- a/beecrypt/gas/mpopt.m68k.m4 +++ /dev/null @@ -1,159 +0,0 @@ -dnl mpopt.m68k.m4 -dnl -dnl Copyright (c) 2003 Bob Deblier -dnl -dnl Author: Bob Deblier <bob.deblier@pandora.be> -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -include(config.m4) -include(ASM_SRCDIR/asmdefs.m4) -include(ASM_SRCDIR/m68k.m4) - -dnl works -C_FUNCTION_BEGIN(mpadd) - move.l 4(%sp),%d0 - movea.l 8(%sp),%a0 - movea.l 12(%sp),%a1 - move.l %d0,%d1 - lsl.l #2,%d0 - subq.l #1,%d1 - adda.l %d0,%a0 - adda.l %d0,%a1 - clr %d0 - - .align 2 -LOCAL(mpadd_loop): - addx.l -(%a1),-(%a0) - dbf %d1,LOCAL(mpadd_loop) - - addx.l %d0,%d0 - rts -C_FUNCTION_END(mpadd) - -dnl works -C_FUNCTION_BEGIN(mpsub) - move.l 4(%sp),%d0 - movea.l 8(%sp),%a0 - movea.l 12(%sp),%a1 - move.l %d0,%d1 - lsl.l #2,%d0 - subq.l #1,%d1 - adda.l %d0,%a0 - adda.l %d0,%a1 - clr %d0 - - .align 2 -LOCAL(mpsub_loop): - subx.l -(%a1),-(%a0) - dbf %d1,LOCAL(mpsub_loop) - - addx.l %d0,%d0 - rts -C_FUNCTION_END(mpsub) - -dnl works -C_FUNCTION_BEGIN(mpsetmul) - movem.l %d2-%d5,-(%sp) - move.l 20(%sp),%d0 - movea.l 24(%sp),%a0 - movea.l 28(%sp),%a1 - move.l 32(%sp),%d2 - move.l %d0,%d5 - lsl.l #2,%d0 - subq.l #1,%d5 - adda.l %d0,%a0 - adda.l %d0,%a1 - clr.l %d3 - clr.l %d4 - - .align 2 -LOCAL(mpsetmul_loop): - move.l -(%a1),%d1 - mulu.l %d2,%d0:%d1 - add.l %d3,%d1 - addx.l %d4,%d0 - move.l %d1,-(%a0) - move.l %d0,%d3 - dbf %d5,LOCAL(mpsetmul_loop) - - movem.l (%sp)+,%d2-%d5 - rts -C_FUNCTION_END(mpsetmul) - -dnl works -C_FUNCTION_BEGIN(mpaddmul) - movem.l %d2-%d5,-(%sp) - move.l 20(%sp),%d0 - movea.l 24(%sp),%a0 - movea.l 28(%sp),%a1 - move.l 32(%sp),%d2 - move.l %d0,%d5 - lsl.l #2,%d0 - subq.l #1,%d5 - adda.l %d0,%a0 - adda.l %d0,%a1 - clr.l %d3 - clr.l %d4 - - .align 2 -LOCAL(mpaddmul_loop): - move.l -(%a1),%d1 - mulu.l %d2,%d0:%d1 - add.l %d3,%d1 - addx.l %d4,%d0 - add.l -(%a0),%d1 - addx.l %d4,%d0 - move.l %d1,(%a0) - move.l %d0,%d3 - dbf %d5,LOCAL(mpaddmul_loop) - - movem.l (%sp)+,%d2-%d5 - rts -C_FUNCTION_END(mpaddmul) - - -C_FUNCTION_BEGIN(mpaddsqrtrc) - movem.l %d3-%d5,-(%sp) - move.l 16(%sp),%d0 - movea.l 20(%sp),%a0 - movea.l 24(%sp),%a1 - move.l %d0,%d5 - lsl.l #2,%d0 - subq.l #1,%d5 - adda.l %d0,%a0 - adda.l %d0,%a0 - adda.l %d0,%a1 - clr.l %d3 - clr.l %d4 - -LOCAL(mpaddsqrtrc_loop): - move.l -(%a1),%d1 -dnl square %d1 into %d0 and %d1 - mulu.l %d1,%d0:%d1 - add.l %d3,%d1 - addx.l %d4,%d0 - add.l -(%a0),%d1 - addx.l %d4,%d0 - move.l %d1,(%a0) - clr.l %d3 - add.l -(%a0),%d0 - addx.l %d4,%d3 - move.l %d0,0(%a0) - dbf %d5,LOCAL(mpaddsqrtrc_loop) - - movem.l (%sp)+,%d3-%d5 - rts -C_FUNCTION_END(mpaddsqrtrc) diff --git a/beecrypt/gas/mpopt.ppc.m4 b/beecrypt/gas/mpopt.ppc.m4 deleted file mode 100644 index 54bb32b67..000000000 --- a/beecrypt/gas/mpopt.ppc.m4 +++ /dev/null @@ -1,196 +0,0 @@ -dnl mpopt.ppc.m4 -dnl -dnl Copyright (c) 2003 Bob Deblier -dnl -dnl Author: Bob Deblier <bob.deblier@pandora.be> -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -include(config.m4) -include(ASM_SRCDIR/asmdefs.m4) -include(ASM_SRCDIR/ppc.m4) - - -C_FUNCTION_BEGIN(mpaddw) - mtctr r3 - slwi r0,r3,2 - add r4,r4,r0 - li r0,0 - lwzu r6,-4(r4) - addc r6,r6,r5 - stw r6,0(r4) - bdz LOCAL(mpaddw_skip) -LOCAL(mpaddw_loop): - lwzu r6,-4(r4) - adde r6,r0,r6 - stw r6,0(r4) - bdnz LOCAL(mpaddw_loop) -LOCAL(mpaddw_skip): - addze r3,r0 - blr -C_FUNCTION_END(mpaddw) - - -C_FUNCTION_BEGIN(mpsubw) - mtctr r3 - slwi r0,r3,2 - add r4,r4,r0 - li r0,0 - lwz r6,-4(r4) - subfc r6,r5,r6 - stwu r6,-4(r4) - bdz LOCAL(mpsubw_skip) -LOCAL(mpsubw_loop): - lwz r6,-4(r4) - subfe r6,r0,r6 - stwu r6, -4(r4) - bdnz LOCAL(mpsubw_loop) -LOCAL(mpsubw_skip): - subfe r3,r0,r0 - neg r3,r3 - blr -C_FUNCTION_END(mpsubw) - - -C_FUNCTION_BEGIN(mpadd) - mtctr r3 - slwi r0,r3,2 - add r4,r4,r0 - add r5,r5,r0 - li r0,0 - lwz r6,-4(r4) - lwzu r7,-4(r5) - addc r6,r7,r6 - stwu r6,-4(r4) - bdz LOCAL(mpadd_skip) -LOCAL(mpadd_loop): - lwz r6,-4(r4) - lwzu r7,-4(r5) - adde r6,r7,r6 - stwu r6,-4(r4) - bdnz LOCAL(mpadd_loop) -LOCAL(mpadd_skip): - addze r3,r0 - blr -C_FUNCTION_END(mpadd) - - -C_FUNCTION_BEGIN(mpsub) - mtctr r3 - slwi r0,r3,2 - add r4,r4,r0 - add r5,r5,r0 - li r0,0 - lwz r6,-4(r4) - lwzu r7,-4(r5) - subfc r6,r7,r6 - stwu r6,-4(r4) - bdz LOCAL(mpsub_skip) -LOCAL(mpsub_loop): - lwz r6,-4(r4) - lwzu r7,-4(r5) - subfe r6,r7,r6 - stwu r6,-4(r4) - bdnz LOCAL(mpsub_loop) -LOCAL(mpsub_skip): - subfe r3,r0,r0 - neg r3,r3 - blr -C_FUNCTION_END(mpsub) - - -C_FUNCTION_BEGIN(mpmultwo) - mtctr r3 - slwi r0,r3,2 - add r4,r4,r0 - li r0,0 - lwz r6,-4(r4) - addc r6,r6,r6 - stwu r6,-4(r4) - bdz LOCAL(mpmultwo_skip) -LOCAL(mpmultwo_loop): - lwz r6,-4(r4) - adde r6,r6,r6 - stwu r6,-4(r4) - bdnz LOCAL(mpmultwo_loop) -LOCAL(mpmultwo_skip): - addze r3,r0 - blr -C_FUNCTION_END(mpmultwo) - - -C_FUNCTION_BEGIN(mpsetmul) - mtctr r3 - slwi r0,r3,2 - add r4,r4,r0 - add r5,r5,r0 - li r3,0 -LOCAL(mpsetmul_loop): - lwzu r7,-4(r5) - mullw r8,r7,r6 - addc r8,r8,r3 - mulhwu r9,r7,r6 - addze r3,r9 - stwu r8,-4(r4) - bdnz LOCAL(mpsetmul_loop) - blr -C_FUNCTION_END(mpsetmul) - - -C_FUNCTION_BEGIN(mpaddmul) - mtctr r3 - slwi r0,r3,2 - add r4,r4,r0 - add r5,r5,r0 - li r3,0 -LOCAL(mpaddmul_loop): - lwzu r8,-4(r5) - lwzu r7,-4(r4) - mullw r9,r8,r6 - addc r9,r9,r3 - mulhwu r10,r8,r6 - addze r3,r10 - addc r9,r9,r7 - addze r3,r3 - stw r9,0(r4) - bdnz LOCAL(mpaddmul_loop) - blr -C_FUNCTION_END(mpaddmul) - - -C_FUNCTION_BEGIN(mpaddsqrtrc) - mtctr r3 - slwi r0,r3,2 - add r4,r4,r0 - add r5,r5,r0 - add r4,r4,r0 - li r3,0 -LOCAL(mpaddsqrtrc_loop): - lwzu r0,-4(r5) - lwz r6,-8(r4) - lwz r7,-4(r4) - mullw r9,r0,r0 - addc r9,r9,r3 - mulhwu r8,r0,r0 - addze r8,r8 - li r3,0 - addc r7,r7,r9 - adde r6,r6,r8 - addze r3,r3 - stw r7,-4(r4) - stwu r6,-8(r4) - bdnz LOCAL(mpaddsqrtrc_loop) - blr -C_FUNCTION_END(mpaddsqrtrc) diff --git a/beecrypt/gas/mpopt.ppc64.m4 b/beecrypt/gas/mpopt.ppc64.m4 deleted file mode 100644 index 348b101e2..000000000 --- a/beecrypt/gas/mpopt.ppc64.m4 +++ /dev/null @@ -1,196 +0,0 @@ -dnl mpopt.ppc64.m4 -dnl -dnl Copyright (c) 2003 Bob Deblier -dnl -dnl Author: Bob Deblier <bob.deblier@pandora.be> -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -include(config.m4) -include(ASM_SRCDIR/asmdefs.m4) -include(ASM_SRCDIR/ppc64.m4) - - -C_FUNCTION_BEGIN(mpaddw) - mtctr r3 - sldi r0,r3,3 - add r4,r4,r0 - li r0,0 - ldu r6,-8(r4) - addc r6,r6,r5 - std r6,0(r4) - bdz LOCAL(mpaddw_skip) -LOCAL(mpaddw_loop): - ldu r6,-8(r4) - adde r6,r0,r6 - std r6,0(r4) - bdnz LOCAL(mpaddw_loop) -LOCAL(mpaddw_skip): - addze r3,r0 - blr -C_FUNCTION_END(mpaddw) - - -C_FUNCTION_BEGIN(mpsubw) - mtctr r3 - sldi r0,r3,3 - add r4,r4,r0 - li r0,0 - ld r6,-8(r4) - subfc r6,r5,r6 - stdu r6,-8(r4) - bdz LOCAL(mpsubw_skip) -LOCAL(mpsubw_loop): - ld r6,-8(r4) - subfe r6,r0,r6 - stdu r6, -8(r4) - bdnz LOCAL(mpsubw_loop) -LOCAL(mpsubw_skip): - subfe r3,r0,r0 - neg r3,r3 - blr -C_FUNCTION_END(mpsubw) - - -C_FUNCTION_BEGIN(mpadd) - mtctr r3 - sldi r0,r3,3 - add r4,r4,r0 - add r5,r5,r0 - li r0,0 - ld r6,-8(r4) - ldu r7,-8(r5) - addc r6,r7,r6 - stdu r6,-8(r4) - bdz LOCAL(mpadd_skip) -LOCAL(mpadd_loop): - ld r6,-8(r4) - ldu r7,-8(r5) - adde r6,r7,r6 - stdu r6,-8(r4) - bdnz LOCAL(mpadd_loop) -LOCAL(mpadd_skip): - addze r3,r0 - blr -C_FUNCTION_END(mpadd) - - -C_FUNCTION_BEGIN(mpsub) - mtctr r3 - sldi r0,r3,3 - add r4,r4,r0 - add r5,r5,r0 - li r0,0 - ld r6,-8(r4) - ldu r7,-8(r5) - subfc r6,r7,r6 - stdu r6,-8(r4) - bdz LOCAL(mpsub_skip) -LOCAL(mpsub_loop): - ld r6,-8(r4) - ldu r7,-8(r5) - subfe r6,r7,r6 - stdu r6,-8(r4) - bdnz LOCAL(mpsub_loop) -LOCAL(mpsub_skip): - subfe r3,r0,r0 - neg r3,r3 - blr -C_FUNCTION_END(mpsub) - - -C_FUNCTION_BEGIN(mpmultwo) - mtctr r3 - sldi r0,r3,3 - add r4,r4,r0 - li r0,0 - ld r6,-8(r4) - addc r6,r6,r6 - stdu r6,-8(r4) - bdz LOCAL(mpmultwo_skip) -LOCAL(mpmultwo_loop): - ld r6,-8(r4) - adde r6,r6,r6 - stdu r6,-8(r4) - bdnz LOCAL(mpmultwo_loop) -LOCAL(mpmultwo_skip): - addze r3,r0 - blr -C_FUNCTION_END(mpmultwo) - - -C_FUNCTION_BEGIN(mpsetmul) - mtctr r3 - sldi r0,r3,3 - add r4,r4,r0 - add r5,r5,r0 - li r3,0 -LOCAL(mpsetmul_loop): - ldu r7,-8(r5) - mulld r8,r7,r6 - addc r8,r8,r3 - mulhdu r9,r7,r6 - addze r3,r9 - stdu r8,-8(r4) - bdnz LOCAL(mpsetmul_loop) - blr -C_FUNCTION_END(mpsetmul) - - -C_FUNCTION_BEGIN(mpaddmul) - mtctr r3 - sldi r0,r3,3 - add r4,r4,r0 - add r5,r5,r0 - li r3,0 -LOCAL(mpaddmul_loop): - ldu r8,-8(r5) - ldu r7,-8(r4) - mulld r9,r8,r6 - addc r9,r9,r3 - mulhdu r10,r8,r6 - addze r3,r10 - addc r9,r9,r7 - addze r3,r3 - std r9,0(r4) - bdnz LOCAL(mpaddmul_loop) - blr -C_FUNCTION_END(mpaddmul) - - -C_FUNCTION_BEGIN(mpaddsqrtrc) - mtctr r3 - sldi r0,r3,3 - add r4,r4,r0 - add r5,r5,r0 - add r4,r4,r0 - li r3,0 -LOCAL(mpaddsqrtrc_loop): - ldu r0,-8(r5) - ld r6,-16(r4) - ld r7,-8(r4) - mulld r9,r0,r0 - addc r9,r9,r3 - mulhdu r8,r0,r0 - addze r8,r8 - li r3,0 - addc r7,r7,r9 - adde r6,r6,r8 - addze r3,r3 - std r7,-8(r4) - stdu r6,-16(r4) - bdnz LOCAL(mpaddsqrtrc_loop) - blr -C_FUNCTION_END(mpaddsqrtrc) diff --git a/beecrypt/gas/mpopt.s390x.m4 b/beecrypt/gas/mpopt.s390x.m4 deleted file mode 100644 index 80816dbd2..000000000 --- a/beecrypt/gas/mpopt.s390x.m4 +++ /dev/null @@ -1,97 +0,0 @@ -dnl mpopt.s390x.m4 -dnl -dnl Copyright (c) 2003, 2004 Bob Deblier -dnl -dnl Author: Bob Deblier <bob.deblier@telenet.be> -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -include(config.m4) -include(ASM_SRCDIR/asmdefs.m4) - - -C_FUNCTION_BEGIN(mpsetmul) - stmg %r6,%r7,48(%r15) - sllg %r6,%r2,3 - aghi %r6,-8 - xgr %r2,%r2 - xgr %r7,%r7 - -LOCAL(mpsetmul_loop): - lgr %r1,%r5 - mlg %r0,0(%r4,%r6) - algr %r1,%r2 - alcgr %r0,%r7 - stg %r1,0(%r3,%r6) - lgr %r2,%r0 - aghi %r6,-8 - jhe LOCAL(mpsetmul_loop) - - lmg %r6,%r7,48(%r15) - br %r14 -C_FUNCTION_END(mpsetmul) - - -C_FUNCTION_BEGIN(mpaddmul) - stmg %r6,%r7,48(%r15) - sllg %r6,%r2,3 - aghi %r6,-8 - xgr %r2,%r2 - xgr %r7,%r7 - -LOCAL(mpaddmul_loop): - lgr %r1,%r5 - mlg %r0,0(%r4,%r6) - algr %r1,%r2 - alcgr %r0,%r7 - alg %r1,0(%r3,%r6) - alcgr %r0,%r7 - stg %r1,0(%r3,%r6) - lgr %r2,%r0 - aghi %r6,-8 - jhe LOCAL(mpaddmul_loop) - - lmg %r6,%r7,48(%r15) - br %r14 -C_FUNCTION_END(mpaddmul) - - -C_FUNCTION_BEGIN(mpaddsqrtrc) - stmg %r6,%r7,48(%r15) - sllg %r5,%r2,3 - sllg %r6,%r2,4 - aghi %r5,-8 - aghi %r6,-16 - xgr %r2,%r2 - xgr %r7,%r7 - -LOCAL(mpaddsqrtrc_loop): - lg %r1,0(%r4,%r5) - mlg %r0,0(%r4,%r5) - algr %r1,%r2 - alcgr %r0,%r7 - xgr %r2,%r2 - alg %r1,8(%r3,%r6) - alcg %r0,0(%r3,%r6) - alcgr %r2,%r7 - stg %r1,8(%r3,%r6) - stg %r0,0(%r3,%r6) - aghi %r5,-8 - aghi %r6,-16 - jhe LOCAL(mpaddsqrtrc_loop) - - lmg %r6,%r7,48(%r15) - br %r14 -C_FUNCTION_END(mpaddsqrtrc) diff --git a/beecrypt/gas/mpopt.sparcv8.m4 b/beecrypt/gas/mpopt.sparcv8.m4 deleted file mode 100644 index b5306e85a..000000000 --- a/beecrypt/gas/mpopt.sparcv8.m4 +++ /dev/null @@ -1,91 +0,0 @@ -dnl mpopt.sparcv8.m4 -dnl -dnl Copyright (c) 2003 Bob Deblier -dnl -dnl Author: Bob Deblier <bob.deblier@pandora.be> -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -include(config.m4) -include(ASM_SRCDIR/asmdefs.m4) -include(ASM_SRCDIR/sparc.m4) - - -C_FUNCTION_BEGIN(mpsetmul) - sll %o0,2,%g1 - dec 4,%o2 - clr %o0 -LOCAL(mpsetmul_loop): - ld [%o2+%g1],%g2 - umul %o3,%g2,%g2 - rd %y,%g3 - addcc %o0,%g2,%g2 - addx %g0,%g3,%o0 - deccc 4,%g1 - bnz LOCAL(mpsetmul_loop) - st %g2,[%o1+%g1] - retl - nop -C_FUNCTION_END(mpsetmul) - - -C_FUNCTION_BEGIN(mpaddmul) - sll %o0,2,%g1 - mov %o1,%o4 - dec 4,%o1 - dec 4,%o2 - clr %o0 -LOCAL(mpaddmul_loop): - ld [%o2+%g1],%g2 - ld [%o1+%g1],%g3 - umul %o3,%g2,%g2 - rd %y,%g4 - addcc %o0,%g2,%g2 - addx %g0,%g4,%g4 - addcc %g2,%g3,%g2 - addx %g0,%g4,%o0 - deccc 4,%g1 - bnz LOCAL(mpaddmul_loop) - st %g2,[%o4+%g1] - retl - nop -C_FUNCTION_END(mpaddmul) - - -C_FUNCTION_BEGIN(mpaddsqrtrc) - sll %o0,2,%g1 - add %o1,%g1,%o1 - dec 4,%o2 - add %o1,%g1,%o1 - dec 8,%o1 - clr %o0 -LOCAL(mpaddsqrtrc_loop): - ld [%o2+%g1],%g2 - ldd [%o1],%o4 - umul %g2,%g2,%g3 - rd %y,%g2 - addcc %o5,%g3,%o5 - addxcc %o4,%g2,%o4 - addx %g0,%g0,%o3 - addcc %o5,%o0,%o5 - addxcc %o4,%g0,%o4 - addx %o3,%g0,%o0 - std %o4,[%o1] - deccc 4,%g1 - bnz LOCAL(mpaddsqrtrc_loop) - sub %o1,8,%o1 - retl - nop -C_FUNCTION_END(mpaddsqrtrc) diff --git a/beecrypt/gas/mpopt.sparcv8plus.m4 b/beecrypt/gas/mpopt.sparcv8plus.m4 deleted file mode 100644 index 44962b8b4..000000000 --- a/beecrypt/gas/mpopt.sparcv8plus.m4 +++ /dev/null @@ -1,172 +0,0 @@ -dnl mpopt.sparcv8plus.m4 -dnl -dnl Copyright (c) 2003 Bob Deblier -dnl -dnl Author: Bob Deblier <bob.deblier@pandora.be> -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -include(config.m4) -include(ASM_SRCDIR/asmdefs.m4) -include(ASM_SRCDIR/sparc.m4) - - -C_FUNCTION_BEGIN(mpaddw) - sll %o0,2,%g1 - dec 4,%g1 - clr %o0 - lduw [%o1+%g1],%g2 - addcc %g2,%o2,%g2 - stw %g2,[%o1+%g1] - brz,pn %g1,LOCAL(mpaddw_skip) - dec 4,%g1 -LOCAL(mpaddw_loop): - lduw [%o1+%g1],%g2 - addccc %g2,%g0,%g2 - stw %g2,[%o1+%g1] - brnz,pt %g1,LOCAL(mpaddw_loop) - dec 4,%g1 -LOCAL(mpaddw_skip): - retl - movcs %icc,1,%o0 -C_FUNCTION_END(mpaddw) - - -C_FUNCTION_BEGIN(mpsubw) - sll %o0,2,%g1 - dec 4,%g1 - clr %o0 - lduw [%o1+%g1],%g2 - subcc %g2,%o2,%g2 - stw %g2,[%o1+%g1] - brz,pn %g1,LOCAL(mpsubw_skip) - dec 4,%g1 -LOCAL(mpsubw_loop): - lduw [%o1+%g1],%g2 - subccc %g2,%g0,%g2 - stw %g2,[%o1+%g1] - brnz,pt %g1,LOCAL(mpsubw_loop) - dec 4,%g1 -LOCAL(mpsubw_skip): - retl - movcs %icc,1,%o0 -C_FUNCTION_END(mpsubw) - - -C_FUNCTION_BEGIN(mpadd) - sll %o0,2,%g1 - dec 4,%g1 - addcc %g0,%g0,%o0 -LOCAL(mpadd_loop): - lduw [%o1+%g1],%g2 - lduw [%o2+%g1],%g3 - addccc %g2,%g3,%g4 - stw %g4,[%o1+%g1] - brnz,pt %g1,LOCAL(mpadd_loop) - dec 4,%g1 - retl - movcs %icc,1,%o0 -C_FUNCTION_END(mpadd) - - -C_FUNCTION_BEGIN(mpsub) - sll %o0,2,%g1 - dec 4,%g1 - addcc %g0,%g0,%o0 -LOCAL(mpsub_loop): - lduw [%o1+%g1],%g2 - lduw [%o2+%g1],%g3 - subccc %g2,%g3,%g4 - stw %g4,[%o1+%g1] - brnz,pt %g1,LOCAL(mpsub_loop) - dec 4,%g1 - retl - movcs %icc,1,%o0 -C_FUNCTION_END(mpsub) - - -C_FUNCTION_BEGIN(mpmultwo) - sll %o0,2,%g1 - dec 4,%g1 - addcc %g0,%g0,%o0 -LOCAL(mpmultwo_loop): - lduw [%o1+%g1],%g2 - addccc %g2,%g2,%g3 - stw %g3,[%o1+%g1] - brnz,pt %g1,LOCAL(mpmultwo_loop) - dec 4,%g1 - retl - movcs %icc,1,%o0 -C_FUNCTION_END(mpmultwo) - - -C_FUNCTION_BEGIN(mpsetmul) - sll %o0,2,%g1 - dec 4,%g1 - clr %o0 -LOCAL(mpsetmul_loop): - lduw [%o2+%g1],%g2 - srlx %o0,32,%o0 - mulx %o3,%g2,%g3 - add %o0,%g3,%o0 - stw %o0,[%o1+%g1] - brnz,pt %g1,LOCAL(mpsetmul_loop) - dec 4,%g1 - retl - srlx %o0,32,%o0 -C_FUNCTION_END(mpsetmul) - - -C_FUNCTION_BEGIN(mpaddmul) - sll %o0,2,%g1 - dec 4,%g1 - clr %o0 -LOCAL(mpaddmul_loop): - lduw [%o2+%g1],%g2 - lduw [%o1+%g1],%g4 - srlx %o0,32,%o0 - mulx %o3,%g2,%g3 - add %o0,%g3,%o0 - add %o0,%g4,%o0 - stw %o0,[%o1+%g1] - brnz,pt %g1,LOCAL(mpaddmul_loop) - dec 4,%g1 - retl - srlx %o0,32,%o0 -C_FUNCTION_END(mpaddmul) - - -C_FUNCTION_BEGIN(mpaddsqrtrc) - sll %o0,2,%g1 - dec 4,%g1 - add %o1,%g1,%o1 - add %o1,%g1,%o1 - clr %o0 -LOCAL(mpaddsqrtrc_loop): - lduw [%o2+%g1],%g2 - ldx [%o1],%g4 - mulx %g2,%g2,%g2 - add %o0,%g4,%g3 - clr %o0 - add %g3,%g2,%g3 - cmp %g4,%g3 - movgu %xcc,1,%o0 - stx %g3,[%o1] - sub %o1,8,%o1 - brnz,pt %g1,LOCAL(mpaddsqrtrc_loop) - dec 4,%g1 - retl - nop -C_FUNCTION_END(mpaddsqrtrc) diff --git a/beecrypt/gas/mpopt.x86.m4 b/beecrypt/gas/mpopt.x86.m4 deleted file mode 100644 index 278848c06..000000000 --- a/beecrypt/gas/mpopt.x86.m4 +++ /dev/null @@ -1,420 +0,0 @@ -dnl mpopt.x86.m4 -dnl -dnl Copyright (c) 2003 Bob Deblier -dnl -dnl Author: Bob Deblier <bob.deblier@pandora.be> -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -include(config.m4) -include(ASM_SRCDIR/asmdefs.m4) -include(ASM_SRCDIR/x86.m4) - - -C_FUNCTION_BEGIN(mpzero) - pushl %edi - - movl 8(%esp),%ecx - movl 12(%esp),%edi - - xorl %eax,%eax - repz; stosl - - popl %edi - ret -C_FUNCTION_END(mpzero) - - -C_FUNCTION_BEGIN(mpfill) - pushl %edi - - movl 8(%esp),%ecx - movl 12(%esp),%edi - movl 16(%esp),%eax - - repz; stosl - - popl %edi - ret -C_FUNCTION_END(mpfill) - - -C_FUNCTION_BEGIN(mpeven) - movl 4(%esp),%ecx - movl 8(%esp),%eax - movl -4(%eax,%ecx,4),%eax - notl %eax - andl `$'1,%eax - ret -C_FUNCTION_END(mpeven) - - -C_FUNCTION_BEGIN(mpodd) - movl 4(%esp),%ecx - movl 8(%esp),%eax - movl -4(%eax,%ecx,4),%eax - andl `$'1,%eax - ret -C_FUNCTION_END(mpodd) - - -C_FUNCTION_BEGIN(mpaddw) - pushl %edi - - movl 8(%esp),%ecx - movl 12(%esp),%edi - movl 16(%esp),%eax - - xorl %edx,%edx - leal -4(%edi,%ecx,4),%edi - addl %eax,(%edi) - decl %ecx - jz LOCAL(mpaddw_skip) - leal -4(%edi),%edi - - .align 4 -LOCAL(mpaddw_loop): - adcl %edx,(%edi) - leal -4(%edi),%edi - decl %ecx - jnz LOCAL(mpaddw_loop) -LOCAL(mpaddw_skip): - sbbl %eax,%eax - negl %eax - - popl %edi - ret -C_FUNCTION_END(mpaddw) - - -C_FUNCTION_BEGIN(mpsubw) - pushl %edi - - movl 8(%esp),%ecx - movl 12(%esp),%edi - movl 16(%esp),%eax - - xorl %edx,%edx - leal -4(%edi,%ecx,4),%edi - subl %eax,(%edi) - decl %ecx - jz LOCAL(mpsubw_skip) - leal -4(%edi),%edi - - .align 4 -LOCAL(mpsubw_loop): - sbbl %edx,(%edi) - leal -4(%edi),%edi - decl %ecx - jnz LOCAL(mpsubw_loop) -LOCAL(mpsubw_skip): - sbbl %eax,%eax - negl %eax - popl %edi - ret -C_FUNCTION_END(mpsubw) - - -C_FUNCTION_BEGIN(mpadd) - pushl %edi - pushl %esi - - movl 12(%esp),%ecx - movl 16(%esp),%edi - movl 20(%esp),%esi - - xorl %edx,%edx - decl %ecx - - .align 4 -LOCAL(mpadd_loop): - movl (%esi,%ecx,4),%eax - movl (%edi,%ecx,4),%edx - adcl %eax,%edx - movl %edx,(%edi,%ecx,4) - decl %ecx - jns LOCAL(mpadd_loop) - - sbbl %eax,%eax - negl %eax - - popl %esi - popl %edi - ret -C_FUNCTION_END(mpadd) - - -C_FUNCTION_BEGIN(mpsub) - pushl %edi - pushl %esi - - movl 12(%esp),%ecx - movl 16(%esp),%edi - movl 20(%esp),%esi - - xorl %edx,%edx - decl %ecx - - .align 4 -LOCAL(mpsub_loop): - movl (%esi,%ecx,4),%eax - movl (%edi,%ecx,4),%edx - sbbl %eax,%edx - movl %edx,(%edi,%ecx,4) - decl %ecx - jns LOCAL(mpsub_loop) - - sbbl %eax,%eax - negl %eax - popl %esi - popl %edi - ret -C_FUNCTION_END(mpsub) - - -C_FUNCTION_BEGIN(mpdivtwo) - pushl %edi - - movl 8(%esp),%ecx - movl 12(%esp),%edi - - leal (%edi,%ecx,4),%edi - negl %ecx - xorl %eax,%eax - - .align 4 -LOCAL(mpdivtwo_loop): - rcrl `$'1,(%edi,%ecx,4) - inc %ecx - jnz LOCAL(mpdivtwo_loop) - - popl %edi - ret -C_FUNCTION_END(mpdivtwo) - - -C_FUNCTION_BEGIN(mpmultwo) - pushl %edi - - movl 8(%esp),%ecx - movl 12(%esp),%edi - - xorl %edx,%edx - decl %ecx - - .align 4 -LOCAL(mpmultwo_loop): - movl (%edi,%ecx,4),%eax - adcl %eax,%eax - movl %eax,(%edi,%ecx,4) - decl %ecx - jns LOCAL(mpmultwo_loop) - - sbbl %eax,%eax - negl %eax - - popl %edi - ret -C_FUNCTION_END(mpmultwo) - - -C_FUNCTION_BEGIN(mpsetmul) - pushl %edi - pushl %esi -ifdef(`USE_SSE2',` - movl 12(%esp),%ecx - movl 16(%esp),%edi - movl 20(%esp),%esi - movd 24(%esp),%mm1 - - pxor %mm0,%mm0 - decl %ecx - - .align 4 -LOCAL(mpsetmul_loop): - movd (%esi,%ecx,4),%mm2 - pmuludq %mm1,%mm2 - paddq %mm2,%mm0 - movd %mm0,(%edi,%ecx,4) - decl %ecx - psrlq `$'32,%mm0 - jns LOCAL(mpsetmul_loop) - - movd %mm0,%eax - emms -',` - pushl %ebx - pushl %ebp - - movl 20(%esp),%ecx - movl 24(%esp),%edi - movl 28(%esp),%esi - movl 32(%esp),%ebp - - xorl %edx,%edx - decl %ecx - - .align 4 -LOCAL(mpsetmul_loop): - movl %edx,%ebx - movl (%esi,%ecx,4),%eax - mull %ebp - addl %ebx,%eax - adcl `$'0,%edx - movl %eax,(%edi,%ecx,4) - decl %ecx - jns LOCAL(mpsetmul_loop) - - movl %edx,%eax - - popl %ebp - popl %ebx -') - popl %esi - popl %edi - ret -C_FUNCTION_END(mpsetmul) - - -C_FUNCTION_BEGIN(mpaddmul) - pushl %edi - pushl %esi -ifdef(`USE_SSE2',` - movl 12(%esp),%ecx - movl 16(%esp),%edi - movl 20(%esp),%esi - movd 24(%esp),%mm1 - - pxor %mm0,%mm0 - decl %ecx - - .align 4 -LOCAL(mpaddmul_loop): - movd (%esi,%ecx,4),%mm2 - movd (%edi,%ecx,4),%mm3 - pmuludq %mm1,%mm2 - paddq %mm2,%mm3 - paddq %mm3,%mm0 - movd %mm0,(%edi,%ecx,4) - decl %ecx - psrlq $32,%mm0 - jns LOCAL(mpaddmul_loop) - - movd %mm0,%eax - emms -',` - pushl %ebx - pushl %ebp - - movl 20(%esp),%ecx - movl 24(%esp),%edi - movl 28(%esp),%esi - movl 32(%esp),%ebp - - xorl %edx,%edx - decl %ecx - - .align 4 -LOCAL(mpaddmul_loop): - movl %edx,%ebx - movl (%esi,%ecx,4),%eax - mull %ebp - addl %ebx,%eax - adcl `$'0,%edx - addl (%edi,%ecx,4),%eax - adcl `$'0,%edx - movl %eax,(%edi,%ecx,4) - decl %ecx - jns LOCAL(mpaddmul_loop) - - movl %edx,%eax - - popl %ebp - popl %ebx -') - popl %esi - popl %edi - ret -C_FUNCTION_END(mpaddmul) - - -C_FUNCTION_BEGIN(mpaddsqrtrc) - pushl %edi - pushl %esi -ifdef(`USE_SSE2',` - movl 12(%esp),%ecx - movl 16(%esp),%edi - movl 20(%esp),%esi - - pxor %mm0,%mm0 - decl %ecx - - .align 4 -LOCAL(mpaddsqrtrc_loop): - movd (%esi,%ecx,4),%mm2 - pmuludq %mm2,%mm2 - movd 4(%edi,%ecx,8),%mm3 - paddq %mm2,%mm3 - movd 0(%edi,%ecx,8),%mm4 - paddq %mm3,%mm0 - movd %mm0,4(%edi,%ecx,8) - psrlq $32,%mm0 - paddq %mm4,%mm0 - movd %mm0,0(%edi,%ecx,8) - decl %ecx - psrlq $32,%mm0 - jns LOCAL(mpaddsqrtrc_loop) - - movd %mm0,%eax - emms -',` - pushl %ebx - - movl 16(%esp),%ecx - movl 20(%esp),%edi - movl 24(%esp),%esi - - xorl %ebx,%ebx - decl %ecx - - .align 4 -LOCAL(mpaddsqrtrc_loop): - movl (%esi,%ecx,4),%eax - mull %eax - addl %ebx,%eax - adcl `$'0,%edx - addl %eax,4(%edi,%ecx,8) - adcl %edx,(%edi,%ecx,8) - sbbl %ebx,%ebx - negl %ebx - decl %ecx - jns LOCAL(mpaddsqrtrc_loop) - - movl %ebx,%eax - - popl %ebx -') - popl %esi - popl %edi - ret -C_FUNCTION_END(mpaddsqrtrc) - - -C_FUNCTION_BEGIN(mppndiv) - movl 4(%esp),%edx - movl 8(%esp),%eax - divl 12(%esp) - ret -C_FUNCTION_END(mppndiv) diff --git a/beecrypt/gas/mpopt.x86_64.m4 b/beecrypt/gas/mpopt.x86_64.m4 deleted file mode 100644 index 515c84d3a..000000000 --- a/beecrypt/gas/mpopt.x86_64.m4 +++ /dev/null @@ -1,254 +0,0 @@ -dnl mpopt.x86_64.m4 -dnl -dnl Copyright (c) 2003 Bob Deblier -dnl -dnl Author: Bob Deblier <bob.deblier@pandora.be> -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - .file "mpopt.s" - -include(config.m4) -include(ASM_SRCDIR/asmdefs.m4) -include(ASM_SRCDIR/x86_64.m4) - - -C_FUNCTION_BEGIN(mpzero) - movq %rdi,%rcx - movq %rsi,%rdi - xorq %rax,%rax - repz stosq - ret -C_FUNCTION_END(mpzero) - - -C_FUNCTION_BEGIN(mpfill) - movq %rdi,%rcx - movq %rsi,%rdi - movq %rdx,%rax - repz stosq - ret -C_FUNCTION_END(mpfill) - - -C_FUNCTION_BEGIN(mpeven) - movq -8(%rsi,%rdi,8),%rax - notq %rax - andq `$'1,%rax - ret -C_FUNCTION_END(mpeven) - - -C_FUNCTION_BEGIN(mpodd) - movq -8(%rsi,%rdi,8),%rax - andq `$'1,%rax - ret -C_FUNCTION_END(mpodd) - - -C_FUNCTION_BEGIN(mpaddw) - movq %rdx,%rax - xorq %rdx,%rdx - leaq -8(%rsi,%rdi,8),%rsi - addq %rax,(%rsi) - decq %rdi - jz LOCAL(mpaddw_skip) - leaq -8(%rsi),%rsi - - .align 4 -LOCAL(mpaddw_loop): - adcq %rdx,(%rsi) - leaq -8(%rsi),%rsi - decq %rdi - jnz LOCAL(mpaddw_loop) -LOCAL(mpaddw_skip): - sbbq %rax,%rax - negq %rax - ret -C_FUNCTION_END(mpaddw) - - -C_FUNCTION_BEGIN(mpsubw) - movq %rdx,%rax - xorq %rdx,%rdx - leaq -8(%rsi,%rdi,8),%rsi - subq %rax,(%rsi) - decq %rdi - jz LOCAL(mpsubw_skip) - leaq -8(%rsi),%rsi - - .align 4 -LOCAL(mpsubw_loop): - sbbq %rdx,(%rsi) - leaq -8(%rsi),%rsi - decq %rdi - jnz LOCAL(mpsubw_loop) -LOCAL(mpsubw_skip): - sbbq %rax,%rax - negq %rax - ret -C_FUNCTION_END(mpsubw) - - -C_FUNCTION_BEGIN(mpadd) - xorq %r8,%r8 - decq %rdi - - .align 4 -LOCAL(mpadd_loop): - movq (%rdx,%rdi,8),%rax - movq (%rsi,%rdi,8),%r8 - adcq %rax,%r8 - movq %r8,(%rsi,%rdi,8) - decq %rdi - jns LOCAL(mpadd_loop) - - sbbq %rax,%rax - negq %rax - ret -C_FUNCTION_END(mpadd) - - -C_FUNCTION_BEGIN(mpsub) - xorq %r8,%r8 - decq %rdi - - .align 4 -LOCAL(mpsub_loop): - movq (%rdx,%rdi,8),%rax - movq (%rsi,%rdi,8),%r8 - sbbq %rax,%r8 - movq %r8,(%rsi,%rdi,8) - decq %rdi - jns LOCAL(mpsub_loop) - - sbbq %rax,%rax - negq %rax - ret -C_FUNCTION_END(mpsub) - - -C_FUNCTION_BEGIN(mpdivtwo) - leaq (%rsi,%rdi,8),%rsi - negq %rdi - xorq %rax,%rax - - .align 4 -LOCAL(mpdivtwo_loop): - rcrq `$'1,(%rsi,%rdi,8) - inc %rdi - jnz LOCAL(mpdivtwo_loop) - - ret -C_FUNCTION_END(mpdivtwo) - - -C_FUNCTION_BEGIN(mpmultwo) - xorq %rdx,%rdx - decq %rdi - - .align 4 -LOCAL(mpmultwo_loop): - movq (%rsi,%rdi,8),%rax - adcq %rax,%rax - movq %rax,(%rsi,%rdi,8) - decq %rdi - jns LOCAL(mpmultwo_loop) - - sbbq %rax,%rax - negq %rax - ret -C_FUNCTION_END(mpmultwo) - - -C_FUNCTION_BEGIN(mpsetmul) - movq %rcx,%r8 - movq %rdi,%rcx - movq %rdx,%rdi - - xorq %rdx,%rdx - decq %rcx - - .align 4 -LOCAL(mpsetmul_loop): - movq %rdx,%r9 - movq (%rdi,%rcx,8),%rax - mulq %r8 - addq %r9,%rax - adcq `$'0,%rdx - movq %rax,(%rsi,%rcx,8) - decq %rcx - jns LOCAL(mpsetmul_loop) - - movq %rdx,%rax - - ret -C_FUNCTION_END(mpsetmul) - - -C_FUNCTION_BEGIN(mpaddmul) - movq %rcx,%r8 - movq %rdi,%rcx - movq %rdx,%rdi - - xorq %rdx,%rdx - decq %rcx - - .align 4 -LOCAL(mpaddmul_loop): - movq %rdx,%r9 - movq (%rdi,%rcx,8),%rax - mulq %r8 - addq %r9,%rax - adcq `$'0,%rdx - addq (%rsi,%rcx,8),%rax - adcq `$'0,%rdx - movq %rax,(%rsi,%rcx,8) - decq %rcx - jns LOCAL(mpaddmul_loop) - - movq %rdx,%rax - ret -C_FUNCTION_END(mpaddmul) - - -C_FUNCTION_BEGIN(mpaddsqrtrc) - movq %rdi,%rcx - movq %rsi,%rdi - movq %rdx,%rsi - - xorq %r8,%r8 - decq %rcx - - leaq (%rdi,%rcx,8),%rdi - leaq (%rdi,%rcx,8),%rdi - - .align 4 -LOCAL(mpaddsqrtrc_loop): - movq (%rsi,%rcx,8),%rax - mulq %rax - addq %r8,%rax - adcq `$'0,%rdx - addq %rax,8(%rdi) - adcq %rdx,0(%rdi) - sbbq %r8,%r8 - negq %r8 - subq `$'16,%rdi - decq %rcx - jns LOCAL(mpaddsqrtrc_loop) - - movq %r8,%rax - ret -C_FUNCTION_END(mpaddsqrtrc) diff --git a/beecrypt/gas/ppc.m4 b/beecrypt/gas/ppc.m4 deleted file mode 100644 index 33ba0ccc4..000000000 --- a/beecrypt/gas/ppc.m4 +++ /dev/null @@ -1,99 +0,0 @@ -dnl ppc.m4 -dnl -dnl Copyright (c) 2003 Bob Deblier -dnl -dnl Author: Bob Deblier <bob.deblier@pandora.be> -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -ifelse(substr(ASM_OS,0,3),aix,` -define(USE_NUMERIC_REGISTERS) -undefine(`C_FUNCTION_BEGIN') -define(C_FUNCTION_BEGIN,` - .toc - .globl $1[DS] - .csect $1[DS] - .long .$1[PR], TOC[tc0], 0 - .toc - .globl .$1[PR] - .csect .$1[PR] -') -undefine(`C_FUNCTION_END') -define(C_FUNCTION_END,` - .tbtag 0x0,0xc,0x0,0x0,0x0,0x0,0x0,0x0 -') -define(LOAD_ADDRESS,` - lwz $2,L$1(r2) -') -define(EXTERNAL_VARIABLE,` - .toc -L$1: - .tc $1[TC],$1[RW] -') - .machine "ppc" -') - -ifelse(substr(ASM_OS,0,6),darwin,` -define(LOAD_ADDRESS,` - lis $2,hi16($1) - la $2,lo16($1)($2) -') -define(EXTERNAL_VARIABLE) -') - -ifelse(substr(ASM_OS,0,5),linux,` -define(USE_NUMERIC_REGISTERS) -define(LOAD_ADDRESS,` - lis $2,$1@ha - la $2,$1@l($2) -') -define(EXTERNAL_VARIABLE) -') - - -ifdef(`USE_NUMERIC_REGISTERS',` -define(r0,0) -define(r1,1) -define(r2,2) -define(r3,3) -define(r4,4) -define(r5,5) -define(r6,6) -define(r7,7) -define(r8,8) -define(r9,9) -define(r10,10) -define(r11,11) -define(r12,12) -define(r13,13) -define(r14,14) -define(r15,15) -define(r16,16) -define(r17,17) -define(r18,18) -define(r19,19) -define(r20,20) -define(r21,21) -define(r22,22) -define(r23,23) -define(r24,24) -define(r25,25) -define(r26,26) -define(r27,27) -define(r28,28) -define(r29,29) -define(r30,30) -define(r31,31) -') diff --git a/beecrypt/gas/ppc64.m4 b/beecrypt/gas/ppc64.m4 deleted file mode 100644 index a0b426851..000000000 --- a/beecrypt/gas/ppc64.m4 +++ /dev/null @@ -1,108 +0,0 @@ -dnl ppc64.m4 -dnl -dnl Copyright (c) 2003 Bob Deblier -dnl -dnl Author: Bob Deblier <bob.deblier@pandora.be> -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -ifelse(substr(ASM_OS,0,3),aix,` -define(USE_NUMERIC_REGISTERS) -undefine(`C_FUNCTION_BEGIN') -define(C_FUNCTION_BEGIN,` - .toc - .globl $1[DS] - .csect $1[DS] - .llong .$1[PR], TOC[tc0], 0 - .toc - .globl .$1[PR] - .csect .$1[PR] -') -undefine(`C_FUNCTION_END') -define(C_FUNCTION_END,` - .tbtag 0x0,0xc,0x0,0x0,0x0,0x0,0x0,0x0 -') - - .machine "ppc64" -') - -ifelse(substr(ASM_OS,0,5),linux,` -define(USE_NUMERIC_REGISTERS) -dnl trampoline definitions from glibc-2.3.2/sysdeps/powerpc/powerpc64/dl-machine.h -undefine(`C_FUNCTION_BEGIN') -define(C_FUNCTION_BEGIN,` - .section .text - .align 2 - .globl .$1 - .type .$1,@function - .section ".opd","aw" - .align 3 - .globl $1 - .size $1,24 -$1: - .quad .$1,.TOC.@tocbase,0 - .previous -.$1: -') -undefine(`C_FUNCTION_END') -define(C_FUNCTION_END,` -.LT_$1: - .long 0 - .byte 0x00,0x0c,0x24,0x40,0x00,0x00,0x00,0x00 - .long .LT_$1 - .$1 - .short .LT_$1_name_end-.LT_$1_name_start -.LT_$1_name_start: - .ascii "$1" -.LT_$1_name_end: - .align 2 - .size .$1,. - .$1 - .previous -') -') - -ifdef(`USE_NUMERIC_REGISTERS',` -define(r0,0) -define(r1,1) -define(r2,2) -define(r3,3) -define(r4,4) -define(r5,5) -define(r6,6) -define(r7,7) -define(r8,8) -define(r9,9) -define(r10,10) -define(r11,11) -define(r12,12) -define(r13,13) -define(r14,14) -define(r15,15) -define(r16,16) -define(r17,17) -define(r18,18) -define(r19,19) -define(r20,20) -define(r21,21) -define(r22,22) -define(r23,23) -define(r24,24) -define(r25,25) -define(r26,26) -define(r27,27) -define(r28,28) -define(r29,29) -define(r30,30) -define(r31,31) -') diff --git a/beecrypt/gas/sha1opt.x86.m4 b/beecrypt/gas/sha1opt.x86.m4 deleted file mode 100644 index b2d9a3d01..000000000 --- a/beecrypt/gas/sha1opt.x86.m4 +++ /dev/null @@ -1,290 +0,0 @@ -dnl sha1opt.i586.m4 -dnl -dnl Copyright (c) 2003 Bob Deblier -dnl -dnl Author: Bob Deblier <bob.deblier@pandora.be> -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -include(config.m4) -include(ASM_SRCDIR/asmdefs.m4) -include(ASM_SRCDIR/x86.m4) - - .set K00, 0x5a827999 - .set K20, 0x6ed9eba1 - .set K40, 0x8f1bbcdc - .set K60, 0xca62c1d6 - - .set PARAM_H, 0 - .set PARAM_DATA, 20 - -define(`subround1',` - movl $2,%ecx - movl $1,%ebx - movl $3,%edx - roll `$'5,%eax - xorl %edx,%ecx - addl $4,%eax - andl %ebx,%ecx - addl `$'K00,%eax - rorl `$'2,%ebx - addl $5(%esi,%edi),%eax - xorl %edx,%ecx - movl %ebx,$1 - addl %ecx,%eax - movl %eax,$4 -') - -define(`subround2',` - movl $2,%ecx - movl $1,%ebx - roll `$'5,%eax - xorl %ebx,%ecx - addl $4,%eax - xorl $3,%ecx - addl `$'K20,%eax - rorl `$'2,%ebx - addl $5(%esi,%edi),%eax - movl %ebx,$1 - addl %ecx,%eax - movl %eax,$4 -') - -define(`subround3',` - movl $2,%ecx - roll `$'5,%eax - movl $1,%ebx - movl %ecx,%edx - addl $4,%eax - orl %ebx,%ecx - andl %ebx,%edx - andl $3,%ecx - addl `$'K40,%eax - orl %edx,%ecx - addl $5(%esi,%edi),%eax - rorl `$'2,%ebx - addl %ecx,%eax - movl %ebx,$1 - movl %eax,$4 -') - -define(`subround4',` - movl $2,%ecx - movl $1,%ebx - roll `$'5,%eax - xorl %ebx,%ecx - addl $4,%eax - xorl $3,%ecx - addl `$'K60,%eax - rorl `$'2,%ebx - addl $5(%esi,%edi),%eax - movl %ebx,$1 - addl %ecx,%eax - movl %eax,$4 -') - -C_FUNCTION_BEGIN(sha1Process) - pushl %edi - pushl %esi - pushl %ebx - pushl %ebp - - movl 20(%esp),%esi - subl `$'20,%esp - leal PARAM_DATA(%esi),%edi - movl %esp,%ebp - - movl `$'4,%ecx -LOCAL(0): - movl (%esi,%ecx,4),%edx - movl %edx,(%ebp,%ecx,4) - decl %ecx - jns LOCAL(0) - - movl `$'15,%ecx - - .align 4 -LOCAL(1): - movl (%edi,%ecx,4),%edx -ifdef(`USE_BSWAP',` - bswap %edx -',` - movl %edx,%eax - andl `$'0xff00ff,%edx - rol `$'8,%eax - andl `$'0xff00ff,%eax - ror `$'8,%edx - or %eax,%edx -') - mov %edx,(%edi,%ecx,4) - decl %ecx - jns LOCAL(1) - - leal PARAM_DATA(%esi),%edi - movl `$'16,%ecx - xorl %eax,%eax - - .align 4 -LOCAL(2): - movl 52(%edi),%eax - movl 56(%edi),%ebx - xorl 32(%edi),%eax - xorl 36(%edi),%ebx - xorl 8(%edi),%eax - xorl 12(%edi),%ebx - xorl (%edi),%eax - xorl 4(%edi),%ebx - roll `$'1,%eax - roll `$'1,%ebx - movl %eax,64(%edi) - movl %ebx,68(%edi) - movl 60(%edi),%eax - movl 64(%edi),%ebx - xorl 40(%edi),%eax - xorl 44(%edi),%ebx - xorl 16(%edi),%eax - xorl 20(%edi),%ebx - xorl 8(%edi),%eax - xorl 12(%edi),%ebx - roll `$'1,%eax - roll `$'1,%ebx - movl %eax,72(%edi) - movl %ebx,76(%edi) - addl `$'16,%edi - decl %ecx - jnz LOCAL(2) - - movl `$'PARAM_DATA,%edi - - movl (%ebp),%eax -LOCAL(01_20): - subround1( 4(%ebp), 8(%ebp), 12(%ebp), 16(%ebp), 0) - subround1( (%ebp), %ebx , 8(%ebp), 12(%ebp), 4) - subround1(16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8) - subround1(12(%ebp), %ebx , (%ebp), 4(%ebp), 12) - subround1( 8(%ebp), %ebx , 16(%ebp), (%ebp), 16) - addl `$'20,%edi - subround1( 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0) - subround1( (%ebp), %ebx , 8(%ebp), 12(%ebp), 4) - subround1(16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8) - subround1(12(%ebp), %ebx , (%ebp), 4(%ebp), 12) - subround1( 8(%ebp), %ebx , 16(%ebp), (%ebp), 16) - addl `$'20,%edi - subround1( 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0) - subround1( (%ebp), %ebx , 8(%ebp), 12(%ebp), 4) - subround1(16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8) - subround1(12(%ebp), %ebx , (%ebp), 4(%ebp), 12) - subround1( 8(%ebp), %ebx , 16(%ebp), (%ebp), 16) - addl `$'20,%edi - subround1( 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0) - subround1( (%ebp), %ebx , 8(%ebp), 12(%ebp), 4) - subround1(16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8) - subround1(12(%ebp), %ebx , (%ebp), 4(%ebp), 12) - subround1( 8(%ebp), %ebx , 16(%ebp), (%ebp), 16) - addl `$'20,%edi - -LOCAL(21_40): - subround2( 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0) - subround2( (%ebp), %ebx , 8(%ebp), 12(%ebp), 4) - subround2(16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8) - subround2(12(%ebp), %ebx , (%ebp), 4(%ebp), 12) - subround2( 8(%ebp), %ebx , 16(%ebp), (%ebp), 16) - addl `$'20,%edi - subround2( 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0) - subround2( (%ebp), %ebx , 8(%ebp), 12(%ebp), 4) - subround2(16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8) - subround2(12(%ebp), %ebx , (%ebp), 4(%ebp), 12) - subround2( 8(%ebp), %ebx , 16(%ebp), (%ebp), 16) - addl `$'20,%edi - subround2( 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0) - subround2( (%ebp), %ebx , 8(%ebp), 12(%ebp), 4) - subround2(16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8) - subround2(12(%ebp), %ebx , (%ebp), 4(%ebp), 12) - subround2( 8(%ebp), %ebx , 16(%ebp), (%ebp), 16) - addl `$'20,%edi - subround2( 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0) - subround2( (%ebp), %ebx , 8(%ebp), 12(%ebp), 4) - subround2(16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8) - subround2(12(%ebp), %ebx , (%ebp), 4(%ebp), 12) - subround2( 8(%ebp), %ebx , 16(%ebp), (%ebp), 16) - addl `$'20,%edi - -LOCAL(41_60): - subround3( 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0) - subround3( (%ebp), %ebx , 8(%ebp), 12(%ebp), 4) - subround3(16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8) - subround3(12(%ebp), %ebx , (%ebp), 4(%ebp), 12) - subround3( 8(%ebp), %ebx , 16(%ebp), (%ebp), 16) - addl `$'20,%edi - subround3( 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0) - subround3( (%ebp), %ebx , 8(%ebp), 12(%ebp), 4) - subround3(16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8) - subround3(12(%ebp), %ebx , (%ebp), 4(%ebp), 12) - subround3( 8(%ebp), %ebx , 16(%ebp), (%ebp), 16) - addl `$'20,%edi - subround3( 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0) - subround3( (%ebp), %ebx , 8(%ebp), 12(%ebp), 4) - subround3(16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8) - subround3(12(%ebp), %ebx , (%ebp), 4(%ebp), 12) - subround3( 8(%ebp), %ebx , 16(%ebp), (%ebp), 16) - addl `$'20,%edi - subround3( 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0) - subround3( (%ebp), %ebx , 8(%ebp), 12(%ebp), 4) - subround3(16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8) - subround3(12(%ebp), %ebx , (%ebp), 4(%ebp), 12) - subround3( 8(%ebp), %ebx , 16(%ebp), (%ebp), 16) - addl `$'20,%edi - -LOCAL(61_80): - subround4( 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0) - subround4( (%ebp), %ebx , 8(%ebp), 12(%ebp), 4) - subround4(16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8) - subround4(12(%ebp), %ebx , (%ebp), 4(%ebp), 12) - subround4( 8(%ebp), %ebx , 16(%ebp), (%ebp), 16) - addl `$'20,%edi - subround4( 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0) - subround4( (%ebp), %ebx , 8(%ebp), 12(%ebp), 4) - subround4(16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8) - subround4(12(%ebp), %ebx , (%ebp), 4(%ebp), 12) - subround4( 8(%ebp), %ebx , 16(%ebp), (%ebp), 16) - addl `$'20,%edi - subround4( 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0) - subround4( (%ebp), %ebx , 8(%ebp), 12(%ebp), 4) - subround4(16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8) - subround4(12(%ebp), %ebx , (%ebp), 4(%ebp), 12) - subround4( 8(%ebp), %ebx , 16(%ebp), (%ebp), 16) - addl `$'20,%edi - subround4( 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0) - subround4( (%ebp), %ebx , 8(%ebp), 12(%ebp), 4) - subround4(16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8) - subround4(12(%ebp), %ebx , (%ebp), 4(%ebp), 12) - subround4( 8(%ebp), %ebx , 16(%ebp), (%ebp), 16) - - movl `$'4,%ecx - - .align 4 -LOCAL(3): - movl (%ebp,%ecx,4),%eax - addl %eax,(%esi,%ecx,4) - decl %ecx - jns LOCAL(3) - - addl `$'20,%esp - popl %ebp - popl %ebx - popl %esi - popl %edi - ret -C_FUNCTION_END(sha1Process) diff --git a/beecrypt/gas/sparc.m4 b/beecrypt/gas/sparc.m4 deleted file mode 100644 index e735600c3..000000000 --- a/beecrypt/gas/sparc.m4 +++ /dev/null @@ -1,30 +0,0 @@ -dnl sparc.m4 -dnl -dnl Copyright (c) 2003 Bob Deblier -dnl -dnl Author: Bob Deblier <bob.deblier@pandora.be> -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -ifelse(substr(ASM_OS,0,7),solaris,` -undefine(`C_FUNCTION_BEGIN') -define(C_FUNCTION_BEGIN,` - TEXTSEG - GLOBL SYMNAME($1) -SYMNAME($1): - .register %g2,#scratch - .register %g3,#scratch -') -') diff --git a/beecrypt/gas/x86.m4 b/beecrypt/gas/x86.m4 deleted file mode 100644 index 770b42b5a..000000000 --- a/beecrypt/gas/x86.m4 +++ /dev/null @@ -1,50 +0,0 @@ -dnl x86.m4 -dnl -dnl Copyright (c) 2003 Bob Deblier -dnl -dnl Author: Bob Deblier <bob.deblier@pandora.be> -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -ifelse(substr(ASM_ARCH,0,6),athlon,` -define(USE_BSWAP) -define(USE_MMX) -') -ifelse(substr(ASM_ARCH,0,7),pentium,` -define(USE_BSWAP) -') -ifelse(ASM_ARCH,i586,` -define(USE_BSWAP) -') -ifelse(ASM_ARCH,i686,` -define(USE_BSWAP) -') -ifelse(ASM_ARCH,pentium-mmx,` -define(USE_MMX) -') -ifelse(ASM_ARCH,pentium2,` -define(USE_MMX) -') -ifelse(ASM_ARCH,pentium3,` -define(USE_MMX) -define(USE_SSE) -') -ifelse(ASM_ARCH,pentium4,` -undefine(`ALIGN') -define(ALIGN,`.p2align 4') -define(USE_MMX) -define(USE_SSE) -define(USE_SSE2) -') diff --git a/beecrypt/gas/x86_64.m4 b/beecrypt/gas/x86_64.m4 deleted file mode 100644 index 3fcfbf987..000000000 --- a/beecrypt/gas/x86_64.m4 +++ /dev/null @@ -1,20 +0,0 @@ -dnl x86_64.m4 -dnl -dnl Copyright (c) 2003 Bob Deblier -dnl -dnl Author: Bob Deblier <bob.deblier@pandora.be> -dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License, or (at your option) any later version. -dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. -dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - diff --git a/beecrypt/gnu.h.in b/beecrypt/gnu.h.in deleted file mode 100644 index 6afe7881d..000000000 --- a/beecrypt/gnu.h.in +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2003 Bob Deblier - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef _BEECRYPT_GNU_H -#define _BEECRYPT_GNU_H - -@INCLUDE_INTTYPES_H@ -@INCLUDE_STDINT_H@ -@INCLUDE_SYNCH_H@ -@INCLUDE_THREAD_H@ -@INCLUDE_PTHREAD_H@ -@INCLUDE_STDIO_H@ -@INCLUDE_STDLIB_H@ -@INCLUDE_MALLOC_H@ -@INCLUDE_STRING_H@ -@INCLUDE_UNISTD_H@ -@INCLUDE_DLFCN_H@ - -@TYPEDEF_BC_COND_T@ -@TYPEDEF_BC_MUTEX_T@ -@TYPEDEF_BC_THREAD_T@ - -@TYPEDEF_SIZE_T@ - -@TYPEDEF_INT8_T@ -@TYPEDEF_INT16_T@ -@TYPEDEF_INT32_T@ -@TYPEDEF_INT64_T@ - -@TYPEDEF_UINT8_T@ -@TYPEDEF_UINT16_T@ -@TYPEDEF_UINT32_T@ -@TYPEDEF_UINT64_T@ - -/* WARNING: overriding this value is dangerous; some assembler routines - * make assumptions about the size set by the configure script - */ -#if !defined(MP_WBITS) -# define MP_WBITS @MP_WBITS@ -#endif - -#endif diff --git a/beecrypt/gnu/blowfishopt.gas.i586.S b/beecrypt/gnu/blowfishopt.gas.i586.S deleted file mode 100644 index 02a00a812..000000000 --- a/beecrypt/gnu/blowfishopt.gas.i586.S +++ /dev/null @@ -1,200 +0,0 @@ -/* - * blowfishopt.gas.i586.S - * - * Assembler optimized blowfish routines for Intel Pentium processors - * - * Compile target is GNU Assembler - * - * Copyright (c) 2000 Virtual Unlimited B.V. - * - * Author: Bob Deblier <bob@virtualunlimited.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - .file "blowfishopt.gas.i586.S" - - .text - - .macro etworounds p # bp in %esi, xl and xr in %ecx and %edx, %eax and %ebx clear - xorl 0+\p(%esi),%ecx - roll $16,%ecx - movb %ch,%al - movb %cl,%bl - roll $16,%ecx - movl 0x000+72(%esi,%eax,4),%edi - addl 0x400+72(%esi,%ebx,4),%edi - movb %ch,%al - movb %cl,%bl - xorl 0x800+72(%esi,%eax,4),%edi - addl 0xC00+72(%esi,%ebx,4),%edi - xorl %edi,%edx - xorl 4+\p(%esi),%edx - roll $16,%edx - movb %dh,%al - movb %dl,%bl - roll $16,%edx - movl 0x000+72(%esi,%eax,4),%edi - addl 0x400+72(%esi,%ebx,4),%edi - movb %dh,%al - movb %dl,%bl - xorl 0x800+72(%esi,%eax,4),%edi - addl 0xC00+72(%esi,%ebx,4),%edi - xorl %edi,%ecx - .endm - - .macro dtworounds p # bp in %esi, xl and xr in %ecx and %edx, %eax and %ebx clear - xorl 4+\p(%esi),%ecx - roll $16,%ecx - movb %ch,%al - movb %cl,%bl - roll $16,%ecx - movl 0x000+72(%esi,%eax,4),%edi - addl 0x400+72(%esi,%ebx,4),%edi - movb %ch,%al - movb %cl,%bl - xorl 0x800+72(%esi,%eax,4),%edi - addl 0xC00+72(%esi,%ebx,4),%edi - xorl %edi,%edx - xorl 0+\p(%esi),%edx - roll $16,%edx - movb %dh,%al - movb %dl,%bl - roll $16,%edx - movl 0x000+72(%esi,%eax,4),%edi - addl 0x400+72(%esi,%ebx,4),%edi - movb %dh,%al - movb %dl,%bl - xorl 0x800+72(%esi,%eax,4),%edi - addl 0xC00+72(%esi,%ebx,4),%edi - xorl %edi,%ecx - .endm - - .align 4 -#if defined(CYGWIN) - .globl _blowfishEncrypt - .def _blowfishEncrypt - .scl 2 - .type 32 - .endef - -_blowfishEncrypt: -#else - .global blowfishEncrypt - .type blowfishEncrypt,@function - -blowfishEncrypt: -#endif - /* parameter one is the blowfish parameters; need to extract bp and set it up in esi */ - pushl %edi - pushl %esi - pushl %ebx - - movl 16(%esp),%esi # esi now contains bp - movl 24(%esp),%edi # edi now contains src - - xorl %eax,%eax - xorl %ebx,%ebx - - movl 0(%edi),%ecx - movl 4(%edi),%edx - - bswap %ecx - bswap %edx - - etworounds p= 0 - etworounds p= 8 - etworounds p=16 - etworounds p=24 - etworounds p=32 - etworounds p=40 - etworounds p=48 - etworounds p=56 - - movl 20(%esp),%edi # edi now contains dst - xorl 64(%esi),%ecx - xorl 68(%esi),%edx - - bswap %ecx - bswap %edx - - movl %ecx,4(%edi) - movl %edx,0(%edi) - - xorl %eax,%eax - popl %ebx - popl %esi - popl %edi - ret - - .align 4 -#if defined(CYGWIN) - .globl _blowfishDecrypt - .def _blowfishDecrypt - .scl 2 - .type 32 - .endef - -_blowfishDecrypt: -#else - .global blowfishDecrypt - .type blowfishDecrypt,@function - -blowfishDecrypt: -#endif - /* parameter one is the blowfish parameters; need to extract bp and set it up in ebp */ - pushl %edi - pushl %esi - pushl %ebx - - movl 16(%esp),%esi # esi now contains bp - movl 24(%esp),%edi # edi now contains dst - - xorl %eax,%eax - xorl %ebx,%ebx - - movl 0(%edi),%ecx - movl 4(%edi),%edx - - bswap %ecx - bswap %edx - - dtworounds p=64 - dtworounds p=56 - dtworounds p=48 - dtworounds p=40 - dtworounds p=32 - dtworounds p=24 - dtworounds p=16 - dtworounds p= 8 - - movl 20(%esp),%edi # edi now contains dst - xorl 4(%esi),%ecx - xorl 0(%esi),%edx - - bswap %ecx - bswap %edx - - movl %ecx,4(%edi) - movl %edx,0(%edi) - - xorl %eax,%eax - - popl %ebx - popl %esi - popl %edi - ret - diff --git a/beecrypt/gnu/blowfishopt.gas.i586.s b/beecrypt/gnu/blowfishopt.gas.i586.s deleted file mode 100644 index 39fa55272..000000000 --- a/beecrypt/gnu/blowfishopt.gas.i586.s +++ /dev/null @@ -1,179 +0,0 @@ -# -# blowfishopt.gas.i586.s -# -# Assembler optimized blowfish routines for Intel Pentium processors -# -# Compile target is GNU Assembler -# -# Copyright (c) 2000 Virtual Unlimited B.V. -# -# Author: Bob Deblier <bob@virtualunlimited.com> -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# - - .file "blowfishopt.gas.i586.s" - - .text - - .macro etworounds p # bp in %esi, xl and xr in %ecx and %edx, %eax and %ebx clear - xorl 0+\p(%esi),%ecx - roll $16,%ecx - movb %ch,%al - movb %cl,%bl - roll $16,%ecx - movl 0x000+72(%esi,%eax,4),%edi - addl 0x400+72(%esi,%ebx,4),%edi - movb %ch,%al - movb %cl,%bl - xorl 0x800+72(%esi,%eax,4),%edi - addl 0xC00+72(%esi,%ebx,4),%edi - xorl %edi,%edx - xorl 4+\p(%esi),%edx - roll $16,%edx - movb %dh,%al - movb %dl,%bl - roll $16,%edx - movl 0x000+72(%esi,%eax,4),%edi - addl 0x400+72(%esi,%ebx,4),%edi - movb %dh,%al - movb %dl,%bl - xorl 0x800+72(%esi,%eax,4),%edi - addl 0xC00+72(%esi,%ebx,4),%edi - xorl %edi,%ecx - .endm - - .macro dtworounds p # bp in %esi, xl and xr in %ecx and %edx, %eax and %ebx clear - xorl 4+\p(%esi),%ecx - roll $16,%ecx - movb %ch,%al - movb %cl,%bl - roll $16,%ecx - movl 0x000+72(%esi,%eax,4),%edi - addl 0x400+72(%esi,%ebx,4),%edi - movb %ch,%al - movb %cl,%bl - xorl 0x800+72(%esi,%eax,4),%edi - addl 0xC00+72(%esi,%ebx,4),%edi - xorl %edi,%edx - xorl 0+\p(%esi),%edx - roll $16,%edx - movb %dh,%al - movb %dl,%bl - roll $16,%edx - movl 0x000+72(%esi,%eax,4),%edi - addl 0x400+72(%esi,%ebx,4),%edi - movb %dh,%al - movb %dl,%bl - xorl 0x800+72(%esi,%eax,4),%edi - addl 0xC00+72(%esi,%ebx,4),%edi - xorl %edi,%ecx - .endm - - .align 4 - .globl blowfishEncrypt - .type blowfishEncrypt,@function - -blowfishEncrypt: - # parameter one is the blowfish parameters; need to extract bp and set it up in esi - pushl %edi - pushl %esi - pushl %ebx - - movl 16(%esp),%esi # esi now contains bp - movl 20(%esp),%edi # edi now contains bl - - xorl %eax,%eax - xorl %ebx,%ebx - - movl 0(%edi),%ecx - movl 4(%edi),%edx - - bswap %ecx - bswap %edx - - etworounds p= 0 - etworounds p= 8 - etworounds p=16 - etworounds p=24 - etworounds p=32 - etworounds p=40 - etworounds p=48 - etworounds p=56 - - movl 20(%esp),%edi - xorl 64(%esi),%ecx - xorl 68(%esi),%edx - - bswap %ecx - bswap %edx - - movl %ecx,4(%edi) - movl %edx,0(%edi) - - xorl %eax,%eax - popl %ebx - popl %esi - popl %edi - ret - - .align 4 - .globl blowfishDecrypt - .type blowfishDecrypt,@function - -blowfishDecrypt: - # parameter one is the blowfish parameters; need to extract bp and set it up in ebp - pushl %edi - pushl %esi - pushl %ebx - - movl 16(%esp),%esi # esi now contains bp - movl 20(%esp),%edi # edi now contains bl - - xorl %eax,%eax - xorl %ebx,%ebx - - movl 0(%edi),%ecx - movl 4(%edi),%edx - - bswap %ecx - bswap %edx - - dtworounds p=64 - dtworounds p=56 - dtworounds p=48 - dtworounds p=40 - dtworounds p=32 - dtworounds p=24 - dtworounds p=16 - dtworounds p= 8 - - movl 20(%esp),%edi - xorl 4(%esi),%ecx - xorl 0(%esi),%edx - - bswap %ecx - bswap %edx - - movl %ecx,4(%edi) - movl %edx,0(%edi) - - xorl %eax,%eax - - popl %ebx - popl %esi - popl %edi - ret - diff --git a/beecrypt/gnu/config.gas.h b/beecrypt/gnu/config.gas.h deleted file mode 100644 index 5903708a7..000000000 --- a/beecrypt/gnu/config.gas.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef _CONFIG_GAS_H -#define _CONFIG_GAS_H - -#include <gnu/config.gnu.h> - -#ifndef C_FUNCTION_NAME -# if LEADING_UNDERSCORE -# ifdef __STDC__ -# define C_FUNCTION_NAME(name) _##name -# else -# define C_FUNCTION_NAME(name) _/**/name -# endif -# else -# define C_FUNCTION_NAME(name) name -# endif -#endif - -#if defined(alpha) -# define ALIGNMENT 5 -#elif defined(i386) || defined(i486) || defined(i586) || defined(i686) -# define ALIGNMENT 8 -#elif defined(ia64) -# define ALIGNMENT 32 -#elif defined(powerpc) -# define ALIGNMENT 8 -#elif defined(sparcv8plus) || defined(sparcv9) -# define ALIGNMENT 8 -#else -# define ALIGNMENT 8 -#endif - -#if CYGWIN -# define C_FUNCTION(name) \ - .align ALIGNMENT; \ - .globl C_FUNCTION_NAME(name); \ - .def C_FUNCTION_NAME(name); \ - .scl 2; \ - .type 32; \ - .endef; \ -C_FUNCTION_NAME(name): -#else -# define C_FUNCTION(name) \ - .align ALIGNMENT; \ - .global C_FUNCTION_NAME(name); \ - .type C_FUNCTION_NAME(name),@function; \ -C_FUNCTION_NAME(name): -#endif - -#endif diff --git a/beecrypt/gnu/config.gnu.h.in b/beecrypt/gnu/config.gnu.h.in deleted file mode 100644 index a99b320a0..000000000 --- a/beecrypt/gnu/config.gnu.h.in +++ /dev/null @@ -1,175 +0,0 @@ -/* - * config.gnu.h.in - * - * Autoconf config.gnu.h template - * - * Copyright (c) 1999-2000 Virtual Unlimited B.V. - * - * Author: Bob Deblier <bob@virtualunlimited.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef _CONFIG_GNU_H -#define _CONFIG_GNU_H - -#ifndef _REENTRANT -#define _REENTRANT -#endif - -#ifndef __cplusplus -#undef inline -#endif - -#define AIX 0 -#define BEOS 0 -#define FREEBSD 0 -#define HPUX 0 -#define LINUX 0 -#define MACOSX 0 -#define OPENBSD 0 -#define SOLARIS 0 -#define WIN32 0 - -#if LINUX -#define _LIBC_REENTRANT -#endif - -#define WORDS_BIGENDIAN 0 - -#define HAVE_ERRNO_H 0 -#define HAVE_STRING_H 0 -#define HAVE_STDLIB_H 0 -#define HAVE_CTYPE_H 0 -#define HAVE_UNISTD_H 0 -#define HAVE_FCNTL_H 0 -#define HAVE_TIME_H 0 - -#define HAVE_SYS_TYPES_H 0 -#define HAVE_SYS_STAT_H 0 -#define HAVE_SYS_TIME_H 0 - -#define HAVE_THREAD_H 0 -#define HAVE_SYNCH_H 0 -#define HAVE_PTHREAD_H 0 -#define HAVE_SEMAPHORE_H 0 - -#define HAVE_TERMIO_H 0 -#define HAVE_SYS_AUDIOIO_H 0 -#define HAVE_SYS_IOCTL_H 0 -#define HAVE_SYS_SOUNDCARD_H 0 - -#define HAVE_GETTIMEOFDAY 0 -#define HAVE_GETHRTIME 0 - -#define HAVE_DEV_TTY 0 -#define HAVE_DEV_AUDIO 0 -#define HAVE_DEV_DSP 0 -#define HAVE_DEV_RANDOM 0 - -#define SIZEOF_CHAR 0 -#define SIZEOF_UNSIGNED_CHAR 0 -#define SIZEOF_SHORT 0 -#define SIZEOF_UNSIGNED_SHORT 0 -#define SIZEOF_INT 0 -#define SIZEOF_UNSIGNED_INT 0 -#define SIZEOF_LONG 0 -#define SIZEOF_UNSIGNED_LONG 0 -#define SIZEOF_LONG_LONG 0 -#define SIZEOF_UNSIGNED_LONG_LONG 0 - -#define SIZEOF_FLOAT 0 -#define SIZEOF_DOUBLE 0 - -#if (SIZEOF_CHAR == 1) -typedef char int8; -typedef char javabyte; -#else -#error sizeof(char) not 1 -#endif - -#if (SIZEOF_SHORT == 2) -typedef short int16; -typedef short javashort; -#else -#error sizeof(short) is not 2 -#endif - -#if (SIZEOF_INT == 4) -typedef int int32; -typedef int javaint; -#elif (SIZEOF_LONG == 4) -typedef int int32; -typedef long javaint; -#else -#error compiler has no 32 bit integer -#endif - -#if (SIZEOF_LONG == 8) -typedef long int64; -typedef long javalong; -#elif (SIZEOF_LONG_LONG == 8) -typedef long long int64; -typedef long long javalong; -#else -#error compiler has no 64 bit integer -#endif - -#if (SIZEOF_FLOAT == 4) -typedef float javafloat; -#else -#error compiler has no 32 bit float -#endif - -#if (SIZEOF_DOUBLE == 8) -typedef double javadouble; -#else -#error compiler has no 64 bit double; -#endif - -#if (SIZEOF_UNSIGNED_CHAR == 1) -typedef unsigned char uint8; -#else -#error sizeof(unsigned char) is not 1 -#endif - -#if (SIZEOF_UNSIGNED_SHORT == 2) -typedef unsigned short uint16; -typedef unsigned short javachar; -typedef unsigned short unicode; -#else -#error sizeof(unsigned short) is not 2 -#endif - -#if (SIZEOF_UNSIGNED_INT == 4) -typedef unsigned int uint32; -#elif (SIZEOF_UNSIGNED_LONG == 4) -typedef unsigned long uint32; -#else -#error compiler has no 32 bit unsigned integer -#endif - -#if (SIZEOF_UNSIGNED_LONG == 8) -typedef unsigned long uint64; -#elif (SIZEOF_UNSIGNED_LONG_LONG == 8) -typedef unsigned long long uint64; -#else -#error compiler has no 64 bit unsigned integer -#endif - -typedef uint8 byte; - -#endif diff --git a/beecrypt/gnu/fips180opt.gas.i586.S b/beecrypt/gnu/fips180opt.gas.i586.S deleted file mode 100644 index 5087f3eb9..000000000 --- a/beecrypt/gnu/fips180opt.gas.i586.S +++ /dev/null @@ -1,301 +0,0 @@ -/* - * fips180opt.gas.i586.S - * - * Assembler optimized SHA-1 routines for Intel Pentium processors - * - * Compile target is GNU AS - * - * Copyright (c) 2000 Virtual Unlimited B.V. - * - * Author: Bob Deblier <bob@virtualunlimited.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - .file "fips180opt.gas.i586.S" - - .text - - .equ K00, 0x5a827999 - .equ K20, 0x6ed9eba1 - .equ K40, 0x8f1bbcdc - .equ K60, 0xca62c1d6 - - .equ PARAM_H, 0 - .equ PARAM_DATA, 20 - - .macro subround1 b c d e w - movl \c,%ecx - movl \b,%ebx - movl \d,%edx - roll $5,%eax - xorl %edx,%ecx - addl \e,%eax - andl %ebx,%ecx - addl $K00,%eax - rorl $2,%ebx - addl \w(%esi,%edi),%eax - xorl %edx,%ecx - movl %ebx,\b - addl %ecx,%eax - movl %eax,\e - .endm - - .macro subround2 b c d e w - movl \c,%ecx - movl \b,%ebx - roll $5,%eax - xorl %ebx,%ecx - addl \e,%eax - xorl \d,%ecx - addl $K20,%eax - rorl $2,%ebx - addl \w(%esi,%edi),%eax - movl %ebx,\b - addl %ecx,%eax - movl %eax,\e - .endm - - .macro subround3 b c d e w - movl \c,%ecx - roll $5,%eax - movl \b,%ebx - movl %ecx,%edx - addl \e,%eax - orl %ebx,%ecx - andl %ebx,%edx - andl \d,%ecx - addl $K40,%eax - orl %edx,%ecx - addl \w(%esi,%edi),%eax - rorl $2,%ebx - addl %ecx,%eax - movl %ebx,\b - movl %eax,\e - .endm - - .macro subround4 b c d e w - movl \c,%ecx - movl \b,%ebx - roll $5,%eax - xorl %ebx,%ecx - addl \e,%eax - xorl \d,%ecx - addl $K60,%eax - rorl $2,%ebx - addl \w(%esi,%edi),%eax - movl %ebx,\b - addl %ecx,%eax - movl %eax,\e - .endm - - .align 4 -#if defined(CYGWIN) - .globl _sha1Process - .def _sha1Process - .scl 2 - .type 32 - .endef - -_sha1Process: -#else - .global sha1Process - .type sha1Process,@function - -sha1Process: -#endif - pushl %edi - pushl %esi - pushl %ebx - - pushl %ebp - leal -20(%esp),%ebp - - movl 20(%esp),%esi - leal PARAM_DATA(%esi),%edi - - movl $4,%ecx -.L0: - movl (%esi,%ecx,4),%edx - movl %edx,(%ebp,%ecx,4) - decl %ecx - jns .L0 - - movl $15,%ecx - xorl %eax,%eax - - .p2align 2 -.L1: - movl (%edi,%ecx,4),%edx - bswap %edx - mov %edx,(%edi,%ecx,4) - decl %ecx - jns .L1 - - leal PARAM_DATA(%esi),%edi - movl $16,%ecx - - .p2align 2 -.L2: - movl 52(%edi),%eax - movl 56(%edi),%ebx - xorl 32(%edi),%eax - xorl 36(%edi),%ebx - xorl 8(%edi),%eax - xorl 12(%edi),%ebx - xorl (%edi),%eax - xorl 4(%edi),%ebx - roll $1,%eax - roll $1,%ebx - movl %eax,64(%edi) - movl %ebx,68(%edi) - movl 60(%edi),%eax - movl 64(%edi),%ebx - xorl 40(%edi),%eax - xorl 44(%edi),%ebx - xorl 16(%edi),%eax - xorl 20(%edi),%ebx - xorl 8(%edi),%eax - xorl 12(%edi),%ebx - roll $1,%eax - roll $1,%ebx - movl %eax,72(%edi) - movl %ebx,76(%edi) - addl $16,%edi - decl %ecx - jnz .L2 - - movl $PARAM_DATA,%edi - - movl (%ebp),%eax -.L01_20: - subround1 4(%ebp), 8(%ebp), 12(%ebp), 16(%ebp), 0 - subround1 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround1 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround1 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround1 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - addl $20,%edi - subround1 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 - subround1 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround1 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround1 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround1 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - addl $20,%edi - subround1 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 - subround1 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround1 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround1 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround1 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - addl $20,%edi - subround1 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 - subround1 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround1 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround1 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround1 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - addl $20,%edi - -.L21_40: - subround2 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 - subround2 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround2 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround2 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround2 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - addl $20,%edi - subround2 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 - subround2 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround2 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround2 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround2 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - addl $20,%edi - subround2 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 - subround2 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround2 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround2 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround2 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - addl $20,%edi - subround2 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 - subround2 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround2 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround2 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround2 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - addl $20,%edi - -.L41_60: - subround3 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 - subround3 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround3 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround3 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround3 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - addl $20,%edi - subround3 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 - subround3 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround3 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround3 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround3 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - addl $20,%edi - subround3 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 - subround3 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround3 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround3 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround3 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - addl $20,%edi - subround3 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 - subround3 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround3 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround3 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround3 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - addl $20,%edi - -.L61_80: - subround4 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 - subround4 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround4 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround4 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround4 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - addl $20,%edi - subround4 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 - subround4 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround4 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround4 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround4 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - addl $20,%edi - subround4 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 - subround4 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround4 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround4 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround4 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - addl $20,%edi - subround4 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 - subround4 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround4 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround4 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround4 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - /* addl $20,%edi */ - - movl $4,%ecx - - .p2align 2 -.L3: - movl (%ebp,%ecx,4),%eax - addl %eax,(%esi,%ecx,4) - decl %ecx - jns .L3 - - popl %ebp - popl %ebx - popl %esi - popl %edi - ret diff --git a/beecrypt/gnu/fips180opt.gas.i586.s b/beecrypt/gnu/fips180opt.gas.i586.s deleted file mode 100644 index 1c03b4444..000000000 --- a/beecrypt/gnu/fips180opt.gas.i586.s +++ /dev/null @@ -1,292 +0,0 @@ -# -# fips180opt.gas.i586.asm -# -# Assembler optimized SHA-1 routines for Intel Pentium processors -# -# Compile target is GNU AS -# -# Copyright (c) 2000 Virtual Unlimited B.V. -# -# Author: Bob Deblier <bob@virtualunlimited.com> -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# - -.if 1 - .file "fips180opt.gas.i586.s" - - .text - - .equ K00, 0x5a827999 - .equ K20, 0x6ed9eba1 - .equ K40, 0x8f1bbcdc - .equ K60, 0xca62c1d6 - - .equ PARAM_H, 0 - .equ PARAM_DATA, 20 - - .macro subround1 b c d e w - movl \c,%ecx - movl \b,%ebx - movl \d,%edx - roll $5,%eax - xorl %edx,%ecx - addl \e,%eax - andl %ebx,%ecx - addl $K00,%eax - rorl $2,%ebx - addl \w(%esi,%edi),%eax - xorl %ecx,%edx - movl %ebx,\b - addl %ebx,%eax - movl %eax,\e - .endm - - .macro subround2 b c d e w - movl \c,%ecx - movl \b,%ebx - roll $5,%eax - xorl %ebx,%ecx - addl \e,%eax - xorl \d,%ecx - addl $K20,%eax - rorl $2,%ebx - addl \w(%esi,%edi),%eax - movl %ebx,\b - addl %ecx,%eax - movl %eax,\e - .endm - - .macro subround3 b c d e w - movl \c,%ecx - roll $5,%eax - movl \b,%ebx - movl %ecx,%edx - addl \e,%eax - orl %ebx,%ecx - andl %ebx,%edx - andl \d,%ecx - addl $K40,%eax - orl %edx,%ecx - addl \w(%esi,%edi),%eax - rorl $4,%ebx - addl %ecx,%eax - movl %ebx,\b - movl %eax,\e - .endm - - .macro subround4 b c d e w - movl \c,%ecx - movl \b,%ebx - roll $5,%eax - xorl %ebx,%ecx - addl \e,%eax - xorl \d,%ecx - addl $K60,%eax - rorl $2,%ebx - addl \w(%esi,%edi),%eax - movl %ebx,\b - addl %ecx,%eax - movl %eax,\e - .endm - - .align 4 - .globl sha1Process - .type sha1Process,@function - -sha1Process: - pushl %edi - pushl %esi - pushl %ebx - - pushl %ebp - leal -20(%esp),%ebp - - movl 20(%esp),%esi - leal PARAM_DATA(%esi),%edi - - movl $4,%ecx -.L0: - movl (%esi,%ecx,4),%edx - movl %edx,(%ebp,%ecx,4) - decl %ecx - jns .L0 - - movl $15,%ecx - xorl %eax,%eax - - .p2align 2 -.L1: - movl (%edi,%ecx,4),%edx - bswap %edx - mov %edx,(%edi,%ecx,4) - decl %ecx - jns .L1 - - leal PARAM_DATA(%esi),%edi - movl $16,%ecx - - .p2align 2 -.L2: - movl 52(%edi),%eax - movl 56(%edi),%ebx - xorl 32(%edi),%eax - xorl 36(%edi),%ebx - xorl 8(%edi),%eax - xorl 12(%edi),%eax - xorl (%edi),%ebx - xorl 4(%edi),%ebx - roll $1,%eax - roll $1,%ebx - movl %eax,64(%edi) - movl %ebx,68(%edi) - movl 60(%edi),%eax - movl 64(%edi),%ebx - xorl 36(%edi),%eax - xorl 40(%edi),%ebx - xorl 16(%edi),%eax - xorl 20(%edi),%eax - xorl 8(%edi),%ebx - xorl 12(%edi),%ebx - roll $1,%eax - roll $1,%ebx - movl %eax,72(%edi) - movl %ebx,76(%edi) - addl $16,%edi - decl %ecx - jnz .L2 - - movl $PARAM_DATA,%edi - - movl (%ebp),%eax -.L01_20: - subround1 4(%ebp), 8(%ebp), 12(%ebp), 16(%ebp), 0 - subround1 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround1 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround1 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround1 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - addl $20,%edi - subround1 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 - subround1 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround1 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround1 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround1 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - addl $20,%edi - subround1 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 - subround1 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround1 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround1 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround1 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - addl $20,%edi - subround1 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 - subround1 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround1 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround1 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround1 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - addl $20,%edi - -.L21_40: - subround2 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 - subround2 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround2 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround2 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround2 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - addl $20,%edi - subround2 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 - subround2 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround2 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround2 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround2 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - addl $20,%edi - subround2 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 - subround2 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround2 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround2 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround2 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - addl $20,%edi - subround2 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 - subround2 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround2 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround2 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround2 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - addl $20,%edi - -.L41_60: - subround3 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 - subround3 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround3 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround3 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround3 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - addl $20,%edi - subround3 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 - subround3 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround3 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround3 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround3 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - addl $20,%edi - subround3 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 - subround3 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround3 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround3 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround3 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - addl $20,%edi - subround3 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 - subround3 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround3 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround3 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround3 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - addl $20,%edi - -.L61_80: - subround4 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 - subround4 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround4 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround4 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround4 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - addl $20,%edi - subround4 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 - subround4 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround4 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround4 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround4 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - addl $20,%edi - subround4 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 - subround4 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround4 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround4 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround4 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - addl $20,%edi - subround4 4(%ebp), %ebx , 12(%ebp), 16(%ebp), 0 - subround4 (%ebp), %ebx , 8(%ebp), 12(%ebp), 4 - subround4 16(%ebp), %ebx , 4(%ebp), 8(%ebp), 8 - subround4 12(%ebp), %ebx , (%ebp), 4(%ebp), 12 - subround4 8(%ebp), %ebx , 16(%ebp), (%ebp), 16 - # addl $20,%edi - - movl $4,%ecx - - .p2align 2 -.L3: - movl (%ebp,%ecx,4),%eax - addl %eax,(%esi,%ecx,4) - decl %ecx - jns .L3 - - popl %ebp - popl %ebx - popl %esi - popl %edi - ret -.endif diff --git a/beecrypt/gnu/mp32opt.gas.i386.S b/beecrypt/gnu/mp32opt.gas.i386.S deleted file mode 100644 index 94d851448..000000000 --- a/beecrypt/gnu/mp32opt.gas.i386.S +++ /dev/null @@ -1,361 +0,0 @@ -/* - * mp32opt.gas.i386.S - * - * Assembler optimized multiprecision integer routines for Intel 386 and higher - * - * Compile target is GNU AS - * - * Copyright (c) 1998-2000 Virtual Unlimited B.V. - * - * Author: Bob Deblier <bob@virtualunlimited.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - .file "mp32opt.gas.i386.S" - - .text - - .align 4 -#if defined(CYGWIN) - .globl _mp32addw - .def _mp32addw - .scl 2 - .type 32 - .endef - -_mp32addw: -#else - .global mp32addw - .type mp32addw,@function - -mp32addw: -#endif - pushl %edi - - movl 8(%esp),%ecx - movl 12(%esp),%edi - movl 16(%esp),%eax - - xorl %edx,%edx - leal -4(%edi,%ecx,4),%edi - addl %eax,(%edi) - decl %ecx - jz .L1 - leal -4(%edi),%edi - - .p2align 4,,7 -.L0: - adcl %edx,(%edi) - leal -4(%edi),%edi - decl %ecx - jnz .L0 -.L1: - sbbl %eax,%eax - negl %eax - - popl %edi - ret - -#if defined(CYGWIN) - .globl _mp32subw - .def _mp32subw - .scl 2 - .type 32 - .endef - -_mp32subw: -#else - .global mp32subw - .type mp32subw,@function - -mp32subw: -#endif - pushl %edi - - movl 8(%esp),%ecx - movl 12(%esp),%edi - movl 16(%esp),%eax - - xorl %edx,%edx - leal -4(%edi,%ecx,4),%edi - subl %eax,(%edi) - decl %ecx - jz .L3 - leal -4(%edi),%edi - - .p2align 4,,7 -.L2: - sbbl %edx,(%edi) - leal -4(%edi),%edi - decl %ecx - jnz .L2 -.L3: - sbbl %eax,%eax - negl %eax - popl %edi - ret - -#if defined(CYGWIN) - .globl _mp32add - .def _mp32add - .scl 2 - .type 32 - .endef - -_mp32add: -#else - .global mp32add - .type mp32add,@function - -mp32add: -#endif - pushl %edi - pushl %esi - - movl 12(%esp),%ecx - movl 16(%esp),%edi - movl 20(%esp),%esi - - xorl %edx,%edx - decl %ecx - - .p2align 4,,7 -.L4: - movl (%esi,%ecx,4),%eax - adcl %eax,(%edi,%ecx,4) - decl %ecx - jns .L4 - - sbbl %eax,%eax - negl %eax - - popl %esi - popl %edi - ret - -#if defined(CYGWIN) - .globl _mp32sub - .def _mp32sub - .scl 2 - .type 32 - .endef - -_mp32sub: -#else - .global mp32sub - .type mp32sub,@function - -mp32sub: -#endif - pushl %edi - pushl %esi - - movl 12(%esp),%ecx - movl 16(%esp),%edi - movl 20(%esp),%esi - - xorl %edx,%edx - decl %ecx - - .p2align 4,,7 -.L5: - movl (%esi,%ecx,4),%eax - sbbl %eax,(%edi,%ecx,4) - decl %ecx - jns .L5 - - sbbl %eax,%eax - negl %eax - popl %esi - popl %edi - ret - -#if defined(CYGWIN) - .globl _mp32multwo - .def _mp32multwo - .scl 2 - .type 32 - .endef - -_mp32multwo: -#else - .global mp32multwo - .type mp32multwo,@function - -mp32multwo: -#endif - pushl %edi - - movl 8(%esp),%ecx - movl 12(%esp),%edi - - xorl %eax,%eax - decl %ecx - - .p2align 4,,7 -.L6: - movl (%edi,%ecx,4),%eax - adcl %eax,(%edi,%ecx,4) - decl %ecx - jns .L6 - - sbbl %eax,%eax - negl %eax - - popl %edi - ret - -#if defined(CYGWIN) - .globl _mp32setmul - .def _mp32setmul - .scl 2 - .type 32 - .endef - -_mp32setmul: -#else - .global mp32setmul - .type mp32setmul,@function - -mp32setmul: -#endif - pushl %edi - pushl %esi - pushl %ebx - pushl %ebp - - movl 20(%esp),%ecx - movl 24(%esp),%edi - movl 28(%esp),%esi - movl 32(%esp),%ebp - - xorl %ebx,%ebx - decl %ecx - - .p2align 4,,7 -.L7: - movl (%esi,%ecx,4),%eax - mull %ebp - addl %ebx,%eax - adcl $0,%edx - movl %eax,(%edi,%ecx,4) - movl %edx,%ebx - decl %ecx - jns .L7 - - movl %ebx,%eax - - popl %ebp - popl %ebx - popl %esi - popl %edi - ret - -#if defined(CYGWIN) - .globl _mp32addmul - .def _mp32addmul - .scl 2 - .type 32 - .endef - -_mp32addmul: -#else - .global mp32addmul - .type mp32addmul,@function - -mp32addmul: -#endif - pushl %edi - pushl %esi - pushl %ebx - pushl %ebp - - movl 20(%esp),%ecx - movl 24(%esp),%edi - movl 28(%esp),%esi - movl 32(%esp),%ebp - - xorl %ebx,%ebx - decl %ecx - - .p2align 4,,7 -.L8: - movl (%esi,%ecx,4),%eax - mull %ebp - addl %ebx,%eax - adcl $0,%edx - addl (%edi,%ecx,4),%eax - adcl $0,%edx - movl %eax,(%edi,%ecx,4) - movl %edx,%ebx - decl %ecx - jns .L8 - - movl %ebx,%eax - - popl %ebp - popl %ebx - popl %esi - popl %edi - ret - -#if defined(CYGWIN) - .globl _mp32addsqrtrc - .def _mp32addsqrtrc - .scl 2 - .type 32 - .endef - -_mp32addsqrtrc: -#else - .global mp32addsqrtrc - .type mp32addsqrtrc,@function - -mp32addsqrtrc: -#endif - pushl %edi - pushl %esi - pushl %ebx - - movl 16(%esp),%ecx - movl 20(%esp),%edi - movl 24(%esp),%esi - - xorl %ebx,%ebx - decl %ecx - - .p2align 4,,7 -.L9: - movl (%esi,%ecx,4),%eax - mull %eax - addl %ebx,%eax - adcl $0,%edx - addl 4(%edi,%ecx,8),%eax - adcl (%edi,%ecx,8),%edx - sbbl %ebx,%ebx - movl %eax,4(%edi,%ecx,8) - movl %edx,(%edi,%ecx,8) - negl %ebx - decl %ecx - jns .L9 - - movl %ebx,%eax - - popl %ebx - popl %esi - popl %edi - ret diff --git a/beecrypt/gnu/mp32opt.gas.i386.s b/beecrypt/gnu/mp32opt.gas.i386.s deleted file mode 100644 index 31ea45c59..000000000 --- a/beecrypt/gnu/mp32opt.gas.i386.s +++ /dev/null @@ -1,287 +0,0 @@ -# -# mp32opt.gas.i386.s -# -# Assembler optimized multiprecision integer routines for Intel 386 and higher -# -# Compile target is GNU AS -# -# Copyright (c) 1998-2000 Virtual Unlimited B.V. -# -# Author: Bob Deblier <bob@virtualunlimited.com> -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# - - .file "mp32opt.gas.i386.s" - - .text - - .align 4 - .globl mp32addw - .type mp32addw,@function - -mp32addw: - pushl %edi - - movl 8(%esp),%ecx - movl 12(%esp),%edi - movl 16(%esp),%eax - - xorl %edx,%edx - leal -4(%edi,%ecx,4),%edi - addl %eax,(%edi) - decl %ecx - jz .L1 - leal -4(%edi),%edi - - .p2align 4,,7 -.L0: - adcl %edx,(%edi) - leal -4(%edi),%edi - decl %ecx - jnz .L0 -.L1: - sbbl %eax,%eax - negl %eax - - popl %edi - ret - - .align 4 - .globl mp32subw - .type mp32subw,@function - -mp32subw: - pushl %edi - - movl 8(%esp),%ecx - movl 12(%esp),%edi - movl 16(%esp),%eax - - xorl %edx,%edx - leal -4(%edi,%ecx,4),%edi - subl %eax,(%edi) - decl %ecx - jz .L3 - leal -4(%edi),%edi - - .p2align 4,,7 -.L2: - sbbl %edx,(%edi) - leal -4(%edi),%edi - decl %ecx - jnz .L2 -.L3: - sbbl %eax,%eax - negl %eax - popl %edi - ret - - .align 4 - .globl mp32add - .type mp32add,@function - -mp32add: - pushl %edi - pushl %esi - - movl 12(%esp),%ecx - movl 16(%esp),%edi - movl 20(%esp),%esi - - xorl %edx,%edx - decl %ecx - - .p2align 4,,7 -.L4: - movl (%esi,%ecx,4),%eax - adcl %eax,(%edi,%ecx,4) - decl %ecx - jns .L4 - - sbbl %eax,%eax - negl %eax - - popl %esi - popl %edi - ret - - .align 4 - .globl mp32sub - .type mp32sub,@function - -mp32sub: - pushl %edi - pushl %esi - - movl 12(%esp),%ecx - movl 16(%esp),%edi - movl 20(%esp),%esi - - xorl %edx,%edx - decl %ecx - - .p2align 4,,7 -.L5: - movl (%esi,%ecx,4),%eax - sbbl %eax,(%edi,%ecx,4) - decl %ecx - jns .L5 - - sbbl %eax,%eax - negl %eax - popl %esi - popl %edi - ret - - .align 4 - .globl mp32multwo - .type mp32multwo,@function - -mp32multwo: - pushl %edi - - movl 8(%esp),%ecx - movl 12(%esp),%edi - - xorl %eax,%eax - decl %ecx - - .p2align 4,,7 -.L6: - movl (%edi,%ecx,4),%eax - adcl %eax,(%edi,%ecx,4) - decl %ecx - jns .L6 - - sbbl %eax,%eax - negl %eax - - popl %edi - ret - - .align 4 - .globl mp32setmul - .type mp32setmul,@function - -mp32setmul: - pushl %edi - pushl %esi - pushl %ebx - pushl %ebp - - movl 20(%esp),%ecx - movl 24(%esp),%edi - movl 28(%esp),%esi - movl 32(%esp),%ebp - - xorl %ebx,%ebx - decl %ecx - - .p2align 4,,7 -.L7: - movl (%esi,%ecx,4),%eax - mull %ebp - addl %ebx,%eax - adcl $0,%edx - movl %eax,(%edi,%ecx,4) - movl %edx,%ebx - decl %ecx - jns .L7 - - movl %ebx,%eax - - popl %ebp - popl %ebx - popl %esi - popl %edi - ret - - .align 4 - .globl mp32addmul - .type mp32addmul,@function - -mp32addmul: - pushl %edi - pushl %esi - pushl %ebx - pushl %ebp - - movl 20(%esp),%ecx - movl 24(%esp),%edi - movl 28(%esp),%esi - movl 32(%esp),%ebp - - xorl %ebx,%ebx - decl %ecx - - .p2align 4,,7 -.L8: - movl (%esi,%ecx,4),%eax - mull %ebp - addl %ebx,%eax - adcl $0,%edx - addl (%edi,%ecx,4),%eax - adcl $0,%edx - movl %eax,(%edi,%ecx,4) - movl %edx,%ebx - decl %ecx - jns .L8 - - movl %ebx,%eax - - popl %ebp - popl %ebx - popl %esi - popl %edi - ret - - .align 4 - .globl mp32addsqrtrc - .type mp32addsqrtrc,@function - -mp32addsqrtrc: - pushl %edi - pushl %esi - pushl %ebx - - movl 16(%esp),%ecx - movl 20(%esp),%edi - movl 24(%esp),%esi - - xorl %ebx,%ebx - decl %ecx - - .p2align 4,,7 -.L9: - movl (%esi,%ecx,4),%eax - mull %eax - addl %ebx,%eax - adcl $0,%edx - addl 4(%edi,%ecx,8),%eax - adcl (%edi,%ecx,8),%edx - sbbl %ebx,%ebx - movl %eax,4(%edi,%ecx,8) - movl %edx,(%edi,%ecx,8) - negl %ebx - decl %ecx - jns .L9 - - movl %ebx,%eax - - popl %ebx - popl %esi - popl %edi - ret diff --git a/beecrypt/gnu/mp32opt.gas.ia64.S b/beecrypt/gnu/mp32opt.gas.ia64.S deleted file mode 100644 index e7d95f76f..000000000 --- a/beecrypt/gnu/mp32opt.gas.ia64.S +++ /dev/null @@ -1,242 +0,0 @@ -/* - * mp32opt.gas.ia64.S - * - * Assembler optimized multiprecision integer routines for ia64 (Intel Itanium) - * - * Compile target is GNU AS - * - * Copyright (c) 2000 Virtual Unlimited B.V. - * - * Author: Bob Deblier <bob@virtualunlimited.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#define saved_pfs r14 -#define saved_lc r15 - -#define size r16 -#define dst r17 -#define src r18 - - .file "mp32opt.gas.ia64.s" - - .text - - .explicit - - .align 32 - .global mp32zero - .type mp32zero,@function - -mp32zero: - alloc saved_pfs = ar.pfs,2,0,0,0 - mov saved_lc = ar.lc - sub size = in0,r0,1;; - mov src = in1 - mov ar.lc = size;; -.L00: - st4 [src] = r0,4 - br.ctop.sptk .L00 - ;; - mov ar.lc = saved_lc - mov ar.pfs = saved_pfs - br.ret.sptk b0 - - - .align 32 - .global mp32copy - .type mp32copy,@function - -mp32copy: - alloc r14 = ar.pfs,3,5,0,8 - mov r15 = ar.lc - sub r16 = in0,r0,1 - mov r17 = in1 - mov r18 = in2;; - mov ar.lc = r16 - mov ar.ec = 3 - mov pr.rot = (1 << 16);; -.L01: - (p16) ld4 r32 = [r18],4 - (p18) st4 [r17] = r34,4 - br.ctop.sptk .L01;; - mov ar.lc = r15 - mov ar.pfs = r14 - br.ret.sptk b0 - - - .if 0 - .align 32 - .global mp32z - .type mp32z,@function - -mp32z: - alloc r14 = ar.pfs,2,6,0,8 - mov r15 = ar.lc - sub r16= in0,r0,1 - mov r17 = in1 - mov r18 = in2;; - mov r8 = 1 - mov pr.rot = 1 << 16 - mov ar.ec = 2 - mov ar.lc = r16;; -.L02: - (p16) ld4 r32 = [r18],4 - (p18) cmp.eq p0,p32 = r34,r0 - (p33) mov r8 = r0 - (p33) br.exit - .endif - - - .align 32 - .global mp32add - .type mp32add,@function - -mp32add: - alloc r14 = ar.pfs,3,0,0,0 - mov r15 = ar.lc - # adjust size by -1 - sub r16 = in0,r0,1 - # clear carry - mov r8 = r0;; - # load addresses - shladd r17 = r16,2,in1 - shladd r18 = r16,2,in2 - # load loop count - mov ar.lc = r16;; -.L20: - ld4 r20 = [r18],-4 - ld4 r19 = [r17] - tbit.z p1,p2 = r8,32;; - (p1) add r8 = r19,r20 - (p2) add r8 = r19,r20,1;; - st4 [r17] = r8,-4 - br.cloop.sptk .L20;; - extr.u r8 = r8,32,1 - mov ar.lc = r15 - mov ar.pfs = r14 - br.ret.sptk b0 - - - .align 32 - .global mp32sub - .type mp32sub,@function - -mp32sub: - alloc r14 = ar.pfs,3,0,0,0 - mov r15 = ar.lc - # adjust size by -1 - sub r16 = in0,r0,1 - # clear carry - mov r8 = r0;; - # load addresses - shladd r17 = r16,2,in1 - shladd r18 = r16,2,in2 - # load loop count - mov ar.lc = r16;; -.L30: - ld4 r20 = [r18],-4 - ld4 r19 = [r17] - tbit.z p1,p2 = r8,32;; - (p1) sub r8 = r19,r20 - (p2) sub r8 = r19,r20,1;; - st4 [r17] = r8,-4 - br.cloop.sptk .L30;; - extr.u r8 = r8,32,1 - mov ar.lc = r15 - mov ar.pfs = r14 - br.ret.sptk b0 - - - .align 32 - .global mp32setmul - .type mp32setmul,@function - -mp32setmul: - alloc r14 = ar.pfs,4,0,0,0 - mov r15 = ar.lc - # adjust size by -1 - sub r16 = in0,r0,1 - # clear carry - mov r8 = r0;; - # adjust addresses - shladd r17 = r16,2,in1 - shladd r18 = r16,2,in2 - # load loop count - mov ar.lc = r16 - # load mul - setf.sig f96 = in3;; -.L40: - ld4 r19 = [r18],-4;; - setf.sig f98 = r8 - setf.sig f97 = r19;; - # multiplication can only be done in f registers, but we do have a multiply-add - xma.l f98 = f96, f97, f98;; - getf.sig r8 = f98;; - st4 [r17] = r8,-4 - shr.u r8 = r8,32 - br.cloop.sptk .L40;; - mov ar.lc = r15 - mov ar.pfs = r14 - br.ret.sptk b0 - - - .align 32 - .global mp32addmul - .type mp32addmul,@function - -mp32addmul: - alloc r14 = ar.pfs,4,0,0,0 - mov r15 = ar.lc - # adjust size by -1 - sub r16 = in0,r0,1 - # load mul - # setf.sig f6 = r0 - setf.sig f7 = in3 - # clear carry - mov r8 = r0;; - # adjust addresses - shladd r17 = r16,2,in1 - shladd r18 = r16,2,in2 - # load loop count - mov ar.lc = r16;; -.L50: - ld4 r19 = [r17] - ld4 r20 = [r18],-4;; - setf.sig f8 = r8 - setf.sig f32 = r20;; - # multiplication can only be done in f registers, but we do have a multiply-add - xma.l f8 = f7,f32,f8;; - getf.sig r8 = f8;; - add r8 = r8,r19;; - st4 [r17] = r8,-4 - shr.u r8 = r8,32 - br.cloop.sptk .L50;; - mov ar.lc = r15 - mov ar.pfs = r14 - br.ret.sptk b0 - - - .if 0 - .align 16 - .global mp32addsqrtrc# - .proc mp32addsqrtrc# - -mp32addsqrtrc: - .endp mp32addsqrtrc# - .endif - diff --git a/beecrypt/gnu/mp32opt.gas.powerpc.S b/beecrypt/gnu/mp32opt.gas.powerpc.S deleted file mode 100644 index 9ae0489d6..000000000 --- a/beecrypt/gnu/mp32opt.gas.powerpc.S +++ /dev/null @@ -1,259 +0,0 @@ -/* - * mp32opt.gas.powerpc.S - * - * Assembler optimized multiprecision integer routines for PowerPC - * - * Compile target is GNU AS - * - * Copyright (c) 2000 Virtual Unlimited B.V. - * - * Author: Bob Deblier <bob@virtualunlimited.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - .file "mp32opt.gas.powerpc.S" - - .text - -#if defined(DARWIN) -# define reg0 r0 -# define reg3 r3 -# define reg4 r4 -# define reg5 r5 -# define reg6 r6 -# define reg7 r7 -# define reg8 r8 -# define reg9 r9 -#else -# define reg0 %r0 -# define reg3 %r3 -# define reg4 %r4 -# define reg5 %r5 -# define reg6 %r6 -# define reg7 %r7 -# define reg8 %r8 -# define reg9 %r9 -#endif - - .align 4 -#if defined(DARWIN) - .globl _mp32addw - -_mp32addw: -#else - .global mp32addw - .type mp32addw,@function - -mp32addw: -#endif - mtctr reg3 - slwi reg0,reg3,2 - add reg4,reg4,reg0 - li reg0,0 - lwzu reg6,-4(reg4) - addc reg6,reg6,reg5 - stw reg6,0(reg4) - bdz .L01 -.L00: - lwzu reg6,-4(reg4) - adde reg6,reg0,reg6 - stw reg6,0(reg4) - bdnz .L00 -.L01: # return the carry - addze reg3,reg0 - blr - - .align 4 -#if defined(DARWIN) - .globl _mp32subw - -_mp32subw: -#else - .global mp32subw - .type mp32subw,@function - -mp32subw: -#endif - mtctr reg3 - slwi reg0,reg3,2 - add reg4,reg4,reg0 - li reg0,0 - lwz reg6,-4(reg4) - subfc reg6,reg5,reg6 - stwu reg6,-4(reg4) - bdz .L11 -.L10: - lwz reg6,-4(reg4) - subfe reg6,reg0,reg6 - stwu reg6, -4(reg4) - bdnz .L10 -.L11: # return the carry - subfe reg3,reg0,reg0 - neg reg3,reg3 - blr - - .align 4 -#if defined(DARWIN) - .globl _mp32add - -_mp32add: -#else - .global mp32add - .type mp32add,@function - -mp32add: -#endif - mtctr reg3 - slwi reg0,reg3,2 - add reg4,reg4,reg0 - add reg5,reg5,reg0 - li reg0,0 - lwz reg6,-4(reg4) - lwzu reg7,-4(reg5) - addc reg6,reg7,reg6 - stwu reg6,-4(reg4) - bdz .L21 -.L20: - lwz reg6,-4(reg4) - lwzu reg7,-4(reg5) - adde reg6,reg7,reg6 - stwu reg6,-4(reg4) - bdnz .L20 -.L21: # return the carry - addze reg3,reg0 - blr - - .align 4 -#if defined(DARWIN) - .globl _mp32sub - -_mp32sub: -#else - .global mp32sub - .type mp32sub,@function - -mp32sub: -#endif - mtctr reg3 - slwi reg0,reg3,2 - add reg4,reg4,reg0 - add reg5,reg5,reg0 - li reg0,0 - lwz reg6,-4(reg4) - lwzu reg7,-4(reg5) - subfc reg6,reg7,reg6 - stwu reg6,-4(reg4) - bdz .L31 -.L30: - lwz reg6,-4(reg4) - lwzu reg7,-4(reg5) - subfe reg6,reg7,reg6 - stwu reg6,-4(reg4) - bdnz .L30 -.L31: # return the carry - subfe reg3,reg0,reg0 - neg reg3,reg3 - blr - - .align 4 -#if defined(DARWIN) - .globl _mp32setmul - -_mp32setmul: -#else - .globl mp32setmul - .type mp32setmul,@function - -mp32setmul: -#endif - mtctr reg3 - slwi reg0,reg3,2 - add reg4,reg4,reg0 - add reg5,reg5,reg0 - li reg3,0 -.L40: - lwzu reg7,-4(reg5) - mullw reg8,reg7,reg6 - addc reg8,reg8,reg3 - mulhwu reg3,reg7,reg6 - addze reg3,reg3 - stwu reg8,-4(reg4) - bdnz .L40 - blr - - .align 4 -#if defined(DARWIN) - .globl _mp32addmul - -_mp32addmul: -#else - .globl mp32addmul - .type mp32addmul,@function - -mp32addmul: -#endif - mtctr reg3 - slwi reg0,reg3,2 - add reg4,reg4,reg0 - add reg5,reg5,reg0 - li reg3,0 -.L50: - lwzu reg7,-4(reg4) - lwzu reg8,-4(reg5) - mullw reg9,reg8,reg6 - addc reg9,reg9,reg3 - mulhwu reg3,reg8,reg6 - addze reg3,reg3 - addc reg9,reg9,reg7 - addze reg3,reg3 - stw reg9,0(reg4) - bdnz .L50 - blr - - .align 4 -#if defined(DARWIN) - .globl _mp32addsqrtrc - -_mp32addsqrtrc: -#else - .globl mp32addsqrtrc - .type mp32addsqrtrc,@function - -mp32addsqrtrc: -#endif - mtctr reg3 - slwi reg0,reg3,2 - add reg4,reg4,reg0 - add reg5,reg5,reg0 - add reg4,reg4,reg0 - li reg3,0 -.L60: - lwzu reg0,-4(reg5) - lwz reg6,-8(reg4) - lwz reg7,-4(reg4) - mullw reg9,reg0,reg0 - mulhwu reg8,reg0,reg0 - addc reg9,reg9,reg3 - addze reg8,reg8 - addc reg7,reg7,reg9 - adde reg6,reg6,reg8 - li reg3,0 - addze reg3,reg3 - stw reg7,-4(reg4) - stwu reg6,-8(reg4) - bdnz .L60 - blr diff --git a/beecrypt/gnu/mp32opt.gas.powerpc.s b/beecrypt/gnu/mp32opt.gas.powerpc.s deleted file mode 100644 index 1f6017693..000000000 --- a/beecrypt/gnu/mp32opt.gas.powerpc.s +++ /dev/null @@ -1,210 +0,0 @@ -# -# mp32opt.gas.powerpc.s -# -# Assembler optimized multiprecision integer routines for PowerPC -# -# Compile target is GNU AS -# -# Copyright (c) 2000 Virtual Unlimited B.V. -# -# Author: Bob Deblier <bob@virtualunlimited.com> -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# - - .file "mp32opt.gas.powerpc.s" - - .align 4 - .globl mp32addw - .type mp32addw,@function - -mp32addw: - mtctr %r3 - slwi %r0,%r3,2 - add %r4,%r4,%r0 - li %r0,0 - lwzu %r6,-4(%r4) - addc %r6,%r6,%r5 - stw %r6,0(%r4) - bdz .L01 -.L00: - lwzu %r6,-4(%r4) - adde %r6,%r0,%r6 - stw %r6,0(%r4) - bdnz .L00 -.L01: # return the carry - addze %r3,%r0 - blr - - .if 0 # doesn't work yet - .align 4 - .globl mp32subw - .type mp32subw,@function - -mp32subw: - mtctr %r3 - slwi %r0,%r3,2 - add %r4,%r4,%r0 - li %r0,0 - lwz %r6,-4(%r4) - subfc %r6,%r5,%r6 - stwu %r6,-4(%r4) - bdz .L11 -.L10: - lwz %r6,-4(%r4) - subfe %r6,%r0,%r6 - stwu %r6, -4(%r4) - bdnz .L10 -.L11: # return the carry - addze %r3,%r0 - blr - .endif - - .align 4 - .globl mp32add - .type mp32add,@function - -mp32add: - mtctr %r3 - slwi %r0,%r3,2 - add %r4,%r4,%r0 - add %r5,%r5,%r0 - li %r0,0 - lwz %r6,-4(%r4) - lwzu %r7,-4(%r5) - addc %r6,%r7,%r6 - stwu %r6,-4(%r4) - bdz .L21 -.L20: - lwz %r6,-4(%r4) - lwzu %r7,-4(%r5) - adde %r6,%r7,%r6 - stwu %r6,-4(%r4) - bdnz .L20 -.L21: # return the carry - addze %r3,%r0 - blr - - .if 0 # doesn't work yet - .align 4 - .globl mp32sub - .type mp32sub,@function - -mp32sub: - mtctr %r3 - slwi %r0,%r3,2 - add %r4,%r4,%r0 - add %r5,%r5,%r0 - li %r0,0 - lwz %r6,-4(%r4) - lwzu %r7,-4(%r5) - subfc %r6,%r7,%r6 - stwu %r6,-4(%r4) - bdz .L31 -.L30: - lwz %r6,-4(%r4) - lwzu %r7,-4(%r5) - subfe %r6,%r7,%r6 - stwu %r6,-4(%r4) - bdnz .L30 -.L31: # return the carry - addze %r3,%r0 - blr - .endif - - .align 4 - .globl mp32setmul - .type mp32setmul,@function - -# size %r3 -# dst %r4 -# src %r5 -# mulw %r6 - -mp32setmul: - mtctr %r3 - slwi %r0,%r3,2 - add %r4,%r4,%r0 - add %r5,%r5,%r0 - li %r3,0 -.L40: - lwzu %r7,-4(%r5) - mullw %r8,%r7,%r6 - addc %r8,%r8,%r3 - mulhwu %r3,%r7,%r6 - addze %r3,%r3 - stwu %r8,-4(%r4) - bdnz .L40 - blr - - .align 4 - .globl mp32addmul - .type mp32addmul,@function - -# size %r3 -# dst %r4 -# src %r5 -# mulw %r6 - -mp32addmul: - mtctr %r3 - slwi %r0,%r3,2 - add %r4,%r4,%r0 - add %r5,%r5,%r0 - li %r3,0 -.L50: - lwzu %r7,-4(%r4) - lwzu %r8,-4(%r5) - mullw %r9,%r8,%r6 - addc %r9,%r9,%r3 - mulhwu %r3,%r8,%r6 - addze %r3,%r3 - addc %r9,%r9,%r7 - addze %r3,%r3 - stw %r9,0(%r4) - bdnz .L50 - blr - - .align 4 - .globl mp32addsqrtrc - .type mp32addsqrtrc,@function - -# size %r3 -# dst %r4 -# src %r5 - -mp32addsqrtrc: - mtctr %r3 - slwi %r0,%r3,2 - add %r4,%r4,%r0 - add %r5,%r5,%r0 - add %r4,%r4,%r0 - li %r3,0 -.L60: - lwzu %r0,-4(%r5) - lwz %r6,-8(%r4) - lwz %r7,-4(%r4) - mullw %r9,%r0,%r0 - mulhwu %r8,%r0,%r0 - addc %r9,%r9,%r3 - addze %r8,%r8 - addc %r7,%r7,%r9 - adde %r6,%r6,%r8 - li %r3,0 - addze %r3,%r3 - stw %r7,-4(%r4) - stwu %r6,-8(%r4) - bdnz .L60 - blr diff --git a/beecrypt/gnu/mp32opt.gas.sparcv9.S b/beecrypt/gnu/mp32opt.gas.sparcv9.S deleted file mode 100644 index 9fe7c6c4c..000000000 --- a/beecrypt/gnu/mp32opt.gas.sparcv9.S +++ /dev/null @@ -1,180 +0,0 @@ -/* - * mp32opt.gas.sparcv9.S - * - * Assembler optimized multiprecision integer routines for UltraSparc (64 bits instructions, will run on 32 bit OS) - * - * Compile target is GNU AS - * - * Copyright (c) 1998-2000 Virtual Unlimited B.V. - * - * Author: Bob Deblier <bob@virtualunlimited.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - .file "mp32opt.gas.sparcv9.S" - - .text - - .align 8 - .globl mp32addw - .type mp32addw,@function - -mp32addw: - sll %o0,2,%g1 - sub %g1,4,%g1 - mov %g0,%o0 - lduw [%o1+%g1],%g2 - addcc %g2,%o2,%g2 - stw %g2,[%o1+%g1] - brz,pn %g1,.L01 - sub %g1,4,%g1 -.L00: - lduw [%o1+%g1],%g2 - addccc %g2,%g0,%g2 - stw %g2,[%o1+%g1] - brnz,pt %g1,.L00 - sub %g1,4,%g1 -.L01: - retl - movcs %icc,1,%o0 - - .align 8 - .globl mp32subw - .type mp32subw,@function - -mp32subw: - sll %o0,2,%g1 - sub %g1,4,%g1 - mov %g0,%o0 - lduw [%o1+%g1],%g2 - subcc %g2,%o2,%g2 - stw %g2,[%o1+%g1] - brz,pn %g1,.L11 - sub %g1,4,%g1 -.L10: - lduw [%o1+%g1],%g2 - subccc %g2,%g0,%g2 - stw %g2,[%o1+%g1] - brnz,pt %g1,.L10 - sub %g1,4,%g1 -.L11: - retl - movcs %icc,1,%o0 - - .align 8 - .globl mp32add - .type mp32add,@function - -mp32add: - sll %o0,2,%g1 - sub %g1,4,%g1 - addcc %g0,%g0,%o0 -.L20: - lduw [%o1+%g1],%g2 - lduw [%o2+%g1],%g3 - addccc %g2,%g3,%g4 - stw %g4,[%o1+%g1] - brnz,pt %g1,.L20 - sub %g1,4,%g1 - retl - movcs %icc,1,%o0 - - .align 8 - .globl mp32sub - .type mp32sub,@function - -mp32sub: - sll %o0,2,%g1 - sub %g1,4,%g1 - addcc %g0,%g0,%o0 -.L30: - lduw [%o1+%g1],%g2 - lduw [%o2+%g1],%g3 - subccc %g2,%g3,%g4 - stw %g4,[%o1+%g1] - brnz,pt %g1,.L30 - sub %g1,4,%g1 - retl - movcs %icc,1,%o0 - - .align 8 - .globl mp32setmul - .type mp32setmul,@function - -mp32setmul: - sll %o0,2,%g1 - sub %g1,4,%g1 - mov %g0,%o0 -.L40: - lduw [%o2+%g1],%g2 - mulx %o3,%g2,%g3 - add %o0,%g3,%o0 - stw %o0,[%o1+%g1] - srlx %o0,32,%o0 - brnz,pt %g1,.L40 - sub %g1,4,%g1 - retl - nop - - .align 8 - .globl mp32addmul - .type mp32addmul,@function - -mp32addmul: - sll %o0,2,%g1 - sub %g1,4,%g1 - mov %g0,%o0 -.L50: - lduw [%o2+%g1],%g2 - lduw [%o1+%g1],%g4 - mulx %o3,%g2,%g3 - add %o0,%g3,%o0 - add %o0,%g4,%o0 - stw %o0,[%o1+%g1] - srlx %o0,32,%o0 - brnz,pt %g1,.L50 - sub %g1,4,%g1 - retl - nop - - .align 8 - .globl mp32addsqrtrc - .type mp32addsqrtrc,@function - -mp32addsqrtrc: - sll %o0,2,%g1 - sub %g1,4,%g1 - add %o1,%g1,%o1 - add %o1,%g1,%o1 - mov %g0,%o0 - -.L60: - /* load from o1 into g4 as xuint; simulate xuint carry by doing an xuint comparison; carry if result smaller than initial value */ - lduw [%o2+%g1],%g2 - ldx [%o1],%g4 - mulx %g2,%g2,%g2 - add %o0,%g4,%g3 - add %g3,%g2,%g3 - cmp %g4,%g3 - or %g0,0,%o0 - movgu %xcc,1,%o0 - stx %g3,[%o1] - sub %o1,8,%o1 - brnz,pt %g1,.L60 - sub %g1,4,%g1 - retl - nop diff --git a/beecrypt/gnu/mp32opt.gas.sparcv9.s b/beecrypt/gnu/mp32opt.gas.sparcv9.s deleted file mode 100644 index 50e0ed48a..000000000 --- a/beecrypt/gnu/mp32opt.gas.sparcv9.s +++ /dev/null @@ -1,189 +0,0 @@ -# -# mp32opt.gas.sparcv9.s -# -# Assembler optimized multiprecision integer routines for UltraSparc (64 bits instructions, will run on 32 bit OS) -# -# Compile target is GNU AS -# -# Copyright (c) 1998-2000 Virtual Unlimited B.V. -# -# Author: Bob Deblier <bob@virtualunlimited.com> -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# - - .file "mp32opt.gas.sparcv9.s" - - .section ".text" - - .align 4 - .globl mp32addw - .type mp32addw,@function - -# INPUT PARAMETERS -# size %o0 -# data %o1 -# addw %o2 - -mp32addw: - sll %o0,2,%g1 - sub %g1,4,%g1 - mov %g0,%o0 - lduw [%o1+%g1],%g2 - addcc %g2,%o2,%g2 - stw %g2,[%o1+%g1] - brz,pn %g1,.L01 - sub %g1,4,%g1 -.L00: - lduw [%o1+%g1],%g2 - addccc %g2,%g0,%g2 - stw %g2,[%o1+%g1] - brnz,pt %g1,.L00 - sub %g1,4,%g1 -.L01: - retl - movcs %icc,1,%o0 - - .align 4 - .globl mp32subw - .type mp32subw,@function - -mp32subw: - sll %o0,2,%g1 - sub %g1,4,%g1 - mov %g0,%o0 - lduw [%o1+%g1],%g2 - subcc %g2,%o2,%g2 - stw %g2,[%o1+%g1] - brz,pn %g1,.L11 - sub %g1,4,%g1 -.L10: - lduw [%o1+%g1],%g2 - subccc %g2,%g0,%g2 - stw %g2,[%o1+%g1] - brnz,pt %g1,.L10 - sub %g1,4,%g1 -.L11: - retl - movcs %icc,1,%o0 - - .align 4 - .globl mp32add - .type mp32add,@function - -mp32add: - sll %o0,2,%g1 - sub %g1,4,%g1 - addcc %g0,%g0,%o0 -.L20: - lduw [%o1+%g1],%g2 - lduw [%o2+%g1],%g3 - addccc %g2,%g3,%g4 - stw %g4,[%o1+%g1] - brnz,pt %g1,.L20 - sub %g1,4,%g1 - retl - movcs %icc,1,%o0 - - .align 4 - .globl mp32sub - .type mp32sub,@function - -mp32sub: - sll %o0,2,%g1 - sub %g1,4,%g1 - addcc %g0,%g0,%o0 -.L30: - lduw [%o1+%g1],%g2 - lduw [%o2+%g1],%g3 - subccc %g2,%g3,%g4 - stw %g4,[%o1+%g1] - brnz,pt %g1,.L30 - sub %g1,4,%g1 - retl - movcs %icc,1,%o0 - - .align 4 - .globl mp32setmul - .type mp32setmul,@function - -mp32setmul: - sll %o0,2,%g1 - sub %g1,4,%g1 - mov %g0,%o0 -.L40: - lduw [%o2+%g1],%g2 - mulx %o3,%g2,%g3 - add %o0,%g3,%o0 - stw %o0,[%o1+%g1] - srlx %o0,32,%o0 - brnz,pt %g1,.L40 - sub %g1,4,%g1 - retl - nop - - .align 4 - .globl mp32addmul - .type mp32addmul,@function - -mp32addmul: - sll %o0,2,%g1 - sub %g1,4,%g1 - mov %g0,%o0 -.L50: - lduw [%o2+%g1],%g2 - lduw [%o1+%g1],%g4 - mulx %o3,%g2,%g3 - add %o0,%g3,%o0 - add %o0,%g4,%o0 - stw %o0,[%o1+%g1] - srlx %o0,32,%o0 - brnz,pt %g1,.L50 - sub %g1,4,%g1 - retl - nop - -.if 0 - # not finished ! - .align 4 - .globl mp32addsqrtrc - .type mp32addsqrtrc,@function - -mp32addsqrtrc: - sll %o0,2,%g1 - add %o1,%g1,%o1 - sub %g1,4,%g1 - add %o1,%g1,%o1 - mov %g0,%o0 - -.L60: - lduw [%o2+%g1],%g2 - lduw [%o1],%g4 - mulx %g2,%g2,%g3 - add %o0,%g3,%o0 - add %o0,%g4,%o0 - stw %o0,[%o1] - sub %o1,4,%o1 - srlx %o0,32,%o0 - lduw [%o1],%g4 - add %o0,%g4,%g0 - stw %o0,[%o1] - sub %o1,4,%o1 - srlx %o0,32,%o0 - brnz,pt %g1,.L60 - sub %g1,4,%g1 - retl - nop -.endif diff --git a/beecrypt/hmac.c b/beecrypt/hmac.c deleted file mode 100644 index 50a3fd0da..000000000 --- a/beecrypt/hmac.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 1999, 2000, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file hmac.c - * \brief HMAC algorithm. - * - * \see RFC2104 HMAC: Keyed-Hashing for Message Authentication. - * H. Krawczyk, M. Bellare, R. Canetti. - * - * \author Bob Deblier <bob.deblier@pandore.be> - * \ingroup HMAC_m - */ - -#include "system.h" - -#include "hmac.h" -#include "mp.h" -#include "endianness.h" - -#include "debug.h" - -/*!\addtogroup HMAC_m - * \{ - */ - -#define HMAC_IPAD 0x36 -#define HMAC_OPAD 0x5c - -int hmacSetup(byte* kxi, byte* kxo, const hashFunction* hash, hashFunctionParam* param, const byte* key, size_t keybits) -{ - register unsigned int i; - - size_t keybytes = keybits >> 3; - - /* if the key is too large, hash it first */ - if (keybytes > hash->blocksize) - { - /* if the hash digest is too large, this doesn't help; this is really a sanity check */ - if (hash->digestsize > hash->blocksize) - return -1; - - if (hash->reset(param)) - return -1; - - if (hash->update(param, key, keybytes)) - return -1; - - if (hash->digest(param, kxi)) - return -1; - - memcpy(kxo, kxi, keybytes = hash->digestsize); - } - else if (keybytes > 0) - { - memcpy(kxi, key, keybytes); - memcpy(kxo, key, keybytes); - } - else - return -1; - - for (i = 0; i < keybytes; i++) - { - kxi[i] ^= HMAC_IPAD; - kxo[i] ^= HMAC_OPAD; - } - - for (i = keybytes; i < hash->blocksize; i++) - { - kxi[i] = HMAC_IPAD; - kxo[i] = HMAC_OPAD; - } - - return hmacReset(kxi, hash, param); -} - -int hmacReset(const byte* kxi, const hashFunction* hash, hashFunctionParam* param) -{ - if (hash->reset(param)) - return -1; - if (hash->update(param, kxi, hash->blocksize)) - return -1; - - return 0; -} - -int hmacUpdate(const hashFunction* hash, hashFunctionParam* param, const byte* data, size_t size) -{ - return hash->update(param, data, size); -} - -int hmacDigest(const byte* kxo, const hashFunction* hash, hashFunctionParam* param, byte* data) -{ - if (hash->digest(param, data)) - return -1; - if (hash->update(param, kxo, hash->blocksize)) - return -1; - if (hash->update(param, data, hash->digestsize)) - return -1; - if (hash->digest(param, data)) - return -1; - - return 0; -} - -/*!\} - */ diff --git a/beecrypt/hmac.h b/beecrypt/hmac.h deleted file mode 100644 index 4d7de7c0b..000000000 --- a/beecrypt/hmac.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 1999, 2000, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file hmac.h - * \brief HMAC algorithm, headers. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup HMAC_m - */ - -#ifndef _HMAC_H -#define _HMAC_H - -#include "beecrypt.h" - -/*!\ingroup HMAC_m - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* not used directly as keyed hash function, but instead used as generic methods */ - -BEECRYPTAPI -int hmacSetup ( byte* kxi, byte* kxo, const hashFunction* hash, hashFunctionParam* param, const byte* key, size_t keybits) - /*@modifies kxi, kxo @*/; -BEECRYPTAPI -int hmacReset (const byte* kxi, const hashFunction* hash, hashFunctionParam* param) - /*@*/; -BEECRYPTAPI -int hmacUpdate( const hashFunction* hash, hashFunctionParam* param, const byte* data, size_t size) - /*@*/; -BEECRYPTAPI -int hmacDigest( const byte* kxo, const hashFunction* hash, hashFunctionParam* param, byte* data) - /*@*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/hmacmd5.c b/beecrypt/hmacmd5.c deleted file mode 100644 index 33de1b559..000000000 --- a/beecrypt/hmacmd5.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2000, 2001, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file hmacmd5.c - * \brief HMAC-MD5 message authentication code. - * - * \see RFC2202 - Test Cases for HMAC-MD5 and HMAC-SHA-1. - * P. Cheng, R. Glenn. - * - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup HMAC_m HMAC_md5_m - */ - -#include "system.h" - -#include "hmacmd5.h" - -#include "debug.h" - -/*!\addtogroup HMAC_md5_m - * \{ - */ - -const keyedHashFunction hmacmd5 = { - "HMAC-MD5", - sizeof(hmacmd5Param), - 64, - 16, - 64, - 512, - 32, - (keyedHashFunctionSetup) hmacmd5Setup, - (keyedHashFunctionReset) hmacmd5Reset, - (keyedHashFunctionUpdate) hmacmd5Update, - (keyedHashFunctionDigest) hmacmd5Digest -}; - -int hmacmd5Setup (hmacmd5Param* sp, const byte* key, size_t keybits) -{ - return hmacSetup(sp->kxi, sp->kxo, &md5, &sp->mparam, key, keybits); -} - -int hmacmd5Reset (hmacmd5Param* sp) -{ - return hmacReset(sp->kxi, &md5, &sp->mparam); -} - -int hmacmd5Update(hmacmd5Param* sp, const byte* data, size_t size) -{ - return hmacUpdate(&md5, &sp->mparam, data, size); -} - -int hmacmd5Digest(hmacmd5Param* sp, byte* data) -{ - return hmacDigest(sp->kxo, &md5, &sp->mparam, data); -} - -/*!\} - */ diff --git a/beecrypt/hmacmd5.h b/beecrypt/hmacmd5.h deleted file mode 100644 index e56954f40..000000000 --- a/beecrypt/hmacmd5.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2000, 2001, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file hmacmd5.h - * \brief HMAC-MD5 message authentication code, headers. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup HMAC_m HMAC_md5_m - */ - -#ifndef _HMACMD5_H -#define _HMACMD5_H - -#include "hmac.h" -#include "md5.h" - -/*!\ingroup HMAC_md5_m - */ -typedef struct -{ - md5Param mparam; - byte kxi[64]; - byte kxo[64]; -} hmacmd5Param; - -#ifdef __cplusplus -extern "C" { -#endif - -extern BEECRYPTAPI const keyedHashFunction hmacmd5; - -BEECRYPTAPI -int hmacmd5Setup (hmacmd5Param* sp, const byte* key, size_t keybits) - /*@modifies sp @*/; -BEECRYPTAPI -int hmacmd5Reset (hmacmd5Param* sp) - /*@*/; -BEECRYPTAPI -int hmacmd5Update(hmacmd5Param* sp, const byte* data, size_t size) - /*@*/; -BEECRYPTAPI -int hmacmd5Digest(hmacmd5Param* sp, byte* data) - /*@*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/hmacsha1.c b/beecrypt/hmacsha1.c deleted file mode 100644 index 031d70845..000000000 --- a/beecrypt/hmacsha1.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 1999, 2000, 2001, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file hmacsha1.c - * \brief HMAC-SHA-1 message authentication code. - * - * \see RFC2202 - Test Cases for HMAC-MD5 and HMAC-SHA-1. - * P. Cheng, R. Glenn. - * - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup HMAC_m HMAC_sha1_m - */ - -#include "system.h" - -#include "hmacsha1.h" - -#include "debug.h" - -/*!\addtogroup HMAC_sha1_m - * \{ - */ - -const keyedHashFunction hmacsha1 = { - "HMAC-SHA-1", - sizeof(hmacsha1Param), - 64, - 20, - 64, - 512, - 32, - (keyedHashFunctionSetup) hmacsha1Setup, - (keyedHashFunctionReset) hmacsha1Reset, - (keyedHashFunctionUpdate) hmacsha1Update, - (keyedHashFunctionDigest) hmacsha1Digest -}; - -int hmacsha1Setup (hmacsha1Param* sp, const byte* key, size_t keybits) -{ - return hmacSetup(sp->kxi, sp->kxo, &sha1, &sp->sparam, key, keybits); -} - -int hmacsha1Reset (hmacsha1Param* sp) -{ - return hmacReset(sp->kxi, &sha1, &sp->sparam); -} - -int hmacsha1Update(hmacsha1Param* sp, const byte* data, size_t size) -{ - return hmacUpdate(&sha1, &sp->sparam, data, size); -} - -int hmacsha1Digest(hmacsha1Param* sp, byte* data) -{ - return hmacDigest(sp->kxo, &sha1, &sp->sparam, data); -} - -/*!\} - */ diff --git a/beecrypt/hmacsha1.h b/beecrypt/hmacsha1.h deleted file mode 100644 index 342773eb5..000000000 --- a/beecrypt/hmacsha1.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 1999, 2000, 2001, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file hmacsha1.h - * \brief HMAC-SHA-1 message authentication code, headers. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup HMAC_m HMAC_sha1_m - */ - -#ifndef _HMACSHA1_H -#define _HMACSHA1_H - -#include "hmac.h" -#include "sha1.h" - -/*!\ingroup HMAC_sha1_m - */ -typedef struct -{ - sha1Param sparam; - byte kxi[64]; - byte kxo[64]; -} hmacsha1Param; - -#ifdef __cplusplus -extern "C" { -#endif - -extern BEECRYPTAPI const keyedHashFunction hmacsha1; - -BEECRYPTAPI -int hmacsha1Setup (hmacsha1Param* sp, const byte* key, size_t keybits) - /*@modifies sp @*/; -BEECRYPTAPI -int hmacsha1Reset (hmacsha1Param* sp) - /*@*/; -BEECRYPTAPI -int hmacsha1Update(hmacsha1Param* sp, const byte* data, size_t size) - /*@*/; -BEECRYPTAPI -int hmacsha1Digest(hmacsha1Param* sp, byte* data) - /*@*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/hmacsha256.c b/beecrypt/hmacsha256.c deleted file mode 100644 index 5bf2da7fc..000000000 --- a/beecrypt/hmacsha256.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2000, 2001, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file hmacsha256.c - * \brief HMAC-SHA-256 message digest algorithm. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup HMAC_m HMAC_sha256_m - */ - -#include "system.h" - -#include "hmacsha256.h" - -#include "debug.h" - -/*!\addtogroup HMAC_sha256_m - * \{ - */ - -const keyedHashFunction hmacsha256 = { - "HMAC-SHA-256", - sizeof(hmacsha256Param), - 64, - 32, - 64, - 512, - 32, - (keyedHashFunctionSetup) hmacsha256Setup, - (keyedHashFunctionReset) hmacsha256Reset, - (keyedHashFunctionUpdate) hmacsha256Update, - (keyedHashFunctionDigest) hmacsha256Digest -}; - -int hmacsha256Setup (hmacsha256Param* sp, const byte* key, size_t keybits) -{ - return hmacSetup(sp->kxi, sp->kxo, &sha256, &sp->sparam, key, keybits); -} - -int hmacsha256Reset (hmacsha256Param* sp) -{ - return hmacReset(sp->kxi, &sha256, &sp->sparam); -} - -int hmacsha256Update(hmacsha256Param* sp, const byte* data, size_t size) -{ - return hmacUpdate(&sha256, &sp->sparam, data, size); -} - -int hmacsha256Digest(hmacsha256Param* sp, byte* data) -{ - return hmacDigest(sp->kxo, &sha256, &sp->sparam, data); -} - -/*!\} - */ diff --git a/beecrypt/hmacsha256.h b/beecrypt/hmacsha256.h deleted file mode 100644 index 7cca0627a..000000000 --- a/beecrypt/hmacsha256.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2000, 2001, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file hmacsha256.h - * \brief HMAC-SHA-256 message authentication code, headers. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup HMAC_m HMAC_sha256_m - */ - -#ifndef _HMACSHA256_H -#define _HMACSHA256_H - -#include "hmac.h" -#include "sha256.h" - -/*!\ingroup HMAC_sha256_m - */ -typedef struct -{ - sha256Param sparam; - byte kxi[64]; - byte kxo[64]; -} hmacsha256Param; - -#ifdef __cplusplus -extern "C" { -#endif - -extern BEECRYPTAPI const keyedHashFunction hmacsha256; - -BEECRYPTAPI -int hmacsha256Setup (hmacsha256Param* sp, const byte* key, size_t keybits) - /*@modifies sp @*/; -BEECRYPTAPI -int hmacsha256Reset (hmacsha256Param* sp) - /*@*/; -BEECRYPTAPI -int hmacsha256Update(hmacsha256Param* sp, const byte* data, size_t size) - /*@*/; -BEECRYPTAPI -int hmacsha256Digest(hmacsha256Param* sp, byte*) - /*@*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/install-sh b/beecrypt/install-sh deleted file mode 100755 index 67c942908..000000000 --- a/beecrypt/install-sh +++ /dev/null @@ -1,238 +0,0 @@ -#! /bin/sh -# -# install - install a program, script, or datafile -# This comes from X11R5. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. -# - - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" - - -# put in absolute paths if you don't have them in your path; or use env. vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" - -transformbasename="" -transform_arg="" -instcmd="$mvprog" -chmodcmd="$chmodprog 0755" -chowncmd="" -chgrpcmd="" -stripcmd="" -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" -dir_arg="" - -while [ x"$1" != x ]; do - case $1 in - -c) instcmd="$cpprog" - shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - -s) stripcmd="$stripprog" - shift - continue;; - - -t=*) transformarg=`echo $1 | sed 's/-t=//'` - shift - continue;; - - -b=*) transformbasename=`echo $1 | sed 's/-b=//'` - shift - continue;; - - *) if [ x"$src" = x ] - then - src=$1 - else - # this colon is to work around a 386BSD /bin/sh bug - : - dst=$1 - fi - shift - continue;; - esac -done - -if [ x"$src" = x ] -then - echo "install: no input file specified" - exit 1 -else - true -fi - -if [ x"$dir_arg" != x ]; then - dst=$src - src="" - - if [ -d $dst ]; then - instcmd=: - else - instcmd=mkdir - fi -else - -# Waiting for this to be detected by the "$instcmd $src $dsttmp" command -# might cause directories to be created, which would be especially bad -# if $src (and thus $dsttmp) contains '*'. - - if [ -f "$src" -o -d "$src" ] - then - true - else - echo "install: $src does not exist" - exit 1 - fi - - if [ x"$dst" = x ] - then - echo "install: no destination specified" - exit 1 - else - true - fi - -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic - - if [ -d $dst ] - then - dst="$dst"/`basename $src` - else - true - fi -fi - -## this sed command emulates the dirname command -dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` - -# Make sure that the destination directory exists. -# this part is taken from Noah Friedman's mkinstalldirs script - -# Skip lots of stat calls in the usual case. -if [ ! -d "$dstdir" ]; then -defaultIFS=' -' -IFS="${IFS-${defaultIFS}}" - -oIFS="${IFS}" -# Some sh's can't handle IFS=/ for some reason. -IFS='%' -set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` -IFS="${oIFS}" - -pathcomp='' - -while [ $# -ne 0 ] ; do - pathcomp="${pathcomp}${1}" - shift - - if [ ! -d "${pathcomp}" ] ; - then - $mkdirprog "${pathcomp}" - else - true - fi - - pathcomp="${pathcomp}/" -done -fi - -if [ x"$dir_arg" != x ] -then - $doit $instcmd $dst && - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi -else - -# If we're going to rename the final executable, determine the name now. - - if [ x"$transformarg" = x ] - then - dstfile=`basename $dst` - else - dstfile=`basename $dst $transformbasename | - sed $transformarg`$transformbasename - fi - -# don't allow the sed command to completely eliminate the filename - - if [ x"$dstfile" = x ] - then - dstfile=`basename $dst` - else - true - fi - -# Make a temp file name in the proper directory. - - dsttmp=$dstdir/#inst.$$# - -# Move or copy the file name to the temp name - - $doit $instcmd "$src" $dsttmp && - - trap "rm -f ${dsttmp}" 0 && - -# and set any options; do chmod last to preserve setuid bits - -# If any of these fail, we abort the whole thing. If we want to -# ignore errors from any of these, just make sure not to ignore -# errors from the above "$doit $instcmd $src $dsttmp" command. - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && - -# Now rename the file to the real destination. - - $doit $rmcmd -f $dstdir/$dstfile && - $doit $mvcmd $dsttmp $dstdir/$dstfile - -fi && - - -exit 0 diff --git a/beecrypt/java/.cvsignore b/beecrypt/java/.cvsignore deleted file mode 100644 index 9730646fd..000000000 --- a/beecrypt/java/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.la -*.lo diff --git a/beecrypt/java/Makefile.am b/beecrypt/java/Makefile.am deleted file mode 100644 index 6d51a664f..000000000 --- a/beecrypt/java/Makefile.am +++ /dev/null @@ -1,37 +0,0 @@ -# -# Copyright (c) 2003 Bob Deblier -# -# Author: Bob Deblier <bob.deblier@pandora.be> -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# - -AUTOMAKE_OPTIONS = gnu no-dependencies - -LIBBEECRYPT_JAVA_LT_CURRENT = 8 -LIBBEECRYPT_JAVA_LT_AGE = 2 -LIBBEECRYPT_JAVA_LT_REVISION = 0 - -INCLUDES = -I$(top_srcdir)/.. @JAVAINC@ - -libaltdir=$(prefix)/lib@LIBALT@ - -libalt_LTLIBRARIES = libbeecrypt_java.la - -noinst_HEADERS = javaglue.h - -libbeecrypt_java_la_SOURCES = javaglue.c -libbeecrypt_java_la_LIBADD = $(top_builddir)/libbeecrypt.la -libbeecrypt_java_la_LDFLAGS = -no-undefined -version $(LIBBEECRYPT_JAVA_LT_CURRENT):$(LIBBEECRYPT_JAVA_LT_REVISION):$(LIBBEECRYPT_JAVA_LT_AGE) diff --git a/beecrypt/java/javaglue.c b/beecrypt/java/javaglue.c deleted file mode 100644 index 0a2a31c1b..000000000 --- a/beecrypt/java/javaglue.c +++ /dev/null @@ -1,640 +0,0 @@ -#include "system.h" - -#include "beecrypt.h" -#include "blockmode.h" -#include "mpnumber.h" -#include "mpbarrett.h" - -#if JAVAGLUE - -#include "javaglue.h" - -#include "debug.h" - -static const char* JAVA_OUT_OF_MEMORY_ERROR = "java/lang/OutOfMemoryError"; -static const char* JAVA_PROVIDER_EXCEPTION = "java/security/ProviderException"; -static const char* JAVA_INVALID_KEY_EXCEPTION = "java/security/InvalidKeyException"; -static const char* MSG_OUT_OF_MEMORY = "out of memory"; -static const char* MSG_NO_SUCH_ALGORITHM = "algorithm not available"; -static const char* MSG_NO_ENTROPY_SOURCE = "no entropy source"; -static const char* MSG_INVALID_KEY = "invalid key"; - -/* Utility functions */ - -static void jba_to_mpnumber(JNIEnv* env, jbyteArray input, mpnumber* n) -{ - jbyte* data = (*env)->GetByteArrayElements(env, input, (jboolean*) 0); - if (data == (jbyte*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); - if (ex) - (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); - } - else - { - jsize len = (*env)->GetArrayLength(env, input); - size_t size = MP_BYTES_TO_WORDS(len + MP_WBYTES - 1); - - mpnsetbin(n, data, len); - } - (*env)->ReleaseByteArrayElements(env, input, data, JNI_ABORT); -} - -static void jba_to_mpbarrett(JNIEnv* env, jbyteArray input, mpbarrett* b) -{ - jbyte* data = (*env)->GetByteArrayElements(env, input, (jboolean*) 0); - if (data == (jbyte*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); - if (ex) - (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); - } - else - { - jsize len = (*env)->GetArrayLength(env, input); - size_t size = MP_BYTES_TO_WORDS(len + MP_WBYTES - 1); - - mpbsetbin(b, data, len); - } - (*env)->ReleaseByteArrayElements(env, input, data, JNI_ABORT); -} - -/* NativeMessageDigest */ - -jlong JNICALL Java_beecrypt_security_NativeMessageDigest_find(JNIEnv* env, jclass dummy, jstring algorithm) -{ - const char* name = (*env)->GetStringUTFChars(env, algorithm, (jboolean*) 0); - const hashFunction* hash = hashFunctionFind(name); - (*env)->ReleaseStringUTFChars(env, algorithm, name); - if (hash == (hashFunction*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_PROVIDER_EXCEPTION); - if (ex != (jclass) 0) - (*env)->ThrowNew(env, ex, MSG_NO_SUCH_ALGORITHM); - } - return (jlong) hash; -} - -jlong JNICALL Java_beecrypt_security_NativeMessageDigest_allocParam(JNIEnv* env, jclass dummy, jlong hash) -{ - void *param = malloc(((const hashFunction*) hash)->paramsize); - if (param == (void*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); - if (ex != (jclass) 0) - (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); - } - return (jlong) param; -} - -jlong JNICALL Java_beecrypt_security_NativeMessageDigest_cloneParam(JNIEnv* env, jclass dummy, jlong hash, jlong param) -{ - unsigned int paramsize = ((const hashFunction*) hash)->paramsize; - void *clone = malloc(paramsize); - memcpy(clone, (void*) param, paramsize); - return (jlong) clone; -} - -void JNICALL Java_beecrypt_security_NativeMessageDigest_freeParam(JNIEnv* env, jclass dummy, jlong param) -{ - if (param) - free((void*) param); -} - -void JNICALL Java_beecrypt_security_NativeMessageDigest_reset(JNIEnv* env, jclass dummy, jlong hash, jlong param) -{ - ((const hashFunction*) hash)->reset((hashFunctionParam*) param); -} - -void JNICALL Java_beecrypt_security_NativeMessageDigest_update(JNIEnv* env, jclass dummy, jlong hash, jlong param, jbyte input) -{ - ((const hashFunction*) hash)->update((hashFunctionParam*) param, (const byte*) &input, 1); -} - -void JNICALL Java_beecrypt_security_NativeMessageDigest_updateBlock(JNIEnv* env, jclass dummy, jlong hash, jlong param, jbyteArray input, jint offset, jint len) -{ - jbyte* data = (*env)->GetByteArrayElements(env, input, (jboolean*) 0); - if (data == (jbyte*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); - (*env)->ReleaseByteArrayElements(env, input, data, JNI_ABORT); - if (ex) - (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); - return; - } - ((const hashFunction*) hash)->update((hashFunctionParam*) param, (const byte*) data+offset, len); - (*env)->ReleaseByteArrayElements(env, input, data, JNI_ABORT); -} - -jbyteArray JNICALL Java_beecrypt_security_NativeMessageDigest_digest(JNIEnv* env, jclass dummy, jlong hash, jlong param) -{ - jbyteArray digestArray; - jbyte* digest; - - int digestsize = (jsize) ((const hashFunction*) hash)->digestsize; - - digestArray = (*env)->NewByteArray(env, digestsize); - digest = (*env)->GetByteArrayElements(env, digestArray, (jboolean*) 0); - - if (digest == (jbyte*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); - if (ex) - (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); - return (jbyteArray) 0; - } - - ((const hashFunction*) hash)->digest((hashFunctionParam*) param, (byte*) digest); - - (*env)->ReleaseByteArrayElements(env, digestArray, digest, 0); - - return digestArray; -} - -jint JNICALL Java_beecrypt_security_NativeMessageDigest_digestLength(JNIEnv* env, jclass dummy, jlong hash) -{ - return (jint) ((const hashFunction*) hash)->digestsize; -} - -/* NativeSecureRandom */ - -jlong JNICALL Java_beecrypt_security_NativeSecureRandom_find(JNIEnv* env, jclass dummy, jstring algorithm) -{ - const char* name = (*env)->GetStringUTFChars(env, algorithm, (jboolean*) 0); - const randomGenerator* prng = randomGeneratorFind(name); - (*env)->ReleaseStringUTFChars(env, algorithm, name); - if (prng == (randomGenerator*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_PROVIDER_EXCEPTION); - if (ex) - (*env)->ThrowNew(env, ex, MSG_NO_SUCH_ALGORITHM); - } - return (jlong) prng; -} - -jlong JNICALL Java_beecrypt_security_NativeSecureRandom_allocParam(JNIEnv* env, jclass dummy, jlong prng) -{ - void *param = malloc(((const randomGenerator*) prng)->paramsize); - if (param == (void*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); - if (ex) - (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); - } - return (jlong) param; -} - -jlong JNICALL Java_beecrypt_security_NativeSecureRandom_cloneParam(JNIEnv* env, jclass dummy, jlong prng, jlong param) -{ - unsigned int paramsize = ((const randomGenerator*) prng)->paramsize; - void *clone = malloc(paramsize); - memcpy(clone, (void*) param, paramsize); - return (jlong) clone; -} - -void JNICALL Java_beecrypt_security_NativeSecureRandom_freeParam(JNIEnv* env, jclass dummy, jlong param) -{ - if (param) - free((void*) param); -} - -void JNICALL Java_beecrypt_security_NativeSecureRandom_setup(JNIEnv* env, jclass dummy, jlong prng, jlong param) -{ - ((const randomGenerator*) prng)->setup((randomGeneratorParam*) param); -} - -void JNICALL Java_beecrypt_security_NativeSecureRandom_setSeed(JNIEnv* env, jclass dummy, jlong prng, jlong param, jbyteArray seedArray) -{ - /* BeeCrypt takes size in words */ - jsize seedSize = (*env)->GetArrayLength(env, seedArray); - if (seedSize) - { - jbyte* seed = (*env)->GetByteArrayElements(env, seedArray, (jboolean*) 0); - if (seed == (jbyte*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); - if (ex) - (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); - return; - } - - ((const randomGenerator*) prng)->seed((randomGeneratorParam*) param, (byte*) seed, seedSize); - - (*env)->ReleaseByteArrayElements(env, seedArray, seed, JNI_ABORT); - } -} - -void JNICALL Java_beecrypt_security_NativeSecureRandom_nextBytes(JNIEnv* env, jclass dummy, jlong prng, jlong param, jbyteArray bytesArray) -{ - jsize bytesSize = (*env)->GetArrayLength(env, bytesArray); - if (bytesSize) - { - jbyte* bytes = (*env)->GetByteArrayElements(env, bytesArray, (jboolean*) 0); - if (bytes == (jbyte*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); - if (ex) - (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); - return; - } - - ((const randomGenerator*) prng)->next((randomGeneratorParam*) param, (byte*) bytes, bytesSize); - - (*env)->ReleaseByteArrayElements(env, bytesArray, bytes, 0); - } -} - -void JNICALL Java_beecrypt_security_NativeSecureRandom_generateSeed(JNIEnv* env, jclass dummy, jbyteArray seedArray) -{ - /* BeeCrypt takes size in words */ - jsize seedSize = (*env)->GetArrayLength(env, seedArray); - - if (seedSize) - { - jbyte* seed = (*env)->GetByteArrayElements(env, seedArray, (jboolean*) 0); - - const entropySource* ents = entropySourceDefault(); - - if (seed == (jbyte*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); - if (ex) - (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); - return; - } - - if (ents == (entropySource*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_PROVIDER_EXCEPTION); - (*env)->ReleaseByteArrayElements(env, seedArray, seed, JNI_ABORT); - if (ex) - (*env)->ThrowNew(env, ex, MSG_NO_ENTROPY_SOURCE); - return; - } - - ents->next((byte*) seed, seedSize); - - (*env)->ReleaseByteArrayElements(env, seedArray, seed, 0); - } -} - -/* NativeBlockCipher */ - -jlong JNICALL Java_beecrypt_crypto_NativeBlockCipher_find(JNIEnv* env, jclass dummy, jstring algorithm) -{ - const char* name = (*env)->GetStringUTFChars(env, algorithm, (jboolean*) 0); - const blockCipher* ciph = blockCipherFind(name); - (*env)->ReleaseStringUTFChars(env, algorithm, name); - if (ciph == (blockCipher*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_PROVIDER_EXCEPTION); - if (ex) - (*env)->ThrowNew(env, ex, MSG_NO_SUCH_ALGORITHM); - } - return (jlong) ciph; -} - -jlong JNICALL Java_beecrypt_crypto_NativeBlockCipher_allocParam(JNIEnv* env, jclass dummy, jlong ciph) -{ - void *param = malloc(((const blockCipher*) ciph)->paramsize); - if (param == (void*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); - if (ex) - (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); - } - return (jlong) param; -} - -void JNICALL Java_beecrypt_crypto_NativeBlockCipher_freeParam(JNIEnv* env, jclass dummy, jlong param) -{ - if (param) - free((void*) param); -} - -jint JNICALL Java_beecrypt_crypto_NativeBlockCipher_getBlockSize(JNIEnv* env, jclass dummy, jlong ciph) -{ - return ((const blockCipher*) ciph)->blocksize; -} - -void JNICALL Java_beecrypt_crypto_NativeBlockCipher_setup(JNIEnv* env, jclass dummy, jlong ciph, jlong param, jint mode, jbyteArray keyArray) -{ - /* BeeCrypt takes key in byte array with size in bits */ - jsize keysize = (*env)->GetArrayLength(env, keyArray); - - if (keysize) - { - int rc; - cipherOperation nativeop; - jbyte* key; - - switch (mode) - { - case javax_crypto_Cipher_ENCRYPT_MODE: - nativeop = ENCRYPT; - break; - case javax_crypto_Cipher_DECRYPT_MODE: - nativeop = DECRYPT; - break; - } - - key = (*env)->GetByteArrayElements(env, keyArray, (jboolean*) 0); - if (key == (jbyte*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); - if (ex) - (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); - return; - } - - rc = ((const blockCipher*) ciph)->setup((blockCipherParam*) param, (const byte*) key, keysize << 3, nativeop); - - if (rc != 0) - { - jclass ex = (*env)->FindClass(env, JAVA_INVALID_KEY_EXCEPTION); - if (ex) - (*env)->ThrowNew(env, ex, MSG_INVALID_KEY); - } - - (*env)->ReleaseByteArrayElements(env, keyArray, key, JNI_ABORT); - } -} - -void JNICALL Java_beecrypt_crypto_NativeBlockCipher_setIV(JNIEnv* env, jclass dummy, jlong ciph, jlong param, jbyteArray ivArray) -{ - if (ivArray == (jbyteArray) 0) - { - ((const blockCipher*) ciph)->setiv((blockCipherParam*) param, 0); - } - else - { - jsize ivsize = (*env)->GetArrayLength(env, ivArray); - - if (ivsize > 0) - { - jbyte* iv = (*env)->GetByteArrayElements(env, ivArray, (jboolean*) 0); - - if (iv == (jbyte*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); - if (ex) - (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); - return; - } - - ((const blockCipher*) ciph)->setiv((blockCipherParam*) param, (byte*) iv); - - (*env)->ReleaseByteArrayElements(env, ivArray, iv, JNI_ABORT); - } - } -} - -void JNICALL Java_beecrypt_crypto_NativeBlockCipher_encryptECB(JNIEnv* env, jclass dummy, jlong ciph, jlong param, jbyteArray inputArray, jint inputOffset, jbyteArray outputArray, jint outputOffset, jint blocks) -{ - jbyte* input; - jbyte* output; - - input = (*env)->GetByteArrayElements(env, inputArray, (jboolean*) 0); - if (input == (jbyte*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); - if (ex) - (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); - return; - } - output = (*env)->GetByteArrayElements(env, outputArray, (jboolean*) 0); - if (input == (jbyte*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); - (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); - if (ex) - (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); - return; - } - - if (((long) (input+inputOffset) & 0x3) || ((long) (output+outputOffset) & 0x3)) - { /* unaligned */ - uint32_t* datain; - uint32_t* dataout; - - datain = (uint32_t*) malloc(blocks * sizeof(uint32_t)); - if (datain == (uint32_t*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); - (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); - (*env)->ReleaseByteArrayElements(env, outputArray, output, JNI_ABORT); - if (ex) - (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); - return; - } - dataout = (uint32_t*) malloc(blocks * sizeof(uint32_t)); - if (dataout == (uint32_t*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); - free(datain); - (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); - (*env)->ReleaseByteArrayElements(env, outputArray, output, JNI_ABORT); - if (ex) - (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); - return; - } - memcpy(datain, input+inputOffset, blocks * sizeof(uint32_t)); - blockEncryptECB((const blockCipher*) ciph, (blockCipherParam*) param, dataout, datain, blocks); - memcpy(output+outputOffset, dataout, blocks * sizeof(uint32_t)); - } - else - { /* aligned */ - blockEncryptECB((const blockCipher*) ciph, (blockCipherParam*) param, (uint32_t*)(output+outputOffset), (uint32_t*) (input+inputOffset), blocks); - } - - (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); - (*env)->ReleaseByteArrayElements(env, outputArray, output, 0); -} - -void JNICALL Java_beecrypt_crypto_NativeBlockCipher_decryptECB(JNIEnv* env, jclass dummy, jlong ciph, jlong param, jbyteArray inputArray, jint inputOffset, jbyteArray outputArray, jint outputOffset, jint blocks) -{ - jbyte* input; - jbyte* output; - - input = (*env)->GetByteArrayElements(env, inputArray, (jboolean*) 0); - if (input == (jbyte*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); - if (ex) - (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); - return; - } - output = (*env)->GetByteArrayElements(env, outputArray, (jboolean*) 0); - if (input == (jbyte*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); - (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); - if (ex) - (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); - return; - } - - if (((long) (input+inputOffset) & 0x3) || ((long) (output+outputOffset) & 0x3)) - { /* unaligned */ - uint32_t* datain; - uint32_t* dataout; - - datain = (uint32_t*) malloc(blocks * sizeof(uint32_t)); - if (datain == (uint32_t*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); - (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); - (*env)->ReleaseByteArrayElements(env, outputArray, output, JNI_ABORT); - if (ex) - (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); - return; - } - dataout = (uint32_t*) malloc(blocks * sizeof(uint32_t)); - if (dataout == (uint32_t*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); - free(datain); - (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); - (*env)->ReleaseByteArrayElements(env, outputArray, output, JNI_ABORT); - if (ex) - (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); - return; - } - memcpy(datain, input+inputOffset, blocks * sizeof(uint32_t)); - blockDecryptECB((const blockCipher*) ciph, (blockCipherParam*) param, dataout, datain, blocks); - memcpy(output+outputOffset, dataout, blocks * sizeof(uint32_t)); - } - else - { /* aligned */ - blockDecryptECB((const blockCipher*) ciph, (blockCipherParam*) param, (uint32_t*)(output+outputOffset), (uint32_t*) (input+inputOffset), blocks); - } - - (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); - (*env)->ReleaseByteArrayElements(env, outputArray, output, 0); -} - -void JNICALL Java_beecrypt_crypto_NativeBlockCipher_encryptCBC(JNIEnv* env, jclass dummy, jlong ciph, jlong param, jbyteArray inputArray, jint inputOffset, jbyteArray outputArray, jint outputOffset, jint blocks) -{ - jbyte* input; - jbyte* output; - - input = (*env)->GetByteArrayElements(env, inputArray, (jboolean*) 0); - if (input == (jbyte*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); - if (ex) - (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); - return; - } - output = (*env)->GetByteArrayElements(env, outputArray, (jboolean*) 0); - if (input == (jbyte*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); - (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); - if (ex) - (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); - return; - } - - if (((long) (input+inputOffset) & 0x3) || ((long) (output+outputOffset) & 0x3)) - { /* unaligned */ - uint32_t* datain; - uint32_t* dataout; - - datain = (uint32_t*) malloc(blocks * sizeof(uint32_t)); - if (datain == (uint32_t*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); - (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); - (*env)->ReleaseByteArrayElements(env, outputArray, output, JNI_ABORT); - if (ex) - (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); - return; - } - dataout = (uint32_t*) malloc(blocks * sizeof(uint32_t)); - if (dataout == (uint32_t*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); - free(datain); - (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); - (*env)->ReleaseByteArrayElements(env, outputArray, output, JNI_ABORT); - if (ex) - (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); - return; - } - memcpy(datain, input+inputOffset, blocks * sizeof(uint32_t)); - blockEncryptCBC((const blockCipher*) ciph, (blockCipherParam*) param, dataout, datain, blocks); - memcpy(output+outputOffset, dataout, blocks * sizeof(uint32_t)); - } - else - { /* aligned */ - blockEncryptCBC((const blockCipher*) ciph, (blockCipherParam*) param, (uint32_t*)(output+outputOffset), (uint32_t*) (input+inputOffset), blocks); - } - - (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); - (*env)->ReleaseByteArrayElements(env, outputArray, output, 0); -} - -void JNICALL Java_beecrypt_crypto_NativeBlockCipher_decryptCBC(JNIEnv* env, jclass dummy, jlong ciph, jlong param, jbyteArray inputArray, jint inputOffset, jbyteArray outputArray, jint outputOffset, jint blocks) -{ - jbyte* input; - jbyte* output; - - input = (*env)->GetByteArrayElements(env, inputArray, (jboolean*) 0); - if (input == (jbyte*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); - if (ex) - (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); - return; - } - output = (*env)->GetByteArrayElements(env, outputArray, (jboolean*) 0); - if (input == (jbyte*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); - (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); - if (ex) - (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); - return; - } - - if (((long) (input+inputOffset) & 0x3) || ((long) (output+outputOffset) & 0x3)) - { /* unaligned */ - uint32_t* datain; - uint32_t* dataout; - - datain = (uint32_t*) malloc(blocks * sizeof(uint32_t)); - if (datain == (uint32_t*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); - (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); - (*env)->ReleaseByteArrayElements(env, outputArray, output, JNI_ABORT); - if (ex) - (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); - return; - } - dataout = (uint32_t*) malloc(blocks * sizeof(uint32_t)); - if (dataout == (uint32_t*) 0) - { - jclass ex = (*env)->FindClass(env, JAVA_OUT_OF_MEMORY_ERROR); - free(datain); - (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); - (*env)->ReleaseByteArrayElements(env, outputArray, output, JNI_ABORT); - if (ex) - (*env)->ThrowNew(env, ex, MSG_OUT_OF_MEMORY); - return; - } - memcpy(datain, input+inputOffset, blocks * sizeof(uint32_t)); - blockDecryptCBC((const blockCipher*) ciph, (blockCipherParam*) param, dataout, datain, blocks); - memcpy(output+outputOffset, dataout, blocks * sizeof(uint32_t)); - } - else - { /* aligned */ - blockDecryptCBC((const blockCipher*) ciph, (blockCipherParam*) param, (uint32_t*)(output+outputOffset), (uint32_t*) (input+inputOffset), blocks); - } - - (*env)->ReleaseByteArrayElements(env, inputArray, input, JNI_ABORT); - (*env)->ReleaseByteArrayElements(env, outputArray, output, 0); -} - -#endif diff --git a/beecrypt/java/javaglue.h b/beecrypt/java/javaglue.h deleted file mode 100644 index d81edbd5b..000000000 --- a/beecrypt/java/javaglue.h +++ /dev/null @@ -1,290 +0,0 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include <jni.h> -/* Header for class javax_crypto_Cipher */ - -#ifndef _Included_javax_crypto_Cipher -#define _Included_javax_crypto_Cipher -#ifdef __cplusplus -extern "C" { -#endif -#undef javax_crypto_Cipher_UNINITIALIZED -#define javax_crypto_Cipher_UNINITIALIZED 0L -#undef javax_crypto_Cipher_ENCRYPT_MODE -#define javax_crypto_Cipher_ENCRYPT_MODE 1L -#undef javax_crypto_Cipher_DECRYPT_MODE -#define javax_crypto_Cipher_DECRYPT_MODE 2L -#undef javax_crypto_Cipher_WRAP_MODE -#define javax_crypto_Cipher_WRAP_MODE 3L -#undef javax_crypto_Cipher_UNWRAP_MODE -#define javax_crypto_Cipher_UNWRAP_MODE 4L -#undef javax_crypto_Cipher_PUBLIC_KEY -#define javax_crypto_Cipher_PUBLIC_KEY 1L -#undef javax_crypto_Cipher_PRIVATE_KEY -#define javax_crypto_Cipher_PRIVATE_KEY 2L -#undef javax_crypto_Cipher_SECRET_KEY -#define javax_crypto_Cipher_SECRET_KEY 3L -#ifdef __cplusplus -} -#endif -#endif -/* Header for class beecrypt_security_NativeMessageDigest */ - -#ifndef _Included_beecrypt_security_NativeMessageDigest -#define _Included_beecrypt_security_NativeMessageDigest -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: beecrypt_security_NativeMessageDigest - * Method: find - * Signature: (Ljava/lang/String;)J - */ -JNIEXPORT jlong JNICALL Java_beecrypt_security_NativeMessageDigest_find - (JNIEnv *, jclass, jstring); - -/* - * Class: beecrypt_security_NativeMessageDigest - * Method: allocParam - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL Java_beecrypt_security_NativeMessageDigest_allocParam - (JNIEnv *, jclass, jlong); - -/* - * Class: beecrypt_security_NativeMessageDigest - * Method: cloneParam - * Signature: (JJ)J - */ -JNIEXPORT jlong JNICALL Java_beecrypt_security_NativeMessageDigest_cloneParam - (JNIEnv *, jclass, jlong, jlong); - -/* - * Class: beecrypt_security_NativeMessageDigest - * Method: freeParam - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_beecrypt_security_NativeMessageDigest_freeParam - (JNIEnv *, jclass, jlong); - -/* - * Class: beecrypt_security_NativeMessageDigest - * Method: reset - * Signature: (JJ)V - */ -JNIEXPORT void JNICALL Java_beecrypt_security_NativeMessageDigest_reset - (JNIEnv *, jclass, jlong, jlong); - -/* - * Class: beecrypt_security_NativeMessageDigest - * Method: update - * Signature: (JJB)V - */ -JNIEXPORT void JNICALL Java_beecrypt_security_NativeMessageDigest_update - (JNIEnv *, jclass, jlong, jlong, jbyte); - -/* - * Class: beecrypt_security_NativeMessageDigest - * Method: updateBlock - * Signature: (JJ[BII)V - */ -JNIEXPORT void JNICALL Java_beecrypt_security_NativeMessageDigest_updateBlock - (JNIEnv *, jclass, jlong, jlong, jbyteArray, jint, jint); - -/* - * Class: beecrypt_security_NativeMessageDigest - * Method: digest - * Signature: (JJ)[B - */ -JNIEXPORT jbyteArray JNICALL Java_beecrypt_security_NativeMessageDigest_digest - (JNIEnv *, jclass, jlong, jlong); - -/* - * Class: beecrypt_security_NativeMessageDigest - * Method: digestLength - * Signature: (J)I - */ -JNIEXPORT jint JNICALL Java_beecrypt_security_NativeMessageDigest_digestLength - (JNIEnv *, jclass, jlong); - -#ifdef __cplusplus -} -#endif -#endif -/* Header for class beecrypt_security_NativeSecureRandom */ - -#ifndef _Included_beecrypt_security_NativeSecureRandom -#define _Included_beecrypt_security_NativeSecureRandom -#ifdef __cplusplus -extern "C" { -#endif -/* - * Class: beecrypt_security_NativeSecureRandom - * Method: find - * Signature: (Ljava/lang/String;)J - */ -JNIEXPORT jlong JNICALL Java_beecrypt_security_NativeSecureRandom_find - (JNIEnv *, jclass, jstring); - -/* - * Class: beecrypt_security_NativeSecureRandom - * Method: allocParam - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL Java_beecrypt_security_NativeSecureRandom_allocParam - (JNIEnv *, jclass, jlong); - -/* - * Class: beecrypt_security_NativeSecureRandom - * Method: cloneParam - * Signature: (JJ)J - */ -JNIEXPORT jlong JNICALL Java_beecrypt_security_NativeSecureRandom_cloneParam - (JNIEnv *, jclass, jlong, jlong); - -/* - * Class: beecrypt_security_NativeSecureRandom - * Method: freeParam - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_beecrypt_security_NativeSecureRandom_freeParam - (JNIEnv *, jclass, jlong); - -/* - * Class: beecrypt_security_NativeSecureRandom - * Method: setup - * Signature: (JJ)V - */ -JNIEXPORT void JNICALL Java_beecrypt_security_NativeSecureRandom_setup - (JNIEnv *, jclass, jlong, jlong); - -/* - * Class: beecrypt_security_NativeSecureRandom - * Method: setSeed - * Signature: (JJ[B)V - */ -JNIEXPORT void JNICALL Java_beecrypt_security_NativeSecureRandom_setSeed - (JNIEnv *, jclass, jlong, jlong, jbyteArray); - -/* - * Class: beecrypt_security_NativeSecureRandom - * Method: nextBytes - * Signature: (JJ[B)V - */ -JNIEXPORT void JNICALL Java_beecrypt_security_NativeSecureRandom_nextBytes - (JNIEnv *, jclass, jlong, jlong, jbyteArray); - -/* - * Class: beecrypt_security_NativeSecureRandom - * Method: generateSeed - * Signature: ([B)V - */ -JNIEXPORT void JNICALL Java_beecrypt_security_NativeSecureRandom_generateSeed - (JNIEnv *, jclass, jbyteArray); - -#ifdef __cplusplus -} -#endif -#endif -/* Header for class beecrypt_crypto_NativeBlockCipher */ - -#ifndef _Included_beecrypt_crypto_NativeBlockCipher -#define _Included_beecrypt_crypto_NativeBlockCipher -#ifdef __cplusplus -extern "C" { -#endif -#undef beecrypt_crypto_NativeBlockCipher_MODE_ECB -#define beecrypt_crypto_NativeBlockCipher_MODE_ECB 0L -#undef beecrypt_crypto_NativeBlockCipher_MODE_CBC -#define beecrypt_crypto_NativeBlockCipher_MODE_CBC 1L -/* Inaccessible static: MODES */ -#undef beecrypt_crypto_NativeBlockCipher_PADDING_NOPADDING -#define beecrypt_crypto_NativeBlockCipher_PADDING_NOPADDING 0L -#undef beecrypt_crypto_NativeBlockCipher_PADDING_PKCS5 -#define beecrypt_crypto_NativeBlockCipher_PADDING_PKCS5 1L -/* Inaccessible static: PADDINGS */ -/* Inaccessible static: class_00024javax_00024crypto_00024spec_00024PBEParameterSpec */ -/* Inaccessible static: class_00024javax_00024crypto_00024spec_00024IvParameterSpec */ -/* - * Class: beecrypt_crypto_NativeBlockCipher - * Method: find - * Signature: (Ljava/lang/String;)J - */ -JNIEXPORT jlong JNICALL Java_beecrypt_crypto_NativeBlockCipher_find - (JNIEnv *, jclass, jstring); - -/* - * Class: beecrypt_crypto_NativeBlockCipher - * Method: allocParam - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL Java_beecrypt_crypto_NativeBlockCipher_allocParam - (JNIEnv *, jclass, jlong); - -/* - * Class: beecrypt_crypto_NativeBlockCipher - * Method: freeParam - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_beecrypt_crypto_NativeBlockCipher_freeParam - (JNIEnv *, jclass, jlong); - -/* - * Class: beecrypt_crypto_NativeBlockCipher - * Method: getBlockSize - * Signature: (J)I - */ -JNIEXPORT jint JNICALL Java_beecrypt_crypto_NativeBlockCipher_getBlockSize - (JNIEnv *, jclass, jlong); - -/* - * Class: beecrypt_crypto_NativeBlockCipher - * Method: setup - * Signature: (JJI[B)V - */ -JNIEXPORT void JNICALL Java_beecrypt_crypto_NativeBlockCipher_setup - (JNIEnv *, jclass, jlong, jlong, jint, jbyteArray); - -/* - * Class: beecrypt_crypto_NativeBlockCipher - * Method: setIV - * Signature: (JJ[B)V - */ -JNIEXPORT void JNICALL Java_beecrypt_crypto_NativeBlockCipher_setIV - (JNIEnv *, jclass, jlong, jlong, jbyteArray); - -/* - * Class: beecrypt_crypto_NativeBlockCipher - * Method: encryptECB - * Signature: (JJ[BI[BII)V - */ -JNIEXPORT void JNICALL Java_beecrypt_crypto_NativeBlockCipher_encryptECB - (JNIEnv *, jclass, jlong, jlong, jbyteArray, jint, jbyteArray, jint, jint); - -/* - * Class: beecrypt_crypto_NativeBlockCipher - * Method: decryptECB - * Signature: (JJ[BI[BII)V - */ -JNIEXPORT void JNICALL Java_beecrypt_crypto_NativeBlockCipher_decryptECB - (JNIEnv *, jclass, jlong, jlong, jbyteArray, jint, jbyteArray, jint, jint); - -/* - * Class: beecrypt_crypto_NativeBlockCipher - * Method: encryptCBC - * Signature: (JJ[BI[BII)V - */ -JNIEXPORT void JNICALL Java_beecrypt_crypto_NativeBlockCipher_encryptCBC - (JNIEnv *, jclass, jlong, jlong, jbyteArray, jint, jbyteArray, jint, jint); - -/* - * Class: beecrypt_crypto_NativeBlockCipher - * Method: decryptCBC - * Signature: (JJ[BI[BII)V - */ -JNIEXPORT void JNICALL Java_beecrypt_crypto_NativeBlockCipher_decryptCBC - (JNIEnv *, jclass, jlong, jlong, jbyteArray, jint, jbyteArray, jint, jint); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/beecrypt/masm/.cvsignore b/beecrypt/masm/.cvsignore deleted file mode 100644 index 540cfea1a..000000000 --- a/beecrypt/masm/.cvsignore +++ /dev/null @@ -1,19 +0,0 @@ -.deps -.depend -.depend-done -.libs -Makefile -Makefile.in -config.cache -config.guess -config.log -config.status -config.sub -configure -libtool -ltconfig -ltmain.sh -*.o -*.lo -stamp-h -stamp-h.in diff --git a/beecrypt/masm/Makefile.am b/beecrypt/masm/Makefile.am deleted file mode 100644 index dc865e923..000000000 --- a/beecrypt/masm/Makefile.am +++ /dev/null @@ -1,25 +0,0 @@ -# -# Makefile.am's purpose is to add the Microsoft assembler files to the dist -# -# Copyright (c) 2001, 2002 Virtual Unlimited B.V. -# -# Author: Bob Deblier <bob.deblier@pandora.be> -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# - -AUTOMAKE_OPTIONS = gnu no-dependencies - -EXTRA_DIST = aesopt.i586.asm blowfishopt.i586.asm mpopt.x86.asm sha1opt.i586.asm diff --git a/beecrypt/masm/aesopt.i586.asm b/beecrypt/masm/aesopt.i586.asm deleted file mode 100644 index 35527e4e0..000000000 --- a/beecrypt/masm/aesopt.i586.asm +++ /dev/null @@ -1,661 +0,0 @@ -; -; aesopt.i586.asm -; -; Assembler optimized AES routines for Intel Pentium processors -; -; Compile target is Microsoft Macro Assembler -; -; Copyright (c) 2002 Bob Deblier <bob.deblier@pandora.be> -; -; This library is free software; you can redistribute it and/or -; modify it under the terms of the GNU Lesser General Public -; License as published by the Free Software Foundation; either -; version 2.1 of the License, or (at your option) any later version. -; -; This library is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -; Lesser General Public License for more details. -; -; You should have received a copy of the GNU Lesser General Public -; License along with this library; if not, write to the Free Software -; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -; - - .586 - .model flat,C - -EXTRN _ae0:DWORD -EXTRN _ae1:DWORD -EXTRN _ae2:DWORD -EXTRN _ae3:DWORD -EXTRN _ae4:DWORD - -EXTRN _ad0:DWORD -EXTRN _ad1:DWORD -EXTRN _ad2:DWORD -EXTRN _ad3:DWORD -EXTRN _ad4:DWORD - - .code - -; esp points to s and t (on stack; 32 bytes altogether) -; ebp points to rk -; edi points to dst -; esi points to src - -sxrk macro - ; compute swap(src) xor rk - mov eax,dword ptr [esi ] - mov ebx,dword ptr [esi+ 4] - mov ecx,dword ptr [esi+ 8] - mov edx,dword ptr [esi+12] - bswap eax - bswap ebx - bswap ecx - bswap edx - xor eax,dword ptr [ebp ] - xor ebx,dword ptr [ebp+ 4] - xor ecx,dword ptr [ebp+ 8] - xor edx,dword ptr [ebp+12] - mov dword ptr [esp ],eax - mov dword ptr [esp+ 4],ebx - mov dword ptr [esp+ 8],ecx - mov dword ptr [esp+12],edx - endm - -etfs macro offset - ; compute t0 and t1 - mov ecx,[ebp+offset ] - mov edx,[ebp+offset+4] - - movzx eax,byte ptr [esp+ 3] - movzx ebx,byte ptr [esp+ 7] - xor ecx,dword ptr [eax*4+_ae0] - xor edx,dword ptr [ebx*4+_ae0] - - movzx eax,byte ptr [esp+ 6] - movzx ebx,byte ptr [esp+10] - xor ecx,dword ptr [eax*4+_ae1] - xor edx,dword ptr [ebx*4+_ae1] - - movzx eax,byte ptr [esp+ 9] - movzx ebx,byte ptr [esp+13] - xor ecx,dword ptr [eax*4+_ae2] - xor edx,dword ptr [ebx*4+_ae2] - - movzx eax,byte ptr [esp+12] - movzx ebx,byte ptr [esp ] - xor ecx,dword ptr [eax*4+_ae3] - xor edx,dword ptr [ebx*4+_ae3] - - mov dword ptr [esp+16],ecx - mov dword ptr [esp+20],edx - - ; compute t2 and t3 - mov ecx,dword ptr [ebp+offset+ 8] - mov edx,dword ptr [ebp+offset+12] - - movzx eax,byte ptr [esp+11] - movzx ebx,byte ptr [esp+15] - xor ecx,dword ptr [eax*4+_ae0] - xor edx,dword ptr [ebx*4+_ae0] - - movzx eax,byte ptr [esp+14] - movzx ebx,byte ptr [esp+ 2] - xor ecx,dword ptr [eax*4+_ae1] - xor edx,dword ptr [ebx*4+_ae1] - - movzx eax,byte ptr [esp+ 1] - movzx ebx,byte ptr [esp+ 5] - xor ecx,dword ptr [eax*4+_ae2] - xor edx,dword ptr [ebx*4+_ae2] - - movzx eax,byte ptr [esp+ 4] - movzx ebx,byte ptr [esp+ 8] - xor ecx,dword ptr [eax*4+_ae3] - xor edx,dword ptr [ebx*4+_ae3] - - mov dword ptr [esp+24],ecx - mov dword ptr [esp+28],edx - endm - -esft macro offset - ; compute s0 and s1 - mov ecx,[ebp+offset ] - mov edx,[ebp+offset+4] - - movzx eax,byte ptr [esp+19] - movzx ebx,byte ptr [esp+23] - xor ecx,dword ptr [eax*4+_ae0] - xor edx,dword ptr [ebx*4+_ae0] - - movzx eax,byte ptr [esp+22] - movzx ebx,byte ptr [esp+26] - xor ecx,dword ptr [eax*4+_ae1] - xor edx,dword ptr [ebx*4+_ae1] - - movzx eax,byte ptr [esp+25] - movzx ebx,byte ptr [esp+29] - xor ecx,dword ptr [eax*4+_ae2] - xor edx,dword ptr [ebx*4+_ae2] - - movzx eax,byte ptr [esp+28] - movzx ebx,byte ptr [esp+16] - xor ecx,dword ptr [eax*4+_ae3] - xor edx,dword ptr [ebx*4+_ae3] - - mov dword ptr [esp ],ecx - mov dword ptr [esp+ 4],edx - - ; compute s2 and s3 - mov ecx,dword ptr [ebp+offset+ 8] - mov edx,dword ptr [ebp+offset+12] - - movzx eax,byte ptr [esp+27] - movzx ebx,byte ptr [esp+31] - xor ecx,dword ptr [eax*4+_ae0] - xor edx,dword ptr [ebx*4+_ae0] - - movzx eax,byte ptr [esp+30] - movzx ebx,byte ptr [esp+18] - xor ecx,dword ptr [eax*4+_ae1] - xor edx,dword ptr [ebx*4+_ae1] - - movzx eax,byte ptr [esp+17] - movzx ebx,byte ptr [esp+21] - xor ecx,dword ptr [eax*4+_ae2] - xor edx,dword ptr [ebx*4+_ae2] - - movzx eax,byte ptr [esp+20] - movzx ebx,byte ptr [esp+24] - xor ecx,dword ptr [eax*4+_ae3] - xor edx,dword ptr [ebx*4+_ae3] - - mov dword ptr [esp+ 8],ecx - mov dword ptr [esp+12],edx - endm - -elr macro - mov ecx,dword ptr [ebp+ 0] - mov edx,dword ptr [ebp+ 4] - - movzx eax,byte ptr [esp+19] - movzx ebx,byte ptr [esp+23] - mov eax,dword ptr [eax*4+_ae4] - mov ebx,dword ptr [ebx*4+_ae4] - and eax,0ff000000h - and ebx,0ff000000h - xor ecx,eax - xor edx,ebx - - movzx eax,byte ptr [esp+22] - movzx ebx,byte ptr [esp+26] - mov eax,dword ptr [eax*4+_ae4] - mov ebx,dword ptr [ebx*4+_ae4] - and eax,0ff0000h - and ebx,0ff0000h - xor ecx,eax - xor edx,ebx - - movzx eax,byte ptr [esp+25] - movzx ebx,byte ptr [esp+29] - mov eax,dword ptr [eax*4+_ae4] - mov ebx,dword ptr [ebx*4+_ae4] - and eax,0ff00h - and ebx,0ff00h - xor ecx,eax - xor edx,ebx - - movzx eax,byte ptr [esp+28] - movzx ebx,byte ptr [esp+16] - mov eax,dword ptr [eax*4+_ae4] - mov ebx,dword ptr [ebx*4+_ae4] - and eax,0ffh - and ebx,0ffh - xor ecx,eax - xor edx,ebx - - mov dword ptr [esp+ 0],ecx - mov dword ptr [esp+ 4],edx - - mov ecx,dword ptr [ebp+ 8] - mov edx,dword ptr [ebp+12] - - movzx eax,byte ptr [esp+27] - movzx ebx,byte ptr [esp+31] - mov eax,dword ptr [eax*4+_ae4] - mov ebx,dword ptr [ebx*4+_ae4] - and eax,0ff000000h - and ebx,0ff000000h - xor ecx,eax - xor edx,ebx - - movzx eax,byte ptr [esp+30] - movzx ebx,byte ptr [esp+18] - mov eax,dword ptr [eax*4+_ae4] - mov ebx,dword ptr [ebx*4+_ae4] - and eax,0ff0000h - and ebx,0ff0000h - xor ecx,eax - xor edx,ebx - - movzx eax,byte ptr [esp+17] - movzx ebx,byte ptr [esp+21] - mov eax,dword ptr [eax*4+_ae4] - mov ebx,dword ptr [ebx*4+_ae4] - and eax,0ff00h - and ebx,0ff00h - xor ecx,eax - xor edx,ebx - - movzx eax,byte ptr [esp+20] - movzx ebx,byte ptr [esp+24] - mov eax,dword ptr [eax*4+_ae4] - mov ebx,dword ptr [ebx*4+_ae4] - and eax,0ffh - and ebx,0ffh - xor ecx,eax - xor edx,ebx - - mov dword ptr [esp+ 8],ecx - mov dword ptr [esp+12],edx - endm - -eblock macro label - ; load initial values for s0 thru s3 - sxrk - - ; do 9 rounds - etfs 16 - esft 32 - etfs 48 - esft 64 - etfs 80 - esft 96 - etfs 112 - esft 128 - etfs 144 - ; test if we had to do 10 rounds, if yes jump to last round - mov eax,dword ptr [ebp+256] - cmp eax,10 - je @label - ; do two more rounds - esft 160 - etfs 176 - ; test if we had to do 12 rounds, if yes jump to last round - mov eax,dword ptr [ebp+256] - cmp eax,12 - je @label - ; do two more rounds - esft 192 - etfs 208 - ; prepare for last round - mov eax,dword ptr [ebp+256] -@label: - ; add 16 times the number of rounds to ebp - sal eax,4 - add ebp,eax - ; do last round - elr - endm - -eblockc macro label - ; encrypt block in cbc mode - sxrfxrk - - ; do 9 rounds - etfs 16 - esft 32 - etfs 48 - esft 64 - etfs 80 - esft 96 - etfs 112 - esft 128 - etfs 144 - ; test if we had to do 10 rounds, if yes jump to last round - mov eax,dword ptr [ebp+256] - cmp eax,10 - je @label - ; do two more rounds - esft 160 - etfs 176 - ; test if we had to do 12 rounds, if yes jump to last round - mov eax,dword ptr [ebp+256] - cmp eax,12 - je @label - ; do two more rounds - esft 192 - etfs 208 - ; prepare for last round - mov eax,dword ptr [ebp+256] -@label: - ; add 16 times the number of rounds to ebp - sal eax,4 - add ebp,eax - ; do last round - elr - endm - -dtfs macro offset - ; compute t0 and t1 - mov ecx,[ebp+offset ] - mov edx,[ebp+offset+4] - - movzx eax,byte ptr [esp+ 3] - movzx ebx,byte ptr [esp+ 7] - xor ecx,dword ptr [eax*4+_ad0] - xor edx,dword ptr [ebx*4+_ad0] - - movzx eax,byte ptr [esp+14] - movzx ebx,byte ptr [esp+ 2] - xor ecx,dword ptr [eax*4+_ad1] - xor edx,dword ptr [ebx*4+_ad1] - - movzx eax,byte ptr [esp+ 9] - movzx ebx,byte ptr [esp+13] - xor ecx,dword ptr [eax*4+_ad2] - xor edx,dword ptr [ebx*4+_ad2] - - movzx eax,byte ptr [esp+ 4] - movzx ebx,byte ptr [esp+ 8] - xor ecx,dword ptr [eax*4+_ad3] - xor edx,dword ptr [ebx*4+_ad3] - - mov dword ptr [esp+16],ecx - mov dword ptr [esp+20],edx - - ; compute t2 and t3 - mov ecx,dword ptr [ebp+offset+ 8] - mov edx,dword ptr [ebp+offset+12] - - movzx eax,byte ptr [esp+11] - movzx ebx,byte ptr [esp+15] - xor ecx,dword ptr [eax*4+_ad0] - xor edx,dword ptr [ebx*4+_ad0] - - movzx eax,byte ptr [esp+ 6] - movzx ebx,byte ptr [esp+10] - xor ecx,dword ptr [eax*4+_ad1] - xor edx,dword ptr [ebx*4+_ad1] - - movzx eax,byte ptr [esp+ 1] - movzx ebx,byte ptr [esp+ 5] - xor ecx,dword ptr [eax*4+_ad2] - xor edx,dword ptr [ebx*4+_ad2] - - movzx eax,byte ptr [esp+12] - movzx ebx,byte ptr [esp ] - xor ecx,dword ptr [eax*4+_ad3] - xor edx,dword ptr [ebx*4+_ad3] - - mov dword ptr [esp+24],ecx - mov dword ptr [esp+28],edx - endm - -dsft macro offset - ; compute s0 and s1 - mov ecx,[ebp+offset ] - mov edx,[ebp+offset+4] - - movzx eax,byte ptr [esp+19] - movzx ebx,byte ptr [esp+23] - xor ecx,dword ptr [eax*4+_ad0] - xor edx,dword ptr [ebx*4+_ad0] - - movzx eax,byte ptr [esp+30] - movzx ebx,byte ptr [esp+18] - xor ecx,dword ptr [eax*4+_ad1] - xor edx,dword ptr [ebx*4+_ad1] - - movzx eax,byte ptr [esp+25] - movzx ebx,byte ptr [esp+29] - xor ecx,dword ptr [eax*4+_ad2] - xor edx,dword ptr [ebx*4+_ad2] - - movzx eax,byte ptr [esp+20] - movzx ebx,byte ptr [esp+24] - xor ecx,dword ptr [eax*4+_ad3] - xor edx,dword ptr [ebx*4+_ad3] - - mov dword ptr [esp ],ecx - mov dword ptr [esp+ 4],edx - - ; compute s2 and s3 - mov ecx,dword ptr [ebp+offset+ 8] - mov edx,dword ptr [ebp+offset+12] - - movzx eax,byte ptr [esp+27] - movzx ebx,byte ptr [esp+31] - xor ecx,dword ptr [eax*4+_ad0] - xor edx,dword ptr [ebx*4+_ad0] - - movzx eax,byte ptr [esp+22] - movzx ebx,byte ptr [esp+26] - xor ecx,dword ptr [eax*4+_ad1] - xor edx,dword ptr [ebx*4+_ad1] - - movzx eax,byte ptr [esp+17] - movzx ebx,byte ptr [esp+21] - xor ecx,dword ptr [eax*4+_ad2] - xor edx,dword ptr [ebx*4+_ad2] - - movzx eax,byte ptr [esp+28] - movzx ebx,byte ptr [esp+16] - xor ecx,dword ptr [eax*4+_ad3] - xor edx,dword ptr [ebx*4+_ad3] - - mov dword ptr [esp+ 8],ecx - mov dword ptr [esp+12],edx - endm - -dlr macro - mov ecx,dword ptr [ebp+ 0] - mov edx,dword ptr [ebp+ 4] - - movzx eax,byte ptr [esp+19] - movzx ebx,byte ptr [esp+23] - mov eax,dword ptr [eax*4+_ad4] - mov ebx,dword ptr [ebx*4+_ad4] - and eax,0ff000000h - and ebx,0ff000000h - xor ecx,eax - xor edx,ebx - - movzx eax,byte ptr [esp+30] - movzx ebx,byte ptr [esp+18] - mov eax,dword ptr [eax*4+_ad4] - mov ebx,dword ptr [ebx*4+_ad4] - and eax,0ff0000h - and ebx,0ff0000h - xor ecx,eax - xor edx,ebx - - movzx eax,byte ptr [esp+25] - movzx ebx,byte ptr [esp+29] - mov eax,dword ptr [eax*4+_ad4] - mov ebx,dword ptr [ebx*4+_ad4] - and eax,0ff00h - and ebx,0ff00h - xor ecx,eax - xor edx,ebx - - movzx eax,byte ptr [esp+20] - movzx ebx,byte ptr [esp+24] - mov eax,dword ptr [eax*4+_ad4] - mov ebx,dword ptr [ebx*4+_ad4] - and eax,0ffh - and ebx,0ffh - xor ecx,eax - xor edx,ebx - - mov dword ptr [esp+ 0],ecx - mov dword ptr [esp+ 4],edx - - mov ecx,dword ptr [ebp+ 8] - mov edx,dword ptr [ebp+12] - - movzx eax,byte ptr [esp+27] - movzx ebx,byte ptr [esp+31] - mov eax,dword ptr [eax*4+_ad4] - mov ebx,dword ptr [ebx*4+_ad4] - and eax,0ff000000h - and ebx,0ff000000h - xor ecx,eax - xor edx,ebx - - movzx eax,byte ptr [esp+22] - movzx ebx,byte ptr [esp+26] - mov eax,dword ptr [eax*4+_ad4] - mov ebx,dword ptr [ebx*4+_ad4] - and eax,0ff0000h - and ebx,0ff0000h - xor ecx,eax - xor edx,ebx - - movzx eax,byte ptr [esp+17] - movzx ebx,byte ptr [esp+21] - mov eax,dword ptr [eax*4+_ad4] - mov ebx,dword ptr [ebx*4+_ad4] - and eax,0ff00h - and ebx,0ff00h - xor ecx,eax - xor edx,ebx - - movzx eax,byte ptr [esp+28] - movzx ebx,byte ptr [esp+16] - mov eax,dword ptr [eax*4+_ad4] - mov ebx,dword ptr [ebx*4+_ad4] - and eax,0ffh - and ebx,0ffh - xor ecx,eax - xor edx,ebx - - mov dword ptr [esp+ 8],ecx - mov dword ptr [esp+12],edx - endm - -dblock macro label - ; load initial values for s0 thru s3 - sxrk - - ; do 9 rounds - dtfs 16 - dsft 32 - dtfs 48 - dsft 64 - dtfs 80 - dsft 96 - dtfs 112 - dsft 128 - dtfs 144 - ; test if we had to do 10 rounds, if yes jump to last round - mov eax,dword ptr [ebp+256] - cmp eax,10 - je @label - ; do two more rounds - dsft 160 - dtfs 176 - ; test if we had to do 12 rounds, if yes jump to last round - mov eax,dword ptr [ebp+256] - cmp eax,12 - je @label - ; do two more rounds - dsft 192 - dtfs 208 - ; prepare for last round - mov eax,dword ptr [ebp+256] -@label: - ; add 16 times the number of rounds to ebp - sal eax,4 - add ebp,eax - ; do last round - dlr - endm - -aesEncrypt proc c export - push edi - push esi - push ebp - push ebx - - ; set pointers - mov ebp,dword ptr [esp+20] ; rk - mov edi,dword ptr [esp+24] ; dst - mov esi,dword ptr [esp+28] ; src - - ; add local storage for s and t variables, 32 bytes total - sub esp,32 - - eblock e - - ; save stuff back - mov eax,dword ptr [esp+ 0] - mov ebx,dword ptr [esp+ 4] - mov ecx,dword ptr [esp+ 8] - mov edx,dword ptr [esp+12] - bswap eax - bswap ebx - bswap ecx - bswap edx - mov dword ptr [edi ],eax - mov dword ptr [edi+ 4],ebx - mov dword ptr [edi+ 8],ecx - mov dword ptr [edi+12],edx - - ; remove local storage - add esp,32 - - xor eax,eax - - pop ebx - pop ebp - pop esi - pop edi - ret -aesEncrypt endp - -aesDecrypt proc c export - push edi - push esi - push ebp - push ebx - - ; set pointers - mov ebp,dword ptr [esp+20] ; rk - mov edi,dword ptr [esp+24] ; dst - mov esi,dword ptr [esp+28] ; src - - ; add local storage for s and t variables, 32 bytes total - sub esp,32 - - dblock d - - ; save stuff back - mov eax,dword ptr [esp+ 0] - mov ebx,dword ptr [esp+ 4] - mov ecx,dword ptr [esp+ 8] - mov edx,dword ptr [esp+12] - bswap eax - bswap ebx - bswap ecx - bswap edx - mov dword ptr [edi ],eax - mov dword ptr [edi+ 4],ebx - mov dword ptr [edi+ 8],ecx - mov dword ptr [edi+12],edx - - ; remove local storage - add esp,32 - - xor eax,eax - - pop ebx - pop ebp - pop esi - pop edi - ret -aesDecrypt endp - - end diff --git a/beecrypt/masm/blowfishopt.i586.asm b/beecrypt/masm/blowfishopt.i586.asm deleted file mode 100644 index 30658b430..000000000 --- a/beecrypt/masm/blowfishopt.i586.asm +++ /dev/null @@ -1,180 +0,0 @@ -; -; blowfishopt.i586.asm -; -; Assembler optimized blowfish routines for Intel Pentium processors -; -; Compile target is Microsoft Macro Assembler -; -; Copyright (c) 2000 Virtual Unlimited B.V. -; -; Author: Bob Deblier <bob.deblier@pandora.be> -; -; This library is free software; you can redistribute it and/or -; modify it under the terms of the GNU Lesser General Public -; License as published by the Free Software Foundation; either -; version 2.1 of the License, or (at your option) any later version. -; -; This library is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -; Lesser General Public License for more details. -; -; You should have received a copy of the GNU Lesser General Public -; License along with this library; if not, write to the Free Software -; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -; - - .586 - .model flat,C - - .code - -etworounds macro offset - xor ecx,dword ptr [esi+offset] - rol ecx,16 - mov al,ch - mov bl,cl - rol ecx,16 - mov edi,dword ptr [esi+eax*4+72+0000h] - add edi,dword ptr [esi+ebx*4+72+0400h] - mov al,ch - mov bl,cl - xor edi,dword ptr [esi+eax*4+72+0800h] - add edi,dword ptr [esi+ebx*4+72+0C00h] - xor edx,edi - xor edx,dword ptr [esi+offset+4] - rol edx,16 - mov al,dh - mov bl,dl - rol edx,16 - mov edi,dword ptr [esi+eax*4+72+0000h] - add edi,dword ptr [esi+ebx*4+72+0400h] - mov al,dh - mov bl,dl - xor edi,dword ptr [esi+eax*4+72+0800h] - add edi,dword ptr [esi+ebx*4+72+0C00h] - xor ecx,edi - endm - -dtworounds macro offset - xor ecx,dword ptr [esi+offset+4] - rol ecx,16 - mov al,ch - mov bl,cl - rol ecx,16 - mov edi,dword ptr [esi+eax*4+72+0000h] - add edi,dword ptr [esi+ebx*4+72+0400h] - mov al,ch - mov bl,cl - xor edi,dword ptr [esi+eax*4+72+0800h] - add edi,dword ptr [esi+ebx*4+72+0C00h] - xor edx,edi - xor edx,dword ptr [esi+offset] - rol edx,16 - mov al,dh - mov bl,dl - rol edx,16 - mov edi,dword ptr [esi+eax*4+72+0000h] - add edi,dword ptr [esi+ebx*4+72+0400h] - mov al,dh - mov bl,dl - xor edi,dword ptr [esi+eax*4+72+0800h] - add edi,dword ptr [esi+ebx*4+72+0C00h] - xor ecx,edi - endm - - - align 8 - -blowfishEncrypt proc c export - push edi - push esi - push ebx - - mov esi,dword ptr [esp+16] - mov edi,dword ptr [esp+24] - - xor eax,eax - xor ebx,ebx - - mov ecx,dword ptr [edi] - mov edx,dword ptr [edi+4] - - bswap ecx - bswap edx - - etworounds 0 - etworounds 8 - etworounds 16 - etworounds 24 - etworounds 32 - etworounds 40 - etworounds 48 - etworounds 56 - - mov edi,dword ptr [esp+20] - xor ecx,dword ptr [esi+64] - xor edx,dword ptr [esi+68] - - bswap ecx - bswap edx - - mov dword ptr [edi+4],ecx - mov dword ptr [edi],edx - - xor eax,eax - - pop ebx - pop esi - pop edi - ret -blowfishEncrypt endp - - - align 8 - -blowfishDecrypt proc c export - push edi - push esi - push ebx - - mov esi,dword ptr [esp+16] - mov edi,dword ptr [esp+24] - - xor eax,eax - xor ebx,ebx - - mov ecx,dword ptr [edi] - mov edx,dword ptr [edi+4] - - bswap ecx - bswap edx - - dtworounds 64 - dtworounds 56 - dtworounds 48 - dtworounds 40 - dtworounds 32 - dtworounds 24 - dtworounds 16 - dtworounds 8 - - mov edi,dword ptr [esp+20] - xor ecx,dword ptr [esi+4] - xor edx,dword ptr [esi] - - bswap ecx - bswap edx - - mov dword ptr [edi+4],ecx - mov dword ptr [edi],edx - - xor eax,eax - - pop ebx - pop esi - pop edi - ret -blowfishDecrypt endp - - end diff --git a/beecrypt/masm/mpopt.x86.asm b/beecrypt/masm/mpopt.x86.asm deleted file mode 100644 index 7bc457206..000000000 --- a/beecrypt/masm/mpopt.x86.asm +++ /dev/null @@ -1,447 +0,0 @@ -; -; mpopt.x86.asm -; -; Assembler optimized multiprecision integer routines for Intel x86 processors -; -; Copyright (c) 2003 Bob Deblier -; -; Author: Bob Deblier <bob.deblier@pandora.be> -; -; This library is free software; you can redistribute it and/or -; modify it under the terms of the GNU Lesser General Public -; License as published by the Free Software Foundation; either -; version 2.1 of the License, or (at your option) any later version. -; -; This library is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -; Lesser General Public License for more details. -; -; You should have received a copy of the GNU Lesser General Public -; License along with this library; if not, write to the Free Software -; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -; - - .586 - .model flat,C - .xmm - .code - - align 8 -mpzero proc c export - push edi - - mov ecx,dword ptr [esp+8] - mov edi,dword ptr [esp+12] - - xor eax,eax - rep stosd - - pop edi - ret -mpzero endp - - - align 8 -mpfill proc c export - push edi - - mov ecx,dword ptr [esp+8] - mov edi,dword ptr [esp+12] - mov eax,dword ptr [esp+16] - - rep stosd - - pop edi - ret -mpfill endp - - - align 8 -mpodd proc c export - mov ecx,dword ptr [esp+4] - mov eax,dword ptr [esp+8] - mov eax,dword ptr [eax+ecx*4-4] - and eax,1 - ret -mpodd endp - - - align 8 -mpeven proc c export - mov ecx,dword ptr [esp+4] - mov eax,dword ptr [esp+8] - mov eax,dword ptr [eax+ecx*4-4] - not eax - and eax,1 - ret -mpeven endp - - - align 8 -mpaddw proc c export - push edi - - mov ecx,dword ptr [esp+8] - mov edi,dword ptr [esp+12] - mov eax,dword ptr [esp+16] - - lea edi,dword ptr [edi+ecx*4-4] - add dword ptr [edi],eax - dec ecx - jz @mpaddw_end - sub edi,4 - xor edx,edx - - align 4 -@mpaddw_loop: - adc dword ptr [edi],edx - sub edi,4 - dec ecx - jnz @mpaddw_loop -@mpaddw_end: - sbb eax,eax - neg eax - - pop edi - ret -mpaddw endp - - - align 8 -mpsubw proc c export - push edi - - mov ecx,dword ptr [esp+8] - mov edi,dword ptr [esp+12] - mov eax,dword ptr [esp+16] - - lea edi,dword ptr [edi+ecx*4-4] - sub dword ptr [edi],eax - dec ecx - jz @mpsubw_end - sub edi,4 - xor edx,edx - - align 4 -@mpsubw_loop: - sbb dword ptr [edi],edx - sub edi,4 - dec ecx - jnz @mpsubw_loop -@mpsubw_end: - sbb eax,eax - neg eax - - pop edi - ret -mpsubw endp - - - align 8 -mpadd proc c export - push edi - push esi - - mov ecx,dword ptr [esp+12] - mov edi,dword ptr [esp+16] - mov esi,dword ptr [esp+20] - - xor edx,edx - dec ecx - - align 4 -@mpadd_loop: - mov eax,dword ptr [esi+ecx*4] - mov edx,dword ptr [edi+ecx*4] - adc edx,eax - mov dword ptr [edi+ecx*4],edx - dec ecx - jns @mpadd_loop - - sbb eax,eax - neg eax - - pop esi - pop edi - ret -mpadd endp - - - align 8 -mpsub proc c export - push edi - push esi - - mov ecx,dword ptr [esp+12] - mov edi,dword ptr [esp+16] - mov esi,dword ptr [esp+20] - - xor edx,edx - dec ecx - - align 4 -@mpsub_loop: - mov eax,dword ptr [esi+ecx*4] - mov edx,dword ptr [edi+ecx*4] - sbb edx,eax - mov dword ptr [edi+ecx*4],edx - dec ecx - jns @mpsub_loop - - sbb eax,eax - neg eax - - pop esi - pop edi - ret -mpsub endp - - - align 8 -mpdivtwo proc c export - push edi - - mov ecx,dword ptr [esp+8] - mov edi,dword ptr [esp+12] - - lea edi,dword ptr [edi+ecx*4] - neg ecx - clc - -@mpdivtwo_loop: - rcr dword ptr [edi+ecx*4],1 - inc ecx - jnz @mpdivtwo_loop - - pop edi - ret -mpdivtwo endp - - - align 8 -mpmultwo proc c export - push edi - - mov ecx,dword ptr [esp+8] - mov edi,dword ptr [esp+12] - - dec ecx - clc - - align 4 -@mpmultwo_loop: - mov eax,dword ptr [edi+ecx*4] - adc eax,eax - mov dword ptr [edi+ecx*4],eax - dec ecx - jns @mpmultwo_loop - - sbb eax,eax - neg eax - - pop edi - ret -mpmultwo endp - - - align 8 -mpsetmul proc c export - push edi - push esi - - ifdef USE_SSE2 - - mov ecx,dword ptr [esp+12] - mov edi,dword ptr [esp+16] - mov esi,dword ptr [esp+20] - movd mm1,dword ptr [esp+24] - - pxor mm0,mm0 - dec ecx - - align 4 -@mpsetmul_loop: - movd mm2,dword ptr [esi+ecx*4] - pmuludq mm2,mm1 - paddq mm0,mm2 - movd dword ptr [edi+ecx*4],mm0 - dec ecx - psrlq mm0,32 - jns @mpsetmul_loop - - movd eax,mm0 - emms - - else - - push ebx - push ebp - - mov ecx,dword ptr [esp+20] - mov edi,dword ptr [esp+24] - mov esi,dword ptr [esp+28] - mov ebp,dword ptr [esp+32] - - xor edx,edx - dec ecx - - align 4 -@mpsetmul_loop: - mov ebx,edx - mov eax,dword ptr [esi+ecx*4] - mul ebp - add eax,ebx - adc edx,0 - mov dword ptr [edi+ecx*4],eax - dec ecx - jns @mpsetmul_loop - - mov eax,edx - - pop ebp - pop ebx - - endif - - pop esi - pop edi - ret -mpsetmul endp - - - align 8 -mpaddmul proc c export - push edi - push esi - - ifdef USE_SSE2 - - mov ecx,dword ptr [esp+12] - mov edi,dword ptr [esp+16] - mov esi,dword ptr [esp+20] - movd mm1,dword ptr [esp+24] - - pxor mm0,mm0 - dec ecx - -@mpaddmul_loop: - movd mm2,dword ptr [esi+ecx*4] - pmuludq mm2,mm1 - movd mm3,dword ptr [edi+ecx*4] - paddq mm3,mm2 - paddq mm0,mm3 - movd dword ptr [edi+ecx*4],mm0 - dec ecx - psrlq mm0,32 - jns @mpaddmul_loop - - movd eax,mm0 - emms - - else - - push ebx - push ebp - - mov ecx,dword ptr [esp+20] - mov edi,dword ptr [esp+24] - mov esi,dword ptr [esp+28] - mov ebp,dword ptr [esp+32] - - xor edx,edx - dec ecx - - align 4 -@mpaddmul_loop: - mov ebx,edx - mov eax,dword ptr [esi+ecx*4] - mul ebp - add eax,ebx - adc edx,0 - add dword ptr [edi+ecx*4],eax - adc edx,0 - dec ecx - jns @mpaddmul_loop - - mov eax,edx - - pop ebp - pop ebx - - endif - - pop esi - pop edi - ret -mpaddmul endp - - - align 8 -mpaddsqrtrc proc c export - push edi - push esi - - ifdef USE_SSE2 - mov ecx,dword ptr [esp+12] - mov edi,dword ptr [esp+16] - mov esi,dword ptr [esp+20] - - pxor mm0,mm0 - dec ecx - - align 4 -@mpaddsqrtrc_loop: - movd mm2,dword ptr [esi+ecx*4] - pmuludq mm2,mm2 - movd mm3,dword ptr [edi+ecx*8+4] - paddq mm3,mm2 - movd mm4,dword ptr [edi+ecx*8+0] - paddq mm0,mm3 - movd dword ptr [edi+ecx*8+4],mm0 - psrlq mm0,32 - paddq mm0,mm4 - movd dword ptr [edi+ecx*8+0],mm0 - psrlq mm0,32 - dec ecx - jns @mpaddsqrtrc_loop - - movd eax,mm0 - emms - - else - - push ebx - - mov ecx,dword ptr [esp+16] - mov edi,dword ptr [esp+20] - mov esi,dword ptr [esp+24] - - xor ebx,ebx - dec ecx - - align 4 -@mpaddsqrtrc_loop: - mov eax,dword ptr [esi+ecx*4] - mul eax - add eax,ebx - adc edx,0 - add dword ptr [edi+ecx*8+4],eax - adc dword ptr [edi+ecx*8+0],edx - sbb ebx,ebx - neg ebx - dec ecx - jns @mpaddsqrtrc_loop - - mov eax,ebx - - pop ebx - - endif - - pop esi - pop edi - ret -mpaddsqrtrc endp - - end diff --git a/beecrypt/masm/sha1opt.i586.asm b/beecrypt/masm/sha1opt.i586.asm deleted file mode 100644 index 10aac8588..000000000 --- a/beecrypt/masm/sha1opt.i586.asm +++ /dev/null @@ -1,296 +0,0 @@ -; -; sha1.i586.asm -; -; Assembler optimized SHA-1 routines for Intel Pentium processors -; -; Compile target is Microsoft Macro Assembler -; -; Copyright (c) 2000 Virtual Unlimited B.V. -; -; Author: Bob Deblier <bob.deblier@pandora.be> -; -; This library is free software; you can redistribute it and/or -; modify it under the terms of the GNU Lesser General Public -; License as published by the Free Software Foundation; either -; version 2.1 of the License, or (at your option) any later version. -; -; This library is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -; Lesser General Public License for more details. -; -; You should have received a copy of the GNU Lesser General Public -; License along with this library; if not, write to the Free Software -; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -; - - .586 - .model flat,C - -K00 equ 5a827999h -K20 equ 6ed9eba1h -K40 equ 8f1bbcdch -K60 equ 0ca62c1d6h - -PARAM_H equ 0 -PARAM_DATA equ 20 - - .code - -subround1 macro b,c,d,e,w - mov ecx,c - mov ebx,b - mov edx,d - rol eax,5 - xor ecx,edx - add eax,e - and ecx,ebx - add eax,K00 - ror ebx,2 - add eax,w - xor ecx,edx - mov b,ebx - add eax,ecx - mov e,eax - endm - -subround2 macro b,c,d,e,w - mov ecx,c - mov ebx,b - rol eax,5 - xor ecx,ebx - add eax,e - xor ecx,d - add eax,K20 - ror ebx,2 - add eax,w - mov b,ebx - add eax,ecx - mov e,eax - endm - -subround3 macro b,c,d,e,w - mov ecx,c - rol eax,5 - mov ebx,b - mov edx,ecx - add eax,e - or ecx,ebx - and edx,ebx - and ecx,d - add eax,K40 - or ecx,edx - add eax,w - ror ebx,2 - add eax,ecx - mov b,ebx - mov e,eax - endm - -subround4 macro b,c,d,e,w - mov ecx,c - mov ebx,b - rol eax,5 - xor ecx,ebx - add eax,e - xor ecx,d - add eax,K60 - ror ebx,2 - add eax,w - mov b,ebx - add eax,ecx - mov e,eax - endm - - - align 8 - -sha1Process proc - push edi - push esi - push ebx - push ebp - ; allocate local variables - mov esi,dword ptr [esp+20] ; esi now points to param - sub esp,20 ; esp now points below the local variables - lea edi,dword ptr [esi+PARAM_DATA] - mov ebp,esp ; ebp now points to the local variables - - mov ecx,4 -@loads: - mov edx,dword ptr [esi+ecx*4] - mov dword ptr [ebp+ecx*4],edx - dec ecx - jns @loads - - mov ecx,15 - xor eax,eax - - align 4 -@swaps: - mov edx,dword ptr [edi+ecx*4] - bswap edx - mov dword ptr [edi+ecx*4],edx - dec ecx - jns @swaps - - lea edi,dword ptr [esi+PARAM_DATA] - mov ecx,16 - - align 4 -@xors: - mov eax,dword ptr [edi+52] - mov ebx,dword ptr [edi+56] - xor eax,dword ptr [edi+32] - xor ebx,dword ptr [edi+36] - xor eax,dword ptr [edi+ 8] - xor ebx,dword ptr [edi+12] - xor eax,dword ptr [edi ] - xor ebx,dword ptr [edi+ 4] - rol eax,1 - rol ebx,1 - mov dword ptr [edi+64],eax - mov dword ptr [edi+68],ebx - mov eax,dword ptr [edi+60] - mov ebx,dword ptr [edi+64] - xor eax,dword ptr [edi+40] - xor ebx,dword ptr [edi+44] - xor eax,dword ptr [edi+16] - xor ebx,dword ptr [edi+20] - xor eax,dword ptr [edi+ 8] - xor ebx,dword ptr [edi+12] - rol eax,1 - rol ebx,1 - mov dword ptr [edi+72],eax - mov dword ptr [edi+76],ebx - add edi,16 - dec ecx - jnz @xors - - mov edi,PARAM_DATA - - ; to optimize further, use esi only, and store the add constant into edi - ; will make code smaller and faster - -@round01to20: - mov eax,dword ptr [ebp] - subround1 dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround1 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround1 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround1 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround1 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - add edi,20 - subround1 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround1 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround1 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround1 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround1 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - add edi,20 - subround1 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround1 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround1 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround1 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround1 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - add edi,20 - subround1 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround1 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround1 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround1 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround1 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - add edi,20 - -@round21to40: - subround2 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround2 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround2 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround2 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround2 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - add edi,20 - subround2 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround2 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround2 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround2 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround2 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - add edi,20 - subround2 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround2 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround2 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround2 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround2 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - add edi,20 - subround2 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround2 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround2 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround2 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround2 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - add edi,20 - -@round41to60: - subround3 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround3 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround3 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround3 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround3 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - add edi,20 - subround3 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround3 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround3 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround3 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround3 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - add edi,20 - subround3 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround3 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround3 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround3 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround3 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - add edi,20 - subround3 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround3 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround3 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround3 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround3 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - add edi,20 - -@round61to80: - subround4 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround4 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround4 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround4 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround4 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - add edi,20 - subround4 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround4 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround4 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround4 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround4 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - add edi,20 - subround4 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround4 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround4 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround4 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround4 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - add edi,20 - subround4 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround4 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround4 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround4 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround4 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - ; add edi,20 - - mov ecx,4 - -@adds: - mov eax,dword ptr [ebp+ecx*4] - add dword ptr [esi+ecx*4],eax - dec ecx - jns @adds - - add esp,20 - pop ebp - pop ebx - pop esi - pop edi - ret -sha1Process endp - - end diff --git a/beecrypt/md5.c b/beecrypt/md5.c deleted file mode 100644 index f85b3a58f..000000000 --- a/beecrypt/md5.c +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Copyright (c) 2000, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file md5.c - * \brief MD5 hash function - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup HASH_m HASH_md5_m - */ - -#include "system.h" - -#include "md5.h" -#include "mp.h" -#include "endianness.h" - -#include "debug.h" - -/*!\addtogroup HASH_md5_m - * \{ - */ - -static uint32_t md5hinit[4] = { 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476 }; - -const hashFunction md5 = { - "MD5", - sizeof(md5Param), - 64, - 16, - (hashFunctionReset) md5Reset, - (hashFunctionUpdate) md5Update, - (hashFunctionDigest) md5Digest -}; - -int md5Reset(register md5Param* mp) -{ - memcpy(mp->h, md5hinit, 4 * sizeof(uint32_t)); - memset(mp->data, 0, 16 * sizeof(uint32_t)); - #if (MP_WBITS == 64) - mpzero(1, mp->length); - #elif (MP_WBITS == 32) - mpzero(2, mp->length); - #else - # error - #endif - mp->offset = 0; - return 0; -} - -#define FF(a, b, c, d, w, s, t) \ - a += ((b&(c^d))^d) + w + t; \ - a = ROTL32(a, s); \ - a += b; - -#define GG(a, b, c, d, w, s, t) \ - a += ((d&(b^c))^c) + w + t; \ - a = ROTL32(a, s); \ - a += b; - -#define HH(a, b, c, d, w, s, t) \ - a += (b^c^d) + w + t; \ - a = ROTL32(a, s); \ - a += b; - -#define II(a, b, c, d, w, s, t) \ - a += (c^(b|~d)) + w + t; \ - a = ROTL32(a, s); \ - a += b; - -#ifndef ASM_MD5PROCESS -void md5Process(md5Param* mp) -{ - register uint32_t a,b,c,d; - register uint32_t* w; - #if WORDS_BIGENDIAN - register byte t; - #endif - - w = mp->data; - #if WORDS_BIGENDIAN - t = 16; - while (t--) - { - register uint32_t temp = swapu32(*w); - *(w++) = temp; - } - w = mp->data; - #endif - - a = mp->h[0]; b = mp->h[1]; c = mp->h[2]; d = mp->h[3]; - - FF(a, b, c, d, w[ 0], 7, 0xd76aa478); - FF(d, a, b, c, w[ 1], 12, 0xe8c7b756); - FF(c, d, a, b, w[ 2], 17, 0x242070db); - FF(b, c, d, a, w[ 3], 22, 0xc1bdceee); - FF(a, b, c, d, w[ 4], 7, 0xf57c0faf); - FF(d, a, b, c, w[ 5], 12, 0x4787c62a); - FF(c, d, a, b, w[ 6], 17, 0xa8304613); - FF(b, c, d, a, w[ 7], 22, 0xfd469501); - FF(a, b, c, d, w[ 8], 7, 0x698098d8); - FF(d, a, b, c, w[ 9], 12, 0x8b44f7af); - FF(c, d, a, b, w[10], 17, 0xffff5bb1); - FF(b, c, d, a, w[11], 22, 0x895cd7be); - FF(a, b, c, d, w[12], 7, 0x6b901122); - FF(d, a, b, c, w[13], 12, 0xfd987193); - FF(c, d, a, b, w[14], 17, 0xa679438e); - FF(b, c, d, a, w[15], 22, 0x49b40821); - - GG(a, b, c, d, w[ 1], 5, 0xf61e2562); - GG(d, a, b, c, w[ 6], 9, 0xc040b340); - GG(c, d, a, b, w[11], 14, 0x265e5a51); - GG(b, c, d, a, w[ 0], 20, 0xe9b6c7aa); - GG(a, b, c, d, w[ 5], 5, 0xd62f105d); - GG(d, a, b, c, w[10], 9, 0x02441453); - GG(c, d, a, b, w[15], 14, 0xd8a1e681); - GG(b, c, d, a, w[ 4], 20, 0xe7d3fbc8); - GG(a, b, c, d, w[ 9], 5, 0x21e1cde6); - GG(d, a, b, c, w[14], 9, 0xc33707d6); - GG(c, d, a, b, w[ 3], 14, 0xf4d50d87); - GG(b, c, d, a, w[ 8], 20, 0x455a14ed); - GG(a, b, c, d, w[13], 5, 0xa9e3e905); - GG(d, a, b, c, w[ 2], 9, 0xfcefa3f8); - GG(c, d, a, b, w[ 7], 14, 0x676f02d9); - GG(b, c, d, a, w[12], 20, 0x8d2a4c8a); - - HH(a, b, c, d, w[ 5], 4, 0xfffa3942); - HH(d, a, b, c, w[ 8], 11, 0x8771f681); - HH(c, d, a, b, w[11], 16, 0x6d9d6122); - HH(b, c, d, a, w[14], 23, 0xfde5380c); - HH(a, b, c, d, w[ 1], 4, 0xa4beea44); - HH(d, a, b, c, w[ 4], 11, 0x4bdecfa9); - HH(c, d, a, b, w[ 7], 16, 0xf6bb4b60); - HH(b, c, d, a, w[10], 23, 0xbebfbc70); - HH(a, b, c, d, w[13], 4, 0x289b7ec6); - HH(d, a, b, c, w[ 0], 11, 0xeaa127fa); - HH(c, d, a, b, w[ 3], 16, 0xd4ef3085); - HH(b, c, d, a, w[ 6], 23, 0x04881d05); - HH(a, b, c, d, w[ 9], 4, 0xd9d4d039); - HH(d, a, b, c, w[12], 11, 0xe6db99e5); - HH(c, d, a, b, w[15], 16, 0x1fa27cf8); - HH(b, c, d, a, w[ 2], 23, 0xc4ac5665); - - II(a, b, c, d, w[ 0], 6, 0xf4292244); - II(d, a, b, c, w[ 7], 10, 0x432aff97); - II(c, d, a, b, w[14], 15, 0xab9423a7); - II(b, c, d, a, w[ 5], 21, 0xfc93a039); - II(a, b, c, d, w[12], 6, 0x655b59c3); - II(d, a, b, c, w[ 3], 10, 0x8f0ccc92); - II(c, d, a, b, w[10], 15, 0xffeff47d); - II(b, c, d, a, w[ 1], 21, 0x85845dd1); - II(a, b, c, d, w[ 8], 6, 0x6fa87e4f); - II(d, a, b, c, w[15], 10, 0xfe2ce6e0); - II(c, d, a, b, w[ 6], 15, 0xa3014314); - II(b, c, d, a, w[13], 21, 0x4e0811a1); - II(a, b, c, d, w[ 4], 6, 0xf7537e82); - II(d, a, b, c, w[11], 10, 0xbd3af235); - II(c, d, a, b, w[ 2], 15, 0x2ad7d2bb); - II(b, c, d, a, w[ 9], 21, 0xeb86d391); - - mp->h[0] += a; - mp->h[1] += b; - mp->h[2] += c; - mp->h[3] += d; -} -#endif - -int md5Update(md5Param* mp, const byte* data, size_t size) -{ - register uint32_t proclength; - - #if (MP_WBITS == 64) - mpw add[1]; - mpsetw(1, add, size); - mplshift(1, add, 3); - mpadd(1, mp->length, add); - #elif (MP_WBITS == 32) - mpw add[2]; - mpsetw(2, add, size); - mplshift(2, add, 3); - mpadd(2, mp->length, add); - #else - # error - #endif - - while (size > 0) - { - proclength = ((mp->offset + size) > 64U) ? (64U - mp->offset) : size; - memcpy(((byte *) mp->data) + mp->offset, data, proclength); - size -= proclength; - data += proclength; - mp->offset += proclength; - - if (mp->offset == 64U) - { - md5Process(mp); - mp->offset = 0; - } - } - return 0; -} - -static void md5Finish(md5Param* mp) - /*@modifies mp @*/ -{ - register byte *ptr = ((byte *) mp->data) + mp->offset++; - - *(ptr++) = 0x80; - - if (mp->offset > 56) - { - while (mp->offset++ < 64) - *(ptr++) = 0; - - md5Process(mp); - mp->offset = 0; - } - - ptr = ((byte *) mp->data) + mp->offset; - while (mp->offset++ < 56) - *(ptr++) = 0; - - #if (MP_WBITS == 64) - ptr[0] = (byte)(mp->length[0] ); - ptr[1] = (byte)(mp->length[0] >> 8); - ptr[2] = (byte)(mp->length[0] >> 16); - ptr[3] = (byte)(mp->length[0] >> 24); - ptr[4] = (byte)(mp->length[0] >> 32); - ptr[5] = (byte)(mp->length[0] >> 40); - ptr[6] = (byte)(mp->length[0] >> 48); - ptr[7] = (byte)(mp->length[0] >> 56); - #elif (MP_WBITS == 32) - ptr[0] = (byte)(mp->length[1] ); - ptr[1] = (byte)(mp->length[1] >> 8); - ptr[2] = (byte)(mp->length[1] >> 16); - ptr[3] = (byte)(mp->length[1] >> 24); - ptr[4] = (byte)(mp->length[0] ); - ptr[5] = (byte)(mp->length[0] >> 8); - ptr[6] = (byte)(mp->length[0] >> 16); - ptr[7] = (byte)(mp->length[0] >> 24); - #else - # error - #endif - - md5Process(mp); - - mp->offset = 0; -} - -int md5Digest(md5Param* mp, byte* data) -{ - md5Finish(mp); - - /* encode 4 integers little-endian style */ - data[ 0] = (byte)(mp->h[0] ); - data[ 1] = (byte)(mp->h[0] >> 8); - data[ 2] = (byte)(mp->h[0] >> 16); - data[ 3] = (byte)(mp->h[0] >> 24); - data[ 4] = (byte)(mp->h[1] ); - data[ 5] = (byte)(mp->h[1] >> 8); - data[ 6] = (byte)(mp->h[1] >> 16); - data[ 7] = (byte)(mp->h[1] >> 24); - data[ 8] = (byte)(mp->h[2] ); - data[ 9] = (byte)(mp->h[2] >> 8); - data[10] = (byte)(mp->h[2] >> 16); - data[11] = (byte)(mp->h[2] >> 24); - data[12] = (byte)(mp->h[3] ); - data[13] = (byte)(mp->h[3] >> 8); - data[14] = (byte)(mp->h[3] >> 16); - data[15] = (byte)(mp->h[3] >> 24); - - md5Reset(mp); - return 0; -} - -/*!\} - */ diff --git a/beecrypt/md5.h b/beecrypt/md5.h deleted file mode 100644 index beaac7aae..000000000 --- a/beecrypt/md5.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2000, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file md5.h - * \brief MD5 hash function. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup HASH_m HASH_md5_m - */ - -#ifndef _MD5_H -#define _MD5_H - -#include "beecrypt.h" - -/*!\brief Holds all the parameters necessary for the MD5 algorithm. - * \ingroup HASH_md5_h - */ -typedef struct -{ - /*!\var h - */ - uint32_t h[4]; - /*!\var data - */ - uint32_t data[16]; - /*!\var length - * \brief Multi-precision integer counter for the bits that have been - * processed so far. - */ - #if (MP_WBITS == 64) - mpw length[1]; - #elif (MP_WBITS == 32) - mpw length[2]; - #else - # error - #endif - /*!\var offset - * \brief Offset into \a data; points to the place where new data will be - * copied before it is processed. - */ - uint32_t offset; -} md5Param; - -#ifdef __cplusplus -extern "C" { -#endif - -/*!\var sha1 - * \brief Holds the full API description of the MD5 algorithm. - */ -extern BEECRYPTAPI const hashFunction md5; - -/*!\fn int md5Reset(md5Param* mp) - * \brief This function resets the parameter block so that it's ready for a - * new hash. - * \param mp The hash function's parameter block. - * \retval 0 on success. - */ -BEECRYPTAPI -void md5Process(md5Param* mp) - /*@modifies mp @*/; - -/*!\fn int md5Reset(md5Param* mp) - * \brief This function resets the parameter block so that it's ready for a - * new hash. - * \param mp The hash function's parameter block. - * \retval 0 on success. - */ -BEECRYPTAPI -int md5Reset (md5Param* mp) - /*@modifies mp @*/; - -/*!\fn int md5Update(md5Param* mp, const byte* data, size_t size) - * \brief This function should be used to pass successive blocks of data - * to be hashed. - * \param mp The hash function's parameter block. - * \param data - * \param size - * \retval 0 on success. - */ -BEECRYPTAPI -int md5Update (md5Param* mp, const byte* data, size_t size) - /*@modifies mp @*/; - -/*!\fn int md5Digest(md5Param* mp, byte* digest) - * \brief This function finishes the current hash computation and copies - * the digest value into \a digest. - * \param mp The hash function's parameter block. - * \param digest The place to store the 16-byte digest. - * \retval 0 on success. - */ -BEECRYPTAPI -int md5Digest (md5Param* mp, byte* digest) - /*@modifies mp, digest @*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/memchunk.c b/beecrypt/memchunk.c deleted file mode 100644 index bce766926..000000000 --- a/beecrypt/memchunk.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2001 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file memchunk.c - * \author Bob Deblier <bob.deblier@pandora.be> - */ - -#include "system.h" - -#include "memchunk.h" - -#include "debug.h" - -memchunk* memchunkAlloc(size_t size) -{ - memchunk* tmp = (memchunk*) calloc(1, sizeof(memchunk)); - - if (tmp) - { - tmp->size = size; - tmp->data = (byte*) malloc(size); - - if (tmp->data == (byte*) 0) - { - free(tmp); - tmp = 0; - } - } - - return tmp; -} - -void memchunkInit(memchunk* m) - /*@modifies m @*/ -{ - m->data = (byte*) 0; - m->size = 0; -} - -void memchunkWipe(memchunk* m) -{ - if (m) - { - if (m->data) - { - memset(m->data, 0, m->size); - } - } -} - -void memchunkFree(memchunk* m) -{ - if (m) - { - if (m->data) - { - free(m->data); - - m->size = 0; - m->data = (byte*) 0; - } - free(m); - } -} - -memchunk* memchunkResize(memchunk* m, size_t size) -{ - if (m) - { - if (m->data) - m->data = (byte*) realloc(m->data, size); - else - m->data = (byte*) malloc(size); - - if (m->data == (byte*) 0) - { - free(m); - m = (memchunk*) 0; - } - else - m->size = size; - } - - return m; -} - -memchunk* memchunkClone(const memchunk* m) -{ - if (m) - { - memchunk* tmp = memchunkAlloc(m->size); - - if (tmp) - memcpy(tmp->data, m->data, m->size); - - return tmp; - } - - return (memchunk*) 0; -} diff --git a/beecrypt/memchunk.h b/beecrypt/memchunk.h deleted file mode 100644 index b3f346274..000000000 --- a/beecrypt/memchunk.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2001 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*!\file memchunk.h - * \author Bob Deblier <bob.deblier@pandora.be> - */ - -#ifndef _MEMCHUNK_H -#define _MEMCHUNK_H - -#include "api.h" - -typedef struct -{ - size_t size; -/*@relnull@*/ - byte* data; -} memchunk; - -#ifdef __cplusplus -extern "C" { -#endif - -BEECRYPTAPI /*@null@*/ -memchunk* memchunkAlloc(size_t size) - /*@*/; -BEECRYPTAPI -void memchunkWipe(memchunk* m) - /*@modifies m @*/; -BEECRYPTAPI -void memchunkFree(memchunk* m) - /*@modifies m @*/; -BEECRYPTAPI /*@null@*/ -memchunk* memchunkResize(memchunk* m, size_t size) - /*@modifies m @*/; -BEECRYPTAPI /*@null@*/ -memchunk* memchunkClone(const memchunk* m) - /*@*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/mp.c b/beecrypt/mp.c deleted file mode 100644 index 6aab9a121..000000000 --- a/beecrypt/mp.c +++ /dev/null @@ -1,1536 +0,0 @@ -/* - * Copyright (c) 2002, 2003 Bob Deblier - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file mp.c - * \brief Multi-precision integer routines. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup MP_m - */ - -#include "system.h" - -#include "beecrypt.h" -#include "mpopt.h" -#include "mp.h" - -#include "debug.h" - -#ifndef ASM_MPZERO -void mpzero(size_t size, mpw* data) -{ - while (size--) - *(data++) = 0; -} -#endif - -#ifndef ASM_MPFILL -void mpfill(size_t size, mpw* data, mpw fill) -{ - while (size--) - *(data++) = fill; -} -#endif - -#ifndef ASM_MPODD -int mpodd(size_t size, const mpw* data) -{ - return (int)(data[size-1] & 0x1); -} -#endif - -#ifndef ASM_MPEVEN -int mpeven(size_t size, const mpw* data) -{ - return !(int)(data[size-1] & 0x1); -} -#endif - -#ifndef ASM_MPZ -int mpz(size_t size, const mpw* data) -{ - while (size--) - if (*(data++)) - return 0; - return 1; -} -#endif - -#ifndef ASM_MPNZ -int mpnz(size_t size, const mpw* data) -{ - while (size--) - if (*(data++)) - return 1; - return 0; -} -#endif - -#ifndef ASM_MPEQ -int mpeq(size_t size, const mpw* xdata, const mpw* ydata) -{ - while (size--) - { - if (*xdata == *ydata) - { - xdata++; - ydata++; - } - else - return 0; - } - return 1; -} -#endif - -#ifndef ASM_MPEQX -int mpeqx(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata) -{ - if (xsize > ysize) - { - register size_t diff = xsize - ysize; - return mpeq(ysize, xdata+diff, ydata) && mpz(diff, xdata); - } - else if (xsize < ysize) - { - register size_t diff = ysize - xsize; - return mpeq(xsize, ydata+diff, xdata) && mpz(diff, ydata); - } - else - return mpeq(xsize, xdata, ydata); -} -#endif - -#ifndef ASM_MPNE -int mpne(size_t size, const mpw* xdata, const mpw* ydata) -{ - while (size--) - { - if (*xdata == *ydata) - { - xdata++; - ydata++; - } - else - return 1; - } - return 0; -} -#endif - -#ifndef ASM_MPNEX -int mpnex(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata) -{ - if (xsize > ysize) - { - register size_t diff = xsize - ysize; - return mpnz(diff, xdata) || mpne(ysize, xdata+diff, ydata); - } - else if (xsize < ysize) - { - register size_t diff = ysize - xsize; - return mpnz(diff, ydata) || mpne(xsize, ydata+diff, xdata); - } - else - return mpne(xsize, xdata, ydata); -} -#endif - -#ifndef ASM_MPGT -int mpgt(size_t size, const mpw* xdata, const mpw* ydata) -{ - while (size--) - { - if (*xdata < *ydata) - return 0; - if (*xdata > *ydata) - return 1; - xdata++; ydata++; - } - return 0; -} -#endif - -#ifndef ASM_MPGTX -int mpgtx(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata) -{ - if (xsize > ysize) - { - register size_t diff = xsize - ysize; - return mpnz(diff, xdata) || mpgt(ysize, xdata + diff, ydata); - } - else if (xsize < ysize) - { - register size_t diff = ysize - xsize; - return mpz(diff, ydata) && mpgt(xsize, xdata, ydata + diff); - } - else - return mpgt(xsize, xdata, ydata); -} -#endif - -#ifndef ASM_MPLT -int mplt(size_t size, const mpw* xdata, const mpw* ydata) -{ - while (size--) - { - if (*xdata > *ydata) - return 0; - if (*xdata < *ydata) - return 1; - xdata++; ydata++; - } - return 0; -} -#endif - -#ifndef ASM_MPLTX -int mpltx(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata) -{ - if (xsize > ysize) - { - register size_t diff = xsize - ysize; - return mpz(diff, xdata) && mplt(ysize, xdata+diff, ydata); - } - else if (xsize < ysize) - { - register size_t diff = ysize - xsize; - return mpnz(diff, ydata) || mplt(xsize, xdata, ydata+diff); - } - else - return mplt(xsize, xdata, ydata); -} -#endif - -#ifndef ASM_MPGE -int mpge(size_t size, const mpw* xdata, const mpw* ydata) -{ - while (size--) - { - if (*xdata < *ydata) - return 0; - if (*xdata > *ydata) - return 1; - xdata++; ydata++; - } - return 1; -} -#endif - -#ifndef ASM_MPGEX -int mpgex(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata) -{ - if (xsize > ysize) - { - register size_t diff = xsize - ysize; - return mpnz(diff, xdata) || mpge(ysize, xdata+diff, ydata); - } - else if (xsize < ysize) - { - register size_t diff = ysize - xsize; - return mpz(diff, ydata) && mpge(xsize, xdata, ydata+diff); - } - else - return mpge(xsize, xdata, ydata); -} -#endif - -#ifndef ASM_MPLE -int mple(size_t size, const mpw* xdata, const mpw* ydata) -{ - while (size--) - { - if (*xdata < *ydata) - return 1; - if (*xdata > *ydata) - return 0; - xdata++; ydata++; - } - return 1; -} -#endif - -#ifndef ASM_MPLEX -int mplex(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata) -{ - if (xsize > ysize) - { - register size_t diff = xsize - ysize; - return mpz(diff, xdata) && mple(ysize, xdata+ diff, ydata); - } - else if (xsize < ysize) - { - register size_t diff = ysize - xsize; - return mpnz(diff, ydata) || mple(xsize, xdata, ydata+diff); - } - else - return mple(xsize, xdata, ydata); -} -#endif - -#ifndef ASM_MPISONE -int mpisone(size_t size, const mpw* data) -{ - data += size; - if (*(--data) == 1) - { - while (--size) - if (*(--data)) - return 0; - return 1; - } - return 0; -} -#endif - -#ifndef ASM_MPISTWO -int mpistwo(size_t size, const mpw* data) -{ - data += size; - if (*(--data) == 2) - { - while (--size) - if (*(--data)) - return 0; - return 1; - } - return 0; -} -#endif - -#ifndef ASM_MPEQMONE -int mpeqmone(size_t size, const mpw* xdata, const mpw* ydata) -{ - xdata += size; - ydata += size; - - if (*(--xdata)+1 == *(--ydata)) - { - while (--size) - if (*(--xdata) != *(--ydata)) - return 0; - return 1; - } - return 0; -} -#endif - -#ifndef ASM_MPLEONE -int mpleone(size_t size, const mpw* data) -{ - data += size; - if (*(--data) > 1) - return 0; - else - { - while (--size) - if (*(--data)) - return 0; - return 1; - } -} -#endif - -#ifndef ASM_MPMSBSET -int mpmsbset(size_t size, const mpw* data) -{ - return (int)((*data) >> (MP_WBITS-1)); -} -#endif - -#ifndef ASM_MPLSBSET -int mplsbset(size_t size, const mpw* data) -{ - return (int)(data[size-1] & 0x1); -} -#endif - -#ifndef ASM_MPSETMSB -void mpsetmsb(size_t size, mpw* data) -{ - *data |= MP_MSBMASK; -} -#endif - -#ifndef ASM_MPSETLSB -void mpsetlsb(size_t size, mpw* data) -{ - data[size-1] |= MP_LSBMASK; -} -#endif - -#ifndef ASM_MPCLRMSB -void mpclrmsb(size_t size, mpw* data) -{ - *data &= ~ MP_MSBMASK; -} -#endif - -#ifndef ASM_MPCLRLSB -void mpclrlsb(size_t size, mpw* data) -{ - data[size-1] &= ~ MP_LSBMASK; -} -#endif - -#ifndef ASM_MPAND -void mpand(size_t size, mpw* xdata, const mpw* ydata) -{ - while (size--) - xdata[size] &= ydata[size]; -} -#endif - -#ifndef ASM_MPOR -void mpor(size_t size, mpw* xdata, const mpw* ydata) -{ - while (size--) - xdata[size] |= ydata[size]; -} -#endif - -#ifndef ASM_MPXOR -void mpxor(size_t size, mpw* xdata, const mpw* ydata) -{ - while (size--) - xdata[size] ^= ydata[size]; -} -#endif - -#ifndef ASM_MPNOT -void mpnot(size_t size, mpw* data) -{ - while (size--) - data[size] = ~data[size]; -} -#endif - -#ifndef ASM_MPSETW -void mpsetw(size_t size, mpw* xdata, mpw y) -{ - while (--size) - *(xdata++) = 0; - *(xdata++) = y; -} -#endif - -#ifndef ASM_MPSETX -void mpsetx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata) -{ - while (xsize > ysize) - { - xsize--; - *(xdata++) = 0; - } - while (ysize > xsize) - { - ysize--; - ydata++; - } - while (xsize--) - *(xdata++) = *(ydata++); -} -#endif - -#ifndef ASM_MPADDW -int mpaddw(size_t size, mpw* xdata, mpw y) -{ - register mpw load, temp; - register int carry = 0; - - xdata += size-1; - - load = *xdata; - temp = load + y; - *(xdata--) = temp; - carry = (load > temp); - - while (--size && carry) - { - load = *xdata; - temp = load + 1; - *(xdata--) = temp; - carry = (load > temp); - } - return carry; -} -#endif - -#ifndef ASM_MPADD -int mpadd(size_t size, mpw* xdata, const mpw* ydata) -{ - register mpw load, temp; - register int carry = 0; - - xdata += size-1; - ydata += size-1; - - while (size--) - { - temp = *(ydata--); - load = *xdata; - temp = carry ? (load + temp + 1) : (load + temp); - *(xdata--) = temp; - carry = carry ? (load >= temp) : (load > temp); - } - return carry; -} -#endif - -#ifndef ASM_MPADDX -int mpaddx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata) -{ - if (xsize > ysize) - { - register size_t diff = xsize - ysize; - return mpaddw(diff, xdata, (mpw) mpadd(ysize, xdata+diff, ydata)); - } - else - { - register size_t diff = ysize - xsize; - return mpadd(xsize, xdata, ydata+diff); - } -} -#endif - -#ifndef ASM_MPSUBW -int mpsubw(size_t size, mpw* xdata, mpw y) -{ - register mpw load, temp; - register int carry = 0; - - xdata += size-1; - - load = *xdata; - temp = load - y; - *(xdata--) = temp; - carry = (load < temp); - - while (--size && carry) - { - load = *xdata; - temp = load - 1; - *(xdata--) = temp; - carry = (load < temp); - } - return carry; -} -#endif - -#ifndef ASM_MPSUB -int mpsub(size_t size, mpw* xdata, const mpw* ydata) -{ - register mpw load, temp; - register int carry = 0; - - xdata += size-1; - ydata += size-1; - - while (size--) - { - temp = *(ydata--); - load = *xdata; - temp = carry ? (load - temp - 1) : (load - temp); - *(xdata--) = temp; - carry = carry ? (load <= temp) : (load < temp); - } - return carry; -} -#endif - -#ifndef ASM_MPSUBX -int mpsubx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata) -{ - if (xsize > ysize) - { - register size_t diff = xsize - ysize; - return mpsubw(diff, xdata, (mpw) mpsub(ysize, xdata+diff, ydata)); - } - else - { - register size_t diff = ysize - xsize; - return mpsub(xsize, xdata, ydata+diff); - } -} -#endif - -#ifndef ASM_MPNEG -void mpneg(size_t size, mpw* data) -{ - mpnot(size, data); - mpaddw(size, data, 1); -} -#endif - -#ifndef ASM_MPSETMUL -mpw mpsetmul(size_t size, mpw* result, const mpw* data, mpw y) -{ - #if HAVE_MPDW - register mpdw temp; - register mpw carry = 0; - - data += size; - result += size; - - while (size--) - { - temp = *(--data); - temp *= y; - temp += carry; - *(--result) = (mpw) temp; - carry = (mpw)(temp >> MP_WBITS); - } - #else - register mpw temp, load, carry = 0; - register mphw ylo, yhi; - - ylo = (mphw) y; - yhi = (mphw) (y >> MP_HWBITS); - - data += size; - result += size; - - while (size--) - { - register mphw xlo, xhi; - register mpw rlo, rhi; - - xlo = (mphw) (temp = *(--data)); - xhi = (mphw) (temp >> MP_HWBITS); - - rlo = (mpw) xlo * ylo; - rhi = (mpw) xhi * yhi; - load = rlo; - temp = (mpw) xhi * ylo; - rlo += (temp << MP_HWBITS); - rhi += (temp >> MP_HWBITS) + (load > rlo); - load = rlo; - temp = (mpw) xlo * yhi; - rlo += (temp << MP_HWBITS); - rhi += (temp >> MP_HWBITS) + (load > rlo); - load = rlo; - temp = rlo + carry; - carry = rhi + (load > temp); - *(--result) = temp; - } - #endif - return carry; -} -#endif - -#ifndef ASM_MPADDMUL -mpw mpaddmul(size_t size, mpw* result, const mpw* data, mpw y) -{ - #if HAVE_MPDW - register mpdw temp; - register mpw carry = 0; - - data += size; - result += size; - - while (size--) - { - temp = *(--data); - temp *= y; - temp += carry; - temp += *(--result); - *result = (mpw) temp; - carry = (mpw)(temp >> MP_WBITS); - } - #else - register mpw temp, load, carry = 0; - register mphw ylo, yhi; - - ylo = (mphw) y; - yhi = (mphw) (y >> MP_HWBITS); - - data += size; - result += size; - - while (size--) - { - register mphw xlo, xhi; - register mpw rlo, rhi; - - xlo = (mphw) (temp = *(--data)); - xhi = (mphw) (temp >> MP_HWBITS); - - rlo = (mpw) xlo * ylo; - rhi = (mpw) xhi * yhi; - load = rlo; - temp = (mpw) xhi * ylo; - rlo += (temp << MP_HWBITS); - rhi += (temp >> MP_HWBITS) + (load > rlo); - load = rlo; - temp = (mpw) xlo * yhi; - rlo += (temp << MP_HWBITS); - rhi += (temp >> MP_HWBITS) + (load > rlo); - load = rlo; - rlo += carry; - temp = (load > rlo); - load = rhi; - rhi += temp; - carry = (load > rhi); - load = rlo; - rlo += *(--result); - *result = rlo; - carry += rhi + (load > rlo); - } - #endif - return carry; -} -#endif - -#ifndef ASM_MPMUL -void mpmul(mpw* result, size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata) -{ - /* preferred passing of parameters is x the larger of the two numbers */ - if (xsize >= ysize) - { - register mpw rc; - - result += ysize; - ydata += ysize; - - rc = mpsetmul(xsize, result, xdata, *(--ydata)); - *(--result) = rc; - - while (--ysize) - { - rc = mpaddmul(xsize, result, xdata, *(--ydata)); - *(--result) = rc; - } - } - else - { - register mpw rc; - - result += xsize; - xdata += xsize; - - rc = mpsetmul(ysize, result, ydata, *(--xdata)); - *(--result) = rc; - - while (--xsize) - { - rc = mpaddmul(ysize, result, ydata, *(--xdata)); - *(--result) = rc; - } - } -} -#endif - -#ifndef ASM_MPADDSQRTRC -void mpaddsqrtrc(size_t size, mpw* result, const mpw* data) -{ - #if HAVE_MPDW - register mpdw temp; - register mpw load, carry = 0; - - result += (size << 1); - - while (size--) - { - temp = load = data[size]; - temp *= load; - temp += carry; - temp += *(--result); - *result = (mpw) temp; - temp >>= MP_WBITS; - temp += *(--result); - *result = (mpw) temp; - carry = (mpw)(temp >> MP_WBITS); - } - #else - register mpw temp, load, carry = 0; - - result += (size << 1); - - while (size--) - { - register mphw xlo, xhi; - register mpw rlo, rhi; - - xlo = (mphw) (temp = data[size]); - xhi = (mphw) (temp >> MP_HWBITS); - - rlo = (mpw) xlo * xlo; - rhi = (mpw) xhi * xhi; - temp = (mpw) xhi * xlo; - load = rlo; - rlo += (temp << MP_HWBITS); - rhi += (temp >> MP_HWBITS) + (load > rlo); - load = rlo; - rlo += (temp << MP_HWBITS); - rhi += (temp >> MP_HWBITS) + (load > rlo); - load = rlo; - rlo += carry; - rhi += (load > rlo); - load = rlo; - rlo += *(--result); - *result = rlo; - temp = (load > rlo); - load = rhi; - rhi += temp; - carry = (load > rhi); - load = rhi; - rhi += *(--result); - *result = rhi; - carry += (load > rhi); - } - #endif -} -#endif - -#ifndef ASM_MPSQR -void mpsqr(mpw* result, size_t size, const mpw* data) -{ - register mpw rc; - register size_t n = size-1; - - result += size; - result[n] = 0; - - if (n) - { - rc = mpsetmul(n, result, data, data[n]); - *(--result) = rc; - while (--n) - { - rc = mpaddmul(n, result, data, data[n]); - *(--result) = rc; - } - } - - *(--result) = 0; - - mpmultwo(size << 1, result); - - mpaddsqrtrc(size, result, data); -} -#endif - -#ifndef ASM_MPSIZE -size_t mpsize(size_t size, const mpw* data) -{ - while (size) - { - if (*data) - return size; - data++; - size--; - } - return 0; -} -#endif - -#ifndef ASM_MPBITS -size_t mpbits(size_t size, const mpw* data) -{ - return MP_WORDS_TO_BITS(size) - mpmszcnt(size, data); -} -#endif - -#ifndef ASM_MPNORM -size_t mpnorm(size_t size, mpw* data) -{ - register size_t shift = mpmszcnt(size, data); - mplshift(size, data, shift); - return shift; -} -#endif - -#ifndef ASM_MPDIVTWO -void mpdivtwo(size_t size, mpw* data) -{ - register mpw temp, carry = 0; - - while (size--) - { - temp = *data; - *(data++) = (temp >> 1) | carry; - carry = (temp << (MP_WBITS-1)); - } -} -#endif - -#ifndef ASM_MPSDIVTWO -void mpsdivtwo(size_t size, mpw* data) -{ - int carry = mpmsbset(size, data); - mpdivtwo(size, data); - if (carry) - mpsetmsb(size, data); -} -#endif - -#ifndef ASM_MPMULTWO -int mpmultwo(size_t size, mpw* data) -{ - register mpw temp, carry = 0; - - data += size; - while (size--) - { - temp = *(--data); - *data = (temp << 1) | carry; - carry = (temp >> (MP_WBITS-1)); - } - return (int) carry; -} -#endif - -#ifndef ASM_MPMSZCNT -size_t mpmszcnt(size_t size, const mpw* data) -{ - register size_t zbits = 0; - register size_t i = 0; - - while (i < size) - { - register mpw temp = data[i++]; - if (temp) - { - while (!(temp & MP_MSBMASK)) - { - zbits++; - temp <<= 1; - } - break; - } - else - zbits += MP_WBITS; - } - return zbits; -} -#endif - -#ifndef ASM_MPLSZCNT -size_t mplszcnt(size_t size, const mpw* data) -{ - register size_t zbits = 0; - - while (size--) - { - register mpw temp = data[size]; - if (temp) - { - while (!(temp & MP_LSBMASK)) - { - zbits++; - temp >>= 1; - } - break; - } - else - zbits += MP_WBITS; - } - return zbits; -} -#endif - -#ifndef ASM_MPLSHIFT -void mplshift(size_t size, mpw* data, size_t count) -{ - register size_t words = MP_BITS_TO_WORDS(count); - - if (words < size) - { - register short lbits = (short) (count & (MP_WBITS-1)); - - /* first do the shifting, then do the moving */ - if (lbits) - { - register mpw temp, carry = 0; - register short rbits = MP_WBITS - lbits; - register size_t i = size; - - while (i > words) - { - temp = data[--i]; - data[i] = (temp << lbits) | carry; - carry = (temp >> rbits); - } - } - if (words) - { - mpmove(size-words, data, data+words); - mpzero(words, data+size-words); - } - } - else - mpzero(size, data); -} -#endif - -#ifndef ASM_MPRSHIFT -void mprshift(size_t size, mpw* data, size_t count) -{ - register size_t words = MP_BITS_TO_WORDS(count); - - if (words < size) - { - register short rbits = (short) (count & (MP_WBITS-1)); - - /* first do the shifting, then do the moving */ - if (rbits) - { - register mpw temp, carry = 0; - register short lbits = MP_WBITS - rbits; - register size_t i = 0; - - while (i < size-words) - { - temp = data[i]; - data[i++] = (temp >> rbits) | carry; - carry = (temp << lbits); - } - } - if (words) - { - mpmove(size-words, data+words, data); - mpzero(words, data); - } - } - else - mpzero(size, data); -} -#endif - -#ifndef ASM_MPRSHIFTLSZ -size_t mprshiftlsz(size_t size, mpw* data) -{ - register mpw* slide = data+size-1; - register size_t zwords = 0; /* counter for 'all zero bit' words */ - register short lbits, rbits = 0; /* counter for 'least significant zero' bits */ - register mpw temp, carry = 0; - - data = slide; - - /* count 'all zero' words and move src pointer */ - while (size--) - { - /* test if we have a non-zero word */ - if ((carry = *(slide--))) - { - /* count 'least signification zero bits and set zbits counter */ - while (!(carry & MP_LSBMASK)) - { - carry >>= 1; - rbits++; - } - break; - } - zwords++; - } - - if ((rbits == 0) && (zwords == 0)) - return 0; - - /* prepare right-shifting of data */ - lbits = MP_WBITS - rbits; - - /* shift data */ - while (size--) - { - temp = *(slide--); - *(data--) = (temp << lbits) | carry; - carry = (temp >> rbits); - } - - /* store the final carry */ - *(data--) = carry; - - /* store the return value in size */ - size = MP_WORDS_TO_BITS(zwords) + rbits; - - /* zero the (zwords) most significant words */ - while (zwords--) - *(data--) = 0; - - return size; -} -#endif - -/* try an alternate version here, with descending sizes */ -/* also integrate lszcnt and rshift properly into one function */ -#ifndef ASM_MPGCD_W -/* - * mpgcd_w - * need workspace of (size) words - */ -void mpgcd_w(size_t size, const mpw* xdata, const mpw* ydata, mpw* result, mpw* wksp) -{ - register size_t shift, temp; - - if (mpge(size, xdata, ydata)) - { - mpcopy(size, wksp, xdata); - mpcopy(size, result, ydata); - } - else - { - mpcopy(size, wksp, ydata); - mpcopy(size, result, xdata); - } - - /* get the smallest returned values, and set shift to that */ - - shift = mprshiftlsz(size, wksp); - temp = mprshiftlsz(size, result); - - if (shift > temp) - shift = temp; - - while (mpnz(size, wksp)) - { - mprshiftlsz(size, wksp); - mprshiftlsz(size, result); - - if (mpge(size, wksp, result)) - mpsub(size, wksp, result); - else - mpsub(size, result, wksp); - - /* slide past zero words in both operands by increasing pointers and decreasing size */ - if ((*wksp == 0) && (*result == 0)) - { - size--; - wksp++; - result++; - } - } - - /* figure out if we need to slide the result pointer back */ - if ((temp = MP_BITS_TO_WORDS(shift))) - { - size += temp; - result -= temp; - } - - mplshift(size, result, shift); -} -#endif - -#ifndef ASM_MPEXTGCD_W -/* needs workspace of (6*size+6) words */ -/* used to compute the modular inverse */ -int mpextgcd_w(size_t size, const mpw* xdata, const mpw* ydata, mpw* result, mpw* wksp) -{ - /* - * For computing a modular inverse, pass the modulus as xdata and the number - * to be inverted as ydata. - * - * Fact: if a element of Zn, then a is invertible if and only if gcd(a,n) = 1 - * Hence: if n is even, then a must be odd, otherwise the gcd(a,n) >= 2 - * - * The calling routine must guarantee this condition. - */ - - register size_t sizep = size+1; - register int full; - - mpw* udata = wksp; - mpw* vdata = udata+sizep; - mpw* adata = vdata+sizep; - mpw* bdata = adata+sizep; - mpw* cdata = bdata+sizep; - mpw* ddata = cdata+sizep; - - mpsetx(sizep, udata, size, xdata); - mpsetx(sizep, vdata, size, ydata); - mpzero(sizep, bdata); - mpsetw(sizep, ddata, 1); - - if ((full = mpeven(sizep, udata))) - { - mpsetw(sizep, adata, 1); - mpzero(sizep, cdata); - } - - while (1) - { - while (mpeven(sizep, udata)) - { - mpdivtwo(sizep, udata); - - if (mpodd(sizep, bdata) || (full && mpodd(sizep, adata))) - { - if (full) mpaddx(sizep, adata, size, ydata); - mpsubx(sizep, bdata, size, xdata); - } - - if (full) mpsdivtwo(sizep, adata); - mpsdivtwo(sizep, bdata); - } - while (mpeven(sizep, vdata)) - { - mpdivtwo(sizep, vdata); - - if (mpodd(sizep, ddata) || (full && mpodd(sizep, cdata))) - { - if (full) mpaddx(sizep, cdata, size, ydata); - mpsubx(sizep, ddata, size, xdata); - } - - if (full) mpsdivtwo(sizep, cdata); - mpsdivtwo(sizep, ddata); - } - if (mpge(sizep, udata, vdata)) - { - mpsub(sizep, udata, vdata); - if (full) mpsub(sizep, adata, cdata); - mpsub(sizep, bdata, ddata); - } - else - { - mpsub(sizep, vdata, udata); - if (full) mpsub(sizep, cdata, adata); - mpsub(sizep, ddata, bdata); - } - if (mpz(sizep, udata)) - { - if (mpisone(sizep, vdata)) - { - if (result) - { - if (*ddata & MP_MSBMASK) - { - /* keep adding the modulus until we get a carry */ - while (!mpaddx(sizep, ddata, size, xdata)); - } - else - { - /* in some computations, d ends up > x, hence: - * keep subtracting n from d until d < x - */ - while (mpgtx(sizep, ddata, size, xdata)) - mpsubx(sizep, ddata, size, xdata); - } - mpsetx(size, result, sizep, ddata); - } - return 1; - } - return 0; - } - } -} -#endif - -#ifndef ASM_MPPNDIV -mpw mppndiv(mpw xhi, mpw xlo, mpw y) -{ - register mpw result = 0; - register short count = MP_WBITS; - register int carry = 0; - - while (count--) - { - if (carry | (xhi >= y)) - { - xhi -= y; - result++; - } - carry = (xhi >> (MP_WBITS-1)); - xhi <<= 1; - xhi |= (xlo >> (MP_WBITS-1)); - xlo <<= 1; - result <<= 1; - } - if (carry | (xhi >= y)) - { - xhi -= y; - result++; - } - return result; -} -#endif - -#ifndef ASM_MPMOD -void mpmod(mpw* result, size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata, mpw* workspace) -{ - /* result size xsize, workspace size 2*ysize+1 */ - mpw q, msw; - mpw* rdata = result; - mpw* ynorm = workspace+ysize+1; - size_t shift, qsize = xsize-ysize; - - mpcopy(ysize, ynorm, ydata); - shift = mpnorm(ysize, ynorm); - msw = *ynorm; - mpcopy(xsize, rdata, xdata); - if (mpge(ysize, rdata, ynorm)) - mpsub(ysize, rdata, ynorm); - - while (qsize--) - { - q = mppndiv(rdata[0], rdata[1], msw); - - *workspace = mpsetmul(ysize, workspace+1, ynorm, q); - - while (mplt(ysize+1, rdata, workspace)) - { - mpsubx(ysize+1, workspace, ysize, ynorm); - q--; - } - mpsub(ysize+1, rdata, workspace); - rdata++; - } - /* de-normalization steps */ - while (shift--) - { - mpdivtwo(ysize, ynorm); - if (mpge(ysize, rdata, ynorm)) - mpsub(ysize, rdata, ynorm); - } -} -#endif - -#ifndef ASM_MPNDIVMOD -void mpndivmod(mpw* result, size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata, register mpw* workspace) -{ - /* result must be xsize+1 in length */ - /* workspace must be ysize+1 in length */ - /* expect ydata to be normalized */ - mpw q; - mpw msw = *ydata; - size_t qsize = xsize-ysize; - - *result = (mpge(ysize, xdata, ydata) ? 1 : 0); - mpcopy(xsize, result+1, xdata); - - if (*result) - (void) mpsub(ysize, result+1, ydata); - - result++; - - while (qsize--) - { - q = mppndiv(result[0], result[1], msw); - - *workspace = mpsetmul(ysize, workspace+1, ydata, q); - - while (mplt(ysize+1, result, workspace)) - { - mpsubx(ysize+1, workspace, ysize, ydata); - q--; - } - mpsub(ysize+1, result, workspace); - *(result++) = q; - } -} -#endif - -void mpprint(size_t size, const mpw* data) -{ - mpfprint(stdout, size, data); -} - -void mpprintln(size_t size, const mpw* data) -{ - mpfprintln(stdout, size, data); -} - -void mpfprint(FILE* f, size_t size, const mpw* data) -{ - if (data == (mpw*) 0) - return; - - if (f == (FILE*) 0) - return; - - while (size--) - { - #if (MP_WBITS == 32) - fprintf(f, "%08x", (unsigned) *(data++)); - #elif (MP_WBITS == 64) - # if WIN32 - fprintf(f, "%016I64x", *(data++)); - # elif SIZEOF_UNSIGNED_LONG == 8 - fprintf(f, "%016lx", *(data++)); - # else - fprintf(f, "%016llx", *(data++)); - # endif - #else - # error - #endif - } - fflush(f); -} - -void mpfprintln(FILE* f, size_t size, const mpw* data) -{ - if (data == (mpw*) 0) - return; - - if (f == (FILE*) 0) - return; - - while (size--) - { - #if (MP_WBITS == 32) - fprintf(f, "%08x", *(data++)); - #elif (MP_WBITS == 64) - # if WIN32 - fprintf(f, "%016I64x", *(data++)); - # elif SIZEOF_UNSIGNED_LONG == 8 - fprintf(f, "%016lx", *(data++)); - # else - fprintf(f, "%016llx", *(data++)); - # endif - #else - # error - #endif - } - fprintf(f, "\n"); - fflush(f); -} - -int i2osp(byte *osdata, size_t ossize, const mpw* idata, size_t isize) -{ - #if WORDS_BIGENDIAN - size_t max_bytes = MP_WORDS_TO_BYTES(isize); - #endif - size_t significant_bytes = (mpbits(isize, idata) + 7) >> 3; - - /* verify that ossize is large enough to contain the significant bytes */ - if (ossize >= significant_bytes) - { - /* looking good; check if we have more space than significant bytes */ - if (ossize > significant_bytes) - { /* fill most significant bytes with zero */ - memset(osdata, 0, ossize - significant_bytes); - osdata += ossize - significant_bytes; - } - if (significant_bytes) - { /* fill remaining bytes with endian-adjusted data */ - #if !WORDS_BIGENDIAN - mpw w = idata[--isize]; - byte shift = 0; - - /* fill right-to-left; much easier than left-to-right */ - do - { - osdata[--significant_bytes] = (byte)(w >> shift); - shift += 8; - if (shift == MP_WBITS) - { - shift = 0; - w = idata[--isize]; - } - } while (significant_bytes); - #else - /* just copy data past zero bytes */ - memcpy(osdata, ((byte*) idata) + (max_bytes - significant_bytes), significant_bytes); - #endif - } - return 0; - } - return -1; -} - -int os2ip(mpw* idata, size_t isize, const byte* osdata, size_t ossize) -{ - size_t required; - - /* skip non-significant leading zero bytes */ - while (!(*osdata) && ossize) - { - osdata++; - ossize--; - } - - required = MP_BYTES_TO_WORDS(ossize + MP_WBYTES - 1); - - if (isize >= required) - { - /* yes, we have enough space and can proceed */ - mpw w = 0; - /* adjust counter so that the loop will start by skipping the proper - * amount of leading bytes in the first significant word - */ - byte b = (ossize % MP_WBYTES); - - if (isize > required) - { /* fill initials words with zero */ - mpzero(isize-required, idata); - idata += isize-required; - } - - if (b == 0) - b = MP_WBYTES; - - while (ossize--) - { - w <<= 8; - w |= *(osdata++); - b--; - - if (b == 0) - { - *(idata++) = w; - w = 0; - b = MP_WBYTES; - } - } - - return 0; - } - return -1; -} - -int hs2ip(mpw* idata, size_t isize, const char* hsdata, size_t hssize) -{ - size_t required = MP_NIBBLES_TO_WORDS(hssize + MP_WNIBBLES - 1); - - if (isize >= required) - { - register size_t i; - - - if (isize > required) - { /* fill initial words with zero */ - for (i = required; i < isize; i++) - *(idata++) = 0; - } - while (hssize) - { - register mpw w = 0; - register size_t chunk = hssize & (MP_WNIBBLES - 1); - register char ch; - - if (chunk == 0) chunk = MP_WNIBBLES; - - for (i = 0; i < chunk; i++) - { - ch = *(hsdata++); - w <<= 4; - if (ch >= '0' && ch <= '9') - w += (ch - '0'); - else if (ch >= 'A' && ch <= 'F') - w += (ch - 'A') + 10; - else if (ch >= 'a' && ch <= 'f') - w += (ch - 'a') + 10; - } - *(idata++) = w; - hssize -= chunk; - } - return 0; - } - return -1; -} diff --git a/beecrypt/mp.h b/beecrypt/mp.h deleted file mode 100644 index ac01565c0..000000000 --- a/beecrypt/mp.h +++ /dev/null @@ -1,762 +0,0 @@ -/* - * Copyright (c) 2002, 2003 Bob Deblier - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file mp.h - * \brief Multi-precision integer routines. - * - * The routines declared here are all low-level operations, most of them - * suitable to be implemented in assembler. Prime candidates are in order - * of importance (according to gprof): - * <ul> - * <li>mpaddmul - * <li>mpsetmul - * <li>mpaddsqrtrc - * <li>mpsub - * <li>mpadd - * </ul> - * - * With some smart use of available assembler instructions, it's possible - * to speed these routines up by a factor of 2 to 4. - * - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup MP_m - */ - -#ifndef _MP_H -#define _MP_H - -#include "api.h" -#include "mpopt.h" - -#define MP_HWBITS (MP_WBITS >> 1) -#define MP_WBYTES (MP_WBITS >> 3) -#define MP_WNIBBLES (MP_WBITS >> 2) - -#if (MP_WBITS == 64) -# define MP_WORDS_TO_BITS(x) ((x) << 6) -# define MP_WORDS_TO_NIBBLES(x) ((x) << 4) -# define MP_WORDS_TO_BYTES(x) ((x) << 3) -# define MP_BITS_TO_WORDS(x) ((x) >> 6) -# define MP_NIBBLES_TO_WORDS(x) ((x) >> 4) -# define MP_BYTES_TO_WORDS(x) ((x) >> 3) -#elif (MP_WBITS == 32) -# define MP_WORDS_TO_BITS(x) ((x) << 5) -# define MP_WORDS_TO_NIBBLES(x) ((x) << 3) -# define MP_WORDS_TO_BYTES(x) ((x) << 2) -# define MP_BITS_TO_WORDS(x) ((x) >> 5) -# define MP_NIBBLES_TO_WORDS(x) ((x) >> 3) -# define MP_BYTES_TO_WORDS(x) ((x) >> 2) -#else -# error -#endif - -#define MP_MSBMASK (((mpw) 0x1) << (MP_WBITS-1)) -#define MP_LSBMASK ((mpw) 0x1) -#define MP_ALLMASK ~((mpw) 0x0) - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef ASM_MPCOPY -# define mpcopy(size, dst, src) memcpy(dst, src, MP_WORDS_TO_BYTES(size)) -#else -BEECRYPTAPI -void mpcopy(size_t size, mpw* dest, const mpw* src) - /*@*/; -#endif - -#ifndef ASM_MPMOVE -# define mpmove(size, dst, src) memmove(dst, src, MP_WORDS_TO_BYTES(size)) -#else -BEECRYPTAPI -void mpmove(size_t size, mpw* dest, const mpw* src) - /*@modifies dest @*/; -#endif - -/*!\fn void mpzero(size_t size, mpw* data) - * \brief This function zeroes a multi-precision integer of a given size. - * \param size The size of the multi-precision integer. - * \param data The multi-precision integer data. - */ -BEECRYPTAPI -void mpzero(size_t size, mpw* data) - /*@modifies data @*/; - -/*!\fn void mpfill(size_t size, mpw* data, mpw fill) - * \brief This function fills each word of a multi-precision integer with a - * given value. - * \param size The size of the multi-precision integer. - * \param data The multi-precision integer data. - * \param fill The value fill the data with. - */ -BEECRYPTAPI -void mpfill(size_t size, mpw* data, mpw fill) - /*@modifies data @*/; - -/*!\fn int mpodd(size_t size, const mpw* data) - * \brief This functions tests if a multi-precision integer is odd. - * \param size The size of the multi-precision integer. - * \param data The multi-precision integer data. - * \retval 1 if odd - * \retval 0 if even - */ -BEECRYPTAPI -int mpodd (size_t size, const mpw* data) - /*@*/; - -/*!\fn int mpeven(size_t size, const mpw* data) - * \brief This function tests if a multi-precision integer is even. - * \param size The size of the multi-precision integer. - * \param data The multi-precision integer data. - * \retval 1 if even - * \retval 0 if odd - */ -BEECRYPTAPI -int mpeven(size_t size, const mpw* data) - /*@*/; - -/*!\fn int mpz(size_t size, const mpw* data) - * \brief This function tests if a multi-precision integer is zero. - * \param size The size of the multi-precision integer. - * \param data The multi-precision integer data. - * \retval 1 if zero - * \retval 0 if not zero - */ -BEECRYPTAPI -int mpz (size_t size, const mpw* data) - /*@*/; - -/*!\fn int mpnz(size_t size, const mpw* data) - * \brief This function tests if a multi-precision integer is not zero. - * \param size The size of the multi-precision integer. - * \param data The multi-precision integer data. - * \retval 1 if not zero - * \retval 0 if zero - */ -BEECRYPTAPI -int mpnz (size_t size, const mpw* data) - /*@*/; - -/*!\fn int mpeq(size_t size, const mpw* xdata, const mpw* ydata) - * \brief This function tests if two multi-precision integers of the same size - * are equal. - * \param size The size of the multi-precision integers. - * \param xdata The first multi-precision integer. - * \param ydata The second multi-precision integer. - * \retval 1 if equal - * \retval 0 if not equal - */ -BEECRYPTAPI -int mpeq (size_t size, const mpw* xdata, const mpw* ydata) - /*@*/; - -/*!\fn int mpne(size_t size, const mpw* xdata, const mpw* ydata) - * \brief This function tests if two multi-precision integers of the same size - * differ. - * \param size The size of the multi-precision integers. - * \param xdata The first multi-precision integer. - * \param ydata The second multi-precision integer. - * \retval 1 if not equal - * \retval 0 if equal - */ -BEECRYPTAPI -int mpne (size_t size, const mpw* xdata, const mpw* ydata) - /*@*/; - -/*!\fn int mpgt(size_t size, const mpw* xdata, const mpw* ydata) - * \brief This function tests if the first of two multi-precision integers - * of the same size is greater than the second. - * \note The comparison treats the arguments as unsigned. - * \param size The size of the multi-precision integers. - * \param xdata The first multi-precision integer. - * \param ydata The second multi-precision integer. - * \retval 1 if greater - * \retval 0 if less or equal - */ -BEECRYPTAPI -int mpgt (size_t size, const mpw* xdata, const mpw* ydata) - /*@*/; - -/*!\fn int mplt(size_t size, const mpw* xdata, const mpw* ydata) - * \brief This function tests if the first of two multi-precision integers - * of the same size is less than the second. - * \note The comparison treats the arguments as unsigned. - * \param size The size of the multi-precision integers. - * \param xdata The first multi-precision integer. - * \param ydata The second multi-precision integer. - * \retval 1 if less - * \retval 0 if greater or equal - */ -BEECRYPTAPI -int mplt (size_t size, const mpw* xdata, const mpw* ydata) - /*@*/; - -/*!\fn int mpge(size_t size, const mpw* xdata, const mpw* ydata) - * \brief This function tests if the first of two multi-precision integers - * of the same size is greater than or equal to the second. - * \note The comparison treats the arguments as unsigned. - * \param size The size of the multi-precision integers. - * \param xdata The first multi-precision integer. - * \param ydata The second multi-precision integer. - * \retval 1 if greater or equal - * \retval 0 if less - */ -BEECRYPTAPI -int mpge (size_t size, const mpw* xdata, const mpw* ydata) - /*@*/; - -/*!\fn int mple(size_t size, const mpw* xdata, const mpw* ydata) - * \brief This function tests if the first of two multi-precision integers - * of the same size is less than or equal to the second. - * \note The comparison treats the arguments as unsigned. - * \param size The size of the multi-precision integers. - * \param xdata The first multi-precision integer. - * \param ydata The second multi-precision integer. - * \retval 1 if less or equal - * \retval 0 if greater - */ -BEECRYPTAPI -int mple (size_t size, const mpw* xdata, const mpw* ydata) - /*@*/; - -/*!\fn int mpeqx(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata) - * \brief This function tests if two multi-precision integers of different - * size are equal. - * \param xsize The size of the first multi-precision integer. - * \param xdata The first multi-precision integer. - * \param ysize The size of the first multi-precision integer. - * \param ydata The second multi-precision integer. - * \retval 1 if equal - * \retval 0 if not equal - */ -BEECRYPTAPI -int mpeqx(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata) - /*@*/; - -/*!\fn int mpnex(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata) - * \brief This function tests if two multi-precision integers of different - * size are equal. - * \param xsize The size of the first multi-precision integer. - * \param xdata The first multi-precision integer. - * \param ysize The size of the first multi-precision integer. - * \param ydata The second multi-precision integer. - * \retval 1 if equal - * \retval 0 if not equal -*/ -BEECRYPTAPI -int mpnex(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata) - /*@*/; - -/*!\fn int mpgtx(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata) - * \brief This function tests if the first of two multi-precision integers - * of different size is greater than the second. - * \note The comparison treats the arguments as unsigned. - * \param xsize The size of the first multi-precision integer. - * \param xdata The first multi-precision integer. - * \param ysize The size of the second multi-precision integer. - * \param ydata The second multi-precision integer. - * \retval 1 if greater - * \retval 0 if less or equal - */ -BEECRYPTAPI -int mpgtx(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata) - /*@*/; - -/*!\fn int mpltx(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata) - * \brief This function tests if the first of two multi-precision integers - * of different size is less than the second. - * \note The comparison treats the arguments as unsigned. - * \param xsize The size of the first multi-precision integer. - * \param xdata The first multi-precision integer. - * \param ysize The size of the second multi-precision integer. - * \param ydata The second multi-precision integer. - * \retval 1 if less - * \retval 0 if greater or equal - */ -BEECRYPTAPI -int mpltx(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata) - /*@*/; - -/*!\fn int mpgex(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata) - * \brief This function tests if the first of two multi-precision integers - * of different size is greater than or equal to the second. - * \note The comparison treats the arguments as unsigned. - * \param xsize The size of the first multi-precision integer. - * \param xdata The first multi-precision integer. - * \param ysize The size of the second multi-precision integer. - * \param ydata The second multi-precision integer. - * \retval 1 if greater or equal - * \retval 0 if less - */ -BEECRYPTAPI -int mpgex(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata) - /*@*/; - -/*!\fn int mplex(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata) - * \brief This function tests if the first of two multi-precision integers - * of different size is less than or equal to the second. - * \note The comparison treats the arguments as unsigned. - * \param xsize The size of the first multi-precision integer. - * \param xdata The first multi-precision integer. - * \param ysize The size of the second multi-precision integer. - * \param ydata The second multi-precision integer. - * \retval 1 if less or equal - * \retval 0 if greater - */ -BEECRYPTAPI -int mplex(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata) - /*@*/; - -/*!\fn int mpisone(size_t size, const mpw* data) - * \brief This functions tests if the value of a multi-precision integer is - * equal to one. - * \param size The size of the multi-precision integer. - * \param data The multi-precision integer data. - * \retval 1 if one - * \retval 0 if not one - */ -BEECRYPTAPI -int mpisone(size_t size, const mpw* data) - /*@*/; - -/*!\fn int mpistwo(size_t size, const mpw* data) - * \brief This function tests if the value of a multi-precision integer is - * equal to two. - * \param size The size of the multi-precision integer. - * \param data The multi-precision integer data. - * \retval 1 if two - * \retval 0 if not two - */ -BEECRYPTAPI -int mpistwo(size_t size, const mpw* data) - /*@*/; - -/*!\fn int mpleone(size_t size, const mpw* data) - * \brief This function tests if the value of a multi-precision integer is - * less than or equal to one. - * \param size The size of the multi-precision integer. - * \param data The multi-precision integer data. - * \retval 1 if less than or equal to one. - * \retval 0 if greater than one. - */ -BEECRYPTAPI -int mpleone(size_t size, const mpw* data) - /*@*/; - -/*!\fn int mpeqmone(size_t size, const mpw* xdata, const mpw* ydata) - * \brief This function tests if multi-precision integer x is equal to y - * minus one. - * \param size The size of the multi-precision integers. - * \param xdata The first multi-precision integer. - * \param ydata The second multi-precision integer. - * \retval 1 if less than or equal to one. - * \retval 0 if greater than one. - */ -BEECRYPTAPI -int mpeqmone(size_t size, const mpw* xdata, const mpw* ydata) - /*@*/; - -/*!\fn int mpmsbset(size_t size, const mpw* data) - * \brief This function tests if the most significant bit of a multi-precision - * integer is set. - * \param size The size of the multi-precision integer. - * \param data The multi-precision integer data. - * \retval 1 if set - * \retval 0 if not set - */ -BEECRYPTAPI -int mpmsbset(size_t size, const mpw* data) - /*@*/; - -/*!\fn int mplsbset(size_t size, const mpw* data) - * \brief This function tests if the leiast significant bit of a multi-precision - * integer is set. - * \param size The size of the multi-precision integer. - * \param data The multi-precision integer data. - * \retval 1 if set - * \retval 0 if not set - */ -BEECRYPTAPI -int mplsbset(size_t size, const mpw* data) - /*@*/; - -/*!\fn void mpsetmsb(size_t size, mpw* data) - * \brief This function sets the most significant bit of a multi-precision - * integer. - * \param size The size of the multi-precision integer. - * \param data The multi-precision integer data. - */ -BEECRYPTAPI -void mpsetmsb(size_t size, mpw* data) - /*@modifies data */; - -/*!\fn void mpsetlsb(size_t size, mpw* data) - * \brief This function sets the least significant bit of a multi-precision - * integer. - * \param size The size of the multi-precision integer. - * \param data The multi-precision integer data. - */ -BEECRYPTAPI -void mpsetlsb(size_t size, mpw* data) - /*@modifies data */; - -/*!\fn void mpclrmsb(size_t size, mpw* data) - * \brief This function clears the most significant bit of a multi-precision - * integer. - * \param size The size of the multi-precision integer. - * \param data The multi-precision integer data. - */ -BEECRYPTAPI -void mpclrmsb(size_t size, mpw* data) - /*@modifies data */; - -/*!\fn void mpclrlsb(size_t size, mpw* data) - * \brief This function clears the least significant bit of a multi-precision - * integer. - * \param size The size of the multi-precision integer. - * \param data The multi-precision integer data. - */ -BEECRYPTAPI -void mpclrlsb(size_t size, mpw* data) - /*@modifies data */; - -/*!\fn mpand(size_t size, mpw* xdata, const mpw* ydata) - * \brief This function computes the bit-wise AND of two multi-precision - * integers. Modifies xdata. - * \param size The size of the multi-precision integers. - * \param xdata The multi-precision integer data. - * \param ydata The multi-precision integer data. - */ -BEECRYPTAPI -void mpand(size_t size, mpw* xdata, const mpw* ydata) - /*@modifies xdata @*/; - -/*!\fn void mpor(size_t size, mpw* xdata, const mpw* ydata) - * \brief This function computes the bit-wise OR of two multi-precision - * integers. Modifies xdata. - * \param size The size of the multi-precision integer. - * \param xdata The multi-precision integer data. - * \param ydata The multi-precision integer data. - */ -BEECRYPTAPI -void mpor(size_t size, mpw* xdata, const mpw* ydata) - /*@modifies xdata @*/; - -/*!\fn void mpxor(size_t size, mpw* xdata, const mpw* ydata) - * \brief This function computes the bit-wise XOR of two multi-precision - * integers. Modifies xdata. - * \param size The size of the multi-precision integer. - * \param xdata The multi-precision integer data. - * \param ydata The multi-precision integer data. - */ -BEECRYPTAPI -void mpxor(size_t size, mpw* xdata, const mpw* ydata) - /*@modifies xdata @*/; - -/*!\fn mpnot(size_t size, mpw* data) - * \brief This function flips all bits of a multi-precision integer. - * \param size The size of the multi-precision integer. - * \param data The multi-precision integer data. - */ -BEECRYPTAPI -void mpnot(size_t size, mpw* data) - /*@modifies data @*/; - -/*!\fn void mpsetw(size_t size, mpw* xdata, mpw y) - * \brief This function sets the value of a multi-precision integer to the - * given word. The given value is copied into the least significant word, - * while the most significant words are zeroed. - * \param size The size of the multi-precision integer. - * \param xdata The first multi-precision integer. - * \param y The multi-precision word. - */ -BEECRYPTAPI -void mpsetw(size_t size, mpw* xdata, mpw y) - /*@modifies xdata @*/; - -/*!\fn void mpsetx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata) - * \brief This function set the value of the first multi-precision integer - * to the second, truncating the most significant words if ysize > xsize, or - * zeroing the most significant words if ysize < xsize. - * \param xsize The size of the first multi-precision integer. - * \param xdata The first multi-precision integer. - * \param ysize The size of the second multi-precision integer. - * \param ydata The second multi-precision integer. - */ -void mpsetx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata) - /*@modifies xdata @*/; - -/*!\fn int mpaddw(size_t size, mpw* xdata, mpw y) - * \brief This function adds one word to a multi-precision integer. - * The performed operation is in pseudocode: x += y. - * \param size The size of the multi-precision integer. - * \param xdata The first multi-precision integer. - * \param y The multi-precision word. - * \return The carry-over value of the operation; this value is either 0 or 1. - */ -BEECRYPTAPI -int mpaddw(size_t size, mpw* xdata, mpw y) - /*@modifies xdata @*/; - -/*!\fn int mpadd(size_t size, mpw* xdata, const mpw* ydata) - * \brief This function adds two multi-precision integers of equal size. - * The performed operation is in pseudocode: x += y. - * \param size The size of the multi-precision integers. - * \param xdata The first multi-precision integer. - * \param ydata The second multi-precision integer. - * \return The carry-over value of the operation; this value is either 0 or 1. - */ -BEECRYPTAPI -int mpadd (size_t size, mpw* xdata, const mpw* ydata) - /*@modifies xdata @*/; - -/*!\fn int mpaddx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata) - * \brief This function adds two multi-precision integers of different size. - * The performed operation in pseudocode: x += y. - * \param xsize The size of the first multi-precision integer. - * \param xdata The first multi-precision integer. - * \param ysize The size of the second multi-precision integer. - * \param ydata The second multi-precision integer. - * \return The carry-over value of the operation; this value is either 0 or 1. - */ -BEECRYPTAPI -int mpaddx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata) - /*@modifies xdata @*/; - -/*!\fn int mpsubw(size_t size, mpw* xdata, mpw y) - * \brief This function subtracts one word to a multi-precision integer. - * The performed operation in pseudocode: x -= y - * \param size The size of the multi-precision integers. - * \param xdata The first multi-precision integer. - * \param y The multi-precision word. - * \return The carry-over value of the operation; this value is either 0 or 1. - */ -BEECRYPTAPI -int mpsubw(size_t size, mpw* xdata, mpw y) - /*@modifies xdata @*/; - -/*!\fn int mpsub(size_t size, mpw* xdata, const mpw* ydata) - * \brief This function subtracts two multi-precision integers of equal size. - * The performed operation in pseudocode: x -= y - * \param size The size of the multi-precision integers. - * \param xdata The first multi-precision integer. - * \param ydata The second multi-precision integer. - * \return The carry-over value of the operation; this value is either 0 or 1. - */ -BEECRYPTAPI -int mpsub (size_t size, mpw* xdata, const mpw* ydata) - /*@modifies xdata @*/; - -/*!\fn int mpsubx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata) - * \brief This function subtracts two multi-precision integers of different - * size. The performed operation in pseudocode: x -= y. - * \param xsize The size of the first multi-precision integer. - * \param xdata The first multi-precision integer. - * \param ysize The size of the second multi-precision integer. - * \param ydata The second multi-precision integer. - * \return The carry-over value of the operation; this value is either 0 or 1. - */ -BEECRYPTAPI -int mpsubx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata) - /*@modifies xdata @*/; - -BEECRYPTAPI -int mpmultwo(size_t size, mpw* data) - /*@modifies data @*/; - -/*!\fn void mpneg(size_t size, mpw* data) - * \brief This function negates a multi-precision integer. - * \param size The size of the multi-precision integer. - * \param data The multi-precision integer data. - */ -BEECRYPTAPI -void mpneg(size_t size, mpw* data) - /*@modifies data @*/; - -/*!\fn size_t mpsize(size_t size, const mpw* data) - * \brief This function returns the true size of a multi-precision - * integer, after stripping leading zero words. - * \param size The size of the multi-precision integer. - * \param data The multi-precision integer data. - */ -BEECRYPTAPI -size_t mpsize(size_t size, const mpw* data) - /*@*/; - -/*!\fn size_t mpbits(size_t size, const mpw* data) - * \brief This function returns the number of significant bits - * in a multi-precision integer. - * \param size The size of the multi-precision integer. - * \param data The multi-precision integer data. - */ -BEECRYPTAPI -size_t mpbits(size_t size, const mpw* data) - /*@*/; - -BEECRYPTAPI -size_t mpmszcnt(size_t size, const mpw* data) - /*@*/; - -BEECRYPTAPI -size_t mplszcnt(size_t size, const mpw* data) - /*@*/; - -BEECRYPTAPI -void mplshift(size_t size, mpw* data, size_t count) - /*@modifies data @*/; - -BEECRYPTAPI -void mprshift(size_t size, mpw* data, size_t count) - /*@modifies data @*/; - -BEECRYPTAPI -size_t mprshiftlsz(size_t size, mpw* data) - /*@modifies data @*/; - -BEECRYPTAPI -size_t mpnorm(size_t size, mpw* data) - /*@modifies data @*/; - -BEECRYPTAPI -void mpdivtwo (size_t size, mpw* data) - /*@modifies data @*/; - -BEECRYPTAPI -void mpsdivtwo(size_t size, mpw* data) - /*@modifies data @*/; - -/*!\fn mpw mpsetmul(size_t size, mpw* result, const mpw* data, mpw y) - * \brief This function performs a multi-precision multiply-setup. - * - * This function is used in the computation of a full multi-precision - * multiplication. By using it we can shave off a few cycles; otherwise we'd - * have to zero the least significant half of the result first and use - * another call to the slightly slower mpaddmul function. - * - * \param size The size of multi-precision integer multiplier. - * \param result The place where result will be accumulated. - * \param data The multi-precision integer multiplier. - * \param y The multiplicand. - * \return The carry-over multi-precision word. - */ -BEECRYPTAPI -mpw mpsetmul (size_t size, mpw* result, const mpw* data, mpw y) - /*@modifies result @*/; - -/*!\fn mpw mpaddmul(size_t size, mpw* result, const mpw* data, mpw y) - * \brief This function performs a mult-precision multiply-accumulate. - * - * This function is used in the computation of a full multi-precision - * multiplication. It computes the product-by-one-word and accumulates it with - * the previous result. - * - * \param size The size of multi-precision integer multiplier. - * \param result The place where result will be accumulated. - * \param data The multi-precision integer multiplier. - * \param y The multiplicand. - * \retval The carry-over multi-precision word. - */ -BEECRYPTAPI -mpw mpaddmul (size_t size, mpw* result, const mpw* data, mpw y) - /*@modifies result @*/; - -/*!\fn void mpaddsqrtrc(size_t size, mpw* result, const mpw* data) - * \brief This function is used in the calculation of a multi-precision - * squaring. - */ -BEECRYPTAPI -void mpaddsqrtrc(size_t size, mpw* result, const mpw* data) - /*@modifies result @*/; - -/*!\fn void mpmul(mpw* result, size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata) - * \brief This function computes a full multi-precision product. - */ -BEECRYPTAPI -void mpmul(mpw* result, size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata) - /*@modifies result @*/; - -/*!\fn void mpsqr(mpw* result, size_t size, const mpw* data) - * \brief This function computes a full multi-precision square. - */ -BEECRYPTAPI -void mpsqr(mpw* result, size_t size, const mpw* data) - /*@modifies result @*/; - -BEECRYPTAPI -void mpgcd_w(size_t size, const mpw* xdata, const mpw* ydata, mpw* result, mpw* wksp) - /*@modifies result, wksp @*/; - -BEECRYPTAPI -int mpextgcd_w(size_t size, const mpw* xdata, const mpw* ydata, mpw* result, mpw* wksp) - /*@modifies result, wksp @*/; - -BEECRYPTAPI -mpw mppndiv(mpw xhi, mpw xlo, mpw y) - /*@*/; - -BEECRYPTAPI -void mpmod (mpw* result, size_t xsize, const mpw* xdata, size_t ysize, const mpw*ydata, mpw* workspace) - /*@modifies result, workspace @*/; - -BEECRYPTAPI -void mpndivmod(mpw* result, size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata, mpw* workspace) - /*@modifies result, workspace @*/; - -/* - * Output Routines - */ - -BEECRYPTAPI -void mpprint(size_t size, const mpw* data) - /*@*/; - -BEECRYPTAPI -void mpprintln(size_t size, const mpw* data) - /*@*/; - -BEECRYPTAPI -void mpfprint(FILE* f, size_t size, const mpw* data) - /*@modifies f @*/; - -BEECRYPTAPI -void mpfprintln(FILE* f, size_t size, const mpw* data) - /*@modifies f @*/; - -/* - * Conversion Routines - */ - -BEECRYPTAPI -int os2ip(mpw* idata, size_t isize, const byte* osdata, size_t ossize) - /*@modifies idata @*/; - -BEECRYPTAPI -int i2osp(byte* osdata, size_t ossize, const mpw* idata, size_t isize) - /*@modifies osdata @*/; - -BEECRYPTAPI -int hs2ip(mpw* idata, size_t isize, const char* hsdata, size_t hssize) - /*@modifies idata @*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/mpbarrett.c b/beecrypt/mpbarrett.c deleted file mode 100644 index c025488e1..000000000 --- a/beecrypt/mpbarrett.c +++ /dev/null @@ -1,862 +0,0 @@ -/* - * Copyright (c) 1997, 1998, 1999, 2000, 2001 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file mpbarrett.c - * \brief Multi-precision integer routines using Barrett modular reduction. - * For more information on this algorithm, see: - * "Handbook of Applied Cryptography", Chapter 14.3.3 - * Menezes, van Oorschot, Vanstone - * CRC Press - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup MP__m - */ - -#include "system.h" - -#include "beecrypt.h" -#include "mp.h" -#include "mpprime.h" -#include "mpnumber.h" -#include "mpbarrett.h" - -#include "debug.h" - -/* - * mpbzero - */ -void mpbzero(mpbarrett* b) -{ - b->size = 0; - b->modl = b->mu = (mpw*) 0; -} - -/* - * mpbinit - * \brief allocates the data words for an mpbarrett structure - * will allocate 2*size+1 words - */ -void mpbinit(mpbarrett* b, size_t size) -{ - b->size = size; - b->modl = (mpw*) calloc(2*size+1, sizeof(mpw)); - - if (b->modl != (mpw*) 0) - b->mu = b->modl+size; - else - b->mu = (mpw*) 0; -} - -/* - * mpbfree - */ -void mpbfree(mpbarrett* b) -{ - if (b->modl != (mpw*) 0) - { - free(b->modl); - b->modl = b->mu = (mpw*) 0; - } - b->size = 0; -} - -void mpbcopy(mpbarrett* b, const mpbarrett* copy) -{ - register size_t size = copy->size; - - if (size) - { - if (b->modl) - { - if (b->size != size) - b->modl = (mpw*) realloc(b->modl, (2*size+1) * sizeof(mpw)); - } - else - b->modl = (mpw*) malloc((2*size+1) * sizeof(mpw)); - - if (b->modl) - { - b->size = size; - b->mu = b->modl+copy->size; - mpcopy(2*size+1, b->modl, copy->modl); - } - else - { - b->size = 0; - b->mu = (mpw*) 0; - } - } - else if (b->modl) - { - free(b->modl); - b->size = 0; - b->modl = b->mu = (mpw*) 0; - } -} - -void mpbwipe(mpbarrett* b) -{ - if (b->modl != (mpw*) 0) - mpzero(2*(b->size)+1, b->modl); -} - -/* - * mpbset - */ -void mpbset(mpbarrett* b, size_t size, const mpw *data) -{ - if (size > 0) - { - if (b->modl) - { - if (b->size != size) - b->modl = (mpw*) realloc(b->modl, (2*size+1) * sizeof(mpw)); - } - else - b->modl = (mpw*) malloc((2*size+1) * sizeof(mpw)); - - if (b->modl) - { - mpw* temp = (mpw*) malloc((6*size+4) * sizeof(mpw)); - - b->size = size; - b->mu = b->modl+size; - mpcopy(size, b->modl, data); - mpbmu_w(b, temp); - - free(temp); - } - else - { - b->size = 0; - b->mu = (mpw*) 0; - } - } -} - -int mpbsetbin(mpbarrett* b, const byte* osdata, size_t ossize) -{ - int rc = -1; - size_t size; - - /* skip zero bytes */ - while (!(*osdata) && ossize) - { - osdata++; - ossize--; - } - - size = MP_BYTES_TO_WORDS(ossize + MP_WBYTES - 1); - - if (b->modl) - { - if (b->size != size) - b->modl = (mpw*) realloc(b->modl, (2*size+1) * sizeof(mpw)); - } - else - b->modl = (mpw*) malloc((2*size+1) * sizeof(mpw)); - - if (b->modl) - { - register mpw* temp = (mpw*) malloc((6*size+4) * sizeof(mpw)); - - b->size = size; - b->mu = b->modl+size; - - rc = os2ip(b->modl, size, osdata, ossize); - - mpbmu_w(b, temp); - - free(temp); - } - - return rc; -} - -int mpbsethex(mpbarrett* b, const char* hex) -{ - int rc = -1; - size_t len = strlen(hex); - size_t size = MP_NIBBLES_TO_WORDS(len + MP_WNIBBLES - 1); - - if (b->modl) - { - if (b->size != size) - b->modl = (mpw*) realloc(b->modl, (2*size+1) * sizeof(mpw)); - } - else - b->modl = (mpw*) malloc((2*size+1) * sizeof(mpw)); - - if (b->modl) - { - register mpw* temp = (mpw*) malloc((6*size+4) * sizeof(mpw)); - - b->size = size; - b->mu = b->modl+size; - - rc = hs2ip(b->modl, size, hex, len); - - mpbmu_w(b, temp); - - free(temp); - } - else - { - b->size = 0; - b->mu = 0; - } - - return rc; -} - -/* - * mpbmu_w - * computes the Barrett 'mu' coefficient - * needs workspace of (6*size+4) words - */ -void mpbmu_w(mpbarrett* b, mpw* wksp) -{ - register size_t size = b->size; - register size_t shift; - register mpw* divmod = wksp; - register mpw* dividend = divmod+(size*2+2); - register mpw* workspace = dividend+(size*2+1); - - /* normalize modulus before division */ - shift = mpnorm(size, b->modl); - /* make the dividend, initialize first word to 1 (shifted); the rest is zero */ - *dividend = ((mpw) MP_LSBMASK << shift); - mpzero(size*2, dividend+1); - mpndivmod(divmod, size*2+1, dividend, size, b->modl, workspace); - mpcopy(size+1, b->mu, divmod+1); - /* de-normalize */ - mprshift(size, b->modl, shift); -} - -/* - * mpbrnd_w - * generates a random number in the range 1 < r < b-1 - * need workspace of (size) words - */ -void mpbrnd_w(const mpbarrett* b, randomGeneratorContext* rc, mpw* result, mpw* wksp) -{ - size_t msz = mpmszcnt(b->size, b->modl); - - mpcopy(b->size, wksp, b->modl); - mpsubw(b->size, wksp, 1); - - do - { - rc->rng->next(rc->param, (byte*) result, MP_WORDS_TO_BYTES(b->size)); - - result[0] &= (MP_ALLMASK >> msz); - - while (mpge(b->size, result, wksp)) - mpsub(b->size, result, wksp); - } while (mpleone(b->size, result)); -} - -/* - * mpbrndodd_w - * generates a random odd number in the range 1 < r < b-1 - * needs workspace of (size) words - */ -void mpbrndodd_w(const mpbarrett* b, randomGeneratorContext* rc, mpw* result, mpw* wksp) -{ - size_t msz = mpmszcnt(b->size, b->modl); - - mpcopy(b->size, wksp, b->modl); - mpsubw(b->size, wksp, 1); - - do - { - rc->rng->next(rc->param, (byte*) result, MP_WORDS_TO_BYTES(b->size)); - - result[0] &= (MP_ALLMASK >> msz); - mpsetlsb(b->size, result); - - while (mpge(b->size, result, wksp)) - { - mpsub(b->size, result, wksp); - mpsetlsb(b->size, result); - } - } while (mpleone(b->size, result)); -} - -/* - * mpbrndinv_w - * generates a random invertible (modulo b) in the range 1 < r < b-1 - * needs workspace of (6*size+6) words - */ -void mpbrndinv_w(const mpbarrett* b, randomGeneratorContext* rc, mpw* result, mpw* inverse, mpw* wksp) -{ - register size_t size = b->size; - - do - { - if (mpeven(size, b->modl)) - mpbrndodd_w(b, rc, result, wksp); - else - mpbrnd_w(b, rc, result, wksp); - - } while (mpextgcd_w(size, b->modl, result, inverse, wksp) == 0); -} - -/* - * mpbmod_w - * computes the barrett modular reduction of a number x, which has twice the size of b - * needs workspace of (2*size+2) words - */ -void mpbmod_w(const mpbarrett* b, const mpw* data, mpw* result, mpw* wksp) -{ - register mpw rc; - register size_t sp = 2; - register const mpw* src = data+b->size+1; - register mpw* dst = wksp+b->size+1; - - rc = mpsetmul(sp, dst, b->mu, *(--src)); - *(--dst) = rc; - - while (sp <= b->size) - { - sp++; - if ((rc = *(--src))) - { - rc = mpaddmul(sp, dst, b->mu, rc); - *(--dst) = rc; - } - else - *(--dst) = 0; - } - if ((rc = *(--src))) - { - rc = mpaddmul(sp, dst, b->mu, rc); - *(--dst) = rc; - } - else - *(--dst) = 0; - - sp = b->size; - rc = 0; - - dst = wksp+b->size+1; - src = dst; - - *dst = mpsetmul(sp, dst+1, b->modl, *(--src)); - - while (sp > 0) - mpaddmul(sp--, dst, b->modl+(rc++), *(--src)); - - mpsetx(b->size+1, wksp, b->size*2, data); - mpsub(b->size+1, wksp, wksp+b->size+1); - - while (mpgex(b->size+1, wksp, b->size, b->modl)) - mpsubx(b->size+1, wksp, b->size, b->modl); - - mpcopy(b->size, result, wksp+1); -} - -/* - * mpbsubone - * copies (b-1) into result - */ -void mpbsubone(const mpbarrett* b, mpw* result) -{ - register size_t size = b->size; - - mpcopy(size, result, b->modl); - mpsubw(size, result, 1); -} - -/* - * mpbneg - * computes the negative (modulo b) of x, where x must contain a value between 0 and b-1 - */ -void mpbneg(const mpbarrett* b, const mpw* data, mpw* result) - /*@modifies result @*/ -{ - register size_t size = b->size; - - mpcopy(size, result, data); - mpneg(size, result); - mpadd(size, result, b->modl); -} - -/* - * mpbaddmod_w - * computes the sum (modulo b) of x and y - * needs a workspace of (4*size+2) words - */ -void mpbaddmod_w(const mpbarrett* b, size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata, mpw* result, mpw* wksp) -{ - /* xsize and ysize must be less than or equal to b->size */ - register size_t size = b->size; - register mpw* temp = wksp + size*2+2; - - mpsetx(2*size, temp, xsize, xdata); - mpaddx(2*size, temp, ysize, ydata); - - mpbmod_w(b, temp, result, wksp); -} - -/* - * mpbsubmod_w - * computes the difference (modulo b) of x and y - * needs a workspace of (4*size+2) words - */ -void mpbsubmod_w(const mpbarrett* b, size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata, mpw* result, mpw* wksp) -{ - /* xsize and ysize must be less than or equal to b->size */ - register size_t size = b->size; - register mpw* temp = wksp + size*2+2; - - mpsetx(2*size, temp, xsize, xdata); - if (mpsubx(2*size, temp, ysize, ydata)) /* if there's carry, i.e. the result would be negative, add the modulus */ - mpaddx(2*size, temp, size, b->modl); - - mpbmod_w(b, temp, result, wksp); -} - -/* - * mpmulmod_w - * computes the product (modulo b) of x and y - * needs a workspace of (4*size+2) words - */ -void mpbmulmod_w(const mpbarrett* b, size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata, mpw* result, mpw* wksp) -{ - /* xsize and ysize must be <= b->size */ - register size_t size = b->size; - register mpw* temp = wksp + size*2+2; - register mpw fill = size*2-xsize-ysize; - - if (fill) - mpzero(fill, temp); - - mpmul(temp+fill, xsize, xdata, ysize, ydata); - mpbmod_w(b, temp, result, wksp); -} - -/* - * mpbsqrmod_w - * computes the square (modulo b) of x - * needs a workspace of (4*size+2) words - */ -void mpbsqrmod_w(const mpbarrett* b, size_t xsize, const mpw* xdata, mpw* result, mpw* wksp) -{ - /* xsize must be <= b->size */ - register size_t size = b->size; - register mpw* temp = wksp + size*2+2; - register mpw fill = 2*(size-xsize); - - if (fill) - mpzero(fill, temp); - - mpsqr(temp+fill, xsize, xdata); - mpbmod_w(b, temp, result, wksp); -} - -/* - * Sliding Window Exponentiation technique, slightly altered from the method Applied Cryptography: - * - * First of all, the table with the powers of g can be reduced by about half; the even powers don't - * need to be accessed or stored. - * - * Get up to K bits starting with a one, if we have that many still available - * - * Do the number of squarings of A in the first column, the multiply by the value in column two, - * and finally do the number of squarings in column three. - * - * This table can be used for K=2,3,4 and can be extended - * - * 0 : - | - | - - * 1 : 1 | g1 @ 0 | 0 - * 10 : 1 | g1 @ 0 | 1 - * 11 : 2 | g3 @ 1 | 0 - * 100 : 1 | g1 @ 0 | 2 - * 101 : 3 | g5 @ 2 | 0 - * 110 : 2 | g3 @ 1 | 1 - * 111 : 3 | g7 @ 3 | 0 - * 1000 : 1 | g1 @ 0 | 3 - * 1001 : 4 | g9 @ 4 | 0 - * 1010 : 3 | g5 @ 2 | 1 - * 1011 : 4 | g11 @ 5 | 0 - * 1100 : 2 | g3 @ 1 | 2 - * 1101 : 4 | g13 @ 6 | 0 - * 1110 : 3 | g7 @ 3 | 1 - * 1111 : 4 | g15 @ 7 | 0 - * - */ - -/* - * mpbslide_w - * precomputes the sliding window table for computing powers of x modulo b - * needs workspace (4*size+2) - */ -void mpbslide_w(const mpbarrett* b, size_t xsize, const mpw* xdata, mpw* slide, mpw* wksp) - /*@modifies slide, wksp @*/ -{ - register size_t size = b->size; - mpbsqrmod_w(b, xsize, xdata, slide , wksp); /* x^2 mod b, temp */ - mpbmulmod_w(b, xsize, xdata, size, slide , slide+size , wksp); /* x^3 mod b */ - mpbmulmod_w(b, size, slide, size, slide+size , slide+2*size, wksp); /* x^5 mod b */ - mpbmulmod_w(b, size, slide, size, slide+2*size, slide+3*size, wksp); /* x^7 mod b */ - mpbmulmod_w(b, size, slide, size, slide+3*size, slide+4*size, wksp); /* x^9 mod b */ - mpbmulmod_w(b, size, slide, size, slide+4*size, slide+5*size, wksp); /* x^11 mod b */ - mpbmulmod_w(b, size, slide, size, slide+5*size, slide+6*size, wksp); /* x^13 mod b */ - mpbmulmod_w(b, size, slide, size, slide+6*size, slide+7*size, wksp); /* x^15 mod b */ - mpsetx(size, slide, xsize, xdata); /* x^1 mod b */ -} - -static byte mpbslide_presq[16] = -{ 0, 1, 1, 2, 1, 3, 2, 3, 1, 4, 3, 4, 2, 4, 3, 4 }; - -static byte mpbslide_mulg[16] = -{ 0, 0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7 }; - -static byte mpbslide_postsq[16] = -{ 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 }; - -/* - * needs workspace of 4*size+2 words - */ -void mpbpowmod_w(const mpbarrett* b, size_t xsize, const mpw* xdata, size_t psize, const mpw* pdata, mpw* result, mpw* wksp) -{ - /* - * Modular exponention - * - * Uses sliding window exponentiation; needs extra storage: if K=3, needs 8*size, if K=4, needs 16*size - * - */ - - /* K == 4 for the first try */ - - size_t size = b->size; - mpw temp; - - while (psize) - { - if ((temp = *(pdata++))) /* break when first non-zero word found */ - break; - psize--; - } - - /* if temp is still zero, then we're trying to raise x to power zero, and result stays one */ - if (temp) - { - mpw* slide = (mpw*) malloc((8*size)*sizeof(mpw)); - - mpbslide_w(b, xsize, xdata, slide, wksp); - - mpbpowmodsld_w(b, slide, psize, pdata-1, result, wksp); - - free(slide); - } -} - -void mpbpowmodsld_w(const mpbarrett* b, const mpw* slide, size_t psize, const mpw* pdata, mpw* result, mpw* wksp) -{ - /* - * Modular exponentiation with precomputed sliding window table, so no x is required - * - */ - - size_t size = b->size; - mpw temp; - - mpsetw(size, result, 1); - - while (psize) - { - if ((temp = *(pdata++))) /* break when first non-zero word found in power */ - break; - psize--; - } - - /* if temp is still zero, then we're trying to raise x to power zero, and result stays one */ - if (temp) - { - short l = 0, n = 0, count = MP_WBITS; - - /* first skip bits until we reach a one */ - while (count) - { - if (temp & MP_MSBMASK) - break; - temp <<= 1; - count--; - } - - while (psize) - { - while (count) - { - byte bit = (temp & MP_MSBMASK) ? 1 : 0; - - n <<= 1; - n += bit; - - if (n) - { - if (l) - l++; - else if (bit) - l = 1; - - if (l == 4) - { - byte s = mpbslide_presq[n]; - - while (s--) - mpbsqrmod_w(b, size, result, result, wksp); - - mpbmulmod_w(b, size, result, size, slide+mpbslide_mulg[n]*size, result, wksp); - - s = mpbslide_postsq[n]; - - while (s--) - mpbsqrmod_w(b, size, result, result, wksp); - - l = n = 0; - } - } - else - mpbsqrmod_w(b, size, result, result, wksp); - - temp <<= 1; - count--; - } - if (--psize) - { - count = MP_WBITS; - temp = *(pdata++); - } - } - - if (n) - { - byte s = mpbslide_presq[n]; - - while (s--) - mpbsqrmod_w(b, size, result, result, wksp); - - mpbmulmod_w(b, size, result, size, slide+mpbslide_mulg[n]*size, result, wksp); - - s = mpbslide_postsq[n]; - - while (s--) - mpbsqrmod_w(b, size, result, result, wksp); - } - } -} - -/* - * mpbtwopowmod_w - * needs workspace of (4*size+2) words - */ -void mpbtwopowmod_w(const mpbarrett* b, size_t psize, const mpw* pdata, mpw* result, mpw* wksp) -{ - /* - * Modular exponention, 2^p mod modulus, special optimization - * - * Uses left-to-right exponentiation; needs no extra storage - * - */ - - /* this routine calls mpbmod, which needs (size*2+2), this routine needs (size*2) for sdata */ - - register size_t size = b->size; - register mpw temp = 0; - - mpsetw(size, result, 1); - - while (psize) - { - if ((temp = *(pdata++))) /* break when first non-zero word found */ - break; - psize--; - } - - /* if temp is still zero, then we're trying to raise x to power zero, and result stays one */ - if (temp) - { - register int count = MP_WBITS; - - /* first skip bits until we reach a one */ - while (count) - { - if (temp & MP_MSBMASK) - break; - temp <<= 1; - count--; - } - - while (psize--) - { - while (count) - { - /* always square */ - mpbsqrmod_w(b, size, result, result, wksp); - - /* multiply by two if bit is 1 */ - if (temp & MP_MSBMASK) - { - if (mpadd(size, result, result) || mpge(size, result, b->modl)) - { - /* there was carry, or the result is greater than the modulus, so we need to adjust */ - mpsub(size, result, b->modl); - } - } - - temp <<= 1; - count--; - } - count = MP_WBITS; - temp = *(pdata++); - } - } -} - -/* - * needs workspace of (7*size+2) words - */ -int mpbpprime_w(const mpbarrett* b, randomGeneratorContext* r, int t, mpw* wksp) -{ - /* - * This test works for candidate probable primes >= 3, which are also not small primes. - * - * It assumes that b->modl contains the candidate prime - * - */ - - size_t size = b->size; - - /* first test if modl is odd */ - - if (mpodd(b->size, b->modl)) - { - /* - * Small prime factor test: - * - * Tables in mpspprod contain multi-precision integers with products of small primes - * If the greatest common divisor of this product and the candidate is not one, then - * the candidate has small prime factors, or is a small prime. Neither is acceptable when - * we are looking for large probable primes =) - * - */ - - if (size > SMALL_PRIMES_PRODUCT_MAX) - { - mpsetx(size, wksp+size, SMALL_PRIMES_PRODUCT_MAX, mpspprod[SMALL_PRIMES_PRODUCT_MAX-1]); - mpgcd_w(size, b->modl, wksp+size, wksp, wksp+2*size); - } - else - { - mpgcd_w(size, b->modl, mpspprod[size-1], wksp, wksp+2*size); - } - - if (mpisone(size, wksp)) - { - return mppmilrab_w(b, r, t, wksp); - } - } - - return 0; -} - -void mpbnrnd(const mpbarrett* b, randomGeneratorContext* rc, mpnumber* result) -{ - register size_t size = b->size; - register mpw* temp = (mpw*) malloc(size * sizeof(mpw)); - - mpnfree(result); - mpnsize(result, size); - mpbrnd_w(b, rc, result->data, temp); - - free(temp); -} - -void mpbnmulmod(const mpbarrett* b, const mpnumber* x, const mpnumber* y, mpnumber* result) -{ - register size_t size = b->size; - register mpw* temp = (mpw*) malloc((4*size+2) * sizeof(mpw)); - - /* xsize and ysize must be <= b->size */ - register size_t fill = 2*size-x->size-y->size; - register mpw* opnd = temp+size*2+2; - - mpnfree(result); - mpnsize(result, size); - - if (fill) - mpzero(fill, opnd); - - mpmul(opnd+fill, x->size, x->data, y->size, y->data); - mpbmod_w(b, opnd, result->data, temp); - - free(temp); -} - -void mpbnsqrmod(const mpbarrett* b, const mpnumber* x, mpnumber* result) -{ - register size_t size = b->size; - register mpw* temp = (mpw*) malloc(size * sizeof(mpw)); - - /* xsize must be <= b->size */ - register size_t fill = 2*(size-x->size); - register mpw* opnd = temp + size*2+2; - - if (fill) - mpzero(fill, opnd); - - mpsqr(opnd+fill, x->size, x->data); - mpnsize(result, size); - mpbmod_w(b, opnd, result->data, temp); - - free(temp); -} - -void mpbnpowmod(const mpbarrett* b, const mpnumber* x, const mpnumber* pow, mpnumber* y) -{ - register size_t size = b->size; - register mpw* temp = (mpw*) malloc((4*size+2) * sizeof(mpw)); - - mpnfree(y); - mpnsize(y, size); - - mpbpowmod_w(b, x->size, x->data, pow->size, pow->data, y->data, temp); - - free(temp); -} - -void mpbnpowmodsld(const mpbarrett* b, const mpw* slide, const mpnumber* pow, mpnumber* y) -{ - register size_t size = b->size; - register mpw* temp = (mpw*) malloc((4*size+2) * sizeof(mpw)); - - mpnfree(y); - mpnsize(y, size); - - mpbpowmodsld_w(b, slide, pow->size, pow->data, y->data, temp); - - free(temp); -} - -size_t mpbbits(const mpbarrett* b) -{ - return mpbits(b->size, b->modl); -} diff --git a/beecrypt/mpbarrett.h b/beecrypt/mpbarrett.h deleted file mode 100644 index f3cd2c9db..000000000 --- a/beecrypt/mpbarrett.h +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright (c) 2003 Bob Deblier - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file mpbarrett.h - * \brief Multi-precision integer routines using Barrett modular reduction, headers. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup MP_m - */ - -#ifndef _MPBARRETT_H -#define _MPBARRETT_H - -#include "beecrypt.h" -#include "mpnumber.h" - -#ifdef __cplusplus -# include <iostream> -#endif - -#ifdef __cplusplus -struct BEECRYPTAPI mpbarrett -#else -struct _mpbarrett -#endif -{ - size_t size; -/*@relnull@*/ - mpw* modl; /* (size) words */ -/*@relnull@*/ - mpw* mu; /* (size+1) words */ - -#ifdef __cplusplus - mpbarrett(); - mpbarrett(const mpbarrett&); - ~mpbarrett(); - - const mpbarrett& operator=(const mpbarrett&); - bool operator==(const mpbarrett&); - bool operator!=(const mpbarrett&); - - void wipe(); - size_t bitlength() const; -#endif -}; - -#ifndef __cplusplus -typedef struct _mpbarrett mpbarrett; -#else -BEECRYPTAPI -std::ostream& operator<<(std::ostream&, const mpbarrett&); -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -BEECRYPTAPI -void mpbzero(mpbarrett* b) - /*@modifies b @*/; -BEECRYPTAPI -void mpbinit(mpbarrett* b, size_t size) - /*@modifies b @*/; -BEECRYPTAPI -void mpbfree(mpbarrett* b) - /*@modifies b @*/; -BEECRYPTAPI -void mpbcopy(mpbarrett* b, const mpbarrett* copy) - /*@modifies b @*/; -BEECRYPTAPI -void mpbwipe(mpbarrett* b) - /*@modifies b @*/; - -BEECRYPTAPI -void mpbset(mpbarrett* b, size_t size, const mpw* data) - /*@modifies b @*/; - -BEECRYPTAPI -int mpbsetbin(mpbarrett* b, const byte* osdata, size_t ossize) - /*@modifies b @*/; -BEECRYPTAPI -int mpbsethex(mpbarrett* b, const char* hex) - /*@modifies b @*/; - -BEECRYPTAPI -void mpbsubone(const mpbarrett* b, mpw* result) - /*@modifies result @*/; - -BEECRYPTAPI -void mpbmu_w(mpbarrett* b, mpw* wksp) - /*@modifies b, wksp @*/; - -BEECRYPTAPI -void mpbrnd_w (const mpbarrett* b, randomGeneratorContext* rc, mpw* result, mpw* wksp) - /*@modifies result, wksp @*/; -BEECRYPTAPI -void mpbrndodd_w(const mpbarrett* b, randomGeneratorContext* rc, mpw* result, mpw* wksp) - /*@modifies result, wksp @*/; -BEECRYPTAPI -void mpbrndinv_w(const mpbarrett* b, randomGeneratorContext* rc, mpw* result, mpw* inverse, mpw* wksp) - /*@modifies result, inverse, wksp @*/; - -BEECRYPTAPI -void mpbneg_w(const mpbarrett* b, const mpw* data, mpw* result) - /*@modifies result @*/; -BEECRYPTAPI -void mpbmod_w(const mpbarrett* b, const mpw* data, mpw* result, mpw* wksp) - /*@modifies result, wksp @*/; - -BEECRYPTAPI -void mpbaddmod_w(const mpbarrett* b, size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata, mpw* result, mpw* wksp) - /*@modifies result, wksp @*/; -BEECRYPTAPI -void mpbsubmod_w(const mpbarrett* b, size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata, mpw* result, mpw* wksp) - /*@modifies result, wksp @*/; -BEECRYPTAPI -void mpbmulmod_w(const mpbarrett* b, size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata, mpw* result, mpw* wksp) - /*@modifies result, wksp @*/; -BEECRYPTAPI -void mpbsqrmod_w(const mpbarrett* b, size_t xsize, const mpw* xdata, mpw* result, mpw* wksp) - /*@modifies result, wksp @*/; -BEECRYPTAPI -void mpbpowmod_w(const mpbarrett* b, size_t xsize, const mpw* xdata, size_t psize, const mpw* pdata, mpw* result, mpw* wksp) - /*@modifies result, wksp @*/; -BEECRYPTAPI -void mpbpowmodsld_w(const mpbarrett* b, const mpw* slide, size_t psize, const mpw* pdata, mpw* result, mpw* wksp) - /*@modifies result, wksp @*/; -BEECRYPTAPI -void mpbtwopowmod_w(const mpbarrett* b, size_t psize, const mpw* pdata, mpw* result, mpw* wksp) - /*@modifies result, wksp @*/; - -/* To be added: - * simultaneous multiple exponentiation, for use in dsa and elgamal signature verification - */ -BEECRYPTAPI -void mpbsm2powmod(const mpbarrett* b, const mpw*, const mpw*, const mpw*, const mpw*) - /*@*/; -BEECRYPTAPI -void mpbsm3powmod(const mpbarrett* b, const mpw*, const mpw*, const mpw*, const mpw*, const mpw*, const mpw*) - /*@*/; - -BEECRYPTAPI -int mpbpprime_w(const mpbarrett* b, randomGeneratorContext* r, int t, mpw* wksp) - /*@modifies wksp @*/; - -/* the next routines take mpnumbers as parameters */ - -BEECRYPTAPI -void mpbnrnd(const mpbarrett* b, randomGeneratorContext* rc, mpnumber* result) - /*@modifies result @*/; - -BEECRYPTAPI -void mpbnmulmod(const mpbarrett* b, const mpnumber* x, const mpnumber* y, mpnumber* result) - /*@modifies result @*/; -BEECRYPTAPI -void mpbnsqrmod(const mpbarrett* b, const mpnumber* x, mpnumber* result) - /*@modifies result @*/; - -BEECRYPTAPI -void mpbnpowmod (const mpbarrett* b, const mpnumber* x, const mpnumber* pow, mpnumber* y) - /*@modifies y @*/; -BEECRYPTAPI -void mpbnpowmodsld(const mpbarrett* b, const mpw* slide, const mpnumber* pow, mpnumber* y) - /*@modifies y @*/; - -BEECRYPTAPI -size_t mpbbits(const mpbarrett* b) - /*@*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/mpnumber.c b/beecrypt/mpnumber.c deleted file mode 100644 index 558e80a7d..000000000 --- a/beecrypt/mpnumber.c +++ /dev/null @@ -1,268 +0,0 @@ -/* - * Copyright (c) 2003 Bob Deblier - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file mpnumber.c - * \brief Multi-precision numbers. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup MP_m - */ - -#include "system.h" - -#include "mpnumber.h" -#include "mp.h" - -#include "debug.h" - -void mpnzero(mpnumber* n) -{ - n->size = 0; - n->data = (mpw*) 0; -} - -void mpnsize(mpnumber* n, size_t size) -{ - if (size) - { - if (n->data) - { - if (n->size != size) - { - if (size < n->size) - { - register size_t offset = n->size - size; - - memmove(n->data, n->data + offset, offset * sizeof(mpw)); - } - n->data = (mpw*) realloc(n->data, size * sizeof(mpw)); - } - } - else - n->data = (mpw*) malloc(size * sizeof(mpw)); - - if (n->data == (mpw*) 0) - n->size = 0; - else - n->size = size; - - } - else if (n->data) - { - free(n->data); - n->data = (mpw*) 0; - n->size = 0; - } -} - -void mpninit(mpnumber* n, size_t size, const mpw* data) -{ - n->size = size; - n->data = (mpw*) malloc(size * sizeof(mpw)); - - if (n->data) - mpcopy(size, n->data, data); -} - -void mpnfree(mpnumber* n) -{ - if (n->data) - { - free(n->data); - n->data = (mpw*) 0; - } - n->size = 0; -} - -void mpncopy(mpnumber* n, const mpnumber* copy) -{ - mpnset(n, copy->size, copy->data); -} - -void mpnwipe(mpnumber* n) -{ - if (n->data != (mpw*) 0) - mpzero(n->size, n->data); -} - -void mpnset(mpnumber* n, size_t size, const mpw* data) -{ - if (size) - { - if (n->data) - { - if (n->size != size) - n->data = (mpw*) realloc(n->data, size * sizeof(mpw)); - } - else - n->data = (mpw*) malloc(size * sizeof(mpw)); - - if (n->data) - mpcopy(n->size = size, n->data, data); - else - n->size = 0; - } - else if (n->data) - { - free(n->data); - n->data = (mpw*) 0; - n->size = 0; - } -} - -void mpnsetw(mpnumber* n, mpw val) -{ - if (n->data) - { - if (n->size != 1) - n->data = (mpw*) realloc(n->data, sizeof(mpw)); - } - else - n->data = (mpw*) malloc(sizeof(mpw)); - - if (n->data) - { - n->size = 1; - n->data[0] = val; - } - else - n->size = 0; -} - -int mpnsetbin(mpnumber* n, const byte* osdata, size_t ossize) -{ - int rc = -1; - size_t size; - - /* skip zero bytes */ - while ((*osdata == 0) && ossize) - { - osdata++; - ossize--; - } - - size = MP_BYTES_TO_WORDS(ossize + MP_WBYTES - 1); - - if (n->data) - { - if (n->size != size) - n->data = (mpw*) realloc(n->data, size * sizeof(mpw)); - } - else - n->data = (mpw*) malloc(size * sizeof(mpw)); - - if (n->data) - { - n->size = size; - - rc = os2ip(n->data, size, osdata, ossize); - } - else - n->size = 0; - - return rc; -} - -int mpnsethex(mpnumber* n, const char* hex) -{ - int rc = -1; - size_t len = strlen(hex); - size_t size = MP_NIBBLES_TO_WORDS(len + MP_WNIBBLES - 1); - - if (n->data) - { - if (n->size != size) - n->data = (mpw*) realloc(n->data, size * sizeof(mpw)); - } - else - n->data = (mpw*) malloc(size * sizeof(mpw)); - - if (n->data) - { - n->size = size; - - rc = hs2ip(n->data, size, hex, len); - } - else - n->size = 0; - - return rc; -} - -int mpninv(mpnumber* inv, const mpnumber* k, const mpnumber* mod) -{ - int rc = 0; - size_t size = mod->size; - mpw* wksp = (mpw*) malloc((7*size+6) * sizeof(mpw)); - - if (wksp) - { - mpnsize(inv, size); - mpsetx(size, wksp, k->size, k->data); - rc = mpextgcd_w(size, mod->data, wksp, inv->data, wksp+size); - free(wksp); - } - - return rc; -} - -size_t mpntrbits(mpnumber* n, size_t bits) -{ - size_t sigbits = mpbits(n->size, n->data); - size_t offset = 0; - - if (sigbits < bits) - { - /* no need to truncate */ - return sigbits; - } - else - { - size_t allbits = MP_BITS_TO_WORDS(n->size + MP_WBITS - 1); - - while ((allbits - bits) > MP_WBITS) - { - /* zero a word */ - n->data[offset++] = 0; - allbits -= MP_WBITS; - } - - if ((allbits - bits)) - { - /* mask the next word */ - n->data[offset] &= (MP_ALLMASK >> (MP_WBITS - bits)); - - /* resize the number */ - mpnsize(n, n->size - offset); - - /* finally return the number of remaining bits */ - return bits; - } - else - { - /* nothing remains */ - mpnsetw(n, 0); - return 0; - } - } -} - -size_t mpnbits(const mpnumber* n) -{ - return mpbits(n->size, n->data); -} diff --git a/beecrypt/mpnumber.h b/beecrypt/mpnumber.h deleted file mode 100644 index baa86eb95..000000000 --- a/beecrypt/mpnumber.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2003 Bob Deblier - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file mpnumber.h - * \brief Multi-precision numbers, headers. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup MP_m - */ - -#ifndef _MPNUMBER_H -#define _MPNUMBER_H - -#include "mp.h" - -#ifdef __cplusplus -# include <iostream> -#endif - -#ifdef __cplusplus -struct BEECRYPTAPI mpnumber -#else -struct _mpnumber -#endif -{ - size_t size; -/*@relnull@*/ - mpw* data; - -#ifdef __cplusplus - mpnumber(); - mpnumber(unsigned int); - mpnumber(const mpnumber&); - ~mpnumber(); - - const mpnumber& operator=(const mpnumber&); - bool operator==(const mpnumber&); - bool operator!=(const mpnumber&); - - void wipe(); - - size_t bitlength() const; -#endif -}; - -#ifndef __cplusplus -typedef struct _mpnumber mpnumber; -#else -BEECRYPTAPI -std::ostream& operator<<(std::ostream&, const mpnumber&); -/* -BEECRYPTAPI -std::istream& operator>>(std::istream&, mpnumber&); -*/ -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -BEECRYPTAPI -void mpnzero(mpnumber* n) - /*@modifies n @*/; -BEECRYPTAPI -void mpnsize(mpnumber* n, size_t size) - /*@modifies n @*/; -BEECRYPTAPI -void mpninit(mpnumber* n, size_t size, const mpw* data) - /*@modifies n @*/; -BEECRYPTAPI -void mpnfree(mpnumber* n) - /*@modifies n @*/; -BEECRYPTAPI -void mpncopy(mpnumber* n, const mpnumber* copy) - /*@modifies n @*/; -BEECRYPTAPI -void mpnwipe(mpnumber* n) - /*@modifies n @*/; - -BEECRYPTAPI -void mpnset (mpnumber* n, size_t size, const mpw* data) - /*@modifies n @*/; -BEECRYPTAPI -void mpnsetw (mpnumber* n, mpw val) - /*@modifies n @*/; - -BEECRYPTAPI -int mpnsetbin(mpnumber* n, const byte* osdata, size_t ossize) - /*@modifies n @*/; -BEECRYPTAPI -int mpnsethex(/*@out@*/ mpnumber* n, const char* hex) - /*@modifies n @*/; - -BEECRYPTAPI -int mpninv(mpnumber* inv, const mpnumber* k, const mpnumber* mod) - /*@modifies inv @*/; - -/*!\brief Truncate the mpnumber to the specified number of (least significant) bits. - */ -BEECRYPTAPI -size_t mpntrbits(mpnumber* n, size_t bits) - /*@modifies n @*/; -BEECRYPTAPI -size_t mpnbits(const mpnumber* n) - /*@*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/mpopt.h b/beecrypt/mpopt.h deleted file mode 100644 index f9ba2db71..000000000 --- a/beecrypt/mpopt.h +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright (c) 2003 Bob Deblier - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file mpopt.h - * \brief Multi-precision integer optimization definitions. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup MP_m - */ - -#ifndef _MPOPT_H -#define _MPOPT_H - -#if WIN32 -# if __MWERKS__ && __INTEL__ -# elif defined(_MSC_VER) && defined(_M_IX86) -# define ASM_MPZERO -# define ASM_MPFILL -# define ASM_MPEVEN -# define ASM_MPODD -# define ASM_MPADDW -# define ASM_MPSUBW -# define ASM_MPADD -# define ASM_MPSUB -# define ASM_MPMULTWO -# define ASM_MPDIVTWO -# define ASM_MPSETMUL -# define ASM_MPADDMUL -# define ASM_MPADDSQRTRC -# endif -#endif - -#if defined(__DECC) -# if defined(OPTIMIZE_ALPHA) -# define ASM_MPADD -# define ASM_MPSUB -# define ASM_MPSETMUL -# define ASM_MPADDMUL -# define ASM_MPADDSQRTRC -# endif -#endif - -#if defined(__GNUC__) -# if defined(OPTIMIZE_ALPHA) -# define ASM_MPADD -# define ASM_MPSUB -# define ASM_MPSETMUL -# define ASM_MPADDMUL -# define ASM_MPADDSQRTRC -# elif defined(OPTIMIZE_ARM) -# define ASM_MPSETMUL -# define ASM_MPADDMUL -# define ASM_MPADDSQRTRC -# elif defined(OPTIMIZE_I386) || defined(OPTIMIZE_I486) || defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686) -# define ASM_MPZERO -# define ASM_MPFILL -# define ASM_MPEVEN -# define ASM_MPODD -# define ASM_MPADD -# define ASM_MPADDW -# define ASM_MPSUB -# define ASM_MPSUBW -# define ASM_MPMULTWO -# define ASM_MPDIVTWO -# define ASM_MPSETMUL -# define ASM_MPADDMUL -# define ASM_MPADDSQRTRC -# define ASM_MPPNDIV -# elif defined(OPTIMIZE_IA64) -# define ASM_MPZERO -# define ASM_MPCOPY -# define ASM_MPADD -# define ASM_MPSUB -# define ASM_MPMULTWO -# define ASM_MPSETMUL -# define ASM_MPADDMUL -# elif defined(OPTIMIZE_M68K) -# define ASM_MPADD -# define ASM_MPSUB -# define ASM_MPSETMUL -# define ASM_MPADDMUL -# define ASM_MPADDSQRTRC -# elif defined(OPTIMIZE_POWERPC) || defined(OPTIMIZE_POWERPC64) -# define ASM_MPSETMUL -# define ASM_MPADD -# define ASM_MPADDW -# define ASM_MPSUB -# define ASM_MPSUBW -# define ASM_MPMULTWO -# define ASM_MPADDMUL -# define ASM_MPADDSQRTRC -# elif defined(OPTIMIZE_S390X) -# define ASM_MPSETMUL -# define ASM_MPADDMUL -# elif defined(OPTIMIZE_SPARCV8) -# define ASM_MPSETMUL -# define ASM_MPADDMUL -# define ASM_MPADDSQRTRC -# elif defined(OPTIMIZE_SPARCV8PLUS) -# define ASM_MPADDW -# define ASM_MPSUBW -# define ASM_MPADD -# define ASM_MPSUB -# define ASM_MPMULTWO -# define ASM_MPSETMUL -# define ASM_MPADDMUL -# define ASM_MPADDSQRTRC -# elif defined(OPTIMIZE_X86_64) -# define ASM_MPZERO -# define ASM_MPFILL -# define ASM_MPEVEN -# define ASM_MPODD -# define ASM_MPADD -# define ASM_MPADDW -# define ASM_MPSUB -# define ASM_MPSUBW -# define ASM_MPDIVTWO -# define ASM_MPMULTWO -# define ASM_MPSETMUL -# define ASM_MPADDMUL -# define ASM_MPADDSQRTRC -# endif -#endif - -#if defined(__IBMC__) -# if defined(OPTIMIZE_POWERPC) || defined(OPTIMIZE_POWERPC64) -# define ASM_MPSETMUL -# define ASM_MPADDW -# define ASM_MPSUBW -# define ASM_MPADD -# define ASM_MPSUB -# define ASM_MPMULTWO -# define ASM_MPADDMUL -# define ASM_MPADDSQRTRC -# endif -#endif - -#if defined(__INTEL_COMPILER) -# if defined(OPTIMIZE_I386) || defined(OPTIMIZE_I486) || defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686) -# define ASM_MPZERO -# define ASM_MPFILL -# define ASM_MPEVEN -# define ASM_MPODD -# define ASM_MPADDW -# define ASM_MPSUBW -# define ASM_MPADD -# define ASM_MPSUB -# define ASM_MPMULTWO -# define ASM_MPDIVTWO -# define ASM_MPSETMUL -# define ASM_MPADDMUL -# define ASM_MPADDSQRTRC -# define ASM_MPPNDIV -# endif -#endif - -#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) -# if defined(OPTIMIZE_SPARCV8) -# define ASM_MPSETMUL -# define ASM_MPADDMUL -# define ASM_MPADDSQRTRC -# elif defined(OPTIMIZE_SPARCV8PLUS) -# define ASM_MPADDW -# define ASM_MPSUBW -# define ASM_MPADD -# define ASM_MPSUB -# define ASM_MPMULTWO -# define ASM_MPSETMUL -# define ASM_MPADDMUL -# define ASM_MPADDSQRTRC -# endif -#endif - -#endif diff --git a/beecrypt/mpprime.c b/beecrypt/mpprime.c deleted file mode 100644 index b75a6abf0..000000000 --- a/beecrypt/mpprime.c +++ /dev/null @@ -1,1127 +0,0 @@ -/* - * Copyright (c) 2003 Bob Deblier - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file mpprime.c - * \brief Multi-precision primes. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup MP_m - */ - -#include "system.h" - -#include "mpprime.h" -#include "mp.h" -#include "mpbarrett.h" - -#include "debug.h" - -/* - * A word of explanation here on what this table accomplishes: - * - * For fast checking whether a candidate prime can be divided by small primes, we use this table, - * which contains the products of all small primes starting at 3, up to a word size equal to the size - * of the candidate tested. - * - * Instead of trying each small prime in successive divisions, we compute one gcd with a product of small - * primes from this table. - * If the gcd result is not 1, the candidate is divisable by at least one of the small primes(*). If the gcd - * result is 1, then we can subject the candidate to a probabilistic test. - * - * (*) Note: the candidate prime could also be one of the small primes, in which is it IS prime, - * but too small to be of cryptographic interest. Hence, use only for candidate primes that are large enough. - */ - -#if (MP_WBITS == 64) - -static mpw spp_01[] = /* primes 3 to 53 */ -{ 0xe221f97c30e94e1dU }; - -static mpw spp_02[] = /* primes 3 to 101 */ -{ 0x5797d47c51681549U, 0xd734e4fc4c3eaf7fU }; - -static mpw spp_03[] = /* primes 3 to 149 */ -{ 0x1e6d8e2a0ffceafbU, 0xbcbfc14a4c3bc1e1U, - 0x009c6a22a0a7adf5U }; - -static mpw spp_04[] = /* primes 3 to 193 */ -{ 0xdbf05b6f5654b3c0U, 0xf524355143958688U, - 0x9f155887819aed2aU, 0xc05b93352be98677U }; - -static mpw spp_05[] = /* primes 3 to 239 */ -{ 0x3faa5dadb695ce58U, 0x4a579328eab20f1fU, - 0xef00fe27ffc36456U, 0x0a65723e27d8884aU, - 0xd59da0a992f77529U }; - -static mpw spp_06[] = /* primes 3 to 281 */ -{ 0x501201cc51a492a5U, 0x44d3900ad4f8b32aU, - 0x203c858406a4457cU, 0xab0b4f805ab18ac6U, - 0xeb9572ac6e9394faU, 0x522bffb6f44af2f3U }; - -static mpw spp_07[] = /* primes 3 to 331 */ -{ 0x0120eb4d70279230U, 0x9ed122fce0488be4U, - 0x1d0c99f5d8c039adU, 0x058c90b4780500feU, - 0xf39c05cc09817a27U, 0xc3e1776a246b6af2U, - 0x946a10d66eafaedfU }; - -static mpw spp_08[] = /* primes 3 to 379 */ -{ 0x106aa9fb7646fa6eU, 0xb0813c28c5d5f09fU, - 0x077ec3ba238bfb99U, 0xc1b631a203e81187U, - 0x233db117cbc38405U, 0x6ef04659a4a11de4U, - 0x9f7ecb29bada8f98U, 0x0decece92e30c48fU }; - -static mpw spp_09[] = /* primes 3 to 421 */ -{ 0x0185dbeb2b8b11d3U, 0x7633e9dc1eec5415U, - 0x65c6ce8431d227eeU, 0x28f0328a60c90118U, - 0xae031cc5a781c824U, 0xd1f16d25f4f0cccfU, - 0xf35e974579072ec8U, 0xcaf1ac8eefd5566fU, - 0xa15fb94fe34f5d37U }; - -static mpw spp_10[] = /* primes 3 to 463 */ -{ 0x833a505cf9922beeU, 0xc80265a6d50e1cceU, - 0xa22f6fec2eb84450U, 0xcec64a3c0e10d472U, - 0xdd653b9b51d81d0eU, 0x3a3142ea49b91e3aU, - 0x5e21023267bda426U, 0x738730cfb8e6e2aeU, - 0xc08c9d4bd2420066U, 0xdccf95ef49a560b7U }; - -static mpw spp_11[] = /* primes 3 to 509 */ -{ 0x309d024bd5380319U, 0x2ca334690bafb43aU, - 0x0abd5840fbeb24d1U, 0xf49b633047902baeU, - 0x581ca4cba778fdb1U, 0x6dc0a6afef960687U, - 0x16855d9593746604U, 0x201f1919b725fcb7U, - 0x8ffd0db8e8fa61a1U, 0x6e1c0970beb81adcU, - 0xf49c82dff960d36fU }; - -static mpw spp_12[] = /* primes 3 to 569 */ -{ 0x25eac89f8d4da338U, 0x337b49850d2d1489U, - 0x2663177b4010af3dU, 0xd23eeb0b228f3832U, - 0xffcee2e5cbd1acc9U, 0x8f47f251873380aeU, - 0x10f0ffdd8e602ffaU, 0x210f41f669a1570aU, - 0x93c158c1a9a8227fU, 0xf81a90c5630e9c44U, - 0x845c755c7df35a7dU, 0x430c679a11575655U }; - -static mpw spp_13[] = /* primes 3 to 607 */ -{ 0x3383219d26454f06U, 0xe2789b7f9c3b940eU, - 0x03be2105798e3ff7U, 0x945bd325997bc262U, - 0x025598f88577748eU, 0xc7155ff88a1ff4c9U, - 0x2ce95bd8b015101fU, 0x19b73b1481627f9aU, - 0x6f83da3a03259fbdU, 0x41f92a6e85ac6efaU, - 0xde195be86e66ba89U, 0xb0ab042d3276976cU, - 0x3dbeb3d7413ea96dU }; - -static mpw spp_14[] = /* primes 3 to 647 */ -{ 0x6e02645460adbd18U, 0xcd52ce1a1beab1c0U, - 0x36e468e9f350d69bU, 0x1d357d083a59f778U, - 0xc2cc262b4a29ce52U, 0x509bcf97349ba2bfU, - 0x22402d716b32517eU, 0x1941e18ace76cbd8U, - 0x5809701e70eaef96U, 0x9aac365c8a9fea5eU, - 0xc74d951db361f061U, 0xc4d14f000d806db4U, - 0xcd939110c7cab492U, 0x2f3ea4c4852ca469U }; - -static mpw spp_15[] = /* primes 3 to 683 */ -{ 0x008723131f66758aU, 0x414bbebb2f8670bfU, - 0x01dc959d74468901U, 0x57c57f40e210c9c2U, - 0x74f544697c71cc1dU, 0xe2be67a203d8d56fU, - 0x6c363fca0a78676aU, 0x2b9777896ea2db50U, - 0xdb31b73751992f73U, 0x0def293ebc028877U, - 0xdf95ac1b4d0c0128U, 0x9a0b05e00e6c0bc8U, - 0xe61b766ec0943254U, 0x1cd70f0fd5a0ce6bU, - 0x8ab998fb8ab36e0dU }; - -static mpw spp_16[] = /* primes 3 to 739 */ -{ 0x02c85ff870f24be8U, 0x0f62b1ba6c20bd72U, - 0xb837efdf121206d8U, 0x7db56b7d69fa4c02U, - 0x1c107c3ca206fe8fU, 0xa7080ef576effc82U, - 0xf9b10f5750656b77U, 0x94b16afd70996e91U, - 0xaef6e0ad15e91b07U, 0x1ac9b24d98b233adU, - 0x86ee055518e58e56U, 0x638ef18bac5c74cbU, - 0x35bbb6e5dae2783dU, 0xd1c0ce7dec4fc70eU, - 0x5186d411df36368fU, 0x061aa36011f30179U }; - -static mpw spp_17[] = /* primes 3 to 787 */ -{ 0x16af5c18a2bef8efU, 0xf2278332182d0fbfU, - 0x0038cc205148b83dU, 0x06e3d7d932828b18U, - 0xe11e094028c7eaedU, 0xa3395017e07d8ae9U, - 0xb594060451d05f93U, 0x084cb481663c94c6U, - 0xff980ddeccdb42adU, 0x37097f41a7837fc9U, - 0x5afe3f18ad76f234U, 0x83ae942e0f0c0bc6U, - 0xe40016123189872bU, 0xe58f6dfc239ca28fU, - 0xb0cfbf964c8f27ceU, 0x05d6c77a01f9d332U, - 0x36c9d442ad69ed33U }; - -static mpw spp_18[] = /* primes 3 to 827 */ -{ 0x005bfd2583ab7a44U, 0x13d4df0f537c686cU, - 0xa8e6b583e491130eU, 0x96dfcc1c05ba298fU, - 0x8701314b45bf6ff4U, 0xecf372ffe78bccdfU, - 0xfc18365a6ae5ca41U, 0x2794281fbcc762f1U, - 0x8ca1eb11fc8efe0bU, 0x6bb5a7a09954e758U, - 0x074256ad443a8e4bU, 0xaa2675154c43d626U, - 0x464119446e683d08U, 0xd4683db5757d1199U, - 0x9513a9cbe3e67e3aU, 0xe501c1c522aa8ba9U, - 0xf955789589161febU, 0xc69941a147aa9685U }; - -static mpw spp_19[] = /* primes 3 to 877 */ -{ 0x06706918e8355b7fU, 0xfd3f024da6b012e2U, - 0xbb7338f30d51a968U, 0x0f3d912035ed70e0U, - 0x2d38d422e41812d4U, 0xe29d637b318ce6f4U, - 0xea117321ce8b712dU, 0xcca9345fd03ccaf5U, - 0x2e75dafcda909cd4U, 0xb41a9f8753c8df3dU, - 0x284198bcb759d059U, 0x941360572b7ab25fU, - 0x396b9fa37ae0a200U, 0xd998ea09167edc30U, - 0xf9d2c45c7e487029U, 0x927500983f7fb4e8U, - 0xe85d8e9434a37006U, 0x8cebc96060ab2f87U, - 0x81efeb182d0e724bU }; - -static mpw spp_20[] = /* primes 3 to 929 */ -{ 0xa9e9591f7815617eU, 0xcabe352fa13445c4U, - 0xf8e319ba63042e1cU, 0xb0a017d0e729a699U, - 0x5480da4e5091cab4U, 0x12910cf47bb0f24eU, - 0x5e1db41264b9f96aU, 0x2b327e901d9d0a39U, - 0x12659a52d3792d52U, 0x991bfa964fe7d212U, - 0x60374c24a04de69dU, 0xf5d4e46b249cafc7U, - 0x347c6181bd6dc6b8U, 0x13a29dc6d4f785acU, - 0x7806635513530cd5U, 0xdb94de4858c157f0U, - 0x30b96bfb6475393bU, 0x5f43a549d95c5619U, - 0x7e274850ad1a6d18U, 0xb5eaa41dd42fda55U }; - -static mpw spp_21[] = /* primes 3 to 971 */ -{ 0x06e1d136cb78cac5U, 0x4da4bfcb6f2c4a24U, - 0xfcf3796b77719c31U, 0xd27915860001f03eU, - 0x4347621bf62577e0U, 0x280ebfdb77b4f1e9U, - 0x0f954ecafd198609U, 0x68629be91424c37aU, - 0x8f320a34444953d5U, 0x2c278d6485238798U, - 0x709d0063e3fa8623U, 0xea24bf2a2c5278e7U, - 0x4460d05a0a708bd9U, 0xc019d632e39e7300U, - 0x22b9dbb913df73cfU, 0xb959dffe348f9623U, - 0xf697a822f4a11320U, 0xbd044ecc74878f53U, - 0x0d57d0f076647b0aU, 0xb191f543dc08c392U, - 0x3167e5ee56c66847U }; - -static mpw spp_22[] = /* primes 3 to 1013 */ -{ 0x005ca1a92edd0e81U, 0x9619289e1ecfe2d7U, - 0xf3949eaf363a5fe8U, 0xf6fee01ccd480490U, - 0x30a1346ab83c4967U, 0x8c7d58826caf81caU, - 0x1d02473bea8ad400U, 0xd1ce270a5743c3cdU, - 0x892c3bd93b84525dU, 0x8a42071a508fdb8fU, - 0x32952aaa2384cf5dU, 0xf23ed81d10ac0031U, - 0xd85d0e95e3c5bb51U, 0x71a0e3f12b671f8fU, - 0xb07965cc353a784bU, 0x78f719681326c790U, - 0x6e2b7f7b0782848eU, 0xeb1aea5bab10b80eU, - 0x5b7138fc36f7989cU, 0xe85b07c2d4d59d42U, - 0x1541c765f6c2111dU, 0xb82eca06b437f757U }; - -static mpw spp_23[] = /* primes 3 to 1051 */ -{ 0x18e5b310229f618dU, 0xe0f54782f57fff33U, - 0x10546ba8efc0a69cU, 0xac4b573b749cc43dU, - 0xd3ba4df61fe2800dU, 0x733f4eb719a6ea7fU, - 0xa88aebf2d35b26c8U, 0x6e89fe0b27e198deU, - 0xe12a14da03cef215U, 0xe6651c60be9cf337U, - 0x3620f4aba453eeb9U, 0xeb439ba079201376U, - 0x0e3cc7f8722f09a4U, 0x685a5556b4efd158U, - 0xb27a6b79b15f161fU, 0xecf3fd802767da7aU, - 0x37ceb764bebfcc2bU, 0x2d833be00b21bb68U, - 0xeab326b9ebb20cc2U, 0xd76273edefa152adU, - 0x531bccbf17e3c78dU, 0x5c43d8f6866ad640U, - 0xfdbbba0fe997b27bU }; - -static mpw spp_24[] = /* primes 3 to 1093 */ -{ 0x021bf9497091b8c3U, 0x68cc7c8e00c1990cU, - 0x6027481b79215ac8U, 0xa7517749a2151377U, - 0x9a993d2958fcb49aU, 0x7368029268527994U, - 0xc6cc1928add41295U, 0x96765f4cc3141a04U, - 0x4eb1d61578881667U, 0x57d8618781813062U, - 0x032267987df0d471U, 0x9cd38f1b7085fca5U, - 0x334be3a6003a3ce7U, 0xe19aba553e80cc5aU, - 0xe4060eff6e180666U, 0x1da5eeb7d142d3b2U, - 0xe40739f1443dee3aU, 0x198637f03c062845U, - 0xeaff3ff27ea38d93U, 0x44d8a90222472df0U, - 0x7dfb5c9c8ada77cdU, 0x0d5b94eff021e02eU, - 0x307d08010312d57cU, 0xb5d975764697842dU }; - -static mpw spp_25[] = /* primes 3 to 1151 */ -{ 0xfa1bd62baae1e767U, 0x47535af3830fc07dU, - 0xebcf3ef7e5a8e46bU, 0x8937c4afe02aef0aU, - 0xce420c7b2c3f2facU, 0xb9dc94e5100a7191U, - 0xb47cf523520f613bU, 0xee8e095a7b06d781U, - 0xb6204bde1648e17fU, 0x0f1bd4aba00f7e90U, - 0xd8fc2a05f5f1e832U, 0x6e88a4a67e73cae1U, - 0xc4a93d89ad6b301bU, 0x1f185b130246ab44U, - 0x5cadc384931189b5U, 0x566b3ed9dafba4e6U, - 0x59f5446e5a70c8d1U, 0x4626b66d0f1ccfbfU, - 0xd4238b6884af7dd3U, 0xa91d2063ceb2c2f7U, - 0xf273b1da4cb542eaU, 0x62c624cf4fcb0486U, - 0x138b42a3c1d9593cU, 0xe1254fb3214d2b08U, - 0x52532bc528bc6467U }; - -static mpw spp_26[] = /* primes 3 to 1193 */ -{ 0x239afcd438799705U, 0xab8a0cda4802bc8fU, - 0xb0e87f44a568f618U, 0x7c604708dfb79072U, - 0xe24b49cb8b2ac531U, 0x005cf2982437b16eU, - 0x027fa01414e3dbf5U, 0xbf76681166e276ffU, - 0xcf6768550bc1cd9aU, 0x1b387ebaaa8550aeU, - 0xfc10c69c372a0254U, 0xb84666ff35044b9aU, - 0xa34fcf7c817b33f3U, 0x7088a289a17891a7U, - 0xe66f88e8ec2ba784U, 0xb2a09a9102609726U, - 0x17a3dbea8463439dU, 0x47972d09b0e63752U, - 0xbac58d339b402dc1U, 0xa09915543360cd68U, - 0x4df24e437487571dU, 0xfaf68f4fe0a93546U, - 0x66aa84bf84d4448dU, 0x2119029166db27bdU, - 0x515599cdcd147810U, 0x3acf73e7fe62aed9U }; - -static mpw spp_27[] = /* primes 3 to 1231 */ -{ 0x0654f0d4cdacb307U, 0x5419612fae3cf746U, - 0xfbab751fd0887955U, 0x28adc68d26f32877U, - 0xeb1b772db48e49f6U, 0xcb445987c4966560U, - 0xdff8473702bb0fd4U, 0xf8b68b5ce2d496a6U, - 0x0dc7d7e43c3cb0bfU, 0x72665c6e4c86a7ceU, - 0xb78c9da40f4d90a8U, 0xf5dfe2a4dc559b8aU, - 0xba10a63a0ca25d3aU, 0xdec2c4198b688d80U, - 0x71c05d3b694f19deU, 0xda32955f77fbb577U, - 0x27eb652140495e56U, 0x2f4a13e8b648daf2U, - 0x13d1da75e3f04bb0U, 0x43fedcd2b2a0cd30U, - 0xa4339e3a03b7f3a0U, 0xe02a31c28394368cU, - 0x7f73bbf32712e69eU, 0x7ac58373e5f7c7e7U, - 0x55e0d645628c5475U, 0x6217c0bdf119900bU, - 0x05ea71dd714fd2c9U }; - -static mpw spp_28[] = /* primes 3 to 1283 */ -{ 0x01662c66dab7a4faU, 0xdba4265ac2075912U, - 0x59e9c885e1330cb6U, 0xc91bee92f1b334ffU, - 0x384f827cc8057aa7U, 0xc3b65fc6de53dcacU, - 0x2db6d7903febbe07U, 0xcc4012326b128eb7U, - 0x1afd3136a9e7f786U, 0x14648da17b4f50c7U, - 0xbd4129ca746dab21U, 0x09583797fc1c2ecdU, - 0x4c0768a81892bd16U, 0xdfea8227bcb2b8bfU, - 0x168a1452370b0863U, 0xb299d0888434c213U, - 0x2383a6c7b6b4bf20U, 0x5addc8da76d2b172U, - 0xb416f5b0b9a38d87U, 0x738c1cca3fe33dd2U, - 0xf9b7570e3f663f8bU, 0x3416907651b1dd42U, - 0x2192331d9436304aU, 0x0303422f4d420389U, - 0x4548a05562ed1c09U, 0x1a63309bf1a9df8bU, - 0xf0c59af912a62c22U, 0xe1e1f49bb0115c17U }; - -static mpw spp_29[] = /* primes 3 to 1307 */ -{ 0x005cda0c54b07f4fU, 0xff0caca07cc89b95U, - 0x1c021191164be693U, 0x6665357ebb2f689cU, - 0x7157ea4f98037ce1U, 0x5aca14ca3cf1a386U, - 0xb03e831ee09a8d5cU, 0x48d51f5e6646ed8aU, - 0x7ec2b955216587f0U, 0x7f3c42ee06ae3844U, - 0x4c776b8c3ef32747U, 0x97cd2ac1c7cce7ecU, - 0xe75bb0290f5b5a0eU, 0x2c96c4600c678a21U, - 0x0d992d36d441b1fdU, 0x682adf0ef289947eU, - 0x6d3de1a2af0ca945U, 0x859aa1f2b2bb793dU, - 0x351dbebfe05144eeU, 0xfe9c752d75ec602cU, - 0x0e0344ddcfcb642bU, 0x6cfc872219d69873U, - 0xb8c4ace3ffd460e9U, 0x43d903b45de9d402U, - 0x958a41fb5e008a94U, 0xc93610814e5e2811U, - 0xd052c10abfc67bf6U, 0x915d44352688091bU, - 0x1eb1c7117c91eae5U }; - -static mpw spp_30[] = /* primes 3 to 1381 */ -{ 0xa0604bc54c251adeU, 0xcf22bf075a150bb1U, - 0x2a67d65a5045c183U, 0x172466270d72a8c6U, - 0x3e2dd1c46694a251U, 0xf55bca5e7d834c87U, - 0x2a8d10e5ea91ba4dU, 0xcce166f16b1be0efU, - 0xba025bf362f29284U, 0xa36db51675c7d25eU, - 0xac7519925560c7a1U, 0xc70470938bdf2818U, - 0xed42d04253130befU, 0x0d92e596844e073bU, - 0xdd40bd156f433f09U, 0xbdfd3e38769a485cU, - 0xf29380b79c18989cU, 0xed0e6ec43bcc7b73U, - 0x087e1fb94e8cf2d3U, 0x475c77605c707f6bU, - 0x31f7217c4c628da2U, 0xe3263e30a83c1066U, - 0x1378f41533ca7d71U, 0x5d4e2b87c0e142baU, - 0x462e6ffb506e09f9U, 0x7850c73e4b3f7a24U, - 0xca98bda05c0c6ac6U, 0x666daad014d2ff3fU, - 0x7138fa68ddd5e9f0U, 0xe92edcaa62b56483U }; - -static mpw spp_31[] = /* primes 3 to 1433 */ -{ 0x4742fdaff7e8231aU, 0xded6827758493423U, - 0x12b13d2f5925c539U, 0x82d876ef7ff69e7fU, - 0x5b4ff04e8454faeaU, 0x620dc9600c65fd57U, - 0x2aecce4c9656588fU, 0x79dfb5dfd7f99148U, - 0x196c24df6d8c704bU, 0xd6ffb8d9cedb8ee8U, - 0x448d4352d834cef7U, 0xfce9b92907eeca6aU, - 0xcc107008fa118ff7U, 0xedcc0b84207c3eefU, - 0xdb5ea3ef89c684d8U, 0x89c4187a10775358U, - 0xc429d4d2a76bb2c3U, 0x9f406fdc49dcf4b6U, - 0xed773586770e4651U, 0xcb63c78354d2a578U, - 0x5f52816b14d29d62U, 0x06d952ca4428030eU, - 0x2e793590f75f1d07U, 0x79363fa6047f0c64U, - 0xf3ed6a912dbc4437U, 0x673d418400d005caU, - 0x9ca42ff6841c84ddU, 0xaaff5fb087f85954U, - 0x177c5dc0fbfbb491U, 0xa1e5e03e5715875cU, - 0xa02a0fa41fde7abdU }; - -static mpw spp_32[] = /* primes 3 to 1471 */ -{ 0x2465a7bd85011e1cU, 0x9e0527929fff268cU, - 0x82ef7efa416863baU, 0xa5acdb0971dba0ccU, - 0xac3ee4999345029fU, 0x2cf810b99e406aacU, - 0x5fce5dd69d1c717dU, 0xaea5d18ab913f456U, - 0x505679bc91c57d46U, 0xd9888857862b36e2U, - 0xede2e473c1f0ab35U, 0x9da25271affe15ffU, - 0x240e299d0b04f4cdU, 0x0e4d7c0e47b1a7baU, - 0x007de89aae848fd5U, 0xbdcd7f9815564eb0U, - 0x60ae14f19cb50c29U, 0x1f0bbd8ed1c4c7f8U, - 0xfc5fba5166200193U, 0x9b532d92dac844a8U, - 0x431d400c832d039fU, 0x5f900b278a75219cU, - 0x2986140c79045d77U, 0x59540854c31504dcU, - 0x56f1df5eebe7bee4U, 0x47658b917bf696d6U, - 0x927f2e2428fbeb34U, 0x0e515cb9835d6387U, - 0x1be8bbe09cf13445U, 0x799f2e6778815157U, - 0x1a93b4c1eee55d1bU, 0x9072e0b2f5c4607fU }; - -#elif (MP_WBITS == 32) - -static mpw spp_01[] = /* primes 3 to 29 */ -{ 0xc0cfd797U }; - -static mpw spp_02[] = /* primes 3 to 53 */ -{ 0xe221f97cU, 0x30e94e1dU }; - -static mpw spp_03[] = /* primes 3 to 73 */ -{ 0x41cd66acU, 0xc237b226U, 0x81a18067U }; - -static mpw spp_04[] = /* primes 3 to 101 */ -{ 0x5797d47cU, 0x51681549U, 0xd734e4fcU, 0x4c3eaf7fU }; - -static mpw spp_05[] = /* primes 3 to 113 */ -{ 0x02c4b8d0U, 0xd2e0d937U, 0x3935200fU, 0xb49be231U, - 0x5ce1a307U }; - -static mpw spp_06[] = /* primes 3 to 149 */ -{ 0x1e6d8e2aU, 0x0ffceafbU, 0xbcbfc14aU, 0x4c3bc1e1U, - 0x009c6a22U, 0xa0a7adf5U }; - -static mpw spp_07[] = /* primes 3 to 167 */ -{ 0x049265d3U, 0x574cefd0U, 0x4229bfd6U, 0x62a4a46fU, - 0x8611ed02U, 0x26c655f0U, 0x76ebade3U }; - -static mpw spp_08[] = /* primes 3 to 193 */ -{ 0xdbf05b6fU, 0x5654b3c0U, 0xf5243551U, 0x43958688U, - 0x9f155887U, 0x819aed2aU, 0xc05b9335U, 0x2be98677U }; - -static mpw spp_09[] = /* primes 3 to 223 */ -{ 0x5e75cec8U, 0xb5de5ea1U, 0x5da8302aU, 0x2f28b4adU, - 0x2735bdc3U, 0x9344c52eU, 0x67570925U, 0x6feb71efU, - 0x6811d741U }; - -static mpw spp_10[] = /* primes 3 to 239 */ -{ 0x3faa5dadU, 0xb695ce58U, 0x4a579328U, 0xeab20f1fU, - 0xef00fe27U, 0xffc36456U, 0x0a65723eU, 0x27d8884aU, - 0xd59da0a9U, 0x92f77529U }; - -static mpw spp_11[] = /* primes 3 to 263 */ -{ 0x3c9b6e49U, 0xb7cf685bU, 0xe7f3a239U, 0xfb4084cbU, - 0x166885e3U, 0x9d4f65b4U, 0x0bb0e51cU, 0x0a5d36feU, - 0x98c32069U, 0xfd5c441cU, 0x6d82f115U }; - -static mpw spp_12[] = /* primes 3 to 281 */ -{ 0x501201ccU, 0x51a492a5U, 0x44d3900aU, 0xd4f8b32aU, - 0x203c8584U, 0x06a4457cU, 0xab0b4f80U, 0x5ab18ac6U, - 0xeb9572acU, 0x6e9394faU, 0x522bffb6U, 0xf44af2f3U }; - -static mpw spp_13[] = /* primes 3 to 311 */ -{ 0x9397b5b4U, 0x414dc331U, 0x04561364U, 0x79958cc8U, - 0xfd5ea01fU, 0x5d5e9f61U, 0xbd0f1cb6U, 0x24af7e6aU, - 0x3284dbb2U, 0x9857622bU, 0x8be980a6U, 0x5456a5c1U, - 0xed928009U }; - -static mpw spp_14[] = /* primes 3 to 331 */ -{ 0x0120eb4dU, 0x70279230U, 0x9ed122fcU, 0xe0488be4U, - 0x1d0c99f5U, 0xd8c039adU, 0x058c90b4U, 0x780500feU, - 0xf39c05ccU, 0x09817a27U, 0xc3e1776aU, 0x246b6af2U, - 0x946a10d6U, 0x6eafaedfU }; - -static mpw spp_15[] = /* primes 3 to 353 */ -{ 0x03c91dd1U, 0x2e893191U, 0x94095649U, 0x874b41d6U, - 0x05810c06U, 0x195d70ebU, 0xbd54a862U, 0x50c52733U, - 0x06dc6648U, 0x1c251ca4U, 0xa02c9a04U, 0x78c96f0dU, - 0x02f0db0bU, 0x39d624caU, 0x0b0441c1U }; - -static mpw spp_16[] = /* primes 3 to 379 */ -{ 0x106aa9fbU, 0x7646fa6eU, 0xb0813c28U, 0xc5d5f09fU, - 0x077ec3baU, 0x238bfb99U, 0xc1b631a2U, 0x03e81187U, - 0x233db117U, 0xcbc38405U, 0x6ef04659U, 0xa4a11de4U, - 0x9f7ecb29U, 0xbada8f98U, 0x0decece9U, 0x2e30c48fU }; - -static mpw spp_17[] = /* primes 3 to 401 */ -{ 0x5aa88d8cU, 0x594bb372U, 0xc4bc813fU, 0x4a87a266U, - 0x1f984840U, 0xdab15692U, 0x2c2a177dU, 0x95843665U, - 0x6f36d41aU, 0x11c35cccU, 0x2904b7e9U, 0xc424eb61U, - 0x3b3536a4U, 0x0b2745bdU, 0xadf1a6c9U, 0x7b23e85aU, - 0xdc6695c1U }; - -static mpw spp_18[] = /* primes 3 to 421 */ -{ 0x0185dbebU, 0x2b8b11d3U, 0x7633e9dcU, 0x1eec5415U, - 0x65c6ce84U, 0x31d227eeU, 0x28f0328aU, 0x60c90118U, - 0xae031cc5U, 0xa781c824U, 0xd1f16d25U, 0xf4f0cccfU, - 0xf35e9745U, 0x79072ec8U, 0xcaf1ac8eU, 0xefd5566fU, - 0xa15fb94fU, 0xe34f5d37U }; - -static mpw spp_19[] = /* primes 3 to 443 */ -{ 0x0cde6fd1U, 0xcf108066U, 0xcc548df9U, 0x070e102cU, - 0x2c651b88U, 0x5f24f503U, 0xaaffe276U, 0xfeb57311U, - 0x0c1e4592U, 0xa35890d7U, 0x678aaeeeU, 0x9f44800fU, - 0xc43f999dU, 0x5d06b89fU, 0xcb22e533U, 0x5a9287bcU, - 0x6d75a3e9U, 0x1e53906dU, 0x413163d5U }; - -static mpw spp_20[] = /* primes 3 to 463 */ -{ 0x833a505cU, 0xf9922beeU, 0xc80265a6U, 0xd50e1cceU, - 0xa22f6fecU, 0x2eb84450U, 0xcec64a3cU, 0x0e10d472U, - 0xdd653b9bU, 0x51d81d0eU, 0x3a3142eaU, 0x49b91e3aU, - 0x5e210232U, 0x67bda426U, 0x738730cfU, 0xb8e6e2aeU, - 0xc08c9d4bU, 0xd2420066U, 0xdccf95efU, 0x49a560b7U }; - -static mpw spp_21[] = /* primes 3 to 487 */ -{ 0x035417f1U, 0xe321c06cU, 0xbe32ffceU, 0xae752cc9U, - 0xa9fe11a6U, 0x3d94c946U, 0x456edd7dU, 0x5a060de1U, - 0x84a826a6U, 0xf0740c13U, 0x48fa1038U, 0x911d771dU, - 0xb3773e87U, 0x52300c29U, 0xc82c3012U, 0x131673bbU, - 0x491cbd61U, 0x55e565afU, 0x4a9f4331U, 0x0adbb0d7U, - 0x06e86f6dU }; - -static mpw spp_22[] = /* primes 3 to 509 */ -{ 0x309d024bU, 0xd5380319U, 0x2ca33469U, 0x0bafb43aU, - 0x0abd5840U, 0xfbeb24d1U, 0xf49b6330U, 0x47902baeU, - 0x581ca4cbU, 0xa778fdb1U, 0x6dc0a6afU, 0xef960687U, - 0x16855d95U, 0x93746604U, 0x201f1919U, 0xb725fcb7U, - 0x8ffd0db8U, 0xe8fa61a1U, 0x6e1c0970U, 0xbeb81adcU, - 0xf49c82dfU, 0xf960d36fU }; - -static mpw spp_23[] = /* primes 3 to 541 */ -{ 0x01ab244aU, 0x33bc047eU, 0x804590b4U, 0xc3207237U, - 0xea503fa0U, 0x7541b251U, 0x57cfd03fU, 0xf602c9d0U, - 0x3dcd12baU, 0xa4947ae6U, 0xc6ee61beU, 0xedf6c716U, - 0xfa45377dU, 0x5b3c84faU, 0x5fb78b41U, 0x395251ebU, - 0xb6a5129cU, 0x7699fb5cU, 0xccec6d45U, 0x56c9b8eaU, - 0xfa05897cU, 0xb8c5cf72U, 0xb77603d9U }; - -static mpw spp_24[] = /* primes 3 to 569 */ -{ 0x25eac89fU, 0x8d4da338U, 0x337b4985U, 0x0d2d1489U, - 0x2663177bU, 0x4010af3dU, 0xd23eeb0bU, 0x228f3832U, - 0xffcee2e5U, 0xcbd1acc9U, 0x8f47f251U, 0x873380aeU, - 0x10f0ffddU, 0x8e602ffaU, 0x210f41f6U, 0x69a1570aU, - 0x93c158c1U, 0xa9a8227fU, 0xf81a90c5U, 0x630e9c44U, - 0x845c755cU, 0x7df35a7dU, 0x430c679aU, 0x11575655U }; - -static mpw spp_25[] = /* primes 3 to 587 */ -{ 0x01b515a8U, 0xdca3d6e4U, 0x69090373U, 0x84febfe8U, - 0xf32e06cfU, 0x9bde8c89U, 0x6b3f992fU, 0x2ff23508U, - 0xe1c01024U, 0x3b8ad0c4U, 0xac54e7c7U, 0x3f4081d8U, - 0xe495d54dU, 0x74ed01e8U, 0x9dfcbddeU, 0x1fe7e61aU, - 0x839bd902U, 0xf43bf273U, 0x2441f0aeU, 0xb4211c70U, - 0x6b3faafcU, 0x0f200b35U, 0x7485ce4aU, 0x2f08f148U, - 0xcce6887dU }; - -static mpw spp_26[] = /* primes 3 to 607 */ -{ 0x3383219dU, 0x26454f06U, 0xe2789b7fU, 0x9c3b940eU, - 0x03be2105U, 0x798e3ff7U, 0x945bd325U, 0x997bc262U, - 0x025598f8U, 0x8577748eU, 0xc7155ff8U, 0x8a1ff4c9U, - 0x2ce95bd8U, 0xb015101fU, 0x19b73b14U, 0x81627f9aU, - 0x6f83da3aU, 0x03259fbdU, 0x41f92a6eU, 0x85ac6efaU, - 0xde195be8U, 0x6e66ba89U, 0xb0ab042dU, 0x3276976cU, - 0x3dbeb3d7U, 0x413ea96dU }; - -static mpw spp_27[] = /* primes 3 to 619 */ -{ 0x02ced4b7U, 0xf15179e8U, 0x7fcba6daU, 0x7b07a6f3U, - 0xf9311218U, 0xa7b88985U, 0xac74b503U, 0xbf745330U, - 0x6d0a23f5U, 0x27a1fa9aU, 0xc2b85f1aU, 0x26152470U, - 0x6ac242f3U, 0x518cc497U, 0x09a23d74U, 0xff28da52U, - 0xe7bbf7f7U, 0xa63c1c88U, 0x6f684195U, 0x65e472ceU, - 0x80751585U, 0xc70e20c2U, 0x2d15d3feU, 0xc1b40c7fU, - 0x8e25dd07U, 0xdb09dd86U, 0x791aa9e3U }; - -static mpw spp_28[] = /* primes 3 to 647 */ -{ 0x6e026454U, 0x60adbd18U, 0xcd52ce1aU, 0x1beab1c0U, - 0x36e468e9U, 0xf350d69bU, 0x1d357d08U, 0x3a59f778U, - 0xc2cc262bU, 0x4a29ce52U, 0x509bcf97U, 0x349ba2bfU, - 0x22402d71U, 0x6b32517eU, 0x1941e18aU, 0xce76cbd8U, - 0x5809701eU, 0x70eaef96U, 0x9aac365cU, 0x8a9fea5eU, - 0xc74d951dU, 0xb361f061U, 0xc4d14f00U, 0x0d806db4U, - 0xcd939110U, 0xc7cab492U, 0x2f3ea4c4U, 0x852ca469U }; - -static mpw spp_29[] = /* primes 3 to 661 */ -{ 0x074921f7U, 0x6a76cec3U, 0xaeb05f74U, 0x60b21f16U, - 0x49dece2fU, 0x21bb3ed9U, 0xe4cb4ebcU, 0x05d6f408U, - 0xed3d408aU, 0xdee16505U, 0xdc657c6dU, 0x93877982U, - 0xf2d11ce6U, 0xcb5b0bb0U, 0x579b3189U, 0xb339c2ccU, - 0xcf81d846U, 0xa9fbde0cU, 0x723afbc7U, 0x36655d41U, - 0x0018d768U, 0x21779cf3U, 0x52642f1bU, 0x2d17165dU, - 0xc7001c45U, 0x4a84a45dU, 0x66007591U, 0x27e85693U, - 0x2288d0fbU }; - -static mpw spp_30[] = /* primes 3 to 683 */ -{ 0x00872313U, 0x1f66758aU, 0x414bbebbU, 0x2f8670bfU, - 0x01dc959dU, 0x74468901U, 0x57c57f40U, 0xe210c9c2U, - 0x74f54469U, 0x7c71cc1dU, 0xe2be67a2U, 0x03d8d56fU, - 0x6c363fcaU, 0x0a78676aU, 0x2b977789U, 0x6ea2db50U, - 0xdb31b737U, 0x51992f73U, 0x0def293eU, 0xbc028877U, - 0xdf95ac1bU, 0x4d0c0128U, 0x9a0b05e0U, 0x0e6c0bc8U, - 0xe61b766eU, 0xc0943254U, 0x1cd70f0fU, 0xd5a0ce6bU, - 0x8ab998fbU, 0x8ab36e0dU }; - -static mpw spp_31[] = /* primes 3 to 719 */ -{ 0x1e595df4U, 0x3064a8c9U, 0xd61ae17bU, 0xde1938f0U, - 0x22ee6357U, 0x35f4caddU, 0x3d39f473U, 0xafed7df5U, - 0x92ae0fd3U, 0xfe910508U, 0x9ad9e939U, 0x988b0227U, - 0x60dec749U, 0xae7ee54fU, 0xeb0572acU, 0x0aed266dU, - 0x92daafd8U, 0x6135f7a3U, 0xe4e8bf05U, 0x0124c928U, - 0xb0d719d5U, 0x2181aec8U, 0x0f79820fU, 0xcb158642U, - 0x20969ec0U, 0x1a480d31U, 0x331b3252U, 0x01b36fabU, - 0x3d5b415bU, 0x1a4567e7U, 0x3baf6389U }; - -static mpw spp_32[] = /* primes 3 to 739 */ -{ 0x02c85ff8U, 0x70f24be8U, 0x0f62b1baU, 0x6c20bd72U, - 0xb837efdfU, 0x121206d8U, 0x7db56b7dU, 0x69fa4c02U, - 0x1c107c3cU, 0xa206fe8fU, 0xa7080ef5U, 0x76effc82U, - 0xf9b10f57U, 0x50656b77U, 0x94b16afdU, 0x70996e91U, - 0xaef6e0adU, 0x15e91b07U, 0x1ac9b24dU, 0x98b233adU, - 0x86ee0555U, 0x18e58e56U, 0x638ef18bU, 0xac5c74cbU, - 0x35bbb6e5U, 0xdae2783dU, 0xd1c0ce7dU, 0xec4fc70eU, - 0x5186d411U, 0xdf36368fU, 0x061aa360U, 0x11f30179U }; - -#else -# error -#endif - -mpw* mpspprod[SMALL_PRIMES_PRODUCT_MAX] = -{ - spp_01, - spp_02, - spp_03, - spp_04, - spp_05, - spp_06, - spp_07, - spp_08, - spp_09, - spp_10, - spp_11, - spp_12, - spp_13, - spp_14, - spp_15, - spp_16, - spp_17, - spp_18, - spp_19, - spp_20, - spp_21, - spp_22, - spp_23, - spp_24, - spp_25, - spp_26, - spp_27, - spp_28, - spp_29, - spp_30, - spp_31, - spp_32 -}; - -int mpptrials(size_t bits) -{ - if (bits >= 1854) - return 2; - if (bits >= 1223) - return 3; - if (bits >= 927) - return 4; - if (bits >= 747) - return 5; - if (bits >= 627) - return 6; - if (bits >= 543) - return 7; - if (bits >= 480) - return 8; - if (bits >= 431) - return 9; - if (bits >= 393) - return 10; - if (bits >= 361) - return 11; - if (bits >= 335) - return 12; - if (bits >= 314) - return 13; - if (bits >= 295) - return 14; - if (bits >= 279) - return 15; - if (bits >= 265) - return 16; - if (bits >= 253) - return 17; - if (bits >= 242) - return 18; - if (bits >= 232) - return 19; - if (bits >= 223) - return 20; - if (bits >= 216) - return 21; - if (bits >= 209) - return 22; - if (bits >= 202) - return 23; - if (bits >= 196) - return 24; - if (bits >= 191) - return 25; - if (bits >= 186) - return 26; - if (bits >= 182) - return 27; - if (bits >= 178) - return 28; - if (bits >= 174) - return 29; - if (bits >= 170) - return 30; - if (bits >= 167) - return 31; - if (bits >= 164) - return 32; - if (bits >= 161) - return 33; - if (bits >= 160) - return 34; - return 35; -} - -/* - * needs workspace of (size*2) words - */ -static void mpprndbits(mpbarrett* p, size_t bits, size_t lsbset, /*@null@*/ const mpnumber* min, /*@null@*/ const mpnumber* max, randomGeneratorContext* rc, mpw* wksp) - /*@modifies p, wksp @*/ -{ - register size_t size = p->size; - register size_t msbclr = MP_WORDS_TO_BITS(size) - bits; - - /* assume that mpbits(max) == bits */ - /* calculate k=max-min; generate q such that 0 <= q <= k; then set p = q + min */ - /* for the second step, set the appropriate number of bits */ - - if (max) - { - mpsetx(size, wksp, max->size, max->data); - } - else - { - mpfill(size, wksp, MP_ALLMASK); - wksp[0] &= (MP_ALLMASK >> msbclr); - } - if (min) - { - mpsetx(size, wksp+size, min->size, min->data); - } - else - { - mpzero(size, wksp+size); - wksp[size] |= (MP_MSBMASK >> msbclr); - } - - mpsub(size, wksp, wksp+size); - - rc->rng->next(rc->param, (byte*) p->modl, MP_WORDS_TO_BYTES(size)); - - p->modl[0] &= (MP_ALLMASK >> msbclr); - - while (mpgt(size, p->modl, wksp)) - mpsub(size, p->modl, wksp); - - mpadd(size, p->modl, wksp+size); - - if (lsbset) - p->modl[size-1] |= (MP_ALLMASK >> (MP_WBITS - lsbset)); -} - -/* - * mppsppdiv_w - * needs workspace of (3*size) words - */ -int mppsppdiv_w(const mpbarrett* p, mpw* wksp) - /*@modifies wksp @*/ -{ - /* small prime product trial division test */ - register size_t size = p->size; - - if (size > SMALL_PRIMES_PRODUCT_MAX) - { - mpsetx(size, wksp+size, SMALL_PRIMES_PRODUCT_MAX, mpspprod[SMALL_PRIMES_PRODUCT_MAX-1]); - mpgcd_w(size, p->modl, wksp+size, wksp, wksp+2*size); - } - else - { - mpgcd_w(size, p->modl, mpspprod[size-1], wksp, wksp+2*size); - } - - return mpisone(size, wksp); -} - -/* - * needs workspace of (5*size+2) - */ -int mppmilrabtwo_w(const mpbarrett* p, int s, const mpw* rdata, const mpw* ndata, mpw* wksp) - /*@modifies wksp @*/ -{ - register size_t size = p->size; - register int j = 0; - - mpbtwopowmod_w(p, size, rdata, wksp, wksp+size); - - while (1) - { - if (mpisone(size, wksp)) - return (j == 0); - - if (mpeq(size, wksp, ndata)) - return 1; - - if (++j < s) - mpbsqrmod_w(p, size, wksp, wksp, wksp+size); - else - return 0; - } -} - -/* - * needs workspace of (5*size+2) words - */ -int mppmilraba_w(const mpbarrett* p, const mpw* adata, int s, const mpw* rdata, const mpw* ndata, mpw* wksp) - /*@modifies wksp @*/ -{ - register size_t size = p->size; - register int j = 0; - - mpbpowmod_w(p, size, adata, size, rdata, wksp, wksp+size); - - while (1) - { - if (mpisone(size, wksp)) - return (j == 0); - - if (mpeq(size, wksp, ndata)) - return 1; - - if (++j < s) - mpbsqrmod_w(p, size, wksp, wksp, wksp+size); - else - return 0; - } -} - -/* - * needs workspace of (8*size+2) words - */ -int mppmilrab_w(const mpbarrett* p, randomGeneratorContext* rc, int t, mpw* wksp) -{ - /* - * Miller-Rabin probabilistic primality test, with modification - * - * For more information, see: - * "Handbook of Applied Cryptography" - * Chapter 4.24 - * - * Modification to the standard algorithm: - * The first value of a is not obtained randomly, but set to two - */ - - /* this routine uses (size*3) storage, and calls mpbpowmod, which needs (size*4+2) */ - /* (size) for a, (size) for r, (size) for n-1 */ - - register size_t size = p->size; - register mpw* ndata = wksp; - register mpw* rdata = ndata+size; - register mpw* adata = rdata+size; - - int s; - - mpcopy(size, ndata, p->modl); - mpsubw(size, ndata, 1); - mpcopy(size, rdata, ndata); - - s = mprshiftlsz(size, rdata); /* we've split p-1 into (2^s)*r */ - - /* should do an assert that s != 0 */ - - /* do at least one test, with a = 2 */ - if (t == 0) - t++; - - if (!mppmilrabtwo_w(p, s, rdata, ndata, wksp+3*size)) - return 0; - - while (t-- > 0) - { - /* generate a random 'a' into b->data */ - mpbrnd_w(p, rc, adata, wksp); - - if (!mppmilraba_w(p, adata, s, rdata, ndata, wksp+3*size)) - return 0; - } - - return 1; -} - -/* - * needs workspace of (8*size+2) words - */ -int mpprnd_w(mpbarrett* p, randomGeneratorContext* rc, size_t bits, int t, const mpnumber* f, mpw* wksp) -{ - return mpprndr_w(p, rc, bits, t, (const mpnumber*) 0, (const mpnumber*) 0, f, wksp); -} - -/* - * implements IEEE P1363 A.15.6 - * - * f, min, max are optional - */ -int mpprndr_w(mpbarrett* p, randomGeneratorContext* rc, size_t bits, int t, const mpnumber* min, const mpnumber* max, const mpnumber* f, mpw* wksp) -{ - /* - * Generate a prime into p with the requested number of bits - * - * Conditions: size(f) <= size(p) - * - * Optional input min: if min is not null, then search p so that min <= p - * Optional input max: if max is not null, then search p so that p <= max - * Optional input f: if f is not null, then search p so that GCD(p-1,f) = 1 - */ - - size_t size = MP_BITS_TO_WORDS(bits + MP_WBITS - 1); - - /* if min has more bits than what was requested for p, bail out */ - if (min && (mpbits(min->size, min->data) > bits)) - return -1; - - /* if max has a different number of bits than what was requested for p, bail out */ - if (max && (mpbits(max->size, max->data) != bits)) - return -1; - - /* if min is not less than max, bail out */ - if (min && max && mpgex(min->size, min->data, max->size, max->data)) - return -1; - - mpbinit(p, size); - - if (p->modl) - { - while (1) - { - /* - * Generate a random appropriate candidate prime, and test - * it with small prime divisor test BEFORE computing mu - */ - mpprndbits(p, bits, 1, min, max, rc, wksp); - - /* do a small prime product trial division test on p */ - if (!mppsppdiv_w(p, wksp)) - continue; - - /* if we have an f, do the congruence test */ - if (f != (mpnumber*) 0) - { - mpcopy(size, wksp, p->modl); - mpsubw(size, wksp, 1); - mpsetx(size, wksp+size, f->size, f->data); - mpgcd_w(size, wksp, wksp+size, wksp+2*size, wksp+3*size); - - if (!mpisone(size, wksp+2*size)) - continue; - } - - /* candidate has passed so far, now we do the probabilistic test */ - mpbmu_w(p, wksp); - - if (mppmilrab_w(p, rc, t, wksp)) - return 0; - } - } - return -1; -} - -/* - * needs workspace of (8*size+2) words - */ -void mpprndconone_w(mpbarrett* p, randomGeneratorContext* rc, size_t bits, int t, const mpbarrett* q, const mpnumber* f, mpnumber* r, int cofactor, mpw* wksp) -{ - /* - * Generate a prime p with n bits such that p mod q = 1, and p = qr+1 where r = 2s - * - * Conditions: q > 2 and size(q) < size(p) and size(f) <= size(p) - * - * Conditions: r must be chosen so that r is even, otherwise p will be even! - * - * if cofactor == 0, then s will be chosen randomly - * if cofactor == 1, then make sure that q does not divide r, i.e.: - * q cannot be equal to r, since r is even, and q > 2; hence if q <= r make sure that GCD(q,r) == 1 - * if cofactor == 2, then make sure that s is prime - * - * Optional input f: if f is not null, then search p so that GCD(p-1,f) = 1 - */ - - mpbinit(p, MP_BITS_TO_WORDS(bits + MP_WBITS - 1)); - - if (p->modl != (mpw*) 0) - { - size_t sbits = bits - mpbits(q->size, q->modl) - 1; - mpbarrett s; - - mpbzero(&s); - mpbinit(&s, MP_BITS_TO_WORDS(sbits + MP_WBITS - 1)); - - while (1) - { - mpprndbits(&s, sbits, 0, (mpnumber*) 0, (mpnumber*) 0, rc, wksp); - - if (cofactor == 1) - { - mpsetlsb(s.size, s.modl); - - /* if (q <= s) check if GCD(q,s) != 1 */ - if (mplex(q->size, q->modl, s.size, s.modl)) - { - /* we can find adequate storage for computing the gcd in s->wksp */ - mpsetx(s.size, wksp, q->size, q->modl); - mpgcd_w(s.size, s.modl, wksp, wksp+s.size, wksp+2*s.size); - - if (!mpisone(s.size, wksp+s.size)) - continue; - } - } - else if (cofactor == 2) - { - mpsetlsb(s.size, s.modl); - } - - if (cofactor == 2) - { - /* do a small prime product trial division test on r */ - if (!mppsppdiv_w(&s, wksp)) - continue; - } - - /* multiply q*s */ - mpmul(wksp, s.size, s.modl, q->size, q->modl); - /* s.size + q.size may be greater than p.size by 1, but the product will fit exactly into p */ - mpsetx(p->size, p->modl, s.size+q->size, wksp); - /* multiply by two and add 1 */ - mpmultwo(p->size, p->modl); - mpaddw(p->size, p->modl, 1); - /* test if the product actually contains enough bits */ - if (mpbits(p->size, p->modl) < bits) - continue; - - /* do a small prime product trial division test on p */ - if (!mppsppdiv_w(p, wksp)) - continue; - - /* if we have an f, do the congruence test */ - if (f != (mpnumber*) 0) - { - mpcopy(p->size, wksp, p->modl); - mpsubw(p->size, wksp, 1); - mpsetx(p->size, wksp, f->size, f->data); - mpgcd_w(p->size, wksp, wksp+p->size, wksp+2*p->size, wksp+3*p->size); - if (!mpisone(p->size, wksp+2*p->size)) - continue; - } - - /* if cofactor is two, test if s is prime */ - if (cofactor == 2) - { - mpbmu_w(&s, wksp); - - if (!mppmilrab_w(&s, rc, mpptrials(sbits), wksp)) - continue; - } - - /* candidate has passed so far, now we do the probabilistic test on p */ - mpbmu_w(p, wksp); - - if (!mppmilrab_w(p, rc, t, wksp)) - continue; - - mpnset(r, s.size, s.modl); - mpmultwo(r->size, r->data); - mpbfree(&s); - - return; - } - } -} - -void mpprndsafe_w(mpbarrett* p, randomGeneratorContext* rc, size_t bits, int t, mpw* wksp) -{ - /* - * Initialize with a probable safe prime of 'size' words, with probability factor t - * - * A safe prime p has the property that p = 2q+1, where q is also prime - * Use for ElGamal type schemes, where a generator of order (p-1) is required - */ - size_t size = MP_BITS_TO_WORDS(bits + MP_WBITS - 1); - - mpbinit(p, size); - - if (p->modl != (mpw*) 0) - { - mpbarrett q; - - mpbzero(&q); - mpbinit(&q, size); - - while (1) - { - /* - * Generate a random appropriate candidate prime, and test - * it with small prime divisor test BEFORE computing mu - */ - - mpprndbits(p, bits, 2, (mpnumber*) 0, (mpnumber*) 0, rc, wksp); - - mpcopy(size, q.modl, p->modl); - mpdivtwo(size, q.modl); - - /* do a small prime product trial division on q */ - if (!mppsppdiv_w(&q, wksp)) - continue; - - /* do a small prime product trial division on p */ - if (!mppsppdiv_w(p, wksp)) - continue; - - /* candidate prime has passed small prime division test for p and q */ - mpbmu_w(&q, wksp); - - if (!mppmilrab_w(&q, rc, t, wksp)) - continue; - - mpbmu_w(p, wksp); - - if (!mppmilrab_w(p, rc, t, wksp)) - continue; - - mpbfree(&q); - - return; - } - } -} diff --git a/beecrypt/mpprime.h b/beecrypt/mpprime.h deleted file mode 100644 index e0cabc275..000000000 --- a/beecrypt/mpprime.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2003 Bob Deblier - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file mpprime.h - * \brief Multi-precision primes, headers. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup MP_m - */ - -#ifndef _MPPRIME_H -#define _MPPRIME_H - -#include "mpbarrett.h" - -#define SMALL_PRIMES_PRODUCT_MAX 32 - -extern mpw* mpspprod[SMALL_PRIMES_PRODUCT_MAX]; - -#ifdef __cplusplus -extern "C" { -#endif - -BEECRYPTAPI -int mpptrials (size_t bits) - /*@*/; -BEECRYPTAPI -int mppmilrab_w (const mpbarrett* p, randomGeneratorContext* rc, int t, mpw* wksp) - /*@modifies wksp @*/; - -BEECRYPTAPI -int mpprnd_w (mpbarrett* p, randomGeneratorContext* rc, size_t bits, int t, /*@null@*/ const mpnumber* f, mpw* wksp) - /*@modifies p, wksp @*/; -BEECRYPTAPI -int mpprndr_w (mpbarrett* p, randomGeneratorContext* rc, size_t bits, int t, /*@null@*/ const mpnumber* min, /*@null@*/ const mpnumber* max, const mpnumber* f, mpw* wksp) - /*@modifies p, wksp @*/; -BEECRYPTAPI -void mpprndsafe_w (mpbarrett* p, randomGeneratorContext* rc, size_t bits, int t, mpw* wksp) - /*@modifies p, wksp @*/; -BEECRYPTAPI -void mpprndcon_w (mpbarrett*, randomGeneratorContext*, size_t, int, const mpnumber*, const mpnumber*, const mpnumber*, mpnumber*, mpw*) - /*@*/; -BEECRYPTAPI -void mpprndconone_w(mpbarrett* p, randomGeneratorContext* rc, size_t bits, int t, const mpbarrett* q, /*@null@*/ const mpnumber* f, mpnumber* r, int cofactor, mpw* wksp) - /*@modifies p, r, wksp @*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/mtprng.c b/beecrypt/mtprng.c deleted file mode 100644 index 835214fce..000000000 --- a/beecrypt/mtprng.c +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright (c) 1998, 1999, 2000, 2001 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\mtprng.c - * \brief Mersenne Twister pseudo-random number generator. - * - * Developed by Makoto Matsumoto and Takuji Nishimura. For more information, - * see: http://www.math.keio.ac.jp/~matumoto/emt.html - * - * Adapted from optimized code by Shawn J. Cokus <cokus@math.washington.edu> - * - * \warning This generator has a very long period, passes statistical test and - * is very fast, but is not recommended for use in cryptography. - * - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup PRNG_m - */ - -#include "system.h" - -#include "beecrypt.h" -#include "mtprng.h" -#include "mpopt.h" -#include "mp.h" - -#include "debug.h" - -#define hiBit(a) ((a) & 0x80000000U) -#define loBit(a) ((a) & 0x1U) -#define loBits(a) ((a) & 0x7FFFFFFFU) -#define mixBits(a, b) (hiBit(a) | loBits(b)) - -const randomGenerator mtprng = { "Mersenne Twister", sizeof(mtprngParam), (randomGeneratorSetup) mtprngSetup, (randomGeneratorSeed) mtprngSeed, (randomGeneratorNext) mtprngNext, (randomGeneratorCleanup) mtprngCleanup }; - -static void mtprngReload(mtprngParam* mp) - /*@modifies mp @*/ -{ - register uint32_t *p0 = mp->state; - register uint32_t *p2 = p0+2, *pM = p0+M, s0, s1; - register int j; - - for (s0=mp->state[0], s1=mp->state[1], j=N-M+1; --j; s0=s1, s1=*(p2++)) - *(p0++) = *(pM++) ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0); - - for (pM=mp->state, j=M; --j; s0=s1, s1=*(p2++)) - *(p0++) = *(pM++) ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0); - - s1 = mp->state[0], *p0 = *pM ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0); - - mp->left = N; - mp->nextw = mp->state; -} - -int mtprngSetup(mtprngParam* mp) -{ - if (mp) - { - #ifdef _REENTRANT - # if WIN32 - if (!(mp->lock = CreateMutex(NULL, FALSE, NULL))) - return -1; - # else - # if HAVE_THREAD_H && HAVE_SYNCH_H - if (mutex_init(&mp->lock, USYNC_THREAD, (void *) 0)) - return -1; - # elif HAVE_PTHREAD_H - if (pthread_mutex_init(&mp->lock, (pthread_mutexattr_t *) 0)) - return -1; - # endif - # endif - #endif - - mp->left = 0; - - return entropyGatherNext((byte*) mp->state, (N+1) * sizeof(uint32_t)); - } - return -1; -} - -int mtprngSeed(mtprngParam* mp, const byte* data, size_t size) -{ - if (mp) - { - size_t needed = (N+1) * sizeof(uint32_t); - byte* dest = (byte*) mp->state; - - #ifdef _REENTRANT - # if WIN32 - if (WaitForSingleObject(mp->lock, INFINITE) != WAIT_OBJECT_0) - return -1; - # else - # if HAVE_THREAD_H && HAVE_SYNCH_H - if (mutex_lock(&mp->lock)) - return -1; - # elif HAVE_PTHREAD_H - if (pthread_mutex_lock(&mp->lock)) - return -1; - # endif - # endif - #endif - while (size < needed) - { - memcpy(dest, data, size); - dest += size; - needed -= size; - } - memcpy(dest, data, needed); - #ifdef _REENTRANT - # if WIN32 - if (!ReleaseMutex(mp->lock)) - return -1; - # else - # if HAVE_THREAD_H && HAVE_SYNCH_H - if (mutex_unlock(&mp->lock)) - return -1; - # elif HAVE_PTHREAD_H - if (pthread_mutex_unlock(&mp->lock)) - return -1; - # endif - # endif - #endif - return 0; - } - return -1; -} - -int mtprngNext(mtprngParam* mp, byte* data, size_t size) -{ - if (mp) - { - uint32_t tmp; - - #ifdef _REENTRANT - # if WIN32 - if (WaitForSingleObject(mp->lock, INFINITE) != WAIT_OBJECT_0) - return -1; - # else - # if HAVE_THREAD_H && HAVE_SYNCH_H - if (mutex_lock(&mp->lock)) - return -1; - # elif HAVE_PTHREAD_H - if (pthread_mutex_lock(&mp->lock)) - return -1; - # endif - # endif - #endif - while (size > 0) - { - if (mp->left == 0) - mtprngReload(mp); - - tmp = *(mp->nextw++); - tmp ^= (tmp >> 11); - tmp ^= (tmp << 7) & 0x9D2C5680U; - tmp ^= (tmp << 15) & 0xEFC60000U; - tmp ^= (tmp >> 18); - mp->left--; - - if (size >= 4) - { - memcpy(data, &tmp, 4); - size -= 4; - } - else - { - memcpy(data, &tmp, size); - size = 0; - } - } - #ifdef _REENTRANT - # if WIN32 - if (!ReleaseMutex(mp->lock)) - return -1; - # else - # if HAVE_THREAD_H && HAVE_SYNCH_H - if (mutex_unlock(&mp->lock)) - return -1; - # elif HAVE_PTHREAD_H - if (pthread_mutex_unlock(&mp->lock)) - return -1; - # endif - # endif - #endif - return 0; - } - return -1; -} - -int mtprngCleanup(mtprngParam* mp) -{ - if (mp) - { - #ifdef _REENTRANT - # if WIN32 - if (!CloseHandle(mp->lock)) - return -1; - # else - # if HAVE_THREAD_H && HAVE_SYNCH_H - if (mutex_destroy(&mp->lock)) - return -1; - # elif HAVE_PTHREAD_H - if (pthread_mutex_destroy(&mp->lock)) - return -1; - # endif - # endif - #endif - return 0; - } - return -1; -} diff --git a/beecrypt/mtprng.h b/beecrypt/mtprng.h deleted file mode 100644 index bfa6ad126..000000000 --- a/beecrypt/mtprng.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 1998, 1999, 2000, 2003 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file mtprng.h - * \brief Mersenne Twister pseudo-random number generator, headers. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup PRNG_m - */ - -#ifndef _MTPRNG_H -#define _MTPRNG_H - -#include "beecrypt.h" - -#ifdef _REENTRANT -# if WIN32 -# include <windows.h> -# include <winbase.h> -# endif -#endif - -#define N 624 -#define M 397 -#define K 0x9908B0DFU - -/* - */ -typedef struct -{ - #ifdef _REENTRANT - bc_mutex_t lock; - #endif - uint32_t state[N+1]; - uint32_t left; - uint32_t* nextw; -} mtprngParam; - -#ifdef __cplusplus -extern "C" { -#endif - -/* - */ -extern BEECRYPTAPI const randomGenerator mtprng; - -/* - */ -BEECRYPTAPI -int mtprngSetup (mtprngParam* mp) - /*@modifies mp @*/; - -/* - */ -BEECRYPTAPI -int mtprngSeed (mtprngParam* mp, const byte* data, size_t size) - /*@modifies mp @*/; - -/* - */ -BEECRYPTAPI -int mtprngNext (mtprngParam* mp, byte* data, size_t size) - /*@modifies mp, data @*/; - -/* - */ -BEECRYPTAPI -int mtprngCleanup(mtprngParam* mp) - /*@*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/pkcs1.c b/beecrypt/pkcs1.c deleted file mode 100644 index 40900b5d7..000000000 --- a/beecrypt/pkcs1.c +++ /dev/null @@ -1,64 +0,0 @@ -#include "system.h" - -#include "pkcs1.h" - -#include "debug.h" - -const byte EMSA_MD5_DIGESTINFO[18] = { - 0x30,0x20,0x30,0x0c,0x06,0x08,0x2a,0x86,0x48,0x86,0xf7,0x0d,0x02,0x05,0x05,0x00, - 0x04,0x10 -}; - -const byte EMSA_SHA1_DIGESTINFO[15] = { - 0x30,0x21,0x30,0x09,0x06,0x05,0x2b,0x0e,0x03,0x02,0x1a,0x05,0x00,0x04,0x14 -}; - -const byte EMSA_SHA256_DIGESTINFO[19] = { - 0x30,0x31,0x30,0x0d,0x06,0x09,0x60,0x86,0x48,0x01,0x65,0x03,0x04,0x02,0x01,0x05, - 0x00,0x04,0x20 -}; - -int pkcs1_emsa_encode_digest(hashFunctionContext* ctxt, byte* emdata, size_t emlen) -{ - int rc = -1; - const byte* tinfo; - size_t tlen, digestsize = ctxt->algo->digestsize; - - if (strcmp(ctxt->algo->name, "MD5") == 0) - { - /* tlen is 18 bytes for EMSA_MD5_DIGESTINFO plus digestsize */ - tinfo = EMSA_MD5_DIGESTINFO; - tlen = 18; - } - else if (strcmp(ctxt->algo->name, "SHA-1") == 0) - { - /* tlen is 15 bytes for EMSA_SHA1_DIGESTINFO plus 20 bytes digest */ - tinfo = EMSA_SHA1_DIGESTINFO; - tlen = 15; - } - else if (strcmp(ctxt->algo->name, "SHA-256") == 0) - { - /* tlen is 19 bytes for EMSA_SHA256_DIGESTINFO plus 32 bytes digest */ - tinfo = EMSA_SHA256_DIGESTINFO; - tlen = 19; - } - else - goto cleanup; - - tlen += digestsize; - - /* fill emdata with 0x00 0x01 0xff .... 0xff 0x00 EMSA_x_DIGESTINFO DIGEST */ - emdata[0] = 0x00; - emdata[1] = 0x01; - memset(emdata+2, 0xff, emlen-tlen-3); - emdata[emlen-tlen-1] = 0x00; - memcpy(emdata+emlen-tlen, tinfo, tlen-digestsize); - - hashFunctionContextDigest(ctxt, emdata+emlen-digestsize); - - rc = 0; - -cleanup: - - return rc; -} diff --git a/beecrypt/pkcs1.h b/beecrypt/pkcs1.h deleted file mode 100644 index a9943ca8d..000000000 --- a/beecrypt/pkcs1.h +++ /dev/null @@ -1,28 +0,0 @@ -/*!\file pkcs1.h - * \brief PKCS#1 utility routines - * \ingroup PKCS1_m - */ - -#ifndef _PKCS1_H -#define _PKCS1_H - -#include "beecrypt.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/*!\brief This function computes the digest, and encodes it it according to PKCS#1 for signing - * \param ctxt The hash function context - * \param emdata - * \param emsize - */ -BEECRYPTAPI -int pkcs1_emsa_encode_digest(hashFunctionContext* ctxt, byte* emdata, size_t emsize) - /*@modifies ctxt, emdata @*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/pkcs12.c b/beecrypt/pkcs12.c deleted file mode 100644 index 95a0cc960..000000000 --- a/beecrypt/pkcs12.c +++ /dev/null @@ -1,83 +0,0 @@ -#include "system.h" - -#include "pkcs12.h" - -#include "debug.h" - -int pkcs12_derive_key(const hashFunction* h, byte id, const byte* pdata, size_t psize, const byte* sdata, size_t ssize, size_t iterationcount, byte* ndata, size_t nsize) -{ - int rc = -1; - size_t i, remain; - hashFunctionContext ctxt; - byte *digest; - - digest = (byte*) malloc(h->digestsize); - if (!digest) - goto cleanup; - - if (hashFunctionContextInit(&ctxt, h)) - goto cleanup; - - /* we start by hashing the diversifier; don't allocate a buffer for this */ - for (i = 0; i < h->blocksize; i++) - hashFunctionContextUpdate(&ctxt, &id, 1); - - /* next we hash the salt data, concatenating until we have a whole number of blocks */ - if (ssize) - { - remain = ((ssize / h->blocksize) + (ssize % h->blocksize)) * h->blocksize; - while (remain > 0) - { - size_t tmp = remain > ssize ? ssize : remain; - - hashFunctionContextUpdate(&ctxt, sdata, tmp); - - remain -= tmp; - } - } - - /* next we hash the password data, concatenating until we have a whole number of blocks */ - if (psize) - { - remain = ((psize / h->blocksize) + (psize % h->blocksize)) * h->blocksize; - while (remain > 0) - { - size_t tmp = remain > psize ? psize : remain; - - hashFunctionContextUpdate(&ctxt, pdata, tmp); - - remain -= tmp; - } - } - - /* now we iterate through the following loop */ - while (iterationcount-- > 0) - { - hashFunctionContextDigest(&ctxt, digest); - hashFunctionContextUpdate(&ctxt, digest, h->digestsize); - } - - /* do the final digest */ - hashFunctionContextDigest(&ctxt, digest); - - /* fill key */ - while (nsize > 0) - { - size_t tmp = nsize > h->digestsize ? h->digestsize : nsize; - - memcpy(ndata, digest, tmp); - ndata += tmp; - nsize -= tmp; - } - - if (hashFunctionContextFree(&ctxt)) - goto cleanup; - - rc = 0; - -cleanup: - if (digest) - free(digest); - - return rc; -} diff --git a/beecrypt/pkcs12.h b/beecrypt/pkcs12.h deleted file mode 100644 index 927a7ba2d..000000000 --- a/beecrypt/pkcs12.h +++ /dev/null @@ -1,27 +0,0 @@ -/*!\file pkcs12.h - * \brief PKCS#12 utility routines - * \ingroup PKCS12_m - */ - -#ifndef _PKCS12_H -#define _PKCS12_H - -#include "beecrypt.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define PKCS12_ID_CIPHER 0x1 -#define PKCS12_ID_IV 0x2 -#define PKCS12_ID_MAC 0x3 - -BEECRYPTAPI -int pkcs12_derive_key(const hashFunction* h, byte id, const byte* pdata, size_t psize, const byte* sdata, size_t ssize, size_t iterationcount, byte* ndata, size_t nsize) - /*@modifies ndata @*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/python/.cvsignore b/beecrypt/python/.cvsignore deleted file mode 100644 index 88b36fbdd..000000000 --- a/beecrypt/python/.cvsignore +++ /dev/null @@ -1,7 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.la -*.lo -*.pyc diff --git a/beecrypt/python/Makefile.am b/beecrypt/python/Makefile.am deleted file mode 100644 index d4223d53c..000000000 --- a/beecrypt/python/Makefile.am +++ /dev/null @@ -1,31 +0,0 @@ -# Makefile for rpm library. - -AUTOMAKE_OPTIONS = 1.4 foreign no-dependencies - -LINT = splint - -SUBDIRS = test - -EXTRA_DIST = debug-py.c - -INCLUDES = -I. \ - -I$(top_srcdir)/.. @PYTHONINC@ - -noinst_HEADERS = mpw-py.h rng-py.h - -mylibs = $(top_builddir)/libbeecrypt.la - -LDADD = - -pythondir = @PYTHONLIB@ -python_LTLIBRARIES = _bc.la - -_bc_la_SOURCES = _bc-py.c mpw-py.c rng-py.c -_bc_la_LDFLAGS = -avoid-version -module -_bc_la_LIBADD = $(mylibs) - -splint_srcs = _bc-py.c $(libbc_la_sources) - -.PHONY: lint -lint: - $(LINT) $(DEFS) $(INCLUDES) $(splint_srcs) diff --git a/beecrypt/python/_bc-py.c b/beecrypt/python/_bc-py.c deleted file mode 100644 index d2f4b9b30..000000000 --- a/beecrypt/python/_bc-py.c +++ /dev/null @@ -1,89 +0,0 @@ -/** \ingroup py_c - * \file python/_bc-py.c - */ - -#define _REENTRANT 1 /* XXX config.h collides with pyconfig.h */ -#include "system.h" - -#include "mpw-py.h" -#include "rng-py.h" - -#include "debug.h" - -/** - */ -PyObject * py_bcError; - -/** - */ -static PyMethodDef _bcModuleMethods[] = { - { NULL } -} ; - -/** - */ -static char _bc__doc__[] = -""; - -void init_bc(void); /* XXX eliminate gcc warning */ -/** - */ -void init_bc(void) -{ - PyObject *d, *m; -#ifdef NOTYET - PyObject *o, *dict; - int i; -#endif - - if (PyType_Ready(&mpw_Type) < 0) return; - if (PyType_Ready(&rng_Type) < 0) return; - - m = Py_InitModule3("_bc", _bcModuleMethods, _bc__doc__); - if (m == NULL) - return; - - d = PyModule_GetDict(m); - - py_bcError = PyErr_NewException("_bc.error", NULL, NULL); - if (py_bcError != NULL) - PyDict_SetItemString(d, "error", py_bcError); - - Py_INCREF(&mpw_Type); - PyModule_AddObject(m, "mpw", (PyObject *) &mpw_Type); - - Py_INCREF(&rng_Type); - PyModule_AddObject(m, "rng", (PyObject *) &rng_Type); - -#ifdef NOTYET - dict = PyDict_New(); - - for (i = 0; i < _bcTagTableSize; i++) { - tag = PyInt_FromLong(_bcTagTable[i].val); - PyDict_SetItemString(d, (char *) _bcTagTable[i].name, tag); - Py_DECREF(tag); - PyDict_SetItem(dict, tag, o=PyString_FromString(_bcTagTable[i].name + 7)); - Py_DECREF(o); - } - - while (extensions->name) { - if (extensions->type == HEADER_EXT_TAG) { - (const struct headerSprintfExtension *) ext = extensions; - PyDict_SetItemString(d, (char *) extensions->name, o=PyCObject_FromVoidPtr(ext, NULL)); - Py_DECREF(o); - PyDict_SetItem(dict, tag, o=PyString_FromString(ext->name + 7)); - Py_DECREF(o); - } - extensions++; - } - - PyDict_SetItemString(d, "tagnames", dict); - Py_DECREF(dict); - -#define REGISTER_ENUM(val) \ - PyDict_SetItemString(d, #val, o=PyInt_FromLong( val )); \ - Py_DECREF(o); - -#endif - -} diff --git a/beecrypt/python/debug-py.c b/beecrypt/python/debug-py.c deleted file mode 100644 index 62c322b37..000000000 --- a/beecrypt/python/debug-py.c +++ /dev/null @@ -1,65 +0,0 @@ - -/*@unchecked@*/ -extern PyTypeObject PyCode_Type; -/*@unchecked@*/ -extern PyTypeObject PyDictIter_Type; -/*@unchecked@*/ -extern PyTypeObject PyFrame_Type; - -#include "mpw-py.h" /* XXX debug only */ -#include "rng-py.h" /* XXX debug only */ - -#include "debug.h" - -/** - */ -static const char * lbl(void * s) - /*@*/ -{ - PyObject * o = s; - - if (o == NULL) return "null"; - - if (o == Py_None) return "None"; - - if (o->ob_type == &PyType_Type) return o->ob_type->tp_name; - - if (o->ob_type == &PyBaseObject_Type) return "BaseObj"; - if (o->ob_type == &PyBuffer_Type) return "Buffer"; - if (o->ob_type == &PyCFunction_Type) return "CFunction"; - if (o->ob_type == &PyCObject_Type) return "CObject"; - if (o->ob_type == &PyCell_Type) return "Cell"; - if (o->ob_type == &PyClass_Type) return "Class"; - if (o->ob_type == &PyClassMethod_Type) return "ClassMethod"; - if (o->ob_type == &PyStaticMethod_Type) return "StaticMethod"; - if (o->ob_type == &PyCode_Type) return "Code"; - if (o->ob_type == &PyComplex_Type) return "Complex"; - if (o->ob_type == &PyDict_Type) return "Dict"; - if (o->ob_type == &PyDictIter_Type) return "DictIter"; - if (o->ob_type == &PyFile_Type) return "File"; - if (o->ob_type == &PyFloat_Type) return "Float"; - if (o->ob_type == &PyFrame_Type) return "Frame"; - if (o->ob_type == &PyFunction_Type) return "Function"; - if (o->ob_type == &PyInstance_Type) return "Instance"; - if (o->ob_type == &PyInt_Type) return "Int"; - if (o->ob_type == &PyList_Type) return "List"; - if (o->ob_type == &PyLong_Type) return "Long"; - if (o->ob_type == &PyMethod_Type) return "Method"; - if (o->ob_type == &PyWrapperDescr_Type) return "WrapperDescr"; - if (o->ob_type == &PyProperty_Type) return "Property"; - if (o->ob_type == &PyModule_Type) return "Module"; - if (o->ob_type == &PyRange_Type) return "Range"; - if (o->ob_type == &PySeqIter_Type) return "SeqIter"; - if (o->ob_type == &PyCallIter_Type) return "CallIter"; - if (o->ob_type == &PySlice_Type) return "Slice"; - if (o->ob_type == &PyString_Type) return "String"; - if (o->ob_type == &PySuper_Type) return "Super"; - if (o->ob_type == &PyTuple_Type) return "Tuple"; - if (o->ob_type == &PyType_Type) return "Type"; - if (o->ob_type == &PyUnicode_Type) return "Unicode"; - - if (o->ob_type == &mpw_Type) return "mpw"; - if (o->ob_type == &rng_Type) return "rng"; - - return "Unknown"; -} diff --git a/beecrypt/python/mpw-py.c b/beecrypt/python/mpw-py.c deleted file mode 100644 index c5303da3d..000000000 --- a/beecrypt/python/mpw-py.c +++ /dev/null @@ -1,2342 +0,0 @@ -/** \ingroup py_c - * \file python/mpw-py.c - */ - -#define _REENTRANT 1 /* XXX config.h collides with pyconfig.h */ - -#include "system.h" - -#include "longintrepr.h" - -#include "mpw-py.h" -#include "rng-py.h" - -#include "debug-py.c" - -#include "debug.h" - -#define ABS(_x) ((_x) < 0 ? -(_x) : (_x)) -#if !defined(MAX) -#define MAX(x, y) ((x) < (y) ? (y) : (x)) -#endif -#if !defined(MIN) -#define MIN(x, y) ((x) > (y) ? (y) : (x)) -#endif - -#define MPBITCNT(_s, _d) (MP_WORDS_TO_BITS(_s) - mpmszcnt((_s), (_d))) - -#define BITS_TO_DIGITS(_b) (((_b) + SHIFT - 1)/SHIFT) -#define DIGITS_TO_BITS(_d) ((_d) * SHIFT) - -/*@unchecked@*/ -static int _ie = 0x44332211; -/*@unchecked@*/ -static union _dendian { -/*@unused@*/ - int i; - char b[4]; -} *_endian = (union _dendian *)&_ie; -#define IS_BIG_ENDIAN() (_endian->b[0] == '\x44') -#define IS_LITTLE_ENDIAN() (_endian->b[0] == '\x11') - -/*@unchecked@*/ -static int _mpw_debug = 0; - -/*@unchecked@*/ /*@observer@*/ -static const char *initialiser_name = ""; - -/*@unchecked@*/ /*@observer@*/ -static const struct { - /* Number of digits in the conversion base that always fits in an mp_limb_t. - For example, for base 10 on a machine where a mp_limb_t has 32 bits this - is 9, since 10**9 is the largest number that fits into a mp_limb_t. */ - int chars_per_limb; - - /* log(2)/log(conversion_base) */ - double chars_per_bit_exactly; - - /* base**chars_per_limb, i.e. the biggest number that fits a word, built by - factors of base. Exception: For 2, 4, 8, etc, big_base is log2(base), - i.e. the number of bits used to represent each digit in the base. */ - unsigned int big_base; - - /* A BITS_PER_MP_LIMB bit approximation to 1/big_base, represented as a - fixed-point number. Instead of dividing by big_base an application can - choose to multiply by big_base_inverted. */ - unsigned int big_base_inverted; -} mp_bases[257] = { - /* 0 */ {0, 0.0, 0, 0}, - /* 1 */ {0, 1e37, 0, 0}, - /* 2 */ {32, 1.0000000000000000, 0x1, 0x0}, - /* 3 */ {20, 0.6309297535714574, 0xcfd41b91, 0x3b563c24}, - /* 4 */ {16, 0.5000000000000000, 0x2, 0x0}, - /* 5 */ {13, 0.4306765580733931, 0x48c27395, 0xc25c2684}, - /* 6 */ {12, 0.3868528072345416, 0x81bf1000, 0xf91bd1b6}, - /* 7 */ {11, 0.3562071871080222, 0x75db9c97, 0x1607a2cb}, - /* 8 */ {10, 0.3333333333333333, 0x3, 0x0}, - /* 9 */ {10, 0.3154648767857287, 0xcfd41b91, 0x3b563c24}, - /* 10 */ {9, 0.3010299956639812, 0x3b9aca00, 0x12e0be82}, - /* 11 */ {9, 0.2890648263178878, 0x8c8b6d2b, 0xd24cde04}, - /* 12 */ {8, 0.2789429456511298, 0x19a10000, 0x3fa39ab5}, - /* 13 */ {8, 0.2702381544273197, 0x309f1021, 0x50f8ac5f}, - /* 14 */ {8, 0.2626495350371935, 0x57f6c100, 0x74843b1e}, - /* 15 */ {8, 0.2559580248098155, 0x98c29b81, 0xad0326c2}, - /* 16 */ {8, 0.2500000000000000, 0x4, 0x0}, - /* 17 */ {7, 0.2446505421182260, 0x18754571, 0x4ef0b6bd}, - /* 18 */ {7, 0.2398124665681314, 0x247dbc80, 0xc0fc48a1}, - /* 19 */ {7, 0.2354089133666382, 0x3547667b, 0x33838942}, - /* 20 */ {7, 0.2313782131597592, 0x4c4b4000, 0xad7f29ab}, - /* 21 */ {7, 0.2276702486969530, 0x6b5a6e1d, 0x313c3d15}, - /* 22 */ {7, 0.2242438242175754, 0x94ace180, 0xb8cca9e0}, - /* 23 */ {7, 0.2210647294575037, 0xcaf18367, 0x42ed6de9}, - /* 24 */ {6, 0.2181042919855316, 0xb640000, 0x67980e0b}, - /* 25 */ {6, 0.2153382790366965, 0xe8d4a51, 0x19799812}, - /* 26 */ {6, 0.2127460535533632, 0x1269ae40, 0xbce85396}, - /* 27 */ {6, 0.2103099178571525, 0x17179149, 0x62c103a9}, - /* 28 */ {6, 0.2080145976765095, 0x1cb91000, 0x1d353d43}, - /* 29 */ {6, 0.2058468324604344, 0x23744899, 0xce1decea}, - /* 30 */ {6, 0.2037950470905062, 0x2b73a840, 0x790fc511}, - /* 31 */ {6, 0.2018490865820999, 0x34e63b41, 0x35b865a0}, - /* 32 */ {6, 0.2000000000000000, 0x5, 0x0}, - /* 33 */ {6, 0.1982398631705605, 0x4cfa3cc1, 0xa9aed1b3}, - /* 34 */ {6, 0.1965616322328226, 0x5c13d840, 0x63dfc229}, - /* 35 */ {6, 0.1949590218937863, 0x6d91b519, 0x2b0fee30}, - /* 36 */ {6, 0.1934264036172708, 0x81bf1000, 0xf91bd1b6}, - /* 37 */ {6, 0.1919587200065601, 0x98ede0c9, 0xac89c3a9}, - /* 38 */ {6, 0.1905514124267734, 0xb3773e40, 0x6d2c32fe}, - /* 39 */ {6, 0.1892003595168700, 0xd1bbc4d1, 0x387907c9}, - /* 40 */ {6, 0.1879018247091076, 0xf4240000, 0xc6f7a0b}, - /* 41 */ {5, 0.1866524112389434, 0x6e7d349, 0x28928154}, - /* 42 */ {5, 0.1854490234153689, 0x7ca30a0, 0x6e8629d}, - /* 43 */ {5, 0.1842888331487062, 0x8c32bbb, 0xd373dca0}, - /* 44 */ {5, 0.1831692509136336, 0x9d46c00, 0xa0b17895}, - /* 45 */ {5, 0.1820879004699383, 0xaffacfd, 0x746811a5}, - /* 46 */ {5, 0.1810425967800402, 0xc46bee0, 0x4da6500f}, - /* 47 */ {5, 0.1800313266566926, 0xdab86ef, 0x2ba23582}, - /* 48 */ {5, 0.1790522317510414, 0xf300000, 0xdb20a88}, - /* 49 */ {5, 0.1781035935540111, 0x10d63af1, 0xe68d5ce4}, - /* 50 */ {5, 0.1771838201355579, 0x12a05f20, 0xb7cdfd9d}, - /* 51 */ {5, 0.1762914343888821, 0x1490aae3, 0x8e583933}, - /* 52 */ {5, 0.1754250635819545, 0x16a97400, 0x697cc3ea}, - /* 53 */ {5, 0.1745834300480449, 0x18ed2825, 0x48a5ca6c}, - /* 54 */ {5, 0.1737653428714400, 0x1b5e4d60, 0x2b52db16}, - /* 55 */ {5, 0.1729696904450771, 0x1dff8297, 0x111586a6}, - /* 56 */ {5, 0.1721954337940981, 0x20d38000, 0xf31d2b36}, - /* 57 */ {5, 0.1714416005739134, 0x23dd1799, 0xc8d76d19}, - /* 58 */ {5, 0.1707072796637201, 0x271f35a0, 0xa2cb1eb4}, - /* 59 */ {5, 0.1699916162869140, 0x2a9ce10b, 0x807c3ec3}, - /* 60 */ {5, 0.1692938075987814, 0x2e593c00, 0x617ec8bf}, - /* 61 */ {5, 0.1686130986895011, 0x3257844d, 0x45746cbe}, - /* 62 */ {5, 0.1679487789570419, 0x369b13e0, 0x2c0aa273}, - /* 63 */ {5, 0.1673001788101741, 0x3b27613f, 0x14f90805}, - /* 64 */ {5, 0.1666666666666667, 0x6, 0x0}, - /* 65 */ {5, 0.1660476462159378, 0x4528a141, 0xd9cf0829}, - /* 66 */ {5, 0.1654425539190583, 0x4aa51420, 0xb6fc4841}, - /* 67 */ {5, 0.1648508567221603, 0x50794633, 0x973054cb}, - /* 68 */ {5, 0.1642720499620502, 0x56a94400, 0x7a1dbe4b}, - /* 69 */ {5, 0.1637056554452156, 0x5d393975, 0x5f7fcd7f}, - /* 70 */ {5, 0.1631512196835108, 0x642d7260, 0x47196c84}, - /* 71 */ {5, 0.1626083122716342, 0x6b8a5ae7, 0x30b43635}, - /* 72 */ {5, 0.1620765243931223, 0x73548000, 0x1c1fa5f6}, - /* 73 */ {5, 0.1615554674429964, 0x7b908fe9, 0x930634a}, - /* 74 */ {5, 0.1610447717564444, 0x84435aa0, 0xef7f4a3c}, - /* 75 */ {5, 0.1605440854340214, 0x8d71d25b, 0xcf5552d2}, - /* 76 */ {5, 0.1600530732548213, 0x97210c00, 0xb1a47c8e}, - /* 77 */ {5, 0.1595714156699382, 0xa1563f9d, 0x9634b43e}, - /* 78 */ {5, 0.1590988078692941, 0xac16c8e0, 0x7cd3817d}, - /* 79 */ {5, 0.1586349589155960, 0xb768278f, 0x65536761}, - /* 80 */ {5, 0.1581795909397823, 0xc3500000, 0x4f8b588e}, - /* 81 */ {5, 0.1577324383928644, 0xcfd41b91, 0x3b563c24}, - /* 82 */ {5, 0.1572932473495469, 0xdcfa6920, 0x28928154}, - /* 83 */ {5, 0.1568617748594410, 0xeac8fd83, 0x1721bfb0}, - /* 84 */ {5, 0.1564377883420715, 0xf9461400, 0x6e8629d}, - /* 85 */ {4, 0.1560210650222250, 0x31c84b1, 0x491cc17c}, - /* 86 */ {4, 0.1556113914024939, 0x342ab10, 0x3a11d83b}, - /* 87 */ {4, 0.1552085627701551, 0x36a2c21, 0x2be074cd}, - /* 88 */ {4, 0.1548123827357682, 0x3931000, 0x1e7a02e7}, - /* 89 */ {4, 0.1544226628011101, 0x3bd5ee1, 0x11d10edd}, - /* 90 */ {4, 0.1540392219542636, 0x3e92110, 0x5d92c68}, - /* 91 */ {4, 0.1536618862898642, 0x4165ef1, 0xf50dbfb2}, - /* 92 */ {4, 0.1532904886526781, 0x4452100, 0xdf9f1316}, - /* 93 */ {4, 0.1529248683028321, 0x4756fd1, 0xcb52a684}, - /* 94 */ {4, 0.1525648706011593, 0x4a75410, 0xb8163e97}, - /* 95 */ {4, 0.1522103467132434, 0x4dad681, 0xa5d8f269}, - /* 96 */ {4, 0.1518611533308632, 0x5100000, 0x948b0fcd}, - /* 97 */ {4, 0.1515171524096389, 0x546d981, 0x841e0215}, - /* 98 */ {4, 0.1511782109217764, 0x57f6c10, 0x74843b1e}, - /* 99 */ {4, 0.1508442006228941, 0x5b9c0d1, 0x65b11e6e}, - /* 100 */ {4, 0.1505149978319906, 0x5f5e100, 0x5798ee23}, - /* 101 */ {4, 0.1501904832236880, 0x633d5f1, 0x4a30b99b}, - /* 102 */ {4, 0.1498705416319474, 0x673a910, 0x3d6e4d94}, - /* 103 */ {4, 0.1495550618645152, 0x6b563e1, 0x314825b0}, - /* 104 */ {4, 0.1492439365274121, 0x6f91000, 0x25b55f2e}, - /* 105 */ {4, 0.1489370618588283, 0x73eb721, 0x1aadaccb}, - /* 106 */ {4, 0.1486343375718350, 0x7866310, 0x10294ba2}, - /* 107 */ {4, 0.1483356667053617, 0x7d01db1, 0x620f8f6}, - /* 108 */ {4, 0.1480409554829326, 0x81bf100, 0xf91bd1b6}, - /* 109 */ {4, 0.1477501131786861, 0x869e711, 0xe6d37b2a}, - /* 110 */ {4, 0.1474630519902391, 0x8ba0a10, 0xd55cff6e}, - /* 111 */ {4, 0.1471796869179852, 0x90c6441, 0xc4ad2db2}, - /* 112 */ {4, 0.1468999356504447, 0x9610000, 0xb4b985cf}, - /* 113 */ {4, 0.1466237184553111, 0x9b7e7c1, 0xa5782bef}, - /* 114 */ {4, 0.1463509580758620, 0xa112610, 0x96dfdd2a}, - /* 115 */ {4, 0.1460815796324244, 0xa6cc591, 0x88e7e509}, - /* 116 */ {4, 0.1458155105286054, 0xacad100, 0x7b8813d3}, - /* 117 */ {4, 0.1455526803620167, 0xb2b5331, 0x6eb8b595}, - /* 118 */ {4, 0.1452930208392429, 0xb8e5710, 0x627289db}, - /* 119 */ {4, 0.1450364656948130, 0xbf3e7a1, 0x56aebc07}, - /* 120 */ {4, 0.1447829506139581, 0xc5c1000, 0x4b66dc33}, - /* 121 */ {4, 0.1445324131589439, 0xcc6db61, 0x4094d8a3}, - /* 122 */ {4, 0.1442847926987864, 0xd345510, 0x3632f7a5}, - /* 123 */ {4, 0.1440400303421672, 0xda48871, 0x2c3bd1f0}, - /* 124 */ {4, 0.1437980688733776, 0xe178100, 0x22aa4d5f}, - /* 125 */ {4, 0.1435588526911310, 0xe8d4a51, 0x19799812}, - /* 126 */ {4, 0.1433223277500932, 0xf05f010, 0x10a523e5}, - /* 127 */ {4, 0.1430884415049874, 0xf817e01, 0x828a237}, - /* 128 */ {4, 0.1428571428571428, 0x7, 0x0}, - /* 129 */ {4, 0.1426283821033600, 0x10818201, 0xf04ec452}, - /* 130 */ {4, 0.1424021108869747, 0x11061010, 0xe136444a}, - /* 131 */ {4, 0.1421782821510107, 0x118db651, 0xd2af9589}, - /* 132 */ {4, 0.1419568500933153, 0x12188100, 0xc4b42a83}, - /* 133 */ {4, 0.1417377701235801, 0x12a67c71, 0xb73dccf5}, - /* 134 */ {4, 0.1415209988221527, 0x1337b510, 0xaa4698c5}, - /* 135 */ {4, 0.1413064939005528, 0x13cc3761, 0x9dc8f729}, - /* 136 */ {4, 0.1410942141636095, 0x14641000, 0x91bf9a30}, - /* 137 */ {4, 0.1408841194731412, 0x14ff4ba1, 0x86257887}, - /* 138 */ {4, 0.1406761707131039, 0x159df710, 0x7af5c98c}, - /* 139 */ {4, 0.1404703297561400, 0x16401f31, 0x702c01a0}, - /* 140 */ {4, 0.1402665594314587, 0x16e5d100, 0x65c3ceb1}, - /* 141 */ {4, 0.1400648234939879, 0x178f1991, 0x5bb91502}, - /* 142 */ {4, 0.1398650865947379, 0x183c0610, 0x5207ec23}, - /* 143 */ {4, 0.1396673142523192, 0x18eca3c1, 0x48ac9c19}, - /* 144 */ {4, 0.1394714728255649, 0x19a10000, 0x3fa39ab5}, - /* 145 */ {4, 0.1392775294872041, 0x1a592841, 0x36e98912}, - /* 146 */ {4, 0.1390854521985406, 0x1b152a10, 0x2e7b3140}, - /* 147 */ {4, 0.1388952096850913, 0x1bd51311, 0x2655840b}, - /* 148 */ {4, 0.1387067714131417, 0x1c98f100, 0x1e7596ea}, - /* 149 */ {4, 0.1385201075671774, 0x1d60d1b1, 0x16d8a20d}, - /* 150 */ {4, 0.1383351890281539, 0x1e2cc310, 0xf7bfe87}, - /* 151 */ {4, 0.1381519873525671, 0x1efcd321, 0x85d2492}, - /* 152 */ {4, 0.1379704747522905, 0x1fd11000, 0x179a9f4}, - /* 153 */ {4, 0.1377906240751463, 0x20a987e1, 0xf59e80eb}, - /* 154 */ {4, 0.1376124087861776, 0x21864910, 0xe8b768db}, - /* 155 */ {4, 0.1374358029495937, 0x226761f1, 0xdc39d6d5}, - /* 156 */ {4, 0.1372607812113589, 0x234ce100, 0xd021c5d1}, - /* 157 */ {4, 0.1370873187823978, 0x2436d4d1, 0xc46b5e37}, - /* 158 */ {4, 0.1369153914223921, 0x25254c10, 0xb912f39c}, - /* 159 */ {4, 0.1367449754241439, 0x26185581, 0xae150294}, - /* 160 */ {4, 0.1365760475984821, 0x27100000, 0xa36e2eb1}, - /* 161 */ {4, 0.1364085852596902, 0x280c5a81, 0x991b4094}, - /* 162 */ {4, 0.1362425662114337, 0x290d7410, 0x8f19241e}, - /* 163 */ {4, 0.1360779687331669, 0x2a135bd1, 0x8564e6b7}, - /* 164 */ {4, 0.1359147715670014, 0x2b1e2100, 0x7bfbb5b4}, - /* 165 */ {4, 0.1357529539050150, 0x2c2dd2f1, 0x72dadcc8}, - /* 166 */ {4, 0.1355924953769864, 0x2d428110, 0x69ffc498}, - /* 167 */ {4, 0.1354333760385373, 0x2e5c3ae1, 0x6167f154}, - /* 168 */ {4, 0.1352755763596663, 0x2f7b1000, 0x5911016e}, - /* 169 */ {4, 0.1351190772136599, 0x309f1021, 0x50f8ac5f}, - /* 170 */ {4, 0.1349638598663645, 0x31c84b10, 0x491cc17c}, - /* 171 */ {4, 0.1348099059658080, 0x32f6d0b1, 0x417b26d8}, - /* 172 */ {4, 0.1346571975321549, 0x342ab100, 0x3a11d83b}, - /* 173 */ {4, 0.1345057169479844, 0x3563fc11, 0x32dee622}, - /* 174 */ {4, 0.1343554469488779, 0x36a2c210, 0x2be074cd}, - /* 175 */ {4, 0.1342063706143054, 0x37e71341, 0x2514bb58}, - /* 176 */ {4, 0.1340584713587979, 0x39310000, 0x1e7a02e7}, - /* 177 */ {4, 0.1339117329233981, 0x3a8098c1, 0x180ea5d0}, - /* 178 */ {4, 0.1337661393673756, 0x3bd5ee10, 0x11d10edd}, - /* 179 */ {4, 0.1336216750601996, 0x3d311091, 0xbbfb88e}, - /* 180 */ {4, 0.1334783246737591, 0x3e921100, 0x5d92c68}, - /* 181 */ {4, 0.1333360731748201, 0x3ff90031, 0x1c024c}, - /* 182 */ {4, 0.1331949058177136, 0x4165ef10, 0xf50dbfb2}, - /* 183 */ {4, 0.1330548081372441, 0x42d8eea1, 0xea30efa3}, - /* 184 */ {4, 0.1329157659418126, 0x44521000, 0xdf9f1316}, - /* 185 */ {4, 0.1327777653067443, 0x45d16461, 0xd555c0c9}, - /* 186 */ {4, 0.1326407925678156, 0x4756fd10, 0xcb52a684}, - /* 187 */ {4, 0.1325048343149731, 0x48e2eb71, 0xc193881f}, - /* 188 */ {4, 0.1323698773862368, 0x4a754100, 0xb8163e97}, - /* 189 */ {4, 0.1322359088617821, 0x4c0e0f51, 0xaed8b724}, - /* 190 */ {4, 0.1321029160581950, 0x4dad6810, 0xa5d8f269}, - /* 191 */ {4, 0.1319708865228925, 0x4f535d01, 0x9d15039d}, - /* 192 */ {4, 0.1318398080287045, 0x51000000, 0x948b0fcd}, - /* 193 */ {4, 0.1317096685686114, 0x52b36301, 0x8c394d1d}, - /* 194 */ {4, 0.1315804563506306, 0x546d9810, 0x841e0215}, - /* 195 */ {4, 0.1314521597928493, 0x562eb151, 0x7c3784f8}, - /* 196 */ {4, 0.1313247675185968, 0x57f6c100, 0x74843b1e}, - /* 197 */ {4, 0.1311982683517524, 0x59c5d971, 0x6d02985d}, - /* 198 */ {4, 0.1310726513121843, 0x5b9c0d10, 0x65b11e6e}, - /* 199 */ {4, 0.1309479056113158, 0x5d796e61, 0x5e8e5c64}, - /* 200 */ {4, 0.1308240206478128, 0x5f5e1000, 0x5798ee23}, - /* 201 */ {4, 0.1307009860033912, 0x614a04a1, 0x50cf7bde}, - /* 202 */ {4, 0.1305787914387386, 0x633d5f10, 0x4a30b99b}, - /* 203 */ {4, 0.1304574268895465, 0x65383231, 0x43bb66bd}, - /* 204 */ {4, 0.1303368824626505, 0x673a9100, 0x3d6e4d94}, - /* 205 */ {4, 0.1302171484322746, 0x69448e91, 0x374842ee}, - /* 206 */ {4, 0.1300982152363760, 0x6b563e10, 0x314825b0}, - /* 207 */ {4, 0.1299800734730872, 0x6d6fb2c1, 0x2b6cde75}, - /* 208 */ {4, 0.1298627138972530, 0x6f910000, 0x25b55f2e}, - /* 209 */ {4, 0.1297461274170591, 0x71ba3941, 0x2020a2c5}, - /* 210 */ {4, 0.1296303050907487, 0x73eb7210, 0x1aadaccb}, - /* 211 */ {4, 0.1295152381234257, 0x7624be11, 0x155b891f}, - /* 212 */ {4, 0.1294009178639407, 0x78663100, 0x10294ba2}, - /* 213 */ {4, 0.1292873358018581, 0x7aafdeb1, 0xb160fe9}, - /* 214 */ {4, 0.1291744835645007, 0x7d01db10, 0x620f8f6}, - /* 215 */ {4, 0.1290623529140715, 0x7f5c3a21, 0x14930ef}, - /* 216 */ {4, 0.1289509357448472, 0x81bf1000, 0xf91bd1b6}, - /* 217 */ {4, 0.1288402240804449, 0x842a70e1, 0xefdcb0c7}, - /* 218 */ {4, 0.1287302100711566, 0x869e7110, 0xe6d37b2a}, - /* 219 */ {4, 0.1286208859913518, 0x891b24f1, 0xddfeb94a}, - /* 220 */ {4, 0.1285122442369443, 0x8ba0a100, 0xd55cff6e}, - /* 221 */ {4, 0.1284042773229231, 0x8e2ef9d1, 0xcceced50}, - /* 222 */ {4, 0.1282969778809442, 0x90c64410, 0xc4ad2db2}, - /* 223 */ {4, 0.1281903386569819, 0x93669481, 0xbc9c75f9}, - /* 224 */ {4, 0.1280843525090381, 0x96100000, 0xb4b985cf}, - /* 225 */ {4, 0.1279790124049077, 0x98c29b81, 0xad0326c2}, - /* 226 */ {4, 0.1278743114199984, 0x9b7e7c10, 0xa5782bef}, - /* 227 */ {4, 0.1277702427352035, 0x9e43b6d1, 0x9e1771a9}, - /* 228 */ {4, 0.1276667996348261, 0xa1126100, 0x96dfdd2a}, - /* 229 */ {4, 0.1275639755045533, 0xa3ea8ff1, 0x8fd05c41}, - /* 230 */ {4, 0.1274617638294791, 0xa6cc5910, 0x88e7e509}, - /* 231 */ {4, 0.1273601581921740, 0xa9b7d1e1, 0x8225759d}, - /* 232 */ {4, 0.1272591522708010, 0xacad1000, 0x7b8813d3}, - /* 233 */ {4, 0.1271587398372755, 0xafac2921, 0x750eccf9}, - /* 234 */ {4, 0.1270589147554692, 0xb2b53310, 0x6eb8b595}, - /* 235 */ {4, 0.1269596709794558, 0xb5c843b1, 0x6884e923}, - /* 236 */ {4, 0.1268610025517973, 0xb8e57100, 0x627289db}, - /* 237 */ {4, 0.1267629036018709, 0xbc0cd111, 0x5c80c07b}, - /* 238 */ {4, 0.1266653683442337, 0xbf3e7a10, 0x56aebc07}, - /* 239 */ {4, 0.1265683910770258, 0xc27a8241, 0x50fbb19b}, - /* 240 */ {4, 0.1264719661804097, 0xc5c10000, 0x4b66dc33}, - /* 241 */ {4, 0.1263760881150453, 0xc91209c1, 0x45ef7c7c}, - /* 242 */ {4, 0.1262807514205999, 0xcc6db610, 0x4094d8a3}, - /* 243 */ {4, 0.1261859507142915, 0xcfd41b91, 0x3b563c24}, - /* 244 */ {4, 0.1260916806894653, 0xd3455100, 0x3632f7a5}, - /* 245 */ {4, 0.1259979361142023, 0xd6c16d31, 0x312a60c3}, - /* 246 */ {4, 0.1259047118299582, 0xda488710, 0x2c3bd1f0}, - /* 247 */ {4, 0.1258120027502338, 0xdddab5a1, 0x2766aa45}, - /* 248 */ {4, 0.1257198038592741, 0xe1781000, 0x22aa4d5f}, - /* 249 */ {4, 0.1256281102107963, 0xe520ad61, 0x1e06233c}, - /* 250 */ {4, 0.1255369169267456, 0xe8d4a510, 0x19799812}, - /* 251 */ {4, 0.1254462191960791, 0xec940e71, 0x15041c33}, - /* 252 */ {4, 0.1253560122735751, 0xf05f0100, 0x10a523e5}, - /* 253 */ {4, 0.1252662914786691, 0xf4359451, 0xc5c2749}, - /* 254 */ {4, 0.1251770521943144, 0xf817e010, 0x828a237}, - /* 255 */ {4, 0.1250882898658681, 0xfc05fc01, 0x40a1423}, - /* 256 */ {4, 0.1250000000000000, 0x8, 0x0}, -}; - -static void prtmpw(const char * msg, mpwObject * x) - /*@global stderr, fileSystem @*/ - /*@modifies stderr, fileSystem @*/ -{ -fprintf(stderr, "%5.5s %p[%d]:\t", msg, MPW_DATA(x), MPW_SIZE(x)), mpfprintln(stderr, MPW_SIZE(x), MPW_DATA(x)); -} - -static size_t -mpsizeinbase(size_t xsize, mpw* xdata, size_t base) - /*@*/ -{ - size_t nbits; - size_t res; - - if (xsize == 0) - return 1; - - /* XXX assumes positive integer. */ - nbits = MP_WORDS_TO_BITS(xsize) - mpmszcnt(xsize, xdata); - if ((base & (base-1)) == 0) { /* exact power of 2 */ - size_t lbits = mp_bases[base].big_base; - res = (nbits + (lbits - 1)) / lbits; - } else { - res = (nbits * mp_bases[base].chars_per_bit_exactly) + 1; - } -if (_mpw_debug < -1) -fprintf(stderr, "*** mpsizeinbase(%p[%d], %d) res %u\n", xdata, xsize, base, (unsigned)res); - return res; -} - -#ifdef DYING -/*@-boundswrite@*/ -static void myndivmod(mpw* result, size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata, register mpw* workspace) -{ - /* result must be xsize+1 in length */ - /* workspace must be ysize+1 in length */ - /* expect ydata to be normalized */ - mpw q; - mpw msw = *ydata; - size_t qsize = xsize-ysize; - - *result = (mpge(ysize, xdata, ydata) ? 1 : 0); - mpcopy(xsize, result+1, xdata); - if (*result) - (void) mpsub(ysize, result+1, ydata); - result++; - - while (qsize--) - { - q = mppndiv(result[0], result[1], msw); - -/*@-evalorder@*/ - *workspace = mpsetmul(ysize, workspace+1, ydata, q); -/*@=evalorder@*/ - - while (mplt(ysize+1, result, workspace)) - { - (void) mpsubx(ysize+1, workspace, ysize, ydata); - q--; - } - (void) mpsub(ysize+1, result, workspace); - *(result++) = q; - } -} -/*@=boundswrite@*/ -#endif - -static char * -mpstr(char * t, size_t nt, size_t size, mpw* data, mpw base) - /*@modifies t @*/ -{ - static char bchars[] = "0123456789abcdefghijklmnopqrstuvwxyz"; - size_t asize = size + 1; - mpw* adata = alloca(asize * sizeof(*adata)); - size_t anorm; - mpw* zdata = alloca((asize+1) * sizeof(*zdata)); - mpw* wksp = alloca((1+1) * sizeof(*wksp)); - size_t result; - -if (_mpw_debug < -1) -fprintf(stderr, "*** mpstr(%p[%d], %p[%d], %d):\t", t, nt, data, size, base), mpfprintln(stderr, size, data); - - mpsetx(asize, adata, size, data); - - t[nt] = '\0'; - while (nt--) { - - mpndivmod(zdata, asize, adata, 1, &base, wksp); - -if (_mpw_debug < -1) { -fprintf(stderr, " a %p[%d]:\t", adata, asize), mpfprintln(stderr, asize, adata); -fprintf(stderr, " z %p[%d]:\t", zdata, asize+1), mpfprintln(stderr, asize+1, zdata); -} - result = zdata[asize]; - t[nt] = bchars[result]; - - if (mpz(asize, zdata)) - break; - - anorm = asize - mpsize(asize, zdata); - if (anorm < asize) - asize -= anorm; - mpsetx(asize+1, adata, asize, zdata+anorm); - asize++; - } - /* XXX Fill leading zeroes (if any). */ - while (nt--) - t[nt] = '0'; - return t; -} - -static PyObject * -mpw_format(mpwObject * z, size_t base, int addL) - /*@modifies t @*/ -{ - size_t zsize = MPW_SIZE(z); - mpw* zdata = MPW_DATA(z); - PyStringObject * so; - size_t i; - size_t nt; - size_t size; - mpw* data; - char * t, * te; - char prefix[5]; - char * tcp = prefix; - int sign; - - if (z == NULL || !mpw_Check(z)) { - PyErr_BadInternalCall(); - return NULL; - } - -if (_mpw_debug < -1) -fprintf(stderr, "*** mpw_format(%p,%d,%d):\t", z, base, addL), mpfprintln(stderr, zsize, zdata); - - assert(base >= 2 && base <= 36); - - i = 0; - if (addL && initialiser_name != NULL) - i = strlen(initialiser_name) + 2; /* e.g. 'mpw(' + ')' */ - - sign = z->ob_size; - nt = MPBITCNT(zsize, zdata); - if (nt == 0) { - base = 10; /* '0' in every base, right */ - nt = 1; - size = 1; - data = alloca(size * sizeof(*data)); - *data = 0; - } else if (sign < 0) { - *tcp++ = '-'; - i += 1; /* space to hold '-' */ - size = MP_ROUND_B2W(nt); - data = zdata + (zsize - size); - } else { - size = MP_ROUND_B2W(nt); - data = zdata + (zsize - size); - } - - if (addL && size > 1) - i++; /* space for 'L' suffix */ - - nt = mpsizeinbase(size, data, base); - i += nt; - - if (base == 16) { - *tcp++ = '0'; - *tcp++ = 'x'; - i += 2; /* space to hold '0x' */ - } else if (base == 8) { - *tcp++ = '0'; - i += 1; /* space to hold the extra '0' */ - } else if (base > 10) { - *tcp++ = '0' + base / 10; - *tcp++ = '0' + base % 10; - *tcp++ = '#'; - i += 3; /* space to hold e.g. '12#' */ - } else if (base < 10) { - *tcp++ = '0' + base; - *tcp++ = '#'; - i += 2; /* space to hold e.g. '6#' */ - } - - so = (PyStringObject *)PyString_FromStringAndSize((char *)0, i); - if (so == NULL) - return NULL; - - /* get the beginning of the string memory and start copying things */ - te = PyString_AS_STRING(so); - if (addL && initialiser_name != NULL && *initialiser_name != '\0') { - te = stpcpy(te, initialiser_name); - *te++ = '('; /*')'*/ - } - - /* copy the already prepared prefix; e.g. sign and base indicator */ - *tcp = '\0'; - t = te = stpcpy(te, prefix); - - (void) mpstr(te, nt, size, data, base); - - /* Nuke leading zeroes. */ - nt = 0; - while (t[nt] == '0') - nt++; - if (t[nt] == '\0') /* all zeroes special case. */ - nt--; - if (nt > 0) - do { - *t = t[nt]; - } while (*t++ != '\0'); - - te += strlen(te); - - if (addL) { - if (size > 1) - *te++ = 'L'; - if (initialiser_name != NULL && *initialiser_name != '\0') - *te++ = /*'('*/ ')'; - } - *te = '\0'; - - assert(te - PyString_AS_STRING(so) <= i); - - if (te - PyString_AS_STRING(so) != i) - so->ob_size -= i - (te - PyString_AS_STRING(so)); - - return (PyObject *)so; -} - -/** - * Precomputes the sliding window table for computing powers of x. - * - * Sliding Window Exponentiation, Algorithm 14.85 in "Handbook of Applied Cryptography". - * - * First of all, the table with the powers of g can be reduced by - * about half; the even powers don't need to be accessed or stored. - * - * Get up to K bits starting with a one, if we have that many still available. - * - * Do the number of squarings of A in the first column, then multiply by - * the value in column two, and finally do the number of squarings in - * column three. - * - * This table can be used for K=2,3,4 and can be extended. - * - * -\verbatim - 0 : - | - | - - 1 : 1 | g1 @ 0 | 0 - 10 : 1 | g1 @ 0 | 1 - 11 : 2 | g3 @ 1 | 0 - 100 : 1 | g1 @ 0 | 2 - 101 : 3 | g5 @ 2 | 0 - 110 : 2 | g3 @ 1 | 1 - 111 : 3 | g7 @ 3 | 0 - 1000 : 1 | g1 @ 0 | 3 - 1001 : 4 | g9 @ 4 | 0 - 1010 : 3 | g5 @ 2 | 1 - 1011 : 4 | g11 @ 5 | 0 - 1100 : 2 | g3 @ 1 | 2 - 1101 : 4 | g13 @ 6 | 0 - 1110 : 3 | g7 @ 3 | 1 - 1111 : 4 | g15 @ 7 | 0 -\endverbatim - * - */ -static void mpslide(size_t xsize, const mpw* xdata, - size_t size, /*@out@*/ mpw* slide) - /*@modifies slide @*/ -{ - size_t rsize = (xsize > size ? xsize : size); - mpw* result = alloca(2 * rsize * sizeof(*result)); - - mpsqr(result, xsize, xdata); /* x^2 temp */ - mpsetx(size, slide, xsize+xsize, result); -if (_mpw_debug < 0) -fprintf(stderr, "\t x^2:\t"), mpfprintln(stderr, size, slide); - mpmul(result, xsize, xdata, size, slide); /* x^3 */ - mpsetx(size, slide+size, xsize+size, result); -if (_mpw_debug < 0) -fprintf(stderr, "\t x^3:\t"), mpfprintln(stderr, size, slide+size); - mpmul(result, size, slide, size, slide+size); /* x^5 */ - mpsetx(size, slide+2*size, size+size, result); -if (_mpw_debug < 0) -fprintf(stderr, "\t x^5:\t"), mpfprintln(stderr, size, slide+2*size); - mpmul(result, size, slide, size, slide+2*size); /* x^7 */ - mpsetx(size, slide+3*size, size+size, result); -if (_mpw_debug < 0) -fprintf(stderr, "\t x^7:\t"), mpfprintln(stderr, size, slide+3*size); - mpmul(result, size, slide, size, slide+3*size); /* x^9 */ - mpsetx(size, slide+4*size, size+size, result); -if (_mpw_debug < 0) -fprintf(stderr, "\t x^9:\t"), mpfprintln(stderr, size, slide+4*size); - mpmul(result, size, slide, size, slide+4*size); /* x^11 */ - mpsetx(size, slide+5*size, size+size, result); -if (_mpw_debug < 0) -fprintf(stderr, "\t x^11:\t"), mpfprintln(stderr, size, slide+5*size); - mpmul(result, size, slide, size, slide+5*size); /* x^13 */ - mpsetx(size, slide+6*size, size+size, result); -if (_mpw_debug < 0) -fprintf(stderr, "\t x^13:\t"), mpfprintln(stderr, size, slide+6*size); - mpmul(result, size, slide, size, slide+6*size); /* x^15 */ - mpsetx(size, slide+7*size, size+size, result); -if (_mpw_debug < 0) -fprintf(stderr, "\t x^15:\t"), mpfprintln(stderr, size, slide+7*size); - mpsetx(size, slide, xsize, xdata); /* x^1 */ -if (_mpw_debug < 0) -fprintf(stderr, "\t x^1:\t"), mpfprintln(stderr, size, slide); -} - -/*@observer@*/ /*@unchecked@*/ -static byte mpslide_presq[16] = -{ 0, 1, 1, 2, 1, 3, 2, 3, 1, 4, 3, 4, 2, 4, 3, 4 }; - -/*@observer@*/ /*@unchecked@*/ -static byte mpslide_mulg[16] = -{ 0, 0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7 }; - -/*@observer@*/ /*@unchecked@*/ -static byte mpslide_postsq[16] = -{ 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 }; - -/** - * Exponentiation with precomputed sliding window table. - */ -/*@-boundsread@*/ -static void mpnpowsld_w(mpnumber* n, size_t size, const mpw* slide, - size_t psize, const mpw* pdata) - /*@modifies n @*/ -{ - size_t rsize = (n->size > size ? n->size : size); - mpw* rdata = alloca(2 * rsize * sizeof(*rdata)); - short lbits = 0; - short kbits = 0; - byte s; - mpw temp; - short count; - -if (_mpw_debug < 0) -fprintf(stderr, "npowsld: p\t"), mpfprintln(stderr, psize, pdata); - /* 2. A = 1, i = t. */ - mpzero(n->size, n->data); - n->data[n->size-1] = 1; - - /* Find first bit set in exponent. */ - temp = *pdata; - count = 8 * sizeof(temp); - while (count != 0) { - if (temp & MP_MSBMASK) - break; - temp <<= 1; - count--; - } - - while (psize) { - while (count != 0) { - - /* Shift next bit of exponent into sliding window. */ - kbits <<= 1; - if (temp & MP_MSBMASK) - kbits++; - - /* On 1st non-zero in window, try to collect K bits. */ - if (kbits != 0) { - if (lbits != 0) - lbits++; - else if (temp & MP_MSBMASK) - lbits = 1; - else - {}; - - /* If window is full, then compute and clear window. */ - if (lbits == 4) { -if (_mpw_debug < 0) -fprintf(stderr, "*** #1 lbits %d kbits %d\n", lbits, kbits); - for (s = mpslide_presq[kbits]; s > 0; s--) { - mpsqr(rdata, n->size, n->data); - mpsetx(n->size, n->data, 2*n->size, rdata); -if (_mpw_debug < 0) -fprintf(stderr, "\t pre1:\t"), mpfprintln(stderr, n->size, n->data); - } - - mpmul(rdata, n->size, n->data, - size, slide+mpslide_mulg[kbits]*size); - mpsetx(n->size, n->data, n->size+size, rdata); -if (_mpw_debug < 0) -fprintf(stderr, "\t mul1:\t"), mpfprintln(stderr, n->size, n->data); - - for (s = mpslide_postsq[kbits]; s > 0; s--) { - mpsqr(rdata, n->size, n->data); - mpsetx(n->size, n->data, 2*n->size, rdata); -if (_mpw_debug < 0) -fprintf(stderr, "\tpost1:\t"), mpfprintln(stderr, n->size, n->data); - } - - lbits = kbits = 0; - } - } else { - mpsqr(rdata, n->size, n->data); - mpsetx(n->size, n->data, 2*n->size, rdata); -if (_mpw_debug < 0) -fprintf(stderr, "\t sqr:\t"), mpfprintln(stderr, n->size, n->data); - } - - temp <<= 1; - count--; - } - if (--psize) { - count = 8 * sizeof(temp); - temp = *(pdata++); - } - } - - if (kbits != 0) { -if (_mpw_debug < 0) -fprintf(stderr, "*** #1 lbits %d kbits %d\n", lbits, kbits); - for (s = mpslide_presq[kbits]; s > 0; s--) { - mpsqr(rdata, n->size, n->data); - mpsetx(n->size, n->data, 2*n->size, rdata); -if (_mpw_debug < 0) -fprintf(stderr, "\t pre2:\t"), mpfprintln(stderr, n->size, n->data); - } - - mpmul(rdata, n->size, n->data, - size, slide+mpslide_mulg[kbits]*size); - mpsetx(n->size, n->data, n->size+size, rdata); -if (_mpw_debug < 0) -fprintf(stderr, "\t mul2:\t"), mpfprintln(stderr, n->size, n->data); - - for (s = mpslide_postsq[kbits]; s > 0; s--) { - mpsqr(rdata, n->size, n->data); - mpsetx(n->size, n->data, 2*n->size, rdata); -if (_mpw_debug < 0) -fprintf(stderr, "\tpost2:\t"), mpfprintln(stderr, n->size, n->data); - } - } -} -/*@=boundsread@*/ - -/** - * mpnpow_w - * - * Uses sliding window exponentiation; needs extra storage: - * if K=3, needs 4*size, if K=4, needs 8*size - */ -/*@-boundsread@*/ -static void mpnpow_w(mpnumber* n, size_t xsize, const mpw* xdata, - size_t psize, const mpw* pdata) - /*@modifies n @*/ -{ - size_t xbits = MPBITCNT(xsize, xdata); - size_t pbits = MPBITCNT(psize, pdata); - size_t nbits; - mpw *slide; - size_t nsize; - size_t size; - - /* Special case: 0**P and X**(-P) */ - if (xbits == 0 || (psize > 0 && mpmsbset(psize, pdata))) { - mpnsetw(n, 0); - return; - } - /* Special case: X**0 and 1**P */ - if (pbits == 0 || mpisone(xsize, xdata)) { - mpnsetw(n, 1); - return; - } - - /* Normalize (to mpw boundary) exponent. */ - pdata += psize - MP_ROUND_B2W(pbits); - psize -= MP_BITS_TO_WORDS(pbits); - - /* Calculate size of result. */ - if (xbits == 0) xbits = 1; - nbits = (*pdata) * xbits; - nsize = MP_ROUND_B2W(nbits); - - /* XXX Add 1 word to carry sign bit */ - if (!mpmsbset(xsize, xdata) && (nbits & (MP_WBITS - 1)) == 0) - nsize++; - - size = MP_ROUND_B2W(15 * xbits); - -if (_mpw_debug < 0) -fprintf(stderr, "*** pbits %d xbits %d nsize %d size %d\n", pbits, xbits, nsize, size); - mpnsize(n, nsize); - - /* 1. Precompute odd powers of x (up to 2**K). */ - slide = (mpw*) alloca( (8*size) * sizeof(mpw)); - - mpslide(xsize, xdata, size, slide); - - /*@-internalglobs -mods@*/ /* noisy */ - mpnpowsld_w(n, size, slide, psize, pdata); - /*@=internalglobs =mods@*/ - -} -/*@=boundsread@*/ - -/* ---------- */ - -mpwObject * -mpw_New(int ob_size) - /*@*/ -{ - size_t size = ABS(ob_size); - mpwObject * z; - - /* XXX Make sure that 0 has allocated space. */ - if (size == 0) - size++; - z = PyObject_NEW_VAR(mpwObject, &mpw_Type, size); - if (z == NULL) - return NULL; - - z->ob_size = ob_size; - - if (size > 0) - memset(&z->data, 0, size * sizeof(*z->data)); - - return z; -} - -static mpwObject * -mpw_Copy(mpwObject *a) - /*@*/ -{ - mpwObject * z; - - z = mpw_FromMPW(MPW_SIZE(a), MPW_DATA(a), 1); - if (z != NULL) - z->ob_size = a->ob_size; - return z; -} - -static mpwObject * -mpw_FromLong(long ival) - /*@*/ -{ - mpwObject * z = mpw_New(1); - - if (z == NULL) - return NULL; - - if (ival < 0) { - z->ob_size = -z->ob_size; - ival = -ival; - } - z->data[0] = (mpw) ival; - - return z; -} - -static mpwObject * -mpw_FromDouble(double dval) -{ - mpwObject * z = mpw_New(1); - - if (z == NULL) - return NULL; - - if (dval < 0) { - z->ob_size = -z->ob_size; - dval = -dval; - } - z->data[0] = (mpw) dval; - - return z; -} - -#ifdef NOTYET -static mpwObject * -mpw_FromString(const char * str, char ** sep, int base) - /*@*/ -{ - const char * s = str, * se; - mpwObject * z = NULL; - mpw zbase, zval; - int sign = 1; - int ndigits; - - if ((base != 0 && base < 2) || base > 36) { - PyErr_SetString(PyExc_ValueError, "mpw() arg 2 must be >= 2 and <= 36"); - return NULL; - } - while (*s != '\0' && isspace(Py_CHARMASK(*s))) - s++; - if (*s == '+') - ++s; - else if (*s == '-') { - ++s; - sign = -1; - } - while (*s != '\0' && isspace(Py_CHARMASK(*s))) - s++; - if (base == 0) { - if (s[0] != '0') - base = 10; - else if (s[1] == 'x' || s[1] == 'X') - base = 16; - else - base = 8; - } - if (base == 16 && s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) - s += 2; - - /* Validate characters as digits of base. */ - for (se = s; *se != '\0'; se++) { - int k; - - if (*se <= '9') - k = *se - '0'; - else if (*se >= 'a') - k = *se - 'a' + 10; - else if (*se >= 'A') - k = *se - 'A' + 10; - else - k = -1; - if (k < 0 || k >= base) - break; - } - if (se == s) - goto onError; - - ndigits = (se - s); - - if (*se == 'L' || *se == 'l') - se++; - while (*se && isspace(Py_CHARMASK(*se))) - se++; - if (sep) - *sep = se; - if (*se != '\0') - goto onError; - - /* Allocate mpw. */ - - /* Convert digit string. */ - zbase = base; - for (se = s; *se != '\0'; se++) { - if (*se <= '9') - zval = *se - '0'; - else if (*se >= 'a') - zval = *se - 'a' + 10; - else if (*se >= 'A') - zval = *se - 'A' + 10; - } - - if (sign < 0 && z != NULL && z->ob_size != 0) - z->ob_size = -(z->ob_size); - - return z; - -onError: - PyErr_Format(PyExc_ValueError, "invalid literal for mpw(): %.200s", str); - Py_XDECREF(z); - return NULL; -} -#endif - -static mpwObject * -mpw_FromHEX(const char * hex) - /*@*/ -{ - size_t len = strlen(hex); - size_t size = MP_NIBBLES_TO_WORDS(len + MP_WNIBBLES - 1); - mpwObject * z = mpw_New(size); - - if (z != NULL && size > 0) - hs2ip(MPW_DATA(z), size, hex, len); - - return z; -} - -mpwObject * -mpw_FromMPW(size_t size, mpw* data, int normalize) -{ - mpwObject * z; - - if (normalize) { - size_t norm = size - MP_ROUND_B2W(MPBITCNT(size, data)); - if (norm > 0 && norm < size) { - size -= norm; - data += norm; - } - } - - z = mpw_New(size); - if (z == NULL) - return NULL; - - if (size > 0) - memcpy(&z->data, data, size * sizeof(*z->data)); - - return z; -} - -static mpwObject * -mpw_FromLongObject(PyLongObject *lo) - /*@*/ -{ - mpwObject * z; - int lsize = ABS(lo->ob_size); - int lbits = DIGITS_TO_BITS(lsize); - size_t zsize = MP_BITS_TO_WORDS(lbits) + 1; - mpw* zdata; - unsigned char * zb; - size_t nzb; - int is_littleendian = 0; - int is_signed = 0; - - lsize = zsize; - if (lo->ob_size < 0) - lsize = -lsize; - z = mpw_New(lsize); - if (z == NULL) - return NULL; - - zdata = MPW_DATA(z); - zb = (unsigned char *) zdata; - nzb = MP_WORDS_TO_BYTES(zsize); - - /* Grab long as big-endian unsigned octets. */ - if (_PyLong_AsByteArray(lo, zb, nzb, is_littleendian, is_signed)) { - Py_DECREF(z); - return NULL; - } - - /* Endian swap zdata's mpw elements. */ - if (IS_LITTLE_ENDIAN()) { - mpw w = 0; - int zx = 0; - while (nzb) { - w <<= 8; - w |= *zb++; - nzb--; - if ((nzb % MP_WBYTES) == 0) { - zdata[zx++] = w; - w = 0; - } - } - } - - return z; -} - -/* ---------- */ - -static void -mpw_dealloc(/*@only@*/mpwObject * s) - /*@modifies s @*/ -{ -if (_mpw_debug < -1) -fprintf(stderr, "*** mpw_dealloc(%p[%s])\n", s, lbl(s)); - - PyObject_Del(s); -} - -static int -mpw_compare(mpwObject * a, mpwObject * b) - /*@*/ -{ - size_t asize = MPW_SIZE(a); - mpw* adata = MPW_DATA(a); - size_t bsize = MPW_SIZE(b); - mpw* bdata = MPW_DATA(b); - int ret; - - if (mpeqx(asize, adata, bsize, bdata)) - ret = 0; - else if (mpgtx(asize, adata, bsize, bdata)) - ret = 1; - else - ret = -1; - -if (_mpw_debug) -fprintf(stderr, "*** mpw_compare(%p[%s],%p[%s]) ret %d\n", a, lbl(a), b, lbl(b), ret); - return ret; -} - -static PyObject * -mpw_repr(mpwObject * a) - /*@*/ -{ - PyObject * so = mpw_format(a, 10, 1); -if (_mpw_debug && so != NULL) -fprintf(stderr, "*** mpw_repr(%p): \"%s\"\n", a, PyString_AS_STRING(so)); - return so; -} - -/** \ingroup py_c - */ -static PyObject * -mpw_str(mpwObject * a) - /*@*/ -{ - PyObject * so = mpw_format(a, 10, 0); -if (so != NULL && _mpw_debug < -1) -fprintf(stderr, "*** mpw_str(%p): \"%s\"\n", a, PyString_AS_STRING(so)); - return so; -} - -#ifdef DYING -/** \ingroup py_c - */ -static int mpw_init(mpwObject * z, PyObject *args, PyObject *kwds) - /*@modifies s @*/ -{ - PyObject * o = NULL; - long l = 0; - - if (!PyArg_ParseTuple(args, "|O:Cvt", &o)) return -1; - - if (o == NULL) { - mpnsetw(&z->n, l); - } else if (PyInt_Check(o)) { - l = PyInt_AsLong(o); - mpnsetw(&z->n, l); - } else if (PyLong_Check(o)) { - PyLongObject *lo = (PyLongObject *)o; - int lsize = ABS(lo->ob_size); - int lbits = DIGITS_TO_BITS(lsize); - size_t zsize = MP_BITS_TO_WORDS(lbits) + 1; - mpw* zdata = alloca(zsize * sizeof(*zdata)); - unsigned char * zb = (unsigned char *) zdata; - size_t nzb = MP_WORDS_TO_BYTES(zsize); - int is_littleendian = 0; - int is_signed = 1; - - /* Grab long as big-endian signed octets. */ - if (_PyLong_AsByteArray(lo, zb, nzb, is_littleendian, is_signed)) - return -1; - - /* Endian swap zdata's mpw elements. */ - if (IS_LITTLE_ENDIAN()) { - mpw w = 0; - int zx = 0; - while (nzb) { - w <<= 8; - w |= *zb++; - nzb--; - if ((nzb % MP_WBYTES) == 0) { - zdata[zx++] = w; - w = 0; - } - } - } - mpnset(&z->n, zsize, zdata); - } else if (PyFloat_Check(o)) { - double d = PyFloat_AsDouble(o); - /* XXX TODO: check for overflow/underflow. */ - l = (long) (d + 0.5); - mpnsetw(&z->n, l); - } else if (PyString_Check(o)) { - const unsigned char * hex = PyString_AsString(o); - /* XXX TODO: check for hex. */ - mpnsethex(&z->n, hex); - } else if (mpw_Check(o)) { - mpwObject *a = (mpwObject *)o; - mpncopy(&z->n, &a->n); - } else { - PyErr_SetString(PyExc_TypeError, "non-numeric coercion failed (mpw_init)"); - return -1; - } - -if (_mpw_debug) -fprintf(stderr, "*** mpw_init(%p[%s],%p[%s],%p[%s]):\t", z, lbl(z), args, lbl(args), kwds, lbl(kwds)), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z)); - - return 0; -} -#endif - -/** \ingroup py_c - */ -static void mpw_free(/*@only@*/ mpwObject * s) - /*@modifies s @*/ -{ -if (_mpw_debug) -fprintf(stderr, "*** mpw_free(%p[%s])\n", s, lbl(s)); - PyObject_Del(s); -} - -/** \ingroup py_c - * Convert integer to mpw. - */ -static mpwObject * -mpw_i2mpw(PyObject * o) - /*@modifies o @*/ -{ - if (mpw_Check(o)) { - Py_INCREF(o); - return (mpwObject *)o; - } - if (PyInt_Check(o)) - return mpw_FromLong(PyInt_AsLong(o)); - else if (PyLong_Check(o)) - return mpw_FromLongObject((PyLongObject *)o); - else if (PyFloat_Check(o)) - return mpw_FromDouble(PyFloat_AsDouble(o)); - else if (PyString_Check(o)) - return mpw_FromHEX(PyString_AS_STRING(o)); - - PyErr_SetString(PyExc_TypeError, "number coercion (to mpwObject) failed"); - return NULL; -} - -static PyObject * -mpw_new(PyTypeObject *type, PyObject *args, PyObject *kwds) - /*@*/ -{ - mpwObject *z; - - if (type != &mpw_Type) { - mpwObject *tz; - size_t size; - - assert(PyType_IsSubtype(type, &mpw_Type)); - tz = (mpwObject *)mpw_new(&mpw_Type, args, kwds); - if (tz == NULL) - return NULL; - - size = ABS(tz->ob_size); - z = (mpwObject *) type->tp_alloc(type, size); - if (z == NULL) - return NULL; - - z->ob_size = tz->ob_size; - if (size > 0) - memcpy(&z->data, &tz->data, size * sizeof(*z->data)); - Py_DECREF(tz); - } else { - PyObject * x = NULL; - int base = -909; - static char *kwlist[] = {"x", "base", 0}; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oi:mpw", kwlist, &x, &base)) - return NULL; - - if (x != NULL) { - /* XXX make sure new instance, not old reference. */ - if (mpw_Check(x)) { - mpwObject *zo = (mpwObject *)x; - z = mpw_Copy(zo); - } else - z = mpw_i2mpw(x); - } else - z = mpw_FromLong(0); - } - -if (_mpw_debug < -1) -fprintf(stderr, "*** mpw_new(%p[%s],%p[%s],%p[%s])\t", type, lbl(type), args, lbl(args), kwds, lbl(kwds)), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z)); - - return (PyObject *)z; -} - -/** \ingroup py_c - * Compute 2 argument operations. - */ -static PyObject * -mpw_ops2(const char *fname, char op, mpwObject *x, mpwObject *m) - /*@*/ -{ - mpwObject * z = NULL; - size_t xsize; - mpw* xdata; - size_t msize; - mpw* mdata; - size_t mnorm; - size_t asize; - mpw* adata; - size_t bsize; - mpw* bdata; - size_t shift; - size_t zsize; - mpw* zdata; - mpw* wksp; - mpbarrett b; - int carry; - int zsign = 0; - - mpbzero(&b); - if (x == NULL || m == NULL) - goto exit; - - xsize = MPW_SIZE(x); - xdata = MPW_DATA(x); - msize = MPW_SIZE(m); - mdata = MPW_DATA(m); - mnorm = msize - mpsize(msize, mdata); - if (mnorm > 0 && mnorm < msize) { - msize -= mnorm; - mdata += mnorm; - } - -if (_mpw_debug < 0) { -prtmpw("a", x); -prtmpw("b", m); -} - - switch (op) { - default: - goto exit; - /*@notreached@*/ break; - case '+': - zsize = MAX(xsize, msize) + 1; - zdata = alloca(zsize * sizeof(*zdata)); - mpsetx(zsize, zdata, xsize, xdata); - if (x->ob_size < 0) { - zsign = 1; - if (m->ob_size < 0) { - carry = mpaddx(zsize-1, zdata+1, msize, mdata); - if (carry) { -if (_mpw_debug) -fprintf(stderr, "add --: carry\n"); - *zdata = 1; - } - } else { - carry = mpsubx(zsize-1, zdata+1, msize, mdata); - if (carry) { -if (_mpw_debug) -fprintf(stderr, "add -+: borrow\n"); - *zdata = MP_ALLMASK; - mpneg(zsize, zdata); - zsign = 0; - } - } - } else { - zsign = 0; - if (m->ob_size < 0) { - carry = mpsubx(zsize-1, zdata+1, msize, mdata); - if (carry) { -if (_mpw_debug) -fprintf(stderr, "add +-: borrow\n"); - *zdata = MP_ALLMASK; - mpneg(zsize, zdata); - zsign = 1; - } - } else { - carry = mpaddx(zsize-1, zdata+1, msize, mdata); - if (carry) { -if (_mpw_debug) -fprintf(stderr, "add ++: carry\n"); - *zdata = 1; - } - } - } - z = mpw_FromMPW(zsize, zdata, 1); - if (zsign) - z->ob_size = -z->ob_size; - break; - case '-': - zsize = MAX(xsize, msize) + 1; - zdata = alloca(zsize * sizeof(*zdata)); - mpsetx(zsize, zdata, xsize, xdata); - if (x->ob_size < 0) { - zsign = 1; - if (m->ob_size < 0) { - carry = mpsubx(zsize-1, zdata+1, msize, mdata); - if (carry) { -if (_mpw_debug) -fprintf(stderr, "sub --: borrow\n"); - *zdata = MP_ALLMASK; - mpneg(zsize, zdata); - zsign = 0; - } - } else { - carry = mpaddx(zsize-1, zdata+1, msize, mdata); - if (carry) { -if (_mpw_debug) -fprintf(stderr, "sub -+: carry\n"); - *zdata = 1; - } - } - } else { - zsign = 0; - if (m->ob_size < 0) { - carry = mpaddx(zsize-1, zdata+1, msize, mdata); - if (carry) { -if (_mpw_debug) -fprintf(stderr, "sub +-: carry\n"); - *zdata = 1; - } - } else { - carry = mpsubx(zsize-1, zdata+1, msize, mdata); - if (carry) { -if (_mpw_debug) -fprintf(stderr, "sub ++: borrow\n"); - *zdata = MP_ALLMASK; - mpneg(zsize, zdata); - zsign = 1; - } - } - } - z = mpw_FromMPW(zsize-1, zdata+1, 1); - if (zsign) - z->ob_size = -z->ob_size; - break; - case '*': - zsize = xsize + msize; - zdata = alloca(zsize * sizeof(*zdata)); - zsign = x->ob_size * m->ob_size; - mpmul(zdata, xsize, xdata, msize, mdata); - z = mpw_FromMPW(zsize, zdata, 1); - if (zsign < 0) - z->ob_size = -z->ob_size; - break; - case '/': - asize = xsize+1; - adata = alloca(asize * sizeof(*adata)); - mpsetx(asize, adata, xsize, xdata); - bsize = msize; - bdata = alloca(bsize * sizeof(*bdata)); - mpsetx(bsize, bdata, msize, mdata); - - zsize = asize + 1; - zdata = alloca(zsize * sizeof(*zdata)); - zsign = x->ob_size * m->ob_size; - wksp = alloca((bsize+1) * sizeof(*wksp)); - - shift = mpnorm(bsize, bdata); - mplshift(asize, adata, shift); - mpndivmod(zdata, asize, adata, bsize, bdata, wksp); - - zsize -= bsize; - - if (zsign < 0) - (void) mpaddw(zsize, zdata, (mpw)1); - - z = mpw_FromMPW(zsize, zdata, 1); - if (zsign < 0) - z->ob_size = -z->ob_size; - break; - case '%': - asize = xsize+1; - adata = alloca(asize * sizeof(*adata)); - mpsetx(asize, adata, xsize, xdata); - bsize = msize; - bdata = mdata; - - zsize = asize; - zdata = alloca(zsize * sizeof(*zdata)); - zsign = x->ob_size * m->ob_size; - wksp = alloca((2*bsize+1) * sizeof(*wksp)); - - mpmod(zdata, asize, adata, bsize, bdata, wksp); - - if (zsign < 0) { - if (m->ob_size < 0) { - (void) mpsubx(zsize, zdata, bsize, bdata); - mpneg(zsize, zdata); - } else { - zsign = 0; - mpneg(zsize, zdata); - (void) mpaddx(zsize, zdata, bsize, bdata); - } - } - z = mpw_FromMPW(zsize, zdata, 1); - if (zsign < 0) { - z->ob_size = -z->ob_size; - } else if (zsign > 0) { - if (x->ob_size < 0) - z->ob_size = -z->ob_size; - } - break; - case '<': - /* XXX FIXME: enlarge? negative count? sign?. */ - shift = (size_t) (msize == 1 ? mdata[0] : 0); - z = mpw_FromMPW(xsize, xdata, 0); - if (shift > 0) - mplshift(MPW_SIZE(z), MPW_DATA(z), shift); - break; - case '>': - /* XXX FIXME: enlarge? negative count? sign?. */ - shift = (size_t) (msize == 1 ? mdata[0] : 0); - z = mpw_FromMPW(xsize, xdata, 0); - if (shift > 0) - mprshift(MPW_SIZE(z), MPW_DATA(z), shift); - break; - case '&': - /* XXX reset to original size for now. */ - msize = MPW_SIZE(m); - mdata = MPW_DATA(m); - if (xsize <= msize) { - z = mpw_FromMPW(xsize, xdata, 0); - mpand(MPW_SIZE(z), MPW_DATA(z), mdata + (msize - xsize)); - } else { - z = mpw_FromMPW(msize, mdata, 0); - mpand(MPW_SIZE(z), MPW_DATA(z), xdata + (xsize - msize)); - } - break; - case '|': - /* XXX reset to original size for now. */ - msize = MPW_SIZE(m); - mdata = MPW_DATA(m); - if (xsize <= msize) { - z = mpw_FromMPW(xsize, xdata, 0); - mpor(MPW_SIZE(z), MPW_DATA(z), mdata + (msize - xsize)); - } else { - z = mpw_FromMPW(msize, mdata, 0); - mpor(MPW_SIZE(z), MPW_DATA(z), xdata + (xsize - msize)); - } - break; - case '^': - /* XXX reset to original size for now. */ - msize = MPW_SIZE(m); - mdata = MPW_DATA(m); - if (xsize <= msize) { - z = mpw_FromMPW(xsize, xdata, 0); - mpxor(MPW_SIZE(z), MPW_DATA(z), mdata + (msize - xsize)); - } else { - z = mpw_FromMPW(msize, mdata, 0); - mpxor(MPW_SIZE(z), MPW_DATA(z), xdata + (xsize - msize)); - } - break; - case 'P': - { mpnumber zn; - - mpnzero(&zn); - if (msize == 0 || (msize == 1 && *mdata == 0)) - mpnsetw(&zn, 1); - else if (mpz(xsize, xdata) || m->ob_size < 0) - mpnsetw(&zn, 0); - else { - zsign = (x->ob_size > 0 || mpeven(msize, mdata)) ? 1 : -1; - mpnpow_w(&zn, xsize, xdata, msize, mdata); - } - z = mpw_FromMPW(zn.size, zn.data, 1); - mpnfree(&zn); - if (zsign < 0) - z->ob_size = -z->ob_size; - } break; - case 'G': - wksp = alloca((xsize) * sizeof(*wksp)); - z = mpw_New(msize); - mpgcd_w(xsize, xdata, mdata, MPW_DATA(z), wksp); - break; - case 'I': - wksp = alloca((7*msize+6)*sizeof(*wksp)); - z = mpw_New(msize); - (void) mpextgcd_w(msize, wksp, mdata, MPW_DATA(z), wksp+msize); - break; -#ifdef DYING - case 'R': - { rngObject * r = ((rngObject *)x); - - wksp = alloca(msize*sizeof(*wksp)); - mpbset(&b, msize, mdata); - z = mpw_New(msize); - mpbrnd_w(&b, &r->rngc, MPW_DATA(z), wksp); - } break; -#endif - case 'S': - wksp = alloca((4*msize+2)*sizeof(*wksp)); - mpbset(&b, msize, mdata); - z = mpw_New(msize); - mpbsqrmod_w(&b, xsize, xdata, MPW_DATA(z), wksp); - break; - } - -if (_mpw_debug) -fprintf(stderr, "*** mpw_%s %p[%d]\t", fname, MPW_DATA(z), MPW_SIZE(z)), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z)); - -exit: - mpbfree(&b); - Py_XDECREF(x); - Py_XDECREF(m); - return (PyObject *)z; -} - -/** \ingroup py_c - * Compute 3 argument operations. - */ -static PyObject * -mpw_ops3(const char *fname, char op, - mpwObject *x, mpwObject *y, mpwObject *m) - /*@*/ -{ - mpwObject * z = NULL; - size_t xsize; - mpw* xdata; - size_t ysize; - mpw* ydata; - size_t msize; - mpw* mdata; - size_t zsize; - mpw* zdata; - mpbarrett b; - mpw* wksp; - - mpbzero(&b); - if (x == NULL || y == NULL || m == NULL) - goto exit; - -if (_mpw_debug < 0) { -prtmpw("a", x); -prtmpw("b", y); -prtmpw("c", m); -} - - xsize = MPW_SIZE(x); - xdata = MPW_DATA(x); - ysize = MPW_SIZE(y); - ydata = MPW_DATA(y); - msize = MPW_SIZE(m); - mdata = MPW_DATA(m); - - mpbset(&b, msize, mdata); - - zsize = b.size; - zdata = alloca(zsize * sizeof(*zdata)); - wksp = alloca((4*zsize+2)*sizeof(*wksp)); - - switch (op) { - case '/': - case '%': - default: - goto exit; - /*@notreached@*/ break; - case '+': - fname = "Addm"; - mpbaddmod_w(&b, xsize, xdata, ysize, ydata, zdata, wksp); - break; - case '-': - fname = "Subm"; - mpbsubmod_w(&b, xsize, xdata, ysize, ydata, zdata, wksp); - break; - case '*': - fname = "Mulm"; - mpbmulmod_w(&b, xsize, xdata, ysize, ydata, zdata, wksp); - break; - case 'P': - fname = "Powm"; - mpbpowmod_w(&b, xsize, xdata, ysize, ydata, zdata, wksp); - break; - } - - z = mpw_FromMPW(zsize, zdata, 1); - -if (_mpw_debug < 0) -fprintf(stderr, "*** mpw_%s %p[%d]\t", fname, MPW_DATA(z), MPW_SIZE(z)), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z)); - -exit: - mpbfree(&b); - Py_XDECREF(x); - Py_XDECREF(y); - Py_XDECREF(m); - return (PyObject *)z; -} - -/* ---------- */ - -/** \ingroup py_c - */ -static PyObject * -mpw_Debug(/*@unused@*/ mpwObject * s, PyObject * args) - /*@globals _Py_NoneStruct @*/ - /*@modifies _Py_NoneStruct @*/ -{ - if (!PyArg_ParseTuple(args, "i:Debug", &_mpw_debug)) return NULL; - Py_INCREF(Py_None); - return Py_None; -} - -/** \ingroup py_c - * Compute gcd(x, y). - */ -static PyObject * -mpw_Gcd(mpwObject * s, PyObject * args) - /*@*/ -{ - PyObject * xo, * mo; - - if (!PyArg_ParseTuple(args, "OO:Gcd", &xo, &mo)) return NULL; - return mpw_ops2("Gcd", 'G', mpw_i2mpw(xo), mpw_i2mpw(mo)); -} - -/** \ingroup py_c - * Compute inverse (modulo m) of x. - */ -static PyObject * -mpw_Invm(/*@unused@*/ mpwObject * s, PyObject * args) - /*@*/ -{ - PyObject * xo, * mo; - - if (!PyArg_ParseTuple(args, "OO:Invm", &xo, &mo)) return NULL; - return mpw_ops2("Invm", 'I', mpw_i2mpw(xo), mpw_i2mpw(mo)); -} - -/** \ingroup py_c - * Compute x*x (modulo m). - */ -static PyObject * -mpw_Sqrm(mpwObject * s, PyObject * args) - /*@*/ -{ - PyObject * xo, * mo; - - if (!PyArg_ParseTuple(args, "OO:Sqrm", &xo, &mo)) return NULL; - return mpw_ops2("Sqrm", 'S', mpw_i2mpw(xo), mpw_i2mpw(mo)); -} - -/** \ingroup py_c - * Compute x+y (modulo m). - */ -static PyObject * -mpw_Addm(mpwObject * s, PyObject * args) - /*@*/ -{ - PyObject * xo, * yo, * mo; - - if (!PyArg_ParseTuple(args, "OOO:Addm", &xo, &yo, &mo)) return NULL; - return mpw_ops3("Addm", '+', - mpw_i2mpw(xo), mpw_i2mpw(yo), mpw_i2mpw(mo)); -} - -/** \ingroup py_c - * Compute x-y (modulo m). - */ -static PyObject * -mpw_Subm(mpwObject * s, PyObject * args) - /*@*/ -{ - PyObject * xo, * yo, * mo; - - if (!PyArg_ParseTuple(args, "OOO:Subm", &xo, &yo, &mo)) return NULL; - return mpw_ops3("Subm", '-', - mpw_i2mpw(xo), mpw_i2mpw(yo), mpw_i2mpw(mo)); -} - -/** \ingroup py_c - * Compute x*y (modulo m). - */ -static PyObject * -mpw_Mulm(mpwObject * s, PyObject * args) - /*@*/ -{ - PyObject * xo, * yo, * mo; - - if (!PyArg_ParseTuple(args, "OOO:Mulm", &xo, &yo, &mo)) return NULL; - return mpw_ops3("Mulm", '*', - mpw_i2mpw(xo), mpw_i2mpw(yo), mpw_i2mpw(mo)); -} - -/** \ingroup py_c - * Compute x**y (modulo m). - */ -static PyObject * -mpw_Powm(mpwObject * s, PyObject * args) - /*@*/ -{ - PyObject * xo, * yo, * mo; - - if (!PyArg_ParseTuple(args, "OOO:Powm", &xo, &yo, &mo)) return NULL; - return mpw_ops3("Powm", 'P', - mpw_i2mpw(xo), mpw_i2mpw(yo), mpw_i2mpw(mo)); -} - -#ifdef DYNING -/** \ingroup py_c - * Return random number 1 < r < b-1. - */ -static PyObject * -mpw_Rndm(mpwObject * s, PyObject * args) - /*@*/ -{ - PyObject * xo, * mo; - - if (!PyArg_ParseTuple(args, "OO:Rndm", &mo, &xo)) return NULL; - if (!is_rng(xo)) { - PyErr_SetString(PyExc_TypeError, "mpw.rndm() requires rng_Type argument"); - return NULL; - } - return mpw_ops2("Rndm", 'R', (mpwObject*)xo, mpw_i2mpw(mo)); -} -#endif - -/*@-fullinitblock@*/ -/*@unchecked@*/ /*@observer@*/ -static struct PyMethodDef mpw_methods[] = { - {"Debug", (PyCFunction)mpw_Debug, METH_VARARGS, - NULL}, - {"gcd", (PyCFunction)mpw_Gcd, METH_VARARGS, - NULL}, - {"invm", (PyCFunction)mpw_Invm, METH_VARARGS, - NULL}, - {"sqrm", (PyCFunction)mpw_Sqrm, METH_VARARGS, - NULL}, - {"addm", (PyCFunction)mpw_Addm, METH_VARARGS, - NULL}, - {"subm", (PyCFunction)mpw_Subm, METH_VARARGS, - NULL}, - {"mulm", (PyCFunction)mpw_Mulm, METH_VARARGS, - NULL}, - {"powm", (PyCFunction)mpw_Powm, METH_VARARGS, - NULL}, -#ifdef DYING - {"rndm", (PyCFunction)mpw_Rndm, METH_VARARGS, - NULL}, -#endif - {NULL, NULL} /* sentinel */ -}; -/*@=fullinitblock@*/ - -static PyObject * mpw_getattro(PyObject * o, PyObject * n) - /*@*/ -{ - return PyObject_GenericGetAttr(o, n); -} - -static int mpw_setattro(PyObject * o, PyObject * n, PyObject * v) - /*@*/ -{ - return PyObject_GenericSetAttr(o, n, v); -} - -/* ---------- */ - -static PyObject * -mpw_add(PyObject * a, PyObject * b) - /*@*/ -{ - return mpw_ops2("add", '+', mpw_i2mpw(a), mpw_i2mpw(b)); -} - -static PyObject * -mpw_sub(PyObject * a, PyObject * b) - /*@*/ -{ - return mpw_ops2("sub", '-', mpw_i2mpw(a), mpw_i2mpw(b)); -} - -static PyObject * -mpw_mul(PyObject * a, PyObject * b) - /*@*/ -{ - return mpw_ops2("mul", '*', mpw_i2mpw(a), mpw_i2mpw(b)); -} - -static PyObject * -mpw_div(PyObject * a, PyObject * w) - /*@*/ -{ - mpwObject * b = mpw_i2mpw(w); - - if (mpz(MPW_SIZE(b), MPW_DATA(b))) { - Py_DECREF(b); - PyErr_SetString(PyExc_ZeroDivisionError, "mpw_divide by zero"); - return NULL; - } - return mpw_ops2("div", '/', mpw_i2mpw(a), b); -} - -static PyObject * -mpw_classic_div(PyObject * a, PyObject * b) - /*@*/ -{ - if (Py_DivisionWarningFlag && - PyErr_Warn(PyExc_DeprecationWarning, "classic long division") < 0) - return NULL; - return mpw_div(a, b); -} - -static PyObject * -mpw_mod(PyObject * a, PyObject * b) - /*@*/ -{ - return mpw_ops2("rem", '%', mpw_i2mpw(a), mpw_i2mpw(b)); -} - -static PyObject * -mpw_divmod(PyObject * v, PyObject * w) - /*@*/ -{ - PyObject * z = NULL; - mpwObject * q = NULL; - mpwObject * r = NULL; - mpwObject * a = mpw_i2mpw(v); - size_t asize; - mpw* adata; - size_t anorm; - mpwObject * b = mpw_i2mpw(w); - size_t bsize; - mpw* bdata; - size_t bnorm; - size_t zsize; - mpw* zdata; - mpw* wksp; - int qsign = 0; - - if (a == NULL || b == NULL) - goto exit; - - asize = MPW_SIZE(a); - adata = MPW_DATA(a); - anorm = mpsize(asize, adata); - bsize = MPW_SIZE(b); - bdata = MPW_DATA(b); - bnorm = mpsize(bsize, bdata); - - if (mpz(bsize, bdata)) { - PyErr_SetString(PyExc_ZeroDivisionError, "mpw_divmod by zero"); - goto exit; - } - - if (anorm < asize) { - asize -= anorm; - adata += anorm; - } - zsize = asize + 1; - zdata = alloca(zsize * sizeof(*zdata)); - if (bnorm < bsize) { - bsize -= bnorm; - bdata += bnorm; - } - qsign = a->ob_size * b->ob_size; - wksp = alloca((bsize+1) * sizeof(*wksp)); - - mpndivmod(zdata, asize, adata, bsize, bdata, wksp); - -if (_mpw_debug < 0) { -fprintf(stderr, " a %p[%d]:\t", adata, asize), mpfprintln(stderr, asize, adata); -fprintf(stderr, " b %p[%d]:\t", bdata, bsize), mpfprintln(stderr, bsize, bdata); -fprintf(stderr, " z %p[%d]:\t", zdata, zsize), mpfprintln(stderr, zsize, zdata); -} - - zsize -= bsize; - r = mpw_FromMPW(bsize, zdata+zsize, 1); - if (r == NULL) - goto exit; - if (qsign < 0) { - if (b->ob_size < 0) { - (void) mpsubx(MPW_SIZE(r), MPW_DATA(r), bsize, bdata); - mpneg(MPW_SIZE(r), MPW_DATA(r)); - } else { - mpneg(MPW_SIZE(r), MPW_DATA(r)); - (void) mpaddx(MPW_SIZE(r), MPW_DATA(r), bsize, bdata); - } - (void) mpaddw(zsize, zdata, (mpw)1); - } - if (b->ob_size < 0) - r->ob_size = -r->ob_size; - - q = mpw_FromMPW(zsize, zdata, 1); - if (q == NULL) { - Py_DECREF(r); - goto exit; - } - if (qsign < 0) - q->ob_size = -q->ob_size; - -if (_mpw_debug) { -prtmpw("q", q); -prtmpw("r", r); -fprintf(stderr, "*** mpw_divmod(%p,%p)\n", a, b); -} - if ((z = PyTuple_New(2)) == NULL) { - Py_DECREF(q); - Py_DECREF(r); - goto exit; - } - - (void) PyTuple_SetItem(z, 0, (PyObject *)q); - (void) PyTuple_SetItem(z, 1, (PyObject *)r); - -exit: - Py_XDECREF(a); - Py_XDECREF(b); - return (PyObject *)z; -} - -static PyObject * -mpw_pow(PyObject * a, PyObject * b, PyObject * c) - /*@*/ -{ - if (c != Py_None) - return mpw_ops3("Powm", 'P', mpw_i2mpw(a), mpw_i2mpw(b), mpw_i2mpw(c)); - else - return mpw_ops2("pow", 'P', mpw_i2mpw(a), mpw_i2mpw(b)); -} - -static PyObject * -mpw_neg(mpwObject * a) - /*@*/ -{ - mpwObject *z; - - if (a->ob_size == 0 && mpw_CheckExact(a)) { - /* -0 == 0 */ - Py_INCREF(a); - z = a; - } else { - z = mpw_Copy(a); - if (z != NULL) - z->ob_size = -(a->ob_size); - } - -if (z != NULL && _mpw_debug) -fprintf(stderr, "*** mpw_neg %p[%d]\t", MPW_DATA(z), MPW_SIZE(z)), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z)); - - return (PyObject *)z; -} - -static PyObject * -mpw_pos(mpwObject * a) - /*@*/ -{ - mpwObject *z; - - if (mpw_CheckExact(a)) { - Py_INCREF(a); - z = a; - } else - z = mpw_Copy(a); - -if (z != NULL && _mpw_debug) -fprintf(stderr, "*** mpw_pos %p[%d]\t", MPW_DATA(z), MPW_SIZE(z)), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z)); - - return (PyObject *)z; -} - -static PyObject * -mpw_abs(mpwObject * a) - /*@*/ -{ - mpwObject * z; - - if (a->ob_size < 0) - z = (mpwObject *)mpw_neg(a); - else - z = (mpwObject *)mpw_pos(a); - -if (z != NULL && _mpw_debug) -fprintf(stderr, "*** mpw_abs %p[%d]\t", MPW_DATA(z), MPW_SIZE(z)), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z)); - - return (PyObject *)z; -} - -static int -mpw_nonzero(mpwObject * a) - /*@*/ -{ - return ABS(a->ob_size) != 0; -} - -static PyObject * -mpw_invert(mpwObject * a) - /*@*/ -{ - /* Implement ~z as -(z+1) */ - mpwObject * z = mpw_Copy(a); - - if (z != NULL) { - mpw val = 1; - int carry; - - carry = mpaddx(MPW_SIZE(z), MPW_DATA(z), 1, &val); - z->ob_size = -(a->ob_size); - } - return (PyObject *)z; -} - -static PyObject * -mpw_lshift(PyObject * a, PyObject * b) - /*@*/ -{ - return mpw_ops2("lshift", '<', mpw_i2mpw(a), mpw_i2mpw(b)); -} - -static PyObject * -mpw_rshift(PyObject * a, PyObject * b) - /*@*/ -{ - return mpw_ops2("rshift", '>', mpw_i2mpw(a), mpw_i2mpw(b)); -} - -static PyObject * -mpw_and(PyObject * a, PyObject * b) - /*@*/ -{ - return mpw_ops2("and", '&', mpw_i2mpw(a), mpw_i2mpw(b)); -} - -static PyObject * -mpw_xor(PyObject * a, PyObject * b) - /*@*/ -{ - return mpw_ops2("xor", '^', mpw_i2mpw(a), mpw_i2mpw(b)); -} - -static PyObject * -mpw_or(PyObject * a, PyObject * b) - /*@*/ -{ - return mpw_ops2("or", '|', mpw_i2mpw(a), mpw_i2mpw(b)); -} - -static int -mpw_coerce(PyObject ** pv, PyObject ** pw) - /*@modifies *pv, *pw @*/ -{ - -if (_mpw_debug) -fprintf(stderr, "*** mpw_coerce(%p[%s],%p[%s])\n", pv, lbl(*pv), pw, lbl(*pw)); - - if (mpw_Check(*pw)) - Py_INCREF(*pw); - else if (PyInt_Check(*pw)) - *pw = (PyObject *) mpw_FromLong(PyInt_AsLong(*pw)); - else if (PyLong_Check(*pw)) - *pw = (PyObject *) mpw_FromLongObject((PyLongObject *)(*pw)); - else if (PyFloat_Check(*pw)) - *pw = (PyObject *) mpw_FromDouble(PyFloat_AsDouble(*pw)); - else if (PyString_Check(*pw)) - *pw = (PyObject *) mpw_FromHEX(PyString_AS_STRING(*pw)); - else { - PyErr_SetString(PyExc_TypeError, "non-numeric coercion failed (mpw_coerce)"); - return 1; - } - - Py_INCREF(*pv); - return 0; -} - -static PyObject * -mpw_int(mpwObject * a) - /*@*/ -{ - size_t anorm = MPW_SIZE(a) - MP_ROUND_B2W(MPBITCNT(MPW_SIZE(a), MPW_DATA(a))); - size_t asize = MPW_SIZE(a) - anorm; - mpw* adata = MPW_DATA(a) + anorm; - long ival = 0; - - if (asize > 1) { - PyErr_SetString(PyExc_ValueError, "mpw_int: arg too long to convert"); - return NULL; - } - if (asize == 1) - ival = adata[0]; - if (a->ob_size < 0) - ival = -ival; - - return Py_BuildValue("i", ival); -} - -static PyObject * -mpw_long(mpwObject * a) - /*@*/ -{ - size_t abits = MPBITCNT(MPW_SIZE(a), MPW_DATA(a)); - size_t anorm = MPW_SIZE(a) - MP_ROUND_B2W(abits); - size_t asize = MPW_SIZE(a) - anorm; - mpw* adata = MPW_DATA(a) + anorm; - size_t zsize = asize; - mpw* zdata = alloca(zsize * sizeof(*zdata)); - int lsize = BITS_TO_DIGITS(abits); - PyLongObject *lo = _PyLong_New(lsize); - int digx; - - if (lo == NULL) - return NULL; - - mpcopy(asize, zdata, adata); - - for (digx = 0; digx < lsize; digx++) { - lo->ob_digit[digx] = zdata[zsize - 1] & MASK; - mprshift(zsize, zdata, SHIFT); - } - - while (digx > 0 && lo->ob_digit[digx-1] == 0) - digx--; - lo->ob_size = (a->ob_size >= 0 ? digx : -digx); - - return (PyObject *)lo; -} - -static PyObject * -mpw_float(mpwObject * a) - /*@*/ -{ - PyObject * so = mpw_format(a, 10, 0); - char * s, * se; - double d; - - if (so == NULL) - return NULL; - s = PyString_AS_STRING(so); - se = NULL; - d = strtod(s, &se); - -if (_mpw_debug) -fprintf(stderr, "*** mpw_float(%p): s %p \"%s\" se %p d %g\n", a, s, s, se, d); - Py_DECREF(so); - - return Py_BuildValue("d", d); -} - -static PyObject * -mpw_oct(mpwObject * a) - /*@*/ -{ - return mpw_format(a, 8, 1); -} - -static PyObject * -mpw_hex(mpwObject * a) - /*@*/ -{ - return mpw_format(a, 16, 1); -} - -static PyNumberMethods mpw_as_number = { - (binaryfunc) mpw_add, /* nb_add */ - (binaryfunc) mpw_sub, /* nb_subtract */ - (binaryfunc) mpw_mul, /* nb_multiply */ - (binaryfunc) mpw_classic_div, /* nb_divide */ - (binaryfunc) mpw_mod, /* nb_remainder */ - (binaryfunc) mpw_divmod, /* nb_divmod */ - (ternaryfunc) mpw_pow, /* nb_power */ - (unaryfunc) mpw_neg, /* nb_negative */ - (unaryfunc) mpw_pos, /* nb_positive */ - (unaryfunc) mpw_abs, /* nb_absolute */ - (inquiry) mpw_nonzero, /* nb_nonzero */ - (unaryfunc) mpw_invert, /* nb_invert */ - (binaryfunc) mpw_lshift, /* nb_lshift */ - (binaryfunc) mpw_rshift, /* nb_rshift */ - (binaryfunc) mpw_and, /* nb_and */ - (binaryfunc) mpw_xor, /* nb_xor */ - (binaryfunc) mpw_or, /* nb_or */ - (coercion) mpw_coerce, /* nb_coerce */ - - (unaryfunc) mpw_int, /* nb_int */ - (unaryfunc) mpw_long, /* nb_long */ - (unaryfunc) mpw_float, /* nb_float */ - (unaryfunc) mpw_oct, /* nb_oct */ - (unaryfunc) mpw_hex, /* nb_hex */ - - /* Added in release 2.0 */ - (binaryfunc) 0, /* nb_inplace_add */ - (binaryfunc) 0, /* nb_inplace_subtract */ - (binaryfunc) 0, /* nb_inplace_multiply */ - (binaryfunc) 0, /* nb_inplace_divide */ - (binaryfunc) 0, /* nb_inplace_remainder */ - (ternaryfunc)0, /* nb_inplace_power */ - (binaryfunc) 0, /* nb_inplace_lshift */ - (binaryfunc) 0, /* nb_inplace_rshift */ - (binaryfunc) 0, /* nb_inplace_and */ - (binaryfunc) 0, /* nb_inplace_xor */ - (binaryfunc) 0, /* nb_inplace_or */ - - /* Added in release 2.2 */ - /* The following require the Py_TPFLAGS_HAVE_CLASS flag */ - (binaryfunc) mpw_div, /* nb_floor_divide */ - (binaryfunc) 0, /* nb_true_divide */ - (binaryfunc) 0, /* nb_inplace_floor_divide */ - (binaryfunc) 0 /* nb_inplace_true_divide */ - -}; - -/* ---------- */ - -/** - */ -/*@unchecked@*/ /*@observer@*/ -static char mpw_doc[] = -""; - -/*@-fullinitblock@*/ -PyTypeObject mpw_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /* ob_size */ - "_bc.mpw", /* tp_name */ - sizeof(mpwObject) - sizeof(mpw),/* tp_basicsize */ - sizeof(mpw), /* tp_itemsize */ - /* methods */ - (destructor) mpw_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - (cmpfunc) mpw_compare, /* tp_compare */ - (reprfunc) mpw_repr, /* tp_repr */ - &mpw_as_number, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc) mpw_str, /* tp_str */ - (getattrofunc) mpw_getattro, /* tp_getattro */ - (setattrofunc) mpw_setattro, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - mpw_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - mpw_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - (newfunc) mpw_new, /* tp_new */ - mpw_free, /* tp_free */ - 0, /* tp_is_gc */ -}; -/*@=fullinitblock@*/ - -/* ---------- */ diff --git a/beecrypt/python/mpw-py.h b/beecrypt/python/mpw-py.h deleted file mode 100644 index 2ef9707db..000000000 --- a/beecrypt/python/mpw-py.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef H_MPW_PY -#define H_MPW_PY - -/** \ingroup py_c - * \file python/mpw-py.h - */ -#include "mp.h" - -/** - */ -typedef struct mpwObject_s { - PyObject_HEAD - int ob_size; - mpw data[1]; -} mpwObject; - -/** - */ -/*@unchecked@*/ -extern PyTypeObject mpw_Type; - -#define mpw_Check(_o) PyObject_TypeCheck((_o), &mpw_Type) -#define mpw_CheckExact(_o) ((_o)->ob_type == &mpw_Type) - -#define MP_ROUND_B2W(_b) MP_BITS_TO_WORDS((_b) + MP_WBITS - 1) - -#define MPW_SIZE(_a) (size_t)((_a)->ob_size < 0 ? -(_a)->ob_size : (_a)->ob_size) -#define MPW_DATA(_a) ((_a)->data) - -/** - */ -mpwObject * mpw_New(int ob_size) - /*@*/; - -/** - */ -mpwObject * mpw_FromMPW(size_t size, mpw* data, int normalize) - /*@*/; - -#endif diff --git a/beecrypt/python/rng-py.c b/beecrypt/python/rng-py.c deleted file mode 100644 index baed89308..000000000 --- a/beecrypt/python/rng-py.c +++ /dev/null @@ -1,325 +0,0 @@ -/** \ingroup py_c - * \file python/rng-py.c - */ - -#define _REENTRANT 1 /* XXX config.h collides with pyconfig.h */ - -#include "system.h" - -#include "rng-py.h" - -#include "debug-py.c" - -#include "debug.h" - -/*@unchecked@*/ -static int _rng_debug = 0; - -/*@unchecked@*/ /*@observer@*/ -static const char initialiser_name[] = "_bc.rng"; - -/* ---------- */ - -static void -rng_dealloc(rngObject * s) - /*@modifies s @*/ -{ -if (_rng_debug < -1) -fprintf(stderr, "*** rng_dealloc(%p)\n", s); - -/*@-modobserver@*/ - randomGeneratorContextFree(&s->rngc); -/*@=modobserver@*/ - mpbfree(&s->b); - PyObject_Del(s); -} - -static int -rng_print(rngObject * s, FILE * fp, /*@unused@*/ int flags) - /*@globals fileSystem @*/ - /*@modifies fileSystem @*/ -{ -if (_rng_debug < -1) -fprintf(stderr, "*** rng_print(%p)\n", s); - return 0; -} - -/** \ingroup py_c - */ -static int rng_init(rngObject * s, PyObject *args, PyObject *kwds) - /*@modifies s @*/ -{ - PyObject * o = NULL; - const randomGenerator* rng = NULL; - - if (!PyArg_ParseTuple(args, "|O:Cvt", &o)) return -1; - - if (o) { - /* XXX "FIPS 186" or "Mersenne Twister" */ - if (PyString_Check(o)) - rng = randomGeneratorFind(PyString_AsString(o)); - } - - if (rng == NULL) - rng = randomGeneratorDefault(); - -/*@-modobserver@*/ - if (randomGeneratorContextInit(&s->rngc, rng) != 0) - return -1; -/*@=modobserver@*/ - mpbzero(&s->b); - -if (_rng_debug) -fprintf(stderr, "*** rng_init(%p[%s],%p[%s],%p[%s])\n", s, lbl(s), args, lbl(args), kwds, lbl(kwds)); - - return 0; -} - -/** \ingroup py_c - */ -static void rng_free(/*@only@*/ rngObject * s) - /*@modifies s @*/ -{ -if (_rng_debug) -fprintf(stderr, "*** rng_free(%p[%s])\n", s, lbl(s)); -/*@-modobserver@*/ - randomGeneratorContextFree(&s->rngc); -/*@=modobserver@*/ - mpbfree(&s->b); - PyObject_Del(s); -} - -/** \ingroup py_c - */ -static PyObject * rng_alloc(PyTypeObject * subtype, int nitems) - /*@*/ -{ - PyObject * ns = PyType_GenericAlloc(subtype, nitems); - -if (_rng_debug) -fprintf(stderr, "*** rng_alloc(%p[%s},%d) ret %p[%s]\n", subtype, lbl(subtype), nitems, ns, lbl(ns)); - return (PyObject *) ns; -} - -static PyObject * -rng_new(PyTypeObject * subtype, PyObject *args, PyObject *kwds) - /*@*/ -{ - PyObject * ns = (PyObject *) PyObject_New(rngObject, &rng_Type); - -if (_rng_debug < -1) -fprintf(stderr, "*** rng_new(%p[%s],%p[%s],%p[%s]) ret %p[%s]\n", subtype, lbl(subtype), args, lbl(args), kwds, lbl(kwds), ns, lbl(ns)); - return ns; -} - -static rngObject * -rng_New(void) -{ - rngObject * ns = PyObject_New(rngObject, &rng_Type); - - return ns; -} - -/* ---------- */ - -/** \ingroup py_c - */ -static PyObject * -rng_Debug(/*@unused@*/ rngObject * s, PyObject * args) - /*@globals _Py_NoneStruct @*/ - /*@modifies _Py_NoneStruct @*/ -{ - if (!PyArg_ParseTuple(args, "i:Debug", &_rng_debug)) return NULL; - -if (_rng_debug < 0) -fprintf(stderr, "*** rng_Debug(%p)\n", s); - - Py_INCREF(Py_None); - return Py_None; -} - -/** \ingroup py_c - */ -static PyObject * -rng_Seed(rngObject * s, PyObject * args) - /*@globals _Py_NoneStruct @*/ - /*@modifies _Py_NoneStruct @*/ -{ - PyObject * o; - randomGeneratorContext* rc = &s->rngc; - mpwObject *z; - - if (!PyArg_ParseTuple(args, "O:Seed", &o)) return NULL; - - if (!mpw_Check(o) || MPW_SIZE(z = (mpwObject*)o) > 0) - return NULL; - - rc->rng->seed(rc->param, (byte*) MPW_DATA(z), MPW_SIZE(z)); - -if (_rng_debug < 0) -fprintf(stderr, "*** rng_Seed(%p)\n", s); - - Py_INCREF(Py_None); - return Py_None; -} - -/** \ingroup py_c - */ -static PyObject * -rng_Next(rngObject * s, PyObject * args) - /*@*/ -{ - PyObject * o = NULL; - randomGeneratorContext* rc = &s->rngc; - mpbarrett* b = &s->b; - mpwObject *z; - - if (!PyArg_ParseTuple(args, "|O:Next", &o)) return NULL; - - if (o) { - if (mpw_Check(o) && MPW_SIZE(z = (mpwObject*)o) > 0) { - b = alloca(sizeof(*b)); - mpbzero(b); - /* XXX z probably needs normalization here. */ - mpbset(b, MPW_SIZE(z), MPW_DATA(z)); - } else - ; /* XXX error? */ - } - - if (b == NULL || b->size == 0 || b->modl == NULL) { - z = mpw_New(1); - rc->rng->next(rc->param, (byte*) MPW_DATA(z), sizeof(*MPW_DATA(z))); - } else { - mpw* wksp = alloca(b->size * sizeof(*wksp)); - z = mpw_New(b->size); - mpbrnd_w(b, rc, MPW_DATA(z), wksp); - } - -if (_rng_debug) -fprintf(stderr, "*** rng_Next(%p) %p[%d]\t", s, MPW_DATA(z), MPW_SIZE(z)), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z)); - - return (PyObject *)z; -} - -/** \ingroup py_c - */ -static PyObject * -rng_Prime(rngObject * s, PyObject * args) - /*@*/ -{ - randomGeneratorContext* rc = &s->rngc; - unsigned pbits = 160; - int trials = -1; - size_t psize; - mpbarrett* b; - mpw *temp; - mpwObject *z; - - if (!PyArg_ParseTuple(args, "|ii:Prime", &pbits, &trials)) return NULL; - - psize = MP_ROUND_B2W(pbits); - temp = alloca((8*psize+2) * sizeof(*temp)); - - b = alloca(sizeof(*b)); - mpbzero(b); - - if (trials <= 2) - trials = mpptrials(pbits); -#if 1 - mpprnd_w(b, rc, pbits, trials, (const mpnumber*) 0, temp); -#else - mpprndsafe_w(b, rc, pbits, trials, temp); -#endif - - z = mpw_FromMPW(b->size, b->modl, 1); -if (z != NULL && _rng_debug) -fprintf(stderr, "*** rng_Prime(%p) %p[%d]\t", s, MPW_DATA(z), MPW_SIZE(z)), mpfprintln(stderr, MPW_SIZE(z), MPW_DATA(z)); - - return (PyObject *)z; -} - -/*@-fullinitblock@*/ -/*@unchecked@*/ /*@observer@*/ -static struct PyMethodDef rng_methods[] = { - {"Debug", (PyCFunction)rng_Debug, METH_VARARGS, - NULL}, - {"seed", (PyCFunction)rng_Seed, METH_VARARGS, - NULL}, - {"next", (PyCFunction)rng_Next, METH_VARARGS, - NULL}, - {"prime", (PyCFunction)rng_Prime, METH_VARARGS, - NULL}, - {NULL, NULL} /* sentinel */ -}; -/*@=fullinitblock@*/ - -static PyObject * rng_getattro(PyObject * o, PyObject * n) - /*@*/ -{ - return PyObject_GenericGetAttr(o, n); -} - -static int rng_setattro(PyObject * o, PyObject * n, PyObject * v) - /*@*/ -{ - return PyObject_GenericSetAttr(o, n, v); -} - -/* ---------- */ - -/** - */ -/*@unchecked@*/ /*@observer@*/ -static char rng_doc[] = -""; - -/*@-fullinitblock@*/ -PyTypeObject rng_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /* ob_size */ - "_bc.rng", /* tp_name */ - sizeof(rngObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - /* methods */ - (destructor) rng_dealloc, /* tp_dealloc */ - (printfunc) rng_print, /* tp_print */ - (getattrfunc)0, /* tp_getattr */ - (setattrfunc)0, /* tp_setattr */ - (cmpfunc)0, /* tp_compare */ - (reprfunc)0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - (reprfunc)0, /* tp_str */ - (getattrofunc) rng_getattro, /* tp_getattro */ - (setattrofunc) rng_setattro, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - rng_doc, /* tp_doc */ -#if Py_TPFLAGS_HAVE_ITER - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - (getiterfunc)0, /* tp_iter */ - (iternextfunc)0, /* tp_iternext */ - rng_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc) rng_init, /* tp_init */ - (allocfunc) rng_alloc, /* tp_alloc */ - (newfunc) rng_new, /* tp_new */ - rng_free, /* tp_free */ - 0, /* tp_is_gc */ -#endif -}; -/*@=fullinitblock@*/ - -/* ---------- */ diff --git a/beecrypt/python/rng-py.h b/beecrypt/python/rng-py.h deleted file mode 100644 index 70a99c5b4..000000000 --- a/beecrypt/python/rng-py.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef H_RNG_PY -#define H_RNG_PY - -/** \ingroup py_c - * \file python/rng-py.h - */ -#include "beecrypt.h" -#include "mpprime.h" - -/** - */ -typedef struct rngObject_s { - PyObject_HEAD - PyObject *md_dict; /*!< to look like PyModuleObject */ - randomGeneratorContext rngc; - mpbarrett b; -} rngObject; - -/** - */ -/*@unchecked@*/ -extern PyTypeObject rng_Type; -#define is_rng(o) ((o)->ob_type == &rng_Type) - -#endif diff --git a/beecrypt/python/system.h b/beecrypt/python/system.h deleted file mode 100644 index 64b813aea..000000000 --- a/beecrypt/python/system.h +++ /dev/null @@ -1,17 +0,0 @@ -/** \ingroup py_c - * \file python/system.h - */ - -#ifndef H_SYSTEM_PYTHON -#define H_SYSTEM_PYTHON - -#include "Python.h" - -#ifdef __LCLINT__ -#undef PyObject_HEAD -#define PyObject_HEAD int _PyObjectHead; -#endif - -#include "../system.h" - -#endif /* H_SYSTEM_PYTHON */ diff --git a/beecrypt/python/test/.cvsignore b/beecrypt/python/test/.cvsignore deleted file mode 100644 index 12664c724..000000000 --- a/beecrypt/python/test/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -Makefile -Makefile.in -*.pyc diff --git a/beecrypt/python/test/Makefile.am b/beecrypt/python/test/Makefile.am deleted file mode 100644 index 1d00d2495..000000000 --- a/beecrypt/python/test/Makefile.am +++ /dev/null @@ -1,14 +0,0 @@ -# Makefile for rpm library. - -AUTOMAKE_OPTIONS = 1.4 foreign - -VALGRIND = # valgrind --verbose --leak-check=yes - -EXTRA_DIST = \ - test_all.py test_methods.py \ - unittest.py - -all: - -check: - $(VALGRIND) PYTHONPATH=.. python test_all.py verbose diff --git a/beecrypt/python/test/test_all.py b/beecrypt/python/test/test_all.py deleted file mode 100644 index 86ae19425..000000000 --- a/beecrypt/python/test/test_all.py +++ /dev/null @@ -1,59 +0,0 @@ -"""Run all test cases. -""" - -import sys -import os -import unittest - -verbose = 0 -if 'verbose' in sys.argv: - verbose = 1 - sys.argv.remove('verbose') - -if 'silent' in sys.argv: # take care of old flag, just in case - verbose = 0 - sys.argv.remove('silent') - - -def print_versions(): - from _bc import mpw - print - print '-=' * 38 - print 'python version: %s' % sys.version - print 'My pid: %s' % os.getpid() - print '-=' * 38 - - -class PrintInfoFakeTest(unittest.TestCase): - def testPrintVersions(self): - print_versions() - - -# This little hack is for when this module is run as main and all the -# other modules import it so they will still be able to get the right -# verbose setting. It's confusing but it works. -import test_all -test_all.verbose = verbose - - -def suite(): - test_modules = [ - 'test_methods', - ] - - alltests = unittest.TestSuite() - for name in test_modules: - module = __import__(name) - alltests.addTest(module.test_suite()) - return alltests - - -def test_suite(): - suite = unittest.TestSuite() - suite.addTest(unittest.makeSuite(PrintInfoFakeTest)) - return suite - - -if __name__ == '__main__': - print_versions() - unittest.main(defaultTest='suite') diff --git a/beecrypt/python/test/test_methods.py b/beecrypt/python/test/test_methods.py deleted file mode 100644 index 71faa612d..000000000 --- a/beecrypt/python/test/test_methods.py +++ /dev/null @@ -1,322 +0,0 @@ -""" -Basic TestCases for BTree and hash DBs, with and without a DBEnv, with -various DB flags, etc. -""" - -import unittest - -from _bc import mpw - -from test_all import verbose - -DASH = '-' - -Methods = ( '__add__', '__sub__', '__mul__', '__div__', '__mod__', '__lshift__', '__rshift__', '__and__', '__xor__', '__or__') - -class Factory(object): - def __init__(self, false_self, method_name): - self.false_self = false_self - self.method_name = method_name - - def __call__(self, val): - xself = long(self.false_self) - yself = int(self.false_self) - xm = long.__getattribute__(xself, self.method_name) - ym = mpw.__getattribute__(yself, self.method_name) - xa = xm(long(val)) - ya = ym(int(val)) - print " Comparing", xa, ya - assert xa == ya - return xa - -class Long(long): - def __getattribute__(self, name): - print "__getattribute__ ~%s~" % name - if name not in ('__add__', '__sub__'): - return long.getattr(self, name) - return Factory(self, name) - -#a1 = Bar(1) -#a2 = Bar(2) -#print a1.__add__(a2) -#print "Done" -#print a1 + a2 - -#---------------------------------------------------------------------- - -class BasicTestCase(unittest.TestCase): - a = 0x0000000987654321L - b = 0x0000000000000010L - c = 0x0fedcba000000000L - lo = 2 - hi = 200 - t = 10 - - def setUp(self): - mpw().Debug(0) - pass - - def tearDown(self): - mpw().Debug(0) - pass - - #---------------------------------------- - - def test01_SimpleMethods(self): - if verbose: - print '\n', '-=' * 30 - print "Running %s.test01_SimpleMethods..." % \ - self.__class__.__name__ - print "\ta:\t%s\t%s\t0x%x" % (type(self.a), self.a, self.a) - print "\tb:\t%s\t%s\t0x%x" % (type(self.b), self.b, self.b) - print "\tc:\t%s\t%s\t0x%x" % (type(self.c), self.c, self.c) - - wa = mpw(self.a) - wb = mpw(self.b) - wc = mpw(self.c) -# xa - Long(self.a) -# xb = Long(self.b) -# xc = Long(self.c) - za = long(self.a) - zb = long(self.b) - zc = long(self.c) - - print "__int__:\t", int(wb), "\t", int(zb) - assert int(wb) == int(zb) - print "__long__:\t", long(wa), "\t", long(za) - assert long(wb) == long(zb) - print "__float__:\t", float(wa), "\t", float(za) - assert float(wb) == float(zb) - - zs = hex(za) - print "__hex__:\t", hex(wa), "\t", zs -# assert hex(wa) == zs # fails because of missing trailing L - zs = oct(za) - print "__oct__:\t", oct(wa), "\t", zs -# assert oct(wa) == zs # fails because of missing trailing L - - print "__neg__:\t", (-wa), "\t", long(-za) - print "__pos__:\t", (+wa), "\t", long(+za) - print "__abs__:\t", abs(wa), "\t", long(abs(za)) - print "__invert__:\t", (~wa), "\t", long(~za) - - print "__add__:\t", (wa + wb), "\t", long(za + zb) - print "__sub__:\t", (wa - wb), "\t", long(za - zb) - print "__mul__:\t", (wa * wb), "\t", long(za * zb) - print "__div__:\t", (wa / wb), "\t", long(za / zb) - print "__mod__:\t", (wa % wb), "\t", long(za % zb) - - wq, wr = divmod(wa, wb) - zq, zr = divmod(za, zb) - print "__divmod__ q:\t", wq, "\t", long(zq) - print "__divmod__ r:\t", wr, "\t", long(zr) - - print "__pow__:\t", (wb ** wb), "\t", long(zb ** zb) - - print "__lshift__:\t", (wa << wb), "\t", long(za << zb) - print "__rshift__:\t", (wa >> wb), "\t", long(za >> zb) - print "__and__:\t", (wa & wc), "\t", long(za & zc) - print "__xor__:\t", (wa ^ wa), "\t", long(za ^ za) - print "__or__:\t", (wa | wc), "\t", long(za | zc) - -# print mpw.__complex__(b) -# print mpw.__coerce__(b, i) - - del wa - del wb - del wc - del za - del zb - del zc - pass - - #---------------------------------------- - def test02_CarryBorrow(self): - if verbose: - print '\n', '-=' * 30 - print "Running %s.test02_CarryBorrow..." % \ - self.__class__.__name__ - a = 0x7fffffff - wa = -mpw(a); wa = wa+wa - za = -long(a); za = za+za - wb = -mpw(1) - zb = -long(1) - wc = mpw(1) - zc = long(1) - wd = mpw(a); wd = wd+wd - zd = long(a); zd = zd+zd - print "add --:\t", (wa+wa), "\t", (za+za) - print "add -+:\t", (wb+wd), "\t", (zb+zd) - print "add +-:\t", (wc+wa), "\t", (zc+za) - print "add ++:\t", (wd+wd), "\t", (zd+zd) - print "sub --:\t", (wb-wa), "\t", (zb-za) -# print "sub -+:\t", (wb-wd), "\t", (zb-zd) -# print "sub +-:\t", (wc-wa), "\t", (zc-za) - print "sub ++:\t", (wc-wd), "\t", (zc-zd) - pass - - #---------------------------------------- - def test03_Signs(self): - if verbose: - print '\n', '-=' * 30 - print "Running %s.test03_Signs..." % \ - self.__class__.__name__ - wpa = mpw(13) - wma = -wpa - wpb = wpa - 3 - wmb = -wpb - zpa = long(13) - zma = -zpa - zpb = zpa - 3 - zmb = -zpb - print "add --:\t", (wma+wmb), "\t", (zma+zmb) - print "add -+:\t", (wma+wpb), "\t", (zma+zpb) - print "add +-:\t", (wpa+wmb), "\t", (zpa+zmb) - print "add ++:\t", (wpa+wpb), "\t", (zpa+zpb) - - print "sub --:\t", (wma-wmb), "\t", (zma-zmb) - print "sub -+:\t", (wma-wpb), "\t", (zma-zpb) - print "sub +-:\t", (wpa-wmb), "\t", (zpa-zmb) - print "sub ++:\t", (wpa-wpb), "\t", (zpa-zpb) - print "sub --:\t", (wmb-wma), "\t", (zmb-zma) - print "sub -+:\t", (wmb-wpa), "\t", (zmb-zpa) - print "sub +-:\t", (wpb-wma), "\t", (zpb-zma) - print "sub ++:\t", (wpb-wpa), "\t", (zpb-zpa) - - print "mul --:\t", (wma*wmb), "\t", (zma*zmb) - print "mul -+:\t", (wma*wpb), "\t", (zma*zpb) - print "mul +-:\t", (wpa*wmb), "\t", (zpa*zmb) - print "mul ++:\t", (wpa*wpb), "\t", (zpa*zpb) - - print "div --:\t", (wma/wmb), "\t", (zma/zmb) - print "div -+:\t", (wma/wpb), "\t", (zma/zpb) - print "div +-:\t", (wpa/wmb), "\t", (zpa/zmb) - print "div ++:\t", (wpa/wpb), "\t", (zpa/zpb) - print "div --:\t", (wmb/wma), "\t", (zmb/zma) - print "div -+:\t", (wmb/wpa), "\t", (zmb/zpa) - print "div +-:\t", (wpb/wma), "\t", (zpb/zma) - print "div ++:\t", (wpb/wpa), "\t", (zpb/zpa) - - print "pow --:\t", (wma**wmb), "\t", (zma**zmb) - print "pow -+:\t", (wma**wpb), "\t", (zma**zpb) - print "pow +-:\t", (wpa**wmb), "\t", (zpa**zmb) - print "pow ++:\t", (wpa**wpb), "\t", (zpa**zpb) - print "pow --:\t", (wmb**wma), "\t", (zmb**zma) - print "pow -+:\t", (wmb**wpa), "\t", (zmb**zpa) - print "pow +-:\t", (wpb**wma), "\t", (zpb**zma) - print "pow ++:\t", (wpb**wpa), "\t", (zpb**zpa) - -# wpa = mpw(13) -# wma = -wpa -# wpb = wpa - 3 -# wmb = -wpb -# zpa = long(13) -# zma = -zpa -# zpb = zpa - 3 -# zmb = -zpb - print "mod --:\t", (wma%wmb), "\t", (zma%zmb) - print "mod -+:\t", (wma%wpb), "\t", (zma%zpb) - print "mod +-:\t", (wpa%wmb), "\t", (zpa%zmb) - print "mod ++:\t", (wpa%wpb), "\t", (zpa%zpb) - print "mod --:\t", (wmb%wma), "\t", (zmb%zma) - print "mod -+:\t", (wmb%wpa), "\t", (zmb%zpa) - print "mod +-:\t", (wpb%wma), "\t", (zpb%zma) - print "mod ++:\t", (wpb%wpa), "\t", (zpb%zpa) - - print "rem --:\t", divmod(wma, wmb), "\t", divmod(zma, zmb) - print "rem -+:\t", divmod(wma, wpb), "\t", divmod(zma, zpb) - print "rem +-:\t", divmod(wpa, wmb), "\t", divmod(zpa, zmb) - print "rem ++:\t", divmod(wpa, wpb), "\t", divmod(zpa, zpb) - print "rem --:\t", divmod(wmb, wma), "\t", divmod(zmb, zma) - print "rem -+:\t", divmod(wmb, wpa), "\t", divmod(zmb, zpa) - print "rem +-:\t", divmod(wpb, wma), "\t", divmod(zpb, zma) - print "rem ++:\t", divmod(wpb, wpa), "\t", divmod(zpb, zpa) - pass - - #---------------------------------------- - def test04_KnuthPoly(self): - self.t = 8 - tfmt = "%o" - if verbose: - print '\n', '-=' * 30 - print "Running %s.test04_KnuthPoly..." % \ - self.__class__.__name__ - print "\t(%d**m - 1) * (%d**n - 1), m,n in [%d,%d)" % (self.t,self.t,self.lo,self.hi) - tm1 = tfmt % (self.t - 1) - tm2 = tfmt % (self.t - 2) - for m in range(self.lo,self.hi): - for n in range(m+1,self.hi+1): - wt = mpw(self.t) - wa = (wt**m - 1) * (wt**n - 1) - ws = tfmt % long(wa) - zs = tm1 * (m - 1) + tm2 + tm1 * (n - m) + "0" * (m - 1) + "1" - if ws != zs: - print "(%d**%d - 1) * (%d**%d - 1)\t%s" % (self.t,m,self.t,n,ws) - assert ws == zs - - self.t = 10 - tfmt = "%d" - if verbose: - print "\t(%d**m - 1) * (%d**n - 1), m,n in [%d,%d)" % (self.t,self.t,self.lo,self.hi) - tm1 = tfmt % (self.t - 1) - tm2 = tfmt % (self.t - 2) - for m in range(self.lo,self.hi): - for n in range(m+1,self.hi+1): - wt = mpw(self.t) - wa = (wt**m - 1) * (wt**n - 1) - ws = tfmt % long(wa) - zs = tm1 * (m - 1) + tm2 + tm1 * (n - m) + "0" * (m - 1) + "1" - if ws != zs: - print "(%d**%d - 1) * (%d**%d - 1)\t%s" % (self.t,m,self.t,n,ws) - assert ws == zs - - self.t = 16 - tfmt = "%x" - if verbose: - print "\t(%d**m - 1) * (%d**n - 1), m,n in [%d,%d)" % (self.t,self.t,self.lo,self.hi) - tm1 = tfmt % (self.t - 1) - tm2 = tfmt % (self.t - 2) - for m in range(self.lo,self.hi): - for n in range(m+1,self.hi+1): - wt = mpw(self.t) - wa = (wt**m - 1) * (wt**n - 1) - ws = tfmt % long(wa) - zs = tm1 * (m - 1) + tm2 + tm1 * (n - m) + "0" * (m - 1) + "1" - if ws != zs: - print "(%d**%d - 1) * (%d**%d - 1)\t%s" % (self.t,m,self.t,n,ws) - assert ws == zs - pass - - #---------------------------------------- - def test05_IterativePowers(self): - if verbose: - print '\n', '-=' * 30 - print "Running %s.test05_IterativePowers..." % \ - self.__class__.__name__ - print "\t(m**n)/(m**(n-1)) == m for m,n in [%d,%d)" % (self.lo,self.hi) - for m in range(self.lo,self.hi): - wa = mpw(m) - wd = wa - for n in range(self.lo,self.hi): - wc = wa**n - we = wc/wd - if we != m: - print m, '^', n, '=', we - assert we == m - if wc != 0: - wd = wc - pass - -#---------------------------------------------------------------------- -#---------------------------------------------------------------------- - -def test_suite(): - suite = unittest.TestSuite() - - suite.addTest(unittest.makeSuite(BasicTestCase)) - - return suite - - -if __name__ == '__main__': - unittest.main(defaultTest='test_suite') diff --git a/beecrypt/python/test/unittest.py b/beecrypt/python/test/unittest.py deleted file mode 100644 index d31e251d4..000000000 --- a/beecrypt/python/test/unittest.py +++ /dev/null @@ -1,759 +0,0 @@ -#!/usr/bin/env python -''' -Python unit testing framework, based on Erich Gamma's JUnit and Kent Beck's -Smalltalk testing framework. - -This module contains the core framework classes that form the basis of -specific test cases and suites (TestCase, TestSuite etc.), and also a -text-based utility class for running the tests and reporting the results - (TextTestRunner). - -Simple usage: - - import unittest - - class IntegerArithmenticTestCase(unittest.TestCase): - def testAdd(self): ## test method names begin 'test*' - self.assertEquals((1 + 2), 3) - self.assertEquals(0 + 1, 1) - def testMultiply(self): - self.assertEquals((0 * 10), 0) - self.assertEquals((5 * 8), 40) - - if __name__ == '__main__': - unittest.main() - -Further information is available in the bundled documentation, and from - - http://pyunit.sourceforge.net/ - -Copyright (c) 1999, 2000, 2001 Steve Purcell -This module is free software, and you may redistribute it and/or modify -it under the same terms as Python itself, so long as this copyright message -and disclaimer are retained in their original form. - -IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, -SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF -THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGE. - -THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, -AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, -SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. -''' - -__author__ = "Steve Purcell" -__email__ = "stephen_purcell at yahoo dot com" -__version__ = "#Revision: 1.46 $"[11:-2] - -import time -import sys -import traceback -import string -import os -import types - -############################################################################## -# Test framework core -############################################################################## - -# All classes defined herein are 'new-style' classes, allowing use of 'super()' -__metaclass__ = type - -def _strclass(cls): - return "%s.%s" % (cls.__module__, cls.__name__) - -class TestResult: - """Holder for test result information. - - Test results are automatically managed by the TestCase and TestSuite - classes, and do not need to be explicitly manipulated by writers of tests. - - Each instance holds the total number of tests run, and collections of - failures and errors that occurred among those test runs. The collections - contain tuples of (testcase, exceptioninfo), where exceptioninfo is the - formatted traceback of the error that occurred. - """ - def __init__(self): - self.failures = [] - self.errors = [] - self.testsRun = 0 - self.shouldStop = 0 - - def startTest(self, test): - "Called when the given test is about to be run" - self.testsRun = self.testsRun + 1 - - def stopTest(self, test): - "Called when the given test has been run" - pass - - def addError(self, test, err): - """Called when an error has occurred. 'err' is a tuple of values as - returned by sys.exc_info(). - """ - self.errors.append((test, self._exc_info_to_string(err))) - - def addFailure(self, test, err): - """Called when an error has occurred. 'err' is a tuple of values as - returned by sys.exc_info().""" - self.failures.append((test, self._exc_info_to_string(err))) - - def addSuccess(self, test): - "Called when a test has completed successfully" - pass - - def wasSuccessful(self): - "Tells whether or not this result was a success" - return len(self.failures) == len(self.errors) == 0 - - def stop(self): - "Indicates that the tests should be aborted" - self.shouldStop = 1 - - def _exc_info_to_string(self, err): - """Converts a sys.exc_info()-style tuple of values into a string.""" - return string.join(traceback.format_exception(*err), '') - - def __repr__(self): - return "<%s run=%i errors=%i failures=%i>" % \ - (_strclass(self.__class__), self.testsRun, len(self.errors), - len(self.failures)) - - -class TestCase: - """A class whose instances are single test cases. - - By default, the test code itself should be placed in a method named - 'runTest'. - - If the fixture may be used for many test cases, create as - many test methods as are needed. When instantiating such a TestCase - subclass, specify in the constructor arguments the name of the test method - that the instance is to execute. - - Test authors should subclass TestCase for their own tests. Construction - and deconstruction of the test's environment ('fixture') can be - implemented by overriding the 'setUp' and 'tearDown' methods respectively. - - If it is necessary to override the __init__ method, the base class - __init__ method must always be called. It is important that subclasses - should not change the signature of their __init__ method, since instances - of the classes are instantiated automatically by parts of the framework - in order to be run. - """ - - # This attribute determines which exception will be raised when - # the instance's assertion methods fail; test methods raising this - # exception will be deemed to have 'failed' rather than 'errored' - - failureException = AssertionError - - def __init__(self, methodName='runTest'): - """Create an instance of the class that will use the named test - method when executed. Raises a ValueError if the instance does - not have a method with the specified name. - """ - try: - self.__testMethodName = methodName - testMethod = getattr(self, methodName) - self.__testMethodDoc = testMethod.__doc__ - except AttributeError: - raise ValueError, "no such test method in %s: %s" % \ - (self.__class__, methodName) - - def setUp(self): - "Hook method for setting up the test fixture before exercising it." - pass - - def tearDown(self): - "Hook method for deconstructing the test fixture after testing it." - pass - - def countTestCases(self): - return 1 - - def defaultTestResult(self): - return TestResult() - - def shortDescription(self): - """Returns a one-line description of the test, or None if no - description has been provided. - - The default implementation of this method returns the first line of - the specified test method's docstring. - """ - doc = self.__testMethodDoc - return doc and string.strip(string.split(doc, "\n")[0]) or None - - def id(self): - return "%s.%s" % (_strclass(self.__class__), self.__testMethodName) - - def __str__(self): - return "%s (%s)" % (self.__testMethodName, _strclass(self.__class__)) - - def __repr__(self): - return "<%s testMethod=%s>" % \ - (_strclass(self.__class__), self.__testMethodName) - - def run(self, result=None): - return self(result) - - def __call__(self, result=None): - if result is None: result = self.defaultTestResult() - result.startTest(self) - testMethod = getattr(self, self.__testMethodName) - try: - try: - self.setUp() - except KeyboardInterrupt: - raise - except: - result.addError(self, self.__exc_info()) - return - - ok = 0 - try: - testMethod() - ok = 1 - except self.failureException, e: - result.addFailure(self, self.__exc_info()) - except KeyboardInterrupt: - raise - except: - result.addError(self, self.__exc_info()) - - try: - self.tearDown() - except KeyboardInterrupt: - raise - except: - result.addError(self, self.__exc_info()) - ok = 0 - if ok: result.addSuccess(self) - finally: - result.stopTest(self) - - def debug(self): - """Run the test without collecting errors in a TestResult""" - self.setUp() - getattr(self, self.__testMethodName)() - self.tearDown() - - def __exc_info(self): - """Return a version of sys.exc_info() with the traceback frame - minimised; usually the top level of the traceback frame is not - needed. - """ - exctype, excvalue, tb = sys.exc_info() - if sys.platform[:4] == 'java': ## tracebacks look different in Jython - return (exctype, excvalue, tb) - newtb = tb.tb_next - if newtb is None: - return (exctype, excvalue, tb) - return (exctype, excvalue, newtb) - - def fail(self, msg=None): - """Fail immediately, with the given message.""" - raise self.failureException, msg - - def failIf(self, expr, msg=None): - "Fail the test if the expression is true." - if expr: raise self.failureException, msg - - def failUnless(self, expr, msg=None): - """Fail the test unless the expression is true.""" - if not expr: raise self.failureException, msg - - def failUnlessRaises(self, excClass, callableObj, *args, **kwargs): - """Fail unless an exception of class excClass is thrown - by callableObj when invoked with arguments args and keyword - arguments kwargs. If a different type of exception is - thrown, it will not be caught, and the test case will be - deemed to have suffered an error, exactly as for an - unexpected exception. - """ - try: - callableObj(*args, **kwargs) - except excClass: - return - else: - if hasattr(excClass,'__name__'): excName = excClass.__name__ - else: excName = str(excClass) - raise self.failureException, excName - - def failUnlessEqual(self, first, second, msg=None): - """Fail if the two objects are unequal as determined by the '==' - operator. - """ - if not first == second: - raise self.failureException, \ - (msg or '%s != %s' % (`first`, `second`)) - - def failIfEqual(self, first, second, msg=None): - """Fail if the two objects are equal as determined by the '==' - operator. - """ - if first == second: - raise self.failureException, \ - (msg or '%s == %s' % (`first`, `second`)) - - def failUnlessAlmostEqual(self, first, second, places=7, msg=None): - """Fail if the two objects are unequal as determined by their - difference rounded to the given number of decimal places - (default 7) and comparing to zero. - - Note that decimal places (from zero) is usually not the same - as significant digits (measured from the most signficant digit). - """ - if round(second-first, places) != 0: - raise self.failureException, \ - (msg or '%s != %s within %s places' % (`first`, `second`, `places` )) - - def failIfAlmostEqual(self, first, second, places=7, msg=None): - """Fail if the two objects are equal as determined by their - difference rounded to the given number of decimal places - (default 7) and comparing to zero. - - Note that decimal places (from zero) is usually not the same - as significant digits (measured from the most signficant digit). - """ - if round(second-first, places) == 0: - raise self.failureException, \ - (msg or '%s == %s within %s places' % (`first`, `second`, `places`)) - - assertEqual = assertEquals = failUnlessEqual - - assertNotEqual = assertNotEquals = failIfEqual - - assertAlmostEqual = assertAlmostEquals = failUnlessAlmostEqual - - assertNotAlmostEqual = assertNotAlmostEquals = failIfAlmostEqual - - assertRaises = failUnlessRaises - - assert_ = failUnless - - - -class TestSuite: - """A test suite is a composite test consisting of a number of TestCases. - - For use, create an instance of TestSuite, then add test case instances. - When all tests have been added, the suite can be passed to a test - runner, such as TextTestRunner. It will run the individual test cases - in the order in which they were added, aggregating the results. When - subclassing, do not forget to call the base class constructor. - """ - def __init__(self, tests=()): - self._tests = [] - self.addTests(tests) - - def __repr__(self): - return "<%s tests=%s>" % (_strclass(self.__class__), self._tests) - - __str__ = __repr__ - - def countTestCases(self): - cases = 0 - for test in self._tests: - cases = cases + test.countTestCases() - return cases - - def addTest(self, test): - self._tests.append(test) - - def addTests(self, tests): - for test in tests: - self.addTest(test) - - def run(self, result): - return self(result) - - def __call__(self, result): - for test in self._tests: - if result.shouldStop: - break - test(result) - return result - - def debug(self): - """Run the tests without collecting errors in a TestResult""" - for test in self._tests: test.debug() - - -class FunctionTestCase(TestCase): - """A test case that wraps a test function. - - This is useful for slipping pre-existing test functions into the - PyUnit framework. Optionally, set-up and tidy-up functions can be - supplied. As with TestCase, the tidy-up ('tearDown') function will - always be called if the set-up ('setUp') function ran successfully. - """ - - def __init__(self, testFunc, setUp=None, tearDown=None, - description=None): - TestCase.__init__(self) - self.__setUpFunc = setUp - self.__tearDownFunc = tearDown - self.__testFunc = testFunc - self.__description = description - - def setUp(self): - if self.__setUpFunc is not None: - self.__setUpFunc() - - def tearDown(self): - if self.__tearDownFunc is not None: - self.__tearDownFunc() - - def runTest(self): - self.__testFunc() - - def id(self): - return self.__testFunc.__name__ - - def __str__(self): - return "%s (%s)" % (_strclass(self.__class__), self.__testFunc.__name__) - - def __repr__(self): - return "<%s testFunc=%s>" % (_strclass(self.__class__), self.__testFunc) - - def shortDescription(self): - if self.__description is not None: return self.__description - doc = self.__testFunc.__doc__ - return doc and string.strip(string.split(doc, "\n")[0]) or None - - - -############################################################################## -# Locating and loading tests -############################################################################## - -class TestLoader: - """This class is responsible for loading tests according to various - criteria and returning them wrapped in a Test - """ - testMethodPrefix = 'test' - sortTestMethodsUsing = cmp - suiteClass = TestSuite - - def loadTestsFromTestCase(self, testCaseClass): - """Return a suite of all tests cases contained in testCaseClass""" - return self.suiteClass(map(testCaseClass, - self.getTestCaseNames(testCaseClass))) - - def loadTestsFromModule(self, module): - """Return a suite of all tests cases contained in the given module""" - tests = [] - for name in dir(module): - obj = getattr(module, name) - if (isinstance(obj, (type, types.ClassType)) and - issubclass(obj, TestCase)): - tests.append(self.loadTestsFromTestCase(obj)) - return self.suiteClass(tests) - - def loadTestsFromName(self, name, module=None): - """Return a suite of all tests cases given a string specifier. - - The name may resolve either to a module, a test case class, a - test method within a test case class, or a callable object which - returns a TestCase or TestSuite instance. - - The method optionally resolves the names relative to a given module. - """ - parts = string.split(name, '.') - if module is None: - if not parts: - raise ValueError, "incomplete test name: %s" % name - else: - parts_copy = parts[:] - while parts_copy: - try: - module = __import__(string.join(parts_copy,'.')) - break - except ImportError: - del parts_copy[-1] - if not parts_copy: raise - parts = parts[1:] - obj = module - for part in parts: - obj = getattr(obj, part) - - import unittest - if type(obj) == types.ModuleType: - return self.loadTestsFromModule(obj) - elif (isinstance(obj, (type, types.ClassType)) and - issubclass(obj, unittest.TestCase)): - return self.loadTestsFromTestCase(obj) - elif type(obj) == types.UnboundMethodType: - return obj.im_class(obj.__name__) - elif callable(obj): - test = obj() - if not isinstance(test, unittest.TestCase) and \ - not isinstance(test, unittest.TestSuite): - raise ValueError, \ - "calling %s returned %s, not a test" % (obj,test) - return test - else: - raise ValueError, "don't know how to make test from: %s" % obj - - def loadTestsFromNames(self, names, module=None): - """Return a suite of all tests cases found using the given sequence - of string specifiers. See 'loadTestsFromName()'. - """ - suites = [] - for name in names: - suites.append(self.loadTestsFromName(name, module)) - return self.suiteClass(suites) - - def getTestCaseNames(self, testCaseClass): - """Return a sorted sequence of method names found within testCaseClass - """ - testFnNames = filter(lambda n,p=self.testMethodPrefix: n[:len(p)] == p, - dir(testCaseClass)) - for baseclass in testCaseClass.__bases__: - for testFnName in self.getTestCaseNames(baseclass): - if testFnName not in testFnNames: # handle overridden methods - testFnNames.append(testFnName) - if self.sortTestMethodsUsing: - testFnNames.sort(self.sortTestMethodsUsing) - return testFnNames - - - -defaultTestLoader = TestLoader() - - -############################################################################## -# Patches for old functions: these functions should be considered obsolete -############################################################################## - -def _makeLoader(prefix, sortUsing, suiteClass=None): - loader = TestLoader() - loader.sortTestMethodsUsing = sortUsing - loader.testMethodPrefix = prefix - if suiteClass: loader.suiteClass = suiteClass - return loader - -def getTestCaseNames(testCaseClass, prefix, sortUsing=cmp): - return _makeLoader(prefix, sortUsing).getTestCaseNames(testCaseClass) - -def makeSuite(testCaseClass, prefix='test', sortUsing=cmp, suiteClass=TestSuite): - return _makeLoader(prefix, sortUsing, suiteClass).loadTestsFromTestCase(testCaseClass) - -def findTestCases(module, prefix='test', sortUsing=cmp, suiteClass=TestSuite): - return _makeLoader(prefix, sortUsing, suiteClass).loadTestsFromModule(module) - - -############################################################################## -# Text UI -############################################################################## - -class _WritelnDecorator: - """Used to decorate file-like objects with a handy 'writeln' method""" - def __init__(self,stream): - self.stream = stream - - def __getattr__(self, attr): - return getattr(self.stream,attr) - - def writeln(self, *args): - if args: self.write(*args) - self.write('\n') # text-mode streams translate to \r\n if needed - - -class _TextTestResult(TestResult): - """A test result class that can print formatted text results to a stream. - - Used by TextTestRunner. - """ - separator1 = '=' * 70 - separator2 = '-' * 70 - - def __init__(self, stream, descriptions, verbosity): - TestResult.__init__(self) - self.stream = stream - self.showAll = verbosity > 1 - self.dots = verbosity == 1 - self.descriptions = descriptions - - def getDescription(self, test): - if self.descriptions: - return test.shortDescription() or str(test) - else: - return str(test) - - def startTest(self, test): - TestResult.startTest(self, test) - if self.showAll: - self.stream.write(self.getDescription(test)) - self.stream.write(" ... ") - - def addSuccess(self, test): - TestResult.addSuccess(self, test) - if self.showAll: - self.stream.writeln("ok") - elif self.dots: - self.stream.write('.') - - def addError(self, test, err): - TestResult.addError(self, test, err) - if self.showAll: - self.stream.writeln("ERROR") - elif self.dots: - self.stream.write('E') - - def addFailure(self, test, err): - TestResult.addFailure(self, test, err) - if self.showAll: - self.stream.writeln("FAIL") - elif self.dots: - self.stream.write('F') - - def printErrors(self): - if self.dots or self.showAll: - self.stream.writeln() - self.printErrorList('ERROR', self.errors) - self.printErrorList('FAIL', self.failures) - - def printErrorList(self, flavour, errors): - for test, err in errors: - self.stream.writeln(self.separator1) - self.stream.writeln("%s: %s" % (flavour,self.getDescription(test))) - self.stream.writeln(self.separator2) - self.stream.writeln("%s" % err) - - -class TextTestRunner: - """A test runner class that displays results in textual form. - - It prints out the names of tests as they are run, errors as they - occur, and a summary of the results at the end of the test run. - """ - def __init__(self, stream=sys.stderr, descriptions=1, verbosity=1): - self.stream = _WritelnDecorator(stream) - self.descriptions = descriptions - self.verbosity = verbosity - - def _makeResult(self): - return _TextTestResult(self.stream, self.descriptions, self.verbosity) - - def run(self, test): - "Run the given test case or test suite." - result = self._makeResult() - startTime = time.time() - test(result) - stopTime = time.time() - timeTaken = float(stopTime - startTime) - result.printErrors() - self.stream.writeln(result.separator2) - run = result.testsRun - self.stream.writeln("Ran %d test%s in %.3fs" % - (run, run != 1 and "s" or "", timeTaken)) - self.stream.writeln() - if not result.wasSuccessful(): - self.stream.write("FAILED (") - failed, errored = map(len, (result.failures, result.errors)) - if failed: - self.stream.write("failures=%d" % failed) - if errored: - if failed: self.stream.write(", ") - self.stream.write("errors=%d" % errored) - self.stream.writeln(")") - else: - self.stream.writeln("OK") - return result - - - -############################################################################## -# Facilities for running tests from the command line -############################################################################## - -class TestProgram: - """A command-line program that runs a set of tests; this is primarily - for making test modules conveniently executable. - """ - USAGE = """\ -Usage: %(progName)s [options] [test] [...] - -Options: - -h, --help Show this message - -v, --verbose Verbose output - -q, --quiet Minimal output - -Examples: - %(progName)s - run default set of tests - %(progName)s MyTestSuite - run suite 'MyTestSuite' - %(progName)s MyTestCase.testSomething - run MyTestCase.testSomething - %(progName)s MyTestCase - run all 'test*' test methods - in MyTestCase -""" - def __init__(self, module='__main__', defaultTest=None, - argv=None, testRunner=None, testLoader=defaultTestLoader): - if type(module) == type(''): - self.module = __import__(module) - for part in string.split(module,'.')[1:]: - self.module = getattr(self.module, part) - else: - self.module = module - if argv is None: - argv = sys.argv - self.verbosity = 1 - self.defaultTest = defaultTest - self.testRunner = testRunner - self.testLoader = testLoader - self.progName = os.path.basename(argv[0]) - self.parseArgs(argv) - self.runTests() - - def usageExit(self, msg=None): - if msg: print msg - print self.USAGE % self.__dict__ - sys.exit(2) - - def parseArgs(self, argv): - import getopt - try: - options, args = getopt.getopt(argv[1:], 'hHvq', - ['help','verbose','quiet']) - for opt, value in options: - if opt in ('-h','-H','--help'): - self.usageExit() - if opt in ('-q','--quiet'): - self.verbosity = 0 - if opt in ('-v','--verbose'): - self.verbosity = 2 - if len(args) == 0 and self.defaultTest is None: - self.test = self.testLoader.loadTestsFromModule(self.module) - return - if len(args) > 0: - self.testNames = args - else: - self.testNames = (self.defaultTest,) - self.createTests() - except getopt.error, msg: - self.usageExit(msg) - - def createTests(self): - self.test = self.testLoader.loadTestsFromNames(self.testNames, - self.module) - - def runTests(self): - if self.testRunner is None: - self.testRunner = TextTestRunner(verbosity=self.verbosity) - result = self.testRunner.run(self.test) - sys.exit(not result.wasSuccessful()) - -main = TestProgram - - -############################################################################## -# Executing this module from the command line -############################################################################## - -if __name__ == "__main__": - main(module=None) diff --git a/beecrypt/rsa.c b/beecrypt/rsa.c deleted file mode 100644 index 789d83899..000000000 --- a/beecrypt/rsa.c +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (c) 2000, 2001, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file rsa.c - * \brief RSA algorithm. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup IF_m IF_rsa_m - */ - -#include "system.h" - -#include "rsa.h" -#include "mp.h" - -#include "debug.h" - -int rsapub(const mpbarrett* n, const mpnumber* e, - const mpnumber* m, mpnumber* c) -{ - register size_t size = n->size; - register mpw* temp; - - if (mpgex(m->size, m->data, n->size, n->modl)) - return -1; - - temp = (mpw*) malloc((4*size+2)*sizeof(mpw)); - - if (temp) - { - mpnsize(c, size); - - mpbpowmod_w(n, m->size, m->data, e->size, e->data, c->data, temp); - - free(temp); - - return 0; - } - return -1; -} - -int rsapri(const mpbarrett* n, const mpnumber* d, - const mpnumber* c, mpnumber* m) -{ - register size_t size = n->size; - register mpw* temp; - - if (mpgex(c->size, c->data, n->size, n->modl)) - return -1; - - temp = (mpw*) malloc((4*size+2)*sizeof(mpw)); - - if (temp) - { - mpnsize(m, size); - mpbpowmod_w(n, c->size, c->data, d->size, d->data, m->data, temp); - - free(temp); - - return 0; - } - return -1; -} - -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) -{ - register size_t nsize = n->size; - register size_t psize = p->size; - register size_t qsize = q->size; - - register mpw* ptemp; - register mpw* qtemp; - - if (mpgex(c->size, c->data, n->size, n->modl)) - return -1; - - ptemp = (mpw*) malloc((6*psize+2)*sizeof(mpw)); - if (ptemp == (mpw*) 0) - return -1; - - qtemp = (mpw*) malloc((6*qsize+2)*sizeof(mpw)); - if (qtemp == (mpw*) 0) - { - free(ptemp); - return -1; - } - - /* resize c for powmod p */ - mpsetx(psize*2, ptemp, c->size, c->data); - - /* reduce modulo p before we powmod */ - mpbmod_w(p, ptemp, ptemp+psize, ptemp+2*psize); - - /* compute j1 = c^dp mod p, store @ ptemp */ - mpbpowmod_w(p, psize, ptemp+psize, dp->size, dp->data, ptemp, ptemp+2*psize); - - /* resize c for powmod q */ - mpsetx(qsize*2, qtemp, c->size, c->data); - - /* reduce modulo q before we powmod */ - mpbmod_w(q, qtemp, qtemp+qsize, qtemp+2*qsize); - - /* compute j2 = c^dq mod q, store @ qtemp */ - mpbpowmod_w(q, qsize, qtemp+qsize, dq->size, dq->data, qtemp, qtemp+2*qsize); - - /* compute j1-j2 mod p, store @ ptemp */ - mpbsubmod_w(p, psize, ptemp, qsize, qtemp, ptemp, ptemp+2*psize); - - /* compute h = c*(j1-j2) mod p, store @ ptemp */ - mpbmulmod_w(p, psize, ptemp, psize, qi->data, ptemp, ptemp+2*psize); - - /* make sure the message gets the proper size */ - mpnsize(m, nsize); - - /* compute m = h*q + j2 */ - mpmul(m->data, psize, ptemp, qsize, q->modl); - mpaddx(nsize, m->data, qsize, qtemp); - - free(ptemp); - free(qtemp); - - return 0; -} - -int rsavrfy(const mpbarrett* n, const mpnumber* e, - const mpnumber* m, const mpnumber* c) -{ - int rc; - register size_t size = n->size; - - register mpw* temp; - - if (mpgex(m->size, m->data, n->size, n->modl)) - return -1; - - if (mpgex(c->size, c->data, n->size, n->modl)) - return 0; - - temp = (mpw*) malloc((5*size+2)*sizeof(mpw)); - - if (temp) - { - mpbpowmod_w(n, m->size, m->data, e->size, e->data, temp, temp+size); - - rc = mpeqx(size, temp, c->size, c->data); - - free(temp); - - return rc; - } - - return 0; -} diff --git a/beecrypt/rsa.h b/beecrypt/rsa.h deleted file mode 100644 index a429ebda2..000000000 --- a/beecrypt/rsa.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2000, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file rsa.h - * \brief RSA algorithm. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup IF_m IF_rsa_m - */ - -#ifndef _RSA_H -#define _RSA_H - -#include "rsakp.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/*!\fn int rsapub(const mpbarrett* n, const mpnumber* e, const mpnumber* m, mpnumber* c) - * \brief This function performs a raw RSA public key operation. - * - * This function can be used for encryption and verifying. - * - * It performs the following operation: - * \li \f$c=m^{e}\ \textrm{mod}\ n\f$ - * - * \param n The RSA modulus. - * \param e The RSA public exponent. - * \param m The message. - * \param c The ciphertext. - * \retval 0 on success. - * \retval -1 on failure. - */ -BEECRYPTAPI -int rsapub(const mpbarrett* n, const mpnumber* e, - const mpnumber* m, mpnumber* c) - /*@modifies c @*/; - -/*!\fn int rsapri(const mpbarrett* n, const mpnumber* d, const mpnumber* c, mpnumber* m) - * \brief This function performs a raw RSA private key operation. - * - * This function can be used for decryption and signing. - * - * It performs the operation: - * \li \f$m=c^{d}\ \textrm{mod}\ n\f$ - * - * \param n The RSA modulus. - * \param d The RSA private exponent. - * \param c The ciphertext. - * \param m The message. - * \retval 0 on success. - * \retval -1 on failure. - */ -BEECRYPTAPI -int rsapri(const mpbarrett* n, const mpnumber* d, - const mpnumber* c, mpnumber* m) - /*@modifies m @*/; - -/*!\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) - * - * \brief This function performs a raw RSA private key operation, with - * application of the Chinese Remainder Theorem. - * - * It performs the operation: - * \li \f$j_1=c^{dp}\ \textrm{mod}\ p\f$ - * \li \f$j_2=c^{dq}\ \textrm{mod}\ q\f$ - * \li \f$h=qi \cdot (j_1-j_2)\ \textrm{mod}\ p\f$ - * \li \f$m=j_2+hq\f$ - * - * \param n The RSA modulus. - * \param p The first RSA prime factor. - * \param q The second RSA prime factor. - * \param dp - * \param dq - * \param qi - * \param c The ciphertext. - * \param m The message. - * \retval 0 on success. - * \retval -1 on failure. - */ -BEECRYPTAPI -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) - /*@modifies m @*/; - -/*!\fn int rsavrfy(const mpbarrett* n, const mpnumber* e, const mpnumber* m, const mpnumber* c) - * \brief This function performs a raw RSA verification. - * - * It verifies if ciphertext \a c was encrypted from cleartext \a m - * with the private key matching the given public key \a (n, e). - * - * \param n The RSA modulus. - * \param e The RSA public exponent. - * \param m The cleartext message. - * \param c The ciphertext message. - * \retval 1 on success. - * \retval 0 on failure. - */ -BEECRYPTAPI -int rsavrfy(const mpbarrett* n, const mpnumber* e, - const mpnumber* m, const mpnumber* c) - /*@*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/rsakp.c b/beecrypt/rsakp.c deleted file mode 100644 index 51205c20b..000000000 --- a/beecrypt/rsakp.c +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (c) 2000, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file rsakp.c - * \brief RSA keypair. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup IF_m IF_rsa_m - */ - -#include "system.h" - -#include "rsakp.h" -#include "mpprime.h" -#include "mp.h" - -#include "debug.h" - -/*!\addtogroup IF_rsa_m - * \{ - */ - -int rsakpMake(rsakp* kp, randomGeneratorContext* rgc, size_t bits) -{ - /* - * Generates an RSA Keypair for use with the Chinese Remainder Theorem - */ - - size_t pbits = (bits+1) >> 1; - size_t qbits = (bits - pbits); - size_t nsize = MP_BITS_TO_WORDS(bits+MP_WBITS-1); - size_t psize = MP_BITS_TO_WORDS(pbits+MP_WBITS-1); - size_t qsize = MP_BITS_TO_WORDS(qbits+MP_WBITS-1); - size_t pqsize = psize+qsize; - mpw* temp = (mpw*) malloc((16*pqsize+6)*sizeof(mpw)); - - if (temp) - { - mpbarrett psubone, qsubone; - mpnumber phi, min; - mpw* divmod = temp; - mpw* dividend = divmod+nsize+1; - mpw* workspace = dividend+nsize+1; - int shift; - - /* set e to default value if e is empty */ - if (kp->e.size == 0 && !kp->e.data) - mpnsetw(&kp->e, 65537U); - - /* generate a random prime p, so that gcd(p-1,e) = 1 */ - mpprnd_w(&kp->p, rgc, pbits, mpptrials(pbits), &kp->e, temp); - - /* find out how big q should be */ - shift = MP_WORDS_TO_BITS(nsize) - bits; - mpzero(nsize, dividend); - dividend[0] |= MP_MSBMASK; - dividend[nsize-1] |= MP_LSBMASK; - mpndivmod(divmod, nsize+1, dividend, psize, kp->p.modl, workspace); - mprshift(nsize+1, divmod, shift); - - mpnzero(&min); - mpnset(&min, nsize+1-psize, divmod); - - /* generate a random prime q, with min/max constraints, so that gcd(q-1,e) = 1 */ - if (mpprndr_w(&kp->q, rgc, qbits, mpptrials(qbits), &min, (mpnumber*) 0, &kp->e, temp)) - { - /* shouldn't happen */ - mpnfree(&min); - free(temp); - return -1; - } - - mpnfree(&min); - - mpbzero(&psubone); - mpbzero(&qsubone); - mpnzero(&phi); - - /* set n = p*q, with appropriate size (pqsize may be > nsize) */ - mpmul(temp, psize, kp->p.modl, qsize, kp->q.modl); - mpbset(&kp->n, nsize, temp+pqsize-nsize); - - /* compute p-1 */ - mpbsubone(&kp->p, temp); - mpbset(&psubone, psize, temp); - - /* compute q-1 */ - mpbsubone(&kp->q, temp); - mpbset(&qsubone, qsize, temp); - - /* compute phi = (p-1)*(q-1) */ - mpmul(temp, psize, psubone.modl, qsize, qsubone.modl); - mpnset(&phi, nsize, temp); - - /* compute d = inv(e) mod phi; if gcd(e, phi) != 1 then this function will fail - */ - if (mpninv(&kp->d, &kp->e, &phi) == 0) - { - /* shouldn't happen, since gcd(p-1,e) = 1 and gcd(q-1,e) = 1 ==> gcd((p-1)(q-1),e) = 1 */ - free(temp); - return -1; - } - - /* compute dp = d mod (p-1) */ - mpnsize(&kp->dp, psize); - mpbmod_w(&psubone, kp->d.data, kp->dp.data, temp); - - /* compute dq = d mod (q-1) */ - mpnsize(&kp->dq, qsize); - mpbmod_w(&qsubone, kp->d.data, kp->dq.data, temp); - - /* compute qi = inv(q) mod p */ - mpninv(&kp->qi, (mpnumber*) &kp->q, (mpnumber*) &kp->p); - - free(temp); - - return 0; - } - return -1; -} - -int rsakpInit(rsakp* kp) -{ - memset(kp, 0, sizeof(rsakp)); - /* or - mpbzero(&kp->n); - mpnzero(&kp->e); - mpnzero(&kp->d); - mpbzero(&kp->p); - mpbzero(&kp->q); - mpnzero(&kp->dp); - mpnzero(&kp->dq); - mpnzero(&kp->qi); - */ - - return 0; -} - -int rsakpFree(rsakp* kp) -{ - /* wipe all secret key components */ - mpbfree(&kp->n); - mpnfree(&kp->e); - mpnwipe(&kp->d); - mpnfree(&kp->d); - mpbwipe(&kp->p); - mpbfree(&kp->p); - mpbwipe(&kp->q); - mpbfree(&kp->q); - mpnwipe(&kp->dp); - mpnfree(&kp->dp); - mpnwipe(&kp->dq); - mpnfree(&kp->dq); - mpnwipe(&kp->qi); - mpnfree(&kp->qi); - - return 0; -} - -int rsakpCopy(rsakp* dst, const rsakp* src) -{ - mpbcopy(&dst->n, &src->n); - mpncopy(&dst->e, &src->e); - mpncopy(&dst->d, &src->d); - mpbcopy(&dst->p, &src->p); - mpbcopy(&dst->q, &src->q); - mpncopy(&dst->dp, &src->dp); - mpncopy(&dst->dp, &src->dp); - mpncopy(&dst->qi, &src->qi); - - return 0; -} - -/*!\} - */ diff --git a/beecrypt/rsakp.h b/beecrypt/rsakp.h deleted file mode 100644 index 684bef6ad..000000000 --- a/beecrypt/rsakp.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2000, 2001, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file rsakp.h - * \brief RSA keypair, headers. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup IF_m IF_rsa_m - */ - -#ifndef _RSAKP_H -#define _RSAKP_H - -#include "rsapk.h" - -/*!\brief RSA keypair. - * \ingroup IF_rsa_m - */ -#ifdef __cplusplus -struct BEECRYPTAPI rsakp -#else -struct _rsakp -#endif -{ - /*!\var n - * \brief The modulus. - * - * \f$n=pq\f$ - */ - mpbarrett n; - /*!\var e - * \brief The public exponent. - */ - mpnumber e; - /*!\var d - * \brief The private exponent. - */ - mpnumber d; - /*!\var p - * \brief The first prime factor of the modulus. - */ - mpbarrett p; - /*!\var q - * \brief The second prime factor of the modulus. - */ - mpbarrett q; - /*!\var dp - * \brief the first prime coefficient. - * \f$dp=d\ \textrm{mod}\ (p-1)\f$ - */ - mpnumber dp; - /*!\var dq - * \brief the second prime coefficient. - * \f$dq=d\ \textrm{mod}\ (q-1)\f$ - */ - mpnumber dq; - /*!\var qi - * \brief the crt coefficient. - * \f$qi=q^{-1}\ \textrm{mod}\ p\f$ - */ - mpnumber qi; - #ifdef __cplusplus - rsakp(); - rsakp(const rsakp&); - ~rsakp(); - #endif -}; - -#ifndef __cplusplus -typedef struct _rsakp rsakp; -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -BEECRYPTAPI -int rsakpMake(rsakp* kp, randomGeneratorContext* rgc, size_t bits) - /*@modifies kp @*/; -BEECRYPTAPI -int rsakpInit(rsakp* kp) - /*@modifies kp @*/; -BEECRYPTAPI -int rsakpFree(rsakp* kp) - /*@modifies kp @*/; -BEECRYPTAPI -int rsakpCopy(rsakp* dst, const rsakp* src) - /*@modifies dst @*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/rsapk.c b/beecrypt/rsapk.c deleted file mode 100644 index 922e06ed6..000000000 --- a/beecrypt/rsapk.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2000, 2001, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file rsapk.c - * \brief RSA public key. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup IF_m IF_rsa_m - */ - -#include "system.h" - -#include "rsapk.h" - -#include "debug.h" - -/*!\addtogroup IF_rsa_m - * \{ - */ - -int rsapkInit(rsapk* pk) -{ - memset(pk, 0, sizeof(rsapk)); - /* or - mpbzero(&pk->n); - mpnzero(&pk->e); - */ - - return 0; -} - -int rsapkFree(rsapk* pk) -{ - mpbfree(&pk->n); - mpnfree(&pk->e); - - return 0; -} - -int rsapkCopy(rsapk* dst, const rsapk* src) -{ - mpbcopy(&dst->n, &src->n); - mpncopy(&dst->e, &src->e); - - return 0; -} - -/*!\} - */ diff --git a/beecrypt/rsapk.h b/beecrypt/rsapk.h deleted file mode 100644 index a2bdcde51..000000000 --- a/beecrypt/rsapk.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2000, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file rsapk.h - * \brief RSA public key, headers. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup IF_m IF_rsa_m - */ - -#ifndef _RSAPK_H -#define _RSAPK_H - -#include "mpbarrett.h" - -#ifdef __cplusplus -struct BEECRYPTAPI rsapk -#else -struct _rsapk -#endif -{ - mpbarrett n; - mpnumber e; - #ifdef __cplusplus - rsapk(); - rsapk(const rsapk&); - ~rsapk(); - #endif -}; - -#ifndef __cplusplus -typedef struct _rsapk rsapk; -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -BEECRYPTAPI -int rsapkInit(rsapk* pk) - /*@modifies pk @*/; -BEECRYPTAPI -int rsapkFree(rsapk* pk) - /*@modifies pk @*/; -BEECRYPTAPI -int rsapkCopy(rsapk* dst, const rsapk* src) - /*@modifies dst @*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/sha1.c b/beecrypt/sha1.c deleted file mode 100644 index f682a69b2..000000000 --- a/beecrypt/sha1.c +++ /dev/null @@ -1,326 +0,0 @@ -/* - * Copyright (c) 1997, 1998, 1999, 2000, 2001 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file sha1.c - * \brief SHA-1 hash function, as specified by NIST FIPS 180-1. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup HASH_m HASH_sha1_m - */ - -#include "system.h" - -#include "beecrypt.h" -#include "sha1opt.h" -#include "sha1.h" -#include "mp.h" -#include "endianness.h" - -#include "debug.h" - -/*!\addtogroup HASH_sha1_m - * \{ - */ - -static const uint32_t k[4] = { 0x5a827999U, 0x6ed9eba1U, 0x8f1bbcdcU, 0xca62c1d6U }; - -static const uint32_t hinit[5] = { 0x67452301U, 0xefcdab89U, 0x98badcfeU, 0x10325476U, 0xc3d2e1f0U }; - -const hashFunction sha1 = { - "SHA-1", - sizeof(sha1Param), - 64, - 20, - (hashFunctionReset) sha1Reset, - (hashFunctionUpdate) sha1Update, - (hashFunctionDigest) sha1Digest -}; - -int sha1Reset(register sha1Param* p) -{ - memcpy(p->h, hinit, 5 * sizeof(uint32_t)); - memset(p->data, 0, 80 * sizeof(uint32_t)); - #if (MP_WBITS == 64) - mpzero(1, p->length); - #elif (MP_WBITS == 32) - mpzero(2, p->length); - #else - # error - #endif - p->offset = 0; - return 0; -} - -#define SUBROUND1(a, b, c, d, e, w, k) \ - e = ROTL32(a, 5) + ((b&(c^d))^d) + e + w + k; \ - b = ROTR32(b, 2) -#define SUBROUND2(a, b, c, d, e, w, k) \ - e = ROTL32(a, 5) + (b^c^d) + e + w + k; \ - b = ROTR32(b, 2) -#define SUBROUND3(a, b, c, d, e, w, k) \ - e = ROTL32(a, 5) + (((b|c)&d)|(b&c)) + e + w + k; \ - b = ROTR32(b, 2) -#define SUBROUND4(a, b, c, d, e, w, k) \ - e = ROTL32(a, 5) + (b^c^d) + e + w + k; \ - b = ROTR32(b, 2) - -#ifndef ASM_SHA1PROCESS -void sha1Process(sha1Param* sp) -{ - register uint32_t a, b, c, d, e; - register uint32_t *w; - register byte t; - - #if WORDS_BIGENDIAN - w = sp->data + 16; - #else - w = sp->data; - t = 16; - while (t--) - { - register uint32_t temp = swapu32(*w); - *(w++) = temp; - } - #endif - - t = 64; - while (t--) - { - register uint32_t temp = w[-3] ^ w[-8] ^ w[-14] ^ w[-16]; - *(w++) = ROTL32(temp, 1); - } - - w = sp->data; - - a = sp->h[0]; b = sp->h[1]; c = sp->h[2]; d = sp->h[3]; e = sp->h[4]; - - SUBROUND1(a,b,c,d,e,w[ 0],k[0]); - SUBROUND1(e,a,b,c,d,w[ 1],k[0]); - SUBROUND1(d,e,a,b,c,w[ 2],k[0]); - SUBROUND1(c,d,e,a,b,w[ 3],k[0]); - SUBROUND1(b,c,d,e,a,w[ 4],k[0]); - SUBROUND1(a,b,c,d,e,w[ 5],k[0]); - SUBROUND1(e,a,b,c,d,w[ 6],k[0]); - SUBROUND1(d,e,a,b,c,w[ 7],k[0]); - SUBROUND1(c,d,e,a,b,w[ 8],k[0]); - SUBROUND1(b,c,d,e,a,w[ 9],k[0]); - SUBROUND1(a,b,c,d,e,w[10],k[0]); - SUBROUND1(e,a,b,c,d,w[11],k[0]); - SUBROUND1(d,e,a,b,c,w[12],k[0]); - SUBROUND1(c,d,e,a,b,w[13],k[0]); - SUBROUND1(b,c,d,e,a,w[14],k[0]); - SUBROUND1(a,b,c,d,e,w[15],k[0]); - SUBROUND1(e,a,b,c,d,w[16],k[0]); - SUBROUND1(d,e,a,b,c,w[17],k[0]); - SUBROUND1(c,d,e,a,b,w[18],k[0]); - SUBROUND1(b,c,d,e,a,w[19],k[0]); - - SUBROUND2(a,b,c,d,e,w[20],k[1]); - SUBROUND2(e,a,b,c,d,w[21],k[1]); - SUBROUND2(d,e,a,b,c,w[22],k[1]); - SUBROUND2(c,d,e,a,b,w[23],k[1]); - SUBROUND2(b,c,d,e,a,w[24],k[1]); - SUBROUND2(a,b,c,d,e,w[25],k[1]); - SUBROUND2(e,a,b,c,d,w[26],k[1]); - SUBROUND2(d,e,a,b,c,w[27],k[1]); - SUBROUND2(c,d,e,a,b,w[28],k[1]); - SUBROUND2(b,c,d,e,a,w[29],k[1]); - SUBROUND2(a,b,c,d,e,w[30],k[1]); - SUBROUND2(e,a,b,c,d,w[31],k[1]); - SUBROUND2(d,e,a,b,c,w[32],k[1]); - SUBROUND2(c,d,e,a,b,w[33],k[1]); - SUBROUND2(b,c,d,e,a,w[34],k[1]); - SUBROUND2(a,b,c,d,e,w[35],k[1]); - SUBROUND2(e,a,b,c,d,w[36],k[1]); - SUBROUND2(d,e,a,b,c,w[37],k[1]); - SUBROUND2(c,d,e,a,b,w[38],k[1]); - SUBROUND2(b,c,d,e,a,w[39],k[1]); - - SUBROUND3(a,b,c,d,e,w[40],k[2]); - SUBROUND3(e,a,b,c,d,w[41],k[2]); - SUBROUND3(d,e,a,b,c,w[42],k[2]); - SUBROUND3(c,d,e,a,b,w[43],k[2]); - SUBROUND3(b,c,d,e,a,w[44],k[2]); - SUBROUND3(a,b,c,d,e,w[45],k[2]); - SUBROUND3(e,a,b,c,d,w[46],k[2]); - SUBROUND3(d,e,a,b,c,w[47],k[2]); - SUBROUND3(c,d,e,a,b,w[48],k[2]); - SUBROUND3(b,c,d,e,a,w[49],k[2]); - SUBROUND3(a,b,c,d,e,w[50],k[2]); - SUBROUND3(e,a,b,c,d,w[51],k[2]); - SUBROUND3(d,e,a,b,c,w[52],k[2]); - SUBROUND3(c,d,e,a,b,w[53],k[2]); - SUBROUND3(b,c,d,e,a,w[54],k[2]); - SUBROUND3(a,b,c,d,e,w[55],k[2]); - SUBROUND3(e,a,b,c,d,w[56],k[2]); - SUBROUND3(d,e,a,b,c,w[57],k[2]); - SUBROUND3(c,d,e,a,b,w[58],k[2]); - SUBROUND3(b,c,d,e,a,w[59],k[2]); - - SUBROUND4(a,b,c,d,e,w[60],k[3]); - SUBROUND4(e,a,b,c,d,w[61],k[3]); - SUBROUND4(d,e,a,b,c,w[62],k[3]); - SUBROUND4(c,d,e,a,b,w[63],k[3]); - SUBROUND4(b,c,d,e,a,w[64],k[3]); - SUBROUND4(a,b,c,d,e,w[65],k[3]); - SUBROUND4(e,a,b,c,d,w[66],k[3]); - SUBROUND4(d,e,a,b,c,w[67],k[3]); - SUBROUND4(c,d,e,a,b,w[68],k[3]); - SUBROUND4(b,c,d,e,a,w[69],k[3]); - SUBROUND4(a,b,c,d,e,w[70],k[3]); - SUBROUND4(e,a,b,c,d,w[71],k[3]); - SUBROUND4(d,e,a,b,c,w[72],k[3]); - SUBROUND4(c,d,e,a,b,w[73],k[3]); - SUBROUND4(b,c,d,e,a,w[74],k[3]); - SUBROUND4(a,b,c,d,e,w[75],k[3]); - SUBROUND4(e,a,b,c,d,w[76],k[3]); - SUBROUND4(d,e,a,b,c,w[77],k[3]); - SUBROUND4(c,d,e,a,b,w[78],k[3]); - SUBROUND4(b,c,d,e,a,w[79],k[3]); - - sp->h[0] += a; - sp->h[1] += b; - sp->h[2] += c; - sp->h[3] += d; - sp->h[4] += e; -} -#endif - -int sha1Update(sha1Param* sp, const byte* data, size_t size) -{ - register uint32_t proclength; - - #if (MP_WBITS == 64) - mpw add[1]; - mpsetw(1, add, size); - mplshift(1, add, 3); - mpadd(1, sp->length, add); - #elif (MP_WBITS == 32) - mpw add[2]; - mpsetw(2, add, size); - mplshift(2, add, 3); - mpadd(2, sp->length, add); - #else - # error - #endif - - while (size > 0) - { - proclength = ((sp->offset + size) > 64U) ? (64U - sp->offset) : size; - memcpy(((byte *) sp->data) + sp->offset, data, proclength); - size -= proclength; - data += proclength; - sp->offset += proclength; - - if (sp->offset == 64) - { - sha1Process(sp); - sp->offset = 0; - } - } - return 0; -} - -static void sha1Finish(sha1Param* sp) - /*@modifies sp @*/ -{ - register byte *ptr = ((byte *) sp->data) + sp->offset++; - - *(ptr++) = 0x80; - - if (sp->offset > 56) - { - while (sp->offset++ < 64) - *(ptr++) = 0; - - sha1Process(sp); - sp->offset = 0; - } - - ptr = ((byte*) sp->data) + sp->offset; - while (sp->offset++ < 56) - *(ptr++) = 0; - - #if WORDS_BIGENDIAN - memcpy(ptr, sp->length, 8); - #else - # if (MP_WBITS == 64) - ptr[0] = (byte)(sp->length[0] >> 56); - ptr[1] = (byte)(sp->length[0] >> 48); - ptr[2] = (byte)(sp->length[0] >> 40); - ptr[3] = (byte)(sp->length[0] >> 32); - ptr[4] = (byte)(sp->length[0] >> 24); - ptr[5] = (byte)(sp->length[0] >> 16); - ptr[6] = (byte)(sp->length[0] >> 8); - ptr[7] = (byte)(sp->length[0] ); - #elif (MP_WBITS == 32) - ptr[0] = (byte)(sp->length[0] >> 24); - ptr[1] = (byte)(sp->length[0] >> 16); - ptr[2] = (byte)(sp->length[0] >> 8); - ptr[3] = (byte)(sp->length[0] ); - ptr[4] = (byte)(sp->length[1] >> 24); - ptr[5] = (byte)(sp->length[1] >> 16); - ptr[6] = (byte)(sp->length[1] >> 8); - ptr[7] = (byte)(sp->length[1] ); - # else - # error - # endif - #endif - - sha1Process(sp); - - sp->offset = 0; -} - -int sha1Digest(sha1Param* sp, byte* data) -{ - sha1Finish(sp); - - #if WORDS_BIGENDIAN - memcpy(data, sp->h, 20); - #else - /* encode 5 integers big-endian style */ - data[ 0] = (byte)(sp->h[0] >> 24); - data[ 1] = (byte)(sp->h[0] >> 16); - data[ 2] = (byte)(sp->h[0] >> 8); - data[ 3] = (byte)(sp->h[0] >> 0); - data[ 4] = (byte)(sp->h[1] >> 24); - data[ 5] = (byte)(sp->h[1] >> 16); - data[ 6] = (byte)(sp->h[1] >> 8); - data[ 7] = (byte)(sp->h[1] >> 0); - data[ 8] = (byte)(sp->h[2] >> 24); - data[ 9] = (byte)(sp->h[2] >> 16); - data[10] = (byte)(sp->h[2] >> 8); - data[11] = (byte)(sp->h[2] >> 0); - data[12] = (byte)(sp->h[3] >> 24); - data[13] = (byte)(sp->h[3] >> 16); - data[14] = (byte)(sp->h[3] >> 8); - data[15] = (byte)(sp->h[3] >> 0); - data[16] = (byte)(sp->h[4] >> 24); - data[17] = (byte)(sp->h[4] >> 16); - data[18] = (byte)(sp->h[4] >> 8); - data[19] = (byte)(sp->h[4] >> 0); - #endif - - sha1Reset(sp); - - return 0; -} - -/*!\} - */ diff --git a/beecrypt/sha1.h b/beecrypt/sha1.h deleted file mode 100644 index a9b585ecb..000000000 --- a/beecrypt/sha1.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 1997, 1998, 1999, 2000, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file sha1.h - * \brief SHA-1 hash function, headers. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup HASH_m HASH_sha1_m - */ - -#ifndef _SHA1_H -#define _SHA1_H - -#include "beecrypt.h" -#include "sha1opt.h" - -/*!\brief Holds all the parameters necessary for the SHA-1 algorithm. - * \ingroup HASH_sha1_m - */ -typedef struct -{ - /*!\var h - */ - uint32_t h[5]; - /*!\var data - */ - uint32_t data[80]; - /*!\var length - * \brief Multi-precision integer counter for the bits that have been - * processed so far. - */ - #if (MP_WBITS == 64) - mpw length[1]; - #elif (MP_WBITS == 32) - mpw length[2]; - #else - # error - #endif - /*!\var offset - * \brief Offset into \a data; points to the place where new data will be - * copied before it is processed. - */ - uint32_t offset; -} sha1Param; - -#ifdef __cplusplus -extern "C" { -#endif - -/*!\var sha1 - * \brief Holds the full API description of the SHA-1 algorithm. - */ -extern BEECRYPTAPI const hashFunction sha1; - -/*!\fn void sha1Process(sha1Param* sp) - * \brief This function performs the core of the SHA-1 hash algorithm; it - * processes a block of 64 bytes. - * \param sp The hash function's parameter block. - */ -BEECRYPTAPI -void sha1Process(sha1Param* sp) - /*@modifies sp @*/; - -/*!\fn int sha1Reset(sha1Param* sp) - * \brief This function resets the parameter block so that it's ready for a - * new hash. - * \param sp The hash function's parameter block. - * \retval 0 on success. - */ -BEECRYPTAPI -int sha1Reset (sha1Param* sp) - /*@modifies sp @*/; - -/*!\fn int sha1Update(sha1Param* sp, const byte* data, size_t size) - * \brief This function should be used to pass successive blocks of data - * to be hashed. - * \param sp The hash function's parameter block. - * \param data - * \param size - * \retval 0 on success. - */ -BEECRYPTAPI -int sha1Update (sha1Param* sp, const byte* data, size_t size) - /*@modifies sp @*/; - -/*!\fn int sha1Digest(sha1Param* sp, byte* digest) - * \brief This function finishes the current hash computation and copies - * the digest value into \a digest. - * \param sp The hash function's parameter block. - * \param digest The place to store the 20-byte digest. - * \retval 0 on success. - */ -BEECRYPTAPI -int sha1Digest (sha1Param* sp, byte* digest) - /*@modifies sp, digest @*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/sha1hmac.c b/beecrypt/sha1hmac.c deleted file mode 100644 index bd0558c60..000000000 --- a/beecrypt/sha1hmac.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * sha1hmac.c - * - * SHA-1/HMAC message authentication code, code - * - * Copyright (c) 1999-2000 Virtual Unlimited B.V. - * - * Author: Bob Deblier <bob@virtualunlimited.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#define BEECRYPT_DLL_EXPORT - -#include "sha1hmac.h" - -const keyedHashFunction sha1hmac = { "SHA-1/HMAC", sizeof(sha1hmacParam), 5 * sizeof(uint32), 64, 512, 32, (const keyedHashFunctionSetup) sha1hmacSetup, (const keyedHashFunctionReset) sha1hmacReset, (const keyedHashFunctionUpdate) sha1hmacUpdate, (const keyedHashFunctionDigest) sha1hmacDigest }; - -int sha1hmacSetup (sha1hmacParam* sp, const uint32* key, int keybits) -{ - return hmacSetup((hmacParam*) sp, &sha1, &sp->param, key, keybits); -} - -int sha1hmacReset (sha1hmacParam* sp) -{ - return hmacReset((hmacParam*) sp, &sha1, &sp->param); -} - -int sha1hmacUpdate(sha1hmacParam* sp, const byte* data, int size) -{ - return hmacUpdate((hmacParam*) sp, &sha1, &sp->param, data, size); -} - -int sha1hmacDigest(sha1hmacParam* sp, uint32* data) -{ - return hmacDigest((hmacParam*) sp, &sha1, &sp->param, data); -} diff --git a/beecrypt/sha1hmac.h b/beecrypt/sha1hmac.h deleted file mode 100644 index f6876682d..000000000 --- a/beecrypt/sha1hmac.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * sha1hmac.h - * - * SHA-1/HMAC message authentication code, header - * - * Copyright (c) 1999-2000 Virtual Unlimited B.V. - * - * Author: Bob Deblier <bob@virtualunlimited.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef _SHA1HMAC_H -#define _SHA1HMAC_H - -#include "hmac.h" -#include "fips180.h" - -typedef struct -{ - byte kxi[64]; - byte kxo[64]; - sha1Param param; -} sha1hmacParam; - -#ifdef __cplusplus -extern "C" { -#endif - -extern BEEDLLAPI const keyedHashFunction sha1hmac; - -BEEDLLAPI -int sha1hmacSetup (sha1hmacParam*, const uint32*, int); -BEEDLLAPI -int sha1hmacReset (sha1hmacParam*); -BEEDLLAPI -int sha1hmacUpdate(sha1hmacParam*, const byte*, int); -BEEDLLAPI -int sha1hmacDigest(sha1hmacParam*, uint32*); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/sha1opt.h b/beecrypt/sha1opt.h deleted file mode 100644 index 0269cdf45..000000000 --- a/beecrypt/sha1opt.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * sha1opt.h - * - * SHA-1 assembler-optimized routines, header - * - * Copyright (c) 2000, 2003 Virtual Unlimited B.V. - * - * Author: Bob Deblier <bob.deblier@pandora.be> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef _SHA1OPT_H -#define _SHA1OPT_H - -#include "beecrypt.h" -#include "sha1.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if WIN32 -# if defined(_MSC_VER) && defined(_M_IX86) -# define ASM_SHA1PROCESS -# elif __INTEL__ && __MWERKS__ -# define ASM_SHA1PROCESS -# endif -#endif - -#if defined(__GNUC__) -# if defined(OPTIMIZE_I386) || defined(OPTIMIZE_I486) || defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686) -# define ASM_SHA1PROCESS -# endif -#endif - -#if defined(__INTEL_COMPILER) -# if defined(OPTIMIZE_I386) || defined(OPTIMIZE_I486) || defined(OPTIMIZE_I586) || defined(OPTIMIZE_I686) -# define ASM_SHA1PROCESS -# endif -#endif - -#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/sha256.c b/beecrypt/sha256.c deleted file mode 100644 index 10889e257..000000000 --- a/beecrypt/sha256.c +++ /dev/null @@ -1,316 +0,0 @@ -/* - * Copyright (c) 2000, 2001 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file sha256.c - * \brief SHA-256 hash function, as specified by NIST DFIPS 180-2. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup HASH_m HASH_sha256_m - */ - -#include "system.h" - -#include "sha256.h" -#include "mp.h" -#include "endianness.h" - -#include "debug.h" - -/*!\addtogroup HASH_sha256_m - * \{ - */ - -static const uint32_t k[64] = { - 0x428a2f98U, 0x71374491U, 0xb5c0fbcfU, 0xe9b5dba5U, 0x3956c25bU, 0x59f111f1U, 0x923f82a4U, 0xab1c5ed5U, - 0xd807aa98U, 0x12835b01U, 0x243185beU, 0x550c7dc3U, 0x72be5d74U, 0x80deb1feU, 0x9bdc06a7U, 0xc19bf174U, - 0xe49b69c1U, 0xefbe4786U, 0x0fc19dc6U, 0x240ca1ccU, 0x2de92c6fU, 0x4a7484aaU, 0x5cb0a9dcU, 0x76f988daU, - 0x983e5152U, 0xa831c66dU, 0xb00327c8U, 0xbf597fc7U, 0xc6e00bf3U, 0xd5a79147U, 0x06ca6351U, 0x14292967U, - 0x27b70a85U, 0x2e1b2138U, 0x4d2c6dfcU, 0x53380d13U, 0x650a7354U, 0x766a0abbU, 0x81c2c92eU, 0x92722c85U, - 0xa2bfe8a1U, 0xa81a664bU, 0xc24b8b70U, 0xc76c51a3U, 0xd192e819U, 0xd6990624U, 0xf40e3585U, 0x106aa070U, - 0x19a4c116U, 0x1e376c08U, 0x2748774cU, 0x34b0bcb5U, 0x391c0cb3U, 0x4ed8aa4aU, 0x5b9cca4fU, 0x682e6ff3U, - 0x748f82eeU, 0x78a5636fU, 0x84c87814U, 0x8cc70208U, 0x90befffaU, 0xa4506cebU, 0xbef9a3f7U, 0xc67178f2U -}; - -static const uint32_t hinit[8] = { - 0x6a09e667U, 0xbb67ae85U, 0x3c6ef372U, 0xa54ff53aU, 0x510e527fU, 0x9b05688cU, 0x1f83d9abU, 0x5be0cd19U -}; - -const hashFunction sha256 = { "SHA-256", sizeof(sha256Param), 64, 32, (hashFunctionReset) sha256Reset, (hashFunctionUpdate) sha256Update, (hashFunctionDigest) sha256Digest }; - -int sha256Reset(register sha256Param* sp) -{ - memcpy(sp->h, hinit, 8 * sizeof(uint32_t)); - memset(sp->data, 0, 64 * sizeof(uint32_t)); - #if (MP_WBITS == 64) - mpzero(1, sp->length); - #elif (MP_WBITS == 32) - mpzero(2, sp->length); - #else - # error - #endif - sp->offset = 0; - return 0; -} - -#define R(x,s) ((x) >> (s)) -#define S(x,s) ROTR32(x, s) - -#define CH(x,y,z) ((x&(y^z))^z) -#define MAJ(x,y,z) (((x|y)&z)|(x&y)) -#define SIG0(x) (S(x,2) ^ S(x,13) ^ S(x,22)) -#define SIG1(x) (S(x,6) ^ S(x,11) ^ S(x,25)) -#define sig0(x) (S(x,7) ^ S(x,18) ^ R(x,3)) -#define sig1(x) (S(x,17) ^ S(x,19) ^ R(x,10)) - -#define ROUND(a,b,c,d,e,f,g,h,w,k) \ - temp = h + SIG1(e) + CH(e,f,g) + k + w; \ - h = temp + SIG0(a) + MAJ(a,b,c); \ - d += temp - -#ifndef ASM_SHA256PROCESS -void sha256Process(register sha256Param* sp) -{ - register uint32_t a, b, c, d, e, f, g, h, temp; - register uint32_t *w; - register byte t; - - #if WORDS_BIGENDIAN - w = sp->data + 16; - #else - w = sp->data; - t = 16; - while (t--) - { - register uint32_t temp = swapu32(*w); - *(w++) = temp; - } - #endif - - t = 48; - while (t--) - { - register uint32_t temp = sig1(w[-2]) + w[-7] + sig0(w[-15]) + w[-16]; - *(w++) = temp; - } - - w = sp->data; - - a = sp->h[0]; b = sp->h[1]; c = sp->h[2]; d = sp->h[3]; - e = sp->h[4]; f = sp->h[5]; g = sp->h[6]; h = sp->h[7]; - - ROUND(a,b,c,d,e,f,g,h,w[ 0],k[ 0]); - ROUND(h,a,b,c,d,e,f,g,w[ 1],k[ 1]); - ROUND(g,h,a,b,c,d,e,f,w[ 2],k[ 2]); - ROUND(f,g,h,a,b,c,d,e,w[ 3],k[ 3]); - ROUND(e,f,g,h,a,b,c,d,w[ 4],k[ 4]); - ROUND(d,e,f,g,h,a,b,c,w[ 5],k[ 5]); - ROUND(c,d,e,f,g,h,a,b,w[ 6],k[ 6]); - ROUND(b,c,d,e,f,g,h,a,w[ 7],k[ 7]); - ROUND(a,b,c,d,e,f,g,h,w[ 8],k[ 8]); - ROUND(h,a,b,c,d,e,f,g,w[ 9],k[ 9]); - ROUND(g,h,a,b,c,d,e,f,w[10],k[10]); - ROUND(f,g,h,a,b,c,d,e,w[11],k[11]); - ROUND(e,f,g,h,a,b,c,d,w[12],k[12]); - ROUND(d,e,f,g,h,a,b,c,w[13],k[13]); - ROUND(c,d,e,f,g,h,a,b,w[14],k[14]); - ROUND(b,c,d,e,f,g,h,a,w[15],k[15]); - ROUND(a,b,c,d,e,f,g,h,w[16],k[16]); - ROUND(h,a,b,c,d,e,f,g,w[17],k[17]); - ROUND(g,h,a,b,c,d,e,f,w[18],k[18]); - ROUND(f,g,h,a,b,c,d,e,w[19],k[19]); - ROUND(e,f,g,h,a,b,c,d,w[20],k[20]); - ROUND(d,e,f,g,h,a,b,c,w[21],k[21]); - ROUND(c,d,e,f,g,h,a,b,w[22],k[22]); - ROUND(b,c,d,e,f,g,h,a,w[23],k[23]); - ROUND(a,b,c,d,e,f,g,h,w[24],k[24]); - ROUND(h,a,b,c,d,e,f,g,w[25],k[25]); - ROUND(g,h,a,b,c,d,e,f,w[26],k[26]); - ROUND(f,g,h,a,b,c,d,e,w[27],k[27]); - ROUND(e,f,g,h,a,b,c,d,w[28],k[28]); - ROUND(d,e,f,g,h,a,b,c,w[29],k[29]); - ROUND(c,d,e,f,g,h,a,b,w[30],k[30]); - ROUND(b,c,d,e,f,g,h,a,w[31],k[31]); - ROUND(a,b,c,d,e,f,g,h,w[32],k[32]); - ROUND(h,a,b,c,d,e,f,g,w[33],k[33]); - ROUND(g,h,a,b,c,d,e,f,w[34],k[34]); - ROUND(f,g,h,a,b,c,d,e,w[35],k[35]); - ROUND(e,f,g,h,a,b,c,d,w[36],k[36]); - ROUND(d,e,f,g,h,a,b,c,w[37],k[37]); - ROUND(c,d,e,f,g,h,a,b,w[38],k[38]); - ROUND(b,c,d,e,f,g,h,a,w[39],k[39]); - ROUND(a,b,c,d,e,f,g,h,w[40],k[40]); - ROUND(h,a,b,c,d,e,f,g,w[41],k[41]); - ROUND(g,h,a,b,c,d,e,f,w[42],k[42]); - ROUND(f,g,h,a,b,c,d,e,w[43],k[43]); - ROUND(e,f,g,h,a,b,c,d,w[44],k[44]); - ROUND(d,e,f,g,h,a,b,c,w[45],k[45]); - ROUND(c,d,e,f,g,h,a,b,w[46],k[46]); - ROUND(b,c,d,e,f,g,h,a,w[47],k[47]); - ROUND(a,b,c,d,e,f,g,h,w[48],k[48]); - ROUND(h,a,b,c,d,e,f,g,w[49],k[49]); - ROUND(g,h,a,b,c,d,e,f,w[50],k[50]); - ROUND(f,g,h,a,b,c,d,e,w[51],k[51]); - ROUND(e,f,g,h,a,b,c,d,w[52],k[52]); - ROUND(d,e,f,g,h,a,b,c,w[53],k[53]); - ROUND(c,d,e,f,g,h,a,b,w[54],k[54]); - ROUND(b,c,d,e,f,g,h,a,w[55],k[55]); - ROUND(a,b,c,d,e,f,g,h,w[56],k[56]); - ROUND(h,a,b,c,d,e,f,g,w[57],k[57]); - ROUND(g,h,a,b,c,d,e,f,w[58],k[58]); - ROUND(f,g,h,a,b,c,d,e,w[59],k[59]); - ROUND(e,f,g,h,a,b,c,d,w[60],k[60]); - ROUND(d,e,f,g,h,a,b,c,w[61],k[61]); - ROUND(c,d,e,f,g,h,a,b,w[62],k[62]); - ROUND(b,c,d,e,f,g,h,a,w[63],k[63]); - - sp->h[0] += a; - sp->h[1] += b; - sp->h[2] += c; - sp->h[3] += d; - sp->h[4] += e; - sp->h[5] += f; - sp->h[6] += g; - sp->h[7] += h; -} -#endif - -int sha256Update(register sha256Param* sp, const byte* data, size_t size) -{ - register uint32_t proclength; - - #if (MP_WBITS == 64) - mpw add[1]; - mpsetw(1, add, size); - mplshift(1, add, 3); - mpadd(1, sp->length, add); - #elif (MP_WBITS == 32) - mpw add[2]; - mpsetw(2, add, size); - mplshift(2, add, 3); - mpadd(2, sp->length, add); - #else - # error - #endif - - while (size > 0) - { - proclength = ((sp->offset + size) > 64U) ? (64U - sp->offset) : size; - memcpy(((byte *) sp->data) + sp->offset, data, proclength); - size -= proclength; - data += proclength; - sp->offset += proclength; - - if (sp->offset == 64U) - { - sha256Process(sp); - sp->offset = 0; - } - } - return 0; -} - -static void sha256Finish(register sha256Param* sp) - /*@modifies sp @*/ -{ - register byte *ptr = ((byte *) sp->data) + sp->offset++; - - *(ptr++) = 0x80; - - if (sp->offset > 56) - { - while (sp->offset++ < 64) - *(ptr++) = 0; - - sha256Process(sp); - sp->offset = 0; - } - - ptr = ((byte *) sp->data) + sp->offset; - while (sp->offset++ < 56) - *(ptr++) = 0; - - #if (MP_WBITS == 64) - ptr[0] = (byte)(sp->length[0] >> 56); - ptr[1] = (byte)(sp->length[0] >> 48); - ptr[2] = (byte)(sp->length[0] >> 40); - ptr[3] = (byte)(sp->length[0] >> 32); - ptr[4] = (byte)(sp->length[0] >> 24); - ptr[5] = (byte)(sp->length[0] >> 16); - ptr[6] = (byte)(sp->length[0] >> 8); - ptr[7] = (byte)(sp->length[0] ); - #elif (MP_WBITS == 32) - ptr[0] = (byte)(sp->length[0] >> 24); - ptr[1] = (byte)(sp->length[0] >> 16); - ptr[2] = (byte)(sp->length[0] >> 8); - ptr[3] = (byte)(sp->length[0] ); - ptr[4] = (byte)(sp->length[1] >> 24); - ptr[5] = (byte)(sp->length[1] >> 16); - ptr[6] = (byte)(sp->length[1] >> 8); - ptr[7] = (byte)(sp->length[1] ); - #else - # error - #endif - - sha256Process(sp); - sp->offset = 0; -} - -int sha256Digest(register sha256Param* sp, byte* data) -{ - sha256Finish(sp); - - /* encode 8 integers big-endian style */ - data[ 0] = (byte)(sp->h[0] >> 24); - data[ 1] = (byte)(sp->h[0] >> 16); - data[ 2] = (byte)(sp->h[0] >> 8); - data[ 3] = (byte)(sp->h[0] >> 0); - data[ 4] = (byte)(sp->h[1] >> 24); - data[ 5] = (byte)(sp->h[1] >> 16); - data[ 6] = (byte)(sp->h[1] >> 8); - data[ 7] = (byte)(sp->h[1] >> 0); - data[ 8] = (byte)(sp->h[2] >> 24); - data[ 9] = (byte)(sp->h[2] >> 16); - data[10] = (byte)(sp->h[2] >> 8); - data[11] = (byte)(sp->h[2] >> 0); - data[12] = (byte)(sp->h[3] >> 24); - data[13] = (byte)(sp->h[3] >> 16); - data[14] = (byte)(sp->h[3] >> 8); - data[15] = (byte)(sp->h[3] >> 0); - data[16] = (byte)(sp->h[4] >> 24); - data[17] = (byte)(sp->h[4] >> 16); - data[18] = (byte)(sp->h[4] >> 8); - data[19] = (byte)(sp->h[4] >> 0); - data[20] = (byte)(sp->h[5] >> 24); - data[21] = (byte)(sp->h[5] >> 16); - data[22] = (byte)(sp->h[5] >> 8); - data[23] = (byte)(sp->h[5] >> 0); - data[24] = (byte)(sp->h[6] >> 24); - data[25] = (byte)(sp->h[6] >> 16); - data[26] = (byte)(sp->h[6] >> 8); - data[27] = (byte)(sp->h[6] >> 0); - data[28] = (byte)(sp->h[7] >> 24); - data[29] = (byte)(sp->h[7] >> 16); - data[30] = (byte)(sp->h[7] >> 8); - data[31] = (byte)(sp->h[7] >> 0); - - sha256Reset(sp); - return 0; -} - -/*!\} - */ diff --git a/beecrypt/sha256.h b/beecrypt/sha256.h deleted file mode 100644 index 57462c01f..000000000 --- a/beecrypt/sha256.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2000, 2001, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file sha256.h - * \brief SHA-256 hash function, headers. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup HASH_m HASH_sha256_m - */ - -#ifndef _SHA256_H -#define _SHA256_H - -#include "beecrypt.h" - -/*!\brief Holds all the parameters necessary for the SHA-256 algorithm. - * \ingroup HASH_sha256_m - */ -typedef struct -{ - /*!\var h - */ - uint32_t h[8]; - /*!\var data - */ - uint32_t data[64]; - /*!\var length - * \brief Multi-precision integer counter for the bits that have been - * processed so far. - */ - #if (MP_WBITS == 64) - mpw length[1]; - #elif (MP_WBITS == 32) - mpw length[2]; - #else - # error - #endif - /*!\var offset - * \brief Offset into \a data; points to the place where new data will be - * copied before it is processed. - */ - uint32_t offset; -} sha256Param; - -#ifdef __cplusplus -extern "C" { -#endif - -/*!\var sha256 - * \brief Holds the full API description of the SHA-256 algorithm. - */ -extern BEECRYPTAPI const hashFunction sha256; - -/*!\fn void sha256Process(sha256Param* sp) - * \brief This function performs the core of the SHA-256 hash algorithm; it - * processes a block of 64 bytes. - * \param sp The hash function's parameter block. - */ -BEECRYPTAPI -void sha256Process(sha256Param* sp) - /*@modifies sp @*/; - -/*!\fn int sha256Reset(sha256Param* sp) - * \brief This function resets the parameter block so that it's ready for a - * new hash. - * \param sp The hash function's parameter block. - * \retval 0 on success. - */ -BEECRYPTAPI -int sha256Reset (sha256Param* sp) - /*@modifies sp @*/; - -/*!\fn int sha256Update(sha256Param* sp, const byte* data, size_t size) - * \brief This function should be used to pass successive blocks of data - * to be hashed. - * \param sp The hash function's parameter block. - * \param data - * \param size - * \retval 0 on success. - */ -BEECRYPTAPI -int sha256Update (sha256Param* sp, const byte* data, size_t size) - /*@modifies sp @*/; - -/*!\fn int sha256Digest(sha256Param* sp, byte* digest) - * \brief This function finishes the current hash computation and copies - * the digest value into \a digest. - * \param sp The hash function's parameter block. - * \param digest The place to store the 32-byte digest. - * \retval 0 on success. - */ -BEECRYPTAPI -int sha256Digest (sha256Param* sp, byte* digest) - /*@modifies sp, digest @*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/system.h b/beecrypt/system.h deleted file mode 100644 index 625579684..000000000 --- a/beecrypt/system.h +++ /dev/null @@ -1,89 +0,0 @@ -/** - * \file beecrypt/system.h - */ - -#ifndef H_SYSTEM -#define H_SYSTEM - -#define BEECRYPT_DLL_EXPORT - -#if defined(_WIN32) && !defined(WIN32) -# define WIN32 1 -#endif - -#if WIN32 && !__CYGWIN32__ -# include "win.h" -#else -# ifdef HAVE_CONFIG_H -# include "config.h" -# endif -#endif - -#if defined(__LCLINT__) -/* XXX from /usr/include/bits/sigset.h in glibc-2.2.4 */ -/*@-sizeoftype@*/ -# define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int))) -/*@-redef@*/ -typedef struct - { - unsigned long int __val[_SIGSET_NWORDS]; - } __sigset_t; -/*@=redef@*/ -/*@=sizeoftype@*/ -#endif - -#include "gnu.h" - -#if HAVE_SYS_STAT_H -# include <sys/types.h> -# include <sys/stat.h> -#endif - -#include <stdio.h> - -#ifdef HAVE_UNISTD_H -# include <unistd.h> -#endif - -#if TIME_WITH_SYS_TIME -# include <sys/time.h> -# include <time.h> -#else -# if HAVE_SYS_TIME_H -# include <sys/time.h> -# else -# include <time.h> -# endif -#endif - -#if HAVE_TIME_H -# include <time.h> -#endif - -#ifdef HAVE_STRING_H -# include <string.h> -#endif - -#if HAVE_ERRNO_H -# include <errno.h> -#endif - -#if HAVE_STDLIB_H -# include <stdlib.h> -#endif - -#ifdef HAVE_FCNTL_H -# include <fcntl.h> -#else -# include <sys/file.h> -#endif - -#if HAVE_CTYPE_H -# include <ctype.h> -#endif - -#if HAVE_MALLOC_H && !defined(__LCLINT__) -# include <malloc.h> -#endif - -#endif /* H_SYSTEM */ diff --git a/beecrypt/tests/.cvsignore b/beecrypt/tests/.cvsignore deleted file mode 100644 index 5e7d0563f..000000000 --- a/beecrypt/tests/.cvsignore +++ /dev/null @@ -1,37 +0,0 @@ -.deps -.depend -.depend-done -.libs -Makefile -Makefile.in -config.cache -config.guess -config.log -config.status -config.sub -configure -libtool -ltconfig -ltmain.sh -*.o -*.lo -stamp-h -stamp-h.in -base64bug -beetest -benchbc -benchhf -benchme -openpgp -testaes -testblowfish -testdldp -testdsa -testhmacmd5 -testhmacsha1 -testmd5 -testmp -testmpinv -testrsa -testsha1 -testsha256 diff --git a/beecrypt/tests/Makefile.am b/beecrypt/tests/Makefile.am deleted file mode 100644 index beefd2875..000000000 --- a/beecrypt/tests/Makefile.am +++ /dev/null @@ -1,80 +0,0 @@ -# -# Makefile.am's purpose is to build the beetest_ test_ program. -# -# Copyright (c) 2001, 2002, 2003 Virtual Unlimited B.V. -# -# Author: Bob Deblier <bob.deblier@pandora.be> -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# - -AUTOMAKE_OPTIONS = gnu no-dependencies - -INCLUDES = -I$(top_srcdir) -LDADD = $(top_builddir)/libbeecrypt.la - -TESTS = testmd5 testsha1 testsha256 testhmacmd5 testhmacsha1 testaes testblowfish testmp testmpinv testdsa testrsa testdldp - -check_PROGRAMS = testmd5 testsha1 testsha256 testhmacmd5 testhmacsha1 testaes testblowfish testmp testmpinv testdsa testrsa testdldp - -testmd5_SOURCES = testmd5.c - -testsha1_SOURCES = testsha1.c - -testsha256_SOURCES = testsha256.c - -testhmacmd5_SOURCES = testhmacmd5.c - -testhmacsha1_SOURCES = testhmacsha1.c - -testaes_SOURCES = testaes.c testutil.c - -testblowfish_SOURCES = testblowfish.c testutil.c - -testmp_SOURCES = testmp.c - -testmpinv_SOURCES = testmpinv.c - -testdsa_SOURCES = testdsa.c - -testrsa_SOURCES = testrsa.c - -testdldp_SOURCES = testdldp.c - -EXTRA_PROGRAMS = benchme benchhf benchbc testconv - -benchme_SOURCES = benchme.c - -benchhf_SOURCES = benchhf.c - -benchbc_SOURCES = benchbc.c - -testconv_SOURCES = testconv.c - -# Run every benchmark test twice -bench: benchme benchhf benchbc - ./benchme - ./benchme - ./benchhf MD5 - ./benchhf MD5 - ./benchhf SHA-1 - ./benchhf SHA-1 - ./benchhf SHA-256 - ./benchhf SHA-256 - ./benchbc AES 128 - ./benchbc AES 128 - ./benchbc Blowfish 128 - ./benchbc Blowfish 128 - diff --git a/beecrypt/tests/benchbc.c b/beecrypt/tests/benchbc.c deleted file mode 100644 index 955483158..000000000 --- a/beecrypt/tests/benchbc.c +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright (c) 2003 Bob Deblier - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file benchbc.c - * \brief Benchmark program for Block Ciphers. - * \author Bob Deblier <bob.deblier@pandora.be> - */ - -#include "system.h" - -#include "beecrypt.h" -#include "timestamp.h" - -#include "debug.h" - -#define SECONDS 10 - -void validnames() -{ - int i; - - for (i = 0; i < blockCipherCount(); i++) - { - const blockCipher* tmp = blockCipherGet(i); - - if (tmp) - fprintf(stderr, " %s", tmp->name); - } - fprintf(stderr, "\n"); -} - -void usage() -{ - fprintf(stderr, "Usage: benchbf <blockcipher> <keybits> [<size>]\n"); - fprintf(stderr, " <blockcipher> can be any of:"); - validnames(); - exit(1); -} - -byte key[1024]; - -int benchmark(const blockCipher* bc, int keybits, int size) -{ - blockCipherContext bcc; - - void* cleartext = (void*) malloc(size << 10); - void* ciphertext = (void*) malloc(size << 10); - - if (blockCipherContextInit(&bcc, bc)) - { - fprintf(stderr, "blockCipherContextInit failed\n"); - return -1; - } - - if (cleartext && ciphertext) - { - double exact, speed; - javalong start, now; - int iterations, nblocks; - - /* calculcate how many block we need to process */ - nblocks = (size << 10) / bc->blocksize; - - /* set up for encryption */ - if (blockCipherContextSetup(&bcc, key, keybits, ENCRYPT)) - { - fprintf(stderr, "blockCipherContextSetup failed\n"); - return -1; - } - - /* ECB encrypt */ - iterations = 0; - start = timestamp(); - do - { - if (blockCipherContextECB(&bcc, ciphertext, cleartext, nblocks)) - { - fprintf(stderr, "blockCipherContextECB failed\n"); - return -1; - } - - now = timestamp(); - iterations++; - } while (now < (start + (SECONDS * ONE_SECOND))); - - exact = (now - start); - exact /= ONE_SECOND; - - speed = (iterations * size) / exact; - - printf("ECB encrypted %d KB in %.2f seconds = %.2f KB/s\n", iterations * size, exact, speed); - - /* CBC encrypt */ - iterations = 0; - start = timestamp(); - do - { - if (blockCipherContextCBC(&bcc, ciphertext, cleartext, nblocks)) - { - fprintf(stderr, "blockCipherContextCBC failed\n"); - return -1; - } - - now = timestamp(); - iterations++; - } while (now < (start + (SECONDS * ONE_SECOND))); - - exact = (now - start); - exact /= ONE_SECOND; - - speed = (iterations * size) / exact; - - printf("CBC encrypted %d KB in %.2f seconds = %.2f KB/s\n", iterations * size, exact, speed); - - /* set up for decryption */ - if (blockCipherContextSetup(&bcc, key, keybits, DECRYPT)) - { - fprintf(stderr, "blockCipherContextSetup failed\n"); - return -1; - } - - /* ECB decrypt */ - iterations = 0; - start = timestamp(); - do - { - if (blockCipherContextECB(&bcc, cleartext, ciphertext, nblocks)) - { - fprintf(stderr, "blockCipherContextECB failed\n"); - return -1; - } - - now = timestamp(); - iterations++; - } while (now < (start + (SECONDS * ONE_SECOND))); - - exact = (now - start); - exact /= ONE_SECOND; - - speed = (iterations * size) / exact; - - printf("ECB decrypted %d KB in %.2f seconds = %.2f KB/s\n", iterations * size, exact, speed); - - /* CBC decrypt */ - iterations = 0; - start = timestamp(); - do - { - if (blockCipherContextCBC(&bcc, cleartext, ciphertext, nblocks)) - { - fprintf(stderr, "blockCipherContextCBC failed\n"); - return -1; - } - - now = timestamp(); - iterations++; - } while (now < (start + (SECONDS * ONE_SECOND))); - - exact = (now - start); - exact /= ONE_SECOND; - - speed = (iterations * size) / exact; - - printf("CBC decrypted %d KB in %.2f seconds = %.2f KB/s\n", iterations * size, exact, speed); - - free(ciphertext); - free(cleartext); - } - - if (blockCipherContextFree(&bcc)) - { - fprintf(stderr, "blockCipherContextFree failed\n"); - return -1; - } - - return 0; -} - -int main(int argc, char* argv[]) -{ - const blockCipher* bc; - int keybits; - int size = 1024; - - if (argc < 3 || argc > 5) - usage(); - - bc = blockCipherFind(argv[1]); - - keybits = atoi(argv[2]); - - if (!bc) - { - fprintf(stderr, "Illegal blockcipher name\n"); - usage(); - } - - if (argc == 4) - { - size = atoi(argv[2]); - if (size <= 0) - usage(); - } - - return benchmark(bc, keybits, size); -} diff --git a/beecrypt/tests/benchhf.c b/beecrypt/tests/benchhf.c deleted file mode 100644 index 29adcc2ae..000000000 --- a/beecrypt/tests/benchhf.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2003 Bob Deblier - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file benchhf.c - * \brief Benchmark program for Hash Functions. - * \author Bob Deblier <bob.deblier@pandora.be> - */ - -#include "system.h" - -#include "beecrypt.h" -#include "timestamp.h" - -#include "debug.h" - -#define SECONDS 10 - -void validnames() -{ - int i; - - for (i = 0; i < hashFunctionCount(); i++) - { - const hashFunction* tmp = hashFunctionGet(i); - - if (tmp) - fprintf(stderr, " %s", tmp->name); - } - fprintf(stderr, "\n"); -} - -void usage() -{ - fprintf(stderr, "Usage: benchbf <hashfunction> [<size>]\n"); - fprintf(stderr, " <hashfunction> can be any of:"); - validnames(); - exit(1); -} - -int benchmark(const hashFunction* hf, int size) -{ - hashFunctionContext hfc; - - void* data = (void*) malloc(size << 10); - - if (hashFunctionContextInit(&hfc, hf)) - return -1; - - if (data) - { - double exact, speed; - javalong start, now; - int iterations = 0; - - /* get starting time */ - start = timestamp(); - do - { - if (hashFunctionContextUpdate(&hfc, data, size << 10)) - return -1; - - now = timestamp(); - iterations++; - } while (now < (start + (SECONDS * ONE_SECOND))); - - exact = (now - start); - exact /= ONE_SECOND; - - speed = (iterations * size) / exact; - - printf("hashed %d KB in %.2f seconds = %.2f KB/s\n", iterations * size, exact, speed); - - free(data); - } - - if (hashFunctionContextFree(&hfc)) - return -1; - - return 0; -} - -int main(int argc, char* argv[]) -{ - const hashFunction* hf; - int size = 1024; - - if (argc < 2 || argc > 4) - usage(); - - hf = hashFunctionFind(argv[1]); - - if (!hf) - { - fprintf(stderr, "Illegal hash function name\n"); - usage(); - } - - if (argc == 3) - { - size = atoi(argv[2]); - if (size <= 0) - usage(); - } - - return benchmark(hf, size); -} diff --git a/beecrypt/tests/benchme.c b/beecrypt/tests/benchme.c deleted file mode 100644 index 4439c490c..000000000 --- a/beecrypt/tests/benchme.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2003 Bob Deblier - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file benchme.c - * \brief Benchmark program for Modular Exponentiation. - * \author Bob Deblier <bob.deblier@pandora.be> - */ - -#include "system.h" - -#include "beecrypt.h" -#include "dldp.h" -#include "timestamp.h" - -#include "debug.h" - -#define SECONDS 10 - -static const char* hp = "d860d6c36ce3bd73c493e15113abd7ba6cc311d1365ddce4c194b65a96ac47ceab6a9ca7af9bfc871d341bf129e674b903533c7db1f8fad957d679ee14a3cbc5a73bf7f8173f33fb7b6a8a11c24652c2573276b214db3898f51cec3a6ff4263d0c5616502e91055bff6b9717d801c41f4b69eaed911fced89b601edfe73b1103"; -static const char* hq = "ea6f6724b9b9152766d01adfee421f48012e4a35"; -static const char* hg = "9b01e78dcaca5ae69656bb01c9a1f3b159f7cf8f77781146f916836dbca3a2ebc31cd73fbf7ea864ae5e8d0f24ead4332ce0f039ff5648a5f3514d84dd9632598def5b2da266f15391c031758855329ab15f87d3e612bee4f15ab3fd938a1da37992ea64ea90ceeeae654d9f3844e245951fd56a3c7919b3768c5719b43f3d3f"; - -int main() -{ - dldp_p params; - mpnumber gq; - javalong start, now; - int iterations = 0; - - dldp_pInit(¶ms); - - mpbsethex(¶ms.p, hp); - mpbsethex(¶ms.q, hq); - mpnsethex(¶ms.g, hg); - mpnzero(&gq); - - /* get starting time */ - start = timestamp(); - do - { - mpbnpowmod(¶ms.p, ¶ms.g, (mpnumber*) ¶ms.q, &gq); - now = timestamp(); - iterations++; - } while (now < (start + (SECONDS * ONE_SECOND))); - - mpnfree(&gq); - - printf("(%d bits ^ %d bits) mod (%d bits): %d times in %d seconds\n", - (int) mpbits(params.g.size, params.g.data), - (int) mpbits(params.q.size, params.q.modl), - (int) mpbits(params.p.size, params.p.modl), - iterations, - SECONDS); - - dldp_pFree(¶ms); - - return 0; -} diff --git a/beecrypt/tests/testaes.c b/beecrypt/tests/testaes.c deleted file mode 100644 index 303095a5e..000000000 --- a/beecrypt/tests/testaes.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2003 Bob Deblier - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file testaes.c - * \brief Unit test program for the Blowfish cipher. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup UNIT_m - */ - -#include "system.h" - -#include "aes.h" - -#include "debug.h" - -extern int fromhex(byte*, const char*); - -struct vector -{ - char* key; - char* input; - char* expect; - cipherOperation op; -}; - -#define NVECTORS 6 - -struct vector table[NVECTORS] = { - { "000102030405060708090a0b0c0d0e0f", - "00112233445566778899aabbccddeeff", - "69c4e0d86a7b0430d8cdb78070b4c55a", - ENCRYPT }, - { "000102030405060708090a0b0c0d0e0f", - "69c4e0d86a7b0430d8cdb78070b4c55a", - "00112233445566778899aabbccddeeff", - DECRYPT }, - { "000102030405060708090a0b0c0d0e0f1011121314151617", - "00112233445566778899aabbccddeeff", - "dda97ca4864cdfe06eaf70a0ec0d7191", - ENCRYPT }, - { "000102030405060708090a0b0c0d0e0f1011121314151617", - "dda97ca4864cdfe06eaf70a0ec0d7191", - "00112233445566778899aabbccddeeff", - DECRYPT }, - { "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", - "00112233445566778899aabbccddeeff", - "8ea2b7ca516745bfeafc49904b496089", - ENCRYPT }, - { "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", - "8ea2b7ca516745bfeafc49904b496089", - "00112233445566778899aabbccddeeff", - DECRYPT } -}; - -int main() -{ - int i, failures = 0; - aesParam param; - byte key[32]; - byte src[16]; - byte dst[16]; - byte chk[16]; - size_t keybits; - - for (i = 0; i < NVECTORS; i++) - { - keybits = fromhex(key, table[i].key) << 3; - - if (aesSetup(¶m, key, keybits, table[i].op)) - return -1; - - fromhex(src, table[i].input); - fromhex(chk, table[i].expect); - - switch (table[i].op) - { - case ENCRYPT: - if (aesEncrypt(¶m, (uint32_t*) dst, (const uint32_t*) src)) - return -1; - break; - case DECRYPT: - if (aesDecrypt(¶m, (uint32_t*) dst, (const uint32_t*) src)) - return -1; - break; - } - - if (memcmp(dst, chk, 16)) - { - printf("failed vector %d\n", i+1); - failures++; - } - - } - - return failures; -} diff --git a/beecrypt/tests/testblowfish.c b/beecrypt/tests/testblowfish.c deleted file mode 100644 index bd2fa4121..000000000 --- a/beecrypt/tests/testblowfish.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2003 Bob Deblier - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file testblowfish.c - * \brief Unit test program for the Blowfish cipher. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup UNIT_m - */ - -#include "system.h" - -#include "blowfish.h" - -#include "debug.h" - -extern int fromhex(byte*, const char*); - -struct vector -{ - char* key; - char* input; - char* expect; - cipherOperation op; -}; - -#define NVECTORS 4 - -struct vector table[NVECTORS] = { - { "0000000000000000", - "0000000000000000", - "4ef997456198dd78", - ENCRYPT }, - { "ffffffffffffffff", - "ffffffffffffffff", - "51866fd5B85ecb8a", - ENCRYPT }, - { "3000000000000000", - "1000000000000001", - "7d856f9a613063f2", - ENCRYPT }, - { "1111111111111111", - "1111111111111111", - "2466dd878b963c9d", - ENCRYPT } -}; - -int main() -{ - int i, failures = 0; - blowfishParam param; - byte key[56]; - byte src[8]; - byte dst[8]; - byte chk[8]; - size_t keybits; - - for (i = 0; i < NVECTORS; i++) - { - keybits = fromhex(key, table[i].key) << 3; - - if (blowfishSetup(¶m, key, keybits, table[i].op)) - return -1; - - fromhex(src, table[i].input); - fromhex(chk, table[i].expect); - - switch (table[i].op) - { - case ENCRYPT: - if (blowfishEncrypt(¶m, (uint32_t*) dst, (const uint32_t*) src)) - return -1; - break; - case DECRYPT: - if (blowfishDecrypt(¶m, (uint32_t*) dst, (const uint32_t*) src)) - return -1; - break; - } - - if (memcmp(dst, chk, 8)) - { - printf("failed vector %d\n", i+1); - failures++; - } - - } - - return failures; -} diff --git a/beecrypt/tests/testconv.c b/beecrypt/tests/testconv.c deleted file mode 100644 index 9f806ef05..000000000 --- a/beecrypt/tests/testconv.c +++ /dev/null @@ -1,39 +0,0 @@ -#include "system.h" - -#include "mp.h" - -#include "debug.h" - -void hexdump(byte* b, int count) -{ - int i; - - for (i = 0; i < count; i++) - { - printf("%02x", b[i]); - if ((i & 0xf) == 0xf) - printf("\n"); - } - if (i & 0xf) - printf("\n"); -} - -int main() -{ - int rc; - mpw x[4]; - byte o[9]; - - mpsetw(4, x, 255); - mpmultwo(4, x); - rc = i2osp(o, 9, x, 4); - - printf("rc = %d\n", rc); - hexdump(o, 9); - - rc = os2ip(x, 4, o, 9); - printf("rc = %d\n", rc); - mpprintln(4, x); - - exit(0); -} diff --git a/beecrypt/tests/testdldp.c b/beecrypt/tests/testdldp.c deleted file mode 100644 index 027956ff8..000000000 --- a/beecrypt/tests/testdldp.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2002, 2003 Bob Deblier - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file testdldp.c - * \brief Unit test program for discrete logarithm domain parameters. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup UNIT_m - */ - -#include "system.h" - -#include "beecrypt.h" -#include "dldp.h" - -#include "debug.h" - -int main() -{ - int failures = 0; - - dldp_p params; - randomGeneratorContext rngc; - - dldp_pInit(¶ms); - - if (randomGeneratorContextInit(&rngc, randomGeneratorDefault()) == 0) - { - mpnumber gq; - - mpnzero(&gq); - - /* make parameters with p = 1024 bits, q = 160 bits, g of order (q) */ - dldp_pgoqMake(¶ms, &rngc, 1024, 160, 1); - - /* we have the parameters, now see if g^q == 1 */ - mpbnpowmod(¶ms.p, ¶ms.g, (mpnumber*) ¶ms.q, &gq); - if (!mpisone(gq.size, gq.data)) - { - printf("failed test vector 1\n"); - failures++; - } - - mpnfree(&gq); - - dldp_pFree(¶ms); - - randomGeneratorContextFree(&rngc); - } - else - { - printf("random generator failure\n"); - return -1; - } - - return failures; -} diff --git a/beecrypt/tests/testdsa.c b/beecrypt/tests/testdsa.c deleted file mode 100644 index 7834d42fa..000000000 --- a/beecrypt/tests/testdsa.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2002, 2003 Bob Deblier - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file testdsa.c - * \brief Unit test program for the DSA algorithm. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup UNIT_m - */ - -#include "system.h" - -#include "beecrypt.h" -#include "dlkp.h" -#include "dsa.h" - -#include "debug.h" - -struct vector -{ - const char* p; - const char* q; - const char* g; - const char* y; - const char* m; - const char* r; - const char* s; -}; - -#define NVECTORS 2 - -struct vector table[NVECTORS] = { - { "8df2a494492276aa3d25759bb06869cbeac0d83afb8d0cf7cbb8324f0d7882e5d0762fc5b7210eafc2e9adac32ab7aac49693dfbf83724c2ec0736ee31c80291", - "c773218c737ec8ee993b4f2ded30f48edace915f", - "626d027839ea0a13413163a55b4cb500299d5522956cefcb3bff10f399ce2c2e71cb9de5fa24babf58e5b79521925c9cc42e9f6f464b088cc572af53e6d78802", - "19131871d75b1612a819f29d78d1b0d7346f7aa77bb62a859bfd6c5675da9d212d3a36ef1672ef660b8c7c255cc0ec74858fba33f44c06699630a76b030ee333", - "a9993e364706816aba3e25717850c26c9cd0d89d", - "8bac1ab66410435cb7181f95b16ab97c92b341c0", - "41e2345f1f56df2458f426d155b4ba2db6dcd8c8" }, - { "A62927E72F9F12CD31C50E30D0E9B580539C4F7CA2AC3E2EE244C834303B039A1A388FDE4DCD42B5402807047FBEC0DB09ECF897CD2B8546A893499B3A8A409C52476708EAD0124E43F31CA2495A950731D254F56F4F39AC379E0620E15A9CC5A8EA5100CD1137012093E11F73A1E38FAEB95588BB54A48913977D1A1EC6986F", - "C4243BE451ECBA6F87F539A7F899D4047208B091", - "9C8D21312FD7358D86D82E8F237E99A9DFC375529456420F159361C40A76A891DA8D6CEE8EB1BDEC97CA60CCBE921BED5EB29EC35A2EFCA295311585753EFABBADF599620EA0FB8489FBEE60EDE6D5A99DD3506F37CC21741D306BEE15BBB8EAA1261C2DC18221FB5C6A08602B3E1084029285DF161A2CB6B179830C31C351A3", - "7602862B1A4F6F154BE21AFD86CF2AADD6393AE0EBBB5781CB82758C9A360A540BBCC3CBBF014509FD0ED2FC30C6ED0959C43954CF058854B8469DD4247AC463D4C10B6479C8B4FBE56E97067A7FC4E7F1A95507A0B6D70328534C37B590DB8ED12BB460FC3232758F9B64D7BD63BD320FF1FA635A3F77D13D71A8AD4E8B5469", - "73F6679451E5F98CA60235E6B4C58FC14043C56D", - "22EDDAD362C3209DF597070D144E8FDDB8B65E53", - "3AB093E7A7CD30125036B384C6C114317F10E10D" } -}; - -int main() -{ - int i, failures = 0; - - dlkp_p keypair; - mpnumber hm, r, s, k, e_r, e_s; - - for (i = 0; i < NVECTORS; i++) - { - dlkp_pInit(&keypair); - - mpbsethex(&keypair.param.p, table[i].p); - mpbsethex(&keypair.param.q, table[i].q); - mpnsethex(&keypair.param.g, table[i].g); - mpnsethex(&keypair.y, table[i].y); - - mpnzero(&hm); - mpnsethex(&hm, table[i].m); - - mpnzero(&e_r); - mpnzero(&e_s); - - mpnsethex(&e_r, table[i].r); - mpnsethex(&e_s, table[i].s); - - mpnzero(&r); - mpnzero(&s); - - /* first test, verify the signature result from NIST FIPS 186-1 */ - if (!dsavrfy(&keypair.param.p, &keypair.param.q, &keypair.param.g, &hm, &keypair.y, &e_r, &e_s)) - failures++; - - mpnfree(&s); - mpnfree(&r); - - mpnfree(&hm); - - mpnfree(&e_s); - mpnfree(&e_r); - - dlkp_pFree(&keypair); - } - - return failures; -} diff --git a/beecrypt/tests/testhmacmd5.c b/beecrypt/tests/testhmacmd5.c deleted file mode 100644 index 1db1a97bb..000000000 --- a/beecrypt/tests/testhmacmd5.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2002, 2003 Bob Deblier - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file testhmacmd5.c - * \brief Unit test program for HMAC-MD5; it tests all vectors specified - * by RFC 2202. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup UNIT_m - */ - -#include "system.h" - -#include "hmacmd5.h" - -#include "debug.h" - -struct vector -{ - int keybits; - byte* key; - int input_size; - byte* input; - byte* expect; -}; - -struct vector table[7] = -{ - { 128, - (byte*) "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b", - 8, - (byte*) "Hi There", - (byte*) "\x92\x94\x72\x7a\x36\x38\xbb\x1c\x13\xf4\x8e\xf8\x15\x8b\xfc\x9d" }, - { 32, - (byte*) "Jefe", - 28, - (byte*) "what do ya want for nothing?", - (byte*) "\x75\x0c\x78\x3e\x6a\xb0\xb5\x03\xea\xa8\x6e\x31\x0a\x5d\xb7\x38" }, - { 128, - (byte*) "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa", - 50, - (byte*) "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd", - (byte*) "\x56\xbe\x34\x52\x1d\x14\x4c\x88\xdb\xb8\xc7\x33\xf0\xe8\xb3\xf6" }, - { 200, - (byte*) "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19", - 50, - (byte*) "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd", - (byte*) "\x69\x7e\xaf\x0a\xca\x3a\x3a\xea\x3a\x75\x16\x47\x46\xff\xaa\x79" }, - { 128, - (byte*) "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c", - 20, - (byte*) "Test With Truncation", - (byte*) "\x56\x46\x1e\xf2\x34\x2e\xdc\x00\xf9\xba\xb9\x95\x69\x0e\xfd\x4c"}, - { 640, - (byte*) "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa", - 54, - (byte*) "Test Using Larger Than Block-Size Key - Hash Key First", - (byte*) "\x6b\x1a\xb7\xfe\x4b\xd7\xbf\x8f\x0b\x62\xe6\xce\x61\xb9\xd0\xcd" }, - { 640, - (byte*) "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa", - 73, - (byte*) "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data", - (byte*) "\x6f\x63\x0f\xad\x67\xcd\xa0\xee\x1f\xb1\xf5\x62\xdb\x3a\xa5\x3e" } -}; - -int main() -{ - int i, failures = 0; - hmacmd5Param param; - byte digest[16]; - - for (i = 0; i < 7; i++) - { - if (hmacmd5Setup(¶m, table[i].key, table[i].keybits)) - return -1; - if (hmacmd5Update(¶m, table[i].input, table[i].input_size)) - return -1; - if (hmacmd5Digest(¶m, digest)) - return -1; - - if (memcmp(digest, table[i].expect, 16)) - { - printf("failed test vector %d\n", i+1); - failures++; - } - } - - return failures; -} diff --git a/beecrypt/tests/testhmacsha1.c b/beecrypt/tests/testhmacsha1.c deleted file mode 100644 index fe8e84db9..000000000 --- a/beecrypt/tests/testhmacsha1.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2002, 2003 Bob Deblier - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file testhmacsha1.c - * \brief Unit test program for HMAC-SHA1; it tests all vectors specified - * by RFC 2202. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup UNIT_m - */ - -#include "system.h" - -#include "hmacsha1.h" - -#include "debug.h" - -struct vector -{ - int keybits; - byte* key; - int input_size; - byte* input; - byte* expect; -}; - -struct vector table[7] = -{ - { 160, - (byte*) "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b", - 8, - (byte*) "Hi There", - (byte*) "\xb6\x17\x31\x86\x55\x05\x72\x64\xe2\x8b\xc0\xb6\xfb\x37\x8c\x8e\xf1\x46\xbe\x00" }, - { 32, - (byte*) "Jefe", - 28, - (byte*) "what do ya want for nothing?", - (byte*) "\xef\xfc\xdf\x6a\xe5\xeb\x2f\xa2\xd2\x74\x16\xd5\xf1\x84\xdf\x9c\x25\x9a\x7c\x79" }, - { 160, - (byte*) "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa", - 50, - (byte*) "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd", - (byte*) "\x12\x5d\x73\x42\xb9\xac\x11\xcd\x91\xa3\x9a\xf4\x8a\xa1\x7b\x4f\x63\xf1\x75\xd3" }, - { 200, - (byte*) "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19", - 50, - (byte*) "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd", - (byte*) "\x4c\x90\x07\xf4\x02\x62\x50\xc6\xbc\x84\x14\xf9\xbf\x50\xc8\x6c\x2d\x72\x35\xda" }, - { 160, - (byte*) "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c", - 20, - (byte*) "Test With Truncation", - (byte*) "\x4c\x1a\x03\x42\x4b\x55\xe0\x7f\xe7\xf2\x7b\xe1\xd5\x8b\xb9\x32\x4a\x9a\x5a\x04" }, - { 640, - (byte*) "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa", - 54, - (byte*) "Test Using Larger Than Block-Size Key - Hash Key First", - (byte*) "\xaa\x4a\xe5\xe1\x52\x72\xd0\x0e\x95\x70\x56\x37\xce\x8a\x3b\x55\xed\x40\x21\x12" }, - { 640, - (byte*) "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa", - 73, - (byte*) "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data", - (byte*) "\xe8\xe9\x9d\x0f\x45\x23\x7d\x78\x6d\x6b\xba\xa7\x96\x5c\x78\x08\xbb\xff\x1a\x91" } -}; - -int main() -{ - int i, failures = 0; - byte digest[20]; - hmacsha1Param param; - - for (i = 0; i < 7; i++) - { - if (hmacsha1Setup(¶m, table[i].key, table[i].keybits)) - return -1; - if (hmacsha1Update(¶m, table[i].input, table[i].input_size)) - return -1; - if (hmacsha1Digest(¶m, digest)) - return -1; - - if (memcmp(digest, table[i].expect, 20)) - { - printf("failed test vector %d\n", i+1); - failures++; - } - } - - return failures; -} diff --git a/beecrypt/tests/testmd5.c b/beecrypt/tests/testmd5.c deleted file mode 100644 index 5137912ac..000000000 --- a/beecrypt/tests/testmd5.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2002, 2003 Bob Deblier - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file testmd5.c - * \brief Unit test program for the MD5 algorithm; it tests all vectors - * specified by RFC 1321. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup UNIT_m - */ - -#include "system.h" - -#include "md5.h" - -#include "debug.h" - -struct vector -{ - int input_size; - byte* input; - byte* expect; -}; - -struct vector table[7] = { - { 0, (byte*) "", - (byte*) "\xd4\x1d\x8c\xd9\x8f\x00\xb2\x04\xe9\x80\x09\x98\xec\xf8\x42\x7e" }, - { 1, (byte*) "a", - (byte*) "\x0c\xc1\x75\xb9\xc0\xf1\xb6\xa8\x31\xc3\x99\xe2\x69\x77\x26\x61" }, - { 3, (byte*) "abc", - (byte*) "\x90\x01\x50\x98\x3c\xd2\x4f\xb0\xd6\x96\x3f\x7d\x28\xe1\x7f\x72" }, - { 14, (byte*) "message digest", - (byte*) "\xf9\x6b\x69\x7d\x7c\xb7\x93\x8d\x52\x5a\x2f\x31\xaa\xf1\x61\xd0" }, - { 26, (byte*) "abcdefghijklmnopqrstuvwxyz", - (byte*) "\xc3\xfc\xd3\xd7\x61\x92\xe4\x00\x7d\xfb\x49\x6c\xca\x67\xe1\x3b" }, - { 62, (byte*) "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", - (byte*) "\xd1\x74\xab\x98\xd2\x77\xd9\xf5\xa5\x61\x1c\x2c\x9f\x41\x9d\x9f" }, - { 80, (byte*) "12345678901234567890123456789012345678901234567890123456789012345678901234567890", - (byte*) "\x57\xed\xf4\xa2\x2b\xe3\xc9\x55\xac\x49\xda\x2e\x21\x07\xb6\x7a" } -}; - -int main() -{ - int i, failures = 0; - byte digest[16]; - md5Param param; - - for (i = 0; i < 7; i++) - { - if (md5Reset(¶m)) - return -1; - if (md5Update(¶m, table[i].input, table[i].input_size)) - return -1; - if (md5Digest(¶m, digest)) - return -1; - - if (memcmp(digest, table[i].expect, 16)) - { - printf("failed test vector %d\n", i+1); - failures++; - } - } - return failures; -} diff --git a/beecrypt/tests/testmp.c b/beecrypt/tests/testmp.c deleted file mode 100644 index 0a6bb527e..000000000 --- a/beecrypt/tests/testmp.c +++ /dev/null @@ -1,108 +0,0 @@ -#include "system.h" - -#include "beecrypt.h" -#include "mp.h" - -#include "debug.h" - -#define INIT 0xdeadbeefU; - -static const mpw Z[4] = { 0U, 0U, 0U, 0U }; -static const mpw F[4] = { MP_ALLMASK, MP_ALLMASK, MP_ALLMASK, MP_ALLMASK}; -static const mpw P[8] = { MP_ALLMASK, MP_ALLMASK, MP_ALLMASK, MP_ALLMASK-1U, 0U, 0U, 0U, 1U }; - -int main() -{ - int i, carry; - mpw x[4]; - mpw y[4]; - mpw r[8]; - - for (i = 0; i < 4; i++) - x[i] = INIT; - - mpcopy(4, x, Z); - for (i = 0; i < 4; i++) - { - if (x[i] != 0) - { - printf("mpcopy failed\n"); - return 1; - } - } - - if (!mpeq(4, x, Z)) - { - printf("mpeq failed\n"); - return 1; - } - if (mpne(4, x, Z)) - { - printf("mpne failed\n"); - return 1; - } - - mpcopy(4, x, F); - for (i = 0; i < 4; i++) - { - if (x[i] != ~((mpw) 0)) - { - printf("mpcopy failed\n"); - return 1; - } - } - - if (!mpz(4, Z) || mpz(4, F)) - { - printf("mpz failed\n"); - return 1; - } - if (mpnz(4, Z) || !mpnz(4, F)) - { - printf("mpnz failed\n"); - return 1; - } - - if (!mpeq(4, x, F)) - { - printf("mpeq failed\n"); - return 1; - } - if (mpne(4, x, F)) - { - printf("mpne failed\n"); - return 1; - } - - mpcopy(4, x, F); - carry = mpaddw(4, x, (mpw) 1U); - if (!carry || mpne(4, x, Z)) - { - printf("mpaddw failed"); - return 1; - } - carry = mpsubw(4, x, (mpw) 1U); - if (!carry || mpne(4, x, F)) - { - printf("mpsubw failed"); - return 1; - } - - mpzero(8, r); - mpmul(r, 4, F, 4, F); - if (!mpeq(8, r, P)) - { - printf("mpmul failed\n"); - return 1; - } - - mpzero(8, r); - mpsqr(r, 4, F); - if (!mpeq(8, r, P)) - { - printf("mpsqr failed\n"); - return 1; - } - - return 0; -} diff --git a/beecrypt/tests/testmpinv.c b/beecrypt/tests/testmpinv.c deleted file mode 100644 index 5389333c7..000000000 --- a/beecrypt/tests/testmpinv.c +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2003 Bob Deblier - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file testmpinv.c - * \brief Unit test program for the multi-precision modular inverse. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup UNIT_m - */ - -#include "system.h" - -#include "beecrypt.h" -#include "mpnumber.h" - -#include "debug.h" - -struct vector -{ - const char* m; - const char* k; - const char* inv_k; -}; - -#define NVECTORS 5 - -struct vector table[NVECTORS] = { - { "c773218c737ec8ee993b4f2ded30f48edace915f", - "358dad571462710f50e254cf1a376b2bdeaadfbf", - "0d5167298202e49b4116ac104fc3f415ae52f917" }, - { "fe95df16069b516859ba036ef0e563a7b6a86409", - "eedd5539e982b570a5f8efc73f243a04f312920d", - "f64a00a9ce43f4128e5eee1991b2e08c6008ba4e" }, - { "fe95df16069b516859ba036ef0e563a7b6a86409", - "d75f6d17eb243613eacc0dcbb41db4e5a3364b07", - "e90aa0a992ebd4c9176f0e20a885101218111a73" }, - { "fe95df16069b516859ba036ef0e563a7b6a86409", - "759ea04b65f66184af22fcabfe99a1cda3a79236", - "2c701a52078afe539a281cba7f35df34a7a125a4" }, - { "80277b4855a39cb9a98b2107cc1efb29f1832f727df05931cdd4a64cd78363134bf2abe78723784d2013a26875afe13f04526399c6b0cee659abb60dc8263400", - "10001", - "6e5f92b24defc7ffafa20024b30ccbcce810d0408f6efda3035f6e8b27e224e66db6e78f54b89bd7f11477fff7bc2f071335d24a92f19c8090226f7d97303001" } - -}; - -int main() -{ - int i, failures = 0; - - mpnumber m; - mpnumber k; - mpnumber inv_k; - mpnumber inv; - - mpnzero(&m); - mpnzero(&k); - mpnzero(&inv_k); - mpnzero(&inv); - - for (i = 0; i < NVECTORS; i++) - { - mpnsethex(&m, table[i].m); - mpnsethex(&k, table[i].k); - mpnsethex(&inv_k, table[i].inv_k); - - if (mpninv(&inv, &k, &m)) - { - if (mpnex(inv.size, inv.data, inv_k.size, inv_k.data)) - { - printf("mpninv return unexpected result\n"); - failures++; - } - } - else - { - printf("mpninv failed\n"); - failures++; - } - } - - mpnfree(&m); - mpnfree(&k); - mpnfree(&inv_k); - mpnfree(&inv); - - return failures; -} diff --git a/beecrypt/tests/testrsa.c b/beecrypt/tests/testrsa.c deleted file mode 100644 index 63a436fa8..000000000 --- a/beecrypt/tests/testrsa.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2003 Bob Deblier - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file testrsa.c - * \brief Unit test program for the RSA algorithm. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup UNIT_m - */ - -#include "system.h" - -#include "beecrypt.h" -#include "rsa.h" - -#include "debug.h" - -static const char* rsa_n = "bbf82f090682ce9c2338ac2b9da871f7368d07eed41043a440d6b6f07454f51fb8dfbaaf035c02ab61ea48ceeb6fcd4876ed520d60e1ec4619719d8a5b8b807fafb8e0a3dfc737723ee6b4b7d93a2584ee6a649d060953748834b2454598394ee0aab12d7b61a51f527a9a41f6c1687fe2537298ca2a8f5946f8e5fd091dbdcb"; -static const char* rsa_e = "11"; -static const char* rsa_p = "eecfae81b1b9b3c908810b10a1b5600199eb9f44aef4fda493b81a9e3d84f632124ef0236e5d1e3b7e28fae7aa040a2d5b252176459d1f397541ba2a58fb6599"; -static const char* rsa_q = "c97fb1f027f453f6341233eaaad1d9353f6c42d08866b1d05a0f2035028b9d869840b41666b42e92ea0da3b43204b5cfce3352524d0416a5a441e700af461503"; -static const char* rsa_d1 = "54494ca63eba0337e4e24023fcd69a5aeb07dddc0183a4d0ac9b54b051f2b13ed9490975eab77414ff59c1f7692e9a2e202b38fc910a474174adc93c1f67c981"; -static const char* rsa_d2 = "471e0290ff0af0750351b7f878864ca961adbd3a8a7e991c5c0556a94c3146a7f9803f8f6f8ae342e931fd8ae47a220d1b99a495849807fe39f9245a9836da3d"; -static const char* rsa_c = "b06c4fdabb6301198d265bdbae9423b380f271f73453885093077fcd39e2119fc98632154f5883b167a967bf402b4e9e2e0f9656e698ea3666edfb25798039f7"; - -static const char* rsa_m = "d436e99569fd32a7c8a05bbc90d32c49"; - -int main() -{ - int failures = 0; - - rsakp keypair; - mpnumber m, cipher, decipher; - randomGeneratorContext rngc; - - if (randomGeneratorContextInit(&rngc, randomGeneratorDefault()) == 0) - { - /* First we do the fixed value verification */ - rsakpInit(&keypair); - - mpbsethex(&keypair.n, rsa_n); - mpnsethex(&keypair.e, rsa_e); - mpbsethex(&keypair.p, rsa_p); - mpbsethex(&keypair.q, rsa_q); - mpnsethex(&keypair.dp, rsa_d1); - mpnsethex(&keypair.dq, rsa_d2); - mpnsethex(&keypair.qi, rsa_c); - - mpnzero(&m); - mpnzero(&cipher); - mpnzero(&decipher); - - mpnsethex(&m, rsa_m); - - /* it's safe to cast the keypair to a public key */ - if (rsapub(&keypair.n, &keypair.e, &m, &cipher)) - failures++; - - if (rsapricrt(&keypair.n, &keypair.p, &keypair.q, &keypair.dp, &keypair.dq, &keypair.qi, &cipher, &decipher)) - failures++; - - if (mpnex(m.size, m.data, decipher.size, decipher.data)) - failures++; - - mpnfree(&decipher); - mpnfree(&cipher); - mpnfree(&m); - - rsakpFree(&keypair); - - mpnzero(&m); - mpnzero(&cipher); - mpnzero(&decipher); - - /* Now we generate a keypair and do some tests on it */ - rsakpMake(&keypair, &rngc, 512); - - /* generate a random m in the range 0 < m < n */ - mpbnrnd(&keypair.n, &rngc, &m); - - /* it's safe to cast the keypair to a public key */ - if (rsapub(&keypair.n, &keypair.e, &m, &cipher)) - failures++; - - if (rsapricrt(&keypair.n, &keypair.p, &keypair.q, &keypair.dp, &keypair.dq, &keypair.qi, &cipher, &decipher)) - failures++; - - if (mpnex(m.size, m.data, decipher.size, decipher.data)) - failures++; - - rsakpFree(&keypair); - } - return failures; -} diff --git a/beecrypt/tests/testsha1.c b/beecrypt/tests/testsha1.c deleted file mode 100644 index 33c1f6026..000000000 --- a/beecrypt/tests/testsha1.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2002, 2003 Bob Deblier - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file testsha1.c - * \brief Unit test program for the SHA-1 algorithm ; it tests all but one of - * the vectors specified by FIPS PUB 180-1. - * \author Bob Deblier <bob.deblier@pandora.be> - * \ingroup UNIT_m - */ - -#include "system.h" - -#include "sha1.h" -#include "memchunk.h" - -#include "debug.h" - -struct vector -{ - int input_size; - byte* input; - byte* expect; -}; - -struct vector table[2] = { - { 3, (byte*) "abc", - (byte*) "\xA9\x99\x3E\x36\x47\x06\x81\x6A\xBA\x3E\x25\x71\x78\x50\xC2\x6C\x9C\xD0\xD8\x9D" }, - { 56, (byte*) "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", - (byte*) "\x84\x98\x3E\x44\x1C\x3B\xD2\x6E\xBA\xAE\x4A\xA1\xF9\x51\x29\xE5\xE5\x46\x70\xF1" } -}; - -int main() -{ - int i, failures = 0; - byte digest[20]; - sha1Param param; - - for (i = 0; i < 2; i++) - { - if (sha1Reset(¶m)) - return -1; - if (sha1Update(¶m, table[i].input, table[i].input_size)) - return -1; - if (sha1Digest(¶m, digest)) - return -1; - - if (memcmp(digest, table[i].expect, 20)) - { - printf("failed test vector %d\n", i+1); - failures++; - } - } - return failures; -} diff --git a/beecrypt/tests/testsha256.c b/beecrypt/tests/testsha256.c deleted file mode 100644 index 1b60959c7..000000000 --- a/beecrypt/tests/testsha256.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * testsha256.c - * - * Unit test program for SHA-256; it implements the test vectors from the draft FIPS document. - * - * Copyright (c) 2002, 2003 Bob Deblier <bob.deblier@pandora.be> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "system.h" - -#include "sha256.h" - -#include "debug.h" - -struct vector -{ - int input_size; - byte* input; - byte* expect; -}; - - -struct vector table[2] = { - { 3, (byte*) "abc", - (byte*) "\xba\x78\x16\xbf\x8f\x01\xcf\xea\x41\x41\x40\xde\x5d\xae\x22\x23\xb0\x03\x61\xa3\x96\x17\x7a\x9c\xb4\x10\xff\x61\xf2\x00\x15\xad" }, - { 56, (byte*) "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", - (byte*) "\x24\x8d\x6a\x61\xd2\x06\x38\xb8\xe5\xc0\x26\x93\x0c\x3e\x60\x39\xa3\x3c\xe4\x59\x64\xff\x21\x67\xf6\xec\xed\xd4\x19\xdb\x06\xc1" } -}; - -int main() -{ - int i, failures = 0; - sha256Param param; - byte digest[32]; - - for (i = 0; i < 2; i++) - { - if (sha256Reset(¶m)) - return -1; - if (sha256Update(¶m, table[i].input, table[i].input_size)) - return -1; - if (sha256Digest(¶m, digest)) - return -1; - - if (memcmp(digest, table[i].expect, 32)) - { - printf("failed test vector %d\n", i+1); - failures++; - } - } - return failures; -} diff --git a/beecrypt/tests/testutil.c b/beecrypt/tests/testutil.c deleted file mode 100644 index 875474455..000000000 --- a/beecrypt/tests/testutil.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2003 Bob Deblier - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "system.h" - -#include "beecrypt.h" - -#include "debug.h" - -int fromhex(byte* data, const char* hexdata) -{ - int length = strlen(hexdata); - int count = 0, index = 0; - byte b = 0; - char ch; - - if (length & 1) - count = 1; - - while (index++ < length) - { - ch = *(hexdata++); - - b <<= 4; - if (ch >= '0' && ch <= '9') - b += (ch - '0'); - else if (ch >= 'A' && ch <= 'F') - b += (ch - 'A') + 10; - else if (ch >= 'a' && ch <= 'f') - b += (ch - 'a') + 10; - - count++; - if (count == 2) - { - *(data++) = b; - b = 0; - count = 0; - } - } - return (length+1) >> 1; -} diff --git a/beecrypt/timestamp.c b/beecrypt/timestamp.c deleted file mode 100644 index 258922bbc..000000000 --- a/beecrypt/timestamp.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1999, 2000, 2002, 2003 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file timestamp.c - * \brief Java compatible 64-bit timestamp. - * \author Bob Deblier <bob.deblier@pandora.be> - */ - -#include "system.h" - -#include "timestamp.h" - -#include "debug.h" - -javalong timestamp() -{ - javalong tmp; - #if HAVE_SYS_TIME_H - # if HAVE_GETTIMEOFDAY - struct timeval now; - - gettimeofday(&now, 0); - - tmp = ((javalong) now.tv_sec) * 1000 + (now.tv_usec / 1000); - # else - # error - # endif - #elif HAVE_TIME_H - tmp = ((javalong) time(0)) * 1000; - #else - # error implement other time function - #endif - - return tmp; -} diff --git a/beecrypt/timestamp.h b/beecrypt/timestamp.h deleted file mode 100644 index a55cdde71..000000000 --- a/beecrypt/timestamp.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * timestamp.h - * - * Java-compatible 64 bit timestamp, header - * - * Copyright (c) 1999, 2000 Virtual Unlimited B.V. - * - * Author: Bob Deblier <bob@virtualunlimited.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef _TIMESTAMP_H -#define _TIMESTAMP_H - -#include "beecrypt.h" - -#if HAVE_LONG_LONG -# define ONE_SECOND 1000LL -# define ONE_MINUTE 60000LL -# define ONE_HOUR 3600000LL -# define ONE_DAY 86400000LL -# define ONE_WEEK 604800000LL -# define ONE_YEAR 31536000000LL -#else -# define ONE_SECOND 1000L -# define ONE_MINUTE 60000L -# define ONE_HOUR 3600000L -# define ONE_DAY 86400000L -# define ONE_WEEK 604800000L -# define ONE_YEAR 31536000000L -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -BEECRYPTAPI -javalong timestamp(void) - /*@*/; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/beecrypt/win.h b/beecrypt/win.h deleted file mode 100644 index 40a79e457..000000000 --- a/beecrypt/win.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) 2000, 2001, 2002 Virtual Unlimited B.V. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -/*!\file win.h - * \brief BeeCrypt API, windows headers. - * \author Bob Deblier <bob.deblier@pandora.be> - */ - -#ifndef _BEECRYPT_WIN_H -#define _BEECRYPT_WIN_H - -#define _REENTRANT - -#if !defined(_WIN32_WINNT) -#define _WIN32_WINNT 0x0400 -#endif - -#include <windows.h> - -#if __MWERKS__ -# if __INTEL__ -# define WORDS_BIGENDIAN 0 -# else -# error Unknown CPU type in MetroWerks CodeWarrior -# endif -#elif defined(_MSC_VER) -# if defined(_M_IX86) -# define WORDS_BIGENDIAN 0 -# define ROTL32(x, s) _rotl(x, s) -# define ROTR32(x, s) _rotr(x, s) -# else -# error Unknown CPU type in Microsoft Visual C -# endif -#else -# error Unknown compiler for WIN32 -#endif - -#if defined(_MSC_VER) || __MWERKS__ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#define HAVE_ERRNO_H 1 -#define HAVE_CTYPE_H 1 -#define HAVE_FCNTL_H 1 -#define HAVE_TIME_H 1 - -#define HAVE_SYS_TYPES_H 0 -#define HAVE_SYS_TIME_H 0 - -#define HAVE_THREAD_H 0 -#define HAVE_SYNCH_H 0 -#define HAVE_PTHREAD_H 0 -#define HAVE_SEMAPHORE_H 0 - -#define HAVE_TERMIO_H 0 -#define HAVE_SYS_AUDIOIO_H 0 -#define HAVE_SYS_IOCTL_H 0 -#define HAVE_SYS_SOUNDCARD_H 0 - -#define HAVE_GETTIMEOFDAY 0 -#define HAVE_GETHRTIME 0 - -#define HAVE_DEV_TTY 0 -#define HAVE_DEV_AUDIO 0 -#define HAVE_DEV_DSP 0 -#define HAVE_DEV_RANDOM 0 -#define HAVE_DEV_URANDOM 0 -#define HAVE_DEV_TTY 0 - -#else -#error Not set up for this compiler -#endif - -#if __MWERKS__ -#define HAVE_SYS_STAT_H 0 - -#define HAVE_LONG_LONG 1 -#define HAVE_UNSIGNED_LONG_LONG 1 - -#define HAVE_64_BIT_INT 1 -#define HAVE_64_BIT_UINT 1 - -typedef char int8_t; -typedef short int16_t; -typedef long int32_t; -typedef long long int64_t; - -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned long uint32_t; -typedef unsigned long long uint64_t; - -#elif defined(_MSC_VER) -#define HAVE_SYS_STAT_H 1 - -#define HAVE_LONG_LONG 0 -#define HAVE_UNSIGNED_LONG_LONG 0 - -#define HAVE_64_BIT_INT 1 -#define HAVE_64_BIT_UINT 1 - -typedef signed char int8_t; -typedef signed short int16_t; -typedef signed int int32_t; -typedef signed __int64 int64_t; - -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned int uint32_t; -typedef unsigned __int64 uint64_t; - -typedef long off_t; - -#endif - -#define MP_WBITS 32U - -typedef HANDLE bc_cond_t; -typedef HANDLE bc_mutex_t; -typedef DWORD bc_thread_t; - -#endif diff --git a/beecrypt/win32/beecrypt.def b/beecrypt/win32/beecrypt.def deleted file mode 100644 index 965017ff8..000000000 --- a/beecrypt/win32/beecrypt.def +++ /dev/null @@ -1,259 +0,0 @@ -; -; beecrypt.def -; -; BeeCrypt DLL exports -; -; Copyright (c) 2000 Virtual Unlimited B.V. -; -; Author: Bob Deblier <bob@virtualunlimited.com> -; -; This library is free software; you can redistribute it and/or -; modify it under the terms of the GNU Lesser General Public -; License as published by the Free Software Foundation; either -; version 2.1 of the License, or (at your option) any later version. -; -; This library is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -; Lesser General Public License for more details. -; -; You should have received a copy of the GNU Lesser General Public -; License along with this library; if not, write to the Free Software -; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -; - -LIBRARY beecrypt - -EXPORTS - DllMain - b64enc - b64dec - blockCipherContextFree - blockCipherContextInit - blockCipherCount - blockCipherDefault - blockCipherFind - blockCipherGet - blockEncrypt - blockDecrypt - blowfish data - blowfishCBCEncrypt - blowfishCBCDecrypt - blowfishDecrypt - blowfishECBEncrypt - blowfishECBDecrypt - blowfishEncrypt - blowfishSetup - decodeByte - decodeChar - decodeChars - decodeDouble - decodeFloat - decodeInt - decodeInts - decodeLong - decodeShort - dldp_pCopy - dldp_pEqual - dldp_pFree - dldp_pInit - dldp_pPair - dldp_pPrivate - dldp_pPublic - dldp_pgonGenerator - dldp_pgonMake - dldp_pgonMakeSafe - dldp_pgonValidate - dldp_pgoqGenerator - dldp_pgoqMake - dldp_pgoqMakeSafe - dldp_pgoqValidate - dlkp_pCopy - dlkp_pFree - dlkp_pPair - dlpk_pCopy - dlpk_pEqual - dlpk_pFree - dlpk_pgoqValidate - dlpk_pgonValidate - dlsvdp_pDHSecret - ;elgv1sign - ;elgv1vrfy - elgv3sign - elgv3vrfy - encodeByte - encodeChar - encodeChars - encodeDouble - encodeFloat - encodeInt - encodeInts - encodeLong - encodeShort - entropySourceCount - entropySourceDefault - entropySourceFind - entropySourceGet - fips186Cleanup - fips186Next - fips186Seed - fips186Setup - fips186prng data - hashFunctionContextFree - hashFunctionContextInit - hashFunctionCount - hashFunctionDefault - hashFunctionFind - hashFunctionGet - hmacDigest - hmacReset - hmacSetup - hmacUpdate - keyedHashFunctionContextFree - keyedHashFunctionContextInit - keyedHashFunctionCount - keyedHashFunctionDefault - keyedHashFunctionFind - keyedHashFunctionGet - ;mp32copy - ;mp32move - mp32zero - mp32fill - mp32odd - mp32even - mp32z - mp32nz - mp32eq - mp32ne - mp32gt - mp32lt - mp32ge - mp32le - mp32eqx - mp32nex - mp32gtx - mp32ltx - mp32gex - mp32lex - mp32isone - mp32leone - mp32eqmone - mp32msbset - mp32lsbset - mp32setmsb - mp32setlsb - mp32clrmsb - mp32clrlsb - mp32xor - mp32not - mp32setw - mp32setx - mp32addw - mp32add - mp32addx - mp32subw - mp32sub - mp32subx - mp32multwo - mp32neg - mp32size - mp32mszcnt - mp32lszcnt - mp32lshift - mp32rshift - mp32norm - mp32divpowtwo - mp32divtwo - mp32sdivtwo - mp32setmul - mp32addmul - mp32addsqrtrc - mp32mul - mp32sqr - mp32gcd - mp32nmodw - mp32nmod - mp32ndivmod - mp32print - mp32println - mp32bzero - mp32binit - mp32bfree - mp32bset - mp32bmu - mp32brnd - mp32brndres - mp32bmodsubone - mp32bneg - mp32bmod - mp32baddmod - ;mp32bsubmod - mp32bmulmodres - mp32bsqrmodres - mp32bmulmod - mp32bsqrmod - mp32bpowmod - mp32btwopowmod - ;mp32bsm2powmod - ;mp32bsm3powmod - mp32binv - mp32bpprime - mp32bnmulmodres - mp32bnsqrmodres - mp32bnpowmod - mp32bnsqrmod - mp32ptrials - mp32pmilrab - mp32prnd - mp32prndsafe - ;mp32prndcon - mp32prndconone - mp32nzero - mp32nsize - mp32ninit - mp32nfree - mp32nset - mp32nsetw - mp32nsethex - mtprng data - mtprngCleanup - mtprngNext - mtprngSeed - mtprngSetup - randomGeneratorCount - randomGeneratorGet - randomGeneratorFind - randomGeneratorDefault - randomGeneratorContextInit - randomGeneratorContextFree - readByte - readChar - readChars - readInt - readInts - readLong - readShort - sha1 data - sha1Process - sha1Reset - sha1Update - sha1Digest - sha1hmac data - sha1hmacDigest - sha1hmacReset - sha1hmacSetup - sha1hmacUpdate - swap16 - swap32 - swap64 - swapu16 - swapu32 - ;swapu64 - timestamp - writeByte - writeChar - writeChars - writeInt - writeInts - writeLong - writeShort diff --git a/beecrypt/win32/beecrypt.dll.c b/beecrypt/win32/beecrypt.dll.c deleted file mode 100644 index 109005187..000000000 --- a/beecrypt/win32/beecrypt.dll.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * beecrypt.c - * - * BeeCrypt DLL entry point, code - * - * Copyright (c) 2000 Virtual Unlimited B.V. - * - * Author: Bob Deblier <bob@virtualunlimited.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include "beecrypt.h" - -#include <windows.h> - -__declspec(dllexport) -BOOL WINAPI DllMain(HINSTANCE hInst, DWORD wDataSeg, LPVOID lpReserved) -{ - switch (wDataSeg) - { - case DLL_PROCESS_ATTACH: - entropy_provider_setup(hInst); - break; - case DLL_PROCESS_DETACH: - entropy_provider_cleanup(); - break; - } - return TRUE; -} diff --git a/beecrypt/win32/beecrypt.rc b/beecrypt/win32/beecrypt.rc deleted file mode 100644 index 527420543..000000000 --- a/beecrypt/win32/beecrypt.rc +++ /dev/null @@ -1,31 +0,0 @@ -#include <winver.h> - -1 VERSIONINFO - FILEVERSION 1,0,0,0 - PRODUCTVERSION 1,0,0,0 - FILEFLAGSMASK VS_FFI_FILEFLAGSMASK - FILEFLAGS 0x0L - FILEOS VOS__WINDOWS32 - FILETYPE VFT_DLL - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" /* U.S. English; Unicode */ - BEGIN - VALUE "CompanyName", "Virtual Unlimited B.V.\0" - VALUE "FileDescription", "BeeCrypt Cryptography Library\0" - VALUE "FileVersion", "1.0.0\0" - VALUE "InternalName", "beecrypt\0" - VALUE "LegalCopyright", "Copyright (c) 1997-2000 Virtual Unlimited B.V.\0" - VALUE "LegalTradeMarks", "BeeCrypt is a trademark of Virtual Unlimited B.V.\0" - VALUE "OriginalFileName", "BEECRYPT.DLL\0" - VALUE "ProductName", "BeeCrypt\0" - VALUE "ProductVersion", "1.0.0\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END diff --git a/beecrypt/win32/config.win.h b/beecrypt/win32/config.win.h deleted file mode 100644 index bd6c934a3..000000000 --- a/beecrypt/win32/config.win.h +++ /dev/null @@ -1,162 +0,0 @@ -/* - * config.win.h - * - * Win32 config file - * - * Copyright (c) 2000, Virtual Unlimited B.V. - * - * Author: Bob Deblier <bob@virtualunlimited.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifndef _CONFIG_WIN_H -#define _CONFIG_WIN_H - -#define _REENTRANT - -#if __INTEL__ -#define WORDS_BIGENDIAN 0 -#else -#error Trying to compile for WIN32 on non-Intel hardware -#endif - -#if __MWERKS__ -#define HAVE_ERRNO_H 1 -#define HAVE_STRING_H 1 -#define HAVE_STDLIB_H 1 -#define HAVE_CTYPE_H 1 -#define HAVE_UNISTD_H 1 -#define HAVE_FCNTL_H 1 -#define HAVE_TIME_H 1 - -#define HAVE_SYS_TYPES_H 0 -#define HAVE_SYS_STAT_H 0 -#define HAVE_SYS_TIME_H 0 - -#define HAVE_THREAD_H 0 -#define HAVE_PTHREAD_H 0 -#define HAVE_SYNCH_H 0 - -#define HAVE_TERMIO_H 0 -#define HAVE_SYS_AUDIOIO_H 0 -#define HAVE_SYS_IOCTL_H 0 -#define HAVE_SYS_SOUNDCARD_H 0 - -#define HAVE_GETTIMEOFDAY 0 -#define HAVE_GETHRTIME 0 - -#define HAVE_DEV_TTY 0 -#define HAVE_DEV_AUDIO 0 -#define HAVE_DEV_DSP 0 -#define HAVE_DEV_RANDOM 0 - -#define SIZEOF_CHAR 1 -#define SIZEOF_UNSIGNED_CHAR 1 -#define SIZEOF_SHORT 2 -#define SIZEOF_UNSIGNED_SHORT 2 -#define SIZEOF_INT 4 -#define SIZEOF_UNSIGNED_INT 4 -#define SIZEOF_LONG 4 -#define SIZEOF_UNSIGNED_LONG 4 -#define SIZEOF_LONG_LONG 8 -#define SIZEOF_UNSIGNED_LONG_LONG 8 - -#define SIZEOF_FLOAT 4 -#define SIZEOF_DOUBLE 8 -#else -#error Not set up for this compiler -#endif - -#if (SIZEOF_CHAR == 1) -typedef char int8; -typedef char javabyte; -#else -#error sizeof(char) not 1 -#endif - -#if (SIZEOF_SHORT == 2) -typedef short int16; -typedef short javashort; -#else -#error sizeof(short) is not 2 -#endif - -#if (SIZEOF_INT == 4) -typedef int int32; -typedef int javaint; -#elif (SIZEOF_LONG == 4) -typedef int int32; -typedef long javaint; -#else -#error compiler has no 32 bit integer -#endif - -#if (SIZEOF_LONG == 8) -typedef long int64; -typedef long javalong; -#elif (SIZEOF_LONG_LONG == 8) -typedef long long int64; -typedef long long javalong; -#else -#error compiler has no 64 bit integer -#endif - -#if (SIZEOF_FLOAT == 4) -typedef float javafloat; -#else -#error compiler has no 32 bit float -#endif - -#if (SIZEOF_DOUBLE == 8) -typedef double javadouble; -#else -#error compiler has no 64 bit double; -#endif - -#if (SIZEOF_UNSIGNED_CHAR == 1) -typedef unsigned char uint8; -#else -#error sizeof(unsigned char) is not 1 -#endif - -#if (SIZEOF_UNSIGNED_SHORT == 2) -typedef unsigned short uint16; -typedef unsigned short javachar; -typedef unsigned short unicode; -#else -#error sizeof(unsigned short) is not 2 -#endif - -#if (SIZEOF_UNSIGNED_INT == 4) -typedef unsigned int uint32; -#elif (SIZEOF_UNSIGNED_LONG == 4) -typedef unsigned long uint32; -#else -#error compiler has no 32 bit unsigned integer -#endif - -#if (SIZEOF_UNSIGNED_LONG == 8) -typedef unsigned long uint64; -#elif (SIZEOF_UNSIGNED_LONG_LONG == 8) -typedef unsigned long long uint64; -#else -#error compiler has no 64 bit unsigned integer -#endif - -/* typedef uint8 byte */ - -#endif diff --git a/beecrypt/win32/masm/blowfishopt.i586.asm b/beecrypt/win32/masm/blowfishopt.i586.asm deleted file mode 100644 index 16cb1616b..000000000 --- a/beecrypt/win32/masm/blowfishopt.i586.asm +++ /dev/null @@ -1,180 +0,0 @@ -; -; blowfishopt.i586.asm -; -; Assembler optimized blowfish routines for Intel Pentium processors -; -; Compile target is Microsoft Macro Assembler -; -; Copyright (c) 2000 Virtual Unlimited B.V. -; -; Author: Bob Deblier <bob@virtualunlimited.com> -; -; This library is free software; you can redistribute it and/or -; modify it under the terms of the GNU Lesser General Public -; License as published by the Free Software Foundation; either -; version 2.1 of the License, or (at your option) any later version. -; -; This library is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -; Lesser General Public License for more details. -; -; You should have received a copy of the GNU Lesser General Public -; License along with this library; if not, write to the Free Software -; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -; - - .586 - .model flat,C - - .code - -etworounds macro offset - xor ecx,dword ptr [esi+offset] - rol ecx,16 - mov al,ch - mov bl,cl - rol ecx,16 - mov edi,dword ptr [esi+eax*4+72+0000h] - add edi,dword ptr [esi+ebx*4+72+0400h] - mov al,ch - mov bl,cl - xor edi,dword ptr [esi+eax*4+72+0800h] - add edi,dword ptr [esi+ebx*4+72+0C00h] - xor edx,edi - xor edx,dword ptr [esi+offset+4] - rol edx,16 - mov al,dh - mov bl,dl - rol edx,16 - mov edi,dword ptr [esi+eax*4+72+0000h] - add edi,dword ptr [esi+ebx*4+72+0400h] - mov al,dh - mov bl,dl - xor edi,dword ptr [esi+eax*4+72+0800h] - add edi,dword ptr [esi+ebx*4+72+0C00h] - xor ecx,edi - endm - -dtworounds macro offset - xor ecx,dword ptr [esi+offset+4] - rol ecx,16 - mov al,ch - mov bl,cl - rol ecx,16 - mov edi,dword ptr [esi+eax*4+72+0000h] - add edi,dword ptr [esi+ebx*4+72+0400h] - mov al,ch - mov bl,cl - xor edi,dword ptr [esi+eax*4+72+0800h] - add edi,dword ptr [esi+ebx*4+72+0C00h] - xor edx,edi - xor edx,dword ptr [esi+offset] - rol edx,16 - mov al,dh - mov bl,dl - rol edx,16 - mov edi,dword ptr [esi+eax*4+72+0000h] - add edi,dword ptr [esi+ebx*4+72+0400h] - mov al,dh - mov bl,dl - xor edi,dword ptr [esi+eax*4+72+0800h] - add edi,dword ptr [esi+ebx*4+72+0C00h] - xor ecx,edi - endm - - - align 8 - -blowfishEncrypt proc - push edi - push esi - push ebx - - mov esi,dword ptr [esp+16] - mov edi,dword ptr [esp+24] - - xor eax,eax - xor ebx,ebx - - mov ecx,dword ptr [edi] - mov edx,dword ptr [edi+4] - - bswap ecx - bswap edx - - etworounds 0 - etworounds 8 - etworounds 16 - etworounds 24 - etworounds 32 - etworounds 40 - etworounds 48 - etworounds 56 - - mov edi,dword ptr [esp+20] - xor ecx,dword ptr [esi+64] - xor edx,dword ptr [esi+68] - - bswap ecx - bswap edx - - mov dword ptr [edi+4],ecx - mov dword ptr [edi],edx - - xor eax,eax - - pop ebx - pop esi - pop edi - ret -blowfishEncrypt endp - - - align 8 - -blowfishDecrypt proc - push edi - push esi - push ebx - - mov esi,dword ptr [esp+16] - mov edi,dword ptr [esp+24] - - xor eax,eax - xor ebx,ebx - - mov ecx,dword ptr [edi] - mov edx,dword ptr [edi+4] - - bswap ecx - bswap edx - - dtworounds 64 - dtworounds 56 - dtworounds 48 - dtworounds 40 - dtworounds 32 - dtworounds 24 - dtworounds 16 - dtworounds 8 - - mov edi,dword ptr [esp+20] - xor ecx,dword ptr [esi+4] - xor edx,dword ptr [esi] - - bswap ecx - bswap edx - - mov dword ptr [edi+4],ecx - mov dword ptr [edi],edx - - xor eax,eax - - pop ebx - pop esi - pop edi - ret -blowfishDecrypt endp - - end diff --git a/beecrypt/win32/masm/fips180opt.i586.asm b/beecrypt/win32/masm/fips180opt.i586.asm deleted file mode 100644 index 7c5eadac7..000000000 --- a/beecrypt/win32/masm/fips180opt.i586.asm +++ /dev/null @@ -1,298 +0,0 @@ -; -; fips180opt.i586.asm -; -; Assembler optimized SHA-1 routines for Intel Pentium processors -; -; Compile target is Microsoft Macro Assembler -; -; Copyright (c) 2000 Virtual Unlimited B.V. -; -; Author: Bob Deblier <bob@virtualunlimited.com> -; -; This library is free software; you can redistribute it and/or -; modify it under the terms of the GNU Lesser General Public -; License as published by the Free Software Foundation; either -; version 2.1 of the License, or (at your option) any later version. -; -; This library is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -; Lesser General Public License for more details. -; -; You should have received a copy of the GNU Lesser General Public -; License along with this library; if not, write to the Free Software -; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -; - - .586 - .model flat,C - -K00 equ 5a827999h -K20 equ 6ed9eba1h -K40 equ 8f1bbcdch -K60 equ 0ca62c1d6h - -PARAM_H equ 0 -PARAM_DATA equ 20 -PARAM_OFFSET equ 352 - - .code - -subround1 macro b,c,d,e,w - mov ecx,c - mov ebx,b - mov edx,d - rol eax,5 - xor ecx,edx - add eax,e - and ecx,ebx - add eax,K00 - ror ebx,2 - add eax,w - xor ecx,edx - mov b,ebx - add eax,ecx - mov e,eax - endm - -subround2 macro b,c,d,e,w - mov ecx,c - mov ebx,b - rol eax,5 - xor ecx,ebx - add eax,e - xor ecx,d - add eax,K20 - ror ebx,2 - add eax,w - mov b,ebx - add eax,ecx - mov e,eax - endm - -subround3 macro b,c,d,e,w - mov ecx,c - rol eax,5 - mov ebx,b - mov edx,ecx - add eax,e - or ecx,ebx - and edx,ebx - and ecx,d - add eax,K40 - or ecx,edx - add eax,w - ror ebx,2 - add eax,ecx - mov b,ebx - mov e,eax - endm - -subround4 macro b,c,d,e,w - mov ecx,c - mov ebx,b - rol eax,5 - xor ecx,ebx - add eax,e - xor ecx,d - add eax,K60 - ror ebx,2 - add eax,w - mov b,ebx - add eax,ecx - mov e,eax - endm - - - align 8 - -sha1Process proc - push edi - push esi - push ebx - push ebp - ; allocate local variables - mov esi,dword ptr [esp+20] ; esi now points to param - sub esp,20 ; esp now points below the local variables - lea edi,dword ptr [esi+PARAM_DATA] - mov ebp,esp ; ebp now points to the local variables - - mov ecx,4 -@loads: - mov edx,dword ptr [esi+ecx*4] - mov dword ptr [ebp+ecx*4],edx - dec ecx - jns @loads - - mov ecx,15 - xor eax,eax - - align 4 -@swaps: - mov edx,dword ptr [edi+ecx*4] - bswap edx - mov dword ptr [edi+ecx*4],edx - dec ecx - jns @swaps - - lea edi,dword ptr [esi+PARAM_DATA] - mov byte ptr [esi+PARAM_OFFSET],al - mov ecx,16 - - align 4 -@xors: - mov eax,dword ptr [edi+52] - mov ebx,dword ptr [edi+56] - xor eax,dword ptr [edi+32] - xor ebx,dword ptr [edi+36] - xor eax,dword ptr [edi+ 8] - xor ebx,dword ptr [edi+12] - xor eax,dword ptr [edi ] - xor ebx,dword ptr [edi+ 4] - rol eax,1 - rol ebx,1 - mov dword ptr [edi+64],eax - mov dword ptr [edi+68],ebx - mov eax,dword ptr [edi+60] - mov ebx,dword ptr [edi+64] - xor eax,dword ptr [edi+40] - xor ebx,dword ptr [edi+44] - xor eax,dword ptr [edi+16] - xor ebx,dword ptr [edi+20] - xor eax,dword ptr [edi+ 8] - xor ebx,dword ptr [edi+12] - rol eax,1 - rol ebx,1 - mov dword ptr [edi+72],eax - mov dword ptr [edi+76],ebx - add edi,16 - dec ecx - jnz @xors - - mov edi,PARAM_DATA - - ; to optimize further, use esi only, and store the add constant into edi - ; will make code smaller and faster - -@round01to20: - mov eax,dword ptr [ebp] - subround1 dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround1 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround1 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround1 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround1 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - add edi,20 - subround1 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround1 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround1 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround1 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround1 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - add edi,20 - subround1 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround1 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround1 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround1 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround1 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - add edi,20 - subround1 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround1 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround1 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround1 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround1 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - add edi,20 - -@round21to40: - subround2 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround2 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround2 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround2 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround2 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - add edi,20 - subround2 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround2 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround2 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround2 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround2 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - add edi,20 - subround2 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround2 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround2 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround2 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround2 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - add edi,20 - subround2 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround2 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround2 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround2 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround2 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - add edi,20 - -@round41to60: - subround3 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround3 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround3 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround3 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround3 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - add edi,20 - subround3 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround3 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround3 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround3 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround3 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - add edi,20 - subround3 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround3 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround3 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround3 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround3 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - add edi,20 - subround3 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround3 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround3 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround3 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround3 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - add edi,20 - -@round61to80: - subround4 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround4 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround4 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround4 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround4 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - add edi,20 - subround4 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround4 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround4 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround4 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround4 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - add edi,20 - subround4 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround4 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround4 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround4 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround4 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - add edi,20 - subround4 dword ptr [ebp+4 ], ebx, dword ptr [ebp+12], dword ptr [ebp+16], dword ptr [esi+edi] - subround4 dword ptr [ebp ], ebx, dword ptr [ebp+8 ], dword ptr [ebp+12], dword ptr [esi+edi+4 ] - subround4 dword ptr [ebp+16], ebx, dword ptr [ebp+4 ], dword ptr [ebp+8 ], dword ptr [esi+edi+8 ] - subround4 dword ptr [ebp+12], ebx, dword ptr [ebp ], dword ptr [ebp+4 ], dword ptr [esi+edi+12] - subround4 dword ptr [ebp+8 ], ebx, dword ptr [ebp+16], dword ptr [ebp ], dword ptr [esi+edi+16] - ; add edi,20 - - mov ecx,4 - -@adds: - mov eax,dword ptr [ebp+ecx*4] - add dword ptr [esi+ecx*4],eax - dec ecx - jns @adds - - add esp,20 - pop ebp - pop ebx - pop esi - pop edi - ret -sha1Process endp - - end diff --git a/beecrypt/win32/masm/mp32opt.i386.asm b/beecrypt/win32/masm/mp32opt.i386.asm deleted file mode 100644 index 61e305432..000000000 --- a/beecrypt/win32/masm/mp32opt.i386.asm +++ /dev/null @@ -1,287 +0,0 @@ -; -; mp32opt.i386.asm -; -; Assembler optimized multiprecision integer routines for Intel 386 -; -; Compile target is Microsoft Macro Assembler -; -; Copyright (c) 1998-2000 Virtual Unlimited B.V. -; -; Author: Bob Deblier <bob@virtualunlimited.com> -; -; This library is free software; you can redistribute it and/or -; modify it under the terms of the GNU Lesser General Public -; License as published by the Free Software Foundation; either -; version 2.1 of the License, or (at your option) any later version. -; -; This library is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -; Lesser General Public License for more details. -; -; You should have received a copy of the GNU Lesser General Public -; License along with this library; if not, write to the Free Software -; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -; - - .586 - .model flat,C - - .code - - align 8 - -mp32addw proc - push edi - - mov ecx,dword ptr [esp+8] - mov edi,dword ptr [esp+12] - mov eax,dword ptr [esp+16] - - lea edi,dword ptr [edi+ecx*4-4] - add dword ptr [edi],eax - dec ecx - jz @addw_end - sub edi,4 - xor edx,edx - - align 4 -@addw_loop: - adc dword ptr [edi],edx - sub edi,4 - dec ecx - jnz @addw_loop -@addw_end: - sbb eax,eax - neg eax - - pop edi - ret -mp32addw endp - - - align 8 - -mp32subw proc - push edi - - mov ecx,dword ptr [esp+8] - mov edi,dword ptr [esp+12] - mov eax,dword ptr [esp+16] - - lea edi,dword ptr [edi+ecx*4-4] - sub dword ptr [edi],eax - dec ecx - jz @subw_end - sub edi,4 - xor edx,edx - - align 4 -@subw_loop: - sbb dword ptr [edi],edx - sub edi,4 - dec ecx - jnz @subw_loop -@subw_end: - sbb eax,eax - neg eax - - pop edi - ret -mp32subw endp - - - align 8 - -mp32add proc - push edi - push esi - - mov ecx,dword ptr [esp+12] - mov edi,dword ptr [esp+16] - mov esi,dword ptr [esp+20] - - xor edx,edx - dec ecx - -@add_loop: - mov eax,dword ptr [esi+ecx*4] - adc dword ptr [edi+ecx*4],eax - dec ecx - jns @add_loop - - sbb eax,eax - neg eax - - pop esi - pop edi - ret -mp32add endp - - align 8 - -mp32sub proc - push edi - push esi - - mov ecx,dword ptr [esp+12] - mov edi,dword ptr [esp+16] - mov esi,dword ptr [esp+20] - - xor edx,edx - dec ecx - -@sub_loop: - mov eax,dword ptr [esi+ecx*4] - sbb dword ptr [edi+ecx*4],eax - dec ecx - jns @sub_loop - - sbb eax,eax - neg eax - - pop esi - pop edi - ret -mp32sub endp - - - align 8 - -mp32multwo proc - push edi - - mov ecx,dword ptr [esp+8] - mov edi,dword ptr [esp+12] - - xor eax,eax - dec ecx - -@multwo_loop: - mov eax,dword ptr [edi+ecx*4] - adc dword ptr [edi+ecx*4],eax - dec ecx - jns @multwo_loop - - sbb eax,eax - neg eax - - pop edi - ret -mp32multwo endp - - - align 8 - -mp32setmul proc - push edi - push esi - push ebx - push ebp - - mov ecx,dword ptr [esp+20] - mov edi,dword ptr [esp+24] - mov esi,dword ptr [esp+28] - mov ebp,dword ptr [esp+32] - - xor ebx,ebx - dec ecx - - align 4 -@setmul_loop: - mov eax,dword ptr [esi+ecx*4] - mul ebp - add eax,ebx - adc edx,0 - mov dword ptr [edi+ecx*4],eax - mov ebx,edx - dec ecx - jns @setmul_loop - - mov eax,ebx - - pop ebp - pop ebx - pop esi - pop edi - ret -mp32setmul endp - - - align 8 - -mp32addmul proc - push edi - push esi - push ebx - push ebp - - mov ecx,dword ptr [esp+20] - mov edi,dword ptr [esp+24] - mov esi,dword ptr [esp+28] - mov ebp,dword ptr [esp+32] - - xor ebx,ebx - dec ecx - - align 4 -@addmul_loop: - mov eax,dword ptr [esi+ecx*4] - mul ebp - add eax,ebx - adc edx,0 - add eax,dword ptr [edi+ecx*4] - adc edx,0 - mov dword ptr [edi+ecx*4],eax - mov ebx,edx - dec ecx - jns @addmul_loop - - mov eax,ebx - - pop ebp - pop ebx - pop esi - pop edi - ret -mp32addmul endp - - - align 8 - -mp32addsqrtrc proc - push edi - push esi - push ebx - - mov ecx,dword ptr [esp+16] - mov edi,dword ptr [esp+20] - mov esi,dword ptr [esp+24] - - xor ebx,ebx - dec ecx - - align 4 -@addsqrtrc_loop: - mov eax,dword ptr [esi+ecx*4] - mul eax - add eax,ebx - adc edx,0 - add eax,dword ptr [edi+ecx*8+4] - adc edx,dword ptr [edi+ecx*8+0] - sbb ebx,ebx - mov dword ptr [edi+ecx*8+4],eax - mov dword ptr [edi+ecx*8+0],edx - neg ebx - dec ecx - jns @addsqrtrc_loop - - mov eax,ebx - - pop ebx - pop esi - pop edi - ret -mp32addsqrtrc endp - - end diff --git a/beecrypt/win32/mwerks/beecrypt.pch b/beecrypt/win32/mwerks/beecrypt.pch deleted file mode 100644 index 286d5ef4b..000000000 --- a/beecrypt/win32/mwerks/beecrypt.pch +++ /dev/null @@ -1,5 +0,0 @@ -#include <Win32Headers.mch> - -#pragma precompile_target "beecrypt.mch" - -#define HAVE_CONFIG_H
\ No newline at end of file diff --git a/beecrypt/win32/mwerks/blowfishopt.i586.asm b/beecrypt/win32/mwerks/blowfishopt.i586.asm deleted file mode 100644 index 673214119..000000000 --- a/beecrypt/win32/mwerks/blowfishopt.i586.asm +++ /dev/null @@ -1,173 +0,0 @@ -# -# blowfishopt.i586.asm -# -# Assembler optimized blowfish routines for Intel Pentium processors -# -# Compile target is Metrowerks CodeWarrior Pro 5 for Windows -# -# Copyright (c) 2000 Virtual Unlimited B.V. -# -# Author: Bob Deblier <bob@virtualunlimited.com> -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# - -etworounds: .macro p - xor ecx,[esi+p] - rol ecx,16 - mov al,ch - mov bl,cl - rol ecx,16 - mov edi,[esi+eax*4+72+0x000] - add edi,[esi+ebx*4+72+0x400] - mov al,ch - mov bl,cl - xor edi,[esi+eax*4+72+0x800] - add edi,[esi+ebx*4+72+0xC00] - xor edx,edi - xor edx,[esi+p+4] - rol edx,16 - mov al,dh - mov bl,dl - rol edx,16 - mov edi,[esi+eax*4+72+0x000] - add edi,[esi+ebx*4+72+0x400] - mov al,dh - mov bl,dl - xor edi,[esi+eax*4+72+0x800] - add edi,[esi+ebx*4+72+0xC00] - xor ecx,edi - .endm - -dtworounds: .macro p - xor ecx,[esi+p+4] - rol ecx,16 - mov al,ch - mov bl,cl - rol ecx,16 - mov edi,[esi+eax*4+72+0x000] - add edi,[esi+ebx*4+72+0x400] - mov al,ch - mov bl,cl - xor edi,[esi+eax*4+72+0x800] - add edi,[esi+ebx*4+72+0xC00] - xor edx,edi - xor edx,[esi+p] - rol edx,16 - mov al,dh - mov bl,dl - rol edx,16 - mov edi,[esi+eax*4+72+0x000] - add edi,[esi+ebx*4+72+0x400] - mov al,dh - mov bl,dl - xor edi,[esi+eax*4+72+0x800] - add edi,[esi+ebx*4+72+0xC00] - xor ecx,edi - .endm - - .text - - .align 4 - .globl _blowfishEncrypt - -_blowfishEncrypt: - push edi - push esi - push ebx - - mov esi,[esp+16] - mov edi,[esp+20] - - xor eax,eax - xor ebx,ebx - - mov ecx,[edi] - mov edx,[edi+4] - - bswap ecx - bswap edx - - etworounds 0 - etworounds 8 - etworounds 16 - etworounds 24 - etworounds 32 - etworounds 40 - etworounds 48 - etworounds 56 - - mov edi,[esp+20] - xor ecx,[esi+64] - xor edx,[esi+68] - - bswap ecx - bswap edx - - mov [edi+4],ecx - mov [edi],edx - - xor eax,eax - - pop ebx - pop esi - pop edi - ret - - .align 4 - .globl _blowfishDecrypt - -_blowfishDecrypt: - push edi - push esi - push ebx - - mov esi,[esp+16] - mov edi,[esp+20] - - xor eax,eax - xor ebx,ebx - - mov ecx,[edi] - mov edx,[edi+4] - - bswap ecx - bswap edx - - dtworounds 64 - dtworounds 56 - dtworounds 48 - dtworounds 40 - dtworounds 32 - dtworounds 24 - dtworounds 16 - dtworounds 8 - - mov edi,[esp+20] - xor ecx,[esi+4] - xor edx,[esi] - - bswap ecx - bswap edx - - mov [edi+4],ecx - mov [edi],edx - - xor eax,eax - - pop ebx - pop esi - pop edi - ret diff --git a/beecrypt/win32/mwerks/fips180opt.i586.asm b/beecrypt/win32/mwerks/fips180opt.i586.asm deleted file mode 100644 index a87ac462d..000000000 --- a/beecrypt/win32/mwerks/fips180opt.i586.asm +++ /dev/null @@ -1,291 +0,0 @@ -# -# fips180opt.i586.asm -# -# Assembler optimized SHA-1 routines for Intel Pentium processors -# -# Compile target is Metrowerks CodeWarrior Pro 5 for Windows -# -# Copyright (c) 2000 Virtual Unlimited B.V. -# -# Author: Bob Deblier <bob@virtualunlimited.com> -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# - -K00 .equ 0x5a827999 -K20 .equ 0x6ed9eba1 -K40 .equ 0x8f1bbcdc -K60 .equ 0xca62c1d6 - -PARAM_H .equ 0 -PARAM_DATA .equ 20 -PARAM_OFFSET .equ 352 - -subround1: .macro b,c,d,e,w - mov ecx,c - mov ebx,b - mov edx,d - rol eax,5 - xor ecx,edx - add eax,e - and ecx,ebx - add eax,K00 - ror ebx,2 - add eax,w - xor ecx,edx - mov b,ebx - add eax,ecx - mov e,eax - .endm - -subround2: .macro b,c,d,e,w - mov ecx,c - mov ebx,b - rol eax,5 - xor ecx,ebx - add eax,e - xor ecx,d - add eax,K20 - ror ebx,2 - add eax,w - mov b,ebx - add eax,ecx - mov e,eax - .endm - -subround3: .macro b,c,d,e,w - mov ecx,c - rol eax,5 - mov ebx,b - mov edx,ecx - add eax,e - or ecx,ebx # (b|c) - and edx,ebx # (b&c) - and ecx,d # (b|c)&d - add eax,K40 - or ecx,edx - add eax,w - ror ebx,2 - add eax,ecx - mov b,ebx - mov e,eax - .endm - -subround4: .macro b,c,d,e,w - mov ecx,c - mov ebx,b - rol eax,5 - xor ecx,ebx - add eax,e - xor ecx,d - add eax,K60 - ror ebx,2 - add eax,w - mov b,ebx - add eax,ecx - mov e,eax - .endm - - .text - - .align 4 - .globl _sha1Process - -_sha1Process: - push edi - push esi - push ebx - # allocate local variables - push ebp - lea ebp,[esp-24] - - mov esi,[esp+20] - lea edi,[esi+PARAM_DATA] - - mov ecx,4 -@loads: - mov edx,[esi+ecx*4] - mov [ebp+ecx*4],edx - dec ecx - jns @loads - - mov ecx,15 - xor eax,eax - - .align 4 -@swaps: - mov edx,[edi+ecx*4] - bswap edx - mov [edi+ecx*4],edx - dec ecx - jns @swaps - - lea edi,[esi+PARAM_DATA] - mov [esi+PARAM_OFFSET],al - mov ecx,16 - - .align 4 -@xors: - mov eax,[edi+52] - mov ebx,[edi+56] - xor eax,[edi+32] - xor ebx,[edi+36] - xor eax,[edi+ 8] - xor ebx,[edi+12] - xor eax,[edi ] - xor ebx,[edi+ 4] - rol eax,1 - rol ebx,1 - mov [edi+64],eax - mov [edi+68],ebx - mov eax,[edi+60] - mov ebx,[edi+64] - xor eax,[edi+40] - xor ebx,[edi+44] - xor eax,[edi+16] - xor ebx,[edi+20] - xor eax,[edi+ 8] - xor ebx,[edi+12] - rol eax,1 - rol ebx,1 - mov [edi+72],eax - mov [edi+76],ebx - add edi,16 - dec ecx - jnz @xors - - mov edi,PARAM_DATA - - # to optimize further, use esi only, and store the add constant into edi - # will make code smaller and faster - -@round01to20: - mov eax,[ebp] - subround1 [ebp+4],[ebp+8],[ebp+12],[ebp+16],[esi+edi] - subround1 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] - subround1 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] - subround1 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] - subround1 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] - add edi,20 - subround1 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] - subround1 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] - subround1 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] - subround1 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] - subround1 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] - add edi,20 - subround1 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] - subround1 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] - subround1 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] - subround1 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] - subround1 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] - add edi,20 - subround1 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] - subround1 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] - subround1 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] - subround1 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] - subround1 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] - add edi,20 - -@round21to40: - subround2 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] - subround2 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] - subround2 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] - subround2 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] - subround2 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] - add edi,20 - subround2 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] - subround2 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] - subround2 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] - subround2 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] - subround2 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] - add edi,20 - subround2 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] - subround2 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] - subround2 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] - subround2 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] - subround2 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] - add edi,20 - subround2 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] - subround2 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] - subround2 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] - subround2 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] - subround2 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] - add edi,20 - -@round41to60: - subround3 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] - subround3 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] - subround3 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] - subround3 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] - subround3 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] - add edi,20 - subround3 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] - subround3 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] - subround3 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] - subround3 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] - subround3 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] - add edi,20 - subround3 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] - subround3 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] - subround3 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] - subround3 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] - subround3 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] - add edi,20 - subround3 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] - subround3 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] - subround3 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] - subround3 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] - subround3 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] - add edi,20 - -@round61to80: - subround4 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] - subround4 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] - subround4 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] - subround4 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] - subround4 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] - add edi,20 - subround4 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] - subround4 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] - subround4 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] - subround4 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] - subround4 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] - add edi,20 - subround4 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] - subround4 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] - subround4 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] - subround4 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] - subround4 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] - add edi,20 - subround4 [ebp+4],ebx,[ebp+12],[ebp+16],[esi+edi] - subround4 [ebp],ebx,[ebp+8],[ebp+12],[esi+edi+4] - subround4 [ebp+16],ebx,[ebp+4],[ebp+8],[esi+edi+8] - subround4 [ebp+12],ebx,[ebp],[ebp+4],[esi+edi+12] - subround4 [ebp+8],ebx,[ebp+16],[ebp],[esi+edi+16] - # add edi,20 - - mov ecx,4 - -@adds: - mov eax,[ebp+ecx*4] - add [esi+ecx*4],eax - dec ecx - jns @adds - - pop ebp - pop ebx - pop esi - pop edi - ret diff --git a/beecrypt/win32/mwerks/mp32opt.i386.asm b/beecrypt/win32/mwerks/mp32opt.i386.asm deleted file mode 100644 index f43d75938..000000000 --- a/beecrypt/win32/mwerks/mp32opt.i386.asm +++ /dev/null @@ -1,275 +0,0 @@ -# -# mp32opt.i386.asm -# -# Assembler optimized multiprecision integer routines for Intel 386 -# -# Compile target is MetroWerks CodeWarrior Pro 5 for Windows -# -# Copyright (c) 1998-2000 Virtual Unlimited B.V. -# -# Author: Bob Deblier <bob@virtualunlimited.com> -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# - - .text - - .align 4 - .globl _mp32addw - -_mp32addw: - push edi - - mov ecx,[esp+8] - mov edi,[esp+12] - mov eax,[esp+16] - - lea edi,[edi+ecx*4-4] - add [edi],eax - dec ecx - jz @addw_end - sub edi,4 - xor edx,edx - -@addw_loop: - adc [edi],edx - sub edi,4 - dec ecx - jnz @addw_loop -@addw_end: - sbb eax,eax - neg eax - - pop edi - ret - - .align 4 - .globl _mp32subw - -_mp32subw: - push edi - - mov ecx,[esp+8] - mov edi,[esp+12] - mov eax,[esp+16] - - lea edi,[edi+ecx*4-4] - sub [edi],eax - dec ecx - jz @subw_end - sub edi,4 - xor edx,edx - -@subw_loop: - sbb [edi],edx - sub edi,4 - dec ecx - jnz @subw_loop -@subw_end: - sbb eax,eax - neg eax - - pop edi - ret - - .align 4 - .globl _mp32add - -_mp32add: - push edi - push esi - - mov ecx,[esp+12] - mov edi,[esp+16] - mov esi,[esp+20] - - xor edx,edx - dec ecx - -@add_loop: - mov eax,[esi+ecx*4] - adc [edi+ecx*4],eax - dec ecx - jns @add_loop - - sbb eax,eax - neg eax - - pop esi - pop edi - ret - - .align 4 - .globl _mp32sub - -_mp32sub: - push edi - push esi - - mov ecx,[esp+12] - mov edi,[esp+16] - mov esi,[esp+20] - - xor edx,edx - dec ecx - -@sub_loop: - mov eax,[esi+ecx*4] - sbb [edi+ecx*4],eax - dec ecx - jns @sub_loop - - sbb eax,eax - neg eax - - pop esi - pop edi - ret - - .align 4 - .globl _mp32multwo - -_mp32multwo: - push edi - - mov ecx,[esp+8] - mov edi,[esp+12] - - xor eax,eax - dec ecx - -@multwo_loop: - mov eax,[edi+ecx*4] - adc [edi+ecx*4],eax - dec ecx - jns @multwo_loop - - sbb eax,eax - neg eax - - pop edi - ret - - .align 4 - .globl _mp32setmul - -_mp32setmul: - push edi - push esi - push ebx - push ebp - - mov ecx,[esp+20] - mov edi,[esp+24] - mov esi,[esp+28] - mov ebp,[esp+32] - - xor ebx,ebx - dec ecx - - .align 4 -@setmul_loop: - mov eax,[esi+ecx*4] - mul ebp - add eax,ebx - adc edx,0 - mov [edi+ecx*4],eax - mov ebx,edx - dec ecx - jns @setmul_loop - - mov eax,ebx - - pop ebp - pop ebx - pop esi - pop edi - ret - - - .align 4 - .globl _mp32addmul - -_mp32addmul: - push edi - push esi - push ebx - push ebp - - mov ecx,[esp+20] - mov edi,[esp+24] - mov esi,[esp+28] - mov ebp,[esp+32] - - xor ebx,ebx - dec ecx - - .align 4 -@addmul_loop: - mov eax,[esi+ecx*4] - mul ebp - add eax,ebx - adc edx,0 - add eax,[edi+ecx*4] - adc edx,0 - mov [edi+ecx*4],eax - mov ebx,edx - dec ecx - jns @addmul_loop - - mov eax,ebx - - pop ebp - pop ebx - pop esi - pop edi - ret - - .align 4 - .globl _mp32addsqrtrc - -_mp32addsqrtrc: - push edi - push esi - push ebx - - mov ecx,[esp+16] - mov edi,[esp+20] - mov esi,[esp+24] - - xor ebx,ebx - dec ecx - - .align 4 -@addsqrtrc_loop: - mov eax,[esi+ecx*4] - mul eax - add eax,ebx - adc edx,0 - add eax,[edi+ecx*8+4] - adc edx,[edi+ecx*8+0] - sbb ebx,ebx - mov [edi+ecx*8+4],eax - mov [edi+ecx*8+0],edx - neg ebx - dec ecx - jns @addsqrtrc_loop - - mov eax,ebx - - pop ebx - pop esi - pop edi - ret
\ No newline at end of file |