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