Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 1 | /** |
| 2 | * \file arc4.h |
Paul Bakker | e0ccd0a | 2009-01-04 16:27:10 +0000 | [diff] [blame] | 3 | * |
Paul Bakker | 83ded91 | 2010-03-21 17:46:26 +0000 | [diff] [blame] | 4 | * Copyright (C) 2006-2010, Paul Bakker <polarssl_maintainer at polarssl.org> |
Paul Bakker | 77b385e | 2009-07-28 17:23:11 +0000 | [diff] [blame] | 5 | * All rights reserved. |
Paul Bakker | e0ccd0a | 2009-01-04 16:27:10 +0000 | [diff] [blame] | 6 | * |
Paul Bakker | e0ccd0a | 2009-01-04 16:27:10 +0000 | [diff] [blame] | 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. |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 20 | */ |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 21 | #ifndef POLARSSL_ARC4_H |
| 22 | #define POLARSSL_ARC4_H |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 23 | |
| 24 | /** |
| 25 | * \brief ARC4 context structure |
| 26 | */ |
| 27 | typedef struct |
| 28 | { |
| 29 | int x; /*!< permutation index */ |
| 30 | int y; /*!< permutation index */ |
| 31 | unsigned char m[256]; /*!< permutation table */ |
| 32 | } |
| 33 | arc4_context; |
| 34 | |
| 35 | #ifdef __cplusplus |
| 36 | extern "C" { |
| 37 | #endif |
| 38 | |
| 39 | /** |
| 40 | * \brief ARC4 key schedule |
| 41 | * |
| 42 | * \param ctx ARC4 context to be initialized |
| 43 | * \param key the secret key |
| 44 | * \param keylen length of the key |
| 45 | */ |
Paul Bakker | ff60ee6 | 2010-03-16 21:09:09 +0000 | [diff] [blame] | 46 | void arc4_setup( arc4_context *ctx, const unsigned char *key, int keylen ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 47 | |
| 48 | /** |
| 49 | * \brief ARC4 cipher function |
| 50 | * |
| 51 | * \param ctx ARC4 context |
Paul Bakker | baad650 | 2010-03-21 15:42:15 +0000 | [diff] [blame] | 52 | * \param length length of the input data |
| 53 | * \param input buffer holding the input data |
| 54 | * \param output buffer for the output data |
Paul Bakker | f3ccc68 | 2010-03-18 21:21:02 +0000 | [diff] [blame] | 55 | * |
Paul Bakker | 27caa8a | 2010-03-21 15:43:59 +0000 | [diff] [blame] | 56 | * \return 0 if successful |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 57 | */ |
Paul Bakker | baad650 | 2010-03-21 15:42:15 +0000 | [diff] [blame] | 58 | int arc4_crypt( arc4_context *ctx, int length, const unsigned char *input, |
| 59 | unsigned char *output ); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 60 | |
| 61 | /* |
| 62 | * \brief Checkup routine |
| 63 | * |
| 64 | * \return 0 if successful, or 1 if the test failed |
| 65 | */ |
| 66 | int arc4_self_test( int verbose ); |
| 67 | |
| 68 | #ifdef __cplusplus |
| 69 | } |
| 70 | #endif |
| 71 | |
| 72 | #endif /* arc4.h */ |