andre@0: /* andre@0: * des.h andre@0: * andre@0: * header file for DES-150 library andre@0: * andre@0: * This Source Code Form is subject to the terms of the Mozilla Public andre@0: * License, v. 2.0. If a copy of the MPL was not distributed with this andre@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ andre@0: andre@0: #ifndef _DES_H_ andre@0: #define _DES_H_ 1 andre@0: andre@0: #include "blapi.h" andre@0: andre@0: typedef unsigned char BYTE; andre@0: typedef unsigned int HALF; andre@0: andre@0: #define HALFPTR(x) ((HALF *)(x)) andre@0: #define SHORTPTR(x) ((unsigned short *)(x)) andre@0: #define BYTEPTR(x) ((BYTE *)(x)) andre@0: andre@0: typedef enum { andre@0: DES_ENCRYPT = 0x5555, andre@0: DES_DECRYPT = 0xAAAA andre@0: } DESDirection; andre@0: andre@0: typedef void DESFunc(struct DESContextStr *cx, BYTE *out, const BYTE *in, andre@0: unsigned int len); andre@0: andre@0: struct DESContextStr { andre@0: /* key schedule, 16 internal keys, each with 8 6-bit parts */ andre@0: HALF ks0 [32]; andre@0: HALF ks1 [32]; andre@0: HALF ks2 [32]; andre@0: HALF iv [2]; andre@0: DESDirection direction; andre@0: DESFunc *worker; andre@0: }; andre@0: andre@0: void DES_MakeSchedule( HALF * ks, const BYTE * key, DESDirection direction); andre@0: void DES_Do1Block( HALF * ks, const BYTE * inbuf, BYTE * outbuf); andre@0: andre@0: #endif