From b76fa9013f57212370109086227aa77aec5ddd5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se> Date: Fri, 10 Jan 1997 03:53:16 +0100 Subject: [PATCH] *** empty log message *** Rev: src/modules/_Crypto/Makefile:1.7 Rev: src/modules/_Crypto/lib/descore/Makefile:1.1 Rev: src/modules/_Crypto/lib/descore/README:1.1 Rev: src/modules/_Crypto/lib/descore/desCode.h:1.1 Rev: src/modules/_Crypto/lib/descore/desCore.h:1.1 Rev: src/modules/_Crypto/lib/descore/desKerb.c:1.1 Rev: src/modules/_Crypto/lib/descore/desQuick.c:1.1 Rev: src/modules/_Crypto/lib/descore/desTest.c:1.1 Rev: src/modules/_Crypto/lib/descore/desUtil.c:1.1 Rev: src/modules/_Crypto/lib/descore/descore.diffs:1.1 Rev: src/modules/_Crypto/lib/descore/descore.shar.gz:1.1 Rev: src/modules/_Crypto/lib/descore/desdata.c:1.1 Rev: src/modules/_Crypto/lib/descore/desinfo.h:1.1 --- .gitattributes | 11 + src/modules/_Crypto/Makefile | 10 +- src/modules/_Crypto/lib/descore/Makefile | 146 +++++++ src/modules/_Crypto/lib/descore/README | 313 +++++++++++++ src/modules/_Crypto/lib/descore/desCode.h | 410 ++++++++++++++++++ src/modules/_Crypto/lib/descore/desCore.h | 21 + src/modules/_Crypto/lib/descore/desKerb.c | 38 ++ src/modules/_Crypto/lib/descore/desQuick.c | 52 +++ src/modules/_Crypto/lib/descore/desTest.c | 177 ++++++++ src/modules/_Crypto/lib/descore/desUtil.c | 174 ++++++++ src/modules/_Crypto/lib/descore/descore.diffs | 30 ++ .../_Crypto/lib/descore/descore.shar.gz | Bin 0 -> 18434 bytes src/modules/_Crypto/lib/descore/desdata.c | 193 +++++++++ src/modules/_Crypto/lib/descore/desinfo.h | 96 ++++ 14 files changed, 1666 insertions(+), 5 deletions(-) create mode 100644 src/modules/_Crypto/lib/descore/Makefile create mode 100644 src/modules/_Crypto/lib/descore/README create mode 100644 src/modules/_Crypto/lib/descore/desCode.h create mode 100644 src/modules/_Crypto/lib/descore/desCore.h create mode 100644 src/modules/_Crypto/lib/descore/desKerb.c create mode 100644 src/modules/_Crypto/lib/descore/desQuick.c create mode 100644 src/modules/_Crypto/lib/descore/desTest.c create mode 100644 src/modules/_Crypto/lib/descore/desUtil.c create mode 100644 src/modules/_Crypto/lib/descore/descore.diffs create mode 100644 src/modules/_Crypto/lib/descore/descore.shar.gz create mode 100644 src/modules/_Crypto/lib/descore/desdata.c create mode 100644 src/modules/_Crypto/lib/descore/desinfo.h diff --git a/.gitattributes b/.gitattributes index cfdec4acec..c9f2feb1bf 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,6 @@ [attr]binary -text -crlf -diff -ident * text ident +*.gz binary testfont binary # Handling of foreign (ie CVS) identifiers. @@ -27,6 +28,16 @@ testfont binary /src/modules/_Crypto/idea.c foreign_ident /src/modules/_Crypto/idea.pike foreign_ident /src/modules/_Crypto/invert.c foreign_ident +/src/modules/_Crypto/lib/descore/Makefile foreign_ident +/src/modules/_Crypto/lib/descore/README foreign_ident +/src/modules/_Crypto/lib/descore/desCode.h foreign_ident +/src/modules/_Crypto/lib/descore/desCore.h foreign_ident +/src/modules/_Crypto/lib/descore/desKerb.c foreign_ident +/src/modules/_Crypto/lib/descore/desQuick.c foreign_ident +/src/modules/_Crypto/lib/descore/desTest.c foreign_ident +/src/modules/_Crypto/lib/descore/desUtil.c foreign_ident +/src/modules/_Crypto/lib/descore/desdata.c foreign_ident +/src/modules/_Crypto/lib/descore/desinfo.h foreign_ident /src/modules/_Crypto/md2.c foreign_ident /src/modules/_Crypto/md5.c foreign_ident /src/modules/_Crypto/md5.pike foreign_ident diff --git a/src/modules/_Crypto/Makefile b/src/modules/_Crypto/Makefile index 120934db01..df444b0d60 100644 --- a/src/modules/_Crypto/Makefile +++ b/src/modules/_Crypto/Makefile @@ -19,21 +19,21 @@ CPPFLAGS= # The flags to generate a shared library CFLAGS=-Wall -O -shared -fpic $(IFLAGS) $(CPPFLAGS) -pedantic -Wall -LDFLAGS=-shared -fpic -Llib -R$(SSLROOT)/lib -L$(SSLROOT)/lib -LOADLIBES=-lcrypto -lssl +LDFLAGS=-shared -fpic -Llib # -R$(SSLROOT)/lib -L$(SSLROOT)/lib +#LOADLIBES=-lcrypto -lssl OBJS=crypto.o md5.o md2.o idea.o des.o invert.o cbc.o pipe.o sha.o # The actual rules crypto.so: $(OBJS) lib/libib.a - $(CC) $(LDFLAGS) $(OBJS) -Llib -lib -o crypto.so + $(CC) $(LDFLAGS) $(OBJS) -lib -o crypto.so idea.so: idea.o lib/libib.a - $(CC) $(LDFLAGS) idea.o -Llib -lib -o idea.so + $(CC) $(LDFLAGS) idea.o -lib -o idea.so sha.so: sha.o lib/libib.a - $(CC) $(LDFLAGS) sha.o -Llib -lib -o sha.so + $(CC) $(LDFLAGS) sha.o -lib -o sha.so lib/libib.a: cd lib; $(MAKE) libib.a diff --git a/src/modules/_Crypto/lib/descore/Makefile b/src/modules/_Crypto/lib/descore/Makefile new file mode 100644 index 0000000000..4a93c237c5 --- /dev/null +++ b/src/modules/_Crypto/lib/descore/Makefile @@ -0,0 +1,146 @@ +# +# des - fast & portable DES encryption & decryption. +# Copyright (C) 1992 Dana L. How +# Please see the file `README' for the complete copyright notice. +# + +# $Id: Makefile,v 1.1 1997/01/10 02:51:59 nisse Exp $ + +CFLAGS= -g # debug +CFLAGS= -O4 # max opt +CFLAGS= -O4 +CPPFLAGS= -Dsparc # use 6+8 general regs +CPPFLAGS= -Dmc68000 # use 3+4 addr (1+4 live), and 3+3 data regs +CPPFLAGS= -Dvax # use 6+0 general regs +CPPFLAGS= -Di386 # use 3+0 regs, and 3+0 normal variables +CPPFLAGS= -Dsparc +LDFLAGS= +CC= gcc +CPP= $(CC) -E $(CPPFLAGS) +CODEGEN.c= $(CC) $(CFLAGS) $(CPPFLAGS) -S +COMPILE.c= $(CC) $(CFLAGS) $(CPPFLAGS) -c +LINK.c= $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) + +# hand-entered files that go into the library +SC= desKerb.c desUtil.c desQuick.c +SO= desKerb.o desUtil.o desQuick.o + +# special generated files +GH= parity.h rotors.h keymap.h +GC= desSmallFips.c desSmallCore.c desQuickFips.c desQuickCore.c +GI= desSmallFips.i desSmallCore.i desQuickFips.i desQuickCore.i +GO= desSmallFips.o desSmallCore.o desQuickFips.o desQuickCore.o + +# what to distribute +RCS= Makefile README \ + desCore.h desinfo.h desCode.h \ + desTest.c $(SC) desdata.c +FILES= $(RCS) + +O= $(SO) $(GO) + +# prefer compilation from .i if .i exists +.SUFFIXES: +.SUFFIXES: .i .o .c $(SUFFIXES) + +.PRECIOUS: $(RCS) test + +test: desCore.a desTest.o + $(LINK.c) -o $@ desTest.o desCore.a + ./test + +# get stuff from RCS +$(RCS): + co $@ + +# test all performance enhancement flags +sure: + rm *.i; make 'CPPFLAGS=-Di386 -Umc68000 -Usparc' + rm *.i; make 'CPPFLAGS=-Dvax -Umc68000 -Usparc' + rm *.i; make 'CPPFLAGS=-Dmc68000 -Usparc' + rm *.i; make 'CPPFLAGS=-Dsparc -Umc68000' + +desCore.a: $O + ar cru $@ $O + ranlib $@ + +desdata.o: desinfo.h desCore.h +desUtil.o: $(GH) +$(SO): desCore.h +$(GI): desCode.h desCore.h Makefile +desTest.o: desCore.h + +$(GH): desdata + ./desdata $@ > $@ + +desdata: desdata.o + $(LINK.c) -o $@ desdata.o + +tar: $(FILES) + tar cf des.tar $(FILES) + +shar: $(FILES) + makekit -ndes.shar -s53k '-tnow run make' $(FILES) + +lint: desTest.c $(SC) $(GC) + lint $(CPPFLAGS) \ + desTest.c $(SC) $(GC) | \ + sed '/possible pointer alignment problem/d' + +warn: desTest.c $(SC) $(GC) + gcc2 -Wall -ansi -pedantic $(CPPFLAGS) -O2 \ + desTest.c $(SC) $(GC) + +# new rules (note: tr|sed|tr is NOT necessary, just there so .i is readable) +.c.i: + $(CPP) $< > $*.x + @tr ';'\\012 \\012';' < $*.x | \ + sed -e 's/[ ][ ]*/ /g' \ + -e 's/^ //' \ + -e 's/ $$//' \ + -e '/^$$/d' \ + -e '/^[^;]/s/^/;/' \ + -e 's/#[^;]*;//g' \ + -e 's/\([){]\) *\(register\)/\1;\2/g' \ + -e 's/\([[(]\) /\1/g' \ + -e 's/ \([])]\)/\1/g' \ + -e 's/\([^]+0123 ]\) =/\1 =/g' \ + -e 's/}/};;/g' \ + -e 's/ *; */;/g' \ + -e 's/;;;*/;;/g' \ + -e '1s/^;*//' | \ + tr ';'\\012 \\012';' > $@ + @echo "" >> $@ +# @echo "}" >> $@ # last definition must be a procedure + +# -e 's/\(;[kmxyz][0-9]*\)\([^;]*=\)/\1 \2/g' + +.i.o: + $(CODEGEN.c) $< + $(COMPILE.c) $*.s + +# slowest to quickest +desSmallFips.c: + @echo '#include "desCode.h"' > $@ + @echo \ +'ENCRYPT(DesSmallFipsEncrypt,TEMPSMALL,LOADFIPS,KEYMAPSMALL,SAVEFIPS)' >> $@ + @echo \ +'DECRYPT(DesSmallFipsDecrypt,TEMPSMALL,LOADFIPS,KEYMAPSMALL,SAVEFIPS)' >> $@ +desSmallCore.c: + @echo '#include "desCode.h"' > $@ + @echo \ +'ENCRYPT(DesSmallCoreEncrypt,TEMPSMALL,LOADCORE,KEYMAPSMALL,SAVECORE)' >> $@ + @echo \ +'DECRYPT(DesSmallCoreDecrypt,TEMPSMALL,LOADCORE,KEYMAPSMALL,SAVECORE)' >> $@ +desQuickFips.c: + @echo '#include "desCode.h"' > $@ + @echo \ +'ENCRYPT(DesQuickFipsEncrypt,TEMPQUICK,LOADFIPS,KEYMAPQUICK,SAVEFIPS)' >> $@ + @echo \ +'DECRYPT(DesQuickFipsDecrypt,TEMPQUICK,LOADFIPS,KEYMAPQUICK,SAVEFIPS)' >> $@ +desQuickCore.c: + @echo '#include "desCode.h"' > $@ + @echo \ +'ENCRYPT(DesQuickCoreEncrypt,TEMPQUICK,LOADCORE,KEYMAPQUICK,SAVECORE)' >> $@ + @echo \ +'DECRYPT(DesQuickCoreDecrypt,TEMPQUICK,LOADCORE,KEYMAPQUICK,SAVECORE)' >> $@ diff --git a/src/modules/_Crypto/lib/descore/README b/src/modules/_Crypto/lib/descore/README new file mode 100644 index 0000000000..a1d7aeb66b --- /dev/null +++ b/src/modules/_Crypto/lib/descore/README @@ -0,0 +1,313 @@ +des - fast & portable DES encryption & decryption. +Copyright (C) 1992 Dana L. How + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU Library 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 Library General Public License for more details. + +You should have received a copy of the GNU Library General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Author's address: how@isl.stanford.edu + +$Id: README,v 1.1 1997/01/10 02:52:13 nisse Exp $ + + +==>> To compile after untarring/unsharring, just `make' <<== + + +This package was designed with the following goals: +1. Highest possible encryption/decryption PERFORMANCE. +2. PORTABILITY to any byte-addressable machine with a 32bit unsigned C type +3. Plug-compatible replacement for KERBEROS's low-level routines. + + +performance comparison to other available des code which i could +compile on a SPARCStation 1 (cc -O4): + +this code (byte-order independent): + 30us per encryption (options: 64k tables, no IP/FP) + 33us per encryption (options: 64k tables, FIPS standard bit ordering) + 45us per encryption (options: 2k tables, no IP/FP) + 49us per encryption (options: 2k tables, FIPS standard bit ordering) + 275us to set a new key (uses 1k of key tables) + this has the quickest encryption/decryption routines i've seen. + since i was interested in fast des filters rather than crypt(3) + and password cracking, i haven't really bothered yet to speed up + the key setting routine. also, i have no interest in re-implementing + all the other junk in the mit kerberos des library, so i've just + provided my routines with little stub interfaces so they can be + used as drop-in replacements with mit's code or any of the mit- + compatible packages below. (note that the first two timings above + are highly variable because of cache effects). + +kerberos des replacement from australia: + 68us per encryption (uses 2k of tables) + 96us to set a new key (uses 2.25k of key tables) + this is a very nice package which implements the most important + of the optimizations which i did in my encryption routines. + it's a bit weak on common low-level optimizations which is why + it's 39%-106% slower. because he was interested in fast crypt(3) and + password-cracking applications, he also used the same ideas to + speed up the key-setting routines with impressive results. + (at some point i may do the same in my package). he also implements + the rest of the mit des library. + (code from eay@psych.psy.uq.oz.au via comp.sources.misc) + +fast crypt(3) package from denmark: + the des routine here is buried inside a loop to do the + crypt function and i didn't feel like ripping it out and measuring + performance. his code takes 26 sparc instructions to compute one + des iteration; above, Quick (64k) takes 21 and Small (2k) takes 37. + he claims to use 280k of tables but the iteration calculation seems + to use only 128k. his tables and code are machine independent. + (code from glad@daimi.aau.dk via alt.sources or comp.sources.misc) + +swedish reimplementation of Kerberos des library + 108us per encryption (uses 34k worth of tables) + 134us to set a new key (uses 32k of key tables to get this speed!) + the tables used seem to be machine-independent; + he seems to have included a lot of special case code + so that, e.g., `long' loads can be used instead of 4 `char' loads + when the machine's architecture allows it. + (code obtained from chalmers.se:pub/des) + +crack 3.3c package from england: + as in crypt above, the des routine is buried in a loop. it's + also very modified for crypt. his iteration code uses 16k + of tables and appears to be slow. + (code obtained from aem@aber.ac.uk via alt.sources or comp.sources.misc) + +``highly optimized'' and tweaked Kerberos/Athena code (byte-order dependent): + 165us per encryption (uses 6k worth of tables) + 478us to set a new key (uses <1k of key tables) + so despite the comments in this code, it was possible to get + faster code AND smaller tables, as well as making the tables + machine-independent. + (code obtained from prep.ai.mit.edu) + +UC Berkeley code (depends on machine-endedness): + 226us per encryption +10848us to set a new key + table sizes are unclear, but they don't look very small + (code obtained from wuarchive.wustl.edu) + + +motivation and history + +a while ago i wanted some des routines and the routines documented on sun's +man pages either didn't exist or dumped core. i had heard of kerberos, +and knew that it used des, so i figured i'd use its routines. but once +i got it and looked at the code, it really set off a lot of pet peeves - +it was too convoluted, the code had been written without taking +advantage of the regular structure of operations such as IP, E, and FP +(i.e. the author didn't sit down and think before coding), +it was excessively slow, the author had attempted to clarify the code +by adding MORE statements to make the data movement more `consistent' +instead of simplifying his implementation and cutting down on all data +movement (in particular, his use of L1, R1, L2, R2), and it was full of +idiotic `tweaks' for particular machines which failed to deliver significant +speedups but which did obfuscate everything. so i took the test data +from his verification program and rewrote everything else. + +a while later i ran across the great crypt(3) package mentioned above. +the fact that this guy was computing 2 sboxes per table lookup rather +than one (and using a MUCH larger table in the process) emboldened me to +do the same - it was a trivial change from which i had been scared away +by the larger table size. in his case he didn't realize you don't need to keep +the working data in TWO forms, one for easy use of half the sboxes in +indexing, the other for easy use of the other half; instead you can keep +it in the form for the first half and use a simple rotate to get the other +half. this means i have (almost) half the data manipulation and half +the table size. in fairness though he might be encoding something particular +to crypt(3) in his tables - i didn't check. + +i'm glad that i implemented it the way i did, because this C version is +portable (the ifdef's are performance enhancements) and it is faster +than versions hand-written in assembly for the sparc! + + +porting notes + +one thing i did not want to do was write an enormous mess +which depended on endedness and other machine quirks, +and which necessarily produced different code and different lookup tables +for different machines. see the kerberos code for an example +of what i didn't want to do; all their endedness-specific `optimizations' +obfuscate the code and in the end were slower than a simpler machine +independent approach. however, there are always some portability +considerations of some kind, and i have included some options +for varying numbers of register variables. +perhaps some will still regard the result as a mess! + +1) i assume everything is byte addressable, although i don't actually + depend on the byte order, and that bytes are 8 bits. + i assume word pointers can be freely cast to and from char pointers. + note that 99% of C programs make these assumptions. + i always use unsigned char's if the high bit could be set. +2) the typedef `word' means a 32 bit unsigned integral type. + if `unsigned long' is not 32 bits, change the typedef in desCore.h. + i assume sizeof(word) == 4 EVERYWHERE. + +the (worst-case) cost of my NOT doing endedness-specific optimizations +in the data loading and storing code surrounding the key iterations +is less than 12%. also, there is the added benefit that +the input and output work areas do not need to be word-aligned. + + +OPTIONAL performance optimizations + +1) you should define one of `i386,' `vax,' `mc68000,' or `sparc,' + whichever one is closest to the capabilities of your machine. + see the start of desCode.h to see exactly what this selection implies. + note that if you select the wrong one, the des code will still work; + these are just performance tweaks. +2) for those with functional `asm' keywords: you should change the + ROR and ROL macros to use machine rotate instructions if you have them. + this will save 2 instructions and a temporary per use, + or about 32 to 40 instructions per en/decryption. + +these optimizations are all rather persnickety, yet with them you should +be able to get performance equal to assembly-coding, except that: +1) with the lack of a bit rotate operator in C, rotates have to be synthesized + from shifts. so access to `asm' will speed things up if your machine + has rotates, as explained above in (3). +2) if your machine has less than 12 32-bit registers i doubt your compiler will + generate good code. + `i386' tries to configure the code for a 386 by only declaring 3 registers + (it appears that gcc can use ebx, esi and edi to hold register variables). + however, if you like assembly coding, the 386 does have 7 32-bit registers, + and if you use ALL of them, use `scaled by 8' address modes with displacement + and other tricks, you can get reasonable routines for DesQuickCore... with + about 250 instructions apiece. For DesSmall... it will help to rearrange + des_keymap, i.e., now the sbox # is the high part of the index and + the 6 bits of data is the low part; it helps to exchange these. + since i have no way to conveniently test it i have not provided my + shoehorned 386 version. + +coding notes + +the en/decryption routines each use 6 necessary register variables, +with 4 being actively used at once during the inner iterations. +if you don't have 4 register variables get a new machine. +up to 8 more registers are used to hold constants in some configurations. + +i assume that the use of a constant is more expensive than using a register: +a) additionally, i have tried to put the larger constants in registers. + registering priority was by the following: + anything more than 12 bits (bad for RISC and CISC) + greater than 127 in value (can't use movq or byte immediate on CISC) + 9-127 (may not be able to use CISC shift immediate or add/sub quick), + 1-8 were never registered, being the cheapest constants. +b) the compiler may be too stupid to realize table and table+256 should + be assigned to different constant registers and instead repetitively + do the arithmetic, so i assign these to explicit `m' register variables + when possible and helpful. + +i assume that indexing is cheaper or equivalent to auto increment/decrement, +where the index is 7 bits unsigned or smaller. +this assumption is reversed for 68k and vax. + +i assume that addresses can be cheaply formed from two registers, +or from a register and a small constant. i never use the `two registers +and offset' form you see in some CISC machines. +all index scaling is done explicitly - no hidden shifts by log2(sizeof). + +the code is written so that even a dumb compiler +should never need more than one hidden temporary, +increasing the chance that everything will fit in the registers. +KEEP THIS MORE SUBTLE POINT IN MIND IF YOU REWRITE ANYTHING. + + +special efficient data format + +bits are manipulated in this arrangement most of the time (S7 S5 S3 S1): + 003130292827xxxx242322212019xxxx161514131211xxxx080706050403xxxx +(the x bits are still there, i'm just emphasizing where the S boxes are). +bits are rotated left 4 when computing S6 S4 S2 S0: + 282726252423xxxx201918171615xxxx121110090807xxxx040302010031xxxx +the rightmost two bits are usually cleared so the lower byte can be used +as an index into an sbox mapping table. the next two x'd bits are set +to various values to access different parts of the tables. + + +how to use the routines + +datatypes: + pointer to 8 byte area of type DesData + used to hold keys and input/output blocks to des. + + pointer to 128 byte area of type DesKeys + used to hold full 768-bit key. + must be long-aligned. + +DesQuickInit() + call this before using any other routine with `Quick' in its name. + it generates the special 64k table these routines need. +DesQuickDone() + frees this table + +DesMethod(m, k) + m points to a 128byte block, k points to an 8 byte des key + which must have odd parity (or -1 is returned) and which must + not be a (semi-)weak key (or -2 is returned). + normally DesMethod() returns 0. + m is filled in from k so that when one of the routines below + is called with m, the routine will act like standard des + en/decryption with the key k. if you use DesMethod, + you supply a standard 56bit key; however, if you fill in + m yourself, you will get a 768bit key - but then it won't + be standard. it's 768bits not 1024 because the least significant + two bits of each byte are not used. and yes, each byte controls + a specific sbox during a specific iteration. + NOTE: actually, every other word has been rotated right 4 bits + to reduce the number of temporaries needed when the key is used. + you really shouldn't use the 768bit format directly; i should + provide a routine that converts 128 6-bit bytes (specified in + S-box mapping order or something) into the right format for you. + this would entail some byte concatenation and rotation. + +Des{Small|Quick}{Fips|Core}{Encrypt|Decrypt}(d, m, s) + performs des on the 8 bytes at s into the 8 bytes at d. (d,s: char *). + uses m as a 768bit key as explained above. + the Encrypt|Decrypt choice is obvious. + Fips|Core determines whether a completely standard FIPS initial + and final permutation is done; if not, then the data is loaded + and stored in a nonstandard bit order (FIPS w/o IP/FP). + Fips slows down Quick by 10%, Small by 9%. + Small|Quick determines whether you use the normal routine + or the crazy quick one which gobbles up 64k more of memory. + Small is 50% slower then Quick, but Quick needs 32 times as much + memory. Quick is included for programs that do nothing but DES, + e.g., encryption filters, etc. + + +Getting it to compile on your machine + +there are no machine-dependencies in the code (see porting), +except perhaps the `now()' macro in desTest.c. +ALL generated tables are machine independent. +you should edit the Makefile with the appropriate optimization flags +for your compiler (MAX optimization). + + +Speeding up kerberos (and/or its des library) + +note that i have included a kerberos-compatible interface in desUtil.c +through the functions des_key_sched() and des_ecb_encrypt(). +to use these with kerberos or kerberos-compatible code put desCore.a +ahead of the kerberos-compatible library on your linker's command line. +you should not need to #include desCore.h; just include the header +file provided with the kerberos library. + +Other uses + +the macros in desCode.h would be very useful for putting inline des +functions in more complicated encryption routines. diff --git a/src/modules/_Crypto/lib/descore/desCode.h b/src/modules/_Crypto/lib/descore/desCode.h new file mode 100644 index 0000000000..221b31965e --- /dev/null +++ b/src/modules/_Crypto/lib/descore/desCode.h @@ -0,0 +1,410 @@ +/* + * des - fast & portable DES encryption & decryption. + * Copyright (C) 1992 Dana L. How + * Please see the file `README' for the complete copyright notice. + */ + +#ifndef lint +static char desCode_hRcs[] = "$Id: desCode.h,v 1.1 1997/01/10 02:52:19 nisse Exp $"; +#endif + +#include "desCore.h" +extern word des_keymap[], des_bigmap[]; + + +/* optional customization: + * the idea here is to alter the code so it will still run correctly + * on any machine, but the quickest on the specific machine in mind. + * note that these silly tweaks can give you a 15%-20% speed improvement + * on the sparc -- it's probably even more significant on the 68000. */ + +/* take care of machines with incredibly few registers */ +#if defined(i386) +#define REGISTER /* only x, y, z will be declared register */ +#else +#define REGISTER register +#endif /* i386 */ + +/* is auto inc/dec faster than 7bit unsigned indexing? */ +#if defined(vax) || defined(mc68000) +#define FIXR r += 32; +#define FIXS s += 8; +#define PREV(v,o) *--v +#define NEXT(v,o) *v++ +#else +#define FIXR +#define FIXS +#define PREV(v,o) v[o] +#define NEXT(v,o) v[o] +#endif + +/* if no machine type, default is indexing, 6 registers and cheap literals */ +#if !defined(i386) && !defined(vax) && !defined(mc68000) && !defined(sparc) +#define vax +#endif + +/* handle a compiler which can't reallocate registers */ +#if defined(strange) /* didn't feel like deleting */ +#define SREGFREE ; s = (byte *) D +#define DEST s +#define D m0 +#define BYTE word +#else +#define SREGFREE +#define DEST d +#define D d +#define BYTE byte +#endif + +/* handle constants in the optimal way for 386 & vax */ +/* 386: we declare 3 register variables (see above) and use 3 more variables; + * vax: we use 6 variables, all declared register; + * we assume address literals are cheap & unrestricted; + * we assume immediate constants are cheap & unrestricted. */ +#if defined(i386) || defined(vax) +#define MQ0 des_bigmap +#define MQ1 (des_bigmap + 64) +#define MQ2 (des_bigmap + 128) +#define MQ3 (des_bigmap + 192) +#define HQ0(z) /* z |= 0X01000000L; */ +#define HQ2(z) /* z |= 0X03000200L; */ +#define LQ0(z) 0XFCFC & z +#define LQ1(z) 0XFCFC & z +#define LQ2(z) 0XFCFC & z +#define LQ3(z) 0XFCFC & z +#define SQ 16 +#define MS0 des_keymap +#define MS1 (des_keymap + 64) +#define MS2 (des_keymap + 128) +#define MS3 (des_keymap + 192) +#define MS4 (des_keymap + 256) +#define MS5 (des_keymap + 320) +#define MS6 (des_keymap + 384) +#define MS7 (des_keymap + 448) +#define HS(z) +#define LS0(z) 0XFC & z +#define LS1(z) 0XFC & z +#define LS2(z) 0XFC & z +#define LS3(z) 0XFC & z +#define REGQUICK +#define SETQUICK +#define REGSMALL +#define SETSMALL +#endif /* defined(i386) || defined(vax) */ + +/* handle constants in the optimal way for mc68000 */ +/* in addition to the core 6 variables, we declare 3 registers holding constants + * and 4 registers holding address literals. + * at most 6 data values and 5 address values are actively used at once. + * we assume address literals are so expensive we never use them; + * we assume constant index offsets > 127 are expensive, so they are not used. + * we assume all constants are expensive and put them in registers, + * including shift counts greater than 8. */ +#if defined(mc68000) +#define MQ0 m0 +#define MQ1 m1 +#define MQ2 m2 +#define MQ3 m3 +#define HQ0(z) +#define HQ2(z) +#define LQ0(z) k0 & z +#define LQ1(z) k0 & z +#define LQ2(z) k0 & z +#define LQ3(z) k0 & z +#define SQ k1 +#define MS0 m0 +#define MS1 m0 +#define MS2 m1 +#define MS3 m1 +#define MS4 m2 +#define MS5 m2 +#define MS6 m3 +#define MS7 m3 +#define HS(z) z |= k0; +#define LS0(z) k1 & z +#define LS1(z) k2 & z +#define LS2(z) k1 & z +#define LS3(z) k2 & z +#define REGQUICK \ + register word k0, k1; \ + register word *m0, *m1, *m2, *m3; +#define SETQUICK \ + ; k0 = 0XFCFC \ + ; k1 = 16 \ + /*k2 = 28 to speed up ROL */ \ + ; m0 = des_bigmap \ + ; m1 = m0 + 64 \ + ; m2 = m1 + 64 \ + ; m3 = m2 + 64 +#define REGSMALL \ + register word k0, k1, k2; \ + register word *m0, *m1, *m2, *m3; +#define SETSMALL \ + ; k0 = 0X01000100L \ + ; k1 = 0X0FC \ + ; k2 = 0X1FC \ + ; m0 = des_keymap \ + ; m1 = m0 + 128 \ + ; m2 = m1 + 128 \ + ; m3 = m2 + 128 +#endif /* defined(mc68000) */ + +/* handle constants in the optimal way for sparc */ +/* in addition to the core 6 variables, we either declare: + * 4 registers holding address literals and 1 register holding a constant, or + * 8 registers holding address literals. + * up to 14 register variables are declared (sparc has %i0-%i5, %l0-%l7). + * we assume address literals are so expensive we never use them; + * we assume any constant with >10 bits is expensive and put it in a register, + * and any other is cheap and is coded in-line. */ +#if defined(sparc) +#define MQ0 m0 +#define MQ1 m1 +#define MQ2 m2 +#define MQ3 m3 +#define HQ0(z) +#define HQ2(z) +#define LQ0(z) k0 & z +#define LQ1(z) k0 & z +#define LQ2(z) k0 & z +#define LQ3(z) k0 & z +#define SQ 16 +#define MS0 m0 +#define MS1 m1 +#define MS2 m2 +#define MS3 m3 +#define MS4 m4 +#define MS5 m5 +#define MS6 m6 +#define MS7 m7 +#define HS(z) +#define LS0(z) 0XFC & z +#define LS1(z) 0XFC & z +#define LS2(z) 0XFC & z +#define LS3(z) 0XFC & z +#define REGQUICK \ + register word k0; \ + register word *m0, *m1, *m2, *m3; +#define SETQUICK \ + ; k0 = 0XFCFC \ + ; m0 = des_bigmap \ + ; m1 = m0 + 64 \ + ; m2 = m1 + 64 \ + ; m3 = m2 + 64 +#define REGSMALL \ + register word *m0, *m1, *m2, *m3, *m4, *m5, *m6, *m7; +#define SETSMALL \ + ; m0 = des_keymap \ + ; m1 = m0 + 64 \ + ; m2 = m1 + 64 \ + ; m3 = m2 + 64 \ + ; m4 = m3 + 64 \ + ; m5 = m4 + 64 \ + ; m6 = m5 + 64 \ + ; m7 = m6 + 64 +#endif /* defined(sparc) */ + + +/* some basic stuff */ + +/* generate addresses from a base and an index */ +#define ADD(b,x) (word *) ((byte *)b + (x)) + +/* low level rotate operations */ +#define NOP(d,c,o) +#define ROL(d,c,o) d = d << c | d >> o +#define ROR(d,c,o) d = d >> c | d << o +#define ROL1(d) ROL(d, 1, 31) +#define ROR1(d) ROR(d, 1, 31) + +/* elementary swap for doing IP/FP */ +#define SWAP(x,y,m,b) \ + z = ((x >> b) ^ y) & m; \ + x ^= z << b; \ + y ^= z + + +/* the following macros contain all the important code fragments */ + +/* load input data, then setup special registers holding constants */ +#define TEMPQUICK(LOAD) \ + REGQUICK \ + LOAD() \ + SETQUICK +#define TEMPSMALL(LOAD) \ + REGSMALL \ + LOAD() \ + SETSMALL + +/* load data */ +#define LOADDATA(x,y) \ + FIXS \ + y = PREV(s, 7); y<<= 8; \ + y |= PREV(s, 6); y<<= 8; \ + y |= PREV(s, 5); y<<= 8; \ + y |= PREV(s, 4); \ + x = PREV(s, 3); x<<= 8; \ + x |= PREV(s, 2); x<<= 8; \ + x |= PREV(s, 1); x<<= 8; \ + x |= PREV(s, 0) \ + SREGFREE +/* load data without initial permutation and put into efficient position */ +#define LOADCORE() \ + LOADDATA(x, y); \ + ROR1(x); \ + ROR1(y) +/* load data, do the initial permutation and put into efficient position */ +#define LOADFIPS() \ + LOADDATA(y, x); \ + SWAP(x, y, 0X0F0F0F0FL, 004); \ + SWAP(y, x, 0X0000FFFFL, 020); \ + SWAP(x, y, 0X33333333L, 002); \ + SWAP(y, x, 0X00FF00FFL, 010); \ + ROR1(x); \ + z = (x ^ y) & 0X55555555L; \ + y ^= z; \ + x ^= z; \ + ROR1(y) + + +/* core encryption/decryption operations */ +/* S box mapping and P perm */ +#define KEYMAPSMALL(x,z,mq0,mq1,hq,lq0,lq1,sq,ms0,ms1,ms2,ms3,hs,ls0,ls1,ls2,ls3)\ + hs(z) \ + x ^= *ADD(ms3, ls3(z)); \ + z>>= 8; \ + x ^= *ADD(ms2, ls2(z)); \ + z>>= 8; \ + x ^= *ADD(ms1, ls1(z)); \ + z>>= 8; \ + x ^= *ADD(ms0, ls0(z)) +/* alternate version: use 64k of tables */ +#define KEYMAPQUICK(x,z,mq0,mq1,hq,lq0,lq1,sq,ms0,ms1,ms2,ms3,hs,ls0,ls1,ls2,ls3)\ + hq(z) \ + x ^= *ADD(mq0, lq0(z)); \ + z>>= sq; \ + x ^= *ADD(mq1, lq1(z)) +/* apply 24 key bits and do the odd s boxes */ +#define S7S1(x,y,z,r,m,KEYMAP,LOAD) \ + z = LOAD(r, m); \ + z ^= y; \ + KEYMAP(x,z,MQ0,MQ1,HQ0,LQ0,LQ1,SQ,MS0,MS1,MS2,MS3,HS,LS0,LS1,LS2,LS3) +/* apply 24 key bits and do the even s boxes */ +#define S6S0(x,y,z,r,m,KEYMAP,LOAD) \ + z = LOAD(r, m); \ + z ^= y; \ + ROL(z, 4, 28); \ + KEYMAP(x,z,MQ2,MQ3,HQ2,LQ2,LQ3,SQ,MS4,MS5,MS6,MS7,HS,LS0,LS1,LS2,LS3) +/* actual iterations. equivalent except for UPDATE & swapping m and n */ +#define ENCR(x,y,z,r,m,n,KEYMAP) \ + S7S1(x,y,z,r,m,KEYMAP,NEXT); \ + S6S0(x,y,z,r,n,KEYMAP,NEXT) +#define DECR(x,y,z,r,m,n,KEYMAP) \ + S6S0(x,y,z,r,m,KEYMAP,PREV); \ + S7S1(x,y,z,r,n,KEYMAP,PREV) + +/* write out result in correct byte order */ +#define SAVEDATA(x,y) \ + NEXT(DEST, 0) = x; x>>= 8; \ + NEXT(DEST, 1) = x; x>>= 8; \ + NEXT(DEST, 2) = x; x>>= 8; \ + NEXT(DEST, 3) = x; \ + NEXT(DEST, 4) = y; y>>= 8; \ + NEXT(DEST, 5) = y; y>>= 8; \ + NEXT(DEST, 6) = y; y>>= 8; \ + NEXT(DEST, 7) = y +/* write out result */ +#define SAVECORE() \ + ROL1(x); \ + ROL1(y); \ + SAVEDATA(y, x) +/* do final permutation and write out result */ +#define SAVEFIPS() \ + ROL1(x); \ + z = (x ^ y) & 0X55555555L; \ + y ^= z; \ + x ^= z; \ + ROL1(y); \ + SWAP(x, y, 0X00FF00FFL, 010); \ + SWAP(y, x, 0X33333333L, 002); \ + SWAP(x, y, 0X0000FFFFL, 020); \ + SWAP(y, x, 0X0F0F0F0FL, 004); \ + SAVEDATA(x, y) + + +/* the following macros contain the encryption/decryption skeletons */ + +#define ENCRYPT(NAME, TEMP, LOAD, KEYMAP, SAVE) \ + \ +void \ +NAME(D, r, s) \ +REGISTER BYTE * D; \ +REGISTER word * r; \ +REGISTER byte * s; \ +{ \ + register word x, y, z; \ + \ + /* declare temps & load data */ \ + TEMP(LOAD); \ + \ + /* do the 16 iterations */ \ + ENCR(x,y,z,r, 0, 1,KEYMAP); \ + ENCR(y,x,z,r, 2, 3,KEYMAP); \ + ENCR(x,y,z,r, 4, 5,KEYMAP); \ + ENCR(y,x,z,r, 6, 7,KEYMAP); \ + ENCR(x,y,z,r, 8, 9,KEYMAP); \ + ENCR(y,x,z,r,10,11,KEYMAP); \ + ENCR(x,y,z,r,12,13,KEYMAP); \ + ENCR(y,x,z,r,14,15,KEYMAP); \ + ENCR(x,y,z,r,16,17,KEYMAP); \ + ENCR(y,x,z,r,18,19,KEYMAP); \ + ENCR(x,y,z,r,20,21,KEYMAP); \ + ENCR(y,x,z,r,22,23,KEYMAP); \ + ENCR(x,y,z,r,24,25,KEYMAP); \ + ENCR(y,x,z,r,26,27,KEYMAP); \ + ENCR(x,y,z,r,28,29,KEYMAP); \ + ENCR(y,x,z,r,30,31,KEYMAP); \ + \ + /* save result */ \ + SAVE(); \ + \ + return; \ +} + +#define DECRYPT(NAME, TEMP, LOAD, KEYMAP, SAVE) \ + \ +void \ +NAME(D, r, s) \ +REGISTER BYTE * D; \ +REGISTER word * r; \ +REGISTER byte * s; \ +{ \ + register word x, y, z; \ + \ + /* declare temps & load data */ \ + TEMP(LOAD); \ + \ + /* do the 16 iterations */ \ + FIXR \ + DECR(x,y,z,r,31,30,KEYMAP); \ + DECR(y,x,z,r,29,28,KEYMAP); \ + DECR(x,y,z,r,27,26,KEYMAP); \ + DECR(y,x,z,r,25,24,KEYMAP); \ + DECR(x,y,z,r,23,22,KEYMAP); \ + DECR(y,x,z,r,21,20,KEYMAP); \ + DECR(x,y,z,r,19,18,KEYMAP); \ + DECR(y,x,z,r,17,16,KEYMAP); \ + DECR(x,y,z,r,15,14,KEYMAP); \ + DECR(y,x,z,r,13,12,KEYMAP); \ + DECR(x,y,z,r,11,10,KEYMAP); \ + DECR(y,x,z,r, 9, 8,KEYMAP); \ + DECR(x,y,z,r, 7, 6,KEYMAP); \ + DECR(y,x,z,r, 5, 4,KEYMAP); \ + DECR(x,y,z,r, 3, 2,KEYMAP); \ + DECR(y,x,z,r, 1, 0,KEYMAP); \ + \ + /* save result */ \ + SAVE(); \ + \ + return; \ +} diff --git a/src/modules/_Crypto/lib/descore/desCore.h b/src/modules/_Crypto/lib/descore/desCore.h new file mode 100644 index 0000000000..7b62af9107 --- /dev/null +++ b/src/modules/_Crypto/lib/descore/desCore.h @@ -0,0 +1,21 @@ +/* + * des - fast & portable DES encryption & decryption. + * Copyright (C) 1992 Dana L. How + * Please see the file `README' for the complete copyright notice. + */ + +#ifndef lint +static char desCore_hRcs[] = "$Id: desCore.h,v 1.1 1997/01/10 02:52:31 nisse Exp $"; +#endif + +typedef unsigned char byte, DesData[ 8]; +typedef unsigned long word, DesKeys[32]; + +extern int DesMethod(); +extern void DesQuickInit(), DesQuickDone(); +extern void DesQuickCoreEncrypt(), DesQuickFipsEncrypt(); +extern void DesQuickCoreDecrypt(), DesQuickFipsDecrypt(); +extern void DesSmallCoreEncrypt(), DesSmallFipsEncrypt(); +extern void DesSmallCoreDecrypt(), DesSmallFipsDecrypt(); +extern void (*DesCryptFuncs[])(); +extern int des_key_sched(), des_ecb_encrypt(); diff --git a/src/modules/_Crypto/lib/descore/desKerb.c b/src/modules/_Crypto/lib/descore/desKerb.c new file mode 100644 index 0000000000..8d4a0ce6e4 --- /dev/null +++ b/src/modules/_Crypto/lib/descore/desKerb.c @@ -0,0 +1,38 @@ +/* + * des - fast & portable DES encryption & decryption. + * Copyright (C) 1992 Dana L. How + * Please see the file `README' for the complete copyright notice. + */ + +#ifndef lint +static char desKerb_cRcs[] = "$Id: desKerb.c,v 1.1 1997/01/10 02:52:38 nisse Exp $"; +#endif + +#include "desCore.h" + + +/* permit the default style of des functions to be changed */ + +void (*DesCryptFuncs[2])() = { DesSmallFipsDecrypt, DesSmallFipsEncrypt }; + +/* kerberos-compatible key schedule function */ + +int +des_key_sched(k, s) +byte * k; +word * s; +{ + return DesMethod(s, k); +} + +/* kerberos-compatible des coding function */ + +int +des_ecb_encrypt(s, d, r, e) +byte * s, * d; +word * r; +int e; +{ + (*DesCryptFuncs[e])(d, r, s); + return 0; +} diff --git a/src/modules/_Crypto/lib/descore/desQuick.c b/src/modules/_Crypto/lib/descore/desQuick.c new file mode 100644 index 0000000000..779fcb12bf --- /dev/null +++ b/src/modules/_Crypto/lib/descore/desQuick.c @@ -0,0 +1,52 @@ +/* + * des - fast & portable DES encryption & decryption. + * Copyright (C) 1992 Dana L. How + * Please see the file `README' for the complete copyright notice. + */ + +#ifndef lint +static char desQuick_cRcs[] = "$Id: desQuick.c,v 1.1 1997/01/10 02:52:44 nisse Exp $"; +#endif + +#include "desCore.h" +extern word des_keymap[]; + + +/* static information */ + +static depth = 0; /* keep track of the request depth */ +word des_bigmap[0x4000]; /* big lookup table */ + +/* fill in the 64k table used by the `quick' option */ + +void +DesQuickInit() +{ + int s1, s3, x; + word * t0, * t1, * t2, * t3; + + if ( depth++ ) + return; + + t0 = des_bigmap; + t1 = t0 + 64; + t2 = t1 + 64; + t3 = t2 + 64; + + for ( s3 = 63; s3 >= 0; s3-- ) { + for ( s1 = 63; s1 >= 0; s1-- ) { + x = (s3 << 8) | s1; + t0[x] = des_keymap[s3+128] ^ des_keymap[s1+192]; + t1[x] = des_keymap[s3 ] ^ des_keymap[s1+ 64]; + t2[x] = des_keymap[s3+384] ^ des_keymap[s1+448]; + t3[x] = des_keymap[s3+256] ^ des_keymap[s1+320]; + } + } +} + +/* free the 64k table, if necessary */ + +void +DesQuickDone() +{ +} diff --git a/src/modules/_Crypto/lib/descore/desTest.c b/src/modules/_Crypto/lib/descore/desTest.c new file mode 100644 index 0000000000..a439911d8b --- /dev/null +++ b/src/modules/_Crypto/lib/descore/desTest.c @@ -0,0 +1,177 @@ +/* + * des - fast & portable DES encryption & decryption. + * Copyright (C) 1992 Dana L. How + * Please see the file `README' for the complete copyright notice. + * + * Exercise the DES routines and collect performance statistics. + */ + +#ifndef lint +static char desTest_cRcs[] = "$Id: desTest.c,v 1.1 1997/01/10 02:52:49 nisse Exp $"; +#endif + +extern printf(); + +#include "desCore.h" + +/* define now(w) to be the elapsed time in hundredths of a second */ + +#include <sys/time.h> +#include <sys/resource.h> +extern getrusage(); +static struct rusage usage; +#define now(w) ( \ + (void)getrusage(RUSAGE_SELF, &usage), \ + usage.ru_utime.tv_sec * 100 + \ + usage.ru_utime.tv_usec / 10000 \ + ) + +/* test data + * the tests (key0-3, text0-3) are cribbed from code which is (c) 1988 MIT + */ + +byte keyt[8] = {0x5d, 0x85, 0x91, 0x73, 0xcb, 0x49, 0xdf, 0x2f}; +byte key0[8] = {0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x80}; +byte key1[8] = {0x80, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}; +byte key2[8] = {0x08, 0x19, 0x2a, 0x3b, 0x4c, 0x5d, 0x6e, 0x7f}; +byte key3[8] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef}; +byte textt[8] = {0x67, 0x1f, 0xc8, 0x93, 0x46, 0x5e, 0xab, 0x1e}; +byte text0[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +byte text1[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40}; +byte text2[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +byte text3[8] = {'N', 'o', 'w', ' ', 'i', 's', ' ', 't' }; + +/* work areas */ + +DesKeys keys; +byte cipher[8], output[8]; + +/* noisy interfaces to the routines under test */ + +static void +method(key) +byte *key; +{ + int j; + + (void)printf("\nkey:\t"); + for ( j = 0; j < 8; j++ ) + (void)printf("%02X ", key[j]); + if ( des_key_sched(key, keys) ) + (void)printf("W"); + (void)printf("\t"); +} + +static void +encode(src, dst) +byte *src, *dst; +{ + int j; + + (void)printf("clear:\t"); + for (j = 0; j < 8; j++) + (void)printf("%02X ", src[j]); + + (void)des_ecb_encrypt(src, dst, keys, 1); + + (void)printf("\tcipher:\t"); + for (j = 0; j < 8; j++) + (void)printf("%02X ", dst[j]); + (void)printf("\n"); +} + +static void +decode(src, dst) +byte *src, *dst; +{ + int j; + + (void)printf("cipher:\t"); + for (j = 0; j < 8; j++) + (void)printf("%02X ", src[j]); + + (void)des_ecb_encrypt(src, dst, keys, 0); + + (void)printf("\tclear:\t"); + for (j = 0; j < 8; j++) + (void)printf("%02X ", dst[j]); + (void)printf("\n"); +} + +/* run the tests */ + +int +main() +{ + int j, m, e, n; + void (*f)(); + static char * expect[] = { + "57 99 F7 2A D2 3F AE 4C", "9C C6 2D F4 3B 6E ED 74", + "90 E6 96 A2 AD 56 50 0D", "A3 80 E0 2A 6B E5 46 96", + "43 5C FF C5 68 B3 70 1D", "25 DD AC 3E 96 17 64 67", + "80 B5 07 E1 E6 A7 47 3D", "3F A4 0E 8A 98 4D 48 15", + }; + static void (*funcs[])() = { + DesQuickCoreEncrypt, DesQuickFipsEncrypt, + DesSmallCoreEncrypt, DesSmallFipsEncrypt, + DesQuickCoreDecrypt, DesQuickFipsDecrypt, + DesSmallCoreDecrypt, DesSmallFipsDecrypt }; + static char * names[] = { + "QuickCore", "QuickFips", + "SmallCore", "SmallFips" }; + + n = 0; + DesQuickInit(); + + /* do timing info first */ + + f = (void (*)())DesMethod; + j = 10000; + m = now(0); + do + (*f)(keys, keyt); + while ( --j ); + m = now(1) - m; + + do { + DesCryptFuncs[0] = funcs[n+4]; + f = DesCryptFuncs[1] = funcs[n ]; + j = 100000; + e = now(0); + do + (*f)(cipher, keys, textt); + while ( --j ); + e = now(1) - e; + + (void)printf( "%s: setkey,%5duS; encode,%3d.%1duS.\n", + names[n], m, e/10, e%10); + + /* now check functionality */ + + method(key0); + (void)printf("cipher?\t%s\n", expect[(n % 2) + 0]); + encode(text0, cipher); + decode(cipher, output); + + method(key1); + (void)printf("cipher?\t%s\n", expect[(n % 2) + 2]); + encode(text1, cipher); + decode(cipher, output); + + method(key2); + (void)printf("cipher?\t%s\n", expect[(n % 2) + 4]); + encode(text2, cipher); + decode(cipher, output); + + method(key3); + (void)printf("cipher?\t%s\n", expect[(n % 2) + 6]); + encode(text3, cipher); + decode(cipher, output); + + (void)printf("%c", "\n\f\n\0"[n]); + + } while ( ++n < 4 ); + + DesQuickDone(); + return 0; +} diff --git a/src/modules/_Crypto/lib/descore/desUtil.c b/src/modules/_Crypto/lib/descore/desUtil.c new file mode 100644 index 0000000000..0153d76488 --- /dev/null +++ b/src/modules/_Crypto/lib/descore/desUtil.c @@ -0,0 +1,174 @@ +/* + * des - fast & portable DES encryption & decryption. + * Copyright (C) 1992 Dana L. How + * Please see the file `README' for the complete copyright notice. + */ + +#ifndef lint +static char desUtil_cRcs[] = "$Id: desUtil.c,v 1.1 1997/01/10 02:52:55 nisse Exp $"; +#endif + +#include "desCode.h" + + +/* various tables */ + +word des_keymap[] = { +#include "keymap.h" +}; + +static byte rotors[] = { +#include "rotors.h" +}; +static char parity[] = { +#include "parity.h" +}; + +#ifndef lint +static char ego[] = "\n\nFast DES Library Copyright (c) 1991 Dana L. How\n\n"; +#endif + + +/* set up the method list from the key */ + +int +DesMethod(method, k) +register word * method; +register byte * k; +{ + register word n, w; + register char * b0, * b1; + char bits0[56], bits1[56]; + + /* check for bad parity and weak keys */ + b0 = parity; + n = b0[k[0]]; n <<= 4; + n |= b0[k[1]]; n <<= 4; + n |= b0[k[2]]; n <<= 4; + n |= b0[k[3]]; n <<= 4; + n |= b0[k[4]]; n <<= 4; + n |= b0[k[5]]; n <<= 4; + n |= b0[k[6]]; n <<= 4; + n |= b0[k[7]]; + w = 0X88888888L; + /* report bad parity in key */ + if ( n & w ) + return -1; + /* report a weak or semi-weak key */ + if ( !((n - (w >> 3)) & w) ) { /* 1 in 10^10 keys passes this test */ + if ( n < 0X41415151 ) { + if ( n < 0X31312121 ) { + if ( n < 0X14141515 ) { + /* 01 01 01 01 01 01 01 01 */ + if ( n == 0X11111111 ) return -2; + /* 01 1F 01 1F 01 0E 01 0E */ + if ( n == 0X13131212 ) return -2; + } else { + /* 01 E0 01 E0 01 F1 01 F1 */ + if ( n == 0X14141515 ) return -2; + /* 01 FE 01 FE 01 FE 01 FE */ + if ( n == 0X16161616 ) return -2; + } + } else { + if ( n < 0X34342525 ) { + /* 1F 01 1F 01 0E 01 0E 01 */ + if ( n == 0X31312121 ) return -2; + /* 1F 1F 1F 1F 0E 0E 0E 0E */ /* ? */ + if ( n == 0X33332222 ) return -2; + } else { + /* 1F E0 1F E0 0E F1 0E F1 */ + if ( n == 0X34342525 ) return -2; + /* 1F FE 1F FE 0E FE 0E FE */ + if ( n == 0X36362626 ) return -2; + } + } + } else { + if ( n < 0X61616161 ) { + if ( n < 0X44445555 ) { + /* E0 01 E0 01 F1 01 F1 01 */ + if ( n == 0X41415151 ) return -2; + /* E0 1F E0 1F F1 0E F1 0E */ + if ( n == 0X43435252 ) return -2; + } else { + /* E0 E0 E0 E0 F1 F1 F1 F1 */ /* ? */ + if ( n == 0X44445555 ) return -2; + /* E0 FE E0 FE F1 FE F1 FE */ + if ( n == 0X46465656 ) return -2; + } + } else { + if ( n < 0X64646565 ) { + /* FE 01 FE 01 FE 01 FE 01 */ + if ( n == 0X61616161 ) return -2; + /* FE 1F FE 1F FE 0E FE 0E */ + if ( n == 0X63636262 ) return -2; + } else { + /* FE E0 FE E0 FE F1 FE F1 */ + if ( n == 0X64646565 ) return -2; + /* FE FE FE FE FE FE FE FE */ + if ( n == 0X66666666 ) return -2; + } + } + } + } + + /* explode the bits */ + n = 56; + b0 = bits0; + b1 = bits1; + do { + w = (256 | *k++) << 2; + do { + --n; + b1[n] = 8 & w; + w >>= 1; + b0[n] = 4 & w; + } while ( w >= 16 ); + } while ( n ); + + /* put the bits in the correct places */ + n = 16; + k = rotors; + do { + w = (b1[k[ 0 ]] | b0[k[ 1 ]]) << 4; + w |= (b1[k[ 2 ]] | b0[k[ 3 ]]) << 2; + w |= b1[k[ 4 ]] | b0[k[ 5 ]]; + w <<= 8; + w |= (b1[k[ 6 ]] | b0[k[ 7 ]]) << 4; + w |= (b1[k[ 8 ]] | b0[k[ 9 ]]) << 2; + w |= b1[k[10 ]] | b0[k[11 ]]; + w <<= 8; + w |= (b1[k[12 ]] | b0[k[13 ]]) << 4; + w |= (b1[k[14 ]] | b0[k[15 ]]) << 2; + w |= b1[k[16 ]] | b0[k[17 ]]; + w <<= 8; + w |= (b1[k[18 ]] | b0[k[19 ]]) << 4; + w |= (b1[k[20 ]] | b0[k[21 ]]) << 2; + w |= b1[k[22 ]] | b0[k[23 ]]; + + method[0] = w; + + w = (b1[k[ 0+24]] | b0[k[ 1+24]]) << 4; + w |= (b1[k[ 2+24]] | b0[k[ 3+24]]) << 2; + w |= b1[k[ 4+24]] | b0[k[ 5+24]]; + w <<= 8; + w |= (b1[k[ 6+24]] | b0[k[ 7+24]]) << 4; + w |= (b1[k[ 8+24]] | b0[k[ 9+24]]) << 2; + w |= b1[k[10+24]] | b0[k[11+24]]; + w <<= 8; + w |= (b1[k[12+24]] | b0[k[13+24]]) << 4; + w |= (b1[k[14+24]] | b0[k[15+24]]) << 2; + w |= b1[k[16+24]] | b0[k[17+24]]; + w <<= 8; + w |= (b1[k[18+24]] | b0[k[19+24]]) << 4; + w |= (b1[k[20+24]] | b0[k[21+24]]) << 2; + w |= b1[k[22+24]] | b0[k[23+24]]; + + ROR(w, 4, 28); /* could be eliminated */ + method[1] = w; + + k += 48; + method += 2; + } while ( --n ); + + return 0; +} diff --git a/src/modules/_Crypto/lib/descore/descore.diffs b/src/modules/_Crypto/lib/descore/descore.diffs new file mode 100644 index 0000000000..5993303ac0 --- /dev/null +++ b/src/modules/_Crypto/lib/descore/descore.diffs @@ -0,0 +1,30 @@ +diff -u orig/Makefile ./Makefile +--- orig/Makefile Fri Jan 10 02:23:08 1997 ++++ ./Makefile Fri Jan 10 02:41:18 1997 +@@ -47,7 +47,7 @@ + + test: desCore.a desTest.o + $(LINK.c) -o $@ desTest.o desCore.a +- test ++ ./test + + # get stuff from RCS + $(RCS): +@@ -71,7 +71,7 @@ + desTest.o: desCore.h + + $(GH): desdata +- desdata $@ > $@ ++ ./desdata $@ > $@ + + desdata: desdata.o + $(LINK.c) -o $@ desdata.o +@@ -111,7 +111,7 @@ + -e '1s/^;*//' | \ + tr ';'\\012 \\012';' > $@ + @echo "" >> $@ +- @echo "}" >> $@ # last definition must be a procedure ++# @echo "}" >> $@ # last definition must be a procedure + + # -e 's/\(;[kmxyz][0-9]*\)\([^;]*=\)/\1 \2/g' + diff --git a/src/modules/_Crypto/lib/descore/descore.shar.gz b/src/modules/_Crypto/lib/descore/descore.shar.gz new file mode 100644 index 0000000000000000000000000000000000000000..f6e97a42fa4eb930ab3143f730bca2e23fef4aea GIT binary patch literal 18434 zcmb2|=HPH%RjbFuoRV6coL`ixSDcYp#Bimywp{A?rRVnxzFFrS?^6z7IM{H3yKJ6@ z(56zQ=&lLEPmg%o98h@1mG<F`0_X9c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y zu@=$OQ@&-z=yrT@n5JVd`+Jv|&$_i-&o{1SJ?IfXx#~>jBk!`UVwGGn`nOg$d)0D$ z>-pKiwDJp+UC9CW`@OO=-<PhF=giFvxZL@iG1Dt%w@<T}{7<VRF}2H-pEzWAMF<@$ zR@>|4?pS@QcD>t5FWX8xp>wiHuR?E`y%y5FH1XG|Ir9W0TesfkzU6LzAvp3vT!7G` zt1|7o7Og*Y>*eo%$L9pT=g9WlvXFC$LdelZyDwH9*(Pr$uhaj=ysPxWr$r9J6OTQa z_p)jU=MS#maY5^H*Xd47mAS$;UH8&;CCQ5mB$LnVJr<JKtJe6WNWXE?JwN8X&#Nn+ z+%8_RJy!ogBv;a-i<%k2YpP3DOpah$^fL9uv|EAut}!@2TWHwM_v9LPmMYhm*1|i1 zvpc+N&uvw{7-V&!d0oHTI@zvmUbdp^*gKYS-7-n~TI>CT!*t^}+k+RSztk-^PcmOt zAYX2~NZdp5yTCfT#SBuJT<LNNj6e4!=}pi)@!jNQ*2D)X>qIV|Ic0Fs;_)QDS(jSG zpNDJutt|X^q*<@~Zb5iA@7X;rwGVi7mr079yWb-|*)wxr$o6N)MAJ&op7lO;%yfJF zvb=rI(j+|i!w*bJw6Olm@bK@J*zbp~-z~T9m!A{2T7B`O>FSfEcOR2Gr}w48ZkAsc zdwpeb#gAvZ^XKK~+BT#<leS4tnErgRrjYiTzl_tqh`sTjf3HT(BkquWh9yt^uOr*% zi>BOmVwvWk<1WCub6bL{#xe%|S@k~oFT4eAo$s7_{NGoxIj35J?<IIIHA)NjxjXUR zTY2N;3|S4ux%wCOF&H|(O=?MrEo?Y{^z3}Lr<(t62F)v3({HaO_~VarV^C^T_wJ8Q ku7BMB2L2V-*?F)hZTgRXdHcE#^8fh-dP~&}?lUj|0K#<w`2YX_ literal 0 HcmV?d00001 diff --git a/src/modules/_Crypto/lib/descore/desdata.c b/src/modules/_Crypto/lib/descore/desdata.c new file mode 100644 index 0000000000..03776533f6 --- /dev/null +++ b/src/modules/_Crypto/lib/descore/desdata.c @@ -0,0 +1,193 @@ +/* + * des - fast & portable DES encryption & decryption. + * Copyright (C) 1992 Dana L. How + * Please see the file `README' for the complete copyright notice. + * + * Generate tables used by desUtil.c and desCode.h. + */ + +#ifndef lint +static char desdata_cRcs[] = "$Id: desdata.c,v 1.1 1997/01/10 02:53:10 nisse Exp $"; +#endif + +#include "desinfo.h" + +#include "desCode.h" + +/* list of weak and semi-weak keys + + +0 +1 +2 +3 +4 +5 +6 +7 + 0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01 + 0x01 0x1f 0x01 0x1f 0x01 0x0e 0x01 0x0e + 0x01 0xe0 0x01 0xe0 0x01 0xf1 0x01 0xf1 + 0x01 0xfe 0x01 0xfe 0x01 0xfe 0x01 0xfe + 0x1f 0x01 0x1f 0x01 0x0e 0x01 0x0e 0x01 + 0x1f 0x1f 0x1f 0x1f 0x0e 0x0e 0x0e 0x0e + 0x1f 0xe0 0x1f 0xe0 0x0e 0xf1 0x0e 0xf1 + 0x1f 0xfe 0x1f 0xfe 0x0e 0xfe 0x0e 0xfe + 0xe0 0x01 0xe0 0x01 0xf1 0x01 0xf1 0x01 + 0xe0 0x1f 0xe0 0x1f 0xf1 0x0e 0xf1 0x0e + 0xe0 0xe0 0xe0 0xe0 0xf1 0xf1 0xf1 0xf1 + 0xe0 0xfe 0xe0 0xfe 0xf1 0xfe 0xf1 0xfe + 0xfe 0x01 0xfe 0x01 0xfe 0x01 0xfe 0x01 + 0xfe 0x1f 0xfe 0x1f 0xfe 0x0e 0xfe 0x0e + 0xfe 0xe0 0xfe 0xe0 0xfe 0xf1 0xfe 0xf1 + 0xfe 0xfe 0xfe 0xfe 0xfe 0xfe 0xfe 0xfe + */ + +/* key bit order in each method pair: bits 31->00 of 1st, bits 31->00 of 2nd */ +/* this does not reflect the rotate of the 2nd word */ + +#define S(box,bit) (box*6+bit) +int korder[] = { + S(7, 5), S(7, 4), S(7, 3), S(7, 2), S(7, 1), S(7, 0), + S(5, 5), S(5, 4), S(5, 3), S(5, 2), S(5, 1), S(5, 0), + S(3, 5), S(3, 4), S(3, 3), S(3, 2), S(3, 1), S(3, 0), + S(1, 5), S(1, 4), S(1, 3), S(1, 2), S(1, 1), S(1, 0), + S(6, 5), S(6, 4), S(6, 3), S(6, 2), S(6, 1), S(6, 0), + S(4, 5), S(4, 4), S(4, 3), S(4, 2), S(4, 1), S(4, 0), + S(2, 5), S(2, 4), S(2, 3), S(2, 2), S(2, 1), S(2, 0), + S(0, 5), S(0, 4), S(0, 3), S(0, 2), S(0, 1), S(0, 0), +}; + +/* the order in which the algorithm accesses the s boxes */ + +int sorder[] = { + 7, 5, 3, 1, 6, 4, 2, 0, +}; + +int +main(argc, argv) +int argc; +char *argv[]; +{ + word d, i, j, k, l, m, n, s; + char b[256], ksr[56]; + extern printf(); + + switch ( argv[1][0] ) { + + /* + * <<< make the key parity table >>> + */ + +case 'p': + (void)printf( +"/* automagically produced - do not fuss with this information */\n\n"); + + /* store parity information */ + for ( i = 0; i < 256; i++ ) { + j = i; + j ^= j >> 4; /* bits 3-0 have pairs */ + j ^= j << 2; /* bits 3-2 have quads */ + j ^= j << 1; /* bit 3 has the entire eight (no cox) */ + b[i] = 8 & ~j; /* 0 is okay and 8 is bad parity */ + } + + /* only these characters can appear in a weak key */ + b[0x01] = 1; + b[0x0e] = 2; + b[0x1f] = 3; + b[0xe0] = 4; + b[0xf1] = 5; + b[0xfe] = 6; + + /* print it out */ + for ( i = 0; i < 256; i++ ) { + (void)printf("%d,", b[i]); + if ( (i & 31) == 31 ) + (void)printf("\n"); + } + + break; + + + /* + * <<< make the key usage table >>> + */ + +case 'r': + (void)printf("/* automagically made - do not fuss with this */\n\n"); + + /* KL specifies the initial key bit positions */ + for (i = 0; i < 56; i++) + ksr[i] = (KL[i] - 1) ^ 7; + + for (i = 0; i < 16; i++) { + + /* apply the appropriate number of left shifts */ + for (j = 0; j < KS[i]; j++) { + m = ksr[ 0]; + n = ksr[28]; + for (k = 0; k < 27; k++) + ksr[k ] = ksr[k + 1], + ksr[k + 28] = ksr[k + 29]; + ksr[27] = m; + ksr[55] = n; + } + + /* output the key bit numbers */ + for (j = 0; j < 48; j++) { + m = ksr[KC[korder[j]] - 1]; + m = (m / 8) * 7 + (m % 8) - 1; + m = 55 - m; + (void)printf(" %2d,", m); + if ((j % 12) == 11) + (void)printf("\n"); + } + (void)printf("\n"); + } + + break; + + + /* + * <<< make the keymap table >>> + */ + +case 'k': + (void)printf("/* automagically made - do not fuss with this */\n\n"); + + for ( i = 0; i <= 7 ; i++ ) { + s = sorder[i]; + for ( d = 0; d <= 63; d++ ) { + /* flip bits */ + k = ((d << 5) & 32) | + ((d << 3) & 16) | + ((d << 1) & 8) | + ((d >> 1) & 4) | + ((d >> 3) & 2) | + ((d >> 5) & 1) ; + /* more bit twiddling */ + l = ((k << 0) & 32) | /* overlap bit */ + ((k << 4) & 16) | /* overlap bit */ + ((k >> 1) & 15) ; /* unique bits */ + /* look up s box value */ + m = SB[s][l]; + /* flip bits */ + n = ((m << 3) & 8) | + ((m << 1) & 4) | + ((m >> 1) & 2) | + ((m >> 3) & 1) ; + /* put in correct nybble */ + n <<= (s << 2); + /* perform p permutation */ + for ( m = j = 0; j < 32; j++ ) + if ( n & (1 << (SP[j] - 1)) ) + m |= (1 << j); + /* rotate right (alg keeps everything rotated by 1) */ + ROR(m, 1, 31); + /* print it out */ + (void)printf(" 0x%08lx,", m); + if ( ( d & 3 ) == 3 ) + (void)printf("\n"); + } + (void)printf("\n"); + } + + break; + + } + + return 0; +} diff --git a/src/modules/_Crypto/lib/descore/desinfo.h b/src/modules/_Crypto/lib/descore/desinfo.h new file mode 100644 index 0000000000..1b30c987bf --- /dev/null +++ b/src/modules/_Crypto/lib/descore/desinfo.h @@ -0,0 +1,96 @@ +/* + * des - fast & portable DES encryption & decryption. + * Copyright (C) 1992 Dana L. How + * Please see the file `README' for the complete copyright notice. + * + * Tables describing DES rather than just this implementation. + * These are used in desdata but NOT in runtime code. + */ + +#ifndef lint +static char desinfo_hRcs[] = "$Id: desinfo.h,v 1.1 1997/01/10 02:53:16 nisse Exp $"; +#endif + +/* the initial permutation, E selection, and final permutation are hardwired */ + +/* Key Load: how to load the shift register from the user key */ + +char KL[] = { + + 57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, + 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36, + + 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22, + 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4, +}; + +/* Key Shift: how many times to shift the key shift register */ + +char KS[] = { + + 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1, +}; + +/* Key Choose: which key bits from shift reg are used in the key schedule */ + +char KC[] = { + + 14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, + 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2, + + 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48, + 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32, +}; + +/* S Boxes */ + +char SB[8][64] = { + + 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7, + 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8, + 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0, + 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13, + + 15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10, + 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5, + 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15, + 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9, + + 10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8, + 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1, + 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7, + 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12, + + 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15, + 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9, + 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4, + 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14, + + 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9, + 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6, + 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14, + 11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3, + + 12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11, + 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8, + 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6, + 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13, + + 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1, + 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6, + 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2, + 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12, + + 13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7, + 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2, + 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8, + 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11 +}; + +/* Sbox Permutation */ + +char SP[] = { + + 16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10, + 2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25, +}; -- GitLab