Change header file guard names.
[u/mdw/catacomb] / des.h
CommitLineData
d03ab969 1/* -*-c-*-
2 *
b3f05084 3 * $Id: des.h,v 1.2 1999/12/10 23:29:48 mdw Exp $
d03ab969 4 *
5 * The Data Encryption Standard
6 *
7 * (c) 1999 Straylight/Edgeware
8 */
9
10/*----- Licensing notice --------------------------------------------------*
11 *
12 * This file is part of Catacomb.
13 *
14 * Catacomb is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU Library General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
18 *
19 * Catacomb is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Library General Public License for more details.
23 *
24 * You should have received a copy of the GNU Library General Public
25 * License along with Catacomb; if not, write to the Free
26 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
27 * MA 02111-1307, USA.
28 */
29
30/*----- Revision history --------------------------------------------------*
31 *
32 * $Log: des.h,v $
b3f05084 33 * Revision 1.2 1999/12/10 23:29:48 mdw
34 * Change header file guard names.
35 *
d03ab969 36 * Revision 1.1 1999/09/03 08:41:11 mdw
37 * Initial import.
38 *
39 */
40
41/*----- Notes on the Data Encryption Standard -----------------------------*
42 *
43 * Almost twenty years after it was first accepted, DES is still the standard
44 * block cipher. It's showing its age in its small key size and poor
45 * optimiziation for software implementations, but it's not really been badly
46 * dented by the intensive analysis thrown at it.
47 *
48 * This interface is here for compatibility with existing protocols, and
49 * because it's a trivial veneer over the base DES code which is used by the
50 * @des3@ interface which implements proper strong triple-DES.
51 */
52
b3f05084 53#ifndef CATACOMB_DES_H
54#define CATACOMB_DES_H
d03ab969 55
56#ifdef __cplusplus
57 extern "C" {
58#endif
59
60/*----- Header files ------------------------------------------------------*/
61
62#include <stddef.h>
63
64#include <mLib/bits.h>
65
66/*----- Magical numbers ---------------------------------------------------*/
67
68#define DES_BLKSZ 8
69#define DES_KEYSZ 7
70#define DES_CLASS (N, B, 64)
71
72/*----- Data structures ---------------------------------------------------*/
73
74typedef struct des_ctx {
75 uint32 k[32];
76} des_ctx;
77
78/*----- Functions provided ------------------------------------------------*/
79
80/* --- @des_init@ --- *
81 *
82 * Arguments: @des_ctx *k@ = pointer to key block
83 * @const void *buf@ = pointer to key buffer
84 * @size_t sz@ = size of key material
85 *
86 * Returns: ---
87 *
88 * Use: Initializes a DES key buffer. The key buffer may be either 7
89 * or 8 bytes long. If it's 8 bytes, the key is assumed to be
90 * padded with parity bits in the low order bit of each octet.
91 * These are stripped out without checking prior to the actual
92 * key scheduling.
93 */
94
95extern void des_init(des_ctx */*k*/, const void */*buf*/, size_t /*sz*/);
96
97/* --- @des_eblk@, @des_dblk@ --- *
98 *
99 * Arguments: @const des_ctx *k@ = pointer to key block
100 * @const uint32 s[2]@ = pointer to source block
101 * @uint32 d[2]@ = pointer to destination block
102 *
103 * Returns: ---
104 *
105 * Use: Low-level block encryption and decryption.
106 */
107
108extern void des_eblk(const des_ctx */*k*/,
109 const uint32 */*s*/, uint32 */*d*/);
110extern void des_dblk(const des_ctx */*k*/,
111 const uint32 */*s*/, uint32 */*d*/);
112
113/*----- That's all, folks -------------------------------------------------*/
114
115#ifdef __cplusplus
116 }
117#endif
118
119#endif