blob: 14abe39e57203fc65479ee4ab367d3e320b9e5ed [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/**
2 * \file arc4.h
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00003 *
Paul Bakker77b385e2009-07-28 17:23:11 +00004 * Copyright (C) 2006-2009, Paul Bakker <polarssl_maintainer at polarssl.org>
5 * All rights reserved.
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00006 *
Paul Bakker77b385e2009-07-28 17:23:11 +00007 * Joined copyright on original XySSL code with: Christophe Devine
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00008 *
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 Bakker5121ce52009-01-03 21:22:43 +000022 */
Paul Bakker40e46942009-01-03 21:51:57 +000023#ifndef POLARSSL_ARC4_H
24#define POLARSSL_ARC4_H
Paul Bakker5121ce52009-01-03 21:22:43 +000025
26/**
27 * \brief ARC4 context structure
28 */
29typedef struct
30{
31 int x; /*!< permutation index */
32 int y; /*!< permutation index */
33 unsigned char m[256]; /*!< permutation table */
34}
35arc4_context;
36
37#ifdef __cplusplus
38extern "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 */
Paul Bakkerff60ee62010-03-16 21:09:09 +000048void arc4_setup( arc4_context *ctx, const unsigned char *key, int keylen );
Paul Bakker5121ce52009-01-03 21:22:43 +000049
50/**
51 * \brief ARC4 cipher function
52 *
53 * \param ctx ARC4 context
Paul Bakkerbaad6502010-03-21 15:42:15 +000054 * \param length length of the input data
55 * \param input buffer holding the input data
56 * \param output buffer for the output data
Paul Bakkerf3ccc682010-03-18 21:21:02 +000057 *
Paul Bakker27caa8a2010-03-21 15:43:59 +000058 * \return 0 if successful
Paul Bakker5121ce52009-01-03 21:22:43 +000059 */
Paul Bakkerbaad6502010-03-21 15:42:15 +000060int arc4_crypt( arc4_context *ctx, int length, const unsigned char *input,
61 unsigned char *output );
Paul Bakker5121ce52009-01-03 21:22:43 +000062
63/*
64 * \brief Checkup routine
65 *
66 * \return 0 if successful, or 1 if the test failed
67 */
68int arc4_self_test( int verbose );
69
70#ifdef __cplusplus
71}
72#endif
73
74#endif /* arc4.h */