c227ec5c86a185cd26eb2f3df973b96ed64bd9f9
3 * $Id: tea.h,v 1.1 2000/07/15 13:44:31 mdw Exp $
5 * The Tiny Encryption Algorithm
7 * (c) 2000 Straylight/Edgeware
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of Catacomb.
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.
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.
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,
30 /*----- Revision history --------------------------------------------------*
33 * Revision 1.1 2000/07/15 13:44:31 mdw
38 /*----- Notes on the Tiny Encryption Algorithm ----------------------------*
40 * TEA is an amazingly simple 64-round Feistel network. It's tiny, fairly
41 * quick and surprisingly strong. It was invented by David Wheeler and Roger
42 * Needham. It's unpatented. The keyspace is has only 126 effective bits,
43 * and there are related-key attacks. If you want these fixed, use XTEA.
45 * This implementation uses big-endian byte order, following SCAN.
48 #ifndef CATACOMB_TEA_H
49 #define CATACOMB_TEA_H
55 /*----- Header files ------------------------------------------------------*/
59 #include <mLib/bits.h>
61 /*----- Magical numbers ---------------------------------------------------*/
65 #define TEA_CLASS (N, B, 64)
67 extern const octet tea_keysz
[];
69 /*----- Data structures ---------------------------------------------------*/
71 typedef struct tea_ctx
{
72 uint32 ka
, kb
, kc
, kd
;
75 /*----- Functions provided ------------------------------------------------*/
77 /* --- @tea_init@ --- *
79 * Arguments: @tea_ctx *k@ = pointer to key block
80 * @const void *buf@ = pointer to key buffer
81 * @size_t sz@ = size of key material
85 * Use: Initializes a TEA key buffer. The key buffer may be up to 16
89 extern void tea_init(tea_ctx */
*k*/
, const void */
*buf*/
, size_t /*sz*/);
91 /* --- @tea_eblk@, @tea_dblk@ --- *
93 * Arguments: @const tea_ctx *k@ = pointer to key block
94 * @const uint32 s[2]@ = pointer to source block
95 * @uint32 d[2]@ = pointer to teatination block
99 * Use: Low-level block encryption and decryption.
102 extern void tea_eblk(const tea_ctx */
*k*/
,
103 const uint32 */
*s*/
, uint32 */
*d*/
);
104 extern void tea_dblk(const tea_ctx */
*k*/
,
105 const uint32 */
*s*/
, uint32 */
*d*/
);
107 /*----- That's all, folks -------------------------------------------------*/