blob: 770ecc2b58844dd303d14ce6f284ecd70a56712a [file] [log] [blame]
Paul Bakker7a7c78f2009-01-04 18:15:48 +00001/**
2 * \file xtea.h
3 *
Paul Bakker27db1f52009-01-25 15:27:00 +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
23#define XTEA_ENCRYPT 1
24#define XTEA_DECRYPT 0
25
26
27/**
28 * \brief XTEA context structure
29 */
30typedef struct
31{
32 unsigned long k[4]; /*!< key */
33}
34xtea_context;
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
40/**
41 * \brief XTEA key schedule
42 *
43 * \param ctx XTEA context to be initialized
44 * \param key the secret key
45 */
46void xtea_setup( xtea_context *ctx, unsigned char key[16] );
47
48/**
49 * \brief XTEA cipher function
50 *
51 * \param ctx XTEA context
52 * \param mode XTEA_ENCRYPT or XTEA_DECRYPT
53 * \param input 8-byte input block
54 * \param output 8-byte output block
55 */
56void xtea_crypt( xtea_context *ctx,
57 int mode,
58 unsigned char input[8],
59 unsigned char output[8] );
60
61/*
62 * \brief Checkup routine
63 *
64 * \return 0 if successful, or 1 if the test failed
65 */
66int xtea_self_test( int verbose );
67
68#ifdef __cplusplus
69}
70#endif
71
72#endif /* xtea.h */