home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 January
/
usenetsourcesnewsgroupsinfomagicjanuary1994.iso
/
sources
/
misc
/
volume40
/
libdes
/
part01
next >
Wrap
Internet Message Format
|
1993-10-14
|
55KB
From: eay@psych.psy.uq.oz.au (Eric Young)
Newsgroups: comp.sources.misc
Subject: v40i008: libdes - DES encryption library, Part01/05
Date: 14 Oct 1993 18:01:32 +0100
Sender: aem@aber.ac.uk
Approved: aem@aber.ac.uk
Message-ID: <csm-v40i008=libdes.180015@aber.ac.uk>
X-Md4-Signature: 49ac6bff40da3fad404d82f113000118
Submitted-by: eay@psych.psy.uq.oz.au (Eric Young)
Posting-number: Volume 40, Issue 8
Archive-name: libdes/part01
Environment: C
Supersedes: libdes: Volume 29, Issue 43-46
This kit builds a DES encryption library and a DES encryption program.
It suports ecb, cbc, ofb, cfb, triple ecb, triple cbc and MIT's pcbc
encryption modes and also has a fast implementation of crypt(3).
It contains support routines to read keys from a terminal,
generate a random key, generate a key from an arbitary length string,
read/write encrypted data from/to a file descriptor.
The implementation was written so as to conform with the manual entry
for the des_crypt(3) library routines from MIT's project Athena.
destest should be run after compilation to test the des routines.
rpw should be run after compilation to test the read password routines.
The des program is a replacement for the sun des command. I believe it
conforms to the sun version.
The Imakefile is setup for use in the kerberos distribution.
These routines are best compiled with gcc or any other good
optimising compiler.
Just turn you optimiser up to the highest settings and run destest
after the build to make sure everything works.
I believe these routines are close to the fastest and most portable DES
routines that use small lookup tables (4.5k) that are publicly available.
The fcrypt routine is faster than ufc's fcrypt (when compiling with
gcc2 -O2) on the sparc 2 (1410 vs 1270) but is not so good on other machines
(on a sun3/260 168 vs 336).
Eric Young (eay@psych.psy.uq.oz.au)
--
#! /bin/sh
# into a shell via "sh file" or similar. To overwrite existing files,
# type "sh file -c".
# The tool that generated this appeared in the comp.sources.unix newsgroup;
# send mail to comp-sources-unix@uunet.uu.net if you want that tool.
# Contents: README MANIFEST COPYING des.pl enc_writ.c
# Wrapped by alecm@uk-usenet on Wed Oct 13 10:33:48 1993
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
echo If this archive is complete, you will see the following message:
echo ' "shar: End of archive 1 (of 5)."'
if test -f 'README' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(2419 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
X
X libdes, Version 3.00 93/10/07
X
X Copyright (c) 1993, Eric Young
X All rights reserved.
X
X This program is free software; you can redistribute it and/or modify
X it under the terms of either:
X
X a) the GNU General Public License as published by the Free
X Software Foundation; either version 1, or (at your option) any
X later version, or
X
X b) the "Artistic License" which comes with this Kit.
X
X This program is distributed in the hope that it will be useful,
X but WITHOUT ANY WARRANTY; without even the implied warranty of
X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either
X the GNU General Public License or the Artistic License for more details.
X
X You should have received a copy of the Artistic License with this
X Kit, in the file named "Artistic". If not, I'll be glad to provide one.
X
X You should also have received a copy of the GNU General Public License
X along with this program; if not, write to the Free Software
X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X---
XThis kit builds a DES encryption library and a DES encryption program.
XIt suports ecb, cbc, ofb, cfb, triple ecb, triple cbc and MIT's pcbc
Xencryption modes and also has a fast implementation of crypt(3).
XIt contains support routines to read keys from a terminal,
Xgenerate a random key, generate a key from an arbitary length string,
Xread/write encrypted data from/to a file descriptor.
X
XThe implementation was written so as to conform with the manual entry
Xfor the des_crypt(3) library routines from MIT's project Athena.
X
Xdestest should be run after compilation to test the des routines.
Xrpw should be run after compilation to test the read password routines.
XThe des program is a replacement for the sun des command. I believe it
Xconforms to the sun version.
X
XThe Imakefile is setup for use in the kerberos distribution.
X
XThese routines are best compiled with gcc or any other good
Xoptimising compiler.
XJust turn you optimiser up to the highest settings and run destest
Xafter the build to make sure everything works.
X
XI believe these routines are close to the fastest and most portable DES
Xroutines that use small lookup tables (4.5k) that are publicly available.
XThe fcrypt routine is faster than ufc's fcrypt (when compiling with
Xgcc2 -O2) on the sparc 2 (1410 vs 1270) but is not so good on other machines
X(on a sun3/260 168 vs 336).
X
XEric Young (eay@psych.psy.uq.oz.au)
END_OF_FILE
if test 2419 -ne `wc -c <'README'`; then
echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'MANIFEST' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'MANIFEST'\"
else
echo shar: Extracting \"'MANIFEST'\" \(1565 characters\)
sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
X File Name Archive # Description
X----------------------------------------------------------
XREADME 1
XMANIFEST 1
X3cbc_enc.c 5
X3ecb_enc.c 5
XARTISTIC 4
XCHANGES 5
XCOPYING 1
XFILES 4
XINSTALL 5
XImakefile 5
XKERBEROS 5
XMODES.DES 4
XPC1 5
XPC2 5
XVERSION 3
Xcbc_cksm.c 3
Xcbc_enc.c 5
Xcfb_enc.c 5
Xdes.c 2
Xdes.h 4
Xdes.man 4
Xdes.pl 1
Xdes_crypt.man 3
Xdes_locl.h 3
Xdestest.c 2
XdoIP 5
XdoPC1 5
XdoPC2 2
Xecb_enc.c 4
Xenc_read.c 4
Xenc_writ.c 1
Xfcrypt.c 2
Xmakefile 4
Xofb_enc.c 5
Xpcbc_enc.c 4
Xpodd.h 5
Xqud_cksm.c 5
Xrand_key.c 5
Xread_pwd.c 3
Xrpw.c 5
Xset_key.c 4
Xshifts.pl 5
Xsk.h 3
Xspeed.c 4
Xspr.h 3
Xstr2key.c 4
Xtestdes.pl 3
Xtimes 4
Xvms.com 4
END_OF_FILE
if test 1565 -ne `wc -c <'MANIFEST'`; then
echo shar: \"'MANIFEST'\" unpacked with wrong size!
fi
# end of 'MANIFEST'
fi
if test -f 'COPYING' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'COPYING'\"
else
echo shar: Extracting \"'COPYING'\" \(25510 characters\)
sed "s/^X//" >'COPYING' <<'END_OF_FILE'
XCopyright (C) 1993 Eric Young
X
XThis is a DES implementation written by Eric Young (eay@psych.psy.uq.oz.au)
XThe implementation was written so as to conform with the manual entry
Xfor the des_crypt(3) library routines from MIT's project Athena.
X
X
X
X GNU LIBRARY GENERAL PUBLIC LICENSE
X Version 2, June 1991
X
X Copyright (C) 1991 Free Software Foundation, Inc.
X 675 Mass Ave, Cambridge, MA 02139, USA
X Everyone is permitted to copy and distribute verbatim copies
X of this license document, but changing it is not allowed.
X
X[This is the first released version of the library GPL. It is
X numbered 2 because it goes with version 2 of the ordinary GPL.]
X
X Preamble
X
X The licenses for most software are designed to take away your
Xfreedom to share and change it. By contrast, the GNU General Public
XLicenses are intended to guarantee your freedom to share and change
Xfree software--to make sure the software is free for all its users.
X
X This license, the Library General Public License, applies to some
Xspecially designated Free Software Foundation software, and to any
Xother libraries whose authors decide to use it. You can use it for
Xyour libraries, too.
X
X When we speak of free software, we are referring to freedom, not
Xprice. Our General Public Licenses are designed to make sure that you
Xhave the freedom to distribute copies of free software (and charge for
Xthis service if you wish), that you receive source code or can get it
Xif you want it, that you can change the software or use pieces of it
Xin new free programs; and that you know you can do these things.
X
X To protect your rights, we need to make restrictions that forbid
Xanyone to deny you these rights or to ask you to surrender the rights.
XThese restrictions translate to certain responsibilities for you if
Xyou distribute copies of the library, or if you modify it.
X
X For example, if you distribute copies of the library, whether gratis
Xor for a fee, you must give the recipients all the rights that we gave
Xyou. You must make sure that they, too, receive or can get the source
Xcode. If you link a program with the library, you must provide
Xcomplete object files to the recipients so that they can relink them
Xwith the library, after making changes to the library and recompiling
Xit. And you must show them these terms so they know their rights.
X
X Our method of protecting your rights has two steps: (1) copyright
Xthe library, and (2) offer you this license which gives you legal
Xpermission to copy, distribute and/or modify the library.
X
X Also, for each distributor's protection, we want to make certain
Xthat everyone understands that there is no warranty for this free
Xlibrary. If the library is modified by someone else and passed on, we
Xwant its recipients to know that what they have is not the original
Xversion, so that any problems introduced by others will not reflect on
Xthe original authors' reputations.
X
X Finally, any free program is threatened constantly by software
Xpatents. We wish to avoid the danger that companies distributing free
Xsoftware will individually obtain patent licenses, thus in effect
Xtransforming the program into proprietary software. To prevent this,
Xwe have made it clear that any patent must be licensed for everyone's
Xfree use or not licensed at all.
X
X Most GNU software, including some libraries, is covered by the ordinary
XGNU General Public License, which was designed for utility programs. This
Xlicense, the GNU Library General Public License, applies to certain
Xdesignated libraries. This license is quite different from the ordinary
Xone; be sure to read it in full, and don't assume that anything in it is
Xthe same as in the ordinary license.
X
X The reason we have a separate public license for some libraries is that
Xthey blur the distinction we usually make between modifying or adding to a
Xprogram and simply using it. Linking a program with a library, without
Xchanging the library, is in some sense simply using the library, and is
Xanalogous to running a utility program or application program. However, in
Xa textual and legal sense, the linked executable is a combined work, a
Xderivative of the original library, and the ordinary General Public License
Xtreats it as such.
X
X Because of this blurred distinction, using the ordinary General
XPublic License for libraries did not effectively promote software
Xsharing, because most developers did not use the libraries. We
Xconcluded that weaker conditions might promote sharing better.
X
X However, unrestricted linking of non-free programs would deprive the
Xusers of those programs of all benefit from the free status of the
Xlibraries themselves. This Library General Public License is intended to
Xpermit developers of non-free programs to use free libraries, while
Xpreserving your freedom as a user of such programs to change the free
Xlibraries that are incorporated in them. (We have not seen how to achieve
Xthis as regards changes in header files, but we have achieved it as regards
Xchanges in the actual functions of the Library.) The hope is that this
Xwill lead to faster development of free libraries.
X
X The precise terms and conditions for copying, distribution and
Xmodification follow. Pay close attention to the difference between a
X"work based on the library" and a "work that uses the library". The
Xformer contains code derived from the library, while the latter only
Xworks together with the library.
X
X Note that it is possible for a library to be covered by the ordinary
XGeneral Public License rather than by this special one.
X
X GNU LIBRARY GENERAL PUBLIC LICENSE
X TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
X
X 0. This License Agreement applies to any software library which
Xcontains a notice placed by the copyright holder or other authorized
Xparty saying it may be distributed under the terms of this Library
XGeneral Public License (also called "this License"). Each licensee is
Xaddressed as "you".
X
X A "library" means a collection of software functions and/or data
Xprepared so as to be conveniently linked with application programs
X(which use some of those functions and data) to form executables.
X
X The "Library", below, refers to any such software library or work
Xwhich has been distributed under these terms. A "work based on the
XLibrary" means either the Library or any derivative work under
Xcopyright law: that is to say, a work containing the Library or a
Xportion of it, either verbatim or with modifications and/or translated
Xstraightforwardly into another language. (Hereinafter, translation is
Xincluded without limitation in the term "modification".)
X
X "Source code" for a work means the preferred form of the work for
Xmaking modifications to it. For a library, complete source code means
Xall the source code for all modules it contains, plus any associated
Xinterface definition files, plus the scripts used to control compilation
Xand installation of the library.
X
X Activities other than copying, distribution and modification are not
Xcovered by this License; they are outside its scope. The act of
Xrunning a program using the Library is not restricted, and output from
Xsuch a program is covered only if its contents constitute a work based
Xon the Library (independent of the use of the Library in a tool for
Xwriting it). Whether that is true depends on what the Library does
Xand what the program that uses the Library does.
X
X 1. You may copy and distribute verbatim copies of the Library's
Xcomplete source code as you receive it, in any medium, provided that
Xyou conspicuously and appropriately publish on each copy an
Xappropriate copyright notice and disclaimer of warranty; keep intact
Xall the notices that refer to this License and to the absence of any
Xwarranty; and distribute a copy of this License along with the
XLibrary.
X
X You may charge a fee for the physical act of transferring a copy,
Xand you may at your option offer warranty protection in exchange for a
Xfee.
X
X 2. You may modify your copy or copies of the Library or any portion
Xof it, thus forming a work based on the Library, and copy and
Xdistribute such modifications or work under the terms of Section 1
Xabove, provided that you also meet all of these conditions:
X
X a) The modified work must itself be a software library.
X
X b) You must cause the files modified to carry prominent notices
X stating that you changed the files and the date of any change.
X
X c) You must cause the whole of the work to be licensed at no
X charge to all third parties under the terms of this License.
X
X d) If a facility in the modified Library refers to a function or a
X table of data to be supplied by an application program that uses
X the facility, other than as an argument passed when the facility
X is invoked, then you must make a good faith effort to ensure that,
X in the event an application does not supply such function or
X table, the facility still operates, and performs whatever part of
X its purpose remains meaningful.
X
X (For example, a function in a library to compute square roots has
X a purpose that is entirely well-defined independent of the
X application. Therefore, Subsection 2d requires that any
X application-supplied function or table used by this function must
X be optional: if the application does not supply it, the square
X root function must still compute square roots.)
X
XThese requirements apply to the modified work as a whole. If
Xidentifiable sections of that work are not derived from the Library,
Xand can be reasonably considered independent and separate works in
Xthemselves, then this License, and its terms, do not apply to those
Xsections when you distribute them as separate works. But when you
Xdistribute the same sections as part of a whole which is a work based
Xon the Library, the distribution of the whole must be on the terms of
Xthis License, whose permissions for other licensees extend to the
Xentire whole, and thus to each and every part regardless of who wrote
Xit.
X
XThus, it is not the intent of this section to claim rights or contest
Xyour rights to work written entirely by you; rather, the intent is to
Xexercise the right to control the distribution of derivative or
Xcollective works based on the Library.
X
XIn addition, mere aggregation of another work not based on the Library
Xwith the Library (or with a work based on the Library) on a volume of
Xa storage or distribution medium does not bring the other work under
Xthe scope of this License.
X
X 3. You may opt to apply the terms of the ordinary GNU General Public
XLicense instead of this License to a given copy of the Library. To do
Xthis, you must alter all the notices that refer to this License, so
Xthat they refer to the ordinary GNU General Public License, version 2,
Xinstead of to this License. (If a newer version than version 2 of the
Xordinary GNU General Public License has appeared, then you can specify
Xthat version instead if you wish.) Do not make any other change in
Xthese notices.
X
X Once this change is made in a given copy, it is irreversible for
Xthat copy, so the ordinary GNU General Public License applies to all
Xsubsequent copies and derivative works made from that copy.
X
X This option is useful when you wish to copy part of the code of
Xthe Library into a program that is not a library.
X
X 4. You may copy and distribute the Library (or a portion or
Xderivative of it, under Section 2) in object code or executable form
Xunder the terms of Sections 1 and 2 above provided that you accompany
Xit with the complete corresponding machine-readable source code, which
Xmust be distributed under the terms of Sections 1 and 2 above on a
Xmedium customarily used for software interchange.
X
X If distribution of object code is made by offering access to copy
Xfrom a designated place, then offering equivalent access to copy the
Xsource code from the same place satisfies the requirement to
Xdistribute the source code, even though third parties are not
Xcompelled to copy the source along with the object code.
X
X 5. A program that contains no derivative of any portion of the
XLibrary, but is designed to work with the Library by being compiled or
Xlinked with it, is called a "work that uses the Library". Such a
Xwork, in isolation, is not a derivative work of the Library, and
Xtherefore falls outside the scope of this License.
X
X However, linking a "work that uses the Library" with the Library
Xcreates an executable that is a derivative of the Library (because it
Xcontains portions of the Library), rather than a "work that uses the
Xlibrary". The executable is therefore covered by this License.
XSection 6 states terms for distribution of such executables.
X
X When a "work that uses the Library" uses material from a header file
Xthat is part of the Library, the object code for the work may be a
Xderivative work of the Library even though the source code is not.
XWhether this is true is especially significant if the work can be
Xlinked without the Library, or if the work is itself a library. The
Xthreshold for this to be true is not precisely defined by law.
X
X If such an object file uses only numerical parameters, data
Xstructure layouts and accessors, and small macros and small inline
Xfunctions (ten lines or less in length), then the use of the object
Xfile is unrestricted, regardless of whether it is legally a derivative
Xwork. (Executables containing this object code plus portions of the
XLibrary will still fall under Section 6.)
X
X Otherwise, if the work is a derivative of the Library, you may
Xdistribute the object code for the work under the terms of Section 6.
XAny executables containing that work also fall under Section 6,
Xwhether or not they are linked directly with the Library itself.
X
X 6. As an exception to the Sections above, you may also compile or
Xlink a "work that uses the Library" with the Library to produce a
Xwork containing portions of the Library, and distribute that work
Xunder terms of your choice, provided that the terms permit
Xmodification of the work for the customer's own use and reverse
Xengineering for debugging such modifications.
X
X You must give prominent notice with each copy of the work that the
XLibrary is used in it and that the Library and its use are covered by
Xthis License. You must supply a copy of this License. If the work
Xduring execution displays copyright notices, you must include the
Xcopyright notice for the Library among them, as well as a reference
Xdirecting the user to the copy of this License. Also, you must do one
Xof these things:
X
X a) Accompany the work with the complete corresponding
X machine-readable source code for the Library including whatever
X changes were used in the work (which must be distributed under
X Sections 1 and 2 above); and, if the work is an executable linked
X with the Library, with the complete machine-readable "work that
X uses the Library", as object code and/or source code, so that the
X user can modify the Library and then relink to produce a modified
X executable containing the modified Library. (It is understood
X that the user who changes the contents of definitions files in the
X Library will not necessarily be able to recompile the application
X to use the modified definitions.)
X
X b) Accompany the work with a written offer, valid for at
X least three years, to give the same user the materials
X specified in Subsection 6a, above, for a charge no more
X than the cost of performing this distribution.
X
X c) If distribution of the work is made by offering access to copy
X from a designated place, offer equivalent access to copy the above
X specified materials from the same place.
X
X d) Verify that the user has already received a copy of these
X materials or that you have already sent this user a copy.
X
X For an executable, the required form of the "work that uses the
XLibrary" must include any data and utility programs needed for
Xreproducing the executable from it. However, as a special exception,
Xthe source code distributed need not include anything that is normally
Xdistributed (in either source or binary form) with the major
Xcomponents (compiler, kernel, and so on) of the operating system on
Xwhich the executable runs, unless that component itself accompanies
Xthe executable.
X
X It may happen that this requirement contradicts the license
Xrestrictions of other proprietary libraries that do not normally
Xaccompany the operating system. Such a contradiction means you cannot
Xuse both them and the Library together in an executable that you
Xdistribute.
X
X 7. You may place library facilities that are a work based on the
XLibrary side-by-side in a single library together with other library
Xfacilities not covered by this License, and distribute such a combined
Xlibrary, provided that the separate distribution of the work based on
Xthe Library and of the other library facilities is otherwise
Xpermitted, and provided that you do these two things:
X
X a) Accompany the combined library with a copy of the same work
X based on the Library, uncombined with any other library
X facilities. This must be distributed under the terms of the
X Sections above.
X
X b) Give prominent notice with the combined library of the fact
X that part of it is a work based on the Library, and explaining
X where to find the accompanying uncombined form of the same work.
X
X 8. You may not copy, modify, sublicense, link with, or distribute
Xthe Library except as expressly provided under this License. Any
Xattempt otherwise to copy, modify, sublicense, link with, or
Xdistribute the Library is void, and will automatically terminate your
Xrights under this License. However, parties who have received copies,
Xor rights, from you under this License will not have their licenses
Xterminated so long as such parties remain in full compliance.
X
X 9. You are not required to accept this License, since you have not
Xsigned it. However, nothing else grants you permission to modify or
Xdistribute the Library or its derivative works. These actions are
Xprohibited by law if you do not accept this License. Therefore, by
Xmodifying or distributing the Library (or any work based on the
XLibrary), you indicate your acceptance of this License to do so, and
Xall its terms and conditions for copying, distributing or modifying
Xthe Library or works based on it.
X
X 10. Each time you redistribute the Library (or any work based on the
XLibrary), the recipient automatically receives a license from the
Xoriginal licensor to copy, distribute, link with or modify the Library
Xsubject to these terms and conditions. You may not impose any further
Xrestrictions on the recipients' exercise of the rights granted herein.
XYou are not responsible for enforcing compliance by third parties to
Xthis License.
X
X 11. If, as a consequence of a court judgment or allegation of patent
Xinfringement or for any other reason (not limited to patent issues),
Xconditions are imposed on you (whether by court order, agreement or
Xotherwise) that contradict the conditions of this License, they do not
Xexcuse you from the conditions of this License. If you cannot
Xdistribute so as to satisfy simultaneously your obligations under this
XLicense and any other pertinent obligations, then as a consequence you
Xmay not distribute the Library at all. For example, if a patent
Xlicense would not permit royalty-free redistribution of the Library by
Xall those who receive copies directly or indirectly through you, then
Xthe only way you could satisfy both it and this License would be to
Xrefrain entirely from distribution of the Library.
X
XIf any portion of this section is held invalid or unenforceable under any
Xparticular circumstance, the balance of the section is intended to apply,
Xand the section as a whole is intended to apply in other circumstances.
X
XIt is not the purpose of this section to induce you to infringe any
Xpatents or other property right claims or to contest validity of any
Xsuch claims; this section has the sole purpose of protecting the
Xintegrity of the free software distribution system which is
Ximplemented by public license practices. Many people have made
Xgenerous contributions to the wide range of software distributed
Xthrough that system in reliance on consistent application of that
Xsystem; it is up to the author/donor to decide if he or she is willing
Xto distribute software through any other system and a licensee cannot
Ximpose that choice.
X
XThis section is intended to make thoroughly clear what is believed to
Xbe a consequence of the rest of this License.
X
X 12. If the distribution and/or use of the Library is restricted in
Xcertain countries either by patents or by copyrighted interfaces, the
Xoriginal copyright holder who places the Library under this License may add
Xan explicit geographical distribution limitation excluding those countries,
Xso that distribution is permitted only in or among countries not thus
Xexcluded. In such case, this License incorporates the limitation as if
Xwritten in the body of this License.
X
X 13. The Free Software Foundation may publish revised and/or new
Xversions of the Library General Public License from time to time.
XSuch new versions will be similar in spirit to the present version,
Xbut may differ in detail to address new problems or concerns.
X
XEach version is given a distinguishing version number. If the Library
Xspecifies a version number of this License which applies to it and
X"any later version", you have the option of following the terms and
Xconditions either of that version or of any later version published by
Xthe Free Software Foundation. If the Library does not specify a
Xlicense version number, you may choose any version ever published by
Xthe Free Software Foundation.
X
X 14. If you wish to incorporate parts of the Library into other free
Xprograms whose distribution conditions are incompatible with these,
Xwrite to the author to ask for permission. For software which is
Xcopyrighted by the Free Software Foundation, write to the Free
XSoftware Foundation; we sometimes make exceptions for this. Our
Xdecision will be guided by the two goals of preserving the free status
Xof all derivatives of our free software and of promoting the sharing
Xand reuse of software generally.
X
X NO WARRANTY
X
X 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
XWARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
XEXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
XOTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
XKIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
XIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
XPURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
XLIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
XTHE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
X
X 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
XWRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
XAND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
XFOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
XCONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
XLIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
XRENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
XFAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
XSUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
XDAMAGES.
X
X END OF TERMS AND CONDITIONS
X
X Appendix: How to Apply These Terms to Your New Libraries
X
X If you develop a new library, and you want it to be of the greatest
Xpossible use to the public, we recommend making it free software that
Xeveryone can redistribute and change. You can do so by permitting
Xredistribution under these terms (or, alternatively, under the terms of the
Xordinary General Public License).
X
X To apply these terms, attach the following notices to the library. It is
Xsafest to attach them to the start of each source file to most effectively
Xconvey the exclusion of warranty; and each file should have at least the
X"copyright" line and a pointer to where the full notice is found.
X
X <one line to give the library's name and a brief idea of what it does.>
X Copyright (C) <year> <name of author>
X
X This library is free software; you can redistribute it and/or
X modify it under the terms of the GNU Library General Public
X License as published by the Free Software Foundation; either
X version 2 of the License, or (at your option) any later version.
X
X This library is distributed in the hope that it will be useful,
X but WITHOUT ANY WARRANTY; without even the implied warranty of
X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
X Library General Public License for more details.
X
X You should have received a copy of the GNU Library General Public
X License along with this library; if not, write to the Free
X Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X
XAlso add information on how to contact you by electronic and paper mail.
X
XYou should also get your employer (if you work as a programmer) or your
Xschool, if any, to sign a "copyright disclaimer" for the library, if
Xnecessary. Here is a sample; alter the names:
X
X Yoyodyne, Inc., hereby disclaims all copyright interest in the
X library `Frob' (a library for tweaking knobs) written by James Random Hacker.
X
X <signature of Ty Coon>, 1 April 1990
X Ty Coon, President of Vice
X
XThat's all there is to it!
END_OF_FILE
if test 25510 -ne `wc -c <'COPYING'`; then
echo shar: \"'COPYING'\" unpacked with wrong size!
fi
# end of 'COPYING'
fi
if test -f 'des.pl' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'des.pl'\"
else
echo shar: Extracting \"'des.pl'\" \(17839 characters\)
sed "s/^X//" >'des.pl' <<'END_OF_FILE'
X#!/usr/local/bin/perl
X# Copyright (C) 1993 Eric Young
X# des.pl - eric young 22/11/1991 eay@psych.psy.uq.oz.au
X# eay - 92/08/31 - I think I have fixed all problems for 64bit
X# versions of perl but I could be wrong since I have not tested it yet :-).
X#
X# This is an implementation of DES in perl.
X# The two routines (des_set_key and des_ecb_encrypt)
X# take 8 byte objects as arguments.
X#
X# des_set_key takes an 8 byte string as a key and returns a key schedule
X# for use in calls to des_ecb_encrypt.
X# des_ecb_encrypt takes three arguments, the first is a key schedule
X# (make sure to pass it by reference with the *), the second is 1
X# to encrypt, 0 to decrypt. The third argument is an 8 byte object
X# to encrypt. The function returns an 8 byte object that has been
X# DES encrypted.
X#
X# example:
X# require 'des.pl'
X#
X# $key =pack("C8",0x12,0x23,0x45,0x67,0x89,0xab,0xcd,0xef);
X# @ks= &des_set_key($key);
X#
X# $outbytes= &des_ecb_encrypt(*ks,1,$data);
X# @enc =unpack("C8",$outbytes);
X#
X
Xpackage des;
X
X# The following 8 arrays are used in des_set_key
X@skb0=(
X# for C bits (numbered as per FIPS 46) 1 2 3 4 5 6
X0x00000000,0x00000010,0x20000000,0x20000010,
X0x00010000,0x00010010,0x20010000,0x20010010,
X0x00000800,0x00000810,0x20000800,0x20000810,
X0x00010800,0x00010810,0x20010800,0x20010810,
X0x00000020,0x00000030,0x20000020,0x20000030,
X0x00010020,0x00010030,0x20010020,0x20010030,
X0x00000820,0x00000830,0x20000820,0x20000830,
X0x00010820,0x00010830,0x20010820,0x20010830,
X0x00080000,0x00080010,0x20080000,0x20080010,
X0x00090000,0x00090010,0x20090000,0x20090010,
X0x00080800,0x00080810,0x20080800,0x20080810,
X0x00090800,0x00090810,0x20090800,0x20090810,
X0x00080020,0x00080030,0x20080020,0x20080030,
X0x00090020,0x00090030,0x20090020,0x20090030,
X0x00080820,0x00080830,0x20080820,0x20080830,
X0x00090820,0x00090830,0x20090820,0x20090830,
X);
X@skb1=(
X# for C bits (numbered as per FIPS 46) 7 8 10 11 12 13
X0x00000000,0x02000000,0x00002000,0x02002000,
X0x00200000,0x02200000,0x00202000,0x02202000,
X0x00000004,0x02000004,0x00002004,0x02002004,
X0x00200004,0x02200004,0x00202004,0x02202004,
X0x00000400,0x02000400,0x00002400,0x02002400,
X0x00200400,0x02200400,0x00202400,0x02202400,
X0x00000404,0x02000404,0x00002404,0x02002404,
X0x00200404,0x02200404,0x00202404,0x02202404,
X0x10000000,0x12000000,0x10002000,0x12002000,
X0x10200000,0x12200000,0x10202000,0x12202000,
X0x10000004,0x12000004,0x10002004,0x12002004,
X0x10200004,0x12200004,0x10202004,0x12202004,
X0x10000400,0x12000400,0x10002400,0x12002400,
X0x10200400,0x12200400,0x10202400,0x12202400,
X0x10000404,0x12000404,0x10002404,0x12002404,
X0x10200404,0x12200404,0x10202404,0x12202404,
X);
X@skb2=(
X# for C bits (numbered as per FIPS 46) 14 15 16 17 19 20
X0x00000000,0x00000001,0x00040000,0x00040001,
X0x01000000,0x01000001,0x01040000,0x01040001,
X0x00000002,0x00000003,0x00040002,0x00040003,
X0x01000002,0x01000003,0x01040002,0x01040003,
X0x00000200,0x00000201,0x00040200,0x00040201,
X0x01000200,0x01000201,0x01040200,0x01040201,
X0x00000202,0x00000203,0x00040202,0x00040203,
X0x01000202,0x01000203,0x01040202,0x01040203,
X0x08000000,0x08000001,0x08040000,0x08040001,
X0x09000000,0x09000001,0x09040000,0x09040001,
X0x08000002,0x08000003,0x08040002,0x08040003,
X0x09000002,0x09000003,0x09040002,0x09040003,
X0x08000200,0x08000201,0x08040200,0x08040201,
X0x09000200,0x09000201,0x09040200,0x09040201,
X0x08000202,0x08000203,0x08040202,0x08040203,
X0x09000202,0x09000203,0x09040202,0x09040203,
X);
X@skb3=(
X# for C bits (numbered as per FIPS 46) 21 23 24 26 27 28
X0x00000000,0x00100000,0x00000100,0x00100100,
X0x00000008,0x00100008,0x00000108,0x00100108,
X0x00001000,0x00101000,0x00001100,0x00101100,
X0x00001008,0x00101008,0x00001108,0x00101108,
X0x04000000,0x04100000,0x04000100,0x04100100,
X0x04000008,0x04100008,0x04000108,0x04100108,
X0x04001000,0x04101000,0x04001100,0x04101100,
X0x04001008,0x04101008,0x04001108,0x04101108,
X0x00020000,0x00120000,0x00020100,0x00120100,
X0x00020008,0x00120008,0x00020108,0x00120108,
X0x00021000,0x00121000,0x00021100,0x00121100,
X0x00021008,0x00121008,0x00021108,0x00121108,
X0x04020000,0x04120000,0x04020100,0x04120100,
X0x04020008,0x04120008,0x04020108,0x04120108,
X0x04021000,0x04121000,0x04021100,0x04121100,
X0x04021008,0x04121008,0x04021108,0x04121108,
X);
X@skb4=(
X# for D bits (numbered as per FIPS 46) 1 2 3 4 5 6
X0x00000000,0x10000000,0x00010000,0x10010000,
X0x00000004,0x10000004,0x00010004,0x10010004,
X0x20000000,0x30000000,0x20010000,0x30010000,
X0x20000004,0x30000004,0x20010004,0x30010004,
X0x00100000,0x10100000,0x00110000,0x10110000,
X0x00100004,0x10100004,0x00110004,0x10110004,
X0x20100000,0x30100000,0x20110000,0x30110000,
X0x20100004,0x30100004,0x20110004,0x30110004,
X0x00001000,0x10001000,0x00011000,0x10011000,
X0x00001004,0x10001004,0x00011004,0x10011004,
X0x20001000,0x30001000,0x20011000,0x30011000,
X0x20001004,0x30001004,0x20011004,0x30011004,
X0x00101000,0x10101000,0x00111000,0x10111000,
X0x00101004,0x10101004,0x00111004,0x10111004,
X0x20101000,0x30101000,0x20111000,0x30111000,
X0x20101004,0x30101004,0x20111004,0x30111004,
X);
X@skb5=(
X# for D bits (numbered as per FIPS 46) 8 9 11 12 13 14
X0x00000000,0x08000000,0x00000008,0x08000008,
X0x00000400,0x08000400,0x00000408,0x08000408,
X0x00020000,0x08020000,0x00020008,0x08020008,
X0x00020400,0x08020400,0x00020408,0x08020408,
X0x00000001,0x08000001,0x00000009,0x08000009,
X0x00000401,0x08000401,0x00000409,0x08000409,
X0x00020001,0x08020001,0x00020009,0x08020009,
X0x00020401,0x08020401,0x00020409,0x08020409,
X0x02000000,0x0A000000,0x02000008,0x0A000008,
X0x02000400,0x0A000400,0x02000408,0x0A000408,
X0x02020000,0x0A020000,0x02020008,0x0A020008,
X0x02020400,0x0A020400,0x02020408,0x0A020408,
X0x02000001,0x0A000001,0x02000009,0x0A000009,
X0x02000401,0x0A000401,0x02000409,0x0A000409,
X0x02020001,0x0A020001,0x02020009,0x0A020009,
X0x02020401,0x0A020401,0x02020409,0x0A020409,
X);
X@skb6=(
X# for D bits (numbered as per FIPS 46) 16 17 18 19 20 21
X0x00000000,0x00000100,0x00080000,0x00080100,
X0x01000000,0x01000100,0x01080000,0x01080100,
X0x00000010,0x00000110,0x00080010,0x00080110,
X0x01000010,0x01000110,0x01080010,0x01080110,
X0x00200000,0x00200100,0x00280000,0x00280100,
X0x01200000,0x01200100,0x01280000,0x01280100,
X0x00200010,0x00200110,0x00280010,0x00280110,
X0x01200010,0x01200110,0x01280010,0x01280110,
X0x00000200,0x00000300,0x00080200,0x00080300,
X0x01000200,0x01000300,0x01080200,0x01080300,
X0x00000210,0x00000310,0x00080210,0x00080310,
X0x01000210,0x01000310,0x01080210,0x01080310,
X0x00200200,0x00200300,0x00280200,0x00280300,
X0x01200200,0x01200300,0x01280200,0x01280300,
X0x00200210,0x00200310,0x00280210,0x00280310,
X0x01200210,0x01200310,0x01280210,0x01280310,
X);
X@skb7=(
X# for D bits (numbered as per FIPS 46) 22 23 24 25 27 28
X0x00000000,0x04000000,0x00040000,0x04040000,
X0x00000002,0x04000002,0x00040002,0x04040002,
X0x00002000,0x04002000,0x00042000,0x04042000,
X0x00002002,0x04002002,0x00042002,0x04042002,
X0x00000020,0x04000020,0x00040020,0x04040020,
X0x00000022,0x04000022,0x00040022,0x04040022,
X0x00002020,0x04002020,0x00042020,0x04042020,
X0x00002022,0x04002022,0x00042022,0x04042022,
X0x00000800,0x04000800,0x00040800,0x04040800,
X0x00000802,0x04000802,0x00040802,0x04040802,
X0x00002800,0x04002800,0x00042800,0x04042800,
X0x00002802,0x04002802,0x00042802,0x04042802,
X0x00000820,0x04000820,0x00040820,0x04040820,
X0x00000822,0x04000822,0x00040822,0x04040822,
X0x00002820,0x04002820,0x00042820,0x04042820,
X0x00002822,0x04002822,0x00042822,0x04042822,
X);
X
X@shifts2=(0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0);
X
X# used in ecb_encrypt
X@SP0=(
X0x00410100, 0x00010000, 0x40400000, 0x40410100,
X0x00400000, 0x40010100, 0x40010000, 0x40400000,
X0x40010100, 0x00410100, 0x00410000, 0x40000100,
X0x40400100, 0x00400000, 0x00000000, 0x40010000,
X0x00010000, 0x40000000, 0x00400100, 0x00010100,
X0x40410100, 0x00410000, 0x40000100, 0x00400100,
X0x40000000, 0x00000100, 0x00010100, 0x40410000,
X0x00000100, 0x40400100, 0x40410000, 0x00000000,
X0x00000000, 0x40410100, 0x00400100, 0x40010000,
X0x00410100, 0x00010000, 0x40000100, 0x00400100,
X0x40410000, 0x00000100, 0x00010100, 0x40400000,
X0x40010100, 0x40000000, 0x40400000, 0x00410000,
X0x40410100, 0x00010100, 0x00410000, 0x40400100,
X0x00400000, 0x40000100, 0x40010000, 0x00000000,
X0x00010000, 0x00400000, 0x40400100, 0x00410100,
X0x40000000, 0x40410000, 0x00000100, 0x40010100,
X);
X@SP1=(
X0x08021002, 0x00000000, 0x00021000, 0x08020000,
X0x08000002, 0x00001002, 0x08001000, 0x00021000,
X0x00001000, 0x08020002, 0x00000002, 0x08001000,
X0x00020002, 0x08021000, 0x08020000, 0x00000002,
X0x00020000, 0x08001002, 0x08020002, 0x00001000,
X0x00021002, 0x08000000, 0x00000000, 0x00020002,
X0x08001002, 0x00021002, 0x08021000, 0x08000002,
X0x08000000, 0x00020000, 0x00001002, 0x08021002,
X0x00020002, 0x08021000, 0x08001000, 0x00021002,
X0x08021002, 0x00020002, 0x08000002, 0x00000000,
X0x08000000, 0x00001002, 0x00020000, 0x08020002,
X0x00001000, 0x08000000, 0x00021002, 0x08001002,
X0x08021000, 0x00001000, 0x00000000, 0x08000002,
X0x00000002, 0x08021002, 0x00021000, 0x08020000,
X0x08020002, 0x00020000, 0x00001002, 0x08001000,
X0x08001002, 0x00000002, 0x08020000, 0x00021000,
X);
X@SP2=(
X0x20800000, 0x00808020, 0x00000020, 0x20800020,
X0x20008000, 0x00800000, 0x20800020, 0x00008020,
X0x00800020, 0x00008000, 0x00808000, 0x20000000,
X0x20808020, 0x20000020, 0x20000000, 0x20808000,
X0x00000000, 0x20008000, 0x00808020, 0x00000020,
X0x20000020, 0x20808020, 0x00008000, 0x20800000,
X0x20808000, 0x00800020, 0x20008020, 0x00808000,
X0x00008020, 0x00000000, 0x00800000, 0x20008020,
X0x00808020, 0x00000020, 0x20000000, 0x00008000,
X0x20000020, 0x20008000, 0x00808000, 0x20800020,
X0x00000000, 0x00808020, 0x00008020, 0x20808000,
X0x20008000, 0x00800000, 0x20808020, 0x20000000,
X0x20008020, 0x20800000, 0x00800000, 0x20808020,
X0x00008000, 0x00800020, 0x20800020, 0x00008020,
X0x00800020, 0x00000000, 0x20808000, 0x20000020,
X0x20800000, 0x20008020, 0x00000020, 0x00808000,
X);
X@SP3=(
X0x00080201, 0x02000200, 0x00000001, 0x02080201,
X0x00000000, 0x02080000, 0x02000201, 0x00080001,
X0x02080200, 0x02000001, 0x02000000, 0x00000201,
X0x02000001, 0x00080201, 0x00080000, 0x02000000,
X0x02080001, 0x00080200, 0x00000200, 0x00000001,
X0x00080200, 0x02000201, 0x02080000, 0x00000200,
X0x00000201, 0x00000000, 0x00080001, 0x02080200,
X0x02000200, 0x02080001, 0x02080201, 0x00080000,
X0x02080001, 0x00000201, 0x00080000, 0x02000001,
X0x00080200, 0x02000200, 0x00000001, 0x02080000,
X0x02000201, 0x00000000, 0x00000200, 0x00080001,
X0x00000000, 0x02080001, 0x02080200, 0x00000200,
X0x02000000, 0x02080201, 0x00080201, 0x00080000,
X0x02080201, 0x00000001, 0x02000200, 0x00080201,
X0x00080001, 0x00080200, 0x02080000, 0x02000201,
X0x00000201, 0x02000000, 0x02000001, 0x02080200,
X);
X@SP4=(
X0x01000000, 0x00002000, 0x00000080, 0x01002084,
X0x01002004, 0x01000080, 0x00002084, 0x01002000,
X0x00002000, 0x00000004, 0x01000004, 0x00002080,
X0x01000084, 0x01002004, 0x01002080, 0x00000000,
X0x00002080, 0x01000000, 0x00002004, 0x00000084,
X0x01000080, 0x00002084, 0x00000000, 0x01000004,
X0x00000004, 0x01000084, 0x01002084, 0x00002004,
X0x01002000, 0x00000080, 0x00000084, 0x01002080,
X0x01002080, 0x01000084, 0x00002004, 0x01002000,
X0x00002000, 0x00000004, 0x01000004, 0x01000080,
X0x01000000, 0x00002080, 0x01002084, 0x00000000,
X0x00002084, 0x01000000, 0x00000080, 0x00002004,
X0x01000084, 0x00000080, 0x00000000, 0x01002084,
X0x01002004, 0x01002080, 0x00000084, 0x00002000,
X0x00002080, 0x01002004, 0x01000080, 0x00000084,
X0x00000004, 0x00002084, 0x01002000, 0x01000004,
X);
X@SP5=(
X0x10000008, 0x00040008, 0x00000000, 0x10040400,
X0x00040008, 0x00000400, 0x10000408, 0x00040000,
X0x00000408, 0x10040408, 0x00040400, 0x10000000,
X0x10000400, 0x10000008, 0x10040000, 0x00040408,
X0x00040000, 0x10000408, 0x10040008, 0x00000000,
X0x00000400, 0x00000008, 0x10040400, 0x10040008,
X0x10040408, 0x10040000, 0x10000000, 0x00000408,
X0x00000008, 0x00040400, 0x00040408, 0x10000400,
X0x00000408, 0x10000000, 0x10000400, 0x00040408,
X0x10040400, 0x00040008, 0x00000000, 0x10000400,
X0x10000000, 0x00000400, 0x10040008, 0x00040000,
X0x00040008, 0x10040408, 0x00040400, 0x00000008,
X0x10040408, 0x00040400, 0x00040000, 0x10000408,
X0x10000008, 0x10040000, 0x00040408, 0x00000000,
X0x00000400, 0x10000008, 0x10000408, 0x10040400,
X0x10040000, 0x00000408, 0x00000008, 0x10040008,
X);
X@SP6=(
X0x00000800, 0x00000040, 0x00200040, 0x80200000,
X0x80200840, 0x80000800, 0x00000840, 0x00000000,
X0x00200000, 0x80200040, 0x80000040, 0x00200800,
X0x80000000, 0x00200840, 0x00200800, 0x80000040,
X0x80200040, 0x00000800, 0x80000800, 0x80200840,
X0x00000000, 0x00200040, 0x80200000, 0x00000840,
X0x80200800, 0x80000840, 0x00200840, 0x80000000,
X0x80000840, 0x80200800, 0x00000040, 0x00200000,
X0x80000840, 0x00200800, 0x80200800, 0x80000040,
X0x00000800, 0x00000040, 0x00200000, 0x80200800,
X0x80200040, 0x80000840, 0x00000840, 0x00000000,
X0x00000040, 0x80200000, 0x80000000, 0x00200040,
X0x00000000, 0x80200040, 0x00200040, 0x00000840,
X0x80000040, 0x00000800, 0x80200840, 0x00200000,
X0x00200840, 0x80000000, 0x80000800, 0x80200840,
X0x80200000, 0x00200840, 0x00200800, 0x80000800,
X);
X@SP7=(
X0x04100010, 0x04104000, 0x00004010, 0x00000000,
X0x04004000, 0x00100010, 0x04100000, 0x04104010,
X0x00000010, 0x04000000, 0x00104000, 0x00004010,
X0x00104010, 0x04004010, 0x04000010, 0x04100000,
X0x00004000, 0x00104010, 0x00100010, 0x04004000,
X0x04104010, 0x04000010, 0x00000000, 0x00104000,
X0x04000000, 0x00100000, 0x04004010, 0x04100010,
X0x00100000, 0x00004000, 0x04104000, 0x00000010,
X0x00100000, 0x00004000, 0x04000010, 0x04104010,
X0x00004010, 0x04000000, 0x00000000, 0x00104000,
X0x04100010, 0x04004010, 0x04004000, 0x00100010,
X0x04104000, 0x00000010, 0x00100010, 0x04004000,
X0x04104010, 0x00100000, 0x04100000, 0x04000010,
X0x00104000, 0x00004010, 0x04004010, 0x04100000,
X0x00000010, 0x04104000, 0x00104010, 0x00000000,
X0x04000000, 0x04100010, 0x00004000, 0x00104010,
X);
X
Xsub main'des_set_key
X {
X local($param)=@_;
X local(@key);
X local($c,$d,$i,$s,$t);
X local(@ks)=();
X
X # Get the bytes in the order we want.
X @key=unpack("C8",$param);
X
X $c= ($key[0] )|
X ($key[1]<< 8)|
X ($key[2]<<16)|
X ($key[3]<<24);
X $d= ($key[4] )|
X ($key[5]<< 8)|
X ($key[6]<<16)|
X ($key[7]<<24);
X
X &doPC1(*c,*d);
X
X for $i (@shifts2)
X {
X if ($i)
X {
X $c=($c>>2)|($c<<26);
X $d=($d>>2)|($d<<26);
X }
X else
X {
X $c=($c>>1)|($c<<27);
X $d=($d>>1)|($d<<27);
X }
X $c&=0x0fffffff;
X $d&=0x0fffffff;
X $s= $skb0[ ($c )&0x3f ]|
X $skb1[(($c>> 6)&0x03)|(($c>> 7)&0x3c)]|
X $skb2[(($c>>13)&0x0f)|(($c>>14)&0x30)]|
X $skb3[(($c>>20)&0x01)|(($c>>21)&0x06) |
X (($c>>22)&0x38)];
X $t= $skb4[ ($d )&0x3f ]|
X $skb5[(($d>> 7)&0x03)|(($d>> 8)&0x3c)]|
X $skb6[ ($d>>15)&0x3f ]|
X $skb7[(($d>>21)&0x0f)|(($d>>22)&0x30)];
X push(@ks,(($t<<16)|($s&0x0000ffff))&0xffffffff);
X $s= ($s>>16)|($t&0xffff0000) ;
X push(@ks,(($s<<4)|($s>>28))&0xffffffff);
X }
X @ks;
X }
X
Xsub doPC1
X {
X local(*a,*b)=@_;
X local($t);
X
X $t=(($b>>4)^$a)&0x0f0f0f0f;
X $b^=($t<<4); $a^=$t;
X # do $a first
X $t=(($a<<18)^$a)&0xcccc0000;
X $a=$a^$t^($t>>18);
X $t=(($a<<17)^$a)&0xaaaa0000;
X $a=$a^$t^($t>>17);
X $t=(($a<< 8)^$a)&0x00ff0000;
X $a=$a^$t^($t>> 8);
X $t=(($a<<17)^$a)&0xaaaa0000;
X $a=$a^$t^($t>>17);
X
X # now do $b
X $t=(($b<<24)^$b)&0xff000000;
X $b=$b^$t^($t>>24);
X $t=(($b<< 8)^$b)&0x00ff0000;
X $b=$b^$t^($t>> 8);
X $t=(($b<<14)^$b)&0x33330000;
X $b=$b^$t^($t>>14);
X $b=(($b&0x00aa00aa)<<7)|(($b&0x55005500)>>7)|($b&0xaa55aa55);
X $b=($b>>8)|(($a&0xf0000000)>>4);
X $a&=0x0fffffff;
X }
X
Xsub doIP
X {
X local(*a,*b)=@_;
X local($t);
X
X $t=(($b>> 4)^$a)&0x0f0f0f0f;
X $b^=($t<< 4); $a^=$t;
X $t=(($a>>16)^$b)&0x0000ffff;
X $a^=($t<<16); $b^=$t;
X $t=(($b>> 2)^$a)&0x33333333;
X $b^=($t<< 2); $a^=$t;
X $t=(($a>> 8)^$b)&0x00ff00ff;
X $a^=($t<< 8); $b^=$t;
X $t=(($b>> 1)^$a)&0x55555555;
X $b^=($t<< 1); $a^=$t;
X $t=$a;
X $a=$b&0xffffffff;
X $b=$t&0xffffffff;
X }
X
Xsub doFP
X {
X local(*a,*b)=@_;
X local($t);
X
X $t=(($b>> 1)^$a)&0x55555555;
X $b^=($t<< 1); $a^=$t;
X $t=(($a>> 8)^$b)&0x00ff00ff;
X $a^=($t<< 8); $b^=$t;
X $t=(($b>> 2)^$a)&0x33333333;
X $b^=($t<< 2); $a^=$t;
X $t=(($a>>16)^$b)&0x0000ffff;
X $a^=($t<<16); $b^=$t;
X $t=(($b>> 4)^$a)&0x0f0f0f0f;
X $b^=($t<< 4); $a^=$t;
X $a&=0xffffffff;
X $b&=0xffffffff;
X }
X
Xsub main'des_ecb_encrypt
X {
X local(*ks,$encrypt,$in)=@_;
X local($l,$r,$inc,$start,$end,$i,$t,$u,@input);
X
X @input=unpack("C8",$in);
X # Get the bytes in the order we want.
X $l= ($input[0] )|
X ($input[1]<< 8)|
X ($input[2]<<16)|
X ($input[3]<<24);
X $r= ($input[4] )|
X ($input[5]<< 8)|
X ($input[6]<<16)|
X ($input[7]<<24);
X
X $l&=0xffffffff;
X $r&=0xffffffff;
X &doIP(*l,*r);
X if ($encrypt)
X {
X for ($i=0; $i<32; $i+=4)
X {
X $t=(($r<<1)|($r>>31))&0xffffffff;
X $u=$t^$ks[$i ];
X $t=$t^$ks[$i+1];
X $t=(($t>>4)|($t<<28))&0xffffffff;
X $l^= $SP1[ $t &0x3f]|
X $SP3[($t>> 8)&0x3f]|
X $SP5[($t>>16)&0x3f]|
X $SP7[($t>>24)&0x3f]|
X $SP0[ $u &0x3f]|
X $SP2[($u>> 8)&0x3f]|
X $SP4[($u>>16)&0x3f]|
X $SP6[($u>>24)&0x3f];
X
X $t=(($l<<1)|($l>>31))&0xffffffff;
X $u=$t^$ks[$i+2];
X $t=$t^$ks[$i+3];
X $t=(($t>>4)|($t<<28))&0xffffffff;
X $r^= $SP1[ $t &0x3f]|
X $SP3[($t>> 8)&0x3f]|
X $SP5[($t>>16)&0x3f]|
X $SP7[($t>>24)&0x3f]|
X $SP0[ $u &0x3f]|
X $SP2[($u>> 8)&0x3f]|
X $SP4[($u>>16)&0x3f]|
X $SP6[($u>>24)&0x3f];
X }
X }
X else
X {
X for ($i=30; $i>0; $i-=4)
X {
X $t=(($r<<1)|($r>>31))&0xffffffff;
X $u=$t^$ks[$i ];
X $t=$t^$ks[$i+1];
X $t=(($t>>4)|($t<<28))&0xffffffff;
X $l^= $SP1[ $t &0x3f]|
X $SP3[($t>> 8)&0x3f]|
X $SP5[($t>>16)&0x3f]|
X $SP7[($t>>24)&0x3f]|
X $SP0[ $u &0x3f]|
X $SP2[($u>> 8)&0x3f]|
X $SP4[($u>>16)&0x3f]|
X $SP6[($u>>24)&0x3f];
X
X $t=(($l<<1)|($l>>31))&0xffffffff;
X $u=$t^$ks[$i-2];
X $t=$t^$ks[$i-1];
X $t=(($t>>4)|($t<<28))&0xffffffff;
X $r^= $SP1[ $t &0x3f]|
X $SP3[($t>> 8)&0x3f]|
X $SP5[($t>>16)&0x3f]|
X $SP7[($t>>24)&0x3f]|
X $SP0[ $u &0x3f]|
X $SP2[($u>> 8)&0x3f]|
X $SP4[($u>>16)&0x3f]|
X $SP6[($u>>24)&0x3f];
X }
X }
X &doFP(*l,*r);
X pack("C8",$l&0xff,$l>>8,$l>>16,$l>>24,
X $r&0xff,$r>>8,$r>>16,$r>>24);
X }
END_OF_FILE
if test 17839 -ne `wc -c <'des.pl'`; then
echo shar: \"'des.pl'\" unpacked with wrong size!
fi
# end of 'des.pl'
fi
if test -f 'enc_writ.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'enc_writ.c'\"
else
echo shar: Extracting \"'enc_writ.c'\" \(1718 characters\)
sed "s/^X//" >'enc_writ.c' <<'END_OF_FILE'
X/* enc_writ.c */
X/* Copyright (C) 1993 Eric Young - see README for more details */
X#include <errno.h>
X#include "des_locl.h"
X
Xint des_enc_write(fd,buf,len,sched,iv)
Xint fd;
Xchar *buf;
Xint len;
Xdes_key_schedule sched;
Xdes_cblock *iv;
X {
X long rnum;
X int i,j,k,outnum;
X char outbuf[BSIZE+HDRSIZE];
X char shortbuf[8];
X char *p;
X static int start=1;
X
X /* If we are sending less than 8 bytes, the same char will look
X * the same if we don't pad it out with random bytes */
X if (start)
X {
X start=0;
X srandom(time(NULL));
X }
X
X /* lets recurse if we want to send the data in small chunks */
X if (len > MAXWRITE)
X {
X j=0;
X for (i=0; i<len; i+=k)
X {
X k=des_enc_write(fd,&(buf[i]),
X ((len-i) > MAXWRITE)?MAXWRITE:(len-i),sched,iv);
X if (k < 0)
X return(k);
X else
X j+=k;
X }
X return(j);
X }
X
X /* write length first */
X p=outbuf;
X l2n(len,p);
X
X /* pad short strings */
X if (len < 8)
X {
X p=shortbuf;
X bcopy(buf,shortbuf,len);
X for (i=len; i<8; i++)
X shortbuf[i]=random();
X rnum=8;
X }
X else
X {
X p=buf;
X rnum=((len+7)/8*8); /* round up to nearest eight */
X }
X
X if (des_rw_mode & DES_PCBC_MODE)
X pcbc_encrypt((des_cblock *)p,(des_cblock *)&(outbuf[HDRSIZE]),
X (long)((len<8)?8:len),sched,iv,DES_ENCRYPT);
X else
X cbc_encrypt((des_cblock *)p,(des_cblock *)&(outbuf[HDRSIZE]),
X (long)((len<8)?8:len),sched,iv,DES_ENCRYPT);
X
X /* output */
X outnum=rnum+HDRSIZE;
X
X for (j=0; j<outnum; j+=i)
X {
X /* eay 26/08/92 I was not doing writing from where we
X * got upto. */
X i=write(fd,&(outbuf[j]),(int)(outnum-j));
X if (i == -1)
X {
X if (errno == EINTR)
X i=0;
X else /* This is really a bad error - very bad
X * It will stuff-up both ends. */
X return(-1);
X }
X }
X
X return(len);
X }
END_OF_FILE
if test 1718 -ne `wc -c <'enc_writ.c'`; then
echo shar: \"'enc_writ.c'\" unpacked with wrong size!
fi
# end of 'enc_writ.c'
fi
echo shar: End of archive 1 \(of 5\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 3 4 5 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 5 archives.
rm -f ark[1-9]isdone
else
echo You still must unpack the following archives:
echo " " ${MISSING}
fi
exit 0
exit 0 # Just in case...