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