#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===============================================================================36License3738des56.c is licensed under the terms of the MIT license reproduced below.39This means that des56.c is free software and can be used for both academic40and commercial purposes at absolutely no cost.41===============================================================================42Copyright (C) 1988 Stuart Levy4344Permission is hereby granted, free of charge, to any person obtaining a copy45of this software and associated documentation files (the "Software"), to deal46in the Software without restriction, including without limitation the rights47to use, copy, modify, merge, publish, distribute, sublicense, and/or sell48copies of the Software, and to permit persons to whom the Software is49furnished to do so, subject to the following conditions:5051The above copyright notice and this permission notice shall be included in52all copies or substantial portions of the Software.5354THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR55IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,56FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE57AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER58LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,59OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN60THE SOFTWARE.61*/6263typedef unsigned long word32;64typedef unsigned char tiny;6566typedef struct keystage {67word32 h, l;68} keystage;6970typedef struct keysched {71keystage KS[16];72} keysched;7374extern void fsetkey(char key[8], keysched *ks);7576extern void fencrypt(char block[8], int decrypt, keysched *ks);7778#endif /*DES56_H*/79808182