blob: 9d3dadd8ff69393c0b4f8e80d9de0417e44b06a5 [file] [log] [blame]
Paul Bakker7a7c78f2009-01-04 18:15:48 +00001/**
2 * \file xtea.h
3 *
Paul Bakker77b385e2009-07-28 17:23:11 +00004 * Copyright (C) 2006-2009, Paul Bakker <polarssl_maintainer at polarssl.org>
5 * All rights reserved.
Paul Bakker7a7c78f2009-01-04 18:15:48 +00006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */
21#ifndef POLARSSL_XTEA_H
22#define POLARSSL_XTEA_H
23
Paul Bakker53443e42009-10-04 15:22:11 +000024#ifdef _MSC_VER
25#include <basetsd.h>
26typedef UINT32 uint32_t;
27#else
28#include <inttypes.h>
Paul Bakker80ab9f52009-05-24 14:42:46 +000029#endif
Paul Bakker0fdf3ca2009-05-03 12:54:07 +000030
Paul Bakker7a7c78f2009-01-04 18:15:48 +000031#define XTEA_ENCRYPT 1
32#define XTEA_DECRYPT 0
33
34
35/**
36 * \brief XTEA context structure
37 */
38typedef struct
39{
Paul Bakker0fdf3ca2009-05-03 12:54:07 +000040 uint32_t k[4]; /*!< key */
Paul Bakker7a7c78f2009-01-04 18:15:48 +000041}
42xtea_context;
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48/**
49 * \brief XTEA key schedule
50 *
51 * \param ctx XTEA context to be initialized
52 * \param key the secret key
53 */
54void xtea_setup( xtea_context *ctx, unsigned char key[16] );
55
56/**
57 * \brief XTEA cipher function
58 *
59 * \param ctx XTEA context
60 * \param mode XTEA_ENCRYPT or XTEA_DECRYPT
61 * \param input 8-byte input block
62 * \param output 8-byte output block
63 */
Paul Bakkere5c19aa2009-07-08 06:43:40 +000064void xtea_crypt_ecb( xtea_context *ctx,
Paul Bakker7a7c78f2009-01-04 18:15:48 +000065 int mode,
66 unsigned char input[8],
67 unsigned char output[8] );
68
69/*
70 * \brief Checkup routine
71 *
72 * \return 0 if successful, or 1 if the test failed
73 */
74int xtea_self_test( int verbose );
75
76#ifdef __cplusplus
77}
78#endif
79
80#endif /* xtea.h */