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