tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

des.h (1037B)


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