blob: fe16ba3e98311fe606bde34d8dbd1a69626764d9 [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 Bakker80ab9f52009-05-24 14:42:46 +000023#ifdef _MSC_VER
24#include <basetsd.h>
25typedef UINT32 uint32_t;
26#else
27#include <inttypes.h>
28#endif
Paul Bakker0fdf3ca2009-05-03 12:54:07 +000029
Paul Bakker7a7c78f2009-01-04 18:15:48 +000030#define XTEA_ENCRYPT 1
31#define XTEA_DECRYPT 0
32
33
34/**
35 * \brief XTEA context structure
36 */
37typedef struct
38{
Paul Bakker0fdf3ca2009-05-03 12:54:07 +000039 uint32_t k[4]; /*!< key */
Paul Bakker7a7c78f2009-01-04 18:15:48 +000040}
41xtea_context;
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
47/**
48 * \brief XTEA key schedule
49 *
50 * \param ctx XTEA context to be initialized
51 * \param key the secret key
52 */
53void xtea_setup( xtea_context *ctx, unsigned char key[16] );
54
55/**
56 * \brief XTEA cipher function
57 *
58 * \param ctx XTEA context
59 * \param mode XTEA_ENCRYPT or XTEA_DECRYPT
60 * \param input 8-byte input block
61 * \param output 8-byte output block
62 */
63void xtea_crypt( xtea_context *ctx,
64 int mode,
65 unsigned char input[8],
66 unsigned char output[8] );
67
68/*
69 * \brief Checkup routine
70 *
71 * \return 0 if successful, or 1 if the test failed
72 */
73int xtea_self_test( int verbose );
74
75#ifdef __cplusplus
76}
77#endif
78
79#endif /* xtea.h */