blob: e903cca4027ca94bdb0f8496b3df18a1b3792e2d [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/**
2 * \file arc4.h
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00003 *
Paul Bakker83ded912010-03-21 17:46:26 +00004 * Copyright (C) 2006-2010, Paul Bakker <polarssl_maintainer at polarssl.org>
Paul Bakker77b385e2009-07-28 17:23:11 +00005 * All rights reserved.
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00006 *
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00007 * 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 Bakker5121ce52009-01-03 21:22:43 +000020 */
Paul Bakker40e46942009-01-03 21:51:57 +000021#ifndef POLARSSL_ARC4_H
22#define POLARSSL_ARC4_H
Paul Bakker5121ce52009-01-03 21:22:43 +000023
24/**
25 * \brief ARC4 context structure
26 */
27typedef struct
28{
29 int x; /*!< permutation index */
30 int y; /*!< permutation index */
31 unsigned char m[256]; /*!< permutation table */
32}
33arc4_context;
34
35#ifdef __cplusplus
36extern "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 Bakkerff60ee62010-03-16 21:09:09 +000046void arc4_setup( arc4_context *ctx, const unsigned char *key, int keylen );
Paul Bakker5121ce52009-01-03 21:22:43 +000047
48/**
49 * \brief ARC4 cipher function
50 *
51 * \param ctx ARC4 context
Paul Bakkerbaad6502010-03-21 15:42:15 +000052 * \param length length of the input data
53 * \param input buffer holding the input data
54 * \param output buffer for the output data
Paul Bakkerf3ccc682010-03-18 21:21:02 +000055 *
Paul Bakker27caa8a2010-03-21 15:43:59 +000056 * \return 0 if successful
Paul Bakker5121ce52009-01-03 21:22:43 +000057 */
Paul Bakkerbaad6502010-03-21 15:42:15 +000058int arc4_crypt( arc4_context *ctx, int length, const unsigned char *input,
59 unsigned char *output );
Paul Bakker5121ce52009-01-03 21:22:43 +000060
61/*
62 * \brief Checkup routine
63 *
64 * \return 0 if successful, or 1 if the test failed
65 */
66int arc4_self_test( int verbose );
67
68#ifdef __cplusplus
69}
70#endif
71
72#endif /* arc4.h */