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 | 77b385e | 2009-07-28 17:23:11 +0000 | [diff] [blame] | 4 | * Copyright (C) 2006-2009, Paul Bakker <polarssl_maintainer at polarssl.org> |
| 5 | * All rights reserved. |
Paul Bakker | e0ccd0a | 2009-01-04 16:27:10 +0000 | [diff] [blame] | 6 | * |
Paul Bakker | 77b385e | 2009-07-28 17:23:11 +0000 | [diff] [blame] | 7 | * Joined copyright on original XySSL code with: Christophe Devine |
Paul Bakker | e0ccd0a | 2009-01-04 16:27:10 +0000 | [diff] [blame] | 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License along |
| 20 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 22 | */ |
Paul Bakker | 40e4694 | 2009-01-03 21:51:57 +0000 | [diff] [blame] | 23 | #ifndef POLARSSL_ARC4_H |
| 24 | #define POLARSSL_ARC4_H |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 25 | |
| 26 | /** |
| 27 | * \brief ARC4 context structure |
| 28 | */ |
| 29 | typedef struct |
| 30 | { |
| 31 | int x; /*!< permutation index */ |
| 32 | int y; /*!< permutation index */ |
| 33 | unsigned char m[256]; /*!< permutation table */ |
| 34 | } |
| 35 | arc4_context; |
| 36 | |
| 37 | #ifdef __cplusplus |
| 38 | extern "C" { |
| 39 | #endif |
| 40 | |
| 41 | /** |
| 42 | * \brief ARC4 key schedule |
| 43 | * |
| 44 | * \param ctx ARC4 context to be initialized |
| 45 | * \param key the secret key |
| 46 | * \param keylen length of the key |
| 47 | */ |
| 48 | void arc4_setup( arc4_context *ctx, unsigned char *key, int keylen ); |
| 49 | |
| 50 | /** |
| 51 | * \brief ARC4 cipher function |
| 52 | * |
| 53 | * \param ctx ARC4 context |
| 54 | * \param buf buffer to be processed |
| 55 | * \param buflen amount of data in buf |
| 56 | */ |
| 57 | void arc4_crypt( arc4_context *ctx, unsigned char *buf, int buflen ); |
| 58 | |
| 59 | /* |
| 60 | * \brief Checkup routine |
| 61 | * |
| 62 | * \return 0 if successful, or 1 if the test failed |
| 63 | */ |
| 64 | int arc4_self_test( int verbose ); |
| 65 | |
| 66 | #ifdef __cplusplus |
| 67 | } |
| 68 | #endif |
| 69 | |
| 70 | #endif /* arc4.h */ |