Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* |
michael@0 | 2 | * des.h |
michael@0 | 3 | * |
michael@0 | 4 | * header file for DES-150 library |
michael@0 | 5 | * |
michael@0 | 6 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 7 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 8 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 9 | |
michael@0 | 10 | #ifndef _DES_H_ |
michael@0 | 11 | #define _DES_H_ 1 |
michael@0 | 12 | |
michael@0 | 13 | #include "blapi.h" |
michael@0 | 14 | |
michael@0 | 15 | typedef unsigned char BYTE; |
michael@0 | 16 | typedef unsigned int HALF; |
michael@0 | 17 | |
michael@0 | 18 | #define HALFPTR(x) ((HALF *)(x)) |
michael@0 | 19 | #define SHORTPTR(x) ((unsigned short *)(x)) |
michael@0 | 20 | #define BYTEPTR(x) ((BYTE *)(x)) |
michael@0 | 21 | |
michael@0 | 22 | typedef enum { |
michael@0 | 23 | DES_ENCRYPT = 0x5555, |
michael@0 | 24 | DES_DECRYPT = 0xAAAA |
michael@0 | 25 | } DESDirection; |
michael@0 | 26 | |
michael@0 | 27 | typedef void DESFunc(struct DESContextStr *cx, BYTE *out, const BYTE *in, |
michael@0 | 28 | unsigned int len); |
michael@0 | 29 | |
michael@0 | 30 | struct DESContextStr { |
michael@0 | 31 | /* key schedule, 16 internal keys, each with 8 6-bit parts */ |
michael@0 | 32 | HALF ks0 [32]; |
michael@0 | 33 | HALF ks1 [32]; |
michael@0 | 34 | HALF ks2 [32]; |
michael@0 | 35 | HALF iv [2]; |
michael@0 | 36 | DESDirection direction; |
michael@0 | 37 | DESFunc *worker; |
michael@0 | 38 | }; |
michael@0 | 39 | |
michael@0 | 40 | void DES_MakeSchedule( HALF * ks, const BYTE * key, DESDirection direction); |
michael@0 | 41 | void DES_Do1Block( HALF * ks, const BYTE * inbuf, BYTE * outbuf); |
michael@0 | 42 | |
michael@0 | 43 | #endif |