Paul Bakker | 7a7c78f | 2009-01-04 18:15:48 +0000 | [diff] [blame] | 1 | /** |
| 2 | * \file xtea.h |
| 3 | * |
Paul Bakker | 785a9ee | 2009-01-25 14:15:10 +0000 | [diff] [blame] | 4 | * Copyright (C) 2009 Paul Bakker <polarssl_maintainer at polarssl dot org> |
Paul Bakker | 7a7c78f | 2009-01-04 18:15:48 +0000 | [diff] [blame] | 5 | * |
| 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 Bakker | 0fdf3ca | 2009-05-03 12:54:07 +0000 | [diff] [blame] | 23 | #include <inttypes.h> |
| 24 | |
Paul Bakker | 7a7c78f | 2009-01-04 18:15:48 +0000 | [diff] [blame] | 25 | #define XTEA_ENCRYPT 1 |
| 26 | #define XTEA_DECRYPT 0 |
| 27 | |
| 28 | |
| 29 | /** |
| 30 | * \brief XTEA context structure |
| 31 | */ |
| 32 | typedef struct |
| 33 | { |
Paul Bakker | 0fdf3ca | 2009-05-03 12:54:07 +0000 | [diff] [blame] | 34 | uint32_t k[4]; /*!< key */ |
Paul Bakker | 7a7c78f | 2009-01-04 18:15:48 +0000 | [diff] [blame] | 35 | } |
| 36 | xtea_context; |
| 37 | |
| 38 | #ifdef __cplusplus |
| 39 | extern "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 | */ |
| 48 | void 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 | */ |
| 58 | void 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 | */ |
| 68 | int xtea_self_test( int verbose ); |
| 69 | |
| 70 | #ifdef __cplusplus |
| 71 | } |
| 72 | #endif |
| 73 | |
| 74 | #endif /* xtea.h */ |