#ifndef DES56_H1#define DES56_H 12/*3* Fast implementation of the DES, as described in the Federal Register,4* Vol. 40, No. 52, p. 12134, March 17, 1975.5*6* Stuart Levy, Minnesota Supercomputer Center, April 1988.7* Currently (2007) [email protected]8* NCSA, University of Illinois Urbana-Champaign9*10* Calling sequence:11*12* typedef unsigned long keysched[32];13*14* fsetkey(key, keysched) / * Converts a DES key to a "key schedule" * /15* unsigned char key[8];16* keysched *ks;17*18* fencrypt(block, decrypt, keysched) / * En/decrypts one 64-bit block * /19* unsigned char block[8]; / * data, en/decrypted in place * /20* int decrypt; / * 0=>encrypt, 1=>decrypt * /21* keysched *ks; / * key schedule, as set by fsetkey * /22*23* Key and data block representation:24* The 56-bit key (bits 1..64 including "parity" bits 8, 16, 24, ..., 64)25* and the 64-bit data block (bits 1..64)26* are each stored in arrays of 8 bytes.27* Following the NBS numbering, the MSB has the bit number 1, so28* key[0] = 128*bit1 + 64*bit2 + ... + 1*bit8, ... through29* key[7] = 128*bit57 + 64*bit58 + ... + 1*bit64.30* In the key, "parity" bits are not checked; their values are ignored.31*32*/3334/*35===============================================================================36License37des56.c is licensed under the terms of the MIT license reproduced below.38This means that des56.c is free software and can be used for both academic39and commercial purposes at absolutely no cost.40===============================================================================41Copyright (C) 1988 Stuart Levy42Permission is hereby granted, free of charge, to any person obtaining a copy43of this software and associated documentation files (the "Software"), to deal44in the Software without restriction, including without limitation the rights45to use, copy, modify, merge, publish, distribute, sublicense, and/or sell46copies of the Software, and to permit persons to whom the Software is47furnished to do so, subject to the following conditions:48The above copyright notice and this permission notice shall be included in49all copies or substantial portions of the Software.50THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR51IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,52FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE53AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER54LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,55OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN56THE SOFTWARE.57*/5859typedef unsigned long word32;60typedef unsigned char tiny;6162typedef struct keysched {63struct keystage {64word32 h, l;65} KS[16];66} keysched;6768extern void fsetkey(char key[8], keysched *ks);6970extern void fencrypt(char block[8], int decrypt, keysched *ks);7172#endif /*DES56_H*/7374