Whoops. Fix the purpose comment.
[u/mdw/catacomb] / xtea.h
1 /* -*-c-*-
2 *
3 * $Id: xtea.h,v 1.2 2000/07/15 13:47:14 mdw Exp $
4 *
5 * The Extended Tiny Encryption Algorithm
6 *
7 * (c) 2000 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: xtea.h,v $
33 * Revision 1.2 2000/07/15 13:47:14 mdw
34 * Whoops. Fix the purpose comment.
35 *
36 * Revision 1.1 2000/07/15 13:44:31 mdw
37 * New ciphers.
38 *
39 */
40
41 /*----- Notes on the Tiny Encryption Algorithm ----------------------------*
42 *
43 * XTEA is an amazingly simple 64-round Feistel network. It's tiny, fairly
44 * quick and surprisingly strong. It was invented by David Wheeler and Roger
45 * Needham. It's unpatented. XTEA is a new version of TEA, by the same
46 * designers, which fixes some weaknesses in TEA's key schedule.
47 *
48 * This implementation uses big-endian byte order, following SCAN.
49 */
50
51 #ifndef CATACOMB_XTEA_H
52 #define CATACOMB_XTEA_H
53
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57
58 /*----- Header files ------------------------------------------------------*/
59
60 #include <stddef.h>
61
62 #include <mLib/bits.h>
63
64 /*----- Magical numbers ---------------------------------------------------*/
65
66 #define XTEA_BLKSZ 8
67 #define XTEA_KEYSZ 16
68 #define XTEA_CLASS (N, B, 64)
69
70 extern const octet xtea_keysz[];
71
72 /*----- Data structures ---------------------------------------------------*/
73
74 typedef struct xtea_ctx {
75 uint32 k[4];
76 } xtea_ctx;
77
78 /*----- Functions provided ------------------------------------------------*/
79
80 /* --- @xtea_init@ --- *
81 *
82 * Arguments: @xtea_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 an XTEA key buffer. The key buffer may be up to
89 * 16 bytes long.
90 */
91
92 extern void xtea_init(xtea_ctx */*k*/, const void */*buf*/, size_t /*sz*/);
93
94 /* --- @xtea_eblk@, @xtea_dblk@ --- *
95 *
96 * Arguments: @const xtea_ctx *k@ = pointer to key block
97 * @const uint32 s[2]@ = pointer to source block
98 * @uint32 d[2]@ = pointer to xteatination block
99 *
100 * Returns: ---
101 *
102 * Use: Low-level block encryption and decryption.
103 */
104
105 extern void xtea_eblk(const xtea_ctx */*k*/,
106 const uint32 */*s*/, uint32 */*d*/);
107 extern void xtea_dblk(const xtea_ctx */*k*/,
108 const uint32 */*s*/, uint32 */*d*/);
109
110 /*----- That's all, folks -------------------------------------------------*/
111
112 #ifdef __cplusplus
113 }
114 #endif
115
116 #endif