blob: d9077de642f7e3eac3c652f6530777c72163d6ed [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/**
2 * \file arc4.h
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00003 *
Paul Bakker84f12b72010-07-18 10:13:04 +00004 * Copyright (C) 2006-2010, Brainspark B.V.
5 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
Paul Bakker77b385e2009-07-28 17:23:11 +00006 * All rights reserved.
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00007 *
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00008 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Paul Bakker5121ce52009-01-03 21:22:43 +000021 */
Paul Bakker40e46942009-01-03 21:51:57 +000022#ifndef POLARSSL_ARC4_H
23#define POLARSSL_ARC4_H
Paul Bakker5121ce52009-01-03 21:22:43 +000024
25/**
26 * \brief ARC4 context structure
27 */
28typedef struct
29{
30 int x; /*!< permutation index */
31 int y; /*!< permutation index */
32 unsigned char m[256]; /*!< permutation table */
33}
34arc4_context;
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
40/**
41 * \brief ARC4 key schedule
42 *
43 * \param ctx ARC4 context to be initialized
44 * \param key the secret key
45 * \param keylen length of the key
46 */
Paul Bakkerff60ee62010-03-16 21:09:09 +000047void arc4_setup( arc4_context *ctx, const unsigned char *key, int keylen );
Paul Bakker5121ce52009-01-03 21:22:43 +000048
49/**
50 * \brief ARC4 cipher function
51 *
52 * \param ctx ARC4 context
Paul Bakkerbaad6502010-03-21 15:42:15 +000053 * \param length length of the input data
54 * \param input buffer holding the input data
55 * \param output buffer for the output data
Paul Bakkerf3ccc682010-03-18 21:21:02 +000056 *
Paul Bakker27caa8a2010-03-21 15:43:59 +000057 * \return 0 if successful
Paul Bakker5121ce52009-01-03 21:22:43 +000058 */
Paul Bakkerbaad6502010-03-21 15:42:15 +000059int arc4_crypt( arc4_context *ctx, int length, const unsigned char *input,
60 unsigned char *output );
Paul Bakker5121ce52009-01-03 21:22:43 +000061
62/*
63 * \brief Checkup routine
64 *
65 * \return 0 if successful, or 1 if the test failed
66 */
67int arc4_self_test( int verbose );
68
69#ifdef __cplusplus
70}
71#endif
72
73#endif /* arc4.h */