Renamed from `rsa-decrypt', since the name was no longer appropriate.
[u/mdw/catacomb] / des3.h
CommitLineData
d03ab969 1/* -*-c-*-
2 *
89ae755d 3 * $Id: des3.h,v 1.3 2000/06/17 10:52:32 mdw Exp $
d03ab969 4 *
5 * Implementation of double- and triple-DES
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: des3.h,v $
89ae755d 33 * Revision 1.3 2000/06/17 10:52:32 mdw
34 * Support new key size interface.
35 *
b3f05084 36 * Revision 1.2 1999/12/10 23:29:48 mdw
37 * Change header file guard names.
38 *
d03ab969 39 * Revision 1.1 1999/09/03 08:41:11 mdw
40 * Initial import.
41 *
42 */
43
b3f05084 44#ifndef CATACOMB_DES3_H
45#define CATACOMB_DES3_H
d03ab969 46
47#ifdef __cplusplus
48 extern "C" {
49#endif
50
51/*----- Notes on double- and triple-DES -----------------------------------*
52 *
53 * The normal recommendation for using DES now is `triple DES'.
54 * Conventionally, this involves an encrypt-decrypt-encrypt sequence,
55 * although whether the first and last operations use the same key is
56 * unfortunately not agreed upon. This interface handles both cases (and the
57 * single-key one too, although the simple @des@ calls are quicker for that).
58 */
59
60/*----- Header files ------------------------------------------------------*/
61
62#include <stddef.h>
63
64#include <mLib/bits.h>
65
b3f05084 66#ifndef CATACOMB_DES_H
d03ab969 67# include "des.h"
68#endif
69
70/*----- Magical numbers ---------------------------------------------------*/
71
72#define DES3_BLKSZ 8
73#define DES3_KEYSZ 21
74#define DES3_CLASS (N, B, 64)
75
89ae755d 76extern const octet des3_keysz[];
77
d03ab969 78/*----- Data structures ---------------------------------------------------*/
79
80typedef struct des3_ctx {
81 des_ctx a, b, c;
82} des3_ctx;
83
84/*----- Functions provided ------------------------------------------------*/
85
86/* --- @des3_init@ --- *
87 *
88 * Arguments: @des3_ctx *k@ = pointer to key block
89 * @const void *buf@ = pointer to key buffer
90 * @size_t sz@ = size of key material
91 *
92 * Returns: ---
93 *
94 * Use: Initializes a DES key buffer. The key buffer may have length
95 * 7, 8, 14, 16, 21, or 24. These correspond to one, two or
96 * three DES keys, either packed or unpacked (i.e., still
97 * containing parity bits).
98 */
99
100extern void des3_init(des3_ctx */*k*/, const void */*buf*/, size_t /*sz*/);
101
102/* --- @des3_eblk@, @des_dblk@ --- *
103 *
104 * Arguments: @const des3_ctx *k@ = pointer to key block
105 * @const uint32 s[2]@ = pointer to source block
106 * @uint32 d[2]@ = pointer to destination block
107 *
108 * Returns: ---
109 *
110 * Use: Low-level block encryption and decryption.
111 */
112
113extern void des3_eblk(const des3_ctx */*k*/,
114 const uint32 */*s*/, uint32 */*d*/);
115extern void des3_dblk(const des3_ctx */*k*/,
116 const uint32 */*s*/, uint32 */*d*/);
117
118/*----- That's all, folks -------------------------------------------------*/
119
120#ifdef __cplusplus
121 }
122#endif
123
124#endif